fix: 更新 magisk.py 文件,调整目标目录的创建逻辑,确保 magisk 相关文件的正确复制和构建流程的完整性。

This commit is contained in:
2025-09-18 16:42:54 +08:00
parent 535735c0e3
commit b74201630d
3 changed files with 12 additions and 8 deletions

View File

@@ -59,7 +59,6 @@ class Magisk:
self.act_md5 = "2691c30ccf059af2536cb0af803c787c"
self.extract_to = os.path.join(os.path.dirname(os.path.abspath(__file__)), "temp")
self.copy_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "magisk")
self.magisk_dir = os.path.join(self.copy_dir, "system", "etc", "init", "magisk")
self.machine = get_host_arch()
def download(self):
@@ -106,7 +105,7 @@ class Magisk:
# 清理并创建目标目录
if os.path.exists(self.copy_dir):
shutil.rmtree(self.copy_dir)
os.makedirs(self.magisk_dir, exist_ok=True)
os.makedirs(self.copy_dir, exist_ok=True)
os.makedirs(os.path.join(self.copy_dir, "sbin"), exist_ok=True)
# 架构映射
@@ -125,20 +124,20 @@ class Magisk:
o_path = os.path.join(lib_dir, filename)
so_name = re.search(r'lib(.*)\.so', filename)
if so_name:
n_path = os.path.join(self.magisk_dir, so_name.group(1))
n_path = os.path.join(self.copy_dir, so_name.group(1))
shutil.copyfile(o_path, n_path)
run_command(["chmod", "+x", n_path])
# 复制 arm32 的 magisk 二进制文件(如果存在)
lib32_path = os.path.join(self.extract_to, "lib", "armeabi-v7a")
magisk32_src = os.path.join(lib32_path, "libmagisk32.so")
magisk32_dst = os.path.join(self.magisk_dir, "magisk32")
magisk32_dst = os.path.join(self.copy_dir, "magisk32")
if os.path.exists(magisk32_src):
shutil.copyfile(magisk32_src, magisk32_dst)
run_command(["chmod", "+x", magisk32_dst])
# 复制 magisk.apk 到目标目录
apk_dst = os.path.join(self.magisk_dir, "magisk.apk")
apk_dst = os.path.join(self.copy_dir, "magisk.apk")
if os.path.exists(self.dl_file_name):
shutil.copyfile(self.dl_file_name, apk_dst)