Browse code

Move chroot cache dirs out of devstack dir

Dean Troyer authored on 2011/10/03 23:14:36
Showing 2 changed files
... ...
@@ -1,5 +1,7 @@
1 1
 #!/bin/bash
2 2
 
3
+CHROOTCACHE=${CHROOTCACHE:-/root/cache}
4
+
3 5
 # Source params
4 6
 source ./stackrc
5 7
 
... ...
@@ -12,24 +14,24 @@ DEST="/nfs/$NAME"
12 12
 rm -rf $DEST
13 13
 
14 14
 # build a proto image - natty + packages that will install (optimization)
15
-if [ ! -d proto ]; then
16
-    debootstrap natty proto
17
-    cp files/sources.list proto/etc/apt/sources.list
18
-    chroot proto apt-get update
19
-    chroot proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
20
-    chroot proto pip install `cat files/pips/*`
21
-    git_clone $NOVA_REPO proto/opt/nova $NOVA_BRANCH
22
-    git_clone $GLANCE_REPO proto/opt/glance $GLANCE_BRANCH
23
-    git_clone $KEYSTONE_REPO proto/opt/keystone $KEYSTONE_BRANCH
24
-    git_clone $NOVNC_REPO proto/opt/novnc $NOVNC_BRANCH
25
-    git_clone $DASH_REPO proto/opt/dash $DASH_BRANCH $DASH_TAG
26
-    git_clone $NOVACLIENT_REPO proto/opt/python-novaclient $NOVACLIENT_BRANCH
27
-    git_clone $OPENSTACKX_REPO proto/opt/openstackx $OPENSTACKX_BRANCH
28
-    chroot proto mkdir -p /opt/files
29
-    wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/files/tty.tgz
15
+if [ ! -d $CHROOTCACHE/proto ]; then
16
+    debootstrap natty $CHROOTCACHE/proto
17
+    cp files/sources.list $CHROOTCACHE/proto/etc/apt/sources.list
18
+    chroot $CHROOTCACHE/proto apt-get update
19
+    chroot $CHROOTCACHE/proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
20
+    chroot $CHROOTCACHE/proto pip install `cat files/pips/*`
21
+    git_clone $NOVA_REPO $CHROOTCACHE/proto/opt/nova $NOVA_BRANCH
22
+    git_clone $GLANCE_REPO $CHROOTCACHE/proto/opt/glance $GLANCE_BRANCH
23
+    git_clone $KEYSTONE_REPO $CHROOTCACHE/proto/opt/keystone $KEYSTONE_BRANCH
24
+    git_clone $NOVNC_REPO $CHROOTCACHE/proto/opt/novnc $NOVNC_BRANCH
25
+    git_clone $DASH_REPO $CHROOTCACHE/proto/opt/dash $DASH_BRANCH $DASH_TAG
26
+    git_clone $NOVACLIENT_REPO $CHROOTCACHE/proto/opt/python-novaclient $NOVACLIENT_BRANCH
27
+    git_clone $OPENSTACKX_REPO $CHROOTCACHE/proto/opt/openstackx $OPENSTACKX_BRANCH
28
+    chroot $CHROOTCACHE/proto mkdir -p /opt/files
29
+    wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/proto/opt/files/tty.tgz
30 30
 fi
31 31
 
32
-cp -pr proto $DEST
32
+cp -pr $CHROOTCACHE/proto $DEST
33 33
 
34 34
 # set hostname
35 35
 echo $NAME > $DEST/etc/hostname
... ...
@@ -7,44 +7,45 @@ if [ ! "$#" -eq "1" ]; then
7 7
 fi
8 8
 
9 9
 PROGDIR=`dirname $0`
10
+CHROOTCACHE=${CHROOTCACHE:-/root/cache}
10 11
 
11 12
 # Source params
12 13
 source ./stackrc
13 14
 
14 15
 # clean install of natty
15
-if [ ! -d natty-base ]; then
16
-    $PROGDIR/make_image.sh -C natty natty-base
16
+if [ ! -d $CHROOTCACHE/natty-base ]; then
17
+    $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
17 18
     # copy kernel modules...  
18 19
     # NOTE(ja): is there a better way to do this?
19
-    cp -pr /lib/modules/`uname -r` natty-base/lib/modules
20
+    cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
20 21
     # a simple password - pass
21
-    echo root:pass | chroot natty-base chpasswd
22
+    echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
22 23
 fi
23 24
 
24 25
 # prime natty with as many apt/pips as we can
25
-if [ ! -d primed ]; then
26
-    rsync -azH natty-base/ primed/
27
-    chroot primed apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
28
-    chroot primed pip install `cat files/pips/*`
26
+if [ ! -d $CHROOTCACHE/natty-dev ]; then
27
+    rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
28
+    chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
29
+    chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
29 30
 
30 31
     # Create a stack user that is a member of the libvirtd group so that stack 
31 32
     # is able to interact with libvirt.
32
-    chroot primed groupadd libvirtd
33
-    chroot primed useradd stack -s /bin/bash -d /opt -G libvirtd
33
+    chroot $CHROOTCACHE/natty-dev groupadd libvirtd
34
+    chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G libvirtd
34 35
 
35 36
     # a simple password - pass
36
-    echo stack:pass | chroot primed chpasswd
37
+    echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
37 38
 
38 39
     # and has sudo ability (in the future this should be limited to only what 
39 40
     # stack requires)
40
-    echo "stack ALL=(ALL) NOPASSWD: ALL" >> primed/etc/sudoers
41
+    echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
41 42
 fi
42 43
 
43 44
 # clone git repositories onto the system
44 45
 # ======================================
45 46
 
46
-if [ ! -d cloned ]; then
47
-    rsync -azH primed/ cloned/
47
+if [ ! -d $CHROOTCACHE/natty-stack ]; then
48
+    rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
48 49
 fi
49 50
 
50 51
 # git clone only if directory doesn't exist already.  Since ``DEST`` might not
... ...
@@ -53,7 +54,7 @@ fi
53 53
 function git_clone {
54 54
 
55 55
     # clone new copy or fetch latest changes
56
-    CHECKOUT=cloned$2
56
+    CHECKOUT=$CHROOTCACHE/natty-stack$2
57 57
     if [ ! -d $CHECKOUT ]; then
58 58
         mkdir -p $CHECKOUT
59 59
         git clone $1 $CHECKOUT
... ...
@@ -73,7 +74,7 @@ function git_clone {
73 73
     popd
74 74
 
75 75
     # give ownership to the stack user
76
-    chroot cloned/ chown -R stack $2
76
+    chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
77 77
 }
78 78
 
79 79
 git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH
... ...
@@ -97,7 +98,7 @@ mkfs.ext2 -F $IMG
97 97
 # mount blank image loopback and load it
98 98
 mkdir -p $MNT
99 99
 mount -o loop $IMG $MNT
100
-rsync -azH cloned/ $MNT
100
+rsync -azH $CHROOTCACHE/natty-stack/ $MNT
101 101
 
102 102
 # umount and cleanup
103 103
 umount $MNT