From 5ff105cf6b3fac9cd12478efd10caf90d1ecf589 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 11 Mar 2024 10:05:32 +0100 Subject: [PATCH] fix: Sign APKs correctly --- .../app/revanced/cli/command/PatchCommand.kt | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt b/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt index b9ca098..b440d62 100644 --- a/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt +++ b/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt @@ -262,12 +262,13 @@ internal object PatchCommand : Runnable { } // endregion + val patcherTemporaryFilesPath = temporaryFilesPath.resolve("patcher") val (packageName, patcherResult) = Patcher( PatcherConfig( apk, - temporaryFilesPath, + patcherTemporaryFilesPath, aaptBinaryPath?.path, - temporaryFilesPath.absolutePath, + patcherTemporaryFilesPath.absolutePath, true, ), ).use { patcher -> @@ -304,21 +305,22 @@ internal object PatchCommand : Runnable { } // region Save - - apk.copyTo(outputFilePath, overwrite = true) - - patcherResult.applyTo(outputFilePath) - - if (!mount) { - outputFilePath.sign( - ApkUtils.SigningOptions( - keystoreFilePath, - keyStorePassword, - alias, - password, - signer, - ), - ) + apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply { + patcherResult.applyTo(this) + }.let { + if (!mount) { + sign( + it, + outputFilePath, + ApkUtils.SigningOptions( + keystoreFilePath, + keyStorePassword, + alias, + password, + signer, + ), + ) + } } logger.info("Saved to $outputFilePath")