Skip to content

Commit

Permalink
Move boot image path to /boot/boot-magisk.img (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
1457384613gh authored Feb 7, 2023
1 parent ac11709 commit fdd8718
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
14 changes: 8 additions & 6 deletions initrd/bin/magisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -132,7 +134,7 @@ OVERLAYDIR="/android/dev/boot-magisk/overlay.d"
# if boot image contains magisk, it will be used instead of magisk.apk

debug_log "initrd-magisk: parse boot image"
( cp -f "/mnt/$SOURCE_OS/boot-magisk.img" /tmp/boot.img
( cp -f "/mnt/$SOURCE_OS/boot/boot-magisk.img" /tmp/boot.img
cd "$inittmp" && $MAGISKCORE/magiskboot unpack "/tmp/boot.img"
cd "$inittmp/boot-magisk" && cat "$inittmp/ramdisk.cpio" | cpio -iud
cp -f "$inittmp/boot-magisk/init" "$MAGISKCORE/magiskinit"
Expand Down
16 changes: 8 additions & 8 deletions initrd/init
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,25 @@ 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"
else
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"
}
Expand Down

0 comments on commit fdd8718

Please sign in to comment.