Allow passing an arbitrary package list to assemble

This lets you build an image to install a package or set of packages
without having to build a fake pbr install.

Change-Id: I6c171881283b89a14a532f31aedb33e223a0ea1f
This commit is contained in:
Monty Taylor 2020-04-22 14:53:31 -05:00
parent ba3a0eb775
commit f3304c38d5
2 changed files with 27 additions and 11 deletions

View File

@ -73,6 +73,8 @@ function install_wheels {
done
}
PACKAGES=$*
# bindep the main package
install_bindep
@ -83,17 +85,25 @@ for sibling in ${ZUUL_SIBLINGS:-}; do
popd
done
# pbr needs git installed, else nothing will work. Do this in between
# bindep and wheel so that we don't miss git in target images.
apt-get install -y git
# Use a clean virtualenv for install steps to prevent things from the
# current environment making us not build a wheel.
python -m venv /tmp/venv
/tmp/venv/bin/pip install -U pip wheel
# Install the main package
# If we got a list of packages, install them, otherwise install the
# main package.
if [[ $PACKAGES ]] ; then
/tmp/venv/bin/pip install --cache-dir=/output/wheels $PACKAGES
for package in $PACKAGES ; do
echo "$package" >> /output/packages.txt
done
else
# pbr needs git installed, else nothing will work. Do this in between
# bindep and wheel so that we don't miss git in target images.
apt-get install -y git
install_wheels
fi
# go through ZUUL_SIBLINGS, if any, and build those wheels too
for sibling in ${ZUUL_SIBLINGS:-}; do

View File

@ -32,11 +32,17 @@ for extra in $* ; do
EXTRAS="${EXTRAS} -f /output/$extra/requirements.txt"
done
if [ -f /output/packages.txt ] ; then
# If a package list was passed to assemble, install that in the final
# image.
pip install --cache-dir=/output/wheels -r /output/packages.txt $EXTRAS
else
# Install the wheels. Use --force here because sibling wheels might
# be built with the same version number as the latest release, but we
# really want the speculatively built wheels installed over any
# automatic dependencies.
pip install --force --cache-dir=/output/wheels /output/wheels/*.whl $EXTRAS
fi
# clean up after ourselves
apt-get clean