blob: c57fc2e59ccca4625f9b19c0b678db9ef409a078 [file] [log] [blame]
Anthony Younge7fa9092011-11-07 16:10:59 -06001#!/usr/bin/env bash
2
Vincent Untz7c3053d2012-11-29 09:19:16 +01003# **warm_apts_for_uec.sh**
Dean Troyere62ba4d2012-06-27 22:07:34 -05004
Anthony Young208ae2f2011-11-07 16:38:03 -06005# Echo commands
Anthony Young8655bf02011-11-07 16:37:00 -06006set -o xtrace
7
Anthony Young208ae2f2011-11-07 16:38:03 -06008# Exit on error to stop unexpected errors
Anthony Young8655bf02011-11-07 16:37:00 -06009set -o errexit
10
Anthony Younge7fa9092011-11-07 16:10:59 -060011# Keep track of the current directory
12TOOLS_DIR=$(cd $(dirname "$0") && pwd)
13TOP_DIR=`cd $TOOLS_DIR/..; pwd`
14
Anthony Young208ae2f2011-11-07 16:38:03 -060015# Change dir to top of devstack
Anthony Younge7fa9092011-11-07 16:10:59 -060016cd $TOP_DIR
17
18# Echo usage
Ian Wienandaee18c72014-02-21 15:35:08 +110019function usage {
Anthony Younge7fa9092011-11-07 16:10:59 -060020 echo "Cache OpenStack dependencies on a uec image to speed up performance."
21 echo ""
22 echo "Usage: $0 [full path to raw uec base image]"
23}
24
25# Make sure this is a raw image
26if ! qemu-img info $1 | grep -q "file format: raw"; then
27 usage
28 exit 1
29fi
30
Anthony Young8655bf02011-11-07 16:37:00 -060031# Make sure we are in the correct dir
32if [ ! -d files/apts ]; then
33 echo "Please run this script from devstack/tools/"
34 exit 1
Hengqing Hu3b719e52012-03-09 16:03:00 +080035fi
Anthony Young8655bf02011-11-07 16:37:00 -060036
Anthony Younge7fa9092011-11-07 16:10:59 -060037# Mount the image
Anthony Youngc1024d82011-11-09 18:58:07 -080038STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage
Anthony Younge7fa9092011-11-07 16:10:59 -060039mkdir -p $STAGING_DIR
Anthony Youngc1024d82011-11-09 18:58:07 -080040umount $STAGING_DIR || true
41sleep 1
Anthony Younge7fa9092011-11-07 16:10:59 -060042mount -t ext4 -o loop $1 $STAGING_DIR
43
44# Make sure that base requirements are installed
45cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
46
47# Perform caching on the base image to speed up subsequent runs
48chroot $STAGING_DIR apt-get update
49chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
Anthony Youngc1024d82011-11-09 18:58:07 -080050chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true
Anthony Younge2280932011-11-09 22:29:22 -080051
52# Unmount
Anthony Youngc1024d82011-11-09 18:58:07 -080053umount $STAGING_DIR