Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apkeditor: init at 1.4.1 #349470

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions pkgs/by-name/ap/apkeditor/arsclib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
fetchFromGitHub,
gradle,
lib,
REAndroidLibrary,
}:

let
self = REAndroidLibrary {
pname = "arsclib";
# 1.3.5 is not new enough for APKEditor because of API changes
version = "1.3.5-unstable-2024-10-21";
projectName = "ARSCLib";

src = fetchFromGitHub {
owner = "REAndroid";
repo = "ARSCLib";
# This is the latest commit at the time of packaging.
# It can be changed to a stable release ("V${version}")
# if it is compatible with APKEditor.
rev = "ed6ccf00e56d7cce13e8648ad46a2678a6093248";
hash = "sha256-jzd7xkc4O+P9hlGsFGGl2P3pqVvV5+mDyKTRUuGfFSA=";
};

mitmCache = gradle.fetchDeps {
pkg = self;
data = ./deps.json;
};

meta.license = lib.licenses.asl20;
};
in
self
17 changes: 17 additions & 0 deletions pkgs/by-name/ap/apkeditor/arsclib/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions pkgs/by-name/ap/apkeditor/fix-gradle.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/build.gradle b/build.gradle
index 97fd54f..128a269 100755
--- a/build.gradle
+++ b/build.gradle
@@ -5,8 +5,8 @@ group 'com.reandroid.apkeditor'
version '1.4.1'

java {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
}

if (JavaVersion.current().isJava8Compatible()) {
@@ -22,13 +22,13 @@ repositories {

dependencies {
//implementation("io.github.reandroid:ARSCLib:+")
- compile(files("$rootProject.projectDir/libs/ARSCLib.jar"))
+ implementation(files("$rootProject.projectDir/libs/ARSCLib.jar"))

// built from: https://github.com/REAndroid/smali-lib
- compile(files("$rootProject.projectDir/libs/smali.jar"))
+ implementation(files("$rootProject.projectDir/libs/smali.jar"))

// built from: https://github.com/REAndroid/JCommand
- compile(files("$rootProject.projectDir/libs/JCommand.jar"))
+ implementation(files("$rootProject.projectDir/libs/JCommand.jar"))
}

processResources {
@@ -52,7 +52,7 @@ task fatJar(type: Jar) {
'Main-Class': 'com.reandroid.apkeditor.Main'
)
}
- from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
+ from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}

33 changes: 33 additions & 0 deletions pkgs/by-name/ap/apkeditor/jcommand/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
fetchFromGitHub,
gradle,
lib,
REAndroidLibrary,
}:

let
self = REAndroidLibrary {
pname = "jcommand";
version = "0-unstable-2024-09-20";
projectName = "JCommand";

src = fetchFromGitHub {
owner = "REAndroid";
repo = "JCommand";
# No tagged releases, and
# it is hard to determine the actual commit that APKEditor is intended to use,
# so I think we should use the latest commit that doesn't break compilation or basic functionality.
# Currently this is the latest commit at the time of packaging.
rev = "714b6263c28dabb34adc858951cf4bc60d6c3fed";
hash = "sha256-6Em+1ddUkZBCYWs88qtfeGnxISZchFrHgDL8fsgZoQg=";
};

mitmCache = gradle.fetchDeps {
pkg = self;
data = ./deps.json;
};

meta.license = lib.licenses.asl20;
};
in
self
17 changes: 17 additions & 0 deletions pkgs/by-name/ap/apkeditor/jcommand/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions pkgs/by-name/ap/apkeditor/package.nix
Atemu marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
lib,
stdenv,
fetchFromGitHub,
callPackage,

jre,
gradle,
makeWrapper,
}:

let
REAndroidLibrary =
args:
let
inherit (args) pname version projectName;
outJar = "share/${projectName}/${projectName}.jar";
self = stdenv.mkDerivation (
{
__darwinAllowLocalNetworking = true;

buildInputs = [ jre ];
nativeBuildInputs = [ gradle ];

gradleFlags = [ "-Dfile.encoding=utf-8" ];
gradleBuildTask = "jar";
doCheck = true;

inherit outJar;
installPhase = ''
runHook preInstall
install -Dm644 build/libs/*.jar $out/${outJar}
runHook postInstall
'';
}
// args
// {
meta = {
sourceProvenance = with lib.sourceTypes; [
fromSource
binaryBytecode # mitm cache
];
} // args.meta;
}
);
in
self;

arsclib = callPackage ./arsclib { inherit REAndroidLibrary; };
smali = callPackage ./smali { inherit REAndroidLibrary; };
jcommand = callPackage ./jcommand { inherit REAndroidLibrary; };

apkeditor =
let
pname = "apkeditor";
version = "1.4.1";
projectName = "APKEditor";
in
REAndroidLibrary {
inherit pname version projectName;

# When you need to update **/deps.json for the dependencies (e.g. for smali),
# run `nix build apkeditor.passthru.deps.smali.mitmCache.updateScript`.
passthru.deps = {
inherit arsclib smali jcommand;
};

src = fetchFromGitHub {
owner = "REAndroid";
repo = "APKEditor";
rev = "V${version}";
hash = "sha256-a72j9qGjJXnTFeqLez2rhBSArFVYCX+Xs7NQd8CY5Yk=";
};

patches = [
# Remove this patch after REAndroid/APKEditor#144 is merged
./fix-gradle.patch
];

nativeBuildInputs = [
gradle
makeWrapper
];

gradleBuildTask = "fatJar";

# The paths libs/*.jar are hardcoded in build.gradle of APKEditor:
# https://github.com/REAndroid/APKEditor/blob/V1.4.1/build.gradle#L24-L31
preConfigure = ''
ln -sf ${arsclib}/${arsclib.outJar} libs/ARSCLib.jar
ln -sf ${smali}/${smali.outJar} libs/smali.jar
ln -sf ${jcommand}/${jcommand.outJar} libs/JCommand.jar
'';
UlyssesZh marked this conversation as resolved.
Show resolved Hide resolved
UlyssesZh marked this conversation as resolved.
Show resolved Hide resolved

postInstall = ''
mkdir -p $out/bin
makeWrapper ${lib.getExe jre} $out/bin/APKEditor \
--add-flags "-jar $out/${apkeditor.outJar}"
'';

meta = {
description = "Powerful android apk resources editor";
maintainers = with lib.maintainers; [ ulysseszhan ];
license = lib.licenses.asl20;
platforms = lib.platforms.all;
mainProgram = "APKEditor";
};
};
in
apkeditor
57 changes: 57 additions & 0 deletions pkgs/by-name/ap/apkeditor/smali/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
fetchFromGitHub,
gradle,
lib,
REAndroidLibrary,
}:

let
self = REAndroidLibrary {
pname = "smali";
version = "0-unstable-2024-10-15";
projectName = "smali";

src = fetchFromGitHub {
owner = "REAndroid";
repo = "smali-lib";
# No tagged releases, and
# it is hard to determine the actual commit that APKEditor is intended to use,
# so I think we should use the latest commit that doesn't break compilation or basic functionality.
# Currently this is the latest commit at the time of packaging.
rev = "c781eafb31f526abce9fdf406ce2c925fec20d28";
hash = "sha256-6tkvikgWMUcKwzsgbfpxlB6NZBAlZtTE34M3qPQw7Y4=";
};

patches = [
# Remove this patch after REAndroid/smali-lib#1 is merged
./fix-gradle.patch
];

mitmCache = gradle.fetchDeps {
pkg = self;
data = ./deps.json;
};
gradleBuildTask = "build";

installPhase = ''
runHook preInstall
install -Dm644 smali/build/libs/*-fat.jar $out/${self.outJar}
runHook postInstall
'';

# This fork deleted the NOTICE file from the original repo:
# https://github.com/REAndroid/smali-lib/commit/40c075a1ff5fa8e29f339f4e71f45c028789c86c#diff-dfb14fbb9e7d095209ec4cfd621069437bf9c442ff9de9d4ce889781bd0fefcf
# Here is the gist of the original NOTICE file:
# Various portions of the code are from AOSP and is licensed under Apache 2.0.
# Other parts are copyrighted by JesusFreke and Google,
# permitting redistribution (with or without modification) of source and binary
# as long as the copyright notice is present.
# For full details, see:
# https://github.com/JesusFreke/smali/blob/master/NOTICE
meta.license = with lib.licenses; [
asl20
free
UlyssesZh marked this conversation as resolved.
Show resolved Hide resolved
];
};
in
self
Loading