Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NoName-exe authored Jun 20, 2024
2 parents 440c558 + 37baf5f commit 24b3218
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 146 deletions.
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ assignees: ''

---

**DO NOT REPORT REVANCED STUFF IN THIS REPO**
**DO NOT REPORT REVANCED STUFF IN THIS REPO**
if you delete these lines and proceed to report revanced stuff like **patch bugs** or **patch requests**, you will be **blocked** from this repo

**Describe the bug of the rvmm builder or the modules**
Use issues only to report bugs of the rvmm builder or the modules
2 changes: 0 additions & 2 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Adding another revanced app is as easy as this:
[Some-App]
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app"
# or uptodown-dlurl = "https://app.en.uptodown.com/android"
# or apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/"
```

## More about other options:
Expand Down Expand Up @@ -37,7 +36,6 @@ included-patches = "'Patch something'" # whitespace seperated list of patches to
exclusive-patches = false # exclude all patches by default. default: false
apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app"
uptodown-dlurl = "https://spotify.en.uptodown.com/android"
apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/"
module-prop-name = "some-app-magisk" # magisk module prop name.
apkmirror-dpi = "360-480dpi" # used to select apk variant from apkmirror. default: nodpi
arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a', 'all', 'both'. 'both' downloads both arm64-v8a and arm-v7a. default: all
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Get the [latest CI release](https://github.com/NoName-exe/revanced-extended/rele
* Non-root versions of YouTube and YouTube-Music require [MicroG](https://github.com/ReVanced/GmsCore/releases) to work.

## Credits
[j-hc](https://github.com/j-hc) for [mindetach](https://github.com/j-hc/mindetach-magisk), [zygisk-detach](https://github.com/j-hc/zygisk-detach) and the [script on which this is based on](https://github.com/j-hc/revanced-magisk-module).
[j-hc](https://github.com/j-hc) for [zygisk-detach](https://github.com/j-hc/zygisk-detach) and the [script on which this is based on](https://github.com/j-hc/revanced-magisk-module).

[ReVanced Team](https://github.com/revanced) for [MicroG](https://github.com/ReVanced/GmsCore/releases).

Expand Down
64 changes: 38 additions & 26 deletions build-termux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pr() { echo -e "\033[0;32m[+] ${1}\033[0m"; }
ask() {
local y
for ((n = 0; n < 3; n++)); do
pr "$1"
pr "$1 [y/n]"
if read -r y; then
if [ "$y" = y ]; then
return 0
Expand All @@ -19,53 +19,65 @@ ask() {
return 1
}

pr "Ask for storage permission"
until
yes | termux-setup-storage >/dev/null 2>&1
ls /sdcard >/dev/null 2>&1
do sleep 1; done
if [ ! -f ~/.rvmm_"$(date '+%Y%m')" ]; then
pr "Setting up environment..."
yes "" | pkg update -y && pkg install -y openssl git wget jq openjdk-17 zip
: >~/.rvmm_"$(date '+%Y%m')"
fi
mkdir -p /sdcard/Download/revanced-magisk-module/

if [ -f build.sh ]; then cd ..; fi
if [ -d revanced-magisk-module ]; then
if [ ! -d revanced-magisk-module ]; then
pr "Cloning revanced-magisk-module."
git clone https://github.com/j-hc/revanced-magisk-module --depth 1
cd revanced-magisk-module
sed -i '/^enabled.*/d; /^\[.*\]/a enabled = false' config.toml
grep -q 'revanced-magisk-module' ~/.gitconfig 2>/dev/null \
|| git config --global --add safe.directory ~/revanced-magisk-module
else
cd revanced-magisk-module
pr "Checking for revanced-magisk-module updates"
git -C revanced-magisk-module fetch
if git -C revanced-magisk-module status | grep -q 'is behind'; then
git fetch
if git status | grep -q 'is behind\|fatal'; then
pr "revanced-magisk-module already is not synced with upstream."
pr "Cloning revanced-magisk-module. config.toml will be preserved."
cd ..
cp -f revanced-magisk-module/config.toml .
rm -rf revanced-magisk-module
git clone https://github.com/j-hc/revanced-magisk-module --recurse --depth 1
mv -f config.toml revanced-magisk-module/config.toml
cd revanced-magisk-module
fi
else
pr "Cloning revanced-magisk-module."
git clone https://github.com/j-hc/revanced-magisk-module --recurse --depth 1
sed -i '/^enabled.*/d; /^\[.*\]/a enabled = false' revanced-magisk-module/config.toml
fi
cd revanced-magisk-module
chmod +x build.sh build-termux.sh

if ask "Do you want to open the config.toml for customizations? [y/n]"; then
nano config.toml
fi
if ! ask "Setup is done. Do you want to start building? [y/n]"; then
exit 0
[ -f ~/storage/downloads/revanced-magisk-module/config.toml ] \
|| cp config.toml ~/storage/downloads/revanced-magisk-module/config.toml

if ask "Open rvmm-config-gen to generate a config?"; then
am start -a android.intent.action.VIEW -d https://j-hc.github.io/rvmm-config-gen/
fi
printf "\n"
until
if ask "Open 'config.toml' to configure builds?\nAll are disabled by default, you will need to enable at first time building"; then
am start -a android.intent.action.VIEW -d file:///sdcard/Download/revanced-magisk-module/config.toml -t text/plain
fi
ask "Setup is done. Do you want to start building?"
do :; done
cp -f ~/storage/downloads/revanced-magisk-module/config.toml config.toml

./build.sh

cd build
pr "Ask for storage permission"
until
yes | termux-setup-storage >/dev/null 2>&1
ls /sdcard >/dev/null 2>&1
do
sleep 1
done

PWD=$(pwd)
mkdir -p ~/storage/downloads/revanced-magisk-module
for op in *; do
[ "$op" = "*" ] && continue
[ "$op" = "*" ] && {
pr "glob fail"
exit 1
}
mv -f "${PWD}/${op}" ~/storage/downloads/revanced-magisk-module/"${op}"
done

Expand Down
30 changes: 20 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jq --version >/dev/null || abort "\`jq\` is not installed. install it with 'apt
java --version >/dev/null || abort "\`openjdk 17\` is not installed. install it with 'apt install openjdk-17-jre' or equivalent"
zip --version >/dev/null || abort "\`zip\` is not installed. install it with 'apt install zip' or equivalent"
# ----------------
rm -rf revanced-magisk/bin/*/tmp.*
get_prebuilts

set_prebuilts() {
Expand All @@ -72,7 +73,10 @@ for table_name in $(toml_get_table_names); do
t=$(toml_get_table "$table_name")
enabled=$(toml_get "$t" enabled) && vtf "$enabled" "enabled" || enabled=true
if [ "$enabled" = false ]; then continue; fi
if ((idx >= PARALLEL_JOBS)); then wait -n; fi
if ((idx >= PARALLEL_JOBS)); then
wait -n
idx=$((idx - 1))
fi

declare -A app_args
patches_src=$(toml_get "$t" patches-source) || patches_src=$DEF_PATCHES_SRC
Expand Down Expand Up @@ -123,10 +127,6 @@ for table_name in $(toml_get_table_names); do
app_args[uptodown_dlurl]=${app_args[uptodown_dlurl]%/}
app_args[dl_from]=uptodown
} || app_args[uptodown_dlurl]=""
app_args[apkmonk_dlurl]=$(toml_get "$t" apkmonk-dlurl) && {
app_args[apkmonk_dlurl]=${app_args[apkmonk_dlurl]%/}
app_args[dl_from]=apkmonk
} || app_args[apkmonk_dlurl]=""
app_args[apkmirror_dlurl]=$(toml_get "$t" apkmirror-dlurl) && {
app_args[apkmirror_dlurl]=${app_args[apkmirror_dlurl]%/}
app_args[dl_from]=apkmirror
Expand All @@ -135,7 +135,7 @@ for table_name in $(toml_get_table_names); do
app_args[archive_dlurl]=${app_args[archive_dlurl]%/}
app_args[dl_from]=archive
} || app_args[archive_dlurl]=""
if [ -z "${app_args[dl_from]-}" ]; then abort "ERROR: no 'apkmirror_dlurl', 'uptodown_dlurl' or 'apkmonk_dlurl' option was set for '$table_name'."; fi
if [ -z "${app_args[dl_from]-}" ]; then abort "ERROR: no 'apkmirror_dlurl', 'uptodown_dlurl' or 'archive_dlurl' option was set for '$table_name'."; fi
app_args[arch]=$(toml_get "$t" arch) || app_args[arch]="all"
if [ "${app_args[arch]}" != "both" ] && [ "${app_args[arch]}" != "all" ] && [[ ${app_args[arch]} != "arm64-v8a"* ]] && [[ ${app_args[arch]} != "arm-v7a"* ]]; then
abort "wrong arch '${app_args[arch]}' for '$table_name'"
Expand All @@ -145,18 +145,28 @@ for table_name in $(toml_get_table_names); do
app_args[dpi]=$(toml_get "$t" apkmirror-dpi) || app_args[dpi]="nodpi"
table_name_f=${table_name,,}
table_name_f=${table_name_f// /-}
app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || app_args[module_prop_name]="${table_name_f}-jhc"
app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || {
app_args[module_prop_name]="${table_name_f}-jhc"
if [ "${app_args[arch]}" = "arm64-v8a" ]; then
app_args[module_prop_name]="${app_args[module_prop_name]}-arm64"
elif [ "${app_args[arch]}" = "arm-v7a" ]; then
app_args[module_prop_name]="${app_args[module_prop_name]}-arm"
fi
}

if [ "${app_args[arch]}" = both ]; then
app_args[table]="$table_name (arm64-v8a)"
app_args[module_prop_name]="${app_args[module_prop_name]}-arm64"
app_args[arch]="arm64-v8a"
app_args[module_prop_name]="${app_args[module_prop_name]}-arm64"
idx=$((idx + 1))
build_rv "$(declare -p app_args)" &
app_args[table]="$table_name (arm-v7a)"
app_args[module_prop_name]="${app_args[module_prop_name]}-arm"
app_args[arch]="arm-v7a"
if ((idx >= PARALLEL_JOBS)); then wait -n; fi
app_args[module_prop_name]="${app_args[module_prop_name]}-arm"
if ((idx >= PARALLEL_JOBS)); then
wait -n
idx=$((idx - 1))
fi
idx=$((idx + 1))
build_rv "$(declare -p app_args)" &
else
Expand Down
82 changes: 38 additions & 44 deletions revanced-magisk/customize.sh
Original file line number Diff line number Diff line change
@@ -1,58 +1,54 @@
# shellcheck disable=SC2148,SC2086,SC1091
. $MODPATH/config
. "$MODPATH/config"

ui_print ""
if [ -n "$MODULE_ARCH" ] && [ $MODULE_ARCH != $ARCH ]; then
if [ -n "$MODULE_ARCH" ] && [ "$MODULE_ARCH" != "$ARCH" ]; then
abort "ERROR: Wrong arch
Your device: $ARCH
Module: $MODULE_ARCH"
fi

if [ $ARCH = "arm" ]; then
if [ "$ARCH" = "arm" ]; then
ARCH_LIB=armeabi-v7a
alias cmpr='$MODPATH/bin/arm/cmpr'
elif [ $ARCH = "arm64" ]; then
elif [ "$ARCH" = "arm64" ]; then
ARCH_LIB=arm64-v8a
alias cmpr='$MODPATH/bin/arm64/cmpr'
elif [ $ARCH = "x86" ]; then
elif [ "$ARCH" = "x86" ]; then
ARCH_LIB=x86
alias cmpr='$MODPATH/bin/x86/cmpr'
elif [ $ARCH = "x64" ]; then
elif [ "$ARCH" = "x64" ]; then
ARCH_LIB=x86_64
alias cmpr='$MODPATH/bin/x64/cmpr'
else
abort "ERROR: unsupported arch: ${ARCH}"
fi
set_perm_recursive $MODPATH/bin 0 0 0755 0777
set_perm_recursive "$MODPATH/bin" 0 0 0755 0777

if su -M -c true >/dev/null 2>/dev/null; then
alias mm='su -M -c'
else
alias mm='nsenter -t1 -m'
fi

mm grep $PKG_NAME /proc/mounts | while read -r line; do
mm grep "$PKG_NAME" /proc/mounts | while read -r line; do
ui_print "- Un-mount"
mp=${line#* }
mp=${mp%% *}
mm umount -l ${mp%%\\*}
mp=${line#* } mp=${mp%% *}
mm umount -l "${mp%%\\*}"
done
am force-stop $PKG_NAME
am force-stop "$PKG_NAME"

INS=true
if BASEPATH=$(pm path $PKG_NAME); then
BASEPATH=${BASEPATH##*:}
BASEPATH=${BASEPATH%/*}
if [ ${BASEPATH:1:6} = system ]; then
if BASEPATH=$(pm path "$PKG_NAME"); then
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ "${BASEPATH:1:6}" = system ]; then
ui_print "- $PKG_NAME is a system app"
elif [ ! -d ${BASEPATH}/lib ]; then
elif [ ! -d "${BASEPATH}/lib" ]; then
ui_print "- Invalid installation found. Uninstalling..."
pm uninstall -k --user 0 $PKG_NAME
elif [ ! -f $MODPATH/$PKG_NAME.apk ]; then
pm uninstall -k --user 0 "$PKG_NAME"
elif [ ! -f "$MODPATH/$PKG_NAME.apk" ]; then
ui_print "- Stock $PKG_NAME APK was not found"
VERSION=$(dumpsys package $PKG_NAME | grep -m1 versionName)
VERSION="${VERSION#*=}"
if [ "$VERSION" = $PKG_VER ] || [ -z "$VERSION" ]; then
VERSION=$(dumpsys package "$PKG_NAME" | grep -m1 versionName) VERSION="${VERSION#*=}"
if [ "$VERSION" = "$PKG_VER" ] || [ -z "$VERSION" ]; then
ui_print "- Skipping stock installation"
INS=false
else
Expand All @@ -61,25 +57,24 @@ if BASEPATH=$(pm path $PKG_NAME); then
module: $PKG_VER
"
fi
elif cmpr $BASEPATH/base.apk $MODPATH/$PKG_NAME.apk; then
elif cmpr "$BASEPATH/base.apk" "$MODPATH/$PKG_NAME.apk"; then
ui_print "- $PKG_NAME is up-to-date"
INS=false
fi
fi

install() {
if [ ! -f $MODPATH/$PKG_NAME.apk ]; then
if [ ! -f "$MODPATH/$PKG_NAME.apk" ]; then
abort "ERROR: Stock $PKG_NAME apk was not found"
fi
ui_print "- Updating $PKG_NAME to $PKG_VER"
settings put global verifier_verify_adb_installs 0
SZ=$(stat -c "%s" $MODPATH/$PKG_NAME.apk)
SZ=$(stat -c "%s" "$MODPATH/$PKG_NAME.apk")
if ! SES=$(pm install-create --user 0 -i com.android.vending -r -d -S "$SZ" 2>&1); then
ui_print "ERROR: install-create failed"
abort "$SES"
fi
SES=${SES#*[}
SES=${SES%]*}
SES=${SES#*[} SES=${SES%]*}
set_perm "$MODPATH/$PKG_NAME.apk" 1000 1000 644 u:object_r:apk_data_file:s0
if ! op=$(pm install-write -S "$SZ" "$SES" "$PKG_NAME.apk" "$MODPATH/$PKG_NAME.apk" 2>&1); then
ui_print "ERROR: install-write failed"
Expand All @@ -88,16 +83,15 @@ install() {
if ! op=$(pm install-commit "$SES" 2>&1); then
if echo "$op" | grep -q INSTALL_FAILED_VERSION_DOWNGRADE; then
ui_print "- INSTALL_FAILED_VERSION_DOWNGRADE. Uninstalling..."
pm uninstall -k --user 0 $PKG_NAME
pm uninstall -k --user 0 "$PKG_NAME"
return 1
fi
ui_print "ERROR: install-commit failed"
abort "$op"
fi
settings put global verifier_verify_adb_installs 1
if BASEPATH=$(pm path $PKG_NAME); then
BASEPATH=${BASEPATH##*:}
BASEPATH=${BASEPATH%/*}
if BASEPATH=$(pm path "$PKG_NAME"); then
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
else
abort "ERROR: install $PKG_NAME manually and reflash the module"
fi
Expand All @@ -111,34 +105,34 @@ if [ $INS = true ]; then
fi

BASEPATHLIB=${BASEPATH}/lib/${ARCH}
if [ -z "$(ls -A1 ${BASEPATHLIB})" ]; then
if [ -z "$(ls -A1 "$BASEPATHLIB")" ]; then
ui_print "- Extracting native libs"
mkdir -p $BASEPATHLIB
if ! op=$(unzip -j $MODPATH/$PKG_NAME.apk lib/${ARCH_LIB}/* -d ${BASEPATHLIB} 2>&1); then
mkdir -p "$BASEPATHLIB"
if ! op=$(unzip -j "$MODPATH"/"$PKG_NAME".apk lib/"${ARCH_LIB}"/* -d "$BASEPATHLIB" 2>&1); then
ui_print "ERROR: extracting native libs failed"
abort "$op"
fi
set_perm_recursive ${BASEPATH}/lib 1000 1000 755 755 u:object_r:apk_data_file:s0
set_perm_recursive "${BASEPATH}/lib" 1000 1000 755 755 u:object_r:apk_data_file:s0
fi
ui_print "- Setting Permissions"
set_perm $MODPATH/base.apk 1000 1000 644 u:object_r:apk_data_file:s0
set_perm "$MODPATH/base.apk" 1000 1000 644 u:object_r:apk_data_file:s0

ui_print "- Mounting $PKG_NAME"
mkdir -p $NVBASE/rvhc
mkdir -p "$NVBASE/rvhc"
RVPATH=$NVBASE/rvhc/${MODPATH##*/}.apk
mv -f $MODPATH/base.apk $RVPATH
mv -f "$MODPATH/base.apk" "$RVPATH"

if ! op=$(mm mount -o bind $RVPATH $BASEPATH/base.apk 2>&1); then
if ! op=$(mm mount -o bind "$RVPATH" "$BASEPATH/base.apk" 2>&1); then
ui_print "ERROR: Mount failed!"
ui_print "$op"
fi
am force-stop $PKG_NAME
am force-stop "$PKG_NAME"
ui_print "- Optimizing $PKG_NAME"
nohup cmd package compile --reset $PKG_NAME >/dev/null 2>&1 &
nohup cmd package compile --reset "$PKG_NAME" >/dev/null 2>&1 &

ui_print "- Cleanup"
rm -rf ${MODPATH:?}/bin $MODPATH/$PKG_NAME.apk
rm -rf "${MODPATH:?}/bin" "$MODPATH/$PKG_NAME.apk"

for s in "uninstall.sh" "service.sh"; do
sed -i "2 i\NVBASE=${NVBASE}" $MODPATH/$s
sed -i "2 i\NVBASE=${NVBASE}" "$MODPATH/$s"
done
Loading

0 comments on commit 24b3218

Please sign in to comment.