build-helm-charts: python 2/3 compatibility
Make sure the helm charts script works with both python2 and python3. The referenced python scripts work with either python version, but some of the required module versions are not available on Debian for python2. Solution: look for python2 (for CentOS compatibility), fallback to python3. TESTS =========================================== Build helm charts on both CentOS and Debian Story: 2009897 Task: 45411 Change-Id: I4df12f1654c0f6950d71b83188a454fc54449d71 Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
This commit is contained in:
parent
fdcdc0d1b7
commit
2941a7b436
@ -23,6 +23,7 @@ declare -a IMAGE_RECORDS
|
||||
declare -a PATCH_DEPENDENCIES
|
||||
declare -a APP_PACKAGES
|
||||
declare -a CHART_PACKAGE_FILES
|
||||
# PYTHON_2_OR_3: initialized below
|
||||
|
||||
VERBOSE=false
|
||||
CPIO_FLAGS=
|
||||
@ -157,7 +158,7 @@ function build_image_versions_to_manifest {
|
||||
# aodh_db_sync: docker.io/starlingx/stx-aodh:master-centos-dev-latest
|
||||
#
|
||||
image_record=${IMAGE_RECORD_PATH}/$(basename ${image_record})
|
||||
${PYTHON2:-python2} $BUILD_HELM_CHARTS_DIR/helm_chart_modify.py ${manifest_file} ${manifest_file}.tmp ${image_record}
|
||||
${PYTHON_2_OR_3} $BUILD_HELM_CHARTS_DIR/helm_chart_modify.py ${manifest_file} ${manifest_file}.tmp ${image_record}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to update manifest file" >&2
|
||||
exit 1
|
||||
@ -318,19 +319,7 @@ for yaml_file in yaml_files:
|
||||
print('Writing merged yaml file: %s' % yaml_output)
|
||||
yaml.dump_all(yaml_out.values(), open(yaml_output, 'w'), Dumper=yaml.RoundTripDumper, default_flow_style=False)
|
||||
"
|
||||
local python python_found
|
||||
for python in ${PYTHON2:-python2} ${PYTHON:-python} ${PYTHON3:-python3} ; do
|
||||
if $python -c 'import ruamel.yaml' >/dev/null 2>&1 ; then
|
||||
python_found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$python_found" ]] ; then
|
||||
echo "ERROR: can't find python!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$python -c "${yaml_script}" ${@} || exit 1
|
||||
$PYTHON_2_OR_3 -c "${yaml_script}" ${@} || exit 1
|
||||
}
|
||||
|
||||
# Find a file named $APP_VERSION_BASE at top-level of each git repo
|
||||
@ -734,6 +723,23 @@ if [ -z "${MY_WORKSPACE}" -o -z "${MY_REPO}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# find a python interpreter
|
||||
function find_python_2_or_3 {
|
||||
local python python_found
|
||||
for python in ${PYTHON2:-python2} ${PYTHON:-python} ${PYTHON3:-python3} ; do
|
||||
if $python -c 'import ruamel.yaml' >/dev/null 2>&1 ; then
|
||||
python_found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "$python_found" ]] ; then
|
||||
echo "ERROR: can't find python!" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$python"
|
||||
}
|
||||
PYTHON_2_OR_3="$(find_python_2_or_3)" || exit 1
|
||||
|
||||
# include SRPM utils
|
||||
if [[ "$OS" == "centos" ]] ; then
|
||||
source $BUILD_HELM_CHARTS_DIR/srpm-utils || exit 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2020 Wind River Systems, Inc.
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user