fix: capture before symbolication and close resident app during upgrades

这个提交包含在:
mac 于 2026-11-06 17:07:18 +08:00 提交
1 父节点 e26a7c68e4
当前提交 d018769558
7 个文件已更改
+130 -7

没有与搜索条件相匹配的文件

+37 -1
查看文件
@@ -11,6 +11,7 @@ import shutil
import stat
import subprocess
import tempfile
import xml.etree.ElementTree as ET
import sys
ROOT = Path(__file__).resolve().parent.parent
@@ -57,6 +58,37 @@ def check_package_bundle_access(package):
return len(entries)
def prepare_resident_entry(skill, destination):
"""Reuse Forge core; add our resident wrapper to its normal-quit checks."""
runner = skill / "package_fxplug.py"
entry = skill / "PackageFxPlug.swift"
source = entry.read_text()
anchor = " var hosts = ApplicationToClose.presets\n"
assert source.count(anchor) == 1, "PKG 工坊入口变化,须重新核对常驻 APP 退出规则"
replacement = anchor + """ for item in items where item.kind == .fxPlug {
hosts.append(try ApplicationToClose.read(URL(fileURLWithPath: item.sourcePath)))
}
"""
destination.mkdir()
shutil.copy2(runner, destination / runner.name)
(destination / entry.name).write_text(source.replace(anchor, replacement))
return dict(upstreamEntrySHA256=hashlib.sha256(entry.read_bytes()).hexdigest(),
adaptedEntrySHA256=hashlib.sha256((destination / entry.name).read_bytes()).hexdigest(),
requiredApplication="com.dayu.color")
def check_resident_close(package):
with tempfile.TemporaryDirectory(dir=CACHE) as scratch:
expanded = Path(scratch) / "expanded"
run("pkgutil", "--expand", str(package), str(expanded))
distribution = ET.parse(expanded / "Distribution")
identifiers = [x.attrib.get("id") for x in distribution.findall(".//must-close/app")]
assert "com.dayu.color" in identifiers, "安装器必须正常退出常驻主 APP"
preinstalls = list(expanded.glob("*.pkg/Scripts/preinstall"))
assert preinstalls and all("'com.dayu.color'" in p.read_text() for p in preinstalls)
return dict(identifiers=identifiers, preinstallGuardCount=len(preinstalls), normalQuit=True)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--pkg-forge-repo", type=Path,
@@ -116,7 +148,9 @@ def main():
license="", conclusion="大鱼调色已安装。主 APP 自动注册插件,成功后保持运行。关闭窗口仍在后台收集已开启的诊断;菜单栏可重新打开或退出。请重开宿主并实际检查效果。"))
manifest_path = CACHE / "dayu-color-package-manifest.json"
manifest_path.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n")
command = ["/usr/bin/python3", str(skill / "package_fxplug.py"), "--repo", str(forge), "--manifest", str(manifest_path)]
adapter = stage / "forge-entry"
adapter_record = prepare_resident_entry(skill, adapter)
command = ["/usr/bin/python3", str(adapter / "package_fxplug.py"), "--repo", str(forge), "--manifest", str(manifest_path)]
subprocess.run(command + ["--check"], check=True)
if args.prepare_only:
print("清单:" + str(manifest_path))
@@ -127,6 +161,7 @@ def main():
subprocess.run(command, stdout=log, stderr=subprocess.STDOUT, check=True)
package = args.output_dir / ("大鱼调色-" + version + ".pkg")
verified_payload_entries = check_package_bundle_access(package)
resident_close = check_resident_close(package)
report_path = ROOT / "verification/Package.json"
subprocess.run(["/usr/bin/python3", str(skill / "verify_fxplug_package.py"), "--manifest", str(manifest_path),
"--package", str(package), "--report", str(report_path)], check=True)
@@ -138,6 +173,7 @@ def main():
report = json.loads(report_path.read_text())
report.update(notarization=job, appCompiledSource=delivery["sourceCommit"], appBuild=info["CFBundleVersion"],
packageBuilderRemote="https://dayu.media/git/dayu/pkg-forge.git",
residentAppClosing=resident_close, packageEntryAdaptation=adapter_record,
packageBuilderCommit=run("git", "rev-parse", "HEAD", cwd=forge), templateSHA256=hashes,
payloadBundleAccess=dict(entries=verified_payload_entries, scope="Read/traverse modes for installer-owned app entries, from the package BOM"),
installedAppHostAcceptance=delivery.get("hostVerification", "verification/HostLUTLoading.json"),