Refactor adb patching and emulator setup

Add support for patching boot images directly via adb
with the build.py script.
This commit is contained in:
topjohnwu
2026-09-21 01:40:07 -07:00
parent 89d3100ffc
commit aed0261c3d
8 changed files with 123 additions and 91 deletions
+37
View File
@@ -0,0 +1,37 @@
#####################################################################
# ADB Magisk Boot Image Patcher
#####################################################################
#
# With a device accessible via ADB, usage:
# ./build.py patch path/to/boot.img
#
#####################################################################
if [ ! -f /system/build.prop ]; then
# Running on PC
echo 'Please run `./build.py patch` instead of directly executing the script!'
exit 1
fi
cd /data/local/tmp
chmod 755 busybox magisk*
if [ -z "$FIRST_STAGE" ]; then
export FIRST_STAGE=1
export ASH_STANDALONE=1
# Re-exec script with busybox
exec ./busybox sh $0 "$@"
fi
TARGET_FILE="$1"
OUTPUT_FILE="$1.magisk"
# Fetch env flags using non-root functions in app_functions
. ./app_functions.sh
mount_partitions
get_flags
# Patch the boot image to the target path
sh boot_patch.sh $TARGET_FILE
mv new-boot.img $OUTPUT_FILE
./magiskboot cleanup