From f25b6c8da48f7403e96a415bda3f7d964db41f10 Mon Sep 17 00:00:00 2001 From: j-hc Date: Sat, 5 Oct 2024 21:21:17 +0300 Subject: [PATCH 1/3] update error handling --- build.sh | 4 +++- utils.sh | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 865f548fa5..7d33f33a42 100755 --- a/build.sh +++ b/build.sh @@ -50,7 +50,9 @@ java --version >/dev/null || abort "\`openjdk 17\` is not installed. install it zip --version >/dev/null || abort "\`zip\` is not installed. install it with 'apt install zip' or equivalent" # ---------------- rm -rf revanced-magisk/bin/*/tmp.* -: >"$TEMP_DIR"/*-rv/changelog.md || : +if [ "$(echo "$TEMP_DIR"/*-rv/changelog.md)" ]; then + : >"$TEMP_DIR"/*-rv/changelog.md || : +fi get_prebuilts diff --git a/utils.sh b/utils.sh index 945b340fb7..5e34beaa13 100755 --- a/utils.sh +++ b/utils.sh @@ -80,13 +80,14 @@ get_rv_prebuilts() { if [ "$tag" = "Integrations" ]; then integs_file=$file; fi echo "$tag: $(cut -d/ -f1 <<<"$src")/${name} " >>"${cl_dir}/changelog.md" else + local for_err=$file if [ "$ver" = "latest" ]; then file=$(grep -v dev <<<"$file" | head -1) else file=$(grep "${ver#v}" <<<"$file" | head -1); fi + if [ -z "$file" ]; then abort "filter fail: '$for_err' with '$ver'"; fi name=$(basename "$file") tag_name=$(cut -d'-' -f3- <<<"$name") tag_name=v${tag_name%.*} - if [ "$tag_name" = "v" ]; then abort "wrong ver"; fi fi echo -n "$file " @@ -543,9 +544,11 @@ build_rv() { fi fi fi - if ! patch_apk "$stock_apk" "$patched_apk" "${patcher_args[*]}" "${args[cli]}" "${args[ptjar]}"; then - epr "Building '${table}' failed!" - return 0 + if [ "${NORB:-}" != true ] || [ ! -f "$patched_apk" ]; then + if ! patch_apk "$stock_apk" "$patched_apk" "${patcher_args[*]}" "${args[cli]}" "${args[ptjar]}"; then + epr "Building '${table}' failed!" + return 0 + fi fi if [ "$build_mode" = apk ]; then local apk_output="${BUILD_DIR}/${app_name_l}-${rv_brand_f}-v${version_f}-${arch_f}.apk" From 1a7678c6f5c957445d23fab0367fdc8db389c473 Mon Sep 17 00:00:00 2001 From: j-hc Date: Sun, 6 Oct 2024 01:40:06 +0300 Subject: [PATCH 2/3] module: update & fix INSTALL_FAILED_VERSION_DOWNGRADE --- revanced-magisk/customize.sh | 127 ++++++++++++++++++++++------------- revanced-magisk/service.sh | 2 +- 2 files changed, 83 insertions(+), 46 deletions(-) diff --git a/revanced-magisk/customize.sh b/revanced-magisk/customize.sh index ad2d7257ee..9344ff9c43 100755 --- a/revanced-magisk/customize.sh +++ b/revanced-magisk/customize.sh @@ -7,21 +7,18 @@ Your device: $ARCH Module: $MODULE_ARCH" fi +alias cmpr="$MODPATH/bin/$ARCH/cmpr" if [ "$ARCH" = "arm" ]; then ARCH_LIB=armeabi-v7a - alias cmpr='$MODPATH/bin/arm/cmpr' elif [ "$ARCH" = "arm64" ]; then ARCH_LIB=arm64-v8a - alias cmpr='$MODPATH/bin/arm64/cmpr' elif [ "$ARCH" = "x86" ]; then ARCH_LIB=x86 - alias cmpr='$MODPATH/bin/x86/cmpr' elif [ "$ARCH" = "x64" ]; then ARCH_LIB=x86_64 - alias cmpr='$MODPATH/bin/x64/cmpr' -else - abort "ERROR: unsupported arch: ${ARCH}" -fi +else abort "ERROR: unreachable: ${ARCH}"; fi +RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk + set_perm_recursive "$MODPATH/bin" 0 0 0755 0777 if su -M -c true >/dev/null 2>/dev/null; then @@ -30,21 +27,34 @@ else alias mm='nsenter -t1 -m' fi -mm grep "$PKG_NAME" /proc/mounts | while read -r line; do +mm grep -F "$PKG_NAME" /proc/mounts | while read -r line; do ui_print "* Un-mount" mp=${line#* } mp=${mp%% *} mm umount -l "${mp%%\\*}" done am force-stop "$PKG_NAME" +if ! (pm path "$PKG_NAME" >/dev/null 2>&1 &1 &1 &1 &1); then - ui_print "ERROR: install-create failed" - abort "$SES" - fi - 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" - abort "$op" - fi - 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" - return 1 + + while true; do + if ! SES=$(pm install-create --user 0 -i com.android.vending -r -d -S "$SZ" 2>&1 &1 &1 &1 &1 &1 &1); then + ui_print "ERROR: Mount failed!" + ui_print "$op" + fi + am force-stop "$PKG_NAME" -if ! op=$(mm mount -o bind "$RVPATH" "$BASEPATH/base.apk" 2>&1); then - ui_print "ERROR: Mount failed!" - ui_print "$op" + ui_print "* Optimizing $PKG_NAME" + nohup cmd package compile --reset "$PKG_NAME" >/dev/null 2>&1 & fi -am force-stop "$PKG_NAME" -ui_print "* Optimizing $PKG_NAME" -nohup cmd package compile --reset "$PKG_NAME" >/dev/null 2>&1 & ui_print "* Cleanup" rm -rf "${MODPATH:?}/bin" "$MODPATH/$PKG_NAME.apk" +if [ -d "/data/adb/modules/zygisk-assistant" ]; then + ui_print "* If you are using zygisk-assistant, you need to" + ui_print " give root permissions to $PKG_NAME" +fi + ui_print "* Done" ui_print " by j-hc (github.com/j-hc)" ui_print " " diff --git a/revanced-magisk/service.sh b/revanced-magisk/service.sh index fdfac8ea6c..09dbcb2c74 100755 --- a/revanced-magisk/service.sh +++ b/revanced-magisk/service.sh @@ -23,7 +23,7 @@ if [ $svcl != 0 ]; then fi BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*} if [ ! -d "$BASEPATH/lib" ]; then - err "zygote crashed (fix your ROM)" + err "system force-rebooted (fix your ROM)" exit fi VERSION=$(dumpsys package "$PKG_NAME" | grep -m1 versionName) VERSION="${VERSION#*=}" From 01c85cb7a2813f777bd8449ed6d9ca73183eccc4 Mon Sep 17 00:00:00 2001 From: j-hc Date: Sun, 6 Oct 2024 15:20:16 +0300 Subject: [PATCH 3/3] fix get_rv_prebuilts --- utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.sh b/utils.sh index 5e34beaa13..448a88d8a3 100755 --- a/utils.sh +++ b/utils.sh @@ -82,8 +82,8 @@ get_rv_prebuilts() { else local for_err=$file if [ "$ver" = "latest" ]; then - file=$(grep -v dev <<<"$file" | head -1) - else file=$(grep "${ver#v}" <<<"$file" | head -1); fi + file=$(grep -v '/[^/]*dev[^/]*$' <<<"$file" | head -1) + else file=$(grep "/[^/]*${ver#v}[^/]*\$" <<<"$file" | head -1); fi if [ -z "$file" ]; then abort "filter fail: '$for_err' with '$ver'"; fi name=$(basename "$file") tag_name=$(cut -d'-' -f3- <<<"$name")