Files
mond/debian/build-deb.sh
Wang Defa 319cadb352
All checks were successful
Build and Release Mond / build-and-test (amd64) (push) Successful in 11m52s
Build and Release Mond / build-and-test (arm64) (push) Successful in 18m1s
Build and Release Mond / release (push) Has been skipped
feat: 更新 Monero 版本至 v0.18.4.5,并调整相关文档和配置
2026-01-21 11:56:40 +08:00

91 lines
2.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -e
# 参数检查
if [ $# -ne 3 ]; then
echo "Usage: $0 <ARCH> <VERSION> <BINARY_DIR>"
echo "Example: $0 amd64 0.18.4.5 build/Linux/release/bin"
exit 1
fi
ARCH=$1
VERSION=$2
BINARY_DIR=$3
PKG_NAME="mond"
DEB_FILE="${PKG_NAME}_${VERSION}_${ARCH}.deb"
# 转换架构名称Docker 使用的架构名到 Debian 架构名)
case "$ARCH" in
amd64)
DEB_ARCH="amd64"
;;
arm64)
DEB_ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
echo "📦 Building Debian package: ${DEB_FILE}"
echo " Architecture: ${DEB_ARCH}"
echo " Version: ${VERSION}"
echo " Binary directory: ${BINARY_DIR}"
# 检查二进制文件是否存在
if [ ! -f "${BINARY_DIR}/mond" ]; then
echo "❌ Error: mond binary not found in ${BINARY_DIR}"
exit 1
fi
# 创建临时目录
BUILD_DIR=$(mktemp -d)
trap "rm -rf $BUILD_DIR" EXIT
# 创建包目录结构
PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${VERSION}_${DEB_ARCH}"
mkdir -p "${PKG_DIR}/DEBIAN"
mkdir -p "${PKG_DIR}/opt/mond"
mkdir -p "${PKG_DIR}/lib/systemd/system"
# 复制二进制文件
echo "📂 Copying binary..."
cp "${BINARY_DIR}/mond" "${PKG_DIR}/opt/mond/mond"
# 生成 control 文件
echo "📝 Generating control file..."
sed -e "s/{{VERSION}}/${VERSION}/" \
-e "s/{{ARCH}}/${DEB_ARCH}/" \
debian/control.template > "${PKG_DIR}/DEBIAN/control"
# 复制维护脚本
echo "📋 Copying maintainer scripts..."
cp debian/postinst "${PKG_DIR}/DEBIAN/postinst"
cp debian/prerm "${PKG_DIR}/DEBIAN/prerm"
cp debian/postrm "${PKG_DIR}/DEBIAN/postrm"
chmod 755 "${PKG_DIR}/DEBIAN/postinst"
chmod 755 "${PKG_DIR}/DEBIAN/prerm"
chmod 755 "${PKG_DIR}/DEBIAN/postrm"
# 复制 systemd service 文件
echo "🔧 Installing systemd service..."
cp debian/mond.service "${PKG_DIR}/lib/systemd/system/"
# 设置权限
chmod 755 "${PKG_DIR}/opt/mond/mond"
chmod 644 "${PKG_DIR}/lib/systemd/system/mond.service"
# 构建 deb 包
echo "🔨 Building package..."
dpkg-deb --build --root-owner-group "${PKG_DIR}" "${DEB_FILE}"
# 检查包
echo "✅ Package built successfully!"
echo "📦 Package: $(pwd)/${DEB_FILE}"
echo "📊 Package info:"
dpkg-deb --info "${DEB_FILE}"
echo ""
echo "🎉 Done!"