Browse code

Merge pull request #91 from cloudbuilders/dt-build_kvm

Fix concurrent build_kvm.sh runs

Jesse Andrews authored on 2011/10/22 05:02:01
Showing 1 changed files
... ...
@@ -45,14 +45,14 @@ source ./stackrc
45 45
 DIST_NAME=${DIST_NAME:-natty}
46 46
 IMAGE_FNAME=$DIST_NAME.raw
47 47
 
48
+# Name of our instance, used by libvirt
49
+CONTAINER_NAME=${CONTAINER_NAME:-kvmstack}
50
+
48 51
 # Original version of built image
49
-BASE_IMAGE=$KVMSTACK_DIR/images/natty.raw
52
+BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw
50 53
 
51 54
 # Copy of base image, which we pre-install with tasty treats
52
-BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.raw.copy
53
-
54
-# Name of our instance, used by libvirt
55
-CONTAINER_NAME=${CONTAINER_NAME:-kvmstack}
55
+VM_IMAGE=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw
56 56
 
57 57
 # Mop up after previous runs
58 58
 virsh destroy $CONTAINER_NAME
... ...
@@ -70,14 +70,14 @@ mkdir -p $COPY_DIR
70 70
 # Create the base image if it does not yet exist
71 71
 if [ ! -e $IMAGES_DIR/$IMAGE_FNAME ]; then
72 72
     cd $TOOLS_DIR
73
-    ./make_image.sh -m -r 5000  natty raw
74
-    mv natty.raw $BASE_IMAGE
73
+    ./make_image.sh -m -r 5000  $DIST_NAME raw
74
+    mv $DIST_NAME.raw $BASE_IMAGE
75 75
     cd $TOP_DIR
76 76
 fi
77 77
 
78 78
 # Create a copy of the base image
79
-if [ ! -e $BASE_IMAGE_COPY ]; then
80
-    cp -p $BASE_IMAGE $BASE_IMAGE_COPY
79
+if [ ! -e $VM_IMAGE ]; then
80
+    cp -p $BASE_IMAGE $VM_IMAGE
81 81
 fi
82 82
 
83 83
 # Unmount the copied base image
... ...
@@ -108,7 +108,7 @@ trap kill_unmount SIGINT
108 108
 DEST=${DEST:-/opt/stack}
109 109
 
110 110
 # Mount the file system
111
-mount -o loop,offset=32256 $BASE_IMAGE_COPY  $COPY_DIR
111
+mount -o loop,offset=32256 $VM_IMAGE  $COPY_DIR
112 112
 
113 113
 # git clone only if directory doesn't exist already.  Since ``DEST`` might not
114 114
 # be owned by the installation user, we create the directory and change the
... ...
@@ -231,7 +231,7 @@ cd $VM_DIR
231 231
 rm -f $VM_DIR/disk
232 232
 
233 233
 # Create our instance fs
234
-qemu-img create -f qcow2 -b $BASE_IMAGE_COPY disk
234
+qemu-img create -f qcow2 -b $VM_IMAGE disk
235 235
 
236 236
 sleep 5
237 237
 
... ...
@@ -306,7 +306,7 @@ chmod 755 $RUN_SH
306 306
 RC_LOCAL=$ROOTFS/etc/init.d/local
307 307
 cat > $RC_LOCAL <<EOF
308 308
 #!/bin/sh -e
309
-# Reboot if this is our first run to enable console log on natty :(
309
+# Reboot if this is our first run to enable console log on $DIST_NAME :(
310 310
 if [ ! -e /root/firstlaunch ]; then
311 311
     touch /root/firstlaunch
312 312
     reboot -f