Skip to content

Commit 236cae6

Browse files
authored
fix: use binary name "aapt2" as prefix for temporary file (#4001)
1 parent ded2957 commit 236cae6

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AaptManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public static File getBinaryFile() throws AndrolibException {
4545

4646
StringBuilder binPath = new StringBuilder("/prebuilt/");
4747
if (OSDetection.isUnix()) {
48-
binPath.append("linux");
48+
binPath.append("linux"); // ELF 64-bit LSB executable, x86-64
4949
} else if (OSDetection.isMacOSX()) {
50-
binPath.append("macosx");
50+
binPath.append("macosx"); // fat binary x86_64 + arm64
5151
} else if (OSDetection.isWindows()) {
52-
binPath.append("windows");
52+
binPath.append("windows"); // x86_64
5353
} else {
5454
throw new AndrolibException("Could not identify platform: " + OSDetection.returnOS());
5555
}
@@ -61,7 +61,7 @@ public static File getBinaryFile() throws AndrolibException {
6161

6262
File binFile;
6363
try {
64-
binFile = Jar.getResourceAsFile(AaptManager.class, binPath.toString());
64+
binFile = Jar.getResourceAsFile(AaptManager.class, binPath.toString(), binName + "_");
6565
} catch (BrutException ex) {
6666
throw new AndrolibException(ex);
6767
}

brut.j.util/src/main/java/brut/util/Jar.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ private Jar() {
3636
}
3737

3838
public static File getResourceAsFile(Class<?> clz, String name) throws BrutException {
39+
return getResourceAsFile(clz, name, "brut_util_Jar_");
40+
}
41+
42+
public static File getResourceAsFile(Class<?> clz, String name, String tmpPrefix) throws BrutException {
3943
File file = sExtracted.get(name);
4044
if (file == null) {
41-
file = extractToTmp(clz, name);
45+
file = extractToTmp(clz, name, tmpPrefix);
4246
sExtracted.put(name, file);
4347
}
4448
return file;

brut.j.util/src/main/java/brut/util/OS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public static void exec(String[] cmd) throws BrutException {
145145

146146
int exitValue = ps.waitFor();
147147
if (exitValue != 0) {
148-
throw new BrutException("could not exec (exit code = " + exitValue + "): " + Arrays.toString(cmd));
148+
throw new BrutException("Execution failed (exit code = " + exitValue + "): " + Arrays.toString(cmd));
149149
}
150150
} catch (IOException ex) {
151151
throw new BrutException("could not exec: " + Arrays.toString(cmd), ex);

0 commit comments

Comments
 (0)