改用 musl 全静态构建,零依赖跨发行版
Build and Release Mond / release (push) Successful in 19s
Build and Release Mond / build-and-test (amd64) (push) Successful in 4m11s
Build and Release Mond / build-and-test (arm64) (push) Successful in 9m19s

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 12:03:43 +08:00
co-authored by Claude Opus 4.8
parent 5430297ff9
commit b44b118be7
8 changed files with 111 additions and 126 deletions
+14 -34
View File
@@ -9,8 +9,8 @@
- 🏗️ **多架构支持** - 原生支持 AMD64 和 ARM64 架构
- 📦 **多种安装方式** - 提供 Debian 包和通用二进制包
- 🐧 **发行版兼容** - 支持 UbuntuDebian
- 🔗 **依赖精简** - 第三方库(boost/OpenSSL/ZMQ 等)全部静态链入,运行时仅依赖系统 glibc(libc6 ≥ 2.31
- 🐧 **发行版** - musl 纯静态二进制,glibc/musl 任意发行版(Ubuntu/Debian/CentOS/Alpine)直接运行
- 🔗 **依赖** - 所有库(boost/OpenSSL/ZMQ/sodium/unbound 及 libc)全部静态链入,`ldd` 显示 `statically linked`,无任何动态依赖
- 🔒 **隐私优先** - 基于 Monero 的隐私保护技术
- 🔄 **自动更新** - 通过 Debian 仓库轻松安装和更新
@@ -34,10 +34,10 @@ sudo apt-get install mond
```bash
# 1. 下载对应架构的包(registry 路径与下载名版本号均不带 v 前缀)
wget https://gitea.bcde.io/api/packages/wangdefa/generic/mond/0.18.5.0/mond-amd64-ubuntu-0.18.5.0.tar.gz
wget https://gitea.bcde.io/api/packages/wangdefa/generic/mond/0.18.5.0/mond-amd64-linux-static-0.18.5.0.tar.gz
# 2. 解压
tar -xzf mond-amd64-ubuntu-0.18.5.0.tar.gz
tar -xzf mond-amd64-linux-static-0.18.5.0.tar.gz
# 3. 运行
./mond --help
@@ -144,14 +144,14 @@ sudo systemctl restart mond.service
### Docker 构建(推荐)
本项目使用 Docker 和官方 depends 系统构建,将 boost/OpenSSL/ZMQ 等第三方依赖全部静态链入(运行时仅依赖系统 glibc)。
本项目使用 Docker + Alpine/musl 构建:手动源码编译 5 个静态库(OpenSSL/libsodium/libzmq/expat/unbound)并 patch monero CMakeLists,产出 static-pie 纯静态二进制(零外部依赖、跨发行版)。
#### 构建多架构二进制文件
```bash
# 构建 amd64 和 arm64 架构
docker buildx build --platform linux/amd64,linux/arm64 \
-f docker/Dockerfile.ubuntu \
-f docker/Dockerfile \
--output type=local,dest=./output .
```
@@ -160,54 +160,34 @@ docker buildx build --platform linux/amd64,linux/arm64 \
```bash
# 仅构建 amd64
docker buildx build --platform linux/amd64 \
-f docker/Dockerfile.ubuntu \
-f docker/Dockerfile \
--output type=local,dest=./output .
# 仅构建 arm64
docker buildx build --platform linux/arm64 \
-f docker/Dockerfile.ubuntu \
-f docker/Dockerfile \
--output type=local,dest=./output .
```
#### 验证依赖
```bash
# 运行时动态依赖应只有 glibc 组件(libc/libm/libpthread/ld-linux),无第三方库
# 纯静态校验:应输出 "statically linked"(零外部依赖,可在 glibc/musl 任意发行版运行)
ldd output/linux_amd64/mond
# 预期: 仅 linux-vdso、libc、libm、libpthread、ld-linux 等 glibc 组件
# 预期: statically linked
```
### 本地构建
如果不使用 Docker,可以手动构建:
```bash
# 1. 克隆并准备源代码
git clone https://github.com/monero-project/monero.git .source
cd .source
git checkout v0.18.3.4
git submodule update --init --force
# 2. 应用修改
../init.sh
# 3. 使用 depends 系统构建(推荐)
make -j$(nproc) depends target=x86_64-linux-gnu
# 二进制文件位于: build/x86_64-linux-gnu/release/bin/mond
# 或者简单构建(需要手动安装依赖)
mkdir -p build/release && cd build/release
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI_DEPS=OFF
make -j$(nproc) daemon
```
纯静态构建需在 Alpine 下手编 5 个静态库(OpenSSL/libsodium/libzmq/expat/unbound)并 patch monero CMakeLists,步骤已固化在 [docker/Dockerfile](docker/Dockerfile)——**直接用上面的 Docker 构建即可**,无需手动复现。换名 + patch 逻辑见 [init.sh](init.sh)。
### 构建环境要求
- **操作系统**: Ubuntu 20.04(推荐)或更新版本
- **CPU**: 多核 CPU构建时间约 30-60 分钟
- **构建镜像**: `alpine:3.23`Dockerfile 内置,无需本机安装)
- **CPU**: 多核 CPU`make daemon` 约 7 分钟/架构,5 库命中缓存后
- **内存**: 至少 4GB RAM
- **磁盘**: 至少 10GB 可用空间
- **Docker**: 如使用 Docker 构建,需安装 Docker 和 buildx
- **Docker**: 需安装 Docker 和 buildx
## 📝 许可证