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: a25b39f2f261
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8ed475b31ef3
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Oct 15, 2019

  1. Backport pull request #69131 from xzfc/subshells

    Avoid using subshells
    
    (cherry picked from commit 268d510)
    
    #69131
    matthewbauer committed Oct 15, 2019
    Copy the full SHA
    2d81865 View commit details

Commits on Oct 16, 2019

  1. Merge pull request #71196 from matthewbauer/avoid-subshells-19-09

    Backport pull request #69131 from xzfc/subshells
    matthewbauer authored Oct 16, 2019
    Copy the full SHA
    d3a928f View commit details

Commits on Oct 21, 2019

  1. Copy the full SHA
    8ed475b View commit details
Showing with 46 additions and 40 deletions.
  1. +4 −4 pkgs/build-support/bintools-wrapper/setup-hook.sh
  2. +42 −36 pkgs/stdenv/generic/setup.sh
8 changes: 4 additions & 4 deletions pkgs/build-support/bintools-wrapper/setup-hook.sh
Original file line number Diff line number Diff line change
@@ -24,7 +24,8 @@ bintoolsWrapper_addLDVars () {
# Python and Haskell packages often only have directories like $out/lib/ghc-8.4.3/ or
# $out/lib/python3.6/, so having them in LDFLAGS just makes the linker search unnecessary
# directories and bloats the size of the environment variable space.
if [[ -n "$(echo $1/lib/lib*)" ]]; then
local -a glob=( $1/lib/lib* )
if [ "${#glob[*]}" -gt 0 ]; then
export NIX_${role_pre}LDFLAGS+=" -L$1/lib"
fi
fi
@@ -61,9 +62,8 @@ do
if
PATH=$_PATH type -p "@targetPrefix@${cmd}" > /dev/null
then
upper_case="$(echo "$cmd" | tr "[:lower:]" "[:upper:]")"
export "${role_pre}${upper_case}=@targetPrefix@${cmd}";
export "${upper_case}${role_post}=@targetPrefix@${cmd}";
export "${role_pre}${cmd^^}=@targetPrefix@${cmd}";
export "${cmd^^}${role_post}=@targetPrefix@${cmd}";
fi
done

78 changes: 42 additions & 36 deletions pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@ 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="$(shopt -po nounset)"
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set -u # May be called from elsewhere, so do `set -u`.

local hookName="$1"
@@ -32,15 +33,16 @@ runHook() {
set -u # To balance `_eval`
done

eval "${oldOpts}"
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="$(shopt -po nounset)"
local oldOpts="-u"
shopt -qo nounset || oldOpts="+u"
set -u # May be called from elsewhere, so do `set -u`.

local hookName="$1"
@@ -57,7 +59,7 @@ runOneHook() {
set -u # To balance `_eval`
done

eval "${oldOpts}"
set "$oldOpts"
return "$ret"
}

@@ -71,21 +73,18 @@ _callImplicitHook() {
set -u
local def="$1"
local hookName="$2"
case "$(type -t "$hookName")" in
(function|alias|builtin)
set +u
"$hookName";;
(file)
set +u
source "$hookName";;
(keyword) :;;
(*) if [ -z "${!hookName:-}" ]; then
return "$def";
else
set +u
eval "${!hookName}"
fi;;
esac
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"
fi
# `_eval` expects hook to need nounset disable and leave it
# disabled anyways, so Ok to to delegate. The alternative of a
# return trap is no good because it would affect nested returns.
@@ -96,7 +95,7 @@ _callImplicitHook() {
# hooks exits the hook, not the caller. Also will only pass args if
# command can take them
_eval() {
if [ "$(type -t "$1")" = function ]; then
if declare -F "$1" > /dev/null 2>&1; then
set +u
"$@" # including args
else
@@ -389,14 +388,15 @@ findInputs() {
# The current package's host and target offset together
# provide a <=-preserving homomorphism from the relative
# offsets to current offset
local -i mapOffsetResult
function mapOffset() {
local -ri inputOffset="$1"
if (( "$inputOffset" <= 0 )); then
local -ri outputOffset="$inputOffset + $hostOffset"
else
local -ri outputOffset="$inputOffset - 1 + $targetOffset"
fi
echo "$outputOffset"
mapOffsetResult="$outputOffset"
}

# Host offset relative to that of the package whose immediate
@@ -408,8 +408,8 @@ findInputs() {

# Host offset relative to the package currently being
# built---as absolute an offset as will be used.
local -i hostOffsetNext
hostOffsetNext="$(mapOffset relHostOffset)"
mapOffset relHostOffset
local -i hostOffsetNext="$mapOffsetResult"

# Ensure we're in bounds relative to the package currently
# being built.
@@ -427,8 +427,8 @@ findInputs() {

# Target offset relative to the package currently being
# built.
local -i targetOffsetNext
targetOffsetNext="$(mapOffset relTargetOffset)"
mapOffset relTargetOffset
local -i targetOffsetNext="$mapOffsetResult"

# Once again, ensure we're in bounds relative to the
# package currently being built.
@@ -437,7 +437,8 @@ findInputs() {
[[ -f "$pkg/nix-support/$file" ]] || continue

local pkgNext
for pkgNext in $(< "$pkg/nix-support/$file"); do
read -r -d '' pkgNext < "$pkg/nix-support/$file" || true
for pkgNext in $pkgNext; do
findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"
done
done
@@ -488,10 +489,11 @@ activatePackage() {
(( "$hostOffset" <= "$targetOffset" )) || exit -1

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

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

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

@@ -1261,17 +1264,19 @@ showPhaseHeader() {

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

@@ -1301,10 +1306,11 @@ genericBuild() {

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

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