Skip to content

Commit

Permalink
support all revanced packages
Browse files Browse the repository at this point in the history
  • Loading branch information
programminghoch10 committed Jun 17, 2023
1 parent 25f4832 commit 0ad49eb
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 120 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
magiskmodule/README.md
magiskmodule/module.prop
magiskmodule/version.sh
magiskmodule/aapt2
magiskmodule/aapt2lib
magiskmodule/packageversions
magiskmodule/supportedversions.md
35 changes: 0 additions & 35 deletions 0001-Load-classes-in-dex-mode.patch

This file was deleted.

26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ contains only the ReVanced Patcher.
It will patch the installed YouTube app
right on your device during installation.

![GitHub Latest Release (by date)](https://img.shields.io/github/v/release/programminghoch10/ReVancedRepackaged?label=latest&logo=github&display_name=release)
![GitHub Latest Release Date](https://img.shields.io/github/release-date/programminghoch10/ReVancedRepackaged?logo=github) \
![GitHub Global Download Counter](https://img.shields.io/github/downloads/programminghoch10/ReVancedRepackaged/total?logo=github)
![GitHub Latest Download Counter](https://img.shields.io/github/downloads/programminghoch10/ReVancedRepackaged/latest/total?logo=github) \
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/programminghoch10/ReVancedRepackaged/build.yml?logo=github%20actions&logoColor=white)
![GitHub commits since last release](https://img.shields.io/github/commits-since/programminghoch10/ReVancedRepackaged/latest?logo=git&logoColor=white)
![GitHub last commit](https://img.shields.io/github/last-commit/programminghoch10/ReVancedRepackaged?logo=git&logoColor=white) \
![GitHub Repo stars](https://img.shields.io/github/stars/programminghoch10/ReVancedRepackaged?style=social) \
[![GitHub Latest Release (by date)](https://img.shields.io/github/v/release/programminghoch10/ReVancedRepackaged?label=latest&logo=github&display_name=release)](https://github.com/programminghoch10/ReVancedRepackaged/releases/latest)
[![GitHub Latest Release Date](https://img.shields.io/github/release-date/programminghoch10/ReVancedRepackaged?logo=github)](https://github.com/programminghoch10/ReVancedRepackaged/releases/latest) \
[![GitHub Global Download Counter](https://img.shields.io/github/downloads/programminghoch10/ReVancedRepackaged/total?logo=github)](https://github.com/programminghoch10/ReVancedRepackaged/releases)
[![GitHub Latest Download Counter](https://img.shields.io/github/downloads/programminghoch10/ReVancedRepackaged/latest/total?logo=github)](https://github.com/programminghoch10/ReVancedRepackaged/releases/latest) \
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/programminghoch10/ReVancedRepackaged/build.yml?logo=github%20actions&logoColor=white)](https://github.com/programminghoch10/ReVancedRepackaged/actions/workflows/build.yml)
[![GitHub commits since last release](https://img.shields.io/github/commits-since/programminghoch10/ReVancedRepackaged/latest?logo=git&logoColor=white)](https://github.com/programminghoch10/ReVancedRepackaged/compare/)
[![GitHub last commit](https://img.shields.io/github/last-commit/programminghoch10/ReVancedRepackaged?logo=git&logoColor=white)](https://github.com/programminghoch10/ReVancedRepackaged/commits/main) \
[![GitHub Repo stars](https://img.shields.io/github/stars/programminghoch10/ReVancedRepackaged?style=social)](https://github.com/programminghoch10/ReVancedRepackaged/stargazers) \
[![GitHub followers](https://img.shields.io/github/followers/programminghoch10?style=social)](https://github.com/programminghoch10)

## Installation

1. Install the original stock YouTube app.
*Make sure you have the correct version installed before proceeding.*
1. Install the module and wait for it to patch the YouTube app.
*This might take a while.*
1. Install the original variants of the apps you want to be patched.
*Make sure you have the correct versions installed before proceeding.*
1. Install the module and wait for it to patch every compatible app.
*This will take very long.*
*Please refrain from doing anything else on your device in the meantime.*
1. Go into the Google Play Store and disable automatic app updates for YouTube.
1. Go into the Google Play Store and disable automatic app updates for all patched apps.
1. Reboot

## Concept
Expand Down
36 changes: 31 additions & 5 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash
set -e

for cmd in git wget zip java; do
[ -z "$(command -v "$cmd")" ] && echo "missing $cmd" && exit 1
done

[ -f .gitauth ] && source .gitauth
[ -z "$GITHUB_ACTOR" ] && echo "missing GITHUB_ACTOR" && exit 1
[ -z "$GITHUB_TOKEN" ] && echo "missing GITHUB_TOKEN" && exit 1
declare -x GITHUB_ACTOR GITHUB_TOKEN

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

Expand All @@ -25,10 +29,12 @@ executeGradle() {

(
cd revanced-cli
git am ../0001-Load-classes-in-dex-mode.patch
for patch in $(ls ../revanced-cli-patches/*.patch); do
git am "$patch"
done
)

executeGradle assemble
executeGradle assemble :revancedcli:shadowJar

git submodule update --checkout

Expand All @@ -44,10 +50,30 @@ for dlurl in "$REVANCED_INTEGRATIONS_DL" "$REVANCED_PATCHES_DL"; do
[ ! -f "$dlfile" ] && wget -c -O "$dlfile" "$dlurl"
done

cp -v revanced-android/revancedcliwrapper/build/outputs/apk/release/revancedcliwrapper-release.apk magiskmodule/wrapper.apk
REVANCED_CLI=$(sed -e 's/^v//' <<< "$REVANCED_CLI")
ln -v -s -f "revanced-cli/build/libs/revancedcli-$REVANCED_CLI-all.jar" "revanced-cli.jar"

PATCHES_LIST=$(java -jar revanced-cli.jar \
-b "$(basename "$REVANCED_PATCHES_DL")" \
-a dummy.apk \
--list \
--with-versions \
--with-packages \
| sed 's/^INFORMATION: \s*//')
rm -r magiskmodule/packageversions
mkdir magiskmodule/packageversions
echo '## Supported Packages and Versions' > magiskmodule/supportedversions.md
for package in $(cut -d$'\t' -f1 <<< "$PATCHES_LIST" | sort -u); do
cut -d$'\t' -f1,4 <<< "$PATCHES_LIST" | grep "^$package" | cut -d$'\t' -f2 | tr ',' '\n' | sed -e 's/^ //' -e 's/ $//' -e '/^$/d' | sort -u > magiskmodule/packageversions/"$package"
echo "- **\`$package\`**" >> magiskmodule/supportedversions.md
sed 's/^\(.*\)$/`\1`/' < magiskmodule/packageversions/"$package" | tr '\n' '#' | sed -e '/^$/d' -e 's/#$//' -e 's/#/\n/g' | sed -e 's/^/ - /' >> magiskmodule/supportedversions.md
[ $(wc -l < magiskmodule/packageversions/"$package") -gt 0 ] && echo >> magiskmodule/supportedversions.md
done

cp -v revanced-android/revancedcliwrapper/build/outputs/apk/release/revancedcliwrapper-release.apk magiskmodule/revancedandroidcli.apk
cp -v "$(basename "$REVANCED_INTEGRATIONS_DL")" magiskmodule/integrations.apk
cp -v "$(basename "$REVANCED_PATCHES_DL")" magiskmodule/patches.jar
cp -r -v aapt2 magiskmodule/
cp -r -v aapt2 magiskmodule/aapt2lib
cp README.md magiskmodule/README.md

[ -n "$(git status --porcelain)" ] && CHANGES="+" || CHANGES="-"
Expand Down
107 changes: 60 additions & 47 deletions magiskmodule/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,79 @@ cd "$MODPATH"
[ ! -f ./version.sh ] && abort "Missing version.sh"
source ./version.sh

[ -z "$(pm list packages "$YOUTUBE_PACKAGE")" ] && {
ui_print "YouTube not found."
abort "Please install YouTube $YOUTUBE_VERSION manually before installing this module."
}

installedyoutubeversion="$(pm dump $YOUTUBE_PACKAGE | grep -E '^ *versionName=.*$' | cut -d'=' -f2)"

[ "$installedyoutubeversion" != "$YOUTUBE_VERSION" ] && {
ui_print "YouTube version mismatch!"
ui_print " Found: $installedyoutubeversion"
ui_print " Expected: $YOUTUBE_VERSION"
abort "Please install the correct YouTube version before installing this module."
}
ui_print "- Found YouTube $installedyoutubeversion"

youtubeapkpath=$(pm path "$YOUTUBE_PACKAGE" | grep -E 'package:.*/base\.apk' | cut -d':' -f2)
ui_print "- Found YouTube APK at $youtubeapkpath"

MAGISKTMP="$(magisk --path)" || MAGISKTMP=/sbin
MIRROR="$MAGISKTMP"/.magisk/mirror
ui_print "- Found Magisk mirror at $MIRROR"
youtubeapkpath="$MIRROR"/"$youtubeapkpath"

ui_print "- Preparing Patching Process"

cp -v wrapper.apk patches.jar integrations.apk "$TMPDIR"
[ ! -f aapt2lib/$ARCH/libaapt2.so ] && abort "Failed to locate libaapt2.so for $ARCH"
mv -v aapt2lib/$ARCH/libaapt2.so aapt2
rm -r aapt2lib
chmod -v +x aapt2

[ ! -f aapt2/$ARCH/libaapt2.so ] && abort "Failed to locate libaapt2.so for $ARCH"
cp -v aapt2/$ARCH/libaapt2.so "$TMPDIR"/aapt2
chmod -v +x "$TMPDIR"/aapt2
chmod -v +x system/bin/revancedcli

cd "$TMPDIR"
ui_print " TMPDIR=$TMPDIR"
mkdir overlay

ui_print " Increase Heap Growth limit from $(getprop dalvik.vm.heapgrowthlimit) to 4096m"
resetprop dalvik.vm.heapgrowthlimit 4096m
processPackage() {
local packagename="$1"

ui_print "- Patching YouTube APK"
[ -z "$(pm list packages "$packagename")" ] && {
#ui_print "- $packagename not found"
return
}

app_process \
-cp wrapper.apk \
$(pwd) \
com.programminghoch10.revancedandroidcli.MainCommand \
-a "$youtubeapkpath" \
-c \
-o revanced.apk \
-b patches.jar \
-m integrations.apk \
-e vanced-microg-support \
--custom-aapt2-binary=$(pwd)/aapt2 \
2>&1 || abort "Patching failed! $?"
ui_print "- Processing $packagename"

[ ! -f revanced.apk ] && abort "Patching failed!"
installedpackageversion="$(pm dump $packagename | grep -E '^ *versionName=.*$' | cut -d'=' -f2)"

mv -v revanced.apk "$MODPATH"/revanced.apk
rm aapt2
grep -q -F "$installedpackageversion" < packageversions/"$packagename" || {
ui_print "- $packagename $installedpackageversion is not supported."
return
}

cd "$MODPATH"
ui_print "- Found $packagename $installedpackageversion"

apkpath=$(pm path "$packagename" | grep -E 'package:.*/base\.apk' | cut -d':' -f2)
ui_print "- Found YouTube APK at $apkpath"

apkpath="$MIRROR"/"$apkpath"

patchAPK "$packagename" "$apkpath"

[ ! -f overlay/"$packagename".apk ] && abort "Couldn't locate patched file!"

chcon u:object_r:apk_data_file:s0 overlay/"$packagename".apk
}

patchAPK() {
local packagename="$1"
local apkpath="$2"
cd "$TMPDIR"

ui_print "- Patching $packagename"

export MODPATH
"$MODPATH"/system/bin/revancedcli \
-a "$apkpath" \
-c \
-o out.apk \
-b "$MODPATH"/patches.jar \
-m "$MODPATH"/integrations.apk \
-e vanced-microg-support \
2>&1 || abort "Patching failed! $?"

[ ! -f out.apk ] && abort "Patching failed!"

mv -v out.apk "$MODPATH"/overlay/"$packagename".apk

cd "$MODPATH"
}

chcon u:object_r:apk_data_file:s0 revanced.apk
for packagename in packageversions/*; do
packagename="$(basename "$packagename")"
processPackage "$packagename"
done

rm wrapper.apk integrations.apk patches.jar
rm -r aapt2
[ -z "$(ls overlay)" ] && abort "No compatible packages have been found."
45 changes: 29 additions & 16 deletions magiskmodule/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ cd $(dirname $0)

source ./version.sh

err() {
logi() {
local msg="ReVancedRepackaged: $1"
log -t Magisk "$msg"
echo "$msg" >> /cache/magisk.log
touch disable
exit 1
}

REVANCEDAPK="$(pwd)"/revanced.apk
[ ! -f "$REVANCEDAPK" ] && err "Missing $REVANCEDAPK"
[ -z "$(ls overlay)" ] && logi "No overlays found!" && touch remove && exit 1

while [ "$(getprop sys.boot_completed)" != "1" ]; do
sleep 1
Expand All @@ -21,18 +18,34 @@ done
MAGISKTMP="$(magisk --path)" || MAGISKTMP=/sbin
MIRROR="$MAGISKTMP"/.magisk/mirror

youtubeapkpath=$(pm path "$YOUTUBE_PACKAGE" \
| grep -E 'package:.*/base\.apk' \
| cut -d':' -f2)
overlayPackage() {
local packagename="$1"
logi "Overlaying $packagename"

[ -z "$youtubeapkpath" ] && \
youtubeapkpath=$(find -H \
"$MIRROR"/data/app \
-wholename "*${YOUTUBE_PACKAGE}*/base.apk")
overlayapk=$(pwd)/overlay/"$packagename".apk

[ -z "$youtubeapkpath" ] && err "Couldn't locate YouTube base.apk"
apkpath=$(pm path "$packagename" \
| grep -E 'package:.*/base\.apk' \
| cut -d':' -f2)

mount -o bind "$MIRROR"/"$REVANCEDAPK" "$youtubeapkpath" \
|| err "Failed to mount $REVANCEDAPK on $youtubeapkpath"
[ -z "$apkpath" ] && \
apkpath=$(find -H \
"$MIRROR"/data/app \
-wholename "*${packagename}*/base.apk")

am force-stop "$YOUTUBE_PACKAGE"
[ -z "$apkpath" ] \
&& logi "Couldn't locate $packagename base.apk" \
&& return 1

mount -o bind "$MIRROR"/"$overlayapk" "$apkpath" || {
logi "Failed to mount $overlayapk on $apkpath"
return 1
}

am force-stop "$packagename"
}

for packagename in overlay/*; do
packagename="$(basename "$packagename" | sed -e 's/\.apk$//')"
overlayPackage "$packagename"
done
14 changes: 14 additions & 0 deletions magiskmodule/system/bin/revancedcli
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/system/bin/sh

[ -z "$MODPATH" ] && MODPATH=/data/adb/modules/revancedrepackaged
echo "modpath = $MODPATH" >&2

#echo " Increase Heap Growth limit from $(getprop dalvik.vm.heapgrowthlimit) to 4096m" >&2
resetprop dalvik.vm.heapgrowthlimit 4096m

app_process \
-cp "$MODPATH"/revancedandroidcli.apk \
$(pwd) \
com.programminghoch10.revancedandroidcli.MainCommand \
--custom-aapt2-binary="$MODPATH"/aapt2 \
"$@"
Loading

0 comments on commit 0ad49eb

Please sign in to comment.