gradle: Add ncurses dependencies on Linux
If ncurses is available Gradle can use it to prettify its output and show progress during task execution. The fixup step patches the bundled native libraries with libstdc++ but not with ncurses, which means that Gradle will always use the (non-pretty) fallback native platform libraries. Patching the native platform libraries with ncurses5 and ncurses6 dependencies fixes the issue. For some reason both ncurses5 and ncurses6 are required. Gradle will refuse to start if, for example, the ncurses5 native platform jar is missing.
This commit is contained in:
parent
2680bbd4b3
commit
d298031095
@ -6,7 +6,7 @@ rec {
|
||||
{ version, nativeVersion, sha256, defaultJava ? jdk8 }:
|
||||
|
||||
{ lib, stdenv, fetchurl, makeWrapper, unzip, java ? defaultJava
|
||||
, javaToolchains ? [ ] }:
|
||||
, javaToolchains ? [ ], ncurses5, ncurses6 }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "gradle";
|
||||
@ -52,18 +52,25 @@ rec {
|
||||
|
||||
fixupPhase = let arch = if stdenv.is64bit then "amd64" else "i386";
|
||||
in ''
|
||||
mkdir patching
|
||||
pushd patching
|
||||
jar xf $out/lib/gradle/lib/native-platform-linux-${arch}-${nativeVersion}.jar
|
||||
patchelf --set-rpath "${stdenv.cc.cc.lib}/lib:${stdenv.cc.cc.lib}/lib64" net/rubygrapefruit/platform/linux-${arch}/libnative-platform.so
|
||||
jar cf native-platform-linux-${arch}-${nativeVersion}.jar .
|
||||
mv native-platform-linux-${arch}-${nativeVersion}.jar $out/lib/gradle/lib/
|
||||
popd
|
||||
for variant in "" "-ncurses5" "-ncurses6"; do
|
||||
mkdir "patching$variant"
|
||||
pushd "patching$variant"
|
||||
jar xf $out/lib/gradle/lib/native-platform-linux-${arch}$variant-${nativeVersion}.jar
|
||||
patchelf \
|
||||
--set-rpath "${stdenv.cc.cc.lib}/lib64:${lib.makeLibraryPath [ stdenv.cc.cc ncurses5 ncurses6 ]}" \
|
||||
net/rubygrapefruit/platform/linux-${arch}$variant/libnative-platform*.so
|
||||
jar cf native-platform-linux-${arch}$variant-${nativeVersion}.jar .
|
||||
mv native-platform-linux-${arch}$variant-${nativeVersion}.jar $out/lib/gradle/lib/
|
||||
popd
|
||||
done
|
||||
|
||||
# The scanner doesn't pick up the runtime dependency in the jar.
|
||||
# Manually add a reference where it will be found.
|
||||
mkdir $out/nix-support
|
||||
echo ${stdenv.cc.cc} > $out/nix-support/manual-runtime-dependencies
|
||||
# Gradle will refuse to start without _both_ 5 and 6 versions of ncurses.
|
||||
echo ${ncurses5} >> $out/nix-support/manual-runtime-dependencies
|
||||
echo ${ncurses6} >> $out/nix-support/manual-runtime-dependencies
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
|
Loading…
Reference in New Issue
Block a user