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