openjdk: boostrap with adoptopenjdk-bin and cleanup

This allows OpenJDK 11 to build for armv6l, armv7l and aarch64, and OpenJDK 8 to
build for aarch64.
This commit is contained in:
Ben Wolsieffer 2019-07-21 15:41:44 -04:00
parent ded7ec067f
commit de5e65ad80
4 changed files with 188 additions and 209 deletions
pkgs
development/compilers/openjdk
top-level

View File

@ -1,42 +1,33 @@
{ stdenv, lib, fetchurl, bash, cpio, autoconf, pkgconfig, file, which, unzip, zip, cups, freetype { stdenv, lib, fetchurl, bash, pkgconfig, autoconf, cpio, file, which, unzip
, alsaLib, bootjdk, perl, fontconfig, zlib, lndir , zip, perl, cups, freetype, alsaLib, libjpeg, giflib, libpng, zlib, lcms2
, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr , libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama
, libjpeg, giflib , libXcursor, libXrandr, fontconfig, openjdk11-bootstrap
, setJavaClassPath , setJavaClassPath
, minimal ? false , headless ? false
, enableJavaFX ? true, openjfx , enableJavaFX ? openjfx.meta.available, openjfx
, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf , enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf
}: }:
let let
/**
* The JDK libraries are in directories that depend on the CPU.
*/
architecture =
if stdenv.hostPlatform.system == "i686-linux" then
"i386"
else "amd64";
major = "11"; major = "11";
update = ".0.3"; update = ".0.3";
build = "ga"; build = "ga";
repover = "jdk-${major}${update}-${build}";
openjdk = stdenv.mkDerivation { openjdk = stdenv.mkDerivation rec {
name = "openjdk-${major}${update}-${build}"; pname = "openjdk" + lib.optionalString headless "-headless";
version = "${major}${update}-${build}";
src = fetchurl { src = fetchurl {
url = "http://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/${repover}.tar.gz"; url = "http://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/jdk-${version}.tar.gz";
sha256 = "1v6pam38iidlhz46046h17hf5kki6n3kl302awjcyxzk7bmkvb8x"; sha256 = "1v6pam38iidlhz46046h17hf5kki6n3kl302awjcyxzk7bmkvb8x";
}; };
nativeBuildInputs = [ pkgconfig ]; nativeBuildInputs = [ pkgconfig autoconf ];
buildInputs = [ buildInputs = [
autoconf cpio file which unzip zip perl bootjdk zlib cups freetype alsaLib cpio file which unzip zip perl zlib cups freetype alsaLib libjpeg giflib
libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst libpng zlib lcms2 libX11 libICE libXrender libXext libXtst libXt libXtst
libXi libXinerama libXcursor libXrandr lndir fontconfig libXi libXinerama libXcursor libXrandr fontconfig openjdk11-bootstrap
] ++ lib.optionals (!minimal && enableGnome2) [ ] ++ lib.optionals (!headless && enableGnome2) [
gtk3 gnome_vfs GConf glib gtk3 gnome_vfs GConf glib
]; ];
@ -45,66 +36,60 @@ let
./read-truststore-from-env-jdk10.patch ./read-truststore-from-env-jdk10.patch
./currency-date-range-jdk10.patch ./currency-date-range-jdk10.patch
./increase-javadoc-heap.patch ./increase-javadoc-heap.patch
] ++ lib.optionals (!minimal && enableGnome2) [ ] ++ lib.optionals (!headless && enableGnome2) [
./swing-use-gtk-jdk10.patch ./swing-use-gtk-jdk10.patch
]; ];
preConfigure = '' preConfigure = ''
chmod +x configure chmod +x configure
substituteInPlace configure --replace /bin/bash "${bash}/bin/bash" substituteInPlace configure --replace /bin/bash "${bash}/bin/bash"
configureFlagsArray=(
"--with-boot-jdk=${bootjdk.home}"
"--with-update-version=${major}${update}"
"--with-build-number=${build}"
"--with-milestone=fcs"
"--enable-unlimited-crypto"
"--disable-debug-symbols"
"--with-zlib=system"
"--with-giflib=system"
"--with-stdc++lib=dynamic"
# glibc 2.24 deprecated readdir_r so we need this
# See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html
"--with-extra-cflags=-Wno-error=deprecated-declarations -Wno-error=format-contains-nul -Wno-error=unused-result"
''
+ lib.optionalString (architecture == "amd64") " \"--with-jvm-features=zgc\""
+ lib.optionalString minimal " \"--enable-headless-only\""
+ lib.optionalString (!minimal && enableJavaFX) " \"--with-import-modules=${openjfx}\""
+ ");"
# https://bugzilla.redhat.com/show_bug.cgi?id=1306558
# https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716
+ stdenv.lib.optionalString stdenv.cc.isGNU ''
NIX_CFLAGS_COMPILE+=" -fno-lifetime-dse -fno-delete-null-pointer-checks -std=gnu++98 -Wno-error"
''; '';
NIX_LDFLAGS= lib.optionals (!minimal) [ configureFlags = [
"--with-boot-jdk=${openjdk11-bootstrap.home}"
"--enable-unlimited-crypto"
"--with-native-debug-symbols=internal"
"--with-libjpeg=system"
"--with-giflib=system"
"--with-libpng=system"
"--with-zlib=system"
"--with-lcms=system"
"--with-stdc++lib=dynamic"
] ++ lib.optional stdenv.isx86_64 "--with-jvm-features=zgc"
++ lib.optional headless "--enable-headless-only"
++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}";
separateDebugInfo = true;
NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
NIX_LDFLAGS = lib.optionals (!headless) [
"-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic"
] ++ lib.optionals (!minimal && enableGnome2) [ ] ++ lib.optionals (!headless && enableGnome2) [
"-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2" "-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
]; ];
buildFlags = [ "all" ]; buildFlags = [ "all" ];
installPhase = '' installPhase = ''
mkdir -p $out/lib/openjdk $out/share mkdir -p $out/lib
cp -av build/*/images/jdk/* $out/lib/openjdk mv build/*/images/jdk $out/lib/openjdk
# Remove some broken manpages. # Remove some broken manpages.
rm -rf $out/lib/openjdk/man/ja* rm -rf $out/lib/openjdk/man/ja*
# Mirror some stuff in top-level. # Mirror some stuff in top-level.
mkdir $out/include $out/share/man mkdir -p $out/share
ln -s $out/lib/openjdk/include/* $out/include/ ln -s $out/lib/openjdk/include $out/include
ln -s $out/lib/openjdk/man/* $out/share/man/ ln -s $out/lib/openjdk/man $out/share/man
# jni.h expects jni_md.h to be in the header search path. # jni.h expects jni_md.h to be in the header search path.
ln -s $out/include/linux/*_md.h $out/include/ ln -s $out/include/linux/*_md.h $out/include/
# Remove crap from the installation. # Remove crap from the installation.
rm -rf $out/lib/openjdk/demo rm -rf $out/lib/openjdk/demo
${lib.optionalString minimal '' ${lib.optionalString headless ''
rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so
''} ''}
@ -129,11 +114,12 @@ let
# Build the set of output library directories to rpath against # Build the set of output library directories to rpath against
LIBDIRS="" LIBDIRS=""
for output in $outputs; do for output in $outputs; do
if [ "$output" = debug ]; then continue; fi
LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS" LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS"
done done
# Add the local library paths to remove dependencies on the bootstrap # Add the local library paths to remove dependencies on the bootstrap
for output in $outputs; do for output in $outputs; do
if [ "$output" = debug ]; then continue; fi
OUTPUTDIR=$(eval echo \$$output) OUTPUTDIR=$(eval echo \$$output)
BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)
echo "$BINLIBS" | while read i; do echo "$BINLIBS" | while read i; do
@ -141,26 +127,20 @@ let
patchelf --shrink-rpath "$i" || true patchelf --shrink-rpath "$i" || true
done done
done done
# Test to make sure that we don't depend on the bootstrap
for output in $outputs; do
if grep -q -r '${bootjdk}' $(eval echo \$$output); then
echo "Extraneous references to ${bootjdk} detected"
exit 1
fi
done
''; '';
disallowedReferences = [ openjdk11-bootstrap ];
meta = with stdenv.lib; { meta = with stdenv.lib; {
homepage = http://openjdk.java.net/; homepage = http://openjdk.java.net/;
license = licenses.gpl2; license = licenses.gpl2;
description = "The open-source Java Development Kit"; description = "The open-source Java Development Kit";
maintainers = with maintainers; [ edwtjo ]; maintainers = with maintainers; [ edwtjo ];
platforms = ["i686-linux" "x86_64-linux"]; platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux" ];
}; };
passthru = { passthru = {
inherit architecture; architecture = "";
home = "${openjdk}/lib/openjdk"; home = "${openjdk}/lib/openjdk";
}; };
}; };

View File

@ -1,9 +1,10 @@
{ stdenv, lib, fetchurl, bash, cpio, pkgconfig, file, which, unzip, zip, cups, freetype { stdenv, lib, fetchurl, bash, cpio, pkgconfig, file, which, unzip, zip, cups, freetype
, alsaLib, bootjdk, cacert, perl, liberation_ttf, fontconfig, zlib, lndir , alsaLib, cacert, perl, liberation_ttf, fontconfig, zlib
, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr , libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr
, libjpeg, giflib , libjpeg, giflib
, openjdk8-bootstrap
, setJavaClassPath , setJavaClassPath
, minimal ? false , headless ? false
, enableInfinality ? true # font rendering patch , enableInfinality ? true # font rendering patch
, enableGnome2 ? true, gtk2, gnome_vfs, glib, GConf , enableGnome2 ? true, gtk2, gnome_vfs, glib, GConf
}: }:
@ -13,52 +14,71 @@ let
/** /**
* The JRE libraries are in directories that depend on the CPU. * The JRE libraries are in directories that depend on the CPU.
*/ */
architecture = architecture = {
if stdenv.hostPlatform.system == "i686-linux" then "i686-linux" = "i386";
"i386" "x86_64-linux" = "amd64";
else if stdenv.hostPlatform.system == "x86_64-linux" then "aarch64-linux" = "aarch64";
"amd64" }.${stdenv.system} or (throw "Unsupported platform");
else
throw "openjdk requires i686-linux or x86_64 linux";
update = "212"; update = "212";
build = "ga"; build = if stdenv.isAarch64 then "b04"
baseurl = "http://hg.openjdk.java.net/jdk8u/jdk8u"; else "ga";
repover = "jdk8u${update}-${build}"; baseurl = if stdenv.isAarch64 then "https://hg.openjdk.java.net/aarch64-port/jdk8u-shenandoah"
else "https://hg.openjdk.java.net/jdk8u/jdk8u";
repover = lib.optionalString stdenv.isAarch64 "aarch64-shenandoah-"
+ "jdk8u${update}-${build}";
jdk8 = fetchurl { jdk8 = fetchurl {
name = "jdk8-${repover}.tar.gz";
url = "${baseurl}/archive/${repover}.tar.gz"; url = "${baseurl}/archive/${repover}.tar.gz";
sha256 = "00rl33h4cl4b4p3hcid765h38x2jdkb14ylh8k1zhnd0ka76crgg"; sha256 = if stdenv.isAarch64 then "0z2n2b5f1jmdzycb7ppqz3dx5sf1rwwd3fvk15zq4cm7908wapjw"
else "00rl33h4cl4b4p3hcid765h38x2jdkb14ylh8k1zhnd0ka76crgg";
}; };
langtools = fetchurl { langtools = fetchurl {
name = "langtools-${repover}.tar.gz";
url = "${baseurl}/langtools/archive/${repover}.tar.gz"; url = "${baseurl}/langtools/archive/${repover}.tar.gz";
sha256 = "0va6g2dccf1ph6mpwxswbks5axp7zz258cl89qq9r8jn4ni04agw"; sha256 = if stdenv.isAarch64 then "0j0fbxj7fkl8bn8lq3s3sssa26hskaf8c9rmsay8r91m4vnxisv1"
else "0va6g2dccf1ph6mpwxswbks5axp7zz258cl89qq9r8jn4ni04agw";
}; };
hotspot = fetchurl { hotspot = fetchurl {
name = "hotspot-${repover}.tar.gz";
url = "${baseurl}/hotspot/archive/${repover}.tar.gz"; url = "${baseurl}/hotspot/archive/${repover}.tar.gz";
sha256 = "0sgr9df10hs49pjld6c6kr374v4zwd9s52pc3drz68zrlk71ja4s"; sha256 = if stdenv.isAarch64 then "1ld76jx0v1z6755a61k5da0cks7dqwvwc5l8rvyw9r9py1n7421w"
else "0sgr9df10hs49pjld6c6kr374v4zwd9s52pc3drz68zrlk71ja4s";
}; };
corba = fetchurl { corba = fetchurl {
name = "corba-${repover}.tar.gz";
url = "${baseurl}/corba/archive/${repover}.tar.gz"; url = "${baseurl}/corba/archive/${repover}.tar.gz";
sha256 = "1hq0sr4k4k4iv815kg72i9lvd7n7mn5pmw96ckk9p1rnyagn9z03"; sha256 = if stdenv.isAarch64 then "1jcw90y3d8rnvqpiyyvsx976f5i8d60p0d6652v4mz41pyjjhyw5"
else "1hq0sr4k4k4iv815kg72i9lvd7n7mn5pmw96ckk9p1rnyagn9z03";
}; };
jdk = fetchurl { jdk = fetchurl {
name = "jdk-${repover}.tar.gz";
url = "${baseurl}/jdk/archive/${repover}.tar.gz"; url = "${baseurl}/jdk/archive/${repover}.tar.gz";
sha256 = "1fc59jrbfq8l067mggzy5dnrvni7lwaqd7hahs4nqv87kyrfg545"; sha256 = if stdenv.isAarch64 then "19mnlw7igxblxx8qp6l9rn2w0xw1akdx2v1rw6pq14d03dgwby22"
else "1fc59jrbfq8l067mggzy5dnrvni7lwaqd7hahs4nqv87kyrfg545";
}; };
jaxws = fetchurl { jaxws = fetchurl {
name = "jaxws-${repover}.tar.gz";
url = "${baseurl}/jaxws/archive/${repover}.tar.gz"; url = "${baseurl}/jaxws/archive/${repover}.tar.gz";
sha256 = "1ka2fvyxdmpfhk814s314gx53yvdr19vpsqygx283v9nbq90l1yg"; sha256 = if stdenv.isAarch64 then "1dvlcj5jrwia08im1is9ms6r619jvzkhyg3ls0czh2yycabg6p51"
else "1ka2fvyxdmpfhk814s314gx53yvdr19vpsqygx283v9nbq90l1yg";
}; };
jaxp = fetchurl { jaxp = fetchurl {
name = "jaxp-${repover}.tar.gz";
url = "${baseurl}/jaxp/archive/${repover}.tar.gz"; url = "${baseurl}/jaxp/archive/${repover}.tar.gz";
sha256 = "15vlgs5v2ax8sqwh7bg50fnlrwlpnkp0myzrvpqs1mcza8pyasp8"; sha256 = if stdenv.isAarch64 then "1imz7bsiqhhh5qx8hjpm46y7a4j282vmdd6xljz8n148vml2p936"
else "15vlgs5v2ax8sqwh7bg50fnlrwlpnkp0myzrvpqs1mcza8pyasp8";
}; };
nashorn = fetchurl { nashorn = fetchurl {
name = "nashorn-${repover}.tar.gz";
url = "${baseurl}/nashorn/archive/${repover}.tar.gz"; url = "${baseurl}/nashorn/archive/${repover}.tar.gz";
sha256 = "1jzn0yi0v6lda5y8ib07g1p6zymnbcx9yy6iz8niggpm7205y93h"; sha256 = if stdenv.isAarch64 then "0rnrzz42f3ismhwj05sim7d05wccp5bcr5rhxgnvs3hjqaqvq51n"
else "1jzn0yi0v6lda5y8ib07g1p6zymnbcx9yy6iz8niggpm7205y93h";
}; };
openjdk8 = stdenv.mkDerivation { openjdk8 = stdenv.mkDerivation {
name = "openjdk-8u${update}-${build}"; pname = "openjdk" + lib.optionalString headless "-headless";
version = "8u${update}-${build}";
srcs = [ jdk8 langtools hotspot corba jdk jaxws jaxp nashorn ]; srcs = [ jdk8 langtools hotspot corba jdk jaxws jaxp nashorn ];
sourceRoot = "."; sourceRoot = ".";
@ -67,10 +87,10 @@ let
nativeBuildInputs = [ pkgconfig ]; nativeBuildInputs = [ pkgconfig ];
buildInputs = [ buildInputs = [
cpio file which unzip zip perl bootjdk zlib cups freetype alsaLib cpio file which unzip zip perl openjdk8-bootstrap zlib cups freetype alsaLib
libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst
libXi libXinerama libXcursor libXrandr lndir fontconfig libXi libXinerama libXcursor libXrandr fontconfig
] ++ lib.optionals (!minimal && enableGnome2) [ ] ++ lib.optionals (!headless && enableGnome2) [
gtk2 gnome_vfs GConf glib gtk2 gnome_vfs GConf glib
]; ];
@ -88,10 +108,10 @@ let
./fix-java-home-jdk8.patch ./fix-java-home-jdk8.patch
./read-truststore-from-env-jdk8.patch ./read-truststore-from-env-jdk8.patch
./currency-date-range-jdk8.patch ./currency-date-range-jdk8.patch
] ++ lib.optionals (!minimal && enableInfinality) [ ] ++ lib.optionals (!headless && enableInfinality) [
./004_add-fontconfig.patch ./004_add-fontconfig.patch
./005_enable-infinality.patch ./005_enable-infinality.patch
] ++ lib.optionals (!minimal && enableGnome2) [ ] ++ lib.optionals (!headless && enableGnome2) [
./swing-use-gtk-jdk8.patch ./swing-use-gtk-jdk8.patch
]; ];
@ -103,33 +123,39 @@ let
substituteInPlace configure --replace /bin/bash "${bash}/bin/bash" substituteInPlace configure --replace /bin/bash "${bash}/bin/bash"
substituteInPlace hotspot/make/linux/adlc_updater --replace /bin/sh "${stdenv.shell}" substituteInPlace hotspot/make/linux/adlc_updater --replace /bin/sh "${stdenv.shell}"
substituteInPlace hotspot/make/linux/makefiles/dtrace.make --replace /usr/include/sys/sdt.h "/no-such-path" substituteInPlace hotspot/make/linux/makefiles/dtrace.make --replace /usr/include/sys/sdt.h "/no-such-path"
''
# https://bugzilla.redhat.com/show_bug.cgi?id=1306558
# https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716
+ stdenv.lib.optionalString stdenv.cc.isGNU ''
NIX_CFLAGS_COMPILE+=" -fno-lifetime-dse -fno-delete-null-pointer-checks -std=gnu++98 -Wno-error"
''; '';
configureFlags = [ configureFlags = [
"--with-boot-jdk=${bootjdk.home}" "--with-boot-jdk=${openjdk8-bootstrap.home}"
"--with-update-version=${update}" "--with-update-version=${update}"
"--with-build-number=${build}" "--with-build-number=${build}"
"--with-milestone=fcs" "--with-milestone=fcs"
"--enable-unlimited-crypto" "--enable-unlimited-crypto"
"--disable-debug-symbols" "--with-native-debug-symbols=internal"
"--disable-freetype-bundling" "--disable-freetype-bundling"
"--with-zlib=system" "--with-zlib=system"
"--with-giflib=system" "--with-giflib=system"
"--with-stdc++lib=dynamic" "--with-stdc++lib=dynamic"
] ++ lib.optional headless "--disable-headful";
separateDebugInfo = true;
NIX_CFLAGS_COMPILE = [
# glibc 2.24 deprecated readdir_r so we need this # glibc 2.24 deprecated readdir_r so we need this
# See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html # See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html
"--with-extra-cflags=\"-Wno-error=deprecated-declarations\"" "-Wno-error=deprecated-declarations"
] ++ lib.optional minimal "--disable-headful"; ] ++ lib.optionals stdenv.cc.isGNU [
# https://bugzilla.redhat.com/show_bug.cgi?id=1306558
# https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716
"-fno-lifetime-dse"
"-fno-delete-null-pointer-checks"
"-std=gnu++98"
"-Wno-error"
];
NIX_LDFLAGS= lib.optionals (!minimal) [ NIX_LDFLAGS= lib.optionals (!headless) [
"-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic"
] ++ lib.optionals (!minimal && enableGnome2) [ ] ++ lib.optionals (!headless && enableGnome2) [
"-lgtk-x11-2.0" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2" "-lgtk-x11-2.0" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
]; ];
@ -138,45 +164,39 @@ let
doCheck = false; # fails with "No rule to make target 'y'." doCheck = false; # fails with "No rule to make target 'y'."
installPhase = '' installPhase = ''
mkdir -p $out/lib/openjdk $out/share $jre/lib/openjdk mkdir -p $out/lib
cp -av build/*/images/j2sdk-image/* $out/lib/openjdk mv build/*/images/j2sdk-image $out/lib/openjdk
# Remove some broken manpages. # Remove some broken manpages.
rm -rf $out/lib/openjdk/man/ja* rm -rf $out/lib/openjdk/man/ja*
# Mirror some stuff in top-level. # Mirror some stuff in top-level.
mkdir $out/include $out/share/man mkdir -p $out/share
ln -s $out/lib/openjdk/include/* $out/include/ ln -s $out/lib/openjdk/include $out/include
ln -s $out/lib/openjdk/man/* $out/share/man/ ln -s $out/lib/openjdk/man $out/share/man
# jni.h expects jni_md.h to be in the header search path. # jni.h expects jni_md.h to be in the header search path.
ln -s $out/include/linux/*_md.h $out/include/ ln -s $out/include/linux/*_md.h $out/include/
# Remove crap from the installation. # Remove crap from the installation.
rm -rf $out/lib/openjdk/demo $out/lib/openjdk/sample rm -rf $out/lib/openjdk/demo $out/lib/openjdk/sample
${lib.optionalString minimal '' ${lib.optionalString headless ''
rm $out/lib/openjdk/jre/lib/${architecture}/{libjsound,libjsoundalsa,libsplashscreen,libawt*,libfontmanager}.so rm $out/lib/openjdk/jre/lib/${architecture}/{libjsound,libjsoundalsa,libsplashscreen,libawt*,libfontmanager}.so
rm $out/lib/openjdk/jre/bin/policytool rm $out/lib/openjdk/jre/bin/policytool
rm $out/lib/openjdk/bin/{policytool,appletviewer} rm $out/lib/openjdk/bin/{policytool,appletviewer}
''} ''}
# Move the JRE to a separate output and setup fallback fonts # Move the JRE to a separate output
mv $out/lib/openjdk/jre $jre/lib/openjdk/ mkdir -p $jre/lib/openjdk
mkdir $out/lib/openjdk/jre mv $out/lib/openjdk/jre $jre/lib/openjdk/jre
${lib.optionalString (!minimal) '' ln -s $jre/lib/openjdk/jre $out/lib/openjdk/jre
mkdir -p $jre/lib/openjdk/jre/lib/fonts/fallback
lndir ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback # Setup fallback fonts
${lib.optionalString (!headless) ''
mkdir -p $jre/lib/openjdk/jre/lib/fonts
ln -s ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback
''} ''}
lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre
rm -rf $out/lib/openjdk/jre/bina
ln -s $out/lib/openjdk/bin $out/lib/openjdk/jre/bin
# Make sure cmm/*.pf are not symlinks:
# https://youtrack.jetbrains.com/issue/IDEA-147272
rm -rf $out/lib/openjdk/jre/lib/cmm
ln -s {$jre,$out}/lib/openjdk/jre/lib/cmm
# Remove duplicate binaries. # Remove duplicate binaries.
for i in $(cd $out/lib/openjdk/bin && echo *); do for i in $(cd $out/lib/openjdk/bin && echo *); do
@ -198,12 +218,7 @@ let
ln -s $jre/lib/openjdk/jre $out/jre ln -s $jre/lib/openjdk/jre $out/jre
''; '';
# FIXME: this is unnecessary once the multiple-outputs branch is merged.
preFixup = '' preFixup = ''
prefix=$jre stripDirs "$STRIP" "$stripDebugList" "''${stripDebugFlags:--S}"
patchELF $jre
propagatedBuildInputs+=" $jre"
# Propagate the setJavaClassPath setup hook from the JRE so that # Propagate the setJavaClassPath setup hook from the JRE so that
# any package that depends on the JRE has $CLASSPATH set up # any package that depends on the JRE has $CLASSPATH set up
# properly. # properly.
@ -221,11 +236,12 @@ let
# Build the set of output library directories to rpath against # Build the set of output library directories to rpath against
LIBDIRS="" LIBDIRS=""
for output in $outputs; do for output in $outputs; do
if [ "$output" = debug ]; then continue; fi
LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS" LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS"
done done
# Add the local library paths to remove dependencies on the bootstrap # Add the local library paths to remove dependencies on the bootstrap
for output in $outputs; do for output in $outputs; do
if [ "$output" = debug ]; then continue; fi
OUTPUTDIR=$(eval echo \$$output) OUTPUTDIR=$(eval echo \$$output)
BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)
echo "$BINLIBS" | while read i; do echo "$BINLIBS" | while read i; do
@ -233,22 +249,16 @@ let
patchelf --shrink-rpath "$i" || true patchelf --shrink-rpath "$i" || true
done done
done done
# Test to make sure that we don't depend on the bootstrap
for output in $outputs; do
if grep -q -r '${bootjdk}' $(eval echo \$$output); then
echo "Extraneous references to ${bootjdk} detected"
exit 1
fi
done
''; '';
meta = with stdenv.lib; { disallowedReferences = [ openjdk8-bootstrap ];
meta = with lib; {
homepage = http://openjdk.java.net/; homepage = http://openjdk.java.net/;
license = licenses.gpl2; license = licenses.gpl2;
description = "The open-source Java Development Kit"; description = "The open-source Java Development Kit";
maintainers = with maintainers; [ edwtjo nequissimus ]; maintainers = with maintainers; [ edwtjo nequissimus ];
platforms = platforms.linux; platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" ];
}; };
passthru = { passthru = {

View File

@ -1,5 +1,6 @@
{ stdenv, fetchurl, writeText, openjdk, bootjdk, gradleGen, pkgconfig, perl, cmake, gperf { stdenv, lib, fetchurl, writeText, openjdk11, gradleGen, pkgconfig, perl, cmake
, gtk2, gtk3, libXtst, libXxf86vm, glib, alsaLib, ffmpeg, python, ruby }: , gperf, gtk2, gtk3, libXtst, libXxf86vm, glib, alsaLib, ffmpeg, python, ruby
, openjdk11-bootstrap }:
let let
major = "11"; major = "11";
@ -7,7 +8,7 @@ let
build = "1"; build = "1";
repover = "${major}${update}+${build}"; repover = "${major}${update}+${build}";
gradle_ = (gradleGen.override { gradle_ = (gradleGen.override {
java = bootjdk; java = openjdk11-bootstrap;
}).gradle_4_10; }).gradle_4_10;
makePackage = args: stdenv.mkDerivation ({ makePackage = args: stdenv.mkDerivation ({
@ -25,7 +26,7 @@ let
config = writeText "gradle.properties" ('' config = writeText "gradle.properties" (''
CONF = Release CONF = Release
JDK_HOME = ${bootjdk}/lib/openjdk JDK_HOME = ${openjdk11-bootstrap.home}
'' + args.gradleProperties or ""); '' + args.gradleProperties or "");
buildPhase = '' buildPhase = ''
@ -56,11 +57,11 @@ let
outputHashAlgo = "sha256"; outputHashAlgo = "sha256";
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHash =
# Downloaded AWT jars differ by platform. # Downloaded AWT jars differ by platform.
if stdenv.system == "x86_64-linux" then "0d4msxswdav1xsfkpr0qd3xgqkcbxzf47v1zdy5jmg5w4bs6a78a" outputHash = {
else if stdenv.system == "i686-linux" then "0mjlyf6jvbis7nrm5d394sjv4hjw6k3753hr1nwdxk8skwc3ry08" "i686-linux" = "0mjlyf6jvbis7nrm5d394sjv4hjw6k3753hr1nwdxk8skwc3ry08";
else throw "Unsupported platform"; "x86_64-linux" = "0d4msxswdav1xsfkpr0qd3xgqkcbxzf47v1zdy5jmg5w4bs6a78a";
}.${stdenv.system} or (throw "Unsupported platform");
}; };
in makePackage { in makePackage {
@ -87,24 +88,20 @@ in makePackage {
postFixup = '' postFixup = ''
# Remove references to bootstrap. # Remove references to bootstrap.
find "$out" -name \*.so | while read lib; do find "$out" -name \*.so | while read lib; do
new_refs="$(patchelf --print-rpath "$lib" | sed -E 's,:?${bootjdk}[^:]*,,')" new_refs="$(patchelf --print-rpath "$lib" | sed -E 's,:?${openjdk11-bootstrap}[^:]*,,')"
patchelf --set-rpath "$new_refs" "$lib" patchelf --set-rpath "$new_refs" "$lib"
done done
# Test to make sure that we don't depend on the bootstrap
if grep -q -r '${bootjdk}' "$out"; then
echo "Extraneous references to ${bootjdk} detected" >&2
exit 1
fi
''; '';
disallowedReferences = [ openjdk11-bootstrap ];
passthru.deps = deps; passthru.deps = deps;
meta = with stdenv.lib; { meta = with stdenv.lib; {
homepage = http://openjdk.java.net/projects/openjfx/; homepage = http://openjdk.java.net/projects/openjfx/;
license = openjdk.meta.license; license = openjdk11.meta.license;
description = "The next-generation Java client toolkit."; description = "The next-generation Java client toolkit.";
maintainers = with maintainers; [ abbradar ]; maintainers = with maintainers; [ abbradar ];
platforms = openjdk.meta.platforms; platforms = [ "i686-linux" "x86_64-linux" ];
}; };
} }

View File

@ -7862,15 +7862,15 @@ in
hugs = callPackage ../development/interpreters/hugs { }; hugs = callPackage ../development/interpreters/hugs { };
bootjdk = callPackage ../development/compilers/openjdk/bootstrap.nix { version = "10"; }; openjfx11 = callPackage ../development/compilers/openjdk/openjfx/11.nix { };
openjfx11 = openjfx12 = callPackage ../development/compilers/openjdk/openjfx/12.nix { };
if stdenv.isDarwin then
null openjdk8-bootstrap =
if adoptopenjdk-hotspot-bin-8.meta.available then
adoptopenjdk-hotspot-bin-8
else else
callPackage ../development/compilers/openjdk/openjfx/11.nix { callPackage ../development/compilers/openjdk/bootstrap.nix { version = "8"; };
openjdk = openjdk11;
};
/* legacy jdk for use as needed by older apps */ /* legacy jdk for use as needed by older apps */
openjdk8 = openjdk8 =
@ -7878,10 +7878,21 @@ in
callPackage ../development/compilers/openjdk/darwin/8.nix { } callPackage ../development/compilers/openjdk/darwin/8.nix { }
else else
callPackage ../development/compilers/openjdk/8.nix { callPackage ../development/compilers/openjdk/8.nix {
bootjdk = bootjdk.override { version = "8"; };
inherit (gnome2) GConf gnome_vfs; inherit (gnome2) GConf gnome_vfs;
}; };
openjdk8_headless =
if stdenv.isDarwin || stdenv.isAarch64 then
openjdk8
else
openjdk8.override { headless = true; };
openjdk11-bootstrap =
if adoptopenjdk-hotspot-bin-11.meta.available then
adoptopenjdk-hotspot-bin-11
else
callPackage ../development/compilers/openjdk/bootstrap.nix { version = "10"; };
/* currently maintained LTS JDK */ /* currently maintained LTS JDK */
openjdk11 = openjdk11 =
if stdenv.isDarwin then if stdenv.isDarwin then
@ -7892,62 +7903,43 @@ in
inherit (gnome2) GConf gnome_vfs; inherit (gnome2) GConf gnome_vfs;
}; };
openjfx12 = openjdk11_headless =
if stdenv.isDarwin then if stdenv.isDarwin then
null openjdk11
else else
callPackage ../development/compilers/openjdk/openjfx/12.nix { openjdk11.override { headless = true; };
openjdk = openjdk12;
bootjdk = openjdk11;
};
/* current JDK */ /* current JDK */
openjdk12 = openjdk12 =
if stdenv.isDarwin then if stdenv.isDarwin then
callPackage ../development/compilers/openjdk/darwin/default.nix { } callPackage ../development/compilers/openjdk/darwin { }
else else
callPackage ../development/compilers/openjdk/default.nix { callPackage ../development/compilers/openjdk {
openjfx = openjfx12; openjfx = openjfx12;
inherit (gnome2) GConf gnome_vfs; inherit (gnome2) GConf gnome_vfs;
bootjdk = openjdk11;
}; };
openjdk12_headless =
if stdenv.isDarwin then
openjdk12
else
openjdk12.override { headless = true; };
openjdk = openjdk8; openjdk = openjdk8;
openjdk_headless = openjdk8_headless;
jdk8 = if stdenv.isAarch32 || stdenv.isAarch64 then oraclejdk8 else openjdk8 // { outputs = [ "out" ]; }; jdk8 = openjdk8;
jre8 = if stdenv.isAarch32 || stdenv.isAarch64 then oraclejre8 else lib.setName "openjre-${lib.getVersion pkgs.openjdk8.jre}" jre8 = openjdk8.jre;
(lib.addMetaAttrs { outputsToInstall = [ "jre" ]; } jre8_headless = openjdk8_headless.jre;
(openjdk8.jre // { outputs = [ "jre" ]; }));
jre8_headless =
if stdenv.isAarch32 || stdenv.isAarch64 then
oraclejre8
else if stdenv.isDarwin then
jre8
else
lib.setName "openjre-${lib.getVersion pkgs.openjdk8.jre}-headless"
(lib.addMetaAttrs { outputsToInstall = [ "jre" ]; }
((openjdk8.override { minimal = true; }).jre // { outputs = [ "jre" ]; }));
jdk11 = openjdk11 // { outputs = [ "out" ]; }; jdk11 = openjdk11;
jdk11_headless = jdk11_headless = openjdk11_headless;
if stdenv.isDarwin then
jdk11
else
lib.setName "openjdk-${lib.getVersion pkgs.openjdk11}-headless"
(lib.addMetaAttrs {}
((openjdk11.override { minimal = true; }) // {}));
jdk12 = openjdk12 // { outputs = [ "out" ]; }; jdk12 = openjdk12;
jdk12_headless = jdk12_headless = openjdk12_headless;
if stdenv.isDarwin then
jdk12
else
lib.setName "openjdk-${lib.getVersion pkgs.openjdk12}-headless"
(lib.addMetaAttrs {}
((openjdk12.override { minimal = true; }) // {}));
jdk = jdk8; jdk = jdk8;
jre = if stdenv.isAarch32 || stdenv.isAarch64 then adoptopenjdk-jre-bin else jre8; jre = jre8;
jre_headless = jre8_headless; jre_headless = jre8_headless;
inherit (callPackages ../development/compilers/graalvm { }) mx jvmci8 graalvm8; inherit (callPackages ../development/compilers/graalvm { }) mx jvmci8 graalvm8;