Creating a quality Debian package is not always a simple task, and becoming a package maintainer takes some learning, both with theory and practice in technical and legal matters. It is not a simple matter of building and installing software; rather, the bulk of the complexity comes from understanding the problems and conflicts, and more generally the interactions, with the myriad of other packages available.
很多工具帮助软件包的维护人员进行他们的工作。这一节快速地描述了这些工具,但没有给出完整细节,因为它们各自都有详细的文档。
devscripts 软件包包含很多程序来帮助大范围的 Debian 开发者的工作:
debuild
允许(以 dpkg-buildpackage
)来生成软件包,此后允许运行lintian
来检查它与 Debian 政策的兼容性。
debclean
在生成二进制包后清除源码包。
dch
允许快速且容易地编辑源码包中的 debian/changelog
文件。
uscan
检查新版本的软件是否已经由上游作者发布;这需要 debian/watch
文件具有这个发布位置的描述。
debi
允许(以 dpkg -i
)来安装刚生成的 Debian 软件包,而无需键入其完整名称与路径。
debc
允许以相似的方式(用 dpkg -c
)来扫描最近生成的软件包,而无需键入其完整名称与路径。
bts
controls the bug tracking system from the command line; this program automatically generates the appropriate emails.
debrelease
将最近生成的软件包上传到远端的服务器,而无需键入相关的 .changes
文件的完整名称与路径。
debsign
签署 *.dsc
和 *.changes
文件。
当上游版本发布时,uupdate
自动创建新版本的软件包。
All of the mentioned commands are documented in their respective manual pages. They can further be configured per user in one file: ~/.devscripts
.
15.4.1.3.2. debhelper 和 dh-make
Debhelper is a set of scripts easing the creation of policy-compliant packages; these scripts are invoked from debian/rules
. Debhelper has been widely adopted within Debian, as evidenced by the fact that it is used by the majority of official Debian packages. All the commands it contains have a dh_
prefix. Each of them is documented in a manual page. The different compatibility levels and common options are described in debhelper(7).
dh_make
脚本(位于 dh-make 软件包中)创建文件,在初始包含一块软件的源代码的目录中生成 Debian 软件包需要这些创建文件。可以从程序的名称猜到,生成的文件默认使用 debhelper。
这是最重要的工具之一:它是 Debian 软件包检查程序。它基于从 Debian 政策创立的大量测试,并快速且自动地检测很多错误,然后可以在软件包发布前修复。
这个工具只是个帮手,它有时会犯错误(例如,由于 Debian 政策不时更改,lintian
有时会过时)。它有时还不够详细:没有得到任何 Lintian 错误不应该被理解成软件包被证明是完美的;最多不过是避免了最常见的错误。
这是另一个重要工具:它(在隔离的环境中)自动安装、升级、删除并净化软件包,并且检查这些操作不会导致错误。它可以帮助检查丢失的依赖,并且还可以检查在软件包净化后文件在什么时候不正确地留下来。
autopkgtest
runs tests on binary packages, using the tests supplied in the source package in debian/tests/
. Several commands allow the easy creation of chrooted or virtual test environments.
reprotest
在不同的环境中两次构建相同的源代码,然后检查每次构建的二进制文件的差异。如果发现任何差异,那么 diffoscope
(如果可用的话则用 diff
)来具体显示它们供后面进行分析。
15.4.1.3.7. dupload
和 dput
The dupload
and dput
commands allow uploading a Debian package to a (possibly remote) server. This allows developers to publish their package on the main Debian server (ftp-master.debian.org
) so that it can be integrated to the archive and distributed by mirrors. These commands take a .changes
file as a parameter, and deduce the other relevant files from its contents.
15.4.1.3.8. git-buildpackage and dgit
The project has been using various version control systems over the years to store packaging efforts or package source code, or allow collaborative package maintenance. In an effort to unify the systems and efforts, it was ultimately decided in 2017 to move (almost) all package sources into
Git (
文化 Git) onto a Gitlab instance called
salsa.debian.org
.
To make packaging using Git easier for Debian developers, tools have been developed. These allow not only to store the packaging files in Git, but also to use the Git repositories (and their history) of software projects, put patches applied to package sources into Git history, maintain software versions per distribution, etc.
One of the most famous packages is git-buildpackage. An alternative is dgit. Of course it is still possible to use neither of those.
Below is an example for a ~/.gbp.conf
configuration file
[DEFAULT]
builder = sbuild -d bullseye --build-dep-resolver=aptitude -s --source-only-changes --build-failed-commands "%SBUILD_SHELL"
pristine-tar = true
[buildpackage]
sign-tags = true
keyid = XXXX
postbuild = autopkgtest --user debci --apt-upgrade -s "$GBP_CHANGES_FILE" -- lxc --sudo autopkgtest-bullseye-amd64
export-dir = /tmp/build-area/
notify = off
[import-orig]
filter-pristine-tar = true
sign-tags = true
[pq]
drop = true
Building the package is then as easy as running gbp buildpackage
in the Git tree. It will start a package build in a Debian Bullseye chroot using sbuild
. When the build succeeds, the created files are checked running the autopkgtest
-testsuite (if defined). All the various options are explained in gbp.conf(5) and /etc/git-buildpackage/gbp.conf
.
All the tools mentioned so far have been included in the continuous integration (CI) process in the
salsa.debian.org
instance as well: