Compare commits

...

1 Commits

Author SHA1 Message Date
oSumAtrIX
c335850cc5 build(Needs bump): Bump dependencies 2024-02-11 21:47:15 +01:00
3 changed files with 38 additions and 26 deletions

3
.editorconfig Normal file
View File

@@ -0,0 +1,3 @@
[*.{kt,kts}]
ktlint_code_style = intellij_idea
ktlint_standard_no-wildcard-imports = disabled

View File

@@ -1,13 +1,13 @@
[versions] [versions]
shadow = "8.1.1" shadow = "8.1.1"
kotlin-test = "1.9.20" kotlin = "1.9.22"
kotlinx-coroutines-core = "1.7.3" kotlinx-coroutines-core = "1.7.3"
picocli = "4.7.3" picocli = "4.7.3"
revanced-patcher = "19.2.0" revanced-patcher = "19.3.0"
revanced-library = "1.4.0" revanced-library = "2.0.0"
[libraries] [libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-test" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
picocli = { module = "info.picocli:picocli", version.ref = "picocli" } picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" } revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }

View File

@@ -1,13 +1,15 @@
package app.revanced.cli.command package app.revanced.cli.command
import app.revanced.library.ApkUtils import app.revanced.library.ApkUtils
import app.revanced.library.ApkUtils.applyTo
import app.revanced.library.ApkUtils.sign
import app.revanced.library.Options import app.revanced.library.Options
import app.revanced.library.Options.setOptions import app.revanced.library.Options.setOptions
import app.revanced.library.adb.AdbManager import app.revanced.library.adb.AdbManager
import app.revanced.patcher.PatchBundleLoader import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.PatchSet import app.revanced.patcher.PatchSet
import app.revanced.patcher.Patcher import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherOptions import app.revanced.patcher.PatcherConfig
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import picocli.CommandLine import picocli.CommandLine
import picocli.CommandLine.Help.Visibility.ALWAYS import picocli.CommandLine.Help.Visibility.ALWAYS
@@ -30,9 +32,9 @@ internal object PatchCommand : Runnable {
private lateinit var apk: File private lateinit var apk: File
private var integrations = listOf<File>() private var integrations = setOf<File>()
private var patchBundles = emptyList<File>() private var patchBundles = emptySet<File>()
@CommandLine.Option( @CommandLine.Option(
names = ["-i", "--include"], names = ["-i", "--include"],
@@ -91,7 +93,8 @@ internal object PatchCommand : Runnable {
@CommandLine.Option( @CommandLine.Option(
names = ["-d", "--device-serial"], names = ["-d", "--device-serial"],
description = ["ADB device serial to install to. If not supplied, the first connected device will be used."], description = ["ADB device serial to install to. If not supplied, the first connected device will be used."],
fallbackValue = "", // Empty string to indicate that the first connected device should be used. // Empty string to indicate that the first connected device should be used.
fallbackValue = "",
arity = "0..1", arity = "0..1",
) )
private var deviceSerial: String? = null private var deviceSerial: String? = null
@@ -144,6 +147,17 @@ internal object PatchCommand : Runnable {
description = ["Path to temporary resource cache directory."], description = ["Path to temporary resource cache directory."],
) )
private var resourceCachePath: File? = null private var resourceCachePath: File? = null
set(value) {
logger.warning("The --resource-cache option is deprecated. Use --temporary-files-patch instead.")
field = value
temporaryFilesPath = value
}
@CommandLine.Option(
names = ["-t", "--temporary-files-path"],
description = ["Path to temporary files directory."],
)
private var temporaryFilesPath: File? = null
private var aaptBinaryPath: File? = null private var aaptBinaryPath: File? = null
@@ -194,11 +208,11 @@ internal object PatchCommand : Runnable {
required = true, required = true,
) )
@Suppress("unused") @Suppress("unused")
private fun setPatchBundles(patchBundles: Array<File>) { private fun setPatchBundles(patchBundles: Set<File>) {
patchBundles.firstOrNull { !it.exists() }?.let { patchBundles.firstOrNull { !it.exists() }?.let {
throw CommandLine.ParameterException(spec.commandLine(), "Patch bundle ${it.name} does not exist") throw CommandLine.ParameterException(spec.commandLine(), "Patch bundle ${it.name} does not exist")
} }
this.patchBundles = patchBundles.toList() this.patchBundles = patchBundles
} }
@CommandLine.Option( @CommandLine.Option(
@@ -224,9 +238,9 @@ internal object PatchCommand : Runnable {
"${apk.nameWithoutExtension}-patched.${apk.extension}", "${apk.nameWithoutExtension}-patched.${apk.extension}",
) )
val resourceCachePath = val temporaryFilesPath =
resourceCachePath ?: outputFilePath.parentFile.resolve( temporaryFilesPath ?: outputFilePath.parentFile.resolve(
"${outputFilePath.nameWithoutExtension}-resource-cache", "${outputFilePath.nameWithoutExtension}-temporary-files",
) )
val optionsFile = val optionsFile =
@@ -261,11 +275,11 @@ internal object PatchCommand : Runnable {
// endregion // endregion
Patcher( Patcher(
PatcherOptions( PatcherConfig(
apk, apk,
resourceCachePath, temporaryFilesPath,
aaptBinaryPath?.path, aaptBinaryPath?.path,
resourceCachePath.absolutePath, temporaryFilesPath.absolutePath,
true, true,
), ),
).use { patcher -> ).use { patcher ->
@@ -304,15 +318,12 @@ internal object PatchCommand : Runnable {
// region Save // region Save
val alignedFile = apk.copyTo(outputFilePath, overwrite = true)
resourceCachePath.resolve(apk.name).apply {
ApkUtils.copyAligned(apk, this, patcherResult) patcherResult.applyTo(outputFilePath)
}
if (!mount) { if (!mount) {
ApkUtils.sign( outputFilePath.sign(
alignedFile,
outputFilePath,
ApkUtils.SigningOptions( ApkUtils.SigningOptions(
keystoreFilePath, keystoreFilePath,
keyStorePassword, keyStorePassword,
@@ -321,8 +332,6 @@ internal object PatchCommand : Runnable {
signer, signer,
), ),
) )
} else {
alignedFile.renameTo(outputFilePath)
} }
logger.info("Saved to $outputFilePath") logger.info("Saved to $outputFilePath")
@@ -340,7 +349,7 @@ internal object PatchCommand : Runnable {
if (purge) { if (purge) {
logger.info("Purging temporary files") logger.info("Purging temporary files")
purge(resourceCachePath) purge(temporaryFilesPath)
} }
} }