From a15c9433376c190b6592f0089157d5ba85b60e5f Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 2 Oct 2016 19:44:21 +0300 Subject: [PATCH] openjdk8: rework dependencies This makes several adjustments around what is linked into JRE. * system giflib, libjpeg, zlib are now used unconditionally; * libstdc++ is linked dynamically. For full version: * GTK+ and GNOME libraries are linked; * Extra X11 libraries are linked; * CUPS is linked; * libmagic (file) is linked. For minimal version: * All X11 support is removed; * Sound support is removed. * Fonts and their support are not lined. jre8_headless is added as a minimal build. Overall this adds support for all things GUI into the default Java build and removes them from the minimal build. --- pkgs/development/compilers/openjdk/8.nix | 50 +++++++++++++++--------- pkgs/top-level/all-packages.nix | 4 ++ 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/pkgs/development/compilers/openjdk/8.nix b/pkgs/development/compilers/openjdk/8.nix index 50199852ae2..fb0a20b865a 100644 --- a/pkgs/development/compilers/openjdk/8.nix +++ b/pkgs/development/compilers/openjdk/8.nix @@ -1,8 +1,11 @@ -{ stdenv, fetchurl, cpio, pkgconfig, file, which, unzip, zip, xorg, cups, freetype -, alsaLib, bootjdk, cacert, perl, liberation_ttf, fontconfig, zlib +{ stdenv, lib, fetchurl, cpio, pkgconfig, file, which, unzip, zip, cups, freetype +, alsaLib, bootjdk, cacert, perl, liberation_ttf, fontconfig, zlib, lndir +, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor +, libjpeg, giflib , setJavaClassPath , minimal ? false , enableInfinality ? true # font rendering patch +, enableGnome2 ? true, gtk2, gnome_vfs, glib, GConf }: let @@ -65,10 +68,11 @@ let nativeBuildInputs = [ pkgconfig ]; buildInputs = [ - cpio file which unzip zip - xorg.libX11 xorg.libXt xorg.libXext xorg.libXrender xorg.libXtst - xorg.libXi xorg.libXinerama xorg.libXcursor xorg.lndir - cups freetype alsaLib perl liberation_ttf fontconfig bootjdk zlib + cpio file which unzip zip perl bootjdk zlib cups freetype alsaLib + libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst + libXi libXinerama libXcursor lndir fontconfig + ] ++ lib.optionals (!minimal && enableGnome2) [ + gtk2 gnome_vfs GConf glib ]; prePatch = '' @@ -82,10 +86,10 @@ let ./fix-java-home-jdk8.patch ./read-truststore-from-env-jdk8.patch ./currency-date-range-jdk8.patch - ] ++ (if enableInfinality then [ + ] ++ lib.optionals (!minimal && enableInfinality) [ ./004_add-fontconfig.patch ./005_enable-infinality.patch - ] else []); + ]; preConfigure = '' chmod +x configure @@ -101,21 +105,22 @@ let "--enable-unlimited-crypto" "--disable-debug-symbols" "--disable-freetype-bundling" + "--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\"" - ] ++ (if minimal then [ - "--disable-headful" - "--with-zlib=bundled" - "--with-giflib=bundled" - ] else [ - "--with-zlib=system" - ]); + ] ++ lib.optional minimal "--disable-headful"; - NIX_LDFLAGS= if minimal then null else "-lfontconfig"; + NIX_LDFLAGS= lib.optionals (!minimal) [ + "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" + ] ++ lib.optionals (!minimal && enableGnome2) [ + "-lgtk-x11-2.0" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2" + ]; - buildFlags = "all"; + buildFlags = [ "all" ]; installPhase = '' mkdir -p $out/lib/openjdk $out/share $jre/lib/openjdk @@ -135,12 +140,19 @@ let # Remove crap from the installation. rm -rf $out/lib/openjdk/demo $out/lib/openjdk/sample + ${lib.optionalString minimal '' + rm $out/lib/openjdk/jre/lib/${architecture}/{libjsound,libjsoundalsa,libsplashscreen,libawt*,libfontmanager}.so + rm $out/lib/openjdk/jre/bin/policytool + rm $out/lib/openjdk/bin/{policytool,appletviewer} + ''} # Move the JRE to a separate output and setup fallback fonts mv $out/lib/openjdk/jre $jre/lib/openjdk/ mkdir $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 + ${lib.optionalString (!minimal) '' + mkdir -p $jre/lib/openjdk/jre/lib/fonts/fallback + lndir ${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 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7c5c35abdf6..4caf62060a2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4862,6 +4862,7 @@ in else callPackage ../development/compilers/openjdk/8.nix { bootjdk = callPackage ../development/compilers/openjdk/bootstrap.nix { version = "8"; }; + inherit (gnome2) GConf gnome_vfs; }; openjdk = if stdenv.isDarwin then openjdk7 else openjdk8; @@ -4875,6 +4876,9 @@ in jre8 = lib.setName "openjre-${lib.getVersion pkgs.openjdk8.jre}" (lib.addMetaAttrs { outputsToInstall = [ "jre" ]; } (openjdk8.jre // { outputs = [ "jre" ]; })); + jre8_headless = lib.setName "openjre-${lib.getVersion pkgs.openjdk8.jre}-headless" + (lib.addMetaAttrs { outputsToInstall = [ "jre" ]; } + ((openjdk8.override { minimal = true; }).jre // { outputs = [ "jre" ]; })); jdk = if stdenv.isDarwin then jdk7 else jdk8; jre = if stdenv.isDarwin then jre7 else jre8;