Product SiteDocumentation Site

15.2. بناء حزمتك الأولى

15.2.1. الحزم الفوقية أو الحزم الزائفة

تتشابه الحزم الزائفة (fake packages) مع الحزم الفوقية (meta-packages) من ناحية أن كلاً منها عبارة عن قواقع فارغة تستخدم فقط للاستفادة من تأثير بياناتها الفوقية على عملية معالجة الحزم.
The purpose of a fake package is to trick dpkg and apt into believing that some package is installed even though it's only an empty shell. This allows satisfying dependencies on a package when the corresponding software was installed outside the scope of the packaging system. Such a method works, but it should still be avoided whenever possible, since there is no guarantee that the manually installed software behaves exactly like the corresponding package would and other packages depending on it would not work properly.
من ناحية اخرى، تُمثّل الحزمة الفوقية مجموعة اعتماديات غالباً، حيث ينتج عن تثبيت الحزمة الفوقية تثبيت مجموعة من الحزم الأخرى بنقلة واحدة.
يمكن إنشاء هذين النوعين من الحزم باستخدام الأمرين equivs-control وequivs-build (من الحزمة equivs)، ينشئ الأمر equivs-control ملف ترويسة حزمة دبيان يجب تعديله حتى يحوي اسم الحزمة المنشأة، ورقم إصدارها، واسم مشرفها، واعتمادياتها، ووصفها. الحقول الأخرى التي لا تملك قيماً افتراضية ليست إلزامية ويمكن حذفها. الحقول Copyright وChangelog وReadme وExtra-Files ليست حقولاً معيارية في في حزم دبيان؛ لا معنى لهذه الحقول خارج نطاق equivs-build، وسوف تُحذَف من ترويسات الحزم المولّدة.

مثال 15.2. ملف ترويسة الحزمة الزائفة libxml-libxml-perl

Section: perl
Priority: optional
Standards-Version: 3.9.6

Package: libxml-libxml-perl
Version: 2.0116-1
Maintainer: Raphael Hertzog <hertzog@debian.org>
Depends: libxml2 (>= 2.7.4)
Architecture: all
Description: Fake package - module manually installed in site_perl
 This is a fake package to let the packaging system
 believe that this Debian package is installed. 
 .
 In fact, the package is not installed since a newer version
 of the module has been manually compiled & installed in the
 site_perl directory.
الخطوة التالية هي توليد حزمة دبيان باستخدام الأمر equivs-build file. تهانينا: أُنشِئَت الحزمة في المجلد الحالي ويمكن التعامل معها مثل أي حزمة دبيان أخرى.

15.2.2. أرشيف ملفات بسيط

The Falcot Corp administrators need to create a Debian package in order to ease deployment of a set of documents on a large number of machines. The administrator in charge of this task first reads the “New Maintainer's Guide”, then starts working on their first package.
الخطوة الأولى هي إنشاء مجلد بالاسم falcot-data-1.0 لتخزين الحزمة المصدرية. سوف تُسمّى الحزمة ‒منطقياً‒ falcot-data وستحمل رقم الإصدار 1.0. بعدها يضع مدير النظام المستندات في المجلد الفرعي data. ثم يستدعي الأمر dh_make (من الحزمة dh-make) لإضافة الملفات اللازمة لعملية توليد الحزمة، التي ستحفظ جميعاً في المجلد الفرعي debian:
$ cd falcot-data-1.0
$ dh_make --native

Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch?
 [s/i/m/l/k/n] i

Maintainer name : Raphael Hertzog
Email-Address   : hertzog@debian.org
Date            : Fri, 04 Sep 2015 12:09:39 -0400
Package Name    : falcot-data
Version         : 1.0
License         : gpl3
Type of Package : Independent
Hit <enter> to confirm:
Currently there is no top level Makefile. This may require additional tuning.
Done. Please edit the files in the debian/ subdirectory now. You should also
check that the falcot-data Makefiles install into $DESTDIR and not in / .
$
The selected type of package (indep binary) indicates that this source package will generate a single binary package that can be shared across all architectures (Architecture: all). single binary acts as a counterpart, and leads to a single binary package that is dependent on the target architecture (Architecture: any). In this case, the former choice is more relevant since the package only contains documents and no binary programs, so it can be used similarly on computers of all architectures.
The multiple binary type corresponds to a source package leading to several binary packages. A particular case, library, is useful for shared libraries, since they need to follow strict packaging rules. In a similar fashion, kernel module or kernel patch should be restricted to packages containing kernel modules.
أنشأ الأمر dh_make مجلداً فرعياً بالاسم debian يحوي ملفات عديدة. بعض هذه الملفات ضروري، خصوصاً rules وcontrol وchangelog وcopyright. أما الملفات ذات اللاحقة .ex فهي أمثلة يمكن استخدامها بعد تعديلها (وإزالة اللاحقة) إذا كانت تناسبك. أما إذا لم تكن بحاجة لها، فعليك إزالتها. لكن حافظ على الملف compat، لأنه يلزم لعمل مجموعة برامج debhelper (كلها تبدأ أسماؤها بالبادئة dh_) بشكل صحيح، التي تستخدم في المراحل المختلفة من عملية بناء الحزمة.
The copyright file must contain information about the authors of the documents included in the package, and the related license. In our case, these are internal documents and their use is restricted to within the Falcot Corp company. The default changelog file is generally appropriate; replacing the “Initial release” with a more verbose explanation and changing the distribution from unstable to internal is enough. The control file was also updated: the Section field has been changed to misc and the Homepage, Vcs-Git and Vcs-Browser fields were removed. The Depends fields was completed with iceweasel | www-browser so as to ensure the availability of a web browser able to display the documents in the package.

مثال 15.3. ملف control

Source: falcot-data
Section: misc
Priority: optional
Maintainer: Raphael Hertzog <hertzog@debian.org>
Build-Depends: debhelper (>= 9)
Standards-Version: 3.9.5

Package: falcot-data
Architecture: all
Depends: iceweasel | www-browser, ${misc:Depends}
Description: Internal Falcot Corp Documentation
 This package provides several documents describing the internal
 structure at Falcot Corp.  This includes:
  - organization diagram
  - contacts for each department.
 .
 These documents MUST NOT leave the company.
 Their use is INTERNAL ONLY.

مثال 15.4. ملف changelog

falcot-data (1.0) internal; urgency=low

  * Initial Release.
  * Let's start with few documents:
    - internal company structure;
    - contacts for each department.

 -- Raphael Hertzog <hertzog@debian.org>  Fri, 04 Sep 2015 12:09:39 -0400

مثال 15.5. ملف copyright

Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: falcot-data

Files: *
Copyright: 2004-2015 Falcot Corp
License: 
 All rights reserved.
يجوي الملف rules عادة مجموعة قواعد تستخدم لضبط وبناء وتثبيت البرنامج في مجلد فرعي مخصص (يسمى حسب اسم الحزمة الثنائية). بعدها تؤرشف محتويات هذا المجلد الفرعي في حزمة دبيان كما لو كانت جذر نظام الملفات. في حالتنا، سوف تثبت الملفات في المجلد الفرعي debian/falcot-data/usr/share/falcot-data/، حتى يؤدي تثبيت الحزمة المولّدة لنشر الملفات في /usr/share/falcot-data/. يستخدم الملف rules كملف Makefile فيه بضعة أهداف قياسية (منها clean الذي يستخدم لتنظيف المجلد المصدر، وbinary الذي يستخدم لتوليد الحزمة الثنائية).
رغم أن هذا الملف هو لبُّ العملية، إلا أنه لم يعد يحوي إلا القليل اللازم لاستدعاء مجموعة قياسية من الأوامر التي توفرها الأداة debhelper. وهذه هي حالة الملفات التي يولدها dh_make. لتثبيت ملفاتنا، علينا فقط ضبط سلوك الأمر dh_install عبر إنشاء ملف debian/falcot-data.install التالي:
data/* usr/share/falcot-data/
At this point, the package can be created. We will however add a lick of paint. Since the administrators want the documents to be easily accessed from the menus of graphical desktop environments, we add a falcot-data.desktop file and get it installed in /usr/share/applications by adding a second line to debian/falcot-data.install.

مثال 15.6. The falcot-data.desktop file

[Desktop Entry]
Name=Internal Falcot Corp Documentation
Comment=Starts a browser to read the documentation
Exec=x-www-browser /usr/share/falcot-data/index.html
Terminal=false
Type=Application
Categories=Documentation;
The updated debian/falcot-data.install looks like this:
data/* usr/share/falcot-data/
falcot-data.desktop usr/share/applications/
أصبحت حزمتنا المصدرية الآن جاهزة. لم يبقَ إلا توليد الحزمة الثنائية، باستخدام الطريقة نفسها التي استخدمناها سابقاً لإعادة بناء الحزم: نستدعي الأمر dpkg-buildpackage -us -uc من داخل المجلد falcot-data-1.0.