fix for ubuntu, forgot some $verser in there
[build.git] / lbuild-initvm.sh
index 9eda8d9..fdea57a 100755 (executable)
@@ -8,11 +8,7 @@ DIRNAME=$(dirname $0)
 BUILD_DIR=$(pwd)
 
 # 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
-export PATH=PATH=$PATH:/bin:/sbin 
+export PATH=$(dirname $0):$PATH
 
 . build.common
 
@@ -388,9 +384,6 @@ EOF
     mknod -m 600 ${dev_path}/initctl p
     mknod -m 666 ${dev_path}/ptmx c 5 2
 
-    #echo "setting root passwd to $root_password"
-    #echo "root:$root_password" | chroot $rootfs_path chpasswd
-
     if [ "$(echo $fcdistro | cut -d"f" -f2)" -le "14" ]; then
        fedora_configure_init
     else
@@ -582,7 +575,8 @@ function setup_lxc() {
     mkdir $rootfs_path/root/.ssh
     cat /root/.ssh/id_rsa.pub >> $rootfs_path/root/.ssh/authorized_keys
     
-    config_xml=$config_path/"lxc.xml"
+    # don't keep the input xml, this can be retrieved at all times with virsh dumpxml
+    config_xml=$tmp/$lxc.xml
     ( [ -n "$BUILD_MODE" ] && write_lxc_xml_build $lxc || write_lxc_xml_test $lxc ) > $config_xml
     
     # define lxc container for libvirt
@@ -727,10 +721,25 @@ function devel_or_vtest_tools () {
            chroot $rootfs_path rpm -aq > $rootfs_path/init-lxc.rpms
            ;;
        debootstrap)
+           # for ubuntu
+           if grep -iq ubuntu /vservers/$lxc/rootfs/etc/lsb-release 2> /dev/null; then
+               # on ubuntu, at this point we end up with a single feed in /etc/apt/sources.list
+               # we need at least to add the 'universe' feed for python-rpm
+               ( cd /vservers/$lxc/rootfs/etc/apt ; head -1 sources.list | sed -e s,main,universe, > sources.list.d/universe.list )
+               # also adding a link to updates sounds about right
+               ( cd /vservers/$lxc/rootfs/etc/apt ; head -1 sources.list | sed -e 's, main,-updates main,' > sources.list.d/updates.list )
+           fi
            chroot $rootfs_path apt-get update
            for package in $packages ; do
                # close stdin in an attempt to avoid this hanging
-               chroot $rootfs_path apt-get install -y $package < /dev/null
+               # 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..
            ;;
@@ -749,7 +758,7 @@ function post_install () {
        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 $lxc dhclient) $VIF_GUEST
     else
        post_install_myplc $lxc $personality
        lxc_start $lxc
@@ -1023,7 +1032,6 @@ function main () {
     config_path=$path/$lxc
     cache_base=/var/cache/lxc/fedora/$arch
     cache=$cache_base/$release
-    root_password=root
     
     # check whether the rootfs directory is created to know if the container exists
     # bacause /var/lib/lxc/$lxc is already created while putting $lxc.timestamp