Compare commits

...

11 Commits

Author SHA1 Message Date
semantic-release-bot
4105b638c0 chore(release): 2.23.0-dev.1 [skip ci]
# [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](f9cf7d21b7))
2023-07-30 00:52:33 +00:00
oSumAtrIX
f9cf7d21b7 feat: Improve command line argument descriptions 2023-07-30 02:49:49 +02:00
oSumAtrIX
0a758d86df build(Needs bump): Bump dependencies 2023-07-30 02:49:48 +02:00
oSumAtrIX
83f99e29ec ci: Change bumping commit scope 2023-07-30 02:49:39 +02:00
semantic-release-bot
00410d54c0 chore(release): 2.22.1-dev.1 [skip ci]
## [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](5eaad33dc1))
2023-07-24 12:20:19 +00:00
oSumAtrIX
5eaad33dc1 fix: print original instead of kebab cased names 2023-07-24 14:18:15 +02:00
semantic-release-bot
fa85482c4a chore(release): 2.22.0 [skip ci]
# [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](f6c221d72d))
2023-07-11 03:14:04 +00:00
oSumAtrIX
caed39af7f chore: merge branch dev to main (#233) 2023-07-11 05:12:30 +02:00
oSumAtrIX
20e1fdc18d chore: add notice to move option 2023-07-11 05:11:24 +02:00
semantic-release-bot
19cd541e9a 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-11 05:06:46 +02:00
oSumAtrIX
f6c221d72d feat: use new patch naming convention 2023-07-11 05:06:46 +02:00
8 changed files with 81 additions and 44 deletions

View File

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

View File

@@ -1,3 +1,31 @@
# [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)
### Features
* use new patch naming convention ([e4908c7](https://github.com/revanced/revanced-cli/commit/e4908c71051a535f8ce3406427cebbb0941464df))
## [2.21.5](https://github.com/revanced/revanced-cli/compare/v2.21.4...v2.21.5) (2023-07-01)
## [2.21.5-dev.2](https://github.com/revanced/revanced-cli/compare/v2.21.5-dev.1...v2.21.5-dev.2) (2023-07-01)

View File

@@ -23,14 +23,14 @@ repositories {
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20-RC")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20")
implementation("app.revanced:revanced-patcher:11.0.3")
implementation("info.picocli:picocli:4.7.1")
implementation("app.revanced:revanced-patcher:12.0.0")
implementation("info.picocli:picocli:4.7.3")
implementation("com.github.revanced:jadb:2531a28109") // updated fork
implementation("com.android.tools.build:apksig:8.1.0-alpha09")
implementation("com.android.tools.build:apksig:8.1.0")
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.+")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3")
testImplementation("org.jetbrains.kotlin:kotlin-test:1.8.20-RC")
}

View File

@@ -35,7 +35,7 @@ Learn how to ReVanced CLI.
```bash
java -jar revanced-cli.jar
-b revanced-patches.jar \
-l
-l # Names of all patches will be in kebab-case
```
- ### 💉 Use ReVanced CLI to patch an APK file but deploy without root permissions

View File

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

View File

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

View File

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

View File

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