mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-18 17:03:58 +00:00
feat: remove extra zipalign step (#106)
* feat: remove extra zipalign step * remove zipfs * remove use * reduce compression * put back misc.xml * revert stupid autofix
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package app.revanced.cli.aligning
|
||||
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.utils.signing.align.ZipAligner
|
||||
import java.io.File
|
||||
|
||||
object Aligning {
|
||||
fun align(inputFile: File, outputFile: File) {
|
||||
logger.info("Aligning ${inputFile.name} to ${outputFile.name}")
|
||||
ZipAligner.align(inputFile, outputFile)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.cli.command
|
||||
|
||||
import app.revanced.cli.aligning.Aligning
|
||||
import app.revanced.cli.logging.impl.DefaultCliLogger
|
||||
import app.revanced.cli.patcher.Patcher
|
||||
import app.revanced.cli.patcher.logging.impl.PatcherLogger
|
||||
@@ -161,15 +160,11 @@ internal object MainCommand : Runnable {
|
||||
|
||||
val cacheDirectory = File(pArgs.cacheDirectory)
|
||||
|
||||
// align the file
|
||||
val alignedFile = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_aligned.apk")
|
||||
Aligning.align(patchedFile, alignedFile)
|
||||
|
||||
// sign the file
|
||||
val finalFile = if (!pArgs.mount) {
|
||||
val signedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_signed.apk")
|
||||
Signing.sign(
|
||||
alignedFile,
|
||||
patchedFile,
|
||||
signedOutput,
|
||||
SigningOptions(
|
||||
pArgs.cn,
|
||||
@@ -182,7 +177,7 @@ internal object MainCommand : Runnable {
|
||||
|
||||
signedOutput
|
||||
} else
|
||||
alignedFile
|
||||
patchedFile
|
||||
|
||||
// finally copy to the specified output file
|
||||
logger.info("Copying ${finalFile.name} to ${outputFile.name}")
|
||||
|
||||
@@ -2,10 +2,12 @@ package app.revanced.cli.patcher
|
||||
|
||||
import app.revanced.cli.command.MainCommand.args
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.utils.filesystem.ZipFileSystemUtils
|
||||
import app.revanced.utils.patcher.addPatchesFiltered
|
||||
import app.revanced.utils.patcher.applyPatchesVerbose
|
||||
import app.revanced.utils.patcher.mergeFiles
|
||||
import app.revanced.utils.signing.align.ZipAligner
|
||||
import app.revanced.utils.signing.align.zip.ZipFile
|
||||
import app.revanced.utils.signing.align.zip.structures.ZipEntry
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
@@ -23,26 +25,22 @@ internal object Patcher {
|
||||
|
||||
// write output file
|
||||
if (output.exists()) Files.delete(output.toPath())
|
||||
inputFile.copyTo(output)
|
||||
|
||||
val result = patcher.save()
|
||||
ZipFileSystemUtils(output).use { outputFileSystem ->
|
||||
ZipFile(output).use { outputFile ->
|
||||
// replace all dex files
|
||||
result.dexFiles.forEach {
|
||||
logger.info("Writing dex file ${it.name}")
|
||||
outputFileSystem.write(it.name, it.dexFileInputStream.readAllBytes())
|
||||
outputFile.addEntryCompressData(ZipEntry.createWithName(it.name), it.dexFileInputStream.readAllBytes())
|
||||
}
|
||||
|
||||
if (!args.disableResourcePatching) {
|
||||
logger.info("Writing resources...")
|
||||
|
||||
ZipFileSystemUtils(result.resourceFile!!).use { resourceFileSystem ->
|
||||
val resourceFiles = resourceFileSystem.getFile(File.separator)
|
||||
outputFileSystem.writePathRecursively(resourceFiles)
|
||||
}
|
||||
outputFile.copyEntriesFromFileAligned(ZipFile(result.resourceFile!!), ZipAligner::getEntryAlignment)
|
||||
}
|
||||
|
||||
result.doNotCompress?.let { outputFileSystem.uncompress(*it.toTypedArray()) }
|
||||
outputFile.copyEntriesFromFileAligned(ZipFile(inputFile), ZipAligner::getEntryAlignment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user