# pkgs parsing utilities
PATH=$(dirname $0):$PATH export PATH
+
+# old guests have e.g. mount in /bin but this is no longer part of
+# the standard PATH in recent hosts after usrmove, so let's keep it simple
+PATH=$PATH:/bin:/sbin export PATH
+
. build.common
DEFAULT_FCDISTRO=f20
fi
guest_ifcfg=${rootfs_path}/etc/sysconfig/network-scripts/ifcfg-$VIF_GUEST
- [ -n "$BUILD_MODE" ] && write_guest_ifcfg_build || write_guest_ifcfg_test > $guest_ifcfg
+ ( [ -n "$BUILD_MODE" ] && write_guest_ifcfg_build || write_guest_ifcfg_test ) > $guest_ifcfg
fedora_configure_yum $lxc $fcdistro $pldistro
# don't mount devpts, for pete's sake
sed -i 's/^.*dev.pts.*$/#\0/' ${rootfs_path}/etc/rc.sysinit
sed -i 's/^.*dev.pts.*$/#\0/' ${rootfs_path}/etc/rc.d/rc.sysinit
- chroot ${rootfs_path} /sbin/chkconfig udev-post off
- chroot ${rootfs_path} /sbin/chkconfig network on
+ chroot ${rootfs_path} chkconfig udev-post off
+ chroot ${rootfs_path} chkconfig network on
}
# this code of course is for guests that do run on systemd
ln -sf /dev/null ${rootfs_path}/etc/systemd/system/"getty@.service"
rm -f ${rootfs_path}/etc/systemd/system/getty.target.wants/*service || :
# can't seem to handle this one with systemctl
- chroot ${rootfs_path} /sbin/chkconfig network on
+ chroot ${rootfs_path} chkconfig network on
}
# overwrite container yum config
pldistro=$1; shift
# rpm --rebuilddb
- chroot $rootfs_path /bin/rpm --rebuilddb
+ chroot $rootfs_path rpm --rebuilddb
echo "Initializing yum.repos.d in $lxc"
rm -f $rootfs_path/etc/yum.repos.d/*
mkdir -p $rootfs_path
arch=$(canonical_arch $personality $fcdistro)
mirror=$(debian_mirror $fcdistro)
- # old guests have mount in /bin but this is no longer part of
- # the standard PATH in recent hosts
- PATH=$PATH:/bin:/sbin debootstrap --arch $arch $fcdistro $rootfs_path $mirror
+ debootstrap --arch $arch $fcdistro $rootfs_path $mirror
}
function debian_configure () {
- echo "WARNING No debian config available yet"
+ guest_interfaces=${rootfs_path}/etc/network/interfaces
+ ( [ -n "$BUILD_MODE" ] && write_guest_interfaces_build || write_guest_interfaces_test ) > $guest_interfaces
+}
+
+function write_guest_interfaces_build () {
+ cat <<EOF
+auto $VIF_GUEST
+iface $VIF_GUEST inet dhcp
+EOF
+}
+
+function write_guest_interfaces_test () {
+ cat <<EOF
+auto $VIF_GUEST
+iface $VIF_GUEST
+ address $IP
+ netmask $NETMASK
+ gateway $GATEWAY
+EOF
}
##############################
function setup_lxc() {
cat /root/.ssh/id_rsa.pub >> $rootfs_path/root/.ssh/authorized_keys
config_xml=$config_path/"lxc.xml"
- [ -n "$BUILD_MODE" ] && write_lxc_xml_build $lxc || write_lxc_xml_test $lxc > $config_xml
+ ( [ -n "$BUILD_MODE" ] && write_lxc_xml_build $lxc || write_lxc_xml_test $lxc ) > $config_xml
# define lxc container for libvirt
virsh -c lxc:/// define $config_xml
### install individual packages, then groups
# get target arch - use uname -i here (we want either x86_64 or i386)
- lxc_arch=$(chroot $rootfs_path /bin/uname -i)
+ lxc_arch=$(chroot $rootfs_path uname -i)
# on debian systems we get arch through the 'arch' command
- [ "$lxc_arch" = "unknown" ] && lxc_arch=$(chroot $rootfs_path /bin/arch)
+ [ "$lxc_arch" = "unknown" ] && lxc_arch=$(chroot $rootfs_path arch)
packages=$(pl_getPackages -a $lxc_arch $fcdistro $pldistro $pkgsfile)
groups=$(pl_getGroups -a $lxc_arch $fcdistro $pldistro $pkgsfile)
case "$pkg_method" in
yum)
- [ -n "$packages" ] && chroot $rootfs_path /usr/bin/yum -y install $packages
+ [ -n "$packages" ] && chroot $rootfs_path yum -y install $packages
for group_plus in $groups; do
group=$(echo $group_plus | sed -e "s,+++, ,g")
- chroot $rootfs_path /usr/bin/yum -y groupinstall "$group"
+ chroot $rootfs_path yum -y groupinstall "$group"
done
# store current rpm list in /init-lxc.rpms in case we need to check the contents
- chroot $rootfs_path /bin/rpm -aq > $rootfs_path/init-lxc.rpms
+ chroot $rootfs_path rpm -aq > $rootfs_path/init-lxc.rpms
;;
debootstrap)
- chroot $rootfs_path /usr/bin/apt-get update
- for package in $packages ; do
- chroot $rootfs_path /usr/bin/apt-get install -y $package
+ chroot $rootfs_path apt-get update
+ for package in $packages ; do
+ # close stdin in an attempt to avoid this hanging
+ # xxx also we ignore result for now, not sure if the kind of errors like below
+ # truly is serious or not
+#Setting up at (3.1.13-2ubuntu2) ...
+#initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
+#initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
+#start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
+
+ chroot $rootfs_path apt-get install -y $package < /dev/null || :
done
### xxx todo install groups with apt..
;;
return 0
}
+# would be much simpler if enter-lxc-namespace was looking along a PATH...
+function bin_in_container () {
+ binary=$1; shift
+ lxc=$1; shift
+
+ for path in /sbin /bin /usr/bin /usr/sbin; do
+ [ -f $rootfs_path/$path/$binary ] && { echo $path/$binary; return; }
+ done
+ echo bin_in_container_cannot_find_$binary
+}
+
function post_install () {
lxc=$1; shift
personality=$1; shift
post_install_build $lxc $personality
lxc_start $lxc
# manually run dhclient in guest - somehow this network won't start on its own
- virsh -c lxc:/// lxc-enter-namespace $lxc /usr/sbin/dhclient $VIF_GUEST
+ virsh -c lxc:/// lxc-enter-namespace $lxc $(bin_in_container dhclient $lxc) $VIF_GUEST
else
post_install_myplc $lxc $personality
lxc_start $lxc
### From myplc-devel-native.spec
# be careful to backslash $ in this, otherwise it's the root context that's going to do the evaluation
- cat << EOF | chroot $rootfs_path /bin/bash -x
+ cat << EOF | chroot $rootfs_path bash -x
# set up /dev/loop* in lxc
for i in \$(seq 0 255) ; do
/bin/mknod -m 640 /dev/loop\$i b 7 \$i
personality=$1; shift
# be careful to backslash $ in this, otherwise it's the root context that's going to do the evaluation
- cat << EOF | chroot $rootfs_path /bin/bash -x
+ cat << EOF | chroot $rootfs_path bash -x
# create /etc/sysconfig/network if missing
[ -f /etc/sysconfig/network ] || /bin/echo NETWORKING=yes > /etc/sysconfig/network