forked from conda/constructor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_install.sh
More file actions
66 lines (57 loc) · 2.24 KB
/
Copy pathpost_install.sh
File metadata and controls
66 lines (57 loc) · 2.24 KB
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
#!/bin/bash
set -euxo pipefail
# the ^u here will cause unbound variables to cause errors
# we use that to test whether these vars are set or not; they should!
echo "Added by post-install script" > "$PREFIX/post_install_sentinel.txt"
echo "INSTALLER_NAME=${INSTALLER_NAME}"
echo "INSTALLER_VER=${INSTALLER_VER}"
echo "INSTALLER_PLAT=${INSTALLER_PLAT}"
echo "INSTALLER_TYPE=${INSTALLER_TYPE}"
echo "INSTALLER_UNATTENDED=${INSTALLER_UNATTENDED}"
echo "CUSTOM_VARIABLE_1=${CUSTOM_VARIABLE_1}"
echo "CUSTOM_VARIABLE_2=${CUSTOM_VARIABLE_2}"
echo "PREFIX=${PREFIX}"
test "${INSTALLER_NAME}" = "Scripts"
test "${INSTALLER_VER}" = "1.0.0"
# shellcheck disable=SC2016 # String interpolation disabling is deliberate
test "${CUSTOM_VARIABLE_1}" = 'FIR$T-CUSTOM_'\''STRING'\'' WITH SPACES AND @*! "CHARACTERS"'
# shellcheck disable=SC2016 # String interpolation disabling is deliberate
test "${CUSTOM_VARIABLE_2}" = '$ECOND-CUSTOM_'\''STRING'\'' WITH SPACES AND @*! "CHARACTERS"'
test "${INSTALLER_UNATTENDED}" = "1"
# Print to stderr if any of the input variables are set, and returns 1 - otherwise 0.
# Note that variables that are set but are empty strings will also trigger an error.
# All input variables are checked before exit.
verify_var_is_unset() {
local failed=0
for var in "$@"; do
if [[ -n "${!var+x}" ]]; then
echo "Error: environment variable $var must be unset." >&2
failed=1
fi
done
return $failed
}
if [[ $(uname -s) == "Linux" ]]; then
if [[ ${INSTALLER_PLAT} != linux-* ]]; then
echo "Error: INSTALLER_PLAT must match 'linux-*' on Linux systems."
exit 1
fi
if ! verify_var_is_unset LD_LIBRARY_PATH LD_PRELOAD LD_AUDIT; then
echo "Error: One or more of LD_LIBRARY_PATH, LD_PRELOAD, or LD_AUDIT are set."
exit 1
fi
else # macOS
if [[ ${INSTALLER_PLAT} != osx-* ]]; then
echo "Error: INSTALLER_PLAT must match 'osx-*' on macOS systems."
exit 1
fi
if ! verify_var_is_unset \
DYLD_LIBRARY_PATH \
DYLD_FALLBACK_LIBRARY_PATH \
DYLD_INSERT_LIBRARIES \
DYLD_FRAMEWORK_PATH; then
echo "Error: One or more DYLD_* environment variables are set."
exit 1
fi
fi
test -f "${PREFIX}/pre_install_sentinel.txt"