Fix CPU architecture detection for Magisk installation
This commit is contained in:
parent
325dbb472a
commit
7a27b8c193
1 changed files with 23 additions and 9 deletions
|
|
@ -24,6 +24,25 @@ print(download_loc)
|
|||
if not os.path.exists(download_loc):
|
||||
os.makedirs(download_loc)
|
||||
|
||||
def host():
|
||||
machine = platform.machine()
|
||||
|
||||
mapping = {
|
||||
"i686": ("x86", 32),
|
||||
"x86_64": ("x86_64", 64),
|
||||
"aarch64": ("arm64-v8a", 64),
|
||||
"armv7l": ("armeabi-v7a", 32),
|
||||
"armv8l": ("armeabi-v7a", 32)
|
||||
}
|
||||
if machine in mapping:
|
||||
if mapping[machine] == "x86_64":
|
||||
with open("/proc/cpuinfo") as f:
|
||||
if "sse4_2" not in f.read():
|
||||
print("x86_64 CPU does not support SSE4.2, falling back to x86...")
|
||||
return ("x86", 32)
|
||||
return mapping[machine]
|
||||
raise ValueError("platform.machine '" + machine + "'"
|
||||
" architecture is not supported")
|
||||
|
||||
def download_file(url, f_name):
|
||||
md5 = ""
|
||||
|
|
@ -341,13 +360,8 @@ def install_magisk():
|
|||
merge_dir = "/var/lib/waydroid/rootfs"
|
||||
magisk_dir = os.path.join(sys_overlay_dir, "system", "etc", "init", "magisk")
|
||||
sys_overlay_rw = "/var/lib/waydroid/overlay_rw"
|
||||
arch = platform.architecture()[0][0:2]
|
||||
machine = platform.machine()
|
||||
if "x86" not in machine:
|
||||
if arch == "64":
|
||||
machine = "arm64-v8a"
|
||||
else:
|
||||
machine = "armeabi-v7a"
|
||||
|
||||
machine = host()
|
||||
init_rc_component = """
|
||||
on post-fs-data
|
||||
start logd
|
||||
|
|
@ -383,7 +397,7 @@ on property:init.svc.zygote=restarting
|
|||
|
||||
on property:init.svc.zygote=stopped
|
||||
exec u:r:su:s0 root root -- /sbin/magisk --auto-selinux --zygote-restart
|
||||
""".format(arch=arch)
|
||||
""".format(arch=machine[1])
|
||||
|
||||
if not DBusContainerService().GetSession():
|
||||
print("Please make sure waydroid container is running!")
|
||||
|
|
@ -425,7 +439,7 @@ on property:init.svc.zygote=stopped
|
|||
# Now setup and install magisk binary and app
|
||||
print("==> Installing magisk now ...")
|
||||
|
||||
lib_dir = os.path.join(extract_to, "lib", machine)
|
||||
lib_dir = os.path.join(extract_to, "lib", machine[0])
|
||||
for parent, dirnames, filenames in os.walk(lib_dir):
|
||||
for filename in filenames:
|
||||
o_path = os.path.join(lib_dir, filename)
|
||||
|
|
|
|||
Loading…
Reference in a new issue