blob: ec7e916c24d8a57d9dfa1c44bfb2b316fcce7d07 [file] [log] [blame]
Anthony Younge7fa9092011-11-07 16:10:59 -06001#!/usr/bin/env bash
2
Anthony Young208ae2f2011-11-07 16:38:03 -06003# Echo commands
Anthony Young8655bf02011-11-07 16:37:00 -06004set -o xtrace
5
Anthony Young208ae2f2011-11-07 16:38:03 -06006# Exit on error to stop unexpected errors
Anthony Young8655bf02011-11-07 16:37:00 -06007set -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
Anthony Young208ae2f2011-11-07 16:38:03 -060013# Change dir to top of devstack
Anthony Younge7fa9092011-11-07 16:10:59 -060014cd $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
Anthony Youngc1024d82011-11-09 18:58:07 -080036STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage
Anthony Younge7fa9092011-11-07 16:10:59 -060037mkdir -p $STAGING_DIR
Anthony Youngc1024d82011-11-09 18:58:07 -080038umount $STAGING_DIR || true
39sleep 1
Anthony Younge7fa9092011-11-07 16:10:59 -060040mount -t ext4 -o loop $1 $STAGING_DIR
41
42# Make sure that base requirements are installed
43cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
44
45# Perform caching on the base image to speed up subsequent runs
46chroot $STAGING_DIR apt-get update
47chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
Anthony Youngc1024d82011-11-09 18:58:07 -080048chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true
49mkdir -p $STAGING_DIR/var/cache/pip
50PIP_DOWNLOAD_CACHE=/var/cache/pip chroot $STAGING_DIR pip install `cat files/pips/*` || true
Anthony Younge2280932011-11-09 22:29:22 -080051
52# Unmount
Anthony Youngc1024d82011-11-09 18:58:07 -080053umount $STAGING_DIR