- previously this was failing a bit too spectacularly for my liking since $comp would erroneously get set to "fopen: ramdisk.cpio failed with 2: No such file or directory"
- on devices where there is no ramdisk.cpio unless rooted with Magisk this will indicate better to developers working on the device that they should be using "OG AK" mode to avoid trying to unpack a ramdisk which may or may not exist
- some apps copy the zip to be flashed to the app cache, which would result in the .tgz going either somewhere unknown/inaccessbile to the user or get deleted when the app cleans up after flash, so instead send to /sdcard if the device is booted to Android
- simplify rdtmp and $ramdisk creation and keep only in `unpack_ramdisk`
- fix `reset_ak` and `setup_ak` behavior if run before $block is set
- only save boot.img and boot-new.img in *-files subdirectories on multi-partition setups since otherwise the tmpfs (in recovery) and ext4 .img (when booted) size usage gets quickly out of hand
- fix slot_select=inactive when used with block=auto or block=boot partition detection
- the expected "cat: write error: No space left on device" gives a non-zero return code so always return true
- devices that flash dtbo abort since the return code would get passed back to the Backend and silently fail as the final command in anykernel.sh (via `write_boot`), so catch seperately with a proper error message for other image write methods
- some device recoveries (e.g. TWRP for wahoo) seem to have issues with the new `cat <image> /dev/zero > <block>` method of flashing, so allow setting customdd="bs=1048576" shell variable in anykernel.sh to work around this by reverting back to dd wipe+flash for dtbo as it does with boot
- abstract out execution directory as $home to fascilitate testing individual scripts (defaults to /tmp/anykernel)
- general script clean ups for uniformity, readability, speed and simplicity
- simplify consecutive `ui_print` commands where possible
Backend only fixes:
- use busybox umount and mount whenever possible to avoid linker warnings in stderr during system-as-root setup
- use `busybox --install -s` for bin/* setup
- consolidate setup to abort earlier if there are issues
- add backwards compatible symlinks for those who might not have updated their anykernel.sh with ak3-core.sh (to be renamed in subsequent commit)
Tools only fixes:
- add magiskboot to replace separate support for AOSP and PXA-AOSP formats, with MTK headers, BLOB, DHTB, SEAndroid and Nook signing
- add magiskpolicy to allow for easy sepolicy patching
- remove xz and lz4 since magiskboot supports these
AK3 Core only fixes:
- use full `ui_print` function implementation like the backend
- add `abort` function to simplify exit on errors
- fix $patch directory being excluded from `reset_ak`
- update $ramdisk_compression handling for magiskboot
- magiskboot also resolves long-standing request for built-in Bump support (#18)
- update Sony ELF and related support for initial repack as AOSP by using mkbootimg as plug-and-play optional add-in binary
- update Sony ELF MTK header support using mkmtkhdr only when ELF is initially unpacked by unpackelf
- add support for MTK RECOVERY ramdisk header type with Sony ELF
- simplify U-Boot dumpimage/mkimage and Sony ELF unpackelf/mkbootimg split_img file handling
- update patch_cmdline to handle both magiskboot as header prop file, and unpackelf or mboot as cmdline.txt
- use `cp -fp` for `backup_file` and `restore_file` to hopefully better preserve attributes if used outside of the ramdisk
- refactor setup into `setup_ak` to simplify `reset_ak` trigger to find slot and block again
- add fallback to busybox for compression formats (i.e. lzop) which magiskboot cannot handle
IMPORTANT NOTES:
1) forcing repack with uncompressed cpio ramdisk is not currently supported by magiskboot
2) forcing repack with lzop ramdisk when previously another format is not currently supported by magiskboot
- extend `reset_ak` with `reset_ak keep` which will keep files to be available to patch the other slot
- add optional slot_select=inactive shell variable to force inactive slot during slot detection
- AOSP has added --dtb, so to avoid conflicts *unpackbootimg and unpackelf have had what was previously dumped as *-dtb renamed to *-dt
- the same corresponds to any replacement version of these included in the zip root, i.e. they are now dt or dt.img for the old style from before hdr_v1, and dtb or dtb.img for the new style for hdr_v2
Note: You MUST update to the newer mkbootimg and unpackbootimg for this commit if you are using architectures other than the included ARM builds!
See AIK-mobile v3.5 for updated unpackelf, and mkbootimg/unpackbootimg binaries:
https://forum.xda-developers.com/showthread.php?t=2073775
- dd uses bs=512 by default, which is far from optimal for sequential reads.
Use bs=1048576(1M) for initial dump.
This improves read performance by a measurable amount.
- Zero-fill only the remaining blocks.
There's no need to zero-fill all blocks,
not to mention the additional/unnecessary wear and tear
to the flash storage.
Linux pipe uses bs=4096 by default. By using cat for this,
we additionally gain much better write performance.
On the OnePlus 6T, final write operation took 7.1 seconds in total with
2 consecutive dd commands. With cat, it now takes 0.08 seconds.
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
- some ROMs have taken it upon themselves to go against AOSP, i.e. where starting with Pie AOSP now versions it as only 9, some ROMs are still making it 9.0
- introduce integer 2 float function that will add a decimal place to all for comparisons
- this should support the majority of ROMs, but anything crazy like 9.0.0, or crazier like 09.0.0 should be frowned upon by the community and the ROM devs should be made to get it together and follow AOSP
- checks the supported.versions prop in anykernel.sh and matches against it to prevent users flashing incorrect kernels for ROM versions
- supported.versions can be a list, e.g. "7.1.2, 8.0, 8.1" or a range, e.g. "8.1 - 9" of versions in the correct formatting for that Android version in ro.build.version.release in /system/build.prop
- getprop failures are not only a system-as-root device issue, as it now also happens on OnePlus 5T in recovery when ROM is Pie Open Beta
- this appears to come down to a libc mismatch between recovery and ROM resulting in direct property checks failing but getprop without arguments printing all properties working
- revert most of https://github.com/osm0sis/AnyKernel2/commit/b1524da099efa716616a8eb3357876bca6a73540 since this should remain resolved with the new implementation
- keep the old check and file_getprop fallback for devices without getprop entirely
- add new getprop fallback that parses the full getprop output
- some custom ROMs on some devices (e.g. Lineage on Pocophone) bind mount modules in /system over modules on /vendor, so remount rw at the bind target to ensure the bind source is also remounted and replaced
- toybox mount doesn't accept the /. prefixed paths from find so ensure we use busybox for mounts
Thanks franciscofranco and topjohnwu for the tips!