Compare commits

..

2 Commits

Author SHA1 Message Date
semantic-release-bot
a0067c7911 chore(release): 2.22.0-dev.1 [skip ci]
# [2.22.0-dev.1](https://github.com/revanced/revanced-cli/compare/v2.21.5...v2.22.0-dev.1) (2023-07-10)

### Features

* use new patch naming convention ([e4908c7](e4908c7105))
2023-07-10 16:51:55 +00:00
oSumAtrIX
e4908c7105 feat: use new patch naming convention 2023-07-10 18:49:40 +02:00
8 changed files with 45 additions and 91 deletions

View File

@@ -10,7 +10,7 @@
[ [
"@semantic-release/commit-analyzer", { "@semantic-release/commit-analyzer", {
"releaseRules": [ "releaseRules": [
{ "type": "build", "scope": "Needs bump", "release": "patch" } { "type": "build", "scope": "revanced-patcher", "release": "patch" }
] ]
} }
], ],

View File

@@ -1,37 +1,3 @@
# [2.23.0-dev.5](https://github.com/ReVanced/revanced-cli/compare/v2.23.0-dev.4...v2.23.0-dev.5) (2023-08-14)
# [2.23.0-dev.4](https://github.com/ReVanced/revanced-cli/compare/v2.23.0-dev.3...v2.23.0-dev.4) (2023-08-13)
### Features
* show full package name when listing patches ([#240](https://github.com/ReVanced/revanced-cli/issues/240)) ([7174364](https://github.com/ReVanced/revanced-cli/commit/7174364ef8ef5d6ce8351a8340f9c1a5b58eac3c))
# [2.23.0-dev.3](https://github.com/ReVanced/revanced-cli/compare/v2.23.0-dev.2...v2.23.0-dev.3) (2023-08-03)
# [2.23.0-dev.2](https://github.com/ReVanced/revanced-cli/compare/v2.23.0-dev.1...v2.23.0-dev.2) (2023-08-03)
# [2.23.0-dev.1](https://github.com/ReVanced/revanced-cli/compare/v2.22.1-dev.1...v2.23.0-dev.1) (2023-07-30)
### Features
* Improve command line argument descriptions ([f9cf7d2](https://github.com/ReVanced/revanced-cli/commit/f9cf7d21b7f1c2f11234d604a1047b9d2b165f83))
## [2.22.1-dev.1](https://github.com/ReVanced/revanced-cli/compare/v2.22.0...v2.22.1-dev.1) (2023-07-24)
### Bug Fixes
* print original instead of kebab cased names ([5eaad33](https://github.com/ReVanced/revanced-cli/commit/5eaad33dc1fbd24c36e1498f04e21d068e85f53e))
# [2.22.0](https://github.com/revanced/revanced-cli/compare/v2.21.5...v2.22.0) (2023-07-11)
### Features
* use new patch naming convention ([f6c221d](https://github.com/revanced/revanced-cli/commit/f6c221d72dc43ebea00e5eba6bfa02751ae8ad77))
# [2.22.0-dev.1](https://github.com/revanced/revanced-cli/compare/v2.21.5...v2.22.0-dev.1) (2023-07-10) # [2.22.0-dev.1](https://github.com/revanced/revanced-cli/compare/v2.21.5...v2.22.0-dev.1) (2023-07-10)

View File

@@ -11,7 +11,6 @@ val githubPassword: String = project.findProperty("gpr.key") as? String ?: Syste
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
google()
maven { maven {
url = uri("https://maven.pkg.github.com/revanced/revanced-patcher") url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
credentials { credentials {
@@ -20,17 +19,18 @@ repositories {
} }
} }
maven { url = uri("https://jitpack.io") } maven { url = uri("https://jitpack.io") }
google()
} }
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.22") implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20-RC")
implementation("app.revanced:revanced-patcher:13.0.0") implementation("app.revanced:revanced-patcher:11.0.3")
implementation("info.picocli:picocli:4.7.3") implementation("info.picocli:picocli:4.7.1")
implementation("com.github.revanced:jadb:2531a28109") // Updated fork implementation("com.github.revanced:jadb:2531a28109") // updated fork
implementation("com.android.tools.build:apksig:8.1.0") implementation("com.android.tools.build:apksig:8.1.0-alpha09")
implementation("org.bouncycastle:bcpkix-jdk15on:1.70") implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.+")
testImplementation("org.jetbrains.kotlin:kotlin-test:1.8.20-RC") testImplementation("org.jetbrains.kotlin:kotlin-test:1.8.20-RC")
} }

View File

@@ -1,17 +1,15 @@
# 💼 Prerequisites # 💼 Prerequisites
To use ReVanced CLI, you will need to fulfil specific requirements. To use ReVanced CLI, you will need to fulfill certain requirements.
## 🤝 Requirements ## 🤝 Requirements
- Java SDK 11 (Azul Zulu JDK or OpenJDK) - Java SDK 11 (Azul JDK or OpenJDK)
- [Android Debug Bridge (adb)](https://developer.android.com/studio/command-line/adb) if you want to deploy the patched APK file on your device - [Android Debug Bridge (adb)](https://developer.android.com/studio/command-line/adb) if you want to deploy the patched APK file on your device
- An ABI other than ARMv7 such as x86 or x86-64 (or a custom AAPT binary that supports ARMv7) - An ABI other than ARMv7 such as x86 or x86-64 (or a custom AAPT binary that supports ARMv7)
- ReVanced Patches
- ReVanced Integrations, if the patches require it
## ⏭️ Whats next ## ⏭️ Whats next
The following section will show you how to use ReVanced CLI. The next section will show, how to use [ReVanced CLI](https://github.com/revanced/revanced-cli).
Continue: [🛠️ Using ReVanced CLI](1_usage.md) Continue: [🛠️ Using ReVanced CLI](1_usage.md)

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true org.gradle.parallel = true
org.gradle.caching = true org.gradle.caching = true
kotlin.code.style = official kotlin.code.style = official
version = 2.23.0-dev.5 version = 2.22.0-dev.1

View File

@@ -32,7 +32,7 @@ private class CLIVersionProvider : IVersionProvider {
} }
@Command( @Command(
name = "ReVanced CLI", name = "ReVanced-CLI",
mixinStandardHelpOptions = true, mixinStandardHelpOptions = true,
versionProvider = CLIVersionProvider::class versionProvider = CLIVersionProvider::class
) )
@@ -43,16 +43,15 @@ internal object MainCommand : Runnable {
lateinit var args: Args lateinit var args: Args
class Args { class Args {
// TODO: Move this so it is not required when listing patches @Option(names = ["-a", "--apk"], description = ["Input APK file to be patched"], required = true)
@Option(names = ["-a", "--apk"], description = ["APK file to be patched"], required = true)
lateinit var inputFile: File lateinit var inputFile: File
@Option(names = ["--unmount"], description = ["Unmount a patched APK file"]) @Option(names = ["--uninstall"], description = ["Uninstall the mount variant"])
var unmount: Boolean = false var uninstall: Boolean = false
@Option( @Option(
names = ["-d", "--deploy"], names = ["-d", "--deploy-on"],
description = ["Deploy to the specified device that is connected via ADB"] description = ["If specified, deploy to device over ADB with given name"]
) )
var deploy: String? = null var deploy: String? = null
@@ -78,72 +77,63 @@ internal object MainCommand : Runnable {
@Option(names = ["-l", "--list"], description = ["List patches"], required = true) @Option(names = ["-l", "--list"], description = ["List patches"], required = true)
var listOnly: Boolean = false var listOnly: Boolean = false
@Option(names = ["--with-versions"], description = ["List patches with version compatibilities"]) @Option(names = ["--with-versions"], description = ["List patches with compatible versions"])
var withVersions: Boolean = false var withVersions: Boolean = false
@Option(names = ["--with-packages"], description = ["List patches with package compatibilities"]) @Option(names = ["--with-packages"], description = ["List patches with compatible packages"])
var withPackages: Boolean = false var withPackages: Boolean = false
} }
class PatchingArgs { class PatchingArgs {
@Option(names = ["-o", "--out"], description = ["Path to save the patched APK file to"], required = true) @Option(names = ["-o", "--out"], description = ["Output file path"], required = true)
lateinit var outputPath: String lateinit var outputPath: String
@Option(names = ["-e", "--exclude"], description = ["Exclude patches"]) @Option(names = ["-e", "--exclude"], description = ["Explicitly exclude patches"])
var excludedPatches = arrayOf<String>() var excludedPatches = arrayOf<String>()
@Option( @Option(
names = ["--exclusive"], names = ["--exclusive"],
description = ["Only include patches that were explicitly specified to be included"] description = ["Only installs the patches you include, not including any patch by default"]
) )
var exclusive = false var exclusive = false
@Option(names = ["-i", "--include"], description = ["Include patches"]) @Option(names = ["-i", "--include"], description = ["Include patches"])
var includedPatches = arrayOf<String>() var includedPatches = arrayOf<String>()
@Option(names = ["--experimental"], description = ["Ignore patches incompatibility to versions"]) @Option(names = ["--experimental"], description = ["Disable patch version compatibility patch"])
var experimental: Boolean = false var experimental: Boolean = false
@Option(names = ["-m", "--merge"], description = ["One or more DEX files or containers to merge into the APK"]) @Option(names = ["-m", "--merge"], description = ["One or more dex file containers to merge"])
var mergeFiles = listOf<File>() var mergeFiles = listOf<File>()
@Option( @Option(names = ["--mount"], description = ["If specified, instead of installing, mount"])
names = ["--mount"],
description = ["Mount the patched APK file over the original file instead of installing it"]
)
var mount: Boolean = false var mount: Boolean = false
@Option(names = ["--cn"], description = ["The common name of the signer of the patched APK file"]) @Option(names = ["--cn"], description = ["Overwrite the default CN for the signed file"])
var cn = "ReVanced" var cn = "ReVanced"
@Option(names = ["--keystore"], description = ["Path to the keystore to sign the patched APK file with"]) @Option(names = ["--keystore"], description = ["File path to your keystore"])
var keystorePath: String? = null var keystorePath: String? = null
@Option( @Option(names = ["-p", "--password"], description = ["Overwrite the default password for the signed file"])
names = ["-p", "--password"],
description = ["The password of the keystore to sign the patched APK file with"]
)
var password = "ReVanced" var password = "ReVanced"
@Option(names = ["-t", "--temp-dir"], description = ["Path to temporary resource cache directory"]) @Option(names = ["-t", "--temp-dir"], description = ["Temporary resource cache directory"])
var cacheDirectory = "revanced-cache" var cacheDirectory = "revanced-cache"
@Option( @Option(
names = ["-c", "--clean"], names = ["-c", "--clean"],
description = ["Clean up the temporary resource cache directory after patching"] description = ["Clean the temporary resource cache directory. This will be done anyways when running the patcher"]
) )
var clean: Boolean = false var clean: Boolean = false
@Option( @Option(names = ["--custom-aapt2-binary"], description = ["Path to custom aapt2 binary"])
names = ["--custom-aapt2-binary"],
description = ["Path to custom AAPT binary to compile resources with"]
)
var aaptPath: String = "" var aaptPath: String = ""
} }
override fun run() { override fun run() {
if (args.patchArgs?.listingArgs?.listOnly == true) return printListOfPatches() if (args.patchArgs?.listingArgs?.listOnly == true) return printListOfPatches()
if (args.unmount) return unmount() if (args.uninstall) return uninstall()
val pArgs = this.args.patchArgs?.patchingArgs ?: return val pArgs = this.args.patchArgs?.patchingArgs ?: return
val outputFile = File(pArgs.outputPath) // the file to write to val outputFile = File(pArgs.outputPath) // the file to write to
@@ -224,7 +214,7 @@ internal object MainCommand : Runnable {
logger.info(result) logger.info(result)
} }
private fun unmount() { private fun uninstall() {
val adb: Adb? = args.deploy?.let { val adb: Adb? = args.deploy?.let {
Adb( Adb(
File("placeholder_file"), File("placeholder_file"),
@@ -245,13 +235,13 @@ internal object MainCommand : Runnable {
val packageEntryStr = buildString { val packageEntryStr = buildString {
// Add package if flag is set // Add package if flag is set
if (args.patchArgs?.listingArgs?.withPackages == true) { if (args.patchArgs?.listingArgs?.withPackages == true) {
val packageName = compatiblePackage.name.padStart(25) val packageName = compatiblePackage.name.substringAfterLast(".").padStart(10)
append(packageName) append(packageName)
append("\t") append("\t")
} }
// Add patch name // Add patch name
val patchName = patch.patchName.lowercase().replace(" ", "-").padStart(25) val patchName = patch.patchName.lowercase().replace("-", " ").padStart(25)
append(patchName) append(patchName)
// Add description if flag is set. // Add description if flag is set.

View File

@@ -11,7 +11,7 @@ internal class Adb(
private val file: File, private val file: File,
private val packageName: String, private val packageName: String,
deviceName: String, deviceName: String,
private val install: Boolean = false, private val modeInstall: Boolean = false,
private val logging: Boolean = true private val logging: Boolean = true
) { ) {
private val device: JadbDevice private val device: JadbDevice
@@ -20,7 +20,7 @@ internal class Adb(
device = JadbConnection().devices.let { device -> device.find { it.serial == deviceName } ?: device.first() } device = JadbConnection().devices.let { device -> device.find { it.serial == deviceName } ?: device.first() }
?: throw IllegalArgumentException("No such device with name $deviceName") ?: throw IllegalArgumentException("No such device with name $deviceName")
if (!install && device.run("su -h", false) != 0) if (!modeInstall && device.run("su -h", false) != 0)
throw IllegalArgumentException("Root required on $deviceName. Task failed") throw IllegalArgumentException("Root required on $deviceName. Task failed")
} }
@@ -29,7 +29,7 @@ internal class Adb(
} }
internal fun deploy() { internal fun deploy() {
if (install) { if (modeInstall) {
logger.info("Installing without mounting") logger.info("Installing without mounting")
PackageManager(device).install(file) PackageManager(device).install(file)

View File

@@ -17,11 +17,12 @@ fun Patcher.addPatchesFiltered(allPatches: PatchList) {
val includedPatches = mutableListOf<Class<out Patch<Context>>>() val includedPatches = mutableListOf<Class<out Patch<Context>>>()
allPatches.forEach patchLoop@{ patch -> allPatches.forEach patchLoop@{ patch ->
val compatiblePackages = patch.compatiblePackages val compatiblePackages = patch.compatiblePackages
val patchName = patch.patchName.lowercase().replace(" ", "-")
val args = args.patchArgs?.patchingArgs!! val args = args.patchArgs?.patchingArgs!!
val prefix = "Skipping ${patch.patchName}" val prefix = "Skipping $patchName"
if (compatiblePackages == null) logger.trace("${patch.patchName}: No package constraints.") if (compatiblePackages == null) logger.trace("$patchName: No constraint on packages.")
else { else {
if (!compatiblePackages.any { it.name == packageName }) { if (!compatiblePackages.any { it.name == packageName }) {
logger.trace("$prefix: Incompatible with $packageName. This patch is only compatible with ${ logger.trace("$prefix: Incompatible with $packageName. This patch is only compatible with ${
@@ -41,16 +42,15 @@ fun Patcher.addPatchesFiltered(allPatches: PatchList) {
} }
} }
val kebabCasedPatchName = patch.patchName.lowercase().replace(" ", "-") if (args.excludedPatches.contains(patchName)) {
if (args.excludedPatches.contains(kebabCasedPatchName)) {
logger.info("$prefix: Manually excluded") logger.info("$prefix: Manually excluded")
return@patchLoop return@patchLoop
} else if ((!patch.include || args.exclusive) && !args.includedPatches.contains(kebabCasedPatchName)) { } else if ((!patch.include || args.exclusive) && !args.includedPatches.contains(patchName)) {
logger.info("$prefix: Excluded by default") logger.info("$prefix: Excluded by default")
return@patchLoop return@patchLoop
} }
logger.trace("Adding ${patch.patchName}") logger.trace("Adding $patchName")
includedPatches.add(patch) includedPatches.add(patch)
} }