Commit Graph
90 Commits
Author SHA1 Message Date
osm0sis c35c7ce358 AK3+Backend: /postinstall and opposite slot awareness for FlashAfterUpdate addon.d-v2 support
- for A/B OTAs my FlashAfterUpdate addon.d script requires the zip to know about addon.d-v2 and act accordingly
- signify support with #FLASHAFTERUPDATEV2 tag in updater-script to pass whitelist check since the majority of zips will not work correctly
2020-01-27 16:25:21 -04:00
osm0sis 03af96a541 Backend: fixes for mounting system on Lineage Recovery
- Lineage has a mindboggling: /system_root as mountpoint in ramdisk, neither /system nor /system_root in fstab (it has / instead, which is useless), ANDROID_ROOT=/system, and a possible symlink from /system to /system_root/system
- this failure to have a sensible, working fstab triggers the fallback to mounting directly from /dev/block/bootdevice which should exist on all modern devices which would need this SAR fallback
- add basic slot support for the fallback mount, since Lineage Recovery also doesn't make symlinks to the active slot partitions
2020-01-27 15:28:11 -04:00
osm0sis b772cca3ac Backend: put debugging down where it belongs too 2020-01-26 10:34:27 -04:00
osm0sis 062b44c75a Backend: work around ongoing TWRP SAR support fragmentation
TWRP now has 3(!) different competing implementations of SAR currently in use by maintainers:
1) /system as mountpoint in ramdisk/fstab and ANDROID_ROOT=/system, and possible symlink from /system_root to /system
2) /system_root as mountpoint in ramdisk/fstab, ANDROID_ROOT=/system_root, and possible symlink from /system to /system_root/system
3) /system_root as mountpoint in ramdisk/fstab, ANDROID_ROOT=/system, and possible symlink from /system to /system_root/system

Attempt to continue to accommodate this bullshit.
2020-01-24 14:54:39 -04:00
osm0sis be5c08b520 Backend: overdue clean up and refactor
- move checks to functions to isolate single-use variables as local
- signify globally available variables with capitalization
- move setup and mount to functions to mirror umount_all and restore_env
- cluster functions by use order (no call should preceed its function)
- use short circuit return tests to reduce indentation now that we use functions
2020-01-24 09:51:34 -04:00
osm0sis 7fb9efdb63 Backend: fix link restoration post-install 2020-01-21 06:16:45 -04:00
osm0sis b37d7e225f AK3+Backend: introduce systemless kernel modules support
- with do.systemless prop enabled in anykernel.sh, will push the contents of modules/ to create a simple "ak3-helper" Magisk module, where testing on devices thus far shows it loads early enough that even replacement kernel object .ko modules will get loaded
- the ak3-helper module info is populated from the kernel.string and parsed kernel version from the kernel being flashed, and if at boot time a different kernel is detected the module automatically removes itself before being loaded to avoid conflicts
- since logical partitions and ext4-dedup on Android 10 now prevent mounting /system or /vendor rw under any circumstances, this feature gives kernel developers back the freedom they had before all this to improve kernel .ko modules, .conf files, etc. with the added bonus of it cleaning up after itself
2020-01-18 07:21:46 -04:00
osm0sis bd279e6cba Backend: fix dalvikvm execution in recovery on Android 10 2020-01-15 12:38:24 -04:00
osm0sis d225890532 Backend: don't attempt to unmount /system_root when booted
- work around booted flashing apps like FKM/EXKM which make /system busy to keep it from being unmounted but can't do the same with /system_root which can lead to sketchy behavior
2020-01-15 11:49:40 -04:00
osm0sis 810de5296f Backend: APEX mounts support improvements 2020-01-12 02:22:30 -04:00
Zackptg5 648f23fdaa Should only run in recovery 2020-01-04 17:37:39 -04:00
Zackptg5 bb144e1a51 Add apex mount/umount (#48)
Add apex mounting for android Q so dynamic linked binaries and libs will work during install

* Add apex stuff
* Fix minor type
* Better minor type solution
* Update update-binary
2020-01-03 14:16:14 -04:00
osm0sis beec6a6114 Backend: further fixes for GSIs
- ro.vendor.build.product (from #44) doesn't appear to actually exist in nature, so replace it with ro.product.vendor.device for API 28+ devices, per https://github.com/phhusson/vendor_hardware_overlay/issues/25
- no need to check so many props for getprop parsing fallback check, simply look for ro.build.type which all devices should have in antiquity
2019-10-29 17:22:08 -03:00
osm0sis 07def96480 Backend: break early on getprop failure fallback when value found 2019-10-16 17:15:28 -03:00
osm0sis 6515f57493 Backend: fix getprop and devicecheck for GSIs
- add additional prop locations to getprop failure fallback
- add vendor props to devicecheck and getprop parsing fallback check to avoid false negatives on GSIs
- mask errors from devicecheck getprops as not all of them may exist on GSIs or non-GSIs

Thanks @lazerl0rd for the information and start on the changes

Closes #44
2019-10-16 17:05:52 -03:00
Chris Renshaw 98b1ac602f Backend: fix restore_env $bb commands
- this needs to be before cleanup so busybox will still be there
2019-08-29 01:27:02 -03:00
Chris Renshaw c6ccb4fa4e Backend: add /dev/random workaround for recovery
- per Chainfire, "fix slow RNG on some devices, which may cause installation to take weeks"
- it seems like this issue may have been triggered now in recovery on some devices by some of the changes from the new mounting rewrite
2019-08-27 13:37:49 -03:00
osm0sis a88936cd00 Backend: rewrite mount logic to properly cover all cases
- use $ANDROID_ROOT variable which in TWRP is set to /system_root on properly set up SAR devices and default set it to /system
- continue to correct any issues with /system and /system_root mountpoints but backup and restore any symlinks encountered
- only mount and umount /data when it is not mounted to begin with to fix MTP issues in TWRP on some devices (thanks @Zackptg5)
- refactor tear down into restore_env() function to allow restoring original recovery environment even after abort
- add lazy umounts because let's be thorough
- remove hacky workaround to avoid /system_root umount when booted since that should be handled by flashing app now
2019-08-17 22:50:48 -03:00
Chris Renshaw e2987e3947 Backend: mask error on TWRP devices without /system_root in fstab 2019-08-13 20:36:00 -03:00
Chris Renshaw ff4f310e3a Backend: support TWRP devices with /system_root in fstab 2019-08-13 09:16:34 -03:00
osm0sis 01db339f65 Backend: mounting fixes, simplify ui_printing from files
- rename unmount_all to umount_all since it's been bugging me for a while ;)
- refactor mountpoint setup into its own function
- try mount --move first since /system should already be mounted (thanks @Zackptg5)
- refactor reused script to ui_print from files into its own function
2019-08-12 23:40:53 -03:00
Chris Renshaw 4f722f3d67 Backend: fix derp 2019-08-07 00:31:31 -03:00
osm0sis 146c834d0f Backend: ensure /system_root umount even if /system is a symlink 2019-08-06 20:10:53 -03:00
osm0sis 950b68a1d7 Backend: attempt to fix system_root setup on oddball device recoveries
- TWRP for some devices has /system as a symlink, some do not; apparently some weird devices have /system_root as a symlink (somehow); attempt to fix them all
2019-08-06 19:12:00 -03:00
osm0sis f3f80014cc AK3+Backend: fix multi-line abort outputs 2019-08-04 01:16:54 -03:00
osm0sis 559a6082e8 Backend: remember we needs them busybox awks 2019-07-20 18:43:02 -03:00
osm0sis e4a907b745 Backend: introduce Android security patch level check, cleanups
- checks the supported.patchlevels prop in anykernel.sh and matches against it to prevent users flashing incorrect kernels for patch levels
- this is possibly more important than supported.versions now since modern Android doesn't really do point releases anymore, so a patch level is more likely to signify breakage than a version change
- supported.patchlevels can be a closed or open-ended range of dates in the format YYYY-MM, e.g. "2019-04 - 2019-06", "2019-04 -" or "- 2019-06" where the last two examples show setting a minimum and maximum, respectively
- clean up device and version checks a bit while we're at it
2019-07-20 18:21:55 -03:00
osm0sis c2d3d2513b Backend: speed up and simplify is_mounted use 2019-07-12 21:07:16 -03:00
osm0sis 6872cf5977 AK3: add simple arch detect to optionally support arm + x86 in same zip
- for use with broad zips targetting many devices including different architectures
- enable support by putting current tools binary contents in tools/arm and adding tools/x86

(thanks @Zackptg5 for the nudge)
2019-07-01 17:46:34 -03:00
wloot db390aaafe Backend: use recovery umount for /vendor
* It is a *HACK*
* Avoid "Mount /cust (Device or resource busy) failed" error on orangefox which
  mounting /cust as /vendor and also runing a non-treble ROM.
* It is a Orangefox feature that mount both /vendor and /cust while runing a
  non-treble ROM (Obviously, there is a BUG that it shouldnt mount both but /cust
  only), so both of them have a same block. In this case, normal busybox unmount
  will only un-mount what we inputted. I guess that orangefox hacked umount command
  to make /cust is binding with /vendor.

(See comments in #41)

Signed-off-by: wloot <wlootlxt123@gmail.com>
2019-06-26 17:22:15 -03:00
wloot a7af28e25b Backend: fix getting parent directory on some devices
/tmp/updater: line 33: cd: /tmp/anykernel/..: No such file or directory

Closes #41
2019-06-26 17:16:06 -03:00
Chris Renshaw a48ce68a7c Backend: avoid tar complaining when there is no recovery.log
- clean up needless $parent stuff
- recovery.log will only be in /tmp regardless of $home
2019-06-10 00:10:35 -03:00
Chris Renshaw 16b147e939 Backend: only take relevant files for debug .tgz
- per suggestion from eng.stk avoid archiving all of $home since /tmp in recovery might hold sensitive crypto data
- restrict tar to $home (i.e. /tmp/anykernel by default) and $parent/recovery.log (i.e. /tmp/recovery.log)
- probably no need to be verbose when making the archive, it kinda clutters up the end of the captured log
2019-06-09 23:41:07 -03:00
osm0sis da324c430f Backend: fix debugging .tgz creation for booted installs
- 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
2019-06-07 20:22:03 -03:00
osm0sis 6986821230 Welcome to AK3: AnyKernel2 + Magisk = AnyKernel3!
- 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
2019-05-31 23:49:19 -03:00
osm0sis a1f20c0d53 Backend: support all half-sensible ROM version formats
9
9.0
9.0.0

Anything else is insanity.
2019-01-02 17:08:22 -04:00
osm0sis 34d8a65fbe Backend: workaround bad ROM versioning practices in supported check
- 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
2018-12-20 13:46:52 -04:00
osm0sis 9d49de1caf Backend: clean up mounting
- only mount system when not already mounted (avoids harmless stderr during booted flashes)
- optimize module targeting and mount logic further
2018-12-16 23:38:21 -04:00
osm0sis a31d03f2ce Backend: introduce Android version check
- 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
2018-12-16 18:31:53 -04:00
osm0sis 1d58385b26 AK2+Backend: fix file_getprop truncating if prop value contained =
See comments: https://github.com/osm0sis/AnyKernel2/pull/35#issuecomment-447648900
2018-12-16 13:53:33 -04:00
osm0sis 56b4244d53 Backend: cleanups 2018-12-15 09:00:36 -04:00
osm0sis 77fe6bffeb Backend: more robust getprop checks and replacements
- 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
2018-12-14 16:29:53 -04:00
osm0sis da8c2d1e6c Backend: allow infinite device.name<num>= device check properties (#34) 2018-12-14 15:43:25 -04:00
osm0sis fd881bd8d7 Backend: only attempt module bind remount if already mounted
- blindly attempting to remount broke module placement on some ROMs (e.g. Pocophone MIUI stock)
2018-12-11 13:34:37 -04:00
osm0sis 6d5332e054 Backend: attempt remounting module location as well
- 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!
2018-12-11 02:35:15 -04:00
DarkLord1731 e92d8f96c6 AK2: Allow reading multiple lines from version file
This becomes handy to display some additional details apart from just showing the kernel version
2018-07-29 06:58:38 -03:00
osm0sis b1524da099 Backend: move system_root mounting to after device check
- adapted from https://github.com/nathanchance/AnyKernel2/commit/3dfba3dcabff3cf1f859276e1851ae35891d8801
- works around odd behaviors in TWRP on system-as-root devices, but retains working fallback using /system/system/build.prop if getprop also fails
- simplify unmount_all stderr redirection

Please see the above linked commit for further details.
Thanks to nathanchance for reporting, the device-specific workaround, and much testing
2018-07-19 21:30:56 -03:00
Nathan Chancellor 01bf828e78 backend: Break out of device check loop if a match is found
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-07-16 21:28:54 -03:00
Nathan Chancellor dd914e3385 backend: Break out of device check loop if a blank value is found
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-07-16 21:28:54 -03:00
Nathan Chancellor cea9c5a247 backend: Cache build.prop values in device check block
These values are static, we don't need to keep getting them with
getprop.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-07-16 21:28:54 -03:00