summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/ac_config_iraf_pkg70
1 files changed, 55 insertions, 15 deletions
diff --git a/scripts/ac_config_iraf_pkg b/scripts/ac_config_iraf_pkg
index 52fabde..4d24a7e 100755
--- a/scripts/ac_config_iraf_pkg
+++ b/scripts/ac_config_iraf_pkg
@@ -1,30 +1,70 @@
#!/bin/sh
#
# A post-install script for AstroConda IRAF packages (to update extern.pkg),
-# which gets executed automatically when doing "conda install".
+# which gets executed automatically when doing "conda install", but can also be
+# run by users to restore broken definitions.
script_dir=`dirname "$0"`
-name=$1
-if [ -z "$1" -o -n "$2" ]; then
- echo "Usage: `basename "$0"` NAME"
- exit 1
+st=1
+unset name
+while [ -n "$1" ]; do
+ case "$1" in
+ -h)
+ st=0; break
+ ;;
+ -*)
+ st=1; break
+ ;;
+ *)
+ if [ -n "$name" ]; then
+ st=1
+ else
+ st=""; name="$1"
+ fi
+ ;;
+ esac
+ shift
+done
+
+if [ -n "$st" ]; then
+ echo "Usage: `basename "$0"` NAME (normally invoked by \"conda install\")"
+ exit $st
fi
-if [ -z "$PREFIX" -o ! -d "$PREFIX" ]; then
- echo "ERROR: \$PREFIX not set/found (script should be invoked by"\
- "\"conda install\")" >&2
+# If the shell environment isn't configured by "conda install" as expected, try
+# falling back to Anaconda's run-time path variables to support user invocation.
+if [ -z "$PREFIX" ]; then
+ if [ -n "$CONDA_PREFIX" ]; then
+ export PREFIX="$CONDA_PREFIX" # new convention
+ elif [ -n "$CONDA_ENV_PATH" ]; then
+ export PREFIX="$CONDA_ENV_PATH" # old convention
+ else
+ echo "ERROR: conda environment not configured (source activate?)" >&2
+ exit 1
+ fi
+ inst=0 # report success to user
+else
+ inst=1 # report success to "conda install" via hidden file convention
+fi
+if [ ! -d "$PREFIX" -o ! -w "$PREFIX" ]; then
+ echo "ERROR: cannot write to directory $PREFIX" >&2
exit 1
fi
-# The Python script for updating extern.pkg must be invoked in the following
-# way because conda insists on mangling its interpreter path and does not put
-# it back to something functional before the post install step happens :-(.
-# Both the LSB and MacOS define Python in /usr/bin as standard (used to avoid
-# dependence on the state of the Anaconda environment during installation).
+# The Python script for updating extern.pkg must be invoked as follows because
+# (if directly executable) conda insists on changing its interpreter path to
+# one in the env that may not exist, since IRAF packages do not require python
+# :-(. The conda build docs also explicitly disallow post-install scripts from
+# depending on other packages. Both the LSB and MacOS define Python in /usr/bin
+# as standard, avoiding any dependence on the state of the installation.
-if /usr/bin/python "$script_dir/ac_update_extern_pkg" "$PREFIX" $name; then
- echo "Updated extern.pkg file" >> "$PREFIX/.messages.txt"
+if /usr/bin/python "$script_dir/ac_update_extern_pkg" "$PREFIX" "$name"; then
+ if [ $inst = 1 ]; then
+ echo "Updated extern.pkg file" >> "$PREFIX/.messages.txt"
+ else
+ echo "Updated extern.pkg file"
+ fi
else
echo "ERROR: failed to update extern.pkg" >&2
exit 1