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