at 18.03-beta 60 lines 2.3 kB view raw
1{ stdenv, runCommand, glibc, fetchurl, file 2 3, version 4}: 5 6let 7 # !!! These should be on nixos.org 8 src = if glibc.system == "x86_64-linux" then 9 (if version == "8" then 10 fetchurl { 11 url = "https://www.dropbox.com/s/a0lsq2ig4uguky5/openjdk8-bootstrap-x86_64-linux.tar.xz?dl=1"; 12 sha256 = "18zqx6jhm3lizn9hh6ryyqc9dz3i96pwaz8f6nxfllk70qi5gvks"; 13 } 14 else if version == "7" then 15 fetchurl { 16 url = "https://www.dropbox.com/s/rssfbeommrfbsjf/openjdk7-bootstrap-x86_64-linux.tar.xz?dl=1"; 17 sha256 = "024gg2sgg4labxbc1nhn8lxls2p7d9h3b82hnsahwaja2pm1hbra"; 18 } 19 else throw "No bootstrap for version") 20 else if glibc.system == "i686-linux" then 21 (if version == "8" then 22 fetchurl { 23 url = "https://www.dropbox.com/s/rneqjhlerijsw74/openjdk8-bootstrap-i686-linux.tar.xz?dl=1"; 24 sha256 = "1yx04xh8bqz7amg12d13rw5vwa008rav59mxjw1b9s6ynkvfgqq9"; 25 } 26 else if version == "7" then 27 fetchurl { 28 url = "https://www.dropbox.com/s/6xe64td7eg2wurs/openjdk7-bootstrap-i686-linux.tar.xz?dl=1"; 29 sha256 = "0xwqjk1zx8akziw8q9sbjc1rs8s7c0w6mw67jdmmi26cwwp8ijnx"; 30 } 31 else throw "No bootstrap for version") 32 else throw "No bootstrap for system"; 33 34 bootstrap = runCommand "openjdk-bootstrap" { 35 passthru.home = "${bootstrap}/lib/openjdk"; 36 } '' 37 tar xvf ${src} 38 mv openjdk-bootstrap $out 39 40 LIBDIRS="$(find $out -name \*.so\* -exec dirname {} \; | sort | uniq | tr '\n' ':')" 41 42 for i in $out/bin/*; do 43 patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $i || true 44 patchelf --set-rpath "${glibc.out}/lib:$LIBDIRS" $i || true 45 done 46 47 find $out -name \*.so\* | while read lib; do 48 patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $lib || true 49 patchelf --set-rpath "${glibc.out}/lib:${stdenv.cc.cc.lib}/lib:$LIBDIRS" $lib || true 50 done 51 52 # Temporarily, while NixOS's OpenJDK bootstrap tarball doesn't have PaX markings: 53 exes=$(${file}/bin/file $out/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//') 54 for file in $exes; do 55 paxmark m "$file" 56 # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well. 57 ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''} 58 done 59 ''; 60in bootstrap