1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#! /bin/sh
## $Id: fixscript.in 8561 2009-08-14 18:32:41Z iulius $
##
## Fix interpreter paths and INN variable load paths.
##
## Scripts shipped with INN always have the invocation path for the
## interpreter on the first line and the command to load INN variable
## settings into the script on the second line. For example, for a Bourne
## shell script:
##
## #!/bin/sh
## . /var/news/lib/innshellvars
##
## This script takes as input such a script and outputs the same script
## with the first two lines replaced to have the correct path to the
## interpreter and to the INN variable library, as determined by configure.
##
## If the script is invoked with the -i flag, only fix the interpreter
## path and don't modify the second line of the file to include the
## appropriate innshellvars.
PERLPATH='@PERL@'
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libdir="@libdir@"
libperldir="@LIBPERLDIR@"
# We can probably just assume sed is on the path, but since we have it, we may
# as well use it.
SED='@SED@'
options=true
addlib=true
while $options ; do
case X"$1" in
X-i) addlib=false ;;
*) options=false ;;
esac
$options && shift
done
input="$1"
if [ -z "$input" ] ; then
echo "No input file specified" >&2
exit 1
fi
output="$2"
if [ -z "$output" ] ; then
output=`echo "$input" | sed 's/\.in$//'`
fi
if [ x"$input" = x"$output" ] ; then
echo "No output file specified and input file doesn't end in .in" >&2
exit 1
fi
interpreter=`head -n 1 "$input"`
case "$interpreter" in
*/sh|*SH*)
path="@SHELL@"
lib=". $libdir/innshellvars"
;;
*/perl*|*PERL*)
path=`echo "$interpreter" | sed 's%^#! *[^ ][^ ]*%'"$PERLPATH%"`
lib="use lib '@LIBPERLDIR@'; use INN::Config;"
;;
*)
echo "Unknown interpreter $interpreter" >&2
exit 1
;;
esac
echo "#! $path" > "$output"
if $addlib ; then
echo "$lib" >> "$output"
"$SED" 1,2d "$input" >> "$output"
else
"$SED" 1d "$input" >> "$output"
fi
chmod 755 "$output"
|