- # Allow a user who logins via ssh to sudo
- chroot $rootfs sed -i 's/^Defaults\ *requiretty/\#&/' /etc/sudoers
- # Allow to login at virsh console. loginuid.so doen't work in the absence of auditd
- # which cannot run inside a container.
- chroot $rootfs sed -i 's/^.*loginuid.so.*$/\#&/' /etc/pam.d/login
- # Enable eth0 on bootup
- cat <<EOF > $rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
-DEVICE=eth0
-BOOTPROTO=dhcp
-ONBOOT=yes
-EOF
- # Tweak sshd configuration
- chroot $rootfs sed -i 's/^UsePAM\ *yes/\#&/' /etc/ssh/sshd_config
- chroot $rootfs sed -i 's/^GSSAPIAuthentication\ *yes/\#&/' /etc/ssh/sshd_config
- chroot $rootfs sed -i 's/^PasswordAuthentication\ *yes/\#&/' /etc/ssh/sshd_config
- # Allow root to login at virsh console
- echo "pts/0" >> $rootfs/etc/securetty
- # our image does not have NetworkManager, only network, and it is off by default
- chroot $rootfs chkconfig network on
+
+}
+
+function unfold_system_slices () {
+ for clonedstamp in $sliceimage_stubs/*/*.cloned; do
+ unfold_system_slice_from_cloned $clonedstamp
+ done
+}
+
+function unfold_system_slice_from_cloned () {
+ clonedstamp=$1; shift
+ # e.g. NAME=planetflow
+ NAME=$(basename $clonedstamp .cloned)
+ DIR=$(dirname $clonedstamp)
+ # e.g. SLICEFAMILY=planetlab-f8-i386
+ SLICEFAMILY=$(cat $clonedstamp)
+ # deduce the actual name used in .vref by replacing the first part of slice-family
+ # (pldistro) with the slice name
+ # e.g. VREFNAME=planetflow-f8-i386
+ VREFNAME=$(echo $SLICEFAMILY | sed -e "s,^[^-]*-,$NAME-,")
+
+ VREFPATH="$lxc_dir/$VREFNAME"
+
+ # do not redo existing vref's unless force is mentioned
+ [ -z "$FORCE" -a -d "$VREFPATH" ] && continue
+ [ -z "$FORCE" ] && message=Building
+ [ -n "$FORCE" ] && message=Force-building
+
+ # Copy base reference image
+ echo -n $"$message slice image for $NAME in $VREFNAME: "
+
+ # build the systemslice from the one it was originally cloned from
+ FAMILYREF="$lxc_dir/$SLICEFAMILY"
+ if [ ! -d "$FAMILYREF" ] ; then
+ echo system slice from $clonedstamp - could not find reference $FAMILYREF - skipped
+ return
+ fi
+
+ # safe side
+ mkdir -p "$lxc_dir"
+ # cleanup reference image if already exists
+ [ -d "$VREFPATH" ] && btrfs subvolume delete "$VREFPATH"
+ # extra safe
+ [ -d "$VREFPATH" ] && rm -rf "$VREFPATH"
+
+ # clone subvolume
+ btrfs subvolume snapshot $FAMILYREF $VREFPATH
+
+ # merge the stub with the reference to get the system slice
+ (cd "$DIR/$NAME"/ && find . | cpio -m -d -u -p "$VREFPATH"/) || \
+ { echo "Could not apply stub $DIR/$NAME - skipping $clonedstamp" ; btrfs subvolume delete "$VREFPATH" ; return ; }
+
+ # Clean RPM state
+ rm -f "$VREFPATH/var/lib/rpm/__db"*
+
+ echo Done