You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Add compressed ramdisk support
This commit is contained in:
@@ -90,7 +90,8 @@ esac
|
||||
# Test patch status and do restore, after this section, ramdisk.cpio.orig is guaranteed to exist
|
||||
ui_print "- Checking ramdisk status"
|
||||
./magiskboot --cpio ramdisk.cpio test
|
||||
case $? in
|
||||
STATUS=$?
|
||||
case $((STATUS & 3)) in
|
||||
0 ) # Stock boot
|
||||
ui_print "- Stock boot image detected"
|
||||
ui_print "- Backing up stock boot image"
|
||||
@@ -128,6 +129,11 @@ echo "KEEPFORCEENCRYPT=$KEEPFORCEENCRYPT" >> config
|
||||
"backup ramdisk.cpio.orig" \
|
||||
"add 000 .backup/.magisk config"
|
||||
|
||||
if [ $((STATUS & 4)) -ne 0 ]; then
|
||||
ui_print "- Compressing ramdisk"
|
||||
./magiskboot --cpio ramdisk.cpio compress
|
||||
fi
|
||||
|
||||
rm -f ramdisk.cpio.orig config
|
||||
|
||||
##########################################################################################
|
||||
@@ -167,4 +173,5 @@ ui_print "- Repacking boot image"
|
||||
# Sign chromeos boot
|
||||
$CHROMEOS && sign_chromeos
|
||||
|
||||
./magiskboot --cleanup
|
||||
# Reset any error code
|
||||
true
|
||||
|
||||
@@ -106,7 +106,15 @@ $IS64BIT && mv -f magiskinit64 magiskinit || rm -f magiskinit64
|
||||
. ./boot_patch.sh "$BOOTIMAGE"
|
||||
|
||||
ui_print "- Flashing new boot image"
|
||||
flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size"
|
||||
|
||||
if ! flash_image new-boot.img "$BOOTIMAGE"; then
|
||||
ui_print "- Compressing ramdisk to fit in partition"
|
||||
./magiskboot --cpio ramdisk.cpio compress
|
||||
./magiskboot --repack "$BOOTIMAGE"
|
||||
flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size"
|
||||
fi
|
||||
|
||||
./magiskboot --cleanup
|
||||
rm -f new-boot.img
|
||||
|
||||
if [ -f stock_boot* ]; then
|
||||
|
||||
@@ -256,9 +256,9 @@ flash_image() {
|
||||
CMD2="cat -"
|
||||
fi
|
||||
if [ -b "$2" ]; then
|
||||
local s_size=`stat -c '%s' "$1"`
|
||||
local t_size=`blockdev --getsize64 "$2"`
|
||||
[ $s_size -gt $t_size ] && return 1
|
||||
local img_sz=`stat -c '%s' "$1"`
|
||||
local blk_sz=`blockdev --getsize64 "$2"`
|
||||
[ $img_sz -gt $blk_sz ] && return 1
|
||||
eval $CMD1 | eval $CMD2 | cat - /dev/zero > "$2" 2>/dev/null
|
||||
else
|
||||
ui_print "- Not block device, storing image"
|
||||
|
||||
Reference in New Issue
Block a user