删除Surge。

This commit is contained in:
QiuChenly
2024-04-19 23:55:13 +08:00
parent fdb4781640
commit af79a68be7
2 changed files with 38 additions and 13 deletions

45
main.py
View File

@@ -6,6 +6,7 @@ import shutil
from pathlib import Path
import time
def read_input(prompt):
return input(prompt).strip().lower()
@@ -66,28 +67,43 @@ def check_compatible(
return False
def handle_helper(app_base, target_helper):
subprocess.run("chmod +x ./tool/GenShineImpactStarter", shell=True)
subprocess.run(f"./tool/GenShineImpactStarter '{target_helper}'", shell=True)
subprocess.run(
f"./tool/optool install -p '{app_base}/Contents/Frameworks/91QiuChenly.dylib' -t '{target_helper}'",
shell=True)
shell=True,
)
helper_name = target_helper.split("/")[-1]
subprocess.run(f"sudo /bin/launchctl unload /Library/LaunchDaemons/{helper_name}.plist", shell=True)
subprocess.run(
f"sudo /bin/launchctl unload /Library/LaunchDaemons/{helper_name}.plist",
shell=True,
)
subprocess.run(f"sudo /usr/bin/killall -u root -9 {helper_name}", shell=True)
subprocess.run(f"sudo /bin/rm /Library/LaunchDaemons/{helper_name}.plist", shell=True)
subprocess.run(f"sudo /bin/rm /Library/PrivilegedHelperTools/{helper_name}", shell=True)
subprocess.run(
f"sudo /bin/rm /Library/LaunchDaemons/{helper_name}.plist", shell=True
)
subprocess.run(
f"sudo /bin/rm /Library/PrivilegedHelperTools/{helper_name}", shell=True
)
subprocess.run(f"sudo xattr -c '{app_base}'", shell=True)
src_info = f"{app_base}/Contents/Info.plist"
command = [
"/usr/libexec/PlistBuddy",
"-c",
f"Set :SMPrivilegedExecutables:{helper_name} 'identifier \\\"{helper_name}\\\"'",
src_info
src_info,
]
subprocess.run(command, text=True)
subprocess.run(f"/usr/bin/codesign -f -s - --all-architectures --deep \"{target_helper}\"", shell=True)
subprocess.run(f"/usr/bin/codesign -f -s - --all-architectures --deep \"{app_base}\"", shell=True)
subprocess.run(
f'/usr/bin/codesign -f -s - --all-architectures --deep "{target_helper}"',
shell=True,
)
subprocess.run(
f'/usr/bin/codesign -f -s - --all-architectures --deep "{app_base}"', shell=True
)
def main():
try:
@@ -116,7 +132,10 @@ def main():
app_Lst = []
for app in app_list:
package_name = app["packageName"]
if isinstance(package_name, list):
# 获取macOS系统当前用户账户
if app.get("forQiuChenly") and not os.path.exists("/Users/qiuchenly"):
continue
if isinstance(package_name, list): # 如果是list就检查多项
for name in package_name:
tmp = app.copy()
tmp["packageName"] = name
@@ -141,8 +160,8 @@ def main():
tccutil = app.get("tccutil")
useOptool = app.get("useOptool")
auto_handle_setapp = app.get("autoHandleSetapp")
auto_handle_helper = app.get('autoHandleHelper')
helper_file = app.get('helperFile')
auto_handle_helper = app.get("autoHandleHelper")
helper_file = app.get("helperFile")
local_app = [
local_app
@@ -229,6 +248,10 @@ def main():
if need_copy_to_app_dir:
source_dylib = f"{current.parent}/tool/91QiuChenly.dylib"
if app.get("forQiuChenly"):
# 开发者自己的prebuild库路径 直接在.zshrc设置环境变量这里就可以读取到。
# export InjectLibDev="自己的路径/91QiuChenly.dylib" # 要设置全路径哦
source_dylib = os.getenv("InjectLibDev")
destination_dylib = f"'{app_base_locate}{bridge_file}91QiuChenly.dylib'"
subprocess.run(f"cp {source_dylib} {destination_dylib}", shell=True)
# shutil.copy(source_dylib, destination_dylib)
@@ -280,7 +303,7 @@ def main():
handle_helper(app_base_locate, target_helper)
else:
target_helper = f"{app_base_locate}{helper_file}"
if (os.path.exists(target_helper)):
if os.path.exists(target_helper):
handle_helper(app_base_locate, target_helper)
if tccutil is not None: