mirror of
https://github.com/topjohnwu/Magisk
synced 2025-09-02 08:45:15 +00:00
scripts: refactor and major addon.d fixes
- remove redundant addon.d.sh script bits that were covered elsewhere ($TMPDIR in util_functions.sh, find_dtbo_image in patch_dtbo_image) - refactor addon.d.sh and flash_script.sh for simplicity and readability, and put common flashing script in util_functions.sh (as patch_boot_image), which should greatly help avoid them getting out of sync going forward and fixes compressing ramdisk support and post-patch cleanup for addon.d - add check_data to addon.d.sh since moving stock_boot* and stock_dtbo* backups depend on it and so weren't occuring with addon.d - fix find_manager_apk with working fallback for recovery addon.d execution (where `magisk --sqlite` will not work for hidden Manager), Manager DynAPK hiding, and print a useful log warning if an APK can't be found
This commit is contained in:
@@ -293,6 +293,45 @@ patch_dtbo_image() {
|
||||
return 1
|
||||
}
|
||||
|
||||
patch_boot_image() {
|
||||
# Common installation script for flash_script.sh (updater-script) and addon.d.sh
|
||||
eval $BOOTSIGNER -verify < $BOOTIMAGE && BOOTSIGNED=true
|
||||
$BOOTSIGNED && ui_print "- Boot image is signed with AVB 1.0"
|
||||
|
||||
SOURCEDMODE=true
|
||||
cd $MAGISKBIN
|
||||
|
||||
$IS64BIT && mv -f magiskinit64 magiskinit 2>/dev/null || rm -f magiskinit64
|
||||
|
||||
# Source the boot patcher
|
||||
. ./boot_patch.sh "$BOOTIMAGE"
|
||||
|
||||
ui_print "- Flashing new boot image"
|
||||
|
||||
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
|
||||
rm -f /data/stock_boot* 2>/dev/null
|
||||
$DATA && mv stock_boot* /data
|
||||
fi
|
||||
|
||||
# Patch DTBO together with boot image
|
||||
$KEEPVERITY || patch_dtbo_image
|
||||
|
||||
if [ -f stock_dtbo* ]; then
|
||||
rm -f /data/stock_dtbo* 2>/dev/null
|
||||
$DATA && mv stock_dtbo* /data
|
||||
fi
|
||||
}
|
||||
|
||||
sign_chromeos() {
|
||||
ui_print "- Signing ChromeOS boot image"
|
||||
|
||||
@@ -360,13 +399,16 @@ check_data() {
|
||||
}
|
||||
|
||||
find_manager_apk() {
|
||||
APK=/data/adb/magisk.apk
|
||||
[ -z $APK ] && APK=/data/adb/magisk.apk
|
||||
[ -f $APK ] || APK=/data/magisk/magisk.apk
|
||||
[ -f $APK ] || APK=/data/app/com.topjohnwu.magisk*/*.apk
|
||||
if [ ! -f $APK ]; then
|
||||
DBAPK=`magisk --sqlite "SELECT value FROM strings WHERE key='requester'" | cut -d= -f2`
|
||||
[ -z "$DBAPK" ] || APK=/data/app/$DBAPK*/*.apk
|
||||
DBAPK=`magisk --sqlite "SELECT value FROM strings WHERE key='requester'" 2>/dev/null | cut -d= -f2`
|
||||
[ -z $DBAPK ] && DBAPK=`strings /data/adb/magisk.db | grep 5requester | cut -c11-`
|
||||
[ -z $DBAPK ] || APK=/data/user_de/*/$DBAPK/dyn/*.apk
|
||||
[ -f $APK ] || APK=/data/app/$DBAPK*/*.apk
|
||||
fi
|
||||
[ -f $APK ] || ui_print "! Unable to detect Magisk Manager APK for BootSigner"
|
||||
}
|
||||
|
||||
#################
|
||||
|
Reference in New Issue
Block a user