mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix(terminal): bootstrap packages are not installed on first install
This commit is contained in:
@@ -52,8 +52,8 @@ class TerminalActivity : TermuxActivity() {
|
||||
}
|
||||
|
||||
override fun onServiceConnected(componentName: ComponentName?, service: IBinder?) {
|
||||
writeSourcesList()
|
||||
super.onServiceConnected(componentName, service)
|
||||
writeSourcesList()
|
||||
}
|
||||
|
||||
private fun writeSourcesList() {
|
||||
|
||||
@@ -33,10 +33,13 @@ import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import static com.itsaky.androidide.utils.Environment.PREFIX;
|
||||
import static com.itsaky.androidide.utils.Environment.SHELL;
|
||||
import static com.termux.shared.termux.TermuxConstants.TERMUX_PREFIX_DIR;
|
||||
import static com.termux.shared.termux.TermuxConstants.TERMUX_PREFIX_DIR_PATH;
|
||||
import static com.termux.shared.termux.TermuxConstants.TERMUX_STAGING_PREFIX_DIR;
|
||||
import static com.termux.shared.termux.TermuxConstants.TERMUX_STAGING_PREFIX_DIR_PATH;
|
||||
import static com.termux.shared.termux.shell.TermuxShellUtils.shellExists;
|
||||
|
||||
/**
|
||||
* Install the Termux bootstrap packages if necessary by following the below steps:
|
||||
@@ -102,8 +105,7 @@ public final class TermuxInstaller {
|
||||
return;
|
||||
}
|
||||
|
||||
// If prefix directory exists, even if its a symlink to a valid directory and symlink is not broken/dangling
|
||||
if (FileUtils.directoryFileExists(TERMUX_PREFIX_DIR_PATH, true)) {
|
||||
if (shellExists(false)) {
|
||||
if (TermuxFileUtils.isTermuxPrefixDirectoryEmpty()) {
|
||||
Logger.logInfo(LOG_TAG, "The termux prefix directory \"" + TERMUX_PREFIX_DIR_PATH + "\" exists but is empty or only contains specific unimportant files.");
|
||||
} else {
|
||||
|
||||
+5
-1
@@ -31,7 +31,11 @@ public class AndroidShellEnvironment extends UnixShellEnvironment {
|
||||
@NonNull
|
||||
@Override
|
||||
public HashMap<String, String> getEnvironment(@NonNull Context currentPackageContext, boolean isFailSafe) {
|
||||
HashMap<String, String> environment = new HashMap<>(Environment.getEnvironment());
|
||||
HashMap<String, String> environment = new HashMap<>();
|
||||
|
||||
if (!isFailSafe) {
|
||||
environment.putAll(Environment.getEnvironment());
|
||||
}
|
||||
|
||||
environment.put(ENV_HOME, "/");
|
||||
environment.put(ENV_LANG, "en_US.UTF-8");
|
||||
|
||||
+14
@@ -3,13 +3,16 @@ package com.termux.shared.termux.shell;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.itsaky.androidide.utils.Environment;
|
||||
import com.termux.shared.errors.Error;
|
||||
import com.termux.shared.file.filesystem.FileTypes;
|
||||
import com.termux.shared.shell.command.environment.UnixShellEnvironment;
|
||||
import com.termux.shared.termux.TermuxConstants;
|
||||
import com.termux.shared.file.FileUtils;
|
||||
import com.termux.shared.logger.Logger;
|
||||
import com.termux.shared.termux.settings.properties.TermuxAppSharedProperties;
|
||||
|
||||
import com.termux.shared.termux.shell.command.environment.TermuxShellEnvironment;
|
||||
import org.apache.commons.io.filefilter.TrueFileFilter;
|
||||
|
||||
import java.io.File;
|
||||
@@ -23,6 +26,17 @@ public class TermuxShellUtils {
|
||||
|
||||
private static final String LOG_TAG = "TermuxShellUtils";
|
||||
|
||||
public static boolean shellExists(boolean failsafe) {
|
||||
for (String shellBinary : UnixShellEnvironment.LOGIN_SHELL_BINARIES) {
|
||||
File shellFile = new File(Environment.PREFIX, shellBinary);
|
||||
if (shellFile.canExecute()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup shell command arguments for the execute. The file interpreter may be prefixed to
|
||||
* command arguments if needed.
|
||||
|
||||
Reference in New Issue
Block a user