Skip to content

Commit

Permalink
Merge branch 'j-hc:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vucko130 authored Oct 6, 2024
2 parents e1372ad + 01c85cb commit ee4082c
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 53 deletions.
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
127 changes: 82 additions & 45 deletions revanced-magisk/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 </dev/null); then
if ! op=$(pm install-existing "$PKG_NAME" 2>&1 </dev/null) && echo "$op" | grep -qv NameNotFoundException; then
ui_print "ERROR: install-existing failed"
abort "$op"
fi
ui_print "* Installed existing $PKG_NAME"
fi

INS=true
IS_SYS=false
if BASEPATH=$(pm path "$PKG_NAME" 2>&1 </dev/null); then
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ "${BASEPATH:1:6}" = system ]; then
if echo "$BASEPATH" | grep -qF -e '/system/' -e '/product/'; then
ui_print "* $PKG_NAME is a system app"
if [ "${BASEPATH:1:6}" != system ]; then BASEPATH=/system${BASEPATH}; fi
IS_SYS=true
elif [ ! -d "${BASEPATH}/lib" ]; then
ui_print "* Invalid installation found. Uninstalling..."
pm uninstall -k --user 0 "$PKG_NAME"
if ! op=$(pm uninstall -k --user 0 "$PKG_NAME" 2>&1 </dev/null); then
abort "$op"
fi
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#*=}"
Expand All @@ -68,33 +78,53 @@ install() {
abort "ERROR: Stock $PKG_NAME apk was not found"
fi
ui_print "* Updating $PKG_NAME to $PKG_VER"
VERIF_ADB=$(settings get global verifier_verify_adb_installs)
settings put global verifier_verify_adb_installs 0
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%]*}
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 </dev/null); then
ui_print "ERROR: install-create failed"
settings put global verifier_verify_adb_installs "$VERIF_ADB"
abort "$SES"
fi
ui_print "ERROR: install-commit failed"
abort "$op"
fi
settings put global verifier_verify_adb_installs 1
if BASEPATH=$(pm path "$PKG_NAME" 2>&1 </dev/null); then
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
else
abort "ERROR: install $PKG_NAME manually and reflash the module"
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 </dev/null); then
ui_print "ERROR: install-write failed"
settings put global verifier_verify_adb_installs "$VERIF_ADB"
abort "$op"
fi
if ! op=$(pm install-commit "$SES" 2>&1 </dev/null); then
if echo "$op" | grep -q INSTALL_FAILED_VERSION_DOWNGRADE; then
ui_print "* ERROR: INSTALL_FAILED_VERSION_DOWNGRADE"
if [ "$IS_SYS" = true ]; then
ui_print "* Use system mount mode"
BASEPATH=${MODPATH}${BASEPATH}
set_perm "$BASEPATH" 1000 1000 755 u:object_r:system_file:s0
RVPATH=$BASEPATH/${BASEPATH##*/}.apk
rm "$MODPATH/service.sh" "$MODPATH/uninstall.sh"
break
else
ui_print "* Uninstalling..."
if ! op=$(pm uninstall -k --user 0 "$PKG_NAME" 2>&1 </dev/null); then
ui_print "$op"
fi
continue
fi
fi
ui_print "ERROR: install-commit failed"
settings put global verifier_verify_adb_installs "$VERIF_ADB"
abort "$op"
fi
if BASEPATH=$(pm path "$PKG_NAME" 2>&1 </dev/null); then
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
else
abort "ERROR: install $PKG_NAME manually and reflash the module"
fi
break
done
settings put global verifier_verify_adb_installs "$VERIF_ADB"
}
if [ $INS = true ] && ! install; then abort; fi

Expand All @@ -108,25 +138,32 @@ if [ -z "$(ls -A1 "$BASEPATHLIB")" ]; then
fi
set_perm_recursive "${BASEPATH}/lib" 1000 1000 755 755 u:object_r:apk_data_file:s0
fi
mv -f "$MODPATH/base.apk" "$RVPATH"

ui_print "* Setting Permissions"
set_perm "$MODPATH/base.apk" 1000 1000 644 u:object_r:apk_data_file:s0
set_perm "$RVPATH" 1000 1000 644 u:object_r:apk_data_file:s0

ui_print "* Mounting $PKG_NAME"
mkdir -p "/data/adb/rvhc"
RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk
mv -f "$MODPATH/base.apk" "$RVPATH"
if [ "$IS_SYS" = false ]; then
ui_print "* Mounting $PKG_NAME"
mkdir -p "/data/adb/rvhc"
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"

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 Vucko130 (github.com/Vucko130)"
ui_print " "
2 changes: 1 addition & 1 deletion revanced-magisk/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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#*=}"
Expand Down
15 changes: 9 additions & 6 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 "
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit ee4082c

Please sign in to comment.