mirror of
https://git-qiuchenly.yltfspace.com/QiuChenly/corepatch
synced 2025-11-25 05:40:27 +08:00
fix helper resolve issues.
This commit is contained in:
10
config.json
10
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,
|
||||
|
||||
@@ -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):
|
||||
"""处理单个应用的注入逻辑"""
|
||||
# 获取项目根目录
|
||||
|
||||
@@ -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}"')
|
||||
@@ -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):
|
||||
"""处理应用注册"""
|
||||
|
||||
Reference in New Issue
Block a user