Skip to content

Commit

Permalink
Merge commit 'ad83979e5986fa3bb0d254c2be9482c12a8743b9' from staging
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Aug 6, 2017
2 parents a5e135e + ad83979 commit 145be4e
Show file tree
Hide file tree
Showing 15 changed files with 486 additions and 144 deletions.
7 changes: 4 additions & 3 deletions pkgs/build-support/buildenv/builder.pl
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ sub addPkg {
my $propagatedFN = "$pkgDir/nix-support/propagated-user-env-packages";
if (-e $propagatedFN) {
open PROP, "<$propagatedFN" or die;
while (my $p = <PROP>) {
chomp $p;
my $propagated = <PROP>;
close PROP;
my @propagated = split ' ', $propagated;
foreach my $p (@propagated) {
$postponed{$p} = 1 unless defined $done{$p};
}
close PROP;
}
}

Expand Down
182 changes: 77 additions & 105 deletions pkgs/build-support/cc-wrapper/ld-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! @shell@ -e
shopt -s nullglob
path_backup="$PATH"
if [ -n "@coreutils_bin@" ]; then
PATH="@coreutils_bin@/bin"
Expand All @@ -20,18 +21,19 @@ expandResponseParams "$@"
if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \
-a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \) ]; then
rest=()
n=0
while [ $n -lt ${#params[*]} ]; do
nParams=${#params[@]}
declare -i n=0
while [ $n -lt $nParams ]; do
p=${params[n]}
p2=${params[$((n+1))]}
if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
skip $p
skip "${p:2}"
elif [ "$p" = -L ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
n+=1; skip "$p2"
elif [ "$p" = -rpath ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
n+=1; skip "$p2"
elif [ "$p" = -dynamic-linker ] && badPath "$p2"; then
n=$((n + 1)); skip $p2
n+=1; skip "$p2"
elif [ "${p:0:1}" = / ] && badPath "$p"; then
# We cannot skip this; barf.
echo "impure path \`$p' used in link" >&2
Expand All @@ -40,17 +42,17 @@ if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \
# Our ld is not built with sysroot support (Can we fix that?)
:
else
rest=("${rest[@]}" "$p")
rest+=("$p")
fi
n=$((n + 1))
n+=1
done
params=("${rest[@]}")
fi

LD=@prog@
source @out@/nix-support/add-hardening.sh

extra=(${hardeningLDFlags[@]})
extra=("${hardeningLDFlags[@]}")
extraBefore=()

if [ -z "$NIX_LDFLAGS_SET" ]; then
Expand All @@ -60,127 +62,97 @@ fi

extra+=($NIX_LDFLAGS_AFTER $NIX_LDFLAGS_HARDEN)


# Add all used dynamic libraries to the rpath.
if [ "$NIX_DONT_SET_RPATH" != 1 ]; then

declare -A libDirsSeen
declare -a libDirs

addToLibPath() {
local path="$1"
if [ "${path:0:1}" != / ]; then return 0; fi
case "$path" in
*..*|*./*|*/.*|*//*)
local path2
if path2=$(readlink -f "$path"); then
path="$path2"
fi
declare -a libDirs
declare -A libs
relocatable=

# Find all -L... switches for rpath, and relocatable flags for build id.
if [ "$NIX_DONT_SET_RPATH" != 1 ] || [ "$NIX_SET_BUILD_ID" = 1 ]; then
prev=
for p in "${params[@]}" "${extra[@]}"; do
case "$prev" in
-L)
libDirs+=("$p")
;;
-l)
libs["lib${p}.so"]=1
;;
-dynamic-linker | -plugin)
# Ignore this argument, or it will match *.so and be added to rpath.
;;
*)
case "$p" in
-L/*)
libDirs+=("${p:2}")
;;
-l?*)
libs["lib${p:2}.so"]=1
;;
"$NIX_STORE"/*.so | "$NIX_STORE"/*.so.*)
# This is a direct reference to a shared library.
libDirs+=("${p%/*}")
libs["${p##*/}"]=1
;;
-r | --relocatable | -i)
relocatable=1
esac
;;
esac
if [[ -z ${libDirsSeen[$path]} ]]; then
libDirs+=("$path")
libDirsSeen[$path]=1
fi
}

declare -A rpathsSeen
declare -a rpaths

addToRPath() {
# If the path is not in the store, don't add it to the rpath.
# This typically happens for libraries in /tmp that are later
# copied to $out/lib. If not, we're screwed.
if [ "${1:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then return 0; fi
if [[ -z ${rpathsSeen[$1]} ]]; then
rpaths+=("$1")
rpathsSeen[$1]=1
fi
}

declare -a libs

# First, find all -L... switches.
allParams=("${params[@]}" ${extra[@]})
n=0
while [ $n -lt ${#allParams[*]} ]; do
p=${allParams[n]}
p2=${allParams[$((n+1))]}
if [ "${p:0:3}" = -L/ ]; then
addToLibPath ${p:2}
elif [ "$p" = -L ]; then
addToLibPath ${p2}
n=$((n + 1))
elif [ "$p" = -l ]; then
libs+=(${p2})
n=$((n + 1))
elif [ "${p:0:2}" = -l ]; then
libs+=(${p:2})
elif [ "$p" = -dynamic-linker ]; then
# Ignore the dynamic linker argument, or it
# will get into the next 'elif'. We don't want
# the dynamic linker path rpath to go always first.
n=$((n + 1))
elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
# This is a direct reference to a shared library, so add
# its directory to the rpath.
path="$(dirname "$p")";
addToRPath "${path}"
fi
n=$((n + 1))
prev="$p"
done
fi


# Second, for each directory in the library search path (-L...),
# Add all used dynamic libraries to the rpath.
if [ "$NIX_DONT_SET_RPATH" != 1 ]; then
# For each directory in the library search path (-L...),
# see if it contains a dynamic library used by a -l... flag. If
# so, add the directory to the rpath.
# It's important to add the rpath in the order of -L..., so
# the link time chosen objects will be those of runtime linking.
for i in ${libDirs[@]}; do
for j in ${libs[@]}; do
if [ -f "$i/lib$j.so" ]; then
addToRPath $i
break
declare -A rpaths
for dir in "${libDirs[@]}"; do
if [[ "$dir" =~ [/.][/.] ]] && dir2=$(readlink -f "$dir"); then
dir="$dir2"
fi
if [ "${rpaths[$dir]}" ] || [[ "$dir" != "$NIX_STORE"/* ]]; then
# If the path is not in the store, don't add it to the rpath.
# This typically happens for libraries in /tmp that are later
# copied to $out/lib. If not, we're screwed.
continue
fi
for path in "$dir"/lib*.so; do
file="${path##*/}"
if [ "${libs[$file]}" ]; then
libs["$file"]=
if [ ! "${rpaths[$dir]}" ]; then
rpaths["$dir"]=1
extra+=(-rpath "$dir")
fi
fi
done
done

# Finally, add `-rpath' switches.
for i in ${rpaths[@]}; do
extra+=(-rpath "$i")
done
fi


# Only add --build-id if this is a final link. FIXME: should build gcc
# with --enable-linker-build-id instead?
if [ "$NIX_SET_BUILD_ID" = 1 ]; then
for p in "${params[@]}"; do
if [ "$p" = "-r" -o "$p" = "--relocatable" -o "$p" = "-i" ]; then
relocatable=1
break
fi
done
if [ -z "$relocatable" ]; then
extra+=(--build-id)
fi
if [ "$NIX_SET_BUILD_ID" = 1 ] && [ ! "$relocatable" ]; then
extra+=(--build-id)
fi


# Optionally print debug info.
if [ -n "$NIX_DEBUG" ]; then
echo "original flags to @prog@:" >&2
for i in "${params[@]}"; do
echo " $i" >&2
done
echo "extra flags to @prog@:" >&2
for i in ${extra[@]}; do
echo " $i" >&2
done
echo "original flags to @prog@:" >&2
printf " %q\n" "${params[@]}" >&2
echo "extra flags to @prog@:" >&2
printf " %q\n" "${extraBefore[@]}" "${extra[@]}" >&2
fi

if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_LD_WRAPPER_EXEC_HOOK"
fi

PATH="$path_backup"
exec @prog@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
exec @prog@ "${extraBefore[@]}" "${params[@]}" "${extra[@]}"
3 changes: 2 additions & 1 deletion pkgs/build-support/fetchurl/boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ let mirrors = import ./mirrors.nix; in
{ url ? builtins.head urls
, urls ? []
, sha256
, name ? baseNameOf (toString url)
}:

import <nix/fetchurl.nix> {
inherit system sha256;
inherit system sha256 name;

url =
# Handle mirror:// URIs. Since <nix/fetchurl.nix> currently
Expand Down
17 changes: 17 additions & 0 deletions pkgs/build-support/trivial-builders.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ rec {
, text
, executable ? false # run chmod +x ?
, destination ? "" # relative path appended to $out eg "/bin/foo"
, checkPhase ? "" # syntax checks, e.g. for scripts
}:
runCommand name
{ inherit text executable;
Expand All @@ -44,6 +45,8 @@ rec {
echo -n "$text" > "$n"
fi
${checkPhase}
(test -n "$executable" && chmod +x "$n") || true
'';

Expand All @@ -54,6 +57,20 @@ rec {
writeScript = name: text: writeTextFile {inherit name text; executable = true;};
writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";};

# Create a Shell script, check its syntax
writeShellScriptBin = name : text :
writeTextFile {
inherit name;
executable = true;
destination = "/bin/${name}";
text = ''
#!${stdenv.shell}
${text}
'';
checkPhase = ''
${stdenv.shell} -n $out
'';
};

# Create a forest of symlinks to the files in `paths'.
symlinkJoin =
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/interpreters/python/wrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ wrapPythonProgramsIn() {
# above. The script will set PYTHONPATH and PATH variables.!
# (see pkgs/build-support/setup-hooks/make-wrapper.sh)
local -a wrap_args=("$f"
--prefix PATH ':' "$program_PATH")
--prefix PATH ':' "$program_PATH"
--set PYTHONNOUSERSITE "true"
)

# Add any additional arguments provided by makeWrapperArgs
# argument to buildPythonPackage.
Expand Down
32 changes: 17 additions & 15 deletions pkgs/development/interpreters/python/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# Create a python executable that knows about additional packages.
let
recursivePthLoader = import ../../python-modules/recursive-pth-loader/default.nix { stdenv = stdenv; python = python; };
env = (
let
env = let
paths = stdenv.lib.closePropagation (extraLibs ++ [ python recursivePthLoader ] ) ;
in buildEnv {
name = "${python.name}-env";
Expand All @@ -29,26 +28,29 @@ let
for prg in *; do
if [ -f "$prg" ]; then
rm -f "$out/bin/$prg"
makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out"
makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out" --set PYTHONNOUSERSITE "true"
fi
done
fi
done
'' + postBuild;

passthru.env = stdenv.mkDerivation {
name = "interactive-${python.name}-environment";
nativeBuildInputs = [ env ];
inherit (python) meta;

passthru = python.passthru // {
interpreter = "${env}/bin/${python.executable}";
inherit python;
env = stdenv.mkDerivation {
name = "interactive-${python.name}-environment";
nativeBuildInputs = [ env ];

buildCommand = ''
echo >&2 ""
echo >&2 "*** Python 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
echo >&2 ""
exit 1
'';
buildCommand = ''
echo >&2 ""
echo >&2 "*** Python 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
echo >&2 ""
exit 1
'';
};
};
}) // {
inherit python;
inherit (python) meta;
};
in env
4 changes: 2 additions & 2 deletions pkgs/development/libraries/avahi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ assert qt4Support -> qt4 != null;

stdenv.mkDerivation rec {
name = "avahi-${version}";
version = "0.6.32";
version = "0.7";

src = fetchurl {
url = "https://github.com/lathiat/avahi/releases/download/v${version}/avahi-${version}.tar.gz";
sha256 = "0m5l3ny9i2z1l27y4wm731c0zdkmfn6l1szbajx0ljjiblc92jfm";
sha256 = "0128n7jlshw4bpx0vg8lwj8qwdisjxi7mvniwfafgnkzzrfrpaap";
};

patches = [ ./no-mkdir-localstatedir.patch ];
Expand Down

0 comments on commit 145be4e

Please sign in to comment.