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