MinMicroG: Support lineage recovery and dynamic partitions devices

With the previous install script we'd try to mount /system
which is in fstab on lineage recovery, but on Q and up recoveries
recovery has it's own /system and all the executables are in
/system/bin rather than /sbin, resulting in tools like "chcon"
missing after mounting /system
Also on dynamic partitions devices /system is not in fstab
due to the block device being only created when logical
partitions are mapped, support that case as well

Most of the code is taken from
https://gitlab.com/MindTheGapps/vendor_gapps/-/blob/tau/build/meta/com/google/android/update-binary
pull/53/head
Tim Zimmermann 2 years ago committed by FriendlyNeighborhoodShane
parent e641178926
commit 20f467c6b0

@ -72,6 +72,39 @@ abort() {
exit 1;
}
fstab_getmount() {
grep -v "^#" /etc/recovery.fstab | grep "[[:blank:]]$1[[:blank:]]" | tail -n1 | tr -s "[:blank:]" " " | cut -d" " -f1;
}
find_block() {
dynamicpart="$(getprop ro.boot.dynamicpart)";
[ "$dynamicpart" = "true" ] || dynamicpart="false";
[ "$dynamicpart" = "true" ] && blkpath="/dev/block/mapper" || {
blkpath="/dev/block/by-name";
[ -d "$blkpath" ] || blkpath="/dev/block/bootdevice/by-name";
}
blkabslot="$(getprop ro.boot.slot_suffix)";
for name in "$@"; do
blkmount="$(fstab_getmount "$name")";
[ "$blkmount" ] && blkmountexists="true" || blkmountexists="false";
case "$dynamicpart-$blkmountexists" in
true-true)
blkdev="${blkpath}/${blkmount}${blkabslot}";
;;
false-true)
blkdev="${blkmount}${blkabslot}";
;;
true-false|false-false)
blkdev="${blkpath}/${name}${blkabslot}";
;;
esac;
[ -b "$blkdev" ] && {
echo "$blkdev";
return;
}
done;
}
ui_print " ";
ui_print "-- Minimal MicroG Installer --";
ui_print "-- The Essentials only MicroG pack --";
@ -82,10 +115,13 @@ log "Zip File is $zipfile";
log "Bootmode is $bootmode";
$bootmode || {
for part in "/system" "/system_root" "/mnt/system"; do
[ -e "$part" ] || continue;
mount -o ro "$part";
umountparts="$umountparts $part";
sysblk="$(find_block /mnt/system /system_root /system /)";
for mntpoint in "/mnt/system" "/system_root" "/system"; do
[ -e "$mntpoint" ] || continue;
mount -o ro "$mntpoint" || mount -o ro "$sysblk" "$mntpoint" && {
umountparts="$umountparts $mntpoint";
break;
}
done;
mount /data;
umountparts="$umountparts /data";
@ -435,6 +471,7 @@ else
rootpart="$sysrootpart";
mount -o rw,remount "$rootpart";
mount -o rw,remount "$rootpart" "$rootpart";
[ "$dynamicpart" = "true" ] && blockdev --setrw "$sysblk";
root="$sysroot";
magisk=no;
log "Mounted $rootpart RW";

Loading…
Cancel
Save