mirror of
https://github.com/ayasa520/redroid-script.git
synced 2026-11-26 06:35:21 +08:00
Update ReDroid to Magisk 31.1
Use the Direct System Install release without a stub APK. Initialize the runtime binaries and companion scripts before post-fs-data so the daemon can load modules and the manager recognizes the installation.
This commit is contained in:
1 file changed
+28
-16
+28
-16
@@ -2,15 +2,15 @@ import gzip
|
||||
import os
|
||||
import shutil
|
||||
import re
|
||||
from tempfile import TemporaryDirectory
|
||||
from stuff.general import General
|
||||
from tools.helper import bcolors, download_file, host, print_color, run, get_download_dir
|
||||
from tools.helper import bcolors, host, print_color, run, get_download_dir
|
||||
|
||||
class Magisk(General):
|
||||
download_loc = get_download_dir()
|
||||
dl_link = "https://github.com/ayasa520/Magisk/releases/download/v30.7/Magisk-v30.7.apk"
|
||||
dl_file_name = os.path.join(download_loc, "magisk.apk")
|
||||
act_md5 = "0a31050fdcfaa15f47c9dd1eb8d04fc8"
|
||||
extract_to = "/tmp/magisk_unpack"
|
||||
dl_link = "https://github.com/ayasa520/Magisk/releases/download/v31.1/Magisk-v31.1.apk"
|
||||
dl_file_name = os.path.join(download_loc, "magisk-v31.1.apk")
|
||||
act_md5 = "10304bbeddb6e1bbc7040fc7ec133178"
|
||||
copy_dir = "./magisk"
|
||||
magisk_dir = os.path.join(copy_dir, "system", "etc", "init", "magisk")
|
||||
machine = host()
|
||||
@@ -32,13 +32,17 @@ on post-fs-data
|
||||
exec u:r:magisk:s0 root root -- {MAGISKSYSTEMDIR}/magiskpolicy --live --magisk
|
||||
exec u:r:update_engine:s0 root root -- {MAGISKSYSTEMDIR}/magiskpolicy --live --magisk
|
||||
exec u:r:su:s0 root root -- {MAGISKSYSTEMDIR}/{magisk_name} --auto-selinux --setup-sbin {MAGISKSYSTEMDIR} {MAGISKTMP}
|
||||
# The daemon loads BusyBox from /data/adb/magisk at post-fs-data, and
|
||||
# the manager checks the tools and script versions in that same directory.
|
||||
mkdir /data/adb 0700 root root
|
||||
mkdir /data/adb/magisk 0755 root root
|
||||
exec -- /system/bin/sh -c "cd {MAGISKSYSTEMDIR} && cp -p busybox magisk magiskboot magiskinit magiskpolicy *.sh /data/adb/magisk/"
|
||||
exec u:r:su:s0 root root -- {MAGISKTMP}/magisk --auto-selinux --post-fs-data
|
||||
on nonencrypted
|
||||
exec u:r:su:s0 root root -- {MAGISKTMP}/magisk --auto-selinux --service
|
||||
on property:vold.decrypt=trigger_restart_framework
|
||||
exec u:r:su:s0 root root -- {MAGISKTMP}/magisk --auto-selinux --service
|
||||
on property:sys.boot_completed=1
|
||||
mkdir /data/adb/magisk 755
|
||||
exec u:r:su:s0 root root -- {MAGISKTMP}/magisk --auto-selinux --boot-complete
|
||||
exec -- /system/bin/sh -c "if ! pm path --user 0 com.topjohnwu.magisk >/dev/null; then pm install {MAGISKSYSTEMDIR}/magisk.apk; fi"
|
||||
|
||||
@@ -50,9 +54,16 @@ on property:init.svc.zygote=stopped
|
||||
""".format(MAGISKSYSTEMDIR="/system/etc/init/magisk", MAGISKTMP="/sbin", magisk_name="magisk")
|
||||
|
||||
def download(self):
|
||||
print_color("Downloading latest Magisk now .....", bcolors.GREEN)
|
||||
print_color("Preparing Magisk 31.1 ...", bcolors.GREEN)
|
||||
super().download()
|
||||
|
||||
def install(self):
|
||||
# Extract each APK into an empty directory so removed or renamed
|
||||
# entries from an earlier release cannot leak into the image.
|
||||
with TemporaryDirectory(prefix="redroid-magisk-") as extract_to:
|
||||
self.extract_to = extract_to
|
||||
super().install()
|
||||
|
||||
def copy(self):
|
||||
if os.path.exists(self.copy_dir):
|
||||
shutil.rmtree(self.copy_dir)
|
||||
@@ -78,16 +89,17 @@ on property:init.svc.zygote=stopped
|
||||
n_path = os.path.join(self.magisk_dir, filename.group(1))
|
||||
shutil.copyfile(o_path, n_path)
|
||||
run(["chmod", "+x", n_path])
|
||||
shutil.copyfile(self.dl_file_name, os.path.join(self.magisk_dir,"magisk.apk") )
|
||||
|
||||
# Bootless setup copies this stub into Magisk's runtime directory. At
|
||||
# post-fs-data the daemon reads its trusted manager certificate from
|
||||
# the stub's APK signature. Use the stub from the same APK as the
|
||||
# manager so the daemon can authenticate the app when it first opens.
|
||||
shutil.copyfile(
|
||||
os.path.join(self.extract_to, "assets", "stub.apk"),
|
||||
os.path.join(self.magisk_dir, "stub.apk"),
|
||||
)
|
||||
# Seed the runtime directory with the release's companion scripts.
|
||||
# util_functions.sh carries the version checked by the manager.
|
||||
assets_dir = os.path.join(self.extract_to, "assets")
|
||||
for filename in os.listdir(assets_dir):
|
||||
if filename.endswith(".sh"):
|
||||
shutil.copyfile(os.path.join(assets_dir, filename), os.path.join(self.magisk_dir, filename))
|
||||
|
||||
# Magisk 31.1 verifies the installed manager APK directly. Ship the
|
||||
# full APK alongside its own native binaries for boot-time installation.
|
||||
shutil.copyfile(self.dl_file_name, os.path.join(self.magisk_dir, "magisk.apk"))
|
||||
|
||||
# Updating Magisk from Magisk manager will modify bootanim.rc,
|
||||
# So it is necessary to backup the original bootanim.rc.
|
||||
|
||||
Reference in new issue
Block a user