Peach: Local-first video metadata scraper and media manager.
fix(packaging): 统一发布运行时并保留镜像资源签名
longmeidaoe86b92738c97
diff --git a/.gitignore b/.gitignoreindex 2d4743fcf..23fb28e49 100644--- a/.gitignore+++ b/.gitignore@@ -1,5 +1,7 @@.venv*/node_modules/+.npm/+.uv-cache/__pycache__/*.py[cod].pytest_cache/diff --git a/.gitlab-ci.yml b/.gitlab-ci.ymlindex 19aaa2899..8b3519729 100644--- a/.gitlab-ci.yml+++ b/.gitlab-ci.yml@@ -99,12 +99,13 @@ wheel-smoke:paths: [build/wheelhouse/].release-linux:- image: node:24-bookworm+ image: ghcr.io/astral-sh/uv:0.13.3-python3.14-trixie-slimrules:- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/ && $CI_COMMIT_REF_PROTECTED == "true"'before_script:- apt-get update- apt-get install -y --no-install-recommends python3 ca-certificates git+ - python3 -c 'import sys; assert sys.version_info[:2] == (3, 14), sys.version'- python3 scripts/fetch_release_tools.py- export PATH="$CI_PROJECT_DIR/build/release-tools:$PATH"- export GLAB_ENABLE_CI_AUTOLOGIN=truediff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.mdindex a9b6ae57a..4bd4babee 100644--- a/docs/OPERATIONS.md+++ b/docs/OPERATIONS.md@@ -41,7 +41,7 @@ MACOSX_DEPLOYMENT_TARGET=11.0 uv sync --locked --extra build --extra macos打开匹配架构的 DMG,把 `Peach.app` 拖入 Applications,再打开应用完成首次设置。菜单栏提供打开页面、重启和退出入口;数据默认保存在 `~/Library/Application Support/Peach/peach-data`,可用 `PEACH_DATA_ROOT` 指定独立目录。-安装镜像使用浅桃色背景,固定左侧 Peach、右侧 Applications 的拖放布局,隐藏工具栏与边栏,背景同时提供标准与 Retina 分辨率。许可证保留在应用的 `Contents/Resources/LICENSE`,安装窗口只显示两个入口。+安装镜像使用 APFS 文件系统,保留已签名资源的 Unicode 文件名及应用扩展属性。浅桃色背景固定左侧 Peach、右侧 Applications 的拖放布局,隐藏工具栏与边栏,背景同时提供标准与 Retina 分辨率。许可证保留在应用的 `Contents/Resources/LICENSE`,安装窗口只显示两个入口。版本标签触发 Release 工作流,在 Apple Silicon 与 Intel 原生 runner 分别构建,再由干净 runner 下载并挂载 DMG,验证签名、架构和独立运行。两种 DMG 与 Windows 安装包全部通过后,才一同上传到 GitHub 预发布,统一生成 SHA-256 清单。手动运行工作流只验收候选制品,不创建 Release;推送普通提交不会触发安装包构建。发版检查见[测试与依赖](TESTING.md#每次发版检查),打标签统一使用 `scripts/release_tag.py`。@@ -55,6 +55,8 @@ Windows 原生 Runner 在深目录中检出项目时,需为 Git 启用 `core.l版本标签须受保护。标签流水线重新核对提交与版本,构建固定来源的媒体工具、Windows 完整包与拆分包、macOS 双架构 DMG,并进行独立制品验收。只有全部成功后才创建 GitLab Release。`PEACH_DOWNLOAD_BACKEND` 默认 `gitgud`,通过 Generic Package Registry 保存制品;不把会过期的 job artifacts 当作永久下载地址。+Linux 发布任务使用官方 uv Python 3.14 容器,并在获取制品工具前核对解释器版本;源码归档使用 `tarfile` 的 `data` 过滤器解压。CI 的 `.npm/` 与 `.uv-cache/` 属于生成缓存,不计入源码工作区变化。+可选的 `r2` 后端使用独立 Standard 桶与 HTTPS 自定义域名。`PEACH_R2_ACCESS_KEY_ID`、`PEACH_R2_SECRET_ACCESS_KEY`、`PEACH_R2_ENDPOINT` 放入受保护且隐藏的 CI 变量,环境作用域为 `release`;`PEACH_R2_BUCKET` 和 `PEACH_R2_PUBLIC_BASE` 指定发布目标。S3 传输复用 rclone,版本文件禁止覆盖;每份文件必须从公开入口完整下载并核对大小及 SHA-256 后,才更新公开版本索引和 Release 链接。Windows 轻量安装器缺少本地工具包时,先从 R2 下载当前版本的工具;连接失败或内容校验失败时,尝试 GitHub 的同版本文件。两个来源均须匹配安装器内置清单的大小与 SHA-256,不能混用其他版本。发布完成后,用 `scripts/smoke_split_update.py` 的 `--prepare-with-app --online` 在空缓存中运行实际制品,核对联网取得的工具能否重建完整程序。GitLab Release 的下载表指向当前后端,文档链接指向对应版本标签。diff --git a/docs/REUSE.md b/docs/REUSE.mdindex 6da804950..9296099ca 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -694,7 +694,7 @@ A 盘垃圾隔离使用短名称 `peach-purge-<32 位 UUID>.peach-quarantine`,| Windows 托盘 | pystray 0.19.5(LGPLv3)、Pillow、Win32 Per-Monitor V2 DPI | Peach 服务归属、后台更新检查、菜单动作、品牌图标 || Windows 托盘恢复 | Windows 自带 `OpenProcess`、`GetProcessTimes`、[`WaitForSingleObject`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject)、`GetExitCodeProcess`;Python 3.12+ 标准库 `ctypes` / `subprocess`,无新增依赖或分发体积 | `tray_lifecycle` 保留明确退出意图、创建时间校验、3 次 / 5 分钟预算与重启交接。pystray 0.19.5 的 `_message_handlers` 接收 `WM_STOP` / `WM_ENDSESSION`,已核对安装包源码;Windows 临时进程实验证明强制退出能恢复,明确退出不会恢复。原生 API 随受支持的 Windows 维护;pystray 使用项目固定版本。不采用 Task Scheduler `RestartOnFailure`:它只管理任务启动的实例,桌面快捷方式与现有重启脚本不归其管理;不新增 psutil 运行时依赖,进程句柄已覆盖等待与退出码。已知边界是监视器随整棵进程树被终止时不能恢复。 || macOS 菜单栏 | `pyobjc-framework-Cocoa==12.2.2`(MIT)提供 AppKit / PyObjCTools / objc | 附件应用策略、18 pt template 图、服务归属与菜单动作 |-| macOS 拖放安装镜像 | [dmgbuild 1.6.7](https://github.com/dmgbuild/dmgbuild)(MIT,Python ≥3.10,macOS)直接写 Finder 元数据;仅安装于 `build` extra。纯 Python wheel 约 35 KB,依赖 `ds-store`、`mac-alias`;固定传递版本见 `uv.lock` | 已读取固定版的文件复制、背景多分辨率合成与图标布局实现;背景渲染复用 resvg-py 0.5.0,无运行时新增依赖。Peach 提供 640×420 拖放布局、双分辨率背景和应用内许可证;单元验证配置与图片尺寸,发布验收实际挂载镜像。磁盘镜像创建依赖 macOS 的 hdiutil;无需 Finder 自动化权限,挂载或文件系统失败会终止构建 |+| macOS 拖放安装镜像 | [dmgbuild 1.6.7](https://github.com/dmgbuild/dmgbuild)(MIT,Python ≥3.10,macOS)直接写 Finder 元数据;仅安装于 `build` extra。纯 Python wheel 约 35 KB,依赖 `ds-store`、`mac-alias`;固定传递版本见 `uv.lock` | 已读取固定版的文件复制、背景多分辨率合成与图标布局实现;背景渲染复用 resvg-py 0.5.0,无运行时新增依赖。Peach 提供 640×420 拖放布局、双分辨率背景和应用内许可证;[APFS 设置](https://dmgbuild.readthedocs.io/en/latest/settings.html#filesystem)保留签名资源的 Unicode 文件名。单元验证配置与图片尺寸,macOS 原生回归与发布验收实际挂载镜像,检查严格签名、资源字节及软链。磁盘镜像创建依赖 macOS 的 hdiutil;无需 Finder 自动化权限,挂载或文件系统失败会终止构建 || 人脸取景 | `opencv-python-headless==5.0.0.93`(Apache-2.0)的 `cv2.FaceDetectorYN` + opencv_zoo 定版模型 `face_detection_yunet_2023mar.onnx`(sha256 `8f2383e4…52fa4`,232 KB,放 `peach-data/tools/yunet/`,不进 Git);MetaTube SDK `6a5e6128c725187aeaf921d48ed7d9cd9f30671b` 的主脸聚类只作算法参考 | 头像/封面离线脚本共用 `peach.face_detect`(主脸、归一化焦点与 sidecar)。`detect` 按长边 320/640/1280 各检一次、分数取中位数;`main_face` 先筛掉分数落后最好那张 0.1 以上的框,再取最大。不用 Haar 级联(OpenCV 5 wheel 里没有、检出率低)与 Pigo v1.4.6(有无脸误报)。[实测](SOURCING.md#人脸与水印实测) || 人脸比对 | 同一 OpenCV 的 `cv2.FaceRecognizerSF` + opencv_zoo 定版模型 `face_recognition_sface_2021dec.onnx`(sha256 `0ba9fbfa…34e79`,与 LFS 指针的 oid 一致,37 MB,放 `peach-data/tools/sface/`,不进 Git) | `peach.face_match` 提特征、算余弦,阈值用 SFace 官方的 0.363;补头像后继拿图库候选与单人封面截到的脸比(ADR-0056),小脸先放大再检(ADR-0070)。检脸用 `peach.face_detect`,取模型走同一条 `fetch_model`。不引 `face_recognition`/dlib(要编译、体积大)与 InsightFace(模型限非商用、需 onnxruntime)。[实测](SOURCING.md#人脸与水印实测) || 头像水印检出 | 同一 OpenCV 的 `cv2.dnn.TextDetectionModel_DB` + opencv_zoo 定版模型 `text_detection_en_ppocrv3_2023may.onnx`(sha256 `03f550c6…66587`,2.4 MB,放 `peach-data/tools/ppocr/`,不进 Git) | `peach.avatar_watermark` 检出,`scripts/scrub_avatar_watermarks.py` 复核与移除。不用 MSER 自写启发式(抓不到半透明水印)。`MIN_SCORE` 0.9、框宽占图宽 ≥ 4%、框整体落在距边 15% 带内;半透明水印给不出框,所以检出只是候选,人看标注图确认、漏的自己补框。移除优先裁边、不 inpaint。[实测](SOURCING.md#人脸与水印实测) |diff --git a/scripts/build_macos_standalone.py b/scripts/build_macos_standalone.pyindex 7f78d8ec8..493bef8ec 100644--- a/scripts/build_macos_standalone.py+++ b/scripts/build_macos_standalone.py@@ -58,11 +58,11 @@ def package_dmg(app: Path, destination: Path) -> Path:path = background if scale == 1 else staging / "[email protected]"path.write_bytes(svg_to_bytes(svg_path=source, zoom=scale))build_dmg(str(destination), "Peach", settings={- "format": "UDZO", "files": [str(app)],+ "format": "UDZO", "filesystem": "APFS", "files": [str(app)],"symlinks": {"Applications": "/Applications"},"background": str(background), "window_rect": ((160, 160), (640, 420)),"icon_locations": {"Peach.app": (174, 220), "Applications": (466, 220)},- "icon_size": 128, "text_size": 13, "hide_extensions": ["Peach.app"],+ "icon_size": 128, "text_size": 13,"default_view": "icon-view", "arrange_by": None,"show_toolbar": False, "show_sidebar": False, "show_status_bar": False,"show_tab_view": False, "show_pathbar": False,diff --git a/tests/test_macos_standalone.py b/tests/test_macos_standalone.pyindex 26567b5ef..c8db63fcb 100644--- a/tests/test_macos_standalone.py+++ b/tests/test_macos_standalone.py@@ -2,6 +2,9 @@from __future__ import annotationsimport importlib.util+import plistlib+import shutil+import subprocessimport sysimport tempfilefrom types import SimpleNamespace@@ -46,6 +49,8 @@ class MacStandaloneDistributionTests(TestCase):self.assertEqual(filename, str(destination))self.assertEqual(volume_name, "Peach")+ self.assertEqual(settings["filesystem"], "APFS")+ self.assertNotIn("Peach.app", settings.get("hide_extensions", []))self.assertEqual(settings["files"], [str(app)])self.assertEqual(settings["symlinks"], {"Applications": "/Applications"})self.assertEqual((resource / "runtime").read_bytes(), b"native executable")@@ -86,6 +91,43 @@ class MacStandaloneDistributionTests(TestCase):self.builder.package_dmg(self.root / "Peach.app", destination)self.assertFalse(destination.parent.exists())+ @skipUnless(sys.platform == "darwin", "磁盘镜像与代码签名需要 macOS")+ def test_signed_unicode_resources_survive_the_disk_image(self):+ app, resource = self.bundle(links=True)+ executable = app / "Contents/MacOS/Peach"+ shutil.copyfile("/usr/bin/true", executable)+ executable.chmod(0o755)+ (app / "Contents/Info.plist").write_bytes(plistlib.dumps({+ "CFBundleExecutable": "Peach", "CFBundleIdentifier": "video.peach.signature-test",+ "CFBundlePackageType": "APPL", "CFBundleVersion": "1",+ }))+ name = "カリビアンコム.png"+ (resource / name).write_bytes(b"signed unicode resource")+ subprocess.run(["codesign", "--force", "--sign", "-", str(app)], check=True,+ capture_output=True, text=True, encoding="utf-8")+ subprocess.run(["codesign", "--verify", "--deep", "--strict", str(app)], check=True,+ capture_output=True, text=True, encoding="utf-8")+ image = self.builder.package_dmg(app, self.root / "Peach.dmg")+ mount = self.root / "mounted"+ mount.mkdir()+ subprocess.run(["hdiutil", "attach", str(image), "-readonly", "-nobrowse",+ "-mountpoint", str(mount)], check=True,+ capture_output=True, text=True, encoding="utf-8")+ try:+ copied = mount / "Peach.app"+ verification = subprocess.run(+ ["codesign", "--verify", "--deep", "--strict", "--verbose=4", str(copied)],+ capture_output=True, text=True, encoding="utf-8")+ self.assertEqual(verification.returncode, 0, verification.stderr)+ resources = copied / "Contents/Resources"+ self.assertIn(name, [path.name for path in resources.iterdir()])+ self.assertEqual((resources / name).read_bytes(), b"signed unicode resource")+ self.assertTrue((resources / "runtime").is_symlink())+ self.assertEqual((resources / "runtime").readlink(), Path("../MacOS/Peach"))+ finally:+ subprocess.run(["hdiutil", "detach", str(mount)], check=True,+ capture_output=True, text=True, encoding="utf-8")+def test_non_macos_build_is_rejected_before_running_tools(self):with mock.patch.object(self.builder.sys, "platform", "win32"), \mock.patch.object(self.builder.subprocess, "run") as run: