blob: b20519fab5a6f20b63d2ea982f23e2723536eb65 [file] [log] [blame]
Anthony Younge7fa9092011-11-07 16:10:59 -06001#!/usr/bin/env bash
2
Anthony Young8655bf02011-11-07 16:37:00 -06003# echo commands
4set -o xtrace
5
6# exit on error to stop unexpected errors
7set -o errexit
8
Anthony Younge7fa9092011-11-07 16:10:59 -06009# Keep track of the current directory
10TOOLS_DIR=$(cd $(dirname "$0") && pwd)
11TOP_DIR=`cd $TOOLS_DIR/..; pwd`
12
13# cd to top of devstack
14cd $TOP_DIR
15
16# Echo usage
17usage() {
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
24if ! qemu-img info $1 | grep -q "file format: raw"; then
25 usage
26 exit 1
27fi
28
Anthony Young8655bf02011-11-07 16:37:00 -060029# Make sure we are in the correct dir
30if [ ! -d files/apts ]; then
31 echo "Please run this script from devstack/tools/"
32 exit 1
33fi
34
Anthony Younge7fa9092011-11-07 16:10:59 -060035# Mount the image
36STAGING_DIR=`mktemp -d uec.XXXXXXXXXX`
37mkdir -p $STAGING_DIR
38mount -t ext4 -o loop $1 $STAGING_DIR
39
40# Make sure that base requirements are installed
41cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
42
43# Perform caching on the base image to speed up subsequent runs
44chroot $STAGING_DIR apt-get update
45chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
46chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1`
47chroot $STAGING_DIR pip install `cat files/pips/*`
48umount $STAGING_DIR && rm -rf $STAGING_DIR