diff --git a/build.py b/build.py index 0f271c774..8074a2560 100755 --- a/build.py +++ b/build.py @@ -460,14 +460,17 @@ def setup_ndk(args): def setup_avd(args): if not args.skip: - args.release = False build_all(args) header('* Setting up emulator') abi = cmd_out([adb_path, 'shell', 'getprop', 'ro.product.cpu.abi']) - proc = execv([adb_path, 'push', f'native/out/{abi}/busybox', 'out/app-debug.apk', - 'scripts/avd_magisk.sh', '/data/local/tmp']) + proc = execv([adb_path, 'push', f'native/out/{abi}/busybox', 'scripts/avd_magisk.sh', '/data/local/tmp']) + if proc.returncode != 0: + error('adb push failed!') + + apk = 'out/app-release.apk' if args.release else 'out/app-debug.apk' + proc = execv([adb_path, 'push', apk, '/data/local/tmp/magisk.apk']) if proc.returncode != 0: error('adb push failed!') @@ -501,10 +504,15 @@ def patch_avd_ramdisk(args): f.write(adv_ft) abi = cmd_out([adb_path, 'shell', 'getprop', 'ro.product.cpu.abi']) - proc = execv([adb_path, 'push', f'native/out/{abi}/busybox', 'out/app-debug.apk', - 'scripts/avd_patch.sh', '/data/local/tmp']) + proc = execv([adb_path, 'push', f'native/out/{abi}/busybox', 'scripts/avd_patch.sh', '/data/local/tmp']) if proc.returncode != 0: error('adb push failed!') + + apk = 'out/app-release.apk' if args.release else 'out/app-debug.apk' + proc = execv([adb_path, 'push', apk, '/data/local/tmp/magisk.apk']) + if proc.returncode != 0: + error('adb push failed!') + proc = execv([adb_path, 'push', backup, '/data/local/tmp/ramdisk.cpio.tmp']) if proc.returncode != 0: error('adb push failed!') diff --git a/scripts/avd_magisk.sh b/scripts/avd_magisk.sh index a98219d98..d8b65471a 100755 --- a/scripts/avd_magisk.sh +++ b/scripts/avd_magisk.sh @@ -3,8 +3,7 @@ # AVD Magisk Setup ##################################################################### # -# Support emulator ABI: ALL -# Support API level: 23 - 31 (21 and 22 images do not have SELinux) +# Support API level: 21 - 33 # # With an emulator booted and accessible via ADB, usage: # ./build.py emulator @@ -46,15 +45,15 @@ if [ -z "$FIRST_STAGE" ]; then fi fi -pm install -r $(pwd)/app-debug.apk +pm install -r $(pwd)/magisk.apk # Extract files from APK -unzip -oj app-debug.apk 'assets/util_functions.sh' +unzip -oj magisk.apk 'assets/util_functions.sh' . ./util_functions.sh api_level_arch_detect -unzip -oj app-debug.apk "lib/$ABI/*" "lib/$ABI32/libmagisk32.so" -x "lib/$ABI/libbusybox.so" +unzip -oj magisk.apk "lib/$ABI/*" "lib/$ABI32/libmagisk32.so" -x "lib/$ABI/libbusybox.so" for file in lib*.so; do chmod 755 $file mv "$file" "${file:3:${#file}-6}" @@ -120,8 +119,7 @@ fi # Magisk stuff mkdir -p $MAGISKBIN 2>/dev/null -unzip -oj app-debug.apk 'assets/*' -x 'assets/chromeos/*' \ --x 'assets/bootctl' -x 'assets/main.jar' -d $MAGISKBIN +unzip -oj magisk.apk 'assets/*.sh' -d $MAGISKBIN mkdir $NVBASE/modules 2>/dev/null mkdir $POSTFSDATAD 2>/dev/null mkdir $SERVICED 2>/dev/null @@ -135,7 +133,7 @@ cp -af ./magiskboot $MAGISKBIN/magiskboot cp -af ./magiskinit $MAGISKBIN/magiskinit cp -af ./busybox $MAGISKBIN/busybox -if [ "$IS64BIT" = "true" ]; then +if $IS64BIT; then ln -s ./magisk64 $MAGISKTMP/magisk else ln -s ./magisk32 $MAGISKTMP/magisk diff --git a/scripts/avd_patch.sh b/scripts/avd_patch.sh index a1c625014..e787953ca 100644 --- a/scripts/avd_patch.sh +++ b/scripts/avd_patch.sh @@ -3,8 +3,7 @@ # AVD MagiskInit Setup ##################################################################### # -# Support emulator ABI: x86_64 and arm64 -# Support API level: 23 - 31 (21 and 22 images do not have SELinux) +# Support API level: 23 - 33 (21 and 22 images do not have SELinux) # # With an emulator booted and accessible via ADB, usage: # ./build.py avd_patch path/to/booted/avd-image/ramdisk.img @@ -24,7 +23,7 @@ # rootfs w/o early mount: API 23 - 25 # rootfs with early mount: API 26 - 27 # Legacy system-as-root: API 28 -# 2 stage init: API 29 - 31 +# 2 stage init: API 29 - 33 ##################################################################### if [ ! -f /system/build.prop ]; then @@ -44,12 +43,12 @@ if [ -z "$FIRST_STAGE" ]; then fi # Extract files from APK -unzip -oj app-debug.apk 'assets/util_functions.sh' +unzip -oj magisk.apk 'assets/util_functions.sh' . ./util_functions.sh api_level_arch_detect -unzip -oj app-debug.apk "lib/$ABI/*" "lib/$ABI32/libmagisk32.so" -x "lib/$ABI/libbusybox.so" +unzip -oj magisk.apk "lib/$ABI/*" "lib/$ABI32/libmagisk32.so" -x "lib/$ABI/libbusybox.so" for file in lib*.so; do chmod 755 $file mv "$file" "${file:3:${#file}-6}"