common setup hooks: set -u robustness

Explicitly handle `dont*` and friends not being defined.
wip/yesman
John Ericson 5 years ago
parent d901b961a9
commit 43a98868ae
  1. 2
      pkgs/build-support/setup-hooks/audit-tmpdir.sh
  2. 2
      pkgs/build-support/setup-hooks/compress-man-pages.sh
  3. 2
      pkgs/build-support/setup-hooks/move-lib64.sh
  4. 2
      pkgs/build-support/setup-hooks/move-sbin.sh
  5. 6
      pkgs/build-support/setup-hooks/multiple-outputs.sh
  6. 2
      pkgs/build-support/setup-hooks/prune-libtool-files.sh
  7. 4
      pkgs/build-support/setup-hooks/strip.sh

@ -7,7 +7,7 @@
# 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,4 +1,4 @@
fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi')
fixupOutputHooks+=('if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi')
compressManPages() {
local dir="$1"

@ -8,7 +8,7 @@
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

@ -5,7 +5,7 @@
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

@ -9,8 +9,8 @@ _assignFirst() {
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!"
@ -19,7 +19,7 @@ _assignFirst() {
# Same as _assignFirst, but only if "$1" = ""
_overrideFirst() {
if [ -z "${!1}" ]; then
if [ -z "${!1-}" ]; then
_assignFirst "$@"
fi
}

@ -8,7 +8,7 @@
fixupOutputHooks+=(_pruneLibtoolFiles)
_pruneLibtoolFiles() {
if [ "$dontPruneLibtoolFiles" ] || [ ! -e "$prefix" ]; then
if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then
return
fi

@ -10,7 +10,7 @@ _doStrip() {
local -ra stripCmds=(STRIP TARGET_STRIP)
# Optimization
if [[ "$STRIP" == "$TARGET_STRIP" ]]; then
if [[ "${STRIP-}" == "${TARGET_STRIP-}" ]]; then
dontStripTarget+=1
fi
@ -20,7 +20,7 @@ _doStrip() {
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}

Loading…
Cancel
Save