mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-11 22:06:20 +00:00
Compare commits
17 Commits
v1.1.3
...
v1.2.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c5e5e249d | ||
|
|
1b645c67db | ||
|
|
4758289d68 | ||
|
|
87c0e05d9c | ||
|
|
54c0a03d44 | ||
|
|
bd185133bc | ||
|
|
ace70e417f | ||
|
|
735dbc9149 | ||
|
|
e756ac9920 | ||
|
|
a4ef47a285 | ||
|
|
c69170535e | ||
|
|
a1bcd1fdaf | ||
|
|
206f2029d7 | ||
|
|
04e0027c08 | ||
|
|
e76983e01c | ||
|
|
11d67bc1ea | ||
|
|
cabd32fda4 |
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -1,5 +1,6 @@
|
||||
name: Release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
35
CHANGELOG.md
35
CHANGELOG.md
@@ -1,3 +1,38 @@
|
||||
# [1.2.0-dev.2](https://github.com/revanced/revanced-cli/compare/v1.2.0-dev.1...v1.2.0-dev.2) (2022-06-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* debugging option ([1b645c6](https://github.com/revanced/revanced-cli/commit/1b645c67db58eb4d49b5290fd247507c9b43a9c6))
|
||||
|
||||
# [1.2.0-dev.1](https://github.com/revanced/revanced-cli/compare/v1.1.6-dev.1...v1.2.0-dev.1) (2022-06-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add path for `cacheDirectory` and enable resource patching by default ([54c0a03](https://github.com/revanced/revanced-cli/commit/54c0a03d44c8d1b586bc487ee1ca71859d6f0b57))
|
||||
|
||||
## [1.1.6-dev.1](https://github.com/revanced/revanced-cli/compare/v1.1.5...v1.1.6-dev.1) (2022-05-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* migrate to latest patcher api changes ([ace70e4](https://github.com/revanced/revanced-cli/commit/ace70e417fdf280c7630a5a89a773879fd240e96))
|
||||
|
||||
## [1.1.5](https://github.com/revanced/revanced-cli/compare/v1.1.4...v1.1.5) (2022-05-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* invalid code flow when adding patches ([206f202](https://github.com/revanced/revanced-cli/commit/206f2029d7498b6474c16a47cbe451c170fdd31f))
|
||||
|
||||
## [1.1.4](https://github.com/revanced/revanced-cli/compare/v1.1.3...v1.1.4) (2022-05-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* migrate from `PatchLoader.load(...)` to `JarPatchBundle(...).loadPatches()` ([cabd32f](https://github.com/revanced/revanced-cli/commit/cabd32fda41d32616a61ae450c60e1ee7c35bc59))
|
||||
|
||||
## [1.1.3](https://github.com/revanced/revanced-cli/compare/v1.1.2...v1.1.3) (2022-05-25)
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
||||
implementation("app.revanced:revanced-patcher:+")
|
||||
implementation("app.revanced:revanced-patches:+")
|
||||
implementation("app.revanced:revanced-patcher:1.0.0-dev.18")
|
||||
|
||||
implementation("info.picocli:picocli:4.6.3")
|
||||
|
||||
@@ -68,4 +67,4 @@ publishing {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 1.1.3
|
||||
version = 1.2.0-dev.2
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package app.revanced.cli
|
||||
|
||||
import app.revanced.patcher.PatcherOptions
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||
import app.revanced.patcher.util.patch.PatchLoader
|
||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||
import app.revanced.utils.adb.Adb
|
||||
import app.revanced.utils.patcher.addPatchesFiltered
|
||||
import app.revanced.utils.signature.Signature
|
||||
@@ -20,13 +20,13 @@ internal object MainCommand : Runnable {
|
||||
internal var includedPatches = arrayOf<String>()
|
||||
|
||||
@Option(names = ["-p", "--patches"], description = ["One or more bundles of patches"])
|
||||
internal var patchBundles = arrayOf<File>()
|
||||
internal var patchBundles = arrayOf<String>()
|
||||
|
||||
@Option(names = ["-t", "--temp-dir"], description = ["Temporal resource cache directory"], required = true)
|
||||
internal lateinit var cacheDirectory: String
|
||||
@Option(names = ["-t", "--temp-dir"], description = ["Temporal resource cache directory"])
|
||||
internal var cacheDirectory = "revanced-cache"
|
||||
|
||||
@Option(names = ["-r", "--resource-patcher"], description = ["Enable patching resources"])
|
||||
internal var patchResources: Boolean = false
|
||||
@Option(names = ["-r", "--resource-patcher"], description = ["Disable patching resources"])
|
||||
internal var disableResourcePatching: Boolean = false
|
||||
|
||||
@Option(
|
||||
names = ["-c", "--clean"],
|
||||
@@ -52,23 +52,23 @@ internal object MainCommand : Runnable {
|
||||
@Option(names = ["-d", "--deploy-on"], description = ["If specified, deploy to adb device with given name"])
|
||||
internal var deploy: String? = null
|
||||
|
||||
@Option(names = ["-b", "--debugging"], description = ["Disable patch version compatibility"])
|
||||
internal var debugging: Boolean = false
|
||||
|
||||
override fun run() {
|
||||
if (listOnly) {
|
||||
for (patchBundle in patchBundles)
|
||||
for (it in PatchLoader.loadFromFile(patchBundle))
|
||||
println(
|
||||
"[available] ${
|
||||
it.javaClass.findAnnotationRecursively(
|
||||
Name::class.java
|
||||
)?.name ?: Name::class.java.name
|
||||
}"
|
||||
)
|
||||
for (patchBundlePath in patchBundles) for (it in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
|
||||
// TODO: adjust extension methods to be able to do this
|
||||
val name = (it.annotations.find { it is Name } as? Name)?.name ?: it.simpleName
|
||||
println(
|
||||
"[available] $name"
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val patcher = app.revanced.patcher.Patcher(
|
||||
inputFile, cacheDirectory, patchResources
|
||||
)
|
||||
val patcher = app.revanced.patcher.Patcher(PatcherOptions(inputFile, cacheDirectory, !disableResourcePatching))
|
||||
|
||||
if (signatureCheck) {
|
||||
patcher.addPatchesFiltered()
|
||||
@@ -90,7 +90,7 @@ internal object MainCommand : Runnable {
|
||||
if (clean) File(cacheDirectory).deleteRecursively()
|
||||
|
||||
adb?.deploy()
|
||||
|
||||
|
||||
if (clean) outputFile.delete()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,9 @@ internal class Patcher {
|
||||
zipFileSystem.replaceFile(name, data.data)
|
||||
}
|
||||
|
||||
if (MainCommand.patchResources) {
|
||||
for (file in File(MainCommand.cacheDirectory).resolve("build/").listFiles(FileFilter { it.isDirectory })?.first()?.listFiles()!!) {
|
||||
if (!MainCommand.disableResourcePatching) {
|
||||
for (file in File(MainCommand.cacheDirectory).resolve("build/").listFiles(FileFilter { it.isDirectory })
|
||||
?.first()?.listFiles()!!) {
|
||||
if (!file.isDirectory) {
|
||||
zipFileSystem.replaceFile(file.name, file.readBytes())
|
||||
continue
|
||||
|
||||
@@ -2,29 +2,23 @@ package app.revanced.utils.patcher
|
||||
|
||||
import app.revanced.cli.MainCommand
|
||||
import app.revanced.patcher.Patcher
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.base.Data
|
||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.patch.base.Patch
|
||||
import app.revanced.patcher.util.patch.PatchLoader
|
||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||
|
||||
fun Patcher.addPatchesFiltered(
|
||||
packageCompatibilityFilter: Boolean = true,
|
||||
packageVersionCompatibilityFilter: Boolean = true,
|
||||
includeFilter: Boolean = false
|
||||
) {
|
||||
val packageName = this.packageName
|
||||
val packageVersion = this.packageVersion
|
||||
|
||||
MainCommand.patchBundles.forEach { bundle ->
|
||||
val includedPatches = mutableListOf<Patch<Data>>()
|
||||
PatchLoader.loadFromFile(bundle).forEach patch@{ p ->
|
||||
val patch = p.getDeclaredConstructor().newInstance()
|
||||
|
||||
val compatibilityAnnotation = patch.javaClass.findAnnotationRecursively(Compatibility::class.java)
|
||||
|
||||
val patchName = patch.javaClass.findAnnotationRecursively(Name::class.java)?.name ?: Name::class.java.name
|
||||
val includedPatches = mutableListOf<Class<out Patch<Data>>>()
|
||||
JarPatchBundle(bundle).loadPatches().forEach patch@{ patch ->
|
||||
val compatiblePackages = patch.compatiblePackages
|
||||
val patchName = patch.patchName
|
||||
|
||||
val prefix = "[skipped] $patchName"
|
||||
|
||||
@@ -33,21 +27,14 @@ fun Patcher.addPatchesFiltered(
|
||||
return@patch
|
||||
}
|
||||
|
||||
if (packageVersionCompatibilityFilter || packageCompatibilityFilter) {
|
||||
|
||||
if (compatibilityAnnotation == null) {
|
||||
println("$prefix: Missing compatibility annotation.")
|
||||
if (compatiblePackages == null) println("$prefix: Missing compatibility annotation. Continuing.")
|
||||
else compatiblePackages.forEach { compatiblePackage ->
|
||||
if (compatiblePackage.name != packageName) {
|
||||
println("$prefix: Package name not matching ${compatiblePackage.name}.")
|
||||
return@patch
|
||||
}
|
||||
|
||||
|
||||
for (compatiblePackage in compatibilityAnnotation.compatiblePackages) {
|
||||
if (packageCompatibilityFilter && compatiblePackage.name != packageName) {
|
||||
println("$prefix: Package name not matching ${compatiblePackage.name}.")
|
||||
return@patch
|
||||
}
|
||||
|
||||
if (!packageVersionCompatibilityFilter || compatiblePackage.versions.any { it == packageVersion }) continue
|
||||
if (!(MainCommand.debugging || compatiblePackage.versions.any { it == packageVersion })) {
|
||||
println("$prefix: Unsupported version.")
|
||||
return@patch
|
||||
}
|
||||
@@ -61,8 +48,13 @@ fun Patcher.addPatchesFiltered(
|
||||
}
|
||||
|
||||
fun Patcher.applyPatchesPrint() {
|
||||
for ((patch, result) in this.applyPatches()) {
|
||||
println("[${if (result.isFailure) "error" else "success"}] $patch")
|
||||
this.applyPatches().forEach { (patch, result) ->
|
||||
if (result.isSuccess) {
|
||||
println("[success] $patch")
|
||||
return@forEach
|
||||
}
|
||||
println("[error] $patch:")
|
||||
result.exceptionOrNull()!!.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +1,52 @@
|
||||
package app.revanced.utils.signature
|
||||
|
||||
import app.revanced.patcher.Patcher
|
||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
|
||||
import org.jf.dexlib2.iface.Method
|
||||
|
||||
object Signature {
|
||||
|
||||
fun checkSignatures(patcher: Patcher) {
|
||||
TODO()
|
||||
/**
|
||||
val failed = mutableListOf<String>()
|
||||
for (signature in patcher.resolveSignatures()) {
|
||||
val signatureClass = signature::class.java
|
||||
val signatureName =
|
||||
signatureClass.findAnnotationRecursively(app.revanced.patcher.annotation.Name::class.java)?.name
|
||||
?: signatureClass.name
|
||||
if (!signature.resolved) {
|
||||
failed.add(signatureName)
|
||||
continue
|
||||
}
|
||||
val signatureClass = signature::class.java
|
||||
val signatureName = signature.name ?: signatureClass.simpleName
|
||||
if (!signature.resolved) {
|
||||
failed.add(signatureName)
|
||||
continue
|
||||
}
|
||||
|
||||
val method = signature.result!!.method
|
||||
val matchingMethod =
|
||||
signatureClass.findAnnotationRecursively(MatchingMethod::class.java) ?: MatchingMethod()
|
||||
val method = signature.result!!.method
|
||||
val matchingMethod = signature.matchingMethod ?: MatchingMethod()
|
||||
|
||||
println(
|
||||
"""
|
||||
[Signature] $signatureName
|
||||
[Method] ${matchingMethod.definingClass}->${matchingMethod.name}
|
||||
[Match] ${method.definingClass}->${method.toStr()}
|
||||
""".trimIndent()
|
||||
)
|
||||
println(
|
||||
"""
|
||||
[Signature] $signatureName
|
||||
[Method] ${matchingMethod.definingClass}->${matchingMethod.name}
|
||||
[Match] ${method.definingClass}->${method.toStr()}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
signatureClass.findAnnotationRecursively(FuzzyPatternScanMethod::class.java)?.let {
|
||||
val warnings = signature.result!!.scanResult.warnings!!
|
||||
println(
|
||||
"""
|
||||
[Warnings: ${warnings.count()}]
|
||||
${warnings.joinToString(separator = "\n") { warning -> "${warning.instructionIndex} / ${warning.patternIndex}: ${warning.wrongOpcode} (expected: ${warning.correctOpcode})" }}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
signature.fuzzyThreshold.let {
|
||||
val warnings = signature.result!!.scanResult.warnings!!
|
||||
println(
|
||||
"""
|
||||
[Warnings: ${warnings.count()}]
|
||||
${warnings.joinToString(separator = "\n") { warning -> "${warning.instructionIndex} / ${warning.patternIndex}: ${warning.wrongOpcode} (expected: ${warning.correctOpcode})" }}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
println(
|
||||
"""
|
||||
${"=".repeat(50)}
|
||||
[Failed signatures: ${failed.size}]
|
||||
${failed.joinToString(separator = "\n") { it }}
|
||||
"""
|
||||
${"=".repeat(50)}
|
||||
[Failed signatures: ${failed.size}]
|
||||
${failed.joinToString(separator = "\n") { it }}
|
||||
""".trimIndent()
|
||||
)
|
||||
*/
|
||||
}
|
||||
|
||||
private fun Method.toStr(): String {
|
||||
|
||||
Reference in New Issue
Block a user