common setup hooks: set -u robustness

Explicitly handle `dont*` and friends not being defined.

+1 -1
pkgs/build-support/setup-hooks/audit-tmpdir.sh
···
# the moment that would produce too many spurious errors (e.g. debug
# info or assertion messages that refer to $TMPDIR).
-
fixupOutputHooks+=('if [ -z "$noAuditTmpdir" -a -e "$prefix" ]; then auditTmpdir "$prefix"; fi')
+
fixupOutputHooks+=('if [[ -z "${noAuditTmpdir-}" && -e "$prefix" ]]; then auditTmpdir "$prefix"; fi')
auditTmpdir() {
local dir="$1"
+1 -1
pkgs/build-support/setup-hooks/compress-man-pages.sh
···
-
fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi')
+
fixupOutputHooks+=('if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi')
compressManPages() {
local dir="$1"
+1 -1
pkgs/build-support/setup-hooks/move-lib64.sh
···
fixupOutputHooks+=(_moveLib64)
_moveLib64() {
-
if [ "$dontMoveLib64" = 1 ]; then return; fi
+
if [ "${dontMoveLib64-}" = 1 ]; then return; fi
if [ ! -e "$prefix/lib64" -o -L "$prefix/lib64" ]; then return; fi
echo "moving $prefix/lib64/* to $prefix/lib"
mkdir -p $prefix/lib
+1 -1
pkgs/build-support/setup-hooks/move-sbin.sh
···
fixupOutputHooks+=(_moveSbin)
_moveSbin() {
-
if [ "$dontMoveSbin" = 1 ]; then return; fi
+
if [ "${dontMoveSbin-}" = 1 ]; then return; fi
if [ ! -e "$prefix/sbin" -o -L "$prefix/sbin" ]; then return; fi
echo "moving $prefix/sbin/* to $prefix/bin"
mkdir -p $prefix/bin
+3 -3
pkgs/build-support/setup-hooks/multiple-outputs.sh
···
local varName="$1"
local REMOVE=REMOVE # slightly hacky - we allow REMOVE (i.e. not a variable name)
shift
-
while [ $# -ge 1 ]; do
-
if [ -n "${!1}" ]; then eval "${varName}"="$1"; return; fi
+
while (( $# )); do
+
if [ -n "${!1-}" ]; then eval "${varName}"="$1"; return; fi
shift
done
echo "Error: _assignFirst found no valid variant!"
···
# Same as _assignFirst, but only if "$1" = ""
_overrideFirst() {
-
if [ -z "${!1}" ]; then
+
if [ -z "${!1-}" ]; then
_assignFirst "$@"
fi
}
+1 -1
pkgs/build-support/setup-hooks/prune-libtool-files.sh
···
fixupOutputHooks+=(_pruneLibtoolFiles)
_pruneLibtoolFiles() {
-
if [ "$dontPruneLibtoolFiles" ] || [ ! -e "$prefix" ]; then
+
if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then
return
fi
+2 -2
pkgs/build-support/setup-hooks/strip.sh
···
local -ra stripCmds=(STRIP TARGET_STRIP)
# Optimization
-
if [[ "$STRIP" == "$TARGET_STRIP" ]]; then
+
if [[ "${STRIP-}" == "${TARGET_STRIP-}" ]]; then
dontStripTarget+=1
fi
···
local -n stripCmd="${stripCmds[$i]}"
# `dontStrip` disables them all
-
if [[ "$dontStrip" || "$flag" ]] || ! type -f "$stripCmd" 2>/dev/null
+
if [[ "${dontStrip-}" || "${flag-}" ]] || ! type -f "${stripCmd-}" 2>/dev/null
then continue; fi
stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}