mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-15 18:30:21 +00:00
Do not modify system-images contents when patching
This commit is contained in:
@@ -34,7 +34,16 @@ if [ -z "$FIRST_STAGE" ]; then
|
||||
export FIRST_STAGE=1
|
||||
export ASH_STANDALONE=1
|
||||
# Re-exec script with busybox
|
||||
exec ./busybox sh $0
|
||||
exec ./busybox sh $0 "$@"
|
||||
fi
|
||||
|
||||
TARGET_FILE="$1"
|
||||
OUTPUT_FILE="$1.magisk"
|
||||
|
||||
if echo "$TARGET_FILE" | grep -q 'ramdisk'; then
|
||||
IS_RAMDISK=true
|
||||
else
|
||||
IS_RAMDISK=false
|
||||
fi
|
||||
|
||||
# Extract files from APK
|
||||
@@ -49,7 +58,11 @@ for file in lib*.so; do
|
||||
mv "$file" "${file:3:${#file}-6}"
|
||||
done
|
||||
|
||||
./magiskboot decompress ramdisk.cpio.tmp ramdisk.cpio
|
||||
if $IS_RAMDISK; then
|
||||
./magiskboot decompress "$TARGET_FILE" ramdisk.cpio
|
||||
else
|
||||
./magiskboot unpack "$TARGET_FILE"
|
||||
fi
|
||||
cp ramdisk.cpio ramdisk.cpio.orig
|
||||
|
||||
export KEEPVERITY=true
|
||||
@@ -78,4 +91,9 @@ cat config
|
||||
"add 000 .backup/.magisk config"
|
||||
|
||||
rm -f ramdisk.cpio.orig config magisk*.xz stub.xz
|
||||
./magiskboot compress=gzip ramdisk.cpio ramdisk.cpio.gz
|
||||
if $IS_RAMDISK; then
|
||||
./magiskboot compress=gzip ramdisk.cpio "$OUTPUT_FILE"
|
||||
else
|
||||
./magiskboot repack "$TARGET_FILE" "$OUTPUT_FILE"
|
||||
./magiskboot cleanup
|
||||
fi
|
||||
|
@@ -26,9 +26,7 @@ print_error() {
|
||||
cleanup() {
|
||||
print_error "! An error occurred when testing $pkg"
|
||||
|
||||
find $ANDROID_SDK_ROOT/system-images -name 'ramdisk.img' -exec cp -v {}.bak {} \; 2>/dev/null
|
||||
find $ANDROID_SDK_ROOT/system-images -name 'advancedFeatures.ini' -exec cp -v {}.bak {} \; 2>/dev/null
|
||||
|
||||
rm -f magisk_patched.img
|
||||
"$avd" delete avd -n test
|
||||
pkill -INT -P $$
|
||||
wait
|
||||
@@ -62,12 +60,6 @@ wait_for_boot() {
|
||||
done
|
||||
}
|
||||
|
||||
restore_backup() {
|
||||
if [ -f "${1}.bak" ]; then
|
||||
cp "${1}.bak" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
wait_emu() {
|
||||
local wait_fn=$1
|
||||
local which_pid
|
||||
@@ -195,8 +187,6 @@ run_test() {
|
||||
# Setup emulator
|
||||
"$sdk" --channel=3 $pkg
|
||||
echo no | "$avd" create avd -f -n test -k $pkg
|
||||
restore_backup $ramdisk
|
||||
restore_backup $features
|
||||
|
||||
# Launch stock emulator
|
||||
print_title "* Launching $pkg"
|
||||
@@ -204,14 +194,17 @@ run_test() {
|
||||
emu_pid=$!
|
||||
wait_emu wait_for_bootanim
|
||||
|
||||
# Update arguments for Magisk runs
|
||||
emu_args="$emu_args -ramdisk magisk_patched.img -feature -SystemAsRoot"
|
||||
|
||||
# Patch and test debug build
|
||||
./build.py avd_patch -s "$ramdisk"
|
||||
./build.py avd_patch -s "$ramdisk" magisk_patched.img
|
||||
kill -INT $emu_pid
|
||||
wait $emu_pid
|
||||
test_emu debug $api
|
||||
|
||||
# Re-patch and test release build
|
||||
./build.py -r avd_patch -s "$ramdisk"
|
||||
./build.py -r avd_patch -s "$ramdisk" magisk_patched.img
|
||||
kill -INT $emu_pid
|
||||
wait $emu_pid
|
||||
test_emu release $api
|
||||
@@ -219,8 +212,7 @@ run_test() {
|
||||
# Cleanup
|
||||
kill -INT $emu_pid
|
||||
wait $emu_pid
|
||||
restore_backup $ramdisk
|
||||
restore_backup $features
|
||||
rm -f magisk_patched.img
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
Reference in New Issue
Block a user