blob: 8011797fbfbfc88f54043da2f1c99a730b5a16c8 (
plain) (
blame)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/bin/sh
# Copyright(c) 2016 Association of Universities for Research in Astronomy, Inc.
# A post-install script for AstroConda IRAF packages (to update extern.pkg),
# which gets executed automatically when doing "conda install", but can also be
# run by users to restore broken definitions.
script_dir=`dirname "$0"`
st=1
unset name remove flags
while [ -n "$1" ]; do
case "$1" in
-h)
st=0; break
;;
--remove)
remove=1
;;
-*)
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"` [--remove] NAME " >&2
echo " (normally invoked automatically by \"conda install\")" >&2
echo >&2
exit $st
fi
[ -n "$remove" ] && flags="${flags}${flags:+ }--remove"
# 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
fi
if [ ! -d "$PREFIX" -o ! -w "$PREFIX" ]; then
echo "ERROR: cannot write to directory $PREFIX" >&2
exit 1
fi
# Create any new file with the expected permissions:
umask 022
# Both the LSB and MacOS define Python in /usr/bin as standard, avoiding any
# dependence on the state of the installation. This does not always exist on
# some OSs like Ubuntu, however, so try a couple of other known possibilities
# and default to whatever "python" is found in the PATH if even those fail.
for PYTHON in /usr/bin/python /usr/bin/python2 /usr/bin/python3 python; do
[ -x "$PYTHON" ] && break
done
if [ "$PYTHON" = "python" ]; then
if ! $PYTHON -c "pass"; then
echo "ERROR: cannot execute python (for IRAF package $name)" >&2
exit 1
fi
fi
# 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.
if ! $PYTHON "$script_dir/ac_update_extern_pkg" $flags "$PREFIX" "$name"; then
echo "ERROR: failed to update extern.pkg for $name" >&2
exit 1
fi
|