You've already forked revanced-cli
mirror of
https://github.com/revanced/revanced-cli
synced 2025-11-19 15:33:27 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fc3ae67c8 | ||
|
|
0df936e99b | ||
|
|
83743929c8 | ||
|
|
51e091ce40 | ||
|
|
e5a37e0a5f | ||
|
|
c94471f464 | ||
|
|
bfd50a43b9 | ||
|
|
2c8a106151 |
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
||||
## [1.9.2](https://github.com/revanced/revanced-cli/compare/v1.9.1...v1.9.2) (2022-06-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update patcher version ([0df936e](https://github.com/revanced/revanced-cli/commit/0df936e99b01358a88a628af63eebb5ac92cae76))
|
||||
|
||||
## [1.9.1](https://github.com/revanced/revanced-cli/compare/v1.9.0...v1.9.1) (2022-06-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add back in: option to specify keystore file path ([c94471f](https://github.com/revanced/revanced-cli/commit/c94471f4643e44b2b472ff0d826db0d2743bdc86))
|
||||
* remove logger from Signer.kt ([51e091c](https://github.com/revanced/revanced-cli/commit/51e091ce4021418508044029aa5af6aa7d5162a3))
|
||||
|
||||
|
||||
### Reverts
|
||||
|
||||
* "feat: use of `java.util.logging.Logger`" ([2c8a106](https://github.com/revanced/revanced-cli/commit/2c8a10615192635202ddc137fc02f175c5914d8f))
|
||||
|
||||
# [1.9.0](https://github.com/revanced/revanced-cli/compare/v1.8.0...v1.9.0) (2022-06-22)
|
||||
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation(kotlin("reflect"))
|
||||
|
||||
implementation("app.revanced:revanced-patcher:1.6.0")
|
||||
implementation("org.slf4j:slf4j-api:1.7.36")
|
||||
implementation("app.revanced:revanced-patcher:1.7.1")
|
||||
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
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 1.9.0
|
||||
version = 1.9.2
|
||||
|
||||
@@ -8,20 +8,14 @@ import app.revanced.patcher.extensions.PatchExtensions.description
|
||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||
import app.revanced.utils.adb.Adb
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import picocli.CommandLine.*
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.name
|
||||
|
||||
@Command(
|
||||
name = "ReVanced-CLI", version = ["1.0.0"], mixinStandardHelpOptions = true
|
||||
)
|
||||
internal object MainCommand : Runnable {
|
||||
val logger: Logger = LoggerFactory.getLogger(MainCommand::class.java)
|
||||
|
||||
@ArgGroup(exclusive = false, multiplicity = "1")
|
||||
lateinit var args: Args
|
||||
|
||||
@@ -88,15 +82,13 @@ internal object MainCommand : Runnable {
|
||||
override fun run() {
|
||||
if (args.lArgs?.listOnly == true) {
|
||||
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
logger.info("${patch.patchName}: ${patch.description}")
|
||||
println("[available] ${patch.patchName}: ${patch.description}")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val args = args.pArgs ?: return
|
||||
|
||||
logger.info("Initialize patcher")
|
||||
|
||||
val patcher = app.revanced.patcher.Patcher(
|
||||
PatcherOptions(
|
||||
args.inputFile, args.cacheDirectory, !args.disableResourcePatching
|
||||
@@ -116,21 +108,27 @@ internal object MainCommand : Runnable {
|
||||
|
||||
if (!args.mount) {
|
||||
Signing.start(
|
||||
patchedFile, outputFile, SigningOptions(
|
||||
patchedFile,
|
||||
outputFile,
|
||||
SigningOptions(
|
||||
args.cn,
|
||||
args.password,
|
||||
args.keystorePath
|
||||
?: Path(outputFile.parent).resolve("${outputFile.nameWithoutExtension}.keystore").name
|
||||
args.keystorePath ?: outputFile.parentFile
|
||||
.resolve("${outputFile.nameWithoutExtension}.keystore")
|
||||
.name
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (args.clean) File(args.cacheDirectory).deleteRecursively()
|
||||
|
||||
adb?.deploy()
|
||||
adb?.let {
|
||||
println("[deploying]")
|
||||
it.deploy()
|
||||
}
|
||||
|
||||
if (args.clean && args.deploy != null) Files.delete(outputFile.toPath())
|
||||
|
||||
logger.info("Done")
|
||||
println("[done]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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
|
||||
@@ -31,13 +30,9 @@ internal object Patcher {
|
||||
ZipFileSystemUtils(inputFile, output).use { fileSystem ->
|
||||
// replace all dex files
|
||||
result.dexFiles.forEach {
|
||||
logger.info("Write ${it.name}")
|
||||
|
||||
fileSystem.write(it.name, it.dexFileInputStream.readAllBytes())
|
||||
}
|
||||
|
||||
logger.info("Write resources")
|
||||
|
||||
// inputFile being null implies resource patching being disabled
|
||||
if (inputFile != null) {
|
||||
// write resources
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package app.revanced.cli.signing
|
||||
|
||||
import app.revanced.cli.command.MainCommand.args
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.utils.signing.Signer
|
||||
import app.revanced.utils.signing.align.ZipAligner
|
||||
import java.io.File
|
||||
@@ -12,16 +11,13 @@ object Signing {
|
||||
val alignedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_aligned.apk")
|
||||
val signedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_signed.apk")
|
||||
|
||||
logger.info("Align zip entries")
|
||||
|
||||
// align the inputFile and write to alignedOutput
|
||||
println("[aligning]")
|
||||
ZipAligner.align(inputFile, alignedOutput)
|
||||
|
||||
logger.info("Sign zip file")
|
||||
|
||||
// sign the alignedOutput and write to signedOutput
|
||||
// the reason is, in case the signer fails
|
||||
// it does not damage the output file
|
||||
println("[signing]")
|
||||
val keyStore = Signer(signingOptions).signApk(alignedOutput, signedOutput)
|
||||
|
||||
// afterwards copy over the file and the keystore to the output
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.utils.adb
|
||||
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import se.vidstige.jadb.JadbConnection
|
||||
import se.vidstige.jadb.JadbDevice
|
||||
import se.vidstige.jadb.managers.PackageManager
|
||||
@@ -30,12 +29,8 @@ internal class Adb(
|
||||
|
||||
internal fun deploy() {
|
||||
if (modeInstall) {
|
||||
logger.info("Install without mount")
|
||||
|
||||
PackageManager(device).install(file)
|
||||
} else {
|
||||
logger.info("Install by mount")
|
||||
|
||||
// push patched file
|
||||
device.copy(Constants.PATH_INIT_PUSH, file)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package app.revanced.utils.patcher
|
||||
|
||||
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.base.Data
|
||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||
@@ -23,34 +22,33 @@ fun Patcher.addPatchesFiltered(
|
||||
val compatiblePackages = patch.compatiblePackages
|
||||
val patchName = patch.patchName
|
||||
|
||||
val prefix = "Skip $patchName"
|
||||
val prefix = "[skipped] $patchName"
|
||||
|
||||
val args = MainCommand.args.pArgs!!
|
||||
|
||||
if (excludePatches && args.excludedPatches.contains(patchName)) {
|
||||
logger.info("$prefix: Explicitly excluded")
|
||||
println("$prefix: Explicitly excluded.")
|
||||
return@patch
|
||||
} else if (!patch.include) {
|
||||
logger.info("$prefix: Implicitly excluded")
|
||||
println("$prefix: Implicitly excluded.")
|
||||
return@patch
|
||||
}
|
||||
|
||||
if (compatiblePackages == null) logger.warn("$prefix: Missing compatibility annotation. Continuing.")
|
||||
if (compatiblePackages == null) println("$prefix: Missing compatibility annotation. Continuing.")
|
||||
else {
|
||||
if (!compatiblePackages.any { it.name == packageName }) {
|
||||
logger.info("$prefix: Incompatible package")
|
||||
println("$prefix: Incompatible package.")
|
||||
return@patch
|
||||
}
|
||||
|
||||
if (!(args.experimental || compatiblePackages.any { it.versions.isEmpty() || it.versions.any { version -> version == packageVersion } })) {
|
||||
logger.info("$prefix: The package version is $packageVersion and is incompatible")
|
||||
println("$prefix: The package version is $packageVersion and is incompatible.")
|
||||
return@patch
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Add $patchName")
|
||||
|
||||
includedPatches.add(patch)
|
||||
println("[added] $patchName")
|
||||
}
|
||||
this.addPatches(includedPatches)
|
||||
}
|
||||
@@ -59,12 +57,10 @@ fun Patcher.addPatchesFiltered(
|
||||
fun Patcher.applyPatchesVerbose() {
|
||||
this.applyPatches().forEach { (patch, result) ->
|
||||
if (result.isSuccess) {
|
||||
logger.info("Success: $patch")
|
||||
|
||||
println("[success] $patch")
|
||||
return@forEach
|
||||
}
|
||||
logger.error("Error: $patch")
|
||||
|
||||
println("[error] $patch:")
|
||||
result.exceptionOrNull()!!.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.utils.signing
|
||||
|
||||
import app.revanced.cli.command.MainCommand.logger
|
||||
import app.revanced.cli.signing.SigningOptions
|
||||
import com.android.apksig.ApkSigner
|
||||
import org.bouncycastle.asn1.x500.X500Name
|
||||
@@ -55,7 +54,9 @@ internal class Signer(
|
||||
|
||||
// TODO: keystore should be saved securely
|
||||
val ks = File(signingOptions.keyStoreFilePath)
|
||||
if (!ks.exists()) newKeystore(ks) else logger.info("Found existing keystore ${ks.nameWithoutExtension}")
|
||||
if (!ks.exists()) newKeystore(ks) else {
|
||||
println("found existing keystore: ${ks.nameWithoutExtension}")
|
||||
}
|
||||
|
||||
val keyStore = KeyStore.getInstance("BKS", "BC")
|
||||
FileInputStream(ks).use { fis -> keyStore.load(fis, null) }
|
||||
|
||||
Reference in New Issue
Block a user