wheels: support extra wheels in tarball

build-wheel-tarball.sh: new option "--extra-wheels-dir": allow user to
pass an additional directory containing wheels files to be included in
the tarball. This lets users add arbitrary wheels in their privbate
builds when troubleshooting an image build.

Story: 2010294
Task: 46278

Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
Change-Id: I090723e95b91b90d0092b9692b33d382e7bbd6cf
This commit is contained in:
Davlet Panech 2022-09-13 15:44:58 +00:00
parent b4d55d8229
commit 2cea530c51

View File

@ -32,6 +32,7 @@ DOCKER_USER=${USER}
declare -i MAX_ATTEMPTS=1
PYTHON2=no
USE_DOCKER_CACHE=no
EXTRA_WHEELS_DIR=
# Requirement/constraint URLs -- these will be read from openstack.cfg
STABLE_OPENSTACK_REQ_URL=
@ -74,6 +75,7 @@ Options:
--version: Version for pushed image (if used with --push)
--attempts: Max attempts, in case of failure (default: 1)
--python2: Build a python2 tarball
--extra-wheels-dir: Directory containing additional .whl files
--keep-image: Don't delete wheel builder image at the end
--cache: Allow docker to use filesystem cache when building
@ -83,7 +85,7 @@ Options:
EOF
}
OPTS=$(getopt -o h -l help,os:,os-version:,push,clean,user:,release:,stream:,http_proxy:,https_proxy:,no_proxy:,version:,attempts:,python2,keep-image,cache -- "$@")
OPTS=$(getopt -o h -l help,os:,os-version:,push,clean,user:,release:,stream:,http_proxy:,https_proxy:,no_proxy:,version:,attempts:,python2,extra-wheels-dir:,keep-image,cache -- "$@")
if [ $? -ne 0 ]; then
usage
exit 1
@ -150,6 +152,10 @@ while true; do
PYTHON2=yes
shift
;;
--extra-wheels-dir)
EXTRA_WHEELS_DIR="$2"
shift 2
;;
--keep-image)
KEEP_IMAGE=yes
shift
@ -201,6 +207,11 @@ if [ "${PYTHON2}" = "yes" ]; then
PY_SUFFIX="-py2"
fi
# Resolve $EXTRA_WHEELS_DIR
if [[ -n "$EXTRA_WHEELS_DIR" ]] ; then
EXTRA_WHEELS_DIR="$(readlink -ev "$EXTRA_WHEELS_DIR")" || exit 1
fi
# Build the base wheels and retrieve the StarlingX wheels
declare -a BUILD_BASE_WL_ARGS
BUILD_BASE_WL_ARGS+=(--os ${OS} --stream ${BUILD_STREAM})
@ -305,7 +316,16 @@ if [ "${OS}" == "debian" ]; then
else
stx_find_wheels_cmd=(find ../stx/wheels -mindepth 1 -maxdepth 1 -name '*.whl')
fi
for wheel in ../base${PY_SUFFIX}/*.whl $("${stx_find_wheels_cmd[@]}") ; do
if [[ -d "$EXTRA_WHEELS_DIR" ]] ; then
find_extra_wheels_cmd=(find "$EXTRA_WHEELS_DIR" -mindepth 1 -maxdepth 1 -name '*.whl')
else
find_extra_wheels_cmd=()
fi
for wheel in ../base${PY_SUFFIX}/*.whl $("${stx_find_wheels_cmd[@]}") $("${find_extra_wheels_cmd[@]}") ; do
if [[ ! -f "$wheel" ]] ; then
echo "WARNING: $wheel doesn't exist or is not a regular file" >&2
continue
fi
# Get the wheel name and version from the METADATA
METADATA=$(unzip -p ${wheel} '*/METADATA')
name=$(echo "${METADATA}" | grep '^Name:' | awk '{print $2}')