5.8. Step 4: Building package with debuild
您可以使用 debuild 或者等效的命令工具(参见 “第 5.4 节 “什么是 debuild?””)在这个源码树内构建一个非原生 Debian
软件包。命令的输出通常十分详细,如下所示,它会对构建中执行的操作进行解释。
Building package with debuild.
$ cd /path/to/debhello-0.0
$ debuild
dpkg-buildpackage -us -uc -ui -i
dpkg-buildpackage: info: source package debhello
dpkg-buildpackage: info: source version 0.0-1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Osamu Aoki
dpkg-source -i --before-build .
dpkg-buildpackage: info: host architecture amd64
debian/rules clean
dh clean
dh_auto_clean
make -j12 distclean
...
debian/rules binary
dh binary
dh_update_autotools_config
dh_autoreconf
dh_auto_configure
dh_auto_build
make -j12 "INSTALL=install --strip-program=true"
make[1]: Entering directory '/path/to/debhello-0.0'
# CFLAGS=-g -O2 -Werror=implicit-function-declaration
...
Finished running lintian.
这里验证了 CFLAGS 已经得到了更新,添加了 -Wall 和 -pendatic 参数;这是我们先前在 DEB_CFLAGS_MAINT_APPEND 变量中所指定的。
根据 lintian 的报告,您应该如同后文中的例子那样(请见
“第 14 章 更多示例”)为软件包添加 man 手册页。我们这里暂且跳过这部分内容。
现在我们来看看成果如何。
debhello 0.0 版使用 debuild
命令产生的文件:.
$ cd /path/to
$ tree -FL 1
./
├── debhello-0.0/
├── debhello-0.0.tar.gz
├── debhello-dbgsym_0.0-1_amd64.deb
├── debhello_0.0-1.debian.tar.xz
├── debhello_0.0-1.dsc
├── debhello_0.0-1_amd64.build
├── debhello_0.0-1_amd64.buildinfo
├── debhello_0.0-1_amd64.changes
├── debhello_0.0-1_amd64.deb
└── debhello_0.0.orig.tar.gz -> debhello-0.0.tar.gz
2 directories, 9 files
您可以看见生成的全部文件。
debhello_0.0.orig.tar.gz 是指向上游源码压缩包的符号链接。
debhello_0.0-1.debian.tar.xz 包含了维护者生成的内容。
debhello_0.0-1.dsc 是 Debian 源码包的元数据文件。
debhello_0.0-1_amd64.deb 是 Debian 二进制软件包。
debhello-dbgsym_0.0-1_amd64.deb 是 Debian
的调试符号二进制软件包。另请参见 “第 10.21 节 “-dbgsym package””。
debhello_0.0-1_amd64.build 是构建日志文件。
debhello_0.0-1_amd64.buildinfo 是
dpkg-genbuildinfo(1) 生成的元数据文件。
debhello_0.0-1_amd64.changes 是 Debian
二进制软件包的元数据文件。
debhello_0.0-1.debian.tar.xz 包含了 Debian
对上游源代码的修改,具体如下所示。
压缩文件 debhello_0.0-1.debian.tar.xz 的内容:.
$ tar -tzf debhello-0.0.tar.gz
debhello-0.0/
debhello-0.0/src/
debhello-0.0/src/hello.c
debhello-0.0/Makefile
debhello-0.0/README.md
$ tar --xz -tf debhello_0.0-1.debian.tar.xz
debian/
debian/README.Debian
debian/changelog
debian/control
debian/copyright
debian/gbp.conf
debian/rules
debian/salsa-ci.yml
debian/source/
debian/source/format
debian/tests/
debian/tests/control
debian/upstream/
debian/upstream/metadata
debian/watch
debhello_0.0-1_amd64.deb
包含了将要安装至目标系统中的文件。
The debhello-debsym_0.0-1_amd64.deb
contains the debug symbol files to be installed to the target system.
所有二进制包的包内容:.
$ dpkg -c debhello-dbgsym_0.0-1_amd64.deb
drwxr-xr-x root/root ... ./
drwxr-xr-x root/root ... ./usr/
drwxr-xr-x root/root ... ./usr/lib/
drwxr-xr-x root/root ... ./usr/lib/debug/
drwxr-xr-x root/root ... ./usr/lib/debug/.build-id/
drwxr-xr-x root/root ... ./usr/lib/debug/.build-id/c4/
-rw-r--r-- root/root ... ./usr/lib/debug/.build-id/c4/cec6427d45de48efc7f263...
drwxr-xr-x root/root ... ./usr/share/
drwxr-xr-x root/root ... ./usr/share/doc/
lrwxrwxrwx root/root ... ./usr/share/doc/debhello-dbgsym -> debhello
$ dpkg -c debhello_0.0-1_amd64.deb
drwxr-xr-x root/root ... ./
drwxr-xr-x root/root ... ./usr/
drwxr-xr-x root/root ... ./usr/bin/
-rwxr-xr-x root/root ... ./usr/bin/hello
drwxr-xr-x root/root ... ./usr/share/
drwxr-xr-x root/root ... ./usr/share/doc/
drwxr-xr-x root/root ... ./usr/share/doc/debhello/
-rw-r--r-- root/root ... ./usr/share/doc/debhello/README.Debian
-rw-r--r-- root/root ... ./usr/share/doc/debhello/changelog.Debian.gz
-rw-r--r-- root/root ... ./usr/share/doc/debhello/copyright
生成的依赖列表会给出所有二进制软件包的依赖。
生成的所有二进制软件包的依赖列表(v=0.0):.
$ dpkg -f debhello-dbgsym_0.0-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: debhello (= 0.0-1)
$ dpkg -f debhello_0.0-1_amd64.deb pre-depends \
depends recommends conflicts breaks
Depends: libc6 (>= 2.34)
小心
在将软件包上传至 Debian 仓库之前,仍然有很多细节需要进行处理。
注意
如果跳过了对 debmake
命令自动生成的配置文件的手工调整步骤,所生成的二进制软件包可能缺少有用的软件包描述信息,某些政策的要求也无法满足。这个不正式的软件包对于
dpkg 命令来说可以正常处理,也许这样对您本地的部署来说已经足够好了。