Compare commits

..

9 Commits

Author SHA1 Message Date
oSumAtrIX
b6b6f159cc refactor 2026-01-28 20:10:14 +01:00
oSumAtrIX
b140badcf1 update to newest patcher v22 2026-01-28 16:27:41 +01:00
oSumAtrIX
e6032a1e4f update to patcher v22 for dev 2026-01-28 15:26:40 +01:00
oSumAtrIX
0725395b23 build: Bump Gradle 2026-01-28 15:26:27 +01:00
Pun Butrach
731865e167 docs: Use American spelling (#381) 2025-12-14 16:39:29 +01:00
Pun Butrach
8e18082862 ci: Use default fetch-depth of 1 for checkout step (#375) 2025-07-08 18:01:12 +02:00
Pun Butrach
77862e8940 ci: Attest release artifacts (#367)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2025-05-22 14:54:29 +02:00
semantic-release-bot
f29eda8674 chore: Release v5.0.2-dev.2 [skip ci]
## [5.0.2-dev.2](https://github.com/ReVanced/revanced-cli/compare/v5.0.2-dev.1...v5.0.2-dev.2) (2025-04-25)

### Bug Fixes

* Do not print patch description if null ([bba90fe](bba90fede8))
2025-04-25 20:29:10 +00:00
oSumAtrIX
bba90fede8 fix: Do not print patch description if null 2025-04-25 22:27:11 +02:00
14 changed files with 133 additions and 118 deletions

View File

@@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Gradle
uses: burrunan/gradle-cache-action@v1

View File

@@ -12,15 +12,12 @@ jobs:
name: Release
permissions:
contents: write
id-token: write
attestations: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Make sure the release step uses its own credentials:
# https://github.com/cycjimmy/semantic-release-action#private-packages
persist-credentials: false
fetch-depth: 0
- name: Cache Gradle
uses: burrunan/gradle-cache-action@v1
@@ -47,6 +44,14 @@ jobs:
fingerprint: ${{ vars.GPG_FINGERPRINT }}
- name: Release
uses: cycjimmy/semantic-release-action@v4
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm exec semantic-release
- name: Attest
if: steps.release.outputs.new_release_published == 'true'
uses: actions/attest-build-provenance@v2
with:
subject-name: 'ReVanced CLI ${{ steps.release.outputs.new_release_git_tag }}'
subject-path: build/libs/revanced-cli*.jar

View File

@@ -1,3 +1,10 @@
## [5.0.2-dev.2](https://github.com/ReVanced/revanced-cli/compare/v5.0.2-dev.1...v5.0.2-dev.2) (2025-04-25)
### Bug Fixes
* Do not print patch description if null ([bba90fe](https://github.com/ReVanced/revanced-cli/commit/bba90fede85e4632efb9509e5bcf9091a9435549))
## [5.0.2-dev.1](https://github.com/ReVanced/revanced-cli/compare/v5.0.1...v5.0.2-dev.1) (2025-04-20)

View File

@@ -100,7 +100,7 @@ To build a ReVanced CLI, you can follow the [documentation](/docs).
You can find the documentation of ReVanced CLI [here](/docs).
## 📜 Licence
## 📜 License
ReVanced CLI is licensed under the GPLv3 license. Please see the [license file](LICENSE) for more information.
[tl;dr](https://www.tldrlegal.com/license/gnu-general-public-license-v3-gpl-3) you may copy, distribute and modify ReVanced CLI as long as you track changes/dates in source files.

View File

@@ -15,6 +15,7 @@ application {
}
repositories {
mavenLocal()
mavenCentral()
google()
maven {
@@ -28,6 +29,8 @@ repositories {
}
dependencies {
implementation(libs.bcpg.jdk18on)
implementation(libs.sigstore.java)
implementation(libs.revanced.patcher)
implementation(libs.revanced.library)
implementation(libs.kotlinx.coroutines.core)
@@ -39,6 +42,11 @@ dependencies {
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.addAll(
"-Xexplicit-backing-fields",
"-Xcontext-parameters",
)
}
}

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 5.0.2-dev.1
version = 5.0.2-dev.2

View File

@@ -1,18 +1,22 @@
[versions]
shadow = "8.1.1"
kotlin = "2.0.20"
kotlinx = "1.8.1"
picocli = "4.7.6"
revanced-patcher = "21.0.0"
revanced-library = "3.1.0"
bcpg-jdk18on = "1.82"
shadow = "9.3.1"
kotlin = "2.3.0"
kotlinx = "1.10.2"
picocli = "4.7.7"
revanced-patcher = "22.0.0-local"
revanced-library = "3.2.0-dev.2-local"
sigstore = "2.0.0"
[libraries]
bcpg-jdk18on = { module = "org.bouncycastle:bcpg-jdk18on", version.ref = "bcpg-jdk18on" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx" }
picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
revanced-patcher = { module = "app.revanced:patcher", version.ref = "revanced-patcher" }
revanced-library = { module = "app.revanced:revanced-library-jvm", version.ref = "revanced-library" }
sigstore-java = { module = "dev.sigstore:sigstore-java", version.ref = "sigstore" }
[plugins]
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

Binary file not shown.

View File

@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

7
gradlew vendored
View File

@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

2
gradlew.bat vendored
View File

@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################

View File

@@ -3,7 +3,7 @@ package app.revanced.cli.command
import app.revanced.library.PackageName
import app.revanced.library.VersionMap
import app.revanced.library.mostCommonCompatibleVersions
import app.revanced.patcher.patch.loadPatchesFromJar
import app.revanced.patcher.patch.loadPatches
import picocli.CommandLine
import java.io.File
import java.util.logging.Logger
@@ -48,15 +48,14 @@ internal class ListCompatibleVersions : Runnable {
}
}
fun buildString(entry: Map.Entry<PackageName, VersionMap>) =
buildString {
fun buildString(entry: Map.Entry<PackageName, VersionMap>) = buildString {
val (name, versions) = entry
appendLine("Package name: $name")
appendLine("Most common compatible versions:")
appendLine(versions.buildVersionsString().prependIndent("\t"))
}
val patches = loadPatchesFromJar(patchesFiles)
val patches = loadPatches(patchesFiles = patchesFiles.toTypedArray())
patches.mostCommonCompatibleVersions(
packageNames,

View File

@@ -2,7 +2,7 @@ package app.revanced.cli.command
import app.revanced.patcher.patch.Package
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.loadPatchesFromJar
import app.revanced.patcher.patch.loadPatches
import picocli.CommandLine.*
import picocli.CommandLine.Help.Visibility.ALWAYS
import java.io.File
@@ -85,15 +85,11 @@ internal object ListPatchesCommand : Runnable {
}
}
fun PatchOption<*>.buildString() =
buildString {
appendLine("Title: $title")
fun PatchOption<*>.buildString() = buildString {
appendLine("Name: $name")
description?.let { appendLine("Description: $it") }
appendLine("Required: $required")
default?.let {
appendLine("Key: $key")
append("Default: $it")
} ?: append("Key: $key")
default?.let { append("Default: $it") }
values?.let { values ->
appendLine("\nPossible values:")
@@ -103,14 +99,13 @@ internal object ListPatchesCommand : Runnable {
append("\nType: $type")
}
fun IndexedValue<Patch<*>>.buildString() =
let { (index, patch) ->
fun IndexedValue<Patch>.buildString() = let { (index, patch) ->
buildString {
if (withIndex) appendLine("Index: $index")
append("Name: ${patch.name}")
if (withDescriptions) append("\nDescription: ${patch.description}")
if (withDescriptions) patch.description?.let { append("\nDescription: $it") }
append("\nEnabled: ${patch.use}")
@@ -134,11 +129,10 @@ internal object ListPatchesCommand : Runnable {
}
}
fun Patch<*>.filterCompatiblePackages(name: String) =
compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
fun Patch.filterCompatiblePackages(name: String) = compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
?: withUniversalPatches
val patches = loadPatchesFromJar(patchesFiles).withIndex().toList()
val patches = loadPatches(patchesFiles = patchesFiles.toTypedArray()).withIndex().toList()
val filtered =
packageName?.let { patches.filter { (_, patch) -> patch.filterCompatiblePackages(it) } } ?: patches

View File

@@ -4,10 +4,9 @@ import app.revanced.library.ApkUtils
import app.revanced.library.ApkUtils.applyTo
import app.revanced.library.installation.installer.*
import app.revanced.library.setOptions
import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherConfig
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.loadPatchesFromJar
import app.revanced.patcher.patch.loadPatches
import app.revanced.patcher.patcher
import kotlinx.coroutines.runBlocking
import picocli.CommandLine
import picocli.CommandLine.ArgGroup
@@ -260,7 +259,7 @@ internal object PatchCommand : Runnable {
} else {
AdbInstaller(deviceSerial)
}
} catch (e: DeviceNotFoundException) {
} catch (_: DeviceNotFoundException) {
if (deviceSerial?.isNotEmpty() == true) {
logger.severe(
"Device with serial $deviceSerial not found to install to. " +
@@ -285,42 +284,43 @@ internal object PatchCommand : Runnable {
logger.info("Loading patches")
val patches = loadPatchesFromJar(patchesFiles)
val patches = loadPatches(patchesFiles = patchesFiles.toTypedArray()) { file, throwable ->
logger.severe("Failed to load patches from ${file.path}:\n$throwable")
}
// endregion
val patcherTemporaryFilesPath = temporaryFilesPath.resolve("patcher")
val (packageName, patcherResult) = Patcher(
PatcherConfig(
lateinit var _packageName: String
val patch = patcher(
apk,
patcherTemporaryFilesPath,
aaptBinaryPath?.path,
aaptBinaryPath,
patcherTemporaryFilesPath.absolutePath,
),
).use { patcher ->
val packageName = patcher.context.packageMetadata.packageName
val packageVersion = patcher.context.packageMetadata.packageVersion
) { packageName, versionName ->
_packageName = packageName
val filteredPatches = patches.filterPatchSelection(packageName, packageVersion)
val filteredPatches = patches.filterPatchSelection(packageName, versionName)
logger.info("Setting patch options")
val patchesList = patches.toList()
selection.filter { it.enabled != null }.associate {
val enabledSelection = it.enabled!!
val name = enabledSelection.selector.name ?: patchesList[enabledSelection.selector.index!!].name!!
(enabledSelection.selector.name ?: patchesList[enabledSelection.selector.index!!].name!!) to
enabledSelection.options
name to enabledSelection.options
}.let(filteredPatches::setOptions)
patcher += filteredPatches
filteredPatches
}
// Execute patches.
runBlocking {
patcher().collect { patchResult ->
val patchesResult = patch { patchResult ->
val exception = patchResult.exception
?: return@collect logger.info("\"${patchResult.patch}\" succeeded")
?: return@patch logger.info("\"${patchResult.patch}\" succeeded")
StringWriter().use { writer ->
exception.printStackTrace(PrintWriter(writer))
@@ -328,19 +328,15 @@ internal object PatchCommand : Runnable {
logger.severe("\"${patchResult.patch}\" failed:\n$writer")
}
}
}
patcher.context.packageMetadata.packageName to patcher.get()
}
// region Save.
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply {
patcherResult.applyTo(this)
}.let { patchedApkFile ->
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).let {
patchesResult.applyTo(it)
if (installation?.mount != true) {
ApkUtils.signApk(
patchedApkFile,
it,
outputFilePath,
signer,
ApkUtils.KeyStoreDetails(
@@ -351,7 +347,7 @@ internal object PatchCommand : Runnable {
),
)
} else {
patchedApkFile.copyTo(outputFilePath, overwrite = true)
it.copyTo(outputFilePath, overwrite = true)
}
}
@@ -363,7 +359,7 @@ internal object PatchCommand : Runnable {
installation?.deviceSerial?.let {
runBlocking {
when (val result = installer!!.install(Installer.Apk(outputFilePath, packageName))) {
when (val result = installer!!.install(Installer.Apk(outputFilePath, _packageName))) {
RootInstallerResult.FAILURE -> logger.severe("Failed to mount the patched APK file")
is AdbInstallerResult.Failure -> logger.severe(result.exception.toString())
else -> logger.info("Installed the patched APK file")
@@ -386,10 +382,10 @@ internal object PatchCommand : Runnable {
* @param packageVersion The version of the APK file to be patched.
* @return The filtered patches.
*/
private fun Set<Patch<*>>.filterPatchSelection(
private fun Set<Patch>.filterPatchSelection(
packageName: String,
packageVersion: String,
): Set<Patch<*>> = buildSet {
) = buildSet {
val enabledPatchesByName =
selection.mapNotNull { it.enabled?.selector?.name }.toSet()
val enabledPatchesByIndex =