ToolsInstaller: terminators are better than seperators

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-01-09 12:20:44 +01:00
parent 2785def37a
commit 1451c4baf5

View File

@ -66,7 +66,7 @@ public final class ToolsInstaller {
new File(nativeLibraryDir, names[0]),
new File(INSTALL_DIR, names[1])));
}
script.append("exit ").append(OsConstants.EALREADY);
script.append("exit ").append(OsConstants.EALREADY).append(';');
try {
return rootShell.run(null, script.toString()) == OsConstants.EALREADY;
} catch (final ErrnoException | IOException | NoRootException ignored) {
@ -81,7 +81,7 @@ public final class ToolsInstaller {
new File(nativeLibraryDir, names[0]),
new File(localBinaryDir, names[1])));
}
script.append("exit ").append(OsConstants.EALREADY);
script.append("exit ").append(OsConstants.EALREADY).append(';');
try {
return rootShell.run(null, script.toString()) == OsConstants.EALREADY;
} catch (final ErrnoException | IOException | NoRootException ignored) {
@ -116,11 +116,11 @@ public final class ToolsInstaller {
public int install() {
if (INSTALL_DIR == null)
return OsConstants.ENOENT;
final StringBuilder script = new StringBuilder("set -ex"
+ "; trap 'mount -o ro,remount /system' EXIT; mount -o rw,remount /system");
final StringBuilder script = new StringBuilder("set -ex;");
script.append("trap 'mount -o ro,remount /system' EXIT; mount -o rw,remount /system; ");
for (final String[] names : EXECUTABLES) {
final File destination = new File(INSTALL_DIR, names[1]);
script.append(String.format("; cp '%s' '%s'; chmod 755 '%s'; restorecon '%s' ",
script.append(String.format("cp '%s' '%s'; chmod 755 '%s'; restorecon '%s' || true; ",
new File(nativeLibraryDir, names[0]), destination, destination, destination));
}
try {
@ -135,9 +135,9 @@ public final class ToolsInstaller {
}
public int symlink() {
final StringBuilder script = new StringBuilder("set -ex");
final StringBuilder script = new StringBuilder("set -ex;");
for (final String[] names : EXECUTABLES) {
script.append(String.format("; ln -fns '%s' '%s'",
script.append(String.format("ln -fns '%s' '%s'; ",
new File(nativeLibraryDir, names[0]),
new File(localBinaryDir, names[1])));
}