Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cbbcb25e6cdc^
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ffc1416b570c
Choose a head ref
  • 3 commits
  • 9 files changed
  • 1 contributor

Commits on Oct 29, 2019

  1. common setup hooks: set -u robustness

    Explicitly handle `dont*` and friends not being defined.
    Ericson2314 committed Oct 29, 2019
    Copy the full SHA
    cbbcb25 View commit details
  2. stdenv: Don't stop set -u-ing

    Before, we very carefully unapplied and reapplied `set -u` so the rest
    of Nixpkgs could continue to not fail on undefined variables. Let's rip
    off the band-aid.
    Ericson2314 committed Oct 29, 2019
    Copy the full SHA
    f2f4f3f View commit details
  3. bintools-wrapper: Don't stop set -u-ing

    Same justification as previous commit.
    Ericson2314 committed Oct 29, 2019
    Copy the full SHA
    ffc1416 View commit details
7 changes: 0 additions & 7 deletions pkgs/build-support/bintools-wrapper/default.nix
Original file line number Diff line number Diff line change
@@ -111,17 +111,13 @@ stdenv.mkDerivation {

installPhase =
''
set -u
mkdir -p $out/bin $out/nix-support
wrap() {
local dst="$1"
local wrapper="$2"
export prog="$3"
set +u
substituteAll "$wrapper" "$out/bin/$dst"
set -u
chmod +x "$out/bin/$dst"
}
''
@@ -163,8 +159,6 @@ stdenv.mkDerivation {
[[ -e "$underlying" ]] || continue
wrap ${targetPrefix}$variant ${./ld-wrapper.sh} $underlying
done
set +u
'';

emulation = let
@@ -307,7 +301,6 @@ stdenv.mkDerivation {
''

+ ''
set +u
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
2 changes: 1 addition & 1 deletion pkgs/build-support/setup-hooks/audit-tmpdir.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion pkgs/build-support/setup-hooks/compress-man-pages.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fixupOutputHooks+=('if [ -z "$dontGzipMan" ]; then compressManPages "$prefix"; fi')
fixupOutputHooks+=('if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi')

compressManPages() {
local dir="$1"
2 changes: 1 addition & 1 deletion pkgs/build-support/setup-hooks/move-lib64.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pkgs/build-support/setup-hooks/move-sbin.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions pkgs/build-support/setup-hooks/multiple-outputs.sh
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion pkgs/build-support/setup-hooks/prune-libtool-files.sh
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
fixupOutputHooks+=(_pruneLibtoolFiles)

_pruneLibtoolFiles() {
if [ "$dontPruneLibtoolFiles" ] || [ ! -e "$prefix" ]; then
if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then
return
fi

4 changes: 2 additions & 2 deletions pkgs/build-support/setup-hooks/strip.sh
Original file line number Diff line number Diff line change
@@ -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}
45 changes: 3 additions & 42 deletions pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
@@ -17,10 +17,6 @@ fi
# code). The hooks for <hookName> are the shell function or variable
# <hookName>, and the values of the shell array ‘<hookName>Hooks’.
runHook() {
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set -u # May be called from elsewhere, so do `set -u`.

local hookName="$1"
shift
local hooksSlice="${hookName%Hook}Hooks[@]"
@@ -30,21 +26,15 @@ runHook() {
# undefined.
for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do
_eval "$hook" "$@"
set -u # To balance `_eval`
done

set "$oldOpts"
return 0
}


# Run all hooks with the specified name, until one succeeds (returns a
# zero exit code). If none succeed, return a non-zero exit code.
runOneHook() {
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set -u # May be called from elsewhere, so do `set -u`.

local hookName="$1"
shift
local hooksSlice="${hookName%Hook}Hooks[@]"
@@ -56,10 +46,8 @@ runOneHook() {
ret=0
break
fi
set -u # To balance `_eval`
done

set "$oldOpts"
return "$ret"
}

@@ -70,17 +58,13 @@ runOneHook() {
# environment variables) and from shell scripts (as functions). If you
# want to allow multiple hooks, use runHook instead.
_callImplicitHook() {
set -u
local def="$1"
local hookName="$2"
if declare -F "$hookName" > /dev/null; then
set +u
"$hookName"
elif type -p "$hookName" > /dev/null; then
set +u
source "$hookName"
elif [ -n "${!hookName:-}" ]; then
set +u
eval "${!hookName}"
else
return "$def"
@@ -96,13 +80,10 @@ _callImplicitHook() {
# command can take them
_eval() {
if declare -F "$1" > /dev/null 2>&1; then
set +u
"$@" # including args
else
set +u
eval "$1"
fi
# `run*Hook` reenables `set -u`
}


@@ -190,12 +171,12 @@ addToSearchPath() {
# so it is defined here but tried after the hook.
_addRpathPrefix() {
if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then
export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS"
export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}"
if [ -n "${NIX_LIB64_IN_SELF_RPATH:-}" ]; then
export NIX_LDFLAGS="-rpath $1/lib64 $NIX_LDFLAGS"
export NIX_LDFLAGS="-rpath $1/lib64 ${NIX_LDFLAGS-}"
fi
if [ -n "${NIX_LIB32_IN_SELF_RPATH:-}" ]; then
export NIX_LDFLAGS="-rpath $1/lib32 $NIX_LDFLAGS"
export NIX_LDFLAGS="-rpath $1/lib32 ${NIX_LDFLAGS-}"
fi
fi
}
@@ -489,11 +470,7 @@ activatePackage() {
(( "$hostOffset" <= "$targetOffset" )) || exit -1

if [ -f "$pkg" ]; then
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set +u
source "$pkg"
set "$oldOpts"
fi

# Only dependencies whose host platform is guaranteed to match the
@@ -512,11 +489,7 @@ activatePackage() {
fi

if [[ -f "$pkg/nix-support/setup-hook" ]]; then
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set +u
source "$pkg/nix-support/setup-hook"
set "$oldOpts"
fi
}

@@ -1264,19 +1237,11 @@ showPhaseHeader() {

genericBuild() {
if [ -f "${buildCommandPath:-}" ]; then
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set +u
source "$buildCommandPath"
set "$oldOpts"
return
fi
if [ -n "${buildCommand:-}" ]; then
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set +u
eval "$buildCommand"
set "$oldOpts"
return
fi

@@ -1306,11 +1271,7 @@ genericBuild() {

# Evaluate the variable named $curPhase if it exists, otherwise the
# function named $curPhase.
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set +u
eval "${!curPhase:-$curPhase}"
set "$oldOpts"

if [ "$curPhase" = unpackPhase ]; then
cd "${sourceRoot:-.}"