blob: fef24e01708d763fa80e0c82d1e0739ae5261f04 (
plain)
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
|
#!/bin/sh
# usage:
# .../install-wrap $(PYTHON_PATH) install <options-to-install> <src>... <dest>
# where
# PYTHON_PATH is what to put after #! and may be `/usr/bin/env python'
#
# Used via $(INSTALL_PYTHON_PROG) in Rules.mk; PYTHON_PATH comes from $(PYTHON)
set -e
if test $# -lt 2; then
echo >&2 "${0##*/}: too few arguments"
exit 1
fi
pythonpath="$1"
shift
install="$1"
shift
srcs=""
while [ $# != 0 ]; do
case "$1" in
-|--) install=`echo "${install} $1"`
shift
break
;;
-*) install=`echo "${install} $1"`
shift
;;
*) break
;;
esac
done
while test $# -gt 1; do
srcs=`echo "${srcs} $1"`
shift
done
dest="$1"
shift
destf="$dest"
for srcf in ${srcs}; do
if test -d "$dest"; then
destf="$dest/${srcf##*/}"
fi
org="$(sed -n '2q; /^#! *\/usr\/bin\/env python *$/p' $srcf)"
if test "x$org" = x; then
eval "${install} $srcf $destf"
continue
fi
tmpf="$destf.tmp"
eval "${install} $srcf $tmpf"
printf >"$tmpf" "#!%s\n" "$pythonpath"
sed -e 1d "$srcf" >>"$tmpf"
mv -f "$tmpf" "$destf"
done
exit 0
|