Compare commits

...

7 Commits

Author SHA1 Message Date
semantic-release-bot
1781612789 chore(release): 1.6.1 [skip ci]
## [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](3829136c49))
2022-06-21 17:06:20 +00:00
oSumAtrIX
3829136c49 fix: remove -e from experimental option 2022-06-21 19:04:32 +02:00
oSumAtrIX
00145f2bb6 chore: merge nested if blocks 2022-06-21 19:00:11 +02:00
semantic-release-bot
7dabd53109 chore(release): 1.6.0 [skip ci]
# [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](98bd6f3f4b))
* use `install` mode by default ([1a3db77](1a3db77c21))
2022-06-21 16:44:30 +00:00
oSumAtrIX
98bd6f3f4b feat: rename debugging option to experimental 2022-06-21 18:42:30 +02:00
oSumAtrIX
1a3db77c21 feat: use install mode by default 2022-06-21 18:42:29 +02:00
oSumAtrIX
430de23856 refactor: replace try catch block with null check 2022-06-21 18:42:29 +02:00
6 changed files with 43 additions and 36 deletions

View File

@@ -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)

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official
version = 1.5.1
version = 1.6.1

View File

@@ -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,

View File

@@ -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()

View File

@@ -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")

View File

@@ -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)
}