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