2016-03-21 19:30:39 +00:00
|
|
|
# This hook executes the following tasks:
|
|
|
|
# - rewrites python shebangs with the corresponding python version
|
|
|
|
|
|
|
|
hook() {
|
|
|
|
local pyver= shebang= warn=
|
|
|
|
|
2016-03-27 10:24:00 +00:00
|
|
|
case $pkgname in
|
|
|
|
python-*)
|
|
|
|
pyver=2.7;;
|
|
|
|
python3.4-*)
|
|
|
|
pyver=3.4;;
|
2016-03-27 13:12:40 +00:00
|
|
|
python3.5-*)
|
|
|
|
pyver=3.5;;
|
2016-03-27 10:24:00 +00:00
|
|
|
*)
|
2016-03-27 13:12:40 +00:00
|
|
|
for i in $pycompile_version $python_versions; do
|
2016-03-27 10:24:00 +00:00
|
|
|
if [ "$pyver" ]; then
|
|
|
|
warn=1
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
pyver=$i
|
|
|
|
done
|
|
|
|
: ${pyver:=2.7}
|
|
|
|
;;
|
|
|
|
esac
|
2016-03-21 19:30:39 +00:00
|
|
|
|
|
|
|
shebang="#!/usr/bin/python$pyver"
|
|
|
|
find ${PKGDESTDIR} -type f -print0 | \
|
2016-03-25 18:12:58 +00:00
|
|
|
xargs -0 grep -H -b -m 1 "^#!.*\([[:space:]]\|/\)python\([[:space:]]\|$\)" -- | while IFS=: read -r f off _; do
|
2016-04-01 06:08:52 +00:00
|
|
|
[ "$off" -a "$off" -eq 0 ] || continue
|
2016-03-21 19:30:39 +00:00
|
|
|
if [ "$warn" ]; then
|
|
|
|
msg_warn "$pkgname: multiple python versions defined!"
|
|
|
|
msg_warn "$pkgname: using $pyver for shebang"
|
|
|
|
warn=
|
|
|
|
fi
|
|
|
|
echo " Unversioned shebang replaced by '$shebang': ${f#$PKGDESTDIR}"
|
|
|
|
sed -i "1s@.*python@${shebang}@" -- "$f"
|
|
|
|
done
|
|
|
|
}
|