diff options
author | Tad Fisher <tadfisher@gmail.com> | 2018-06-26 09:48:07 -0700 |
---|---|---|
committer | Tad Fisher <tadfisher@gmail.com> | 2018-06-26 12:21:16 -0700 |
commit | 3c5e7e2ae4fbc4270e410adf134ef726895ce9c1 (patch) | |
tree | c80cf5ad00c736c52f779bd15d262bfa1a54faae /pkgs/tools/security/jd-gui | |
parent | 5ac6ab091a4883385e68571425fb7fef4d74c207 (diff) |
jd-gui: 0.3.5 -> 1.4.0
Diffstat (limited to 'pkgs/tools/security/jd-gui')
-rw-r--r-- | pkgs/tools/security/jd-gui/default.nix | 122 |
1 files changed, 86 insertions, 36 deletions
diff --git a/pkgs/tools/security/jd-gui/default.nix b/pkgs/tools/security/jd-gui/default.nix index 72cb19aa732b1..d9617e3eb2baf 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 <<EOF + #!${stdenv.shell} + export JAVA_HOME=${jre} + ${jre}/bin/java -jar ${jar} $@ + EOF + chmod +x $out/bin/jd-gui + + ${(desktopItem "$out/bin/jd-gui").buildCommand} ''; dontStrip = true; - meta = { + meta = with stdenv.lib; { description = "Fast Java Decompiler with powerful GUI"; homepage = "http://jd.benow.ca/"; - license = stdenv.lib.licenses.unfreeRedistributable; - platforms = [ "i686-linux" ]; - maintainers = [ stdenv.lib.maintainers.thoughtpolice ]; + license = licenses.gpl3; + platforms = platforms.unix; + maintainers = [ maintainers.thoughtpolice ]; }; } |