Pure-MoonBit toolkit to build, inspect and verify Linux packages (deb, rpm, Arch, Alpine) and apt/dnf repositories, without dpkg-deb or rpmbuild
状态:0.3.0 已发布到 mooncakes(Xpeng/linuxpkg)。deb、rpm、Arch Linux、Alpine 四种包的构建、检查、校验,以及 apt / dnf 软件源索引都已可用;压缩支持 gzip / xz / zstd / 不压缩。
| 功能 | 状态 |
|---|---|
| 构建 .deb(control、md5sums、conffiles、维护者脚本、软链接、目录、属主属组) | ✅ |
| 读取 / 检查 .deb(inspect,含 --json) | ✅ |
| 校验 .deb(verify:md5sums、gzip 校验和、路径安全) | ✅ |
| tar(ustar / PAX / GNU 长名)读写、ar 读写 | ✅ |
| linuxpkg.json 配置、依赖关系(libc6 (>= 2.31)) | ✅ |
| 构建 .rpm(文件摘要 SHA-256、头部摘要、payload 摘要、依赖关系、脚本、配置文件) | ✅ |
| 读取 / 检查 / 校验 .rpm(头部摘要、payload 摘要、每个文件的摘要) | ✅ |
| cpio(newc)读写 | ✅ |
| 依赖关系:depends、recommends、suggests、conflicts、replaces、provides(带版本约束) | ✅ |
| 压缩:gzip(默认)、xz、zstd、不压缩,deb 和 rpm 都能选(--compression 或配置里的 compression) | ✅ |
| 读取并完整校验 gzip / xz / zstd / lzma / 不压缩的 deb 与 rpm,包括 Debian、Ubuntu、Fedora、openEuler 的真实发行版包 | ✅ |
| Arch Linux 包(.pkg.tar.zst:.PKGINFO、带 SHA-256 的 .MTREE、.INSTALL;构建、检查、校验,pacman -U 能装、pacman -Qkk 无差异) | ✅ |
| Alpine 包(.apk:控制段、数据段、datahash、每个文件的 SHA-1;构建、检查、校验,apk add --allow-untrusted 能装、apk audit 无差异) | ✅ |
| 软件源:linuxpkg repo <目录> 生成 apt 平铺仓库(Packages / Packages.gz / Packages.xz / Release)和 dnf 仓库(repodata,与 createrepo_c 输出一致),别人直接 apt install / dnf install | ✅ |
| 有界解压:xz、zstd、gzip 炸弹在解压前或解压中就被上限截住(默认 1 GiB) | ✅ |
moon add Xpeng/linuxpkgmoonx Xpeng/linuxpkg/cmd/main@0.3.0 inspect /绝对路径/hello_1.0.0-1_all.deb
moonx Xpeng/linuxpkg/cmd/main@0.3.0 verify /绝对路径/hello-1.0.0-1.noarch.rpmgit clone https://github.com/pxgt/linuxpkg
cd linuxpkg
moon build --target native cmd/main # Windows 上请用 wasm-gc,或在 WSL 里用 native
moon run cmd/main --target wasm-gc -- --helplinuxpkg init # 写出一份示例 linuxpkg.json
linuxpkg build examples/hello/linuxpkg.json --out dist # 同时生成 deb、rpm、Arch 包和 Alpine 包(--format deb|rpm|arch|apk|all)
linuxpkg build examples/hello/linuxpkg.json --compression zstd --out dist-zstd # 换压缩:none|gzip|xz|zstd
linuxpkg inspect dist/hello_1.0.0-1_all.deb # 看元数据和文件列表(也认 .rpm、.apk 和 .pkg.tar.*)
linuxpkg inspect dist/hello-1.0.0-1.noarch.rpm --json
linuxpkg verify dist/hello-1.0.0-1.noarch.rpm # 退出码 0 表示通过
linuxpkg repo dist # 给 dist 里的包生成 apt / dnf 软件源索引{
"name": "hello",
"version": "1.0.0",
"release": "1",
"arch": "all",
"maintainer": "Your Name <you@example.org>",
"description": "一行摘要\n后面几行是详细说明",
"mtime": 1700000000,
"depends": ["libc6 (>= 2.31)"],
"contents": [
{ "src": "hello.sh", "dst": "/usr/bin/hello", "mode": "0755" },
{ "src": "hello", "dst": "/usr/bin/hi", "type": "symlink" },
{ "src": "hello.conf", "dst": "/etc/hello.conf", "type": "config" },
{ "dst": "/var/lib/hello", "type": "dir" }
],
"scripts": { "postinstall": "scripts/postinst.sh" }
}moon fmt --check
moon info && git diff --exit-code # 公开接口 pkg.generated.mbti 要保持最新
moon check --target all --deny-warn
moon test --target wasm-gc # 也可以换 js、wasm;native 在 Linux/WSL 上跑
tools/oracle/run.sh # 需要 dpkg-deb、dpkg、sudo(可选 lintian)let VERSION : StringInstall
Download zipPure-MoonBit toolkit to build, inspect and verify Linux packages (deb, rpm, Arch, Alpine) and apt/dnf repositories, without dpkg-deb or rpmbuild