Fix absolute paths to the ondir python binary when building DEB/RPM

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-01-24 06:16:59 +00:00 committed by Megan Wilhite
parent 840cc98bc0
commit 5285aaad77
2 changed files with 17 additions and 1 deletions

View file

@ -24,6 +24,10 @@ override_dh_auto_build:
build/onedir/salt/bin/python3 -m pip install "pip>=22.3.1,<23.0" "setuptools>=65.6.3,<66" "wheel"
export PY=$$(build/onedir/salt/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()') \
&& build/onedir/salt/bin/python3 -m pip install -r requirements/static/pkg/py$${PY}/linux.txt
# Fix any hardcoded paths to the relenv python binary on any of the scripts installed in the <onedir>/bin directory
find build/onedir/salt/bin/ -type f -exec sed -i 's:#!/\(.*\)salt/bin/python3:#!/bin/sh\n"exec" "$$(dirname $$(readlink -f $$0))/python3" "$$0" "$$@":g' {} \;
export USE_STATIC_REQUIREMENTS=1 \
&& export RELENV_PIP_DIR=1 \
&& build/onedir/salt/bin/python3 -m pip install --no-warn-script-location .
@ -37,6 +41,9 @@ override_dh_auto_build:
# is expected to be done
mkdir -p build/onedir
cd build/onedir; tar xvf ${SALT_ONEDIR_ARCHIVE}
# Fix any hardcoded paths to the relenv python binary on any of the scripts installed in the <onedir>/bin directory
find build/onedir/salt/bin/ -type f -exec sed -i 's:#!/\(.*\)salt/bin/python3:#!/bin/sh\n"exec" "$$(dirname $$(readlink -f $$0))/python3" "$$0" "$$@":g' {} \;
endif
# dh_auto_install tries to invoke distutils causing failures.

View file

@ -141,6 +141,11 @@ cd $RPM_BUILD_DIR
build/salt/bin/python3 -m pip install "pip>=22.3.1,<23.0" "setuptools>=65.6.3,<66" "wheel"
export PY=$(build/salt/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()')
build/salt/bin/python3 -m pip install -r %{_salt_src}/requirements/static/pkg/py${PY}/linux.txt
# Fix any hardcoded paths to the relenv python binary on any of the scripts installed in
# the <onedir>/bin directory
find build/salt/bin/ -type f -exec sed -i 's:#!/\(.*\)salt/bin/python3:#!/bin/sh\n"exec" "$(dirname $(readlink -f $0))/python3" "$0" "$@":g' {} \;
export USE_STATIC_REQUIREMENTS=1
export RELENV_PIP_DIR=1
build/salt/bin/python3 -m pip install --no-warn-script-location %{_salt_src}
@ -154,7 +159,11 @@ cd $RPM_BUILD_DIR
# is expected to be done
cd build
tar xf ${SALT_ONEDIR_ARCHIVE}
cd ..
# Fix any hardcoded paths to the relenv python binary on any of the scripts installed in the <onedir>/bin directory
find salt/bin/ -type f -exec sed -i 's:#!/\(.*\)salt/bin/python3:#!/bin/sh\n"exec" "$$(dirname $$(readlink -f $$0))/python3" "$$0" "$$@":g' {} \;
cd $RPM_BUILD_DIR
%endif