mirror of
https://github.com/revanced/revanced-cli.git
synced 2025-02-02 14:17:32 +01:00
Merge branch 'dev'
# Conflicts: # build.gradle.kts
This commit is contained in:
commit
8665661ed7
21
CHANGELOG.md
21
CHANGELOG.md
@ -1,3 +1,24 @@
|
|||||||
|
# [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)
|
## [1.1.5](https://github.com/revanced/revanced-cli/compare/v1.1.4...v1.1.5) (2022-05-27)
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
||||||
implementation("app.revanced:revanced-patcher:1.0.0-dev.16")
|
implementation("app.revanced:revanced-patcher:1.0.0-dev.18")
|
||||||
|
|
||||||
implementation("info.picocli:picocli:4.6.3")
|
implementation("info.picocli:picocli:4.6.3")
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 1.1.5
|
version = 1.2.0-dev.2
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package app.revanced.cli
|
package app.revanced.cli
|
||||||
|
|
||||||
|
import app.revanced.patcher.PatcherOptions
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
|
||||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||||
import app.revanced.utils.adb.Adb
|
import app.revanced.utils.adb.Adb
|
||||||
import app.revanced.utils.patcher.addPatchesFiltered
|
import app.revanced.utils.patcher.addPatchesFiltered
|
||||||
@ -22,11 +22,11 @@ internal object MainCommand : Runnable {
|
|||||||
@Option(names = ["-p", "--patches"], description = ["One or more bundles of patches"])
|
@Option(names = ["-p", "--patches"], description = ["One or more bundles of patches"])
|
||||||
internal var patchBundles = arrayOf<String>()
|
internal var patchBundles = arrayOf<String>()
|
||||||
|
|
||||||
@Option(names = ["-t", "--temp-dir"], description = ["Temporal resource cache directory"], required = true)
|
@Option(names = ["-t", "--temp-dir"], description = ["Temporal resource cache directory"])
|
||||||
internal lateinit var cacheDirectory: String
|
internal var cacheDirectory = "revanced-cache"
|
||||||
|
|
||||||
@Option(names = ["-r", "--resource-patcher"], description = ["Enable patching resources"])
|
@Option(names = ["-r", "--resource-patcher"], description = ["Disable patching resources"])
|
||||||
internal var patchResources: Boolean = false
|
internal var disableResourcePatching: Boolean = false
|
||||||
|
|
||||||
@Option(
|
@Option(
|
||||||
names = ["-c", "--clean"],
|
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"])
|
@Option(names = ["-d", "--deploy-on"], description = ["If specified, deploy to adb device with given name"])
|
||||||
internal var deploy: String? = null
|
internal var deploy: String? = null
|
||||||
|
|
||||||
|
@Option(names = ["-b", "--debugging"], description = ["Disable patch version compatibility"])
|
||||||
|
internal var debugging: Boolean = false
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (listOnly) {
|
if (listOnly) {
|
||||||
for (patchBundlePath in patchBundles)
|
for (patchBundlePath in patchBundles) for (it in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||||
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(
|
println(
|
||||||
"[available] ${
|
"[available] $name"
|
||||||
it.findAnnotationRecursively(
|
|
||||||
Name::class.java
|
|
||||||
)?.name ?: it::class.java.name
|
|
||||||
}"
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val patcher = app.revanced.patcher.Patcher(
|
val patcher = app.revanced.patcher.Patcher(PatcherOptions(inputFile, cacheDirectory, !disableResourcePatching))
|
||||||
inputFile, cacheDirectory, patchResources
|
|
||||||
)
|
|
||||||
|
|
||||||
if (signatureCheck) {
|
if (signatureCheck) {
|
||||||
patcher.addPatchesFiltered()
|
patcher.addPatchesFiltered()
|
||||||
|
@ -30,8 +30,9 @@ internal class Patcher {
|
|||||||
zipFileSystem.replaceFile(name, data.data)
|
zipFileSystem.replaceFile(name, data.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainCommand.patchResources) {
|
if (!MainCommand.disableResourcePatching) {
|
||||||
for (file in File(MainCommand.cacheDirectory).resolve("build/").listFiles(FileFilter { it.isDirectory })?.first()?.listFiles()!!) {
|
for (file in File(MainCommand.cacheDirectory).resolve("build/").listFiles(FileFilter { it.isDirectory })
|
||||||
|
?.first()?.listFiles()!!) {
|
||||||
if (!file.isDirectory) {
|
if (!file.isDirectory) {
|
||||||
zipFileSystem.replaceFile(file.name, file.readBytes())
|
zipFileSystem.replaceFile(file.name, file.readBytes())
|
||||||
continue
|
continue
|
||||||
|
@ -2,29 +2,23 @@ package app.revanced.utils.patcher
|
|||||||
|
|
||||||
import app.revanced.cli.MainCommand
|
import app.revanced.cli.MainCommand
|
||||||
import app.revanced.patcher.Patcher
|
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.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.patch.base.Patch
|
||||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||||
|
|
||||||
fun Patcher.addPatchesFiltered(
|
fun Patcher.addPatchesFiltered(
|
||||||
packageCompatibilityFilter: Boolean = true,
|
|
||||||
packageVersionCompatibilityFilter: Boolean = true,
|
|
||||||
includeFilter: Boolean = false
|
includeFilter: Boolean = false
|
||||||
) {
|
) {
|
||||||
val packageName = this.packageName
|
val packageName = this.packageName
|
||||||
val packageVersion = this.packageVersion
|
val packageVersion = this.packageVersion
|
||||||
|
|
||||||
MainCommand.patchBundles.forEach { bundle ->
|
MainCommand.patchBundles.forEach { bundle ->
|
||||||
val includedPatches = mutableListOf<Patch<Data>>()
|
val includedPatches = mutableListOf<Class<out Patch<Data>>>()
|
||||||
JarPatchBundle(bundle).loadPatches().forEach patch@{ p ->
|
JarPatchBundle(bundle).loadPatches().forEach patch@{ patch ->
|
||||||
val patch = p.getDeclaredConstructor().newInstance()
|
val compatiblePackages = patch.compatiblePackages
|
||||||
|
val patchName = patch.patchName
|
||||||
val compatibilityAnnotation = patch.javaClass.findAnnotationRecursively(Compatibility::class.java)
|
|
||||||
|
|
||||||
val patchName = patch.javaClass.findAnnotationRecursively(Name::class.java)?.name ?: patch.javaClass.name
|
|
||||||
|
|
||||||
val prefix = "[skipped] $patchName"
|
val prefix = "[skipped] $patchName"
|
||||||
|
|
||||||
@ -33,26 +27,18 @@ fun Patcher.addPatchesFiltered(
|
|||||||
return@patch
|
return@patch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageVersionCompatibilityFilter || packageCompatibilityFilter) {
|
if (compatiblePackages == null) println("$prefix: Missing compatibility annotation. Continuing.")
|
||||||
|
else compatiblePackages.forEach { compatiblePackage ->
|
||||||
if (compatibilityAnnotation == null) {
|
if (compatiblePackage.name != packageName) {
|
||||||
println("$prefix: Missing compatibility annotation.")
|
|
||||||
return@patch
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
compatibilityAnnotation.compatiblePackages.forEach { compatiblePackage ->
|
|
||||||
if (packageCompatibilityFilter && compatiblePackage.name != packageName) {
|
|
||||||
println("$prefix: Package name not matching ${compatiblePackage.name}.")
|
println("$prefix: Package name not matching ${compatiblePackage.name}.")
|
||||||
return@patch
|
return@patch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageVersionCompatibilityFilter && !compatiblePackage.versions.any { it == packageVersion }) {
|
if (!(MainCommand.debugging || compatiblePackage.versions.any { it == packageVersion })) {
|
||||||
println("$prefix: Unsupported version.")
|
println("$prefix: Unsupported version.")
|
||||||
return@patch
|
return@patch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
includedPatches.add(patch)
|
includedPatches.add(patch)
|
||||||
println("[added] $patchName")
|
println("[added] $patchName")
|
||||||
|
@ -1,28 +1,24 @@
|
|||||||
package app.revanced.utils.signature
|
package app.revanced.utils.signature
|
||||||
|
|
||||||
import app.revanced.patcher.Patcher
|
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
|
import org.jf.dexlib2.iface.Method
|
||||||
|
|
||||||
object Signature {
|
object Signature {
|
||||||
|
|
||||||
fun checkSignatures(patcher: Patcher) {
|
fun checkSignatures(patcher: Patcher) {
|
||||||
|
TODO()
|
||||||
|
/**
|
||||||
val failed = mutableListOf<String>()
|
val failed = mutableListOf<String>()
|
||||||
for (signature in patcher.resolveSignatures()) {
|
for (signature in patcher.resolveSignatures()) {
|
||||||
val signatureClass = signature::class.java
|
val signatureClass = signature::class.java
|
||||||
val signatureName =
|
val signatureName = signature.name ?: signatureClass.simpleName
|
||||||
signatureClass.findAnnotationRecursively(app.revanced.patcher.annotation.Name::class.java)?.name
|
|
||||||
?: signatureClass.name
|
|
||||||
if (!signature.resolved) {
|
if (!signature.resolved) {
|
||||||
failed.add(signatureName)
|
failed.add(signatureName)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
val method = signature.result!!.method
|
val method = signature.result!!.method
|
||||||
val matchingMethod =
|
val matchingMethod = signature.matchingMethod ?: MatchingMethod()
|
||||||
signatureClass.findAnnotationRecursively(MatchingMethod::class.java) ?: MatchingMethod()
|
|
||||||
|
|
||||||
println(
|
println(
|
||||||
"""
|
"""
|
||||||
@ -32,7 +28,7 @@ object Signature {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
|
||||||
signatureClass.findAnnotationRecursively(FuzzyPatternScanMethod::class.java)?.let {
|
signature.fuzzyThreshold.let {
|
||||||
val warnings = signature.result!!.scanResult.warnings!!
|
val warnings = signature.result!!.scanResult.warnings!!
|
||||||
println(
|
println(
|
||||||
"""
|
"""
|
||||||
@ -50,6 +46,7 @@ object Signature {
|
|||||||
${failed.joinToString(separator = "\n") { it }}
|
${failed.joinToString(separator = "\n") { it }}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Method.toStr(): String {
|
private fun Method.toStr(): String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user