diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 93a20c0..c22d68a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -134,21 +134,11 @@
android:exported="false"
android:label="@string/error"
android:theme="@style/AppTheme.NoActionBar.Dark"/>
-
-
static const char *rewrite_executable(const char *filename, char *buffer, int buffer_len) {
- strcpy(buffer, "/data/data/io.neoterm/files/usr/bin/");
char *bin_match = strstr(filename, "/bin/");
if (bin_match == filename || bin_match == (filename + 4)) {
// We have either found "/bin/" at the start of the string or at
// "/xxx/bin/". Take the path after that.
- strncpy(buffer + 36, bin_match + 5, (size_t) (buffer_len - 37));
+ strncpy(buffer, bin_match + 5, (size_t) (buffer_len - 1));
filename = buffer;
}
return filename;
diff --git a/app/src/main/cpp/neoterm.cpp b/app/src/main/cpp/neoterm.cpp
index fc00e85..9a63af8 100755
--- a/app/src/main/cpp/neoterm.cpp
+++ b/app/src/main/cpp/neoterm.cpp
@@ -108,7 +108,7 @@ static int create_subprocess(JNIEnv *env,
// Show terminal output about failing exec() call:
char *error_message;
if (asprintf(&error_message, "exec(\"%s\")", cmd) == -1)
- error_message = const_cast("exec()");;
+ error_message = const_cast("exec()");
perror(error_message);
_exit(1);
}
diff --git a/app/src/main/java/io/neoterm/component/comp.kt b/app/src/main/java/io/neoterm/component/comp.kt
index be1541a..1ec3ea6 100644
--- a/app/src/main/java/io/neoterm/component/comp.kt
+++ b/app/src/main/java/io/neoterm/component/comp.kt
@@ -7,7 +7,6 @@ import io.neoterm.component.completion.CompletionComponent
import io.neoterm.component.config.ConfigureComponent
import io.neoterm.component.extrakey.ExtraKeyComponent
import io.neoterm.component.font.FontComponent
-import io.neoterm.component.pm.PackageComponent
import io.neoterm.component.profile.ProfileComponent
import io.neoterm.component.session.SessionComponent
import io.neoterm.component.session.ShellProfile
@@ -80,7 +79,6 @@ object NeoInitializer {
ComponentManager.registerComponent(UserScriptComponent::class.java)
ComponentManager.registerComponent(ExtraKeyComponent::class.java)
ComponentManager.registerComponent(CompletionComponent::class.java)
- ComponentManager.registerComponent(PackageComponent::class.java)
ComponentManager.registerComponent(SessionComponent::class.java)
ComponentManager.registerComponent(ProfileComponent::class.java)
diff --git a/app/src/main/java/io/neoterm/component/config/comp.kt b/app/src/main/java/io/neoterm/component/config/comp.kt
index af7c1d3..e732aad 100644
--- a/app/src/main/java/io/neoterm/component/config/comp.kt
+++ b/app/src/main/java/io/neoterm/component/config/comp.kt
@@ -84,18 +84,6 @@ object NeoPreference {
val dipInPixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1f, context.resources.displayMetrics)
MIN_FONT_SIZE = (4f * dipInPixels).toInt()
MAX_FONT_SIZE = 256
-
- // load apt source
- val sourceFile = File(NeoTermPath.SOURCE_FILE)
- kotlin.runCatching {
- Files.readAllBytes(sourceFile.toPath())?.let {
- val source = String(it).trim().trimEnd()
- val array = source.split(" ")
- if (array.size >= 2 && array[0] == "deb") {
- store(R.string.key_package_source, array[1])
- }
- }
- }
}
fun store(key: Int, value: Any) {
@@ -156,7 +144,6 @@ object NeoPreference {
val loginProgramPath = findLoginProgram(loginProgramName) ?: return false
store(R.string.key_general_shell, loginProgramName)
- symlinkLoginShell(loginProgramPath)
return true
}
@@ -167,39 +154,17 @@ object NeoPreference {
fun getLoginShellPath(): String {
val loginProgramName = getLoginShellName()
- // Some programs like ssh needs it
- val shell = File(NeoTermPath.NEOTERM_LOGIN_SHELL_PATH)
val loginProgramPath = findLoginProgram(loginProgramName) ?: {
setLoginShellName(DefaultValues.loginShell)
- "${NeoTermPath.USR_PATH}/bin/${DefaultValues.loginShell}"
+ loadString(R.string.key_general_shell,DefaultValues.loginShell)
}()
- if (!shell.exists()) {
- symlinkLoginShell(loginProgramPath)
- }
-
return loginProgramPath
}
fun validateFontSize(fontSize: Int): Int {
return Math.max(MIN_FONT_SIZE, Math.min(fontSize, MAX_FONT_SIZE))
}
-
- private fun symlinkLoginShell(loginProgramPath: String) {
- File(NeoTermPath.CUSTOM_PATH).mkdirs()
- try {
- val shellSymlink = File(NeoTermPath.NEOTERM_LOGIN_SHELL_PATH)
- if (shellSymlink.exists()) {
- shellSymlink.delete()
- }
- Os.symlink(loginProgramPath, NeoTermPath.NEOTERM_LOGIN_SHELL_PATH)
- Os.chmod(NeoTermPath.NEOTERM_LOGIN_SHELL_PATH, 448 /* Decimal of 0700 */)
- } catch (e: ErrnoException) {
- NLog.e("Preference", "Failed to symlink login shell: ${e.localizedMessage}")
- e.printStackTrace()
- }
- }
-
fun findLoginProgram(loginProgramName: String): String? {
val file = File("${NeoTermPath.USR_PATH}/bin", loginProgramName)
return if (file.canExecute()) file.absolutePath else null
diff --git a/app/src/main/java/io/neoterm/component/config/defaults.kt b/app/src/main/java/io/neoterm/component/config/defaults.kt
index eaf2d34..82e8085 100644
--- a/app/src/main/java/io/neoterm/component/config/defaults.kt
+++ b/app/src/main/java/io/neoterm/component/config/defaults.kt
@@ -18,7 +18,7 @@ object DefaultValues {
const val enableSpecialVolumeKeys = false
const val enableWordBasedIme = false
- const val loginShell = "bash"
+ const val loginShell = "sh"
const val initialCommand = ""
const val defaultFont = "SourceCodePro"
}
@@ -28,7 +28,6 @@ object NeoTermPath {
const val ROOT_PATH = "/data/data/io.neoterm/files"
const val USR_PATH = "$ROOT_PATH/usr"
const val HOME_PATH = "$ROOT_PATH/home"
- const val APT_BIN_PATH = "$USR_PATH/bin/apt"
const val LIB_PATH = "$USR_PATH/lib"
const val CUSTOM_PATH = "$HOME_PATH/.neoterm"
@@ -40,14 +39,4 @@ object NeoTermPath {
const val USER_SCRIPT_PATH = "$CUSTOM_PATH/script"
const val PROFILE_PATH = "$CUSTOM_PATH/profile"
- const val SOURCE_FILE = "$USR_PATH/etc/apt/sources.list"
- const val PACKAGE_LIST_DIR = "$USR_PATH/var/lib/apt/lists"
-
- private const val SOURCE = "https://raw.githubusercontent.com/NeoTerm/NeoTerm-repo/main"
-
- val DEFAULT_MAIN_PACKAGE_SOURCE: String
-
- init {
- DEFAULT_MAIN_PACKAGE_SOURCE = SOURCE
- }
}
diff --git a/app/src/main/java/io/neoterm/component/pm/NeoPackageParser.java b/app/src/main/java/io/neoterm/component/pm/NeoPackageParser.java
deleted file mode 100644
index 2c5d816..0000000
--- a/app/src/main/java/io/neoterm/component/pm/NeoPackageParser.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package io.neoterm.component.pm;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * @author kiva
- */
-
-public class NeoPackageParser {
- public interface ParseStateListener {
- void onStartState();
-
- void onEndState();
-
- NeoPackageInfo onCreatePackageInfo();
-
- void onStartParsePackage(String name, NeoPackageInfo packageInfo);
-
- void onEndParsePackage(NeoPackageInfo packageInfo);
- }
-
- private static final String
- KEY_PACKAGE_NAME = "Package",
- KEY_VERSION = "Version",
- KEY_ESSENTIAL = "Essential",
- KEY_ARCH = "Architecture",
- KEY_MAINTAINER = "Maintainer",
- KEY_INSTALLED_SIZE = "Installed-Size",
- KEY_DEPENDS = "Depends",
- KEY_FILENAME = "Filename",
- KEY_SIZE = "Size",
- KEY_MD5 = "MD5sum",
- KEY_SHA1 = "SHA1",
- KEY_SHA256 = "SHA256",
- KEY_HOMEPAGE = "Homepage",
- KEY_DESC = "Description";
-
- private BufferedReader reader;
- private ParseStateListener stateListener;
-
- NeoPackageParser(InputStream inputStream) {
- reader = new BufferedReader(new InputStreamReader(inputStream));
- }
-
- void setStateListener(ParseStateListener stateListener) {
- this.stateListener = stateListener;
- }
-
- public void parse() throws IOException {
- if (stateListener == null) {
- return;
- }
-
- String line;
- String[] splits = new String[2];
- String key = null;
- String value = null;
- boolean appendMode = false;
-
- NeoPackageInfo packageInfo = null;
-
- stateListener.onStartState();
- while ((line = reader.readLine()) != null) {
- if (line.isEmpty()) {
- continue;
- }
-
- if (splitKeyAndValue(line, splits)) {
- key = splits[0];
- value = splits[1];
- appendMode = false;
- } else {
- if (key == null) {
- // no key provided, we don't know where the value should be appended to
- continue;
- }
- // the rest value to previous key
- value = line.trim();
- appendMode = true;
- }
-
- if (key.equals(KEY_PACKAGE_NAME)) {
- if (packageInfo != null) {
- stateListener.onEndParsePackage(packageInfo);
- }
- packageInfo = stateListener.onCreatePackageInfo();
- packageInfo.setPackageName(value);
- stateListener.onStartParsePackage(value, packageInfo);
- }
-
- if (packageInfo == null) {
- continue;
- }
-
- if (appendMode) {
- value = appendToLastValue(packageInfo, key, value);
- }
-
- switch (key) {
- case KEY_ARCH:
- packageInfo.setArchitecture(Architecture.Companion.parse(value));
- break;
- case KEY_DEPENDS:
- packageInfo.setDependenciesString(value);
- break;
- case KEY_DESC:
- packageInfo.setDescription(value);
- break;
- case KEY_ESSENTIAL:
- packageInfo.setEssential(value.equals("yes"));
- break;
- case KEY_FILENAME:
- packageInfo.setFileName(value);
- break;
- case KEY_HOMEPAGE:
- packageInfo.setHomePage(value);
- break;
- case KEY_INSTALLED_SIZE:
- packageInfo.setInstalledSizeInBytes(Long.parseLong(value));
- break;
- case KEY_MAINTAINER:
- packageInfo.setMaintainer(value);
- break;
- case KEY_MD5:
- packageInfo.setMd5(value);
- break;
- case KEY_SHA1:
- packageInfo.setSha1(value);
- break;
- case KEY_SHA256:
- packageInfo.setSha256(value);
- break;
- case KEY_SIZE:
- packageInfo.setSizeInBytes(Long.parseLong(value));
- break;
- case KEY_VERSION:
- packageInfo.setVersion(value);
- break;
- }
- }
- if (packageInfo != null) {
- stateListener.onEndParsePackage(packageInfo);
- }
- stateListener.onEndState();
- }
-
- private String appendToLastValue(NeoPackageInfo packageInfo, String key, String value) {
- // Currently, only descriptions can be multiline
- switch (key) {
- case KEY_DESC:
- return packageInfo.getDescription() + " " + value;
- default:
- return value;
- }
- }
-
- private boolean splitKeyAndValue(String line, String[] splits) {
- int valueIndex = line.indexOf(':');
- if (valueIndex < 0) {
- return false;
- }
-
- splits[0] = line.substring(0, valueIndex).trim();
- splits[1] = line.substring(valueIndex == line.length() ? valueIndex : valueIndex + 1).trim();
- return true;
- }
-}
diff --git a/app/src/main/java/io/neoterm/component/pm/PackageComponent.java b/app/src/main/java/io/neoterm/component/pm/PackageComponent.java
deleted file mode 100644
index 56099bd..0000000
--- a/app/src/main/java/io/neoterm/component/pm/PackageComponent.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package io.neoterm.component.pm;
-
-import io.neoterm.component.NeoComponent;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-
-/**
- * @author kiva
- */
-
-public class PackageComponent implements NeoComponent {
- private final Object lock = new Object();
- private boolean isRefreshing = false;
- private boolean queryEnabled = true;
- private HashMap neoPackages;
-
- private NeoPackageInfo getPackageInfo(String packageName) {
- return queryEnabled ? neoPackages.get(packageName) : null;
- }
-
- public HashMap getPackages() {
- return queryEnabled ? neoPackages : new HashMap<>();
- }
-
- public int getPackageCount() {
- return queryEnabled ? neoPackages.size() : -1;
- }
-
- public SourceManager getSourceManager() {
- return new SourceManager();
- }
-
- public void reloadPackages(File packageListFile, boolean clearPrevious) throws IOException {
- synchronized (lock) {
- if (isRefreshing) {
- return;
- }
- isRefreshing = true;
- }
- tryParsePackages(packageListFile, clearPrevious);
- synchronized (lock) {
- isRefreshing = false;
- }
- }
-
- public void clearPackages() {
- if (isRefreshing) {
- return;
- }
- neoPackages.clear();
- }
-
- private void tryParsePackages(File packageListFile, final boolean clearPrevious) throws IOException {
- NeoPackageParser packageParser = new NeoPackageParser(new FileInputStream(packageListFile));
- packageParser.setStateListener(new NeoPackageParser.ParseStateListener() {
- @Override
- public void onStartState() {
- queryEnabled = false;
- if (clearPrevious) {
- neoPackages.clear();
- }
- }
-
- @Override
- public void onEndState() {
- queryEnabled = true;
- for (NeoPackageInfo info : neoPackages.values()) {
- resolveDepends(info);
- }
- }
-
- @Override
- public NeoPackageInfo onCreatePackageInfo() {
- return new NeoPackageInfo();
- }
-
- @Override
- public void onStartParsePackage(String name, NeoPackageInfo packageInfo) {
- }
-
- @Override
- public void onEndParsePackage(NeoPackageInfo packageInfo) {
- neoPackages.put(packageInfo.getPackageName(), packageInfo);
- }
- });
- packageParser.parse();
- }
-
- private void resolveDepends(NeoPackageInfo info) {
- String dep = info.getDependenciesString();
- if (dep == null) {
- return;
- }
-
- String[] splits = dep.split(",");
- NeoPackageInfo[] depends = new NeoPackageInfo[splits.length];
- info.setDependencies(depends);
-
- for (int i = 0; i < splits.length; ++i) {
- String item = splits[i].trim();
- depends[i] = getPackageInfo(item);
- }
- }
-
- @Override
- public void onServiceInit() {
- neoPackages = new HashMap<>();
- }
-
- @Override
- public void onServiceDestroy() {
- }
-
- @Override
- public void onServiceObtained() {
- }
-}
diff --git a/app/src/main/java/io/neoterm/component/pm/Source.java b/app/src/main/java/io/neoterm/component/pm/Source.java
deleted file mode 100644
index e88f960..0000000
--- a/app/src/main/java/io/neoterm/component/pm/Source.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package io.neoterm.component.pm;
-
-import io.neoterm.framework.database.annotation.ID;
-import io.neoterm.framework.database.annotation.Table;
-
-/**
- * @author kiva
- */
-@Table
-public class Source {
- @ID(autoIncrement = true)
- private int id;
-
- public String url;
-
- public String repo;
-
- public boolean enabled;
-
- public Source() {
- // for Database
- }
-
- public Source(String url, String repo, boolean enabled) {
- this.url = url;
- this.repo = repo;
- this.enabled = enabled;
- }
-}
diff --git a/app/src/main/java/io/neoterm/component/pm/data.kt b/app/src/main/java/io/neoterm/component/pm/data.kt
deleted file mode 100644
index c7029c8..0000000
--- a/app/src/main/java/io/neoterm/component/pm/data.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-package io.neoterm.component.pm
-
-enum class Architecture {
- ALL, ARM, AARCH64, X86, X86_64;
-
- companion object {
- fun parse(arch: String): Architecture {
- return when (arch) {
- "arm" -> ARM
- "aarch64" -> AARCH64
- "x86" -> X86
- "x86_64" -> X86_64
- else -> ALL
- }
- }
- }
-}
-
-class NeoPackageInfo {
- var packageName: String? = null
- var isEssential: Boolean = false
- var version: String? = null
- var architecture: Architecture = Architecture.ALL
- var maintainer: String? = null
- var installedSizeInBytes: Long = 0L
- var fileName: String? = null
- var dependenciesString: String? = null
- var dependencies: Array? = null
- var sizeInBytes: Long = 0L
- var md5: String? = null
- var sha1: String? = null
- var sha256: String? = null
- var homePage: String? = null
- var description: String? = null
-}
diff --git a/app/src/main/java/io/neoterm/component/pm/helper.kt b/app/src/main/java/io/neoterm/component/pm/helper.kt
deleted file mode 100644
index 2b7ed9a..0000000
--- a/app/src/main/java/io/neoterm/component/pm/helper.kt
+++ /dev/null
@@ -1,120 +0,0 @@
-package io.neoterm.component.pm
-
-import io.neoterm.App
-import io.neoterm.R
-import io.neoterm.component.ComponentManager
-import io.neoterm.component.config.NeoTermPath
-import io.neoterm.framework.NeoTermDatabase
-import io.neoterm.utils.NLog
-import java.io.File
-import java.net.URL
-import java.nio.file.Files
-import java.nio.file.Paths
-
-object SourceHelper {
- fun syncSource() {
- val sourceManager = ComponentManager.getComponent().sourceManager
- syncSource(sourceManager)
- }
-
- fun syncSource(sourceManager: SourceManager) {
- val content = buildString {
- this.append("# Generated by NeoTerm-Preference\n")
- sourceManager.getEnabledSources()
- .joinTo(this, "\n") { "deb [trusted=yes] ${it.url} ${it.repo}\n" }
- }
- kotlin.runCatching {
- Files.write(Paths.get(NeoTermPath.SOURCE_FILE), content.toByteArray())
- }
- }
-
- fun detectSourceFiles(): List {
- val sourceManager = ComponentManager.getComponent().sourceManager
- val sourceFiles = ArrayList()
- try {
- val prefixes = sourceManager.getEnabledSources()
- .map { detectSourceFilePrefix(it) }
- .filter { it.isNotEmpty() }
-
- File(NeoTermPath.PACKAGE_LIST_DIR)
- .listFiles()
- .filterTo(sourceFiles) { file ->
- prefixes.filter { file.name.startsWith(it) }
- .count() > 0
- }
- } catch (e: Exception) {
- sourceFiles.clear()
- NLog.e("PM", "Failed to detect source files: ${e.localizedMessage}")
- }
-
- return sourceFiles
- }
-
- fun detectSourceFilePrefix(source: Source): String {
- try {
- val url = URL(source.url)
- val builder = StringBuilder(url.host)
- if (url.port != -1) {
- builder.append(":${url.port}")
- }
-
- val path = url.path
- if (path != null && path.isNotEmpty()) {
- builder.append("_")
- val fixedPath = path.replace("/", "_").substring(1) // skip the last '/'
- builder.append(fixedPath)
- }
- builder.append("_dists_${source.repo.replace(" ".toRegex(), "_")}_binary-")
- return builder.toString()
- } catch (e: Exception) {
- NLog.e("PM", "Failed to detect source file prefix: ${e.localizedMessage}")
- return ""
- }
- }
-}
-
-class SourceManager internal constructor() {
- private val database = NeoTermDatabase.instance("sources")
-
- init {
- if (database.findAll