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.
A Debian package must comply with the precise rules compiled in the Debian policy, and each package maintainer must know them. There is no requirement to know them by heart, but rather to know they exist and to refer to them whenever a choice presents a non-trivial alternative. Every Debian maintainer has made mistakes by not knowing about a rule, but this is not a huge problem as long as the error gets fixed when a user reports it as a bug report (which tends to happen fairly soon thanks to advanced users). The
Standards-Version
field in
debian/control
specifies the version of the Debian policy with which a package complies. Maintainers should comply to the latest version of the Debian policy.
هناك أدوات عديدة تساعد مشرفي الحزم على إنجاز أعمالهم. يمرّ هذا القسم عليها سريعاً، لكن لا يتفصل فيها كثيراً، لأن هناك وثائق شاملة لكل منها.
تحوي الحزمة devscripts العديد من البرامج التي تساعد في نواحي كثيرة من عمل مطوري دبيان:
يسمح debuild
بتوليد حزمة (باستخدام dpkg-buildpackage
) وتشغيل lintian
للتحقق من توافقها مع سياسة دبيان بعد ذلك.
يُنظّف debclean
الحزمة المصدرية بعد توليد الحزمة الثنائية.
يسمح dch
بتحرير الملف debian/changelog
في الحزمة المصدرية بسرعة وسهولة.
يتحقق uscan
من إصدار المؤلف المنبعي نسخة جديدة من البرنامج؛ هذا يحتاج لملف debian/watch
يحدد موقع هذه الإصدارات الجديدة.
يسمح debi
بتثبيت حزمة دبيان المولدة (من خلال dpkg -i
) دون الحاجة لكتابة اسمها الكامل ومسارها.
كما يسمح 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
إنشاء مراجعة جديدة للحزمة عندما تصدر نسخة منبعية (upstream version) جديدة.
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) الملفات اللازمة لتوليد حزمة دبيان في مجلد يحوي مصادر أحد البرامج. كما يمكنك أن تخمن من اسم البرنامج، سوف تستخدم الملفات المولدة debhelper افتراضياً.
This tool is one of the most important: it is the Debian package checker. It is based on a large array of tests created from the Debian policy, and detects quickly and automatically many errors that can then be fixed before packages are released.
هذه الأداة للمساعدة فقط، وأحياناً تخطئ (مثلاً، سياسة دبيان تتغير مع الوقت، ولذلك قد يتخلف lintian
أحياناً). كما أنها ليست شاملة: فإذا لم يظهر Lintain أي أخطاء فلا يجب أن تفهم هذا على أنه برهان على أن الحزمة مثالية؛ بل هي تتفادى أكثر الأخطاء شيوعاً في أفضل الحالات.
هذه أداة مهمة أيضاً: تؤتمت هذه الأداة تثبيت وتحديث وإزالة وتطهير الحزمة (في بيئة معزولة)، وتتحقق من عدم ظهور أخطاء في أي واحدة من هذه العمليات. يمكنها أن تساعدك على اكتشاف الاعتماديات المفقودة، كما تكتشف بقاء بعض الملفات بالخطأ بعد تطهير الحزمة.
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
builds the same source code twice in different environments, and then checks the binaries produced by each build for differences. If any are found, then diffoscope
(if unavailable, diff
) is used to display them in detail for later analysis.
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 bookworm --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-bookworm-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 Bookworm 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: