From 0d94b73772026cf6db8b4e457a4ff3d95a0acdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chauncy=E2=99=8B?= <1457384613g@gmail.com> Date: Sat, 4 Feb 2023 20:28:36 +0800 Subject: [PATCH] Move boot image path to /boot/boot-magisk.img https://github.com/HuskyDG/initrd-magisk/issues/25 --- initrd/bin/magisk.sh | 12 +++++++----- initrd/init | 16 ++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/initrd/bin/magisk.sh b/initrd/bin/magisk.sh index 957885e..522da81 100644 --- a/initrd/bin/magisk.sh +++ b/initrd/bin/magisk.sh @@ -76,12 +76,14 @@ fi killall -9 magiskd } -if [ -f "/mnt/$SOURCE_OS/boot-magisk.img" ]; then - loop_setup "/mnt/$SOURCE_OS/boot-magisk.img" - BOOTIMAGE="$LOOPDEV" - debug_log "initrd-magisk: boot image = $BOOTIMAGE" +if [ -f "/mnt/$SOURCE_OS/boot/boot-magisk.img" ]; then + loop_setup "/mnt/$SOURCE_OS/boot/boot-magisk.img" + BOOTIMAGE="$LOOPDEV" + debug_log "initrd-magisk: boot image = $BOOTIMAGE" +fi +if [ -z "$BOOTIMAGE" ]; then + debug_log "initrd-magisk: boot image is not found" fi -[ -z "$BOOTIMAGE" ] && BOOTIMAGE=/dev/null ( # BEGIN : inject magisk diff --git a/initrd/init b/initrd/init index d701c50..55470e4 100644 --- a/initrd/init +++ b/initrd/init @@ -149,15 +149,15 @@ check_root() mkdir /mnt/iso mount -o loop /iso/$iso /mnt/iso fi - INITRD_REAL=initrd_real.img - APKFILE=/mnt/$SRC/magisk.apk + INITRD_REAL=boot/initrd_real.img + APKFILE=/mnt/$SRC/boot/magisk.apk echo "$dev" >"$MAGISKCORE/osroot_dev" if [ -e /mnt/$SRC/$INITRD_REAL ]; then zcat /mnt/$SRC/$INITRD_REAL | cpio -id > /dev/null INITRD_IMAGE="/mnt/$SRC/$INITRD_REAL" - elif [ -e /mnt/$SRC/initrd.img ]; then - zcat /mnt/$SRC/initrd.img | cpio -id > /dev/null - INITRD_IMAGE="/mnt/$SRC/initrd.img" + elif [ -e /mnt/$SRC/boot/initrd.img ]; then + zcat /mnt/$SRC/boot/initrd.img | cpio -id > /dev/null + INITRD_IMAGE="/mnt/$SRC/boot/initrd.img" elif [ -b /dev/$INITRD_REAL ]; then zcat /dev/$INITRD_REAL | cpio -id > /dev/null INITRD_IMAGE="/dev/$INITRD_REAL" @@ -165,9 +165,9 @@ check_root() return 1 fi err="$?" - if [ ! -f "/mnt/$SRC/boot-magisk.img" ]; then - rm -rf "/mnt/$SRC/boot-magisk.img" - zcat "/boot.img.gz" >"/mnt/$SRC/boot-magisk.img" + if [ ! -f "/mnt/$SRC/boot/boot-magisk.img" ]; then + rm -rf "/mnt/$SRC/boot/boot-magisk.img" + zcat "/boot.img.gz" >"/mnt/$SRC/boot/boot-magisk.img" fi return "$err" }