mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Do not force LD_LIBRARY_PATH in recovery
This commit is contained in:
parent
3a9a3ed184
commit
25703c1750
@ -84,7 +84,7 @@ chmod -R 755 .
|
|||||||
CHROMEOS=false
|
CHROMEOS=false
|
||||||
|
|
||||||
ui_print "- Unpacking boot image"
|
ui_print "- Unpacking boot image"
|
||||||
eval $LIB32PFX ./magiskboot --unpack "$BOOTIMAGE"
|
./magiskboot --unpack "$BOOTIMAGE"
|
||||||
|
|
||||||
case $? in
|
case $? in
|
||||||
1 )
|
1 )
|
||||||
@ -113,14 +113,14 @@ esac
|
|||||||
# Test patch status and do restore, after this section, ramdisk.cpio.orig is guaranteed to exist
|
# Test patch status and do restore, after this section, ramdisk.cpio.orig is guaranteed to exist
|
||||||
ui_print "- Checking ramdisk status"
|
ui_print "- Checking ramdisk status"
|
||||||
MAGISK_PATCHED=false
|
MAGISK_PATCHED=false
|
||||||
eval $LIB32PFX ./magiskboot --cpio ramdisk.cpio test
|
./magiskboot --cpio ramdisk.cpio test
|
||||||
case $? in
|
case $? in
|
||||||
0 ) # Stock boot
|
0 ) # Stock boot
|
||||||
ui_print "- Stock boot image detected"
|
ui_print "- Stock boot image detected"
|
||||||
ui_print "- Backing up stock boot image"
|
ui_print "- Backing up stock boot image"
|
||||||
SHA1=`eval $LIB32PFX ./magiskboot --sha1 "$BOOTIMAGE" 2>/dev/null`
|
SHA1=`./magiskboot --sha1 "$BOOTIMAGE" 2>/dev/null`
|
||||||
STOCKDUMP=stock_boot_${SHA1}.img.gz
|
STOCKDUMP=stock_boot_${SHA1}.img.gz
|
||||||
eval $LIB32PFX ./magiskboot --compress "$BOOTIMAGE" $STOCKDUMP
|
./magiskboot --compress "$BOOTIMAGE" $STOCKDUMP
|
||||||
cp -af ramdisk.cpio ramdisk.cpio.orig
|
cp -af ramdisk.cpio ramdisk.cpio.orig
|
||||||
;;
|
;;
|
||||||
1 ) # Magisk patched
|
1 ) # Magisk patched
|
||||||
@ -140,8 +140,8 @@ esac
|
|||||||
if $MAGISK_PATCHED; then
|
if $MAGISK_PATCHED; then
|
||||||
ui_print "- Magisk patched image detected"
|
ui_print "- Magisk patched image detected"
|
||||||
# Find SHA1 of stock boot image
|
# Find SHA1 of stock boot image
|
||||||
[ -z $SHA1 ] && SHA1=`eval $LIB32PFX ./magiskboot --cpio ramdisk.cpio sha1 2>/dev/null`
|
[ -z $SHA1 ] && SHA1=`./magiskboot --cpio ramdisk.cpio sha1 2>/dev/null`
|
||||||
eval $LIB32PFX ./magiskboot --cpio ramdisk.cpio restore
|
./magiskboot --cpio ramdisk.cpio restore
|
||||||
cp -af ramdisk.cpio ramdisk.cpio.orig
|
cp -af ramdisk.cpio ramdisk.cpio.orig
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -156,9 +156,9 @@ fi
|
|||||||
|
|
||||||
ui_print "- Patching ramdisk"
|
ui_print "- Patching ramdisk"
|
||||||
|
|
||||||
eval $LIB32PFX ./magiskboot --cpio ramdisk.cpio \
|
./magiskboot --cpio ramdisk.cpio \
|
||||||
\"add 750 init magiskinit\" \
|
"add 750 init magiskinit" \
|
||||||
\"magisk ramdisk.cpio.orig $HIGHCOMP $KEEPVERITY $KEEPFORCEENCRYPT $SHA1\"
|
"magisk ramdisk.cpio.orig $HIGHCOMP $KEEPVERITY $KEEPFORCEENCRYPT $SHA1"
|
||||||
|
|
||||||
rm -f ramdisk.cpio.orig
|
rm -f ramdisk.cpio.orig
|
||||||
|
|
||||||
@ -167,17 +167,17 @@ rm -f ramdisk.cpio.orig
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
if ! $KEEPVERITY && [ -f dtb ]; then
|
if ! $KEEPVERITY && [ -f dtb ]; then
|
||||||
eval $LIB32PFX ./magiskboot --dtb-patch dtb && ui_print "- Patching fstab in dtb to remove dm-verity"
|
./magiskboot --dtb-patch dtb && ui_print "- Patching fstab in dtb to remove dm-verity"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f kernel ]; then
|
if [ -f kernel ]; then
|
||||||
# Remove Samsung RKP in stock kernel
|
# Remove Samsung RKP in stock kernel
|
||||||
eval $LIB32PFX ./magiskboot --hexpatch kernel \
|
./magiskboot --hexpatch kernel \
|
||||||
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054 \
|
||||||
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
||||||
|
|
||||||
# skip_initramfs -> want_initramfs
|
# skip_initramfs -> want_initramfs
|
||||||
eval $LIB32PFX ./magiskboot --hexpatch kernel \
|
./magiskboot --hexpatch kernel \
|
||||||
736B69705F696E697472616D6673 \
|
736B69705F696E697472616D6673 \
|
||||||
77616E745F696E697472616D6673
|
77616E745F696E697472616D6673
|
||||||
fi
|
fi
|
||||||
@ -187,9 +187,9 @@ fi
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
ui_print "- Repacking boot image"
|
ui_print "- Repacking boot image"
|
||||||
eval $LIB32PFX ./magiskboot --repack "$BOOTIMAGE" || abort "! Unable to repack boot image!"
|
./magiskboot --repack "$BOOTIMAGE" || abort "! Unable to repack boot image!"
|
||||||
|
|
||||||
# Sign chromeos boot
|
# Sign chromeos boot
|
||||||
$CHROMEOS && sign_chromeos
|
$CHROMEOS && sign_chromeos
|
||||||
|
|
||||||
eval $LIB32PFX ./magiskboot --cleanup
|
./magiskboot --cleanup
|
||||||
|
@ -45,7 +45,7 @@ cd $MAGISKBIN
|
|||||||
ui_print "- Found Boot Image: $BOOTIMAGE"
|
ui_print "- Found Boot Image: $BOOTIMAGE"
|
||||||
|
|
||||||
ui_print "- Unpacking boot image"
|
ui_print "- Unpacking boot image"
|
||||||
eval $LIB32PFX ./magiskboot --unpack "$BOOTIMAGE"
|
./magiskboot --unpack "$BOOTIMAGE"
|
||||||
CHROMEOS=false
|
CHROMEOS=false
|
||||||
|
|
||||||
case $? in
|
case $? in
|
||||||
@ -67,7 +67,7 @@ esac
|
|||||||
|
|
||||||
# Detect boot image state
|
# Detect boot image state
|
||||||
ui_print "- Checking ramdisk status"
|
ui_print "- Checking ramdisk status"
|
||||||
eval $LIB32PFX ./magiskboot --cpio ramdisk.cpio test
|
./magiskboot --cpio ramdisk.cpio test
|
||||||
case $? in
|
case $? in
|
||||||
0 ) # Stock boot
|
0 ) # Stock boot
|
||||||
ui_print "- Stock boot image detected"
|
ui_print "- Stock boot image detected"
|
||||||
@ -76,14 +76,14 @@ case $? in
|
|||||||
1|2 ) # Magisk patched
|
1|2 ) # Magisk patched
|
||||||
ui_print "- Magisk patched image detected"
|
ui_print "- Magisk patched image detected"
|
||||||
# Find SHA1 of stock boot image
|
# Find SHA1 of stock boot image
|
||||||
[ -z $SHA1 ] && SHA1=`eval $LIB32PFX ./magiskboot --cpio ramdisk.cpio sha1 2>/dev/null`
|
[ -z $SHA1 ] && SHA1=`./magiskboot --cpio ramdisk.cpio sha1 2>/dev/null`
|
||||||
OK=false
|
OK=false
|
||||||
[ ! -z $SHA1 ] && restore_imgs $SHA1 && OK=true
|
[ ! -z $SHA1 ] && restore_imgs $SHA1 && OK=true
|
||||||
if ! $OK; then
|
if ! $OK; then
|
||||||
ui_print "! Boot image backup unavailable"
|
ui_print "! Boot image backup unavailable"
|
||||||
ui_print "- Restoring ramdisk with internal backup"
|
ui_print "- Restoring ramdisk with internal backup"
|
||||||
eval $LIB32PFX ./magiskboot --cpio ramdisk.cpio restore
|
./magiskboot --cpio ramdisk.cpio restore
|
||||||
eval $LIB32PFX ./magiskboot --repack $BOOTIMAGE
|
./magiskboot --repack $BOOTIMAGE
|
||||||
# Sign chromeos boot
|
# Sign chromeos boot
|
||||||
$CHROMEOS && sign_chromeos
|
$CHROMEOS && sign_chromeos
|
||||||
flash_boot_image new-boot.img "$BOOTIMAGE"
|
flash_boot_image new-boot.img "$BOOTIMAGE"
|
||||||
|
@ -20,7 +20,7 @@ MAGISKBIN=/data/adb/magisk
|
|||||||
[ -z $MOUNTPATH ] && MOUNTPATH=/sbin/.core/img
|
[ -z $MOUNTPATH ] && MOUNTPATH=/sbin/.core/img
|
||||||
[ -z $IMG ] && IMG=/data/adb/magisk.img
|
[ -z $IMG ] && IMG=/data/adb/magisk.img
|
||||||
|
|
||||||
BOOTSIGNER="eval \$LIBPFX /system/bin/dalvikvm -Xnodex2oat -Xnoimage-dex2oat -cp \$APK com.topjohnwu.magisk.utils.BootSigner"
|
BOOTSIGNER="/system/bin/dalvikvm -Xnodex2oat -Xnoimage-dex2oat -cp \$APK com.topjohnwu.magisk.utils.BootSigner"
|
||||||
BOOTSIGNED=false
|
BOOTSIGNED=false
|
||||||
|
|
||||||
get_outfd() {
|
get_outfd() {
|
||||||
@ -128,15 +128,15 @@ find_boot_image() {
|
|||||||
run_migrations() {
|
run_migrations() {
|
||||||
# Update the broken boot backup
|
# Update the broken boot backup
|
||||||
if [ -f /data/stock_boot_.img.gz ]; then
|
if [ -f /data/stock_boot_.img.gz ]; then
|
||||||
eval $LIB32PFX $MAGISKBIN/magiskboot --decompress /data/stock_boot_.img.gz /data/stock_boot.img
|
$MAGISKBIN/magiskboot --decompress /data/stock_boot_.img.gz /data/stock_boot.img
|
||||||
fi
|
fi
|
||||||
# Update our previous backup to new format if exists
|
# Update our previous backup to new format if exists
|
||||||
if [ -f /data/stock_boot.img ]; then
|
if [ -f /data/stock_boot.img ]; then
|
||||||
ui_print "- Migrating boot image backup"
|
ui_print "- Migrating boot image backup"
|
||||||
SHA1=`eval $LIB32PFX $MAGISKBIN/magiskboot --sha1 /data/stock_boot.img 2>/dev/null`
|
SHA1=`$MAGISKBIN/magiskboot --sha1 /data/stock_boot.img 2>/dev/null`
|
||||||
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
||||||
mv /data/stock_boot.img $STOCKDUMP
|
mv /data/stock_boot.img $STOCKDUMP
|
||||||
eval $LIB32PFX $MAGISKBIN/magiskboot --compress $STOCKDUMP
|
$MAGISKBIN/magiskboot --compress $STOCKDUMP
|
||||||
fi
|
fi
|
||||||
# Move the stock backups
|
# Move the stock backups
|
||||||
if [ -f /data/magisk/stock_boot* ]; then
|
if [ -f /data/magisk/stock_boot* ]; then
|
||||||
@ -154,7 +154,7 @@ run_migrations() {
|
|||||||
|
|
||||||
flash_boot_image() {
|
flash_boot_image() {
|
||||||
# Make sure all blocks are writable
|
# Make sure all blocks are writable
|
||||||
eval $LIB32PFX $MAGISKBIN/magisk --unlock-blocks 2>/dev/null
|
$MAGISKBIN/magisk --unlock-blocks 2>/dev/null
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*.gz) COMMAND="gzip -d < '$1'";;
|
*.gz) COMMAND="gzip -d < '$1'";;
|
||||||
*) COMMAND="cat '$1'";;
|
*) COMMAND="cat '$1'";;
|
||||||
@ -184,11 +184,11 @@ find_dtbo_image() {
|
|||||||
|
|
||||||
patch_dtbo_image() {
|
patch_dtbo_image() {
|
||||||
if [ ! -z $DTBOIMAGE ]; then
|
if [ ! -z $DTBOIMAGE ]; then
|
||||||
if eval $LIB32PFX $MAGISKBIN/magiskboot --dtb-test $DTBOIMAGE; then
|
if $MAGISKBIN/magiskboot --dtb-test $DTBOIMAGE; then
|
||||||
ui_print "- Backing up stock dtbo image"
|
ui_print "- Backing up stock dtbo image"
|
||||||
eval $LIB32PFX $MAGISKBIN/magiskboot --compress $DTBOIMAGE $MAGISKBIN/stock_dtbo.img.gz
|
$MAGISKBIN/magiskboot --compress $DTBOIMAGE $MAGISKBIN/stock_dtbo.img.gz
|
||||||
ui_print "- Patching fstab in dtbo to remove avb-verity"
|
ui_print "- Patching fstab in dtbo to remove avb-verity"
|
||||||
eval $LIB32PFX $MAGISKBIN/magiskboot --dtb-patch $DTBOIMAGE
|
$MAGISKBIN/magiskboot --dtb-patch $DTBOIMAGE
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -200,7 +200,7 @@ restore_imgs() {
|
|||||||
STOCKDTBO=/data/stock_dtbo.img.gz
|
STOCKDTBO=/data/stock_dtbo.img.gz
|
||||||
|
|
||||||
# Make sure all blocks are writable
|
# Make sure all blocks are writable
|
||||||
eval $LIB32PFX $MAGISKBIN/magisk --unlock-blocks 2>/dev/null
|
$MAGISKBIN/magisk --unlock-blocks 2>/dev/null
|
||||||
find_dtbo_image
|
find_dtbo_image
|
||||||
if [ ! -z "$DTBOIMAGE" -a -f "$STOCKDTBO" ]; then
|
if [ ! -z "$DTBOIMAGE" -a -f "$STOCKDTBO" ]; then
|
||||||
ui_print "- Restoring stock dtbo image"
|
ui_print "- Restoring stock dtbo image"
|
||||||
@ -220,7 +220,7 @@ sign_chromeos() {
|
|||||||
ui_print "- Signing ChromeOS boot image"
|
ui_print "- Signing ChromeOS boot image"
|
||||||
|
|
||||||
echo > empty
|
echo > empty
|
||||||
eval $LIBPFX ./chromeos/futility vbutil_kernel --pack new-boot.img.signed \
|
./chromeos/futility vbutil_kernel --pack new-boot.img.signed \
|
||||||
--keyblock ./chromeos/kernel.keyblock --signprivate ./chromeos/kernel_data_key.vbprivk \
|
--keyblock ./chromeos/kernel.keyblock --signprivate ./chromeos/kernel_data_key.vbprivk \
|
||||||
--version 1 --vmlinuz new-boot.img --config empty --arch arm --bootloader empty --flags 0x1
|
--version 1 --vmlinuz new-boot.img --config empty --arch arm --bootloader empty --flags 0x1
|
||||||
|
|
||||||
@ -296,14 +296,18 @@ recovery_actions() {
|
|||||||
fi
|
fi
|
||||||
# Temporarily block out all custom recovery binaries/libs
|
# Temporarily block out all custom recovery binaries/libs
|
||||||
mv /sbin /sbin_tmp
|
mv /sbin /sbin_tmp
|
||||||
# Set library paths
|
# Unset library paths
|
||||||
$IS64BIT && LIBPFX="LD_LIBRARY_PATH=/system/lib64:/system/vendor/lib64" || LIBPFX="LD_LIBRARY_PATH=/system/lib:/system/vendor/lib"
|
OLD_LD_LIB=$LD_LIBRARY_PATH
|
||||||
LIB32PFX="LD_LIBRARY_PATH=/system/lib:/system/vendor/lib"
|
OLD_LD_PRE=$LD_PRELOAD
|
||||||
|
unset LD_LIBRARY_PATH
|
||||||
|
unset LD_PRELOAD
|
||||||
}
|
}
|
||||||
|
|
||||||
recovery_cleanup() {
|
recovery_cleanup() {
|
||||||
mv /sbin_tmp /sbin 2>/dev/null
|
mv /sbin_tmp /sbin 2>/dev/null
|
||||||
[ -z $OLD_PATH ] || export PATH=$OLD_PATH
|
[ -z $OLD_PATH ] || export PATH=$OLD_PATH
|
||||||
|
[ -z $OLD_LD_LIB ] || export LD_LIBRARY_PATH=$OLD_LD_LIB
|
||||||
|
[ -z $OLD_LD_PRE ] || export LD_PRELOAD=$OLD_LD_PRE
|
||||||
ui_print "- Unmounting partitions"
|
ui_print "- Unmounting partitions"
|
||||||
umount -l /system_root 2>/dev/null
|
umount -l /system_root 2>/dev/null
|
||||||
umount -l /system 2>/dev/null
|
umount -l /system 2>/dev/null
|
||||||
@ -348,7 +352,7 @@ request_zip_size_check() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
image_size_check() {
|
image_size_check() {
|
||||||
SIZE="`eval $LIB32PFX $MAGISKBIN/magisk --imgsize $IMG`"
|
SIZE="`$MAGISKBIN/magisk --imgsize $IMG`"
|
||||||
curUsedM=`echo "$SIZE" | cut -d" " -f1`
|
curUsedM=`echo "$SIZE" | cut -d" " -f1`
|
||||||
curSizeM=`echo "$SIZE" | cut -d" " -f2`
|
curSizeM=`echo "$SIZE" | cut -d" " -f2`
|
||||||
curFreeM=$((curSizeM - curUsedM))
|
curFreeM=$((curSizeM - curUsedM))
|
||||||
@ -362,28 +366,28 @@ mount_magisk_img() {
|
|||||||
if [ "$reqSizeM" -gt "$curFreeM" ]; then
|
if [ "$reqSizeM" -gt "$curFreeM" ]; then
|
||||||
newSizeM=$(((reqSizeM + curUsedM) / 32 * 32 + 64))
|
newSizeM=$(((reqSizeM + curUsedM) / 32 * 32 + 64))
|
||||||
ui_print "- Resizing $IMG to ${newSizeM}M"
|
ui_print "- Resizing $IMG to ${newSizeM}M"
|
||||||
eval $LIB32PFX $MAGISKBIN/magisk --resizeimg $IMG $newSizeM >&2
|
$MAGISKBIN/magisk --resizeimg $IMG $newSizeM >&2
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
newSizeM=$((reqSizeM / 32 * 32 + 64));
|
newSizeM=$((reqSizeM / 32 * 32 + 64));
|
||||||
ui_print "- Creating $IMG with size ${newSizeM}M"
|
ui_print "- Creating $IMG with size ${newSizeM}M"
|
||||||
eval $LIB32PFX $MAGISKBIN/magisk --createimg $IMG $newSizeM >&2
|
$MAGISKBIN/magisk --createimg $IMG $newSizeM >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ui_print "- Mounting $IMG to $MOUNTPATH"
|
ui_print "- Mounting $IMG to $MOUNTPATH"
|
||||||
MAGISKLOOP=`eval $LIB32PFX $MAGISKBIN/magisk --mountimg $IMG $MOUNTPATH`
|
MAGISKLOOP=`$MAGISKBIN/magisk --mountimg $IMG $MOUNTPATH`
|
||||||
is_mounted $MOUNTPATH || abort "! $IMG mount failed..."
|
is_mounted $MOUNTPATH || abort "! $IMG mount failed..."
|
||||||
}
|
}
|
||||||
|
|
||||||
unmount_magisk_img() {
|
unmount_magisk_img() {
|
||||||
eval $LIB32PFX $MAGISKBIN/magisk --umountimg $MOUNTPATH $MAGISKLOOP
|
$MAGISKBIN/magisk --umountimg $MOUNTPATH $MAGISKLOOP
|
||||||
|
|
||||||
# Shrink the image if possible
|
# Shrink the image if possible
|
||||||
image_size_check $IMG
|
image_size_check $IMG
|
||||||
newSizeM=$((curUsedM / 32 * 32 + 64))
|
newSizeM=$((curUsedM / 32 * 32 + 64))
|
||||||
if [ $curSizeM -gt $newSizeM ]; then
|
if [ $curSizeM -gt $newSizeM ]; then
|
||||||
ui_print "- Shrinking $IMG to ${newSizeM}M"
|
ui_print "- Shrinking $IMG to ${newSizeM}M"
|
||||||
eval $LIB32PFX $MAGISKBIN/magisk --resizeimg $IMG $newSizeM
|
$MAGISKBIN/magisk --resizeimg $IMG $newSizeM
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user