blob: 2a55b7a85244e4bb0db104667e6bf56ca2a8c191 (
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
|
#!/bin/sh
# pyccopy: a build-time utiltiy script
# objective: copy one or more source python (.py) scripts
# to the destination directory specified via the
# environment variable PYCOPY_DSTDIR, replacing
# the original shebang line, should the script
# contain one, with a program interpreter based
# on the PYCOPY_PREFIX and PYCOPY_PYTHON
# environment variables.
if [ -z "$PYCOPY_PYTHON" ]; then
python='python'
else
python="$PYCOPY_PYTHON"
fi
if [ -z "$PYCOPY_PREFIX" ]; then
prefix='/usr'
else
prefix="$PYCOPY_PREFIX"
fi
if [ -z "$PYCOPY_DSTDIR" ]; then
dstdir='.'
else
dstdir="$PYCOPY_DSTDIR"
fi
for pysrc in $@; do
basename=$(basename "$pysrc");
sed -e '1s@^#!.*@#!'" $prefix/bin/$python"'@g' \
"$pysrc" > "$dstdir/$basename" || exit 2
if [ "$(head -n1 "$dstdir/$basename")" = "#! $prefix/bin/$python" ]; then
chmod +x "$dstdir/$basename" || exit 2
fi
done
exit 0
|