vp-build/helper-templates/replace-interpreter.sh
Juan RP 5a0aac4fd2 Added some ANSI colors for messages, may be disabled.
With the -e flag those colors will be disabled. As bonus also
I removed blank lines in .xbps-filelist and other misc tweaks, fixes
I cannot remember now.

--HG--
extra : convert_revision : 5e481d0faa14518363eafc622633d645c335ed78
2008-10-29 03:20:14 +01:00

47 lines
811 B
Bash

#
# 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
trpath="/bin/bash"
;;
perl)
orsb=$perl_regexp
trpath="/usr/bin/perl"
;;
python)
orsb=$python_regexp
trpath="/usr/bin/python"
;;
*)
;;
esac
if [ -f $wrksrc/$file ]; then
sed -i -e "1s|^#![[:space:]]*${orsb}|#!${trpath}|" $file && \
msg_normal "Transformed $lang script: ${file##$wrksrc}."
else
msg_warn "Ignoring unexistent $lang script: ${file##$wrksrc}."
fi
}