Find boot image with MagiskInstaller

Fix #8211
This commit is contained in:
topjohnwu
2024-10-07 16:52:35 -07:00
parent 7188de1205
commit e1b847fbc5
4 changed files with 68 additions and 49 deletions

View File

@ -2,10 +2,14 @@
# Magisk app internal scripts
##################################
# $1 = delay
# $2 = command
run_delay() {
(sleep $1; $2)&
}
# $1 = version string
# $2 = version code
env_check() {
for file in busybox magiskboot magiskinit util_functions.sh boot_patch.sh; do
[ -f "$MAGISKBIN/$file" ] || return 1
@ -21,6 +25,8 @@ env_check() {
return 0
}
# $1 = dir to copy
# $2 = destination (optional)
cp_readlink() {
if [ -z $2 ]; then
cd $1
@ -39,6 +45,7 @@ cp_readlink() {
cd /
}
# $1 = install dir
fix_env() {
# Cleanup and make dirs
rm -rf $MAGISKBIN/*
@ -49,6 +56,8 @@ fix_env() {
chown -R 0:0 $MAGISKBIN
}
# $1 = install dir
# $2 = boot partition
direct_install() {
echo "- Flashing new boot image"
flash_image $1/new-boot.img $2
@ -70,6 +79,7 @@ direct_install() {
return 0
}
# $1 = uninstaller zip
run_uninstaller() {
rm -rf /dev/tmp
mkdir -p /dev/tmp/install
@ -77,24 +87,16 @@ run_uninstaller() {
INSTALLER=/dev/tmp/install sh /dev/tmp/install/assets/uninstaller.sh dummy 1 "$1"
}
# $1 = boot partition
restore_imgs() {
local SHA1=$(grep_prop SHA1 $MAGISKTMP/.magisk/config)
local BACKUPDIR=/data/magisk_backup_$SHA1
[ -d $BACKUPDIR ] || return 1
get_flags
find_boot_image
for name in dtb dtbo; do
[ -f $BACKUPDIR/${name}.img.gz ] || continue
local IMAGE=$(find_block $name$SLOT)
[ -z $IMAGE ] && continue
flash_image $BACKUPDIR/${name}.img.gz $IMAGE
done
[ -f $BACKUPDIR/boot.img.gz ] || return 1
flash_image $BACKUPDIR/boot.img.gz $BOOTIMAGE
flash_image $BACKUPDIR/boot.img.gz $1
}
# $1 = path to bootctl executable
post_ota() {
cd /data/adb
cp -f $1 bootctl
@ -131,6 +133,8 @@ EOF
cd /
}
# $1 = APK
# $2 = package name
adb_pm_install() {
local tmp=/data/local/tmp/temp.apk
cp -f "$1" $tmp