chsrc/pkg/DEB/BUILD.md
Aoran Zeng c6bbf99883
Update DEB doc
[GitHub #207]
2025-06-15 13:00:31 +08:00

1.9 KiB

构建 DEB package

从源代码构建

准备

安装构建所需的依赖:

sudo apt-get update
sudo apt-get install build-essential debhelper devscripts fakeroot

构建

git clone https://github.com/RubyMetric/chsrc.git
cd chsrc

# 执行构建命令
./deb.makefile deb-build

# 安装生成的 .deb 文件
sudo dpkg -i ../chsrc_*.deb

交叉编译

为不同架构进行构建:

# For ARM64
CC=aarch64-linux-gnu-gcc dpkg-buildpackage -us -uc -b -aarm64

# For ARMv7 (armhf)
CC=arm-linux-gnueabihf-gcc dpkg-buildpackage -us -uc -b -aarmhf

安装与测试

# 安装生成的包
sudo dpkg -i ../chsrc_*.deb
sudo apt-get install -f  # 修复依赖问题

# 运行测试
./deb-test.sh

# 卸载
sudo apt-get remove chsrc

清理构建产物

./deb.makefile deb-clean

卸载

sudo apt-get remove chsrc

包括删除配置在内的完全删除:

sudo apt-get purge chsrc

故障排查

常见问题

  1. 构建失败: 检查 debian/control 中的依赖是否正确
  2. 交叉编译失败: 确认目标架构的工具链已正确安装
  3. 安装测试失败: 检查 postinst 脚本是否有错误

调试构建

# 启用详细输出
DEB_BUILD_OPTIONS="nocheck" debuild -us -uc -b

# 检查构建日志
less ../chsrc_*.build

# 检查包内容
dpkg --contents ../chsrc_*.deb
# 或
dpkg-deb --contents ../chsrc_*.deb