mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-12 06:16:20 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1781612789 | ||
|
|
3829136c49 | ||
|
|
00145f2bb6 | ||
|
|
7dabd53109 | ||
|
|
98bd6f3f4b | ||
|
|
1a3db77c21 | ||
|
|
430de23856 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,3 +1,18 @@
|
||||
## [1.6.1](https://github.com/revanced/revanced-cli/compare/v1.6.0...v1.6.1) (2022-06-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove `-e` from `experimental` option ([3829136](https://github.com/revanced/revanced-cli/commit/3829136c49ddce1dc6b01eda04ce013540b213c2))
|
||||
|
||||
# [1.6.0](https://github.com/revanced/revanced-cli/compare/v1.5.1...v1.6.0) (2022-06-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* rename `debugging` option to `experimental` ([98bd6f3](https://github.com/revanced/revanced-cli/commit/98bd6f3f4b3eb34c445cbd5e3a3196f399f8bb3b))
|
||||
* use `install` mode by default ([1a3db77](https://github.com/revanced/revanced-cli/commit/1a3db77c21b5795220fbac1ec36827fc521fface))
|
||||
|
||||
## [1.5.1](https://github.com/revanced/revanced-cli/compare/v1.5.0...v1.5.1) (2022-06-21)
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 1.5.1
|
||||
version = 1.6.1
|
||||
|
||||
@@ -23,10 +23,10 @@ internal object MainCommand : Runnable {
|
||||
var patchBundles = arrayOf<String>()
|
||||
|
||||
@ArgGroup(exclusive = false)
|
||||
lateinit var lArgs: ListingArgs
|
||||
var lArgs: ListingArgs? = null
|
||||
|
||||
@ArgGroup(exclusive = false)
|
||||
lateinit var pArgs: PatchingArgs
|
||||
var pArgs: PatchingArgs? = null
|
||||
}
|
||||
|
||||
class ListingArgs {
|
||||
@@ -41,23 +41,20 @@ internal object MainCommand : Runnable {
|
||||
@Option(names = ["-o", "--out"], description = ["Output file path"], required = true)
|
||||
lateinit var outputPath: String
|
||||
|
||||
@Option(
|
||||
names = ["-i", "--include"],
|
||||
description = ["Which patches to include. If none is specified, all compatible default patches will be included"]
|
||||
)
|
||||
var includedPatches = arrayOf<String>()
|
||||
@Option(names = ["-e", "--exclude"], description = ["Explicitly exclude patches"])
|
||||
var excludedPatches = arrayOf<String>()
|
||||
|
||||
@Option(names = ["-r", "--resource-patcher"], description = ["Disable patching resources"])
|
||||
var disableResourcePatching: Boolean = false
|
||||
|
||||
@Option(names = ["--debugging"], description = ["Disable patch version compatibility"])
|
||||
var debugging: Boolean = false
|
||||
@Option(names = ["--experimental"], description = ["Disable patch version compatibility patch"])
|
||||
var experimental: Boolean = false
|
||||
|
||||
@Option(names = ["-m", "--merge"], description = ["One or more dex file containers to merge"])
|
||||
var mergeFiles = listOf<File>()
|
||||
|
||||
@Option(names = ["--install"], description = ["If specified, instead of mounting, install"])
|
||||
var install: Boolean = false
|
||||
@Option(names = ["--mount"], description = ["If specified, instead of installing, mount"])
|
||||
var mount: Boolean = false
|
||||
|
||||
@Option(names = ["--cn"], description = ["Overwrite the default CN for the signed file"])
|
||||
var cn = "ReVanced"
|
||||
@@ -79,17 +76,14 @@ internal object MainCommand : Runnable {
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
try {
|
||||
if (args.lArgs.listOnly) {
|
||||
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
println("[available] ${patch.patchName}")
|
||||
}
|
||||
return
|
||||
if (args.lArgs?.listOnly == true) {
|
||||
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
println("[available] ${patch.patchName}")
|
||||
}
|
||||
} catch (_: UninitializedPropertyAccessException) {
|
||||
return
|
||||
}
|
||||
|
||||
val args = args.pArgs
|
||||
val args = args.pArgs ?: return
|
||||
|
||||
val patcher = app.revanced.patcher.Patcher(
|
||||
PatcherOptions(
|
||||
@@ -100,17 +94,17 @@ internal object MainCommand : Runnable {
|
||||
val outputFile = File(args.outputPath)
|
||||
|
||||
val adb: Adb? = args.deploy?.let {
|
||||
Adb(outputFile, patcher.data.packageMetadata.packageName, args.deploy!!, args.install)
|
||||
Adb(outputFile, patcher.data.packageMetadata.packageName, args.deploy!!, !args.mount)
|
||||
}
|
||||
|
||||
val patchedFile =
|
||||
if (args.install) File(args.cacheDirectory).resolve("${outputFile.nameWithoutExtension}_raw.apk") else outputFile
|
||||
if (args.mount) outputFile else File(args.cacheDirectory).resolve("${outputFile.nameWithoutExtension}_raw.apk")
|
||||
|
||||
Patcher.start(patcher, patchedFile)
|
||||
|
||||
println("[aligning & signing]")
|
||||
|
||||
if (args.install) {
|
||||
if (args.mount) {
|
||||
Signing.start(
|
||||
patchedFile,
|
||||
outputFile,
|
||||
|
||||
@@ -10,12 +10,12 @@ import java.nio.file.Files
|
||||
|
||||
internal object Patcher {
|
||||
internal fun start(patcher: app.revanced.patcher.Patcher, output: File) {
|
||||
val args = args.pArgs;
|
||||
val args = args.pArgs!!
|
||||
|
||||
// merge files like necessary integrations
|
||||
patcher.mergeFiles()
|
||||
// add patches, but filter incompatible or excluded patches
|
||||
patcher.addPatchesFiltered(includeFilter = args.includedPatches.isNotEmpty())
|
||||
patcher.addPatchesFiltered(excludePatches = args.excludedPatches.isNotEmpty())
|
||||
// apply patches
|
||||
patcher.applyPatchesVerbose()
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.File
|
||||
|
||||
object Signing {
|
||||
fun start(inputFile: File, outputFile: File, cn: String, password: String) {
|
||||
val cacheDirectory = File(args.pArgs.cacheDirectory)
|
||||
val cacheDirectory = File(args.pArgs!!.cacheDirectory)
|
||||
val alignedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_aligned.apk")
|
||||
val signedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_signed.apk")
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ import app.revanced.patcher.patch.base.Patch
|
||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||
|
||||
fun Patcher.addPatchesFiltered(
|
||||
includeFilter: Boolean = false
|
||||
excludePatches: Boolean = false
|
||||
) {
|
||||
val packageName = this.data.packageMetadata.packageName
|
||||
val packageVersion = this.data.packageMetadata.packageVersion
|
||||
|
||||
MainCommand.args.patchBundles.forEach { bundle ->
|
||||
args.patchBundles.forEach { bundle ->
|
||||
val includedPatches = mutableListOf<Class<out Patch<Data>>>()
|
||||
JarPatchBundle(bundle).loadPatches().forEach patch@{ patch ->
|
||||
val compatiblePackages = patch.compatiblePackages
|
||||
@@ -24,13 +24,11 @@ fun Patcher.addPatchesFiltered(
|
||||
|
||||
val prefix = "[skipped] $patchName"
|
||||
|
||||
val args = MainCommand.args.pArgs
|
||||
val args = MainCommand.args.pArgs!!
|
||||
|
||||
if (includeFilter) {
|
||||
if (!args.includedPatches.contains(patchName)) {
|
||||
println("$prefix: Explicitly excluded.")
|
||||
return@patch
|
||||
}
|
||||
if (excludePatches && args.excludedPatches.contains(patchName)) {
|
||||
println("$prefix: Explicitly excluded.")
|
||||
return@patch
|
||||
} else if (!patch.include) {
|
||||
println("$prefix: Implicitly excluded.")
|
||||
return@patch
|
||||
@@ -43,7 +41,7 @@ fun Patcher.addPatchesFiltered(
|
||||
return@patch
|
||||
}
|
||||
|
||||
if (!(args.debugging || compatiblePackages.any { it.versions.isEmpty() || it.versions.any { version -> version == packageVersion }})) {
|
||||
if (!(args.experimental || compatiblePackages.any { it.versions.isEmpty() || it.versions.any { version -> version == packageVersion } })) {
|
||||
println("$prefix: The package version is $packageVersion and is incompatible.")
|
||||
return@patch
|
||||
}
|
||||
@@ -68,5 +66,5 @@ fun Patcher.applyPatchesVerbose() {
|
||||
}
|
||||
|
||||
fun Patcher.mergeFiles() {
|
||||
this.addFiles(MainCommand.args.pArgs.mergeFiles)
|
||||
this.addFiles(args.pArgs!!.mergeFiles)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user