module: update

This commit is contained in:
j-hc 2024-10-22 12:56:34 +03:00
parent 6f491ad481
commit 4d6ca4bbfc
No known key found for this signature in database
GPG Key ID: CDF97F1DBFE904CD
2 changed files with 52 additions and 39 deletions

View File

@ -37,9 +37,16 @@ pmex() {
return $RET return $RET
} }
if ! pmex path "$PKG_NAME" >/dev/null; then if ! pmex path "$PKG_NAME" >&2; then
if pmex install-existing "$PKG_NAME" >/dev/null; then if pmex install-existing "$PKG_NAME" >&2; then
ui_print "* Installed existing $PKG_NAME" BASEPATH=$(pmex path "$PKG_NAME") || abort "ERROR: pm path failed $BASEPATH"
echo >&2 "'$BASEPATH'"
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ "${BASEPATH:1:4}" = data ]; then
if pmex uninstall -k --user 0 "$PKG_NAME" >&2; then
ui_print "* Cleared existing $PKG_NAME package"
else abort "ERROR: pm uninstall failed"; fi
else ui_print "* Installed stock $PKG_NAME package"; fi
fi fi
fi fi
@ -48,7 +55,7 @@ INS=true
if BASEPATH=$(pmex path "$PKG_NAME"); then if BASEPATH=$(pmex path "$PKG_NAME"); then
echo >&2 "'$BASEPATH'" echo >&2 "'$BASEPATH'"
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*} BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if echo "$BASEPATH" | grep -qF -e '/system/' -e '/product/'; then if [ "${BASEPATH:1:4}" != data ]; then
ui_print "* $PKG_NAME is a system app." ui_print "* $PKG_NAME is a system app."
IS_SYS=true IS_SYS=true
elif [ ! -f "$MODPATH/$PKG_NAME.apk" ]; then elif [ ! -f "$MODPATH/$PKG_NAME.apk" ]; then
@ -77,7 +84,7 @@ install() {
VERIF_ADB=$(settings get global verifier_verify_adb_installs) VERIF_ADB=$(settings get global verifier_verify_adb_installs)
settings put global verifier_verify_adb_installs 0 settings put global verifier_verify_adb_installs 0
SZ=$(stat -c "%s" "$MODPATH/$PKG_NAME.apk") SZ=$(stat -c "%s" "$MODPATH/$PKG_NAME.apk")
for _ in 1 2; do for IT in 1 2; do
if ! SES=$(pmex install-create --user 0 -i com.android.vending -r -d -S "$SZ"); then if ! SES=$(pmex install-create --user 0 -i com.android.vending -r -d -S "$SZ"); then
ui_print "ERROR: install-create failed" ui_print "ERROR: install-create failed"
settings put global verifier_verify_adb_installs "$VERIF_ADB" settings put global verifier_verify_adb_installs "$VERIF_ADB"
@ -106,6 +113,7 @@ install() {
ui_print "* Uninstalling..." ui_print "* Uninstalling..."
if ! op=$(pmex uninstall -k --user 0 "$PKG_NAME"); then if ! op=$(pmex uninstall -k --user 0 "$PKG_NAME"); then
ui_print "$op" ui_print "$op"
if [ $IT = 2 ]; then abort "ERROR: pm uninstall failed."; fi
fi fi
continue continue
fi fi

View File

@ -3,42 +3,47 @@ MODDIR=${0%/*}
RVPATH=/data/adb/rvhc/${MODDIR##*/}.apk RVPATH=/data/adb/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" 2>&1 </dev/null)
svcl=$?
[ $svcl = 20 ]
do sleep 2; done
sleep 5
if [ $svcl != 0 ]; then
err "app not installed"
exit
fi
BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
err() { err() {
[ ! -f "$MODDIR/err" ] && cp "$MODDIR/module.prop" "$MODDIR/err" [ ! -f "$MODDIR/err" ] && cp "$MODDIR/module.prop" "$MODDIR/err"
sed -i "s/^des.*/description=⚠️ Needs reflash: '${1}'/g" "$MODDIR/module.prop" sed -i "s/^des.*/description=⚠️ Needs reflash: '${1}'/g" "$MODDIR/module.prop"
} }
if [ ! -d "$BASEPATH/lib" ]; then until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
ls -Zla "$BASEPATH" >"$MODDIR/log.txt" until [ -d "/sdcard/Android" ]; do sleep 1; done
ls -Zla "$BASEPATH/lib" >>"$MODDIR/log.txt" while
else rm "$MODDIR/log.txt"; fi BASEPATH=$(pm path "$PKG_NAME" 2>&1 </dev/null)
VERSION=$(dumpsys package "$PKG_NAME" | grep -m1 versionName) VERSION="${VERSION#*=}" SVCL=$?
if [ "$VERSION" != "$PKG_VER" ] && [ "$VERSION" ]; then [ $SVCL = 20 ]
err "version mismatch (installed:${VERSION}, module:$PKG_VER)" do sleep 2; done
exit
fi run() {
grep "$PKG_NAME" /proc/mounts | while read -r line; do if [ $SVCL != 0 ]; then
mp=${line#* } mp=${mp%% *} err "app not installed"
umount -l "${mp%%\\*}" return
done fi
if ! chcon u:object_r:apk_data_file:s0 "$RVPATH"; then sleep 4
err "apk not found"
exit BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
fi if [ ! -d "$BASEPATH/lib" ]; then # TODO: is this ok? idk
mount -o bind "$RVPATH" "$BASEPATH/base.apk" ls -Zla "$BASEPATH" >"$MODDIR/log.txt"
am force-stop "$PKG_NAME" ls -Zla "$BASEPATH/lib" >>"$MODDIR/log.txt"
[ -f "$MODDIR/err" ] && mv -f "$MODDIR/err" "$MODDIR/module.prop" else rm "$MODDIR/log.txt" >/dev/null 2>&1; 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)"
return
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"
return
fi
mount -o bind "$RVPATH" "$BASEPATH/base.apk"
am force-stop "$PKG_NAME"
[ -f "$MODDIR/err" ] && mv -f "$MODDIR/err" "$MODDIR/module.prop"
}
run