2019-10-13 21:13:06 +00:00
plugins {
2021-07-16 12:08:26 +00:00
id "com.android.application"
2019-10-13 21:13:06 +00:00
}
2015-10-25 14:27:32 +00:00
2022-04-28 04:33:20 +00:00
ext {
// The packageVariant defines the bootstrap variant that will be included in the app APK.
// This must be supported by com.termux.shared.termux.TermuxBootstrap.PackageVariant or app will
// crash at startup.
// Bootstrap of a different variant must not be manually installed by the user after app installation
// by replacing $PREFIX since app code is dependant on the variant used to build the APK.
2022-04-28 05:22:38 +00:00
// Currently supported values are: [ "apt-android-7" "apt-android-5" ]
2022-04-28 04:33:20 +00:00
packageVariant = System . getenv ( "TERMUX_PACKAGE_VARIANT" ) ? : "apt-android-7" // Default: "apt-android-7"
}
2015-10-25 14:27:32 +00:00
android {
2020-08-04 12:36:14 +00:00
compileSdkVersion project . properties . compileSdkVersion . toInteger ( )
2021-07-01 03:34:00 +00:00
ndkVersion = System . getenv ( "JITPACK_NDK_VERSION" ) ? : project . properties . ndkVersion
Changed: Move to semantic versioning for app and library versions and add commit hash and `github` to APK file names
The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html
APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35f and 94e01d68, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.
For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.
For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.
Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.
The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.
- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.
So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.
```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```
The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`
The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at https://github.com/termux/termux-packages/pull/7227#issuecomment-893022283.
```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```
The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`
Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.
Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
2022-01-07 17:31:06 +00:00
def appVersionName = System . getenv ( "TERMUX_APP_VERSION_NAME" ) ? : ""
def apkVersionTag = System . getenv ( "TERMUX_APK_VERSION_TAG" ) ? : ""
def splitAPKsForDebugBuilds = System . getenv ( "TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS" ) ? : "1"
def splitAPKsForReleaseBuilds = System . getenv ( "TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS" ) ? : "0" // F-Droid does not support split APKs #1904
2015-11-28 23:25:51 +00:00
dependencies {
2022-01-07 18:09:23 +00:00
implementation "androidx.annotation:annotation:1.3.0"
implementation "androidx.core:core:1.6.0"
2021-01-01 16:14:04 +00:00
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
2021-04-06 01:00:05 +00:00
implementation "androidx.preference:preference:1.1.1"
2021-03-18 16:55:42 +00:00
implementation "androidx.viewpager:viewpager:1.0.0"
2022-01-22 19:18:33 +00:00
implementation "com.google.android.material:material:1.4.0"
2021-04-06 01:00:05 +00:00
implementation "com.google.guava:guava:24.1-jre"
2021-04-07 06:31:30 +00:00
implementation "io.noties.markwon:core:$markwonVersion"
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
implementation "io.noties.markwon:linkify:$markwonVersion"
implementation "io.noties.markwon:recycler:$markwonVersion"
2021-04-06 01:00:05 +00:00
2021-04-07 06:31:30 +00:00
implementation project ( ":terminal-view" )
implementation project ( ":termux-shared" )
2015-10-25 14:27:32 +00:00
}
defaultConfig {
applicationId "com.termux"
2020-08-04 12:36:14 +00:00
minSdkVersion project . properties . minSdkVersion . toInteger ( )
targetSdkVersion project . properties . targetSdkVersion . toInteger ( )
2022-01-07 22:32:35 +00:00
versionCode 118
versionName "0.118.0"
Changed: Move to semantic versioning for app and library versions and add commit hash and `github` to APK file names
The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html
APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35f and 94e01d68, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.
For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.
For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.
Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.
The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.
- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.
So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.
```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```
The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`
The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at https://github.com/termux/termux-packages/pull/7227#issuecomment-893022283.
```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```
The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`
Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.
Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
2022-01-07 17:31:06 +00:00
if ( appVersionName ) versionName = appVersionName
validateVersionName ( versionName )
2019-10-13 21:13:06 +00:00
2022-04-28 04:33:20 +00:00
buildConfigField "String" , "TERMUX_PACKAGE_VARIANT" , "\"" + project . ext . packageVariant + "\"" // Used by TermuxApplication class
2021-03-08 10:09:22 +00:00
manifestPlaceholders . TERMUX_PACKAGE_NAME = "com.termux"
manifestPlaceholders . TERMUX_APP_NAME = "Termux"
manifestPlaceholders . TERMUX_API_APP_NAME = "Termux:API"
manifestPlaceholders . TERMUX_BOOT_APP_NAME = "Termux:Boot"
manifestPlaceholders . TERMUX_FLOAT_APP_NAME = "Termux:Float"
manifestPlaceholders . TERMUX_STYLING_APP_NAME = "Termux:Styling"
manifestPlaceholders . TERMUX_TASKER_APP_NAME = "Termux:Tasker"
manifestPlaceholders . TERMUX_WIDGET_APP_NAME = "Termux:Widget"
2019-10-13 21:13:06 +00:00
externalNativeBuild {
ndkBuild {
cFlags "-std=c11" , "-Wall" , "-Wextra" , "-Werror" , "-Os" , "-fno-stack-protector" , "-Wl,--gc-sections"
}
}
2021-07-02 01:14:38 +00:00
splits {
abi {
Changed: Move to semantic versioning for app and library versions and add commit hash and `github` to APK file names
The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html
APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35f and 94e01d68, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.
For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.
For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.
Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.
The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.
- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.
So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.
```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```
The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`
The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at https://github.com/termux/termux-packages/pull/7227#issuecomment-893022283.
```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```
The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`
Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.
Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
2022-01-07 17:31:06 +00:00
enable ( ( gradle . startParameter . taskNames . any { it . contains ( "Debug" ) } & & splitAPKsForDebugBuilds = = "1" ) | |
( gradle . startParameter . taskNames . any { it . contains ( "Release" ) } & & splitAPKsForReleaseBuilds = = "1" ) )
2021-07-02 01:14:38 +00:00
reset ( )
include 'x86' , 'x86_64' , 'armeabi-v7a' , 'arm64-v8a'
universalApk true
}
2019-10-13 21:13:06 +00:00
}
2015-10-25 14:27:32 +00:00
}
2019-10-06 19:30:57 +00:00
signingConfigs {
debug {
2022-09-21 07:30:24 +00:00
storeFile file ( 'testkey_untrusted.jks' )
2019-10-06 19:30:57 +00:00
keyAlias 'alias'
storePassword 'xrj45yWGLbsO7W0v'
keyPassword 'xrj45yWGLbsO7W0v'
}
}
2015-10-25 14:27:32 +00:00
buildTypes {
release {
2016-05-20 08:30:25 +00:00
minifyEnabled true
2021-09-04 03:34:32 +00:00
shrinkResources false // Reproducible builds
2015-10-25 14:27:32 +00:00
proguardFiles getDefaultProguardFile ( 'proguard-android.txt' ) , 'proguard-rules.pro'
}
2019-10-06 19:30:57 +00:00
debug {
signingConfig signingConfigs . debug
}
2015-10-25 14:27:32 +00:00
}
2018-09-28 22:49:05 +00:00
compileOptions {
2022-04-25 21:02:26 +00:00
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
2018-09-28 22:49:05 +00:00
sourceCompatibility JavaVersion . VERSION_1_8
targetCompatibility JavaVersion . VERSION_1_8
}
2019-10-13 21:13:06 +00:00
externalNativeBuild {
ndkBuild {
path "src/main/cpp/Android.mk"
}
}
2020-01-05 00:02:13 +00:00
2021-01-01 16:41:18 +00:00
lintOptions {
disable 'ProtectedPermissions'
}
2020-01-05 00:02:13 +00:00
testOptions {
unitTests {
includeAndroidResources = true
}
}
2021-07-16 09:42:15 +00:00
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
2021-07-16 12:08:26 +00:00
applicationVariants . all { variant - >
variant . outputs . all { output - >
if ( variant . buildType . name = = "debug" ) {
def abi = output . getFilter ( com . android . build . OutputFile . ABI )
2022-04-28 04:33:20 +00:00
outputFileName = new File ( "termux-app_" + ( apkVersionTag ? apkVersionTag : project . ext . packageVariant + "-" + "debug" ) + "_" + ( abi ? abi : "universal" ) + ".apk" )
Changed: Move to semantic versioning for app and library versions and add commit hash and `github` to APK file names
The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html
APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35f and 94e01d68, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.
For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.
For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.
Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.
The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.
- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.
So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.
```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```
The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`
The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at https://github.com/termux/termux-packages/pull/7227#issuecomment-893022283.
```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```
The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`
Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.
Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
2022-01-07 17:31:06 +00:00
} else if ( variant . buildType . name = = "release" ) {
def abi = output . getFilter ( com . android . build . OutputFile . ABI )
2022-04-28 04:33:20 +00:00
outputFileName = new File ( "termux-app_" + ( apkVersionTag ? apkVersionTag : project . ext . packageVariant + "-" + "release" ) + "_" + ( abi ? abi : "universal" ) + ".apk" )
2021-07-16 12:08:26 +00:00
}
}
}
2015-10-25 14:27:32 +00:00
}
dependencies {
2021-04-07 06:31:30 +00:00
testImplementation "junit:junit:4.13.2"
2023-04-16 03:22:21 +00:00
testImplementation "org.robolectric:robolectric:4.10"
2022-04-25 21:02:26 +00:00
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
2015-10-25 14:27:32 +00:00
}
2019-05-26 22:07:41 +00:00
task versionName {
2021-07-16 12:08:26 +00:00
doLast {
print android . defaultConfig . versionName
}
2019-05-26 22:07:41 +00:00
}
2019-10-13 21:13:06 +00:00
Changed: Move to semantic versioning for app and library versions and add commit hash and `github` to APK file names
The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html
APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35f and 94e01d68, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.
For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.
For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.
Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.
The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.
- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.
So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.
```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```
The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`
The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at https://github.com/termux/termux-packages/pull/7227#issuecomment-893022283.
```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```
The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`
Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.
Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
2022-01-07 17:31:06 +00:00
def validateVersionName ( String versionName ) {
// https://semver.org/spec/v2.0.0.html#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
// ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
if ( ! java . util . regex . Pattern . matches ( "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?\$" , versionName ) )
throw new GradleException ( "The versionName '" + versionName + "' is not a valid version as per semantic version '2.0.0' spec in the format 'major.minor.patch(-prerelease)(+buildmetadata)'. https://semver.org/spec/v2.0.0.html." )
}
2021-02-11 15:51:46 +00:00
def downloadBootstrap ( String arch , String expectedChecksum , String version ) {
2019-10-13 21:13:06 +00:00
def digest = java . security . MessageDigest . getInstance ( "SHA-256" )
def localUrl = "src/main/cpp/bootstrap-" + arch + ".zip"
def file = new File ( projectDir , localUrl )
if ( file . exists ( ) ) {
def buffer = new byte [ 8192 ]
def input = new FileInputStream ( file )
while ( true ) {
def readBytes = input . read ( buffer )
if ( readBytes < 0 ) break
digest . update ( buffer , 0 , readBytes )
}
def checksum = new BigInteger ( 1 , digest . digest ( ) ) . toString ( 16 )
2022-01-07 22:30:15 +00:00
while ( checksum . length ( ) < 64 ) { checksum = "0" + checksum }
2019-10-13 21:13:06 +00:00
if ( checksum = = expectedChecksum ) {
return
} else {
2022-04-28 04:33:20 +00:00
logger . quiet ( "Deleting old local file with wrong hash: " + localUrl + ": expected: " + expectedChecksum + ", actual: " + checksum )
2019-10-13 21:13:06 +00:00
file . delete ( )
}
}
2021-02-11 15:51:46 +00:00
def remoteUrl = "https://github.com/termux/termux-packages/releases/download/bootstrap-" + version + "/bootstrap-" + arch + ".zip"
2019-10-13 21:13:06 +00:00
logger . quiet ( "Downloading " + remoteUrl + " ..." )
file . parentFile . mkdirs ( )
def out = new BufferedOutputStream ( new FileOutputStream ( file ) )
def connection = new URL ( remoteUrl ) . openConnection ( )
connection . setInstanceFollowRedirects ( true )
def digestStream = new java . security . DigestInputStream ( connection . inputStream , digest )
out < < digestStream
out . close ( )
def checksum = new BigInteger ( 1 , digest . digest ( ) ) . toString ( 16 )
2022-01-07 19:23:40 +00:00
while ( checksum . length ( ) < 64 ) { checksum = "0" + checksum }
2019-10-13 21:13:06 +00:00
if ( checksum ! = expectedChecksum ) {
file . delete ( )
throw new GradleException ( "Wrong checksum for " + remoteUrl + ": expected: " + expectedChecksum + ", actual: " + checksum )
}
}
clean {
doLast {
def tree = fileTree ( new File ( projectDir , 'src/main/cpp' ) )
tree . include 'bootstrap-*.zip'
tree . each { it . delete ( ) }
}
}
2021-04-12 09:32:02 +00:00
task downloadBootstraps ( ) {
2019-10-13 21:13:06 +00:00
doLast {
2022-04-28 04:33:20 +00:00
def packageVariant = project . ext . packageVariant
if ( packageVariant = = "apt-android-7" ) {
2022-04-28 20:44:07 +00:00
def version = "2022.04.28-r5" + "+" + packageVariant
downloadBootstrap ( "aarch64" , "4a51a7eb209fe82efc24d52e3cccc13165f27377290687cb82038cbd8e948430" , version )
downloadBootstrap ( "arm" , "6459a786acbae50d4c8a36fa1c3de6a4dd2d482572f6d54f73274709bd627325" , version )
downloadBootstrap ( "i686" , "919d212b2f19e08600938db4079e794e947365022dbfd50ac342c50fcedcd7be" , version )
downloadBootstrap ( "x86_64" , "61b02fdc03ea4f5d9da8d8cf018013fdc6659e6da6cbf44e9b24d1c623580b89" , version )
2022-04-28 05:22:38 +00:00
} else if ( packageVariant = = "apt-android-5" ) {
2022-04-28 19:54:18 +00:00
def version = "2022.04.28-r6" + "+" + packageVariant
downloadBootstrap ( "aarch64" , "913609d439415c828c5640be1b0561467e539cb1c7080662decaaca2fb4820e7" , version )
downloadBootstrap ( "arm" , "26bfb45304c946170db69108e5eb6e3641aad751406ce106c80df80cad2eccf8" , version )
downloadBootstrap ( "i686" , "46dcfeb5eef67ba765498db9fe4c50dc4690805139aa0dd141a9d8ee0693cd27" , version )
downloadBootstrap ( "x86_64" , "615b590679ee6cd885b7fd2ff9473c845e920f9b422f790bb158c63fe42b8481" , version )
2022-04-28 04:33:20 +00:00
} else {
throw new GradleException ( "Unsupported TERMUX_PACKAGE_VARIANT \"" + packageVariant + "\"" )
}
2019-10-13 21:13:06 +00:00
}
}
afterEvaluate {
2021-07-16 12:08:26 +00:00
android . applicationVariants . all { variant - >
variant . javaCompileProvider . get ( ) . dependsOn ( downloadBootstraps )
}
2019-10-13 21:13:06 +00:00
}