Compare commits

...

13 Commits

Author SHA1 Message Date
semantic-release-bot
aba7965df8 chore(release): 1.1.0-dev.2 [skip ci]
# [1.1.0-dev.2](https://github.com/revanced/revanced-cli/compare/v1.1.0-dev.1...v1.1.0-dev.2) (2022-05-07)

### Bug Fixes

* wrong use of dependency to `revanced-patches` ([351de6c](351de6cb90))
2022-05-07 21:16:55 +00:00
oSumAtrIX
351de6cb90 fix: wrong use of dependency to revanced-patches
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-05-07 23:15:31 +02:00
oSumAtrIX
52dacc16a0 chore: bump project JDK to JDK 17
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-05-07 21:37:24 +02:00
oSumAtrIX
4fe620e84b chore: bump java-version for action setup-java
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-05-07 21:21:44 +02:00
semantic-release-bot
7b1f10a8e9 chore(release): 1.1.0-dev.1 [skip ci]
# [1.1.0-dev.1](https://github.com/revanced/revanced-cli/compare/v1.0.1...v1.1.0-dev.1) (2022-05-07)

### Bug Fixes

* ClassLoader not working with Java 9+ ([3a11e11](3a11e1135b))
* leftover TODOs ([5b1139c](5b1139ce43))

### Features

* run `release.yml` workflow on branch `dev` ([9a64730](9a6473056b))
2022-05-07 19:20:22 +00:00
oSumAtrIX
9a6473056b feat: run release.yml workflow on branch dev
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-05-07 21:19:01 +02:00
oSumAtrIX
a108c92ade Merge pull request #9 from danthe1st/main
fix: ClassLoader not working with Java 9+
2022-05-07 21:15:02 +02:00
oSumAtrIX
5b1139ce43 fix: leftover TODOs
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-05-07 21:13:28 +02:00
danthe1st
3a11e1135b fix: ClassLoader not working with Java 9+ 2022-05-07 21:08:11 +02:00
semantic-release-bot
7a6025a278 chore(release): 1.0.1 [skip ci]
## [1.0.1](https://github.com/revanced/revanced-cli/compare/v1.0.0...v1.0.1) (2022-05-07)

### Bug Fixes

* broken script `CONTENT_UNMOUNT_SCRIPT` ([be53e64](be53e649a7))
* use latest version of patches dependency ([029f1ad](029f1ad722))
2022-05-07 16:16:48 +00:00
oSumAtrIX
f0d79941aa Merge remote-tracking branch 'origin/main' 2022-05-07 18:15:18 +02:00
oSumAtrIX
029f1ad722 fix: use latest version of patches dependency
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-05-07 18:15:02 +02:00
oSumAtrIX
be53e649a7 fix: broken script CONTENT_UNMOUNT_SCRIPT
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-05-07 18:13:14 +02:00
12 changed files with 60 additions and 59 deletions

View File

@@ -3,9 +3,11 @@ on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
release:
name: Release
@@ -18,7 +20,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v2
with:
java-version: '8'
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Setup Node.js

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="azul-1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="azul-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -1,3 +1,31 @@
# [1.1.0-dev.2](https://github.com/revanced/revanced-cli/compare/v1.1.0-dev.1...v1.1.0-dev.2) (2022-05-07)
### Bug Fixes
* wrong use of dependency to `revanced-patches` ([351de6c](https://github.com/revanced/revanced-cli/commit/351de6cb90aa0f2ec93e8b8f6c10d7d312082079))
# [1.1.0-dev.1](https://github.com/revanced/revanced-cli/compare/v1.0.1...v1.1.0-dev.1) (2022-05-07)
### Bug Fixes
* ClassLoader not working with Java 9+ ([3a11e11](https://github.com/revanced/revanced-cli/commit/3a11e1135bd1e8958dd21247622d549440725ead))
* leftover TODOs ([5b1139c](https://github.com/revanced/revanced-cli/commit/5b1139ce43df1f5c2c848a8209a9e618857031ce))
### Features
* run `release.yml` workflow on branch `dev` ([9a64730](https://github.com/revanced/revanced-cli/commit/9a6473056b940c6df4860dd09c09d7ac61545f7d))
## [1.0.1](https://github.com/revanced/revanced-cli/compare/v1.0.0...v1.0.1) (2022-05-07)
### Bug Fixes
* broken script `CONTENT_UNMOUNT_SCRIPT` ([be53e64](https://github.com/revanced/revanced-cli/commit/be53e649a7a43de70ba2a7227c49b085001066a6))
* use latest version of patches dependency ([029f1ad](https://github.com/revanced/revanced-cli/commit/029f1ad72223e5be6664c2c8810ac35e5807d9a8))
# 1.0.0 (2022-05-07)

View File

@@ -22,12 +22,9 @@ repositories {
}
}
val patchesDependency = "app.revanced:revanced-patches:1.0.0-dev.5"
dependencies {
implementation(kotlin("stdlib"))
implementation("app.revanced:revanced-patcher:+")
implementation(patchesDependency)
implementation("info.picocli:picocli:+")
implementation("me.tongfei:progressbar:+")
@@ -45,9 +42,6 @@ tasks {
dependsOn(shadowJar)
}
shadowJar {
dependencies {
exclude(dependency(patchesDependency))
}
manifest {
attributes("Main-Class" to "app.revanced.cli.MainKt")
attributes("Implementation-Title" to project.name)

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official
version = 1.0.0
version = 1.1.0-dev.2

View File

@@ -1,6 +1,5 @@
package app.revanced.cli
import app.revanced.patch.PatchLoader
import app.revanced.patch.Patches
import app.revanced.utils.adb.Adb
import picocli.CommandLine.*
@@ -49,8 +48,7 @@ internal object MainCommand : Runnable {
override fun run() {
if (listOnly) {
patchBundles.forEach {
PatchLoader.injectPatches(it)
Patches.loadPatches().forEach {
Patches.load(it).forEach {
println(it().metadata)
}
}

View File

@@ -1,6 +1,5 @@
package app.revanced.cli
import app.revanced.patch.PatchLoader
import app.revanced.patch.Patches
import app.revanced.patcher.data.base.Data
import app.revanced.patcher.patch.base.Patch
@@ -52,19 +51,16 @@ internal class Patcher {
}
private fun app.revanced.patcher.Patcher.addPatchesFiltered() {
// TODO: get package metadata (outside of this method) for apk file which needs to be patched
val packageName = this.packageName
val packageVersion = this.packageVersion
val checkInclude = MainCommand.includedPatches.isNotEmpty()
MainCommand.patchBundles.forEach { bundle ->
PatchLoader.injectPatches(bundle)
val includedPatches = mutableListOf<Patch<Data>>()
Patches.loadPatches().forEach patch@{
Patches.load(bundle).forEach patch@{
val patch = it()
// TODO: filter out incompatible patches with package metadata
val filterOutPatches = true
if (filterOutPatches && !patch.metadata.compatiblePackages.any { packageMetadata ->
packageMetadata.name == packageName && packageMetadata.versions.any {

View File

@@ -1,25 +0,0 @@
package app.revanced.patch
import java.io.File
import java.net.URL
import java.net.URLClassLoader
internal class PatchLoader {
internal companion object {
internal fun injectPatches(file: File) {
// This function will fail on Java 9 and above.
try {
val url = file.toURI().toURL()
val classLoader = Thread.currentThread().contextClassLoader as URLClassLoader
val method = URLClassLoader::class.java.getDeclaredMethod("addURL", URL::class.java)
method.isAccessible = true
method.invoke(classLoader, url)
} catch (e: Exception) {
throw Exception(
"Failed to inject patches! The CLI does NOT work on Java 9 and above, please use Java 8!",
e // propagate exception
)
}
}
}
}

View File

@@ -1,15 +1,26 @@
package app.revanced.patch
import app.revanced.patches.Index
import app.revanced.patcher.data.base.Data
import app.revanced.patcher.patch.base.Patch
import java.io.File
import java.net.URLClassLoader
internal class Patches {
internal companion object {
// You may ask yourself, "why do this?".
// We do it like this, because we don't want the Index class
// to be loaded while the dependency hasn't been injected yet.
// You can see this as "controlled class loading".
// Whenever this class is loaded (because it is invoked), all the imports
// will be loaded too. We don't want to do this until we've injected the class.
internal fun loadPatches() = Index.patches
internal object Patches {
/**
* This method loads patches from a given patch file
* @return the loaded patches represented as a list of functions returning instances of [Patch]
*/
internal fun load(patchesJar: File): List<() -> Patch<Data>> {
val url = patchesJar.toURI().toURL()
val classLoader = URLClassLoader(arrayOf(url))
val indexClass = classLoader.loadClass("app.revanced.patches.Index")
val index = indexClass.declaredFields.last()
index.isAccessible = true
@Suppress("UNCHECKED_CAST")
return index.get(null) as List<() -> Patch<Data>>
}
}
}

View File

@@ -43,7 +43,7 @@ internal object Constants {
#!/system/bin/sh
stock_path=${'$'}{ pm path $PLACEHOLDER | grep base | sed 's/package://g' }
umount -l $PLACEHOLDER; done< /proc/mounts
umount -l ${'$'}stock_path
""".trimIndent()
// mount script

View File

@@ -12,10 +12,7 @@ internal class FileSystemUtils(
private var fileSystem: FileSystem
init {
fileSystem = FileSystems.newFileSystem(
file.toPath(),
null
)
fileSystem = FileSystems.newFileSystem(file.toPath(), null as ClassLoader?)
}
private fun deleteDirectory(dirPath: String) {

View File

@@ -91,7 +91,7 @@ object Signer {
(keyStore.getKey(alias, PASSWORD) as PrivateKey)
)
val zip = FileSystems.newFileSystem(apkFile.toPath(), null)
val zip = FileSystems.newFileSystem(apkFile.toPath(), null as ClassLoader?)
val dig = MessageDigest.getInstance("SHA1")
val digests: MutableMap<String, String> = LinkedHashMap()