mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-12 05:07:48 +01:00
chore: migrate to new changes from the patcher
This commit is contained in:
parent
839854d890
commit
e035d93d2c
@ -25,7 +25,7 @@ repositories {
|
||||
dependencies {
|
||||
implementation(kotlin("reflect"))
|
||||
|
||||
implementation("app.revanced:revanced-patcher:5.1.2")
|
||||
implementation("app.revanced:revanced-patcher:6.0.0")
|
||||
implementation("info.picocli:picocli:4.6.3")
|
||||
implementation("com.android.tools.build:apksig:7.2.1")
|
||||
implementation("com.github.revanced:jadb:master-SNAPSHOT") // updated fork
|
||||
|
@ -10,7 +10,7 @@ import app.revanced.patcher.PatcherOptions
|
||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||
import app.revanced.patcher.extensions.PatchExtensions.description
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.util.patch.impl.JarPatchBundle
|
||||
import app.revanced.patcher.util.patch.PatchBundle
|
||||
import app.revanced.utils.OptionsLoader
|
||||
import app.revanced.utils.adb.Adb
|
||||
import picocli.CommandLine.*
|
||||
@ -131,7 +131,7 @@ internal object MainCommand : Runnable {
|
||||
val outputFile = File(pArgs.outputPath) // the file to write to
|
||||
|
||||
val allPatches = args.patchArgs!!.patchBundles.flatMap { bundle ->
|
||||
JarPatchBundle(bundle).loadPatches()
|
||||
PatchBundle.Jar(bundle).loadPatches()
|
||||
}
|
||||
|
||||
OptionsLoader.init(args.patchArgs!!.options, allPatches)
|
||||
@ -148,7 +148,7 @@ internal object MainCommand : Runnable {
|
||||
|
||||
// prepare adb
|
||||
val adb: Adb? = args.deploy?.let {
|
||||
Adb(outputFile, patcher.data.packageMetadata.packageName, args.deploy!!, !pArgs.mount)
|
||||
Adb(outputFile, patcher.context.packageMetadata.packageName, args.deploy!!, !pArgs.mount)
|
||||
}
|
||||
|
||||
val patchedFile = File(pArgs.cacheDirectory).resolve("${outputFile.nameWithoutExtension}_raw.apk")
|
||||
@ -209,7 +209,7 @@ internal object MainCommand : Runnable {
|
||||
val adb: Adb? = args.deploy?.let {
|
||||
Adb(
|
||||
File("placeholder_file"),
|
||||
app.revanced.patcher.Patcher(PatcherOptions(args.inputFile, "")).data.packageMetadata.packageName,
|
||||
app.revanced.patcher.Patcher(PatcherOptions(args.inputFile, "")).context.packageMetadata.packageName,
|
||||
args.deploy!!,
|
||||
false
|
||||
)
|
||||
@ -219,7 +219,8 @@ internal object MainCommand : Runnable {
|
||||
|
||||
private fun printListOfPatches() {
|
||||
val logged = mutableListOf<String>()
|
||||
for (patchBundlePath in args.patchArgs?.patchBundles!!) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
for (patchBundlePath in args.patchArgs?.patchBundles!!) for (patch in PatchBundle.Jar(patchBundlePath)
|
||||
.loadPatches()) {
|
||||
if (patch.patchName in logged) continue
|
||||
for (compatiblePackage in patch.compatiblePackages!!) {
|
||||
val packageEntryStr = buildString {
|
||||
|
@ -2,7 +2,7 @@ package app.revanced.cli.patcher
|
||||
|
||||
import app.revanced.cli.command.MainCommand.args
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.patcher.data.Data
|
||||
import app.revanced.patcher.data.Context
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.utils.filesystem.ZipFileSystemUtils
|
||||
import app.revanced.utils.patcher.addPatchesFiltered
|
||||
@ -12,7 +12,11 @@ import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
internal object Patcher {
|
||||
internal fun start(patcher: app.revanced.patcher.Patcher, output: File, allPatches: List<Class<out Patch<Data>>>) {
|
||||
internal fun start(
|
||||
patcher: app.revanced.patcher.Patcher,
|
||||
output: File,
|
||||
allPatches: List<Class<out Patch<Context>>>
|
||||
) {
|
||||
val inputFile = args.inputFile
|
||||
|
||||
// merge files like necessary integrations
|
||||
|
@ -2,7 +2,7 @@ package app.revanced.utils
|
||||
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.patcher.Patcher
|
||||
import app.revanced.patcher.data.Data
|
||||
import app.revanced.patcher.data.Context
|
||||
import app.revanced.patcher.extensions.PatchExtensions.options
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.patch.Patch
|
||||
@ -12,7 +12,7 @@ import cc.ekblad.toml.serialization.from
|
||||
import cc.ekblad.toml.tomlMapper
|
||||
import java.io.File
|
||||
|
||||
private typealias PatchList = List<Class<out Patch<Data>>>
|
||||
private typealias PatchList = List<Class<out Patch<Context>>>
|
||||
private typealias OptionsMap = MutableMap<String, MutableMap<String, Any>>
|
||||
|
||||
object OptionsLoader {
|
||||
|
@ -4,18 +4,18 @@ import app.revanced.cli.command.MainCommand
|
||||
import app.revanced.cli.command.MainCommand.args
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.patcher.Patcher
|
||||
import app.revanced.patcher.data.Data
|
||||
import app.revanced.patcher.data.Context
|
||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||
import app.revanced.patcher.extensions.PatchExtensions.deprecated
|
||||
import app.revanced.patcher.extensions.PatchExtensions.include
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.patch.Patch
|
||||
|
||||
fun Patcher.addPatchesFiltered(allPatches: List<Class<out Patch<Data>>>) {
|
||||
val packageName = this.data.packageMetadata.packageName
|
||||
val packageVersion = this.data.packageMetadata.packageVersion
|
||||
fun Patcher.addPatchesFiltered(allPatches: List<Class<out Patch<Context>>>) {
|
||||
val packageName = this.context.packageMetadata.packageName
|
||||
val packageVersion = this.context.packageMetadata.packageVersion
|
||||
|
||||
val includedPatches = mutableListOf<Class<out Patch<Data>>>()
|
||||
val includedPatches = mutableListOf<Class<out Patch<Context>>>()
|
||||
allPatches.forEach patchLoop@{ patch ->
|
||||
val compatiblePackages = patch.compatiblePackages
|
||||
val patchName = patch.patchName
|
||||
@ -66,7 +66,7 @@ fun Patcher.addPatchesFiltered(allPatches: List<Class<out Patch<Data>>>) {
|
||||
}
|
||||
|
||||
fun Patcher.applyPatchesVerbose() {
|
||||
this.applyPatches().forEach { (patch, result) ->
|
||||
this.executePatches().forEach { (patch, result) ->
|
||||
if (result.isSuccess) {
|
||||
logger.info("$patch succeeded")
|
||||
return@forEach
|
||||
|
@ -1,10 +1,6 @@
|
||||
package app.revanced.utils.signing.align.zip.structures
|
||||
|
||||
import app.revanced.utils.signing.align.zip.getUShort
|
||||
import app.revanced.utils.signing.align.zip.putUInt
|
||||
import app.revanced.utils.signing.align.zip.putUShort
|
||||
import app.revanced.utils.signing.align.zip.readUIntLE
|
||||
import app.revanced.utils.signing.align.zip.readUShortLE
|
||||
import app.revanced.utils.signing.align.zip.*
|
||||
import java.io.DataInput
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
|
Loading…
Reference in New Issue
Block a user