oops, fix onelab.mk for a missing endif
[build.git] / lbuild-initvm.sh
index c623bc0..19e2743 100755 (executable)
@@ -535,7 +535,7 @@ function package_method () {
     fcdistro=$1; shift
     case $fcdistro in
        f[0-9]*|centos[0-9]*|sl[0-9]*) echo yum ;;
-       lenny|etch) echo debootstrap ;;
+       squeeze|wheezy|oneiric|precise|quantal|raring|saucy) echo debootstrap ;;
        *) echo Unknown distro $fcdistro ;;
     esac 
 }
@@ -581,23 +581,26 @@ function setup_lxc() {
         exit 1
     fi
 
-    install_fedora
-    if [ $? -ne 0 ]; then
-        echo "failed to install fedora"
-        exit 1
-    fi
-
-    configure_fedora
-    if [ $? -ne 0 ]; then
-        echo "failed to configure fedora for a container"
-        exit 1
-    fi
-
-    if [ "$(echo $fcdistro | cut -d"f" -f2)" -le "14" ]; then
-        configure_fedora_init
-    else
-        configure_fedora_systemd
-    fi
+    pkg_method=$(package_method $fcdistro)
+    case $pkg_method in
+       yum)
+           install_fedora || { echo "failed to install fedora"; exit 1 ; }
+           configure_fedora || { echo "failed to configure fedora for a container"; exit 1 ; }
+           if [ "$(echo $fcdistro | cut -d"f" -f2)" -le "14" ]; then
+               configure_fedora_init
+           else
+               configure_fedora_systemd
+           fi
+           ;;
+       debootstrap)
+           echo "$COMMAND: no support for debootstrap-based systems - yet"
+           exit 1
+           ;;
+       *)
+           echo "$COMMAND:: unknown package_method - exiting"
+           exit 1
+           ;;
+    esac
 
     # Enable cgroup
     mkdir $rootfs_path/cgroup
@@ -674,13 +677,7 @@ function devel_or_vtest_tools () {
 
     pkg_method=$(package_method $fcdistro)
 
-    # check for .pkgs file based on pldistro
-    if [ -n "$BUILD_MODE" ] ; then
-       pkgsname=devel.pkgs
-    else
-       pkgsname=vtest.pkgs
-    fi
-    pkgsfile=$(pl_locateDistroFile $DIRNAME $pldistro $pkgsname)
+    pkgsfile=$(pl_locateDistroFile $DIRNAME $pldistro $PREINSTALLED)
 
     ### install individual packages, then groups
     # get target arch - use uname -i here (we want either x86_64 or i386)
@@ -722,8 +719,10 @@ function post_install () {
     personality=$1; shift
     if [ -n "$BUILD_MODE" ] ; then
        post_install_build $lxc $personality
+       start_lxc $lxc
     else
        post_install_myplc $lxc $personality
+       start_lxc $lxc
        wait_for_ssh $lxc
     fi
     # setup localtime from the host
@@ -901,11 +900,19 @@ function main () {
     RESISTANT=""
     IFNAME=""
     LXC_OPTIONS=""
-    while getopts "f:d:p:i:" opt ; do
+
+    # the set of preinstalled packages - depends on vbuild or vtest
+    if [ -n "$VBUILD_MODE" ] ; then
+       PREINSTALLED=devel.pkgs
+    else
+       PREINSTALLED=vtest.pkgs
+    fi
+    while getopts "f:d:p:P:i:" opt ; do
        case $opt in
            f) fcdistro=$OPTARG;;
            d) pldistro=$OPTARG;;
            p) personality=$OPTARG;;
+           P) PREINSTALLED=$OPTARG;;
            i) IFNAME=$OPTARG;;
            *) usage ;;
        esac
@@ -1022,8 +1029,6 @@ function main () {
 
     post_install $lxc $personality
     
-    start_lxc $lxc
-
     echo $COMMAND Done
 }