From d05014fb7ee3eb7a4feda93be337691b15354e5b Mon Sep 17 00:00:00 2001 From: j-hc Date: Thu, 9 May 2024 14:09:24 +0300 Subject: [PATCH 1/9] enable revanced extended --- README.md | 3 --- config.toml | 40 +++++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 98a3a1b..a50e274 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -#### ⚠️ Do not download modules from 3rd party sources like random websites you found on Google. There are many that uses my modules and impersonates ReVanced. - # ReVanced Magisk Module [![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)](https://t.me/rvc_magisk) [![CI](https://github.com/j-hc/revanced-magisk-module/actions/workflows/ci.yml/badge.svg?event=schedule)](https://github.com/j-hc/revanced-magisk-module/actions/workflows/ci.yml) @@ -29,7 +27,6 @@ Note that the CI workflow is schedu ## To include/exclude patches or patch other apps -[**See the list of patches**](https://j-hc.github.io/rvmm-config-gen/) * Star the repo :eyes: * Use the repo as a [template](https://github.com/new?template_name=revanced-magisk-module&template_owner=j-hc) diff --git a/config.toml b/config.toml index ad92efd..cb0c70f 100755 --- a/config.toml +++ b/config.toml @@ -17,6 +17,25 @@ build-mode = "both" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" arch = "both" +[Music-Extended] +app-name = "Music" +patches-source = "inotia00/revanced-patches" +integrations-source = "inotia00/revanced-integrations" +cli-source = "inotia00/revanced-cli" +rv-brand = "ReVanced Extended" +build-mode = "both" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" +arch = "both" + +[YouTube-Extended] +app-name = "YouTube" +patches-source = "inotia00/revanced-patches" +integrations-source = "inotia00/revanced-integrations" +cli-source = "inotia00/revanced-cli" +rv-brand = "ReVanced Extended" +build-mode = "both" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" + [Twitter] build-mode = "apk" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.twitter.android" @@ -43,24 +62,3 @@ uptodown-dlurl = "https://spotify.en.uptodown.com/android" [IconPackStudio] enabled = false apkmirror-dlurl = "https://www.apkmirror.com/apk/smart-launcher-team/icon-pack-studio/" - -[Music-Extended] -enabled = false -app-name = "Music" -patches-source = "inotia00/revanced-patches" -integrations-source = "inotia00/revanced-integrations" -cli-source = "inotia00/revanced-cli" -rv-brand = "ReVanced Extended" -build-mode = "both" -archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" -arch = "both" - -[YouTube-Extended] -enabled = false -app-name = "YouTube" -patches-source = "inotia00/revanced-patches" -integrations-source = "inotia00/revanced-integrations" -cli-source = "inotia00/revanced-cli" -rv-brand = "ReVanced Extended" -build-mode = "both" -archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" From e0de71bb57d9f617daec6421469eb4d2e0e87128 Mon Sep 17 00:00:00 2001 From: j-hc Date: Tue, 21 May 2024 15:07:00 +0300 Subject: [PATCH 2/9] config-update --- utils.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/utils.sh b/utils.sh index 3cdba21..cb111f2 100755 --- a/utils.sh +++ b/utils.sh @@ -40,7 +40,9 @@ abort() { get_rv_prebuilts() { local cli_src=$1 cli_ver=$2 integrations_src=$3 integrations_ver=$4 patches_src=$5 patches_ver=$6 pr "Getting prebuilts (${patches_src%/*})" >&2 - for f in "${TEMP_DIR}"/*-rv; do : >"${f}/changelog.md"; done + local cl_dir=${patches_src%/*} + cl_dir=${TEMP_DIR}/${cl_dir,,}-rv + [ -d "$cl_dir" ] || mkdir "$cl_dir" for src_ver in "$cli_src CLI $cli_ver" "$integrations_src Integrations $integrations_ver" "$patches_src Patches $patches_ver"; do set -- $src_ver local src=$1 tag=$2 ver=${3-} ext @@ -64,7 +66,7 @@ get_rv_prebuilts() { file="${dir}/${name}" [ -f "$file" ] || REBUILD=true - echo "$tag: $(cut -d/ -f5 <<<"$url")/${name} " >>"$dir/changelog.md" + echo "$tag: $(cut -d/ -f5 <<<"$url")/${name} " >>"${cl_dir}/changelog.md" gh_dl "$file" "$url" >&2 || return 1 echo -n "$file " if [ "$tag" = "Patches" ]; then @@ -75,7 +77,7 @@ get_rv_prebuilts() { url=$(jq -e -r '.assets[] | select(.name | endswith("json")) | .url' <<<"$resp") || return 1 gh_dl "$file" "$url" >&2 || return 1 echo -n "$file " - echo -e "[Changelog](https://github.com/${src}/releases/tag/${tag_name})\n" >>"$dir/changelog.md" + echo -e "[Changelog](https://github.com/${src}/releases/tag/${tag_name})\n" >>"${cl_dir}/changelog.md" fi done echo @@ -99,6 +101,7 @@ get_prebuilts() { } config_update() { + if [ ! -f build.md ]; then abort "build.md not available"; fi declare -A sources : >$TEMP_DIR/skipped local conf="" @@ -119,11 +122,10 @@ config_update() { fi else sources[$PATCHES_SRC]=0 - if ! last_patches_url=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" - \ + if ! last_patches=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" - \ | jq -e -r '.assets[] | select(.name | endswith("jar")) | .name'); then abort oops fi - last_patches=${last_patches_url##*/} cur_patches=$(sed -n "s/.*Patches: ${PATCHES_SRC%%/*}\/\(.*\)/\1/p" build.md | xargs) if [ "$cur_patches" ] && [ "$last_patches" ]; then if [ "${cur_patches}" != "$last_patches" ]; then From 38334d2e93341cd9073d044a2841434b076bf2b4 Mon Sep 17 00:00:00 2001 From: j-hc <25510067+j-hc@users.noreply.github.com> Date: Sat, 25 May 2024 00:39:27 +0300 Subject: [PATCH 3/9] Update report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 74ff10b..bb59bcc 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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 From e7ae0800db0c748bc0723f0ce1e59a22c938873a Mon Sep 17 00:00:00 2001 From: j-hc <25510067+j-hc@users.noreply.github.com> Date: Sun, 26 May 2024 19:13:19 +0300 Subject: [PATCH 4/9] Update config.toml --- config.toml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config.toml b/config.toml index cb0c70f..2a04c5e 100755 --- a/config.toml +++ b/config.toml @@ -11,10 +11,12 @@ excluded-patches = "" included-patches = "" version = "auto" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube" # fallback [Music] build-mode = "both" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music" arch = "both" [Music-Extended] @@ -25,6 +27,7 @@ cli-source = "inotia00/revanced-cli" rv-brand = "ReVanced Extended" build-mode = "both" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music" arch = "both" [YouTube-Extended] @@ -35,6 +38,7 @@ cli-source = "inotia00/revanced-cli" rv-brand = "ReVanced Extended" build-mode = "both" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube" [Twitter] build-mode = "apk" @@ -47,7 +51,11 @@ archive-dlurl = "https://archive.org/download/jhc-apks/apks/tv.twitch.android.ap archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.zhiliaoapp.musically" included-patches = "'SIM spoof'" -[Reddit] +[Reddit-Extended] +patches-source = "inotia00/revanced-patches" +integrations-source = "inotia00/revanced-integrations" +cli-source = "inotia00/revanced-cli" +rv-brand = "ReVanced Extended" archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.reddit.frontpage" [Messenger] From fcc9cd7dd2f1233a4a16f95b5c4924b6199a0662 Mon Sep 17 00:00:00 2001 From: j-hc Date: Sat, 1 Jun 2024 23:04:53 +0300 Subject: [PATCH 5/9] build termux ergonomics --- build-termux.sh | 64 ++++++++++++++++----------- build.sh | 1 + revanced-magisk/customize.sh | 83 +++++++++++++++++------------------- revanced-magisk/service.sh | 58 ++++++++++++------------- 4 files changed, 105 insertions(+), 101 deletions(-) diff --git a/build-termux.sh b/build-termux.sh index 299e0cb..85e63af 100755 --- a/build-termux.sh +++ b/build-termux.sh @@ -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 @@ -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 diff --git a/build.sh b/build.sh index 58b0a2c..cb61d72 100755 --- a/build.sh +++ b/build.sh @@ -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() { diff --git a/revanced-magisk/customize.sh b/revanced-magisk/customize.sh index 37838cc..04e70a9 100755 --- a/revanced-magisk/customize.sh +++ b/revanced-magisk/customize.sh @@ -1,29 +1,29 @@ -# shellcheck disable=SC2148,SC2086,SC1091 -. $MODPATH/config +#!/system/bin/sh +. "$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' @@ -31,28 +31,25 @@ 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 @@ -61,25 +58,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" @@ -88,16 +84,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 @@ -111,36 +106,36 @@ 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 ui_print "* Done" diff --git a/revanced-magisk/service.sh b/revanced-magisk/service.sh index a241f3b..974c75d 100755 --- a/revanced-magisk/service.sh +++ b/revanced-magisk/service.sh @@ -1,48 +1,44 @@ #!/system/bin/sh -# shellcheck disable=SC2086,SC1091 MODDIR=${0%/*} RVPATH=$NVBASE/rvhc/${MODDIR##*/}.apk -. $MODDIR/config +. "$MODDIR/config" until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done until [ -d "/sdcard/Android" ]; do sleep 1; done while - BASEPATH=$(pm path $PKG_NAME) + BASEPATH=$(pm path "$PKG_NAME") svcl=$? [ $svcl = 20 ] do sleep 2; done sleep 5 err() { - [ ! -f $MODDIR/err ] && cp $MODDIR/module.prop $MODDIR/err - sed -i "s/^des.*/description=⚠️ Needs reflash: '${1}'/g" $MODDIR/module.prop + [ ! -f "$MODDIR/err" ] && cp "$MODDIR/module.prop" "$MODDIR/err" + sed -i "s/^des.*/description=⚠️ Needs reflash: '${1}'/g" "$MODDIR/module.prop" } -if [ $svcl = 0 ]; then - BASEPATH=${BASEPATH##*:} - BASEPATH=${BASEPATH%/*} - if [ -d $BASEPATH/lib ]; then - VERSION=$(dumpsys package $PKG_NAME | grep -m1 versionName) - VERSION="${VERSION#*=}" - if [ "$VERSION" = $PKG_VER ] || [ -z "$VERSION" ]; then - grep $PKG_NAME /proc/mounts | while read -r line; do - mp=${line#* } - mp=${mp%% *} - umount -l ${mp%%\\*} - done - if chcon u:object_r:apk_data_file:s0 $RVPATH; then - mount -o bind $RVPATH $BASEPATH/base.apk - am force-stop $PKG_NAME - [ -f $MODDIR/err ] && mv -f $MODDIR/err $MODDIR/module.prop - else - err "mount failed" - fi - else - err "version mismatch (installed:${VERSION}, module:$PKG_VER)" - fi - else - err "zygote crashed" - fi -else +if [ $svcl != 0 ]; then err "app not installed" + exit fi +BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*} +if [ ! -d "$BASEPATH/lib" ]; then + err "zygote crashed (fix your ROM)" + exit +fi +VERSION=$(dumpsys package "$PKG_NAME" | grep -m1 versionName) VERSION="${VERSION#*=}" +if [ "$VERSION" != "$PKG_VER" ] && [ "$VERSION" ]; then + err "version mismatch (installed:${VERSION}, module:$PKG_VER)" + exit +fi +grep "$PKG_NAME" /proc/mounts | while read -r line; do + mp=${line#* } mp=${mp%% *} + umount -l "${mp%%\\*}" +done +if ! chcon u:object_r:apk_data_file:s0 "$RVPATH"; then + err "apk not found" + exit +fi +mount -o bind "$RVPATH" "$BASEPATH/base.apk" +am force-stop "$PKG_NAME" +[ -f "$MODDIR/err" ] && mv -f "$MODDIR/err" "$MODDIR/module.prop" From 90ab179a526fa5d441e1a1e1b0096cb0b336054c Mon Sep 17 00:00:00 2001 From: j-hc Date: Mon, 3 Jun 2024 11:11:00 +0300 Subject: [PATCH 6/9] update customize.sh --- build.sh | 13 ++++++++++--- revanced-magisk/customize.sh | 5 ++--- utils.sh | 1 - 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index cb61d72..888c559 100755 --- a/build.sh +++ b/build.sh @@ -146,17 +146,24 @@ 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" + app_args[module_prop_name]="${app_args[module_prop_name]}-arm" if ((idx >= PARALLEL_JOBS)); then wait -n; fi idx=$((idx + 1)) build_rv "$(declare -p app_args)" & diff --git a/revanced-magisk/customize.sh b/revanced-magisk/customize.sh index 04e70a9..1e00b9d 100755 --- a/revanced-magisk/customize.sh +++ b/revanced-magisk/customize.sh @@ -1,4 +1,3 @@ -#!/system/bin/sh . "$MODPATH/config" ui_print "" @@ -106,10 +105,10 @@ 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 + 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 diff --git a/utils.sh b/utils.sh index cb111f2..90bd20c 100755 --- a/utils.sh +++ b/utils.sh @@ -435,7 +435,6 @@ build_rv() { elif [ "$arch" = "arm-v7a" ]; then patcher_args+=("--rip-lib arm64-v8a") fi - fi fi if [ ! -f "$patched_apk" ] || [ "$REBUILD" = true ]; then From 366286f55949d41d3a31fa38abb9ceed702e0333 Mon Sep 17 00:00:00 2001 From: j-hc Date: Mon, 3 Jun 2024 20:39:59 +0300 Subject: [PATCH 7/9] update build.sh --- build.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 888c559..d670895 100755 --- a/build.sh +++ b/build.sh @@ -73,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 @@ -164,7 +167,10 @@ for table_name in $(toml_get_table_names); do app_args[table]="$table_name (arm-v7a)" app_args[arch]="arm-v7a" app_args[module_prop_name]="${app_args[module_prop_name]}-arm" - if ((idx >= PARALLEL_JOBS)); then wait -n; fi + if ((idx >= PARALLEL_JOBS)); then + wait -n + idx=$((idx - 1)) + fi idx=$((idx + 1)) build_rv "$(declare -p app_args)" & else From 4d751689787dd6b4cc98e9058553fb861620b06e Mon Sep 17 00:00:00 2001 From: j-hc Date: Sat, 8 Jun 2024 01:59:06 +0300 Subject: [PATCH 8/9] uptodown add support for arch option --- utils.sh | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/utils.sh b/utils.sh index 90bd20c..fc19e00 100755 --- a/utils.sh +++ b/utils.sh @@ -10,7 +10,6 @@ NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')} REBUILD=${REBUILD:-false} OS=$(uname -o) -# -------------------- json/toml -------------------- toml_prep() { __TOML__=$(tr -d '\t\r' <<<"$1" | tr "'" '"' | grep -o '^[^#]*' | grep -v '^$' | sed -r 's/(\".*\")|\s*/\1/g; 1i []'); } toml_get_table_names() { local tn @@ -25,7 +24,6 @@ toml_get() { local table=$1 key=$2 val val=$(grep -m 1 "^${key}=" <<<"$table") && sed -e "s/^\"//; s/\"$//" <<<"${val#*=}" } -# --------------------------------------------------- pr() { echo -e "\033[0;32m[+] ${1}\033[0m"; } epr() { @@ -254,7 +252,6 @@ get_apkmirror_resp() { __APKMIRROR_RESP__=$(req "${1}" -) __APKMIRROR_CAT__="${1##*/}" } -# -------------------------------------------------- # -------------------- uptodown -------------------- get_uptodown_resp() { @@ -263,29 +260,36 @@ get_uptodown_resp() { } get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; } dl_uptodown() { - local uptodown_dlurl=$1 version=$2 output=$3 + local uptodown_dlurl=$1 version=$2 output=$3 arch=$4 is_latest=$6 local url - url=$(grep -F "${version}" -B 2 <<<"$__UPTODOWN_RESP__" | head -1 | sed -n 's;.*data-url=".*download\/\(.*\)".*;\1;p') || return 1 - url="https://dw.uptodown.com/dwn/$(req "${uptodown_dlurl}/post-download/${url}" - | sed -n 's;.*class="post-download" data-url="\(.*\)".*;\1;p')" || return 1 + if [ "$is_latest" = false ]; then + url=$(grep -F "${version}" -B 2 <<<"$__UPTODOWN_RESP__" | head -1 | sed -n 's;.*data-url=".*download\/\(.*\)".*;\1;p') || return 1 + url="/$url" + else url=""; fi + if [ "$arch" != all ]; then + local app_code data_version files node_arch content resp + if [ "$is_latest" = false ]; then + resp=$(req "${1}/download${url}" -) + else resp="$__UPTODOWN_RESP_PKG__"; fi + app_code=$($HTMLQ "#detail-app-name" --attribute code <<<"$resp") + data_version=$($HTMLQ "button.button:nth-child(2)" --attribute data-version <<<"$resp") + files=$(req "${uptodown_dlurl%/*}/app/${app_code}/version/${data_version}/files" - | jq -r .content) + for ((n = 1; n < 40; n++)); do + node_arch=$($HTMLQ ".content > p:nth-child($n)" --text <<<"$files" | xargs) || return 1 + if [ -z "$node_arch" ]; then return 1; fi + if [ "$node_arch" != "$arch" ]; then continue; fi + content=$($HTMLQ "div.variant:nth-child($((n + 1)))" <<<"$files") + url=$(sed -n "s;.*'.*android\/post-download\/\(.*\)'.*;\1;p" <<<"$content" | head -1) + url="/$url" + break + done + fi + url="https://dw.uptodown.com/dwn/$(req "${uptodown_dlurl}/post-download${url}" - | sed -n 's;.*class="post-download" data-url="\(.*\)".*;\1;p')" || return 1 req "$url" "$output" } get_uptodown_pkg_name() { $HTMLQ --text "tr.full:nth-child(1) > td:nth-child(3)" <<<"$__UPTODOWN_RESP_PKG__"; } -# -------------------------------------------------- -# -------------------- apkmonk --------------------- -get_apkmonk_resp() { - __APKMONK_RESP__=$(req "${1}" -) - __APKMONK_PKG_NAME__=$(awk -F/ '{print $NF}' <<<"$1") -} -get_apkmonk_vers() { grep -oP 'download_ver.+?>\K([0-9,\.]*)' <<<"$__APKMONK_RESP__"; } -dl_apkmonk() { - local url=$1 version=$2 output=$3 - url="https://www.apkmonk.com/down_file?pkg="$(grep -F "$version" <<<"$__APKMONK_RESP__" | grep -oP 'href=\"/download-app/\K.+?(?=/?\">)' | sed 's;/;\&key=;') || return 1 - url=$(req "$url" - | grep -oP 'https.+?(?=\",)') || return 1 - req "$url" "$output" -} -get_apkmonk_pkg_name() { echo "$__APKMONK_PKG_NAME__"; } -# -------------------------------------------------- +# -------------------- archive -------------------- dl_archive() { local url=$1 version=$2 output=$3 arch=$4 local path version=${version// /} @@ -381,7 +385,7 @@ build_rv() { for dl_p in archive apkmirror uptodown apkmonk; do if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi pr "Downloading '${table}' from ${dl_p}" - if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}"; then + if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}" "$get_latest_ver"; then epr "ERROR: Could not download '${table}' from ${dl_p} with version '${version}', arch '${arch}', dpi '${args[dpi]}'" continue fi From 37baf5ffdb069fd36de93dbc7d35a34e7afd6f9e Mon Sep 17 00:00:00 2001 From: j-hc Date: Sat, 8 Jun 2024 02:00:38 +0300 Subject: [PATCH 9/9] remove apkmonk --- CONFIG.md | 2 -- build.sh | 6 +----- utils.sh | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 3256feb..678960a 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -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: @@ -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 diff --git a/build.sh b/build.sh index d670895..7f67488 100755 --- a/build.sh +++ b/build.sh @@ -127,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 @@ -139,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'" diff --git a/utils.sh b/utils.sh index fc19e00..91a186e 100755 --- a/utils.sh +++ b/utils.sh @@ -341,7 +341,7 @@ build_rv() { p_patcher_args+=("$(join_args "${args[excluded_patches]}" -e) $(join_args "${args[included_patches]}" -i)") [ "${args[exclusive_patches]}" = true ] && p_patcher_args+=("--exclusive") - for dl_p in archive apkmirror uptodown apkmonk; do + for dl_p in archive apkmirror uptodown; do if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi if ! get_"${dl_p}"_resp "${args[${dl_p}_dlurl]}" || ! pkg_name=$(get_"${dl_p}"_pkg_name); then args[${dl_p}_dlurl]="" @@ -382,7 +382,7 @@ build_rv() { version_f=${version_f#v} local stock_apk="${TEMP_DIR}/${pkg_name}-${version_f}-${arch_f}.apk" if [ ! -f "$stock_apk" ]; then - for dl_p in archive apkmirror uptodown apkmonk; do + for dl_p in archive apkmirror uptodown; do if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi pr "Downloading '${table}' from ${dl_p}" if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}" "$get_latest_ver"; then