Commit Graph

313 Commits

Author SHA1 Message Date
topjohnwu
51bc27a869 Avoid F2FS like a plague 2021-01-15 02:24:11 -08:00
topjohnwu
bb303d2da1 Remove old unused code 2021-01-14 05:59:53 -08:00
topjohnwu
b51b884fc7 Fix module installs in recovery
Close #3494
2020-12-28 00:25:01 -08:00
Mohd Faraz
dc3d57deba utils_functions: Added a check for the system_root
now on addon while flashing recovery usign mount point /system_root by which this is causing a flashing error.
Let's first check and unmount /system_root if mounted

Signed-off-by: Mohd Faraz <androiabledroid@gmail.com>
2020-12-22 23:30:14 -08:00
vvb2060
6ce9225f52 Check block dev ro status
magisk is shared object, use static busybox instead
2020-12-19 14:12:12 -08:00
vvb2060
13a8820603 Double check $DATA_DE 2020-12-19 14:08:32 -08:00
vvb2060
503997a09a Trim out \r 2020-12-19 14:08:06 -08:00
vvb2060
17efdff134 remove_system_su only on recovery mode
We may mount su to /system/bin/su
2020-12-19 13:59:08 -08:00
vvb2060
984f32f994 Move copy_sepolicy_rules to manager
We don’t need it when patch boot
2020-12-19 13:58:53 -08:00
osm0sis
125ee46685 scripts: fix find_manager_apk
- the strings fallback was broken when the preceding character changed from 5 to ! recently, this new regex should cover any preceding character going forward
2020-12-06 23:49:03 -08:00
osm0sis
ce84f1762c scripts: fix sloppy/unpredictable cmd && this || that statements
- be a bit more POSIX to avoid any potential issues when full shell stdout/err are redirected
- actual logic chains remain unchanged
2020-12-06 23:48:43 -08:00
topjohnwu
e0afbb647b Minor changes 2020-11-13 02:31:54 -08:00
pablomh
bd1dd9d863 Fix ensure_bb by assigning the arguments propery
If we assign the execution output directly it will fail (tested on Android 11):

pdx201:/ # INSTALLER=/data/adb/magisk_install /data/adb/magisk_install/flash_script.sh                                                                          
/data/adb/magisk_install/flash_script.sh[31]: typeset: -o: is not an identifier

Because:

local cmds=$($bb sh -o standalone -c "
	  for arg in \$(tr '\0' '\n' < /proc/$$/cmdline); do
	    if [ -z \"\$cmds\" ]; then
	      # Skip the first argument as we want to change the interpreter
	      cmds=\"sh -o standalone\"
	    else
	      cmds=\"\$cmds '\$arg'\"
	    fi
	  done
	  echo \$cmds")
/system/bin/sh: typeset: -o: is not an identifier

Signed-off-by: Pablo Mendez Hernandez <pablomh@gmail.com>
2020-11-07 14:39:03 -08:00
topjohnwu
16e4c67992 Significantly broaden sepolicy.rule compatibility
Previously, Magisk uses persist or cache for storing modules' custom
sepolicy rules. In this commit, we significantly broaden its
compatibility and also prevent mounting errors.

The persist partition is non-standard and also critical for Snapdragon
devices, so we prefer not to use it by default.

We will go through the following logic to find the best suitable
non-volatile, writable location to store and load sepolicy.rule files:

Unencrypted data -> FBE data unencrypted dir -> cache -> metadata -> persist

This should cover almost all possible cases: very old devices have
cache partitions; newer devices will use FBE; latest devices will use
metadata FBE (which guarantees a metadata parition); and finally,
all Snapdragon devices have the persist partition (as a last resort).

Fix #3179
2020-11-02 23:20:38 -08:00
topjohnwu
cf47214ee4 Require Magisk v20.4 for modules
It has been long enough
2020-10-28 05:13:39 -07:00
topjohnwu
46de1ed968 Better handling of data encryption 2020-09-28 04:45:56 -07:00
topjohnwu
4fd04e62af Remove compressed ramdisk support
It is causing more issues than it addresses
2020-09-24 02:49:09 -07:00
topjohnwu
ca9f9fee9a Update device state detection 2020-09-23 04:49:38 -07:00
osm0sis
6d749a58c6 scripts: fix addon.d using $TMPDIR
/data/adb/magisk/addon.d.sh: cd: line 73: can't cd to /dev/tmp: no such file or directory
2020-08-19 02:05:58 -07:00
topjohnwu
7fc9b908d4 Update Android 11 emulator support 2020-07-27 03:33:11 -07:00
topjohnwu
97b72a5941 Revert to old SElinux rules on pre 8.0 devices
Fix #2910
2020-07-06 01:13:50 -07:00
Chris Renshaw
f79a40a67a scripts: uninstaller fixes
- LOS Recovery can't decrypt or even mount /data, thus the installer can't do everything it needs to do and must abort, so also suggest uninstall via Manager at that point
- fix removal of addon.d script when uninstall is run via Manager on SAR
- fix removal of addon.d with dynamic/logical partitions via mapper
2020-06-20 01:37:06 -07:00
Chris Renshaw
ad94f10205 Fix direct install on NAND devices
Co-authored-by: John Wu <topjohnwu@gmail.com>
2020-06-01 02:08:13 -07:00
topjohnwu
85755e3022 Tone down our DTB patching
- Do not attempt to patch DTB anywhere outside of boot images as they
are no longer essential. This makes Magisk installation to only modify
strictly boot/recovery partitions again.
- The only required patch for DTB is to strip verity out of partitions
2020-05-05 03:29:36 -07:00
Chris Renshaw
23dc19ad94 scripts: don't abort if /vendor fails to mount
- /vendor is used only on some older devices for recovery AVBv1 signing so is not critical if fails
- this fixes installation in Lineage Recovery on some older devices where /vendor is actually by-name partitions like oem, cust (or even cache), which likely also don't require the AVBv1 signing
2020-05-03 23:06:16 -07:00
osm0sis
03c1053871 scripts: fix persist out-of-space copying sepolicy.rule
- bugged TWRPs were filling persist with recovery logs, so clean those as a potential workaround
- abort module install if sepolicy.rule fails to copy, since 99% of the time the module wouldn't include it if it could function without it

Closes #2461
2020-04-29 20:25:18 -07:00
osm0sis
2aede97754 scripts: fix find_block false positives /dev/log/kernel and /dev/BOOT
- try /dev/block first with full depth to catch all platform/soc variations to the by-name directory, and the new dynamic partition /dev/block/mapper
- next try uevent for block devices as before
- lastly try /dev with maxdepth 1 (immediate directory) to find /dev/bootimg, /dev/recovery, etc. while avoiding /dev/log/kernel
- move bootimg higher in the list than boot so /dev/bootimg gets found first and avoids /dev/BOOT
- recovery_a/_b now also exists
- minor touch-ups for readability and consistency

Fixes #2720
2020-04-24 02:24:36 -07:00
osm0sis
9b8a5e9bf3 scripts: add author name back to module install banner print 2020-04-24 02:24:36 -07:00
osm0sis
0f910f2d40 scripts: ensure system is able to be mounted rw before attempting
- this is needed for installations on Lineage 17.1 Recovery (AOSP Q) for logical partition devices, which uses /dev/block/mapper to stage the partitions

Thanks LuK1337 & erfanoabdi @ Lineage
2020-04-24 02:24:36 -07:00
topjohnwu
800b7f4370 Bump min module Magisk version to v20.0
It has been over half an year now, time for an update!
2020-04-21 01:14:14 -07:00
topjohnwu
44b7a3c3f1 Only run bootsigner on Android 5.0+
Close #2712
2020-04-20 22:12:14 -07:00
vvb2060
68532fade3 Update SAR detection method for Android 11 2020-04-20 04:41:11 -07:00
voodik
7188462c55 fix Magisk install on ODROID-N2/C4
add /dev/block/dtbs support
2020-04-19 02:51:05 -07:00
topjohnwu
93aedcfeb7 Update all hardcode paths in app and script 2020-04-05 01:27:07 -07:00
Chris Renshaw
2742edd73f scripts: only show addon.d error once on failures 2020-04-02 20:54:56 -07:00
Chris Renshaw
11102b4dd6 scripts: fix finding nand/mtd boot on some devices
Fixes #2619
2020-04-02 20:52:46 -07:00
topjohnwu
ba7cb47383 Make version reporting consistent 2020-03-23 01:17:13 -07:00
osm0sis
91b6d2852a scripts: add nand/mtd support to uninstaller 2020-03-22 13:43:13 -07:00
topjohnwu
160ff7bb07 Update abort function to cleanup module installs
CLose #2373
2020-03-22 00:08:04 -07:00
osm0sis
0b70bd2b60 scripts: make remaining header/section dividers uniform
- match other recent formatting updates from topjohnwu
2020-03-21 04:32:20 -07:00
osm0sis
84ecba4629 scripts: fix addon.d again by ensuring all arguments get passed
- /proc/$$/cmdline is \0 terminated argument strings except for the last argument which has no terminus, so the last argument was being dropped by `while read` which requires input to be \n terminated
- switch to a for loop, which will use the \n delimiter but also read the last argument; all arguments are still protected by quoting
- clean up potentially breaking recovery env since $OLD_PATH no longer exists
2020-03-20 10:51:55 -07:00
topjohnwu
f7142e69b6 Fix module install in util_functions.sh 2020-03-19 03:53:15 -07:00
topjohnwu
ed7e560849 Fix ensure_bb implementation
Close #2549, close #2560
2020-03-19 03:53:15 -07:00
osm0sis
47e50e8511 scripts: add nand/mtd support to installer
- Magisk's busybox now has nanddump, flash_eraseall and nandwrite, so use these to support character devices

Closes #1526
2020-03-15 12:37:19 -07:00
topjohnwu
7da35e5468 Extract full module installation logic 2020-03-15 00:23:07 -07:00
topjohnwu
d6fdbfe9b7 Utilize standalone mode for emulator.sh 2020-03-08 23:27:06 -07:00
Alessandro Astone
ab9442d4ae
Fixup mounting system on Lineage Recovery
* Lineage Recovery 17.1, like AOSP Q recovery, has '/' as a shared
   mount point, causing `mount --move` to fail.
   If it fails, directly mount system to /system_root via
   /dev/block/ symlinks, like AnyKernel and OpenGapps

Co-authored-by: John Wu <topjohnwu@gmail.com>
2020-03-08 22:38:47 -07:00
osm0sis
f5c099e9a7 scripts: fix addon.d after merge to trampoline
- pass addon.d arguments through trampoline or nothing will happen
- exit immediately after handing over from trampoline
- better grep for recovery OUTFD which should work in all cases
- output to logcat when booted and no binaries are found
- use /postinstall/tmp path to call functions from addon.d-v2 in progress
- remove unnecessary check for $MAGISKBIN since we're already executing from within it
- make sure we're not in $TMPDIR again before we delete it
- use $MAGISKBIN wherever possible in case it ever needs to be changed
2020-03-08 22:33:19 -07:00
topjohnwu
db9a4b31f9 Update scripts to use BusyBox standalone mode 2020-03-08 22:25:06 -07:00
topjohnwu
740559e3bc Fix int detection in scripts 2020-02-10 16:45:44 -08:00