2011-11-07 16:10:59 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2012-11-29 09:19:16 +01:00
|
|
|
# **warm_apts_for_uec.sh**
|
2012-06-27 22:07:34 -05:00
|
|
|
|
2011-11-07 16:38:03 -06:00
|
|
|
# Echo commands
|
2011-11-07 16:37:00 -06:00
|
|
|
set -o xtrace
|
|
|
|
|
2011-11-07 16:38:03 -06:00
|
|
|
# Exit on error to stop unexpected errors
|
2011-11-07 16:37:00 -06:00
|
|
|
set -o errexit
|
|
|
|
|
2011-11-07 16:10:59 -06:00
|
|
|
# Keep track of the current directory
|
|
|
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
|
|
|
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
|
|
|
|
2011-11-07 16:38:03 -06:00
|
|
|
# Change dir to top of devstack
|
2011-11-07 16:10:59 -06:00
|
|
|
cd $TOP_DIR
|
|
|
|
|
|
|
|
# Echo usage
|
2014-02-21 15:35:08 +11:00
|
|
|
function usage {
|
2011-11-07 16:10:59 -06:00
|
|
|
echo "Cache OpenStack dependencies on a uec image to speed up performance."
|
|
|
|
echo ""
|
|
|
|
echo "Usage: $0 [full path to raw uec base image]"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make sure this is a raw image
|
|
|
|
if ! qemu-img info $1 | grep -q "file format: raw"; then
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-11-07 16:37:00 -06:00
|
|
|
# Make sure we are in the correct dir
|
|
|
|
if [ ! -d files/apts ]; then
|
|
|
|
echo "Please run this script from devstack/tools/"
|
|
|
|
exit 1
|
2012-03-09 16:03:00 +08:00
|
|
|
fi
|
2011-11-07 16:37:00 -06:00
|
|
|
|
2011-11-07 16:10:59 -06:00
|
|
|
# Mount the image
|
2011-11-09 18:58:07 -08:00
|
|
|
STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage
|
2011-11-07 16:10:59 -06:00
|
|
|
mkdir -p $STAGING_DIR
|
2011-11-09 18:58:07 -08:00
|
|
|
umount $STAGING_DIR || true
|
|
|
|
sleep 1
|
2011-11-07 16:10:59 -06:00
|
|
|
mount -t ext4 -o loop $1 $STAGING_DIR
|
|
|
|
|
|
|
|
# Make sure that base requirements are installed
|
|
|
|
cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
|
|
|
|
|
|
|
|
# Perform caching on the base image to speed up subsequent runs
|
|
|
|
chroot $STAGING_DIR apt-get update
|
|
|
|
chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
|
2011-11-09 18:58:07 -08:00
|
|
|
chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true
|
2011-11-09 22:29:22 -08:00
|
|
|
|
|
|
|
# Unmount
|
2011-11-09 18:58:07 -08:00
|
|
|
umount $STAGING_DIR
|