use shell expansion

This commit is contained in:
j-hc 2022-08-13 03:18:51 +03:00
parent d818d142e7
commit 4a4d1b2ba9
No known key found for this signature in database
GPG Key ID: 242B44D16774A2ED
3 changed files with 15 additions and 6 deletions

View File

@ -1,9 +1,10 @@
# shellcheck disable=SC2148,SC2086,SC2115
ui_print ""
am force-stop __PKGNAME
grep __PKGNAME /proc/mounts | while read -r line; do
ui_print "* Un-mount"
echo "$line" | cut -d" " -f2 | xargs -r umount -l
line=${line#*' '}
line=${line%%' '*}
umount -l ${line%%\\*} # trims \040(deleted)
done
if [ $ARCH = "arm" ]; then
@ -19,7 +20,12 @@ else
fi
set_perm_recursive $MODPATH/bin 0 0 0755 0777
BASEPATH=$(pm path __PKGNAME | grep base | cut -d: -f2)
basepath() {
basepath=$(pm path __PKGNAME | grep base)
echo ${basepath#*:}
}
BASEPATH=$(basepath)
if [ -n "$BASEPATH" ] && cmpr $BASEPATH $MODPATH/stock.apk; then
ui_print "* Installed __PKGNAME and module stock.apk are identical"
ui_print "* Skipping stock APK installation"
@ -30,7 +36,7 @@ else
ui_print "ERROR: APK installation failed!"
abort "${op}"
fi
BASEPATH=$(pm path __PKGNAME | grep base | cut -d: -f2)
BASEPATH=$(basepath)
fi
ui_print "* Patching __PKGNAME (v__MDVRSN) on the fly"

View File

@ -1,4 +1,6 @@
#!/system/bin/sh
grep __PKGNAME /proc/mounts | while read -r line; do
echo "$line" | cut -d" " -f2 | xargs -r umount -l
line=${line#*' '}
line=${line%%' '*}
umount -l ${line%%\\*}
done

View File

@ -4,7 +4,8 @@ MODDIR=${0%/*}
until [ "$(getprop sys.boot_completed)" = 1 ]; do
sleep 1
done
BASEPATH=$(pm path __PKGNAME | grep base | cut -d: -f2)
BASEPATH=$(pm path __PKGNAME | grep base)
BASEPATH=${BASEPATH#*:}
if [ "$BASEPATH" ]; then
chcon u:object_r:apk_data_file:s0 $MODDIR/base.apk
mount -o bind $MODDIR/base.apk $BASEPATH