Set executable bits for files in EXECUTABLES.txt

Partial reimplementation of d3d8aebd1c.
This commit is contained in:
Zhaofeng Li 2022-09-13 01:34:34 -06:00 committed by midirhee12
parent 6c2e5b59a3
commit 68530b31f0
No known key found for this signature in database

View file

@ -183,6 +183,7 @@ final class TermuxInstaller {
final byte[] buffer = new byte[8096];
final List<Pair<String, String>> symlinks = new ArrayList<>(50);
final List<String> executables = new ArrayList<>(128);
final URL zipUrl = determineZipUrl(bootstrapURL);
try (ZipInputStream zipInput = new ZipInputStream(zipUrl.openStream())) {
@ -205,6 +206,12 @@ final class TermuxInstaller {
return;
}
}
} else if (zipEntry.getName().equals("EXECUTABLES.txt")) {
BufferedReader executablesReader = new BufferedReader(new InputStreamReader(zipInput));
String line;
while ((line = executablesReader.readLine()) != null) {
executables.add(line);
}
} else {
String zipEntryName = zipEntry.getName();
File targetFile = new File(TERMUX_STAGING_PREFIX_DIR_PATH, zipEntryName);
@ -232,6 +239,19 @@ final class TermuxInstaller {
}
}
if (!executables.isEmpty()) {
for (String executable : executables) {
//noinspection OctalInteger
try {
Os.chmod(TERMUX_STAGING_PREFIX_DIR + "/" + executable, 0700);
} catch (Throwable t) {
Logger.logError(LOG_TAG, "EXECUTABLES error: " + TERMUX_STAGING_PREFIX_DIR + "/" + executable + t);
}
}
} else {
throw new RuntimeException("Installer: no EXECUTABLES.txt found while extracting environment archive.");
}
if (symlinks.isEmpty())
throw new RuntimeException("No SYMLINKS.txt encountered");
for (Pair<String, String> symlink : symlinks) {