From 3c5e7e2ae4fbc4270e410adf134ef726895ce9c1 Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Tue, 26 Jun 2018 09:48:07 -0700 Subject: [PATCH] jd-gui: 0.3.5 -> 1.4.0 --- pkgs/tools/security/jd-gui/default.nix | 122 +++++++++++++++++-------- pkgs/top-level/all-packages.nix | 4 +- 2 files changed, 88 insertions(+), 38 deletions(-) diff --git a/pkgs/tools/security/jd-gui/default.nix b/pkgs/tools/security/jd-gui/default.nix index 72cb19aa732b..d9617e3eb2ba 100644 --- a/pkgs/tools/security/jd-gui/default.nix +++ b/pkgs/tools/security/jd-gui/default.nix @@ -1,52 +1,102 @@ -{ stdenv, fetchurl, gtk2, atk, gdk_pixbuf, glib, pango, fontconfig, zlib, xorg, upx, patchelf }: +{ stdenv, fetchurl, gradle_2_5, perl, makeWrapper, jre, makeDesktopItem, writeShellScriptBin, writeText }: let - dynlibPath = stdenv.lib.makeLibraryPath - ([ gtk2 atk gdk_pixbuf glib pango fontconfig zlib stdenv.cc.cc.lib ] - ++ (with xorg; [ - libX11 - libXext - libXrender - libXrandr - libSM - libXfixes - libXdamage - libXcursor - libXinerama - libXi - libXcomposite - libXxf86vm - ])); -in -stdenv.mkDerivation rec { - name = "jd-gui-${version}"; - version = "0.3.5"; + version = "1.4.0"; + name = "jd-gui-${version}"; src = fetchurl { - url = "http://jd.benow.ca/jd-gui/downloads/${name}.linux.i686.tar.gz"; - sha256 = "0jrvzs2s836yvqi41c7fq0gfiwf187qg765b9r1il2bjc0mb3dqv"; + url = "https://github.com/java-decompiler/jd-gui/archive/v${version}.tar.gz"; + sha256 = "0anz7szlr5kgmsmkyv34jdynsnk8v6kvibcyz98jsd96fh725lax"; }; - nativeBuildInputs = [ upx patchelf ]; + deps = stdenv.mkDerivation { + name = "${name}-deps"; + inherit src; + nativeBuildInputs = [ gradle_2_5 perl ]; - unpackPhase = "tar xf ${src}"; - installPhase = '' - mkdir -p $out/bin - upx -d jd-gui -o $out/bin/jd-gui + buildPhase = '' + export GRADLE_USER_HOME=$(mktemp -d); + gradle --no-daemon build + ''; - patchelf \ - --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \ - --set-rpath ${dynlibPath} \ - $out/bin/jd-gui + # Mavenize dependency paths + # e.g. org.codehaus.groovy/groovy/2.4.0/{hash}/groovy-2.4.0.jar -> org/codehaus/groovy/groovy/2.4.0/groovy-2.4.0.jar + installPhase = '' + find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ + | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ + | sh + ''; + + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = "1apmqiphnav79m4rdii58h7f4qslpfig4qybyyl2fr7zk92gv3l9"; + }; + + # Point to our local deps repo + gradleInit = writeText "init.gradle" '' + logger.lifecycle 'Replacing Maven repositories with ${deps}...' + + gradle.projectsLoaded { + rootProject.allprojects { + buildscript { + repositories { + clear() + maven { url '${deps}' } + } + } + repositories { + clear() + maven { url '${deps}' } + } + } + } + ''; + + desktopItem = launcher: makeDesktopItem { + name = "jd-gui"; + exec = "${launcher} %F"; + icon = "jd-gui"; + comment = "Java Decompiler JD-GUI"; + desktopName = "JD-GUI"; + genericName = "Java Decompiler"; + mimeType = "application/x-java-archive;application/x-java"; + categories = "Development;Debugger;"; + }; + +in stdenv.mkDerivation rec { + inherit name version src; + + nativeBuildInputs = [ gradle_2_5 perl makeWrapper ]; + + buildPhase = '' + export GRADLE_USER_HOME=$(mktemp -d) + gradle --offline --no-daemon --info --init-script ${gradleInit} jar + ''; + + installPhase = let + jar = "$out/share/jd-gui/${name}.jar"; + in '' + mkdir -p $out/bin $out/share/{jd-gui,icons/hicolor/128x128/apps} + cp build/libs/${name}.jar ${jar} + cp src/linux/resources/jd_icon_128.png $out/share/icons/hicolor/128x128/apps/jd-gui.png + + cat > $out/bin/jd-gui <