diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-01-17 17:53:45 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-01-23 17:08:35 +0100 |
commit | a63cac26680dd2c7b6615fc9b8623b9b543e1f10 (patch) | |
tree | 133c786cdcf94cd2ddf79c33fd3e32e7f8339843 /scripts | |
parent | b8060a253bada299010c0169f0ff7470b8c04322 (diff) | |
download | ptxdist-a63cac26680dd2c7b6615fc9b8623b9b543e1f10.tar.gz ptxdist-a63cac26680dd2c7b6615fc9b8623b9b543e1f10.tar.xz |
wrapper: add python wrapper
It enforces a dependency on host-system-python{,3} and chooses the
corresponding Python version when called as 'python'.
This makes it possible to use Python 3 for packages that support it but use
'python' to support both Python versions.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/wrapper/python-wrapper | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/wrapper/python-wrapper b/scripts/wrapper/python-wrapper new file mode 100755 index 000000000..8449aae33 --- /dev/null +++ b/scripts/wrapper/python-wrapper @@ -0,0 +1,45 @@ +#!/bin/bash + +name=$(basename "${0}") +if [ "${name#*-}" != "${name}" ]; then + suffix="-${name#*-}" + name="${name%-*}" +fi + +case "${name}" in +python) dep="host-system-python / host-system-python3" ;; +python2) dep=host-system-python ;; +python3) dep=host-system-python3 ;; +esac + +case " ${pkg_build_deps} " in +*" ${dep} "*) ;; +*" host-system-python "*) name=python2 ;; +*" host-system-python3 "*) name=python3 ;; +*) + case " ${pkg_build_deps_all} " in + *" ${dep} "*) ;; + *" host-system-python "*) name=python2 ;; + *" host-system-python3 "*) name=python3 ;; + *) + if [ -n "${pkg_stamp}" ]; then + echo -e "\n'${pkg_stamp%.*}' must depend on '${dep}' for '${name}'!\n" >&2 + exit 1 + fi + ;; + esac + ;; +esac + +name="${name}${suffix}" +skip="$(dirname "${0}")/${name}" + +for path in $(type -a -P ${name}); do + if [ "${path}" = "${skip}" ]; then + continue + fi + exec "${path}" "${@}" +done + +echo "'${name}' not found!" >&2 +exit 1 |