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