diff --git a/README.md b/README.md index 80da2c58..3bdedf20 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,24 @@ +Fork information +================ + +Nix on Android, in a single-click installable package. +It's kind of a mess for now, but hey, it works! + +This repository is a fork of Termux-the-terminal-emulator used to execute +Nix-on-Droid. + +All credit goes to Termux: + +* https://github.com/termux/termux-app +* https://termux.com + +For the script responsible for the initial bootstrap zipball generation +please refer to https://github.com/t184256/nix-on-droid-bootstrap + + + +Original README starts here: + [![Travis build status](https://travis-ci.org/termux/termux-app.svg?branch=master)](https://travis-ci.org/termux/termux-app) [![Join the chat at https://gitter.im/termux/termux](https://badges.gitter.im/termux/termux.svg)](https://gitter.im/termux/termux) @@ -30,3 +51,4 @@ Terminal emulators * xterm: The grandfather of terminal emulators. [Source](http://invisible-island.net/datafiles/release/xterm.tar.gz). * Connectbot: Android SSH client. [Source](https://github.com/connectbot/connectbot) * Android Terminal Emulator: Android terminal app which Termux terminal handling is based on. Inactive. [Source](https://github.com/jackpal/Android-Terminal-Emulator). + diff --git a/app/build.gradle b/app/build.gradle index f75d8eb8..c2ddb1be 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,8 @@ android { minSdkVersion 21 targetSdkVersion 28 versionCode 66 - versionName "0.66_v0.4_by-xeffyr" + versionName "0.66_v0.1.0_nix" + applicationIdSuffix ".nix" } buildTypes { @@ -30,6 +31,10 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + lintOptions { + abortOnError false + } } dependencies { @@ -38,7 +43,7 @@ dependencies { preBuild.doFirst { assert file("./src/main/assets/bootstrap-aarch64").exists() - assert file("./src/main/assets/bootstrap-arm").exists() - assert file("./src/main/assets/bootstrap-i686").exists() - assert file("./src/main/assets/bootstrap-x86_64").exists() + //assert file("./src/main/assets/bootstrap-arm").exists() + //assert file("./src/main/assets/bootstrap-i686").exists() + //assert file("./src/main/assets/bootstrap-x86_64").exists() } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 335a6406..8986a678 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ xmlns:tools="http://schemas.android.com/tools" package="com.termux" android:installLocation="internalOnly" - android:sharedUserId="com.termux" + android:sharedUserId="com.termux.nix" android:sharedUserLabel="@string/shared_user_label" > @@ -114,6 +114,7 @@ + + diff --git a/app/src/main/java/com/termux/app/TermuxActivity.java b/app/src/main/java/com/termux/app/TermuxActivity.java index dba3cbbd..c6a617f4 100644 --- a/app/src/main/java/com/termux/app/TermuxActivity.java +++ b/app/src/main/java/com/termux/app/TermuxActivity.java @@ -153,8 +153,8 @@ public final class TermuxActivity extends Activity implements ServiceConnection void checkForFontAndColors() { try { - @SuppressLint("SdCardPath") File fontFile = new File("/data/data/com.termux/files/home/.termux/font.ttf"); - @SuppressLint("SdCardPath") File colorsFile = new File("/data/data/com.termux/files/home/.termux/colors.properties"); + @SuppressLint("SdCardPath") File fontFile = new File("/data/data/com.termux.nix/files/home/.termux/font.ttf"); + @SuppressLint("SdCardPath") File colorsFile = new File("/data/data/com.termux.nix/files/home/.termux/colors.properties"); final Properties props = new Properties(); if (colorsFile.isFile()) { diff --git a/app/src/main/java/com/termux/app/TermuxInstaller.java b/app/src/main/java/com/termux/app/TermuxInstaller.java index 68dfd8dc..aa4dac5f 100644 --- a/app/src/main/java/com/termux/app/TermuxInstaller.java +++ b/app/src/main/java/com/termux/app/TermuxInstaller.java @@ -136,7 +136,11 @@ final class TermuxInstaller { if (!executables.isEmpty()) { for (String executable : executables) { //noinspection OctalInteger + try { Os.chmod(STAGING_PREFIX_PATH + "/" + executable, 0700); + } catch (Throwable t) { + Log.e(EmulatorDebug.LOG_TAG, "EXECUTABLES error: " + STAGING_PREFIX_FILE + "/" + executable, t); + } } } else { throw new RuntimeException("Installer: no EXECUTABLES.txt found while extracting environment archive."); @@ -144,7 +148,11 @@ final class TermuxInstaller { if (!symlinks.isEmpty()) { for (Pair symlink : symlinks) { + try { Os.symlink(symlink.first, symlink.second); + } catch (Throwable t) { + Log.e(EmulatorDebug.LOG_TAG, "SYMLINKS error: " + symlink.first + " ! " + symlink.second, t); + } } } else { throw new RuntimeException("Installer: no SYMLINKS.txt found while extracting environment archive."); diff --git a/app/src/main/java/com/termux/app/TermuxService.java b/app/src/main/java/com/termux/app/TermuxService.java index f162d4b6..ffd0e7e1 100644 --- a/app/src/main/java/com/termux/app/TermuxService.java +++ b/app/src/main/java/com/termux/app/TermuxService.java @@ -46,7 +46,7 @@ public final class TermuxService extends Service implements SessionChangedCallba /** Note that this is a symlink on the Android M preview. */ @SuppressLint("SdCardPath") - public static final String FILES_PATH = "/data/data/com.termux/files"; + public static final String FILES_PATH = "/data/data/com.termux.nix/files"; public static final String PREFIX_PATH = FILES_PATH + "/usr"; public static final String HOME_PATH = FILES_PATH + "/home"; @@ -269,6 +269,7 @@ public final class TermuxService extends Service implements SessionChangedCallba if (executablePath == null) { for (String shellBinary : new String[]{"login", "bash", "zsh"}) { File shellFile = new File(PREFIX_PATH + "/bin/" + shellBinary); + Log.w(EmulatorDebug.LOG_TAG, "sf: " + shellFile + " " + shellFile.canExecute()); if (shellFile.canExecute()) { executablePath = shellFile.getAbsolutePath(); break; @@ -279,6 +280,7 @@ public final class TermuxService extends Service implements SessionChangedCallba // Fall back to system shell as last resort: executablePath = "/system/bin/sh"; } + Log.w(EmulatorDebug.LOG_TAG, "Shell: " + executablePath); isLoginShell = true; } diff --git a/app/src/main/java/com/termux/widget/TermuxWidgetService.java b/app/src/main/java/com/termux/widget/TermuxWidgetService.java index 3048db07..c2467431 100644 --- a/app/src/main/java/com/termux/widget/TermuxWidgetService.java +++ b/app/src/main/java/com/termux/widget/TermuxWidgetService.java @@ -16,7 +16,7 @@ import java.util.List; public final class TermuxWidgetService extends RemoteViewsService { @SuppressLint("SdCardPath") - public static final File SHORTCUTS_DIR = new File("/data/data/com.termux/files/home/.shortcuts"); + public static final File SHORTCUTS_DIR = new File("/data/data/com.termux.nix/files/home/.shortcuts"); public static final class TermuxWidgetItem { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dc3ad0ef..820a3c7c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,10 +1,10 @@ - Termux - Termux user - Termux (failsafe) - Termux:Execute - Allows application to execute arbitrary shell commands within Termux. + Nix + Nix user + Nix (failsafe shell) + Nix:Execute + Allows application to execute arbitrary shell commands within Nix (Termux). New session Failsafe Keyboard @@ -16,10 +16,10 @@ Installing… Unable to install - Termux was unable to install the bootstrap packages.\n\nCheck your network connection and try again. + Nix was unable to install the bootstrap package. Abort Try again - Termux can only be installed on the primary user account. + Nix can only be installed on the primary user account. Max terminals reached Close down existing ones before creating new. diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..0bbdeda3 --- /dev/null +++ b/shell.nix @@ -0,0 +1,45 @@ +{ pkgs ? import {} }: + +let fhs = pkgs.buildFHSUserEnv { + name = "android-env"; + targetPkgs = pkgs: with pkgs; + [ git + gitRepo + gnupg + python2 + curl + procps + openssl + gnumake + nettools + androidenv.platformTools + jdk + schedtool + utillinux + m4 + gperf + perl + libxml2 + zip + unzip + bison + flex + lzop + file + gnumake + ]; + multiPkgs = pkgs: with pkgs; + [ zlib + ]; + runScript = "bash"; + profile = '' + export USE_CCACHE=1 + export ANDROID_JAVA_HOME=${pkgs.jdk.home} + export JAVA_HOME=${pkgs.jdk.home} + ''; +}; +in pkgs.stdenv.mkDerivation { + name = "android-env-shell"; + nativeBuildInputs = [ fhs ]; + shellHook = "exec android-env"; +} diff --git a/terminal-emulator/build.gradle b/terminal-emulator/build.gradle index 320e549d..40502a02 100644 --- a/terminal-emulator/build.gradle +++ b/terminal-emulator/build.gradle @@ -30,7 +30,7 @@ android { } ndk { - abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' + abiFilters 'arm64-v8a' } }