diff --git a/Magisk-v24.3/magisk32 b/Magisk-v24.3/magisk32 deleted file mode 100755 index 8b6d754..0000000 Binary files a/Magisk-v24.3/magisk32 and /dev/null differ diff --git a/Magisk-v24.3/magisk64 b/Magisk-v24.3/magisk64 deleted file mode 100755 index 54c7d69..0000000 Binary files a/Magisk-v24.3/magisk64 and /dev/null differ diff --git a/Magisk-v24.3/magiskboot b/Magisk-v24.3/magiskboot deleted file mode 100755 index 507de38..0000000 Binary files a/Magisk-v24.3/magiskboot and /dev/null differ diff --git a/Magisk-v24.3/magiskinit b/Magisk-v24.3/magiskinit deleted file mode 100755 index 1191c69..0000000 Binary files a/Magisk-v24.3/magiskinit and /dev/null differ diff --git a/Magisk-v24.3/boot_patch.sh b/Magisk-v25.2/boot_patch.sh similarity index 94% rename from Magisk-v24.3/boot_patch.sh rename to Magisk-v25.2/boot_patch.sh index 37a2247..c334e8d 100755 --- a/Magisk-v24.3/boot_patch.sh +++ b/Magisk-v25.2/boot_patch.sh @@ -111,7 +111,7 @@ if [ -e ramdisk.cpio ]; then ./magiskboot cpio ramdisk.cpio test STATUS=$? else - # Stock A only system-as-root + # Stock A only legacy SAR, or some Android 13 GKIs STATUS=0 fi case $((STATUS & 3)) in @@ -183,7 +183,15 @@ rm -f ramdisk.cpio.orig config magisk*.xz ################# for dt in dtb kernel_dtb extra; do - [ -f $dt ] && ./magiskboot dtb $dt patch && ui_print "- Patch fstab in $dt" + if [ -f $dt ]; then + if ! ./magiskboot dtb $dt test; then + ui_print "! Boot image $dt was patched by old (unsupported) Magisk" + abort "! Please try again with *unpatched* boot image" + fi + if ./magiskboot dtb $dt patch; then + ui_print "- Patch fstab in boot image $dt" + fi + fi done if [ -f kernel ]; then diff --git a/Magisk-v25.2/magisk32 b/Magisk-v25.2/magisk32 new file mode 100755 index 0000000..df25437 Binary files /dev/null and b/Magisk-v25.2/magisk32 differ diff --git a/Magisk-v25.2/magisk64 b/Magisk-v25.2/magisk64 new file mode 100755 index 0000000..b667d2e Binary files /dev/null and b/Magisk-v25.2/magisk64 differ diff --git a/Magisk-v25.2/magiskboot b/Magisk-v25.2/magiskboot new file mode 100755 index 0000000..23427b3 Binary files /dev/null and b/Magisk-v25.2/magiskboot differ diff --git a/Magisk-v25.2/magiskinit b/Magisk-v25.2/magiskinit new file mode 100755 index 0000000..6dd9b85 Binary files /dev/null and b/Magisk-v25.2/magiskinit differ diff --git a/Magisk-v24.3/util_functions.sh b/Magisk-v25.2/util_functions.sh similarity index 96% rename from Magisk-v24.3/util_functions.sh rename to Magisk-v25.2/util_functions.sh index 098c690..12c0253 100755 --- a/Magisk-v24.3/util_functions.sh +++ b/Magisk-v25.2/util_functions.sh @@ -2,8 +2,8 @@ # Magisk General Utility Functions ############################################ -MAGISK_VER='24.3' -MAGISK_VER_CODE=24300 +MAGISK_VER='25.2' +MAGISK_VER_CODE=25200 ################### # Helper Functions @@ -292,6 +292,13 @@ mount_partitions() { # Allow /system/bin commands (dalvikvm) on Android 10+ in recovery $BOOTMODE || mount_apex + + # Mount sepolicy rules dir locations in recovery (best effort) + if ! $BOOTMODE; then + mount_name "cache cac" /cache + mount_name metadata /metadata + mount_name persist /persist + fi } # loop_setup , sets LOOPDEV @@ -410,7 +417,7 @@ get_flags() { PATCHVBMETAFLAG=false else PATCHVBMETAFLAG=true - ui_print "- Cannot find vbmeta partition, patch vbmeta in boot image" + ui_print "- No vbmeta partition, patch vbmeta in boot image" fi fi [ -z $RECOVERYMODE ] && RECOVERYMODE=false @@ -574,16 +581,13 @@ check_data() { find_magisk_apk() { local DBAPK - [ -z $APK ] && APK=$NVBASE/magisk.apk - [ -f $APK ] || APK=$MAGISKBIN/magisk.apk - [ -f $APK ] || APK=/data/app/com.topjohnwu.magisk*/*.apk - [ -f $APK ] || APK=/data/app/*/com.topjohnwu.magisk*/*.apk + [ -z $APK ] && APK=/data/app/com.topjohnwu.magisk*/base.apk + [ -f $APK ] || APK=/data/app/*/com.topjohnwu.magisk*/base.apk if [ ! -f $APK ]; then DBAPK=$(magisk --sqlite "SELECT value FROM strings WHERE key='requester'" 2>/dev/null | cut -d= -f2) [ -z $DBAPK ] && DBAPK=$(strings $NVBASE/magisk.db | grep -oE 'requester..*' | cut -c10-) - [ -z $DBAPK ] || APK=/data/user_de/*/$DBAPK/dyn/*.apk - [ -f $APK ] || [ -z $DBAPK ] || APK=/data/app/$DBAPK*/*.apk - [ -f $APK ] || [ -z $DBAPK ] || APK=/data/app/*/$DBAPK*/*.apk + [ -z $DBAPK ] || APK=/data/user_de/0/$DBAPK/dyn/current.apk + [ -f $APK ] || [ -z $DBAPK ] || APK=/data/data/$DBAPK/dyn/current.apk fi [ -f $APK ] || ui_print "! Unable to detect Magisk app APK for BootSigner" } @@ -651,9 +655,9 @@ copy_sepolicy_rules() { fi if [ -d ${RULESDIR%/magisk} ]; then - ui_print "- Sepolicy rules dir is ${RULESDIR%/magisk}" + echo "RULESDIR=$RULESDIR" >&2 else - ui_print "- Sepolicy rules dir ${RULESDIR%/magisk} not found" + ui_print "- Unable to find sepolicy rules dir ${RULESDIR%/magisk}" return 1 fi @@ -716,6 +720,7 @@ is_legacy_script() { install_module() { rm -rf $TMPDIR mkdir -p $TMPDIR + chcon u:object_r:system_file:s0 $TMPDIR cd $TMPDIR setup_flashable @@ -810,7 +815,7 @@ install_module() { rm -rf \ $MODPATH/system/placeholder $MODPATH/customize.sh \ $MODPATH/README.md $MODPATH/.git* - rmdir -p $MODPATH + rmdir -p $MODPATH 2>/dev/null cd / $BOOTMODE || recovery_cleanup @@ -832,7 +837,7 @@ NVBASE=/data/adb TMPDIR=/dev/tmp # Bootsigner related stuff -BOOTSIGNERCLASS=com.topjohnwu.signing.SignBoot +BOOTSIGNERCLASS=com.topjohnwu.magisk.signing.SignBoot BOOTSIGNER='/system/bin/dalvikvm -Xnoimage-dex2oat -cp $APK $BOOTSIGNERCLASS' BOOTSIGNED=false diff --git a/README.md b/README.md index 4a9c4f8..307d2b6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ It has been made to run on Linux x86 or x64 and patch a boot image for an ARM de It detects LineageOS **for microG** version via adb, download the ROM, extracts `payload.bin` and dumps `boot.img`, patches it with Magisk, and flashes it. -:warning: **This has only been tested on a FP3 device, at the time of writing with LineageOS for microG 18.1 (March 17, 2022 build) Magisk v24.3** :warning: +:warning: **This has only been tested on a FP3 device, at the time of writing with LineageOS for microG 19.1 (August 23, 2022 build) Magisk v25.2** :warning: ## Run on an other device @@ -55,7 +55,7 @@ Run `python magisk_boot_flasher.py`. That's how we can run Magisk's `boot_patch.sh` on Linux x86 or x64 and patch a boot image for an ARM device -> Tested with Magisk v24.3 with FP3 +> Tested with Magisk v25.2 with FP3 * Get Magisk `.apk` * Extract it @@ -78,4 +78,3 @@ You can now run: `sh boot_patch.sh boot.img` The outpout file `new-boot.img` has the exact same sha256 hash as the `magisk_patched-*.img`, so we can consider it works :) - diff --git a/magisk_boot_flasher.py b/magisk_boot_flasher.py index 3d04984..344c475 100644 --- a/magisk_boot_flasher.py +++ b/magisk_boot_flasher.py @@ -7,7 +7,7 @@ import subprocess import time device = 'FP3' -magiskdir = 'Magisk-v24.3' +magiskdir = 'Magisk-v25.2' def yes_or_no(question, default=None): @@ -119,10 +119,15 @@ def rebootToBootloader(): def flashBoot(): + ''' currentSlot = getCurrentSlot() cmd = ['fastboot', 'flash', f'boot_{currentSlot}', f'{magiskdir}/new-boot.img'] - subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) + ''' + for slot in 'ab': + cmd = ['fastboot', 'flash', f'boot_{slot}', + f'{magiskdir}/new-boot.img'] + subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) def getCurrentSlot():