1{ lib
2, stdenv
3, fetchurl
4, makeWrapper
5, jdk_headless
6, aapt
7}:
8
9stdenv.mkDerivation rec {
10 pname = "apktool";
11 version = "2.9.3";
12
13 src = fetchurl {
14 urls = [
15 "https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_${version}.jar"
16 "https://github.com/iBotPeaches/Apktool/releases/download/v${version}/apktool_${version}.jar"
17 ];
18 hash = "sha256-eVbrBBlDAM4NCoStGHce68lLifuNHdzOjqTAVoGGRvQ=";
19 };
20
21 dontUnpack = true;
22
23 nativeBuildInputs = [ makeWrapper ];
24
25 sourceRoot = ".";
26
27 installPhase =
28 ''
29 install -D ${src} "$out/libexec/apktool/apktool.jar"
30 mkdir -p "$out/bin"
31 makeWrapper "${jdk_headless}/bin/java" "$out/bin/apktool" \
32 --add-flags "-jar $out/libexec/apktool/apktool.jar" \
33 --prefix PATH : ${lib.getBin aapt}
34 '';
35
36 meta = with lib; {
37 description = "Tool for reverse engineering Android apk files";
38 mainProgram = "apktool";
39 homepage = "https://ibotpeaches.github.io/Apktool/";
40 changelog = "https://github.com/iBotPeaches/Apktool/releases/tag/v${version}";
41 sourceProvenance = with sourceTypes; [ binaryBytecode ];
42 license = licenses.asl20;
43 maintainers = with maintainers; [ offline ];
44 platforms = with platforms; unix;
45 };
46}