From 933e8663ad7b2adc41c158fd2c765eef2334baca Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 20 Feb 2018 17:44:40 -0500 Subject: [PATCH] openjdk: Clean up platform conditionals --- pkgs/development/compilers/openjdk/8.nix | 4 +-- .../compilers/openjdk/bootstrap.nix | 29 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pkgs/development/compilers/openjdk/8.nix b/pkgs/development/compilers/openjdk/8.nix index b74c8a47dde..24cf1b8a0c9 100644 --- a/pkgs/development/compilers/openjdk/8.nix +++ b/pkgs/development/compilers/openjdk/8.nix @@ -14,9 +14,9 @@ let * The JRE libraries are in directories that depend on the CPU. */ architecture = - if stdenv.system == "i686-linux" then + if stdenv.hostPlatform.system == "i686-linux" then "i386" - else if stdenv.system == "x86_64-linux" then + else if stdenv.hostPlatform.system == "x86_64-linux" then "amd64" else throw "openjdk requires i686-linux or x86_64 linux"; diff --git a/pkgs/development/compilers/openjdk/bootstrap.nix b/pkgs/development/compilers/openjdk/bootstrap.nix index 48a22638813..38171c4d3fe 100644 --- a/pkgs/development/compilers/openjdk/bootstrap.nix +++ b/pkgs/development/compilers/openjdk/bootstrap.nix @@ -1,11 +1,14 @@ -{ stdenv, runCommand, glibc, fetchurl, file +{ stdenv +, runCommand, fetchurl, file , version }: +assert stdenv.hostPlatform.libc == "glibc"; + let # !!! These should be on nixos.org - src = if glibc.system == "x86_64-linux" then + src = if stdenv.hostPlatform.system == "x86_64-linux" then (if version == "8" then fetchurl { url = "https://www.dropbox.com/s/a0lsq2ig4uguky5/openjdk8-bootstrap-x86_64-linux.tar.xz?dl=1"; @@ -17,7 +20,7 @@ let sha256 = "024gg2sgg4labxbc1nhn8lxls2p7d9h3b82hnsahwaja2pm1hbra"; } else throw "No bootstrap for version") - else if glibc.system == "i686-linux" then + else if stdenv.hostPlatform.system == "i686-linux" then (if version == "8" then fetchurl { url = "https://www.dropbox.com/s/rneqjhlerijsw74/openjdk8-bootstrap-i686-linux.tar.xz?dl=1"; @@ -39,22 +42,18 @@ let LIBDIRS="$(find $out -name \*.so\* -exec dirname {} \; | sort | uniq | tr '\n' ':')" - for i in $out/bin/*; do - patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $i || true - patchelf --set-rpath "${glibc.out}/lib:$LIBDIRS" $i || true - done - - find $out -name \*.so\* | while read lib; do - patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $lib || true - patchelf --set-rpath "${glibc.out}/lib:${stdenv.cc.cc.lib}/lib:$LIBDIRS" $lib || true + find "$out" -type f -print0 | while IFS= read -r -d "" elf; do + isELF "$elf" || continue + patchelf --set-interpreter $(cat "${stdenv.cc}/nix-support/dynamic-linker") "$elf" || true + patchelf --set-rpath "${stdenv.cc.libc}/lib:$LIBDIRS" "$elf" || true done # Temporarily, while NixOS's OpenJDK bootstrap tarball doesn't have PaX markings: - exes=$(${file}/bin/file $out/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//') - for file in $exes; do - paxmark m "$file" + find "$out/bin" -type f -print0 | while IFS= read -r -d "" elf; do + isELF "$elf" || continue + paxmark m "$elf" # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well. - ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''} + ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$elf"''} done ''; in bootstrap