|
|
b4ba4d |
#!/bin/sh
|
|
|
b4ba4d |
|
|
|
b4ba4d |
|
|
|
b4ba4d |
# objective: copy one or more source python (.py) scripts
|
|
|
b4ba4d |
|
|
|
b4ba4d |
# environment variable PYCOPY_DSTDIR, replacing
|
|
|
b4ba4d |
|
|
|
b4ba4d |
|
|
|
b4ba4d |
|
|
|
b4ba4d |
# environment variables.
|
|
|
b4ba4d |
|
|
|
b4ba4d |
if [ -z "$PYCOPY_PYTHON" ]; then
|
|
|
b4ba4d |
python='python'
|
|
|
b4ba4d |
else
|
|
|
b4ba4d |
python="$PYCOPY_PYTHON"
|
|
|
b4ba4d |
fi
|
|
|
b4ba4d |
|
|
|
b4ba4d |
if [ -z "$PYCOPY_PREFIX" ]; then
|
|
|
b4ba4d |
prefix='/usr'
|
|
|
b4ba4d |
else
|
|
|
b4ba4d |
prefix="$PYCOPY_PREFIX"
|
|
|
b4ba4d |
fi
|
|
|
b4ba4d |
|
|
|
b4ba4d |
if [ -z "$PYCOPY_DSTDIR" ]; then
|
|
|
b4ba4d |
dstdir='.'
|
|
|
b4ba4d |
else
|
|
|
b4ba4d |
dstdir="$PYCOPY_DSTDIR"
|
|
|
b4ba4d |
fi
|
|
|
b4ba4d |
|
|
|
b4ba4d |
for pysrc in $@; do
|
|
|
b4ba4d |
basename=$(basename "$pysrc");
|
|
|
b4ba4d |
|
|
|
b4ba4d |
sed -e '1s@^#!.*@#!'" $prefix/bin/$python"'@g' \
|
|
|
b4ba4d |
"$pysrc" > "$dstdir/$basename" || exit 2
|
|
|
b4ba4d |
|
|
|
b4ba4d |
if [ "$(head -n1 "$dstdir/$basename")" = "#! $prefix/bin/$python" ]; then
|
|
|
b4ba4d |
chmod +x "$dstdir/$basename" || exit 2
|
|
|
b4ba4d |
fi
|
|
|
b4ba4d |
done
|
|
|
b4ba4d |
|
|
|
b4ba4d |
exit 0
|