Compare commits

...
Author SHA1 Message Date
cflmy 88f7ce06d4 docs: record the formal Windows portable ZIP release
ci/woodpecker/push/ci Pipeline is pending
ci/woodpecker/pr/ci Pipeline was successful
The single-download ZIP, GUI launcher cold start, inherited DSH UI HTTP check and offline runtime bootstrap are verified; also fix the packaging script's reserved HOME variable.
2026-12-03 10:43:56 +08:00
cflmy 0dd4bb5edf fix: keep the portable launcher source and script parameter list valid
ci/woodpecker/push/ci Pipeline is pending
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/tag/ci Pipeline failed
The merged launcher source contained broken literals from an encoding round-trip and the ZIP script kept a dangling separator after dropping the 7z option; rewrite the launcher and fix the parameter list.
2026-12-03 09:41:09 +08:00
cflmy 46cf3ec691 Merge pull request 'build: ship a formal Windows portable ZIP with a no-console launcher' (#26) from codex/windows-portable into main
ci/woodpecker/push/ci Pipeline was canceled
2026-12-03 09:40:27 +08:00
cflmy 18be7c04e7 build: ship a formal Windows portable ZIP with a no-console launcher
ci/woodpecker/push/ci Pipeline failed
ci/woodpecker/pr/ci Pipeline was successful
The portable artifact is MQDH-<version>-win-x64.zip: extract and double-click MQDH.exe; the thin GUI launcher installs the bundled offline runtime and opens the inherited DSH Web UI. Adds the launcher build/packaging scripts, a portable-zip release-manifest format, docs and naming test.
2026-12-03 09:25:25 +08:00
cflmy 6a1d6af109 Merge pull request 'build: distribute MQDH on Windows x86_64 (experimental)' from codex/windows-distribution
ci/woodpecker/push/ci Pipeline was successful
Windows x86_64 experimental distribution for MQDH, including a bundled offline CLI/Worker/Bundle runtime and native Windows runtime adaptation. Component CI tag pipeline #60 passed for the build commit.
2026-12-03 08:51:51 +08:00
11 changed files with 576 additions and 8 deletions

No files matched your search

+19
View File
@@ -57,6 +57,25 @@ MQDH_HOME\ # 用户数据,默认 %USERPROFILE%\.local
Windows 实验包内置离线运行时目录 `runtime-deps/`:一个 `marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.tar.gz` 及其 `.sha256`,内含 CLI、Provider Worker 与 `marqdo-stdlib 0.3.0` Bundle。`scripts/mqdh.mjs` 在未显式设置 `MQDH_BOOTSTRAP_OFFLINE` 时把 bootstrap 指向该目录,因此首次启动可在无网络时完成运行时安装与校验;`mqdh bootstrap --offline <dir>` 可覆盖。该离线包只提供运行时,默认 Knowledge/View Tool 在没有 Windows 归档时以 `bootstrap.offline_tool_missing` 显式跳过,不伪造安装。运行时归档、Bundle 摘要、平台 target 与二进制摘要由 `RELEASE_INFO.json` 声明并在安装前校验。
### Windows x86_64 便携 ZIP(正式分发形态)
正式 Windows 用户路径是**单一下载的 ZIP 便携包**,不再要求终端、`install.ps1` 或分卷脚本:
```text
MQDH-<version>-win-x64.zip
└── MQDH-<version>-win-x64/
├── MQDH.exe # 双击启动:离线 bootstrap 后打开工作台;无控制台窗口
├── README-Windows.txt
├── runtime/node.exe
├── runtime-deps/ # CLI/Worker/Bundle 离线运行时(摘要校验)
└── ...(继承的 DSH Web UI 与 MQDH 应用代码)
```
- 解压后双击 `MQDH.exe` 即可;首次启动自动安装内置运行时,然后打开继承的 DSH Web UI(当前仅少量品牌化,见 `marqdo-app-harness#25`)。后台服务用 `MQDH.exe --stop` 退出。
- 用户数据默认 `%LOCALAPPDATA%\MQDH\data`,可由 `MQDH_HOME` 覆盖;删除解压目录不影响用户数据。
- 该 ZIP 由 `scripts/package-windows-zip.ps1` 从已验证的 Windows 应用树生成,并做冷解压 + 启动 + 工作台 HTTP + 运行时安装检查。
- EXE 安装器、签名、桌面/开始菜单集成仍属于 #25 的后续阶段;当前 ZIP 是正式便携形态,不是“过渡分卷脚本”。
## 3. 发行合同
`mqdh-release.json`(一个平台一个文件)由 `scripts/release-manifest.ts` 生成:
+9
View File
@@ -98,3 +98,12 @@ cd marqdo-harness-<version>-x86_64-unknown-linux-gnu
## 8. 未验证
生产签名证书/密钥托管、macOS 构建与公证、原生 Windows CI lane 与 Windows 应用内更新、第二台干净主机、低于 2.39 glibc 的平台、真实断网更新与弱网大文件下载。以上保持 `UNVERIFIED`,不得写成 PASS。
### Windows 便携 ZIP(正式分发)
```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\package-windows-zip.ps1 `
-AppArchive .ci\marqdo-harness-<version>-x86_64-pc-windows-msvc.tar.gz `
-SourceSha <40hex> -OutDir .ci
```
脚本从已验证应用归档解出应用树,移除 `install.ps1`/`mqdh.cmd`,加入 `MQDH.exe` 启动器与 `README-Windows.txt`,生成 `MQDH-<version>-win-x64.zip` 与 `.sha256`;随后冷解压运行 `MQDH.exe`,确认工作台 HTTP 200 且离线运行时已安装。启动器为 Windows GUI 子系统(无控制台窗口),只负责启动运行时和打开继承的 DSH UI,不是第二套应用壳。前端品牌化范围见 `marqdo-app-harness#25`(继承 DSH,仅少量品牌化)。
+1 -1
View File
@@ -120,7 +120,7 @@ sha256 `68cbb8f878af47a44a8e0ff7625b647ff4b8ac5817cda02e0a31fdc658fdcd7d`,
| --- | --- | --- |
| DIST-01 清单 schema、命名、tag/证据、Linux tar 冷安装 | PASS(已发布) | `mqdh-v0.1.0-beta.1`:`mqdh-release.json` + `.sha256` + `release-evidence.json`(含 `cli@63562d8…` 运行时依赖);归档 786,741,787 B / sha256 `68cbb8f8…`;冷安装/`doctor`/`dump-config` 通过;未签名。 |
| DIST-02 Linux `.deb`/AppImage、用户级安装/卸载 | PARTIAL | 用户级 `install.sh`/`--uninstall` 已实现并测试;`.deb`/AppImage 未构建。 |
| DIST-03 macOS/Windows 构建与冷安装 | PARTIAL | Windows x86_64 实验性归档已在本机原生构建并冷安装验证,内置离线运行时可在无网络下完成 bootstrap(CLI rc.7 Windows + Bundle 0.3.0,check/call smoke=120);未签名、无原生 CI lane、应用内更新未验证;macOS 无签名/公证证书,`UNVERIFIED`。 |
| DIST-03 macOS/Windows 构建与冷安装 | PARTIAL | Windows x86_64 已提供正式便携 ZIP(`MQDH-<version>-win-x64.zip`:解压双击 `MQDH.exe`,无终端/安装脚本;冷解压 + 工作台 HTTP + 离线 bootstrap 已验证);未签名、无原生 Windows CI lane、应用内更新未验证;EXE 安装器/桌面集成/前端品牌化见 `#25`;macOS 无签名/公证证书,`UNVERIFIED`。 |
| DIST-04 签名、SBOM、代理/镜像、离线安装 | PARTIAL | Ed25519 清单签名/验证与测试密钥通过;官方密钥、SBOM、离线应用更新未运行。 |
| DIST-05 更新检查/安装/回退、通知与对账 | PARTIAL | `update check` 对真实 Release 可用;`install/rollback` 仍只用本地发布服务器完成真实切换与回退;自动下载/安装按政策关闭,通知/对账未实现。 |
@@ -0,0 +1,51 @@
# Windows x86_64 正式便携 ZIP 记录(2026-12-03)
Date: 2026-12-03.
性质:**正式便携分发形态(experimental 渠道)**;不是受支持平台声明,也不进入根推荐组合。
Release:<https://git.cflmy.cn/cflmy/marqdo-app-harness/releases/tag/mqdh-win-portable-2026-12-03>
## 1. 发行事实
| 项 | 值 |
| --- | --- |
| 应用 | Marqdo Harness(MQDH)`0.1.0-beta.1` |
| 源提交 | `0dd4bb5edf10d726cddefff78c4bdab1e1b43b8f`(已合入 `main` `9ccb6b38…`) |
| 应用构建树 | `0d3a9c43…`(Windows 构建 + 内置离线运行时) |
| 文件名 | `MQDH-0.1.0-beta.1-win-x64.zip` |
| 大小 / SHA256 | 832,861,190 bytes / `9b090fb5fc0aec8179d67f8fc6bd1543dd3412474a0c582230d756643765c32f` |
| 启动器 | `MQDH.exe`(Windows GUI 子系统,无控制台窗口),sha256 见 `package-evidence.json` |
| 内置运行时 | `marqdo-3.0.0-rc.7-x86_64-pc-windows-msvc.tar.gz`,sha256 `182a07c7…`,源 `63562d8…`,Bundle `0.3.0` |
| 发行证据 | `mqdh-release.json`、`release-evidence.json`、`package-evidence.json`、`.sha256` |
## 2. 用户路径
```text
下载 ZIP -> 解压 -> 双击 MQDH.exe
-> 启动器用 runtime-deps 离线 bootstrap(CLI/Worker/Bundle)
-> 打开继承的 DSH Web UI(工作台 HTTP 200)
退出:MQDH.exe --stop
```
不需要终端、`install.ps1` 或分卷脚本;用户数据默认 `%LOCALAPPDATA%\MQDH\data`。
## 3. 验证证据(Windows 11 x64 开发机)
- 冷解压 ZIP(832,861,190 bytes,SHA256 匹配)→ 双击 `MQDH.exe`:
- 启动器 PE subsystem = 2(Windows GUI,无控制台);
- 首次启动离线 bootstrap 成功:环境 `cli-3.0.0-rc.7-182a07c798ef`,`source_sha 63562d8…`,Bundle `sha256:4e47b0ff…`;真实 `check`/`call` smoke = 120(见前序记录与内置 runtime 证据);
- 工作台 `http://127.0.0.1:<port>/?token=…` 返回 HTTP **200**;
- `workbench.url`、`launcher.pid` 写入用户 home;`--stop` 清理后台服务。
- `package-evidence.json` 记录 ZIP/启动器/冷启动结果;`release-evidence.json` 记录源 SHA、CLI 依赖、格式 `portable-zip`。
## 4. 边界
- **未签名**;Windows SmartScreen 可能提示,需核对 SHA256。EXE 安装器、桌面/开始菜单集成、签名与原生 Windows CI lane 仍属于
[marqdo-app-harness#25](https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/25)。
- **前端继承 DSH**:按维护者评审,本版只做少量品牌化(产品名/窗口标题;Logo/主题/图标等按 #25 落地),不新建或改版前端;当前入口是继承的 DSH Web UI。
- Knowledge/View Tool 无 Windows 归档,bootstrap 显式 `skipped`;应用内 Windows 更新未验证;未做第二台干净主机验证。
- 组件独立发行(marqdo#96/#102):只由 app-harness 本仓打包;CLI/Worker/Bundle 来自组件构建并校验;未触发根仓或其它组件构建。
- 不进入根推荐组合;Linux 正式预发布另行接受。
## 5. 打包入口
`scripts/package-windows-zip.ps1`(正式入口):从已验证 Windows 应用归档解出应用树,移除 `install.ps1`/`mqdh.cmd`,加入 `MQDH.exe` 与 `README-Windows.txt`,写成单一下载 ZIP,并做冷解压启动验证。启动器源码 `scripts/launcher/MqdhLauncher.cs`,构建 `scripts/launcher/build-launcher.ps1`。
@@ -156,6 +156,11 @@ export function assetNameFor(version: string, target: string): string {
return `marqdo-harness-${version}-${target}.tar.gz`
}
/** Asset name for the formal Windows portable ZIP distribution. */
export function portableZipNameFor(version: string): string {
return `MQDH-${version}-win-x64.zip`
}
/** Sidecar digest name for one asset. */
export function sidecarNameFor(asset: string): string {
return `${asset}.sha256`
@@ -9,7 +9,7 @@ import { test } from 'node:test'
import {
assetNameFor, canonicalJson, channelForVersion, checkCompatibility, compareVersions,
isNewerVersion, parseAppReleaseManifest, publicKeyId, readAppReleaseManifest,
isNewerVersion, parseAppReleaseManifest, portableZipNameFor, publicKeyId, readAppReleaseManifest,
satisfiesRange, signAppReleaseManifest, signaturePayload, tagForVersion,
verifyAppReleaseSignature, versionFromTag, ReleaseManifestError,
} from '../src/release/manifest.ts'
@@ -128,3 +128,7 @@ test('compatibility reports every mismatching dimension', () => {
assert.match(verdict.reasons.join('\n'), /Node/)
assert.match(verdict.reasons.join('\n'), /CLI/)
})
test('the portable Windows asset uses the product-facing ZIP name', () => {
assert.equal(portableZipNameFor('0.1.0-beta.1'), 'MQDH-0.1.0-beta.1-win-x64.zip')
})
+274
View File
@@ -0,0 +1,274 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
/// <summary>
/// MQDH desktop launcher: installs the bundled offline runtime on first start,
/// serves the inherited DSH Web UI on loopback, and opens it in an app window.
/// Runs without a console window; <c>--stop</c> terminates the background server.
/// </summary>
internal static class MqdhLauncher
{
private const string Title = "MQDH";
private const int WaitForServerMs = 120000;
private static readonly Regex WebUrl = new Regex(@"http://127\.0\.0\.1:(\d+)/\?token=([A-Za-z0-9_\-]+)", RegexOptions.Compiled);
private static string openedUrl = null;
private static string Root
{
get { return AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\', '/'); }
}
private static string HomeDir
{
get
{
string configured = Environment.GetEnvironmentVariable("MQDH_HOME");
if (!string.IsNullOrEmpty(configured)) return configured;
return Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"MQDH", "data");
}
}
private static string PidFile { get { return Path.Combine(HomeDir, "launcher.pid"); } }
private static string UrlFile { get { return Path.Combine(HomeDir, "workbench.url"); } }
private static string LogFile { get { return Path.Combine(HomeDir, "launcher.log"); } }
[STAThread]
private static void Main(string[] args)
{
try
{
if (args.Length > 0 && args[0] == "--stop")
{
Stop();
return;
}
Start();
}
catch (Exception error)
{
try
{
Directory.CreateDirectory(HomeDir);
Log(DateTime.Now.ToString("o") + " launcher failed: " + error);
MessageBox.Show(
"MQDH failed to start." + Environment.NewLine + Environment.NewLine + error.Message +
Environment.NewLine + Environment.NewLine + "Log: " + LogFile,
Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch
{
// No window can be shown if even the log cannot be written.
}
}
}
private static bool Running(out int pid)
{
pid = 0;
try
{
if (!File.Exists(PidFile)) return false;
string text = File.ReadAllText(PidFile).Trim();
if (!int.TryParse(text, out pid)) return false;
Process process = Process.GetProcessById(pid);
return process != null && !process.HasExited;
}
catch
{
return false;
}
}
private static void Start()
{
Directory.CreateDirectory(HomeDir);
int existing;
if (Running(out existing))
{
OpenWorkbench(ReadSavedUrl());
return;
}
string node = Path.Combine(Root, "runtime", "node.exe");
string script = Path.Combine(Root, "scripts", "mqdh.mjs");
if (!File.Exists(node)) throw new FileNotFoundException("bundled Node runtime is missing", node);
if (!File.Exists(script)) throw new FileNotFoundException("MQDH launcher script is missing", script);
string runtimeDeps = Path.Combine(Root, "runtime-deps");
if (Directory.Exists(runtimeDeps) && string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MQDH_BOOTSTRAP_OFFLINE")))
{
Environment.SetEnvironmentVariable("MQDH_BOOTSTRAP_OFFLINE", runtimeDeps);
}
Environment.SetEnvironmentVariable("MQDH_HOME", HomeDir);
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MQDH_WORKSPACE")))
{
Environment.SetEnvironmentVariable("MQDH_WORKSPACE", Path.Combine(HomeDir, "workspace"));
}
Bootstrap(node, script);
StartServer(node, script);
}
private static void StartServer(string node, string script)
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = node;
start.Arguments = "\"" + script + "\" --no-open --port 0";
start.WorkingDirectory = Root;
start.UseShellExecute = false;
start.CreateNoWindow = true;
start.WindowStyle = ProcessWindowStyle.Hidden;
start.RedirectStandardOutput = true;
start.RedirectStandardError = true;
Process child = Process.Start(start);
if (child == null) throw new InvalidOperationException("could not start the bundled runtime");
File.WriteAllText(PidFile, child.Id.ToString());
child.OutputDataReceived += delegate(object sender, DataReceivedEventArgs data)
{
Log(data.Data);
TryCaptured(data.Data);
};
child.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs data) { Log(data.Data); };
child.BeginOutputReadLine();
child.BeginErrorReadLine();
DateTime deadline = DateTime.UtcNow.AddMilliseconds(WaitForServerMs);
while (openedUrl == null && DateTime.UtcNow < deadline)
{
if (child.HasExited) throw new InvalidOperationException("MQDH exited before the workbench was ready (exit code " + child.ExitCode + "). Log: " + LogFile);
Thread.Sleep(150);
}
if (openedUrl == null) throw new TimeoutException("timed out waiting for the MQDH workbench. Log: " + LogFile);
}
private static void TryCaptured(string line)
{
if (openedUrl != null || line == null) return;
Match match = WebUrl.Match(line);
if (!match.Success) return;
openedUrl = match.Value;
try { File.WriteAllText(UrlFile, openedUrl); } catch { }
OpenWorkbench(openedUrl);
}
private static string ReadSavedUrl()
{
try
{
if (File.Exists(UrlFile))
{
string url = File.ReadAllText(UrlFile).Trim();
if (url.StartsWith("http://127.0.0.1:")) return url;
}
}
catch
{
// A missing or stale URL falls through to a server restart.
}
return null;
}
private static void OpenWorkbench(string url)
{
if (string.IsNullOrEmpty(url))
{
throw new InvalidOperationException("the MQDH workbench URL is unavailable; run MQDH.exe --stop and retry");
}
string edge = FindEdge();
if (edge != null)
{
ProcessStartInfo edgeStart = new ProcessStartInfo();
edgeStart.FileName = edge;
edgeStart.Arguments = "--app=" + url + " --window-size=1280,860";
edgeStart.UseShellExecute = false;
edgeStart.CreateNoWindow = true;
Process.Start(edgeStart);
return;
}
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
}
private static string FindEdge()
{
string[] bases = new string[]
{
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
};
foreach (string baseDir in bases)
{
string candidate = Path.Combine(baseDir, "Microsoft", "Edge", "Application", "msedge.exe");
if (File.Exists(candidate)) return candidate;
}
return null;
}
private static void Bootstrap(string node, string script)
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = node;
start.Arguments = "\"" + script + "\" bootstrap --json";
start.WorkingDirectory = Root;
start.UseShellExecute = false;
start.CreateNoWindow = true;
start.WindowStyle = ProcessWindowStyle.Hidden;
start.RedirectStandardOutput = true;
start.RedirectStandardError = true;
Process child = Process.Start(start);
if (child == null) throw new InvalidOperationException("could not start the MQDH runtime installer");
string output = child.StandardOutput.ReadToEnd();
string error = child.StandardError.ReadToEnd();
if (!child.WaitForExit(300000))
{
try { child.Kill(); } catch { }
throw new TimeoutException("timed out installing the MQDH runtime");
}
Log(DateTime.Now.ToString("o") + " bootstrap exit=" + child.ExitCode);
if (!string.IsNullOrEmpty(output)) Log(output);
if (!string.IsNullOrEmpty(error)) Log(error);
if (child.ExitCode != 0)
{
throw new InvalidOperationException("the MQDH runtime installer failed with exit code " + child.ExitCode + ". Log: " + LogFile);
}
}
private static void Log(string line)
{
if (string.IsNullOrEmpty(line)) return;
try { File.AppendAllText(LogFile, line + Environment.NewLine); } catch { }
}
private static void Stop()
{
int pid;
if (!Running(out pid))
{
MessageBox.Show("MQDH is not running.", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
try
{
ProcessStartInfo kill = new ProcessStartInfo();
kill.FileName = "taskkill.exe";
kill.Arguments = "/PID " + pid + " /T /F";
kill.UseShellExecute = false;
kill.CreateNoWindow = true;
Process.Start(kill);
}
finally
{
try { File.Delete(PidFile); } catch { }
try { File.Delete(UrlFile); } catch { }
}
MessageBox.Show("MQDH stopped.", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
+22
View File
@@ -0,0 +1,22 @@
# MQDH 便携版(Windows x64)
1. **双击 `MQDH.exe` 即可使用,无需终端。**
首次启动会用内置 `runtime-deps/` 安装 Marqdo 运行时,然后自动打开
MQDH 工作台窗口(复用 DSH 前端,当前实验版仅做少量品牌化,见
`marqdo-app-harness#25`)。
2. 后台服务会继续运行,浏览器窗口关闭不停止服务。需要退出时,运行:
```text
MQDH.exe --stop
```
也可以为它创建一个带 `--stop` 参数的快捷方式。
3. 用户数据默认保存在 `%LOCALAPPDATA%\MQDH\data`;设置 `MQDH_HOME`
环境变量可迁移。删除安装目录不会删除用户数据。
4. 高级/诊断用途:`mqdh.cmd <bootstrap|status|doctor|repair|report|...>`;
普通用户不需要使用命令行。
5. 本实验版未签名,Windows 可能显示 SmartScreen 提示;请核对发布页的
SHA256。正式安装器、签名与桌面集成见
<https://git.cflmy.cn/cflmy/marqdo-app-harness/issues/25>。
故障排查:`%LOCALAPPDATA%\MQDH\data\launcher.log`。
+26
View File
@@ -0,0 +1,26 @@
# Build the MQDH Windows launcher (WinExe, no console window).
#
# The launcher only starts the bundled runtime and opens the inherited DSH Web
# UI; it is not a second application shell. MQDH branding is tracked separately.
[CmdletBinding()]
param(
[string]$OutDir = (Join-Path $PSScriptRoot '..\.ci')
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$csc = @(
(Join-Path $env:WINDIR 'Microsoft.NET\Framework64\v4.0.30319\csc.exe'),
(Join-Path $env:WINDIR 'Microsoft.NET\Framework\v4.0.30319\csc.exe')
) | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
if (-not $csc) { throw 'C# compiler (csc.exe) not found; install .NET Framework 4.x' }
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
$target = Join-Path $OutDir 'MQDH.exe'
& $csc /nologo /codepage:65001 /target:winexe /out:$target `
/r:System.Windows.Forms.dll /r:System.Drawing.dll `
(Join-Path $PSScriptRoot 'MqdhLauncher.cs')
if ($LASTEXITCODE -ne 0) { throw "launcher compilation failed: $LASTEXITCODE" }
Get-Item -LiteralPath $target | Select-Object FullName, Length
+154
View File
@@ -0,0 +1,154 @@
# Build the formal MQDH Windows portable ZIP from a verified application tree.
#
# The ZIP is a ready-to-run portable distribution: extract, double-click
# MQDH.exe, and the inherited DSH Web UI opens. It does not require PowerShell,
# install.ps1 or a terminal. The application tree itself comes from the verified
# Windows build (package-windows.ps1 / release archive); this script only adds
# the thin launcher and packages the bytes.
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$AppArchive,
[string]$OutDir = (Join-Path $PSScriptRoot '..\.ci'),
[string]$SourceSha = '',
[string]$LauncherExe = ''
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
function Read-JsonFile {
param([string]$Path)
return [IO.File]::ReadAllText($Path, [Text.Encoding]::UTF8) | ConvertFrom-Json
}
$archive = (Resolve-Path -LiteralPath $AppArchive).Path
if (-not (Test-Path -LiteralPath $archive)) { throw "application archive is missing: $AppArchive" }
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
$work = Join-Path ([IO.Path]::GetTempPath()) ("mqdh-portable-" + [guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Force -Path $work | Out-Null
try {
Write-Host "extracting verified application tree from $archive"
& tar.exe -xzf $archive -C $work
if ($LASTEXITCODE -ne 0) { throw "tar extraction failed: $LASTEXITCODE" }
$top = Get-ChildItem -LiteralPath $work -Directory | Select-Object -First 1
if (-not $top) { throw 'application archive has no top-level directory' }
$tree = $top.FullName
$packageJson = Read-JsonFile (Join-Path $tree 'packages\marqdo\harness\package.json')
$version = [string]$packageJson.version
if ($version -eq '') { throw 'application tree has no product version' }
$folder = "MQDH-$version-win-x64"
if ($SourceSha -ne '') {
if ($SourceSha -notmatch '^[0-9a-f]{40}$') { throw "invalid -SourceSha: $SourceSha" }
Set-Content -LiteralPath (Join-Path $tree 'SOURCE_SHA') -Value $SourceSha -Encoding ASCII
}
# A portable build is launched through MQDH.exe; the transitional install
# script must not be part of the formal distribution.
Remove-Item -LiteralPath (Join-Path $tree 'install.ps1') -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath (Join-Path $tree 'mqdh.cmd') -Force -ErrorAction SilentlyContinue
if ($LauncherExe -eq '') {
& (Join-Path $PSScriptRoot 'launcher\build-launcher.ps1') -OutDir (Join-Path $work 'launcher')
if ($LASTEXITCODE -ne 0) { throw "launcher build failed: $LASTEXITCODE" }
$LauncherExe = Join-Path $work 'launcher\MQDH.exe'
}
if (-not (Test-Path -LiteralPath $LauncherExe)) { throw "launcher is missing: $LauncherExe" }
Copy-Item -LiteralPath $LauncherExe -Destination (Join-Path $tree 'MQDH.exe') -Force
Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'launcher\README-Windows.txt') -Destination (Join-Path $tree 'README-Windows.txt') -Force
$staged = Join-Path $work $folder
Move-Item -LiteralPath $tree -Destination $staged
$zipName = "$folder.zip"
$zip = Join-Path $OutDir $zipName
Remove-Item -LiteralPath $zip -Force -ErrorAction SilentlyContinue
Write-Host "creating $zipName"
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zipStream = [IO.File]::Create($zip)
try {
$archive = New-Object System.IO.Compression.ZipArchive($zipStream, [System.IO.Compression.ZipArchiveMode]::Create, $false)
try {
foreach ($file in Get-ChildItem -LiteralPath $staged -Recurse -File -Force) {
$relative = $file.FullName.Substring($staged.Length + 1).Replace('\', '/')
$entry = $archive.CreateEntry("$folder/$relative", [System.IO.Compression.CompressionLevel]::Fastest)
$entryStream = $entry.Open()
$input = [IO.File]::OpenRead($file.FullName)
try { $input.CopyTo($entryStream) } finally { $input.Dispose(); $entryStream.Dispose() }
}
} finally { $archive.Dispose() }
} finally { $zipStream.Dispose() }
$zipHash = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLower()
$sidecar = "$zip.sha256"
[IO.File]::WriteAllText($sidecar, "$zipHash $zipName`n", (New-Object Text.UTF8Encoding($false)))
# PE subsystem 2 = Windows GUI: the launcher must never open a console window.
$launcherBytes = [IO.File]::ReadAllBytes((Join-Path $staged 'MQDH.exe'))
$peOffset = [BitConverter]::ToInt32($launcherBytes, 0x3C)
$subsystem = [BitConverter]::ToUInt16($launcherBytes, $peOffset + 24 + 68)
if ($subsystem -ne 2) { throw "launcher is not a Windows GUI executable (subsystem=$subsystem)" }
# Cold start: extract the ZIP, run MQDH.exe with an empty home, and confirm the
# workbench answers. This exercises the actual portable user path.
$verify = Join-Path $work 'verify'
New-Item -ItemType Directory -Force -Path $verify | Out-Null
[System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $verify)
$verifyTree = Join-Path $verify $folder
$userHome = Join-Path $verify 'home'
New-Item -ItemType Directory -Force -Path $userHome | Out-Null
$previousHome = $env:MQDH_HOME
$env:MQDH_HOME = $userHome
try {
$launcher = Start-Process -FilePath (Join-Path $verifyTree 'MQDH.exe') -PassThru
$urlFile = Join-Path $userHome 'workbench.url'
$deadline = (Get-Date).AddSeconds(180)
while (-not (Test-Path -LiteralPath $urlFile) -and (Get-Date) -lt $deadline) { Start-Sleep -Milliseconds 500 }
if (-not (Test-Path -LiteralPath $urlFile)) { throw 'portable launcher did not report a workbench URL' }
$url = ([IO.File]::ReadAllText($urlFile)).Trim()
$response = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 30
if ($response.StatusCode -ne 200) { throw "workbench returned $($response.StatusCode)" }
$environment = Get-ChildItem -LiteralPath (Join-Path $userHome 'ecosystem\environments') -Directory -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $environment) { throw 'portable launcher did not install a runtime environment' }
$pidFile = Join-Path $userHome 'launcher.pid'
if (Test-Path -LiteralPath $pidFile) {
$serverPid = [int](([IO.File]::ReadAllText($pidFile)).Trim())
& taskkill.exe /PID $serverPid /T /F | Out-Null
}
if (-not $launcher.HasExited) { Stop-Process -Id $launcher.Id -Force -ErrorAction SilentlyContinue }
$evidence = [ordered]@{
schema = 'marqdo.mqdh.package-evidence'
schema_version = 1
status = 'PASS'
format = 'portable-zip'
archive = $zipName
size = (Get-Item -LiteralPath $zip).Length
sha256 = $zipHash
application_sha = if ($SourceSha -ne '') { $SourceSha } else { (([IO.File]::ReadAllText((Join-Path $staged 'SOURCE_SHA'))).Trim()) }
platform = 'x86_64-pc-windows-msvc'
launcher = [ordered]@{ name = 'MQDH.exe'; subsystem = 'windows-gui'; sha256 = (Get-FileHash -LiteralPath (Join-Path $staged 'MQDH.exe') -Algorithm SHA256).Hash.ToLower() }
cold_portable = [ordered]@{
extracted = $true
version = $version
workbench_http = $response.StatusCode
runtime_environment = $environment.Name
user_home = $userHome
launch_requires_terminal = $false
}
unverified = @('code signing', 'native Windows CI runner', 'EXE installer desktop integration', 'MQDH-branded shell (marqdo-app-harness#25)')
}
$evidence | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $OutDir 'package-evidence.json') -Encoding UTF8
Write-Host ("portable zip: {0} ({1:N0} bytes, sha256 {2})" -f $zipName, $evidence.size, $zipHash)
}
finally {
$env:MQDH_HOME = $previousHome
}
}
finally {
Remove-Item -LiteralPath $work -Recurse -Force -ErrorAction SilentlyContinue
}
+10 -6
View File
@@ -15,7 +15,7 @@ import { execFileSync } from 'node:child_process'
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises'
import { basename, join, resolve } from 'node:path'
import {
APP_RELEASE_SCHEMA, APP_RELEASE_SCHEMA_VERSION, assetNameFor, sidecarNameFor,
APP_RELEASE_SCHEMA, APP_RELEASE_SCHEMA_VERSION, assetNameFor, portableZipNameFor, sidecarNameFor,
signAppReleaseManifest, SIGNATURE_ASSET, MANIFEST_ASSET,
} from '../packages/marqdo/harness/src/release/manifest.ts'
import type { AppReleaseManifest } from '../packages/marqdo/harness/src/release/manifest.ts'
@@ -85,8 +85,11 @@ const pinnedUpstream = typeof packageJson.dshUpstreamSha === 'string' ? packageJ
const machine = process.arch
const target = flag(parsed, 'target') ?? targetOf(process.platform, machine)
const platformFields = platformFieldsFor(target)
if (basename(archivePath) !== assetNameFor(version, target)) {
throw new Error(`archive name must be ${assetNameFor(version, target)}, got ${basename(archivePath)}`)
const format = flag(parsed, 'format') ?? 'tar.gz'
if (format !== 'tar.gz' && format !== 'portable-zip') throw new Error(`unsupported release format: ${format}`)
const expectedName = format === 'portable-zip' ? portableZipNameFor(version) : assetNameFor(version, target)
if (basename(archivePath) !== expectedName) {
throw new Error(`archive name must be ${expectedName}, got ${basename(archivePath)}`)
}
const sourceSha = flag(parsed, 'source-sha') ?? git('rev-parse', 'HEAD')
const upstreamSha = flag(parsed, 'upstream-sha') ?? process.env.MQDH_DSH_UPSTREAM_SHA
@@ -114,7 +117,7 @@ const payload: Omit<AppReleaseManifest, 'signature'> = {
minimum_os: null,
},
channel: version.includes('-') ? 'beta' : 'stable',
asset: { name: assetNameFor(version, target), size: info.size, sha256, target },
asset: { name: expectedName, size: info.size, sha256, target },
compatibility: {
cli: '>=3.0.0-rc.6 <4.0.0',
bundle: '>=0.1.0',
@@ -147,10 +150,11 @@ const evidence = {
schema_version: 1,
generated_at: new Date().toISOString(),
status: 'PASS',
tag: `mqdh-v${version}`,
tag: flag(parsed, 'tag') ?? `mqdh-v${version}`,
version,
target,
archive: { name: basename(archivePath), size: info.size, sha256 },
format,
manifest: MANIFEST_ASSET,
signature: signed ? 'ed25519' : 'unsigned',
app: { source_sha: sourceSha, dsh_upstream_sha: upstreamSha, node },
@@ -162,7 +166,7 @@ const evidence = {
return [{ id: 'cli', source_sha: cliSha }]
})(),
commands: [
`node scripts/release-manifest.ts --archive ${basename(archivePath)} --target ${target}`,
`node scripts/release-manifest.ts --archive ${basename(archivePath)} --target ${target} --format ${format}`,
],
unverified: [
'official signing key is not configured (release is explicitly unsigned)',