mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-11 22:06:20 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e3d147690 | ||
|
|
87ffaa4bdb | ||
|
|
8a49dcc110 | ||
|
|
4a23cb69bc | ||
|
|
8c325af0f9 | ||
|
|
a26ab2a2c3 | ||
|
|
d335846202 | ||
|
|
6fc3ae67c8 | ||
|
|
0df936e99b | ||
|
|
83743929c8 | ||
|
|
51e091ce40 | ||
|
|
e5a37e0a5f | ||
|
|
c94471f464 | ||
|
|
bfd50a43b9 | ||
|
|
2c8a106151 | ||
|
|
ea7efd2afc | ||
|
|
6c4c1924ee |
46
CHANGELOG.md
46
CHANGELOG.md
@@ -1,3 +1,49 @@
|
||||
# [1.10.0](https://github.com/revanced/revanced-cli/compare/v1.9.3...v1.10.0) (2022-06-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add callback for addFiles ([87ffaa4](https://github.com/revanced/revanced-cli/commit/87ffaa4bdb25cb85c6ba7195f5d3b13b09a5f912))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add logging back ([4a23cb6](https://github.com/revanced/revanced-cli/commit/4a23cb69bc385158d47b6ea8d3da54b0566a242c))
|
||||
|
||||
## [1.9.3](https://github.com/revanced/revanced-cli/compare/v1.9.2...v1.9.3) (2022-06-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use absolute file path for key store ([d335846](https://github.com/revanced/revanced-cli/commit/d335846202b991e130882e9ce0ab268deb2e27ab))
|
||||
|
||||
## [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)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* migrate logger to `slf4j` ([6c4c192](https://github.com/revanced/revanced-cli/commit/6c4c1924ee9ae75af3449749a6a82b7ae5572129))
|
||||
|
||||
# [1.8.0](https://github.com/revanced/revanced-cli/compare/v1.7.1...v1.8.0) (2022-06-22)
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation(kotlin("reflect"))
|
||||
|
||||
implementation("app.revanced:revanced-patcher:1.6.0")
|
||||
implementation("app.revanced:revanced-patcher:1.7.2")
|
||||
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.8.0
|
||||
version = 1.10.0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package app.revanced.cli.command
|
||||
|
||||
import app.revanced.cli.patcher.Patcher
|
||||
import app.revanced.cli.patcher.PatcherLogger
|
||||
import app.revanced.cli.signing.Signing
|
||||
import app.revanced.cli.signing.SigningOptions
|
||||
import app.revanced.patcher.PatcherOptions
|
||||
@@ -11,16 +12,11 @@ import app.revanced.utils.adb.Adb
|
||||
import picocli.CommandLine.*
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.util.logging.Logger
|
||||
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 = Logger.getLogger(MainCommand.javaClass.name)
|
||||
|
||||
@ArgGroup(exclusive = false, multiplicity = "1")
|
||||
lateinit var args: Args
|
||||
|
||||
@@ -85,22 +81,21 @@ internal object MainCommand : Runnable {
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
System.setProperty("java.util.logging.SimpleFormatter.format", "%4\$s: %5\$s %n")
|
||||
|
||||
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
|
||||
args.inputFile,
|
||||
args.cacheDirectory,
|
||||
!args.disableResourcePatching,
|
||||
logger = PatcherLogger
|
||||
)
|
||||
)
|
||||
|
||||
@@ -117,21 +112,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.absoluteFile.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
|
||||
|
||||
23
src/main/kotlin/app/revanced/cli/patcher/PatcherLogger.kt
Normal file
23
src/main/kotlin/app/revanced/cli/patcher/PatcherLogger.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
package app.revanced.cli.patcher
|
||||
|
||||
import app.revanced.patcher.PatchLogger
|
||||
|
||||
object PatcherLogger : PatchLogger {
|
||||
private const val prefix = "[patcher]"
|
||||
|
||||
override fun error(msg: String) {
|
||||
println("error: $prefix: $msg")
|
||||
}
|
||||
|
||||
override fun info(msg: String) {
|
||||
println("info: $prefix: $msg")
|
||||
}
|
||||
|
||||
override fun trace(msg: String) {
|
||||
println("trace: $prefix: $msg")
|
||||
}
|
||||
|
||||
override fun warn(msg: String) {
|
||||
println("warn: $prefix: $msg")
|
||||
}
|
||||
}
|
||||
@@ -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.warning("$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,16 +57,16 @@ fun Patcher.addPatchesFiltered(
|
||||
fun Patcher.applyPatchesVerbose() {
|
||||
this.applyPatches().forEach { (patch, result) ->
|
||||
if (result.isSuccess) {
|
||||
logger.info("Success: $patch")
|
||||
|
||||
println("[success] $patch")
|
||||
return@forEach
|
||||
}
|
||||
logger.severe("Error: $patch")
|
||||
|
||||
println("[error] $patch:")
|
||||
result.exceptionOrNull()!!.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun Patcher.mergeFiles() {
|
||||
this.addFiles(args.pArgs!!.mergeFiles)
|
||||
this.addFiles(args.pArgs!!.mergeFiles) {
|
||||
println("[merged] ${it.name}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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