DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(linux): 剔除 AppImage 过度打包的宿主显示栈库,修复启动即崩(#620)
hairyfbff9c84e3112
diff --git a/.gitattributes b/.gitattributesindex c733bd36..8f9b805f 100644--- a/.gitattributes+++ b/.gitattributes@@ -10,6 +10,7 @@*.toml text eol=lf*.js text eol=lf*.mjs text eol=lf+*.sh text eol=lf*.ico binary*.icns binary*.png binarydiff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.ymlindex 7216423d..638e0b69 100644--- a/.github/workflows/build-linux.yml+++ b/.github/workflows/build-linux.yml@@ -53,7 +53,8 @@ jobs:sleep 10done[ "$apt_ok" = "1" ] || { echo "apt-get update 连续 3 次失败,中止"; exit 1; }- sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf+ # squashfs-tools 提供 mksquashfs,供 AppImage 宿主库剔除后重打包使用。+ sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf squashfs-tools- name: Install frontend dependenciesrun: pnpm install --frozen-lockfile@@ -64,6 +65,21 @@ jobs:TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}run: pnpm tauri build --bundles appimage,deb+ # Tauri 固定的 linuxdeploy 会把构建镜像的 libwayland-*/libxkbcommon/libxcb/+ # libXau/libXdmcp 一并打进 AppImage,AppRun 又把这些库置于 LD_LIBRARY_PATH 首位;+ # 较新发行版(Arch/CachyOS、Fedora 44…)的宿主 Mesa 因而加载到旧库,EGL 协商失败,+ # WebKit 在 eglGetDisplay 失败时直接 abort()——WebKitWebProcess SIGABRT、无窗口无日志+ #(上游 tauri#15976,本仓 #620)。.deb 用系统库,不受影响。+ # 必须在签名/上传之前完成:本步会重写 AppImage 字节。+ - name: Drop over-bundled host-interface libs from the AppImage+ shell: bash+ run: |+ mapfile -d '' appimages < <(find src-tauri/target/release/bundle/appimage -name '*.AppImage' -print0)+ [ "${#appimages[@]}" -gt 0 ] || { echo '::error::no AppImage was produced'; exit 1; }+ for appimage in "${appimages[@]}"; do+ bash scripts/fix-appimage-host-libs.sh --require-removal "$appimage"+ done+- name: Upload build outputsuses: actions/upload-artifact@v6with:diff --git a/README.en.md b/README.en.mdindex bebf3f52..d8375d4e 100644--- a/README.en.md+++ b/README.en.md@@ -93,6 +93,8 @@ The first run downloads the Node runtime and Harness core (if `dsh` is already i**System requirements:** Windows 10+ · macOS 10.15+ · Linux (AppImage / .deb) · network on first launch · Harness core **0.1.5-rc.2** or later> **Linux Wayland note (PikaOS / GNOME Wayland / Ubuntu 22.04+):** AppImage may crash or render black on Wayland due to WebKitGTK; the app auto-fixes the common case. <details><summary>If it still crashes / renders black:</summary><br>**Prefer `.deb`** (verified on PikaOS 4 Wayland), or manually run `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`. If icons do not appear, copy the app's `hicolor` icons to `~/.local/share/icons` and run `update-desktop-database`.<br></details>+>+> **Rolling-release Linux starts and dies at once (Arch / CachyOS / Fedora, …):** older AppImages bundled the build image's (Ubuntu 22.04) display-stack libs such as `libwayland-client`. A newer host Mesa is ABI-incompatible with them, so `WebKitWebProcess` calls `abort()` — the app shows **no window and no logs at all**. The build now strips these libs (see `.github/workflows/build-linux.yml` and `scripts/fix-appimage-host-libs.sh`); use a release built after that change. If you are still affected, use the `.deb`, or `LD_PRELOAD=/usr/lib/libwayland-client.so.0 ./AppImage` (adjust the path for your distro).## Communitydiff --git a/README.es.md b/README.es.mdindex 1765bf02..45be1425 100644--- a/README.es.md+++ b/README.es.md@@ -92,6 +92,8 @@ El primer arranque descarga el runtime de Node y el núcleo Harness (si `dsh` ya**Requisitos:** Windows 10+ · macOS 10.15+ · Linux (AppImage / .deb) · red en el primer arranque · núcleo Harness **0.1.5-rc.2** o superior> **Nota Wayland en Linux (PikaOS / GNOME Wayland / Ubuntu 22.04+):** el AppImage puede crashear o verse negro en Wayland por WebKitGTK; la app corrige sola el caso común. <details><summary>Si igual crashea / se ve negro:</summary><br>**Preferí el `.deb`** (verificado en PikaOS 4 Wayland), o ejecutá a mano `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`. Si no aparecen los iconos, copiá los iconos `hicolor` de la app a `~/.local/share/icons` y ejecutá `update-desktop-database`.<br></details>+>+> **Linux de liberación continua arranca y muere al instante (Arch / CachyOS / Fedora, …):** los AppImage antiguos empaquetaban las librerías de la pila de display de la imagen de build (Ubuntu 22.04), como `libwayland-client`. Un Mesa más nuevo del sistema es incompatible a nivel ABI con ellas, así que `WebKitWebProcess` llama a `abort()`: la app **no muestra ninguna ventana ni ningún log**. El build ya elimina esas librerías (ver `.github/workflows/build-linux.yml` y `scripts/fix-appimage-host-libs.sh`); usá una versión publicada después de ese cambio. Si igual te afecta, usá el `.deb`, o `LD_PRELOAD=/usr/lib/libwayland-client.so.0 ./AppImage` (ajustá la ruta según tu distro).## Comunidaddiff --git a/README.md b/README.mdindex b288ad5d..63d8e7b7 100644--- a/README.md+++ b/README.md@@ -88,6 +88,8 @@ brew install dsh-tauri/desktop/deepseek-harness**系统要求:** Windows 10+ · macOS 10.15+ · Linux(AppImage / .deb)· 首次运行需要网络 · Harness 内核 **0.1.5-rc.2** 或更高> **Linux Wayland 注意(PikaOS / GNOME Wayland / Ubuntu 22.04+):** AppImage 在 Wayland 下可能因 WebKitGTK 黑屏/崩溃,应用已自动处理常见情形。 <details><summary>若仍黑屏/崩溃:</summary><br>**改用 `.deb`**(已验证 PikaOS 4 Wayland),或手动 `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`。图标不显示时,将应用内 `hicolor` 图标复制到 `~/.local/share/icons` 并运行 `update-desktop-database`。<br></details>+>+> **Linux 滚动发行版启动即崩(Arch / CachyOS / Fedora 等):** 旧版 AppImage 会随包携带构建镜像(Ubuntu 22.04)的 `libwayland-client` 等显示栈库,较新的宿主 Mesa 与之 ABI 不匹配会导致 `WebKitWebProcess` 直接 `abort()`——表现为**双击后没有任何界面、也没有任何日志**。构建阶段已剔除这些库(见 `.github/workflows/build-linux.yml` 与 `scripts/fix-appimage-host-libs.sh`),请使用修复后发布的版本;仍受影响时可用 `.deb`,或 `LD_PRELOAD=/usr/lib/libwayland-client.so.0 ./AppImage`(路径按发行版调整)。## 交流diff --git a/docs/specs/agents.desktop.md b/docs/specs/agents.desktop.mdindex 769be37a..dfb12835 100644--- a/docs/specs/agents.desktop.md+++ b/docs/specs/agents.desktop.md@@ -197,4 +197,5 @@ function ConfirmDialog(props: ConfirmDialogProps) {* **Windows `.cmd` shim 行尾 (Issue #581)**:`.gitattributes` 把 `.rs` 固定为 LF,生成的 `dsh.cmd`/`pnpm.cmd` 必须在返回前统一转 CRLF(`normalize_cmd_line_endings`),LF-only 会让部分环境下 cmd.exe 解析错位、内置插件安装全部失败。* **本地核心低于内置插件基线 (Issue #596)**:内置插件在构建期按 catalog 的 dsh 版本编译,`scripts/build-plugins.ts` 会把整个 `@deepseek-ai` scope 从产物里删掉,client bundle 只能靠运行时模块表解析这些模块。核心低于该基线时模块表里根本没有它们(`@deepseek-ai/dsh-client-store` 首版为 dsh 0.1.2-alpha.2,0.1.5 起才是平台种子词),插件加载必然失败并把应用卡在启动阶段。`service::core::source::core_supports_bundled_plugins` 以 `version-recommend.json` 的推荐核心版本为基线(与 catalog 同源):低于基线的本地核心不参与「本地优先」并回退预打包核心(日志标记 `CORE_LOCAL_UNSUPPORTED`),`set_active("local")` 同样拒绝;持久化的 `active_core` 不改写,用户升级本地核心后自动恢复。核心面板据此标注「不兼容」并给出更新提示。* **macOS 媒体权限配置 (Issue #214)**:必须同时在 `Info.plist` (声明 Usage Description) 与 `Entitlements.plist` (声明 `com.apple.security.device.*`) 中配置,相对路径基于 tauri bundle 运行时的 CWD 目录。+* **AppImage 过度打包宿主显示栈库 (Issue #620)**:Tauri 固定的 linuxdeploy 会把构建镜像(ubuntu-22.04)的 `libwayland-{client,cursor,egl,server}`、`libxkbcommon`、`libxcb-{randr,render,shm}`、`libXau`、`libXdmcp` 共 10 个库打进 `usr/lib`,而 `AppRun.wrapped` 又把 `$APPDIR/usr/lib` 置于 `LD_LIBRARY_PATH` 首位。较新发行版(Arch/CachyOS、Fedora 44…)的宿主 Mesa 因此加载到旧库、`eglGetDisplay` 返回 `EGL_BAD_PARAMETER`,WebKit 视之为致命错误直接 `abort()`——表现为 `WebKitWebProcess` SIGABRT、无窗口且用户侧无任何运行日志(上游 tauri#15976)。`.deb` 用系统库不受影响。修法:`scripts/fix-appimage-host-libs.sh` 在构建后(**签名/上传之前**,会重写字节)剔除这 10 个库并按原 squashfs 参数(zstd / 128K block)复用原 runtime 前缀重打包;`build-linux.yml` 带 `--require-removal` 调用,将来 bundler 不再过度打包时构建会明确失败而非静默回归。**不要**顺手剔除 `libEGL`/`libGL`/`libgbm`/`libdrm`:linuxdeploy 的 excludelist 本就没打包它们。* **Linux 托盘点击适配 (Issue #386/#438)**:Linux 环境下通过 `linux_tray.rs` 基于 `tray-icon 0.25 (ksni)` 单独构建托盘,避免 muda 依赖版本冲突,通过 `Box::leak` 保活并在独立线程中处理事件。\ No newline at end of filediff --git a/scripts/fix-appimage-host-libs.sh b/scripts/fix-appimage-host-libs.shnew file mode 100755index 00000000..a9b0ca21--- /dev/null+++ b/scripts/fix-appimage-host-libs.sh@@ -0,0 +1,223 @@+#!/usr/bin/env bash+#+# 剔除 AppImage 内过度打包的「宿主接口」显示栈库(上游 tauri#15976,本仓 #620)。+#+# Tauri 固定使用的 linuxdeploy 会把构建镜像(ubuntu-22.04)的+# libwayland-*、libxkbcommon、libxcb-{randr,render,shm}、libXau、libXdmcp+# 一并塞进 usr/lib,而 AppRun.wrapped 又把 $APPDIR/usr/lib 放在 LD_LIBRARY_PATH+# 首位。较新发行版(Arch/CachyOS、Fedora 44…)的宿主 Mesa 因此加载到这些旧库,+# EGL 协商失败;WebKit 把 eglGetDisplay 失败当作致命错误直接 abort(),于是+# WebKitWebProcess 以 SIGABRT 退出、主窗口从未出现,用户侧看不到任何运行日志。+# 宿主安装包(.deb/.rpm)用系统 WebKit + 系统库,因此不受影响。+#+# 这 10 个库是「宿主 ↔ 驱动」的接口,必须用宿主版本(ABI 上向下兼容的落地替换,+# tauri#15976 已用同一份最小集合复现修复)。libEGL/libGL/libgbm/libdrm 不在剔除+# 之列:linuxdeploy 自带的 excludelist 本来就没有打包它们,误删反而会破坏渲染。+#+# 重打包复用原 AppImage 自带的 runtime 前缀(head -c <offset>),不调用+# appimagetool:既不用额外下载,也不依赖上游 floating tag,结果可复现。+set -euo pipefail++readonly EXCLUDED_LIBS=(+ libwayland-client.so.0+ libwayland-cursor.so.0+ libwayland-egl.so.1+ libwayland-server.so.0+ libxkbcommon.so.0+ libxcb-randr.so.0+ libxcb-render.so.0+ libxcb-shm.so.0+ libXau.so.6+ libXdmcp.so.6+)++# 与 linuxdeploy 产出的 squashfs 对齐(实测 zstd / 128K block / 单一 root id)。+readonly SQUASHFS_COMPRESSION=zstd+readonly SQUASHFS_BLOCK_SIZE=131072++# 在镜像中扫描 squashfs 4.0 superblock:magic "hsqs",且 s_major/s_minor == 4/0,+# block_size 为 2 的幂且在 [4096, 1048576],compression 在 1..6。Type-2 AppImage 的+# 尾部是 ELF runtime,正文里还可能出现字面量 "hsqs",因此必须按 superblock 字段校验,+# 而不是命中第一个 magic 就返回(实测镜像里第一个 "hsqs" 是误报)。+detect_squashfs_offset() {+ local file="$1"+ python3 - "$file" <<'PY'+import struct+import sys++path = sys.argv[1]+with open(path, 'rb') as handle:+ data = handle.read()++start = 0+while True:+ index = data.find(b'hsqs', start)+ if index < 0:+ break+ start = index + 1+ if index + 32 > len(data):+ continue+ magic, _inodes, _mtime, block_size, _fragments, compression, block_log, _flags = \+ struct.unpack_from('<IIIIIHHH', data, index)+ if magic != 0x73717368:+ continue+ if block_size < 4096 or block_size > 1048576 or block_size & (block_size - 1):+ continue+ if compression < 1 or compression > 6:+ continue+ if (1 << block_log) != block_size:+ continue+ print(index)+ sys.exit(0)+sys.exit(1)+PY+}++usage() {+ echo "usage: $(basename "$0") [--require-removal] <path-to.AppImage>" >&2+}++# CI 用 --require-removal:linuxdeploy 升级后若不再过度打包这些库,剔除会静默变成+# no-op,届时 #620 会悄悄回归。要求「至少剔掉一个」把这种退化变成构建失败。+require_removal=0+if [ "${1:-}" = "--require-removal" ]; then+ require_removal=1+ shift+fi++appimage="${1:-}"+if [ -z "$appimage" ]; then+ usage+ exit 2+fi+if [ ! -f "$appimage" ]; then+ echo "fix-appimage-host-libs: no such file: $appimage" >&2+ exit 1+fi++appimage="$(cd "$(dirname "$appimage")" && pwd)/$(basename "$appimage")"++for tool in mksquashfs unsquashfs; do+ if ! command -v "$tool" >/dev/null 2>&1; then+ echo "fix-appimage-host-libs: required tool not found: $tool (install squashfs-tools)" >&2+ exit 1+ fi+done++work="$(mktemp -d)"+trap 'rm -rf "$work"' EXIT++cp "$appimage" "$work/in.AppImage"+chmod +x "$work/in.AppImage"++# 先让 AppImage 自带 runtime 报出 squashfs 偏移并解包(不挂载 FUSE,容器里可直接跑)。+# runtime 不可执行时(noexec 挂载等)退回扫描 superblock + unsquashfs -o。+offset=""+if offset="$("$work/in.AppImage" --appimage-offset 2>/dev/null)" && [ -n "$offset" ]; then+ case "$offset" in+ *[!0-9]*)+ echo "fix-appimage-host-libs: unexpected AppImage offset: $offset" >&2+ exit 1+ ;;+ esac+else+ # 注意 set -e:赋值里的命令替换失败会直接终止脚本,因此必须用 `|| true` 兜住,+ # 否则扫描失败时既拿不到下面的明确报错,也看不到自己写的诊断信息。+ offset="$(detect_squashfs_offset "$work/in.AppImage" || true)"+ if [ -z "$offset" ]; then+ echo "fix-appimage-host-libs: runtime unusable and no squashfs superblock found in $appimage" >&2+ exit 1+ fi+ echo "fix-appimage-host-libs: runtime unusable, scanned squashfs offset $offset"+fi++tree="$work/squashfs-root"+if ! (+ cd "$work"+ ./in.AppImage --appimage-extract >/dev/null 2>&1+) || [ ! -d "$tree" ]; then+ rm -rf "$tree"+ if ! unsquashfs -o "$offset" -d "$tree" "$work/in.AppImage" >/dev/null; then+ echo "fix-appimage-host-libs: extraction failed (runtime and unsquashfs)" >&2+ exit 1+ fi+fi+if [ ! -d "$tree" ]; then+ echo "fix-appimage-host-libs: extraction produced no root directory" >&2+ exit 1+fi++removed=()+for lib in "${EXCLUDED_LIBS[@]}"; do+ while IFS= read -r found; do+ rm -f "$found"+ removed+=("${found#"$tree"/}")+ done < <(find "$tree" -name "$lib" -print)+done++if [ "${#removed[@]}" -eq 0 ]; then+ if [ "$require_removal" -eq 1 ]; then+ echo "fix-appimage-host-libs: none of the host-interface libs were bundled, but" >&2+ echo " --require-removal was requested: the over-bundling this guards against (#620)" >&2+ echo " is no longer happening, or the bundler changed. Re-verify before dropping the fix." >&2+ exit 1+ fi+ echo "fix-appimage-host-libs: none of the host-interface libs were bundled, nothing to do"+ exit 0+fi++echo "fix-appimage-host-libs: removed from AppDir:"+printf ' %s\n' "${removed[@]}"++head -c "$offset" "$work/in.AppImage" > "$work/out.AppImage"+mksquashfs "$tree" "$work/fs.squashfs" \+ -comp "$SQUASHFS_COMPRESSION" \+ -b "$SQUASHFS_BLOCK_SIZE" \+ -all-root -mkfs-time 0 -no-xattrs -noappend -no-progress -quiet+cat "$work/fs.squashfs" >> "$work/out.AppImage"+chmod +x "$work/out.AppImage"++# 交付前自检:库确实消失、AppRun 与主程序仍在、新镜像仍能被 runtime 解析。+# 在独立目录解包,避免与已剔除的 $tree 混在一起而看漏残留库。+verify="$work/verify"+mkdir -p "$verify"+verdict=0+if (+ cd "$verify"+ ../out.AppImage --appimage-extract >/dev/null 2>&1+) && [ -d "$verify/squashfs-root" ]; then+ verified="$verify/squashfs-root"+else+ rm -rf "$verify/squashfs-root"+ if unsquashfs -o "$offset" -d "$verify/squashfs-root" "$work/out.AppImage" >/dev/null 2>&1; then+ verified="$verify/squashfs-root"+ else+ echo "fix-appimage-host-libs: verification failed, repacked image cannot be extracted" >&2+ exit 1+ fi+fi++for lib in "${EXCLUDED_LIBS[@]}"; do+ if find "$verified" -name "$lib" -print -quit | grep -q .; then+ echo "fix-appimage-host-libs: verification failed, $lib is still bundled" >&2+ verdict=1+ fi+done+for required in AppRun AppRun.wrapped; do+ if [ ! -e "$verified/$required" ]; then+ echo "fix-appimage-host-libs: verification failed, $required is missing" >&2+ verdict=1+ fi+done+if [ ! -e "$verified/usr/lib/libwebkit2gtk-4.1.so.0" ]; then+ echo "fix-appimage-host-libs: verification failed, bundled WebKit is missing" >&2+ verdict=1+fi+if ! find "$verified/usr/bin" -type f -perm -u+x -print -quit | grep -q .; then+ echo "fix-appimage-host-libs: verification failed, no executable remained in usr/bin" >&2+ verdict=1+fi+[ "$verdict" -eq 0 ] || exit 1++mv "$work/out.AppImage" "$appimage"+echo "fix-appimage-host-libs: repacked $(basename "$appimage") (${#removed[@]} host-interface libs dropped)"diff --git a/test/appimage-host-libs.test.ts b/test/appimage-host-libs.test.tsnew file mode 100644index 00000000..b47a78a6--- /dev/null+++ b/test/appimage-host-libs.test.ts@@ -0,0 +1,165 @@+// @vitest-environment node+import { execFileSync } from 'node:child_process'+import { readFileSync } from 'node:fs'+import { fileURLToPath } from 'node:url'+import { describe, expect, it } from 'vitest'++/**+ * AppImage 宿主接口库剔除契约(issue #620)。+ *+ * Tauri 固定使用的 linuxdeploy 会把构建镜像(ubuntu-22.04)的显示栈库一并打进+ * AppImage,而 `AppRun.wrapped` 又把 `$APPDIR/usr/lib` 放在 `LD_LIBRARY_PATH` 首位。+ * 较新发行版(Arch/CachyOS、Fedora 44…)的宿主 Mesa 因此加载到这些旧库、EGL 协商+ * 失败,WebKit 在 `eglGetDisplay` 失败时调用 `abort()`:`WebKitWebProcess` 以 SIGABRT+ * 退出,主窗口从未出现且用户侧没有任何日志。上游 tauri#15976 用同一份最小库集合+ * 复现并验证了「剔除即恢复」。.deb 走系统库,不受影响。+ *+ * 这里锁三件事:+ * 1. 剔除清单不退化(10 个宿主接口库),且不多删渲染栈本体(libEGL/libGL/libgbm/libdrm);+ * 2. CI 在签名/上传之前对每个 AppImage 跑到本脚本,并带 `--require-removal`——将来+ * bundler 不再过度打包时构建会明确失败,而不是让 #620 静默回归;+ * 3. 脚本本身仍具备幂等与告警语义(重复执行的输出/退出码契约)。+ */++const fixScriptPath = fileURLToPath(new URL('../scripts/fix-appimage-host-libs.sh', import.meta.url))+const linuxWorkflowPath = fileURLToPath(new URL('../.github/workflows/build-linux.yml', import.meta.url))++/**+ * `bash`(Windows 上是 Git Bash)只认 `C:/…` 或 MSYS 的 `/c/…` 形式,+ * 混合形式 `/c:/…` 会被当成不存在的路径(退出码 127)。非 Windows 平台原样返回。+ */+function toBashPath(filePath: string): string {+ if (process.platform !== 'win32')+ return filePath+ return `/${filePath[0].toLowerCase()}${filePath.slice(2).replace(/\\/g, '/')}`+}++function bashExitCode(args: string[]): number {+ try {+ // `stdio: 'ignore'`:管道捕获子进程输出在受限沙箱下会因命名管道不可用而失败,+ // 这里只需退出码,不需要 stdout/stderr。+ execFileSync('bash', args, { stdio: 'ignore' })+ return 0+ }+ catch (error) {+ return (error as { status?: number }).status ?? -1+ }+}++const fixScript = readFileSync(fixScriptPath, 'utf8')+const linuxWorkflow = readFileSync(linuxWorkflowPath, 'utf8')++/** 必须交给宿主提供的显示/输入栈库(tauri#15976 二分出的最小集合)。 */+const HOST_INTERFACE_LIBS = [+ 'libwayland-client.so.0',+ 'libwayland-cursor.so.0',+ 'libwayland-egl.so.1',+ 'libwayland-server.so.0',+ 'libxkbcommon.so.0',+ 'libxcb-randr.so.0',+ 'libxcb-render.so.0',+ 'libxcb-shm.so.0',+ 'libXau.so.6',+ 'libXdmcp.so.6',+]++/**+ * 渲染栈本体:linuxdeploy 自带 excludelist 本就不打包它们,剔除反而破坏渲染。+ * 严格断言「脚本没有把它们放进 EXCLUDED_LIBS 数组」,而不是全文搜字符串——+ * 注释里提到这些名字是合理的,被误删才是 bug。+ */+const RENDER_STACK_LIBS = ['libEGL.so.1', 'libGL.so.1', 'libgbm.so.1', 'libdrm.so.2']++function excludedLibsArray(): string {+ const match = /^readonly EXCLUDED_LIBS=\(\n([\s\S]*?)^\)/m.exec(fixScript)+ if (!match)+ throw new Error('scripts/fix-appimage-host-libs.sh 里找不到 EXCLUDED_LIBS 数组')+ return match[1]+}++describe('appimage host-interface library exclusion (#620)', () => {+ it('drops every lib from the upstream minimal set', () => {+ const array = excludedLibsArray()+ const listed = array+ .split('\n')+ .map(line => line.trim())+ .filter(line => line.length > 0 && !line.startsWith('#'))++ for (const lib of HOST_INTERFACE_LIBS)+ expect(listed, `${lib} 必须从 AppImage 中剔除`).toContain(lib)+ expect(listed).toHaveLength(HOST_INTERFACE_LIBS.length)+ })++ it('never removes the render stack the bundler already excludes', () => {+ const array = excludedLibsArray()+ for (const lib of RENDER_STACK_LIBS)+ expect(array, `${lib} 由 linuxdeploy excludelist 负责,剔除会破坏渲染`).not.toContain(lib)+ })++ it('repacks with the same squashfs parameters linuxdeploy produced', () => {+ // 与实测产物对齐(zstd / 128K block):换压缩器或块大小会让镜像体积与兼容性漂移。+ expect(fixScript).toContain('SQUASHFS_COMPRESSION=zstd')+ expect(fixScript).toContain('SQUASHFS_BLOCK_SIZE=131072')+ expect(fixScript).toContain('-comp "$SQUASHFS_COMPRESSION"')+ expect(fixScript).toContain('-b "$SQUASHFS_BLOCK_SIZE"')+ // 复用原 runtime 前缀,不依赖 appimagetool / 上游 floating tag。+ expect(fixScript).toContain('head -c "$offset"')+ })++ it('verifies the repacked image before overwriting the artifact', () => {+ for (const required of ['AppRun', 'AppRun.wrapped', 'usr/lib/libwebkit2gtk-4.1.so.0'])+ expect(fixScript, `自检必须保留 ${required}`).toContain(required)+ // 交付前在独立目录复核剔除结果,避免只看已被剪过的同一棵树。+ expect(fixScript).toContain('verify="$work/verify"')+ })++ it('supports --require-removal so a silent bundler change fails the build', () => {+ expect(fixScript).toContain('--require-removal')+ expect(fixScript).toContain('require_removal=1')+ expect(fixScript).toContain('is no longer happening, or the bundler changed')+ })++ it('is syntactically valid bash', () => {+ // `bash -n` 只做语法解析,不需要真机 AppImage,因此能在任意平台跑。+ expect(bashExitCode(['-n', toBashPath(fixScriptPath)])).toBe(0)+ })++ it('exits 2 with usage when no AppImage is given', () => {+ expect(bashExitCode([toBashPath(fixScriptPath)])).toBe(2)+ })++ it('fails loudly on a missing AppImage', () => {+ const missing = fileURLToPath(new URL('../scripts/__definitely-missing__.AppImage', import.meta.url))+ expect(bashExitCode([toBashPath(fixScriptPath), toBashPath(missing)])).toBe(1)+ })++ it('requires --require-removal to precede the AppImage argument', () => {+ // 顺序写反会让脚本把 `--require-removal` 当成文件路径并报「no such file」,+ // 这里锁定参数解析形式,避免 CI 里静默失效。+ expect(fixScript).toMatch(/if \[ "\$\{1:-\}" = "--require-removal" \]/)+ })+})++describe('linux release workflow wires the appimage fix', () => {+ it('installs squashfs-tools for mksquashfs', () => {+ expect(linuxWorkflow).toContain('squashfs-tools')+ })++ it('runs the fix with --require-removal for every built AppImage', () => {+ expect(linuxWorkflow).toContain('scripts/fix-appimage-host-libs.sh --require-removal')+ expect(linuxWorkflow).toContain('find src-tauri/target/release/bundle/appimage -name \'*.AppImage\'')+ })++ it('runs the fix after the bundle and before uploading artifacts', () => {+ const bundleIndex = linuxWorkflow.indexOf('pnpm tauri build --bundles appimage,deb')+ const fixIndex = linuxWorkflow.indexOf('scripts/fix-appimage-host-libs.sh --require-removal')+ const uploadIndex = linuxWorkflow.indexOf('actions/upload-artifact')++ expect(bundleIndex).toBeGreaterThan(-1)+ expect(fixIndex).toBeGreaterThan(-1)+ expect(uploadIndex).toBeGreaterThan(-1)+ // 重写 AppImage 字节必须在打包之后、上传之前;顺序反了会发布未修复的镜像。+ expect(bundleIndex).toBeLessThan(fixIndex)+ expect(fixIndex).toBeLessThan(uploadIndex)+ })+})