Skip to content

浏览器预览支持 deb(5) 全部压缩格式(zstd 回退/bz2/lzma)+ 我的软件包下载按钮#7

Merged
eggfly merged 2 commits into
mainfrom
cursor/deb-decompress-formats-8337
Jul 15, 2026
Merged

浏览器预览支持 deb(5) 全部压缩格式(zstd 回退/bz2/lzma)+ 我的软件包下载按钮#7
eggfly merged 2 commits into
mainfrom
cursor/deb-decompress-formats-8337

Conversation

@eggfly

@eggfly eggfly commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

背景

用户的 nc2000 包用 zstd 压缩(dpkg 新版默认支持),但页面此前只依赖浏览器原生 DecompressionStream("zstd")(仅 Chrome 133+ 支持),其他浏览器直接报"解析失败:此浏览器不支持 zstd 解压"。

改动

1. 本地解析支持 deb(5) 允许的全部压缩格式

deb(5) 手册,control.tar/data.tar 成员合法压缩为:无压缩、gzip、xz、zstd、bzip2(.bz2)、lzma(.lzma)。现在全部支持:

格式 实现
gzip 原生 DecompressionStream("gzip")(不变)
xz vendored xz-decompress WASM(不变)
zstd 先试原生 DecompressionStream("zstd"),失败回退 fzstd 0.1.1(纯 JS,~24KB)
bzip2 bz2 1.0.1(纯 JS,SheetJS)
lzma LZMA-JS 2.3.2 解压专用构建(纯 JS,~7KB)
无压缩 直接解 tar(原有逻辑)

三个新库都 vendored 在 site/vendor/ 同域托管、按需懒加载(与原有 xz 同一策略:不依赖第三方 CDN,加载失败只影响对应格式)。jsDelivr 的 +esm 构建在浏览器里只把 bz2 挂到 window.bz2、LZMA-JS 用 this.LZMA,因此这两个库用了轻量 ESM 包装(原始源码原样内嵌,包装逻辑有注释说明)。

2. "我的软件包"增加下载 .deb 按钮

  • 从 APT 索引的 Filename 字段解析下载地址(本仓库发布到 GitHub Releases 是绝对 URL;也兼容相对 pool 路径)
  • 下载链接带规范文件名 包名_版本_架构.deb,同名包多版本按版本排序展示

测试

  • extractMember 识别 .tar.bz2 / .tar.lzma
  • 测试夹具覆盖全部 6 种格式:gzip/xz/zstd 用 dpkg-deb 直出;bz2/lzma 通过手工重打 ar 包生成(dpkg-deb 已不能构建这两种);顺带覆盖了无压缩 .tar 路径
  • zstd/bzip2/lzma 测试直接 import 页面同款 vendored 纯 JS 库解压,保证浏览器实际运行的代码被测到
  • node --test test/*.test.js 全部通过;另做了 nc2000 样例的 zstd 回退路径冒烟测试

CI 依赖从 zstd 换成 bzip2(zstd 解压现在走纯 JS 库,lzma 压缩夹具用 xz --format=lzma)。

Open in Web Open in Cursor 

cursoragent and others added 2 commits July 15, 2026 12:39
Vendored pure-JS decompressors (same-origin, lazily imported):
- fzstd 0.1.1 as zstd fallback when DecompressionStream('zstd') is
  unavailable (only Chrome 133+ has it natively)
- bz2 1.0.1 for legacy data.tar.bz2 members
- LZMA-JS 2.3.2 decompression-only build for legacy data.tar.lzma

debparse.js now recognizes .tar.bz2 and .tar.lzma members alongside
gz/xz/zst/uncompressed. Tests build fixtures for every format (bz2/lzma
via ar repack since dpkg-deb cannot build them) and decompress zstd/
bzip2/lzma with the same vendored libraries the page ships.

Co-authored-by: eggfly <lihaohua90@gmail.com>
Resolve the download URL from the APT index Filename field (absolute
URL or pool path relative to the repository root) and render a styled
download link next to the unpublish button; rows now sort by version
within the same package name.

Co-authored-by: eggfly <lihaohua90@gmail.com>
@eggfly
eggfly marked this pull request as ready for review July 15, 2026 12:42
@eggfly
eggfly merged commit 57eada3 into main Jul 15, 2026
2 checks passed
@eggfly
eggfly deleted the cursor/deb-decompress-formats-8337 branch July 15, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants