Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 24s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 13s
Build and Release / build-and-test (arm64, alpine) (push) Successful in 6s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 0s
Build and Release / release (push) Successful in 28s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
96 lines
2.6 KiB
Bash
Executable File
96 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# 参数检查
|
|
if [ $# -ne 3 ]; then
|
|
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
|
|
echo "Example: $0 amd64 6.26.0 xxxig-amd64-ubuntu-6.26.0.tar.gz"
|
|
exit 1
|
|
fi
|
|
|
|
ARCH=$1
|
|
VERSION=$2
|
|
TARGZ_FILE=$3
|
|
PKG_NAME="xxxig"
|
|
DEB_VERSION="${VERSION#v}" # Debian 版本号必须以数字开头,去掉可能的 v 前缀
|
|
|
|
[ -f "$TARGZ_FILE" ] || { echo "❌ 找不到产物包: $TARGZ_FILE"; exit 1; }
|
|
|
|
# 转换架构名称(Docker 使用的架构名到 Debian 架构名)
|
|
case "$ARCH" in
|
|
amd64)
|
|
DEB_ARCH="amd64"
|
|
;;
|
|
arm64)
|
|
DEB_ARCH="arm64"
|
|
;;
|
|
*)
|
|
echo "Unsupported architecture: $ARCH"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
DEB_FILE="${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}.deb"
|
|
|
|
echo "📦 Building Debian package: ${DEB_FILE}"
|
|
echo " Architecture: ${DEB_ARCH}"
|
|
echo " Version: ${DEB_VERSION}"
|
|
echo " Source: ${TARGZ_FILE}"
|
|
|
|
# 创建临时目录
|
|
BUILD_DIR=$(mktemp -d)
|
|
trap "rm -rf $BUILD_DIR" EXIT
|
|
|
|
# 创建包目录结构
|
|
PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
|
|
mkdir -p "${PKG_DIR}/DEBIAN"
|
|
mkdir -p "${PKG_DIR}/opt/xxxig"
|
|
mkdir -p "${PKG_DIR}/lib/systemd/system"
|
|
|
|
# 解压二进制文件
|
|
echo "📂 Extracting binaries..."
|
|
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/xxxig"
|
|
|
|
# 生成 control 文件
|
|
echo "📝 Generating control file..."
|
|
sed -e "s/{{VERSION}}/${DEB_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 services..."
|
|
cp debian/xxxig-server.service "${PKG_DIR}/lib/systemd/system/"
|
|
cp debian/xxxig-daemon.service "${PKG_DIR}/lib/systemd/system/"
|
|
|
|
# 设置权限
|
|
chmod 755 "${PKG_DIR}/opt/xxxig/xxxigServer"
|
|
chmod 755 "${PKG_DIR}/opt/xxxig/xxxigDaemon"
|
|
chmod 755 "${PKG_DIR}/opt/xxxig/xxxig"
|
|
chmod 644 "${PKG_DIR}/opt/xxxig/config.json"
|
|
chmod 644 "${PKG_DIR}/opt/xxxig/config_cc.json"
|
|
chmod 644 "${PKG_DIR}/opt/xxxig/index.html"
|
|
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-server.service"
|
|
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-daemon.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!"
|