Skip to content

Commit

Permalink
feat: --rip-lib and --unsigned
Browse files Browse the repository at this point in the history
  • Loading branch information
E85Addict committed Nov 26, 2023
1 parent 89c35ee commit ee0135f
Show file tree
Hide file tree
Showing 35 changed files with 1,633 additions and 139 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Delete old workflow runs
on:
workflow_dispatch:
inputs:
days:
description: 'Number of days.'
required: true
default: 0
minimum_runs:
description: 'The minimum runs to keep for each workflow.'
required: true
default: 0
delete_workflow_pattern:
description: 'The name of the workflow. if not set then it will target all workflows.'
required: false

jobs:
del_runs:
runs-on: ubuntu-22.04
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: ${{ github.event.inputs.days }}
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
26 changes: 0 additions & 26 deletions .github/workflows/pull_request.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/sync_upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Sync upstream
on:
workflow_call:
workflow_dispatch:
schedule:
- cron: "0 */8 * * *"

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}

- name: sync
id: sync
shell: bash
run: |
git config --global user.name 'E85Addict'
git config --global user.email '77761710+E85Addict@users.noreply.github.com'
if [[ $(git log | grep Author | head -1) == *"semantic"* ]]; then
git reset --hard HEAD~1
fi
T=$(git tag --sort=creatordate | tail -1)
git remote add upstream https://github.com/revanced/revanced-cli
git tag -d $(git tag -l)
git fetch upstream --tags -f
LatestRemoteTag=$(curl -s https://api.github.com/repos/revanced/revanced-cli/releases/latest | jq -r '.tag_name')
C=$(git rev-list --left-right --count origin/main...remotes/upstream/main | awk '{print$2}')
echo "Ahead $C commits."
if [ "$C" -gt 0 ]; then
echo "Rebasing"
# git push origin --delete $T
git rebase -X ours upstream/main
git push --tags -f
git push origin --delete $LatestRemoteTag
git push -f
else
echo "in sync"
fi
19 changes: 0 additions & 19 deletions .github/workflows/update-documentation.yml

This file was deleted.

9 changes: 1 addition & 8 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,11 @@
{
"assets": [
{
"path": "build/libs/*all.jar"
"path": "revanced-cli/build/libs/*all.jar"
}
],
successComment: false
}
],
[
"@saithodev/semantic-release-backmerge",
{
backmergeBranches: [{"from": "main", "to": "dev"}],
clearWorkspace: true
}
]
]
}
71 changes: 4 additions & 67 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,70 +1,7 @@
plugins {
kotlin("jvm") version "1.9.10"
alias(libs.plugins.shadow)
kotlin("jvm") version "1.9.10" apply false
}

group = "app.revanced"

repositories {
mavenCentral()
mavenLocal()
google()
maven { url = uri("https://jitpack.io") }
}

dependencies {
implementation(libs.revanced.patcher)
implementation(libs.revanced.library)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.picocli)

testImplementation(libs.kotlin.test)
}

kotlin { jvmToolchain(11) }

tasks {
test {
useJUnitPlatform()
testLogging {
events("PASSED", "SKIPPED", "FAILED")
}
}

processResources {
expand("projectVersion" to project.version)
}

shadowJar {
manifest {
attributes("Main-Class" to "app.revanced.cli.command.MainCommandKt")
}
minimize {
exclude(dependency("org.jetbrains.kotlin:.*"))
exclude(dependency("org.bouncycastle:.*"))
exclude(dependency("app.revanced:.*"))
}
}

build {
dependsOn(shadowJar)
}

/*
Dummy task to hack gradle-semantic-release-plugin to release this project.
Explanation:
SemVer is a standard for versioning libraries.
For that reason the semantic-release plugin uses the "publish" task to publish libraries.
However, this subproject is not a library, and the "publish" task is not available for this subproject.
Because semantic-release is not designed to handle this case, we need to hack it.
RE: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
*/

register<DefaultTask>("publish") {
group = "publishing"
description = "Dummy task to hack gradle-semantic-release-plugin to release ReVanced CLI"
dependsOn(build)
}
}
allprojects {
group = "app.revanced"
}
14 changes: 11 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
[versions]
shadow = "8.1.1"
apksig = "8.1.4"
bcpkix-jdk18on = "1.76"
jackson-module-kotlin = "2.14.3"
jadb = "1.2.1"
kotlin-reflect = "1.9.10"
kotlin-test = "1.9.20"
kotlinx-coroutines-core = "1.7.3"
picocli = "4.7.3"
picocli = "4.7.5"
revanced-patcher = "19.0.0"
revanced-library = "1.3.0"

[libraries]
apksig = { module = "com.android.tools.build:apksig", version.ref = "apksig" }
bcpkix-jdk18on = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "bcpkix-jdk18on" }
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson-module-kotlin" }
jadb = { module = "app.revanced:jadb", version.ref = "jadb" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin-reflect" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-test" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
revanced-library = { module = "app.revanced:revanced-library", version.ref = "revanced-library" }

[plugins]
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
1 change: 0 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dist
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
52 changes: 52 additions & 0 deletions revanced-cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
plugins {
kotlin("jvm") version "1.9.10"
alias(libs.plugins.shadow)
}

dependencies {
implementation(project(":revanced-lib"))
implementation(libs.revanced.patcher)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.picocli)

testImplementation(libs.kotlin.test)
}

kotlin { jvmToolchain(11) }

tasks {
test {
useJUnitPlatform()
testLogging {
events("PASSED", "SKIPPED", "FAILED")
}
}

processResources {
expand("projectVersion" to project.version)
}

shadowJar {
manifest {
attributes("Main-Class" to "app.revanced.cli.command.MainCommandKt")
}
minimize {
exclude(dependency("org.jetbrains.kotlin:.*"))
exclude(dependency("org.bouncycastle:.*"))
exclude(dependency("app.revanced:.*"))
}
}

build {
dependsOn(shadowJar)
}

// Dummy task to fix the Gradle semantic-release plugin.
// Remove this if you forked it to support building only.
// Tracking issue: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
register<DefaultTask>("publish") {
group = "publish"
description = "Dummy task"
dependsOn(build)
}
}
7 changes: 7 additions & 0 deletions revanced-cli/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rootProject.name = "revanced-cli"

buildCache {
local {
isEnabled = !System.getenv().containsKey("CI")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ internal object PatchCommand : Runnable {
this.aaptBinaryPath = aaptBinaryPath
}

@CommandLine.Option(
names = ["--unsigned"], description = ["Disable signing of the final apk."]
)
private var unsigned: Boolean = false

@CommandLine.Option(
names = ["--rip-lib"], description = ["Rip native libs from APK. (x86_64 etc.)"]
)
private var ripLibs = arrayOf<String>()

override fun run() {
// region Setup

Expand Down Expand Up @@ -306,10 +316,10 @@ internal object PatchCommand : Runnable {

val alignedFile =
resourceCachePath.resolve(apk.name).apply {
ApkUtils.copyAligned(apk, this, patcherResult)
ApkUtils.copyAligned(apk, this, patcherResult, ripLibs)
}

if (!mount) {
if (!mount && !unsigned) {
ApkUtils.sign(
alignedFile,
outputFilePath,
Expand Down
Loading

0 comments on commit ee0135f

Please sign in to comment.