an attempt to make VM creation more robust, as more often than expected we fail that...
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 26 Mar 2014 11:04:18 +0000 (12:04 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 26 Mar 2014 11:04:18 +0000 (12:04 +0100)
lbuild-initvm.sh

index c65026c..ee03232 100755 (executable)
@@ -104,13 +104,12 @@ function fedora_install() {
 
     cache=/var/cache/lxc/fedora/$arch/$release
     
-    mkdir -p /var/lock/subsys/
     (
-        flock -n -x 200 || { echo "Cache repository is busy." ; return 1 ; }
+        flock --exclusive --timeout 60 200 || { echo "Cache repository is busy." ; return 1 ; }
 
         if [ ! -e "$cache/rootfs" ]; then
             echo "Getting cache download in $cache/rootfs ... "
-            fedora_download || { echo "Failed to download 'fedora base'"; return 1; }
+            fedora_download $cache || { echo "Failed to download 'fedora base'"; return 1; }
         else
             echo "Updating cache $cache/rootfs ..."
            if ! yum --installroot $cache/rootfs -y --nogpgcheck update ; then
@@ -120,18 +119,21 @@ function fedora_install() {
             fi
         fi
 
-        echo "Copy $cache/rootfs to $lxc_root ... "
+        echo "Filling $lxc_root from $cache/rootfs ... "
        rsync -a $cache/rootfs/ $lxc_root/
        
         return 0
 
-        ) 200>/var/lock/subsys/lxc
+        ) 200> $cache/lock
 
     return $?
 }
 
 function fedora_download() {
     set -x
+
+    cache=$1; shift
+
     # check the mini fedora was not already downloaded
     INSTALL_ROOT=$cache/partial
     echo $INSTALL_ROOT