apt-get source source-package-name
command. This command requires a deb-src
line in the /etc/apt/sources.list
file, and up-to-date index files (i.e. apt-get update
). These conditions should already be met if you followed the instructions from the chapter dealing with APT configuration (see قسم 6.1, “تعبئة الملف sources.list
”). Note, however, that you will be downloading the source packages from the Debian version mentioned in the deb-src
line. If you need another version, you may need to download it manually from a Debian mirror or from the web site. This involves fetching two or three files (with extensions *.dsc
— for Debian Source Control — *.tar.comp
, and sometimes *.diff.gz
or *.debian.tar.comp
— comp taking one value among gz
, bz2
or xz
depending on the compression tool in use), then run the dpkg-source -x file.dsc
command. If the *.dsc
file is directly accessible at a given URL, there is an even simpler way to fetch it all, with the dget URL
command. This command (which can be found in the devscripts package) fetches the *.dsc
file at the given address, then analyzes its contents, and automatically fetches the file or files referenced within. Once everything has been downloaded, it verifies the integrity of the downloaded source packages using dscverify
, and it extracts the source package (unless the -d
or --download-only
option is used). The Debian keyring is needed, unless the option -u
is supplied.
$
apt source samba
Reading package lists... Done NOTICE: 'samba' packaging is maintained in the 'Git' version control system at: https://salsa.debian.org/samba-team/samba.git Please use: git clone https://salsa.debian.org/samba-team/samba.git to retrieve the latest (possibly unreleased) updates to the package. Need to get 11.7 MB of source archives. Get:1 http://security.debian.org/debian-security buster/updates/main samba 2:4.9.5+dfsg-5+deb10u1 (dsc) [4,316 B] Get:2 http://security.debian.org/debian-security buster/updates/main samba 2:4.9.5+dfsg-5+deb10u1 (tar) [11.4 MB] Get:3 http://security.debian.org/debian-security buster/updates/main samba 2:4.9.5+dfsg-5+deb10u1 (diff) [252 kB] Fetched 11.7 MB in 1s (9,505 kB/s) dpkg-source: info: extracting samba in samba-4.9.5+dfsg dpkg-source: info: unpacking samba_4.9.5+dfsg.orig.tar.xz dpkg-source: info: unpacking samba_4.9.5+dfsg-5+deb10u1.debian.tar.xz dpkg-source: info: using patch list from debian/patches/series dpkg-source: info: applying 07_private_lib dpkg-source: info: applying bug_221618_precise-64bit-prototype.patch [...]
2:4.9.5+dfsg-5
, we can create version 2:4.9.5+dfsg-5falcot1
, which clearly indicates the origin of the package. This makes the package version number higher than the one provided by Debian, so that the package will easily install as an update to the original package. Such a change is best effected with the dch
command (Debian CHangelog) from the devscripts package.
The last command invokes a text editor ($
cd samba-4.9.5+dfsg
$
dch --local falcot
sensible-editor
— this should be your favorite editor if it is mentioned in the VISUAL
or EDITOR
environment variables, and the default editor otherwise) to allow documenting the differences brought by this rebuild. This editor shows us that dch
really did change the debian/changelog
file.
debian/rules
، الذي يقود الخطوات المختلفة في عملية بناء الحزمة. في أبسط الحالات، ستجد السطور التي تتعلق بالإعدادات الافتراضية (./configure …
) أو عملية البناء الفعلية ($(MAKE) …
or make …
) بسهولة. إذا لم تُستَدعى هذه الأوامر صراحة، فالأغلب أن هناك أمر صريح آخر يستدعيها، وفي تلك الحالة عليك الرجوع إلى وثائق تلك الأوامر حتى تعرف طريقة تغيير السلوك الافتراضي. قد تحتاج في الحزم التي تستخدم الأمر dh
لتعديل سلوك الأمرين dh_auto_configure
وdh_auto_build
(انظر صفحات الدليل الخاصة بهما لمعرفة طريقة عمل هذا).
debian/control
أيضاً اعتماداً على طبيعة التغييرات المحلية التي أجريتها على الحزمة، يحوي هذا الملف وصفاً للحزم المولّدة. على وجه الخصوص، يحوي هذا الملف سطور Build-Depends
تتحكم بقائمة الاعتماديات التي يجب تلبيتها عند بناء الحزمة. تشير هذه الاعتماديات غالباً إلى نسخ الحزم الموجودة في التوزيعة التي أتت منها الحزمة المصدرية، لكنها قد لا تكون متوفرة في التوزيعة المستخدمة للبناء. لا توجد طريقة مؤتمتة تبيّن هل الاعتمادية حقيقية أم أنها محددة فقط لضمان محاولة البناء باستخدام آخر نسخة من المكتبة — هذه هي الطريقة الوحيدة المتاحة لإجبار البانيات الآلية (autobuilder) على استخدام نسخة معينة من الحزمة أثناء البناء، لذلك يستخدم مشرفو دبيان في كثير من الأحيان اعتماديات لها أرقام محددة.
INSTALL
غالباً — على معرفة الاعتماديات المناسبة. في الحالة المثالية، يجب أن تتمكن من تلبية الاعتماديات ضمن التوزيعة المستخدمة للبناء؛ إذا لم تتمكن من ذلك، ستبدأ عملية تعاودية، حيث يجب نقل الحزم المذكورة في الحقل Build-Depends
خلفاً قبل أن تتمكن من نقل الحزمة المستهدفة. قد لا تحتاج بعض الحزم أن تنقلها خلفياً، ويمكن تثبيتها كما هي أثناء عملية البناء (إحدى الأمثلة البارزة هي debhelper). لاحظ أن عملية النقل الخلفي قد تتعقد سريعاً إذا لم تكن حذراً. لذلك، يجب تقليل المنقولات الخلفية إلى أقل ما يمكن.
.deb
). يدير الأمر dpkg-buildpackage
العملية كلها.
Build-Depends
، أو إذا لم تُثبَّت الحزم المناسبة. في هذه الحالات، يمكن تجاوز عملية التحقق عبر تمرير الخيار -d
إلى dpkg-buildpackage
. لكن تجاهل هذه الاعتماديات صراحة يعرضك لخطر إخفاق عملية البناء في مرحلة لاحقة. وأسوأ من ذلك، قد يبدو أن الحزمة تبنى بشكل صحيح لكنها لا تعمل بشكل سليم لاحقاً: فبعض البرامج تعطّل بعض مزاياها آلياً إذا لم تعثر على إحدى المكتبات المطلوبة أثناء البناء.
debuild
؛ الذي يستدعي dpkg-buildpackage
كالعادة لكنه يضيف أيضاً استدعاءً لبرنامج يجري عدة فحوصات للتحقق من اتفاق الحزم المولّدة مع سياسة دبيان. كما يُنظِّف هذا السكربت البيئة بحيث لا ”تُلوّث“ متغيرات البيئة المحلية عملية بناء الحزمة. الأمر debuild
هو أحد الأدوات من المجموعة devscripts، التي تتناسق مع بعضها وتشترك في بعض الإعدادات حتى تسهِّل مهمة مشرف الحزمة.