From c8c11b4a859e82c78de2674a6bb17a5d332a80a8 Mon Sep 17 00:00:00 2001 From: QiuChenly Date: Sun, 18 May 2025 11:55:23 +0800 Subject: [PATCH] fix helper resolve issues. --- config.json | 10 ++++++++++ src/app/processor.py | 30 +----------------------------- src/inject/helper.py | 6 ++++-- src/inject/keygen.py | 30 +----------------------------- 4 files changed, 16 insertions(+), 60 deletions(-) diff --git a/config.json b/config.json index 11cadaa..3e2dcd2 100644 --- a/config.json +++ b/config.json @@ -1076,6 +1076,16 @@ "deepSignApp": true, "injectFile": "Sparkle.framework/Versions/A/Sparkle" }, + { + "info":"这个App不是很难,但我没搞懂这个怎么用,没法找人测试。", + "packageName":"com.renewedvision.pvp3", + "helperFile":"/Contents/Library/LaunchServices/com.renewedvision.HelperV2", + "SMExtra":"com.renewedvision.Helper", + "supportVersion":[ + "3.8" + ], + "forQiuChenly":true + }, { "packageName": "com.culturedcode.ThingsMac", "needCopyToAppDir": true, diff --git a/src/app/processor.py b/src/app/processor.py index 83aa9ec..9c960d8 100644 --- a/src/app/processor.py +++ b/src/app/processor.py @@ -10,7 +10,7 @@ from src.app.scanner import check_compatible from src.inject.helper import handle_helper from src.inject.keygen import handle_keygen from src.utils.color import Color - +from src.inject.helper import run_command # 获取工具真实路径的辅助函数 def get_tool_path(tool_name): @@ -32,34 +32,6 @@ def get_tool_path(tool_name): return tool_path - -# 执行命令并检查结果的辅助函数 -def run_command(command, shell=True): - """运行命令并检查结果,如果出错则显示红色警告 - - Args: - command: 要执行的命令 - shell: 是否使用shell执行 - check_error: 是否检查错误 - - Returns: - bool: 命令执行成功返回True,否则返回False - """ - try: - result = subprocess.run(command, shell=shell, capture_output=True, text=True) - - # 检查命令是否执行成功 - if result.returncode != 0: - error_msg = result.stderr.strip() or f"命令执行失败: {command}" - if "No such file or directory" in error_msg or "command not found" in error_msg: - print(Color.red(f"[错误] {error_msg}")) - return False - return True - except Exception as e: - print(Color.red(f"[错误] 执行命令时发生异常: {e}")) - return False - - def process_app(app, base_public_config, install_apps, current_dir=None, skip_confirmation=False): """处理单个应用的注入逻辑""" # 获取项目根目录 diff --git a/src/inject/helper.py b/src/inject/helper.py index 826e5bb..7be3b96 100644 --- a/src/inject/helper.py +++ b/src/inject/helper.py @@ -81,12 +81,14 @@ def handle_helper(app_base, target_helper, component_apps, SMExtra, bridge_path, run_command(f"sudo xattr -c '{app_base}'") src_info = [f"{app_base}/Contents/Info.plist"] + if isinstance(component_apps, list): src_info.extend([f"{app_base}{i}/Contents/Info.plist" for i in component_apps]) for i in src_info: - command = ["/usr/libexec/PlistBuddy", "-c", f"Set :SMPrivilegedExecutables:{helper_name} 'identifier \\\"{helper_name}\\\"'", i] - run_command(command, shell=False) + helper_name = SMExtra if SMExtra != None else helper_name + command = [f"/usr/libexec/PlistBuddy -c \"Set :SMPrivilegedExecutables:{helper_name} identifier {helper_name}\" '{i}'"] + run_command(command) run_command(f'/usr/bin/codesign -f -s - --all-architectures --deep "{target_helper}"') run_command(f'/usr/bin/codesign -f -s - --all-architectures --deep "{app_base}"') \ No newline at end of file diff --git a/src/inject/keygen.py b/src/inject/keygen.py index 24903c8..be1ea67 100644 --- a/src/inject/keygen.py +++ b/src/inject/keygen.py @@ -2,35 +2,7 @@ import os import subprocess from pathlib import Path from src.utils.color import Color - - -# 执行命令并检查结果的辅助函数 -def run_command(command, shell=True, check_error=True): - """运行命令并检查结果,如果出错则显示红色警告 - - Args: - command: 要执行的命令 - shell: 是否使用shell执行 - check_error: 是否检查错误 - - Returns: - bool: 命令执行成功返回True,否则返回False - """ - try: - result = subprocess.run(command, shell=shell, capture_output=True, text=True) - - # 检查命令是否执行成功 - if check_error and result.returncode != 0: - error_msg = result.stderr.strip() or f"命令执行失败: {command}" - if "No such file or directory" in error_msg or "command not found" in error_msg: - print(Color.red(f"[错误] {error_msg}")) - return False - return True - except Exception as e: - if check_error: - print(Color.red(f"[错误] 执行命令时发生异常: {e}")) - return False - +from src.inject.helper import run_command def handle_keygen(bundleIdentifier): """处理应用注册"""