[jhbuild] scripts: Make the ~/.local/bin/python2 idempotent



commit 1d3644c78eb3b8f4bb384701a7318b5ccb76b9ae
Author: Emanuele Aina <emanuele aina collabora com>
Date:   Tue Jan 29 19:27:33 2013 +0100

    scripts: Make the ~/.local/bin/python2 idempotent
    
    The python2 hack for Debian system causes `make install' to fail if ran
    more than once, since it tries to create the link even if it exists
    already.
    
    Other than making it idempotent such that it can be run more than once
    also drop an unused variable, improve the runtime checks and make the
    coding style more shell-like.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692825

 scripts/debian-python2-postinstall-hook.sh |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/scripts/debian-python2-postinstall-hook.sh b/scripts/debian-python2-postinstall-hook.sh
index ef7b39b..889e175 100755
--- a/scripts/debian-python2-postinstall-hook.sh
+++ b/scripts/debian-python2-postinstall-hook.sh
@@ -8,11 +8,17 @@
 
 set -e
 
-bindir=$1
-test -n "$bindir" || (echo "usage: $0 bindir"; exit 1)
+BINDIR=$1
+DEST="$BINDIR/python2"
+PYTHON=$(which python 2>/dev/null || true);
 
-py2=$(which python2 2>/dev/null || true)
-if test -z "$py2"; then
-    py=$(which python 2>/dev/null);
-    ln -s "$(which python)" ${bindir}/python2;
-fi
+function die() { echo "$1" >&2 ; exit 2; }
+
+test -n "$BINDIR" || die "Usage: $0 BINDIR"
+test -d "$BINDIR" || die "$0: '$BINDIR' is not a directory"
+
+which python2 2>/dev/null && exit 0 # 'python2' is already on PATH
+
+test -x "$PYTHON" || die "$0: Unable to find 'python' in the PATH"
+
+ln -sf "$PYTHON" "$DEST"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]