Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

feat(desktop): Windows 版加上当前用户安装包,与免安装 zip 一起发布

longmeidaofb06d01ab482
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1ed374650..d96ac8d3a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -58,15 +58,22 @@ jobs:
- name: 获取并校验 cloudflared 旁路文件
shell: pwsh
run: '& ./scripts/fetch_cloudflared.ps1 -OutputPath "$env:RUNNER_TEMP/cloudflared.exe"'
- - name: 构建独立目录包
+ - name: 准备 Inno Setup
shell: pwsh
- run: '& ./scripts/build_windows.ps1 -Standalone -CloudflaredPath "$env:RUNNER_TEMP/cloudflared.exe"'
+ run: |
+ if (-not (Test-Path -LiteralPath "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe")) {
+ choco install innosetup --version 6.7.3 --yes --no-progress
+ if ($LASTEXITCODE -ne 0) { throw 'Inno Setup 安装失败' }
+ }
+ - name: 构建独立目录包与安装包
+ shell: pwsh
+ run: '& ./scripts/build_windows.ps1 -Installer -CloudflaredPath "$env:RUNNER_TEMP/cloudflared.exe"'
- name: 压缩完整程序目录
shell: pwsh
run: |
New-Item -ItemType Directory -Path release | Out-Null
- Copy-Item docs/TESTING_DESKTOP.md dist/Peach/开始使用.md
Compress-Archive -Path dist/Peach -DestinationPath 'release/Peach-${{ steps.version.outputs.version }}-windows-x64.zip'
+ Copy-Item 'dist/Peach-${{ steps.version.outputs.version }}-windows-x64-setup.exe' release/
Copy-Item scripts/smoke_desktop.py release/smoke_desktop.py
python scripts/changelog.py --notes '${{ steps.version.outputs.version }}' --to release/RELEASE_NOTES.md
if ($LASTEXITCODE -ne 0) { throw 'CHANGELOG.md 缺这一版的一节,不发没有说明的版本' }
@@ -92,6 +99,24 @@ jobs:
Expand-Archive -Path 'Peach-${{ needs.windows.outputs.version }}-windows-x64.zip' -DestinationPath candidate
python smoke_desktop.py candidate/Peach/Peach.exe
if ($LASTEXITCODE -ne 0) { throw '制品验收失败' }
+ - name: 静默安装、验收并卸载安装包
+ shell: pwsh
+ run: |
+ $Setup = Start-Process -FilePath './Peach-${{ needs.windows.outputs.version }}-windows-x64-setup.exe' `
+ -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART' -Wait -PassThru
+ if ($Setup.ExitCode -ne 0) { throw "安装包退出码 $($Setup.ExitCode)" }
+ $Installed = Join-Path $env:LOCALAPPDATA 'Programs\Peach'
+ $Key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\{02D9748A-78F6-4866-AC75-918177194DAB}_is1'
+ $Menu = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs\Peach.lnk'
+ if (-not (Test-Path -LiteralPath $Key) -or -not (Test-Path -LiteralPath $Menu)) { throw '安装包没有登记卸载项或开始菜单项' }
+ python smoke_desktop.py (Join-Path $Installed 'Peach.exe')
+ if ($LASTEXITCODE -ne 0) { throw '安装包验收失败' }
+ # 卸载程序会把自己复制到临时目录再运行,原进程立即返回,按目录消失判断完成。
+ Start-Process -FilePath (Join-Path $Installed 'unins000.exe') -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART' -Wait
+ $Deadline = (Get-Date).AddSeconds(120)
+ while ((Test-Path -LiteralPath $Installed) -and (Get-Date) -lt $Deadline) { Start-Sleep -Seconds 1 }
+ if (Test-Path -LiteralPath $Installed) { throw '卸载后程序目录仍在' }
+ if ((Test-Path -LiteralPath $Key) -or (Test-Path -LiteralPath $Menu)) { throw '卸载后仍留有登记项或开始菜单项' }
release:
name: GitHub 预发布
@@ -112,5 +137,5 @@ jobs:
VERSION: ${{ needs.windows.outputs.version }}
run: |
cd release
- sha256sum *.zip > SHA256SUMS.txt
- gh release create "$GITHUB_REF_NAME" *.zip SHA256SUMS.txt --verify-tag --prerelease --title "Peach $VERSION · Windows 测试版" --notes-file RELEASE_NOTES.md
+ sha256sum *.zip *-setup.exe > SHA256SUMS.txt
+ gh release create "$GITHUB_REF_NAME" *.zip *-setup.exe SHA256SUMS.txt --verify-tag --prerelease --title "Peach $VERSION · Windows 测试版" --notes-file RELEASE_NOTES.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 469e0a34d..a9f6b0cc1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,10 @@ Removed / Fixed / Security。
## [未发布]
+### 新增
+
+- **桌面**:Windows 版多了安装包 `Peach-<版本>-windows-x64-setup.exe`,装到当前用户、不需要管理员权限,开始菜单里有入口,可以在系统设置里卸载;原来的 zip 继续作为免安装包提供,两种共用同一份数据。
+
### 变更
- **界面**:操作提示改用 Sonner 的堆叠样式,几条同时出现时叠成一摞,鼠标移上去展开,可以滑动关掉。
diff --git a/README.en.md b/README.en.md
index 3ffc2ea7a..aca3c2a32 100644
--- a/README.en.md
+++ b/README.en.md
@@ -72,8 +72,10 @@ Want to look around before installing? The [live demo](https://demo.peach.video)
### Windows
-1. Download `Peach-<version>-windows-x64.zip` from [Releases](https://github.com/longmeidao/peach/releases), right-click it and choose "Extract All".
-2. Double-click `Peach.exe`. Your browser opens the first-run setup page.
+1. Download one of the two packages from [Releases](https://github.com/longmeidao/peach/releases):
+ - Installer `Peach-<version>-windows-x64-setup.exe`: double-click to install. No administrator rights needed; Peach appears in the Start menu and can be uninstalled from Windows Settings.
+ - Portable `Peach-<version>-windows-x64.zip`: right-click it, choose "Extract All", then double-click `Peach.exe` inside.
+2. Your browser opens the first-run setup page.
3. Pick your media folders and who may access Peach, then start the scan.
The test package is not code-signed yet. If Windows says "Windows protected your PC", make sure the file came from this project's Releases, then choose "More info → Run anyway". Transcoding and thumbnails need FFmpeg; without it you can still browse and play MP4 and WebM. See [Windows test build](docs/TESTING_DESKTOP.md) for how to install it.
diff --git a/README.md b/README.md
index a2edc8e5a..d73682936 100644
--- a/README.md
+++ b/README.md
@@ -72,8 +72,10 @@ https://github.com/user-attachments/assets/cc164de3-28d6-4fc9-8067-f2e70e94cb93
### Windows
-1. 从 [Releases](https://github.com/longmeidao/peach/releases) 下载 `Peach-<版本>-windows-x64.zip`,右键「全部解压」。
-2. 双击 `Peach.exe`,浏览器会打开首次设置页。
+1. 从 [Releases](https://github.com/longmeidao/peach/releases) 下载其中一种:
+ - 安装包 `Peach-<版本>-windows-x64-setup.exe`:双击安装,不需要管理员权限,开始菜单里有 Peach,可以在系统设置里卸载。
+ - 免安装包 `Peach-<版本>-windows-x64.zip`:右键「全部解压」,双击里面的 `Peach.exe`。
+2. 浏览器会打开首次设置页。
3. 选好媒体文件夹和谁能访问,开始扫描。
测试包还没有代码签名。Windows 提示「已保护你的电脑」时,确认文件来自本项目的 Release,再点「更多信息 → 仍要运行」。转码和缩略图要用到 FFmpeg,没装也能浏览和播放 MP4、WebM,安装方法见 [Windows 测试版](docs/TESTING_DESKTOP.md)。
diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md
index cb0643d95..f662152f9 100644
--- a/docs/OPERATIONS.md
+++ b/docs/OPERATIONS.md
@@ -319,6 +319,7 @@ curl -s --noproxy '*' -o /dev/null -w '%{http_code}\n' https://peach.local/healt
- 构建入口是 `scripts/build_windows.ps1`:先用 `scripts/generate_brand_assets.py` 生成方形 Logo 与多尺寸 `.ico`,再构建单一的 `dist/Peach/Peach.exe`。不带参数运行是托盘,`serve`/`migrate` 运行 CLI。
- 对外测试包由 `.github/workflows/release.yml` 构建:`build_windows.ps1 -Standalone` 用 PyInstaller onedir 生成完整的 Windows 程序目录,压缩后由不检出源码的消费任务运行 `scripts/smoke_desktop.py`。冒烟测试会完成首次设置、以 `0.0.0.0` 重启、从本机局域网地址读 `/healthz`、确认 mDNS 已装配,并用访问密码登录。`v<__version__>` 标签与版本不一致会失败;制品验收通过后才创建 GitHub 预发布并附 SHA256。`workflow_dispatch` 只生成和验收制品。
+- 安装包由 `build_windows.ps1 -Installer` 在同一个程序目录上调 Inno Setup 6 的 `ISCC` 编译 `scripts/installer/peach.iss`,产物是 `dist/Peach-<版本>-windows-x64-setup.exe`;找 `ISCC` 的顺序是 `PEACH_ISCC`、`PATH`、两个默认安装位置。它只装到当前用户的 `%LOCALAPPDATA%\Programs\Peach`,程序目录不可选:自更新要在程序目录旁建事务目录,数据根又在 `%LOCALAPPDATA%\Peach` 下,可选目录会让两者重叠。覆盖安装与卸载前分别调 `Peach.exe --installer-stop`、`--installer-uninstall` 停托盘(后者再撤启动项与桌面图标),覆盖安装后账本存在就跑 `migrate upgrade --yes`;这些约定与 `AppId` 在 `src/peach/desktop_installer.py`。消费任务静默安装、对安装位置跑同一个冒烟,再静默卸载并确认程序目录、卸载登记项与开始菜单项都已移除。
- 独立包构建会把固定版本的官方 `cloudflared-windows-amd64.exe` 放在 `Peach.exe` 旁边,并用 `scripts/cloudflared-windows.json` 里的 SHA-256 校验。构建前运行 `scripts/fetch_cloudflared.ps1`,或给 `build_windows.ps1 -CloudflaredPath` 一个哈希相同的文件。源码运行不携带这个二进制。
- 每个包都带构建身份:`build_windows.ps1` 在调用 PyInstaller 前把 `{commit, version, built_at}` 写进 `build/windows/build-info.json`,再用 `--add-data` 放到包根,本机托盘与独立测试包共用。构建机没有 git 或源码不是检出时 `commit` 为 `null`,构建照常。`peach.buildinfo.frozen_build()` 只在 `sys.frozen` 时读它;文件缺失或格式不对返回 `None`,托盘照常启动,只是认为自己身份未取得。
- PyInstaller 的资源直接在 `sys._MEIPASS` 下,没有源码树的 `src/` 这一层;打包后的 `migrate`、Web 与品牌资源都要从这里解析,不能在 `config.py` 里固定取 `parents[2]`。
diff --git a/docs/PRODUCT_BACKLOG.md b/docs/PRODUCT_BACKLOG.md
index 07b7c5c36..fb4934bc1 100644
--- a/docs/PRODUCT_BACKLOG.md
+++ b/docs/PRODUCT_BACKLOG.md
@@ -57,7 +57,7 @@ shuffle_key 会改变随机浏览的顺序语义,先测关系筛选的收益
11. 非 editable 安装的跨平台验收:wheel 资源与 Windows 基础依赖、仓库外 CLI 冒烟已就绪,仍需取得 macOS、Python 3.12 消费任务结果。
12. 健康检查生产验收:`db` 区分 missing、empty、available、unavailable,`?ready=1` 检查 schema 校验和;待部署后用项目 CA 验证 HTTPS 与损坏/未初始化状态。
13. 界面国际化:界面目前只有中文,先补英文。
-14. 制品与更新渠道:剩余 macOS 独立包、代码签名、独立测试包的自动更新、局域网配对和更完整的配置管理。已有的部分是 Windows 独立测试包、首次引导与本机配置表单、按构建身份自行重建的打包托盘、由 `release_tag.py` 在发布点独家发出的版本号与标签(每个版本号对应一份制品并在 `CHANGELOG.md` 有一节),以及退出程序后完整解压新版、数据目录保持独立的测试包更新。关闭判据见 ADR-0012「1.0 门槛」第 8 项。
+14. 制品与更新渠道:剩余 macOS 独立包、代码签名、独立测试包的自动更新、局域网配对和更完整的配置管理。已有的部分是 Windows 独立测试包(免安装 zip 与当前用户安装包两种)、首次引导与本机配置表单、按构建身份自行重建的打包托盘、由 `release_tag.py` 在发布点独家发出的版本号与标签(每个版本号对应一份制品并在 `CHANGELOG.md` 有一节),以及退出程序后完整解压新版、数据目录保持独立的测试包更新。关闭判据见 ADR-0012「1.0 门槛」第 8 项。
15. 「第一个小时」教程与故障排查文档:init → 声明来源根 → scan → 打开页面 → 手机信任 CA → 托盘/菜单栏自启动,每一步写清失败表现与对应的排查动作;截图用一套小的 SFW 演示数据集生成,不取自真实馆藏。演示数据集由 `scripts/demo_dataset.py` 生成,用法见 `docs/README_MAINTENANCE.md`「演示数据集」;教程正文与截图仍待做。
16. 项目网站:一页说明是什么、截图、安装入口与文档链接。
17. 口味导入引导:`/taste` 上传(Takeout ZIP、browserexport 兼容文件)与 `scripts/taste_history.py` 直读本机浏览器库两条路都能用,首次设置和口味页也有简短指南,但没有面向陌生人的完整文档。需要一页「各浏览器怎么导出、多台设备怎么各自刷新」教程,把脚本折进 `peach` CLI(见「把常跑批处理折进 `peach` CLI」一条),并写明定时刷新的安装方式。
diff --git a/docs/REUSE.md b/docs/REUSE.md
index 4ec8ee9a4..17e63533e 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -159,6 +159,7 @@ CloudDrive 为外部应用,本项目不捆绑其二进制或依赖其管理 AP
- 标签发布复用系统 Git、GitHub CLI 2.100.0(MIT)和 [Actions runs REST API](https://docs.github.com/en/rest/actions/workflow-runs),不新增 Python 依赖;`release_tag.py` 只实现版本、主线归属、同提交最新 CI 与不可覆盖策略。Windows Python 3.14 使用提交 `45168dd` 的真实成功 Test 记录完成只读 POC;失败/运行中/其它分支与 master 并发推进用隔离测试拒绝。工作流仍复用既有 Release 制品验收,未引入发布服务。
- 独立 Windows 测试包复用 PyInstaller 6.22.2(GPL-2.0-or-later,带分发 bootloader 例外)的 [onedir 与自启动子进程](https://pyinstaller.org/en/stable/common-issues-and-pitfalls.html);使用已有精确固定的 build 依赖。Python 3.14 / Windows x64 在清除开发工具 PATH、隔离数据目录下实测初始化、页面与 API。保留 Peach 的进程所有权、数据目录、配置和扫描策略;onefile 的托盘入口只用于既有源码部署,独立包采用完整目录以共享资源并避免重复解包。没有新增运行时依赖。
+- Windows 安装包复用 Inno Setup 6.7.3(Inno Setup License,允许免费分发)与官方仓库 `Files/Languages/Unofficial/ChineseSimplified.isl` 的简体中文译文,译文随仓库放在 `scripts/installer/`。`.iss` 只管文件、开始菜单项和卸载登记;停托盘、补迁移、撤快捷方式都调 Peach 已有的入口,由 `desktop_installer` 衔接,自更新与应用内卸载继续是唯一实现。Windows 11 本机实测静默安装、托盘运行中覆盖安装、已有账本补跑迁移与卸载。没有新增运行时依赖。
- 运行一致性复评:复用 `LedgerDatabase.write_transaction` 的提交边界和标准库 `OrderedDict`;HTTP 导航复用 FastAPI/Starlette,图片复验复用 `StaticFiles.is_not_modified` 与 `FileResponse` 的 ETag。列表使用 SQLite 的 IN/UNION 保留隐藏标签与多标签组合,不引入查询框架。
- 馆藏侧栏复用 `catalog_filter` 的列表条件,已保存在线卡片复用关注来源的标签与封面投影,详情复用 `openFollowDetail`、Video.js 和媒体队列。导航范围与标签计数位于 `frontend/src/sidebar.ts`;不新增依赖。截图所示 F95 合集的只读核对结果为无封面、无标签、无已解析媒体,详情按现有来源信息展示。
diff --git a/docs/TESTING_DESKTOP.md b/docs/TESTING_DESKTOP.md
index 4697cd6e9..33b03e5a9 100644
--- a/docs/TESTING_DESKTOP.md
+++ b/docs/TESTING_DESKTOP.md
@@ -1,13 +1,21 @@
# Windows 测试版
-Windows 测试版是一个解压就能用的程序包,不需要安装 Python、Git、Node 或 OpenSSL。macOS 暂无独立包,请按 [README](https://github.com/longmeidao/peach) 从源码运行。
+Windows 测试版有安装包和免安装包两种,程序文件相同,都不需要安装 Python、Git、Node 或 OpenSSL。macOS 暂无独立包,请按 [README](https://github.com/longmeidao/peach) 从源码运行。
+
+| | 安装包 | 免安装包 |
+| --- | --- | --- |
+| 文件 | `Peach-<版本>-windows-x64-setup.exe` | `Peach-<版本>-windows-x64.zip` |
+| 程序位置 | 固定在 `%LOCALAPPDATA%\Programs\Peach`,不需要管理员权限 | 解压到哪里就在哪里 |
+| 开始菜单与系统设置里的卸载项 | 有 | 没有 |
+
+两种的数据都在 `%LOCALAPPDATA%\Peach\peach-data`,换用另一种时设置和数据库照常沿用。
## 开始使用
-1. 从 [GitHub Releases](https://github.com/longmeidao/peach/releases) 下载 `Peach-<版本>-windows-x64.zip` 和 `SHA256SUMS.txt`。
-2. 核对哈希:在 PowerShell 里运行 `Get-FileHash .\Peach-<版本>-windows-x64.zip`,结果应与 `SHA256SUMS.txt` 里对应的那一行相同(不区分大小写)。
-3. 右键压缩包,选「全部解压」。保留整个 `Peach` 文件夹,不要只拿出 `Peach.exe`。
-4. 双击 `Peach.exe`。浏览器会打开首次设置页。
+1. 从 [GitHub Releases](https://github.com/longmeidao/peach/releases) 下载其中一种,以及 `SHA256SUMS.txt`。
+2. 核对哈希:在 PowerShell 里运行 `Get-FileHash .\<下载的文件名>`,结果应与 `SHA256SUMS.txt` 里对应的那一行相同(不区分大小写)。
+3. 安装包:双击,按提示完成安装,最后一步勾选「运行 Peach」。免安装包:右键压缩包,选「全部解压」,保留整个 `Peach` 文件夹,不要只拿出 `Peach.exe`,然后双击 `Peach.exe`。
+4. 浏览器会打开首次设置页。
5. 添加媒体文件夹(可以用「选择文件夹」挑选),选择谁可以访问、要不要设访问密码、是否立即扫描,然后提交。
6. 设置完成后自动进入馆藏,右下角会显示一份安装教程,照着做或逐项跳过都可以。
@@ -81,11 +89,16 @@ Windows 第一次询问防火墙权限时,只勾选「专用网络」。
也可以打开「自动检查新版本」和「自动下载更新」,下载完成后仍要在这里确认重启。
-手动更新时,先从托盘退出 Peach,再把新版完整解压到一个新文件夹。不要只替换 `Peach.exe`:旁边的 `_internal` 文件夹也是程序的一部分。数据目录不用动,新版启动后会沿用已有配置。
+也可以手动更新,数据目录不用动,新版启动后会沿用已有配置:
+
+- 安装包:直接运行新版安装包。它会先让正在运行的 Peach 退出,装完后在需要时更新本地数据库,更新前的数据库备份在数据目录的 `database` 文件夹里,文件名以 `ledger.pre-migrate-` 开头。
+- 免安装包:先从托盘退出 Peach,再把新版完整解压到一个新文件夹。不要只替换 `Peach.exe`:旁边的 `_internal` 文件夹也是程序的一部分。
## 卸载
-在配置页「更新与维护 → 卸载 Peach」里操作。卸载会先退出 Peach,再移除程序文件夹、开机自启和桌面图标。
+在配置页「更新与维护 → 卸载 Peach」里操作。卸载会先退出 Peach,再移除程序文件夹、开机自启和桌面图标;用安装包装的,开始菜单项和系统设置里的卸载项也一并移除。
+
+用安装包装的也可以在系统设置「应用 → 已安装的应用」里卸载 Peach。这条路只移除程序、开始菜单项、开机自启和桌面图标,数据全部保留;要连数据一起删,用配置页里的「完全卸载」。
- 默认保留数据:设置、本地数据库、观看记录和缓存都留着,以后重新安装可以接着用。
- 勾选「完全卸载」会同时删除设置、本地数据库、观看记录、凭据和缓存。
diff --git a/scripts/build_app_entry.py b/scripts/build_app_entry.py
index ce09a96a1..3b60000a0 100644
--- a/scripts/build_app_entry.py
+++ b/scripts/build_app_entry.py
@@ -75,6 +75,9 @@ def main(argv: list[str] | None = None) -> int:
if len(argv) == 4 and argv[1] == "--apply-standalone-update":
from peach.standalone_update import apply
return apply(Path(argv[2]), int(argv[3]))
+ if len(argv) == 2 and argv[1] in {"--installer-stop", "--installer-uninstall"}:
+ from peach.desktop_installer import main as installer_main
+ return installer_main(argv[1])
if wants_cli(argv):
_prepare_console()
try:
diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1
index 8db227189..f672029e7 100644
--- a/scripts/build_windows.ps1
+++ b/scripts/build_windows.ps1
@@ -1,10 +1,13 @@
param(
[string]$OutputDirectory = (Join-Path $PSScriptRoot '..\dist\Peach'),
[switch]$Standalone,
+ # 在独立目录包之上再编一个 Inno Setup 安装包,放在输出目录的上一层。
+ [switch]$Installer,
[string]$CloudflaredPath = ''
)
$ErrorActionPreference = 'Stop'
+if ($Installer) { $Standalone = $true }
$ProjectRoot = Split-Path -Parent $PSScriptRoot
$Python = Join-Path $ProjectRoot '.venv\Scripts\python.exe'
if (-not (Test-Path -LiteralPath $Python)) {
@@ -128,7 +131,24 @@ if (Test-Path -LiteralPath $WorkPath) {
Remove-Item -LiteralPath $WorkPath -Recurse -Force
}
+$InstallerPath = $null
+if ($Installer) {
+ $IsccCandidates = @($env:PEACH_ISCC, (Get-Command ISCC.exe -ErrorAction SilentlyContinue).Source,
+ (Join-Path ${env:ProgramFiles(x86)} 'Inno Setup 6\ISCC.exe'),
+ (Join-Path $env:LOCALAPPDATA 'Programs\Inno Setup 6\ISCC.exe'))
+ $Iscc = $IsccCandidates | Where-Object { $_ -and (Test-Path -LiteralPath $_ -PathType Leaf) } | Select-Object -First 1
+ if (-not $Iscc) {
+ throw 'Inno Setup 6 not found. Install it with: winget install JRSoftware.InnoSetup, or set PEACH_ISCC.'
+ }
+ $InstallerOutput = Split-Path -Parent $OutputPath
+ & $Iscc /Q "/DAppVersion=$($BuildInfo.version)" "/DSourceDir=$OutputPath" "/DOutputDir=$InstallerOutput" `
+ (Join-Path $PSScriptRoot 'installer\peach.iss')
+ if ($LASTEXITCODE -ne 0) { throw 'Installer build failed.' }
+ $InstallerPath = Join-Path $InstallerOutput "Peach-$($BuildInfo.version)-windows-x64-setup.exe"
+}
+
[pscustomobject]@{
Executable = Join-Path $OutputPath 'Peach.exe'
Icon = Join-Path $ProjectRoot 'resources\peach.ico'
+ Installer = $InstallerPath
}
diff --git a/scripts/installer/ChineseSimplified.isl b/scripts/installer/ChineseSimplified.isl
new file mode 100644
index 000000000..d6a11c449
--- /dev/null
+++ b/scripts/installer/ChineseSimplified.isl
@@ -0,0 +1,418 @@
+; *** Inno Setup version 6.5.0+ Chinese Simplified messages ***
+;
+; To download user-contributed translations of this file, go to:
+; https://jrsoftware.org/files/istrans/
+;
+; Note: When translating this text, do not add periods (.) to the end of
+; messages that didn't have them already, because on those messages Inno
+; Setup adds the periods automatically (appending a period would result in
+; two periods being displayed).
+;
+; Maintained by Zhenghan Yang
+; Translation based on network resource
+; The latest Translation is on https://github.com/kira-96/Inno-Setup-Chinese-Simplified-Translation
+;
+
+[LangOptions]
+; The following three entries are very important. Be sure to read and
+; understand the '[LangOptions] section' topic in the help file.
+LanguageName=简体中文
+; If Language Name display incorrect, uncomment next line
+; LanguageName=<7B80><4F53><4E2D><6587>
+; About LanguageID, to reference link:
+; https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c
+LanguageID=$0804
+; About CodePage, to reference link:
+; https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
+LanguageCodePage=936
+; If the language you are translating to requires special font faces or
+; sizes, uncomment any of the following entries and change them accordingly.
+;DialogFontName=
+;DialogFontSize=9
+;DialogFontBaseScaleWidth=7
+;DialogFontBaseScaleHeight=15
+;WelcomeFontName=Segoe UI
+;WelcomeFontSize=14
+
+[Messages]
+
+; *** 应用程序标题
+SetupAppTitle=安装
+SetupWindowTitle=安装 - %1
+UninstallAppTitle=卸载
+UninstallAppFullTitle=%1 卸载
+
+; *** Misc. common
+InformationTitle=信息
+ConfirmTitle=确认
+ErrorTitle=错误
+
+; *** SetupLdr messages
+SetupLdrStartupMessage=现在将安装 %1。您想要继续吗?
+LdrCannotCreateTemp=无法创建临时文件。安装程序已中止
+LdrCannotExecTemp=无法执行临时目录中的文件。安装程序已中止
+HelpTextNote=
+
+; *** 启动错误消息
+LastErrorMessage=%1。%n%n错误 %2: %3
+SetupFileMissing=安装目录中缺少文件 %1。请修正这个问题或者获取程序的新副本。
+SetupFileCorrupt=安装文件已损坏。请获取程序的新副本。
+SetupFileCorruptOrWrongVer=安装文件已损坏,或是与这个安装程序的版本不兼容。请修正这个问题或获取新的程序副本。
+InvalidParameter=无效的命令行参数:%n%n%1
+SetupAlreadyRunning=安装程序正在运行。
+WindowsVersionNotSupported=此程序不支持当前计算机运行的 Windows 版本。
+WindowsServicePackRequired=此程序需要 %1 服务包 %2 或更高版本。
+NotOnThisPlatform=此程序不能在 %1 上运行。
+OnlyOnThisPlatform=此程序只能在 %1 上运行。
+OnlyOnTheseArchitectures=此程序只能安装到为下列处理器架构设计的 Windows 版本中:%n%n%1
+WinVersionTooLowError=此程序需要 %1 版本 %2 或更高。
+WinVersionTooHighError=此程序不能安装于 %1 版本 %2 或更高。
+AdminPrivilegesRequired=在安装此程序时您必须以管理员身份登录。
+PowerUserPrivilegesRequired=在安装此程序时您必须以管理员身份或有权限的用户组身份登录。
+SetupAppRunningError=安装程序发现 %1 当前正在运行。%n%n请先关闭正在运行的程序,然后点击“确定”继续,或点击“取消”退出。
+UninstallAppRunningError=卸载程序发现 %1 当前正在运行。%n%n请先关闭正在运行的程序,然后点击“确定”继续,或点击“取消”退出。
+
+; *** 启动问题
+PrivilegesRequiredOverrideTitle=选择安装程序模式
+PrivilegesRequiredOverrideInstruction=选择安装模式
+PrivilegesRequiredOverrideText1=%1 可以为所有用户安装(需要管理员权限),或仅为您安装。
+PrivilegesRequiredOverrideText2=%1 可以仅为您安装,或为所有用户安装(需要管理员权限)。
+PrivilegesRequiredOverrideAllUsers=为所有用户安装(&A)
+PrivilegesRequiredOverrideAllUsersRecommended=为所有用户安装(&A) (建议选项)
+PrivilegesRequiredOverrideCurrentUser=仅为我安装(&M)
+PrivilegesRequiredOverrideCurrentUserRecommended=仅为我安装(&M) (建议选项)
+
+; *** 其他错误
+ErrorCreatingDir=安装程序无法创建目录“%1”
+ErrorTooManyFilesInDir=无法在目录“%1”中创建文件,因为里面包含太多文件
+
+; *** 安装程序公共消息
+ExitSetupTitle=退出安装程序
+ExitSetupMessage=安装程序尚未完成。如果现在退出,将不会安装该程序。%n%n您之后可以再次运行安装程序完成安装。%n%n现在退出安装程序吗?
+AboutSetupMenuItem=关于安装程序(&A)...
+AboutSetupTitle=关于安装程序
+AboutSetupMessage=%1 版本 %2%n%3%n%n%1 主页:%n%4
+AboutSetupNote=
+TranslatorNote=简体中文翻译由Kira([email protected])维护。项目地址:https://github.com/kira-96/Inno-Setup-Chinese-Simplified-Translation
+
+; *** 按钮
+ButtonBack=< 上一步(&B)
+ButtonNext=下一步(&N) >
+ButtonInstall=安装(&I)
+ButtonOK=确定
+ButtonCancel=取消
+ButtonYes=是(&Y)
+ButtonYesToAll=全是(&A)
+ButtonNo=否(&N)
+ButtonNoToAll=全否(&O)
+ButtonFinish=完成(&F)
+ButtonBrowse=浏览(&B)...
+ButtonWizardBrowse=浏览(&R)...
+ButtonNewFolder=新建文件夹(&M)
+
+; *** “选择语言”对话框消息
+SelectLanguageTitle=选择安装语言
+SelectLanguageLabel=选择安装时使用的语言。
+
+; *** 公共向导文字
+ClickNext=点击“下一步”继续,或点击“取消”退出安装程序。
+BeveledLabel=
+BrowseDialogTitle=浏览文件夹
+BrowseDialogLabel=在下面的列表中选择一个文件夹,然后点击“确定”。
+NewFolderName=新建文件夹
+
+; *** “欢迎”向导页
+WelcomeLabel1=欢迎使用 [name] 安装向导
+WelcomeLabel2=现在将安装 [name/ver] 到您的电脑中。%n%n建议您在继续安装前关闭所有其他应用程序。
+
+; *** “密码”向导页
+WizardPassword=密码
+PasswordLabel1=这个安装程序有密码保护。
+PasswordLabel3=请输入密码,然后点击“下一步”继续。密码区分大小写。
+PasswordEditLabel=密码(&P):
+IncorrectPassword=您输入的密码不正确,请重新输入。
+
+; *** “许可协议”向导页
+WizardLicense=许可协议
+LicenseLabel=请在继续安装前阅读以下重要信息。
+LicenseLabel3=请仔细阅读下列许可协议。在继续安装前您必须同意这些协议条款。
+LicenseAccepted=我同意此协议(&A)
+LicenseNotAccepted=我不同意此协议(&D)
+
+; *** “信息”向导页
+WizardInfoBefore=信息
+InfoBeforeLabel=请在继续安装前阅读以下重要信息。
+InfoBeforeClickLabel=准备好继续安装后,点击“下一步”。
+WizardInfoAfter=信息
+InfoAfterLabel=请在继续安装前阅读以下重要信息。
+InfoAfterClickLabel=准备好继续安装后,点击“下一步”。
+
+; *** “用户信息”向导页
+WizardUserInfo=用户信息
+UserInfoDesc=请输入您的信息。
+UserInfoName=用户名(&U):
+UserInfoOrg=组织(&O):
+UserInfoSerial=序列号(&S):
+UserInfoNameRequired=您必须输入用户名。
+
+; *** “选择目标目录”向导页
+WizardSelectDir=选择目标位置
+SelectDirDesc=您想将 [name] 安装在哪里?
+SelectDirLabel3=安装程序将安装 [name] 到下面的文件夹中。
+SelectDirBrowseLabel=点击“下一步”继续。如果您想选择其他文件夹,点击“浏览”。
+DiskSpaceGBLabel=至少需要有 [gb] GB 的可用磁盘空间。
+DiskSpaceMBLabel=至少需要有 [mb] MB 的可用磁盘空间。
+CannotInstallToNetworkDrive=安装程序无法安装到一个网络驱动器。
+CannotInstallToUNCPath=安装程序无法安装到一个 UNC 路径。
+InvalidPath=您必须输入一个带驱动器卷标的完整路径,例如:%n%nC:\APP%n%n或UNC路径:%n%n\\server\share
+InvalidDrive=您选定的驱动器或 UNC 共享不存在或不能访问。请选择其他位置。
+DiskSpaceWarningTitle=磁盘空间不足
+DiskSpaceWarning=安装程序至少需要 %1 KB 的可用空间才能安装,但选定驱动器只有 %2 KB 的可用空间。%n%n您一定要继续吗?
+DirNameTooLong=文件夹名称或路径太长。
+InvalidDirName=文件夹名称无效。
+BadDirName32=文件夹名称不能包含下列任何字符:%n%n%1
+DirExistsTitle=文件夹已存在
+DirExists=文件夹:%n%n%1%n%n已经存在。您一定要安装到这个文件夹中吗?
+DirDoesntExistTitle=文件夹不存在
+DirDoesntExist=文件夹:%n%n%1%n%n不存在。您想要创建此文件夹吗?
+
+; *** “选择组件”向导页
+WizardSelectComponents=选择组件
+SelectComponentsDesc=您想安装哪些程序组件?
+SelectComponentsLabel2=选中您想安装的组件;取消您不想安装的组件。然后点击“下一步”继续。
+FullInstallation=完全安装
+; if possible don't translate 'Compact' as 'Minimal' (I mean 'Minimal' in your language)
+CompactInstallation=简洁安装
+CustomInstallation=自定义安装
+NoUninstallWarningTitle=组件已存在
+NoUninstallWarning=安装程序检测到下列组件已安装在您的电脑中:%n%n%1%n%n取消选中这些组件不会卸载它们。%n%n确定要继续吗?
+ComponentSize1=%1 KB
+ComponentSize2=%1 MB
+ComponentsDiskSpaceGBLabel=当前选择的组件需要至少 [gb] GB 的磁盘空间。
+ComponentsDiskSpaceMBLabel=当前选择的组件需要至少 [mb] MB 的磁盘空间。
+
+; *** “选择附加任务”向导页
+WizardSelectTasks=选择附加任务
+SelectTasksDesc=您想要安装程序执行哪些附加任务?
+SelectTasksLabel2=选择您想要安装程序在安装 [name] 时执行的附加任务,然后点击“下一步”。
+
+; *** “选择开始菜单文件夹”向导页
+WizardSelectProgramGroup=选择开始菜单文件夹
+SelectStartMenuFolderDesc=安装程序应该在哪里放置程序的快捷方式?
+SelectStartMenuFolderLabel3=安装程序将在下列“开始”菜单文件夹中创建程序的快捷方式。
+SelectStartMenuFolderBrowseLabel=点击“下一步”继续。如果您想选择其他文件夹,点击“浏览”。
+MustEnterGroupName=您必须输入一个文件夹名。
+GroupNameTooLong=文件夹名或路径太长。
+InvalidGroupName=无效的文件夹名字。
+BadGroupName=文件夹名不能包含下列任何字符:%n%n%1
+NoProgramGroupCheck2=不创建开始菜单文件夹(&D)
+
+; *** “准备安装”向导页
+WizardReady=准备安装
+ReadyLabel1=安装程序准备就绪,现在可以开始安装 [name] 到您的电脑。
+ReadyLabel2a=点击“安装”继续此安装程序。如果您想重新考虑或修改任何设置,点击“上一步”。
+ReadyLabel2b=点击“安装”继续此安装程序。
+ReadyMemoUserInfo=用户信息:
+ReadyMemoDir=目标位置:
+ReadyMemoType=安装类型:
+ReadyMemoComponents=已选择组件:
+ReadyMemoGroup=开始菜单文件夹:
+ReadyMemoTasks=附加任务:
+
+; *** TExtractionWizardPage 向导页面与 ExtractArchive
+ExtractingLabel=正在解压文件...
+ButtonStopExtraction=停止解压(&S)
+StopExtraction=您确定要停止解压吗?
+ErrorExtractionAborted=解压已中止
+ErrorExtractionFailed=解压失败:%1
+
+; *** 压缩文件解压失败详情
+ArchiveIncorrectPassword=压缩文件密码不正确
+ArchiveIsCorrupted=压缩文件已损坏
+ArchiveUnsupportedFormat=不支持的压缩文件格式
+
+; *** TDownloadWizardPage 向导页面和 DownloadTemporaryFile
+DownloadingLabel2=正在下载文件...
+ButtonStopDownload=停止下载(&S)
+StopDownload=您确定要停止下载吗?
+ErrorDownloadAborted=下载已中止
+ErrorDownloadFailed=下载失败:%1 %2
+ErrorDownloadSizeFailed=获取下载大小失败:%1 %2
+ErrorProgress=无效的进度:%1 / %2
+ErrorFileSize=文件大小错误:预期 %1,实际 %2
+
+; *** “正在准备安装”向导页
+WizardPreparing=正在准备安装
+PreparingDesc=安装程序正在准备安装 [name] 到您的电脑。
+PreviousInstallNotCompleted=先前的程序安装或卸载未完成,您需要重启您的电脑以完成。%n%n在重启电脑后,再次运行安装程序以完成 [name] 的安装。
+CannotContinue=安装程序不能继续。请点击“取消”退出。
+ApplicationsFound=以下应用程序正在使用将由安装程序更新的文件。建议您允许安装程序自动关闭这些应用程序。
+ApplicationsFound2=以下应用程序正在使用将由安装程序更新的文件。建议您允许安装程序自动关闭这些应用程序。安装完成后,安装程序将尝试重新启动这些应用程序。
+CloseApplications=自动关闭应用程序(&A)
+DontCloseApplications=不要关闭应用程序(&D)
+ErrorCloseApplications=安装程序无法自动关闭所有应用程序。建议您在继续之前,关闭所有在使用需要由安装程序更新的文件的应用程序。
+PrepareToInstallNeedsRestart=安装程序必须重启您的计算机。计算机重启后,请再次运行安装程序以完成 [name] 的安装。%n%n是否立即重新启动?
+
+; *** “正在安装”向导页
+WizardInstalling=正在安装
+InstallingLabel=安装程序正在安装 [name] 到您的电脑,请稍候。
+
+; *** “安装完成”向导页
+FinishedHeadingLabel=[name] 安装完成
+FinishedLabelNoIcons=安装程序已在您的电脑中安装了 [name]。
+FinishedLabel=安装程序已在您的电脑中安装了 [name]。您可以通过已安装的快捷方式运行此应用程序。
+ClickFinish=点击“完成”退出安装程序。
+FinishedRestartLabel=为完成 [name] 的安装,安装程序必须重新启动您的电脑。要立即重启吗?
+FinishedRestartMessage=为完成 [name] 的安装,安装程序必须重新启动您的电脑。%n%n要立即重启吗?
+ShowReadmeCheck=是,我想查阅自述文件
+YesRadio=是,立即重启电脑(&Y)
+NoRadio=否,稍后重启电脑(&N)
+; used for example as 'Run MyProg.exe'
+RunEntryExec=运行 %1
+; used for example as 'View Readme.txt'
+RunEntryShellExec=查阅 %1
+
+; *** “安装程序需要下一张磁盘”提示
+ChangeDiskTitle=安装程序需要下一张磁盘
+SelectDiskLabel2=请插入磁盘 %1 并点击“确定”。%n%n如果这个磁盘中的文件可以在下列文件夹之外的文件夹中找到,请输入正确的路径或点击“浏览”。
+PathLabel=路径(&P):
+FileNotInDir2=“%2”中找不到文件“%1”。请插入正确的磁盘或选择其他文件夹。
+SelectDirectoryLabel=请指定下一张磁盘的位置。
+
+; *** 安装阶段消息
+SetupAborted=安装程序未完成安装。%n%n请修正这个问题并重新运行安装程序。
+AbortRetryIgnoreSelectAction=选择操作
+AbortRetryIgnoreRetry=重试(&T)
+AbortRetryIgnoreIgnore=忽略错误并继续(&I)
+AbortRetryIgnoreCancel=关闭安装程序
+RetryCancelSelectAction=选择操作
+RetryCancelRetry=重试(&T)
+RetryCancelCancel=取消(&C)
+
+; *** 安装状态消息
+StatusClosingApplications=正在关闭应用程序...
+StatusCreateDirs=正在创建目录...
+StatusExtractFiles=正在提取文件...
+StatusDownloadFiles=正在下载文件...
+StatusCreateIcons=正在创建快捷方式...
+StatusCreateIniEntries=正在创建 INI 条目...
+StatusCreateRegistryEntries=正在创建注册表条目...
+StatusRegisterFiles=正在注册文件...
+StatusSavingUninstall=正在保存卸载信息...
+StatusRunProgram=正在完成安装...
+StatusRestartingApplications=正在重启应用程序...
+StatusRollback=正在撤销更改...
+
+; *** 其他错误
+ErrorInternal2=内部错误:%1
+ErrorFunctionFailedNoCode=%1 失败
+ErrorFunctionFailed=%1 失败;错误代码 %2
+ErrorFunctionFailedWithMessage=%1 失败;错误代码 %2.%n%3
+ErrorExecutingProgram=无法执行文件:%n%1
+
+; *** 注册表错误
+ErrorRegOpenKey=打开注册表项时出错:%n%1\%2
+ErrorRegCreateKey=创建注册表项时出错:%n%1\%2
+ErrorRegWriteKey=写入注册表项时出错:%n%1\%2
+
+; *** INI 错误
+ErrorIniEntry=在文件“%1”中创建 INI 条目时出错。
+
+; *** 文件复制错误
+FileAbortRetryIgnoreSkipNotRecommended=跳过此文件(&S) (不推荐)
+FileAbortRetryIgnoreIgnoreNotRecommended=忽略错误并继续(&I) (不推荐)
+SourceIsCorrupted=源文件已损坏
+SourceDoesntExist=源文件“%1”不存在
+SourceVerificationFailed=源文件验证失败: %1
+VerificationSignatureDoesntExist=签名文件“%1”不存在
+VerificationSignatureInvalid=签名文件“%1”无效
+VerificationKeyNotFound=签名文件“%1”使用了未知密钥
+VerificationFileNameIncorrect=文件名不正确
+VerificationFileTagIncorrect=文件标签不正确
+VerificationFileSizeIncorrect=文件大小不正确
+VerificationFileHashIncorrect=文件哈希值不正确
+ExistingFileReadOnly2=无法替换现有文件,它是只读的。
+ExistingFileReadOnlyRetry=移除只读属性并重试(&R)
+ExistingFileReadOnlyKeepExisting=保留现有文件(&K)
+ErrorReadingExistingDest=尝试读取现有文件时出错:
+FileExistsSelectAction=选择操作
+FileExists2=文件已经存在。
+FileExistsOverwriteExisting=覆盖已存在的文件(&O)
+FileExistsKeepExisting=保留现有的文件(&K)
+FileExistsOverwriteOrKeepAll=为所有冲突文件执行此操作(&D)
+ExistingFileNewerSelectAction=选择操作
+ExistingFileNewer2=现有的文件比安装程序将要安装的文件还要新。
+ExistingFileNewerOverwriteExisting=覆盖已存在的文件(&O)
+ExistingFileNewerKeepExisting=保留现有的文件(&K) (推荐)
+ExistingFileNewerOverwriteOrKeepAll=为所有冲突文件执行此操作(&D)
+ErrorChangingAttr=尝试更改下列现有文件的属性时出错:
+ErrorCreatingTemp=尝试在目标目录创建文件时出错:
+ErrorReadingSource=尝试读取下列源文件时出错:
+ErrorCopying=尝试复制下列文件时出错:
+ErrorDownloading=下载文件时出错:
+ErrorExtracting=解压压缩文件时出错:
+ErrorReplacingExistingFile=尝试替换现有文件时出错:
+ErrorRestartReplace=重启并替换失败:
+ErrorRenamingTemp=尝试重命名下列目标目录中的一个文件时出错:
+ErrorRegisterServer=无法注册 DLL/OCX:%1
+ErrorRegSvr32Failed=RegSvr32 失败;退出代码 %1
+ErrorRegisterTypeLib=无法注册类库:%1
+
+; *** 卸载显示名字标记
+; used for example as 'My Program (32-bit)'
+UninstallDisplayNameMark=%1 (%2)
+; used for example as 'My Program (32-bit, All users)'
+UninstallDisplayNameMarks=%1 (%2, %3)
+UninstallDisplayNameMark32Bit=32 位
+UninstallDisplayNameMark64Bit=64 位
+UninstallDisplayNameMarkAllUsers=所有用户
+UninstallDisplayNameMarkCurrentUser=当前用户
+
+; *** 安装后错误
+ErrorOpeningReadme=尝试打开自述文件时出错。
+ErrorRestartingComputer=安装程序无法重启电脑,请手动重启。
+
+; *** 卸载消息
+UninstallNotFound=文件“%1”不存在。无法卸载。
+UninstallOpenError=文件“%1”不能被打开。无法卸载。
+UninstallUnsupportedVer=此版本的卸载程序无法识别卸载日志文件“%1”的格式。无法卸载
+UninstallUnknownEntry=卸载日志中遇到一个未知条目 (%1)
+ConfirmUninstall=您确认要完全移除 %1 及其所有组件吗?
+UninstallOnlyOnWin64=仅允许在 64 位 Windows 中卸载此程序。
+OnlyAdminCanUninstall=仅使用管理员权限的用户能完成此卸载。
+UninstallStatusLabel=正在从您的电脑中移除 %1,请稍候。
+UninstalledAll=已顺利从您的电脑中移除 %1。
+UninstalledMost=%1 卸载完成。%n%n有部分内容未能被删除,但您可以手动删除它们。
+UninstalledAndNeedsRestart=为完成 %1 的卸载,需要重启您的电脑。%n%n立即重启电脑吗?
+UninstallDataCorrupted=文件“%1”已损坏。无法卸载
+
+; *** 卸载状态消息
+ConfirmDeleteSharedFileTitle=删除共享的文件吗?
+ConfirmDeleteSharedFile2=系统表示下列共享的文件已不有其他程序使用。您希望卸载程序删除这些共享的文件吗?%n%n如果删除这些文件,但仍有程序在使用这些文件,则这些程序可能出现异常。如果您不能确定,请选择“否”,在系统中保留这些文件以免引发问题。
+SharedFileNameLabel=文件名:
+SharedFileLocationLabel=位置:
+WizardUninstalling=卸载状态
+StatusUninstalling=正在卸载 %1...
+
+; *** Shutdown block reasons
+ShutdownBlockReasonInstallingApp=正在安装 %1。
+ShutdownBlockReasonUninstallingApp=正在卸载 %1。
+
+; The custom messages below aren't used by Setup itself, but if you make
+; use of them in your scripts, you'll want to translate them.
+
+[CustomMessages]
+
+NameAndVersion=%1 版本 %2
+AdditionalIcons=附加快捷方式:
+CreateDesktopIcon=创建桌面快捷方式(&D)
+CreateQuickLaunchIcon=创建快速启动栏快捷方式(&Q)
+ProgramOnTheWeb=%1 网站
+UninstallProgram=卸载 %1
+LaunchProgram=运行 %1
+AssocFileExtension=将 %2 文件扩展名与 %1 建立关联(&A)
+AssocingFileExtension=正在将 %2 文件扩展名与 %1 建立关联...
+AutoStartProgramGroupDescription=启动:
+AutoStartProgram=自动启动 %1
+AddonHostProgramNotFound=您选择的文件夹中无法找到 %1。%n%n您要继续吗?
diff --git a/scripts/installer/peach.iss b/scripts/installer/peach.iss
new file mode 100644
index 000000000..ad311d816
--- /dev/null
+++ b/scripts/installer/peach.iss
@@ -0,0 +1,123 @@
+; Peach Windows 安装包。由 scripts/build_windows.ps1 -Installer 调用 ISCC 编译:
+; ISCC /DAppVersion=<版本> /DSourceDir=<独立目录包 Peach\> /DOutputDir=<输出目录> peach.iss
+; 装的内容与免安装包逐字节相同,差别只在程序目录固定、开始菜单项和「应用和功能」里的登记。
+; 自更新、开机自启、桌面图标和应用内卸载仍由 Peach 管,约定见 src/peach/desktop_installer.py。
+
+#ifndef AppVersion
+ #error 缺少 /DAppVersion
+#endif
+#ifndef SourceDir
+ #error 缺少 /DSourceDir
+#endif
+#ifndef OutputDir
+ #define OutputDir "."
+#endif
+
+[Setup]
+; 与 desktop_installer.APP_ID 相同;改了它,已装的机器会并排出现第二份。
+AppId={{02D9748A-78F6-4866-AC75-918177194DAB}
+AppName=Peach
+AppVersion={#AppVersion}
+AppVerName=Peach {#AppVersion}
+AppPublisher=Peach
+AppPublisherURL=https://github.com/longmeidao/peach
+AppSupportURL=https://github.com/longmeidao/peach/issues
+; 只装到当前用户:自更新在程序目录旁边建事务目录再整目录切换,Program Files 不可写。
+PrivilegesRequired=lowest
+DefaultDirName={userpf}\Peach
+; 程序目录固定。数据在 %LOCALAPPDATA%\Peach\peach-data,选到它的上层会让程序与数据重叠,
+; 自更新和应用内卸载都会因此拒绝工作。
+DisableDirPage=yes
+DisableProgramGroupPage=yes
+ArchitecturesAllowed=x64compatible
+ArchitecturesInstallIn64BitMode=x64compatible
+OutputDir={#OutputDir}
+OutputBaseFilename=Peach-{#AppVersion}-windows-x64-setup
+SetupIconFile=..\..\resources\peach.ico
+UninstallDisplayIcon={app}\Peach.exe
+UninstallDisplayName=Peach
+Compression=lzma2/max
+SolidCompression=yes
+WizardStyle=modern
+CloseApplications=yes
+RestartApplications=no
+
+[Languages]
+Name: "chs"; MessagesFile: "ChineseSimplified.isl"
+
+[CustomMessages]
+chs.StillRunning=Peach 仍在运行,未能自动退出。请从托盘菜单退出 Peach 后重试。
+chs.MigrationFailed=本地数据库未能更新到新版本,Peach 启动后可能出错。升级前的备份在数据目录的 database 文件夹里,文件名以 ledger.pre-migrate- 开头。
+chs.DataKept=Peach 已卸载。设置、本地数据库和观看记录保留在 %1,需要时可手动删除;媒体文件不受影响。
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[InstallDelete]
+; PyInstaller 的依赖都在 _internal 里;覆盖安装留下上一版多出来的库会被新版误加载。
+Type: filesandordirs; Name: "{app}\_internal"
+
+[Files]
+Source: "{#SourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
+
+[Icons]
+Name: "{userprograms}\Peach"; Filename: "{app}\Peach.exe"; Parameters: "--show"
+Name: "{userdesktop}\Peach"; Filename: "{app}\Peach.exe"; Parameters: "--show"; Tasks: desktopicon
+
+[Run]
+Filename: "{app}\Peach.exe"; Parameters: "--show"; Description: "{cm:LaunchProgram,Peach}"; Flags: nowait postinstall skipifsilent
+
+[UninstallDelete]
+; 自更新整目录换过之后,卸载记录里的文件清单不再完整,按目录整个移除。
+Type: filesandordirs; Name: "{app}"
+
+[Code]
+function DataRoot(): String;
+begin
+ Result := GetEnv('PEACH_DATA_ROOT');
+ if Result = '' then
+ Result := ExpandConstant('{localappdata}\Peach\peach-data');
+end;
+
+function PrepareToInstall(var NeedsRestart: Boolean): String;
+var
+ ResultCode: Integer;
+begin
+ Result := '';
+ { 退出码 1 是托盘没能退出;2 是不认这个参数的旧版本,交给 CloseApplications 处理。 }
+ if FileExists(ExpandConstant('{app}\Peach.exe')) then
+ if Exec(ExpandConstant('{app}\Peach.exe'), '--installer-stop', ExpandConstant('{app}'),
+ SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 1) then
+ Result := CustomMessage('StillRunning');
+end;
+
+procedure CurStepChanged(CurStep: TSetupStep);
+var
+ ResultCode: Integer;
+begin
+ { 服务启动时不迁移账本;覆盖安装换了程序,要在这里补上。没有账本的新机器不跑,
+ 否则会凭空建出账本,首次设置页就再也不出现。migrate 自己会先备份。 }
+ if (CurStep = ssPostInstall) and FileExists(DataRoot() + '\database\ledger.db') then
+ if not Exec(ExpandConstant('{app}\Peach.exe'), 'migrate upgrade --yes', ExpandConstant('{app}'),
+ SW_HIDE, ewWaitUntilTerminated, ResultCode) or (ResultCode <> 0) then
+ SuppressibleMsgBox(CustomMessage('MigrationFailed'), mbError, MB_OK, IDOK);
+end;
+
+function InitializeUninstall(): Boolean;
+var
+ ResultCode: Integer;
+begin
+ Result := True;
+ if Exec(ExpandConstant('{app}\Peach.exe'), '--installer-uninstall', ExpandConstant('{app}'),
+ SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 1) then
+ begin
+ SuppressibleMsgBox(CustomMessage('StillRunning'), mbError, MB_OK, IDOK);
+ Result := False;
+ end;
+end;
+
+procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
+begin
+ if (CurUninstallStep = usPostUninstall) and DirExists(DataRoot()) then
+ SuppressibleMsgBox(FmtMessage(CustomMessage('DataKept'), [DataRoot()]), mbInformation, MB_OK, IDOK);
+end;
diff --git a/scripts/test_runner.py b/scripts/test_runner.py
index 1b0492403..6e809c86c 100644
--- a/scripts/test_runner.py
+++ b/scripts/test_runner.py
@@ -104,7 +104,7 @@ SCOPES: dict[str, tuple[str, ...]] = {
"test_restart_windows_tray.py", "test_deploy_windows_tray.py",
"test_buildinfo.py", "test_versioning.py",
"test_windows_update.py", "test_release_updates.py", "test_automatic_updates.py", "test_standalone_update.py", "test_certs.py", "test_config.py",
- "test_fsutil.py", "test_desktop_settings.py",
+ "test_fsutil.py", "test_desktop_settings.py", "test_desktop_installer.py",
"test_job_status.py", "test_jobs.py", "test_task_runs.py", "test_followups.py",
"test_task_center_integration.py", "test_reference_updates.py",
"test_repo_hygiene.py", "test_seed_pack.py", "test_seed_followup.py",
@@ -136,7 +136,7 @@ SCOPES: dict[str, tuple[str, ...]] = {
"test_subprocess_encoding.py", "test_windows_update.py", "test_buildinfo.py"),
"packaging": ("test_dependency_policy.py", "test_buildinfo.py", "test_onboarding.py",
"test_cli.py", "test_versioning.py", "test_frontend_build.py",
- "test_cloudflared_packaging.py"),
+ "test_cloudflared_packaging.py", "test_desktop_installer.py"),
}
SCOPE_TEST_IDS: dict[str, tuple[str, ...]] = {
diff --git a/src/peach/desktop_installer.py b/src/peach/desktop_installer.py
new file mode 100644
index 000000000..bb51d6f4c
--- /dev/null
+++ b/src/peach/desktop_installer.py
@@ -0,0 +1,118 @@
+"""安装包装出的程序目录与 Peach 自己的更新、卸载、快捷方式之间的约定。
+
+安装包(`scripts/installer/peach.iss`,Inno Setup)只放程序文件、开始菜单项和「应用和功能」
+里的那一条;自更新、应用内卸载、开机自启和桌面图标仍归 Peach 自己管。两边靠三件事对上:
+
+- 程序目录里有 `unins000.exe` 就是安装包装的,免安装包没有这个文件;
+- 注册表项名由 `APP_ID` 推出,`.iss` 用同一个值,`tests/test_desktop_installer.py` 钉住两处;
+- 安装包在覆盖安装与卸载前调 `Peach.exe --installer-stop` / `--installer-uninstall`,
+ Inno Setup 调不到 Python,只能经由程序自己的入口停托盘、撤快捷方式。
+"""
+from __future__ import annotations
+
+import os
+from pathlib import Path
+import re
+import shutil
+import subprocess
+import sys
+import time
+
+from . import distribution
+
+APP_ID = "02D9748A-78F6-4866-AC75-918177194DAB"
+UNINSTALL_KEY = rf"Software\Microsoft\Windows\CurrentVersion\Uninstall\{{{APP_ID}}}_is1"
+#: 开始菜单项的文件名,与 `.iss` 的 `[Icons]` 一致。
+MENU_SHORTCUT = "Peach.lnk"
+_UNINSTALLER = re.compile(r"unins\d{3}\.(?:exe|dat|msg)", re.IGNORECASE)
+
+
+def installed(program: Path) -> bool:
+ return (program / "unins000.exe").is_file()
+
+
+def menu_shortcut() -> Path:
+ return Path(os.environ["APPDATA"]) / "Microsoft/Windows/Start Menu/Programs" / MENU_SHORTCUT
+
+
+def carry_uninstaller(source: Path, destination: Path) -> None:
+ """自更新整目录切换前,把卸载程序带进新目录。
+
+ 更新包是免安装 zip,里面没有 `unins000.*`;不带过去的话,切换之后「应用和功能」
+ 那一条指向一个已经不存在的卸载程序。
+ """
+ for path in source.iterdir():
+ if path.is_file() and _UNINSTALLER.fullmatch(path.name):
+ shutil.copy2(path, destination / path.name)
+
+
+def record_version(version: str) -> None:
+ """自更新完成后改写「应用和功能」里显示的版本;没有安装包那一条就什么都不做。"""
+ import winreg
+ try:
+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, UNINSTALL_KEY, 0, winreg.KEY_SET_VALUE) as key:
+ winreg.SetValueEx(key, "DisplayVersion", 0, winreg.REG_SZ, version)
+ except FileNotFoundError:
+ return
+
+
+def _running_from(program: Path) -> list[int]:
+ """仍从程序目录运行的进程,不含自己和自己的祖先。
+
+ 卸载时调用链是 `{app}\\unins000.exe` → 临时目录里的第二阶段 → 这个进程,第一阶段
+ 就住在程序目录里;把它算进来的话,清场会连同整棵进程树把卸载程序和自己一起结束。
+ """
+ from .windows_restart import _normal_path, _process_paths_and_parents
+ prefix = _normal_path(program) + os.sep
+ paths, parents = _process_paths_and_parents()
+ own = {os.getpid()}
+ parent = parents.get(os.getpid(), 0)
+ while parent and parent not in own:
+ own.add(parent)
+ parent = parents.get(parent, 0)
+ return [pid for pid, path in paths.items()
+ if pid not in own and _normal_path(path).startswith(prefix)]
+
+
+def stop(program: Path, *, timeout: float = 60) -> bool:
+ """让这个目录里的托盘正常退出,再结束它没收干净、仍从程序目录运行的进程。
+
+ 托盘退出时会停掉自己名下的服务;被强杀过的托盘留下的 `serve` 和转码进程不归任何
+ 托盘管,只能按镜像路径清场,否则覆盖安装写不进被占用的 DLL。
+ """
+ from .windows_restart import find_tray_windows, post_stop
+ for window in find_tray_windows(program / "Peach.exe"):
+ post_stop(window.handle)
+ deadline = time.monotonic() + timeout
+ while find_tray_windows(program / "Peach.exe"):
+ if time.monotonic() > deadline:
+ return False
+ time.sleep(.25)
+ while (strays := _running_from(program)) and time.monotonic() < deadline:
+ time.sleep(.5)
+ for pid in strays:
+ subprocess.run(["taskkill", "/PID", str(pid), "/T", "/F"], capture_output=True,
+ creationflags=subprocess.CREATE_NO_WINDOW, check=False)
+ return not _running_from(program)
+
+
+def remove_shortcuts(program: Path) -> None:
+ """撤掉这份安装自己放的开机自启与桌面图标;属于另一份安装的不动。"""
+ from . import desktop_startup, settings_file
+ try:
+ desktop_startup.save(settings_file.load_config(), enabled=False, silent=True, desktop=False,
+ executable=program / "Peach.exe")
+ except ValueError:
+ return
+
+
+def main(action: str) -> int:
+ """`--installer-stop` 与 `--installer-uninstall` 的入口,退出码给 Inno Setup 判断。"""
+ if sys.platform != "win32" or not distribution.standalone():
+ return 2
+ program = Path(sys.executable).resolve().parent
+ if not stop(program):
+ return 1
+ if action == "--installer-uninstall":
+ remove_shortcuts(program)
+ return 0
diff --git a/src/peach/desktop_uninstall.py b/src/peach/desktop_uninstall.py
index 528fe7940..4b806abb0 100644
--- a/src/peach/desktop_uninstall.py
+++ b/src/peach/desktop_uninstall.py
@@ -12,7 +12,7 @@ import time
from filelock import FileLock
-from . import desktop_startup, distribution, settings_file, standalone_update
+from . import desktop_installer, desktop_startup, distribution, settings_file, standalone_update
from .fsutil import atomic_write_text
@@ -108,6 +108,8 @@ if ($peachProcess -and -not $peachProcess.WaitForExit(90000)) { exit 3 }
foreach ($peachPath in @($peachJob.directories) + @($peachJob.files)) {
if ([IO.Path]::GetDirectoryName([IO.Path]::GetFullPath($peachPath)) -ne $peachData) { exit 2 }
}
+if ($peachJob.installer_key -and $peachJob.installer_key -notmatch '^Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\{[0-9A-F-]{36}\}_is1$') { exit 2 }
+if ($peachJob.installer_menu -and [IO.Path]::GetFileName($peachJob.installer_menu) -ne 'Peach.lnk') { exit 2 }
function Stop-PeachProgramProcesses {
# 托盘退出时被硬杀的服务会留下自己的子进程:扫描、转码用的可执行文件可能就在
# `_internal` 里。按镜像路径清场,只匹配程序目录前缀加一个分隔符,不误伤名字
@@ -165,6 +167,17 @@ try {
if ($peachJob.delete_data -and (Test-Path -LiteralPath $peachData) -and -not (Get-ChildItem -LiteralPath $peachData -Force | Select-Object -First 1)) {
Remove-Item -LiteralPath $peachData
}
+ # 安装包装的程序还有「应用和功能」里那一条和开始菜单项,程序目录删掉后它们都指向空处。
+ # 开始菜单项只在仍指向这个程序目录时才删:同名的可能是另一份安装放的。
+ if ($peachJob.installer_key) {
+ Remove-Item -LiteralPath ('HKCU:\' + $peachJob.installer_key) -Recurse -Force -ErrorAction SilentlyContinue
+ }
+ if ($peachJob.installer_menu -and (Test-Path -LiteralPath $peachJob.installer_menu)) {
+ $peachMenuTarget = (New-Object -ComObject WScript.Shell).CreateShortcut($peachJob.installer_menu).TargetPath
+ if ($peachMenuTarget -and $peachMenuTarget.StartsWith($peachProgram + [IO.Path]::DirectorySeparatorChar, [StringComparison]::OrdinalIgnoreCase)) {
+ Remove-Item -LiteralPath $peachJob.installer_menu -Force
+ }
+ }
} catch {
$peachReason = $_.Exception.Message
# 弹窗只说原因;日志另记出错的那一行,「不能对 Null 值表达式调用方法」单看查不出是哪一步。
@@ -206,7 +219,11 @@ def poll(tray) -> None:
process = subprocess.Popen([str(shell), "-NoProfile", "-NonInteractive", "-EncodedCommand",
base64.b64encode(_SCRIPT.encode("utf-16-le")).decode("ascii")],
stdin=subprocess.PIPE, creationflags=subprocess.CREATE_NO_WINDOW)
- process.stdin.write(json.dumps(dict(checked, pid=os.getpid())).encode("utf-8"))
+ job = dict(checked, pid=os.getpid())
+ if desktop_installer.installed(Path(checked["program"])):
+ job.update(installer_key=desktop_installer.UNINSTALL_KEY,
+ installer_menu=str(desktop_installer.menu_shortcut()))
+ process.stdin.write(json.dumps(job).encode("utf-8"))
process.stdin.close()
path.unlink()
tray.exit()
diff --git a/src/peach/standalone_update.py b/src/peach/standalone_update.py
index fe19cc91e..107c4ae60 100644
--- a/src/peach/standalone_update.py
+++ b/src/peach/standalone_update.py
@@ -18,7 +18,7 @@ import zipfile
import httpx
from filelock import FileLock, Timeout
-from . import distribution, release_updates
+from . import desktop_installer, distribution, release_updates
from .config import STATE_DIR, DATABASE_PATH
from .fsutil import atomic_write_text
from .windows_update import replace_with_retry
@@ -119,6 +119,7 @@ def prepare(data: dict, lock: FileLock) -> None:
if not info or info.version != release["latest_version"]:
raise ValueError("包内版本与发布版本不符")
write(data, state="preparing", progress=90, message="正在准备安装")
+ desktop_installer.carry_uninstaller(target, stage)
# 助手从自己的目录运行,正式目录与暂存目录都不会被它的 DLL 句柄占用。
helper = transaction / "helper"
shutil.copytree(target, helper, ignore=shutil.ignore_patterns("*.log"))
@@ -248,6 +249,11 @@ def apply(manifest: Path, wait_pid: int) -> int:
ready = httpx.get(spec.health_url + "?ready=1", verify=spec.verify, trust_env=False, timeout=3)
if (health.status_code == ready.status_code == 200 and health.json().get("version") == data["version"]
and ready.json().get("ready") and find_tray_windows(target / "Peach.exe")):
+ if desktop_installer.installed(target):
+ try:
+ desktop_installer.record_version(data["version"])
+ except OSError:
+ pass
write(data, state="complete", progress=100, message=f"已更新至 {data['version']}")
return 0
except (httpx.HTTPError, ValueError):
diff --git a/tests/test_cli.py b/tests/test_cli.py
index e8f9e0c89..77a47402a 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -597,6 +597,13 @@ class PackagedEntryTests(unittest.TestCase):
self.assertTrue(self.entry.wants_cli(["peach.exe", "status"]))
self.assertTrue(self.entry.wants_cli(["peach.exe", "ledger-sync"]))
+ def test_installer_hooks_reach_the_installer_handoff_not_the_tray(self):
+ with mock.patch("peach.desktop_installer.main", return_value=0) as handoff, \
+ mock.patch.object(self.entry, "tray_main") as tray:
+ self.assertEqual(self.entry.main(["peach.exe", "--installer-uninstall"]), 0)
+ handoff.assert_called_once_with("--installer-uninstall")
+ tray.assert_not_called()
+
def test_packaged_command_failure_returns_without_a_native_error_dialog(self):
output = io.StringIO()
with mock.patch.object(self.entry, "cli_main", side_effect=RuntimeError("migration failed")), mock.patch.object(
diff --git a/tests/test_desktop_installer.py b/tests/test_desktop_installer.py
new file mode 100644
index 000000000..54d63cbef
--- /dev/null
+++ b/tests/test_desktop_installer.py
@@ -0,0 +1,88 @@
+"""安装包与 Peach 自身更新、卸载机制之间的约定。"""
+from pathlib import Path
+import re
+import tempfile
+import unittest
+from unittest.mock import patch
+
+from peach import desktop_installer
+from peach.windows_restart import TrayWindow
+
+ISS = Path(__file__).resolve().parents[1] / "scripts" / "installer" / "peach.iss"
+
+
+def iss_value(pattern: str) -> str:
+ match = re.search(pattern, ISS.read_text(encoding="utf-8"), re.MULTILINE)
+ if match is None:
+ raise AssertionError(f"peach.iss 里没有 {pattern}")
+ return match.group(1)
+
+
+class InstallerContractTests(unittest.TestCase):
+ def test_installer_registers_under_the_key_peach_cleans_up(self):
+ self.assertEqual(iss_value(r"^AppId=\{\{([0-9A-F-]+)\}$"), desktop_installer.APP_ID)
+
+ def test_start_menu_entry_is_the_shortcut_peach_removes(self):
+ name = iss_value(r'^Name: "\{userprograms\}\\([^"]+)"; Filename: "\{app\}\\Peach\.exe"')
+ self.assertEqual(name + ".lnk", desktop_installer.MENU_SHORTCUT)
+
+
+class InstallerHandoffTests(unittest.TestCase):
+ def setUp(self):
+ temporary = tempfile.TemporaryDirectory()
+ self.addCleanup(temporary.cleanup)
+ self.root = Path(temporary.name)
+
+ def test_update_carries_only_the_uninstaller_into_the_new_directory(self):
+ old, new = self.root / "old", self.root / "new"
+ old.mkdir(); new.mkdir()
+ for name in ("unins000.exe", "unins000.dat", "unins000.msg", "Peach.exe", "unins.txt"):
+ (old / name).write_text(name)
+ desktop_installer.carry_uninstaller(old, new)
+ self.assertEqual(sorted(path.name for path in new.iterdir()),
+ ["unins000.dat", "unins000.exe", "unins000.msg"])
+ self.assertTrue(desktop_installer.installed(new))
+ self.assertFalse(desktop_installer.installed(self.root))
+
+ def test_entry_refuses_outside_a_standalone_windows_package(self):
+ with patch.object(desktop_installer.distribution, "standalone", return_value=False):
+ self.assertEqual(desktop_installer.main("--installer-stop"), 2)
+
+ def test_stop_waits_for_the_tray_to_exit(self):
+ windows = [(TrayWindow(10, 20),), (TrayWindow(10, 20),), ()]
+ with patch("peach.windows_restart.find_tray_windows", side_effect=lambda _: windows.pop(0)), \
+ patch("peach.windows_restart.post_stop") as post, \
+ patch.object(desktop_installer, "_running_from", return_value=[]), \
+ patch.object(desktop_installer.time, "sleep"):
+ self.assertTrue(desktop_installer.stop(self.root))
+ post.assert_called_once_with(20)
+
+ def test_the_uninstaller_that_called_us_is_not_a_stray(self):
+ program = self.root / "Peach"
+ paths = {1: str(program / "unins000.exe"), 2: str(self.root / "temp" / "_unins.tmp"),
+ 3: str(program / "Peach.exe"), 4: str(program / "_internal" / "ffmpeg.exe")}
+ parents = {2: 1, 3: 2, 4: 99}
+ with patch("peach.windows_restart._process_paths_and_parents", return_value=(paths, parents)), \
+ patch.object(desktop_installer.os, "getpid", return_value=3):
+ self.assertEqual(desktop_installer._running_from(program), [4])
+
+ def test_stop_reports_a_tray_that_never_exits(self):
+ with patch("peach.windows_restart.find_tray_windows", return_value=(TrayWindow(10, 20),)), \
+ patch("peach.windows_restart.post_stop"), \
+ patch.object(desktop_installer.time, "sleep"), \
+ patch.object(desktop_installer.time, "monotonic", side_effect=[0, 0, 100]):
+ self.assertFalse(desktop_installer.stop(self.root, timeout=1))
+
+ def test_uninstall_also_withdraws_startup_and_desktop_shortcuts(self):
+ with patch.object(desktop_installer.distribution, "standalone", return_value=True), \
+ patch.object(desktop_installer.sys, "platform", "win32"), \
+ patch.object(desktop_installer, "stop", return_value=True), \
+ patch.object(desktop_installer, "remove_shortcuts") as remove:
+ self.assertEqual(desktop_installer.main("--installer-stop"), 0)
+ remove.assert_not_called()
+ self.assertEqual(desktop_installer.main("--installer-uninstall"), 0)
+ remove.assert_called_once()
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_desktop_settings.py b/tests/test_desktop_settings.py
index a07a0c6a5..cb49ae892 100644
--- a/tests/test_desktop_settings.py
+++ b/tests/test_desktop_settings.py
@@ -370,6 +370,29 @@ class DesktopSettingsTests(unittest.TestCase):
self.assertTrue(self.root.exists(), '只删除 Peach 解压目录,不删除用户选择的父目录')
self.assertIsNotNone(held.poll())
+ @unittest.skipUnless(os.name == 'nt', 'Windows 系统卸载助手')
+ def test_native_uninstall_withdraws_what_the_installer_registered(self):
+ import uuid
+ import winreg
+ key = rf"Software\Microsoft\Windows\CurrentVersion\Uninstall\{{{str(uuid.uuid4()).upper()}}}_is1"
+ winreg.CloseKey(winreg.CreateKey(winreg.HKEY_CURRENT_USER, key))
+ self.addCleanup(lambda: subprocess.run(['reg', 'delete', 'HKCU\\' + key, '/f'], capture_output=True))
+ owned, foreign = self.root / 'menu' / 'Peach.lnk', self.root / 'other' / 'Peach.lnk'
+ owned.parent.mkdir(); foreign.parent.mkdir()
+ desktop_startup.shortcut('write', owned, target=str(self.program / 'Peach.exe'))
+ desktop_startup.shortcut('write', foreign, target=str(self.root / 'Elsewhere' / 'Peach.exe'))
+ job = desktop_uninstall.plan(self.config, delete_data=False, program=self.program)
+ result = self._run_native_uninstall(dict(job, installer_key=key, installer_menu=str(owned)))
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertFalse(owned.exists())
+ with self.assertRaises(FileNotFoundError):
+ winreg.OpenKey(winreg.HKEY_CURRENT_USER, key)
+ (self.program / '_internal').mkdir(parents=True)
+ (self.program / '_internal/standalone.txt').touch()
+ result = self._run_native_uninstall(dict(job, installer_menu=str(foreign)))
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertTrue(foreign.exists(), '同名开始菜单项指向别处时属于另一份安装')
+
@unittest.skipUnless(os.name == 'nt', 'Windows 系统卸载助手')
def test_native_uninstall_retries_until_the_file_is_released(self):
blocked = self.program / '_internal' / 'locked.bin'
diff --git a/tests/test_standalone_update.py b/tests/test_standalone_update.py
index e2dcec6d7..5216537e7 100644
--- a/tests/test_standalone_update.py
+++ b/tests/test_standalone_update.py
@@ -68,6 +68,7 @@ class StandaloneUpdateTests(unittest.TestCase):
def test_download_prepares_verified_package_without_stopping_the_app(self):
target = self.root / "installed"; target.mkdir()
(target / "Peach.exe").write_text("old")
+ (target / "unins000.exe").write_text("uninstaller")
archive = self.archive(["Peach/Peach.exe", "Peach/_internal/standalone.txt"])
with zipfile.ZipFile(archive, "a") as package:
package.writestr("Peach/_internal/build-info.json", json.dumps({"version":"1.0.0","commit":None,"built_at":"fixture"}))
@@ -87,6 +88,7 @@ class StandaloneUpdateTests(unittest.TestCase):
self.assertEqual(state["state"],"ready",state)
self.assertEqual(state["downloaded"],len(content))
self.assertTrue((Path(state["helper"])/"Peach.exe").is_file())
+ self.assertEqual((Path(state["stage"])/"unins000.exe").read_text(),"uninstaller")
self.assertEqual((target/"Peach.exe").read_text(),"old")
launch.assert_not_called()
lock.release.assert_called_once()