e7fa9093 |
#!/usr/bin/env bash
|
7c3053da |
# **warm_apts_for_uec.sh** |
e62ba4d3 |
|
208ae2f6 |
# Echo commands |
8655bf0e |
set -o xtrace
|
208ae2f6 |
# Exit on error to stop unexpected errors |
8655bf0e |
set -o errexit
|
e7fa9093 |
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
208ae2f6 |
# Change dir to top of devstack |
e7fa9093 |
cd $TOP_DIR
# Echo usage
usage() {
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
|
8655bf0e |
# Make sure we are in the correct dir
if [ ! -d files/apts ]; then
echo "Please run this script from devstack/tools/"
exit 1 |
3b719e50 |
fi |
8655bf0e |
|
e7fa9093 |
# Mount the image |
c1024d89 |
STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage |
e7fa9093 |
mkdir -p $STAGING_DIR |
c1024d89 |
umount $STAGING_DIR || true
sleep 1 |
e7fa9093 |
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` |
c1024d89 |
chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true |
e228093e |
# Unmount |
c1024d89 |
umount $STAGING_DIR |