diff --git a/Packaging/build_pkg.py b/Packaging/build_pkg.py index d430ff9..62d7339 100644 --- a/Packaging/build_pkg.py +++ b/Packaging/build_pkg.py @@ -8,7 +8,9 @@ import os from pathlib import Path import plistlib import shutil +import stat import subprocess +import tempfile ROOT = Path(__file__).resolve().parent.parent APP = Path("/Library/Plug-Ins/FxPlug/大鱼调色.app") @@ -25,6 +27,33 @@ def history(profile, keychain): "--keychain", keychain, "--output-format", "json"))["history"] +def check_bundle_access(entries): + for path, mode in entries: + if stat.S_ISLNK(mode): + continue + required = 0o555 if stat.S_ISDIR(mode) or mode & stat.S_IXUSR else 0o444 + if mode & required != required: + raise ValueError(f"普通用户无法读取或执行安装载荷:{path}({stat.S_IMODE(mode):04o})") + + +def check_package_bundle_access(package): + prefix = "." + str(APP) + with tempfile.TemporaryDirectory(dir=CACHE) as scratch: + expanded = Path(scratch) / "expanded" + run("pkgutil", "--expand", str(package), str(expanded)) + entries = {} + for bom in expanded.glob("*.pkg/Bom"): + for line in run("lsbom", "-p", "fm", str(bom)).splitlines(): + path, mode = line.rsplit("\t", 1) + if path == prefix or path.startswith(prefix + "/"): + if not any(part.startswith("._") for part in Path(path).parts): + entries[path] = int(mode, 8) + if prefix not in entries: + raise ValueError(f"安装载荷清单缺少正式 APP:{APP}") + check_bundle_access(entries.items()) + return len(entries) + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--pkg-forge-repo", type=Path, @@ -51,6 +80,7 @@ def main(): (LOCK / "owner.json").write_text(json.dumps(dict(PID=os.getpid(), cwd=str(ROOT), product="大鱼调色", phase="PKG packaging", started=datetime.datetime.now(datetime.timezone.utc).isoformat()))) try: + check_bundle_access((path, path.lstat().st_mode) for path in [APP, *APP.rglob("*")]) source = APP / "Contents/Resources/FCP Templates" staged = CACHE / "pkg-inputs/大鱼调色/大鱼调色" staged.mkdir(parents=True, exist_ok=True) @@ -93,6 +123,7 @@ def main(): with log_path.open("w") as log: subprocess.run(command, stdout=log, stderr=subprocess.STDOUT, check=True) package = args.output_dir / ("大鱼调色-" + version + ".pkg") + verified_payload_entries = check_package_bundle_access(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) @@ -105,6 +136,7 @@ def main(): report.update(notarization=job, appCompiledSource=delivery["sourceCommit"], appBuild=info["CFBundleVersion"], packageBuilderRemote="https://dayu.media/git/dayu/pkg-forge.git", 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"), installScope="本轮仅生成并验包,未再次执行系统安装;正式 APP 已有独立宿主验收。") report_path.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n") diff --git a/tools/deliver.py b/tools/deliver.py index a5a6af1..b530d39 100644 --- a/tools/deliver.py +++ b/tools/deliver.py @@ -55,8 +55,12 @@ def main(): print('Building final Release',flush=True) run('xcodebuild','-project','大鱼调色.xcodeproj','-scheme','Wrapper Application','-configuration','Release','-enableAddressSanitizer','NO','-derivedDataPath',str(CACHE/'DerivedData'),'clean','build',log=CACHE/'release-build.log') b=APP/'Contents/Resources/FCP Templates/大鱼调色.moef';b.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(ROOT/'template/大鱼调色.moef',b) + b.chmod(0o644) for name in ['large.png','small.png']: - if (ROOT/'template'/name).exists():shutil.copy2(ROOT/'template'/name,b.parent/name) + if (ROOT/'template'/name).exists(): + target=b.parent/name;shutil.copy2(ROOT/'template'/name,target);target.chmod(0o644) + # Sources on exFAT can be exposed as owner-only. Installer changes ownership to root. + (APP/'Contents/Resources/Basis_balanceWheel.png').chmod(0o644) identity(APP,'com.dayu.color');plugin=APP/PLUGIN;identity(plugin,'com.dayu.color.XPC') # Xcode registers its build product with Launch Services. Keep the host from # discovering this generated copy while signing/notarization are pending.