Skip to content

Commit

Permalink
compile revanced patches locally
Browse files Browse the repository at this point in the history
* removed CheckEnvironmentPatch because it didnt correctly detect the on-device local patching
* revanced-patches `v5.2.1`
  • Loading branch information
programminghoch10 committed Dec 5, 2024
1 parent 2763f41 commit d4b4b0c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "revanced-cli"]
path = revanced-cli
url = https://github.com/revanced/revanced-cli
url = https://github.com/revanced/revanced-cli
[submodule "revanced-patches"]
path = revanced-patches
url = https://github.com/revanced/revanced-patches
37 changes: 21 additions & 16 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
set -e
shopt -s inherit_errexit
set -o pipefail

for cmd in git wget zip java; do
[ -z "$(command -v "$cmd")" ] && echo "missing $cmd" && exit 1
Expand All @@ -10,46 +12,49 @@ done
[ -z "$GITHUB_TOKEN" ] && echo "missing GITHUB_TOKEN" && exit 1

declare -x GITHUB_ACTOR GITHUB_TOKEN
REVANCED_PATCHES_URL="https://github.com/revanced/revanced-patches/releases/download/v%s/patches-%s.rvp"

git submodule update --checkout
git clean -fdx magiskmodule/

executeGradle() {
(
cd revanced-android
cd "$1"
shift
./gradlew "$@"
)
}
applyPatches() {
(
cd "$1"
for patch in ../"$1"-patches/*.patch; do
git am --no-3way "$patch"
done
)
}

[ "$1" = "clean" ] && {
executeGradle clean
executeGradle revanced-android clean
executeGradle revanced-patches clean
exit
}

(
cd revanced-cli
for patch in ../revanced-cli-patches/*.patch; do
git am --no-3way "$patch"
done
)
applyPatches revanced-cli
executeGradle revanced-android assemble :revancedcli:shadowJar

executeGradle assemble :revancedcli:shadowJar
applyPatches revanced-patches
executeGradle revanced-patches buildAndroid

git submodule update --checkout

source version.sh

REVANCED_PATCHES=${REVANCED_PATCHES#v}
printf -v REVANCED_PATCHES_DL "$REVANCED_PATCHES_URL" "$REVANCED_PATCHES" "$REVANCED_PATCHES"
[ ! -f "$(basename "$REVANCED_PATCHES_DL")" ] && wget -c -O "$(basename "$REVANCED_PATCHES_DL")" "$REVANCED_PATCHES_DL"

REVANCED_CLI=${REVANCED_CLI#v}
ln -v -s -f "revanced-cli/build/libs/revancedcli-$REVANCED_CLI-all.jar" "revanced-cli.jar"
ln -v -s -f revanced-cli/build/libs/revancedcli-"$REVANCED_CLI"-all.jar revanced-cli.jar

PATCHES_LIST=$(java -jar revanced-cli.jar \
list-packages \
"$(basename "$REVANCED_PATCHES_DL")" \
revanced-patches/patches/build/libs/patches-"$REVANCED_PATCHES".rvp \
| sed 's/^INFORMATION: \s*//')
rm -rf magiskmodule/packageversions
mkdir magiskmodule/packageversions
Expand All @@ -65,7 +70,7 @@ done
logo/convert.sh

cp -v revanced-android/revancedcliwrapper/build/outputs/apk/release/revancedcliwrapper-release.apk magiskmodule/revancedandroidcli.apk
cp -v "$(basename "$REVANCED_PATCHES_DL")" magiskmodule/patches.rvp
cp -v revanced-patches/patches/build/libs/patches-"$REVANCED_PATCHES".rvp magiskmodule/patches.rvp
cp -r -v --no-target-directory aapt2 magiskmodule/aapt2lib
cp -r --no-target-directory logo/assets magiskmodule/logo
cp README.md magiskmodule/README.md
Expand Down
1 change: 1 addition & 0 deletions revanced-patches
Submodule revanced-patches added at 69ec47
27 changes: 27 additions & 0 deletions revanced-patches-patches/remove-CheckEnvironmentPatch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 7b6d527f31ae0e1f2b9aa1b357dd4e9ed4e95e36 Mon Sep 17 00:00:00 2001
From: programminghoch10 <[email protected]>
Date: Thu, 5 Dec 2024 21:09:36 +0100
Subject: [PATCH] remove CheckEnvironmentPatch

since we build on device this patch is not required
---
.../revanced/patches/youtube/misc/settings/SettingsPatch.kt | 3 ---
1 file changed, 3 deletions(-)

diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt
index 627a70f91..e15fc9d00 100644
--- a/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt
+++ b/patches/src/main/kotlin/app/revanced/patches/youtube/misc/settings/SettingsPatch.kt
@@ -118,9 +118,6 @@ val settingsPatch = bytecodePatch(
settingsResourcePatch,
addResourcesPatch,
disableCairoSettingsPatch,
- // Currently there is no easy way to make a mandatory patch,
- // so for now this is a dependent of this patch.
- checkEnvironmentPatch,
)

val extensionPackage = "app/revanced/extension/youtube"
--
2.45.2

6 changes: 6 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ source version.sh

REVANCED_PATCHES_TAG=$(curl -s https://api.github.com/repos/revanced/revanced-patches/releases/latest | jq -r '.tag_name')
if [ "$REVANCED_PATCHES" != "$REVANCED_PATCHES_TAG" ]; then
(
git submodule update --checkout
cd revanced-patches
git fetch --all --quiet
git checkout "$REVANCED_PATCHES_TAG"
)
sed -i "s/^REVANCED_PATCHES=.*$/REVANCED_PATCHES=\"$REVANCED_PATCHES_TAG\"/" version.sh
echo "Updated REVANCED_PATCHES from $REVANCED_PATCHES to $REVANCED_PATCHES_TAG"
else
Expand Down
2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

REVANCED_PATCHES="v5.0.2"
REVANCED_PATCHES="v5.2.1"
REVANCED_CLI="v5.0.0"

0 comments on commit d4b4b0c

Please sign in to comment.