Compare commits

...

11 Commits

Author SHA1 Message Date
agnostic-apollo
8f9771adce Bump to v0.111 2021-04-21 14:07:25 +05:00
agnostic-apollo
b34f60b1b0 Fix the bootstrap reinstallation logic for when PREFIX is a symlink
Changes were made to bootstrap reinstallation logic in 107927f5, but it wasn't considering that PREFIX may be a symlink file to a directory instead of a directory file. With this commit, the previous behaviour of termux is restored where PREFIX can optionally be a symlink to a valid directory where the symlink isn't broken/dangling.
2021-04-21 14:06:57 +05:00
agnostic-apollo
0fe608f91e Revert "Bump to v0.111"
This reverts commit 5d911ef93f.
2021-04-21 13:55:25 +05:00
agnostic-apollo
5d911ef93f Bump to v0.111 2021-04-21 07:01:59 +05:00
agnostic-apollo
1d06ff9bf0 Bump gradle to v7.0 2021-04-20 13:05:15 +05:00
agnostic-apollo
107927f5a1 Fix cases where bootstrap was not reinstalled even if PREFIX was broken
The TermuxInstaller.setupBootstrapIfNeeded() previously only checked if PREFIX directory existed or not to decide whether to install bootstrap or not. Now it will also check if its empty or only contains the tmp directory, since in that case the PREFIX must be deleted and bootstrap reinstalled, otherwise a broken environment will be loaded since no termux binaries/libs would exist.

It will now also delete any file at the prefix or staging prefix path, even if its not a directory. If the user does not want the bootstrap to be installed for some reason, then any other file other than "tmp" can be created under PREFIX.
2021-04-20 12:49:43 +05:00
agnostic-apollo
d6eb5e3511 Fix termux-reset
The TMPDIR was being automatically cleared and recreated even if it didn't already exist when TermuxService was stopped. This left an empty TMPDIR in the PREFIX directory when termux-reset was run and on termux restart the bootstrap wasn't installed again because PREFIX directory already existed. This resulted in a broken environment since no binaries/libs existed under PREFIX and /system/bin/sh was loaded.

This issue was created due to v0.109.
2021-04-20 12:39:54 +05:00
agnostic-apollo
a6ae656c9f Bump to v0.110 2021-04-15 05:14:31 +05:00
agnostic-apollo
3af5730354 Add support for allowing IDE to show documentation in .gradle files 2021-04-15 05:03:44 +05:00
agnostic-apollo
3306c3c2a2 Add support to include source jar files for libraries published by termux 2021-04-15 05:01:41 +05:00
agnostic-apollo
cde0bd2246 Prevent DebuggingPreferencesFragment and TerminalIOPreferencesFragment from being removed during minification
Fixes #2005
2021-04-15 02:15:55 +05:00
11 changed files with 59 additions and 14 deletions

View File

@@ -26,8 +26,8 @@ android {
applicationId "com.termux"
minSdkVersion project.properties.minSdkVersion.toInteger()
targetSdkVersion project.properties.targetSdkVersion.toInteger()
versionCode 109
versionName "0.109"
versionCode project.properties.termuxVersionCode.toInteger()
versionName project.properties.termuxVersion
manifestPlaceholders.TERMUX_PACKAGE_NAME = "com.termux"
manifestPlaceholders.TERMUX_APP_NAME = "Termux"

View File

@@ -62,10 +62,21 @@ final class TermuxInstaller {
return;
}
final String PREFIX_FILE_PATH = TermuxConstants.TERMUX_PREFIX_DIR_PATH;
final File PREFIX_FILE = TermuxConstants.TERMUX_PREFIX_DIR;
if (PREFIX_FILE.isDirectory()) {
whenDone.run();
return;
// If prefix directory exists, even if its a symlink to a valid directory and symlink is not broken/dangling
if (FileUtils.directoryFileExists(PREFIX_FILE_PATH, true)) {
File[] PREFIX_FILE_LIST = PREFIX_FILE.listFiles();
// If prefix directory is empty or only contains the tmp directory
if(PREFIX_FILE_LIST == null || PREFIX_FILE_LIST.length == 0 || (PREFIX_FILE_LIST.length == 1 && TermuxConstants.TERMUX_TMP_PREFIX_DIR_PATH.equals(PREFIX_FILE_LIST[0].getAbsolutePath()))) {
Logger.logInfo(LOG_TAG, "The prefix directory \"" + PREFIX_FILE_PATH + "\" exists but is empty or only contains the tmp directory.");
} else {
whenDone.run();
return;
}
} else if (FileUtils.fileExists(PREFIX_FILE_PATH, false)) {
Logger.logInfo(LOG_TAG, "The prefix directory \"" + PREFIX_FILE_PATH + "\" does not exist but another file exists at its destination.");
}
final ProgressDialog progress = ProgressDialog.show(activity, null, activity.getString(R.string.bootstrap_installer_body), true, false);
@@ -80,12 +91,19 @@ final class TermuxInstaller {
final String STAGING_PREFIX_PATH = TermuxConstants.TERMUX_STAGING_PREFIX_DIR_PATH;
final File STAGING_PREFIX_FILE = new File(STAGING_PREFIX_PATH);
errmsg = FileUtils.clearDirectory(activity, "prefix staging directory", STAGING_PREFIX_PATH);
// Delete prefix staging directory or any file at its destination
errmsg = FileUtils.deleteFile(activity, "prefix staging directory", STAGING_PREFIX_PATH, true);
if (errmsg != null) {
throw new RuntimeException(errmsg);
}
Logger.logInfo(LOG_TAG, "Extracting bootstrap zip to prefix staging directory \"" + TermuxConstants.TERMUX_STAGING_PREFIX_DIR_PATH + "\".");
// Delete prefix directory or any file at its destination
errmsg = FileUtils.deleteFile(activity, "prefix directory", PREFIX_FILE_PATH, true);
if (errmsg != null) {
throw new RuntimeException(errmsg);
}
Logger.logInfo(LOG_TAG, "Extracting bootstrap zip to prefix staging directory \"" + STAGING_PREFIX_PATH + "\".");
final byte[] buffer = new byte[8096];
final List<Pair<String, String>> symlinks = new ArrayList<>(50);

View File

@@ -157,7 +157,7 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas
public void onDestroy() {
Logger.logVerbose(LOG_TAG, "onDestroy");
ShellUtils.clearTermuxTMPDIR(this);
ShellUtils.clearTermuxTMPDIR(this, true);
actionReleaseWakeLock(false);
if (!mWantsToStop)

View File

@@ -3,6 +3,7 @@ package com.termux.app.fragments.settings;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceCategory;
@@ -14,6 +15,7 @@ import com.termux.R;
import com.termux.shared.settings.preferences.TermuxAppSharedPreferences;
import com.termux.shared.logger.Logger;
@Keep
public class DebuggingPreferencesFragment extends PreferenceFragmentCompat {
@Override

View File

@@ -3,6 +3,7 @@ package com.termux.app.fragments.settings;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Keep;
import androidx.preference.PreferenceDataStore;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
@@ -10,6 +11,7 @@ import androidx.preference.PreferenceManager;
import com.termux.R;
import com.termux.shared.settings.preferences.TermuxAppSharedPreferences;
@Keep
public class TerminalIOPreferencesFragment extends PreferenceFragmentCompat {
@Override

View File

@@ -15,6 +15,9 @@
org.gradle.jvmargs=-Xmx2048M
android.useAndroidX=true
termuxVersion=0.111
termuxVersionCode=111
minSdkVersion=24
targetSdkVersion=28
ndkVersion=22.0.7026061

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -53,13 +53,18 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
}
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}
publishing {
publications {
bar(MavenPublication) {
groupId 'com.termux'
artifactId 'terminal-emulator'
version '0.109'
version project.properties.termuxVersion
artifact(sourceJar)
artifact("$buildDir/outputs/aar/terminal-emulator-release.aar")
}
}

View File

@@ -29,7 +29,12 @@ android {
}
dependencies {
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
}
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}
publishing {
@@ -37,7 +42,8 @@ publishing {
bar(MavenPublication) {
groupId 'com.termux'
artifactId 'terminal-view'
version '0.109'
version project.properties.termuxVersion
artifact(sourceJar)
artifact("$buildDir/outputs/aar/terminal-view-release.aar")
}
}

View File

@@ -45,12 +45,18 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}
publishing {
publications {
bar(MavenPublication) {
groupId 'com.termux'
artifactId 'termux-shared'
version '0.109'
version project.properties.termuxVersion
artifact(sourceJar)
artifact("$buildDir/outputs/aar/termux-shared-release.aar")
}
}

View File

@@ -150,7 +150,10 @@ public class ShellUtils {
return (lastSlash == -1) ? executable : executable.substring(lastSlash + 1);
}
public static void clearTermuxTMPDIR(Context context) {
public static void clearTermuxTMPDIR(Context context, boolean onlyIfExists) {
if(onlyIfExists && !FileUtils.directoryFileExists(TermuxConstants.TERMUX_TMP_PREFIX_DIR_PATH, false))
return;
String errmsg;
errmsg = FileUtils.clearDirectory(context, "$TMPDIR", FileUtils.getCanonicalPath(TermuxConstants.TERMUX_TMP_PREFIX_DIR_PATH, null, false));
if (errmsg != null) {