2008-10-14 18:24:53 +02:00
|
|
|
#
|
|
|
|
# This helper replaces shebang paths pointing to the correct ones
|
|
|
|
# as used by xbps. Multiple languages are supported:
|
|
|
|
#
|
|
|
|
# - GNU Bash
|
|
|
|
# - Perl
|
|
|
|
# - Python
|
|
|
|
#
|
|
|
|
|
|
|
|
bash_regexp=".*sh"
|
|
|
|
perl_regexp=".*perl[^[:space:]]*"
|
|
|
|
python_regexp=".*python[^[:space:]]*"
|
|
|
|
|
|
|
|
replace_interpreter()
|
|
|
|
{
|
|
|
|
local lang="$1"
|
|
|
|
local file="$2"
|
|
|
|
local trsb=
|
|
|
|
local orsb=
|
|
|
|
|
|
|
|
[ -z $lang -o -z $file ] && return 1
|
|
|
|
|
|
|
|
case $lang in
|
|
|
|
bash)
|
|
|
|
orsb=$bash_regexp
|
2008-10-28 09:26:55 +01:00
|
|
|
trpath="/bin/bash"
|
2008-10-14 18:24:53 +02:00
|
|
|
;;
|
|
|
|
perl)
|
|
|
|
orsb=$perl_regexp
|
2008-10-28 09:26:55 +01:00
|
|
|
trpath="/usr/bin/perl"
|
2008-10-14 18:24:53 +02:00
|
|
|
;;
|
|
|
|
python)
|
|
|
|
orsb=$python_regexp
|
2008-10-28 09:26:55 +01:00
|
|
|
trpath="/usr/bin/python"
|
2008-10-14 18:24:53 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-11-03 10:32:36 +01:00
|
|
|
if [ -f $file ]; then
|
2008-10-28 09:26:55 +01:00
|
|
|
sed -i -e "1s|^#![[:space:]]*${orsb}|#!${trpath}|" $file && \
|
2008-10-29 03:20:14 +01:00
|
|
|
msg_normal "Transformed $lang script: ${file##$wrksrc}."
|
2008-10-14 18:24:53 +02:00
|
|
|
else
|
2008-10-29 03:20:14 +01:00
|
|
|
msg_warn "Ignoring unexistent $lang script: ${file##$wrksrc}."
|
2008-10-14 18:24:53 +02:00
|
|
|
fi
|
|
|
|
}
|