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