feat: install addons as Magisk modules when root is active#51
Merged
Conversation
When ROOT_SETUP is enabled, finish the Magisk install inline so the
addon installs land as proper Magisk modules instead of direct /system
pushes. Reproduces what the Magisk app does on first launch (the
"additional setup" prompt) without requiring a manual tap.
install_root now:
- Calls adb root first (the previous omission silently failed all
writes into /data/adb/ as the shell user)
- After rootAVD patches the ramdisk, extracts Magisk.zip's lib/x86_64/
and assets/ and stages them into /data/adb/magisk/, renaming
lib<name>.so -> <name> and dropping bootctl/main.jar/installer scripts
— same layout the Magisk updater-script produces
install_gapps and install_arm_translation gain a parallel
_magisk_module path that writes the payload under
/data/adb/modules/<id>/system/, plus a module.prop and (for ARM) a
system.prop with the ABI / native-bridge properties and a
post-fs-data.sh that registers binfmt_misc (init.rc files injected via
Magisk overlay aren't parsed by init).
magisk_active() checks for the magiskinit binary rather than just the
/data/adb/magisk directory, since the rootAVD-patched ramdisk creates
that directory empty and the old check returned a false positive.
The main flow now calls install_root before install_gapps and
install_arm_translation so the latter two see a populated Magisk env
and take the module path automatically.
Verified end-to-end on a fresh AVD with ROOT_SETUP=GAPPS_SETUP=
ARM_TRANSLATION=1: /data/adb/magisk/ ends up populated, modules
created under /data/adb/modules/{gapps,ndk_translation}, ABI list
advertises arm64-v8a,armeabi-v7a,armeabi, Google services visible at
/system/priv-app/ via Magisk's overlay, and an arm64-v8a-only APK
(v2rayNG) installs and launches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-targets the Magisk-module work from #49 onto
main. #49 was originally stacked on #48 and got merged into the intermediaterefactor/self-contained-installsbranch instead ofmain— so its content never landed. Now that #50 (the refactor) is onmain, this is the same commit cherry-picked unchanged on top.Why
rootAVDonly patches the ramdisk. The Magisk app's first-launch "additional setup" prompt is what normally populates/data/adb/magisk/with the actual binaries (magisk64,magiskinit,magiskboot,magiskpolicy,busybox,stub.apk, …) — without that step, Magisk reports "environment incomplete, abort" on every boot and refuses to mount modules. That means modules dropped under/data/adb/modules/<id>/are silently ignored.Without this PR:
/systemdirectly, polluting the qcow2 system overlay./systemis wrapped in a read-only magic mount and any subsequent push-based install fails (theINSTALL_FAILEDyou'd hit if you flip a flag on an already-rooted container).Changes
install_rootadb rootbefore any/data/adb/*write (the previous omission silently failed every write as the shell user).rootAVD.shpatches the ramdisk, reproduce the Magisk app'sFixEnv: extractMagisk.zip'slib/x86_64/andassets/, renamelib<name>.so→<name>(same naming the Magisk updater-script does), drop app-only files (bootctl,main.jar,module_installer.sh,uninstaller.sh),chmod -R 755./data/adb/magisk/is then complete when the patched ramdisk activates on the next QEMU restart — no manual setup prompt.install_gapps/install_arm_translation_magisk_modulesiblings to the existing_systempaths. They write the payload under/data/adb/modules/<id>/system/plus amodule.prop.system.propwith the ABI / native-bridge properties (Magisk'sresetpropoverrides thero.*first-write-wins rule) and apost-fs-data.shthat registersbinfmt_misc(init.rc files injected via Magisk overlay aren't parsed by init).magisk_active()— now checks for themagiskinitbinary, not just the directory, so the rootAVD-empty case correctly evaluates to "not yet ready".Main flow ordering
install_rootruns beforeinstall_gappsandinstall_arm_translation. When ROOT is enabled, the magisk-env is complete by the time the other two run, so they automatically take the module path.Result
Verified end-to-end on a fresh AVD with
ROOT_SETUP=GAPPS_SETUP=ARM_TRANSLATION=1:/data/adb/magisk/populated withmagisk64,magiskinit,magiskboot,magiskpolicy,busybox,stub.apk, etc./data/adb/modules/containsgapps/andndk_translation/adb shell getprop ro.product.cpu.abilist→x86_64,x86,arm64-v8a,armeabi-v7a,armeabiadb shell ls /system/priv-app/shows Google services (GoogleBackupTransport,GoogleExtServices, …) via Magisk's overlayadb install v2rayNG_2.1.7_arm64-v8a.apksucceeds and the app launches cleanly (bothcom.v2ray.angandcom.v2ray.ang:bgprocesses alive, noSIGABRTinnative_bridge_initialize)Supersedes
main)