fix: 更新路径结构,统一 magisk 相关文件的目录,优化提取脚本和服务配置,确保与构建流程一致性。
This commit is contained in:
41
extract.py
41
extract.py
@@ -28,8 +28,8 @@ def main():
|
||||
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||
apk_path = os.path.join(current_path, "magisk.apk")
|
||||
unzip_path = os.path.join(current_path, "temp")
|
||||
overlay_path = os.path.join(current_path, "rootfs")
|
||||
overlay_magisk_path = os.path.join(overlay_path, "vendor", "etc", "init", "magisk")
|
||||
overlay_path = os.path.join(current_path, "magisk")
|
||||
overlay_magisk_path = os.path.join(overlay_path, "system", "etc", "init", "magisk")
|
||||
|
||||
# Magisk 下载配置
|
||||
magisk_url = "https://github.com/topjohnwu/Magisk/releases/download/v30.2/Magisk-v30.2.apk"
|
||||
@@ -47,7 +47,7 @@ def main():
|
||||
print(f"==> MD5 mismatch. Expected: {expected_md5}, Got: {actual_md5}")
|
||||
|
||||
if need_download:
|
||||
print("==> Downloading Magisk v30.2...")
|
||||
print("==> Downloading Magisk Debug 7be6d81-30200...")
|
||||
download_file(magisk_url, apk_path)
|
||||
actual_md5 = calculate_md5(apk_path)
|
||||
if actual_md5 != expected_md5:
|
||||
@@ -66,18 +66,31 @@ def main():
|
||||
os.makedirs(overlay_magisk_path, exist_ok=True)
|
||||
|
||||
print("==> Installing magisk now ...")
|
||||
# Extract arm64 binaries
|
||||
lib64_path = os.path.join(unzip_path, "lib", "arm64-v8a")
|
||||
for parent, dirnames, filenames in os.walk(lib64_path):
|
||||
for filename in filenames:
|
||||
so_path = os.path.join(lib64_path, filename)
|
||||
so_name = re.search(r"lib(.*)\.so", filename)
|
||||
if so_name:
|
||||
target_path = os.path.join(overlay_magisk_path, so_name.group(1))
|
||||
shutil.copyfile(so_path, target_path)
|
||||
subprocess.check_call(["chmod", "+x", target_path])
|
||||
|
||||
# 架构映射,与 magisk.py 保持一致
|
||||
arch_map = {
|
||||
"x86": "x86",
|
||||
"x86_64": "x86_64",
|
||||
"arm": "armeabi-v7a",
|
||||
"arm64": "arm64-v8a"
|
||||
}
|
||||
|
||||
# 默认使用 arm64 架构
|
||||
machine_arch = "arm64"
|
||||
lib_dir = os.path.join(unzip_path, "lib", arch_map[machine_arch])
|
||||
|
||||
# 复制主要架构的所有库文件
|
||||
if os.path.exists(lib_dir):
|
||||
for parent, dirnames, filenames in os.walk(lib_dir):
|
||||
for filename in filenames:
|
||||
o_path = os.path.join(lib_dir, filename)
|
||||
so_name = re.search(r'lib(.*)\.so', filename)
|
||||
if so_name:
|
||||
n_path = os.path.join(overlay_magisk_path, so_name.group(1))
|
||||
shutil.copyfile(o_path, n_path)
|
||||
subprocess.check_call(["chmod", "+x", n_path])
|
||||
|
||||
# Extract arm32 magisk binary
|
||||
# 同时复制 arm32 的 magisk 二进制文件(如果存在)
|
||||
lib32_path = os.path.join(unzip_path, "lib", "armeabi-v7a")
|
||||
magisk32_src = os.path.join(lib32_path, "libmagisk32.so")
|
||||
magisk32_dst = os.path.join(overlay_magisk_path, "magisk32")
|
||||
|
||||
Reference in New Issue
Block a user