force-debloat.sh: A/B partition scheme support

merge-requests/23/head
Christopher Roy Bratusek 6 years ago
parent d8a7a397c0
commit 66149bc5b7

@ -79,12 +79,40 @@ is_mounted() {
return $?
}
debloat_system () {
if (is_mounted /system); then
mount -orw,remount /system || error "!! failed to remount system read-write"
else mount -orw /system || error "!! failed to mount system read-write"
# taken from Magisk, with minor modifications for NanoDroid
mount_partitions () {
SLOT=$(grep_cmdline androidboot.slot_suffix)
if [ -z ${SLOT} ]; then
SLOT=_$(grep_cmdline androidboot.slot)
[ "${SLOT}" = "_" ] && SLOT=
fi
is_mounted /data || mount /data
${BOOTMODE} || mount -o bind /dev/urandom /dev/random
! is_mounted /system && mount -o rw /system
if [ ! -f /system/build.prop ]; then
SYSTEMBLOCK=$(find /dev/block -iname system${SLOT} | head -n 1)
mount -t ext4 -o rw ${SYSTEMBLOCK} /system
fi
[ -f /system/build.prop ] || is_mounted /system || error "failed to mount /system (unsupported A/B device?)"
if [ -f /system/init ]; then
mkdir /system_root 2>/dev/null
mount --move /system /system_root
mount -o bind /system_root/system /system
fi
[ ! -f /system/build.prop ] && error "failed to mount /system (unsupported A/B device?)"
}
debloat_system () {
mount_partitions
for app in ${APPS}; do
if [[ -d /system/app/${app} ]]; then
rm -rf /system/app/${app}

Loading…
Cancel
Save