2008-10-14 16:24:53 +00: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 08:26:55 +00:00
|
|
|
trpath="/bin/bash"
|
2008-10-14 16:24:53 +00:00
|
|
|
;;
|
|
|
|
perl)
|
|
|
|
orsb=$perl_regexp
|
2008-10-28 08:26:55 +00:00
|
|
|
trpath="/usr/bin/perl"
|
2008-10-14 16:24:53 +00:00
|
|
|
;;
|
|
|
|
python)
|
|
|
|
orsb=$python_regexp
|
2008-10-28 08:26:55 +00:00
|
|
|
trpath="/usr/bin/python"
|
2008-10-14 16:24:53 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-11-03 09:32:36 +00:00
|
|
|
if [ -f $file ]; then
|
2008-10-28 08:26:55 +00:00
|
|
|
sed -i -e "1s|^#![[:space:]]*${orsb}|#!${trpath}|" $file && \
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_normal "Transformed $lang script: ${file##$wrksrc}.\n"
|
2008-10-14 16:24:53 +00:00
|
|
|
else
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_warn "Ignoring unexistent $lang script: ${file##$wrksrc}.\n"
|
2008-10-14 16:24:53 +00:00
|
|
|
fi
|
|
|
|
}
|