+# Path's to the reference images and stubs
+# This is inherited from util-vservers
+vrefdir=$PWD/vservers/.vref
+vref=${vrefdir}/${slicefamily}
+# stubs are created in a subdir per slicefamily
+vstubdir=$PWD/vservers/.vstub/${slicefamily}
+
+# Create paths
+install -d -m 755 ${vref}
+install -d -m 755 ${vstubdir}
+
+# Some of the PlanetLab RPMs attempt to (re)start themselves in %post,
+# unless the installation is running inside the BootCD environment. We
+# would like to pretend that we are.
+export PL_BOOTCD=1
+
+# Populate image with sliceimage packages
+pl_root_makedevs ${vref}
+# locate the packages and groups file
+pkgsfile=$(pl_locateDistroFile ../build/ ${pldistro} sliceimage.pkgs)
+pl_root_mkfedora ${vref} ${pldistro} $pkgsfile
+pl_root_tune_image ${vref}
+
+systemslice_count=$(ls ../build/config.${pldistro}/sliceimage-*.pkgs 2> /dev/null | wc -l)
+[ $systemslice_count -gt 0 ] && for systemslice in $(ls ../build/config.${pldistro}/sliceimage-*.pkgs) ; do
+ NAME=$(basename $systemslice .pkgs | sed -e s,sliceimage-,,)
+
+ echo " * --------START BUILDING system sliceimage ${NAME}: $(date)"
+
+ # "Parse" out the packages and groups for yum
+ systempackages=$(pl_getPackages ${pl_DISTRO_NAME} $pldistro $systemslice)
+ systemgroups=$(pl_getGroups ${pl_DISTRO_NAME} $pldistro $systemslice)
+ systempips=$(pl_getPips ${pl_DISTRO_NAME} $pldistro $systemslice)
+ systemgems=$(pl_getGems ${pl_DISTRO_NAME} $pldistro $systemslice)
+
+ vdir=${vstubdir}/${NAME}
+ rm -rf ${vdir}/*
+ install -d -m 755 ${vdir}
+
+ # Clone the base sliceimage reference to the system sliceimage reference
+ (cd ${vref} && find . | cpio -m -d -u -p ${vdir})
+ rm -f ${vdir}/var/lib/rpm/__db*
+
+ # Communicate to the initialization script from which vref this stub was cloned
+ echo ${slicefamily} > ${vdir}.cloned
+
+ # Install the system sliceimage specific packages
+ for yum_package in $systempackages; do
+ echo " * yum installing $yum_package"
+ yum -c ${vdir}/etc/mkfedora-yum.conf --installroot=${vdir} -y install $yum_package || \
+ echo " * WARNING image $systemslice - yum install $yum_package failed"
+ done
+ for group_plus in $systemgroups; do
+ yum_group=$(echo $group_plus | sed -e "s,+++, ,g")
+ echo " * yum groupinstalling $yum_group"
+ yum -c ${vdir}/etc/mkfedora-yum.conf --installroot=${vdir} -y groupinstall "$yum_group" || \
+ echo " * WARNING image $systemslice - yum groupinstall $yum_group failed"
+ done