diff options
Diffstat (limited to 'common/hooks/pre-pkg/03-rewrite-python-shebang.sh')
-rw-r--r-- | common/hooks/pre-pkg/03-rewrite-python-shebang.sh | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/common/hooks/pre-pkg/03-rewrite-python-shebang.sh b/common/hooks/pre-pkg/03-rewrite-python-shebang.sh index 4de75da2a76..3450c3a3a8f 100644 --- a/common/hooks/pre-pkg/03-rewrite-python-shebang.sh +++ b/common/hooks/pre-pkg/03-rewrite-python-shebang.sh @@ -4,25 +4,23 @@ hook() { local pyver= shebang= off= - : ${pyver:=2} - if [ -d ${PKGDESTDIR}/usr/lib/python* ]; then pyver="$(find ${PKGDESTDIR}/usr/lib/python* -prune -type d | grep -o '[[:digit:]]\.[[:digit:]]$')" fi - if [ -n "$pycompile_version" ]; then - pyver="$pycompile_version" + if [ -n "$python_version" ]; then + pyver="$python_version" fi - if [ "$python_version" = "3" ]; then - pyver="$python_version" + if [ -n "$pyver" ]; then + shebang="#!/usr/bin/python${pyver%.*}" fi - shebang="#!/usr/bin/python${pyver%.*}" find "${PKGDESTDIR}" -type f -print0 | \ while IFS= read -r -d '' file; do [ ! -s "$file" ] && continue [ -z "$(sed -n -E -e 2q -e '/^#!.*([[:space:]]|\/)python([0-9]\.[0-9])?([[:space:]]+|$)/p' "$file")" ] && continue + [ -n "$shebang" ] || msg_error "cannot convert shebang, set python_version\n" echo " Shebang converted to '$shebang': ${file#$PKGDESTDIR}" sed -i "1s@.*python.*@${shebang}@" -- "$file" done |