2018-10-10 18:54:53 +02:00
|
|
|
{ stdenv, lib, fetchurl, bash, cpio, autoconf, pkgconfig, file, which, unzip, zip, cups, freetype
|
2018-07-21 02:44:44 +02:00
|
|
|
, alsaLib, bootjdk, perl, liberation_ttf, fontconfig, zlib, lndir
|
2018-06-19 00:25:41 +02:00
|
|
|
, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr
|
2018-03-25 06:34:50 +02:00
|
|
|
, libjpeg, giflib
|
|
|
|
, setJavaClassPath
|
|
|
|
, minimal ? false
|
2018-03-07 21:17:02 +01:00
|
|
|
, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf
|
2018-03-25 06:34:50 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
/**
|
2018-10-10 18:54:53 +02:00
|
|
|
* The JDK libraries are in directories that depend on the CPU.
|
2018-03-25 06:34:50 +02:00
|
|
|
*/
|
|
|
|
architecture =
|
2018-08-20 21:11:29 +02:00
|
|
|
if stdenv.hostPlatform.system == "i686-linux" then
|
2018-03-25 06:34:50 +02:00
|
|
|
"i386"
|
|
|
|
else "amd64";
|
|
|
|
|
2018-10-10 18:54:53 +02:00
|
|
|
major = "11";
|
|
|
|
update = ".0.1";
|
2018-08-31 21:20:50 +02:00
|
|
|
build = "13";
|
2018-10-10 18:54:53 +02:00
|
|
|
repover = "jdk-${major}${update}+${build}";
|
2018-03-25 06:34:50 +02:00
|
|
|
paxflags = if stdenv.isi686 then "msp" else "m";
|
2018-03-26 02:14:55 +02:00
|
|
|
|
2018-10-10 18:54:53 +02:00
|
|
|
openjdk = stdenv.mkDerivation {
|
|
|
|
name = "openjdk-${major}${update}-b${build}";
|
2018-03-25 06:34:50 +02:00
|
|
|
|
2018-03-26 02:14:55 +02:00
|
|
|
src = fetchurl {
|
2018-10-10 18:54:53 +02:00
|
|
|
url = "http://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/${repover}.tar.gz";
|
|
|
|
sha256 = "1ri3fv67rvs9xxhc3ynklbprhxbdsgpwafbw6wqj950xy5crgysm";
|
2018-03-26 02:14:55 +02:00
|
|
|
};
|
2018-03-25 06:34:50 +02:00
|
|
|
|
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
buildInputs = [
|
2018-10-10 18:54:53 +02:00
|
|
|
autoconf cpio file which unzip zip perl bootjdk zlib cups freetype alsaLib
|
2018-03-25 06:34:50 +02:00
|
|
|
libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst
|
2018-06-19 00:25:41 +02:00
|
|
|
libXi libXinerama libXcursor libXrandr lndir fontconfig
|
2018-03-25 06:34:50 +02:00
|
|
|
] ++ lib.optionals (!minimal && enableGnome2) [
|
2018-03-07 21:17:02 +01:00
|
|
|
gtk3 gnome_vfs GConf glib
|
2018-03-25 06:34:50 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./fix-java-home-jdk10.patch
|
|
|
|
./read-truststore-from-env-jdk10.patch
|
|
|
|
./currency-date-range-jdk10.patch
|
|
|
|
] ++ lib.optionals (!minimal && enableGnome2) [
|
|
|
|
./swing-use-gtk-jdk10.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
chmod +x configure
|
|
|
|
substituteInPlace configure --replace /bin/bash "${bash}/bin/bash"
|
|
|
|
|
|
|
|
configureFlagsArray=(
|
|
|
|
"--with-boot-jdk=${bootjdk.home}"
|
2018-10-10 18:54:53 +02:00
|
|
|
"--with-update-version=${major}${update}"
|
2018-03-25 06:34:50 +02:00
|
|
|
"--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"
|
|
|
|
''
|
2018-11-17 01:48:25 +01:00
|
|
|
+ lib.optionalString (architecture == "amd64") "\"--with-jvm-features=zgc\""
|
2018-03-25 06:34:50 +02:00
|
|
|
+ lib.optionalString minimal "\"--enable-headless-only\""
|
|
|
|
+ ");"
|
|
|
|
# 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) [
|
|
|
|
"-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic"
|
|
|
|
] ++ lib.optionals (!minimal && enableGnome2) [
|
2018-03-07 21:17:02 +01:00
|
|
|
"-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
|
2018-03-25 06:34:50 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
buildFlags = [ "all" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
2018-10-10 18:54:53 +02:00
|
|
|
mkdir -p $out/lib/openjdk $out/share
|
2018-03-25 06:34:50 +02:00
|
|
|
|
|
|
|
cp -av build/*/images/jdk/* $out/lib/openjdk
|
|
|
|
|
|
|
|
# Remove some broken manpages.
|
|
|
|
rm -rf $out/lib/openjdk/man/ja*
|
|
|
|
|
|
|
|
# Mirror some stuff in top-level.
|
|
|
|
mkdir $out/include $out/share/man
|
|
|
|
ln -s $out/lib/openjdk/include/* $out/include/
|
|
|
|
ln -s $out/lib/openjdk/man/* $out/share/man/
|
|
|
|
|
|
|
|
# jni.h expects jni_md.h to be in the header search path.
|
|
|
|
ln -s $out/include/linux/*_md.h $out/include/
|
|
|
|
|
|
|
|
# Remove crap from the installation.
|
|
|
|
rm -rf $out/lib/openjdk/demo
|
|
|
|
${lib.optionalString minimal ''
|
2018-10-10 18:54:53 +02:00
|
|
|
rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so
|
2018-03-25 06:34:50 +02:00
|
|
|
''}
|
|
|
|
|
|
|
|
# Set PaX markings
|
2018-10-10 18:54:53 +02:00
|
|
|
exes=$(file $out/lib/openjdk/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
|
2018-03-25 06:34:50 +02:00
|
|
|
echo "to mark: *$exes*"
|
|
|
|
for file in $exes; do
|
|
|
|
echo "marking *$file*"
|
|
|
|
paxmark ${paxflags} "$file"
|
|
|
|
done
|
|
|
|
|
|
|
|
ln -s $out/lib/openjdk/bin $out/bin
|
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = ''
|
2018-10-10 18:54:53 +02:00
|
|
|
# Propagate the setJavaClassPath setup hook so that any package
|
|
|
|
# that depends on the JDK has $CLASSPATH set up properly.
|
|
|
|
mkdir -p $out/nix-support
|
2018-03-25 06:34:50 +02:00
|
|
|
#TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040
|
2018-10-10 18:54:53 +02:00
|
|
|
echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs
|
2018-03-25 06:34:50 +02:00
|
|
|
|
|
|
|
# Set JAVA_HOME automatically.
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
cat <<EOF > $out/nix-support/setup-hook
|
|
|
|
if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
# Build the set of output library directories to rpath against
|
|
|
|
LIBDIRS=""
|
|
|
|
for output in $outputs; do
|
|
|
|
LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Add the local library paths to remove dependencies on the bootstrap
|
|
|
|
for output in $outputs; do
|
|
|
|
OUTPUTDIR=$(eval echo \$$output)
|
|
|
|
BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)
|
|
|
|
echo "$BINLIBS" | while read i; do
|
|
|
|
patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true
|
|
|
|
patchelf --shrink-rpath "$i" || true
|
|
|
|
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; {
|
|
|
|
homepage = http://openjdk.java.net/;
|
|
|
|
license = licenses.gpl2;
|
|
|
|
description = "The open-source Java Development Kit";
|
|
|
|
maintainers = with maintainers; [ edwtjo ];
|
|
|
|
platforms = ["i686-linux" "x86_64-linux"];
|
|
|
|
};
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit architecture;
|
2018-10-10 18:54:53 +02:00
|
|
|
home = "${openjdk}/lib/openjdk";
|
2018-03-25 06:34:50 +02:00
|
|
|
};
|
|
|
|
};
|
2018-10-10 18:54:53 +02:00
|
|
|
in openjdk
|