Enforce upper-constraints when building ramdisks
Currently, building ramdisks installs ironic-python-agent without any upper-constraints. This causes the package to be installed with newer, untested dependencies. This commits introduces a tool to generate a local upper-constraints file based on predefined strategies (below). Additionally, the fallback to the openstack/requirements uses the URL defined in tox.ini instead of redefining it. This prevents having to keep track of two separate variables when releasing. upper-constraints lookup strategies (in order): * UPPER_CONSTRAINTS_FILE points to a local file * UPPER_CONSTRAINTS_FILE points to a URL * /opt/stack/new/requirements/upper-constraints.txt * upper-constraints.txt from openstack/requirements git repository Partial-bug: #1616554 Change-Id: Ib5c0c57cafdb6ffd7456e61f3b1bb5fa57520e5achanges/55/358855/10
parent
007654a9b6
commit
a0ca6ce157
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
# NOTE(mmitchell): This extracts the URL defined as the default value for
|
||||
# UPPER_CONSTRAINTS_FILE in tox.ini. This is used by image
|
||||
# builders to avoid duplicating the default value in multiple
|
||||
# scripts. This is specially done to leverage the release
|
||||
# tools that automatically update the tox.ini when projects
|
||||
# are released.
|
||||
sed -n 's/^.*{env:UPPER_CONSTRAINTS_FILE\:\([^}]*\)}.*$/\1/p' $1 | head -n1
|
||||
|
@ -0,0 +1,79 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
COMMON_ROOT=$(dirname $0)
|
||||
DESTINATION="$1"
|
||||
TOX_INI_UPPER_CONSTRAINT_URL="$(${COMMON_ROOT}/extract_upper_constraints_from_tox_ini.sh ${COMMON_ROOT}/../../tox.ini)"
|
||||
|
||||
copy() {
|
||||
local src=$1
|
||||
local destination=$2
|
||||
|
||||
if test -z "${src}"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if test -e "${src}"; then
|
||||
log "File '${src}' exists. Using as upper-constraints."
|
||||
cp "${src}" "${destination}"
|
||||
else
|
||||
log "File '${src}' not found. Skipping local file strategy."
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
download() {
|
||||
local url=$1
|
||||
local destination=$2
|
||||
|
||||
if test -z "${url}"; then
|
||||
return 1
|
||||
else
|
||||
log "Downloading from '${url}'"
|
||||
curl ${url} -o "${destination}"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
log() {
|
||||
echo "${SCRIPT_NAME}: ${@}"
|
||||
}
|
||||
|
||||
fail() {
|
||||
log ${@}
|
||||
exit 1
|
||||
}
|
||||
|
||||
upper_constraints_is_not_null() {
|
||||
test "${UPPER_CONSTRAINTS_FILE:-""}" != ""
|
||||
}
|
||||
|
||||
copy_uc() {
|
||||
copy "${UPPER_CONSTRAINTS_FILE:-""}" "${DESTINATION}"
|
||||
}
|
||||
|
||||
download_uc() {
|
||||
download "${UPPER_CONSTRAINTS_FILE:-""}" "${DESTINATION}"
|
||||
}
|
||||
|
||||
copy_new_requirements_uc() {
|
||||
copy "/opt/stack/new/requirements/upper-constraints.txt" "${DESTINATION}"
|
||||
}
|
||||
|
||||
download_from_tox_ini_url() {
|
||||
log "tox.ini indicates '${TOX_INI_UPPER_CONSTRAINT_URL}' as fallback."
|
||||
download "${TOX_INI_UPPER_CONSTRAINT_URL}" "${DESTINATION}"
|
||||
}
|
||||
|
||||
log "Generating local constraints file..."
|
||||
|
||||
if upper_constraints_is_not_null; then
|
||||
log "UPPER_CONSTRAINTS_FILE is defined as '${UPPER_CONSTRAINTS_FILE:-""}'"
|
||||
copy_uc || download_uc || fail "Failed to copy or download file indicated in UPPER_CONSTRAINTS_FILE."
|
||||
else
|
||||
log "UPPER_CONSTRAINTS_FILE is not defined. Using fallback strategies."
|
||||
|
||||
copy_new_requirements_uc || \
|
||||
download_from_tox_ini_url || fail "Failed to download upper-constraints.txt from '${TOX_INI_UPPER_CONSTRAINT_URL}'."
|
||||
fi
|
Loading…
Reference in New Issue