| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,36 @@ |
| 0 |
+#!/usr/bin/env bash |
|
| 1 |
+ |
|
| 2 |
+# Keep track of the current directory |
|
| 3 |
+TOOLS_DIR=$(cd $(dirname "$0") && pwd) |
|
| 4 |
+TOP_DIR=`cd $TOOLS_DIR/..; pwd` |
|
| 5 |
+ |
|
| 6 |
+# cd to top of devstack |
|
| 7 |
+cd $TOP_DIR |
|
| 8 |
+ |
|
| 9 |
+# Echo usage |
|
| 10 |
+usage() {
|
|
| 11 |
+ echo "Cache OpenStack dependencies on a uec image to speed up performance." |
|
| 12 |
+ echo "" |
|
| 13 |
+ echo "Usage: $0 [full path to raw uec base image]" |
|
| 14 |
+} |
|
| 15 |
+ |
|
| 16 |
+# Make sure this is a raw image |
|
| 17 |
+if ! qemu-img info $1 | grep -q "file format: raw"; then |
|
| 18 |
+ usage |
|
| 19 |
+ exit 1 |
|
| 20 |
+fi |
|
| 21 |
+ |
|
| 22 |
+# Mount the image |
|
| 23 |
+STAGING_DIR=`mktemp -d uec.XXXXXXXXXX` |
|
| 24 |
+mkdir -p $STAGING_DIR |
|
| 25 |
+mount -t ext4 -o loop $1 $STAGING_DIR |
|
| 26 |
+ |
|
| 27 |
+# Make sure that base requirements are installed |
|
| 28 |
+cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf |
|
| 29 |
+ |
|
| 30 |
+# Perform caching on the base image to speed up subsequent runs |
|
| 31 |
+chroot $STAGING_DIR apt-get update |
|
| 32 |
+chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1` |
|
| 33 |
+chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` |
|
| 34 |
+chroot $STAGING_DIR pip install `cat files/pips/*` |
|
| 35 |
+umount $STAGING_DIR && rm -rf $STAGING_DIR |