Skip to content

Commit

Permalink
feat: riplib
Browse files Browse the repository at this point in the history
  • Loading branch information
j-hc committed Aug 31, 2022
1 parent 3cef245 commit bd5c78c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/app/revanced/cli/command/MainCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ internal object MainCommand : Runnable {

@Option(names = ["--custom-aapt2-binary"], description = ["Path to custom aapt2 binary"])
var aaptPath: String = ""

@Option(names = ["--rip-lib"], description = ["Rips the lib (arm64-v8a etc.) from the APK"])
var ripLibs = arrayOf<String>()
}

override fun run() {
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/app/revanced/cli/patcher/Patcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ internal object Patcher {
}
}

args.ripLibs.forEach {
logger.info("Ripping $it libs")
try {
outputFileSystem.deleteRecursively("lib/$it")
} catch(e: Exception) {
logger.warn("Failed to rip $it libs: $e")
}
}

result.doNotCompress?.let { outputFileSystem.uncompress(*it.toTypedArray()) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ internal class ZipFileSystemUtils(

internal fun write(path: String, content: ByteArray) = Files.write(zipFileSystem.getPath(path), content)

internal fun deleteRecursively(path: String) = zipFileSystem.getPath(path).deleteRecursively()

private fun Path.getRelativePath(path: Path): Path = zipFileSystem.getPath(path.relativize(this).toString())

// TODO: figure out why the file system is uncompressed by default and how to fix it
Expand Down

0 comments on commit bd5c78c

Please sign in to comment.