/[ddp]/manuals/trunk/maint-guide/maint-guide.en.dbk
ViewVC logotype

Contents of /manuals/trunk/maint-guide/maint-guide.en.dbk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8681 - (hide annotations) (download)
Sat Apr 16 07:31:48 2011 UTC (2 years, 1 month ago) by osamu
File size: 199026 byte(s)
Touch up 17 years of ...
1 osamu 8601 <?xml version="1.0" encoding="UTF-8"?>
2     <!-- -*- DocBook -*- -->
3     <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4     "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 osamu 8643 <!ENTITY % trans SYSTEM "po4a/maint-guide.en.ent"> %trans;
6 osamu 8601 <!ENTITY % common SYSTEM "common.ent"> %common;
7     <!ENTITY % version SYSTEM "version.ent"> %version;
8     ]>
9     <book lang="en">
10     <!-- This is UTF-8 encoded. -->
11 osamu 8646 <!--
12     This is reorganized to make this document robust for translation
13     when some externally referenced information changes.
14    
15     If you want to add extra contents to this document, please do so by
16     * adding tag like &othercredit; in English and provide it for each language.
17     * add extra content within msgstr but within <footnote>...</footnote>
18     Please note there will be content checker to match tags of msgid and msgstr.
19     The second rule is a way to get exception to this rule.
20    
21     Please try to correct something in translation. If you think contents needs fix,
22     Let's fix it in the root cause.
23    
24     Please understand to keep this document focused. Not everything you think important
25     for new maintainer should be written down. Something social needs to be elsewhere.
26     Some thing should be left to the practice. Something needs to be left for exercise
27     for people to check official documentations.
28     -->
29 osamu 8601 <title>Debian New Maintainers' Guide</title>
30     <bookinfo>
31     <authorgroup>
32 osamu 8673 <!-- do not use firstname and surname tags it braks Japanese. The same with othercredit -->
33     <author> <personname>Josip Rodin</personname> <email>joy-mg@debian.org</email> <contrib>original contents</contrib> </author>
34     <author> <personname>Osamu Aoki</personname> <email>osamu@debian.org</email> <contrib>updated contents</contrib> </author>
35 osamu 8643 <!-- translator credits in po4a/translator.*.ent -->
36     &othercredit;
37 osamu 8601 </authorgroup>
38     <releaseinfo>version &docversion;</releaseinfo>
39     <pubdate>&docisodate;</pubdate>
40     <copyright><year>1998-2002</year> <holder>Josip Rodin</holder></copyright>
41     <copyright><year>2005-2011</year> <holder>Osamu Aoki</holder></copyright>
42     <copyright><year>2010</year> <holder>Craig Small</holder></copyright>
43     <copyright><year>2010</year> <holder>Raphaël Hertzog</holder></copyright>
44     <legalnotice>
45     <para>
46     This document may be used under the terms the GNU General Public License
47     version 2 or higher.
48     </para>
49     <para>
50     This document was made using with these two documents as examples:
51     </para>
52 osamu 8650 <itemizedlist>
53     <listitem>
54 osamu 8601 <para>
55     Making a Debian Package (AKA the Debmake Manual), copyright © 1997 Jaldhar
56     Vyas.
57     </para>
58 osamu 8650 </listitem>
59     <listitem>
60 osamu 8601 <para>
61     The New-Maintainer's Debian Packaging Howto, copyright © 1997 Will Lowe.
62     </para>
63 osamu 8650 </listitem>
64     </itemizedlist>
65 osamu 8601 </legalnotice>
66     <!-- toc -->
67     </bookinfo>
68     <chapter id="start"><title>Getting started The Right Way</title>
69     <para>
70     This document tries to describe building of a Debian package to the common
71     Debian user, and the prospectus developer. It uses pretty common language, and
72     it's well covered with working examples. There is an old Roman saying,
73     <emphasis>Longum iter est per preaecepta, breve et efficax per
74     exempla!</emphasis> (It's a long way by the rules, but short and efficient with
75     examples!).
76     </para>
77     <para>
78 osamu 8636 This document has been updated for the Debian <literal>&base-release;</literal>
79     release.
80     <footnote><para> The document assumes you are using the
81     <literal>&base-release;</literal> system or newer. If you need to follow this
82 taffit-guest 8665 text in an older system (including an older Ubuntu system etc.), you must
83 osamu 8639 install backported <systemitem role="package">dpkg</systemitem> and
84     <systemitem role="package">debhelper</systemitem> packages, at least.
85     </para> </footnote>
86 osamu 8601 </para>
87     <para>
88     One of the things that makes Debian such a top-notch distribution is its
89     package system. While there is a vast quantity of software already in the
90     Debian format, sometimes you need to install software that isn't. You may be
91     wondering how you can make your own packages and perhaps you think it is a very
92     difficult task. Well, if you are a real novice on Linux, it is hard, but if
93     you were rookie, you wouldn't be reading this doc now. :-) You do need to know
94     a little about Unix programming but you certainly don't need to be a wizard.
95 osamu 8639 <footnote><para>
96     You can learn basic operations of the Debian system from
97     <ulink url="&debref;">Debian Reference</ulink>. It contains some pointers to
98     learn about Unix programming, too.
99     </para></footnote>
100 osamu 8601 </para>
101     <para>
102     One thing is certain, though: to properly create and maintain Debian packages
103     you need many hours. Make no mistake, for our system to work the maintainers
104     need to be both technically competent and diligent.
105     </para>
106     <para>
107     This document will explain every little (at first maybe irrelevant) step, and
108     help you create that first package, and to gain some experience in building
109     next releases of that and maybe other packages later on.
110     </para>
111     <para>
112 taffit-guest 8665 If you need some help on packaging, please read <xref linkend="helpme"/>.
113 osamu 8601 </para>
114     <para>
115 osamu 8636 Newer versions of this document should always be available online at
116     <ulink url="&maint-guide;"/> and in the
117     <systemitem role="package">maint-guide</systemitem> package.
118 osamu 8639 The translations may be available in packages such as
119     <systemitem role="package">maint-guide-es</systemitem>.
120 osamu 8655 Please note that this documentation may be slightly outdated.
121 osamu 8601 </para>
122 osamu 8654 <section id="socialdynamism"><title>Social dynamism of Debian</title>
123 osamu 8651 <para>
124 taffit-guest 8665 Here are my observations of the social dynamism of Debian. I hope this will prepare you for the interaction with Debian.
125 osamu 8651 </para>
126     <itemizedlist>
127     <listitem><para>We all are volunteers.</para>
128     <itemizedlist>
129     <listitem><para>You can not impose others what to do.</para></listitem>
130     <listitem><para>You should be motivated to do things by yourself.</para></listitem>
131     </itemizedlist></listitem>
132     <listitem><para>Friendly cooperation is the driving force.</para>
133     <itemizedlist>
134     <listitem><para>Your contribution should not overstrain others.</para></listitem>
135     <listitem><para>Your contribution is valuable only when others appreciate it.</para></listitem>
136     </itemizedlist></listitem>
137     <listitem><para>Debian is not your school where you get automatic attention of teachers.</para>
138     <itemizedlist>
139     <listitem><para>You should be able to learn many things by yourself.</para></listitem>
140     <listitem><para>Attention of other volunteers is the very scarce resource.</para></listitem>
141     </itemizedlist></listitem>
142     <listitem><para>Debian is constantly improving.</para>
143     <itemizedlist>
144 osamu 8655 <listitem><para>You are expected to make high quality packages.</para></listitem>
145     <listitem><para>You should adapt yourself to the change.</para></listitem>
146 osamu 8651 </itemizedlist></listitem>
147     </itemizedlist>
148     <para>
149     Since we focus only on technical aspects of packaging in this document,
150     please refer to the following to learn how Debian functions and how you can get involved.
151     </para>
152     <itemizedlist>
153 osamu 8681 <listitem><para><ulink url="&logiciellibre;">Debian: 17 years of Free Software, "do-ocracy", and democracy</ulink> (Introductory slides) </para> </listitem>
154 osamu 8656 <listitem><para><ulink url="&debianorghelp;">How can you help Debian?</ulink> (official) </para> </listitem>
155 taffit-guest 8665 <listitem><para><ulink url="&debianfaqhelp;">The Debian GNU/Linux FAQ, Chapter 13 - 'Contributing to the Debian Project'</ulink> (semi-official) </para> </listitem>
156 osamu 8656 <listitem><para><ulink url="&debianwikihelp;">Debian Wiki, HelpDebian</ulink> (supplemental) </para> </listitem>
157 osamu 8651 <listitem><para><ulink url="&nm-do;">Debian New Maintainer site</ulink> (official) </para> </listitem>
158     <listitem><para><ulink url="&debianmentorfaq;">Debian Mentors FAQ</ulink> (supplemental) </para> </listitem>
159     </itemizedlist>
160     </section>
161     <section id="debiandeveloper"><title>Official Debian Developer</title>
162     <para>
163     You can not become an official
164     <emphasis role="strong">Debian Developer</emphasis> (DD) over night because it
165     takes more than technical skill. Please do not be discouraged by this. If it
166     is useful to others, you can still upload your package either as a
167     <emphasis role="strong">maintainer</emphasis> through a
168     <emphasis role="strong">sponsor</emphasis> or as a
169     <emphasis role="strong">Debian Maintainer</emphasis>.
170     </para>
171     <para>
172     Please note that you do not need to create any new package to become an
173     official Debian Developer. Contributing to the existing packages can provide a
174     path to become an official Debian Developer too. There are many packages
175 taffit-guest 8665 waiting for good maintainers (see <xref linkend="choose"/>).
176 osamu 8651 </para>
177     </section>
178 osamu 8601 <section id="needprogs"><title>Programs you need for development</title>
179     <para>
180     Before you start anything, you should make sure that you have properly
181     installed some additional packages needed for development. Note that the list
182     doesn't contain any packages marked <literal>essential</literal> or
183     <literal>required</literal> - we expect that you have those installed already.
184     </para>
185     <para>
186     The following packages come with the standard Debian installation, so you
187     probably have them already (along with any additional packages they depend on).
188     Still, you should check it with <literal>aptitude show
189 osamu 8621 <replaceable>package</replaceable></literal>
190     or with <literal>dpkg -s <replaceable>package</replaceable></literal>.
191 osamu 8601 </para>
192     <para>
193     The most important package to install on your development system is the
194     <systemitem role="package">build-essential</systemitem> package. Once you try
195     to install it, it will <emphasis>pull in</emphasis> other packages required to
196     have a basic build environment.
197     </para>
198     <para>
199     For some types of packages, that is all you will require, however there is
200     another set of packages that while not essential for all package builds are
201     useful to have install or may be required by your package:
202     </para>
203     <itemizedlist>
204     <listitem>
205     <para>
206     <systemitem role="package">file</systemitem> - this handy program can determine
207     what type a file is. (see <citerefentry> <refentrytitle>file</refentrytitle>
208     <manvolnum>1</manvolnum> </citerefentry>)
209     </para>
210     </listitem>
211     <listitem>
212     <para>
213     <systemitem role="package">patch</systemitem> - this very useful utility will
214     take a file containing a difference listing (produced by the
215     <command>diff</command> program) and apply it to the original file, producing a
216     patched version. (see <citerefentry> <refentrytitle>patch</refentrytitle>
217     <manvolnum>1</manvolnum> </citerefentry>)
218     </para>
219     </listitem>
220     <listitem>
221     <para>
222     <systemitem role="package">perl</systemitem> - Perl is one of the most used
223     interpreted scripting languages on today's Unix-like systems, often referred to
224     as Unix's Swiss Army Chainsaw. (see <citerefentry>
225     <refentrytitle>perl</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>)
226     </para>
227     </listitem>
228     <listitem>
229     <para>
230     <systemitem role="package">python</systemitem> - Python is another of the most
231     used interpreted scripting languages on the Debian system that combines
232     remarkable power with very clear syntax. (see <citerefentry>
233     <refentrytitle>python</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>)
234     </para>
235     </listitem>
236     <listitem>
237     <para>
238     <systemitem role="package">autoconf</systemitem>, <systemitem role="package">automake</systemitem> and <systemitem role="package">autotools-dev</systemitem> - many newer programs use configure
239     scripts and <filename>Makefile</filename> files preprocessed with help of
240     programs like these. (see <literal>info autoconf</literal>, <literal>info
241     automake</literal>). The <systemitem role="package">autotools-dev</systemitem>
242     keeps up-to-date versions of certain auto files and has documentation about the
243     best way to use those files.
244     </para>
245     </listitem>
246     <listitem>
247     <para>
248     <systemitem role="package">dh-make</systemitem> and <systemitem role="package">debhelper</systemitem> - <systemitem role="package">dh-make</systemitem> is necessary to create the skeleton of our
249     example package, and it will use some of the <systemitem role="package">debhelper</systemitem> tools for creating packages. They are
250     not essential for creation of packages, but are <emphasis>highly</emphasis>
251     recommended for new maintainers. It makes the whole process very much easier
252     to start, and control afterwards. (see <citerefentry>
253     <refentrytitle>dh_make</refentrytitle> <manvolnum>1</manvolnum>
254     </citerefentry>, <citerefentry> <refentrytitle>debhelper</refentrytitle>
255 osamu 8639 <manvolnum>1</manvolnum> </citerefentry>) <footnote><para> There
256 osamu 8601 are few similar but specialized packages such as <systemitem role="package">dh-make-perl</systemitem>, <systemitem role="package">dh-make-php</systemitem>, etc. </para> </footnote>
257     </para>
258     </listitem>
259     <listitem>
260     <para>
261     <systemitem role="package">devscripts</systemitem> - this package contains some
262     nice and useful scripts that can be helpful to the maintainers, but they are
263     also not necessary for building packages. Packages recommended and suggested
264     by this package are worth looking into. (see
265 osamu 8639 <ulink url="&devscripts-readme;"/>.)
266 osamu 8601 </para>
267     </listitem>
268     <listitem>
269     <para>
270     <systemitem role="package">fakeroot</systemitem> - this utility lets you
271     emulate being root which is necessary for some parts of the build process.
272     (see <citerefentry> <refentrytitle>fakeroot</refentrytitle>
273     <manvolnum>1</manvolnum> </citerefentry>)
274     </para>
275     </listitem>
276     <listitem>
277     <para>
278     <systemitem role="package">gnupg</systemitem> - a tool that enables you to
279     digitally <emphasis>sign</emphasis> packages. This is especially important if
280     you want to distribute it to other people, and you will certainly be doing that
281     when your work gets included in the Debian distribution. (see <citerefentry>
282     <refentrytitle>gpg</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>)
283     </para>
284     </listitem>
285     <listitem>
286     <para>
287     <systemitem role="package">gfortran</systemitem> - the GNU Fortran 95 compiler,
288     necessary if your program is written in Fortran. (see <citerefentry>
289     <refentrytitle>gfortran</refentrytitle> <manvolnum>1</manvolnum>
290     </citerefentry>)
291     </para>
292     </listitem>
293     <listitem>
294     <para>
295     <systemitem role="package">gpc</systemitem> - the GNU Pascal compiler,
296     necessary if your program is written in Pascal. Worthy of note here is
297     <systemitem role="package">fp-compiler</systemitem>, the Free Pascal Compiler,
298     which is also good at this task. (see <citerefentry>
299     <refentrytitle>gpc</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>,
300     <citerefentry> <refentrytitle>ppc386</refentrytitle> <manvolnum>1</manvolnum>
301     </citerefentry>)
302     </para>
303     </listitem>
304     <listitem>
305     <para>
306     <systemitem role="package">xutils-dev</systemitem> - some programs, usually
307     those made for X11, also use these programs to generate
308     <filename>Makefile</filename> files from sets of macro functions. (see
309     <citerefentry> <refentrytitle>imake</refentrytitle> <manvolnum>1</manvolnum>
310     </citerefentry>, <citerefentry> <refentrytitle>xmkmf</refentrytitle>
311     <manvolnum>1</manvolnum> </citerefentry>)
312     </para>
313     </listitem>
314     <listitem>
315     <para>
316     <systemitem role="package">lintian</systemitem> - this is the Debian package
317     checker that can let you know of any common mistakes after you build the
318     package, and explains the errors found. (see <citerefentry>
319     <refentrytitle>lintian</refentrytitle> <manvolnum>1</manvolnum>
320     </citerefentry>,
321 osamu 8639 <ulink url="&lintian-doc;">Lintian User's Manual</ulink>)
322 osamu 8601 </para>
323     </listitem>
324     <listitem>
325     <para>
326     <systemitem role="package">pbuilder</systemitem> - this package contains
327     programs which are used for creating and maintaining <command>chroot</command>
328     environment. Building Debian package in this <command>chroot</command>
329     environment verifies the proper build dependency and avoid FTBFS (Fails To
330     Build From Source) bugs. (see <citerefentry>
331     <refentrytitle>pbuilder</refentrytitle> <manvolnum>8</manvolnum>
332     </citerefentry> and <citerefentry> <refentrytitle>pdebuild</refentrytitle>
333     <manvolnum>1</manvolnum> </citerefentry>)
334     </para>
335     </listitem>
336     <listitem>
337     <para>
338     <systemitem role="package">patchutils</systemitem> - this package contains some
339     utilities to work with patches such as the <command>lsdiff</command>,
340     <command>interdiff</command> and <command>filterdiff</command> commands.
341     </para>
342     </listitem>
343     <listitem>
344     <para>
345     <systemitem role="package">quilt</systemitem> - this package helps you to
346     manage a series of patches by keeping track of the changes each of them makes.
347     They are logically organized as a stack, and you can apply (=push), un-apply
348     (=pop), refresh them easily by traveling into the stack. (see <citerefentry>
349     <refentrytitle>quilt</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>,
350 osamu 8639 <ulink url="&quilt-pdf;">quilt.pdf</ulink>)
351 osamu 8601 </para>
352     </listitem>
353     <listitem>
354     <para>
355     <systemitem role="package">git</systemitem> - this package provides popular
356     version control system designed to handle very large projects with speed and
357     efficiency; it is used for many high profile open source projects, most notably
358     the Linux kernel. (see <citerefentry> <refentrytitle>git</refentrytitle>
359     <manvolnum>1</manvolnum> </citerefentry>,
360 osamu 8639 <ulink url="&git-doc;">git Manual</ulink>)
361 osamu 8601 </para>
362     </listitem>
363     </itemizedlist>
364 osamu 8651 <para>
365     The short descriptions that are given above only serve to introduce you to what
366     each package does. Before continuing please thoroughly read the documentation
367     of each program, at least, for the standard usage. It may seem like heavy
368     going now, but later on you'll be <emphasis>very</emphasis> glad you read it.
369     </para>
370     <para>
371     If you have specific questions later, I suggest you to read the documents
372     mentioned above again. Since this is a tutorial, I intentionally skipped
373     details and provided only pointers to keep it simple.
374     </para>
375 osamu 8646 </section>
376     <section id="needdocs"><title>Documentations you need for development</title>
377 osamu 8601 <para>
378     The following is the <emphasis>very important</emphasis> documentation which
379     you should read along with this document:
380     </para>
381     <itemizedlist>
382     <listitem>
383     <para>
384 osamu 8628 <systemitem role="package">debian-policy</systemitem> - the <ulink url="&debian-policy;">Debian Policy
385 osamu 8601 Manual</ulink> includes explanations of the structure and contents of the
386 osamu 8642 Debian archive, several OS design issues, the <ulink url="&fhs;">Filesystem Hierarchy Standard</ulink>
387     (FHS, which says where each file and directory should be) etc. For you, the most
388 osamu 8601 important thing is that it describes requirements that each package must
389 osamu 8642 satisfy to be included in the distribution (see the local copies of
390     <ulink url="&policy-pdf;">policy.pdf</ulink> and <ulink url="&fhs-pdf;">fhs-2.3.pdf</ulink>).
391 osamu 8601 </para>
392     </listitem>
393     <listitem>
394     <para>
395 osamu 8642 <systemitem role="package">developers-reference</systemitem>
396     - the <ulink url="&developers-reference;">Debian Developer's Reference</ulink>
397     describes all matters not specifically about the technical
398 osamu 8601 details of packaging, like the structure of the archive, how to rename, orphan,
399     pick up packages, how to do NMUs, how to manage bugs, best packaging practices,
400 osamu 8639 when and where to upload etc. (see the local copy of
401     <ulink url="&developers-refpdf;">developers-reference.pdf</ulink>).
402 osamu 8601 </para>
403     </listitem>
404     <listitem>
405     <para>
406 osamu 8628 <ulink url="&autotools-tutorial;">Autotools
407     Tutorial</ulink> provides very good tutorial for <ulink url="&gnu-build-system;">the GNU Build System known
408 osamu 8601 as the GNU Autotools</ulink> whose most important components are Autoconf,
409     Automake, Libtool, and gettext.
410     </para>
411     </listitem>
412     <listitem>
413     <para>
414     <systemitem role="package">gnu-standards</systemitem> - this package contains
415 osamu 8639 two pieces of documentation from the GNU project:
416     <ulink url="&gnu-standard;">GNU Coding Standards</ulink>, and
417     <ulink url="&gnu-maintainer;">Information for Maintainers of GNU Software</ulink>.
418     Although Debian does not require these to
419     be followed, these are still helpful as guidelines and common sense. (see the local copies of
420     <ulink url="&gnu-standard-pdf;">standards.pdf</ulink> and
421     <ulink url="&gnu-maintainer-pdf;">maintain.pdf</ulink>).
422 osamu 8601 </para>
423     </listitem>
424     </itemizedlist>
425     <para>
426 osamu 8642 If this document contradicts with any of the documents mentioned above, they
427     are correct. Please file a bug report on the
428     <systemitem role="package">maint-guide</systemitem> package using
429     <command>reportbug</command>.
430     </para>
431 osamu 8601 </section>
432     <section id="terminology"><title>Basic terminology</title>
433     <para>
434     There are two types of packages.
435     </para>
436     <itemizedlist>
437     <listitem>
438     <para>
439     <emphasis role="strong">source package</emphasis>: A source package is a set of
440     files which contain code and data which you can compile and process into
441     execution programs and formatted documents. It usually comes as a combination
442     of <filename>*.orig.tar.gz</filename>, <filename>*.debian.tar.gz</filename> (or
443     <filename>*.diff.gz</filename>), and <filename>*.dsc</filename>. Some other
444     archive and compression methods may be used, too.
445     </para>
446     </listitem>
447     <listitem>
448     <para>
449     <emphasis role="strong">binary package</emphasis>: A binary package contains
450     execution programs and formatted documents. It usually comes as
451     <filename>*.deb</filename> for the normal Debian system and as
452     <filename>*.udeb</filename> for the Debian Installer.
453     </para>
454     </listitem>
455     </itemizedlist>
456     <para>
457     Don't mix terms like source of the program and the source package of the
458     program!
459     </para>
460     <para>
461     There are several role names used around Debian.
462     </para>
463     <itemizedlist>
464     <listitem>
465     <para>
466     <emphasis role="strong">upstream author</emphasis>: The person who made the
467     original program.
468     </para>
469     </listitem>
470     <listitem>
471     <para>
472     <emphasis role="strong">upstream maintainer</emphasis>: The person who
473     currently maintains the program.
474     </para>
475     </listitem>
476     <listitem>
477     <para>
478     <emphasis role="strong">maintainer</emphasis>: The person who makes Debian
479     package of the program.
480     </para>
481     </listitem>
482     <listitem>
483     <para>
484     <emphasis role="strong">sponsor</emphasis>: The person who helps maintainers to
485     upload packages to the official Debian Package Archive after checking their
486     contents.
487     </para>
488     </listitem>
489     <listitem>
490     <para>
491     <emphasis role="strong">mentor</emphasis>: The person who helps novice
492     maintainers on packaging etc.
493     </para>
494     </listitem>
495     <listitem>
496     <para>
497     <emphasis role="strong">Debian Developer</emphasis> (DD): The person who is a
498     member of Debian. He has full upload right to the official Debian Package
499     Archive.
500     </para>
501     </listitem>
502     <listitem>
503     <para>
504     <emphasis role="strong">Debian Maintainer</emphasis> (DM): The person who has
505     limited upload right to the official Debian Package Archive.
506     </para>
507     </listitem>
508     </itemizedlist>
509     <para>
510 osamu 8648 There are several version names<footnote><para>See <ulink url="&policy-control;#s-f-Version">Debian Policy Manual: 5.6.12 Version</ulink>.</para></footnote> used around Debian.
511 osamu 8601 </para>
512     <itemizedlist>
513     <listitem>
514     <para>
515     <emphasis role="strong">upstream source version</emphasis>: The upstream source
516     version is referred as <literal><replaceable>version</replaceable></literal>.
517     </para>
518     </listitem>
519     <listitem>
520     <para>
521     <emphasis role="strong">Debian revision</emphasis>: The revision by Debian on
522     package is referred as <literal><replaceable>revision</replaceable></literal>.
523     </para>
524     </listitem>
525     <listitem>
526     <para>
527     <emphasis role="strong">Debian package version</emphasis>: The Debian package
528     version is referred as the following.
529     </para>
530     <itemizedlist>
531     <listitem>
532     <para>
533     <literal><replaceable>version</replaceable></literal> for the native Debian
534     binary package and for the Debian source package.
535     </para>
536     </listitem>
537     <listitem>
538     <para>
539     <literal><replaceable>version</replaceable>-<replaceable>revision</replaceable></literal>
540     for the non-native Debian binary package.
541     </para>
542     </listitem>
543     </itemizedlist>
544     </listitem>
545     </itemizedlist>
546     <para>
547     Please read the other manuals if you need more details on terminology.
548 osamu 8654 <footnote><para>See lists in <xref linkend="socialdynamism"/> and <xref linkend="needdocs"/>.</para></footnote>
549 osamu 8601 </para>
550     </section>
551     <section id="helpme"><title>Where to ask for help</title>
552     <para>
553 osamu 8621 Before you decide to ask your question in some public place, please read the fine documentation.
554 osamu 8601 </para>
555 osamu 8621 <itemizedlist>
556     <listitem>
557 osamu 8601 <para>
558 osamu 8628 files in <filename>/usr/share/doc/dpkg</filename>
559 osamu 8621 </para>
560     </listitem>
561     <listitem>
562     <para>
563 osamu 8628 files in <filename>/usr/share/doc/debian</filename>
564 osamu 8636 <!-- /usr/share/doc/debian is used be doc-debian and debian-faq -->
565 osamu 8621 </para>
566     </listitem>
567     <listitem>
568     <para>
569 osamu 8628 files in <filename>/usr/share/doc/autotools-dev</filename>
570 osamu 8621 </para>
571     </listitem>
572     <listitem>
573     <para>
574 taffit-guest 8665 files in <filename>/usr/share/doc/<replaceable>package</replaceable></filename> for all pertinent packages
575 osamu 8621 </para>
576     </listitem>
577     <listitem>
578     <para>
579 osamu 8642 contents of <literal><command>man</command> <replaceable>command</replaceable></literal> for all pertinent commands
580 osamu 8621 </para>
581     </listitem>
582     <listitem>
583     <para>
584 osamu 8642 contents of <literal><command>info</command> <replaceable>command</replaceable></literal> for all pertinent commands
585 osamu 8621 </para>
586     </listitem>
587     <listitem>
588     <para>
589 osamu 8636 contents of <ulink url="&debian-mentors-ldo;">debian-mentors@lists.debian.org mailing list archive</ulink>
590 osamu 8621 </para>
591     </listitem>
592 osamu 8636 <listitem>
593     <para>
594     contents of <ulink url="&debian-devel-ldo;">debian-devel@lists.debian.org mailing list archive</ulink>
595     </para>
596     </listitem>
597 osamu 8621 </itemizedlist>
598     <para>
599 osamu 8636 Please consider to use web search engine effectively by including search string
600 osamu 8642 such as <literal>site:lists.debian.org</literal> to limit the domain.
601 osamu 8636 </para>
602     <para>
603 osamu 8601 Making a small test package is good way to learn details of packaging.
604     Inspecting existing well maintained packages is the best way to learn how other
605     people make packages.
606     </para>
607     <para>
608     If you still have questions about packaging that you couldn't find answers to
609 osamu 8636 in the available documentation and web resources, you can ask them interactively.
610     </para>
611     <itemizedlist>
612     <listitem>
613     <para>
614     <ulink url="&debian-mentors-ldo;">debian-mentors@lists.debian.org mailing list</ulink>. (This mailing list is for the novice.)
615     </para>
616     </listitem>
617     <listitem>
618     <para>
619     <ulink url="&debian-devel-ldo;">debian-devel@lists.debian.org mailing list</ulink>. (This mailing list is for the expert.)
620     </para>
621     </listitem>
622     <listitem>
623     <para>
624     <ulink url="&irc-debian;">IRC</ulink> such as <literal>#debian-mentors</literal>.
625     </para>
626     </listitem>
627     </itemizedlist>
628     <para>
629 osamu 8652 The more experienced Debian developers will gladly help you, if you ask
630     properly after making your required efforts.
631 osamu 8601 </para>
632     <para>
633     When you receive a bug report (yes, actual bug reports!), you will know that it
634 osamu 8636 is time for you to dig into the
635     <ulink url="&bts;">Debian Bug Tracking System</ulink>
636     and read the documentation there, to be able to
637     deal with the reports efficiently. I highly recommend reading the
638     <ulink url="&devref-bug-handling;">Debian Developer's Reference, 5.8. 'Handling bugs'</ulink>.
639 osamu 8601 </para>
640     <para>
641     Even if it all worked well, it's time to start praying. Why? Because in just
642     a few hours (or days) users from all around the world will start to use your
643     package, and if you made some critical error you'll get mailbombed by numerous
644     angry Debian users... Just kidding. :-)
645     </para>
646     <para>
647     Relax and be ready for bug reports, because there is a lot more work to be done
648     before your package will be fully in line with Debian policies and its best
649     practice guidelines (once again, read the <emphasis>real
650     documentation</emphasis> for details). Good luck!
651     </para>
652     </section>
653     </chapter>
654     <chapter id="first"><title>First steps</title>
655     <para>
656     Let's try to make your own package (or, better even, adopt an existing one).
657     </para>
658     <section id="choose"><title>Choose your program</title>
659     <para>
660     You have probably chosen the package you want to create. The first thing you
661     need to do is check if the package is in the distribution archive already by
662 osamu 8636 using the following.
663 osamu 8601 </para>
664 osamu 8636 <itemizedlist>
665     <listitem>
666     <para>the <command>aptitude</command> command</para>
667     </listitem>
668     <listitem>
669     <para><ulink url="&packages-do;">Debian packages</ulink> web page</para>
670     </listitem>
671     <listitem>
672     <para><ulink url="&packages-qa-do;">Debian Package Tracking System</ulink> web page</para>
673     </listitem>
674     </itemizedlist>
675 osamu 8601 <para>
676     If the package already exists, well, install it! :-) If it happens to be
677     <emphasis role="strong">orphaned</emphasis> -- if its maintainer is set to
678 osamu 8636 <ulink url="&qa-do;">Debian QA Group</ulink>, you may be able to pick it up if
679     it's still available. You may also adopt a package for which the corresponding
680     maintainer has filed a Request for Adoption
681 osamu 8676 (<emphasis role="strong">RFA</emphasis>).<footnote> <para>See
682     <ulink url="&devref-adopt;">Debian Developer's Reference 5.9.5. 'Adopting a package'</ulink>.</para> </footnote>
683 osamu 8601 </para>
684     <para>
685 osamu 8648 There are several package ownership status resources.
686 osamu 8601 </para>
687     <itemizedlist>
688     <listitem>
689 osamu 8636 <para> <ulink url="&wnpp-do;">Work-Needing and Prospective Packages</ulink> </para>
690 osamu 8601 </listitem>
691     <listitem>
692 taffit-guest 8665 <para> <ulink url="&wnpp-bts;">Debian Bug report logs: Bugs in pseudo-package <systemitem role="package">wnpp</systemitem> in <literal>unstable</literal></ulink> </para>
693 osamu 8601 </listitem>
694     <listitem>
695 osamu 8636 <para> <ulink url="&wnpp-dn;">Debian Packages that Need Lovin'</ulink> </para>
696 osamu 8601 </listitem>
697 osamu 8636 <listitem>
698 taffit-guest 8665 <para> <ulink url="&wnpp-debtags;">Browse <systemitem role="package">wnpp</systemitem> bugs based on debtags</ulink> </para>
699 osamu 8636 </listitem>
700 osamu 8601 </itemizedlist>
701     <para>
702     As a side note, it's important to point out that Debian already has packages
703     for most kinds of programs, and the number of packages already in the Debian
704     archive is much larger than that of contributors with upload rights. Thus,
705     contributions to packages already in the archive are far more appreciated (and
706     more likely to receive sponsorship) by other developers <footnote><para> Having
707     said that, there will of course always be new programs that are worthwhile
708     packaging. </para> </footnote>. You can do that in various ways.
709     </para>
710     <itemizedlist>
711     <listitem>
712     <para>
713     taking over orphaned, yet actively used, packages
714     </para>
715     </listitem>
716     <listitem>
717     <para>
718 osamu 8628 joining <ulink url="&teams;">packaging teams</ulink>
719 osamu 8601 </para>
720     </listitem>
721     <listitem>
722     <para>
723     triaging bugs of very popular packages
724     </para>
725     </listitem>
726     <listitem>
727     <para>
728 osamu 8636 preparing <ulink url="&devref-nmu;">QA or NMU uploads</ulink>
729 osamu 8601 </para>
730     </listitem>
731     </itemizedlist>
732     <para>
733     If you are able to adopt the package, get the sources (with something like
734     <literal>apt-get source <replaceable>packagename</replaceable></literal>) and
735     examine them. This document unfortunately doesn't include comprehensive
736     information about adopting packages. Thankfully you shouldn't have a hard time
737     figuring out how the package works since someone has already done the initial
738     set up for you. Keep reading, though, a lot of the advice below will still be
739     applicable for your case.
740     </para>
741     <para>
742     If the package is new, and you decide you'd like to see it in Debian, proceed
743     as follows:
744     </para>
745     <itemizedlist>
746     <listitem>
747     <para>
748     First, you must know that program works, and have tried it for some time to
749     confirm its usefulness.
750     </para>
751     </listitem>
752     <listitem>
753     <para>
754 osamu 8636 You must check if no one else is working on the package already at the
755     <ulink url="&wnpp-do;">Work-Needing and Prospective Packages</ulink> site.
756     If no one else is working on it, file an ITP (Intent
757 osamu 8601 To Package) bug report to the <systemitem role="package">wnpp</systemitem>
758     pseudo-package using <command>reportbug</command>. If someone's already on it,
759     contact them if you feel you need to. If not - find another interesting
760     program that nobody maintains.
761     </para>
762     </listitem>
763     <listitem>
764     <para>
765     That program <emphasis role="strong">must have a license</emphasis>.
766     </para>
767     <itemizedlist>
768     <listitem>
769     <para>
770     For the <literal>main</literal> section, it <emphasis role="strong">must be
771 osamu 8636 compliant to all the Debian Free Software Guidelines</emphasis> (<ulink url="&dfsg;">DFSG</ulink>)
772 osamu 8601 and <emphasis role="strong">that program must not require a package outside of
773     <literal>main</literal></emphasis> for compilation or execution as required by
774     the Debian Policy. This is desired case.
775     </para>
776     </listitem>
777     <listitem>
778     <para>
779     For the <literal>contrib</literal> section, it must be compliant to all the
780     DFSG but it may require a package outside of <literal>main</literal> for
781     compilation or execution.
782     </para>
783     </listitem>
784     <listitem>
785     <para>
786     For the <literal>non-free</literal> section, it may not be compliant to some of
787     the DFSG but it <emphasis role="strong">must be distributable</emphasis>.
788     </para>
789     </listitem>
790     </itemizedlist>
791     <para>
792 osamu 8628 If you are unsure about where it should go, post the license text on <ulink url="&debian-legal-ldo;">debian-legal@lists.debian.org</ulink>
793 osamu 8601 and ask for advice.
794     </para>
795     </listitem>
796     <listitem>
797     <para>
798     That program certainly should <emphasis role="strong">not</emphasis> run setuid
799     root, or even better - it shouldn't need to be setuid or setgid to anything.
800     </para>
801     </listitem>
802     <listitem>
803     <para>
804     That program should not be a daemon, or something that goes in
805     <filename>*/sbin</filename> directories, or open a port as root.
806     </para>
807     </listitem>
808     <listitem>
809     <para>
810     That program should result in binary executable form, libraries are harder to
811     handle.
812     </para>
813     </listitem>
814     <listitem>
815     <para>
816     That program should be well documented and its code needs to be understandable
817     (i.e. not obfuscated).
818     </para>
819     </listitem>
820     <listitem>
821     <para>
822     You should contact program's author(s) to check if they agree with packaging it
823     and amicable to Debian. It is important to be able to consult with author(s)
824     about the program in case of any program specific problems, so don't try to
825     package unmaintained pieces of software.
826     </para>
827     </listitem>
828     </itemizedlist>
829     <para>
830     Of course, these things are just safety measures, and intended to save you from
831     raging users if you do something wrong in some setuid daemon... When you gain
832 osamu 8636 some more experience in packaging, you'll be able to package such packages.
833 osamu 8601 </para>
834     </section>
835     <section id="getit"><title>Get the program, and try it out</title>
836     <para>
837     So the first thing to do is to find and download the original source code. I
838     presume that you already have the source file that you picked up at the
839     author's homepage. Sources for free Unix programs usually come in
840     <command>tar</command>+<command>gzip</command> format with extension
841     <filename>.tar.gz</filename>, or
842     <command>tar</command>+<command>bzip2</command> format with extension
843     <filename>.tar.bz2</filename>. These usually contain the subdirectory called
844     <filename><replaceable>programname</replaceable>-<replaceable>version</replaceable></filename>
845     in them and all the sources under it.
846     </para>
847     <para>
848     If the latest version of such sources are available through VCS such as Git,
849     Subversion, or CVS repository, you need to get it with <literal>git
850 osamu 8621 clone</literal>, <literal>svn co</literal>, or <literal>cvs co</literal> and
851 osamu 8601 repack it into <command>tar</command>+<command>gzip</command> format by
852     yourself using the <literal>--exclude-vcs</literal> option.
853     </para>
854     <para>
855     If your program's source comes as some other sort of archive (for instance, the
856     filename ends in <filename>.Z</filename> or
857     <filename>.zip</filename><footnote><para> You can identify the archive format
858     using the <command>file</command> command when the file extension is not
859     enough. </para> </footnote>), unpack it with appropriate tools and repack it,
860     too.
861     </para>
862     <para>
863     As an example, I'll use a program called <command>gentoo</command>, an X GTK+
864 osamu 8648 file manager.
865     <footnote><para> This program is already packaged. Its
866     <ulink url="&gentoo-package;">current version</ulink> uses Autotools as its
867     build structure and is substantially different from the following examples
868     based on the version 0.9.12.</para>
869     </footnote>
870 osamu 8601 </para>
871     <para>
872     Create a subdirectory under your home directory named
873     <filename>debian</filename> or <filename>deb</filename> or anything you find
874     appropriate (e.g. just <filename>~/gentoo</filename> would do fine in this
875     case). Place the downloaded archive in it, and extract it (with <literal>tar
876     xzf gentoo-0.9.12.tar.gz</literal>). Make sure there are no errors, even some
877     <emphasis>irrelevant</emphasis> ones, because there will most probably be
878     problems unpacking on other people's systems, whose unpacking tools may or may
879     not ignore those anomalies. On your console screen, you should see the
880     following.
881     </para>
882     <screen>
883     $ mkdir ~/gentoo ; cd ~/gentoo
884     $ wget http://<replaceable>www.example.org</replaceable>/gentoo-0.9.12.tar.gz
885     $ tar xvzf gentoo-0.9.12.tar.gz
886     $ ls -F
887     gentoo-0.9.12/
888     gentoo-0.9.12.tar.gz
889     </screen>
890     <para>
891     Now you have another subdirectory, called <filename>gentoo-0.9.12</filename>.
892     Change to that directory and <emphasis>thoroughly</emphasis> read the provided
893     documentation. Usually there are files named <filename>README*</filename>,
894     <filename>INSTALL*</filename>, <filename>*.lsm</filename> or
895     <filename>*.html</filename>. You must find instructions on how to correctly
896     compile and install the program (most probably they'll assume you want to
897     install to <filename>/usr/local/bin</filename> directory; you won't be doing
898 taffit-guest 8665 that, but more on that later in <xref linkend="destdir"/>).
899 osamu 8601 </para>
900     <para>
901     Simple programs come with a <filename>Makefile</filename> file in them and can
902 osamu 8621 be compiled simply with <literal>make</literal>.<footnote><para>
903     Many modern programs come with a script <filename>configure</filename> which
904     creates a <filename>Makefile</filename> file customized for your system upon
905     its execution.</para></footnote> Some of them support
906 osamu 8601 <literal>make check</literal>, which runs included self-checks. Installation
907     to the destination directories is usually done with <literal>make
908     install</literal>.
909     </para>
910     <para>
911     Now try to compile and run your program, to make sure it works properly and
912     doesn't break something else while it's installing or running.
913     </para>
914     <para>
915     Also, you can usually run <literal>make clean</literal> (or better
916     <literal>make distclean</literal>) to clean up the build directory. Sometimes
917     there's even a <literal>make uninstall</literal> which can be used to remove
918     all the installed files.
919     </para>
920     </section>
921     <section id="portable"><title>Free portable programs</title>
922     <para>
923 osamu 8636 A lot of Free programs are written in the <ulink url="&c-program;">C</ulink> and
924     <ulink url="&cxx;">C++</ulink> languages. Many of
925 osamu 8601 these use Autotools or CMake to make them portable across different platforms.
926     These tools are used to generate <filename>Makefile</filename> and other
927     required source files. Then, such programs are built with usual <literal>make;
928     make install</literal>.
929     </para>
930     <para>
931 osamu 8628 <ulink url="&gnu-build-system;">Autotools</ulink>
932     are the GNU build system comprising <ulink url="&autoconf;">Autoconf</ulink>, <ulink url="&automake;">Automake</ulink>, <ulink url="&libtool;">Libtool</ulink>, and <ulink url="&gettext;">gettext</ulink>. You can notice
933 osamu 8601 such sources by the <filename>configure.ac</filename>,
934     <filename>Makefile.am</filename>, and <filename>Makefile.in</filename> files.
935 osamu 8628 <footnote><para> See <ulink url="&autotools-tutorial;">Autotools Tutorial</ulink>
936 osamu 8639 and <ulink url="&autotools-readme;"/>. </para> </footnote>
937 osamu 8601 </para>
938     <para>
939     The first step of Autotools work flow is usually that the upstream runs
940     <literal>autoreconf -i -f</literal> in the source and distributes this source
941     with generated files.
942     </para>
943     <screen>
944     configure.ac-----+-&gt; autoreconf -+-&gt; configure
945     Makefile.am -----+ | +-&gt; Makefile.in
946     src/Makefile.am -+ | +-&gt; src/Makefile.in
947     | +-&gt; config.h.in
948     automake
949     aclocal
950     aclocal.m4
951     autoheader
952     </screen>
953     <para>
954     Editing <filename>configure.ac</filename> and <filename>Makefile.am</filename>
955     files requires some knowledge of <command>autoconf</command> and
956     <command>automake</command>. See <literal>info autoconf</literal> and
957     <literal>info automake</literal>.
958     </para>
959     <para>
960     The second step of Autotools work flow is usually that the user obtains this
961     distributed source and runs <literal>./configure &amp;&amp; make</literal> in
962     the source to compile program into a
963     <command><replaceable>binary</replaceable></command>.
964     </para>
965     <screen>
966     Makefile.in -----+ +-&gt; Makefile -----+-&gt; make -&gt; <replaceable>binary</replaceable>
967     src/Makefile.in -+-&gt; ./configure -+-&gt; src/Makefile -+
968     config.h.in -----+ +-&gt; config.h -----+
969     |
970     config.status -+
971     config.guess --+
972     </screen>
973     <para>
974     You can change many things in the <filename>Makefile</filename> file such as
975     the default file install location using the command option, e.g.
976     <command>./configure --prefix=/usr</command>.
977     </para>
978     <para>
979     Although it is not required, updating the <filename>configure</filename> and
980     other files with <literal>autoreconf -i -f</literal> as the user may improve
981     the compatibility of the source.
982 osamu 8646 <footnote><para>You can automate this by using
983 taffit-guest 8665 <systemitem role="package">dh-autoreconf</systemitem> package.
984 osamu 8646 See <xref linkend="customrules"/>.</para></footnote>
985 osamu 8601 </para>
986     <para>
987 osamu 8636 <ulink url="&cmake;">CMake</ulink> is an alternative
988 osamu 8601 build system. You can notice such sources by the
989     <filename>CMakeLists.txt</filename> file.
990     </para>
991     </section>
992     <section id="namever"><title>Package name and version</title>
993     <para>
994     You should start packaging with a completely clean (pristine) source directory,
995     or simply with freshly unpacked sources.
996     </para>
997     <para>
998     For the package to be built correctly, you must make the program's original
999     name lowercase (if it isn't already), and you should move the source directory
1000     to
1001     <filename><replaceable>packagename</replaceable>-<replaceable>version</replaceable></filename>.
1002     </para>
1003     <para>
1004     If the program name consists of more than one word, contract them to one word,
1005     or make an abbreviation. For example, program John's little editor for X
1006     package would be named <systemitem role="package">johnledx</systemitem>, or
1007     <systemitem role="package">jle4x</systemitem>, or whatever you decide, as long
1008     as it's under some reasonable limit, e.g. 20 characters.
1009     </para>
1010     <para>
1011     Also check for the exact version of the program (to be included in the package
1012     version). If that piece of software is not numbered with versions like
1013     <literal>X.Y.Z</literal>, but with some kind of date, feel free to use that
1014     date as the version number, as long as newer version numbers will look larger.
1015     While it is best to use the same version number as what upstream uses, if it is
1016     in the format of <literal>09Oct23</literal> you may need to convert it to
1017     <literal>YYYYMMDD</literal> format, which would be <literal>20091023</literal>,
1018     to ensure proper order for upgrade with the <command>dpkg</command>
1019     program.<footnote><para> Version string can be compared by <literal>dpkg
1020     --compare-versions <replaceable>ver1</replaceable>
1021     <replaceable>op</replaceable> <replaceable>ver2</replaceable></literal>. See
1022     <citerefentry> <refentrytitle>dpkg</refentrytitle> <manvolnum>1</manvolnum>
1023     </citerefentry> manpage. </para> </footnote>
1024     </para>
1025     <para>
1026     Some programs won't be numbered at all, in which case you should contact the
1027     upstream maintainer to see if they've got some other revision-tracking method.
1028     </para>
1029     </section>
1030     <section id="dh-make"><title>Initial Debian package</title>
1031     <para>
1032     Let's set up the shell environment variable <literal>$DEBEMAIL</literal> and
1033     <literal>$DEBFULLNAME</literal> so many Debian maintenance tools recognize your
1034     name and email address to use for packages as follows.<footnote><para> The
1035     following text assumes you are using Bash as your login shell. If you use
1036     other login shells such as Z shell, use their pertinent configuration files
1037     instead of <filename>~/.bashrc</filename>. </para> </footnote>.
1038     </para>
1039     <screen>
1040     $ cat &gt;&gt;~/.bashrc &lt;&lt;EOF
1041     DEBEMAIL=your.email.address@example.org
1042     DEBFULLNAME=Firstname Lastname
1043     export DEBEMAIL DEBFULLNAME
1044     EOF
1045     </screen>
1046     <para>
1047     Let's make an initial Debian package by issuing the <command>dh_make</command>
1048     command as follows.
1049     </para>
1050     <screen>
1051     $ . ~/.bashrc
1052     $ cd ~/gentoo/gentoo-0.9.12
1053     $ dh_make -f ../gentoo-0.9.12.tar.gz
1054     </screen>
1055     <para>
1056     Of course, replace the filename with the name of your original source archive.
1057     <footnote><para> If the upstream source provides the
1058     <filename>debian</filename> directory and its contents, run the
1059     <command>dh_make</command> command with the <literal>--addmissing</literal>
1060     option, instead. The new source <literal>3.0 (quilt)</literal> format is quite
1061     robust not to break even for these packages. You may need to update contents
1062     provided by the upstream for your Debian package. </para> </footnote> See
1063     <citerefentry> <refentrytitle>dh_make</refentrytitle> <manvolnum>1</manvolnum>
1064     </citerefentry> for details.
1065     </para>
1066     <para>
1067     Some information will come up. It will ask you what sort of package you want
1068     to create. Gentoo is a single binary package - it creates only one binary, and
1069     thus one <filename>.deb</filename> file - so we will select the first option,
1070     with the <literal>s</literal> key, check the information on the screen and
1071     confirm by pressing <literal><replaceable>ENTER</replaceable></literal>.
1072     <footnote><para> There are few choices here: <literal>s</literal> for Single
1073     binary, <literal>i</literal> for Arch-Independent, <literal>m</literal> for
1074     Multiple binary, <literal>l</literal> for Library, <literal>k</literal> for
1075     Kernel module, <literal>n</literal> for Kernel patch and <literal>b</literal>
1076     for <systemitem role="package">cdbs</systemitem>. This document focuses on the
1077     use of the <systemitem role="package">debhelper</systemitem> package with the
1078     <command>dh</command> command. This document focuses on the use of the new
1079     <command>dh</command> command for Single binary and touches on it for
1080     Arch-Independent and Multiple binary. The <systemitem role="package">cdbs</systemitem> package offers alternative package script
1081     infrastructure to the <command>dh</command> command and outside of the scope of
1082     this document. </para> </footnote>
1083     </para>
1084     <para>
1085     After this execution of <command>dh_make</command>, a copy of the upstream
1086     tarball is created as <filename>gentoo_0.9.12.orig.tar.gz</filename> in the
1087     parent directory to accommodate the creation of the non-native Debian source
1088     package with the <filename>debian.tar.gz</filename> later.
1089     </para>
1090     <screen>
1091     $ cd ~/gentoo ; ls -F
1092     gentoo-0.9.12/
1093     gentoo-0.9.12.tar.gz
1094     gentoo_0.9.12.orig.tar.gz
1095     </screen>
1096     <para>
1097     Please note 2 key features in this
1098     <filename>gentoo_0.9.12.orig.tar.gz</filename> file name:
1099     </para>
1100     <itemizedlist>
1101     <listitem>
1102     <para>
1103     Package name and version are separated by the <literal>_</literal>
1104     (underscore).
1105     </para>
1106     </listitem>
1107     <listitem>
1108     <para>
1109     There is the <filename>.orig</filename> before the
1110     <filename>.tar.gz</filename>.
1111     </para>
1112     </listitem>
1113     </itemizedlist>
1114     <para>
1115     You should also notice that many template files are created in the source under
1116 taffit-guest 8665 the <filename>debian</filename> directory. These will be explained in <xref linkend="dreq"/> and <xref linkend="dother"/>. You should also understand
1117 osamu 8601 that the packaging is not automatic process. You need to modify the upstream
1118 taffit-guest 8665 source for Debian as <xref linkend="modify"/>. After all these, you need to
1119     build Debian packages under the proper method as <xref linkend="build"/>,
1120     check them as <xref linkend="checkit"/>, and upload them as <xref linkend="upload"/>. I will explain all these steps.
1121 osamu 8601 </para>
1122     <para>
1123     Once again, as a new maintainer you are discouraged from creating complicated
1124     packages, e.g.,
1125     </para>
1126     <itemizedlist>
1127     <listitem>
1128     <para>
1129     multiple binary packages,
1130     </para>
1131     </listitem>
1132     <listitem>
1133     <para>
1134     library packages,
1135     </para>
1136     </listitem>
1137     <listitem>
1138     <para>
1139     kernel module packages,
1140     </para>
1141     </listitem>
1142     <listitem>
1143     <para>
1144     kernel patch packages,
1145     </para>
1146     </listitem>
1147     <listitem>
1148     <para>
1149     the source file format being neither in <filename>tar.gz</filename> nor
1150     <filename>tar.bz2</filename>, or
1151     </para>
1152     </listitem>
1153     <listitem>
1154     <para>
1155     the source tarball containing undistributable contents.
1156     </para>
1157     </listitem>
1158     </itemizedlist>
1159     <para>
1160     It's not too hard, but it does require a bit more knowledge, so we won't
1161     describe all of it here.
1162     </para>
1163     <para>
1164     If you accidentally erased some template files while working on them, you can
1165     recover them by running <command>dh_make</command> with the
1166     <literal>--addmissing</literal> option again in a Debian package source tree.
1167     </para>
1168     <para>
1169     Updating an existing package may get complicated since it may be using older
1170     techniques. Please stick with fresh packaging cases for now to learn basics.
1171 taffit-guest 8665 I will come back to explain it later in <xref linkend="update"/>.
1172 osamu 8601 </para>
1173     </section>
1174     </chapter>
1175     <chapter id="modify"><title>Modifying the source</title>
1176     <para>
1177     Please note that there isn't space here to go into <emphasis>all</emphasis> the
1178     details of fixing upstream sources, but here are some basic steps and problems
1179     people often run across.
1180     </para>
1181     <section id="quiltrc"><title>Set up <command>quilt</command></title>
1182     <para>
1183     The <command>quilt</command> program offers the basic method to record
1184     modification to the source for the Debian packaging. Since slightly different
1185 osamu 8646 default is desirable, let's create an alias <command>dquilt</command> for
1186 osamu 8648 Debian packaging by adding the following line to <filename>~/.bashrc</filename>.
1187 osamu 8601 </para>
1188     <screen>
1189 osamu 8646 alias dquilt=quilt --quiltrc=~/.quiltrc-dpkg
1190     </screen>
1191     <para>
1192     Then let's create <filename>~/.quiltrc-dpkg</filename> as follows.
1193     </para>
1194     <screen>
1195 osamu 8601 d=. ; while [ ! -d $d/debian -a `readlink -e $d` != / ]; do d=$d/..; done
1196     if [ -d $d/debian ] &amp;&amp; [ -z $QUILT_PATCHES ]; then
1197     # Debian packaging case and unset $QUILT_PATCHES
1198 osamu 8649 QUILT_PATCHES="debian/patches"
1199     QUILT_PATCH_OPTS="--reject-format=unified"
1200     QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto"
1201     QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
1202     QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33"
1203 osamu 8601 if ! [ -d $d/debian/patches ]; then mkdir $d/debian/patches; fi
1204     fi
1205     </screen>
1206     <para>
1207     See <citerefentry> <refentrytitle>quilt</refentrytitle>
1208     <manvolnum>1</manvolnum> </citerefentry> and
1209 osamu 8639 <ulink url="&quilt-pdf;">quilt.pdf</ulink> for how to use
1210 osamu 8601 <command>quilt</command>.
1211     </para>
1212     </section>
1213     <section id="fixupstream"><title>Fixing upstream bug</title>
1214     <para>
1215     Let's assume you find an error in the upstream <filename>Makefile</filename>
1216     file as follows where <literal>install: gentoo</literal> should have been
1217     <literal>install: gentoo-target</literal>.
1218     </para>
1219     <screen>
1220     install: gentoo
1221     install ./gentoo $(BIN)
1222     install icons/* $(ICONS)
1223     install gentoorc-example $(HOME)/.gentoorc
1224     </screen>
1225     <para>
1226 osamu 8646 Let's fix this and record this with the <command>dquilt</command> command as
1227 osamu 8601 <filename>fix-gentoo-target.patch</filename>. <footnote><para> The
1228     <filename>debian/patches</filename> directory should exist now if you run
1229     <command>dh_make</command> as described before. This example operation creates
1230     it just in case you are updating the existing package. </para> </footnote>
1231     </para>
1232     <screen>
1233     $ mkdir debian/patches
1234 osamu 8646 $ dquilt new fix-gentoo-target.patch
1235     $ dquilt add Makefile
1236 osamu 8601 </screen>
1237     <para>
1238     You change the <filename>Makefile</filename> file as follows.
1239     </para>
1240     <screen>
1241     install: gentoo-target
1242     install ./gentoo $(BIN)
1243     install icons/* $(ICONS)
1244     install gentoorc-example $(HOME)/.gentoorc
1245     </screen>
1246     <para>
1247 osamu 8646 Ask <command>dquilt</command> to refresh the patch to create
1248 osamu 8601 <filename>debian/patches/fix-gentoo-target.patch</filename> and add its
1249 osamu 8621 description following <ulink url="&dep3;">DEP-3: Patch Tagging Guidelines</ulink>.
1250 osamu 8601 </para>
1251     <screen>
1252 osamu 8646 $ dquilt refresh
1253     $ dquilt header -e
1254 osamu 8601 ... describe patch
1255     </screen>
1256     </section>
1257 osamu 8621
1258 osamu 8601 <section id="destdir"><title>Installation of files to the destination</title>
1259     <para>
1260     Normally, programs install themselves in the <filename>/usr/local</filename>
1261     subdirectory. Since it is reserved for system administrator's (or user's)
1262     private use, Debian packages must not use that directory but should use system
1263     directories such as the <filename>/usr/bin</filename> subdirectory following
1264 osamu 8642 the <ulink url="&fhs;">Filesystem Hierarchy Standard</ulink> (FHS).
1265 osamu 8601 </para>
1266     <para>
1267     Normally, <citerefentry> <refentrytitle>make</refentrytitle>
1268     <manvolnum>1</manvolnum> </citerefentry> is used to automate building the
1269     program and the execution of <literal>make install</literal> installs programs
1270     directly to the desired destination by the <literal>install</literal> target of
1271     the <filename>Makefile</filename> file. In order for Debian to provide binary
1272     packages, the build system installs programs to the file tree image created
1273     under a temporary directory instead to the actual destination.
1274     </para>
1275     <para>
1276     These 2 differences between (1) the normal program installation and (2) the
1277     Debian packaging can be transparently addressed by the <systemitem role="package">debhelper</systemitem> package through the
1278     <command>dh_auto_configure</command> and <command>dh_auto_install</command>
1279     commands if the following conditions are met.
1280     </para>
1281     <itemizedlist>
1282     <listitem>
1283     <para>
1284     The <filename>Makefile</filename> file follows the GNU conventions to support
1285 osamu 8621 <literal>$(DESTDIR)</literal> variable.
1286 osamu 8628 <footnote><para> See <ulink url="&gnu-destdir;">GNU Coding Standards: 7.2.4 DESTDIR: Support for Staged Installs</ulink>.</para></footnote>
1287 osamu 8601 </para>
1288     </listitem>
1289     <listitem>
1290     <para>
1291     The source follows the Filesystem Hierarchy Standard (FHS).
1292     </para>
1293     </listitem>
1294     </itemizedlist>
1295     <para>
1296     Programs that use GNU <command>autoconf</command>
1297     <emphasis>automatically</emphasis> follow the GNU conventions and their
1298     packaging is almost <emphasis>automatic</emphasis>. With this and other
1299     heuristics, the <systemitem role="package">debhelper</systemitem> package
1300     estimates that it works for about 90% of packages without making any intrusive
1301     changes to their build system. So the packaging is not as complicated as it
1302     may seem.
1303     </para>
1304     <para>
1305     If you need to make changes in the <filename>Makefile</filename> file, you
1306     should make sure to support these <literal>$(DESTDIR)</literal> variable. The
1307     <literal>$(DESTDIR)</literal> variable is unset in it and is prepended to each
1308     file path used for the program installation. The packaging script will set
1309     <literal>$(DESTDIR)</literal> to the temporary directory.
1310     </para>
1311     <para>
1312     The temporary directory used by the <command>dh_auto_install</command> command
1313     is chosen as <filename>debian/<replaceable>package</replaceable></filename> for
1314     single binary packages. <footnote><para> For multiple binary packages, the
1315     <command>dh_auto_install</command> command uses <filename>debian/tmp</filename>
1316     as the temporary directory while the <command>dh_install</command> command with
1317     the help of
1318     <filename>debian/<replaceable>package-1</replaceable>.install</filename> and
1319     <filename>debian/<replaceable>package-2</replaceable>.install</filename> files
1320     will split contents of <filename>debian/tmp</filename> into
1321     <filename>debian/<replaceable>package-1</replaceable></filename> and
1322     <filename>debian/<replaceable>package-2</replaceable></filename> temporary
1323     directories to create multiple binary <filename>*.deb</filename> packages.
1324     </para> </footnote> Everything that is contained in the temporary directory
1325     will be installed on a user's system when they install your package, the only
1326     difference is that <command>dpkg</command> will be installing the files in the
1327     root directory.
1328     </para>
1329     <para>
1330     Bear in mind that even though your program installs in
1331     <filename>debian/<replaceable>package</replaceable></filename>, it still needs
1332     to behave correctly when placed in the root directory, i.e. when installed
1333     from the <filename>.deb</filename> package. So you must not allow the build
1334     system to hardcode strings like
1335     <literal>/home/me/deb/<replaceable>package</replaceable>-<replaceable>version</replaceable>/usr/share/<replaceable>package</replaceable></literal>
1336     into the package file.
1337     </para>
1338     <para>
1339     Here's the relevant part of <systemitem role="package">gentoo</systemitem>'s
1340     <filename>Makefile</filename> file <footnote><para> This is just an example to
1341     show how the <filename>Makefile</filename> file should look like. If the
1342     <filename>Makefile</filename> file is created by the
1343     <command>./configure</command> command, the correct way to fix this kind of
1344     <filename>Makefile</filename> is to executed the <command>./configure</command>
1345     command from the <command>dh_auto_configure</command> command with default
1346     options including <literal>--prefix=/usr</literal>. </para> </footnote>:
1347     </para>
1348     <screen>
1349     # Where to put binary on 'make install'?
1350     BIN = /usr/local/bin
1351     # Where to put icons on 'make install'?
1352     ICONS = /usr/local/share/gentoo
1353     </screen>
1354     <para>
1355     We see that the files are set to install under <filename>/usr/local</filename>.
1356     Change those paths to:
1357     </para>
1358     <screen>
1359     # Where to put binary on 'make install'?
1360     BIN = $(DESTDIR)/usr/bin
1361     # Where to put icons on 'make install'?
1362     ICONS = $(DESTDIR)/usr/share/gentoo
1363     </screen>
1364     <para>
1365     But why in that directory, and not some other? Because Debian packages never
1366     install files beneath <filename>/usr/local</filename> -- that tree is reserved
1367     for the system administrator's use. Such files on Debian systems go under
1368     <filename>/usr</filename> instead.
1369     </para>
1370     <para>
1371     The more exact locations for binaries, icons, documentation etc. are specified
1372 osamu 8642 in the Filesystem Hierarchy Standard (FHS). I recommend you
1373 osamu 8601 browse it and read the sections that might concern your package.
1374     </para>
1375     <para>
1376     So, we should install the binary in <filename>/usr/bin</filename> instead of
1377     <filename>/usr/local/bin</filename>, the manual page in
1378     <filename>/usr/share/man/man1</filename> instead of
1379     <filename>/usr/local/man/man1</filename> etc. Notice how there's no manual
1380     page mentioned in <systemitem role="package">gentoo</systemitem>'s
1381     <filename>Makefile</filename>, but since the Debian Policy requires that every
1382     program has one, we'll make one later and install it in
1383     <filename>/usr/share/man/man1</filename>.
1384     </para>
1385     <para>
1386     Some programs don't use <filename>Makefile</filename> variables to define paths
1387     such as these. This means you might have to edit some real C sources in order
1388     to fix them to use the right locations. But where to search, and exactly what
1389     for? You can find this out by issuing:
1390     </para>
1391     <screen>
1392     $ grep -nr -e 'usr/local/lib' --include='*.[c|h]' .
1393     </screen>
1394     <para>
1395     <command>grep</command> will run recursively through the source tree and tell
1396     you the filename and the line number for all matches.
1397     </para>
1398     <para>
1399     Edit those files and in those lines replace <literal>usr/local/lib</literal>
1400 osamu 8621 with <literal>usr/lib</literal>. This can be done automatically as follows:
1401 osamu 8601 </para>
1402     <screen>
1403     $ vim '+argdo %s/usr\/local\/lib/usr\/lib/gce|update' +q \
1404     $(find . -type f -name '*.[c|h]')
1405     </screen>
1406     <para>
1407     Be careful that you don't mess up the rest of the code! :-)
1408     </para>
1409     <para>
1410     After that you should find the install target (search for line that starts with
1411     <literal>install:</literal>, that will usually work) and rename all references
1412     to directories other than ones defined at the top of the
1413     <filename>Makefile</filename>.
1414     </para>
1415     <para>
1416 osamu 8621 Before your upstream bug fix, <systemitem role="package">gentoo</systemitem>'s
1417 osamu 8601 install target said:
1418     </para>
1419     <screen>
1420     install: gentoo-target
1421     install ./gentoo $(BIN)
1422     install icons/* $(ICONS)
1423     install gentoorc-example $(HOME)/.gentoorc
1424     </screen>
1425     <para>
1426 osamu 8646 Let's fix this and record this with the <command>dquilt</command> command as
1427 osamu 8601 <filename>debian/patches/install.patch</filename>.
1428     </para>
1429     <screen>
1430 osamu 8646 $ dquilt new install.patch
1431     $ dquilt add Makefile
1432 osamu 8601 </screen>
1433     <para>
1434     Let's change this for Debian package as following using the editor:
1435     </para>
1436     <screen>
1437     install: gentoo-target
1438     install -d $(BIN) $(ICONS) $(DESTDIR)/etc
1439     install ./gentoo $(BIN)
1440     install -m644 icons/* $(ICONS)
1441     install -m644 gentoorc-example $(DESTDIR)/etc/gentoorc
1442     </screen>
1443     <para>
1444     You've surely noticed that there's now a <literal>install -d</literal> command
1445     before the other commands in the rule. The original
1446     <filename>Makefile</filename> didn't have it because usually the
1447     <literal>/usr/local/bin</literal> and other directories already exist on the
1448     system where one runs <literal>make install</literal>. However, since we will
1449     install into our own empty (or even nonexistent) directory, we will have to
1450     create each and every one of those directories.
1451     </para>
1452     <para>
1453     We can also add in other things at the end of the rule, like the installation
1454     of additional documentation that the upstream authors sometimes omit:
1455     </para>
1456     <screen>
1457     install -d $(DESTDIR)/usr/share/doc/gentoo/html
1458     cp -a docs/* $(DESTDIR)/usr/share/doc/gentoo/html
1459     </screen>
1460     <para>
1461 osamu 8646 After careful check, if everything is fine, ask <command>dquilt</command> to
1462 osamu 8601 refresh the patch to create <filename>debian/patches/install.patch</filename>
1463     and add its description.
1464     </para>
1465     <screen>
1466 osamu 8646 $ dquilt refresh
1467     $ dquilt header -e
1468 osamu 8601 ... describe patch
1469     </screen>
1470     <para>
1471     Now you have a series of patches.
1472     </para>
1473     <orderedlist numeration="arabic">
1474     <listitem>
1475     <para>
1476     Upstream bug fix: <filename>debian/patches/fix-gentoo-target.patch</filename>
1477     </para>
1478     </listitem>
1479     <listitem>
1480     <para>
1481     Debian specific packaging modification:
1482     <filename>debian/patches/install.patch</filename>
1483     </para>
1484     </listitem>
1485     </orderedlist>
1486     <para>
1487     Whenever you make changes that are not specifically related to Debian package
1488     such as <filename>debian/patches/fix-gentoo-target.patch</filename>, be sure to
1489     send them to the upstream maintainer so they can be included in the next
1490     program revision and be useful to everyone else. Also remember to make your
1491     fixes not specific to Debian or Linux (or even Unix!) prior to sending them --
1492     make them portable. This will make your fixes much easier to apply.
1493     </para>
1494     <para>
1495     Note that you don't have to send the <filename>debian/*</filename> files
1496     upstream.
1497     </para>
1498     </section>
1499     <section id="difflibs"><title>Differing libraries</title>
1500     <para>
1501     There is one other common problem: libraries are often different from platform
1502     to platform. For example, a <filename>Makefile</filename> can contain a
1503     reference to a library which doesn't exist on Debian systems. In that case, we
1504     need to change it to a library which does exist in Debian, and serves the same
1505     purpose.
1506     </para>
1507     <para>
1508     So, if there is a line in your program's <filename>Makefile</filename> (or
1509     <filename>Makefile.in</filename>) that says something like this (and your
1510     program doesn't compile) <footnote><para> The author realizes that this is not
1511     the best example considering our <systemitem role="package">libncurses</systemitem> package now ships with a
1512     <filename>libcurses.so</filename> symlink, but he couldn't think of a better
1513     one. Suggestions very welcome :-) </para> </footnote>:
1514     </para>
1515     <screen>
1516     LIBS = -lcurses -lsomething -lsomethingelse
1517     </screen>
1518     <para>
1519     Let's fix this as <filename>debian/patches/ncurse.patch</filename> by changing
1520     <literal>curses</literal> into <literal>ncurses</literal>.
1521     </para>
1522     <screen>
1523 osamu 8646 $ dquilt new ncurse.patch
1524     $ dquilt add Makefile
1525 osamu 8601 $ sed -i -e s/-lcurses/-lncurses/g Makefile
1526 osamu 8646 $ dquilt refresh
1527     $ dquilt header -e
1528 osamu 8601 ... describe patch
1529     </screen>
1530     </section>
1531     </chapter>
1532     <chapter id="dreq"><title>Required files under the <filename>debian</filename> directory</title>
1533     <para>
1534     There is a new subdirectory under the program's source directory, it's called
1535     <filename>debian</filename>. There are a number of files in this directory
1536     that we should edit in order to customize the behavior of the package. The
1537     most important of them are <filename>control</filename>,
1538     <filename>changelog</filename>, <filename>copyright</filename> and
1539     <filename>rules</filename>, which are required for all packages.
1540 osamu 8668 <footnote><para>
1541     In this chapter, files in the <filename>debian</filename> directory are
1542     referred without preceding <filename>debian/</filename> for simplicity whenever
1543     they are obvious.
1544     </para></footnote>
1545 osamu 8601 </para>
1546     <section id="control"><title><filename>control</filename> file</title>
1547     <para>
1548     This file contains various values which <command>dpkg</command>,
1549     <command>dselect</command>, <command>apt-get</command>,
1550     <command>apt-cache</command>, <command>aptitude</command>, and other package
1551 osamu 8628 management tools will use to manage the package. It is defined by the <ulink url="&policy-control;">Debian
1552 osamu 8601 Policy Manual, 5 'Control files and their fields'</ulink>.
1553     </para>
1554     <para>
1555     Here is the <filename>control</filename> file <command>dh_make</command>
1556     created for us:
1557     </para>
1558     <screen>
1559     1 Source: gentoo
1560     2 Section: unknown
1561     3 Priority: extra
1562     4 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
1563     5 Build-Depends: debhelper (&gt;= 7.0.50~)
1564     6 Standards-Version: 3.8.4
1565     7 Homepage: &lt;insert the upstream URL, if relevant&gt;
1566     8
1567     9 Package: gentoo
1568     10 Architecture: any
1569     11 Depends: ${shlibs:Depends}, ${misc:Depends}
1570     12 Description: &lt;insert up to 60 chars description&gt;
1571     13 &lt;insert long description, indented with spaces&gt;
1572     </screen>
1573     <para>
1574     (I've added the line numbers.)
1575     </para>
1576     <para>
1577 osamu 8621 Lines 1-7 are the control information for the source package.
1578     Lines 9-13 are the control information for the binary package.
1579 osamu 8601 </para>
1580     <para>
1581     Line 1 is the name of the source package.
1582     </para>
1583     <para>
1584     Line 2 is the section of the distribution the source package goes into.
1585     </para>
1586     <para>
1587     As you may have noticed, Debian archive is divided in sections:
1588     <literal>main</literal> (the free software), <literal>non-free</literal> (the
1589     not really free software) and <literal>contrib</literal> (free software that
1590     depends on non-free software). Under those, there are logical subsections that
1591     describe in short what packages are in. So we have <literal>admin</literal>
1592     for administrator-only programs, <literal>base</literal> for the basic tools,
1593     <literal>devel</literal> for programmer tools, <literal>doc</literal> for
1594     documentation, <literal>libs</literal> for libraries, <literal>mail</literal>
1595     for e-mail readers and daemons, <literal>net</literal> for network apps and
1596     daemons, <literal>x11</literal> for X11 programs that don't fit anywhere else,
1597 osamu 8648 and many more.
1598     <footnote> <para>See
1599     <ulink url="&policy-subsections;">Debian Policy Manual, 2.4 'Sections'</ulink> and
1600 taffit-guest 8665 <ulink url="&sections-unstable;">List of sections in <literal>sid</literal></ulink>.</para>
1601 osamu 8648 </footnote>
1602 osamu 8601 </para>
1603     <para>
1604     Let's change it then to x11. (A <literal>main/</literal> prefix is implied so
1605     we can omit it.)
1606     </para>
1607     <para>
1608 osamu 8648 Line 3 describes how important it is that the user installs this package.
1609     <footnote> <para>See
1610     <ulink url="&policy-priorities;">Debian Policy Manual, 2.5 'Priorities'</ulink>.
1611 osamu 8601 </para>
1612 osamu 8648 </footnote>
1613     </para>
1614 osamu 8601 <itemizedlist>
1615     <listitem>
1616     <para>
1617     The <literal>optional</literal> priority will usually work for new packages
1618     that do not conflict with others with <literal>required</literal>,
1619     <literal>important</literal> or <literal>standard</literal> priorities.
1620     </para>
1621     </listitem>
1622     <listitem>
1623     <para>
1624     The <literal>extra</literal> priority will usually work for new packages that
1625     conflict with others with non-<literal>extra</literal> priorities.
1626     </para>
1627     </listitem>
1628     </itemizedlist>
1629     <para>
1630     Section and priority are used by the frontends like <command>aptitude</command>
1631     when they sort packages and select defaults. Once you upload the package to
1632     Debian, the value of these two fields can be overridden by the archive
1633     maintainers, in which case you will be notified by email.
1634     </para>
1635     <para>
1636     As this is a normal priority package and doesn't conflict with anything else,
1637     we will change the priority to <literal>optional</literal>.
1638     </para>
1639     <para>
1640     Line 4 is the name and email address of the maintainer. Make sure that this
1641     field includes a valid <literal>To</literal> header for an email, because after
1642     you upload it, the bug tracking system will use it to deliver bug emails to
1643     you. Avoid using commas, ampersands and parenthesis.
1644     </para>
1645     <para>
1646     The 5th line includes the list of packages required to build your package as
1647     the <literal>Build-Depends</literal> field. You can also have the
1648 osamu 8648 <literal>Build-Depends-Indep</literal> field as an additional line, here.
1649     <footnote><para>See <ulink url="&policy-relationships;#s-sourcebinarydeps">Debian
1650 osamu 8601 Policy Manual, 7.7 'Relationships between source and binary packages -
1651     Build-Depends, Build-Depends-Indep, Build-Conflicts,
1652 osamu 8648 Build-Conflicts-Indep'</ulink>.</para></footnote> Some packages like
1653 osamu 8642 <systemitem role="package">gcc</systemitem> and
1654     <systemitem role="package">make</systemitem> which are required by the
1655     <systemitem role="package">build-essential</systemitem> package are implied. If you need
1656 osamu 8601 to have other tools to build your package, you should add them to these fields.
1657     Multiple entries are separated with commas; read on for the explanation of
1658     binary dependencies to find out more about the syntax of these lines.
1659     </para>
1660     <itemizedlist>
1661     <listitem>
1662     <para>
1663     For all packages packaged with the <command>dh</command> command in the
1664     <filename>debian/rules</filename> file, you must have <literal>debhelper
1665     (&gt;=7.0.50~)</literal> in the <literal>Build-Depends</literal> field to
1666     satisfy the Debian Policy requirement for the <literal>clean</literal> target.
1667     </para>
1668     </listitem>
1669     <listitem>
1670     <para>
1671     For source packages which have some binary packages with <literal>Architecture:
1672     any</literal>, they are rebuild by the autobuilder. Since this autobuilder
1673     procedure runs <literal>debian/rules build</literal> in it while installing
1674 taffit-guest 8665 only packages listed in the <literal>Build-Depends</literal> field (see <xref linkend="autobuilder"/>), the <literal>Build-Depends</literal> field needs to
1675 osamu 8601 list practically all the required packages and the
1676     <literal>Build-Depends-indep</literal> is rarely used.
1677     </para>
1678     </listitem>
1679     <listitem>
1680     <para>
1681     For source packages which have binary packages only with <literal>Architecture:
1682     all</literal>, the <literal>Build-Depends-Indep</literal> field may list all
1683     the required packages unless they are already listed in the
1684     <literal>Build-Depends</literal> field to satisfy the Debian Policy requirement
1685     for the <literal>clean</literal> target.
1686     </para>
1687     </listitem>
1688     </itemizedlist>
1689     <para>
1690     If you are not sure which one should be used, use the
1691     <literal>Build-Depends</literal> field to be on the safe side.
1692     <footnote><para> This somewhat strange situation is a feature well documented
1693 osamu 8628 in the <ulink url="&policy-build-depends-indep;">Debian Policy
1694 osamu 8601 Manual, Footnotes 48</ulink>. This is not due to the use of the
1695     <command>dh</command> command in the <filename>debian/rules</filename> file but
1696     due to how the <command>dpkg-buildpackage</command> works. The same situation
1697     applies to the <ulink url="https://bugs.launchpad.net/launchpad-buildd/+bug/238141">auto build system
1698     for Ubuntu</ulink>. </para> </footnote>
1699     </para>
1700     <para>
1701     To find out what packages your package needs to be built run the command:
1702     </para>
1703     <screen>
1704     $ dpkg-depcheck -d ./configure
1705     </screen>
1706     <para>
1707     To manually find exact build dependency for
1708     <command><replaceable>/usr/bin/foo</replaceable></command>, you execute
1709     </para>
1710     <screen>
1711     $ objdump -p <replaceable>/usr/bin/foo</replaceable> | grep NEEDED
1712     </screen>
1713     <para>
1714     and for each library listed, e.g., <command>libfoo.so.6</command>, execute
1715     </para>
1716     <screen>
1717     $ dpkg -S libfoo.so.6
1718     </screen>
1719     <para>
1720     Then you just take <literal>-dev</literal> version of every package as
1721     <literal>Build-Depends</literal> entry. If you use <command>ldd</command> for
1722     this purpose, it will report indirect lib dependencies as well, resulting in
1723     the problem of excessive build dependencies.
1724     </para>
1725     <para>
1726     <systemitem role="package">gentoo</systemitem> also happens to require
1727     <systemitem role="package">xlibs-dev</systemitem>, <systemitem role="package">libgtk1.2-dev</systemitem> and <systemitem role="package">libglib1.2-dev</systemitem> to build, so we'll add them here
1728     next to <systemitem role="package">debhelper</systemitem>.
1729     </para>
1730     <para>
1731 osamu 8628 Line 6 is the version of the <ulink url="&debian-policy;">Debian Policy
1732 osamu 8601 Manual</ulink> standards this package follows, the one you read while making
1733     your package.
1734     </para>
1735     <para>
1736     On line 7 you can put the URL of the homepage for the upstream program.
1737     </para>
1738     <para>
1739     Line 9 is the name of the binary package. This is usually the same as the name
1740     of the source package, but it doesn't necessarily have to be that way.
1741     </para>
1742     <para>
1743     Line 10 describes the CPU architecture the binary package can be compiled for.
1744     We'll leave this as <literal>any</literal> because <citerefentry>
1745     <refentrytitle>dpkg-gencontrol</refentrytitle> <manvolnum>1</manvolnum>
1746     </citerefentry> will fill in the appropriate value for any machine this package
1747     gets compiled on.
1748     </para>
1749     <para>
1750     If your package is architecture independent (for example, a shell or Perl
1751     script, or a document), change this to <literal>all</literal>, and read later
1752     in <xref linkend="rules"/> about using the <literal>binary-indep</literal> rule
1753     instead of <literal>binary-arch</literal> for building the package.
1754     </para>
1755     <para>
1756     Line 11 shows one of the most powerful features of the Debian packaging system.
1757     Packages can relate to each other in various ways. Apart from
1758     <literal>Depends</literal>, other relationship fields are
1759     <literal>Recommends</literal>, <literal>Suggests</literal>,
1760     <literal>Pre-Depends</literal>, <literal>Breaks</literal>,
1761     <literal>Conflicts</literal>, <literal>Provides</literal>, and
1762     <literal>Replaces</literal>.
1763     </para>
1764     <para>
1765     The package management tools usually behave the same way when dealing with
1766     these relations; if not, it will be explained. (see <citerefentry>
1767     <refentrytitle>dpkg</refentrytitle> <manvolnum>8</manvolnum> </citerefentry>,
1768     <citerefentry> <refentrytitle>dselect</refentrytitle> <manvolnum>8</manvolnum>
1769     </citerefentry>, <citerefentry> <refentrytitle>apt</refentrytitle>
1770     <manvolnum>8</manvolnum> </citerefentry>, <citerefentry>
1771     <refentrytitle>aptitude</refentrytitle> <manvolnum>1</manvolnum>
1772     </citerefentry> etc.)
1773     </para>
1774     <para>
1775 osamu 8648 Here is a simplified description of package relationships.
1776 osamu 8621 <footnote><para>See
1777 osamu 8648 <ulink url="&policy-relationships;">Debian Policy Manual, 7 'Declaring relationships between packages'</ulink>.
1778     </para></footnote>
1779 osamu 8601 </para>
1780     <itemizedlist>
1781     <listitem>
1782     <para>
1783     <literal>Depends</literal>
1784     </para>
1785     <para>
1786     The package will not be installed unless the packages it depends on are
1787     installed. Use this if your program absolutely will not run (or will cause
1788     severe breakage) unless a particular package is present.
1789     </para>
1790     </listitem>
1791     <listitem>
1792     <para>
1793     <literal>Recommends</literal>
1794     </para>
1795     <para>
1796     Use this for packages that are not strictly necessary but are typically used
1797     with your program. When a user installs your program, all frontends will
1798     likely prompt them to install the recommended packages.
1799     <command>aptitude</command> and <command>apt-get</command> install recommended
1800     packages along with your package (but the user can disable this default
1801     behaviour). <command>dpkg</command> will ignore this field.
1802     </para>
1803     </listitem>
1804     <listitem>
1805     <para>
1806     <literal>Suggests</literal>
1807     </para>
1808     <para>
1809     Use this for packages which will work nicely with your program but are not at
1810     all necessary. When a user installs your program, all frontends will likely
1811     prompt them to install the suggested packages. <command>aptitude</command> can
1812     be configured to install suggested packages along with your package but this is
1813     not its default. <command>dpkg</command> and <command>apt-get</command> will
1814     ignore this field.
1815     </para>
1816     </listitem>
1817     <listitem>
1818     <para>
1819     <literal>Pre-Depends</literal>
1820     </para>
1821     <para>
1822     This is stronger than <literal>Depends</literal>. The package will not be
1823     installed unless the packages it pre-depends on are installed and
1824     <emphasis>correctly configured</emphasis>. Use this <emphasis>very</emphasis>
1825 osamu 8628 sparingly and only after discussing it on the <ulink url="&debian-devel-ldo;">debian-devel@lists.debian.org</ulink>
1826 osamu 8601 mailing list. Read: don't use it at all. :-)
1827     </para>
1828     </listitem>
1829     <listitem>
1830     <para>
1831     <literal>Conflicts</literal>
1832     </para>
1833     <para>
1834     The package will not be installed until all the packages it conflicts with have
1835     been removed. Use this if your program absolutely will not run or will cause
1836     severe problems if a particular package is present.
1837     </para>
1838     </listitem>
1839     <listitem>
1840     <para>
1841     <literal>Breaks</literal>
1842     </para>
1843     <para>
1844     The package will be installed while all the listed packages will be broken.
1845     Normally a <literal>Breaks</literal> entry has an earlier than version clause.
1846     The resolution is generally to upgrade the listed packages by the higher-level
1847     package management tools.
1848     </para>
1849     </listitem>
1850     <listitem>
1851     <para>
1852     <literal>Provides</literal>
1853     </para>
1854     <para>
1855     For some types of packages where there are multiple alternatives virtual names
1856     have been defined. You can get the full list in the
1857 osamu 8639 <ulink url="&virtual-package;">virtual-package-names-list.txt.gz</ulink>
1858 osamu 8601 file. Use this if your program provides a function of an existing virtual
1859     package.
1860     </para>
1861     </listitem>
1862     <listitem>
1863     <para>
1864     <literal>Replaces</literal>
1865     </para>
1866     <para>
1867     Use this when your program replaces files from another package, or completely
1868     replaces another package (used in conjunction with
1869     <literal>Conflicts</literal>). Files from the named packages will be
1870     overwritten with the files from your package.
1871     </para>
1872     </listitem>
1873     </itemizedlist>
1874     <para>
1875     All these fields have uniform syntax. They are a list of package names
1876     separated by commas. These package names may also be lists of alternative
1877     package names, separated by vertical bar symbols <literal>|</literal> (pipe
1878     symbols).
1879     </para>
1880     <para>
1881     The fields may restrict their applicability to particular versions of each
1882     named package. These versions are listed in parentheses after each individual
1883     package name, and they should contain a relation from the list below followed
1884     by the version number. The relations allowed are: <literal>&lt;&lt;</literal>,
1885     <literal>&lt;=</literal>, <literal>=</literal>, <literal>&gt;=</literal> and
1886     <literal>&gt;&gt;</literal> for strictly lower, lower or equal, exactly equal,
1887     greater or equal and strictly greater, respectively. For example,
1888     </para>
1889     <screen>
1890     Depends: foo (&gt;= 1.2), libbar1 (= 1.3.4)
1891     Conflicts: baz
1892     Recommends: libbaz4 (&gt;&gt; 4.0.7)
1893     Suggests: quux
1894     Replaces: quux (&lt;&lt; 5), quux-foo (&lt;= 7.6)
1895     </screen>
1896     <para>
1897     The last feature you need to know about is
1898     <literal>${shlibs:Depends}</literal>, <literal>${perl:Depends}</literal>,
1899 osamu 8648 <literal>${misc:Depends}</literal>, etc.
1900 osamu 8601 </para>
1901     <para>
1902     <citerefentry> <refentrytitle>dh_shlibdeps</refentrytitle>
1903 osamu 8648 <manvolnum>1</manvolnum> </citerefentry> calculates shared library dependencies
1904     for binary packages. It generates a list of ELF executables and shared
1905     libraries it has found for each binary package. Such list is used for
1906     substituting <literal>${shlibs:Depends}</literal>.
1907 osamu 8601 </para>
1908     <para>
1909 osamu 8648 <citerefentry> <refentrytitle>dh_perl</refentrytitle> <manvolnum>1</manvolnum>
1910 taffit-guest 8665 </citerefentry> calculates Perl dependencies. It generates a list of a
1911     dependency on <literal>perl</literal> or <literal>perlapi</literal> for each binary package. Such list is used for
1912 osamu 8648 substituting <literal>${perl:Depends}</literal>.
1913 osamu 8601 </para>
1914     <para>
1915     Some <systemitem role="package">debhelper</systemitem> commands may make the
1916 osamu 8648 generated package need to depend on some other packages. All such commands
1917     generate a list of required packages for each binary package.
1918     Such list is used for substituting <literal>${misc:Depends}</literal>.
1919 osamu 8601 </para>
1920     <para>
1921 osamu 8648 <citerefentry> <refentrytitle>dh_gencontrol</refentrytitle>
1922     <manvolnum>1</manvolnum> </citerefentry> generates
1923     <filename>DEBIAN/control</filename> for each binary package while
1924     substituting <literal>${shlibs:Depends}</literal>,
1925     <literal>${perl:Depends}</literal>, <literal>${misc:Depends}</literal>, etc.
1926     </para>
1927     <para>
1928 osamu 8601 Having said all that, we can leave the <literal>Depends</literal> field exactly
1929     as it is now, and insert another line after it saying <literal>Suggests:
1930     file</literal>, because <systemitem role="package">gentoo</systemitem> can use
1931     some features provided by that <systemitem role="package">file</systemitem>
1932     package.
1933     </para>
1934 osamu 8621 <para> Line 9 is the Homepage URL. Let's assume this to be at
1935 osamu 8637 <ulink url="&gentoo;"/>.
1936 osamu 8621 </para>
1937 osamu 8601 <para>
1938     Line 12 is the short description. Most people screens are 80 columns wide so
1939     this shouldn't be longer than about 60 characters. I'll change it to
1940     <literal>fully GUI-configurable, two-pane X file manager</literal>.
1941     </para>
1942     <para>
1943     Line 13 is where the long description goes. This should be a paragraph which
1944     gives more details about the package. Column 1 of each line should be empty.
1945     There must be no blank lines, but you can put a single <literal>.</literal>
1946     (dot) in a column to simulate that. Also, there must be no more than one blank
1947 osamu 8621 line after the long description. <footnote><para>These descriptions are in
1948     English. Translations of these descriptions are provided by
1949     <ulink url="&ddtp;">The Debian Description Translation Project - DDTP</ulink>.</para></footnote>
1950 osamu 8601 </para>
1951     <para>
1952 osamu 8648 Let's insert <literal>Vcs-*</literal> fields to document the Version Control
1953     System (VCS) location between line 6 and 7.
1954     <footnote><para>See
1955     <ulink url="&devref-bpp-vcs;">Developer's Reference, 6.2.5. 'Version Control System location'</ulink>.
1956     </para></footnote>
1957     Let's assume that the <systemitem role="package">gentoo</systemitem>
1958     package has its VCS located in Debian Alioth Git Service at
1959 osamu 8601 <literal>git://git.debian.org/git/collab-maint/gentoo.git</literal>.
1960     </para>
1961     <para>
1962     Finally, here is the updated <filename>control</filename> file:
1963     </para>
1964     <screen>
1965     1 Source: gentoo
1966     2 Section: x11
1967     3 Priority: optional
1968     4 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
1969     5 Build-Depends: debhelper (&gt;= 7.0.5), xlibs-dev, libgtk1.2-dev, libglib1.2-dev
1970     6 Standards-Version: 3.8.4
1971     7 Vcs-Git: git://git.debian.org/git/collab-maint/gentoo.git
1972     8 Vcs-browser: http://git.debian.org/?p=collab-maint/gentoo.git
1973 osamu 8628 9 Homepage: &gentoo;
1974 osamu 8601 10
1975     11 Package: gentoo
1976     12 Architecture: any
1977     13 Depends: ${shlibs:Depends}, ${misc:Depends}
1978     14 Suggests: file
1979     15 Description: fully GUI-configurable, two-pane X file manager
1980     16 gentoo is a two-pane file manager for the X Window System. gentoo lets the
1981     17 user do (almost) all of the configuration and customizing from within the
1982     18 program itself. If you still prefer to hand-edit configuration files,
1983     19 they're fairly easy to work with since they are written in an XML format.
1984     20 .
1985     21 gentoo features a fairly complex and powerful file identification system,
1986     22 coupled to a object-oriented style system, which together give you a lot
1987     23 of control over how files of different types are displayed and acted upon.
1988     24 Additionally, over a hundred pixmap images are available for use in file
1989     25 type descriptions.
1990     26 .
1991     29 gentoo was written from scratch in ANSI C, and it utilises the GTK+ toolkit
1992     30 for its interface.
1993     </screen>
1994     <para>
1995     (I've added the line numbers.)
1996     </para>
1997     </section>
1998     <section id="copyright"><title><filename>copyright</filename> file</title>
1999     <para>
2000     This file contains the information about package upstream resources, copyright
2001 osamu 8648 and license information.
2002     <ulink url="&policy-copyright;">Debian Policy Manual, 12.5 'Copyright information'</ulink>
2003     dictates its content and
2004 taffit-guest 8665 <ulink url="&dep5;">DEP-5: Machine-parseable <filename>debian/copyright</filename></ulink>
2005 osamu 8648 provides guidelines for its format.
2006 osamu 8601 </para>
2007     <para>
2008     <command>dh_make</command> can give you a template
2009     <filename>copyright</filename> file. Let's use the <literal>--copyright
2010     gpl2</literal> option here to get a template file for the <systemitem role="package">gentoo</systemitem> package released under GPL-2.
2011     </para>
2012     <para>
2013     You must fill in missing information such as the place you got the package
2014     from, the actual copyright notice and their license to complete this file. For
2015     the common free software licenses such as GNU GPL-1, GNU GPL-2, GNU GPL-3,
2016     LGPL-2, LGPL-2.1, LGPL-3, GNU FDL-1.2, GNU FDL-1.3, Apache-2.0 or the Artistic
2017     license, you can just refer to the appropriate file in
2018     <filename>/usr/share/common-licenses/</filename> directory that exists on every
2019     Debian system. Otherwise, you must include the complete license.
2020     </para>
2021     <para>
2022     In short, here's how <systemitem role="package">gentoo</systemitem>'s
2023     <filename>copyright</filename> file should look like:
2024     </para>
2025     <screen>
2026     1 Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&amp;rev=135
2027     2 Name: gentoo
2028     3 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
2029     4 Source: http://sourceforge.net/projects/gentoo/files/
2030     5
2031     6 Copyright: 1998-2010 Emil Brink &lt;emil@obsession.se&gt;
2032     7 License: GPL-2+
2033     8
2034     9 Files: icons/*
2035     10 Copyright: 1998 Johan Hanson &lt;johan@tiq.com&gt;
2036     11 License: GPL-2+
2037     12
2038     13 Files: debian/*
2039     14 Copyright: 1998-2010 Josip Rodin &lt;joy-mg@debian.org&gt;
2040     15 License: GPL-2+
2041     16
2042     17 License: GPL-2+
2043     18 This program is free software; you can redistribute it and/or modify
2044     19 it under the terms of the GNU General Public License as published by
2045     20 the Free Software Foundation; either version 2 of the License, or
2046     21 (at your option) any later version.
2047     22 .
2048     23 This program is distributed in the hope that it will be useful,
2049     24 but WITHOUT ANY WARRANTY; without even the implied warranty of
2050     25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2051     26 GNU General Public License for more details.
2052     27 .
2053     28 You should have received a copy of the GNU General Public License along
2054     29 with this program; if not, write to the Free Software Foundation, Inc.,
2055     30 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2056     31 .
2057     32 On Debian systems, the full text of the GNU General Public
2058     33 License version 2 can be found in the file
2059     34 `/usr/share/common-licenses/GPL-2'.
2060     </screen>
2061     <para>
2062     (I've added the line numbers.)
2063     </para>
2064     <para>
2065     Please follow the HOWTO provided by ftpmasters and sent to
2066 osamu 8637 debian-devel-announce: <ulink url="&howto-copyright;"/>.
2067 osamu 8601 </para>
2068     </section>
2069     <section id="changelog"><title><filename>changelog</filename> file</title>
2070     <para>
2071 osamu 8648 This is a required file, which has a special format described in the
2072     <ulink url="&policy-dpkgchangelog;">Debian Policy Manual, 4.4 'debian/changelog'</ulink>.
2073     This format is used by <command>dpkg</command> and other programs to obtain the
2074     version number, revision, distribution and urgency of your package.
2075 osamu 8601 </para>
2076     <para>
2077     For you, it is also important, since it is good to have documented all changes
2078     you have done. It will help people downloading your package to see whether
2079     there are issues with the package that they should know about. It will be
2080     saved as <filename>/usr/share/doc/gentoo/changelog.Debian.gz</filename> in the
2081     binary package.
2082     </para>
2083     <para>
2084     <command>dh_make</command> created a default one, and this is how it looks
2085     like:
2086     </para>
2087     <screen>
2088     1 gentoo (0.9.12-1) unstable; urgency=low
2089     2
2090     3 * Initial release (Closes: #<replaceable>nnnn</replaceable>) &lt;<replaceable>nnnn</replaceable> is the bug number of your ITP&gt;
2091     4
2092     5 -- Josip Rodin &lt;joy-mg@debian.org&gt; Mon, 22 Mar 2010 00:37:31 +0100
2093     6
2094     </screen>
2095     <para>
2096     (I've added the line numbers.)
2097     </para>
2098     <para>
2099     Line 1 is the package name, version, distribution, and urgency. The name must
2100     match the source package name, distribution should be either
2101     <literal>unstable</literal> (or even <literal>experimental</literal>)
2102     <footnote><para> Some people use invalid distribution values such as
2103     <literal>UNRELEASED</literal> to prevent a package to be accidentally uploaded
2104     when updating a package in a shared VCS. </para> </footnote>, and urgency
2105     shouldn't be changed to anything higher than <literal>low</literal>. :-)
2106     </para>
2107     <para>
2108     Lines 3-5 are a log entry, where you document changes made in this package
2109     revision (not the upstream changes - there is special file for that purpose,
2110     created by the upstream authors, which you will later install as
2111     <filename>/usr/share/doc/gentoo/changelog.gz</filename>). Let's assume your
2112     ITP (Intent To Package) bug report number was <literal>12345</literal>. New
2113     lines must be inserted just before the uppermost line that begins with
2114     <literal>*</literal> (asterisk). You can do it with <citerefentry>
2115     <refentrytitle>dch</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>, or
2116     manually with a text editor.
2117     </para>
2118     <para>
2119     You will end up with something like this:
2120     </para>
2121     <screen>
2122     1 gentoo (0.9.12-1) unstable; urgency=low
2123     2
2124     3 * Initial Release. Closes: #12345
2125     4 * This is my first Debian package.
2126     5 * Adjusted the Makefile to fix $(DESTDIR) problems.
2127     6
2128     7 -- Josip Rodin &lt;joy-mg@debian.org&gt; Mon, 22 Mar 2010 00:37:31 +0100
2129     8
2130     </screen>
2131     <para>
2132     (I've added the line numbers.)
2133     </para>
2134     <para>
2135     You can read more about updating the <filename>changelog</filename> file later
2136 taffit-guest 8665 in <xref linkend="update"/>.
2137 osamu 8601 </para>
2138     </section>
2139     <section id="rules"><title><filename>rules</filename> file</title>
2140     <para>
2141     Now we need to take a look at the exact rules which <citerefentry>
2142     <refentrytitle>dpkg-buildpackage</refentrytitle> <manvolnum>1</manvolnum>
2143     </citerefentry> will use to actually create the package. This file is actually
2144     another <filename>Makefile</filename>, but different from the one(s) in the
2145     upstream source. Unlike other files in <filename>debian</filename>, this one
2146     is marked as executable.
2147     </para>
2148     <section id="targets"><title>Targets of <filename>rules</filename> file</title>
2149     <para>
2150     Every <filename>rules</filename> file, as any other
2151     <filename>Makefile</filename>, consists of several targets and their rules
2152 osamu 8628 specifying how to handle the source. <ulink url="&policy-debianrules;">Debian
2153 osamu 8601 Policy Manual, 4.9 'Main building script: debian/rules'</ulink> explains its
2154     details.
2155     </para>
2156     <para>
2157     The simplified explanation of targets are the following.
2158     </para>
2159     <itemizedlist>
2160     <listitem>
2161     <para>
2162     <literal>clean</literal> target: to clean all compiled, generated, and useless
2163     files in the build-tree. (required)
2164     </para>
2165     </listitem>
2166     <listitem>
2167     <para>
2168     <literal>build</literal> target: to build the source into compiled programs and
2169     formatted documents in the build-tree. (required)
2170     </para>
2171     </listitem>
2172     <listitem>
2173     <para>
2174     <literal>install</literal> target: to install files into a file tree for each
2175     binary package under the <filename>debian</filename> directory. If defined,
2176     <literal>binary*</literal> targets effectively depend on this target.
2177     (optional)
2178     </para>
2179     </listitem>
2180     <listitem>
2181     <para>
2182     <literal>binary</literal> target: to create all binary packages (effectively
2183     combination of <literal>binary-arch</literal> and
2184     <literal>binary-indep</literal> targets). (required)<footnote><para> This
2185 taffit-guest 8665 target is used by <literal>dpkg-buildpackage</literal> as in <xref linkend="completebuild"/>. </para> </footnote>
2186 osamu 8601 </para>
2187     </listitem>
2188     <listitem>
2189     <para>
2190     <literal>binary-arch</literal> target: to create arch-dependent
2191     (<literal>Architecture: any</literal>) binary packages in the parent directory.
2192     (required)<footnote><para> This target is used by <literal>dpkg-buildpackage
2193 taffit-guest 8665 -B</literal> as in <xref linkend="autobuilder"/>. </para> </footnote>
2194 osamu 8601 </para>
2195     </listitem>
2196     <listitem>
2197     <para>
2198     <literal>binary-indep</literal> target: to create arch-independent
2199     (<literal>Architecture: all</literal>) binary packages in the parent directory.
2200     (required)<footnote><para> This target is used by <literal>dpkg-buildpackage
2201     -A</literal>. </para> </footnote>
2202     </para>
2203     </listitem>
2204     <listitem>
2205     <para>
2206     <literal>get-orig-source</literal> target: to obtain the most recent version of
2207     the original source package from upstream archive site. (optional)
2208     </para>
2209     </listitem>
2210     </itemizedlist>
2211     <para>
2212     Rules that you want to execute are invoked as command line arguments (for
2213     example, <literal>./debian/rules build</literal> or <literal>fakeroot make -f
2214     debian/rules binary</literal>). After the target name, you can name the
2215     dependency, program or file that the rule depends on. After that, there can be
2216     any number of commands, indented with
2217     <literal><replaceable>TAB</replaceable></literal>. A new rule begins with the
2218     target declaration in the first column. Empty lines and lines beginning with
2219     <literal>#</literal> (hash) are treated as comments and ignored.
2220     </para>
2221     <para>
2222     You are probably confused now, but it will all be clear upon examination of the
2223     <filename>rules</filename> file that <command>dh_make</command> gives us as a
2224     default. You should also read <literal>info make</literal> for more
2225     information.
2226     </para>
2227     </section>
2228     <section id="defaultrules"><title>Default <filename>rules</filename> file</title>
2229     <para>
2230     Newer <command>dh_make</command> generates a very simple but powerful default
2231     <filename>rules</filename> file using the <command>dh</command> command:
2232     </para>
2233     <screen>
2234     1 #!/usr/bin/make -f
2235     2 # -*- makefile -*-
2236     3 # Sample debian/rules that uses debhelper.
2237     4 # This file was originally written by Joey Hess and Craig Small.
2238     5 # As a special exception, when this file is copied by dh-make into a
2239     6 # dh-make output file, you may use that output file without restriction.
2240     7 # This special exception was added by Craig Small in version 0.37 of dh-make.
2241     8
2242     9 # Uncomment this to turn on verbose mode.
2243     10 #export DH_VERBOSE=1
2244     11
2245     12 %:
2246     13 dh $@
2247     </screen>
2248     <para>
2249     (I've added the line numbers. In the actual <filename>rules</filename> file,
2250     the leading white spaces are TAB codes.)
2251     </para>
2252     <para>
2253     You are probably familiar with lines like line 1 from shell and Perl scripts.
2254     It tells the operating system that this file is to be processed with
2255     <filename>/usr/bin/make</filename>.
2256     </para>
2257     <para>
2258 taffit-guest 8665 Line 11 can be uncommented to set <literal>DH_VERBOSE</literal> variable to 1.
2259 osamu 8601 Then, the <command>dh</command> command will output which
2260     <command>dh_*</command> commands are executed by the <command>dh</command>
2261     command. You can also add <literal>export DH_OPTIONS=-v</literal> line here.
2262     Then each <command>dh_*</command> command will output which commands are
2263     executed by each <command>dh_*</command> command. This helps you to understand
2264     what exactly is going on behind this simple <filename>rules</filename> file and
2265     to debug its problems. This new <command>dh</command> is a core part of the
2266     <systemitem role="package">debhelper</systemitem> tools and does not hide
2267     anything from you.
2268     </para>
2269     <para>
2270     Lines 12 and 13 are where all the work is done. The percent sign means any
2271     targets which then call a single program, <command>dh</command> with the target
2272     name. <footnote><para> This uses the new <systemitem role="package">debhelper</systemitem> V7 features. Its design concepts are
2273 osamu 8628 explained in <ulink url="&debhelper-slides;">Not Your
2274 osamu 8601 Grandpa's Debhelper</ulink> presented at Debconf9 by the <systemitem role="package">debhelper</systemitem> upstream. Under
2275     <literal>lenny</literal>, <command>dh_make</command> created a much more
2276     complicated <filename>rules</filename> file with many <command>dh_*</command>
2277     scripts listed for each required explicit targets and frozen them to the state
2278     when it was initially packaged. This new <command>dh</command> command is
2279     simpler and frees us from this constrain. You still have full power to
2280 taffit-guest 8665 customize this with <literal>override_dh_*</literal> targets. See <xref linkend="customrules"/>. It is based only on the <systemitem role="package">debhelper</systemitem> package and does not obfuscate the
2281 osamu 8601 package building process like the <systemitem role="package">cdbs</systemitem>
2282     package. </para> </footnote> The <command>dh</command> command is a wrapper
2283     script which runs appropriate sequences of <command>dh_*</command> programs
2284     depending on its argument. <footnote><para> You can verify actual sequences of
2285     <command>dh_*</command> programs invoked for a given
2286     <literal><replaceable>target</replaceable></literal> as <literal>dh --no-act
2287     <replaceable>target</replaceable></literal> or <literal>debian/rules --
2288     '--no-act <replaceable>target</replaceable>'</literal> without really running
2289     them. </para> </footnote>
2290     </para>
2291     <itemizedlist>
2292     <listitem>
2293     <para>
2294     <literal>debian/rules clean</literal> runs <literal>dh clean</literal>; which
2295     in turn runs the following:
2296     </para>
2297     <screen>
2298     dh_testdir
2299     dh_auto_clean
2300     dh_clean
2301     </screen>
2302     </listitem>
2303     <listitem>
2304     <para>
2305     <literal>debian/rules build</literal> runs <literal>dh build</literal>; which
2306     in turn runs the following:
2307     </para>
2308     <screen>
2309     dh_testdir
2310     dh_auto_configure
2311     dh_auto_build
2312     dh_auto_test
2313     </screen>
2314     </listitem>
2315     <listitem>
2316     <para>
2317     <literal>fakeroot debian/rules binary</literal> runs <literal>fakeroot dh
2318     binary</literal>; which in turn runs the following<footnote><para> This assumes
2319     that the <systemitem role="package">python-support</systemitem> package is
2320     installed on the system. </para> </footnote>:
2321     </para>
2322     <screen>
2323     dh_testroot
2324     dh_prep
2325     dh_installdirs
2326     dh_auto_install
2327     dh_install
2328     dh_installdocs
2329     dh_installchangelogs
2330     dh_installexamples
2331     dh_installman
2332     dh_installcatalogs
2333     dh_installcron
2334     dh_installdebconf
2335     dh_installemacsen
2336     dh_installifupdown
2337     dh_installinfo
2338     dh_pysupport
2339     dh_installinit
2340     dh_installmenu
2341     dh_installmime
2342     dh_installmodules
2343     dh_installlogcheck
2344     dh_installlogrotate
2345     dh_installpam
2346     dh_installppp
2347     dh_installudev
2348     dh_installwm
2349     dh_installxfonts
2350     dh_bugfiles
2351     dh_lintian
2352     dh_gconf
2353     dh_icons
2354     dh_perl
2355     dh_usrlocal
2356     dh_link
2357     dh_compress
2358     dh_fixperms
2359     dh_strip
2360     dh_makeshlibs
2361     dh_shlibdeps
2362     dh_installdeb
2363     dh_gencontrol
2364     dh_md5sums
2365     dh_builddeb
2366     </screen>
2367     </listitem>
2368     <listitem>
2369     <para>
2370     <literal>fakeroot debian/rules binary-arch</literal> runs <literal>fakeroot dh
2371     binary-arch</literal>; which in turn runs the same sequence as
2372     <literal>fakeroot dh binary</literal> but with the <literal>-a</literal> option
2373     appended for each command.
2374     </para>
2375     </listitem>
2376     <listitem>
2377     <para>
2378     <literal>fakeroot debian/rules binary-indep</literal> runs <literal>fakeroot dh
2379     binary-indep</literal>; which in turn runs almost the same sequence as
2380     <literal>fakeroot dh binary</literal> but excluding
2381     <command>dh_strip</command>, <command>dh_makeshlibs</command>, and
2382     <command>dh_shlibdeps</command> with the <literal>-i</literal> option appended
2383     for each remaining command.
2384     </para>
2385     </listitem>
2386     </itemizedlist>
2387     <para>
2388     The function of <command>dh_*</command> commands are almost self-evident from
2389     their names. <footnote><para> For complete information on what do all these
2390     <command>dh_*</command> scripts exactly do, and what their other options are,
2391     please read their respective manual pages and the <systemitem role="package">debhelper</systemitem> documentation. </para> </footnote> There
2392     are few notable ones worth making (over)simplified explanation here assuming
2393     typical build environment based on <filename>Makefile</filename>.
2394     <footnote><para> These commands support other build environments such as
2395     <filename>setup.py</filename> which can be listed by executing
2396     <literal>dh_auto_build --list</literal> in a package source directory. </para>
2397     </footnote>
2398     </para>
2399     <itemizedlist>
2400     <listitem>
2401     <para>
2402     <command>dh_auto_clean</command> usually executes the following if
2403     <filename>Makefile</filename> exists with the <literal>distclean</literal>
2404     target. <footnote><para> It actually looks for the first available target of
2405     <literal>distclean</literal>, <literal>realclean</literal> or
2406     <literal>clean</literal> in <filename>Makefile</filename> and execute it.
2407     </para> </footnote>
2408     </para>
2409     <screen>
2410     make distclean
2411     </screen>
2412     </listitem>
2413     <listitem>
2414     <para>
2415     <command>dh_auto_configure</command> usually executes the following if
2416     <filename>./configure</filename> exists (arguments abbreviated for
2417     readability).
2418     </para>
2419     <screen>
2420     ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var ...
2421     </screen>
2422     </listitem>
2423     <listitem>
2424     <para>
2425     <command>dh_auto_build</command> usually executes the following to execute the
2426     first target of <filename>Makefile</filename> if it exists.
2427     </para>
2428     <screen>
2429     make
2430     </screen>
2431     </listitem>
2432     <listitem>
2433     <para>
2434     <command>dh_auto_test</command> usually executes the following if
2435     <filename>Makefile</filename> exists with the <literal>test</literal> target.
2436     <footnote><para> It actually looks for the first available target of
2437     <literal>test</literal> or <literal>check</literal> in
2438     <filename>Makefile</filename> and execute it. </para> </footnote>
2439     </para>
2440     <screen>
2441     make test
2442     </screen>
2443     </listitem>
2444     <listitem>
2445     <para>
2446     <command>dh_auto_install</command> usually executes the following if
2447     <filename>Makefile</filename> exists with the <literal>install</literal> target
2448     (line folded for readability).
2449     </para>
2450     <screen>
2451     make install \
2452     DESTDIR=<replaceable>/path/to</replaceable>/<replaceable>package</replaceable>_<replaceable>version</replaceable>-<replaceable>revision</replaceable>/debian/<replaceable>package</replaceable>
2453     </screen>
2454     </listitem>
2455     </itemizedlist>
2456     <para>
2457     Targets which require the <command>fakeroot</command> command contain
2458     <command>dh_testroot</command>. If you are not pretending to be root using
2459     this command, it exits with an error.
2460     </para>
2461     <para>
2462     The important part to know about the <filename>rules</filename> file created by
2463     <command>dh_make</command>, is that it is just a suggestion. It will work for
2464     most packages but for more complicated ones, don't be afraid to customize it to
2465     fit your needs. Only things that you must not change are the names of the
2466     rules, because all the tools use these names, as mandated by the Debian Policy.
2467     </para>
2468     <para>
2469     Although <literal>install</literal> is not required target, it is supported.
2470     <literal>fakeroot dh install</literal> behaves like <literal>fakeroot dh
2471     binary</literal> but stops after <command>dh_fixperms</command>.
2472     </para>
2473     </section>
2474     <section id="customrules"><title>Customization of <filename>rules</filename> file</title>
2475     <para>
2476     There are many ways to customize the <filename>rules</filename> file created
2477     with the new <command>dh</command> command.
2478     </para>
2479     <para>
2480     The <literal>dh $@</literal> command can be customized as follows.
2481     <footnote><para> If a package installs the
2482     <filename>/usr/share/perl5/Debian/Debhelper/Sequence/<replaceable>custom_name</replaceable>.pm</filename>
2483     file, you should activate its customization function by <literal>dh --with
2484     <replaceable>custom-name</replaceable> $@</literal>. </para> </footnote>
2485     </para>
2486     <itemizedlist>
2487     <listitem>
2488     <para>
2489     Add support of the <command>dh_pysupport</command> command. (The best choice
2490     for Python.) <footnote><para> Use of the <command>dh_pysupport</command>
2491     command is preferred over use of the <command>dh_pycentral</command> command.
2492     Do not use the <command>dh_python</command> command. </para> </footnote>
2493     </para>
2494     <itemizedlist>
2495     <listitem>
2496     <para>
2497     Install the <systemitem role="package">python-support</systemitem> package in
2498     <literal>Build-Depends</literal>.
2499     </para>
2500     </listitem>
2501     <listitem>
2502     <para>
2503     Use <literal>dh $@</literal> as usual. (This is enabled by default)
2504     </para>
2505     </listitem>
2506     <listitem>
2507     <para>
2508     This handles Python modules using the <systemitem role="package">python-support</systemitem> framework.
2509     </para>
2510     </listitem>
2511     </itemizedlist>
2512     </listitem>
2513     <listitem>
2514     <para>
2515     Add support of the <command>dh_pycentral</command> command.
2516     </para>
2517     <itemizedlist>
2518     <listitem>
2519     <para>
2520     Install the <systemitem role="package">python-central</systemitem> package in
2521     <literal>Build-Depends</literal>.
2522     </para>
2523     </listitem>
2524     <listitem>
2525     <para>
2526     Use <literal>dh --with python-central $@</literal> instead.
2527     </para>
2528     </listitem>
2529     <listitem>
2530     <para>
2531     This also deactivates the <command>dh_pysupport</command> command.
2532     </para>
2533     </listitem>
2534     <listitem>
2535     <para>
2536     This handles Python modules using the <systemitem role="package">python-central</systemitem> framework.
2537     </para>
2538     </listitem>
2539     </itemizedlist>
2540     </listitem>
2541     <listitem>
2542     <para>
2543     Add support of the <command>dh_installtex</command> command.
2544     </para>
2545     <itemizedlist>
2546     <listitem>
2547     <para>
2548     Install the <systemitem role="package">tex-common</systemitem> package in
2549     <literal>Build-Depends</literal>.
2550     </para>
2551     </listitem>
2552     <listitem>
2553     <para>
2554     Use <literal>dh --with tex $@</literal> instead.
2555     </para>
2556     </listitem>
2557     <listitem>
2558     <para>
2559     This registers Type 1 fonts, hyphenation patterns, or formats with TeX.
2560     </para>
2561     </listitem>
2562     </itemizedlist>
2563     </listitem>
2564     <listitem>
2565     <para>
2566     Add support of the <command>dh_quilt_patch</command> and
2567     <command>dh_quilt_unpatch</command> commands.
2568     </para>
2569     <itemizedlist>
2570     <listitem>
2571     <para>
2572     Install the <systemitem role="package">quilt</systemitem> package in
2573     <literal>Build-Depends</literal>.
2574     </para>
2575     </listitem>
2576     <listitem>
2577     <para>
2578     Use <literal>dh --with quilt $@</literal> instead.
2579     </para>
2580     </listitem>
2581     <listitem>
2582     <para>
2583     This applies and un-applies patches to the upstream source from files in the
2584     <filename>debian/patches</filename> directory for the <literal>1.0</literal>
2585     source package.
2586     </para>
2587     </listitem>
2588     <listitem>
2589     <para>
2590     This is not needed if you use the new <literal>3.0 (quilt)</literal> source
2591     package.
2592     </para>
2593     </listitem>
2594     </itemizedlist>
2595     </listitem>
2596     <listitem>
2597     <para>
2598     Add support of the <command>dh_dkms</command> command.
2599     </para>
2600     <itemizedlist>
2601     <listitem>
2602     <para>
2603     Install the <systemitem role="package">dkms</systemitem> package in
2604     <literal>Build-Depends</literal>.
2605     </para>
2606     </listitem>
2607     <listitem>
2608     <para>
2609     Use <literal>dh --with dkms $@</literal> instead.
2610     </para>
2611     </listitem>
2612     <listitem>
2613     <para>
2614     This correctly handles DKMS usage by the kernel module package.
2615     </para>
2616     </listitem>
2617     </itemizedlist>
2618     </listitem>
2619     <listitem>
2620     <para>
2621     Add support of the <command>dh_autotools-dev_updateconfig</command> and
2622     <command>dh_autotools-dev_restoreconfig</command> commands.
2623     </para>
2624     <itemizedlist>
2625     <listitem>
2626     <para>
2627     Install the <systemitem role="package">autotools-dev</systemitem> package in
2628     <literal>Build-Depends</literal>.
2629     </para>
2630     </listitem>
2631     <listitem>
2632     <para>
2633     Use <literal>dh --with autotools-dev $@</literal> instead.
2634     </para>
2635     </listitem>
2636     <listitem>
2637     <para>
2638     This updates and restores <filename>config.sub</filename> and
2639     <filename>config.guess</filename>.
2640     </para>
2641     </listitem>
2642     </itemizedlist>
2643     </listitem>
2644     <listitem>
2645     <para>
2646     Add support of the <command>dh_autoreconf</command> and
2647     <command>dh_autoreconf_clean</command> commands.
2648     </para>
2649     <itemizedlist>
2650     <listitem>
2651     <para>
2652     Install the <systemitem role="package">dh-autoreconf</systemitem> package in
2653     <literal>Build-Depends</literal>.
2654     </para>
2655     </listitem>
2656     <listitem>
2657     <para>
2658     Use <literal>dh --with autoreconf $@</literal> instead.
2659     </para>
2660     </listitem>
2661     <listitem>
2662     <para>
2663     This updates the GNU Build System files and restores them after the build.
2664     </para>
2665     </listitem>
2666     </itemizedlist>
2667     </listitem>
2668     <listitem>
2669     <para>
2670     Add support to the <command>bash</command> completion feature.
2671     </para>
2672     <itemizedlist>
2673     <listitem>
2674     <para>
2675     Install the <systemitem role="package">bash-completion</systemitem> package in
2676     <literal>Build-Depends</literal>.
2677     </para>
2678     </listitem>
2679     <listitem>
2680     <para>
2681     Use <literal>dh --with bash-completion $@</literal> instead.
2682     </para>
2683     </listitem>
2684     <listitem>
2685     <para>
2686     This installs <command>bash</command> completions using configuration file at
2687     <filename>debian/<replaceable>package</replaceable>.bash-completion</filename>.
2688     </para>
2689     </listitem>
2690     </itemizedlist>
2691     </listitem>
2692     </itemizedlist>
2693     <para>
2694     For sources using Autotools, use combination of above as <literal>dh --with
2695     autotools-dev --with autoreconf $@</literal> to be most current with the GNU
2696     Build System.
2697     </para>
2698     <para>
2699     Many <command>dh_*</command> commands invoked by the new <command>dh</command>
2700     command can be customized by the corresponding configuration files in the
2701     <filename>debian</filename> directory. See <xref linkend="dother"/> and the
2702     manpage of each command for the customization of such features.
2703     </para>
2704     <para>
2705     Some <command>dh_*</command> commands invoked by the new <command>dh</command>
2706     command may require you to run it with some arguments or to run additional
2707     commands with them or to skip them. For such cases, you create an
2708     <literal>override_dh_<replaceable>foo</replaceable></literal> target with its
2709     rule in the <filename>rules</filename> file only for the
2710     <command>dh_<replaceable>foo</replaceable></command> command you want to
2711     change. It basically say <emphasis>run me instead</emphasis>.
2712     <footnote><para> Under <literal>lenny</literal>, if you wanted to change the
2713     behavior of a <command>dh_*</command> script you found the relevant line in the
2714     <filename>rules</filename> file and adjusted it. </para> </footnote>
2715     </para>
2716     <para>
2717     Please note that the <command>dh_auto_*</command> commands tend to do more than
2718     what has been discussed as (over)simplified explanation to take care all the
2719     corner cases. Use of simplified equivalent command instead of these in
2720     <literal>override_dh_*</literal> targets except the
2721     <literal>override_dh_auto_clean</literal> target is a bad idea since it may
2722     kill such <systemitem role="package">debhelper</systemitem>'s smart features.
2723     </para>
2724     <para>
2725 osamu 8650 If you want to store the system configuration data in the
2726 osamu 8601 <filename>/etc/gentoo</filename> directory instead of the usual
2727 osamu 8650 <filename>/etc</filename> directory for the recent
2728     <systemitem role="package">gentoo</systemitem> package using Autotools, you can override the default
2729 osamu 8601 <literal>--sysconfig=/etc</literal> argument given by the
2730     <command>dh_auto_configure</command> command to the
2731 osamu 8650 <command>./configure</command> command by the following.
2732 osamu 8601 </para>
2733     <screen>
2734     override_dh_auto_configure:
2735     dh_auto_configure -- --sysconfig=/etc/gentoo
2736     </screen>
2737     <para>
2738     The arguments given after <literal>--</literal> are appended to the default
2739     arguments of the auto-executed program to override them. Using the
2740     <command>dh_auto_configure</command> command is better than the
2741     <command>./configure</command> command here since it will only override the
2742     <literal>--sysconfig</literal> argument and keeps well intended other arguments
2743     to the <command>./configure</command> command.
2744     </para>
2745     <para>
2746     If <filename>Makefile</filename> of a source for <systemitem role="package">gentoo</systemitem> requires you to specify
2747     <literal>build</literal> as its target to build it <footnote><para>
2748     <command>dh_auto_build</command> without any arguments will execute the first
2749     target in the <filename>Makefile</filename> file. </para> </footnote>, you
2750     create an <literal>override_dh_auto_build</literal> target to enable it.
2751     </para>
2752     <screen>
2753     override_dh_auto_build:
2754     dh_auto_build -- build
2755     </screen>
2756     <para>
2757     This ensures to run $(MAKE) with all the default arguments given by the
2758     <command>dh_auto_build</command> command and <literal>build</literal> argument.
2759     </para>
2760     <para>
2761     If <filename>Makefile</filename> of a source for <systemitem role="package">gentoo</systemitem> requires you to specify the
2762     <literal>packageclean</literal> target to clean it for Debian package instead
2763     of the <literal>distclean</literal> or <literal>clean</literal> targets in the
2764     <filename>Makefile</filename> file, you create an
2765     <literal>override_dh_auto_clean</literal> target to enable it.
2766     </para>
2767     <screen>
2768     override_dh_auto_clean:
2769     $(MAKE) packageclean
2770     </screen>
2771     <para>
2772     If <filename>Makefile</filename> of a source for <systemitem role="package">gentoo</systemitem> contains <literal>test</literal> target
2773     which you do not want to run for the Debian package building process, you can
2774     use empty <literal>override_dh_auto_test</literal> target to skip it.
2775     </para>
2776     <screen>
2777     override_dh_auto_test:
2778     </screen>
2779     <para>
2780     If <systemitem role="package">gentoo</systemitem> has an unusual upstream
2781     changelog file called <filename>FIXES</filename>,
2782     <command>dh_installchangelogs</command> will not install that file by default.
2783     The <command>dh_installchangelogs</command> command requires
2784     <filename>FIXES</filename> as its argument to install it. <footnote><para> The
2785     <filename>debian/changelog</filename> and <filename>debian/NEWS</filename>
2786     files are always automatically installed. The upstream changelog is searched
2787     by converting filenames to the lower case and matching them with the
2788     <filename>changelog</filename>, <filename>changes</filename>,
2789     <filename>changelog.txt</filename>, and <filename>changes.txt</filename>.
2790     </para> </footnote>
2791     </para>
2792     <screen>
2793     override_dh_installchangelogs:
2794     dh_installchangelogs FIXES
2795     </screen>
2796     <para>
2797     When you use the new <command>dh</command> command, use of explicit targets
2798     such as the ones listed in <xref linkend="targets"/> except
2799     <literal>get-orig-source</literal> target may make it difficult to understand
2800     their exact effects. Please limit explicit targets to
2801     <literal>override_dh_*</literal> targets and completely independent ones, if
2802     possible.
2803     </para>
2804     </section>
2805     </section>
2806     </chapter>
2807     <chapter id="dother"><title>Other files under the <filename>debian</filename> directory</title>
2808     <para>
2809     To control most of what <systemitem role="package">debhelper</systemitem> does
2810     while building the package, you put optional configuration files under the
2811     <filename>debian</filename> directory. This chapter will make an overview of
2812 osamu 8628 what each of these does and its format. Please read <ulink url="&debian-policy;">Debian Policy
2813     Manual</ulink> and <ulink url="&developers-reference;">Debian Developer's
2814 osamu 8601 Reference</ulink> for guidelines for the packaging.
2815     </para>
2816     <para>
2817     The <command>dh_make</command> command will create some template configuration
2818     files under the <filename>debian</filename> directory. Most of them come with
2819     filenames suffixed by <literal>.ex</literal>. Some of them come with filenames
2820     prefixed by the binary package name such as
2821     <literal><replaceable>package</replaceable></literal>. Take a look at all of
2822     them.
2823 osamu 8668 <footnote><para>
2824     In this chapter, files in the <filename>debian</filename> directory are
2825     referred without preceding <filename>debian/</filename> for simplicity whenever
2826     they are obvious.
2827     </para></footnote>
2828 osamu 8601 </para>
2829     <para>
2830     The <command>dh_make</command> command may not create some template
2831     configuration files for <systemitem role="package">debhelper</systemitem>. In
2832     such cases, you need to create them with the editor.
2833     </para>
2834     <para>
2835     If you wish or need to activate any of those, please do the following.
2836     </para>
2837     <itemizedlist>
2838     <listitem>
2839     <para>
2840     rename template files by removing the <literal>.ex</literal> or
2841     <literal>.EX</literal> suffix if the template files have one.
2842     </para>
2843     </listitem>
2844     <listitem>
2845     <para>
2846     rename the name of these configuration files using the actual binary package
2847     name in place of <literal><replaceable>package</replaceable></literal>.
2848     </para>
2849     </listitem>
2850     <listitem>
2851     <para>
2852     modify template file contents to suit your needs.
2853     </para>
2854     </listitem>
2855     <listitem>
2856     <para>
2857     remove template files which you do not need.
2858     </para>
2859     </listitem>
2860     <listitem>
2861     <para>
2862 taffit-guest 8665 modify the <filename>control</filename> file (see <xref linkend="control"/>),
2863 osamu 8601 if necessary.
2864     </para>
2865     </listitem>
2866     <listitem>
2867     <para>
2868 taffit-guest 8665 modify the <filename>rules</filename> file (see <xref linkend="rules"/>), if
2869 osamu 8601 necessary.
2870     </para>
2871     </listitem>
2872     </itemizedlist>
2873     <para>
2874     Those <systemitem role="package">debhelper</systemitem> configuration files
2875     without <filename><replaceable>package</replaceable></filename> prefix such as
2876     <filename>install</filename> apply to the first binary package. When there are
2877     many binary packages, their configurations can be specified by prefixing their
2878     name to their configuration filenames such as
2879     <filename><replaceable>package-1</replaceable>.install</filename>,
2880     <filename><replaceable>package-2</replaceable>.install</filename>, etc.
2881     </para>
2882     <section id="readme"><title><filename>README.Debian</filename> file</title>
2883     <para>
2884     Any extra details or discrepancies between the original package and your Debian
2885     version should be documented here.
2886     </para>
2887     <para>
2888     <command>dh_make</command> created a default one, this is what it looks like:
2889     </para>
2890     <screen>
2891     gentoo for Debian
2892     -----------------
2893     &lt;possible notes regarding this package - if none, delete this file&gt;
2894     -- Josip Rodin &lt;joy-mg@debian.org&gt;, Wed, 11 Nov 1998 21:02:14 +0100
2895     </screen>
2896     <para>
2897     If you have nothing to be documented, remove this file. See <citerefentry>
2898     <refentrytitle>dh_installdocs</refentrytitle> <manvolnum>1</manvolnum>
2899     </citerefentry>.
2900     </para>
2901     </section>
2902     <section id="compat"><title><filename>compat</filename> file</title>
2903     <para>
2904     The <filename>compat</filename> file defines the <systemitem role="package">debhelper</systemitem> compatibility level. Currently, you
2905     should set it to the <systemitem role="package">debhelper</systemitem> V7 by
2906     the following.
2907     </para>
2908     <screen>
2909     $ echo 7 &gt; debian/compat
2910     </screen>
2911     </section>
2912     <section id="conffiles"><title><filename>conffiles</filename> file</title>
2913     <para>
2914     One of the most annoying things about software is when you spend a great deal
2915     of time and effort customizing a program, only to have an upgrade stomp all
2916 osamu 8622 over your changes. Debian solves this problem by marking such configuration files as conffiles.
2917     <footnote><para>See <citerefentry> <refentrytitle>dpkg</refentrytitle>
2918     <manvolnum>1</manvolnum> </citerefentry> and
2919 osamu 8628 <ulink url="&policy-conffiles;">Debian Policy Manual 'D.2.5 Conffiles'</ulink>.
2920 osamu 8622 </para></footnote>
2921     When you upgrade a package, you'll be prompted whether you want to keep
2922     your old configuration files or not.
2923 osamu 8601 </para>
2924     <para>
2925     Since <systemitem role="package">debhelper</systemitem> V3, <citerefentry>
2926     <refentrytitle>dh_installdeb</refentrytitle> <manvolnum>1</manvolnum>
2927     </citerefentry> will <emphasis>automatically</emphasis> flag any files under
2928     the <filename>/etc</filename> directory as conffiles, so if your program only
2929     has conffiles there you do not need to specify them in this file. For most
2930     package types, the only place there is (and should be conffiles) is under
2931     <filename>/etc</filename> and so this file doesn't need to exist.
2932     </para>
2933     <para>
2934     If your program uses configuration files but also rewrites them on its own,
2935     it's best not to make them as conffiles because <command>dpkg</command> will
2936     then prompt users to verify the changes all the time.
2937     </para>
2938     <para>
2939     If the program you're packaging requires every user to modify the configuration
2940     files in the <filename>/etc</filename> directory, there are 2 popular ways to
2941     make them not as conffiles to keep <command>dpkg</command> quiet.
2942     </para>
2943     <itemizedlist>
2944     <listitem>
2945     <para>
2946     You make a symlink under the <filename>/etc</filename> directory pointing to a
2947     file under the <filename>/var</filename> directory generated by the
2948     <emphasis>maintainer scripts</emphasis>.
2949     </para>
2950     </listitem>
2951     <listitem>
2952     <para>
2953     You make a file generated by the <emphasis>maintainer scripts</emphasis> under
2954     the <filename>/etc</filename> directory.
2955     </para>
2956     </listitem>
2957     </itemizedlist>
2958     <para>
2959 taffit-guest 8665 For more information on the <emphasis>maintainer scripts</emphasis>, see <xref linkend="maintscripts"/>.
2960 osamu 8601 </para>
2961     </section>
2962     <section id="crond"><title><filename><replaceable>package</replaceable>.cron.*</filename> files</title>
2963     <para>
2964     If your package requires regularly scheduled tasks to operate properly, you can
2965     use this file to set it up. You can either setup regular tasks that happen
2966     hourly, daily, weekly or monthly or alternatively happen any other time that
2967     you wish. The filenames are:
2968     </para>
2969     <itemizedlist>
2970     <listitem>
2971     <para>
2972     <filename>cron.hourly</filename> - Installed as
2973     <filename>/etc/cron.hourly/<replaceable>package</replaceable></filename>: run
2974     once an hour every hour.
2975     </para>
2976     </listitem>
2977     <listitem>
2978     <para>
2979     <filename>cron.daily</filename> - Installed as
2980     <filename>/etc/cron.daily/<replaceable>package</replaceable></filename>: run
2981     once a day, usually early morning.
2982     </para>
2983     </listitem>
2984     <listitem>
2985     <para>
2986     <filename>cron.weekly</filename> - Installed as
2987     <filename>/etc/cron.weekly/<replaceable>package</replaceable></filename>: run
2988     once a week, usually early Sunday morning.
2989     </para>
2990     </listitem>
2991     <listitem>
2992     <para>
2993     <filename>cron.monthly</filename> - Installed as
2994     <filename>/etc/cron.monthly/<replaceable>package</replaceable></filename>: run
2995     once a month, usually early morning on the first of the month.
2996     </para>
2997     </listitem>
2998     <listitem>
2999     <para>
3000     <filename>cron.d</filename> - Installed as
3001     <filename>/etc/cron.d/<replaceable>package</replaceable></filename>: for any
3002     other time
3003     </para>
3004     </listitem>
3005     </itemizedlist>
3006     <para>
3007     For the named files, the format of them is the shell script. The different one
3008     is <filename><replaceable>package</replaceable>.cron.d</filename> which follows
3009     the format of <citerefentry> <refentrytitle>crontab</refentrytitle>
3010     <manvolnum>5</manvolnum> </citerefentry>.
3011     </para>
3012     <para>
3013     Note that this doesn't include log rotation; for that, see <citerefentry>
3014     <refentrytitle>dh_installlogrotate</refentrytitle> <manvolnum>1</manvolnum>
3015     </citerefentry> and <citerefentry> <refentrytitle>logrotate</refentrytitle>
3016     <manvolnum>8</manvolnum> </citerefentry>.
3017     </para>
3018     </section>
3019     <section id="dirs"><title><filename>dirs</filename> file</title>
3020     <para>
3021     This file specifies the directories which we need but the normal installation
3022     procedure (<literal>make install DESTDIR=...</literal> invoked by
3023     <literal>dh_auto_install</literal>) somehow doesn't create. This generally
3024     means there is a problem with the <filename>Makefile</filename>.
3025     </para>
3026     <para>
3027     Files listed in the <filename>install</filename> file doesn't need the
3028 taffit-guest 8665 directories created first. See <xref linkend="install"/>.
3029 osamu 8601 </para>
3030     <para>
3031 osamu 8652 It is best to try to run the installation first and only use this if you
3032 osamu 8622 run into trouble. There is no preceding slash on the directory names listed in
3033     the <filename>dirs</filename> file.
3034 osamu 8601 </para>
3035     </section>
3036     <section id="doc-base"><title><filename><replaceable>package</replaceable>.doc-base</filename> file</title>
3037     <para>
3038     If your package has documentation other than manual pages and info docs, you
3039     should use the <systemitem role="package">doc-base</systemitem> file to
3040     register it, so the user can find it with e.g. <citerefentry>
3041     <refentrytitle>dhelp</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>,
3042     <citerefentry> <refentrytitle>dwww</refentrytitle> <manvolnum>1</manvolnum>
3043     </citerefentry> or <citerefentry> <refentrytitle>doccentral</refentrytitle>
3044     <manvolnum>1</manvolnum> </citerefentry>.
3045     </para>
3046     <para>
3047     This usually includes HTML, PS and PDF files, shipped in
3048     <filename>/usr/share/doc/<replaceable>packagename</replaceable>/</filename>.
3049     </para>
3050     <para>
3051     This is how <systemitem role="package">gentoo</systemitem>'s doc-base file
3052     <filename>gentoo.doc-base</filename> looks like:
3053     </para>
3054     <screen>
3055     Document: gentoo
3056     Title: Gentoo Manual
3057     Author: Emil Brink
3058     Abstract: This manual describes what Gentoo is, and how it can be used.
3059     Section: File Management
3060     Format: HTML
3061     Index: /usr/share/doc/gentoo/html/index.html
3062     Files: /usr/share/doc/gentoo/html/*.html
3063     </screen>
3064     <para>
3065     For information on the file format, see <citerefentry>
3066     <refentrytitle>install-docs</refentrytitle> <manvolnum>8</manvolnum>
3067     </citerefentry> and the <systemitem role="package">doc-base</systemitem>
3068 osamu 8639 manual, in <ulink url="&doc-base;">Debian doc-base Manual</ulink>.
3069 osamu 8601 </para>
3070     <para>
3071 taffit-guest 8665 For more details on installing additional documentation, look in <xref linkend="destdir"/>.
3072 osamu 8601 </para>
3073     </section>
3074     <section id="docs"><title><filename>docs</filename> file</title>
3075     <para>
3076     This file specifies the file names of documentation files we can have
3077     <citerefentry> <refentrytitle>dh_installdocs</refentrytitle>
3078     <manvolnum>1</manvolnum> </citerefentry> install into the temporary directory
3079     for us.
3080     </para>
3081     <para>
3082     By default, it will include all existing files in the top-level source
3083     directory that are called <filename>BUGS</filename>,
3084     <filename>README*</filename>, <filename>TODO</filename> etc.
3085     </para>
3086     <para>
3087     For <systemitem role="package">gentoo</systemitem>, I also included some other
3088     files:
3089     </para>
3090     <screen>
3091     BUGS
3092     CONFIG-CHANGES
3093     CREDITS
3094     NEWS
3095     README
3096     README.gtkrc
3097     TODO
3098     </screen>
3099     </section>
3100     <section id="emacsen"><title><filename>emacsen-*</filename> file</title>
3101     <para>
3102     If your package supplies Emacs files that can be bytecompiled at package
3103     installation time, you can use these files to set it up.
3104     </para>
3105     <para>
3106     They are installed into the temporary directory by <citerefentry>
3107     <refentrytitle>dh_installemacsen</refentrytitle> <manvolnum>1</manvolnum>
3108     </citerefentry>.
3109     </para>
3110     <para>
3111     If you don't need these, remove them.
3112     </para>
3113     </section>
3114     <section id="examples"><title><filename><replaceable>package</replaceable>.examples</filename> file</title>
3115     <para>
3116     The <citerefentry> <refentrytitle>dh_installexamples</refentrytitle>
3117     <manvolnum>1</manvolnum> </citerefentry> command installs files and directories
3118     listed in this file as example files.
3119     </para>
3120     </section>
3121     <section id="initd"><title><filename><replaceable>package</replaceable>.init</filename> and <filename><replaceable>package</replaceable>.default</filename> files</title>
3122     <para>
3123     If your package is a daemon that needs to be run at the system start-up, you've
3124     obviously disregarded my initial recommendation, haven't you? :-)
3125     </para>
3126     <para>
3127     The <filename><replaceable>package</replaceable>.init</filename> file is
3128     installed as the
3129 osamu 8668 <filename>/etc/init.d/<replaceable>package</replaceable></filename> script
3130     for the <emphasis>init script</emphasis> which starts and stops a daemon.
3131 osamu 8601 Its fairly generic skeleton template is provided by the
3132     <command>dh_make</command> command as <filename>init.d.ex</filename>. You'll
3133     likely have to rename and edit it, a lot, while making sure to provide
3134 osamu 8642 <ulink url="&lsb;">Linux Standard Base</ulink> (LSB) compliant headers. It
3135 osamu 8601 gets installed into the temporary directory by <citerefentry>
3136     <refentrytitle>dh_installinit</refentrytitle> <manvolnum>1</manvolnum>
3137     </citerefentry>.
3138     </para>
3139     <para>
3140     The <filename><replaceable>package</replaceable>.default</filename> file will
3141     be installed into
3142     <filename>/etc/default/<replaceable>package</replaceable></filename>. This
3143 osamu 8668 file sets defaults that are sourced by the <emphasis>init script</emphasis>. Most times this
3144     <filename><replaceable>package</replaceable>.default</filename> file is used to disable running a daemon, set some default flags or
3145     timeouts. If your <emphasis>init script</emphasis> has certain <emphasis>settable</emphasis>
3146     features you want to install these into the <filename><replaceable>package</replaceable>.default</filename> file, not the <emphasis>init script</emphasis>.
3147 osamu 8601 </para>
3148     <para>
3149 osamu 8680 If your upstream program provides a file for the <emphasis>init script</emphasis>, you can either use it or not. If you
3150 osamu 8668 don't use their <emphasis>init script</emphasis> then create a new one in
3151     <filename><replaceable>package</replaceable>.init</filename>. However
3152     if the upstream <emphasis>init script</emphasis> looks fine and installs in the right place you
3153 osamu 8601 still need to setup the <filename>rc*</filename> symlinks. To do this you will
3154     need to override <command>dh_installinit</command> in the
3155     <filename>rules</filename> file with the following lines:
3156     </para>
3157     <screen>
3158     override_dh_installinit:
3159     dh_installinit --onlyscripts
3160     </screen>
3161     <para>
3162     If you don't need this, remove the files.
3163     </para>
3164     </section>
3165     <section id="install"><title><filename>install</filename> file</title>
3166     <para>
3167     If there are files that need to be installed into your package but your
3168     standard <literal>make install</literal> won't do it, you put the filenames and
3169     destinations into this <filename>install</filename> file. They are installed
3170     by <citerefentry> <refentrytitle>dh_install</refentrytitle>
3171     <manvolnum>1</manvolnum> </citerefentry>.<footnote><para> This replaces the
3172     deprecated <citerefentry> <refentrytitle>dh_movefiles</refentrytitle>
3173     <manvolnum>1</manvolnum> </citerefentry> command which is configured by the
3174     <filename>files</filename> file. </para> </footnote> You should first check
3175     there is not a more specific tool to use. For example, documents should be in
3176     the <filename>docs</filename> file and not in this one.
3177     </para>
3178     <para>
3179     This <filename>install</filename> file has one line per file installed, with
3180     the name of the file (relative to the top build directory) then a space then
3181     the installation directory (relative to the install directory). One example of
3182     where this is used is where a binary is forgotten to be installed, the
3183     <filename>install</filename> file would look like:
3184     </para>
3185     <screen>
3186     src/foo/mybin usr/bin
3187     </screen>
3188     <para>
3189     This will mean when this package is installed, there will be a binary file
3190     <filename>/usr/bin/mybin</filename>.
3191     </para>
3192     <para>
3193     Alternatively, this <filename>install</filename> can have the name of the file
3194     only without the installation directory when the relative directory path does
3195     not change. This format is usually used for a large package that splits build
3196     result into multiple binary packages using
3197     <filename><replaceable>package-1</replaceable>.install</filename>,
3198     <filename><replaceable>package-2</replaceable>.install</filename>, etc.
3199     </para>
3200     <para>
3201     The <command>dh_install</command> command will fall back to look in
3202     <filename>debian/tmp</filename> for files, if it doesn't find them in the
3203     current directory (or wherever you've told it to look using
3204     <literal>--sourcedir</literal>).
3205     </para>
3206     </section>
3207     <section id="info"><title><filename><replaceable>package</replaceable>.info</filename> file</title>
3208     <para>
3209     If your package has info pages, you should install them using <citerefentry>
3210     <refentrytitle>dh_installinfo</refentrytitle> <manvolnum>1</manvolnum>
3211     </citerefentry> by listing them in the
3212     <filename><replaceable>package</replaceable>.info</filename> files.
3213     </para>
3214     </section>
3215     <section id="lintian"><title><filename>{<replaceable>package</replaceable>.|source/}lintian-overrides</filename> files</title>
3216     <para>
3217     If <systemitem role="package">lintian</systemitem> reports an erroneous
3218     diagnostics for a case when the policy allows exceptions to some rule, you can
3219     use <filename><replaceable>package</replaceable>.lintian-overrides</filename>
3220     or <filename>source/lintian-overrides</filename> to quiet it. Please read
3221 osamu 8639 <ulink url="&lintian-doc;">Lintian User's Manual</ulink> and refrain
3222 osamu 8601 from abusing this.
3223     </para>
3224     <para>
3225     <filename><replaceable>package</replaceable>.lintian-overrides</filename> is
3226     for the binary package named as <systemitem role="package"><replaceable>package</replaceable></systemitem> and is installed
3227     into
3228     <filename>usr/share/lintian/overrides/<replaceable>package</replaceable></filename>
3229     by the <command>dh_lintian</command> command.
3230     </para>
3231     <para>
3232     <filename>source/lintian-overrides</filename> is for the source package. This
3233     is not installed.
3234     </para>
3235     </section>
3236     <section id="manpage"><title><filename>manpage.*</filename> files</title>
3237     <para>
3238     Your program(s) should have a manual page. If they don't, you should create
3239     them. The <command>dh_make</command> command creates few template files for a
3240     manual page. These need to be copied and edited for each command without its
3241     manual page. Please make sure to remove unused templates.
3242     </para>
3243     <section id="manpage1"><title><filename>manpage.1.ex</filename> file</title>
3244     <para>
3245     Manual pages are normally written in <citerefentry>
3246     <refentrytitle>nroff</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.
3247     The <filename>manpage.1.ex</filename> template is written in
3248     <command>nroff</command>, too. See the <citerefentry>
3249     <refentrytitle>man</refentrytitle> <manvolnum>7</manvolnum> </citerefentry>
3250     manual page for a brief description of how to edit such a file.
3251     </para>
3252     <para>
3253     The final manual page file name should include the name of the program it is
3254     documenting, so we will rename it from <literal>manpage</literal> to
3255     <literal>gentoo</literal>. The file name also includes <literal>.1</literal>
3256     as the first suffix, which means it's a manual page for a user command. Be
3257     sure to verify that this section is indeed the correct one. Here's a short
3258     list of manual page sections:
3259     </para>
3260 osamu 8636 <table id="manpage-sections" pgwide="0" frame="topbot" rowsep="1" colsep="1">
3261     <title>manual page sections</title>
3262     <tgroup cols="3">
3263     <colspec colwidth="8*" align="left"/> <colspec colwidth="24*" align="left"/> <colspec colwidth="40*" align="left"/>
3264     <thead>
3265     <row> <entry>Section</entry> <entry>Description</entry> <entry>Notes</entry> </row>
3266     </thead>
3267     <tbody>
3268     <row> <entry>1</entry> <entry>User command</entry> <entry>Executable commands or scripts</entry> </row>
3269     <row> <entry>2</entry> <entry>System calls</entry> <entry>Functions provided by the kernel</entry> </row>
3270     <row> <entry>3</entry> <entry>Library calls</entry> <entry>Functions within system libraries</entry> </row>
3271 taffit-guest 8665 <row> <entry>4</entry> <entry>Special files</entry> <entry>Usually found in <filename>/dev</filename></entry> </row>
3272 osamu 8636 <row> <entry>5</entry> <entry>File formats</entry> <entry>E.g. <filename>/etc/passwd</filename>'s format</entry> </row>
3273     <row> <entry>6</entry> <entry>Games</entry> <entry>Games or other frivolous programs</entry> </row>
3274 taffit-guest 8665 <row> <entry>7</entry> <entry>Macro packages</entry> <entry>Such as <command>man</command> macros</entry> </row>
3275 osamu 8636 <row> <entry>8</entry> <entry>System administration</entry> <entry>Programs typically only run by root</entry> </row>
3276     <row> <entry>9</entry> <entry>Kernel routines</entry> <entry>Non-standard calls and internals</entry> </row>
3277     </tbody>
3278     </tgroup>
3279     </table>
3280 osamu 8601 <para>
3281     So <systemitem role="package">gentoo</systemitem>'s man page should be called
3282     <filename>gentoo.1</filename>. If there was no <filename>gentoo.1</filename>
3283     man page in the original source, you should create it by renaming the
3284     <filename>manpage.1.ex</filename> template to <filename>gentoo.1</filename> and
3285     edit it by using information from the example and from upstream docs.
3286     </para>
3287     <para>
3288     You can use the <command>help2man</command> command to generate a man page out
3289     of <literal>--help</literal> and <literal>--version</literal> output of each
3290     program, too. <footnote><para> If the command is missing
3291     <command>info</command> page but have documentation files in the
3292     <filename>/usr/share/<replaceable>package</replaceable></filename> directory,
3293     you should manually edit generated the man page created by the
3294     <command>help2man</command> command. </para> </footnote>
3295     </para>
3296     </section>
3297     <section id="manpagesgml"><title><filename>manpage.sgml.ex</filename> file</title>
3298     <para>
3299     If on the other hand you prefer writing SGML instead of
3300     <command>nroff</command>, you can use the <filename>manpage.sgml.ex</filename>
3301     template. If you do this, you have to:
3302     </para>
3303     <itemizedlist>
3304     <listitem>
3305     <para>
3306     rename the file to something like <filename>gentoo.sgml</filename>.
3307     </para>
3308     </listitem>
3309     <listitem>
3310     <para>
3311     install the <systemitem role="package">docbook-to-man</systemitem> package
3312     </para>
3313     </listitem>
3314     <listitem>
3315     <para>
3316     add <literal>docbook-to-man</literal> to the <literal>Build-Depends</literal>
3317     line in the <filename>control</filename> file
3318     </para>
3319     </listitem>
3320     <listitem>
3321     <para>
3322     add a <literal>override_dh_auto_build</literal> target to your
3323     <filename>rules</filename> file:
3324     </para>
3325     <screen>
3326     override_dh_auto_build:
3327     docbook-to-man debian/gentoo.sgml &gt; debian/gentoo.1
3328     dh_auto_build
3329     </screen>
3330     </listitem>
3331     </itemizedlist>
3332     </section>
3333     <section id="manpagexml"><title><filename>manpage.xml.ex</filename> file</title>
3334     <para>
3335     If you prefer XML over SGML, you can use the <literal>manpage.xml.ex</literal>
3336     template. If you do this, you have to:
3337     </para>
3338     <itemizedlist>
3339     <listitem>
3340     <para>
3341     rename the source file to something like <literal>gentoo.1.xml</literal>
3342     </para>
3343     </listitem>
3344     <listitem>
3345     <para>
3346     install the <systemitem role="package">docbook-xsl</systemitem> package and an
3347     XSLT processor like <systemitem role="package">xsltproc</systemitem>
3348     (recommended)
3349     </para>
3350     </listitem>
3351     <listitem>
3352     <para>
3353     add the <literal>docbook-xsl</literal>, <literal>docbook-xml</literal> and
3354     <literal>xsltproc</literal> packages to the <literal>Build-Depends</literal>
3355     line in the <literal>control</literal> file
3356     </para>
3357     </listitem>
3358     <listitem>
3359     <para>
3360     add a <literal>override_dh_auto_build</literal> target to your
3361     <filename>rules</filename> file:
3362     </para>
3363     <screen>
3364     override_dh_auto_build:
3365     xsltproc --nonet \
3366     --param make.year.ranges 1 \
3367     --param make.single.year.ranges 1 \
3368     --param man.charmap.use.subset 0 \
3369     -o debian/ \
3370     http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl\
3371     debian/gentoo.1.xml
3372     dh_auto_build
3373     </screen>
3374     </listitem>
3375     </itemizedlist>
3376     </section>
3377     </section>
3378     <section id="manpages"><title><filename><replaceable>package</replaceable>.manpages</filename> file</title>
3379     <para>
3380     If your package has manual pages, you should install them using <citerefentry>
3381     <refentrytitle>dh_installman</refentrytitle> <manvolnum>1</manvolnum>
3382     </citerefentry> by listing them in the
3383     <filename><replaceable>package</replaceable>.manpages</filename> files.
3384     </para>
3385     <para>
3386 osamu 8621 To install <filename>docs/gentoo.1</filename> for the <systemitem role="package">gentoo</systemitem> package as its manpage, you create a
3387 osamu 8650 <filename>gentoo.manpages</filename> file as the following.
3388 osamu 8601 </para>
3389     <screen>
3390     docs/gentoo.1
3391     </screen>
3392     </section>
3393     <section id="menu"><title><filename>menu</filename> file</title>
3394     <para>
3395     X Window System users usually have a window manager with a menu that can be
3396     customized to launch programs. If they have installed the Debian <systemitem role="package">menu</systemitem> package, a set of menus for every program on
3397     the system will be created for them.
3398     </para>
3399     <para>
3400     Here's the default <filename>menu.ex</filename> file that
3401 osamu 8650 <command>dh_make</command> created.
3402 osamu 8601 </para>
3403     <screen>
3404     ?package(gentoo):needs=X11|text|vc|wm \
3405     section=Applications/see-menu-manual\
3406     title=gentoo command=/usr/bin/gentoo
3407     </screen>
3408     <para>
3409     The first field after the colon character is <literal>needs</literal>, and it
3410     specifies what kind of interface the program needs. Change this to one of the
3411     listed alternatives, e.g. <literal>text</literal> or <literal>X11</literal>.
3412     </para>
3413     <para>
3414 osamu 8652 The next is <literal>section</literal>, where the menu and submenu entry
3415 osamu 8642 should appear in.
3416     <footnote><para> The current list of sections is at
3417     <ulink url="&menu-structure;">The Debian Menu sub-policy 2.1 'Preferred menu structure'</ulink>.
3418     There were a major reorganization of menu structure for <literal>squeeze</literal>.
3419     </para> </footnote>
3420 osamu 8601 </para>
3421     <para>
3422     The <literal>title</literal> field is the name of the program. You can start
3423     this one in uppercase if you like. Just keep it short.
3424     </para>
3425     <para>
3426     Finally, the <literal>command</literal> field is the command that runs the
3427     program.
3428     </para>
3429     <para>
3430     Let's change the file name to <filename>menu</filename> and change the menu
3431     entry to this:
3432     </para>
3433     <screen>
3434     ?package(gentoo): needs=X11 \
3435     section=Applications/Tools \
3436     title=Gentoo command=gentoo
3437     </screen>
3438     <para>
3439     You can also add other fields like <literal>longtitle</literal>,
3440     <literal>icon</literal>, <literal>hints</literal> etc. See <citerefentry>
3441     <refentrytitle>dh_installmenu</refentrytitle> <manvolnum>1</manvolnum>
3442     </citerefentry>, <citerefentry> <refentrytitle>menufile</refentrytitle>
3443     <manvolnum>5</manvolnum> </citerefentry>, <citerefentry>
3444     <refentrytitle>update-menus</refentrytitle> <manvolnum>1</manvolnum>
3445 osamu 8639 </citerefentry> and
3446     <ulink url="&menu-policy;">The Debian Menu sub-policy</ulink> for more
3447 osamu 8601 information.
3448     </para>
3449     </section>
3450     <section id="news"><title><filename>NEWS</filename> file</title>
3451     <para>
3452     The <citerefentry> <refentrytitle>dh_installchangelogs</refentrytitle>
3453     <manvolnum>1</manvolnum> </citerefentry> command installs this.
3454     </para>
3455     </section>
3456     <section id="maintscripts"><title><filename>{post|pre}{inst|rm}</filename> files</title>
3457     <para>
3458     These <filename>postinst</filename>, <filename>preinst</filename>,
3459     <filename>postrm</filename>, and <filename>prerm</filename> files
3460     <footnote><para> Although I used Bash short hand expression to indicate these
3461     files as <filename>{post|pre}{inst|rm}</filename> here, I recommend you to use
3462     pure POSIX (non-Bash) shell for these <emphasis>maintainer scripts</emphasis>
3463     as much as possible for the better compatibility. </para> </footnote> are
3464     called <emphasis>maintainer scripts</emphasis>. They are scripts which are put
3465     in the control area of the package and run by <command>dpkg</command> when your
3466     package is installed, upgraded or removed.
3467     </para>
3468     <para>
3469     As a novice maintainer, you should avoid any manual editing of
3470     <emphasis>maintainer scripts</emphasis> because they are problematic. For more
3471 osamu 8628 information look in the <ulink url="&policy-mantainerscripts;">Debian
3472 osamu 8601 Policy Manual, 6 'Package maintainer scripts and installation
3473     procedure'</ulink>, and take a look at these example files provided by
3474     <command>dh_make</command>.
3475     </para>
3476     <para>
3477     If you did not listen to me and made your custom <emphasis>maintainer
3478     scripts</emphasis> for a package, you should make sure to test them not only
3479     for <emphasis role="strong">install</emphasis> and <emphasis role="strong">upgrade</emphasis> but also for <emphasis role="strong">remove</emphasis> and <emphasis role="strong">purge</emphasis>.
3480     </para>
3481     <para>
3482     Upgrades to the new version should be silent and non-intrusive (existing users
3483     should not notice the upgrade except by discovering that old bugs have been
3484     fixed and there perhaps are new features).
3485     </para>
3486     <para>
3487     When the upgrade is necessarily intrusive (eg., config files scattered through
3488     various home directories with totally different structure), you may consider to
3489     set package to the safe default (e.g., disabled service) and provide proper
3490     documentations required by the policy (<filename>README.Debian</filename> and
3491     <filename>NEWS.Debian</filename>) as the last resort. Don't bother user with
3492     the <command>debconf</command> note invoked from these <emphasis>maintainer
3493     scripts</emphasis> for upgrades.
3494     </para>
3495     <para>
3496     The <systemitem role="package">ucf</systemitem> package provides
3497     <emphasis>conffile-like</emphasis> handling infrastructure to preserve user
3498     changes for files that may not be labeled <emphasis>conffiles</emphasis> such
3499     as ones managed by the <emphasis>maintainer scripts</emphasis>. This should
3500     minimize issues associated with them.
3501     </para>
3502     <para>
3503     These <emphasis>maintainer scripts</emphasis> are the Debian enhancements that
3504     explain <emphasis role="strong">why people choose Debian</emphasis>. You must
3505     be very careful not to annoy them with these.
3506     </para>
3507     </section>
3508     <section id="todo"><title><filename>TODO</filename> file</title>
3509     <para>
3510     The <citerefentry> <refentrytitle>dh_installdocs</refentrytitle>
3511     <manvolnum>1</manvolnum> </citerefentry> command installs this.
3512     </para>
3513     </section>
3514     <section id="watch"><title><filename>watch</filename> file</title>
3515     <para>
3516     The <filename>watch</filename> file format is documented in the <citerefentry>
3517     <refentrytitle>uscan</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>
3518     manpage. The <filename>watch</filename> file configures the
3519     <command>uscan</command> program (in the <systemitem role="package">devscripts</systemitem> package) to watch the site where you
3520 osamu 8628 originally got the source from. This is also used by <ulink url="&dehs;">Debian External Health Status (DEHS)</ulink>.
3521 osamu 8601 </para>
3522     <para>
3523     Here's what I put in it:
3524     </para>
3525     <screen>
3526     # watch control file for uscan
3527     version=3
3528 osamu 8628 &sf-net;/gentoo/gentoo-(.+)\.tar\.gz debian uupdate
3529 osamu 8601 </screen>
3530     <para>
3531     Normally with this <filename>watch</filename> file, the URL at
3532 osamu 8628 <literal>&sf-net;/gentoo</literal> is downloaded and searched for links of
3533 osamu 8601 the form <literal>&lt;a href=...&gt;</literal>. The base name (just the part
3534     after the final <literal>/</literal>) of these linked URLs are matched against
3535 osamu 8642 Perl regular expression (see <citerefentry> <refentrytitle>perlre</refentrytitle>
3536 osamu 8601 <manvolnum>1</manvolnum> </citerefentry>) pattern
3537     <literal>gentoo-(.+)\.tar\.gz</literal>. Out of matched files, the file with
3538     the greatest version number is downloaded and the <command>uupdate</command>
3539     program is run to create the updated source tree from them.
3540     </para>
3541     <para>
3542     Although this is true for other sites, the SourceForge download service at
3543 osamu 8642 <ulink url="&sf-net;"/> is an exception. When the
3544 osamu 8601 <filename>watch</filename> file has an URL matching with the Perl regexp
3545     <literal>^http://sf\.net/</literal>, the <command>uscan</command> program
3546 osamu 8628 substitutes it with <literal>&qa-do;watch/sf.php/</literal> and
3547 osamu 8637 then applies this rule. The URL redirector service at this <ulink url="&qa-do;"/> is designed to offer
3548 osamu 8601 a stable redirect service to the desired file for the
3549     <filename>watch</filename> file having
3550 osamu 8628 <literal>&sf-net;/<replaceable>project</replaceable>/<replaceable>tar-name</replaceable>-(.+)\.tar\.gz</literal>.
3551 osamu 8601 This solves issues related to the periodically changing URL there.
3552     </para>
3553     </section>
3554     <section id="sourcef"><title><filename>source/format</filename> file</title>
3555     <para>
3556     In the <filename>debian/source/format</filename> file, there should be a single
3557     line indicating the desired format for the source package (check <citerefentry>
3558     <refentrytitle>dpkg-source</refentrytitle> <manvolnum>1</manvolnum>
3559     </citerefentry> for an exhaustive list). After <literal>squeeze</literal>, it
3560     should say either:
3561     </para>
3562     <itemizedlist>
3563     <listitem>
3564     <para>
3565     <literal>3.0 (native)</literal> for Debian native packages or
3566     </para>
3567     </listitem>
3568     <listitem>
3569     <para>
3570     <literal>3.0 (quilt)</literal> for everything else.
3571     </para>
3572     </listitem>
3573     </itemizedlist>
3574     <para>
3575     The newer <literal>3.0 (quilt)</literal> source format records modifications in
3576     a <command>quilt</command> patch series within
3577     <filename>debian/patches</filename>. Those changes are then automatically
3578 osamu 8628 applied during extraction of the source package. <footnote><para> See <ulink url="&debsrc3;">DebSrc3.0</ulink> for the
3579 osamu 8601 summary information concerning the switch to the new <literal>3.0
3580     (quilt)</literal> and <literal>3.0 (native)</literal> source formats. </para>
3581     </footnote> The Debian modifications are simply stored in a
3582     <filename>debian.tar.gz</filename> archive containing all files under the
3583     <filename>debian</filename> directory. This new format supports inclusion of
3584     binary files such as PNG icons by the package maintainer without requiring
3585     tricks. <footnote><para> Actually, this new format also supports multiple
3586     upstream tarballs and more compression methods. These are beyond the scope of
3587     this document. </para> </footnote>
3588     </para>
3589     <para>
3590     When <command>dpkg-source</command> extracts a source package in <literal>3.0
3591     (quilt)</literal> source format, it automatically applies all patches listed in
3592     <filename>debian/patches/series</filename>. You can avoid applying patches at
3593     the end of the extraction with the <literal>--skip-patches</literal> option.
3594     </para>
3595     </section>
3596     <section id="sourcel"><title><filename>source/local-options</filename> file</title>
3597     <para>
3598     When you want to manage Debian packaging activities under a VCS, you typically
3599     create one branch (e.g. <literal>upstream</literal>) tracking the upstream
3600     source and another branch (e.g. typically <literal>master</literal> for Git)
3601     tracking the Debian package. For the latter, you usually want to have
3602     unpatched upstream source with your <filename>debian/*</filename> files for the
3603     Debian packaging to ease merging of the new upstream source.
3604     </para>
3605     <para>
3606     After you build a package, the source is normally left patched. You need to
3607 osamu 8646 unpatch it manually by running <literal>dquilt pop -a</literal> before
3608 osamu 8601 committing to the <literal>master</literal> branch. You can automate this by
3609     adding the optional <filename>debian/source/local-options</filename> file
3610     containing <literal>unapply-patches</literal>. This file is not included in
3611     the generated source package and changes the local build behavior only. This
3612     file may contain <literal>abort-on-upstream-changes</literal>, too (see
3613     <citerefentry> <refentrytitle>dpkg-source</refentrytitle>
3614     <manvolnum>1</manvolnum> </citerefentry>).
3615     </para>
3616 osamu 8624 <screen>
3617     unapply-patches
3618     abort-on-upstream-changes
3619     </screen>
3620 osamu 8601 </section>
3621 osamu 8624 <section id="sourceopt"><title><filename>source/options</filename> file</title>
3622     <para>
3623 osamu 8637 The autogenerated files in the source tree can be quite annoying for packaging
3624     since they generate meaningless large patch files. There are custom modules
3625     such as <command>dh_autoreconf</command> to ease this problem as described in
3626     <xref linkend="customrules"/>.
3627     </para>
3628     <para>
3629 osamu 8652 You can provide a Perl regular expression to the
3630     <literal>--extend-diff-ignore</literal> option argument of <citerefentry>
3631 osamu 8624 <refentrytitle>dpkg-source</refentrytitle><manvolnum>1</manvolnum>
3632 osamu 8637 </citerefentry> to ignore changes made to the autogenerated files while
3633     creating the source package.
3634 osamu 8624 </para>
3635 osamu 8631 <para>
3636 osamu 8637 You can store such <command>dpkg-source</command> option argument in the
3637     <filename>source/options</filename> file of the source package as the generic
3638     solution to address this problem of the autogenerated files. The following
3639 taffit-guest 8665 will skip creating patch files for <filename>config.sub</filename>,
3640 osamu 8637 <filename>config.guess</filename> and <filename>Makefile</filename>.
3641 osamu 8631 </para>
3642 osamu 8624 <screen>
3643     extend-diff-ignore = "(^|/)(config\.sub|config\.guess|Makefile)$"
3644     </screen>
3645     </section>
3646 osamu 8601 <section id="patches"><title><filename>patches/*</filename> files</title>
3647     <para>
3648     The old <literal>1.0</literal> source format created a single large
3649     <filename>diff.gz</filename> file which contains package maintenance files in
3650     <filename>debian</filename> and patch files to the source. Such a package is a
3651     bit cumbersome to inspect and understand for each source tree modification
3652     later. This is not so nice.
3653     </para>
3654     <para>
3655     The newer <literal>3.0 (quilt)</literal> source format stores patches in
3656     <filename>debian/patches/*</filename> files using the <command>quilt</command>
3657     command. These patches and other package data which are all constrained under
3658     the <filename>debian</filename> directory are packaged as the
3659     <filename>debian.tar.gz</filename> file. Since the
3660     <command>dpkg-source</command> command can handle <command>quilt</command>
3661     formatted patch data in the <literal>3.0 (quilt)</literal> source without the
3662     <systemitem role="package">quilt</systemitem> package, it does not need to
3663     <literal>Build-Depends</literal> on the <systemitem role="package">quilt</systemitem> package. <footnote><para> Several methods
3664     for the patch set maintenance have been proposed and are in use with Debian
3665     packages. The <command>quilt</command> system is the preferred maintenance
3666     system in use. Other ones are <command>dpatch</command>,
3667     <command>dbs</command>, <command>cdbs</command>, etc. Many of these keep such
3668     patches as <filename>debian/patches/*</filename> files. </para> </footnote>
3669     </para>
3670     <para>
3671     The <command>quilt</command> command is explained in <citerefentry>
3672     <refentrytitle>quilt</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.
3673     It records modifications to the source as a stack of <literal>-p1</literal>
3674     patch files in the <filename>debian/patches</filename> directory and the source
3675     tree is untouched outside of the <filename>debian</filename> directory. The
3676     order of these patches are recorded in the
3677     <filename>debian/patches/series</filename> file. You can apply (=push),
3678     un-apply (=pop), and refresh patches easily. <footnote><para> If you are
3679     asking a sponsor to upload your package, this kind of clear separation and
3680     documentation of your changes are very important to expedite the package review
3681     by your sponsor. </para> </footnote>
3682     </para>
3683     <para>
3684 taffit-guest 8665 For <xref linkend="modify"/>, we created 3 patches in
3685 osamu 8601 <filename>debian/patches</filename>.
3686     </para>
3687     <para>
3688     Since Debian patches are located in <filename>debian/patches</filename>, please
3689 osamu 8646 make sure to setup the <command>dquilt</command> command properly as described
3690 taffit-guest 8665 in <xref linkend="quiltrc"/>.
3691 osamu 8601 </para>
3692     <para>
3693     When someone (including yourself) provides you with a patch
3694     <filename><replaceable>foo</replaceable>.patch</filename> to the source later,
3695     then the modification of a <literal>3.0 (quilt)</literal> source package is
3696     quite simple:
3697     </para>
3698     <screen>
3699     $ dpkg-source -x gentoo_0.9.12.dsc
3700     $ cd gentoo-0.9.12
3701 osamu 8646 $ dquilt import ../<replaceable>foo</replaceable>.patch
3702     $ dquilt push
3703     $ dquilt refresh
3704     $ dquilt header -e
3705 osamu 8601 ... describe patch
3706     </screen>
3707     <para>
3708     The patches stored in the newer <literal>3.0 (quilt)</literal> source format
3709 osamu 8646 must be <emphasis>fuzz</emphasis> free. You should ensure it as <literal>dquilt
3710     pop -a; while dquilt push; do dquilt refresh; done</literal>.
3711 osamu 8601 </para>
3712     </section>
3713     </chapter>
3714     <chapter id="build"><title>Building the package</title>
3715     <para>
3716     We should now be ready to build the package.
3717     </para>
3718     <section id="completebuild"><title>Complete (re)build</title>
3719     <para>
3720     In order to properly make complete (re)build of a package, you have to ensure
3721     to install
3722     </para>
3723     <itemizedlist>
3724     <listitem>
3725     <para>
3726     the <systemitem role="package">build-essential</systemitem> package,
3727     </para>
3728     </listitem>
3729     <listitem>
3730     <para>
3731 taffit-guest 8665 packages listed in the <literal>Build-Depends</literal> field (see <xref linkend="control"/>), and
3732 osamu 8601 </para>
3733     </listitem>
3734     <listitem>
3735     <para>
3736 taffit-guest 8665 packages listed in the <literal>Build-Depends-indep</literal> field (see <xref linkend="control"/>).
3737 osamu 8601 </para>
3738     </listitem>
3739     </itemizedlist>
3740     <para>
3741     Then you issue the following command in the source directory:
3742     </para>
3743     <screen>
3744     $ dpkg-buildpackage
3745     </screen>
3746     <para>
3747     This will do everything to make full binary and source packages for you. It
3748     will:
3749     </para>
3750     <itemizedlist>
3751     <listitem>
3752     <para>
3753     clean the source tree (<literal>debian/rules clean</literal>)
3754     </para>
3755     </listitem>
3756     <listitem>
3757     <para>
3758     build the source package (<literal>dpkg-source -b</literal>)
3759     </para>
3760     </listitem>
3761     <listitem>
3762     <para>
3763     build the program (<literal>debian/rules build</literal>)
3764     </para>
3765     </listitem>
3766     <listitem>
3767     <para>
3768     build binary packages (<literal>fakeroot debian/rules binary</literal>)
3769     </para>
3770     </listitem>
3771     <listitem>
3772     <para>
3773     sign the source <filename>.dsc</filename> file, using <command>gpg</command>
3774     </para>
3775     </listitem>
3776     <listitem>
3777     <para>
3778     create and sign the upload <filename>.changes</filename> file, using
3779     <command>dpkg-genchanges</command> and <command>gpg</command>
3780     </para>
3781     </listitem>
3782     </itemizedlist>
3783     <para>
3784     The only input that will be required of you is your GPG secret pass phrase,
3785     twice.
3786 osamu 8622 <footnote><para>
3787 taffit-guest 8665 This GPG key must be signed by a Debian developer to get connected to the web
3788 osamu 8680 of trust and must be registered to <ulink url="&keyring;">the Debian
3789 osamu 8652 keyring</ulink>. This enables your uploaded packages to be accepted to the
3790     Debian archives. See
3791 osamu 8640 <ulink url="&keycreate;">Creating a new GPG key</ulink> and
3792 osamu 8628 <ulink url="&keysigning; ">Debian Wiki on Keysigning</ulink>.
3793 osamu 8622 </para></footnote>
3794 osamu 8601 </para>
3795     <para>
3796     After all this is done, you will see the following files in the directory above
3797     (<filename>~/gentoo</filename>):
3798     </para>
3799     <itemizedlist>
3800     <listitem>
3801     <para>
3802     <filename>gentoo_0.9.12.orig.tar.gz</filename>
3803     </para>
3804     <para>
3805     This is the original source code tarball, merely renamed to the above so that
3806     it adheres to the Debian standard. Note that this was created initially by the
3807     <literal>dh_make -f ../gentoo-0.9.12.tar.gz</literal>.
3808     </para>
3809     </listitem>
3810     <listitem>
3811     <para>
3812     <filename>gentoo_0.9.12-1.dsc</filename>
3813     </para>
3814     <para>
3815     This is a summary of the contents of the source code. The file is generated
3816     from your <filename>control</filename> file, and is used when unpacking the
3817     source with <citerefentry> <refentrytitle>dpkg-source</refentrytitle>
3818     <manvolnum>1</manvolnum> </citerefentry>. This file is GPG signed, so that
3819     people can be sure that it's really yours.
3820     </para>
3821     </listitem>
3822     <listitem>
3823     <para>
3824     <filename>gentoo_0.9.12-1.debian.tar.gz</filename>
3825     </para>
3826     <para>
3827     This compressed tarball contains your <filename>debian</filename> directory
3828     contents. Each and every addition you made to the original source code are
3829     stored as <command>quilt</command> patches in
3830     <filename>debian/patches</filename>.
3831     </para>
3832     <para>
3833     If someone else wants to re-create your package from scratch, they can easily
3834     do so using the above three files. The extraction procedure is trivial: just
3835     copy the three files somewhere else and run <literal>dpkg-source -x
3836     gentoo_0.9.12-1.dsc</literal>. <footnote><para> You can avoid applying
3837     <command>quilt</command> patches in the <literal>3.0 (quilt)</literal> source
3838     format at the end of the extraction with the <literal>--skip-patches</literal>
3839 osamu 8646 option. Alternatively, you can run <literal>dquilt pop -a</literal> after
3840 osamu 8601 normal operation. </para> </footnote>
3841     </para>
3842     </listitem>
3843     <listitem>
3844     <para>
3845     <filename>gentoo_0.9.12-1_i386.deb</filename>
3846     </para>
3847     <para>
3848     This is your completed binary package. You can use <command>dpkg</command> to
3849     install and remove this just like any other package.
3850     </para>
3851     </listitem>
3852     <listitem>
3853     <para>
3854     <filename>gentoo_0.9.12-1_i386.changes</filename>
3855     </para>
3856     <para>
3857     This file describes all the changes made in the current package revision, and
3858     it is used by the Debian FTP archive maintenance programs to install the binary
3859     and source packages in it. It is partly generated from the
3860     <filename>changelog</filename> file and the <filename>.dsc</filename> file.
3861     This file is GPG signed, so that people can be sure that it's really yours.
3862     </para>
3863     <para>
3864     As you keep working on the package, behavior will change and new features will
3865     be added. People downloading your package can look at this file and quickly
3866     see what has changed. Debian archive maintenance programs will also post the
3867 osamu 8628 contents of this file to the <ulink url="&debian-devel-announce-ldo;">debian-devel-announce@lists.debian.org</ulink>
3868 osamu 8601 mailing list.
3869     </para>
3870     </listitem>
3871     </itemizedlist>
3872     <para>
3873     The long strings of numbers in the <filename>.dsc</filename> and
3874     <filename>.changes</filename> files are MD5/SHA1/SHA256 checksums for the files
3875     mentioned. A person downloading your files can test them with <citerefentry>
3876     <refentrytitle>md5sum</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>,
3877     <citerefentry> <refentrytitle>sha1sum</refentrytitle> <manvolnum>1</manvolnum>
3878     </citerefentry>, or <citerefentry> <refentrytitle>sha256sum</refentrytitle>
3879     <manvolnum>1</manvolnum> </citerefentry> and if the numbers don't match,
3880     they'll know the file is corrupt or has been tampered with.
3881     </para>
3882     </section>
3883     <section id="autobuilder"><title>Autobuilder</title>
3884     <para>
3885 osamu 8628 Debian supports many <ulink url="&ports;">ports</ulink>
3886     with the <ulink url="&buildd;">autobuilder
3887 osamu 8601 network</ulink> running <command>buildd</command> daemons on many different
3888     architecture computers. Although you do not need to do this by yourself, you
3889     should be aware of what will happen on your packages. Let's look into roughly
3890     how your packages are rebuild for many different architectures by them.
3891     <footnote><para> The actual autobuilder system involves much more complicated
3892     schemes than the one documented here. Such details are beyond the scope of
3893     this document. </para> </footnote>
3894     </para>
3895     <para>
3896     For <literal>Architecture: any</literal> packages, the autobuilder system
3897     rebuild them. It ensures to install
3898     </para>
3899     <itemizedlist>
3900     <listitem>
3901     <para>
3902     the <systemitem role="package">build-essential</systemitem> package, and
3903     </para>
3904     </listitem>
3905     <listitem>
3906     <para>
3907 taffit-guest 8665 packages listed in the <literal>Build-Depends</literal> field (see <xref linkend="control"/>).
3908 osamu 8601 </para>
3909     </listitem>
3910     </itemizedlist>
3911     <para>
3912     Then it issues the following command in the source directory:
3913     </para>
3914     <screen>
3915     $ dpkg-buildpackage -B
3916     </screen>
3917     <para>
3918     This will do everything to make architecture dependent binary packages on
3919     another architecture. It will:
3920     </para>
3921     <itemizedlist>
3922     <listitem>
3923     <para>
3924     clean the source tree (<literal>debian/rules clean</literal>)
3925     </para>
3926     </listitem>
3927     <listitem>
3928     <para>
3929     build the program (<literal>debian/rules build</literal>)
3930     </para>
3931     </listitem>
3932     <listitem>
3933     <para>
3934     build architecture dependent binary packages (<literal>fakeroot debian/rules
3935     binary-arch</literal>)
3936     </para>
3937     </listitem>
3938     <listitem>
3939     <para>
3940     sign the source <filename>.dsc</filename> file, using <command>gpg</command>
3941     </para>
3942     </listitem>
3943     <listitem>
3944     <para>
3945     create and sign the upload <filename>.changes</filename> file, using
3946     <command>dpkg-genchanges</command> and <command>gpg</command>
3947     </para>
3948     </listitem>
3949     </itemizedlist>
3950     <para>
3951     This is why you see your package for other architectures.
3952     </para>
3953     <para>
3954     Although packages listed in the <literal>Build-Depends-indep</literal> field
3955 taffit-guest 8665 are required to be installed for the normal packaging by us (see <xref linkend="completebuild"/>), they are not required to be installed for the
3956 osamu 8601 autobuilder system since it build only architecture dependent binary packages.
3957     <footnote><para> Unlike under the <systemitem role="package">pbuilder</systemitem> package, the <command>chroot</command>
3958<