Support recovery based Magisk

Some devices (mainly new Samsung phones we're talking here...) using
A only system-as-root refuse to load ramdisk when booted with boot
no matter what we do. With many A only system-as-root devices, even
though their boot image is kernel only, we can still be able to add
a ramdisk section into the image and force the kernel to use it as
rootfs. However the bootloader on devices like the S10 simply does
not load anything within boot image into memory other than the kernel.
This gives as the only option is to install Magisk on the recovery
partition. This commits adds proper support for these kind of scenarios.
This commit is contained in:
topjohnwu
2019-03-30 00:49:48 -04:00
parent 5b30c77403
commit 1cd45b53b1
4 changed files with 28 additions and 14 deletions

View File

@ -58,6 +58,7 @@ BOOTIMAGE="$1"
# Flags
[ -z $KEEPVERITY ] && KEEPVERITY=false
[ -z $KEEPFORCEENCRYPT ] && KEEPFORCEENCRYPT=false
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
chmod -R 755 .
@ -133,6 +134,7 @@ ui_print "- Patching ramdisk"
echo "KEEPVERITY=$KEEPVERITY" > config
echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config
[ ! -z $SHA1 ] && echo "SHA1=$SHA1" >> config
[ -f recovery_dtbo ] && echo "RECOVERYMODE=true" >> config
./magiskboot cpio ramdisk.cpio \
"add 750 init magiskinit" \
@ -153,9 +155,9 @@ rm -f ramdisk.cpio.orig config
##########################################################################################
if ! $KEEPVERITY; then
[ -f dtb ] && ./magiskboot dtb-patch dtb && ui_print "- Removing dm(avb)-verity in dtb"
[ -f kernel_dtb ] && ./magiskboot dtb-patch kernel_dtb && ui_print "- Removing dm(avb)-verity in dtb"
[ -f extra ] && ./magiskboot dtb-patch extra && ui_print "- Removing dm(avb)-verity in extra-dtb"
for dt in dtb kernel_dtb extra recovery_dtbo; do
[ -f $dt ] && ./magiskboot dtb-patch $dt && ui_print "- Removing dm(avb)-verity in $dt"
done
fi
if [ -f kernel ]; then