Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34aa4f8c74 | ||
|
|
1f92188b59 | ||
|
|
1ecf2ca151 | ||
|
|
b98a915df3 | ||
|
|
3b024fdc10 | ||
|
|
b222b802bf |
+45
-17
@@ -9,7 +9,7 @@ on:
|
|||||||
env:
|
env:
|
||||||
DOCKER_BUILDKIT: "1"
|
DOCKER_BUILDKIT: "1"
|
||||||
PRODUCT_NAME: "p2pool"
|
PRODUCT_NAME: "p2pool"
|
||||||
PACKAGE_VERSION: "v4.15"
|
PACKAGE_VERSION: "4.17"
|
||||||
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -18,7 +18,6 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
arch: [amd64, arm64]
|
arch: [amd64, arm64]
|
||||||
distro: [ubuntu, alpine]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -35,11 +34,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Build binaries
|
- name: Build binaries
|
||||||
run: |
|
run: |
|
||||||
P2POOL_VERSION=${PACKAGE_VERSION}
|
|
||||||
PLATFORM="linux/${{ matrix.arch }}"
|
PLATFORM="linux/${{ matrix.arch }}"
|
||||||
|
P2POOL_VERSION="v${PACKAGE_VERSION}" # 上游 p2pool git tag 带 v 前缀,需补回
|
||||||
|
|
||||||
echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner"
|
echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner (musl 纯静态)"
|
||||||
echo "📦 Distribution: ${{ matrix.distro }}"
|
|
||||||
|
|
||||||
# 设置 BuildKit 优化参数
|
# 设置 BuildKit 优化参数
|
||||||
export BUILDKIT_PROGRESS=plain
|
export BUILDKIT_PROGRESS=plain
|
||||||
@@ -48,7 +46,7 @@ jobs:
|
|||||||
--platform ${PLATFORM} \
|
--platform ${PLATFORM} \
|
||||||
--build-arg P2POOL_VERSION=${P2POOL_VERSION} \
|
--build-arg P2POOL_VERSION=${P2POOL_VERSION} \
|
||||||
--output type=local,dest=./output \
|
--output type=local,dest=./output \
|
||||||
-f docker/Dockerfile.${{ matrix.distro }} .
|
-f docker/Dockerfile .
|
||||||
|
|
||||||
- name: Package and test
|
- name: Package and test
|
||||||
run: |
|
run: |
|
||||||
@@ -59,24 +57,30 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz"
|
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${PACKAGE_VERSION}.tar.gz"
|
||||||
tar -czf "${TARGZ}" -C "$DIR" .
|
tar -czf "${TARGZ}" -C "$DIR" .
|
||||||
|
|
||||||
echo "📦 Created package: ${TARGZ}"
|
echo "📦 Created package: ${TARGZ}"
|
||||||
ls -lh "${TARGZ}"
|
ls -lh "${TARGZ}"
|
||||||
|
|
||||||
# 快速验证
|
# 快速验证:--help 冒烟 + ldd 纯静态校验(musl 静态可在 glibc runner 直接跑)
|
||||||
mkdir -p test && tar -xzf "${TARGZ}" -C test
|
mkdir -p test && tar -xzf "${TARGZ}" -C test
|
||||||
test/p2pool --help 2>/dev/null || echo "⚠️ Help displayed"
|
test/p2pool --help >/dev/null 2>&1 && echo "✅ --help OK" || echo "⚠️ --help 退出非0"
|
||||||
|
# ldd 对纯静态二进制返回 exit 1,须先捕获输出再判定(run 块是 bash -e -o pipefail,直接管道会被误杀)
|
||||||
|
LDD_OUT=$(ldd test/p2pool 2>&1 || true)
|
||||||
|
if echo "$LDD_OUT" | grep -qE 'statically linked|not a dynamic executable'; then
|
||||||
|
echo "✅ fully-static(无动态依赖,跨发行版)"
|
||||||
|
else
|
||||||
|
echo "⚠️ 非纯静态:"; echo "$LDD_OUT"; exit 1
|
||||||
|
fi
|
||||||
rm -rf test
|
rm -rf test
|
||||||
|
|
||||||
- name: Build Debian package
|
- name: Build Debian package
|
||||||
if: matrix.distro == 'ubuntu'
|
|
||||||
run: |
|
run: |
|
||||||
# 安装 dpkg-deb(如果需要)
|
# 安装 dpkg-deb(如果需要)
|
||||||
sudo apt-get update && sudo apt-get install -y dpkg-dev
|
sudo apt-get update && sudo apt-get install -y dpkg-dev
|
||||||
|
|
||||||
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz"
|
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${PACKAGE_VERSION}.tar.gz"
|
||||||
|
|
||||||
echo "📦 Building Debian package for ${{ matrix.arch }}..."
|
echo "📦 Building Debian package for ${{ matrix.arch }}..."
|
||||||
chmod +x debian/build-deb.sh
|
chmod +x debian/build-deb.sh
|
||||||
@@ -86,7 +90,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
|
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: binaries-${{ matrix.arch }}-${{ matrix.distro }}
|
name: binaries-${{ matrix.arch }}
|
||||||
path: |
|
path: |
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
*.deb
|
*.deb
|
||||||
@@ -114,12 +118,13 @@ jobs:
|
|||||||
REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
||||||
OWNER="${{ gitea.repository_owner }}"
|
OWNER="${{ gitea.repository_owner }}"
|
||||||
REPO_NAME=$(echo "${{ gitea.repository }}" | cut -d'/' -f2)
|
REPO_NAME=$(echo "${{ gitea.repository }}" | cut -d'/' -f2)
|
||||||
|
VERSION="${TAG#v}" # 包版本:去掉 git tag 的 v 前缀(registry 路径/下载名/Release 标题统一用纯数字)
|
||||||
|
|
||||||
echo "📦 上传包到 Generic Package Registry..."
|
echo "📦 上传包到 Generic Package Registry..."
|
||||||
echo " Registry: ${REGISTRY}"
|
echo " Registry: ${REGISTRY}"
|
||||||
echo " Owner: ${OWNER}"
|
echo " Owner: ${OWNER}"
|
||||||
echo " Package: ${PRODUCT_NAME}"
|
echo " Package: ${PRODUCT_NAME}"
|
||||||
echo " Version: ${TAG}"
|
echo " Version: ${VERSION}"
|
||||||
|
|
||||||
# 上传所有 tar.gz 包到 Generic Package Registry
|
# 上传所有 tar.gz 包到 Generic Package Registry
|
||||||
for file in *.tar.gz; do
|
for file in *.tar.gz; do
|
||||||
@@ -128,7 +133,7 @@ jobs:
|
|||||||
curl -fsSL -X PUT \
|
curl -fsSL -X PUT \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
--upload-file "$file" \
|
--upload-file "$file" \
|
||||||
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/$file" || {
|
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/$file" || {
|
||||||
echo "❌ 上传失败: $file"
|
echo "❌ 上传失败: $file"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -151,12 +156,35 @@ jobs:
|
|||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
# 生成 Release JSON payload
|
# 生成 Release 描述
|
||||||
echo ""
|
echo ""
|
||||||
echo "📝 生成 Release..."
|
echo "📝 生成 Release..."
|
||||||
|
|
||||||
export REGISTRY OWNER TAG
|
# 拼接 tar.gz 下载链接
|
||||||
RELEASE_DATA=$(python3 -c 'import json,glob,os;r=os.environ["REGISTRY"];o=os.environ["OWNER"];p=os.environ["PRODUCT_NAME"];t=os.environ["TAG"];b=["## Release "+t,"","### 📥 下载方式","","#### 方式 1: 直接下载(推荐)","","点击下面 **Assets** 部分的文件名直接下载。","","#### 方式 2: Generic Package Registry",""]+[f"- [`{f}`](https://{r}/api/packages/{o}/generic/{p}/{t}/{f})" for f in sorted(glob.glob("*.tar.gz"))]+["","#### 方式 3: Debian Repository","","```bash","# Download GPG key",f"sudo curl https://{r}/api/packages/{o}/debian/repository.key -o /etc/apt/keyrings/gitea-{o}.asc","","# Add repository",f"echo \"deb [signed-by=/etc/apt/keyrings/gitea-{o}.asc] https://{r}/api/packages/{o}/debian stable main\" | sudo tee -a /etc/apt/sources.list.d/{o}.list","","# Update and install","sudo apt-get update",f"sudo apt-get install {p}","```"];print(json.dumps({"tag_name":t,"name":f"Release {t}","body":"\n".join(b),"draft":False,"prerelease":False}))')
|
ASSETS=$(for f in *.tar.gz; do
|
||||||
|
[ -f "$f" ] || continue
|
||||||
|
echo "- [\`$f\`](https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/$f)"
|
||||||
|
done)
|
||||||
|
|
||||||
|
BODY=$(cat <<EOF
|
||||||
|
## Release ${VERSION}
|
||||||
|
|
||||||
|
### 📥 Debian/Ubuntu 安装
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
sudo curl https://${REGISTRY}/api/packages/${OWNER}/debian/repository.key -o /etc/apt/keyrings/gitea-${OWNER}.asc
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/gitea-${OWNER}.asc] https://${REGISTRY}/api/packages/${OWNER}/debian stable main" | sudo tee /etc/apt/sources.list.d/${OWNER}.list
|
||||||
|
sudo apt-get update && sudo apt-get install ${PRODUCT_NAME}
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
### 📦 tar.gz 下载
|
||||||
|
|
||||||
|
${ASSETS}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
RELEASE_DATA=$(jq -n --arg tag "$TAG" --arg ver "$VERSION" --arg body "$BODY" \
|
||||||
|
'{tag_name: $tag, name: "Release \($ver)", body: $body, draft: false, prerelease: false}')
|
||||||
|
|
||||||
# 创建 Release
|
# 创建 Release
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
+1
-5
@@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
.claude/
|
.claude/
|
||||||
.codex/
|
.codex/
|
||||||
|
|
||||||
docs/
|
|
||||||
example/
|
|
||||||
|
|
||||||
CLAUDE.md
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## 仓库性质
|
||||||
|
|
||||||
|
本仓库**只包含构建与打包基础设施**,不含 p2pool 源码。源码在编译时从上游克隆(见 [docker/Dockerfile](docker/Dockerfile)):
|
||||||
|
|
||||||
|
- 源码仓库:`github.com/SChernykh/p2pool.git`(**p2pool 官方仓库**,非换名)
|
||||||
|
- 发布仓库:Gitea `gitea.bcde.io` 下 `wangdefa/p2pool` 的 Generic / Debian 包仓库
|
||||||
|
|
||||||
|
p2pool 是 Monero 去中心化矿池的 sidechain 节点。本项目对上游唯一的定制是 **`-DWITH_MERGE_MINING_DONATION=OFF`**(禁用合并挖矿捐赠),不改源码。
|
||||||
|
|
||||||
|
> **与同目录 `gitea-xxxig` / `gitea-xxxig-proxy` / `gitea-mond` 的关系**:四者共享同一套 CI / build-deb / debian 打包骨架,且均为 **musl fully-static** 构建。差异:xxxig 系是 XMRig 换名仓库源码;mond 克隆 Monero 官方靠 init.sh 现场换名;p2pool 直接构建官方源码、不换名,版本号纯数字(`4.17`,上游 git tag 带 v、构建时补回)。
|
||||||
|
|
||||||
|
## 整体架构:单二进制
|
||||||
|
|
||||||
|
编译产出单个可执行文件 `p2pool`:连接 monerod(本地,或经 `--rpc-ssl` 连外部 SSL 节点)、维护 P2Pool sidechain、提供 stratum 给矿工。配置模板 [conf/params.conf.example](conf/params.conf.example)。
|
||||||
|
|
||||||
|
## 构建与发布流程(CI)
|
||||||
|
|
||||||
|
[.gitea/workflows/ci.yaml](.gitea/workflows/ci.yaml) 是 Gitea Actions 流水线:
|
||||||
|
|
||||||
|
1. **build-and-test**(矩阵 `arch=[amd64,arm64]`,跑在对应架构原生 runner):用 `docker buildx` 按 [docker/Dockerfile](docker/Dockerfile) 原生编译 → 打成 tar.gz → 解包冒烟(`p2pool --help` + `ldd` 纯静态校验)→ 调 `debian/build-deb.sh` 打 .deb → 上传 artifact。
|
||||||
|
2. **release**(仅 tag 触发):下载 artifact,上传 tar.gz 到 Generic Package Registry、上传 .deb 到 Debian Registry(stable/main),并用 python3 生成描述创建 Gitea Release。
|
||||||
|
|
||||||
|
关键点:
|
||||||
|
- **musl fully-static(Alpine 构建,勿改回 glibc)**:上游 p2pool **官方 release 二进制即用此法**(见上游 `.github/workflows/c-cpp.yml` 的 Alpine static job)。[docker/Dockerfile](docker/Dockerfile) 在 `alpine:3.21` 下自编 external 静态库(curl/libuv/libzmq)+ 静态 grpc 栈(含 boringssl,`WITH_GRPC=ON` 支持 Tari 合并挖矿),再 `-DSTATIC_BINARY=ON` 全静态。产物 `ldd` = `not a dynamic executable`、零外部依赖,**glibc/musl 任意发行版直接运行**(实测 musl 产物在 Debian 13 上正常 `--help`)。
|
||||||
|
- **为何用 musl 而非 glibc**:musl 的 `getaddrinfo` 自带实现,全静态也能解析 DNS;glibc 静态会因 NSS 运行时 `dlopen` 失败。与 `gitea-xxxig`/`gitea-xxxig-proxy`/`gitea-mond` 一致。曾用的 `Dockerfile.ubuntu`(glibc 动态)与 `Dockerfile.alpine`(动态链 system 库)均已删除。
|
||||||
|
- **依赖处理(关键,勿乱改)**:
|
||||||
|
- external 依赖**子模块自带源码**,逐个编静态(`BUILD_SHARED_LIBS=OFF` 等)。拉 8 个常规子模块 + grpc 及其 **6 个必需 third_party**(`abseil-cpp`/`boringssl-with-bazel`/`cares`/`protobuf`/`re2`/`zlib`);其余 9 个 grpc 子模块(benchmark/googletest/envoy/googleapis/xds 等测试或 xDS 依赖,已 `GRPC_NO_XDS`)**跳过**省体积/时间。
|
||||||
|
- **WITH_GRPC=ON(支持 Tari 合并挖矿,勿改回 OFF)**:上游 CMake 默认即 ON(官方 alpine static job 为省体积改 OFF,本项目恢复 ON)。ON 时 `cmake/grpc.cmake` 用 `add_subdirectory(external/src/grpc)` 自动静态编译 grpc/protobuf/abseil/re2/cares,并 `add_subdirectory(external/src/Tari)` 编 checked-in 的 Tari proto(`.pb.cc`,不需运行时 protoc),链接 `Tari_gRPC grpc grpc++ libprotobuf`。这样 `tari://` 主机走 `MergeMiningClientTari`(gRPC)而非 `MergeMiningClientJSON_RPC`(JSON-RPC,与 Tari 不兼容、报 `empty response`)。代价:二进制 ~5MB→~15MB(`-Wl,-s --gc-sections` 剔除未用 grpc/xDS 代码后远小于全量)、构建 +约 15min/arch。曾为省体积误用 `WITH_GRPC=OFF` 致无法与 Tari 合并挖矿,**已改回 ON,勿回退**。
|
||||||
|
- **boringssl 来源**:`WITH_GRPC=ON` 时由 grpc 子模块(`third_party/boringssl-with-bazel`)提供,grpc.cmake 走此分支、**不再** `add_subdirectory(cmake/ssl)`(那是 `elseif (WITH_TLS)` 分支);p2pool 主体 TLS 与下方 curl 共用这一份 boringssl。
|
||||||
|
- **curl 用 boringssl TLS(保留 rpc-ssl,勿改回 no-SSL)**:完整照搬官方 `c-cpp.yml` 的 curl flags——`P2POOL_BORINGSSL=ON`(上游给 curl 的独立 boringssl 后端补丁,与 `CURL_ENABLE_SSL=OFF` 共存、不走 curl 标准 SSL 路径)+ 一整套 `CURL_DISABLE_*`(尤其 `SRP`/`AWS`/`*_AUTH`)。后者跳过会引用 `OpenSSL::SSL` imported target 的 `curl_openssl_check_exists` 符号检测(新版 cmake 在 `try_compile` 阶段校验该 target 必失败,**少一个 disable 都会触发**)。curl 与 p2pool 主体共用同一 boringssl,`json_rpc_request` 的 `CURLOPT_SSL_CTX_FUNCTION` 才能接管证书指纹校验——**`--rpc-ssl`/`--rpc-ssl-fingerprint` 连外部 SSL monerod 的能力得以保留**(已实测连真实 SSL 节点用 `--rpc-ssl` 拿到链上高度)。曾误用 no-SSL curl 会断此能力,勿回退。
|
||||||
|
- **版本号约定**:包版本硬编码在 ci.yaml 的 `PACKAGE_VERSION: "4.17"`(**纯数字、无 v**,符合 Debian 版本规范)。**关键分界**:上游 p2pool git tag 带 `v`,故 build job 用 `P2POOL_VERSION="v${PACKAGE_VERSION}"` 补回 v 传给 Dockerfile `git checkout`;tar.gz / deb / registry 路径 / Release 标题等包版本一律直接用 `${PACKAGE_VERSION}`;release job 用 `VERSION="${TAG#v}"` 归一(tag 带不带 v 都兼容,唯 Release 的 `tag_name` 用 git tag 原值)。CI 触发条件 `tags: ['*']`,发版改 `PACKAGE_VERSION` 并打对应 tag(纯数字,如 `4.17`)。
|
||||||
|
- 架构映射:Dockerfile 内 `arm64→ARCH_ID=aarch64`、`amd64→ARCH_ID=x86_64`(传给 p2pool cmake,控制 RandomX 优化)。
|
||||||
|
- tar.gz 下载 URL 形如 `https://gitea.bcde.io/api/packages/wangdefa/generic/p2pool/{version}/p2pool-{arch}-linux-static-{version}.tar.gz`(version 为纯数字)。
|
||||||
|
|
||||||
|
## 本地常用命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 本地编译某架构的二进制(输出到 ./output/linux_<arch>/p2pool)
|
||||||
|
docker buildx build --platform linux/amd64 \
|
||||||
|
--build-arg P2POOL_VERSION=v4.17 \
|
||||||
|
--output type=local,dest=./output \
|
||||||
|
-f docker/Dockerfile .
|
||||||
|
|
||||||
|
# 校验纯静态(应输出 "not a dynamic executable")
|
||||||
|
ldd output/linux_amd64/p2pool
|
||||||
|
|
||||||
|
# 用已有 tar.gz 打 .deb 包(第三个参数是 tar.gz)
|
||||||
|
./debian/build-deb.sh amd64 4.17 p2pool-amd64-linux-static-4.17.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
无单元测试;CI 唯一冒烟是解包后跑 `p2pool --help`(musl 纯静态可在 glibc runner 直接运行),并用 `ldd` 校验为纯静态。
|
||||||
|
|
||||||
|
## Debian 包布局与服务
|
||||||
|
|
||||||
|
- 二进制装到 `/opt/p2pool/p2pool`,systemd 服务 [debian/p2pool.service](debian/p2pool.service),维护脚本 `debian/{postinst,prerm,postrm}`。
|
||||||
|
- **配置流转(单一数据源,对齐 gitea-mond)**:`conf/params.conf.example` 是唯一配置源 → build-deb.sh 复制进包内 `/opt/p2pool/params.conf` → postinst 首次安装时 `cp` 到 `/etc/p2pool/params.conf`(**升级不覆盖**用户已有配置;旧版本位于 `/var/lib/p2pool/params.conf` 时 postinst 自动迁移到 `/etc/p2pool/`)。service 的 `ExecStart` 用 `--params-file /etc/p2pool/params.conf`。**改默认配置改 conf/params.conf.example 一处即可**(不要再在 postinst 内联 heredoc)。
|
||||||
|
- 数据目录 `/var/lib/p2pool/data-api`、日志目录 `/var/log/p2pool`,均归 `p2pool` 系统用户。postinst 创建 `p2pool` 系统用户/组,**服务不自动启用/启动**(首次需用户配置钱包地址),升级时若服务原为 enabled 则重启加载新二进制。
|
||||||
|
- control.template **无 `Depends` 字段**(纯静态,连 libc6/libuv1/libzmq5/libcurl4 都不需要)。
|
||||||
@@ -1,102 +1,91 @@
|
|||||||
# P2Pool Docker 构建基础设施
|
# P2Pool
|
||||||
|
|
||||||
[]()
|
P2Pool 是 [SChernykh/p2pool](https://github.com/SChernykh/p2pool) 的定制打包——Monero 去中心化矿池的 sidechain 节点。对上游唯一定制是**禁用合并挖矿捐赠**(`-DWITH_MERGE_MINING_DONATION=OFF`),不改源码。
|
||||||
[]()
|
|
||||||
|
|
||||||
为 [p2pool](https://github.com/SChernykh/p2pool) 提供的自动化 Docker 构建和打包系统。
|
**本仓库只包含构建与打包基础设施**,不含 p2pool 源码:二进制在 CI 中从上游官方仓库 `github.com/SChernykh/p2pool` 编译,再打包分发到 [gitea.bcde.io](https://gitea.bcde.io) 的 Generic / Debian 包仓库。
|
||||||
|
|
||||||
## 📋 项目简介
|
## 产物
|
||||||
|
|
||||||
这是一个专业的构建基础设施项目,用于自动化构建、打包和分发 p2pool(Monero 去中心化矿池)的多架构二进制文件和 Debian 软件包。
|
每次构建产出单个可执行文件(musl 纯静态,自带 boringssl/libuv/libzmq + 内置 gRPC,无外部动态库依赖,任意 Linux 发行版可跑):
|
||||||
|
|
||||||
**关键特性**:
|
| 二进制 | 作用 |
|
||||||
- 🏗️ 多架构支持(amd64、arm64)
|
|---|---|
|
||||||
- 📦 多发行版构建(Alpine、Ubuntu)
|
| `p2pool` | P2Pool sidechain 节点:连接 monerod、维护 sidechain、向矿工提供 stratum;支持与 Tari 合并挖矿 |
|
||||||
- 🤖 全自动 CI/CD 流程
|
|
||||||
- 🔒 禁用合并挖矿捐赠
|
|
||||||
- 📊 原生架构构建(无 QEMU)
|
|
||||||
|
|
||||||
## 🚀 快速开始
|
支持架构 `amd64` / `arm64`;musl 纯静态,任意 Linux 发行版(Debian/Ubuntu/Alpine/CentOS 等)开箱即跑。静态构建仍保留 `--rpc-ssl`(连外部 SSL monerod 节点)与内置 gRPC(`--merge-mine tari://...` 与 Tari 合并挖矿)。
|
||||||
|
|
||||||
### Debian/Ubuntu(推荐)
|
## 安装
|
||||||
|
|
||||||
|
### APT(Debian / Ubuntu)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 下载 GPG 密钥
|
|
||||||
sudo curl https://gitea.bcde.io/api/packages/wangdefa/debian/repository.key -o /etc/apt/keyrings/gitea-wangdefa.asc
|
sudo curl https://gitea.bcde.io/api/packages/wangdefa/debian/repository.key -o /etc/apt/keyrings/gitea-wangdefa.asc
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian stable main" | sudo tee /etc/apt/sources.list.d/wangdefa.list
|
||||||
# 添加仓库
|
sudo apt-get update && sudo apt-get install p2pool
|
||||||
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian stable main" | sudo tee -a /etc/apt/sources.list.d/wangdefa.list
|
|
||||||
|
|
||||||
# 更新并安装
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install p2pool
|
|
||||||
```
|
```
|
||||||
|
|
||||||
修改配置:
|
安装布局:
|
||||||
|
|
||||||
|
| | 路径 |
|
||||||
|
|---|---|
|
||||||
|
| 二进制 | `/opt/p2pool/p2pool` |
|
||||||
|
| 默认配置 | `/opt/p2pool/params.conf`(postinst 复制到 `/etc/p2pool/params.conf`) |
|
||||||
|
| 数据 | `/var/lib/p2pool/data-api` |
|
||||||
|
| 日志 | `/var/log/p2pool/` |
|
||||||
|
| 服务 | `p2pool.service` |
|
||||||
|
|
||||||
|
> 安装后服务**不会自动启动**(须先填钱包地址)。编辑 `/etc/p2pool/params.conf` 设置 Monero 钱包地址,再启用:
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> sudo systemctl enable --now p2pool
|
||||||
|
> ```
|
||||||
|
|
||||||
|
### tar.gz(通用:Alpine / Ubuntu / Debian)
|
||||||
|
|
||||||
|
从 Generic Package Registry 下载对应架构的 tar.gz,解压即用(单二进制):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 设置你的 Monero 钱包地址
|
curl -fSL -o p2pool.tar.gz \
|
||||||
sudo nano /var/lib/p2pool/params.conf
|
https://gitea.bcde.io/api/packages/wangdefa/generic/p2pool/4.17/p2pool-amd64-linux-static-4.17.tar.gz
|
||||||
|
tar -xzf p2pool.tar.gz
|
||||||
# 启动服务
|
./p2pool --params-file params.conf # 配置模板见仓库 conf/params.conf.example
|
||||||
sudo systemctl enable --now p2pool.service
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 本地构建
|
## 构建与发布
|
||||||
|
|
||||||
|
CI 定义于 [.gitea/workflows/ci.yaml](.gitea/workflows/ci.yaml):
|
||||||
|
|
||||||
|
- **push 到 `main`/`develop`**:矩阵 `arch=[amd64,arm64]`,在原生 runner 上用 Docker(musl 纯静态)编译为 tar.gz 并打 `.deb`。
|
||||||
|
- **打 tag**:产物上传到 Generic / Debian 包仓库并创建 Release。
|
||||||
|
|
||||||
|
本地构建:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Alpine 构建(推荐,体积更小)
|
# 编译某架构二进制(输出到 ./output/linux_<arch>/p2pool)
|
||||||
docker buildx build --pull \
|
docker buildx build --platform linux/amd64 \
|
||||||
--platform linux/amd64 \
|
--build-arg P2POOL_VERSION=v4.17 \
|
||||||
--build-arg P2POOL_VERSION=v4.15 \
|
|
||||||
--output type=local,dest=./output \
|
--output type=local,dest=./output \
|
||||||
-f docker/Dockerfile.alpine .
|
-f docker/Dockerfile .
|
||||||
|
|
||||||
# Ubuntu 构建
|
# 校验纯静态(应输出 "not a dynamic executable")
|
||||||
docker buildx build --pull \
|
ldd output/linux_amd64/p2pool
|
||||||
--platform linux/amd64 \
|
|
||||||
--build-arg P2POOL_VERSION=v4.15 \
|
# 用产物 tar.gz 打 .deb
|
||||||
--output type=local,dest=./output \
|
./debian/build-deb.sh amd64 4.17 p2pool-amd64-linux-static-4.17.tar.gz
|
||||||
-f docker/Dockerfile.ubuntu .
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🏗️ 构建系统
|
## 版本号约定
|
||||||
|
|
||||||
### 支持的架构和平台
|
- **上游源码 git tag** 带 `v`(如 `v4.17`),CI 用 `P2POOL_VERSION=v${PACKAGE_VERSION}` 检出。
|
||||||
|
- **包版本**(tar.gz / deb / registry 路径)一律用数字(如 `4.17`),符合 Debian 版本规范。
|
||||||
|
|
||||||
| 架构 | Alpine | Ubuntu | Debian 包 |
|
发版只需改 ci.yaml 的 `PACKAGE_VERSION`。
|
||||||
|------|--------|--------|-----------|
|
|
||||||
| amd64 | ✅ | ✅ | ✅ |
|
|
||||||
| arm64 | ✅ | ✅ | ✅ |
|
|
||||||
|
|
||||||
### 构建产物
|
## 目录结构
|
||||||
|
|
||||||
- **二进制包** (`tar.gz`) - 适用于所有 Linux 发行版
|
```
|
||||||
- **Debian 包** (`.deb`) - 适用于 Debian/Ubuntu 系统
|
.gitea/workflows/ CI 流水线
|
||||||
|
docker/ Dockerfile(musl 纯静态,从上游官方源码编译)
|
||||||
## 🔧 配置管理
|
debian/ .deb 打包:control 模板、维护脚本、systemd 服务
|
||||||
|
conf/ params.conf.example 默认配置模板
|
||||||
配置文件模板:[params.conf.example](params.conf.example)
|
```
|
||||||
|
|
||||||
## 🔐 安全性
|
|
||||||
|
|
||||||
- ✅ 禁用上游合并挖矿捐赠
|
|
||||||
- ✅ 使用专用用户运行服务
|
|
||||||
- ✅ Systemd 安全加固
|
|
||||||
- ✅ 最小权限原则
|
|
||||||
- ✅ 安全的文件权限设置
|
|
||||||
|
|
||||||
## 📄 许可证
|
|
||||||
|
|
||||||
本项目为上游 [p2pool](https://github.com/SChernykh/p2pool) 提供构建基础设施。
|
|
||||||
|
|
||||||
上游项目许可证:GPL-3.0
|
|
||||||
|
|
||||||
## 🔗 相关链接
|
|
||||||
|
|
||||||
- **上游项目**: [SChernykh/p2pool](https://github.com/SChernykh/p2pool)
|
|
||||||
- **Monero**: [getmonero.org](https://www.getmonero.org/)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**注意**: 本仓库不包含 p2pool 源代码,仅提供构建和打包基础设施。
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# P2Pool Configuration File Example
|
# P2Pool Configuration File Example
|
||||||
# Copy this file to /var/lib/p2pool/params.conf and edit as needed
|
# Copy this file to /etc/p2pool/params.conf and edit as needed
|
||||||
# Compatible with: p2pool v4.15+
|
# Compatible with: p2pool v4.17+
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Monero Node Connection (REQUIRED)
|
# Monero Node Connection (REQUIRED)
|
||||||
@@ -84,9 +84,13 @@ local-api = true
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Merge Mining (Optional)
|
# Merge Mining (Optional)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Enable Tari merge mining
|
# Tari merge mining (this build includes gRPC, so tari:// is supported)
|
||||||
# Format: tari://<tari_node_ip>:<port> <tari_wallet_address>
|
# Format: tari://<tari_node_ip>:<port> <tari_wallet_address>
|
||||||
# merge-mine = tari://127.0.0.1:18142 YOUR_TARI_WALLET_ADDRESS
|
# merge-mine = tari://127.0.0.1:18142 YOUR_TARI_WALLET_ADDRESS
|
||||||
|
#
|
||||||
|
# Generic JSON-RPC merge mining (other merge-mineable chains).
|
||||||
|
# v4.16+: TLS supported — prefix the host with https:// (default port 443).
|
||||||
|
# merge-mine = https://aux-node.example.com YOUR_AUX_WALLET_ADDRESS
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Logging
|
# Logging
|
||||||
@@ -108,6 +112,8 @@ loglevel = 3
|
|||||||
# Performance Tuning (Advanced)
|
# Performance Tuning (Advanced)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# in-peers = 10
|
# in-peers = 10
|
||||||
|
# Maximum incoming localhost P2P connections (v4.17+)
|
||||||
|
# in-peers-localhost = 10
|
||||||
# out-peers = 10
|
# out-peers = 10
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
Vendored
+6
-2
@@ -4,7 +4,7 @@ set -e
|
|||||||
# 参数检查
|
# 参数检查
|
||||||
if [ $# -ne 3 ]; then
|
if [ $# -ne 3 ]; then
|
||||||
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
|
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
|
||||||
echo "Example: $0 amd64 v4.15 p2pool-amd64-ubuntu-v4.15.tar.gz"
|
echo "Example: $0 amd64 4.17 p2pool-amd64-linux-static-4.17.tar.gz"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -45,12 +45,15 @@ PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
|
|||||||
mkdir -p "${PKG_DIR}/DEBIAN"
|
mkdir -p "${PKG_DIR}/DEBIAN"
|
||||||
mkdir -p "${PKG_DIR}/opt/p2pool"
|
mkdir -p "${PKG_DIR}/opt/p2pool"
|
||||||
mkdir -p "${PKG_DIR}/lib/systemd/system"
|
mkdir -p "${PKG_DIR}/lib/systemd/system"
|
||||||
mkdir -p "${PKG_DIR}/etc/p2pool"
|
|
||||||
|
|
||||||
# 解压二进制文件
|
# 解压二进制文件
|
||||||
echo "📂 Extracting binaries..."
|
echo "📂 Extracting binaries..."
|
||||||
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/p2pool"
|
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/p2pool"
|
||||||
|
|
||||||
|
# 打入默认配置(conf/params.conf.example 为唯一配置源,postinst 据此生成 /etc/p2pool/params.conf)
|
||||||
|
echo "📄 Bundling default config..."
|
||||||
|
cp conf/params.conf.example "${PKG_DIR}/opt/p2pool/params.conf"
|
||||||
|
|
||||||
# 生成 control 文件
|
# 生成 control 文件
|
||||||
echo "📝 Generating control file..."
|
echo "📝 Generating control file..."
|
||||||
sed -e "s/{{VERSION}}/${DEB_VERSION}/" \
|
sed -e "s/{{VERSION}}/${DEB_VERSION}/" \
|
||||||
@@ -72,6 +75,7 @@ cp debian/p2pool.service "${PKG_DIR}/lib/systemd/system/"
|
|||||||
|
|
||||||
# 设置权限
|
# 设置权限
|
||||||
chmod 755 "${PKG_DIR}/opt/p2pool/p2pool"
|
chmod 755 "${PKG_DIR}/opt/p2pool/p2pool"
|
||||||
|
chmod 644 "${PKG_DIR}/opt/p2pool/params.conf"
|
||||||
chmod 644 "${PKG_DIR}/lib/systemd/system/p2pool.service"
|
chmod 644 "${PKG_DIR}/lib/systemd/system/p2pool.service"
|
||||||
|
|
||||||
# 构建 deb 包
|
# 构建 deb 包
|
||||||
|
|||||||
Vendored
-1
@@ -3,7 +3,6 @@ Version: {{VERSION}}
|
|||||||
Section: net
|
Section: net
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: {{ARCH}}
|
Architecture: {{ARCH}}
|
||||||
Depends: libc6, libuv1, libzmq5, libcurl4
|
|
||||||
Maintainer: P2Pool Team <noreply@example.com>
|
Maintainer: P2Pool Team <noreply@example.com>
|
||||||
Homepage: https://github.com/SChernykh/p2pool
|
Homepage: https://github.com/SChernykh/p2pool
|
||||||
Description: Decentralized pool for Monero mining
|
Description: Decentralized pool for Monero mining
|
||||||
|
|||||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ Type=simple
|
|||||||
User=p2pool
|
User=p2pool
|
||||||
Group=p2pool
|
Group=p2pool
|
||||||
WorkingDirectory=/var/lib/p2pool
|
WorkingDirectory=/var/lib/p2pool
|
||||||
ExecStart=/opt/p2pool/p2pool --params-file /var/lib/p2pool/params.conf
|
ExecStart=/opt/p2pool/p2pool --params-file /etc/p2pool/params.conf
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=10s
|
RestartSec=10s
|
||||||
StandardOutput=journal
|
StandardOutput=journal
|
||||||
|
|||||||
Vendored
+39
-84
@@ -12,78 +12,48 @@ if ! getent passwd p2pool >/dev/null; then
|
|||||||
--gecos "P2Pool Service" p2pool
|
--gecos "P2Pool Service" p2pool
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create data directory
|
|
||||||
mkdir -p /var/lib/p2pool/data-api
|
|
||||||
chown -R p2pool:p2pool /var/lib/p2pool
|
|
||||||
chmod -R 750 /var/lib/p2pool
|
|
||||||
|
|
||||||
# Create example params.conf if it doesn't exist
|
|
||||||
if [ ! -f /var/lib/p2pool/params.conf ]; then
|
|
||||||
cat > /var/lib/p2pool/params.conf << 'CONF'
|
|
||||||
# P2Pool Configuration File
|
|
||||||
# Edit this file with your settings and restart the service
|
|
||||||
|
|
||||||
# Monero node connection
|
|
||||||
host = 127.0.0.1
|
|
||||||
rpc-port = 18081
|
|
||||||
zmq-port = 18083
|
|
||||||
|
|
||||||
# Use SSL for RPC connection
|
|
||||||
# rpc-ssl = true
|
|
||||||
|
|
||||||
# RPC credentials (if applicable)
|
|
||||||
# rpc-login = username:password
|
|
||||||
|
|
||||||
# Your Monero wallet address (REQUIRED)
|
|
||||||
wallet = YOUR_MONERO_WALLET_ADDRESS
|
|
||||||
|
|
||||||
# P2P settings
|
|
||||||
p2p = 0.0.0.0:37889
|
|
||||||
|
|
||||||
# API settings
|
|
||||||
data-api = /var/lib/p2pool/data-api
|
|
||||||
local-api = true
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
log-file = /var/log/p2pool/p2pool.log
|
|
||||||
loglevel = 3
|
|
||||||
|
|
||||||
# Mining mode (uncomment to enable mini sidechain)
|
|
||||||
# mini = true
|
|
||||||
|
|
||||||
# Merge mining (optional - uncomment to enable Tari merge mining)
|
|
||||||
# merge-mine = tari://TARI_NODE_IP:18142 TARI_WALLET_ADDRESS
|
|
||||||
|
|
||||||
# Stratum server (for miners to connect)
|
|
||||||
# stratum = 0.0.0.0:3333
|
|
||||||
CONF
|
|
||||||
chown p2pool:p2pool /var/lib/p2pool/params.conf
|
|
||||||
chmod 640 /var/lib/p2pool/params.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create log directory
|
# Create log directory
|
||||||
mkdir -p /var/log/p2pool
|
mkdir -p /var/log/p2pool
|
||||||
chown p2pool:p2pool /var/log/p2pool
|
chown p2pool:p2pool /var/log/p2pool
|
||||||
chmod 750 /var/log/p2pool
|
chmod 750 /var/log/p2pool
|
||||||
|
|
||||||
# Set binary permissions
|
# Create data directory(非递归设权限,避免升级时遍历庞大数据目录)
|
||||||
chown root:root /opt/p2pool/p2pool
|
mkdir -p /var/lib/p2pool/data-api
|
||||||
|
chown p2pool:p2pool /var/lib/p2pool /var/lib/p2pool/data-api
|
||||||
|
chmod 750 /var/lib/p2pool /var/lib/p2pool/data-api
|
||||||
|
|
||||||
|
# Create config directory
|
||||||
|
mkdir -p /etc/p2pool
|
||||||
|
|
||||||
|
# 兼容旧版本:配置文件曾位于 /var/lib/p2pool/params.conf,迁移到 /etc/p2pool/params.conf
|
||||||
|
if [ ! -f /etc/p2pool/params.conf ] && [ -f /var/lib/p2pool/params.conf ]; then
|
||||||
|
echo "Migrating existing config from /var/lib/p2pool to /etc/p2pool..."
|
||||||
|
cp /var/lib/p2pool/params.conf /etc/p2pool/params.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 首次安装:从包内默认配置生成(源:conf/params.conf.example)。升级不覆盖已有配置
|
||||||
|
if [ ! -f /etc/p2pool/params.conf ]; then
|
||||||
|
cp /opt/p2pool/params.conf /etc/p2pool/params.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown p2pool:p2pool /etc/p2pool/params.conf
|
||||||
|
chmod 640 /etc/p2pool/params.conf
|
||||||
|
|
||||||
|
# Set permissions:/opt 目录与二进制 755,数据文件 644(对齐 xxxig / xxxig-proxy / mond)
|
||||||
|
chown -R root:root /opt/p2pool
|
||||||
|
find /opt/p2pool -type d -exec chmod 755 {} +
|
||||||
|
find /opt/p2pool -type f -exec chmod 644 {} +
|
||||||
chmod 755 /opt/p2pool/p2pool
|
chmod 755 /opt/p2pool/p2pool
|
||||||
|
|
||||||
# Reload systemd and handle service restart on upgrade
|
# Reload systemd
|
||||||
if [ -d /run/systemd/system ]; then
|
if [ -d /run/systemd/system ]; then
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
# On upgrade: restart service if it was enabled
|
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
|
||||||
if [ "$1" = "configure" ] && [ -n "$2" ]; then
|
# 故首次安装仍保持"不自动启动"语义
|
||||||
# $2 is the previously installed version (only set on upgrade)
|
systemctl try-restart p2pool.service 2>/dev/null || true
|
||||||
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
|
||||||
echo "Restarting p2pool service after upgrade..."
|
|
||||||
systemctl start p2pool.service || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Note: On fresh install, service is NOT auto-enabled or auto-started
|
# Note: On fresh install, service is NOT auto-enabled or auto-started
|
||||||
# Users should manually enable the service:
|
|
||||||
# systemctl enable p2pool.service
|
# systemctl enable p2pool.service
|
||||||
# systemctl start p2pool.service
|
# systemctl start p2pool.service
|
||||||
fi
|
fi
|
||||||
@@ -91,31 +61,16 @@ fi
|
|||||||
echo ""
|
echo ""
|
||||||
echo "✅ P2Pool installed successfully!"
|
echo "✅ P2Pool installed successfully!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "📋 Before starting P2Pool, you MUST configure your settings:"
|
|
||||||
echo ""
|
|
||||||
echo "1. Edit the configuration file:"
|
|
||||||
echo " sudo nano /var/lib/p2pool/params.conf"
|
|
||||||
echo ""
|
|
||||||
echo " Set your Monero wallet address and adjust other settings as needed."
|
|
||||||
echo ""
|
|
||||||
echo "2. Start P2Pool:"
|
|
||||||
echo " sudo systemctl enable p2pool.service"
|
|
||||||
echo " sudo systemctl start p2pool.service"
|
|
||||||
echo ""
|
|
||||||
echo "3. Check status:"
|
|
||||||
echo " sudo systemctl status p2pool.service"
|
|
||||||
echo " sudo journalctl -u p2pool -f"
|
|
||||||
echo ""
|
|
||||||
echo "📁 Important paths:"
|
echo "📁 Important paths:"
|
||||||
echo " Config file: /var/lib/p2pool/params.conf"
|
echo " Config file: /etc/p2pool/params.conf"
|
||||||
echo " Data directory: /var/lib/p2pool"
|
echo " Data directory: /var/lib/p2pool/data-api"
|
||||||
echo " Log directory: /var/log/p2pool"
|
echo " Log directory: /var/log/p2pool"
|
||||||
echo " Binary: /opt/p2pool/p2pool"
|
echo " Binaries: /opt/p2pool/p2pool"
|
||||||
|
echo " Systemd services: p2pool.service"
|
||||||
echo ""
|
echo ""
|
||||||
echo "💡 Tip: Your params.conf will NOT be overwritten during package upgrades."
|
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
|
||||||
echo ""
|
echo " Before starting, set your Monero wallet in /etc/p2pool/params.conf, then:"
|
||||||
echo "For help:"
|
echo " sudo systemctl enable --now p2pool.service"
|
||||||
echo " /opt/p2pool/p2pool --help"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Vendored
+2
-1
@@ -12,9 +12,10 @@ case "$1" in
|
|||||||
delgroup --quiet p2pool || true
|
delgroup --quiet p2pool || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove data directories (only on purge)
|
# Remove data/config directories (only on purge)
|
||||||
rm -rf /var/lib/p2pool
|
rm -rf /var/lib/p2pool
|
||||||
rm -rf /var/log/p2pool
|
rm -rf /var/log/p2pool
|
||||||
|
rm -rf /etc/p2pool
|
||||||
;;
|
;;
|
||||||
|
|
||||||
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||||
|
|||||||
Vendored
+16
-31
@@ -1,33 +1,18 @@
|
|||||||
case "$1" in
|
#!/bin/sh
|
||||||
upgrade)
|
set -e
|
||||||
# Stop service only during upgrade, keep enabled state
|
|
||||||
if [ -d /run/systemd/system ]; then
|
# 仅在卸载(remove)时停用服务;升级(upgrade)时保持运行,
|
||||||
if systemctl is-active --quiet p2pool.service; then
|
# 由 postinst 的 try-restart 重启以加载新二进制
|
||||||
echo "Stopping p2pool service for upgrade..."
|
if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then
|
||||||
systemctl stop p2pool.service
|
if systemctl is-active --quiet p2pool.service; then
|
||||||
fi
|
echo "Stopping p2pool service..."
|
||||||
fi
|
systemctl stop p2pool.service
|
||||||
;;
|
fi
|
||||||
remove|deconfigure)
|
|
||||||
# Stop and disable service during removal
|
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
||||||
if [ -d /run/systemd/system ]; then
|
echo "Disabling p2pool service..."
|
||||||
if systemctl is-active --quiet p2pool.service; then
|
systemctl disable p2pool.service
|
||||||
echo "Stopping p2pool service..."
|
fi
|
||||||
systemctl stop p2pool.service
|
fi
|
||||||
fi
|
|
||||||
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
|
||||||
echo "Disabling p2pool service..."
|
|
||||||
systemctl disable p2pool.service
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
failed-upgrade)
|
|
||||||
# Do nothing on failed upgrade
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "prerm called with unknown argument \`$1'" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# p2pool musl 纯静态构建(external 静态库参照上游官方 c-cpp.yml 的 Alpine static 流程)
|
||||||
|
# Alpine + 自编 external 静态库(curl/libuv/libzmq) + 静态 grpc 栈(WITH_GRPC=ON,Tari 合并挖矿) + -DSTATIC_BINARY=ON
|
||||||
|
# 产物 fully-static(ldd: not a dynamic executable),glibc/musl 任意发行版直接运行。
|
||||||
|
# 为何 musl:musl getaddrinfo 自包含,全静态可跨发行版;glibc 静态会因 NSS dlopen 失败。
|
||||||
|
FROM alpine:3.21 AS build
|
||||||
|
ARG P2POOL_VERSION
|
||||||
|
ARG TARGETARCH
|
||||||
|
RUN apk add --no-cache git cmake gcc g++ make linux-headers perl
|
||||||
|
|
||||||
|
RUN git clone https://github.com/SChernykh/p2pool /src/p2pool
|
||||||
|
WORKDIR /src/p2pool
|
||||||
|
# 拉 8 个常规子模块 + grpc 及其 6 个必需 third_party(abseil/boringssl/cares/protobuf/re2/zlib)。
|
||||||
|
# WITH_GRPC=ON 需完整 grpc 栈静态编译以支持 Tari 合并挖矿;其余 9 个 grpc 子模块
|
||||||
|
# (benchmark/googletest/envoy/googleapis/xds 等测试或 xDS 依赖,已 GRPC_NO_XDS) 跳过省体积/时间。
|
||||||
|
RUN git checkout ${P2POOL_VERSION} && \
|
||||||
|
git submodule update --init --recursive \
|
||||||
|
external/src/RandomX external/src/rapidjson external/src/cppzmq \
|
||||||
|
external/src/libuv external/src/libzmq external/src/robin-hood-hashing \
|
||||||
|
external/src/curl external/src/miniupnp && \
|
||||||
|
git submodule update --init external/src/grpc && \
|
||||||
|
git -C external/src/grpc submodule update --init --recursive \
|
||||||
|
third_party/abseil-cpp third_party/boringssl-with-bazel \
|
||||||
|
third_party/cares/cares third_party/protobuf third_party/re2 third_party/zlib
|
||||||
|
|
||||||
|
# external libcurl:HTTP + p2pool boringssl 集成(保留 rpc-ssl 连 HTTPS monerod)。
|
||||||
|
# 完整照搬官方 c-cpp.yml 的 curl flags:P2POOL_BORINGSSL=ON 是上游给 curl 打的独立
|
||||||
|
# boringssl TLS 后端补丁(不走 curl 标准 CURL_ENABLE_SSL 路径,故二者共存且仍支持 --rpc-ssl)。
|
||||||
|
# 一整套 CURL_DISABLE_*(尤其 SRP/AWS/*_AUTH) 用于跳过会引用 OpenSSL::SSL imported target 的
|
||||||
|
# curl_openssl_check_exists 符号检测——新版 cmake 在 try_compile 阶段校验该 target 必失败,少一个都会触发。
|
||||||
|
RUN cd external/src/curl && cmake . -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCURL_DROP_UNUSED=ON -DCURL_DISABLE_TYPECHECK=ON \
|
||||||
|
-DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG=ON -DCURL_DISABLE_SHA512_256=ON \
|
||||||
|
-DPICKY_COMPILER=OFF -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF \
|
||||||
|
-DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON \
|
||||||
|
-DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF \
|
||||||
|
-DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF \
|
||||||
|
-DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON \
|
||||||
|
-DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON \
|
||||||
|
-DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON \
|
||||||
|
-DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON \
|
||||||
|
-DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON \
|
||||||
|
-DCURL_DISABLE_VERBOSE_STRINGS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF \
|
||||||
|
-DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF \
|
||||||
|
-DENABLE_UNIX_SOCKETS=OFF -DBUILD_TESTING=OFF -DUSE_NGHTTP2=OFF \
|
||||||
|
-DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON \
|
||||||
|
-DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON \
|
||||||
|
-DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON \
|
||||||
|
-DCURL_DISABLE_NEGOTIATE_AUTH=ON \
|
||||||
|
-DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include && \
|
||||||
|
make -j"$(nproc)"
|
||||||
|
|
||||||
|
# external libuv 静态
|
||||||
|
RUN cd external/src/libuv && mkdir build && cd build && \
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF && \
|
||||||
|
make -j"$(nproc)"
|
||||||
|
|
||||||
|
# external libzmq 静态
|
||||||
|
RUN cd external/src/libzmq && mkdir build && cd build && \
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||||
|
-DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF \
|
||||||
|
-DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF && \
|
||||||
|
make -j"$(nproc)"
|
||||||
|
|
||||||
|
# p2pool 主体:纯静态(STATIC_BINARY) + 启用 grpc(Tari 合并挖矿) + 禁合并挖矿捐赠(gitea-p2pool 定制)
|
||||||
|
RUN if [ "$TARGETARCH" = "arm64" ]; then ARCH_ID=aarch64; else ARCH_ID=x86_64; fi && \
|
||||||
|
mkdir build && cd build && \
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||||
|
-DSTATIC_BINARY=ON -DWITH_GRPC=ON -DWITH_MERGE_MINING_DONATION=OFF \
|
||||||
|
-DARCH_ID="$ARCH_ID" \
|
||||||
|
-DCMAKE_C_FLAGS='-Wl,-s -Wl,--gc-sections' \
|
||||||
|
-DCMAKE_CXX_FLAGS='-Wl,-s -Wl,--gc-sections' && \
|
||||||
|
make -j"$(nproc)" p2pool && cp p2pool /p2pool
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
ARG TARGETARCH
|
||||||
|
COPY --from=build /p2pool /linux_${TARGETARCH}/p2pool
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
FROM alpine:3.21 AS base
|
|
||||||
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
RUN apk update && apk add --no-cache \
|
|
||||||
git \
|
|
||||||
cmake \
|
|
||||||
gcc \
|
|
||||||
g++ \
|
|
||||||
make \
|
|
||||||
linux-headers \
|
|
||||||
libuv-dev \
|
|
||||||
zeromq-dev \
|
|
||||||
curl-dev
|
|
||||||
|
|
||||||
FROM base AS build
|
|
||||||
|
|
||||||
ARG P2POOL_VERSION
|
|
||||||
ARG TARGETARCH
|
|
||||||
ARG BUILDPLATFORM
|
|
||||||
ARG TARGETPLATFORM
|
|
||||||
|
|
||||||
RUN git clone --recursive https://github.com/SChernykh/p2pool /src/p2pool
|
|
||||||
|
|
||||||
WORKDIR /src/p2pool
|
|
||||||
|
|
||||||
RUN git checkout ${P2POOL_VERSION}
|
|
||||||
|
|
||||||
# Determine parallel jobs based on cross-compilation and architecture
|
|
||||||
RUN mkdir build && cd build && \
|
|
||||||
if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
|
||||||
MAKE_JOBS="-j2"; \
|
|
||||||
elif [ "$TARGETARCH" = "amd64" ]; then \
|
|
||||||
MAKE_JOBS="-j$(($(nproc) / 2))"; \
|
|
||||||
else \
|
|
||||||
MAKE_JOBS="-j$(nproc)"; \
|
|
||||||
fi && \
|
|
||||||
echo "Building with parallel jobs: $MAKE_JOBS (arch: $TARGETARCH, cross-compile: $([ "$BUILDPLATFORM" != "$TARGETPLATFORM" ] && echo yes || echo no))" && \
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_MERGE_MINING_DONATION=OFF && \
|
|
||||||
make $MAKE_JOBS
|
|
||||||
|
|
||||||
FROM scratch
|
|
||||||
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
COPY --from=build /src/p2pool/build/p2pool /linux_${TARGETARCH}/p2pool
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
FROM ubuntu:24.04 AS base
|
|
||||||
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
git \
|
|
||||||
cmake \
|
|
||||||
gcc \
|
|
||||||
g++ \
|
|
||||||
make \
|
|
||||||
libuv1-dev \
|
|
||||||
libzmq3-dev \
|
|
||||||
libcurl4-openssl-dev \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
FROM base AS build
|
|
||||||
|
|
||||||
ARG P2POOL_VERSION
|
|
||||||
ARG TARGETARCH
|
|
||||||
ARG BUILDPLATFORM
|
|
||||||
ARG TARGETPLATFORM
|
|
||||||
|
|
||||||
RUN git clone --recursive https://github.com/SChernykh/p2pool /src/p2pool
|
|
||||||
|
|
||||||
WORKDIR /src/p2pool
|
|
||||||
|
|
||||||
RUN git checkout ${P2POOL_VERSION}
|
|
||||||
|
|
||||||
# Determine parallel jobs based on cross-compilation and architecture
|
|
||||||
RUN mkdir build && cd build && \
|
|
||||||
if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
|
||||||
MAKE_JOBS="-j2"; \
|
|
||||||
elif [ "$TARGETARCH" = "amd64" ]; then \
|
|
||||||
MAKE_JOBS="-j$(($(nproc) / 2))"; \
|
|
||||||
else \
|
|
||||||
MAKE_JOBS="-j$(nproc)"; \
|
|
||||||
fi && \
|
|
||||||
echo "Building with parallel jobs: $MAKE_JOBS (arch: $TARGETARCH, cross-compile: $([ "$BUILDPLATFORM" != "$TARGETPLATFORM" ] && echo yes || echo no))" && \
|
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_MERGE_MINING_DONATION=OFF && \
|
|
||||||
make $MAKE_JOBS
|
|
||||||
|
|
||||||
FROM scratch
|
|
||||||
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
COPY --from=build /src/p2pool/build/p2pool /linux_${TARGETARCH}/p2pool
|
|
||||||
Reference in New Issue
Block a user