/[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 8732 - (show annotations) (download)
Tue Apr 26 15:51:53 2011 UTC (2 years ago) by osamu
File size: 207772 byte(s)
informaltable
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- -*- DocBook -*- -->
3 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 <!ENTITY % trans SYSTEM "po4a/maint-guide.en.ent"> %trans;
6 <!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 <!--
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 <title>Debian New Maintainers' Guide</title>
30 <bookinfo>
31 <authorgroup>
32 <!-- 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 <!-- translator credits in po4a/translator.*.ent -->
36 &othercredit;
37 </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 <itemizedlist>
53 <listitem>
54 <para>
55 Making a Debian Package (AKA the Debmake Manual), copyright © 1997 Jaldhar
56 Vyas.
57 </para>
58 </listitem>
59 <listitem>
60 <para>
61 The New-Maintainer's Debian Packaging Howto, copyright © 1997 Will Lowe.
62 </para>
63 </listitem>
64 </itemizedlist>
65 </legalnotice>
66 <!-- toc -->
67 </bookinfo>
68 <chapter id="start"><title>Getting started The Right Way</title>
69 <para>
70 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 </para>
77 <para>
78 This document has been updated for the Debian <literal>&base-release;</literal>
79 release.
80 <footnote><para> The document assumes you are using a
81 <literal>&base-release;</literal> or newer system. If you need to follow this
82 text in an older system (including an older Ubuntu system etc.), you must
83 install backported <systemitem role="package">dpkg</systemitem> and
84 <systemitem role="package">debhelper</systemitem> packages, at least.
85 </para> </footnote>
86 </para>
87 <para>
88 One of the things that makes Debian such a top-notch distribution is its
89 package system. While there is a vast quantity of software already in the
90 Debian format, sometimes you need to install software that isn't. You may be
91 wondering how you can make your own packages; and perhaps you think it is a very
92 difficult task. Well, if you are a real novice on Linux, it is hard, but if
93 you were 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 <footnote><para>
97 You can learn about the basic handling of a Debian system from the
98 <ulink url="&debref;">Debian Reference</ulink>. It contains some pointers to
99 learn about Unix programming, too.
100 </para></footnote>
101 </para>
102 <para>
103 One thing is certain, though: to properly create and maintain Debian packages
104 takes many hours. Make no mistake, for our system to work the maintainers
105 need to be both technically competent and diligent.
106 </para>
107 <para>
108 If you need some help on packaging, please read <xref linkend="helpme"/>.
109 </para>
110 <para>
111 Newer versions of this document should always be available online at
112 <ulink url="&maint-guide;"/> and in the
113 <systemitem role="package">maint-guide</systemitem> package.
114 The translations may be available in packages such as
115 <systemitem role="package">maint-guide-es</systemitem>.
116 Please note that this documentation may be slightly outdated.
117 </para>
118 <para>
119 Since this is a tutorial, I choose to explain each detailed step for some
120 important topics. Some of them may look irrelevant to you. Please be patient.
121 I have also intentionally skipped some corner cases and provided only pointers
122 to keep this document simple.
123 </para>
124 <section id="socialdynamism"><title>Social dynamics of Debian</title>
125 <para>
126 Here are some observations of Debian's social dynamics, presented in the hope
127 that it will prepare you for interactions with Debian.
128 </para>
129 <itemizedlist>
130 <listitem><para>We all are volunteers.</para>
131 <itemizedlist>
132 <listitem><para>You cannot impose on others what to do.</para></listitem>
133 <listitem><para>You should be motivated to do things by yourself.</para></listitem>
134 </itemizedlist></listitem>
135 <listitem><para>Friendly cooperation is the driving force.</para>
136 <itemizedlist>
137 <listitem><para>Your contribution should not overstrain others.</para></listitem>
138 <listitem><para>Your contribution is valuable only when others appreciate it.</para></listitem>
139 </itemizedlist></listitem>
140 <listitem><para>Debian is not your school where you get automatic attention of teachers.</para>
141 <itemizedlist>
142 <listitem><para>You should be able to learn many things by yourself.</para></listitem>
143 <listitem><para>Attention from other volunteers is a very scarce resource.</para></listitem>
144 </itemizedlist></listitem>
145 <listitem><para>Debian is constantly improving.</para>
146 <itemizedlist>
147 <listitem><para>You are expected to make high quality packages.</para></listitem>
148 <listitem><para>You should adapt yourself to change.</para></listitem>
149 </itemizedlist></listitem>
150 </itemizedlist>
151 <para>
152 There are several types of people interacting around Debian with different
153 roles.
154 </para>
155 <itemizedlist>
156 <listitem>
157 <para>
158 <emphasis role="strong">upstream author</emphasis>: the person who made the
159 original program.
160 </para>
161 </listitem>
162 <listitem>
163 <para>
164 <emphasis role="strong">upstream maintainer</emphasis>: the person who
165 currently maintains the program.
166 </para>
167 </listitem>
168 <listitem>
169 <para>
170 <emphasis role="strong">maintainer</emphasis>: the person making the Debian
171 package of the program.
172 </para>
173 </listitem>
174 <listitem>
175 <para>
176 <emphasis role="strong">sponsor</emphasis>: a person who helps maintainers to
177 upload packages to the official Debian package archive (after checking their
178 contents).
179 </para>
180 </listitem>
181 <listitem>
182 <para>
183 <emphasis role="strong">mentor</emphasis>: a person who helps novice
184 maintainers with packaging etc.
185 </para>
186 </listitem>
187 <listitem>
188 <para>
189 <emphasis role="strong">Debian Developer</emphasis> (DD): a member of
190 the Debian project with full upload rights to the official Debian package
191 archive.
192 </para>
193 </listitem>
194 <listitem>
195 <para>
196 <emphasis role="strong">Debian Maintainer</emphasis> (DM): a person with
197 limited upload rights to the official Debian package archive.
198 </para>
199 </listitem>
200 </itemizedlist>
201 <para>
202 Please note that you cannot become an official
203 <emphasis role="strong">Debian Developer</emphasis> (DD) overnight, because it
204 takes more than technical skill. Please do not be discouraged by this. If it
205 is useful to others, you can still upload your package either as a
206 <emphasis role="strong">maintainer</emphasis> through a
207 <emphasis role="strong">sponsor</emphasis> or as a
208 <emphasis role="strong">Debian Maintainer</emphasis>.
209 </para>
210 <para>
211 Please note that you do not need to create any new package to become an
212 official Debian Developer. Contributing to the existing packages can provide a
213 path to becoming an official Debian Developer too. There are many packages
214 waiting for good maintainers (see <xref linkend="choose"/>).
215 </para>
216 <para>
217 Since we focus only on technical aspects of packaging in this document,
218 please refer to the following to learn how Debian functions and how you can get involved.
219 </para>
220 <itemizedlist>
221 <listitem><para><ulink url="&logiciellibre;">Debian: 17 years of Free Software, "do-ocracy", and democracy</ulink> (Introductory slides) </para> </listitem>
222 <listitem><para><ulink url="&debianorghelp;">How can you help Debian?</ulink> (official) </para> </listitem>
223 <listitem><para><ulink url="&debianfaqhelp;">The Debian GNU/Linux FAQ, Chapter 13 - 'Contributing to the Debian Project'</ulink> (semi-official) </para> </listitem>
224 <listitem><para><ulink url="&debianwikihelp;">Debian Wiki, HelpDebian</ulink> (supplemental) </para> </listitem>
225 <listitem><para><ulink url="&nm-do;">Debian New Maintainer site</ulink> (official) </para> </listitem>
226 <listitem><para><ulink url="&debianmentorfaq;">Debian Mentors FAQ</ulink> (supplemental) </para> </listitem>
227 </itemizedlist>
228 </section>
229 <section id="needprogs"><title>Programs you need for development</title>
230 <para>
231 Before you start anything, you should make sure that you have properly
232 installed some additional packages needed for development. Note that the list
233 doesn't contain any packages marked <literal>essential</literal> or
234 <literal>required</literal> - we expect that you have those installed already.
235 </para>
236 <para>
237 The following packages come with the standard Debian installation, so you
238 probably have them already (along with any additional packages they depend on).
239 Still, you should check it with <literal>aptitude show
240 <replaceable>package</replaceable></literal>
241 or with <literal>dpkg -s <replaceable>package</replaceable></literal>.
242 </para>
243 <para>
244 The most important package to install on your development system is the
245 <systemitem role="package">build-essential</systemitem> package. Once you try
246 to install that, it will <emphasis>pull in</emphasis> other packages required to
247 have a basic build environment.
248 </para>
249 <para>
250 For some types of packages, that is all you will require; however, there is
251 another set of packages that while not essential for all package builds are
252 useful to have installed or may be required by your package:
253 </para>
254 <itemizedlist>
255 <listitem>
256 <para>
257 <systemitem role="package">autoconf</systemitem>, <systemitem
258 role="package">automake</systemitem>, and <systemitem
259 role="package">autotools-dev</systemitem> - many newer programs use configure
260 scripts and <filename>Makefile</filename> files preprocessed with the help of
261 programs like these (see <literal>info autoconf</literal>, <literal>info
262 automake</literal>). <systemitem role="package">autotools-dev</systemitem>
263 keeps up-to-date versions of certain auto files and has documentation about the
264 best way to use those files.
265 </para>
266 </listitem>
267 <listitem>
268 <para>
269 <systemitem role="package">debhelper</systemitem> and
270 <systemitem role="package">dh-make</systemitem> -
271 <systemitem role="package">dh-make</systemitem> is necessary to create
272 the skeleton of our example package, and it will use some of the
273 <systemitem role="package">debhelper</systemitem> tools for creating
274 packages. They are not essential for this purpose, but are
275 <emphasis>highly</emphasis> recommended for new maintainers. It makes
276 the whole process very much easier to start, and to control afterwards.
277 (See <citerefentry> <refentrytitle>dh_make</refentrytitle>
278 <manvolnum>1</manvolnum> </citerefentry>, <citerefentry>
279 <refentrytitle>debhelper</refentrytitle> <manvolnum>1</manvolnum>
280 </citerefentry>.) <footnote><para> There are also some more specialized
281 but similar packages such as
282 <systemitem role="package">dh-make-perl</systemitem>,
283 <systemitem role="package">dh-make-php</systemitem>, etc. </para>
284 </footnote>
285 </para>
286 </listitem>
287 <listitem>
288 <para>
289 <systemitem role="package">devscripts</systemitem> - this package contains some
290 useful scripts that can be helpful for maintainers, but they are also
291 not necessary for building packages. Packages recommended and suggested
292 by this package are worth looking into. (See <ulink url="&devscripts-readme;"/>.)
293 </para>
294 </listitem>
295 <listitem>
296 <para>
297 <systemitem role="package">fakeroot</systemitem> - this utility lets you
298 emulate being root which is necessary for some parts of the build process.
299 (See <citerefentry> <refentrytitle>fakeroot</refentrytitle>
300 <manvolnum>1</manvolnum> </citerefentry>.)
301 </para>
302 </listitem>
303 <listitem>
304 <para>
305 <systemitem role="package">file</systemitem> - this handy program can determine
306 what type a file is. (See <citerefentry> <refentrytitle>file</refentrytitle>
307 <manvolnum>1</manvolnum> </citerefentry>.)
308 </para>
309 </listitem>
310 <listitem>
311 <para>
312 <systemitem role="package">gfortran</systemitem> - the GNU Fortran 95 compiler,
313 necessary if your program is written in Fortran. (See <citerefentry>
314 <refentrytitle>gfortran</refentrytitle> <manvolnum>1</manvolnum>
315 </citerefentry>.)
316 </para>
317 </listitem>
318 <listitem>
319 <para>
320 <systemitem role="package">git</systemitem> - this package provides a popular
321 version control system designed to handle very large projects with speed and
322 efficiency; it is used for many high profile open source projects, most notably
323 the Linux kernel. (See <citerefentry> <refentrytitle>git</refentrytitle>
324 <manvolnum>1</manvolnum> </citerefentry>,
325 <ulink url="&git-doc;">git Manual</ulink>.)
326 </para>
327 </listitem>
328 <listitem>
329 <para>
330 <systemitem role="package">gnupg</systemitem> - a tool that enables you to
331 digitally <emphasis>sign</emphasis> packages. This is especially important if
332 you want to distribute it to other people, and you will certainly be doing that
333 when your work gets included in the Debian distribution. (See <citerefentry>
334 <refentrytitle>gpg</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.)
335 </para>
336 </listitem>
337 <listitem>
338 <para>
339 <systemitem role="package">gpc</systemitem> - the GNU Pascal compiler,
340 necessary if your program is written in Pascal. Worthy of note here is
341 <systemitem role="package">fp-compiler</systemitem>, the Free Pascal Compiler,
342 which is also good at this task. (See <citerefentry>
343 <refentrytitle>gpc</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>,
344 <citerefentry> <refentrytitle>ppc386</refentrytitle>
345 <manvolnum>1</manvolnum> </citerefentry>.)
346 </para>
347 </listitem>
348 <listitem>
349 <para>
350 <systemitem role="package">lintian</systemitem> - this is the Debian package
351 checker, which can let you know of any common mistakes after you build the
352 package, and explains the errors found. (See <citerefentry>
353 <refentrytitle>lintian</refentrytitle> <manvolnum>1</manvolnum>
354 </citerefentry>,
355 <ulink url="&lintian-doc;">Lintian User's Manual</ulink>.)
356 </para>
357 </listitem>
358 <listitem>
359 <para>
360 <systemitem role="package">patch</systemitem> - this very useful utility will
361 take a file containing a difference listing (produced by the
362 <command>diff</command> program) and apply it to the original file, producing a
363 patched version. (See <citerefentry> <refentrytitle>patch</refentrytitle>
364 <manvolnum>1</manvolnum> </citerefentry>.)
365 </para>
366 </listitem>
367 <listitem>
368 <para>
369 <systemitem role="package">patchutils</systemitem> - this package contains some
370 utilities to work with patches such as the <command>lsdiff</command>,
371 <command>interdiff</command> and <command>filterdiff</command> commands.
372 </para>
373 </listitem>
374 <listitem>
375 <para>
376 <systemitem role="package">pbuilder</systemitem> - this package contains
377 programs which are used for creating and maintaining <command>chroot</command>
378 environment. Building Debian package in this <command>chroot</command>
379 environment verifies the proper build dependency and avoid FTBFS (Fails To
380 Build From Source) bugs. (see <citerefentry>
381 <refentrytitle>pbuilder</refentrytitle> <manvolnum>8</manvolnum>
382 </citerefentry> and <citerefentry> <refentrytitle>pdebuild</refentrytitle>
383 <manvolnum>1</manvolnum> </citerefentry>)
384 </para>
385 </listitem>
386 <listitem>
387 <para>
388 <systemitem role="package">perl</systemitem> - Perl is one of the most used
389 interpreted scripting languages on today's Unix-like systems, often referred to
390 as Unix's Swiss Army Chainsaw. (See <citerefentry>
391 <refentrytitle>perl</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.)
392 </para>
393 </listitem>
394 <listitem>
395 <para>
396 <systemitem role="package">python</systemitem> - Python is another of the most
397 used interpreted scripting languages on the Debian system, combining
398 remarkable power with very clear syntax. (See <citerefentry>
399 <refentrytitle>python</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.)
400 </para>
401 </listitem>
402 <listitem>
403 <para>
404 <systemitem role="package">quilt</systemitem> - this package helps you to
405 manage large numbers of patches by keeping track of the changes each patch
406 makes. Patches can be applied, un-applied, refreshed, and more. (See
407 <citerefentry> <refentrytitle>quilt</refentrytitle> <manvolnum>1</manvolnum></citerefentry>,
408 <ulink url="&quilt-pdf;">quilt.pdf</ulink>.)
409 </para>
410 </listitem>
411 <listitem>
412 <para>
413 <systemitem role="package">xutils-dev</systemitem> - some programs, usually
414 those made for X11, also use these programs to generate
415 <filename>Makefile</filename> files from sets of macro functions. (See
416 <citerefentry> <refentrytitle>imake</refentrytitle> <manvolnum>1</manvolnum>
417 </citerefentry>, <citerefentry> <refentrytitle>xmkmf</refentrytitle>
418 <manvolnum>1</manvolnum> </citerefentry>.)
419 </para>
420 </listitem>
421 </itemizedlist>
422 <para>
423 The short descriptions that are given above only serve to introduce you to what
424 each package does. Before continuing please read the documentation
425 of each relevant program including ones installed through the package dependency such as
426 <command>make</command>, at least, for the standard usage. It may seem like heavy
427 going now, but later on you'll be <emphasis>very</emphasis> glad you read it.
428 If you have specific questions later, I would suggest re-reading the documents
429 mentioned above.
430 </para>
431 </section>
432 <section id="needdocs"><title>Documentation needed for development</title>
433 <para>
434 The following is the <emphasis>very important</emphasis> documentation which
435 you should read along with this document:
436 </para>
437 <itemizedlist>
438 <listitem>
439 <para>
440 <systemitem role="package">debian-policy</systemitem> - the <ulink url="&debian-policy;">Debian Policy
441 Manual</ulink> includes explanations of the structure and contents of the
442 Debian archive, several OS design issues, the <ulink url="&fhs;">Filesystem Hierarchy Standard</ulink>
443 (FHS, which says where each file and directory should be), etc. For you, the most
444 important thing is that it describes requirements that each package must
445 satisfy to be included in the distribution (see the local copies of
446 <ulink url="&policy-pdf;">policy.pdf</ulink> and <ulink url="&fhs-pdf;">fhs-2.3.pdf</ulink>).
447 </para>
448 </listitem>
449 <listitem>
450 <para>
451 <systemitem role="package">developers-reference</systemitem>
452 - the <ulink url="&developers-reference;">Debian Developer's Reference</ulink>
453 describes all matters not specifically about the technical
454 details of packaging, like the structure of the archive, how to rename, orphan,
455 or adopt packages, how to do NMUs, how to manage bugs, best packaging practices,
456 when and where to upload etc. (See the local copy of
457 <ulink url="&developers-refpdf;">developers-reference.pdf</ulink>.)
458 </para>
459 </listitem>
460 </itemizedlist>
461 <para>
462 The following is the <emphasis>important</emphasis> documentation which
463 you should read along with this document:
464 </para>
465 <itemizedlist>
466 <listitem>
467 <para>
468 <ulink url="&autotools-tutorial;">Autotools
469 Tutorial</ulink> provides a very good tutorial for <ulink url="&gnu-build-system;">the GNU Build System known
470 as the GNU Autotools</ulink> whose most important components are Autoconf,
471 Automake, Libtool, and gettext.
472 </para>
473 </listitem>
474 <listitem>
475 <para>
476 <systemitem role="package">gnu-standards</systemitem> - this package contains
477 two pieces of documentation from the GNU project:
478 <ulink url="&gnu-standard;">GNU Coding Standards</ulink>, and
479 <ulink url="&gnu-maintainer;">Information for Maintainers of GNU Software</ulink>.
480 Although Debian does not require these to
481 be followed, these are still helpful as guidelines and common sense.
482 (See the local copies of
483 <ulink url="&gnu-standard-pdf;">standards.pdf</ulink> and
484 <ulink url="&gnu-maintainer-pdf;">maintain.pdf</ulink>.)
485 </para>
486 </listitem>
487 </itemizedlist>
488 <para>
489 If this document contradicts any of the documents mentioned above, they
490 are correct. Please file a bug report on the
491 <systemitem role="package">maint-guide</systemitem> package using
492 <command>reportbug</command>.
493 </para>
494 </section>
495 <section id="helpme"><title>Where to ask for help</title>
496 <para>
497 Before you decide to ask your question in some public place, please read the fine documentation.
498 </para>
499 <itemizedlist>
500 <listitem>
501 <para>
502 files in <filename>/usr/share/doc/<replaceable>package</replaceable></filename> for all pertinent packages
503 </para>
504 </listitem>
505 <listitem>
506 <para>
507 contents of <literal><command>man</command> <replaceable>command</replaceable></literal> for all pertinent commands
508 </para>
509 </listitem>
510 <listitem>
511 <para>
512 contents of <literal><command>info</command> <replaceable>command</replaceable></literal> for all pertinent commands
513 </para>
514 </listitem>
515 <listitem>
516 <para>
517 contents of <ulink url="&debian-mentors-ldo;">debian-mentors@lists.debian.org mailing list archive</ulink>
518 </para>
519 </listitem>
520 <listitem>
521 <para>
522 contents of <ulink url="&debian-devel-ldo;">debian-devel@lists.debian.org mailing list archive</ulink>
523 </para>
524 </listitem>
525 </itemizedlist>
526 <para>
527 You can use web search engines more effectively by including search strings
528 such as <literal>site:lists.debian.org</literal> to limit the domain.
529 </para>
530 <para>
531 Making a small test package is a good way to learn details of packaging.
532 Inspecting existing well maintained packages is the best way to learn how other
533 people make packages.
534 </para>
535 <para>
536 If you still have questions about packaging that you couldn't find answers to
537 in the available documentation and web resources, you can ask them interactively.
538 </para>
539 <itemizedlist>
540 <listitem>
541 <para>
542 <ulink url="&debian-mentors-ldo;">debian-mentors@lists.debian.org mailing list</ulink>. (This mailing list is for the novice.)
543 </para>
544 </listitem>
545 <listitem>
546 <para>
547 <ulink url="&debian-devel-ldo;">debian-devel@lists.debian.org mailing list</ulink>. (This mailing list is for the expert.)
548 </para>
549 </listitem>
550 <listitem>
551 <para>
552 <ulink url="&irc-debian;">IRC</ulink> such as <literal>#debian-mentors</literal>.
553 </para>
554 </listitem>
555 </itemizedlist>
556 <para>
557 The more experienced Debian developers will gladly help you, if you ask
558 properly after making your required efforts.
559 </para>
560 <para>
561 When you receive a bug report (yes, actual bug reports!), you will know that it
562 is time for you to dig into the
563 <ulink url="&bts;">Debian Bug Tracking System</ulink>
564 and read the documentation there, to be able to
565 deal with the reports efficiently. I highly recommend reading the
566 <ulink url="&devref-bug-handling;">Debian Developer's Reference, 5.8.
567 "Handling bugs"</ulink>.
568 </para>
569 <para>
570 Even if it all worked well, it's time to start praying. Why? Because in just
571 a few hours (or days) users from all around the world will start to use your
572 package, and if you made some critical error you'll get mailbombed by numerous
573 angry Debian users... Just kidding. :-)
574 </para>
575 <para>
576 Relax and be ready for bug reports, because there is a lot more work to be done
577 before your package will be fully in line with Debian policies and its best
578 practice guidelines (once again, read the <emphasis>real
579 documentation</emphasis> for details). Good luck!
580 </para>
581 </section>
582 </chapter>
583 <chapter id="first"><title>First steps</title>
584 <para>
585 Let's start by creating a package of your own (or, even better,
586 adopting an existing one).
587 </para>
588 <section id="workflow"><title>Workflow of the Debian package building</title>
589 <para>
590 If you are making a Debian package with an upstream program,
591 typical workflow of the Debian package building involves generating several
592 specifically named files for each step as the following.
593 </para>
594 <itemizedlist>
595 <listitem>
596 <para>We obtain an upstream program file usually in a compressed tar format.</para>
597 <itemizedlist>
598 <listitem><literal><replaceable>package</replaceable>-<replaceable>version</replaceable>.tar.gz</literal></listitem>
599 </itemizedlist>
600 </listitem>
601 <listitem>
602 <para>
603 We create a non-native Debian source package in the <literal>3.0 (quilt)</literal> format, which refers to the set of input files for
604 the Debian package building, by adding Debian package modifications to the upstream program under the <filename>debian</filename> directory.
605 </para>
606 <itemizedlist>
607 <listitem><literal><replaceable>package</replaceable>_<replaceable>version</replaceable>.orig.tar.gz</literal></listitem>
608 <listitem><literal><replaceable>package</replaceable>_<replaceable>version</replaceable>-<replaceable>revision</replaceable>.debian.tar.gz</literal>
609 <footnote><para>For the older non-native Debian source package in the <literal>1.0</literal> format,
610 <literal><replaceable>package</replaceable>_<replaceable>version</replaceable>-<replaceable>revision</replaceable>.diff.gz</literal>
611 is used instead. </para></footnote></listitem>
612 <listitem><literal><replaceable>package</replaceable>_<replaceable>version</replaceable>-<replaceable>revision</replaceable>.dsc</literal></listitem>
613 </itemizedlist>
614 </listitem>
615 <listitem>
616 <para>
617 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.
618 </para>
619 <itemizedlist>
620 <listitem><literal><replaceable>package</replaceable>_<replaceable>version</replaceable>-<replaceable>revision</replaceable>_<replaceable>arch</replaceable>.deb</literal></listitem>
621 </itemizedlist>
622 </listitem>
623 </itemizedlist>
624 <para>
625 Please note that the character separating
626 <literal><replaceable>package</replaceable></literal> and
627 <literal><replaceable>version</replaceable></literal> was changed from
628 <literal>-</literal> (hyphen) to <literal>_</literal> (underscore).
629 </para>
630 <para>
631 Here,
632 <literal><replaceable>package</replaceable></literal> part of the file name is substituted by the
633 <emphasis role="strong">package name</emphasis>,
634 <literal><replaceable>version</replaceable></literal> part of it is substituted by the
635 <emphasis role="strong">upstream version</emphasis>,
636 <literal><replaceable>revision</replaceable></literal> part of it is substituted by the
637 <emphasis role="strong">Debian revision</emphasis>,
638 <literal><replaceable>arch</replaceable></literal> part of it is substituted by the
639 <emphasis role="strong">package architecture</emphasis>.
640 <footnote><para>
641 The <emphasis role="strong">package name</emphasis>, <emphasis
642 role="strong">upstream version</emphasis>, and <emphasis role="strong">Debian
643 revision</emphasis> must be adjusted to comply with the Debian Policy Manual:
644 <ulink url="&policy-source;">5.6.1 Source</ulink>,
645 <ulink url="&policy-package;">5.6.7 Package</ulink>, and
646 <ulink url="&policy-version;">5.6.12 Version</ulink>.
647 The <emphasis role="strong">package architecture</emphasis> follows the
648 Debian Policy Manual: <ulink url="&policy-architecture;">5.6.8 Architecture</ulink>
649 and is automatically assigned by the package build process.</para></footnote>
650 </para>
651 <para>
652 If you are making a Debian specific package without an upstream program instead,
653 typical workflow of the Debian package building is simpler.
654 </para>
655 <itemizedlist>
656 <listitem>
657 <para>
658 We create a native Debian source package in the <literal>3.0 (quilt)</literal> format using a compressed tar format in which required files under the <filename>debian</filename> directory are also included.
659 </para>
660 <itemizedlist>
661 <listitem><literal><replaceable>package</replaceable>_<replaceable>version</replaceable>.tar.gz</literal></listitem>
662 <listitem><literal><replaceable>package</replaceable>_<replaceable>version</replaceable>.dsc</literal></listitem>
663 </itemizedlist>
664 </listitem>
665 <listitem>
666 <para>
667 We build Debian binary packages from the native Debian source package.
668 </para>
669 <itemizedlist>
670 <listitem><literal><replaceable>package</replaceable>_<replaceable>version</replaceable>_<replaceable>arch</replaceable>.deb</literal></listitem>
671 </itemizedlist>
672 </listitem>
673 </itemizedlist>
674 <para>
675 In the following, each step of this is explained with detailed examples.
676 </para>
677 </section>
678 <section id="choose"><title>Choose your program</title>
679 <para>
680 You have probably chosen the package you want to create. The first thing you
681 need to do is check if the package is in the distribution archive already by
682 using the following.
683 </para>
684 <itemizedlist>
685 <listitem>
686 <para>the <command>aptitude</command> command</para>
687 </listitem>
688 <listitem>
689 <para>the <ulink url="&packages-do;">Debian packages</ulink> web page</para>
690 </listitem>
691 <listitem>
692 <para>the <ulink url="&packages-qa-do;">Debian Package Tracking System</ulink> web page</para>
693 </listitem>
694 </itemizedlist>
695 <para>
696 If the package already exists, well, install it! :-) If it happens to be
697 <emphasis role="strong">orphaned</emphasis> (that is, if its
698 maintainer is set to <ulink url="&qa-do;">Debian QA Group</ulink>),
699 you may be able to pick it up if it's still available. You may also
700 adopt a package whose maintainer has filed a Request for Adoption
701 (<emphasis role="strong">RFA</emphasis>).<footnote> <para>See
702 <ulink url="&devref-adopt;">Debian Developer's Reference 5.9.5.
703 "Adopting a package"</ulink>.</para> </footnote>
704 </para>
705 <para>
706 There are several package ownership status resources.
707 </para>
708 <itemizedlist>
709 <listitem>
710 <para> <ulink url="&wnpp-do;">Work-Needing and Prospective Packages</ulink> </para>
711 </listitem>
712 <listitem>
713 <para> <ulink url="&wnpp-bts;">Debian Bug report logs: Bugs in pseudo-package <systemitem role="package">wnpp</systemitem> in <literal>unstable</literal></ulink> </para>
714 </listitem>
715 <listitem>
716 <para> <ulink url="&wnpp-dn;">Debian Packages that Need Lovin'</ulink> </para>
717 </listitem>
718 <listitem>
719 <para> <ulink url="&wnpp-debtags;">Browse <systemitem role="package">wnpp</systemitem> bugs based on debtags</ulink> </para>
720 </listitem>
721 </itemizedlist>
722 <para>
723 As a side note, it's important to point out that Debian already has packages
724 for most kinds of programs, and the number of packages already in the Debian
725 archive is much larger than that of contributors with upload rights. Thus,
726 contributions to packages already in the archive are far more appreciated (and
727 more likely to receive sponsorship) by other developers <footnote><para> Having
728 said that, there will of course always be new programs that are worth
729 packaging. </para> </footnote>. You can contribute in various ways.
730 </para>
731 <itemizedlist>
732 <listitem>
733 <para>
734 taking over orphaned, yet actively used, packages
735 </para>
736 </listitem>
737 <listitem>
738 <para>
739 joining <ulink url="&teams;">packaging teams</ulink>
740 </para>
741 </listitem>
742 <listitem>
743 <para>
744 triaging bugs of very popular packages
745 </para>
746 </listitem>
747 <listitem>
748 <para>
749 preparing <ulink url="&devref-nmu;">QA or NMU uploads</ulink>
750 </para>
751 </listitem>
752 </itemizedlist>
753 <para>
754 If you are able to adopt the package, get the sources (with something like
755 <literal>apt-get source <replaceable>packagename</replaceable></literal>) and
756 examine them. This document unfortunately doesn't include comprehensive
757 information about adopting packages. Thankfully you shouldn't have a hard time
758 figuring out how the package works since someone has already done the initial
759 setup for you. Keep reading, though; a lot of the advice below will still be
760 applicable for your case.
761 </para>
762 <para>
763 If the package is new, and you decide you'd like to see it in Debian, proceed
764 as follows:
765 </para>
766 <itemizedlist>
767 <listitem>
768 <para>
769 First, you must know that the program works, and have tried it for some time to
770 confirm its usefulness.
771 </para>
772 </listitem>
773 <listitem>
774 <para>
775 You must check that no one else is already working on the package on the
776 <ulink url="&wnpp-do;">Work-Needing and Prospective Packages</ulink> site.
777 If no one else is working on it, file an ITP (Intent
778 To Package) bug report to the <systemitem role="package">wnpp</systemitem>
779 pseudo-package using <command>reportbug</command>. If someone's already on it,
780 contact them if you feel you need to. If not - find another interesting
781 program that nobody is maintaining.
782 </para>
783 </listitem>
784 <listitem>
785 <para>
786 The software <emphasis role="strong">must have a license</emphasis>.
787 </para>
788 <itemizedlist>
789 <listitem>
790 <para>
791 For the <literal>main</literal> section, Debian Policy requires it
792 <emphasis role="strong">to be fully compliant with the Debian Free Software
793 Guidelines</emphasis> (<ulink url="&dfsg;">DFSG</ulink>)
794 and <emphasis role="strong">not to require a package outside of
795 <literal>main</literal></emphasis> for compilation or execution. This
796 is the desired case.
797 </para>
798 </listitem>
799 <listitem>
800 <para>
801 For the <literal>contrib</literal> section, it must comply with the
802 DFSG but it may require a package outside of <literal>main</literal> for
803 compilation or execution.
804 </para>
805 </listitem>
806 <listitem>
807 <para>
808 For the <literal>non-free</literal> section, it may be non-compliant
809 with the DFSG but it <emphasis role="strong">must be distributable</emphasis>.
810 </para>
811 </listitem>
812 </itemizedlist>
813 <para>
814 If you are unsure about where it should go, post the license text on
815 <ulink url="&debian-legal-ldo;">debian-legal@lists.debian.org</ulink>
816 and ask for advice.
817 </para>
818 <listitem>
819 <para>
820 The program should <emphasis role="strong">not</emphasis> introduce security
821 and maintenance concerns to the Debian system. As a new maintainer with no
822 experience in the security audit, it is best to keep away from risky programs.
823 </para>
824 </listitem>
825 <itemizedlist>
826 <listitem>
827 <para>
828 The program certainly should <emphasis role="strong">not</emphasis> run setuid
829 root, or even better, it shouldn't need to be setuid or setgid to anything.
830 </para>
831 </listitem>
832 <listitem>
833 <para>
834 The program should not be a daemon, or go in an
835 <filename>*/sbin</filename> directory, or open a port as root.
836 </para>
837 </listitem>
838 <listitem>
839 <para>
840 The program should be well documented and its code needs to be understandable
841 (i.e. not obfuscated).
842 </para>
843 </listitem>
844 <listitem>
845 <para>
846 You should contact the program's author(s) to check if they agree with packaging it
847 and are amicable to Debian. It is important to be able to consult with the author(s)
848 in case of any problems with the program, so don't try to package
849 unmaintained software.
850 </para>
851 </listitem>
852 </itemizedlist>
853 </listitem>
854 </itemizedlist>
855 <para>
856 Of course, these are just safety measures, and intended to save you from
857 enraging users if you do something wrong in some setuid daemon... When you gain
858 more experience in packaging, you'll be able to package such software.
859 </para>
860 <para>
861 As a new maintainer, you are encouraged to get some experience in packaging
862 with easier packages and discouraged from creating complicated packages.
863 </para>
864 <itemizedlist>
865 <listitem><para>Simple packages</para>
866 <itemizedlist>
867 <listitem><para>single binary package, arch = all (collection of data such as wallpaper graphics)</para></listitem>
868 <listitem><para>single binary package, arch = all (executable written in the POSIX shell language)</para></listitem>
869 <listitem><para>single binary package, arch = all (executable written in interpreter languages)</para></listitem>
870 <listitem><para>single binary package, arch = any (executable compiled from a C source with <filename>Makefile</filename>)</para></listitem>
871 </itemizedlist>
872 </listitem>
873 <listitem><para>Intermediate complexity packages</para>
874 <itemizedlist>
875 <listitem><para>single binary package, arch = any (executable compiled from a C source with Autotools)</para></listitem>
876 <listitem><para>multiple binary packages, arch = any + all (executable package + documentation package)</para></listitem>
877 <listitem><para>upstream source in a format other than <filename>tar.gz</filename> or <filename>tar.bz2</filename></para></listitem>
878 <listitem><para>upstream source containing undistributable contents</para></listitem>
879 <listitem><para>source package with multiple upstream sources</para></listitem>
880 </itemizedlist>
881 </listitem>
882 <listitem><para>High complexity packages</para>
883 <itemizedlist>
884 <listitem><para>interpreter module packages used by other packages</para></listitem>
885 <listitem><para>multiple binary packages containing library package</para></listitem>
886 <listitem><para>generic library package used by other packages, arch = any</para></listitem>
887 <listitem><para>kernel module packages, arch = any</para></listitem>
888 <listitem><para>kernel patch packages</para></listitem>
889 </itemizedlist>
890 </listitem>
891 </itemizedlist>
892 <para>
893 Doing so is not too hard, but it requires a bit more knowledge. You should seek
894 specific guidances for every complexities.
895 </para>
896 </section>
897 <section id="getit"><title>Get the program, and try it out</title>
898 <para>
899 So the first thing to do is to find and download the original source code.
900 Presumably you already have the source file that you picked up at the
901 author's homepage. Sources for free Unix programs usually come in
902 <command>tar</command>+<command>gzip</command> format with the extension
903 <filename>.tar.gz</filename>,
904 <command>tar</command>+<command>bzip2</command> format with the extension
905 <filename>.tar.bz2</filename>, or
906 <command>tar</command>+<command>xz</command> format with the extension
907 <filename>.tar.xz</filename>. These usually contain a directory called
908 <filename><replaceable>package</replaceable>-<replaceable>version</replaceable></filename>
909 with all the sources inside.
910 </para>
911 <para>
912 If the latest version of the source is available through a VCS such as Git,
913 Subversion, or CVS, you need to get it with <literal>git
914 clone</literal>, <literal>svn co</literal>, or <literal>cvs co</literal> and
915 repack it into <command>tar</command>+<command>gzip</command> format yourself
916 by using the <literal>--exclude-vcs</literal> option.
917 </para>
918 <para>
919 If your program's source comes as some other sort of archive (for instance, the
920 filename ends in <filename>.Z</filename> or
921 <filename>.zip</filename><footnote><para> You can identify the archive format
922 using the <command>file</command> command when the file extension is not
923 enough. </para> </footnote>), you should also unpack it with the
924 appropriate tools and repack it.
925 </para>
926 <para>
927 As an example, I'll use a program called <command>gentoo</command>, a GTK+
928 file manager.
929 <footnote><para> This program is already packaged. The
930 <ulink url="&gentoo-package;">current version</ulink> uses Autotools as its
931 build structure and is substantially different from the following examples,
932 which were based on version 0.9.12.</para>
933 </footnote>
934 </para>
935 <para>
936 Create a subdirectory under your home directory named
937 <filename>debian</filename> or <filename>deb</filename> or anything you find
938 appropriate (e.g. just <filename>~/gentoo</filename> would do fine in this
939 case). Place the downloaded archive in it, and extract it (with <literal>tar
940 xzf gentoo-0.9.12.tar.gz</literal>). Make sure there are no warning
941 messages, even <emphasis>irrelevant</emphasis> ones, because other
942 people's unpacking tools may or may not ignore these anomalies, so they
943 may have problems unpacking them. Your shell command line may look
944 something like this:
945 </para>
946 <screen>
947 $ mkdir ~/gentoo ; cd ~/gentoo
948 $ wget http://<replaceable>www.example.org</replaceable>/gentoo-0.9.12.tar.gz
949 $ tar xvzf gentoo-0.9.12.tar.gz
950 $ ls -F
951 gentoo-0.9.12/
952 gentoo-0.9.12.tar.gz
953 </screen>
954 <para>
955 Now you have another subdirectory, called <filename>gentoo-0.9.12</filename>.
956 Change to that directory and <emphasis>thoroughly</emphasis> read the provided
957 documentation. Usually there are files named <filename>README*</filename>,
958 <filename>INSTALL*</filename>, <filename>*.lsm</filename> or
959 <filename>*.html</filename>. You must find instructions on how to
960 compile and install the program (most probably they'll assume you want to
961 install to the <filename>/usr/local/bin</filename> directory; you won't be doing
962 that, but more on that later in <xref linkend="destdir"/>).
963 </para>
964 <para>
965 You should start packaging with a completely clean (pristine) source directory,
966 or simply with freshly unpacked sources.
967 </para>
968 </section>
969 <section id="simplemake"><title>Simple build systems</title>
970 <para>
971 Simple programs come with a <filename>Makefile</filename> and can
972 be compiled just by invoking <literal>make</literal>.<footnote><para>
973 Many modern programs come with a script <filename>configure</filename> which
974 when executed creates a <filename>Makefile</filename> customized for
975 your system.</para></footnote> Some of them support
976 <literal>make check</literal>, which runs included self-tests. Installation
977 to the destination directories is usually done with <literal>make
978 install</literal>.
979 </para>
980 <para>
981 Now try to compile and run your program, to make sure it works properly and
982 doesn't break something else while it's installing or running.
983 </para>
984 <para>
985 Also, you can usually run <literal>make clean</literal> (or better
986 <literal>make distclean</literal>) to clean up the build directory. Sometimes
987 there's even a <literal>make uninstall</literal> which can be used to remove
988 all the installed files.
989 </para>
990 </section>
991 <section id="portable"><title>Popular portable build systems</title>
992 <para>
993 A lot of free software programs are written in the <ulink url="&c-program;">C</ulink> and
994 <ulink url="&cxx;">C++</ulink> languages. Many of these use Autotools or
995 CMake to make them portable across different platforms. These build tools need
996 to be used to generate the <filename>Makefile</filename> and other
997 required source files first. Then, such programs are built using the usual
998 <literal>make; make install</literal>.
999 </para>
1000 <para>
1001 <ulink url="&gnu-build-system;">Autotools</ulink> is the GNU build
1002 system comprising <ulink url="&autoconf;">Autoconf</ulink>,
1003 <ulink url="&automake;">Automake</ulink>,
1004 <ulink url="&libtool;">Libtool</ulink>, and
1005 <ulink url="&gettext;">gettext</ulink>. You can recognize
1006 such sources by the <filename>configure.ac</filename>,
1007 <filename>Makefile.am</filename>, and <filename>Makefile.in</filename> files.
1008 <footnote><para>Autotools is too big to deal in this small tutorial. This
1009 section is meant to provide keywords and references only. Please make sure to read the
1010 <ulink url="&autotools-tutorial;">Autotools Tutorial</ulink> and
1011 <ulink url="&autotools-readme;"/>, if you need to use it.</para></footnote>
1012 </para>
1013 <para>
1014 The first step of the Autotools workflow is usually that upstream runs
1015 <literal>autoreconf -i -f</literal> in the source directory and
1016 distributes the generated files along with the source.
1017 </para>
1018 <screen>
1019 configure.ac-----+-&gt; autoreconf -+-&gt; configure
1020 Makefile.am -----+ | +-&gt; Makefile.in
1021 src/Makefile.am -+ | +-&gt; src/Makefile.in
1022 | +-&gt; config.h.in
1023 automake
1024 aclocal
1025 aclocal.m4
1026 autoheader
1027 </screen>
1028 <para>
1029 Editing <filename>configure.ac</filename> and <filename>Makefile.am</filename>
1030 files requires some knowledge of <command>autoconf</command> and
1031 <command>automake</command>. See <literal>info autoconf</literal> and
1032 <literal>info automake</literal>.
1033 </para>
1034 <para>
1035 The second step of the Autotools workflow is usually that the user obtains this
1036 distributed source and runs <literal>./configure &amp;&amp; make</literal> in
1037 the source directory to compile the program into a
1038 <command><replaceable>binary</replaceable></command> executable.
1039 </para>
1040 <screen>
1041 Makefile.in -----+ +-&gt; Makefile -----+-&gt; make -&gt; <replaceable>binary</replaceable>
1042 src/Makefile.in -+-&gt; ./configure -+-&gt; src/Makefile -+
1043 config.h.in -----+ +-&gt; config.h -----+
1044 |
1045 config.status -+
1046 config.guess --+
1047 </screen>
1048 <para>
1049 You can change many things in the <filename>Makefile</filename>; for
1050 instance you can change the default location for file installation
1051 using the option <command>./configure --prefix=/usr</command>.
1052 </para>
1053 <para>
1054 Although it is not required, updating the <filename>configure</filename> and
1055 other files with <literal>autoreconf -i -f</literal> may improve
1056 the compatibility of the source.
1057 <footnote><para>You can automate this by using
1058 <systemitem role="package">dh-autoreconf</systemitem> package.
1059 See <xref linkend="customrules"/>.</para></footnote>
1060 </para>
1061 <para>
1062 <ulink url="&cmake;">CMake</ulink> is an alternative
1063 build system. You can recognize such sources by the
1064 <filename>CMakeLists.txt</filename> file.
1065 </para>
1066 </section>
1067 <section id="namever"><title>Package name and version</title>
1068 <para>
1069 If the upstream source comes as <filename>gentoo-0.9.12.tar.gz</filename>, you can
1070 consider
1071 <emphasis role="strong">package name</emphasis> to be <literal>gentoo</literal> and
1072 <emphasis role="strong">upstream version</emphasis> to be <literal>0.9.12</literal>.
1073 These are used in the <filename>debian/changelog</filename> file described later in
1074 <xref linkend="changelog"/>, too.
1075 </para>
1076 <para>
1077 Although this simple approach works most of the times, you may need to adjust
1078 <emphasis role="strong">package name</emphasis> and
1079 <emphasis role="strong">upstream version</emphasis> by renaming the upstream
1080 source to follow the Debian Policy and the existing convention.
1081 </para>
1082 <para>
1083 You must choose the <emphasis role="strong">package name</emphasis>
1084 to consist only of lower case letters (<literal>a-z</literal>), digits
1085 (<literal>0-9</literal>), plus (<literal>+</literal>) and minus
1086 (<literal>-</literal>) signs, and periods (<literal>.</literal>). It must be
1087 at least two characters long, must start with an alphanumeric character, and
1088 must not be the same as existing ones.
1089 It is good idea to keep its length within 30 characters and should not exceed
1090 40 characters.
1091 </para>
1092 <!--
1093 Osamu's archive stat (2011-04-23, sid, kfreebsd-amd64):
1094 === stat for package name string length ===
1095 11 1947 36.9% mode
1096 14 1717 54.7% 50% median
1097 23 611 91.0% 90%
1098 32 89 99.0% 99%
1099 41 12 99.9% 99.9%
1100 52 1 100.0%
1101 Previous 20 chars is becoming too short for 17% of packages
1102 Default aptitude setting display up to 30 chars (98.3%).
1103 -->
1104 <para>
1105 If upstream source uses generic words such as <literal>test-suite</literal> as
1106 its name, it is good idea to rename it not to contaminate name space for the
1107 package name and to identify its contents explicitly.
1108 <footnote><para>If you follow the
1109 <ulink url="&devref-newpackage;">Debian Developer's Reference 5.1. "New packages"</ulink>,
1110 the ITP process will usually catch this kind of issues.</para></footnote>
1111 </para>
1112 <para>
1113 You should choose the <emphasis role="strong">upstream version</emphasis>
1114 to consist only of
1115 alphanumerics (<literal>0-9A-Za-z</literal>), plus (<literal>+</literal>),
1116 tildes (<literal>~</literal>), and periods (<literal>.</literal>). It must
1117 start with a digit (<literal>0-9</literal>). <footnote><para>This stricter
1118 rule should help you avoid confusing file names.</para></footnote>
1119 It is good idea to keep its length within 8 characters if possible.
1120 </para>
1121 <!--
1122 Osamu's archive stat (2011-04-23, sid, kfreebsd-amd64):
1123 === stat for upstream version string length ===
1124 5 9765 60.2% 50% median and mode
1125 6 3765 73.3%
1126 7 2789 82.9%
1127 8 1158 86.9%
1128 9 501 88.6%
1129 10 773 91.3% 90%
1130 18 55 99.1% 99%
1131 27 11 99.9% 99.9
1132 35 6 100.0%
1133 === stat for debian revision string length ===
1134 1 22556 83.3% 50% median and mode
1135 2 1106 87.2%
1136 3 1312 91.7% 90%
1137 4 2127 99.1% 99%
1138 7 14 99.9% 99.9%
1139
1140 aptitude display 10 = 8char for up + 1char (for -) + 1char for deb
1141 90chars as max for file name of binary debs (package+up+deb+arch+.deb)
1142 -->
1143 <para>
1144 If the upstream software does not use normal version system like
1145 <literal>2.30.32</literal> but uses some kind of date such as
1146 <literal>09Oct23</literal>, a random codename string or a VCS hash value as a part
1147 of version, make sure to remove them from the
1148 <emphasis role="strong">upstream version</emphasis>. Such information can be
1149 recorded in the <filename>debian/changelog</filename> file. If you need to
1150 invent a version string, use the <literal>YYYYMMDD</literal> format such as
1151 <literal>20110429</literal> as upstream version. This ensures that
1152 <command>dpkg</command> properly sees later versions as upgrades.
1153 </para>
1154 <para>
1155 Version strings can be compared with <citerefentry> <refentrytitle>dpkg</refentrytitle> <manvolnum>1</manvolnum> </citerefentry> as the following.
1156 </para>
1157 <screen>
1158 $ dpkg --compare-versions <replaceable>ver1</replaceable> <replaceable>op</replaceable> <replaceable>ver2</replaceable>
1159 </screen>
1160 <para>
1161 The version comparison rule can be summarized as the following.
1162 </para>
1163 <itemizedlist>
1164 <listitem><para>The strings are compared from the head to the tail.</para></listitem>
1165 <listitem><para>Alphabets are larger than numbers.</para></listitem>
1166 <listitem><para>Numbers are compared as the integer.</para></listitem>
1167 <listitem><para>Alphabets are compared in the ASCII code order.</para></listitem>
1168 <listitem><para>There are some special rules for periods (<literal>.</literal>), plus (<literal>+</literal>) and tildes (<literal>~</literal>) as the followings.</para>
1169 <para>
1170 <literal>0.0</literal> &lt;
1171 <literal>0.5</literal> &lt;
1172 <literal>0.10</literal> &lt;
1173 <literal>0.99</literal> &lt;
1174 <literal>1</literal> &lt;
1175 <literal>1.0~rc1</literal> &lt;
1176 <literal>1.0</literal> &lt;
1177 <literal>1.0+b1</literal> &lt;
1178 <literal>1.0+nmu1</literal> &lt;
1179 <literal>1.1</literal> &lt;
1180 <literal>2.0</literal>
1181 </para>
1182 </listitem>
1183 </itemizedlist>
1184 <para>
1185 One of the tricky case happens when the upstream releases
1186 <filename>gentoo-0.9.12-ReleaseCandidate-99.tar.gz</filename> as the
1187 pre-release of <filename>gentoo-0.9.12.tar.gz</filename>. You need to make
1188 sure that the upgrade works properly by renaming the upstream source to
1189 <filename>gentoo-0.9.12~rc99.tar.gz</filename>.
1190 </para>
1191 </section>
1192 <section id="dh-make"><title>Setting up <command>dh_make</command></title>
1193 <para>
1194 Set up the shell environment variables <literal>$DEBEMAIL</literal> and
1195 <literal>$DEBFULLNAME</literal> so that various Debian maintenance
1196 tools recognize your email address and name to use for packages. <footnote><para> The
1197 following text assumes you are using Bash as your login shell. If you use
1198 some other login shell such as Z shell, use their corresponding
1199 configuration files instead of <filename>~/.bashrc</filename>. </para> </footnote>
1200 </para>
1201 <screen>
1202 $ cat &gt;&gt;~/.bashrc &lt;&lt;EOF
1203 DEBEMAIL=your.email.address@example.org
1204 DEBFULLNAME=Firstname Lastname
1205 export DEBEMAIL DEBFULLNAME
1206 EOF
1207 $ . ~/.bashrc
1208 </screen>
1209 </section>
1210 <section id="non-native-dh-make"><title>Initial non-native Debian package</title>
1211 <para>
1212 Normal Debian packages are non-native Debian packages made from upstream
1213 programs. If you wish to create a non-native Debian package of an upstream
1214 source <filename>gentoo-0.9.12.tar.gz</filename>, you can create an initial
1215 non-native Debian package for it by issuing the <command>dh_make</command>
1216 command as follows.
1217 </para>
1218 <screen>
1219 $ cd ~/gentoo
1220 $ wget http://example.org/gentoo-0.9.12.tar.gz
1221 $ tar -xvzf gentoo-0.9.12.tar.gz
1222 $ cd gentoo-0.9.12
1223 $ dh_make -f ../gentoo-0.9.12.tar.gz
1224 </screen>
1225 <para>
1226 Of course, replace the filename with the name of your original source archive.
1227 <footnote><para> If the upstream source provides the
1228 <filename>debian</filename> directory and its contents, run the
1229 <command>dh_make</command> command with the extra option
1230 <literal>--addmissing</literal>. The new source <literal>3.0 (quilt)</literal> format is
1231 robust enough not to break even for these packages. You may need to update the contents
1232 provided by the upstream for your Debian package. </para> </footnote> See
1233 <citerefentry> <refentrytitle>dh_make</refentrytitle> <manvolnum>1</manvolnum>
1234 </citerefentry> for details.
1235 </para>
1236 <para>
1237 You should see some output asking you what sort of package you want
1238 to create. Gentoo is a single binary package - it creates only one binary package, i.e,
1239 one <filename>.deb</filename> file - so we will select the first option
1240 (with the <literal>s</literal> key), check the information on the screen, and
1241 confirm by pressing <literal><replaceable>ENTER</replaceable></literal>.
1242 <footnote><para> There are several choices here: <literal>s</literal> for
1243 Single binary package, <literal>i</literal> for arch-Independent package, <literal>m</literal> for
1244 Multiple binary packages, <literal>l</literal> for Library package, <literal>k</literal> for
1245 Kernel module package, <literal>n</literal> for kernel patch package, and <literal>b</literal>
1246 for <systemitem role="package">cdbs</systemitem> package. This document focuses on the
1247 use of the <command>dh</command> command (from the package
1248 <systemitem role="package">debhelper</systemitem>) to create a single binary package,
1249 but also touches on how to use it for arch-independent or
1250 multiple binary packages. The package
1251 <systemitem role="package">cdbs</systemitem> offers an alternative packaging script
1252 infrastructure to the <command>dh</command> command and is outside the scope of
1253 this document. </para> </footnote>
1254 </para>
1255 <para>
1256 This execution of <command>dh_make</command> creates a copy of the upstream
1257 tarball as <filename>gentoo_0.9.12.orig.tar.gz</filename> in the
1258 parent directory to accommodate the creation of the non-native Debian source
1259 package with the name <filename>debian.tar.gz</filename> later.
1260 </para>
1261 <screen>
1262 $ cd ~/gentoo ; ls -F
1263 gentoo-0.9.12/
1264 gentoo-0.9.12.tar.gz
1265 gentoo_0.9.12.orig.tar.gz
1266 </screen>
1267 <para>
1268 Please note two key features of this filename
1269 <filename>gentoo_0.9.12.orig.tar.gz</filename>:
1270 </para>
1271 <itemizedlist>
1272 <listitem>
1273 <para>
1274 Package name and version are separated by the character <literal>_</literal>
1275 (underscore).
1276 </para>
1277 </listitem>
1278 <listitem>
1279 <para>
1280 The string <filename>.orig</filename> is inserted before the
1281 <filename>.tar.gz</filename>.
1282 </para>
1283 </listitem>
1284 </itemizedlist>
1285 <para>
1286 You should also notice that many template files are created in the source under
1287 the <filename>debian</filename> directory. These will be explained in
1288 <xref linkend="dreq"/> and <xref linkend="dother"/>. You should also understand
1289 that packaging cannot be a fully automated process. You will need to modify the upstream
1290 source for Debian (see <xref linkend="modify"/>). After this, you need to
1291 use the proper methods for building Debian packages (<xref linkend="build"/>),
1292 testing them (<xref linkend="checkit"/>), and uploading them (<xref linkend="upload"/>).
1293 All the steps will be explained.
1294 </para>
1295 <para>
1296 If you accidentally erased some template files while working on them, you can
1297 recover them by running <command>dh_make</command> with the
1298 <literal>--addmissing</literal> option again in a Debian package source tree.
1299 </para>
1300 <para>
1301 Updating an existing package may get complicated since it may be using older
1302 techniques. While learning the basics, please stick to creating a fresh
1303 package; further explanations are given in <xref linkend="update"/>.
1304 </para>
1305 <para>
1306 Please note that the source file does not need to contain any build system
1307 discussed in <xref linkend="simplemake"/> and <xref linkend="portable"/>. It
1308 could be just a collection of graphics data etc. Installation of files may be
1309 enabled by <systemitem role="package">debhelper</systemitem> configuration
1310 files such as <filename>debian/install</filename> (see
1311 <xref linkend="install"/>) only.
1312 </para>
1313 </section>
1314 <section id="native-dh-make"><title>Initial native Debian package</title>
1315 <para>
1316 Debian native packages are simpler to manage if they contain source files you
1317 manage only for Debian, possibly only for local uses. If you have source
1318 files in <filename>~/mypackage-1.0</filename>, you can create an initial native
1319 Debian package for it by issuing the <command>dh_make</command> command as
1320 follows.
1321 </para>
1322 <screen>
1323 $ cd ~/mypackage-1.0
1324 $ dh_make --native
1325 </screen>
1326 <para>
1327 Then the <filename>debian</filename> directory and its contents are created
1328 just like <xref linkend="non-native-dh-make"/>. This does not create a tarball
1329 since this is a native Debian package. But that is the only difference.
1330 The rest of the packaging activities are practically the same.
1331 </para>
1332 </section>
1333 </chapter>
1334 <chapter id="modify"><title>Modifying the source</title>
1335 <para>
1336 Please note that there isn't space here to go into <emphasis>all</emphasis> the
1337 details of fixing upstream sources, but here are some basic steps and problems
1338 people often run across.
1339 </para>
1340 <section id="quiltrc"><title>Setting up <command>quilt</command></title>
1341 <para>
1342 The program <command>quilt</command> offers a basic method for recording
1343 modifications to the upstream source for Debian packaging. It's
1344 useful to have a slightly customized default, so let's create an alias
1345 <command>dquilt</command> for Debian packaging by adding the following
1346 line to <filename>~/.bashrc</filename>.
1347 </para>
1348 <screen>
1349 alias dquilt="quilt --quiltrc=~/.quiltrc-dpkg"
1350 </screen>
1351 <para>
1352 Then let's create <filename>~/.quiltrc-dpkg</filename> as follows.
1353 </para>
1354 <screen>
1355 d=. ; while [ ! -d $d/debian -a `readlink -e $d` != / ]; do d=$d/..; done
1356 if [ -d $d/debian ] &amp;&amp; [ -z $QUILT_PATCHES ]; then
1357 # if in Debian packaging tree with unset $QUILT_PATCHES
1358 QUILT_PATCHES="debian/patches"
1359 QUILT_PATCH_OPTS="--reject-format=unified"
1360 QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto"
1361 QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
1362 QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33"
1363 if ! [ -d $d/debian/patches ]; then mkdir $d/debian/patches; fi
1364 fi
1365 </screen>
1366 <para>
1367 See <citerefentry> <refentrytitle>quilt</refentrytitle>
1368 <manvolnum>1</manvolnum> </citerefentry> and
1369 <ulink url="&quilt-pdf;">quilt.pdf</ulink> on how to use
1370 <command>quilt</command>.
1371 </para>
1372 </section>
1373 <section id="fixupstream"><title>Fixing upstream bugs</title>
1374 <para>
1375 Let's assume you find an error in the upstream <filename>Makefile</filename>
1376 as follows where <literal>install: gentoo</literal> should have been
1377 <literal>install: gentoo-target</literal>.
1378 </para>
1379 <screen>
1380 install: gentoo
1381 install ./gentoo $(BIN)
1382 install icons/* $(ICONS)
1383 install gentoorc-example $(HOME)/.gentoorc
1384 </screen>
1385 <para>
1386 Let's fix this and record it with the <command>dquilt</command> command as
1387 <filename>fix-gentoo-target.patch</filename>. <footnote><para> The
1388 <filename>debian/patches</filename> directory should exist now if you ran
1389 <command>dh_make</command> as described before. This example operation creates
1390 it just in case you are updating an existing package. </para> </footnote>
1391 </para>
1392 <screen>
1393 $ mkdir debian/patches
1394 $ dquilt new fix-gentoo-target.patch
1395 $ dquilt add Makefile
1396 </screen>
1397 <para>
1398 You change the <filename>Makefile</filename> file as follows.
1399 </para>
1400 <screen>
1401 install: gentoo-target
1402 install ./gentoo $(BIN)
1403 install icons/* $(ICONS)
1404 install gentoorc-example $(HOME)/.gentoorc
1405 </screen>
1406 <para>
1407 Ask <command>dquilt</command> to generate the patch to create
1408 <filename>debian/patches/fix-gentoo-target.patch</filename> and add its
1409 description following <ulink url="&dep3;">DEP-3: Patch Tagging Guidelines</ulink>.
1410 </para>
1411 <screen>
1412 $ dquilt refresh
1413 $ dquilt header -e
1414 ... describe patch
1415 </screen>
1416 </section>
1417 <section id="destdir"><title>Installation of files to their destination</title>
1418 <para>
1419 Most third-party software installs itself in the <filename>/usr/local</filename>
1420 directory hierarchy. On Debian this is reserved for private use
1421 by the system administrator, so packages must not use directories such
1422 as <filename>/usr/local/bin</filename> but should instead use system
1423 directories such as <filename>/usr/bin</filename>, obeying the
1424 <ulink url="&fhs;">Filesystem Hierarchy Standard</ulink> (FHS).
1425 </para>
1426 <para>
1427 Normally, <citerefentry> <refentrytitle>make</refentrytitle>
1428 <manvolnum>1</manvolnum> </citerefentry> is used to automate building the
1429 program, and executing <literal>make install</literal> installs programs
1430 directly to the desired destination (following the
1431 <literal>install</literal> target in the
1432 <filename>Makefile</filename>). In order for Debian to provide
1433 pre-built installable packages, it modifies the build system to install
1434 programs into a file tree image created under a temporary directory
1435 instead of the actual destination.
1436 </para>
1437 <para>
1438 These two differences between normal program installation on one hand and the
1439 Debian packaging system on the other can be transparently addressed by the
1440 <systemitem role="package">debhelper</systemitem> package through the
1441 <command>dh_auto_configure</command> and <command>dh_auto_install</command>
1442 commands if the following conditions are met.
1443 </para>
1444 <itemizedlist>
1445 <listitem>
1446 <para>
1447 The <filename>Makefile</filename> must follow GNU conventions and
1448 support the <literal>$(DESTDIR)</literal> variable.
1449 <footnote><para> See <ulink url="&gnu-destdir;">GNU Coding Standards: 7.2.4 DESTDIR: Support for Staged Installs</ulink>.</para></footnote>
1450 </para>
1451 </listitem>
1452 <listitem>
1453 <para>
1454 The source must follow the Filesystem Hierarchy Standard (FHS).
1455 </para>
1456 </listitem>
1457 </itemizedlist>
1458 <para>
1459 Programs that use GNU <command>autoconf</command> follow the GNU conventions
1460 automatically, so they can be trivial to package. On the basis of
1461 this and other heuristics, it is estimated that the
1462 <systemitem role="package">debhelper</systemitem> package will work for
1463 about 90% of packages without making any intrusive changes to their
1464 build system. So packaging is not as complicated as it may seem.
1465 </para>
1466 <para>
1467 If you need to make changes in the <filename>Makefile</filename>, you
1468 should be careful to support the <literal>$(DESTDIR)</literal>
1469 variable. Although it is unset by default, the <literal>$(DESTDIR)</literal>
1470 variable is prepended to each file path used for the program
1471 installation. The packaging script will set
1472 <literal>$(DESTDIR)</literal> to the temporary directory.
1473 </para>
1474 <para>
1475 For packages of the single binary type, the temporary directory used
1476 by the <command>dh_auto_install</command> command will be set to
1477 <filename>debian/<replaceable>package</replaceable></filename>.
1478 <footnote><para> For packages of the multiple binary type, the
1479 <command>dh_auto_install</command> command uses <filename>debian/tmp</filename>
1480 as the temporary directory while the <command>dh_install</command> command with
1481 the help of
1482 <filename>debian/<replaceable>package-1</replaceable>.install</filename> and
1483 <filename>debian/<replaceable>package-2</replaceable>.install</filename> files
1484 will split the contents of <filename>debian/tmp</filename> into
1485 <filename>debian/<replaceable>package-1</replaceable></filename> and
1486 <filename>debian/<replaceable>package-2</replaceable></filename> temporary
1487 directories, to create
1488 <filename><replaceable>package-1</replaceable>_*.deb</filename> and
1489 <filename><replaceable>package-2</replaceable>_*.deb</filename> binary
1490 packages.
1491 </para> </footnote> Everything that is contained in the temporary directory
1492 will be installed on users' systems when they install your package; the only
1493 difference is that <command>dpkg</command> will be installing the
1494 files to paths relative to the root directory rather than your working
1495 directory.
1496 </para>
1497 <para>
1498 Bear in mind that even though your program installs in
1499 <filename>debian/<replaceable>package</replaceable></filename>, it still needs
1500 to behave correctly when installed from the <filename>.deb</filename>
1501 package under the root directory. So you must not allow the build
1502 system to hardcode strings like
1503 <literal>/home/me/deb/<replaceable>package</replaceable>-<replaceable>version</replaceable>/usr/share/<replaceable>package</replaceable></literal>
1504 into files in the package.
1505 </para>
1506 <para>
1507 Here's the relevant part of <systemitem role="package">gentoo</systemitem>'s
1508 <filename>Makefile</filename><footnote><para> This is just an example to
1509 show what a <filename>Makefile</filename> should look like. If the
1510 <filename>Makefile</filename> is created by the
1511 <command>./configure</command> command, the correct way to fix this kind of
1512 <filename>Makefile</filename> is to execute <command>./configure</command>
1513 from the <command>dh_auto_configure</command> command with default
1514 options including <literal>--prefix=/usr</literal>. </para> </footnote>:
1515 </para>
1516 <screen>
1517 # Where to put binary executables on 'make install'?
1518 BIN = /usr/local/bin
1519 # Where to put icons on 'make install'?
1520 ICONS = /usr/local/share/gentoo
1521 </screen>
1522 <para>
1523 We see that the files are set to install under <filename>/usr/local</filename>.
1524 As explained above, that directory hierarchy is reserved for local use on
1525 Debian, so change those paths to:
1526 </para>
1527 <screen>
1528 # Where to put binary executables on 'make install'?
1529 BIN = $(DESTDIR)/usr/bin
1530 # Where to put icons on 'make install'?
1531 ICONS = $(DESTDIR)/usr/share/gentoo
1532 </screen>
1533 <para>
1534 The exact locations that should be used for binaries, icons,
1535 documentation, etc. are specified in the Filesystem Hierarchy Standard
1536 (FHS). You should browse through it and read the sections relevant to
1537 your package.
1538 </para>
1539 <para>
1540 So, we should install binary executables in <filename>/usr/bin</filename> instead of
1541 <filename>/usr/local/bin</filename>, the manual page in
1542 <filename>/usr/share/man/man1</filename> instead of
1543 <filename>/usr/local/man/man1</filename>, and so on. Notice how there's no manual
1544 page mentioned in <systemitem role="package">gentoo</systemitem>'s
1545 <filename>Makefile</filename>, but since Debian Policy requires that every
1546 program has one, we'll make one later and install it in
1547 <filename>/usr/share/man/man1</filename>.
1548 </para>
1549 <para>
1550 Some programs don't use <filename>Makefile</filename> variables to define paths
1551 such as these. This means you might have to edit some real C sources in order
1552 to fix them to use the right locations. But where to search, and exactly what
1553 for? You can find this out by issuing:
1554 </para>
1555 <screen>
1556 $ grep -nr --include='*.[c|h]' -e 'usr/local/lib' .
1557 </screen>
1558 <para>
1559 <command>grep</command> will run recursively through the source tree and tell
1560 you the filename and the line number for all matches.
1561 </para>
1562 <para>
1563 Edit those files and in those lines replace <literal>usr/local/lib</literal>
1564 with <literal>usr/lib</literal>. This can be done automatically as follows:
1565 </para>
1566 <screen>
1567 $ sed -i -e 's#usr/local/lib#usr/lib#g' \
1568 $(find . -type f -name '*.[c|h]')
1569 </screen>
1570 <para>
1571 If you want to confirm each substitution instead, this can be done interactively as follows:
1572 </para>
1573 <screen>
1574 $ vim '+argdo %s#usr/local/lib#usr/lib#gce|update' +q \
1575 $(find . -type f -name '*.[c|h]')
1576 </screen>
1577
1578 <para>
1579 Next you should find the <literal>install</literal> target (searching
1580 for the line that starts with <literal>install:</literal> will usually
1581 work) and rename all references to directories other than ones defined
1582 at the top of the <filename>Makefile</filename>.
1583 </para>
1584 <para>
1585 Originally, <systemitem role="package">gentoo</systemitem>'s
1586 install target said:
1587 </para>
1588 <screen>
1589 install: gentoo-target
1590 install ./gentoo $(BIN)
1591 install icons/* $(ICONS)
1592 install gentoorc-example $(HOME)/.gentoorc
1593 </screen>
1594 <para>
1595 Let's fix this upstream bug and record it with the <command>dquilt</command> command as
1596 <filename>debian/patches/install.patch</filename>.
1597 </para>
1598 <screen>
1599 $ dquilt new install.patch
1600 $ dquilt add Makefile
1601 </screen>
1602 <para>
1603 In your editor, change this for the Debian package as follows:
1604 </para>
1605 <screen>
1606 install: gentoo-target
1607 install -d $(BIN) $(ICONS) $(DESTDIR)/etc
1608 install ./gentoo $(BIN)
1609 install -m644 icons/* $(ICONS)
1610 install -m644 gentoorc-example $(DESTDIR)/etc/gentoorc
1611 </screen>
1612 <para>
1613 You'll have noticed that there's now an <literal>install -d</literal> command
1614 before the other commands in the rule. The original
1615 <filename>Makefile</filename> didn't have it because usually
1616 <literal>/usr/local/bin</literal> and other directories already exist on the
1617 system where you are running <literal>make install</literal>. However, since we will
1618 be installing into a newly created private directory tree, we will have to
1619 create each and every one of those directories.
1620 </para>
1621 <para>
1622 We can also add in other things at the end of the rule, like the installation
1623 of additional documentation that the upstream authors sometimes omit:
1624 </para>
1625 <screen>
1626 install -d $(DESTDIR)/usr/share/doc/gentoo/html
1627 cp -a docs/* $(DESTDIR)/usr/share/doc/gentoo/html
1628 </screen>
1629 <para>
1630 Check carefully, and if everything is okay, ask <command>dquilt</command> to
1631 generate the patch to create <filename>debian/patches/install.patch</filename>
1632 and add its description.
1633 </para>
1634 <screen>
1635 $ dquilt refresh
1636 $ dquilt header -e
1637 ... describe patch
1638 </screen>
1639 <para>
1640 Now you have a series of patches.
1641 </para>
1642 <orderedlist numeration="arabic">
1643 <listitem>
1644 <para>
1645 Upstream bug fix: <filename>debian/patches/fix-gentoo-target.patch</filename>
1646 </para>
1647 </listitem>
1648 <listitem>
1649 <para>
1650 Debian specific packaging modification:
1651 <filename>debian/patches/install.patch</filename>
1652 </para>
1653 </listitem>
1654 </orderedlist>
1655 <para>
1656 Whenever you make changes that are not specifically related to Debian package
1657 such as <filename>debian/patches/fix-gentoo-target.patch</filename>, be sure to
1658 send them to the upstream maintainer so they can be included in the next
1659 revision of the program and be useful to everyone else. Also remember
1660 to avoid making your fixes specific to Debian or Linux - or even Unix!
1661 Make them portable. This will make your fixes much easier to apply.
1662 </para>
1663 <para>
1664 Note that you don't have to send the <filename>debian/*</filename> files
1665 upstream.
1666 </para>
1667 </section>
1668 <section id="difflibs"><title>Differing libraries</title>
1669 <para>
1670 There is one other common problem: libraries are often different from platform
1671 to platform. For example, a <filename>Makefile</filename> can contain a
1672 reference to a library which doesn't exist on the Debian system. In that case, we
1673 need to change it to a library which does exist in Debian, and serves the same
1674 purpose.
1675 </para>
1676 <para>
1677 Let's assume a line in your program's <filename>Makefile</filename> (or
1678 <filename>Makefile.in</filename>) as the following.
1679 </para>
1680 <screen>
1681 LIBS = -lfoo -lbar
1682 </screen>
1683 <para>
1684 If your program doesn't compile since the <literal>foo</literal> library
1685 doesn't exist and its equivalent is provided by the <literal>foo2</literal>
1686 library on the Debian system, you can fix this build problem as
1687 <filename>debian/patches/foo2.patch</filename> by changing
1688 <literal>foo</literal> into <literal>foo2</literal>.<footnote><para>If there
1689 are API changes from the <literal>foo</literal> library to the
1690 <literal>foo2</literal> library, required changes to the source code need to be
1691 made to match the new API.</para> </footnote>
1692 </para>
1693 <screen>
1694 $ dquilt new foo2.patch
1695 $ dquilt add Makefile
1696 $ sed -i -e 's/-lfoo/-lfoo2/g' Makefile
1697 $ dquilt refresh
1698 $ dquilt header -e
1699 ... describe patch
1700 </screen>
1701 </section>
1702 </chapter>
1703 <chapter id="dreq"><title>Required files under the <filename>debian</filename> directory</title>
1704 <para>
1705 There is a new subdirectory under the program's source directory, it's called
1706 <filename>debian</filename>. There are a number of files in this directory
1707 that we should edit in order to customize the behavior of the package. The
1708 most important of them are <filename>control</filename>,
1709 <filename>changelog</filename>, <filename>copyright</filename> and
1710 <filename>rules</filename>, which are required for all packages.
1711 <footnote><para>
1712 In this chapter, files in the <filename>debian</filename> directory are
1713 referred without preceding <filename>debian/</filename> for simplicity whenever
1714 they are obvious.
1715 </para></footnote>
1716 </para>
1717 <section id="control"><title><filename>control</filename> file</title>
1718 <para>
1719 This file contains various values which <command>dpkg</command>,
1720 <command>dselect</command>, <command>apt-get</command>,
1721 <command>apt-cache</command>, <command>aptitude</command>, and other package
1722 management tools will use to manage the package. It is defined by the <ulink url="&policy-control;">Debian
1723 Policy Manual, 5 'Control files and their fields'</ulink>.
1724 </para>
1725 <para>
1726 Here is the <filename>control</filename> file <command>dh_make</command>
1727 created for us:
1728 </para>
1729 <screen>
1730 1 Source: gentoo
1731 2 Section: unknown
1732 3 Priority: extra
1733 4 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
1734 5 Build-Depends: debhelper (&gt;= 7.0.50~)
1735 6 Standards-Version: 3.8.4
1736 7 Homepage: &lt;insert the upstream URL, if relevant&gt;
1737 8
1738 9 Package: gentoo
1739 10 Architecture: any
1740 11 Depends: ${shlibs:Depends}, ${misc:Depends}
1741 12 Description: &lt;insert up to 60 chars description&gt;
1742 13 &lt;insert long description, indented with spaces&gt;
1743 </screen>
1744 <para>
1745 (I've added the line numbers.)
1746 </para>
1747 <para>
1748 Lines 1-7 are the control information for the source package.
1749 Lines 9-13 are the control information for the binary package.
1750 </para>
1751 <para>
1752 Line 1 is the name of the source package.
1753 </para>
1754 <para>
1755 Line 2 is the section of the distribution the source package goes into.
1756 </para>
1757 <para>
1758 As you may have noticed, Debian archive is divided in sections:
1759 <literal>main</literal> (the free software), <literal>non-free</literal> (the
1760 not really free software) and <literal>contrib</literal> (free software that
1761 depends on non-free software). Under those, there are logical subsections that
1762 describe in short what packages are in. So we have <literal>admin</literal>
1763 for administrator-only programs, <literal>base</literal> for the basic tools,
1764 <literal>devel</literal> for programmer tools, <literal>doc</literal> for
1765 documentation, <literal>libs</literal> for libraries, <literal>mail</literal>
1766 for e-mail readers and daemons, <literal>net</literal> for network apps and
1767 daemons, <literal>x11</literal> for X11 programs that don't fit anywhere else,
1768 and many more.
1769 <footnote> <para>See
1770 <ulink url="&policy-subsections;">Debian Policy Manual, 2.4 'Sections'</ulink> and
1771 <ulink url="&sections-unstable;">List of sections in <literal>sid</literal></ulink>.</para>
1772 </footnote>
1773 </para>
1774 <para>
1775 Let's change it then to x11. (A <literal>main/</literal> prefix is implied so
1776 we can omit it.)
1777 </para>
1778 <para>
1779 Line 3 describes how important it is that the user installs this package.
1780 <footnote> <para>See
1781 <ulink url="&policy-priorities;">Debian Policy Manual, 2.5 'Priorities'</ulink>.
1782 </para>
1783 </footnote>
1784 </para>
1785 <itemizedlist>
1786 <listitem>
1787 <para>
1788 The <literal>optional</literal> priority will usually work for new packages
1789 that do not conflict with others with <literal>required</literal>,
1790 <literal>important</literal> or <literal>standard</literal> priorities.
1791 </para>
1792 </listitem>
1793 <listitem>
1794 <para>
1795 The <literal>extra</literal> priority will usually work for new packages that
1796 conflict with others with non-<literal>extra</literal> priorities.
1797 </para>
1798 </listitem>
1799 </itemizedlist>
1800 <para>
1801 Section and priority are used by the frontends like <command>aptitude</command>
1802 when they sort packages and select defaults. Once you upload the package to
1803 Debian, the value of these two fields can be overridden by the archive
1804 maintainers, in which case you will be notified by email.
1805 </para>
1806 <para>
1807 As this is a normal priority package and doesn't conflict with anything else,
1808 we will change the priority to <literal>optional</literal>.
1809 </para>
1810 <para>
1811 Line 4 is the name and email address of the maintainer. Make sure that this
1812 field includes a valid <literal>To</literal> header for an email, because after
1813 you upload it, the bug tracking system will use it to deliver bug emails to
1814 you. Avoid using commas, ampersands and parenthesis.
1815 </para>
1816 <para>
1817 The 5th line includes the list of packages required to build your package as
1818 the <literal>Build-Depends</literal> field. You can also have the
1819 <literal>Build-Depends-Indep</literal> field as an additional line, here.
1820 <footnote><para>See <ulink url="&policy-relationships;#s-sourcebinarydeps">Debian
1821 Policy Manual, 7.7 'Relationships between source and binary packages -
1822 Build-Depends, Build-Depends-Indep, Build-Conflicts,
1823 Build-Conflicts-Indep'</ulink>.</para></footnote> Some packages like
1824 <systemitem role="package">gcc</systemitem> and
1825 <systemitem role="package">make</systemitem> which are required by the
1826 <systemitem role="package">build-essential</systemitem> package are implied. If you need
1827 to have other tools to build your package, you should add them to these fields.
1828 Multiple entries are separated with commas; read on for the explanation of
1829 binary package dependencies to find out more about the syntax of these lines.
1830 </para>
1831 <itemizedlist>
1832 <listitem>
1833 <para>
1834 For all packages packaged with the <command>dh</command> command in the
1835 <filename>debian/rules</filename> file, you must have <literal>debhelper
1836 (&gt;=7.0.50~)</literal> in the <literal>Build-Depends</literal> field to
1837 satisfy the Debian Policy requirement for the <literal>clean</literal> target.
1838 </para>
1839 </listitem>
1840 <listitem>
1841 <para>
1842 For source packages which have some binary packages with <literal>Architecture:
1843 any</literal>, they are rebuild by the autobuilder. Since this autobuilder
1844 procedure runs <literal>debian/rules build</literal> in it while installing
1845 only packages listed in the <literal>Build-Depends</literal> field (see <xref linkend="autobuilder"/>), the <literal>Build-Depends</literal> field needs to
1846 list practically all the required packages and the
1847 <literal>Build-Depends-indep</literal> is rarely used.
1848 </para>
1849 </listitem>
1850 <listitem>
1851 <para>
1852 For source packages which have binary packages only with <literal>Architecture:
1853 all</literal>, the <literal>Build-Depends-Indep</literal> field may list all
1854 the required packages unless they are already listed in the
1855 <literal>Build-Depends</literal> field to satisfy the Debian Policy requirement
1856 for the <literal>clean</literal> target.
1857 </para>
1858 </listitem>
1859 </itemizedlist>
1860 <para>
1861 If you are not sure which one should be used, use the
1862 <literal>Build-Depends</literal> field to be on the safe side.
1863 <footnote><para> This somewhat strange situation is a feature well documented
1864 in the <ulink url="&policy-build-depends-indep;">Debian Policy
1865 Manual, Footnotes 48</ulink>. This is not due to the use of the
1866 <command>dh</command> command in the <filename>debian/rules</filename> file but
1867 due to how the <command>dpkg-buildpackage</command> works. The same situation
1868 applies to the <ulink url="https://bugs.launchpad.net/launchpad-buildd/+bug/238141">auto build system
1869 for Ubuntu</ulink>. </para> </footnote>
1870 </para>
1871 <para>
1872 To find out what packages your package needs to be built run the command:
1873 </para>
1874 <screen>
1875 $ dpkg-depcheck -d ./configure
1876 </screen>
1877 <para>
1878 To manually find exact build dependency for
1879 <command><replaceable>/usr/bin/foo</replaceable></command>, you execute
1880 </para>
1881 <screen>
1882 $ objdump -p <replaceable>/usr/bin/foo</replaceable> | grep NEEDED
1883 </screen>
1884 <para>
1885 and for each library listed, e.g., <command>libfoo.so.6</command>, execute
1886 </para>
1887 <screen>
1888 $ dpkg -S libfoo.so.6
1889 </screen>
1890 <para>
1891 Then you just take <literal>-dev</literal> version of every package as
1892 <literal>Build-Depends</literal> entry. If you use <command>ldd</command> for
1893 this purpose, it will report indirect lib dependencies as well, resulting in
1894 the problem of excessive build dependencies.
1895 </para>
1896 <para>
1897 <systemitem role="package">gentoo</systemitem> also happens to require
1898 <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
1899 next to <systemitem role="package">debhelper</systemitem>.
1900 </para>
1901 <para>
1902 Line 6 is the version of the <ulink url="&debian-policy;">Debian Policy
1903 Manual</ulink> standards this package follows, the one you read while making
1904 your package.
1905 </para>
1906 <para>
1907 On line 7 you can put the URL of the homepage for the upstream program.
1908 </para>
1909 <para>
1910 Line 9 is the name of the binary package. This is usually the same as the name
1911 of the source package, but it doesn't necessarily have to be that way.
1912 </para>
1913 <para>
1914 Line 10 describes the CPU architecture the binary package can be compiled for.
1915 We'll leave this as <literal>any</literal> because <citerefentry>
1916 <refentrytitle>dpkg-gencontrol</refentrytitle> <manvolnum>1</manvolnum>
1917 </citerefentry> will fill in the appropriate value for any machine this package
1918 gets compiled on.
1919 </para>
1920 <para>
1921 If your package is architecture independent (for example, a shell or Perl
1922 script, or a document), change this to <literal>all</literal>, and read later
1923 in <xref linkend="rules"/> about using the <literal>binary-indep</literal> rule
1924 instead of <literal>binary-arch</literal> for building the package.
1925 </para>
1926 <para>
1927 Line 11 shows one of the most powerful features of the Debian packaging system.
1928 Packages can relate to each other in various ways. Apart from
1929 <literal>Depends</literal>, other relationship fields are
1930 <literal>Recommends</literal>, <literal>Suggests</literal>,
1931 <literal>Pre-Depends</literal>, <literal>Breaks</literal>,
1932 <literal>Conflicts</literal>, <literal>Provides</literal>, and
1933 <literal>Replaces</literal>.
1934 </para>
1935 <para>
1936 The package management tools usually behave the same way when dealing with
1937 these relations; if not, it will be explained. (see <citerefentry>
1938 <refentrytitle>dpkg</refentrytitle> <manvolnum>8</manvolnum> </citerefentry>,
1939 <citerefentry> <refentrytitle>dselect</refentrytitle> <manvolnum>8</manvolnum>
1940 </citerefentry>, <citerefentry> <refentrytitle>apt</refentrytitle>
1941 <manvolnum>8</manvolnum> </citerefentry>, <citerefentry>
1942 <refentrytitle>aptitude</refentrytitle> <manvolnum>1</manvolnum>
1943 </citerefentry> etc.)
1944 </para>
1945 <para>
1946 Here is a simplified description of package relationships.
1947 <footnote><para>See
1948 <ulink url="&policy-relationships;">Debian Policy Manual, 7 'Declaring relationships between packages'</ulink>.
1949 </para></footnote>
1950 </para>
1951 <itemizedlist>
1952 <listitem>
1953 <para>
1954 <literal>Depends</literal>
1955 </para>
1956 <para>
1957 The package will not be installed unless the packages it depends on are
1958 installed. Use this if your program absolutely will not run (or will cause
1959 severe breakage) unless a particular package is present.
1960 </para>
1961 </listitem>
1962 <listitem>
1963 <para>
1964 <literal>Recommends</literal>
1965 </para>
1966 <para>
1967 Use this for packages that are not strictly necessary but are typically used
1968 with your program. When a user installs your program, all frontends will
1969 likely prompt them to install the recommended packages.
1970 <command>aptitude</command> and <command>apt-get</command> install recommended
1971 packages along with your package (but the user can disable this default
1972 behaviour). <command>dpkg</command> will ignore this field.
1973 </para>
1974 </listitem>
1975 <listitem>
1976 <para>
1977 <literal>Suggests</literal>
1978 </para>
1979 <para>
1980 Use this for packages which will work nicely with your program but are not at
1981 all necessary. When a user installs your program, all frontends will likely
1982 prompt them to install the suggested packages. <command>aptitude</command> can
1983 be configured to install suggested packages along with your package but this is
1984 not its default. <command>dpkg</command> and <command>apt-get</command> will
1985 ignore this field.
1986 </para>
1987 </listitem>
1988 <listitem>
1989 <para>
1990 <literal>Pre-Depends</literal>
1991 </para>
1992 <para>
1993 This is stronger than <literal>Depends</literal>. The package will not be
1994 installed unless the packages it pre-depends on are installed and
1995 <emphasis>correctly configured</emphasis>. Use this <emphasis>very</emphasis>
1996 sparingly and only after discussing it on the <ulink url="&debian-devel-ldo;">debian-devel@lists.debian.org</ulink>
1997 mailing list. Read: don't use it at all. :-)
1998 </para>
1999 </listitem>
2000 <listitem>
2001 <para>
2002 <literal>Conflicts</literal>
2003 </para>
2004 <para>
2005 The package will not be installed until all the packages it conflicts with have
2006 been removed. Use this if your program absolutely will not run or will cause
2007 severe problems if a particular package is present.
2008 </para>
2009 </listitem>
2010 <listitem>
2011 <para>
2012 <literal>Breaks</literal>
2013 </para>
2014 <para>
2015 The package will be installed while all the listed packages will be broken.
2016 Normally a <literal>Breaks</literal> entry has an earlier than version clause.
2017 The resolution is generally to upgrade the listed packages by the higher-level
2018 package management tools.
2019 </para>
2020 </listitem>
2021 <listitem>
2022 <para>
2023 <literal>Provides</literal>
2024 </para>
2025 <para>
2026 For some types of packages where there are multiple alternatives virtual names
2027 have been defined. You can get the full list in the
2028 <ulink url="&virtual-package;">virtual-package-names-list.txt.gz</ulink>
2029 file. Use this if your program provides a function of an existing virtual
2030 package.
2031 </para>
2032 </listitem>
2033 <listitem>
2034 <para>
2035 <literal>Replaces</literal>
2036 </para>
2037 <para>
2038 Use this when your program replaces files from another package, or completely
2039 replaces another package (used in conjunction with
2040 <literal>Conflicts</literal>). Files from the named packages will be
2041 overwritten with the files from your package.
2042 </para>
2043 </listitem>
2044 </itemizedlist>
2045 <para>
2046 All these fields have uniform syntax. They are a list of package names
2047 separated by commas. These package names may also be lists of alternative
2048 package names, separated by vertical bar symbols <literal>|</literal> (pipe
2049 symbols).
2050 </para>
2051 <para>
2052 The fields may restrict their applicability to particular versions of each
2053 named package. These versions are listed in parentheses after each individual
2054 package name, and they should contain a relation from the list below followed
2055 by the version number. The relations allowed are: <literal>&lt;&lt;</literal>,
2056 <literal>&lt;=</literal>, <literal>=</literal>, <literal>&gt;=</literal> and
2057 <literal>&gt;&gt;</literal> for strictly lower, lower or equal, exactly equal,
2058 greater or equal and strictly greater, respectively. For example,
2059 </para>
2060 <screen>
2061 Depends: foo (&gt;= 1.2), libbar1 (= 1.3.4)
2062 Conflicts: baz
2063 Recommends: libbaz4 (&gt;&gt; 4.0.7)
2064 Suggests: quux
2065 Replaces: quux (&lt;&lt; 5), quux-foo (&lt;= 7.6)
2066 </screen>
2067 <para>
2068 The last feature you need to know about is
2069 <literal>${shlibs:Depends}</literal>, <literal>${perl:Depends}</literal>,
2070 <literal>${misc:Depends}</literal>, etc.
2071 </para>
2072 <para>
2073 <citerefentry> <refentrytitle>dh_shlibdeps</refentrytitle>
2074 <manvolnum>1</manvolnum> </citerefentry> calculates shared library dependencies
2075 for binary packages. It generates a list of ELF executables and shared
2076 libraries it has found for each binary package. Such list is used for
2077 substituting <literal>${shlibs:Depends}</literal>.
2078 </para>
2079 <para>
2080 <citerefentry> <refentrytitle>dh_perl</refentrytitle> <manvolnum>1</manvolnum>
2081 </citerefentry> calculates Perl dependencies. It generates a list of a
2082 dependency on <literal>perl</literal> or <literal>perlapi</literal> for each binary package. Such list is used for
2083 substituting <literal>${perl:Depends}</literal>.
2084 </para>
2085 <para>
2086 Some <systemitem role="package">debhelper</systemitem> commands may make the
2087 generated package need to depend on some other packages. All such commands
2088 generate a list of required packages for each binary package.
2089 Such list is used for substituting <literal>${misc:Depends}</literal>.
2090 </para>
2091 <para>
2092 <citerefentry> <refentrytitle>dh_gencontrol</refentrytitle>
2093 <manvolnum>1</manvolnum> </citerefentry> generates
2094 <filename>DEBIAN/control</filename> for each binary package while
2095 substituting <literal>${shlibs:Depends}</literal>,
2096 <literal>${perl:Depends}</literal>, <literal>${misc:Depends}</literal>, etc.
2097 </para>
2098 <para>
2099 Having said all that, we can leave the <literal>Depends</literal> field exactly
2100 as it is now, and insert another line after it saying <literal>Suggests:
2101 file</literal>, because <systemitem role="package">gentoo</systemitem> can use
2102 some features provided by that <systemitem role="package">file</systemitem>
2103 package.
2104 </para>
2105 <para> Line 9 is the Homepage URL. Let's assume this to be at
2106 <ulink url="&gentoo;"/>.
2107 </para>
2108 <para>
2109 Line 12 is the short description. Most people screens are 80 columns wide so
2110 this shouldn't be longer than about 60 characters. I'll change it to
2111 <literal>fully GUI-configurable, two-pane X file manager</literal>.
2112 </para>
2113 <para>
2114 Line 13 is where the long description goes. This should be a paragraph which
2115 gives more details about the package. Column 1 of each line should be empty.
2116 There must be no blank lines, but you can put a single <literal>.</literal>
2117 (dot) in a column to simulate that. Also, there must be no more than one blank
2118 line after the long description. <footnote><para>These descriptions are in
2119 English. Translations of these descriptions are provided by
2120 <ulink url="&ddtp;">The Debian Description Translation Project - DDTP</ulink>.</para></footnote>
2121 </para>
2122 <para>
2123 Let's insert <literal>Vcs-*</literal> fields to document the Version Control
2124 System (VCS) location between line 6 and 7.
2125 <footnote><para>See
2126 <ulink url="&devref-bpp-vcs;">Debian Developer's Reference, 6.2.5. "Version Control System location"</ulink>.
2127 </para></footnote>
2128 Let's assume that the <systemitem role="package">gentoo</systemitem>
2129 package has its VCS located in Debian Alioth Git Service at
2130 <literal>git://git.debian.org/git/collab-maint/gentoo.git</literal>.
2131 </para>
2132 <para>
2133 Finally, here is the updated <filename>control</filename> file:
2134 </para>
2135 <screen>
2136 1 Source: gentoo
2137 2 Section: x11
2138 3 Priority: optional
2139 4 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
2140 5 Build-Depends: debhelper (&gt;= 7.0.5), xlibs-dev, libgtk1.2-dev, libglib1.2-dev
2141 6 Standards-Version: 3.8.4
2142 7 Vcs-Git: git://git.debian.org/git/collab-maint/gentoo.git
2143 8 Vcs-browser: http://git.debian.org/?p=collab-maint/gentoo.git
2144 9 Homepage: &gentoo;
2145 10
2146 11 Package: gentoo
2147 12 Architecture: any
2148 13 Depends: ${shlibs:Depends}, ${misc:Depends}
2149 14 Suggests: file
2150 15 Description: fully GUI-configurable, two-pane X file manager
2151 16 gentoo is a two-pane file manager for the X Window System. gentoo lets the
2152 17 user do (almost) all of the configuration and customizing from within the
2153 18 program itself. If you still prefer to hand-edit configuration files,
2154 19 they're fairly easy to work with since they are written in an XML format.
2155 20 .
2156 21 gentoo features a fairly complex and powerful file identification system,
2157 22 coupled to a object-oriented style system, which together give you a lot
2158 23 of control over how files of different types are displayed and acted upon.
2159 24 Additionally, over a hundred pixmap images are available for use in file
2160 25 type descriptions.
2161 26 .
2162 29 gentoo was written from scratch in ANSI C, and it utilises the GTK+ toolkit
2163 30 for its interface.
2164 </screen>
2165 <para>
2166 (I've added the line numbers.)
2167 </para>
2168 </section>
2169 <section id="copyright"><title><filename>copyright</filename> file</title>
2170 <para>
2171 This file contains the information about package upstream resources, copyright
2172 and license information.
2173 <ulink url="&policy-copyright;">Debian Policy Manual, 12.5 'Copyright information'</ulink>
2174 dictates its content and
2175 <ulink url="&dep5;">DEP-5: Machine-parseable <filename>debian/copyright</filename></ulink>
2176 provides guidelines for its format.
2177 </para>
2178 <para>
2179 <command>dh_make</command> can give you a template
2180 <filename>copyright</filename> file. Let's use the <literal>--copyright
2181 gpl2</literal> option here to get a template file for the <systemitem role="package">gentoo</systemitem> package released under GPL-2.
2182 </para>
2183 <para>
2184 You must fill in missing information such as the place you got the package
2185 from, the actual copyright notice and their license to complete this file. For
2186 the common free software licenses such as GNU GPL-1, GNU GPL-2, GNU GPL-3,
2187 LGPL-2, LGPL-2.1, LGPL-3, GNU FDL-1.2, GNU FDL-1.3, Apache-2.0 or the Artistic
2188 license, you can just refer to the appropriate file in
2189 <filename>/usr/share/common-licenses/</filename> directory that exists on every
2190 Debian system. Otherwise, you must include the complete license.
2191 </para>
2192 <para>
2193 In short, here's how <systemitem role="package">gentoo</systemitem>'s
2194 <filename>copyright</filename> file should look like:
2195 </para>
2196 <screen>
2197 1 Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&amp;rev=135
2198 2 Name: gentoo
2199 3 Maintainer: Josip Rodin &lt;joy-mg@debian.org&gt;
2200 4 Source: http://sourceforge.net/projects/gentoo/files/
2201 5
2202 6 Copyright: 1998-2010 Emil Brink &lt;emil@obsession.se&gt;
2203 7 License: GPL-2+
2204 8
2205 9 Files: icons/*
2206 10 Copyright: 1998 Johan Hanson &lt;johan@tiq.com&gt;
2207 11 License: GPL-2+
2208 12
2209 13 Files: debian/*
2210 14 Copyright: 1998-2010 Josip Rodin &lt;joy-mg@debian.org&gt;
2211 15 License: GPL-2+
2212 16
2213 17 License: GPL-2+
2214 18 This program is free software; you can redistribute it and/or modify
2215 19 it under the terms of the GNU General Public License as published by
2216 20 the Free Software Foundation; either version 2 of the License, or
2217 21 (at your option) any later version.
2218 22 .
2219 23 This program is distributed in the hope that it will be useful,
2220 24 but WITHOUT ANY WARRANTY; without even the implied warranty of
2221 25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2222 26 GNU General Public License for more details.
2223 27 .
2224 28 You should have received a copy of the GNU General Public License along
2225 29 with this program; if not, write to the Free Software Foundation, Inc.,
2226 30 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2227 31 .
2228 32 On Debian systems, the full text of the GNU General Public
2229 33 License version 2 can be found in the file
2230 34 `/usr/share/common-licenses/GPL-2'.
2231 </screen>
2232 <para>
2233 (I've added the line numbers.)
2234 </para>
2235 <para>
2236 Please follow the HOWTO provided by ftpmasters and sent to
2237 debian-devel-announce: <ulink url="&howto-copyright;"/>.
2238 </para>
2239 </section>
2240 <section id="changelog"><title><filename>changelog</filename> file</title>
2241 <para>
2242 This is a required file, which has a special format described in the
2243 <ulink url="&policy-dpkgchangelog;">Debian Policy Manual, 4.4 'debian/changelog'</ulink>.
2244 This format is used by <command>dpkg</command> and other programs to obtain the
2245 version number, revision, distribution and urgency of your package.
2246 </para>
2247 <para>
2248 For you, it is also important, since it is good to have documented all changes
2249 you have done. It will help people downloading your package to see whether
2250 there are issues with the package that they should know about. It will be
2251 saved as <filename>/usr/share/doc/gentoo/changelog.Debian.gz</filename> in the
2252 binary package.
2253 </para>
2254 <para>
2255 <command>dh_make</command> created a default one, and this is how it looks
2256 like:
2257 </para>
2258 <screen>
2259 1 gentoo (0.9.12-1) unstable; urgency=low
2260 2
2261 3 * Initial release (Closes: #<replaceable>nnnn</replaceable>) &lt;<replaceable>nnnn</replaceable> is the bug number of your ITP&gt;
2262 4
2263 5 -- Josip Rodin &lt;joy-mg@debian.org&gt; Mon, 22 Mar 2010 00:37:31 +0100
2264 6
2265 </screen>
2266 <para>
2267 (I've added the line numbers.)
2268 </para>
2269 <para>
2270 Line 1 is the package name, version, distribution, and urgency. The name must
2271 match the source package name, distribution should be either
2272 <literal>unstable</literal> (or even <literal>experimental</literal>)
2273 <footnote><para> Some people use invalid distribution values such as
2274 <literal>UNRELEASED</literal> to prevent a package to be accidentally uploaded
2275 when updating a package in a shared VCS. </para> </footnote>, and urgency
2276 shouldn't be changed to anything higher than <literal>low</literal>. :-)
2277 </para>
2278 <para>
2279 Lines 3-5 are a log entry, where you document changes made in this package
2280 revision (not the upstream changes - there is special file for that purpose,
2281 created by the upstream authors, which you will later install as
2282 <filename>/usr/share/doc/gentoo/changelog.gz</filename>). Let's assume your
2283 ITP (Intent To Package) bug report number was <literal>12345</literal>. New
2284 lines must be inserted just before the uppermost line that begins with
2285 <literal>*</literal> (asterisk). You can do it with <citerefentry>
2286 <refentrytitle>dch</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>, or
2287 manually with a text editor.
2288 </para>
2289 <para>
2290 You will end up with something like this:
2291 </para>
2292 <screen>
2293 1 gentoo (0.9.12-1) unstable; urgency=low
2294 2
2295 3 * Initial Release. Closes: #12345
2296 4 * This is my first Debian package.
2297 5 * Adjusted the Makefile to fix $(DESTDIR) problems.
2298 6
2299 7 -- Josip Rodin &lt;joy-mg@debian.org&gt; Mon, 22 Mar 2010 00:37:31 +0100
2300 8
2301 </screen>
2302 <para>
2303 (I've added the line numbers.)
2304 </para>
2305 <para>
2306 You can read more about updating the <filename>changelog</filename> file later
2307 in <xref linkend="update"/>.
2308 </para>
2309 </section>
2310 <section id="rules"><title><filename>rules</filename> file</title>
2311 <para>
2312 Now we need to take a look at the exact rules which <citerefentry>
2313 <refentrytitle>dpkg-buildpackage</refentrytitle> <manvolnum>1</manvolnum>
2314 </citerefentry> will use to actually create the package. This file is actually
2315 another <filename>Makefile</filename>, but different from the one(s) in the
2316 upstream source. Unlike other files in <filename>debian</filename>, this one
2317 is marked as executable.
2318 </para>
2319 <section id="targets"><title>Targets of <filename>rules</filename> file</title>
2320 <para>
2321 Every <filename>rules</filename> file, as any other
2322 <filename>Makefile</filename>, consists of several targets and their rules
2323 specifying how to handle the source. <ulink url="&policy-debianrules;">Debian
2324 Policy Manual, 4.9 'Main building script: debian/rules'</ulink> explains its
2325 details.
2326 </para>
2327 <para>
2328 The simplified explanation of targets are the following.
2329 </para>
2330 <itemizedlist>
2331 <listitem>
2332 <para>
2333 <literal>clean</literal> target: to clean all compiled, generated, and useless
2334 files in the build-tree. (required)
2335 </para>
2336 </listitem>
2337 <listitem>
2338 <para>
2339 <literal>build</literal> target: to build the source into compiled programs and
2340 formatted documents in the build-tree. (required)
2341 </para>
2342 </listitem>
2343 <listitem>
2344 <para>
2345 <literal>install</literal> target: to install files into a file tree for each
2346 binary package under the <filename>debian</filename> directory. If defined,
2347 <literal>binary*</literal> targets effectively depend on this target.
2348 (optional)
2349 </para>
2350 </listitem>
2351 <listitem>
2352 <para>
2353 <literal>binary</literal> target: to create all binary packages (effectively
2354 combination of <literal>binary-arch</literal> and
2355 <literal>binary-indep</literal> targets). (required)<footnote><para> This
2356 target is used by <literal>dpkg-buildpackage</literal> as in <xref linkend="completebuild"/>. </para> </footnote>
2357 </para>
2358 </listitem>
2359 <listitem>
2360 <para>
2361 <literal>binary-arch</literal> target: to create arch-dependent
2362 (<literal>Architecture: any</literal>) binary packages in the parent directory.
2363 (required)<footnote><para> This target is used by <literal>dpkg-buildpackage
2364 -B</literal> as in <xref linkend="autobuilder"/>. </para> </footnote>
2365 </para>
2366 </listitem>
2367 <listitem>
2368 <para>
2369 <literal>binary-indep</literal> target: to create arch-independent
2370 (<literal>Architecture: all</literal>) binary packages in the parent directory.
2371 (required)<footnote><para> This target is used by <literal>dpkg-buildpackage
2372 -A</literal>. </para> </footnote>
2373 </para>
2374 </listitem>
2375 <listitem>
2376 <para>
2377 <literal>get-orig-source</literal> target: to obtain the most recent version of
2378 the original source package from upstream archive site. (optional)
2379 </para>
2380 </listitem>
2381 </itemizedlist>
2382 <para>
2383 Rules that you want to execute are invoked as command line arguments (for
2384 example, <literal>./debian/rules build</literal> or <literal>fakeroot make -f
2385 debian/rules binary</literal>). After the target name, you can name the
2386 dependency, program or file that the rule depends on. After that, there can be
2387 any number of commands, indented with
2388 <literal><replaceable>TAB</replaceable></literal>. A new rule begins with the
2389 target declaration in the first column. Empty lines and lines beginning with
2390 <literal>#</literal> (hash) are treated as comments and ignored.
2391 </para>
2392 <para>
2393 You are probably confused now, but it will all be clear upon examination of the
2394 <filename>rules</filename> file that <command>dh_make</command> gives us as a
2395 default. You should also read <literal>info make</literal> for more
2396 information.
2397 </para>
2398 </section>
2399 <section id="defaultrules"><title>Default <filename>rules</filename> file</title>
2400 <para>
2401 Newer <command>dh_make</command> generates a very simple but powerful default
2402 <filename>rules</filename> file using the <command>dh</command> command:
2403 </para>
2404 <screen>
2405 1 #!/usr/bin/make -f
2406 2 # -*- makefile -*-
2407 3 # Sample debian/rules that uses debhelper.
2408 4 # This file was originally written by Joey Hess and Craig Small.
2409 5 # As a special exception, when this file is copied by dh-make into a
2410 6 # dh-make output file, you may use that output file without restriction.
2411 7 # This special exception was added by Craig Small in version 0.37 of dh-make.
2412 8
2413 9 # Uncomment this to turn on verbose mode.
2414 10 #export DH_VERBOSE=1
2415 11
2416 12 %:
2417 13 dh $@
2418 </screen>
2419 <para>
2420 (I've added the line numbers. In the actual <filename>rules</filename> file,
2421 the leading white spaces are TAB codes.)
2422 </para>
2423 <para>
2424 You are probably familiar with lines like line 1 from shell and Perl scripts.
2425 It tells the operating system that this file is to be processed with
2426 <filename>/usr/bin/make</filename>.
2427 </para>
2428 <para>
2429 Line 11 can be uncommented to set <literal>DH_VERBOSE</literal> variable to 1.
2430 Then, the <command>dh</command> command will output which
2431 <command>dh_*</command> commands are executed by the <command>dh</command>
2432 command. You can also add <literal>export DH_OPTIONS=-v</literal> line here.
2433 Then each <command>dh_*</command> command will output which commands are
2434 executed by each <command>dh_*</command> command. This helps you to understand
2435 what exactly is going on behind this simple <filename>rules</filename> file and
2436 to debug its problems. This new <command>dh</command> is a core part of the
2437 <systemitem role="package">debhelper</systemitem> tools and does not hide
2438 anything from you.
2439 </para>
2440 <para>
2441 Lines 12 and 13 are where all the work is done. The percent sign means any
2442 targets which then call a single program, <command>dh</command> with the target
2443 name. <footnote><para> This uses the new <systemitem role="package">debhelper</systemitem> V7 features. Its design concepts are
2444 explained in <ulink url="&debhelper-slides;">Not Your
2445 Grandpa's Debhelper</ulink> presented at Debconf9 by the <systemitem role="package">debhelper</systemitem> upstream. Under
2446 <literal>lenny</literal>, <command>dh_make</command> created a much more
2447 complicated <filename>rules</filename> file with many <command>dh_*</command>
2448 scripts listed for each required explicit targets and frozen them to the state
2449 when it was initially packaged. This new <command>dh</command> command is
2450 simpler and frees us from this constrain. You still have full power to
2451 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
2452 package building process like the <systemitem role="package">cdbs</systemitem>
2453 package. </para> </footnote> The <command>dh</command> command is a wrapper
2454 script which runs appropriate sequences of <command>dh_*</command> programs
2455 depending on its argument. <footnote><para> You can verify actual sequences of
2456 <command>dh_*</command> programs invoked for a given
2457 <literal><replaceable>target</replaceable></literal> as <literal>dh --no-act
2458 <replaceable>target</replaceable></literal> or <literal>debian/rules --
2459 '--no-act <replaceable>target</replaceable>'</literal> without really running
2460 them. </para> </footnote>
2461 </para>
2462 <itemizedlist>
2463 <listitem>
2464 <para>
2465 <literal>debian/rules clean</literal> runs <literal>dh clean</literal>; which
2466 in turn runs the following:
2467 </para>
2468 <screen>
2469 dh_testdir
2470 dh_auto_clean
2471 dh_clean
2472 </screen>
2473 </listitem>
2474 <listitem>
2475 <para>
2476 <literal>debian/rules build</literal> runs <literal>dh build</literal>; which
2477 in turn runs the following:
2478 </para>
2479 <screen>
2480 dh_testdir
2481 dh_auto_configure
2482 dh_auto_build
2483 dh_auto_test
2484 </screen>
2485 </listitem>
2486 <listitem>
2487 <para>
2488 <literal>fakeroot debian/rules binary</literal> runs <literal>fakeroot dh
2489 binary</literal>; which in turn runs the following<footnote><para> This assumes
2490 that the <systemitem role="package">python-support</systemitem> package is
2491 installed on the system. </para> </footnote>:
2492 </para>
2493 <screen>
2494 dh_testroot
2495 dh_prep
2496 dh_installdirs
2497 dh_auto_install
2498 dh_install
2499 dh_installdocs
2500 dh_installchangelogs
2501 dh_installexamples
2502 dh_installman
2503 dh_installcatalogs
2504 dh_installcron
2505 dh_installdebconf
2506 dh_installemacsen
2507 dh_installifupdown
2508 dh_installinfo
2509 dh_pysupport
2510 dh_installinit
2511 dh_installmenu
2512 dh_installmime
2513 dh_installmodules
2514 dh_installlogcheck
2515 dh_installlogrotate
2516 dh_installpam
2517 dh_installppp
2518 dh_installudev
2519 dh_installwm
2520 dh_installxfonts
2521 dh_bugfiles
2522 dh_lintian
2523 dh_gconf
2524 dh_icons
2525 dh_perl
2526 dh_usrlocal
2527 dh_link
2528 dh_compress
2529 dh_fixperms
2530 dh_strip
2531 dh_makeshlibs
2532 dh_shlibdeps
2533 dh_installdeb
2534 dh_gencontrol
2535 dh_md5sums
2536 dh_builddeb
2537 </screen>
2538 </listitem>
2539 <listitem>
2540 <para>
2541 <literal>fakeroot debian/rules binary-arch</literal> runs <literal>fakeroot dh
2542 binary-arch</literal>; which in turn runs the same sequence as
2543 <literal>fakeroot dh binary</literal> but with the <literal>-a</literal> option
2544 appended for each command.
2545 </para>
2546 </listitem>
2547 <listitem>
2548 <para>
2549 <literal>fakeroot debian/rules binary-indep</literal> runs <literal>fakeroot dh
2550 binary-indep</literal>; which in turn runs almost the same sequence as
2551 <literal>fakeroot dh binary</literal> but excluding
2552 <command>dh_strip</command>, <command>dh_makeshlibs</command>, and
2553 <command>dh_shlibdeps</command> with the <literal>-i</literal> option appended
2554 for each remaining command.
2555 </para>
2556 </listitem>
2557 </itemizedlist>
2558 <para>
2559 The function of <command>dh_*</command> commands are almost self-evident from
2560 their names. <footnote><para> For complete information on what do all these
2561 <command>dh_*</command> scripts exactly do, and what their other options are,
2562 please read their respective manual pages and the <systemitem role="package">debhelper</systemitem> documentation. </para> </footnote> There
2563 are few notable ones worth making (over)simplified explanation here assuming
2564 typical build environment based on <filename>Makefile</filename>.
2565 <footnote><para> These commands support other build environments such as
2566 <filename>setup.py</filename> which can be listed by executing
2567 <literal>dh_auto_build --list</literal> in a package source directory. </para>
2568 </footnote>
2569 </para>
2570 <itemizedlist>
2571 <listitem>
2572 <para>
2573 <command>dh_auto_clean</command> usually executes the following if
2574 <filename>Makefile</filename> exists with the <literal>distclean</literal>
2575 target. <footnote><para> It actually looks for the first available target of
2576 <literal>distclean</literal>, <literal>realclean</literal> or
2577 <literal>clean</literal> in <filename>Makefile</filename> and execute it.
2578 </para> </footnote>
2579 </para>
2580 <screen>
2581 make distclean
2582 </screen>
2583 </listitem>
2584 <listitem>
2585 <para>
2586 <command>dh_auto_configure</command> usually executes the following if
2587 <filename>./configure</filename> exists (arguments abbreviated for
2588 readability).
2589 </para>
2590 <screen>
2591 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var ...
2592 </screen>
2593 </listitem>
2594 <listitem>
2595 <para>
2596 <command>dh_auto_build</command> usually executes the following to execute the
2597 first target of <filename>Makefile</filename> if it exists.
2598 </para>
2599 <screen>
2600 make
2601 </screen>
2602 </listitem>
2603 <listitem>
2604 <para>
2605 <command>dh_auto_test</command> usually executes the following if
2606 <filename>Makefile</filename> exists with the <literal>test</literal> target.
2607 <footnote><para> It actually looks for the first available target of
2608 <literal>test</literal> or <literal>check</literal> in
2609 <filename>Makefile</filename> and execute it. </para> </footnote>
2610 </para>
2611 <screen>
2612 make test
2613 </screen>
2614 </listitem>
2615 <listitem>
2616 <para>
2617 <command>dh_auto_install</command> usually executes the following if
2618 <filename>Makefile</filename> exists with the <literal>install</literal> target
2619 (line folded for readability).
2620 </para>
2621 <screen>
2622 make install \
2623 DESTDIR=<replaceable>/path/to</replaceable>/<replaceable>package</replaceable>_<replaceable>version</replaceable>-<replaceable>revision</replaceable>/debian/<replaceable>package</replaceable>
2624 </screen>
2625 </listitem>
2626 </itemizedlist>
2627 <para>
2628 Targets which require the <command>fakeroot</command> command contain
2629 <command>dh_testroot</command>. If you are not pretending to be root using
2630 this command, it exits with an error.
2631 </para>
2632 <para>
2633 The important part to know about the <filename>rules</filename> file created by
2634 <command>dh_make</command>, is that it is just a suggestion. It will work for
2635 most packages but for more complicated ones, don't be afraid to customize it to
2636 fit your needs. Only things that you must not change are the names of the
2637 rules, because all the tools use these names, as mandated by the Debian Policy.
2638 </para>
2639 <para>
2640 Although <literal>install</literal> is not required target, it is supported.
2641 <literal>fakeroot dh install</literal> behaves like <literal>fakeroot dh
2642 binary</literal> but stops after <command>dh_fixperms</command>.
2643 </para>
2644 </section>
2645 <section id="customrules"><title>Customization of <filename>rules</filename> file</title>
2646 <para>
2647 There are many ways to customize the <filename>rules</filename> file created
2648 with the new <command>dh</command> command.
2649 </para>
2650 <para>
2651 The <literal>dh $@</literal> command can be customized as follows.
2652 <footnote><para> If a package installs the
2653 <filename>/usr/share/perl5/Debian/Debhelper/Sequence/<replaceable>custom_name</replaceable>.pm</filename>
2654 file, you should activate its customization function by <literal>dh --with
2655 <replaceable>custom-name</replaceable> $@</literal>. </para> </footnote>
2656 </para>
2657 <itemizedlist>
2658 <listitem>
2659 <para>
2660 Add support of the <command>dh_pysupport</command> command. (The best choice
2661 for Python.) <footnote><para> Use of the <command>dh_pysupport</command>
2662 command is preferred over use of the <command>dh_pycentral</command> command.
2663 Do not use the <command>dh_python</command> command. </para> </footnote>
2664 </para>
2665 <itemizedlist>
2666 <listitem>
2667 <para>
2668 Install the <systemitem role="package">python-support</systemitem> package in
2669 <literal>Build-Depends</literal>.
2670 </para>
2671 </listitem>
2672 <listitem>
2673 <para>
2674 Use <literal>dh $@</literal> as usual. (This is enabled by default)
2675 </para>
2676 </listitem>
2677 <listitem>
2678 <para>
2679 This handles Python modules using the <systemitem role="package">python-support</systemitem> framework.
2680 </para>
2681 </listitem>
2682 </itemizedlist>
2683 </listitem>
2684 <listitem>
2685 <para>
2686 Add support of the <command>dh_pycentral</command> command.
2687 </para>
2688 <itemizedlist>
2689 <listitem>
2690 <para>
2691 Install the <systemitem role="package">python-central</systemitem> package in
2692 <literal>Build-Depends</literal>.
2693 </para>
2694 </listitem>
2695 <listitem>
2696 <para>
2697 Use <literal>dh --with python-central $@</literal> instead.
2698 </para>
2699 </listitem>
2700 <listitem>
2701 <para>
2702 This also deactivates the <command>dh_pysupport</command> command.
2703 </para>
2704 </listitem>
2705 <listitem>
2706 <para>
2707 This handles Python modules using the <systemitem role="package">python-central</systemitem> framework.
2708 </para>
2709 </listitem>
2710 </itemizedlist>
2711 </listitem>
2712 <listitem>
2713 <para>
2714 Add support of the <command>dh_installtex</command> command.
2715 </para>
2716 <itemizedlist>
2717 <listitem>
2718 <para>
2719 Install the <systemitem role="package">tex-common</systemitem> package in
2720 <literal>Build-Depends</literal>.
2721 </para>
2722 </listitem>
2723 <listitem>
2724 <para>
2725 Use <literal>dh --with tex $@</literal> instead.
2726 </para>
2727 </listitem>
2728 <listitem>
2729 <para>
2730 This registers Type 1 fonts, hyphenation patterns, or formats with TeX.
2731 </para>
2732 </listitem>
2733 </itemizedlist>
2734 </listitem>
2735 <listitem>
2736 <para>
2737 Add support of the <command>dh_quilt_patch</command> and
2738 <command>dh_quilt_unpatch</command> commands.
2739 </para>
2740 <itemizedlist>
2741 <listitem>
2742 <para>
2743 Install the <systemitem role="package">quilt</systemitem> package in
2744 <literal>Build-Depends</literal>.
2745 </para>
2746 </listitem>
2747 <listitem>
2748 <para>
2749 Use <literal>dh --with quilt $@</literal> instead.
2750 </para>
2751 </listitem>
2752 <listitem>
2753 <para>
2754 This applies and un-applies patches to the upstream source from files in the
2755 <filename>debian/patches</filename> directory for the <literal>1.0</literal>
2756 source package.
2757 </para>
2758 </listitem>
2759 <listitem>
2760 <para>
2761 This is not needed if you use the new <literal>3.0 (quilt)</literal> source
2762 package.
2763 </para>
2764 </listitem>
2765 </itemizedlist>
2766 </listitem>
2767 <listitem>
2768 <para>
2769 Add support of the <command>dh_dkms</command> command.
2770 </para>
2771 <itemizedlist>
2772 <listitem>
2773 <para>
2774 Install the <systemitem role="package">dkms</systemitem> package in
2775 <literal>Build-Depends</literal>.
2776 </para>
2777 </listitem>
2778 <listitem>
2779 <para>
2780 Use <literal>dh --with dkms $@</literal> instead.
2781 </para>
2782 </listitem>
2783 <listitem>
2784 <para>
2785 This correctly handles DKMS usage by the kernel module package.
2786 </para>
2787 </listitem>
2788 </itemizedlist>
2789 </listitem>
2790 <listitem>
2791 <para>
2792 Add support of the <command>dh_autotools-dev_updateconfig</command> and
2793 <command>dh_autotools-dev_restoreconfig</command> commands.
2794 </para>
2795 <itemizedlist>
2796 <listitem>
2797 <para>
2798 Install the <systemitem role="package">autotools-dev</systemitem> package in
2799 <literal>Build-Depends</literal>.
2800 </para>
2801 </listitem>
2802 <listitem>
2803 <para>
2804 Use <literal>dh --with autotools-dev $@</literal> instead.
2805 </para>
2806 </listitem>
2807 <listitem>
2808 <para>
2809 This updates and restores <filename>config.sub</filename> and
2810 <filename>config.guess</filename>.
2811 </para>
2812 </listitem>
2813 </itemizedlist>
2814 </listitem>
2815 <listitem>
2816 <para>
2817 Add support of the <command>dh_autoreconf</command> and
2818 <command>dh_autoreconf_clean</command> commands.
2819 </para>
2820 <itemizedlist>
2821 <listitem>
2822 <para>
2823 Install the <systemitem role="package">dh-autoreconf</systemitem> package in
2824 <literal>Build-Depends</literal>.
2825 </para>
2826 </listitem>
2827 <listitem>
2828 <para>
2829 Use <literal>dh --with autoreconf $@</literal> instead.
2830 </para>
2831 </listitem>
2832 <listitem>
2833 <para>
2834 This updates the GNU Build System files and restores them after the build.
2835 </para>
2836 </listitem>
2837 </itemizedlist>
2838 </listitem>
2839 <listitem>
2840 <para>
2841 Add support to the <command>bash</command> completion feature.
2842 </para>
2843 <itemizedlist>
2844 <listitem>
2845 <para>
2846 Install the <systemitem role="package">bash-completion</systemitem> package in
2847 <literal>Build-Depends</literal>.
2848 </para>
2849 </listitem>
2850 <listitem>
2851 <para>
2852 Use <literal>dh --with bash-completion $@</literal> instead.
2853 </para>
2854 </listitem>
2855 <listitem>
2856 <para>
2857 This installs <command>bash</command> completions using configuration file at
2858 <filename>debian/<replaceable>package</replaceable>.bash-completion</filename>.
2859 </para>
2860 </listitem>
2861 </itemizedlist>
2862 </listitem>
2863 </itemizedlist>
2864 <para>
2865 Many <command>dh_*</command> commands invoked by the new <command>dh</command>
2866 command can be customized by the corresponding configuration files in the
2867 <filename>debian</filename> directory. See <xref linkend="dother"/> and the
2868 manpage of each command for the customization of such features.
2869 </para>
2870 <para>
2871 Some <command>dh_*</command> commands invoked by the new <command>dh</command>
2872 command may require you to run it with some arguments or to run additional
2873 commands with them or to skip them. For such cases, you create an
2874 <literal>override_dh_<replaceable>foo</replaceable></literal> target with its
2875 rule in the <filename>rules</filename> file only for the
2876 <command>dh_<replaceable>foo</replaceable></command> command you want to
2877 change. It basically say <emphasis>run me instead</emphasis>.
2878 <footnote><para> Under <literal>lenny</literal>, if you wanted to change the
2879 behavior of a <command>dh_*</command> script you found the relevant line in the
2880 <filename>rules</filename> file and adjusted it. </para> </footnote>
2881 </para>
2882 <para>
2883 Please note that the <command>dh_auto_*</command> commands tend to do more than
2884 what has been discussed as (over)simplified explanation to take care all the
2885 corner cases. Use of simplified equivalent command instead of these in
2886 <literal>override_dh_*</literal> targets except the
2887 <literal>override_dh_auto_clean</literal> target is a bad idea since it may
2888 kill such <systemitem role="package">debhelper</systemitem>'s smart features.
2889 </para>
2890 <para>
2891 If you want to store the system configuration data in the
2892 <filename>/etc/gentoo</filename> directory instead of the usual
2893 <filename>/etc</filename> directory for the recent
2894 <systemitem role="package">gentoo</systemitem> package using Autotools, you can override the default
2895 <literal>--sysconfig=/etc</literal> argument given by the
2896 <command>dh_auto_configure</command> command to the
2897 <command>./configure</command> command by the following.
2898 </para>
2899 <screen>
2900 override_dh_auto_configure:
2901 dh_auto_configure -- --sysconfig=/etc/gentoo
2902 </screen>
2903 <para>
2904 The arguments given after <literal>--</literal> are appended to the default
2905 arguments of the auto-executed program to override them. Using the
2906 <command>dh_auto_configure</command> command is better than the
2907 <command>./configure</command> command here since it will only override the
2908 <literal>--sysconfig</literal> argument and keeps well intended other arguments
2909 to the <command>./configure</command> command.
2910 </para>
2911 <para>
2912 If <filename>Makefile</filename> of a source for <systemitem role="package">gentoo</systemitem> requires you to specify
2913 <literal>build</literal> as its target to build it <footnote><para>
2914 <command>dh_auto_build</command> without any arguments will execute the first
2915 target in the <filename>Makefile</filename> file. </para> </footnote>, you
2916 create an <literal>override_dh_auto_build</literal> target to enable it.
2917 </para>
2918 <screen>
2919 override_dh_auto_build:
2920 dh_auto_build -- build
2921 </screen>
2922 <para>
2923 This ensures to run $(MAKE) with all the default arguments given by the
2924 <command>dh_auto_build</command> command and <literal>build</literal> argument.
2925 </para>
2926 <para>
2927 If <filename>Makefile</filename> of a source for <systemitem role="package">gentoo</systemitem> requires you to specify the
2928 <literal>packageclean</literal> target to clean it for Debian package instead
2929 of the <literal>distclean</literal> or <literal>clean</literal> targets in the
2930 <filename>Makefile</filename> file, you create an
2931 <literal>override_dh_auto_clean</literal> target to enable it.
2932 </para>
2933 <screen>
2934 override_dh_auto_clean:
2935 $(MAKE) packageclean
2936 </screen>
2937 <para>
2938 If <filename>Makefile</filename> of a source for <systemitem role="package">gentoo</systemitem> contains <literal>test</literal> target
2939 which you do not want to run for the Debian package building process, you can
2940 use empty <literal>override_dh_auto_test</literal> target to skip it.
2941 </para>
2942 <screen>
2943 override_dh_auto_test:
2944 </screen>
2945 <para>
2946 If <systemitem role="package">gentoo</systemitem> has an unusual upstream
2947 changelog file called <filename>FIXES</filename>,
2948 <command>dh_installchangelogs</command> will not install that file by default.
2949 The <command>dh_installchangelogs</command> command requires
2950 <filename>FIXES</filename> as its argument to install it. <footnote><para> The
2951 <filename>debian/changelog</filename> and <filename>debian/NEWS</filename>
2952 files are always automatically installed. The upstream changelog is searched
2953 by converting filenames to the lower case and matching them with the
2954 <filename>changelog</filename>, <filename>changes</filename>,
2955 <filename>changelog.txt</filename>, and <filename>changes.txt</filename>.
2956 </para> </footnote>
2957 </para>
2958 <screen>
2959 override_dh_installchangelogs:
2960 dh_installchangelogs FIXES
2961 </screen>
2962 <para>
2963 When you use the new <command>dh</command> command, use of explicit targets
2964 such as the ones listed in <xref linkend="targets"/> except
2965 <literal>get-orig-source</literal> target may make it difficult to understand
2966 their exact effects. Please limit explicit targets to
2967 <literal>override_dh_*</literal> targets and completely independent ones, if
2968 possible.
2969 </para>
2970 </section>
2971 </section>
2972 </chapter>
2973 <chapter id="dother"><title>Other files under the <filename>debian</filename> directory</title>
2974 <para>
2975 To control most of what <systemitem role="package">debhelper</systemitem> does
2976 while building the package, you put optional configuration files under the
2977 <filename>debian</filename> directory. This chapter will provide an overview of
2978 what each of these does and its format. Please read the <ulink url="&debian-policy;">Debian Policy
2979 Manual</ulink> and <ulink url="&developers-reference;">Debian Developer's
2980 Reference</ulink> for guidelines for packaging.
2981 </para>
2982 <para>
2983 The <command>dh_make</command> command will create some template configuration
2984 files under the <filename>debian</filename> directory. Most of them come with
2985 filenames suffixed by <literal>.ex</literal>. Some of them come with filenames
2986 prefixed by the binary package name such as
2987 <literal><replaceable>package</replaceable></literal>. Take a look at all of
2988 them.
2989 <footnote><para>
2990 In this chapter, files in the <filename>debian</filename> directory are
2991 referred to without the preceding <filename>debian/</filename> for simplicity whenever
2992 they are obvious.
2993 </para></footnote>
2994 </para>
2995 <para>
2996 Some template configuration files for <systemitem role="package">debhelper</systemitem>
2997 may not be created by the <command>dh_make</command> command. In
2998 such cases, you need to create them with an editor.
2999 </para>
3000 <para>
3001 If you wish or need to activate any of these, please do the following:
3002 </para>
3003 <itemizedlist>
3004 <listitem>
3005 <para>
3006 rename template files by removing the <literal>.ex</literal> or
3007 <literal>.EX</literal> suffix if they have one;
3008 </para>
3009 </listitem>
3010 <listitem>
3011 <para>
3012 rename the configuration files to use the actual binary package
3013 name in place of <literal><replaceable>package</replaceable></literal>;
3014 </para>
3015 </listitem>
3016 <listitem>
3017 <para>
3018 modify template file contents to suit your needs;
3019 </para>
3020 </listitem>
3021 <listitem>
3022 <para>
3023 remove template files which you do not need;
3024 </para>
3025 </listitem>
3026 <listitem>
3027 <para>
3028 modify the <filename>control</filename> file (see <xref linkend="control"/>),
3029 if necessary;
3030 </para>
3031 </listitem>
3032 <listitem>
3033 <para>
3034 modify the <filename>rules</filename> file (see <xref linkend="rules"/>), if
3035 necessary.
3036 </para>
3037 </listitem>
3038 </itemizedlist>
3039 <para>
3040 Any <systemitem role="package">debhelper</systemitem> configuration files
3041 without a <filename><replaceable>package</replaceable></filename> prefix, such as
3042 <filename>install</filename>, apply to the first binary package. When there are
3043 many binary packages, their configurations can be specified by prefixing their
3044 name to their configuration filenames such as
3045 <filename><replaceable>package-1</replaceable>.install</filename>,
3046 <filename><replaceable>package-2</replaceable>.install</filename>, etc.
3047 </para>
3048 <section id="readme"><title><filename>README.Debian</filename></title>
3049 <para>
3050 Any extra details or discrepancies between the original package and your Debian
3051 version should be documented here.
3052 </para>
3053 <para>
3054 <command>dh_make</command> created a default one; this is what it looks like:
3055 </para>
3056 <screen>
3057 gentoo for Debian
3058 -----------------
3059 &lt;possible notes regarding this package - if none, delete this file&gt;
3060 -- Josip Rodin &lt;joy-mg@debian.org&gt;, Wed, 11 Nov 1998 21:02:14 +0100
3061 </screen>
3062 <para>
3063 If you have nothing to be documented, remove this file. See <citerefentry>
3064 <refentrytitle>dh_installdocs</refentrytitle> <manvolnum>1</manvolnum>
3065 </citerefentry>.
3066 </para>
3067 </section>
3068 <section id="compat"><title><filename>compat</filename></title>
3069 <para>
3070 The <filename>compat</filename> file defines the <systemitem role="package">debhelper</systemitem> compatibility level. Currently, you
3071 should set it to the <systemitem role="package">debhelper</systemitem> v7 as
3072 follows:
3073 </para>
3074 <screen>
3075 $ echo 7 &gt; debian/compat
3076 </screen>
3077 </section>
3078 <section id="conffiles"><title><filename>conffiles</filename></title>
3079 <para>
3080 One of the most annoying things about software is when you spend a great deal
3081 of time and effort customizing a program, only to have an upgrade stomp all
3082 over your changes. Debian solves this problem by marking such configuration files as conffiles.
3083 <footnote><para>See <citerefentry> <refentrytitle>dpkg</refentrytitle>
3084 <manvolnum>1</manvolnum> </citerefentry> and
3085 <ulink url="&policy-conffiles;">Debian Policy Manual 'D.2.5 Conffiles'</ulink>.
3086 </para></footnote>
3087 When you upgrade a package, you'll be asked whether you want to keep
3088 your old configuration files or not.
3089 </para>
3090 <para>
3091 Since <systemitem role="package">debhelper</systemitem> v3, <citerefentry>
3092 <refentrytitle>dh_installdeb</refentrytitle> <manvolnum>1</manvolnum>
3093 </citerefentry> will <emphasis>automatically</emphasis> flag any files under
3094 the <filename>/etc</filename> directory as conffiles, so if your program only
3095 has conffiles there you do not need to specify them in this file. For most
3096 package types, the only place conffiles should ever be is under
3097 <filename>/etc</filename>, and so this file doesn't need to exist.
3098 </para>
3099 <para>
3100 If your program uses configuration files but also rewrites them on its own,
3101 it's best not to make them conffiles because <command>dpkg</command> will
3102 then prompt users to verify the changes all the time.
3103 </para>
3104 <para>
3105 If the program you're packaging requires every user to modify the configuration
3106 files in the <filename>/etc</filename> directory, there are two popular ways to
3107 arrange for them to not be conffiles, keeping <command>dpkg</command> quiet.
3108 </para>
3109 <itemizedlist>
3110 <listitem>
3111 <para>
3112 Create a symlink under the <filename>/etc</filename> directory pointing to a
3113 file under the <filename>/var</filename> directory generated by the
3114 maintainer scripts.
3115 </para>
3116 </listitem>
3117 <listitem>
3118 <para>
3119 Create a file generated by the maintainer scripts under the <filename>/etc</filename> directory.
3120 </para>
3121 </listitem>
3122 </itemizedlist>
3123 <para>
3124 For information on maintainer scripts, see <xref linkend="maintscripts"/>.
3125 </para>
3126 </section>
3127 <section id="crond"><title><filename><replaceable>package</replaceable>.cron.*</filename></title>
3128 <para>
3129 If your package requires regularly scheduled tasks to operate properly, you can
3130 use these files to set that up. You can set up regular tasks that either happen
3131 hourly, daily, weekly, or monthly, or alternatively happen at any other time that
3132 you wish. The filenames are:
3133 </para>
3134 <itemizedlist>
3135 <listitem>
3136 <para>
3137 <filename><replaceable>package</replaceable>.cron.hourly</filename> - Installed as
3138 <filename>/etc/cron.hourly/<replaceable>package</replaceable></filename>; run
3139 once an hour.
3140 </para>
3141 </listitem>
3142 <listitem>
3143 <para>
3144 <filename><replaceable>package</replaceable>.cron.daily</filename> - Installed as
3145 <filename>/etc/cron.daily/<replaceable>package</replaceable></filename>; run
3146 once a day.
3147 </para>
3148 </listitem>
3149 <listitem>
3150 <para>
3151 <filename><replaceable>package</replaceable>.cron.weekly</filename> - Installed as
3152 <filename>/etc/cron.weekly/<replaceable>package</replaceable></filename>; run
3153 once a week.
3154 </para>
3155 </listitem>
3156 <listitem>
3157 <para>
3158 <filename><replaceable>package</replaceable>.cron.monthly</filename> - Installed as
3159 <filename>/etc/cron.monthly/<replaceable>package</replaceable></filename>: run
3160 once a month.
3161 </para>
3162 </listitem>
3163 <listitem>
3164 <para>
3165 <filename><replaceable>package</replaceable>.cron.d</filename> - Installed as
3166 <filename>/etc/cron.d/<replaceable>package</replaceable></filename>: for any
3167 other time.
3168 </para>
3169 </listitem>
3170 </itemizedlist>
3171 <para>
3172 Most of these files are shell scripts, with the exception of
3173 <filename><replaceable>package</replaceable>.cron.d</filename> which follows
3174 the format of <citerefentry> <refentrytitle>crontab</refentrytitle>
3175 <manvolnum>5</manvolnum> </citerefentry>.
3176 </para>
3177 <para>
3178 No explicit <filename>cron.*</filename> file is needed to set up log rotation;
3179 for that, see
3180 <citerefentry><refentrytitle>dh_installlogrotate</refentrytitle>
3181 <manvolnum>1</manvolnum></citerefentry> and
3182 <citerefentry><refentrytitle>logrotate</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
3183 </para>
3184 </section>
3185 <section id="dirs"><title><filename>dirs</filename></title>
3186 <para>
3187 This file specifies any directories which we need but which are not created by the normal installation
3188 procedure (<literal>make install DESTDIR=...</literal> invoked by
3189 <literal>dh_auto_install</literal>). This generally
3190 means there is a problem with the <filename>Makefile</filename>.
3191 </para>
3192 <para>
3193 Files listed in an <filename>install</filename> file don't need their
3194 directories created first. See <xref linkend="install"/>.
3195 </para>
3196 <para>
3197 It is best to try to run the installation first and only use this if you
3198 run into trouble. There is no preceding slash on the directory names listed in
3199 the <filename>dirs</filename> file.
3200 </para>
3201 </section>
3202 <section id="doc-base"><title><filename><replaceable>package</replaceable>.doc-base</filename></title>
3203 <para>
3204 If your package has documentation other than manual and info pages, you
3205 should use the <systemitem role="package">doc-base</systemitem> file to
3206 register it, so the user can find it with e.g. <citerefentry>
3207 <refentrytitle>dhelp</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>,
3208 <citerefentry> <refentrytitle>dwww</refentrytitle> <manvolnum>1</manvolnum>
3209 </citerefentry>, or <citerefentry> <refentrytitle>doccentral</refentrytitle>
3210 <manvolnum>1</manvolnum> </citerefentry>.
3211 </para>
3212 <para>
3213 This usually includes HTML, PS and PDF files, shipped in
3214 <filename>/usr/share/doc/<replaceable>packagename</replaceable>/</filename>.
3215 </para>
3216 <para>
3217 This is what <systemitem role="package">gentoo</systemitem>'s doc-base file
3218 <filename>gentoo.doc-base</filename> looks like:
3219 </para>
3220 <screen>
3221 Document: gentoo
3222 Title: Gentoo Manual
3223 Author: Emil Brink
3224 Abstract: This manual describes what Gentoo is, and how it can be used.
3225 Section: File Management
3226 Format: HTML
3227 Index: /usr/share/doc/gentoo/html/index.html
3228 Files: /usr/share/doc/gentoo/html/*.html
3229 </screen>
3230 <para>
3231 For information on the file format, see <citerefentry>
3232 <refentrytitle>install-docs</refentrytitle> <manvolnum>8</manvolnum>
3233 </citerefentry> and the <systemitem role="package">doc-base</systemitem>
3234 manual, in <ulink url="&doc-base;">Debian doc-base Manual</ulink>.
3235 </para>
3236 <para>
3237 For more details on installing additional documentation, look in <xref linkend="destdir"/>.
3238 </para>
3239 </section>
3240 <section id="docs"><title><filename>docs</filename></title>
3241 <para>
3242 This file specifies the file names of documentation files we can have
3243 <citerefentry> <refentrytitle>dh_installdocs</refentrytitle>
3244 <manvolnum>1</manvolnum> </citerefentry> install into the temporary directory
3245 for us.
3246 </para>
3247 <para>
3248 By default, it will include all existing files in the top-level source
3249 directory that are called <filename>BUGS</filename>,
3250 <filename>README*</filename>, <filename>TODO</filename> etc.
3251 </para>
3252 <para>
3253 For <systemitem role="package">gentoo</systemitem>, some other files
3254 are also included:
3255 </para>
3256 <screen>
3257 BUGS
3258 CONFIG-CHANGES
3259 CREDITS
3260 NEWS
3261 README
3262 README.gtkrc
3263 TODO
3264 </screen>
3265 </section>
3266 <section id="emacsen"><title><filename>emacsen-*</filename></title>
3267 <para>
3268 If your package supplies Emacs files that can be bytecompiled at package
3269 installation time, you can use these files to set it up.
3270 </para>
3271 <para>
3272 They are installed into the temporary directory by <citerefentry>
3273 <refentrytitle>dh_installemacsen</refentrytitle> <manvolnum>1</manvolnum>
3274 </citerefentry>.
3275 </para>
3276 <para>
3277 If you don't need these, remove them.
3278 </para>
3279 </section>
3280 <section id="examples"><title><filename><replaceable>package</replaceable>.examples</filename></title>
3281 <para>
3282 The <citerefentry> <refentrytitle>dh_installexamples</refentrytitle>
3283 <manvolnum>1</manvolnum> </citerefentry> command installs files and directories
3284 listed in this file as example files.
3285 </para>
3286 </section>
3287 <section id="initd"><title><filename><replaceable>package</replaceable>.init</filename> and <filename><replaceable>package</replaceable>.default</filename></title>
3288 <para>
3289 If your package is a daemon that needs to be run at system start-up, you've
3290 obviously disregarded my initial recommendation, haven't you? :-)
3291 </para>
3292 <para>
3293 The <filename><replaceable>package</replaceable>.init</filename> file is
3294 installed as the
3295 <filename>/etc/init.d/<replaceable>package</replaceable></filename> script
3296 which starts and stops the daemon.
3297 Its fairly generic skeleton template is provided by the
3298 <command>dh_make</command> command as <filename>init.d.ex</filename>. You'll
3299 likely have to rename and edit it, a lot, while making sure to provide
3300 <ulink url="&lsb;">Linux Standard Base</ulink> (LSB) compliant headers. It
3301 gets installed into the temporary directory by <citerefentry>
3302 <refentrytitle>dh_installinit</refentrytitle> <manvolnum>1</manvolnum>
3303 </citerefentry>.
3304 </para>
3305 <para>
3306 The <filename><replaceable>package</replaceable>.default</filename> file will
3307 be installed as
3308 <filename>/etc/default/<replaceable>package</replaceable></filename>. This
3309 file sets defaults that are sourced by the init script. This
3310 <filename><replaceable>package</replaceable>.default</filename> file
3311 is most often used to disable running a daemon, or to set some default flags or
3312 timeouts. If your init script has certain configurable
3313 features, you can set them in the <filename><replaceable>package</replaceable>.default</filename> file,
3314 instead of in the init script itself.
3315 </para>
3316 <para>
3317 If your upstream program provides a file for the init script, you can either use it or not. If you
3318 don't use their init script then create a new one in
3319 <filename><replaceable>package</replaceable>.init</filename>. However
3320 if the upstream init script looks fine and installs in the right place you
3321 still need to set up the <filename>rc*</filename> symlinks. To do this you will
3322 need to override <command>dh_installinit</command> in the
3323 <filename>rules</filename> file with the following lines:
3324 </para>
3325 <screen>
3326 override_dh_installinit:
3327 dh_installinit --onlyscripts
3328 </screen>
3329 <para>
3330 If you don't need this, remove the files.
3331 </para>
3332 </section>
3333 <section id="install"><title><filename>install</filename></title>
3334 <para>
3335 If there are files that need to be installed into your package but your
3336 standard <literal>make install</literal> won't do it, put the filenames and
3337 destinations into this <filename>install</filename> file. They are installed
3338 by <citerefentry> <refentrytitle>dh_install</refentrytitle>
3339 <manvolnum>1</manvolnum> </citerefentry>.<footnote><para> This replaces the
3340 deprecated <citerefentry> <refentrytitle>dh_movefiles</refentrytitle>
3341 <manvolnum>1</manvolnum> </citerefentry> command which is configured by the
3342 <filename>files</filename> file. </para> </footnote> You should first check
3343 there is not a more specific tool to use. For example, documents should be in
3344 the <filename>docs</filename> file and not in this one.
3345 </para>
3346 <para>
3347 This <filename>install</filename> file has one line per file installed, with
3348 the name of the file (relative to the top build directory) then a space then
3349 the installation directory (relative to the install directory). One example of where this is used is if a binary <filename>src/<replaceable>bar</replaceable></filename> is left uninstalled; the
3350 <filename>install</filename> file might look like:
3351 </para>
3352 <screen>
3353 src/<replaceable>bar</replaceable> usr/bin
3354 </screen>
3355 <para>
3356 This means when this package is installed, there will be a binary executable
3357 <filename>/usr/bin/<replaceable>bar</replaceable></filename>.
3358 </para>
3359 <para>
3360 Alternatively, this <filename>install</filename> can have the name of the file
3361 only without the installation directory when the relative directory path does
3362 not change. This format is usually used for a large package that splits the
3363 output of its build into multiple binary packages using
3364 <filename><replaceable>package-1</replaceable>.install</filename>,
3365 <filename><replaceable>package-2</replaceable>.install</filename>, etc.
3366 </para>
3367 <para>
3368 The <command>dh_install</command> command will fall back to looking in
3369 <filename>debian/tmp</filename> for files, if it doesn't find them in the
3370 current directory (or wherever you've told it to look using
3371 <literal>--sourcedir</literal>).
3372 </para>
3373 </section>
3374 <section id="info"><title><filename><replaceable>package</replaceable>.info</filename></title>
3375 <para>
3376 If your package has info pages, you should install them using <citerefentry>
3377 <refentrytitle>dh_installinfo</refentrytitle> <manvolnum>1</manvolnum>
3378 </citerefentry> by listing them in a
3379 <filename><replaceable>package</replaceable>.info</filename> file.
3380 </para>
3381 </section>
3382 <section id="lintian"><title><filename>{<replaceable>package</replaceable>.,source/}lintian-overrides</filename></title>
3383 <para>
3384 If <systemitem role="package">lintian</systemitem> reports an erroneous
3385 diagnostic for a case where Debian policy allows exceptions to some rule, you can
3386 use <filename><replaceable>package</replaceable>.lintian-overrides</filename>
3387 or <filename>source/lintian-overrides</filename> to quieten it. Please read
3388 <ulink url="&lintian-doc;">Lintian User's Manual</ulink> and refrain
3389 from abusing this.
3390 </para>
3391 <para>
3392 <filename><replaceable>package</replaceable>.lintian-overrides</filename> is
3393 for the binary package named <systemitem role="package"><replaceable>package</replaceable></systemitem> and is installed
3394 into
3395 <filename>usr/share/lintian/overrides/<replaceable>package</replaceable></filename>
3396 by the <command>dh_lintian</command> command.
3397 </para>
3398 <para>
3399 <filename>source/lintian-overrides</filename> is for the source package. This
3400 is not installed.
3401 </para>
3402 </section>
3403 <section id="manpage"><title><filename>manpage.*</filename></title>
3404 <para>
3405 Your program(s) should have a manual page. If they don't, you should create
3406 them. The <command>dh_make</command> command creates some template files for
3407 manual pages. These need to be copied and edited for each command missing its
3408 manual page. Please make sure to remove unused templates.
3409 </para>
3410 <section id="manpage1"><title><filename>manpage.1.ex</filename></title>
3411 <para>
3412 Manual pages are normally written in <citerefentry>
3413 <refentrytitle>nroff</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.
3414 The <filename>manpage.1.ex</filename> template is written in
3415 <command>nroff</command>, too. See the <citerefentry>
3416 <refentrytitle>man</refentrytitle> <manvolnum>7</manvolnum> </citerefentry>
3417 manual page for a brief description of how to edit such a file.
3418 </para>
3419 <para>
3420 The final manual page file name should give the name of the program it is
3421 documenting, so we will rename it from <literal>manpage</literal> to
3422 <literal>gentoo</literal>. The file name also includes <literal>.1</literal>
3423 as the first suffix, which means it's a manual page for a user command. Be
3424 sure to verify that this section is indeed the correct one. Here's a short
3425 list of manual page sections:
3426 </para>
3427 <informaltable id="manpage-sections" pgwide="0" frame="topbot" rowsep="1" colsep="1">
3428 <tgroup cols="3">
3429 <colspec colwidth="8*" align="left"/> <colspec colwidth="24*" align="left"/> <colspec colwidth="40*" align="left"/>
3430 <thead>
3431 <row> <entry>Section</entry> <entry>Description</entry> <entry>Notes</entry> </row>
3432 </thead>
3433 <tbody>
3434 <row> <entry>1</entry> <entry>User command</entry> <entry>Executable commands or scripts</entry> </row>
3435 <row> <entry>2</entry> <entry>System calls</entry> <entry>Functions provided by the kernel</entry> </row>
3436 <row> <entry>3</entry> <entry>Library calls</entry> <entry>Functions within system libraries</entry> </row>
3437 <row> <entry>4</entry> <entry>Special files</entry> <entry>Usually found in <filename>/dev</filename></entry> </row>
3438 <row> <entry>5</entry> <entry>File formats</entry> <entry>E.g. <filename>/etc/passwd</filename>'s format</entry> </row>
3439 <row> <entry>6</entry> <entry>Games</entry> <entry>Games or other frivolous programs</entry> </row>
3440 <row> <entry>7</entry> <entry>Macro packages</entry> <entry>Such as <command>man</command> macros</entry> </row>
3441 <row> <entry>8</entry> <entry>System administration</entry> <entry>Programs typically only run by root</entry> </row>
3442 <row> <entry>9</entry> <entry>Kernel routines</entry> <entry>Non-standard calls and internals</entry> </row>
3443 </tbody>
3444 </tgroup>
3445 </informaltable>
3446 <para>
3447 So <systemitem role="package">gentoo</systemitem>'s man page should be called
3448 <filename>gentoo.1</filename>. If there was no <filename>gentoo.1</filename>
3449 man page in the original source, you should create it by renaming the
3450 <filename>manpage.1.ex</filename> template to <filename>gentoo.1</filename> and
3451 editing it using information from the example and from the upstream docs.
3452 </para>
3453 <para>
3454 You can use the <command>help2man</command> command to generate a man page out
3455 of the <literal>--help</literal> and <literal>--version</literal> output of each
3456 program, too. <footnote><para> Note that <command>help2man</command>'s
3457 placeholder man page will claim that more detailed documentation is
3458 available in the info system. If the command is missing an
3459 <command>info</command> page, you
3460 should manually edit the man page created by the
3461 <command>help2man</command> command. </para> </footnote>
3462 </para>
3463 </section>
3464 <section id="manpagesgml"><title><filename>manpage.sgml.ex</filename></title>
3465 <para>
3466 If on the other hand you prefer writing SGML instead of
3467 <command>nroff</command>, you can use the <filename>manpage.sgml.ex</filename>
3468 template. If you do this, you have to:
3469 </para>
3470 <itemizedlist>
3471 <listitem>
3472 <para>
3473 rename the file to something like <filename>gentoo.sgml</filename>.
3474 </para>
3475 </listitem>
3476 <listitem>
3477 <para>
3478 install the <systemitem role="package">docbook-to-man</systemitem> package
3479 </para>
3480 </listitem>
3481 <listitem>
3482 <para>
3483 add <literal>docbook-to-man</literal> to the <literal>Build-Depends</literal>
3484 line in the <filename>control</filename> file
3485 </para>
3486 </listitem>
3487 <listitem>
3488 <para>
3489 add an <literal>override_dh_auto_build</literal> target to your
3490 <filename>rules</filename> file:
3491 </para>
3492 <screen>
3493 override_dh_auto_build:
3494 docbook-to-man debian/gentoo.sgml &gt; debian/gentoo.1
3495 dh_auto_build
3496 </screen>
3497 </listitem>
3498 </itemizedlist>
3499 </section>
3500 <section id="manpagexml"><title><filename>manpage.xml.ex</filename></title>
3501 <para>
3502 If you prefer XML over SGML, you can use the <literal>manpage.xml.ex</literal>
3503 template. If you do this, you have to:
3504 </para>
3505 <itemizedlist>
3506 <listitem>
3507 <para>
3508 rename the source file to something like <literal>gentoo.1.xml</literal>
3509 </para>
3510 </listitem>
3511 <listitem>
3512 <para>
3513 install the <systemitem role="package">docbook-xsl</systemitem> package and an
3514 XSLT processor like <systemitem role="package">xsltproc</systemitem>
3515 (recommended)
3516 </para>
3517 </listitem>
3518 <listitem>
3519 <para>
3520 add the <literal>docbook-xsl</literal>, <literal>docbook-xml</literal>, and
3521 <literal>xsltproc</literal> packages to the <literal>Build-Depends</literal>
3522 line in the <literal>control</literal> file
3523 </para>
3524 </listitem>
3525 <listitem>
3526 <para>
3527 add an <literal>override_dh_auto_build</literal> target to your
3528 <filename>rules</filename> file:
3529 </para>
3530 <screen>
3531 override_dh_auto_build:
3532 xsltproc --nonet \
3533 --param make.year.ranges 1 \
3534 --param make.single.year.ranges 1 \
3535 --param man.charmap.use.subset 0 \
3536 -o debian/ \
3537 http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl\
3538 debian/gentoo.1.xml
3539 dh_auto_build
3540 </screen>
3541 </listitem>
3542 </itemizedlist>
3543 </section>
3544 </section>
3545 <section id="manpages"><title><filename><replaceable>package</replaceable>.manpages</filename> file</title>
3546 <para>
3547 If your package has manual pages, you should install them using <citerefentry>
3548 <refentrytitle>dh_installman</refentrytitle> <manvolnum>1</manvolnum>
3549 </citerefentry> by listing them in a
3550 <filename><replaceable>package</replaceable>.manpages</filename> file.
3551 </para>
3552 <para>
3553 To install <filename>docs/gentoo.1</filename> as a manpage for the <systemitem role="package">gentoo</systemitem> package, create a
3554 <filename>gentoo.manpages</filename> file as follows.
3555 </para>
3556 <screen>
3557 docs/gentoo.1
3558 </screen>
3559 </section>
3560 <section id="menu"><title><filename>menu</filename></title>
3561 <para>
3562 X Window System users usually have a window manager with a menu that can be
3563 customized to launch programs. If they have installed the Debian <systemitem role="package">menu</systemitem> package, a set of menus for every program on
3564 the system will be created for them.
3565 </para>
3566 <para>
3567 Here's the default <filename>menu.ex</filename> file that
3568 <command>dh_make</command> created.
3569 </para>
3570 <screen>
3571 ?package(gentoo):needs=X11|text|vc|wm \
3572 section=Applications/see-menu-manual\
3573 title=gentoo command=/usr/bin/gentoo
3574 </screen>
3575 <para>
3576 The first field after the colon character is <literal>needs</literal>, and it
3577 specifies what kind of interface the program needs. Change this to one of the
3578 listed alternatives, e.g. <literal>text</literal> or <literal>X11</literal>.
3579 </para>
3580 <para>
3581 The next is the <literal>section</literal> that the menu and submenu entry
3582 should appear in.
3583 <footnote><para> The current list of sections is in
3584 <ulink url="&menu-structure;">The Debian Menu sub-policy 2.1 'Preferred menu structure'</ulink>.
3585 There was a major reorganization of menu structure for <literal>squeeze</literal>.
3586 </para> </footnote>
3587 </para>
3588 <para>
3589 The <literal>title</literal> field is the name of the program. You can start
3590 this one in uppercase if you like. Just keep it short.
3591 </para>
3592 <para>
3593 Finally, the <literal>command</literal> field is the command that runs the
3594 program.
3595 </para>
3596 <para>
3597 Let's change the file name to <filename>menu</filename> and change the menu
3598 entry to this:
3599 </para>
3600 <screen>
3601 ?package(gentoo): needs=X11 \
3602 section=Applications/Tools \
3603 title=Gentoo command=gentoo
3604 </screen>
3605 <para>
3606 You can also add other fields like <literal>longtitle</literal>,
3607 <literal>icon</literal>, <literal>hints</literal> etc. See <citerefentry>
3608 <refentrytitle>dh_installmenu</refentrytitle> <manvolnum>1</manvolnum>
3609 </citerefentry>, <citerefentry> <refentrytitle>menufile</refentrytitle>
3610 <manvolnum>5</manvolnum> </citerefentry>, <citerefentry>
3611 <refentrytitle>update-menus</refentrytitle> <manvolnum>1</manvolnum>
3612 </citerefentry>, and
3613 <ulink url="&menu-policy;">The Debian Menu sub-policy</ulink> for more
3614 information.
3615 </para>
3616 </section>
3617 <section id="news"><title><filename>NEWS</filename></title>
3618 <para>
3619 The <citerefentry> <refentrytitle>dh_installchangelogs</refentrytitle>
3620 <manvolnum>1</manvolnum> </citerefentry> command installs this.
3621 </para>
3622 </section>
3623 <section id="maintscripts"><title><filename>{pre,post}{inst,rm}</filename></title>
3624 <para>
3625 These <filename>postinst</filename>, <filename>preinst</filename>,
3626 <filename>postrm</filename>, and <filename>prerm</filename> files
3627 <footnote><para> Despite this use of the <command>bash</command>
3628 shorthand expression <filename>{pre,post}{inst,rm}</filename> to indicate these
3629 filenames, you should use pure POSIX syntax for these maintainer scripts for
3630 compatibility with <command>dash</command> as the system shell. </para> </footnote> are
3631 called <emphasis>maintainer scripts</emphasis>. They are scripts which are put
3632 in the control area of the package and run by <command>dpkg</command> when your
3633 package is installed, upgraded, or removed.
3634 </para>
3635 <para>
3636 As a novice maintainer, you should avoid any manual editing of
3637 maintainer scripts because they are problematic. For more
3638 information refer to the <ulink url="&policy-mantainerscripts;">Debian
3639 Policy Manual, 6 'Package maintainer scripts and installation
3640 procedure'</ulink>, and take a look at the example files provided by
3641 <command>dh_make</command>.
3642 </para>
3643 <para>
3644 If you did not listen to me and have created custom maintainer
3645 scripts for a package, you should make sure to test them not only
3646 for <emphasis role="strong">install</emphasis> and
3647 <emphasis role="strong">upgrade</emphasis> but also for
3648 <emphasis role="strong">remove</emphasis> and
3649 <emphasis role="strong">purge</emphasis>.
3650 </para>
3651 <para>
3652 Upgrades to the new version should be silent and non-intrusive (existing users
3653 should not notice the upgrade except by discovering that old bugs have been
3654 fixed and perhaps that there are new features).
3655 </para>
3656 <para>
3657 When the upgrade is necessarily intrusive (eg., config files scattered through
3658 various home directories with totally different structure), you may
3659 consider as the last resort switching the package to a safe fallback state
3660 (e.g., disabling a service) and providing the proper documentation
3661 required by policy (<filename>README.Debian</filename> and
3662 <filename>NEWS.Debian</filename>). Don't bother the user with
3663 <command>debconf</command> notes invoked from these maintainer scripts
3664 for upgrades.
3665 </para>
3666 <para>
3667 The <systemitem role="package">ucf</systemitem> package provides a
3668 <emphasis>conffile-like</emphasis> handling infrastructure to preserve user
3669 changes for files that may not be labeled as <emphasis>conffiles</emphasis> such
3670 as those managed by the maintainer scripts. This should
3671 minimize issues associated with them.
3672 </para>
3673 <para>
3674 These maintainer scripts are among the Debian enhancements that
3675 explain <emphasis role="strong">why people choose Debian</emphasis>. You must
3676 be very careful not to turn them into a source of annoyance.
3677 </para>
3678 </section>
3679 <section id="todo"><title><filename>TODO</filename></title>
3680 <para>
3681 The <citerefentry> <refentrytitle>dh_installdocs</refentrytitle>
3682 <manvolnum>1</manvolnum> </citerefentry> command installs this.
3683 </para>
3684 </section>
3685 <section id="watch"><title><filename>watch</filename></title>
3686 <para>
3687 The <filename>watch</filename> file format is documented in the <citerefentry>
3688 <refentrytitle>uscan</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>
3689 manpage. The <filename>watch</filename> file configures the
3690 <command>uscan</command> program (in the <systemitem role="package">devscripts</systemitem> package) to watch the site where you
3691 originally got the source from. This is also used by the
3692 <ulink url="&dehs;">Debian External Health Status (DEHS)</ulink> service.
3693 </para>
3694 <para>
3695 Here are its contents:
3696 </para>
3697 <screen>
3698 # watch control file for uscan
3699 version=3
3700 &sf-net;/gentoo/gentoo-(.+)\.tar\.gz debian uupdate
3701 </screen>
3702 <para>
3703 Normally with a <filename>watch</filename> file, the URL at
3704 <literal>&sf-net;/gentoo</literal> is downloaded and searched for links of
3705 the form <literal>&lt;a href=...&gt;</literal>. The basename (just the part
3706 after the final <literal>/</literal>) of each linked URL is compared against
3707 the Perl regular expression pattern (see <citerefentry> <refentrytitle>perlre</refentrytitle>
3708 <manvolnum>1</manvolnum> </citerefentry>)
3709 <literal>gentoo-(.+)\.tar\.gz</literal>. Out of the files that match, the one with
3710 the greatest version number is downloaded and the <command>uupdate</command>
3711 program is run to create an updated source tree.
3712 </para>
3713 <para>
3714 Although this is true for other sites, the SourceForge download service at
3715 <ulink url="&sf-net;"/> is an exception. When the
3716 <filename>watch</filename> file has an URL matching the Perl regexp
3717 <literal>^http://sf\.net/</literal>, the <command>uscan</command> program
3718 replaces it with <literal>&qa-do;watch/sf.php/</literal> and
3719 then applies this rule. The URL redirector service at <ulink url="&qa-do;"/> is designed to offer
3720 a stable redirect service to the desired file for any
3721 <filename>watch</filename> pattern of the form
3722 <literal>&sf-net;/<replaceable>project</replaceable>/<replaceable>tar-name</replaceable>-(.+)\.tar\.gz</literal>.
3723 This solves issues related to periodically changing SourceForge URLs.
3724 </para>
3725 </section>
3726 <section id="sourcef"><title><filename>source/format</filename></title>
3727 <para>
3728 In the <filename>debian/source/format</filename> file, there should be a single
3729 line indicating the desired format for the source package (check <citerefentry>
3730 <refentrytitle>dpkg-source</refentrytitle> <manvolnum>1</manvolnum>
3731 </citerefentry> for an exhaustive list). After <literal>squeeze</literal>, it
3732 should say either:
3733 </para>
3734 <itemizedlist>
3735 <listitem>
3736 <para>
3737 <literal>3.0 (native)</literal> for Debian native packages or
3738 </para>
3739 </listitem>
3740 <listitem>
3741 <para>
3742 <literal>3.0 (quilt)</literal> for everything else.
3743 </para>
3744 </listitem>
3745 </itemizedlist>
3746 <para>
3747 The newer <literal>3.0 (quilt)</literal> source format records modifications in
3748 a <command>quilt</command> patch series within
3749 <filename>debian/patches</filename>. Those changes are then automatically
3750 applied during extraction of the source package. <footnote><para> See
3751 <ulink url="&debsrc3;">DebSrc3.0</ulink> for a summary on the switch to the new <literal>3.0
3752 (quilt)</literal> and <literal>3.0 (native)</literal> source formats. </para>
3753 </footnote> The Debian modifications are simply stored in a
3754 <filename>debian.tar.gz</filename> archive containing all files under the
3755 <filename>debian</filename> directory. This new format supports inclusion of
3756 binary files such as PNG icons by the package maintainer without requiring
3757 tricks. <footnote><para>Actually, this new format also supports multiple
3758 upstream tarballs and more compression methods. These are beyond the scope of
3759 this document.</para> </footnote>
3760 </para>
3761 <para>
3762 When <command>dpkg-source</command> extracts a source package in <literal>3.0
3763 (quilt)</literal> source format, it automatically applies all patches listed in
3764 <filename>debian/patches/series</filename>. You can avoid applying patches at
3765 the end of the extraction with the <literal>--skip-patches</literal> option.
3766 </para>
3767 </section>
3768 <section id="sourcel"><title><filename>source/local-options</filename></title>
3769 <para>
3770 When you want to manage Debian packaging activities under a VCS, you typically
3771 create one branch (e.g. <literal>upstream</literal>) tracking the upstream
3772 source and another branch (e.g. typically <literal>master</literal> for Git)
3773 tracking the Debian package. For the latter, you usually want to have
3774 unpatched upstream source with your <filename>debian/*</filename> files for the
3775 Debian packaging to ease merging of the new upstream source.
3776 </para>
3777 <para>
3778 After you build a package, the source is normally left patched. You need to
3779 unpatch it manually by running <literal>dquilt pop -a</literal> before
3780 committing to the <literal>master</literal> branch. You can automate this by
3781 adding the optional <filename>debian/source/local-options</filename> file
3782 containing <literal>unapply-patches</literal>. This file is not included in
3783 the generated source package and changes the local build behavior only. This
3784 file may contain <literal>abort-on-upstream-changes</literal>, too (see
3785 <citerefentry> <refentrytitle>dpkg-source</refentrytitle>
3786 <manvolnum>1</manvolnum> </citerefentry>).
3787 </para>
3788 <screen>
3789 unapply-patches
3790 abort-on-upstream-changes
3791 </screen>
3792 </section>
3793 <section id="sourceopt"><title><filename>source/options</filename></title>
3794 <para>
3795 The autogenerated files in the source tree can be quite annoying for packaging
3796 since they generate meaningless large patch files. There are custom modules
3797 such as <command>dh_autoreconf</command> to ease this problem as described in
3798 <xref linkend="customrules"/>.
3799 </para>
3800 <para>
3801 You can provide a Perl regular expression to the
3802 <literal>--extend-diff-ignore</literal> option argument of <citerefentry>
3803 <refentrytitle>dpkg-source</refentrytitle><manvolnum>1</manvolnum>
3804 </citerefentry> to ignore changes made to the autogenerated files while
3805 creating the source package.
3806 </para>
3807 <para>
3808 As a general solution to address this problem of the autogenerated files,
3809 you can store such a <command>dpkg-source</command> option argument in the
3810 <filename>source/options</filename> file of the source package. The following
3811 will skip creating patch files for <filename>config.sub</filename>,
3812 <filename>config.guess</filename>, and <filename>Makefile</filename>.
3813 </para>
3814 <screen>
3815 extend-diff-ignore = "(^|/)(config\.sub|config\.guess|Makefile)$"
3816 </screen>
3817 </section>
3818 <section id="patches"><title><filename>patches/*</filename></title>
3819 <para>
3820 The old <literal>1.0</literal> source format created a single large
3821 <filename>diff.gz</filename> file containing package maintenance files in
3822 <filename>debian</filename> and patch files for the source. Such a package is a
3823 bit cumbersome to inspect and understand for each source tree modification
3824 later. This is not so nice.
3825 </para>
3826 <para>
3827 The newer <literal>3.0 (quilt)</literal> source format stores patches in
3828 <filename>debian/patches/*</filename> files using the <command>quilt</command>
3829 command. These patches and other package data which are all contained under
3830 the <filename>debian</filename> directory are packaged as the
3831 <filename>debian.tar.gz</filename> file. Since the
3832 <command>dpkg-source</command> command can handle <command>quilt</command>
3833 formatted patch data in the <literal>3.0 (quilt)</literal> source without the
3834 <systemitem role="package">quilt</systemitem> package, it does not need a
3835 <literal>Build-Depends</literal> on <systemitem role="package">quilt</systemitem>.
3836 <footnote><para> Several methods of patch set maintenance have been proposed and are in use for Debian
3837 packages. The <command>quilt</command> system is the preferred maintenance
3838 system in use. Others include <command>dpatch</command>,
3839 <command>dbs</command>, and <command>cdbs</command>. Many of these keep such
3840 patches as <filename>debian/patches/*</filename> files. </para> </footnote>
3841 </para>
3842 <para>
3843 The <command>quilt</command> command is explained in <citerefentry>
3844 <refentrytitle>quilt</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.
3845 It records modifications to the source as a stack of <literal>-p1</literal>
3846 patch files in the <filename>debian/patches</filename> directory and the source
3847 tree is untouched outside of the <filename>debian</filename> directory. The
3848 order of these patches is recorded in the
3849 <filename>debian/patches/series</filename> file. You can apply (=push),
3850 un-apply (=pop), and refresh patches easily. <footnote><para> If you are
3851 asking a sponsor to upload your package, this kind of clear separation and
3852 documentation of your changes is very important to expedite the package review
3853 by your sponsor. </para> </footnote>
3854 </para>
3855 <para>
3856 For <xref linkend="modify"/>, we created three patches in
3857 <filename>debian/patches</filename>.
3858 </para>
3859 <para>
3860 Since Debian patches are located in <filename>debian/patches</filename>, please
3861 make sure to set up the <command>dquilt</command> command properly as described
3862 in <xref linkend="quiltrc"/>.
3863 </para>
3864 <para>
3865 When anyone (including yourself) provides a patch
3866 <filename><replaceable>foo</replaceable>.patch</filename> to the source later,
3867 modifying a <literal>3.0 (quilt)</literal> source package is
3868 quite simple:
3869 </para>
3870 <screen>
3871 $ dpkg-source -x gentoo_0.9.12.dsc
3872 $ cd gentoo-0.9.12
3873 $ dquilt import ../<replaceable>foo</replaceable>.patch
3874 $ dquilt push
3875 $ dquilt refresh
3876 $ dquilt header -e
3877 ... describe patch
3878 </screen>
3879 <para>
3880 The patches stored in the newer <literal>3.0 (quilt)</literal> source format
3881 must be <emphasis>fuzz</emphasis> free. You can ensure this with <literal>dquilt
3882 pop -a; while dquilt push; do dquilt refresh; done</literal>.
3883 </para>
3884 </section>
3885 </chapter>
3886 <chapter id="build"><title>Building the package</title>
3887 <para>
3888 We should now be ready to build the package.
3889 </para>
3890 <section id="completebuild"><title>Complete (re)build</title>
3891 <para>
3892 In order to perform a complete (re)build of a package properly, you
3893 need to make sure you have installed
3894 </para>
3895 <itemizedlist>
3896 <listitem>
3897 <para>
3898 the <systemitem role="package">build-essential</systemitem> package,
3899 </para>
3900 </listitem>
3901 <listitem>
3902 <para>
3903 packages listed in the <literal>Build-Depends</literal> field (see <xref linkend="control"/>), and
3904 </para>
3905 </listitem>
3906 <listitem>
3907 <para>
3908 packages listed in the <literal>Build-Depends-indep</literal> field (see <xref linkend="control"/>).
3909 </para>
3910 </listitem>
3911 </itemizedlist>
3912 <para>
3913 Then you issue the following command in the source directory:
3914 </para>
3915 <screen>
3916 $ dpkg-buildpackage
3917 </screen>
3918 <para>
3919 This will do everything to make full binary and source packages for you. It
3920 will:
3921 </para>
3922 <itemizedlist>
3923 <listitem>
3924 <para>
3925 clean the source tree (<literal>debian/rules clean</literal>)
3926 </para>
3927 </listitem>
3928 <listitem>
3929 <para>
3930 build the source package (<literal>dpkg-source -b</literal>)
3931 </para>
3932 </listitem>
3933 <listitem>
3934 <para>
3935 build the program (<literal>debian/rules build</literal>)
3936 </para>
3937 </listitem>
3938 <listitem>
3939 <para>
3940 build binary packages (<literal>fakeroot debian/rules binary</literal>)
3941 </para>
3942 </listitem>
3943 <listitem>
3944 <para>
3945 sign the source <filename>.dsc</filename> file, using <command>gpg</command>
3946 </para>
3947 </listitem>
3948 <listitem>
3949 <para>
3950 create and sign the upload <filename>.changes</filename> file, using
3951 <command>dpkg-genchanges</command> and <command>gpg</command>
3952 </para>
3953 </listitem>
3954 </itemizedlist>
3955 <para>
3956 The only input that will be required of you is your GPG secret pass phrase,
3957 twice.
3958 <footnote><para>
3959 This GPG key must be signed by a Debian developer to get connected to the web
3960 of trust and must be registered to <ulink url="&keyring;">the Debian
3961 keyring</ulink>. This enables your uploaded packages to be accepted to the
3962 Debian archives. See
3963 <ulink url="&keycreate;">Creating a new GPG key</ulink> and
3964 <ulink url="&keysigning; ">Debian Wiki on Keysigning</ulink>.
3965 </para></footnote>
3966 </para>
3967 <para>
3968 After all this is done, you will see the following files in the directory above
3969 (<filename>~/gentoo</filename>):
3970 </para>
3971 <itemizedlist>
3972 <listitem>
3973 <para>
3974 <filename>gentoo_0.9.12.orig.tar.gz</filename>
3975 </para>
3976 <para>
3977 This is the original source code tarball, merely renamed to the above so that
3978 it adheres to the Debian standard. Note that this was created initially by the
3979 <literal>dh_make -f ../gentoo-0.9.12.tar.gz</literal>.
3980 </para>
3981 </listitem>
3982 <listitem>
3983 <para>
3984 <filename>gentoo_0.9.12-1.dsc</filename>
3985 </para>
3986 <para>
3987 This is a summary of the contents of the source code. The file is generated
3988 from your <filename>control</filename> file, and is used when unpacking the
3989 source with <citerefentry> <refentrytitle>dpkg-source</refentrytitle>
3990 <manvolnum>1</manvolnum> </citerefentry>. This file is GPG signed, so that
3991 people can be sure that it's really yours.
3992 </para>
3993 </listitem>
3994 <listitem>
3995 <para>
3996 <filename>gentoo_0.9.12-1.debian.tar.gz</filename>
3997 </para>
3998 <para>
3999 This compressed tarball contains your <filename>debian</filename> directory
4000 contents. Each and every addition you made to the original source code is
4001 stored as a <command>quilt</command> patch in
4002 <filename>debian/patches</filename>.
4003 </para>
4004 <para>
4005 If someone else wants to re-create your package from scratch, they can easily
4006 do so using the above three files. The extraction procedure is trivial: just
4007 copy the three files somewhere else and run <literal>dpkg-source -x
4008 gentoo_0.9.12-1.dsc</literal>. <footnote><para> You can avoid applying
4009 <command>quilt</command> patches in the <literal>3.0 (quilt)</literal> source
4010 format at the end of the extraction with the <literal>--skip-patches</literal>
4011 option. Alternatively, you can run <literal>dquilt pop -a</literal> after
4012 normal operation. </para> </footnote>
4013 </para>
4014 </listitem>
4015 <listitem>
4016 <para>
4017 <filename>gentoo_0.9.12-1_i386.deb</filename>
4018 </para>
4019 <para>
4020 This is your completed binary package. You can use <command>dpkg</command> to
4021 install and remove this just like any other package.
4022 </para>
4023 </listitem>
4024 <listitem>
4025 <para>
4026 <filename>gentoo_0.9.12-1_i386.changes</filename>
4027 </para>
4028 <para>
4029 This file describes all the changes made in the current package revision;
4030 it is used by the Debian FTP archive maintenance programs to install the binary
4031 and source packages. It is partly generated from the
4032 <filename>changelog</filename> file and the <filename>.dsc</filename> file.
4033 This file is GPG signed, so that people can be sure that it's really yours.
4034 </para>
4035 <para>
4036 As you keep working on the package, its behavior will change and new features will
4037 be added. People downloading your package can look at this file and quickly
4038 see what has changed. Debian archive maintenance programs will also post the
4039 contents of this file to the <ulink url="&debian-devel-announce-ldo;">debian-devel-announce@lists.debian.org</ulink>
4040 mailing list.
4041 </para>
4042 </listitem>
4043 </itemizedlist>
4044 <para>
4045 The long strings of numbers in the <filename>.dsc</filename> and
4046 <filename>.changes</filename> files are SHA1/SHA256 checksums for the files
4047 mentioned. Anyone downloading your files can test them with <citerefentry>
4048 <refentrytitle>sha1sum</refentrytitle> <manvolnum>1</manvolnum>
4049 </citerefentry> or <citerefentry> <refentrytitle>sha256sum</refentrytitle>
4050 <manvolnum>1</manvolnum> </citerefentry> and if the numbers don't match,
4051 they'll know the file is corrupt or has been tampered with.
4052 </para>
4053 </section>
4054 <section id="autobuilder"><title>Autobuilder</title>
4055 <para>
4056 Debian supports many <ulink url="&ports;">ports</ulink>
4057 with the <ulink url="&buildd;">autobuilder
4058 network</ulink> running <command>buildd</command> daemons on computers
4059 of many different architectures. Although you do not need to do this yourself, you
4060 should be aware of what will happen to your packages. Let's look into roughly
4061 how they rebuild your packages for multiple architectures.
4062 <footnote><para> The actual autobuilder system involves much more complicated
4063 schemes than the one documented here. Such details are beyond the scope of
4064 this document. </para> </footnote>
4065 </para>
4066 <para>
4067 For <literal>Architecture: any</literal> packages, the autobuilder system
4068 performs a rebuild. It ensures the installation of
4069 </para>
4070 <itemizedlist>
4071 <listitem>
4072 <para>
4073 the <systemitem role="package">build-essential</systemitem> package, and
4074 </para>
4075 </listitem>
4076 <listitem>
4077 <para>
4078 packages listed in the <literal>Build-Depends</literal> field (see <xref linkend="control"/>).
4079 </para>
4080 </listitem>
4081 </itemizedlist>
4082 <para>
4083 Then it issues the following command in the source directory:
4084 </para>
4085 <screen>
4086 $ dpkg-buildpackage -B
4087 </screen>
4088 <para>
4089 This will do everything to make architecture dependent binary packages on
4090 another architecture. It will:
4091 </para>
4092 <itemizedlist>
4093 <listitem>
4094 <para>
4095 clean the source tree (<literal>debian/rules clean</literal>)
4096 </para>
4097 </listitem>
4098 <listitem>
4099 <para>
4100 build the program (<literal>debian/rules build</literal>)
4101 </para>
4102 </listitem>
4103 <listitem>
4104 <para>
4105 build architecture dependent binary packages (<literal>fakeroot debian/rules
4106 binary-arch</literal>)
4107 </para>
4108 </listitem>
4109 <listitem>
4110 <para>
4111 sign the source <filename>.dsc</filename> file, using <command>gpg</command>
4112 </para>
4113 </listitem>
4114 <listitem>
4115 <para>
4116 create and sign the upload <filename>.changes</filename> file, using
4117 <command>dpkg-genchanges</command> and <command>gpg</command>
4118 </para>
4119 </listitem>
4120 </itemizedlist>
4121 <para>
4122 This is why you see your package for other architectures.
4123 </para>
4124 <para>
4125 Although packages listed in the <literal>Build-Depends-Indep</literal> field
4126 are required to be installed for our normal packaging work (see
4127 <xref linkend="completebuild"/>), they are not required to be installed for the
4128 autobuilder system since it builds only architecture dependent binary packages.
4129 <footnote><para> Unlike under the <systemitem role="package">pbuilder</systemitem> package, the <command>chroot</command>
4130 environment under the <systemitem role="package">sbuild</systemitem> package
4131 used by the autobuilder system does not enforce the use of a minimal
4132 system and may have many leftover packages installed. </para>
4133 </footnote> This distinction between normal packaging and autobuilding
4134 procedures is what dictates whether you should record such required
4135 packages in the <literal>Build-Depends</literal> or
4136 <literal>Build-Depends-Indep</literal> fields of the
4137 <filename>debian/control</filename> file (see <xref linkend="control"/>).
4138 </para>
4139 </section>
4140 <section id="option-sa"><title>Including <filename>orig.tar.gz</filename> for upload</title>
4141 <para>
4142 When you first upload the package to the archive, you need to include the
4143 original <filename>orig.tar.gz</filename> source, too. If the Debian revision
4144 number of this package is neither <literal>1</literal> nor
4145 <literal>0</literal>, you must provide the <command>dpkg-buildpackage</command>
4146 command with the <literal>-sa</literal> option. On the other hand, the
4147 <literal>-sd</literal> option will force the exclusion of the original
4148 <filename>orig.tar.gz</filename> source.
4149 </para>
4150 </section>
4151 <section id="debuild"><title><command>debuild</command> command</title>
4152 <para>
4153 You can automate the <command>dpkg-buildpackage</command> command's
4154 package build process further with the
4155 <command>debuild</command> command. See <citerefentry>
4156 <refentrytitle>debuild</refentrytitle> <manvolnum>1</manvolnum>
4157 </citerefentry>.
4158 </para>
4159 <para>
4160 Customization of the <command>debuild</command> command can be done through
4161 <filename>/etc/devscripts.conf</filename> or
4162 <filename>~/.devscripts</filename>. I would suggest at least the following items:
4163 </para>
4164 <screen>
4165 DEBSIGN_KEYID=Your_GPG_keyID
4166 DEBUILD_LINTIAN=yes
4167 DEBUILD_LINTIAN_OPTS=-i -I --show-overrides
4168 </screen>
4169 <para>
4170 With these, packages are signed by your specified GPG key ID (good for
4171 sponsoring packages) and checked in detail by the <command>lintian</command> command.
4172 </para>
4173 <para>
4174 Cleaning the source and rebuilding the package from your user account is as simple as:
4175 </para>
4176 <screen>
4177 $ debuild
4178 </screen>
4179 <para>
4180 Please note that the <command>dpkg-buildpackage</command> option
4181 <literal>-sa</literal> to include the original <filename>orig.tar.gz</filename>
4182 source can be specified as:
4183 </para>
4184 <screen>
4185 $ debuild -sa
4186 </screen>
4187 <para>
4188 You can clean the source tree as simply as:
4189 </para>
4190 <screen>
4191 $ debuild clean
4192 </screen>
4193 </section>
4194 <section id="pbuilder"><title><systemitem role="package">pbuilder</systemitem> package</title>
4195 <para>
4196 For a clean room (<command>chroot</command>) build environment to verify the
4197 build dependencies, the <systemitem role="package">pbuilder</systemitem>
4198 package is very useful. <footnote><para> Since the <systemitem
4199 role="package">pbuilder</systemitem> package is still evolving, you should
4200 check the actual configuration situation by consulting the latest official
4201 documentation.</para> </footnote> This ensures a clean build from the source
4202 under the <literal>sid</literal> auto-builder for different architectures and
4203 avoids a severity serious FTBFS (Fails To Build From Source) bug which is
4204 always in the RC (release critical) category.
4205 <footnote><para>See <ulink url="&buildd-do;"/> for more on
4206 Debian package auto-building.
4207 .</para></footnote>
4208 </para>
4209 <para>
4210 Let's customize the <systemitem role="package">pbuilder</systemitem> package as
4211 follows:
4212 </para>
4213 <itemizedlist>
4214 <listitem>
4215 <para>
4216 setting the <filename>/var/cache/pbuilder/result</filename> directory writable by
4217 for your user account.
4218 </para>
4219 </listitem>
4220 <listitem>
4221 <para>
4222 creating a directory, e.g.
4223 <filename><replaceable>/var/cache/pbuilder/hooks</replaceable></filename>,
4224 writable by the user, to place hook scripts in.
4225 </para>
4226 </listitem>
4227 <listitem>
4228 <para>
4229 configuring <filename>~/.pbuilderrc</filename> or
4230 <filename>/etc/pbuilderrc</filename> to include the followsing.
4231 </para>
4232 <screen>
4233 AUTO_DEBSIGN=yes
4234 HOOKDIR=<replaceable>/var/cache/pbuilder/hooks</replaceable>
4235 </screen>
4236 </listitem>
4237 </itemizedlist>
4238 <para>
4239 This will allow you to sign generated packages with your secret GPG key in the
4240 <filename>~/.gnupg/</filename> directory.
4241 </para>
4242 <para>
4243 First let's initialize the local <systemitem role="package">pbuilder</systemitem> <command>chroot</command> system as
4244 follows.
4245 </para>
4246 <screen>
4247 $ sudo pbuilder create
4248 </screen>
4249 <para>
4250 If you already have a completed source package, issue the following commands
4251 in the directory where the
4252 <filename><replaceable>foo</replaceable>.orig.tar.gz</filename>,
4253 <filename><replaceable>foo</replaceable>.debian.tar.gz</filename>, and
4254 <filename><replaceable>foo</replaceable>.dsc</filename> files exist to update
4255 the local <systemitem role="package">pbuilder</systemitem>
4256 <command>chroot</command> system and to build binary packages in it.
4257 </para>
4258 <screen>
4259 $ sudo pbuilder --update
4260 $ sudo pbuilder --build <replaceable>foo</replaceable>.dsc
4261 </screen>
4262 <para>
4263 Please note that the <command>dpkg-buildpackage</command> option
4264 <literal>-sa</literal> to include the original <filename>orig.tar.gz</filename>
4265 source can be specified as:
4266 </para>
4267 <screen>
4268 $ sudo pbuilder --build --debbuildopts -sa <replaceable>foo</replaceable>.dsc
4269 </screen>
4270 <para>
4271 The newly built packages will be located in
4272 <filename>/var/cache/pbuilder/result/</filename> with non-root ownership.
4273 </para>
4274 <para>
4275 If you have an updated source tree but have not generated the matching
4276 source package, issue the following commands in the source directory where the
4277 <filename>debian</filename> directory exists, instead.
4278 </para>
4279 <screen>
4280 $ sudo pbuilder --update
4281 $ pdebuild
4282 </screen>
4283 <para>
4284 Please note that the <command>dpkg-buildpackage</command> option
4285 <literal>-sa</literal> to include the original <filename>orig.tar.gz</filename>
4286 source can be specified as:
4287 </para>
4288 <screen>
4289 $ pdebuild --debbuildopts -sa
4290 </screen>
4291 <para>
4292 You can log into its <command>chroot</command> environment with the
4293 <literal>pbuilder --login --save-after-login</literal> command and configure it
4294 as you wish. This environment can be saved by leaving its shell prompt with
4295 <literal>^D</literal> (Control-D).
4296 </para>
4297 <para>
4298 The latest version of the <command>lintian</command> command can be executed in
4299 the <literal>chroot</literal> environment using the hook script
4300 <filename><replaceable>/var/cache/pbuilder/hooks</replaceable>/B90lintian</filename>
4301 configured as follows. <footnote><para> This assumes
4302 <literal>HOOKDIR=/var/cache/pbuilder/hooks</literal>. You can find many
4303 examples of hook scripts in the
4304 <filename>/usr/share/doc/pbuilder/examples</filename> directory. </para>
4305 </footnote>
4306 </para>
4307 <screen>
4308 #!/bin/sh
4309 set -e
4310 install_packages() {
4311 apt-get -y --force-yes install $@
4312 }
4313 install_packages lintian
4314 echo +++ lintian output +++
4315 su -c lintian -i -I --show-overrides /tmp/buildd/*.changes - pbuilder
4316 # use this version if you don't want lintian to fail the build
4317 #su -c lintian -i -I --show-overrides /tmp/buildd/*.changes; : - pbuilder
4318 echo +++ end of lintian output +++
4319 </screen>
4320 <para>
4321 You need to have access to the latest <literal>sid</literal> environment to
4322 build packages properly for <literal>sid</literal>. In practice,
4323 <literal>sid</literal> may be experiencing issues which makes it undesirable
4324 for you to migrate your whole system. The <systemitem role="package">pbuilder</systemitem> package can help you to cope with this
4325 kind of situation.
4326 </para>
4327 <para>
4328 You may need to update your <literal>stable</literal> packages after their
4329 release for <literal>stable-proposed-updates</literal>,
4330 <literal>stable/updates</literal>, etc. <footnote><para> There are some
4331 restrictions for such updates of your <literal>stable</literal> package.
4332 </para> </footnote> For such occasions, the fact you may be running a <literal>sid</literal>
4333 system is not a good enough excuse for failing to update them promptly. The <systemitem role="package">pbuilder</systemitem> package can help you to access
4334 environments of almost any Debian derivative distribution of the same CPU
4335 architecture.
4336 </para>
4337 <para>
4338 See <ulink url="&pbuilder;"/>,
4339 <citerefentry> <refentrytitle>pdebuild</refentrytitle> <manvolnum>1</manvolnum>
4340 </citerefentry>, <citerefentry> <refentrytitle>pbuilderrc</refentrytitle>
4341 <manvolnum>5</manvolnum> </citerefentry>, and <citerefentry>
4342 <refentrytitle>pbuilder</refentrytitle> <manvolnum>8</manvolnum>
4343 </citerefentry>.
4344 </para>
4345 </section>
4346 <section id="git-buildpackage"><title><command>git-buildpackage</command> command and similars</title>
4347 <para>
4348 If your upstream uses a source code management system (VCS)
4349 <footnote><para>See <ulink url="&debref-vcs;">Version control systems</ulink> for more.</para></footnote>
4350 to maintain their code, you should consider using it as well. This makes merging
4351 and cherry-picking upstream patches much easier. There are several specialized
4352 wrapper script packages for Debian package building for each VCS.
4353 </para>
4354 <itemizedlist>
4355 <listitem>
4356 <para>
4357 <systemitem role="package">git-buildpackage</systemitem>: a suite to help with
4358 Debian packages in Git repositories.
4359 </para>
4360 </listitem>
4361 <listitem>
4362 <para>
4363 <systemitem role="package">svn-buildpackage</systemitem>: helper programs to
4364 maintain Debian packages with Subversion.
4365 </para>
4366 </listitem>
4367 <listitem>
4368 <para>
4369 <systemitem role="package">cvs-buildpackage</systemitem>: a set of Debian
4370 package scripts for CVS source trees.
4371 </para>
4372 </listitem>
4373 </itemizedlist>
4374 <para>
4375 For advanced audiences, there are packages which <emphasis>automate</emphasis>
4376 the building of packages under a VCS-managed source tree. I will not explain them
4377 in this tutorial.
4378 <footnote><para> Here are some web resources available for advanced audiences. </para>
4379 <itemizedlist>
4380 <listitem> <para> <ulink url="&git-buildpackage-doc;">Building Debian Packages with git-buildpackage</ulink> </para> </listitem>
4381 <listitem> <para> <ulink url="&debian-packages-git;">debian packages in git</ulink> </para> </listitem>
4382 <listitem> <para> <ulink url="&git-debian-packaging;">Using Git for Debian Packaging</ulink> </para> </listitem>
4383 <listitem> <para> <ulink url="&git-dpm;">git-dpm: Debian packages in Git manager</ulink> </para> </listitem>
4384 <listitem> <para> <ulink url="&topgit;">Using TopGit to generate quilt series for Debian packaging</ulink> </para> </listitem>
4385 </itemizedlist>
4386 </footnote>
4387 </para>
4388 </section>
4389 <section id="quickrebuild"><title>Quick rebuild</title>
4390 <para>
4391 With a large package, you may not want to rebuild from scratch every time while
4392 you're tuning details in <filename>debian/rules</filename>. For testing purposes,
4393 you can make a <filename>.deb</filename> file without rebuilding the upstream
4394 sources like this<footnote><para> Environment variables which are normally
4395 configured to proper values are not set by this method. Never create real
4396 packages to be uploaded using this <emphasis role="strong">quick</emphasis>
4397 method. </para> </footnote>:
4398 </para>
4399 <screen>
4400 $ fakeroot debian/rules binary
4401 </screen>
4402 <para>
4403 Or simply do the following to see if it builds or not:
4404 </para>
4405 <screen>
4406 $ fakeroot debian/rules build
4407 </screen>
4408 <para>
4409 Once you are finished with your tuning, remember to rebuild following the
4410 proper procedure. You may not be able to upload correctly if you try to upload
4411 <filename>.deb</filename> files built this way.
4412 </para>
4413 </section>
4414 </chapter>
4415 <chapter id="checkit"><title>Checking the package for errors</title>
4416 <para>
4417 There are few chores you should know to check the package for errors by
4418 yourself before uploading packages to public archives.
4419 </para>
4420 <para>
4421 Testing on machine other than your own is also good idea. You must watch
4422 closely for any warnings or errors for all the test described here.
4423 </para>
4424 <section id="pinstall"><title>Verifying package for install</title>
4425 <para>
4426 You must test your package if it installs without problem. The <citerefentry>
4427 <refentrytitle>debi</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>
4428 command helps you to test to install all the generated binary packages.
4429 </para>
4430 <screen>
4431 $ sudo debi gentoo_0.9.12-1_i386.changes
4432 </screen>
4433 <para>
4434 You have to make sure that there are no overlapped files with other existing
4435 packages using the
4436 <filename>Contents-<replaceable>i386</replaceable></filename> file downloaded
4437 from the Debian archive to prevent installation problem on different systems.
4438 The <command>apt-file</command> command may be handy for this task. If there
4439 are overlapped files, please take actions to avoid the real problem using the
4440 alternatives mechanism (see <citerefentry>
4441 <refentrytitle>update-alternatives</refentrytitle> <manvolnum>1</manvolnum>
4442 </citerefentry>) by coordinating with other affected packages or by setting the
4443 <literal>Conflicts</literal> entry in the <filename>debian/control</filename>
4444 file.
4445 </para>
4446 </section>
4447 <section id="pmaintscripts"><title>Verifying package for <emphasis>maintainer scripts</emphasis></title>
4448 <para>
4449 All <emphasis>maintainer scripts</emphasis>, i.e.,
4450 <filename>preinst</filename>, <filename>prerm</filename>,
4451 <filename>postinst</filename>, and <filename>postrm</filename> files, are
4452 non-trivial unless they are auto-generated by the <systemitem role="package">debhelper</systemitem> programs. So do not use them if you are
4453 a novice maintainer (see <xref linkend="maintscripts"/>).
4454 </para>
4455 <para>
4456 If the package makes use of these non-trivial <emphasis>maintainer
4457 scripts</emphasis>, be sure to test not only for install but also for remove,
4458 purge, and upgrade. Many <emphasis>maintainer script</emphasis> bugs show up
4459 when packages are removed or purged. Use the <command>dpkg</command> command
4460 as follows to test them.
4461 </para>
4462 <screen>
4463 $ sudo dpkg -r gentoo
4464 $ sudo dpkg -P gentoo
4465 $ sudo dpkg -i gentoo_<replaceable>version</replaceable>-<replaceable>revision</replaceable>_<replaceable>i386</replaceable>.deb
4466 </screen>
4467 <para>
4468 This should be done with sequences such as the following.
4469 </para>
4470 <itemizedlist>
4471 <listitem>
4472 <para>
4473 install the previous version (if needed).
4474 </para>
4475 </listitem>
4476 <listitem>
4477 <para>
4478 upgrade it from the previous version.
4479 </para>
4480 </listitem>
4481 <listitem>
4482 <para>
4483 downgrade it back to the previous version (optional).
4484 </para>
4485 </listitem>
4486 <listitem>
4487 <para>
4488 purge it.
4489 </para>
4490 </listitem>
4491 <listitem>
4492 <para>
4493 install the new package.
4494 </para>
4495 </listitem>
4496 <listitem>
4497 <para>
4498 remove it.
4499 </para>
4500 </listitem>
4501 <listitem>
4502 <para>
4503 install it again.
4504 </para>
4505 </listitem>
4506 <listitem>
4507 <para>
4508 purge it.
4509 </para>
4510 </listitem>
4511 </itemizedlist>
4512 <para>
4513 If this is your first package, you should create dummy packages with different
4514 versions to test your package in advance to prevent future problems.
4515 </para>
4516 <para>
4517 Bear in mind that if your package has previously been released in Debian,
4518 people will often be upgrading to your package from the version that was in the
4519 last Debian release. Remember to test upgrades from that version too.
4520 </para>
4521 <para>
4522 Although downgrade is not officially supported, it should be nice to support
4523 it.
4524 </para>
4525 </section>
4526 <section id="lintians"><title><systemitem role="package">lintian</systemitem> package</title>
4527 <para>
4528 Run <citerefentry> <refentrytitle>lintian</refentrytitle>
4529 <manvolnum>1</manvolnum> </citerefentry> on your <filename>.changes</filename>
4530 file. The <command>lintian</command> command runs many test scripts to check
4531 for many common packaging errors. <footnote><para> You do not need to provide
4532 the <command>lintian</command> option <literal>-i -I --show-overrides</literal>
4533 if you customized <filename>/etc/devscripts.conf</filename> or
4534 <filename>~/.devscripts</filename> as described in <xref linkend="debuild"/>.
4535 </para> </footnote>
4536 </para>
4537 <screen>
4538 $ lintian -i -I --show-overrides gentoo_0.9.12-1_i386.changes
4539 </screen>
4540 <para>
4541 Of course, replace the filename with the name of the
4542 <filename>.changes</filename> file generated for your package. The output of
4543 the <command>lintian</command> command are marked as follows.
4544 </para>
4545 <itemizedlist>
4546 <listitem>
4547 <para>
4548 <literal>E:</literal> for error; a sure policy violation or a packaging error.
4549 </para>
4550 </listitem>
4551 <listitem>
4552 <para>
4553 <literal>W:</literal> for warning; a possible policy violation or a packaging
4554 error.
4555 </para>
4556 </listitem>
4557 <listitem>
4558 <para>
4559 <literal>I:</literal> for info; a information on certain packaging aspects.
4560 </para>
4561 </listitem>
4562 <listitem>
4563 <para>
4564 <literal>N:</literal> for note; a detailed message to help your debugging.
4565 </para>
4566 </listitem>
4567 <listitem>
4568 <para>
4569 <literal>O:</literal> for overridden; a message overridden by the
4570 <filename>lintian-overrides</filename> files but displayed by the
4571 <literal>--show-overrides</literal> option.
4572 </para>
4573 </listitem>
4574 </itemizedlist>
4575 <para>
4576 For warnings, tune the package to avoid them or verify that the warnings are
4577 spurious. If spurious, set the <filename>lintian-overrides</filename> files as
4578 described in <xref linkend="lintian"/>.
4579 </para>
4580 <para>
4581 Note that you can build the package with <command>dpkg-buildpackage</command>
4582 and run <command>lintian</command> on it in one command with <citerefentry>
4583 <refentrytitle>debuild</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>
4584 or with <citerefentry> <refentrytitle>pdebuild</refentrytitle>
4585 <manvolnum>1</manvolnum> </citerefentry>.
4586 </para>
4587 </section>
4588 <section id="debc"><title><command>debc</command> command</title>
4589 <para>
4590 You can list files in the binary Debian package by <citerefentry>
4591 <refentrytitle>debc</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>
4592 command.
4593 </para>
4594 <screen>
4595 $ debc <replaceable>package</replaceable>.changes
4596 </screen>
4597 </section>
4598 <section id="debdiff"><title><command>debdiff</command> command</title>
4599 <para>
4600 You can compare file contents in two source Debian packages with the
4601 <citerefentry> <refentrytitle>debdiff</refentrytitle> <manvolnum>1</manvolnum>
4602 </citerefentry> command.
4603 </para>
4604 <screen>
4605 $ debdiff <replaceable>old-package</replaceable>.dsc <replaceable>new-package</replaceable>.dsc
4606 </screen>
4607 <para>
4608 You can also compare file lists in two sets of binary Debian packages with the
4609 <citerefentry> <refentrytitle>debdiff</refentrytitle> <manvolnum>1</manvolnum>
4610 </citerefentry> command.
4611 </para>
4612 <screen>
4613 $ debdiff <replaceable>old-package</replaceable>.changes <replaceable>new-package</replaceable>.changes
4614 </screen>
4615 <para>
4616 These are useful to identify what has been changed in the source packages, if
4617 no files have been unintentionally misplaced or removed in the binary packages,
4618 and if no other inadvertent changes were made when updating binary packages.
4619 </para>
4620 </section>
4621 <section id="interdiff"><title><command>interdiff</command> command</title>
4622 <para>
4623 You can compare two <filename>diff.gz</filename> files with the <citerefentry>
4624 <refentrytitle>interdiff</refentrytitle> <manvolnum>1</manvolnum>
4625 </citerefentry> command. This is useful for verifying that no inadvertent
4626 changes were made to the source by the maintainer when updating packages in the
4627 old <literal>1.0</literal> source format.
4628 </para>
4629 <screen>
4630 $ interdiff -z <replaceable>old-package</replaceable>.diff.gz <replaceable>new-package</replaceable>.diff.gz
4631 </screen>
4632 <para>
4633 The new <literal>3.0</literal> source format stores changes in multiple patch
4634 files as described in <xref linkend="patches"/>. You can trace changes of each
4635 <filename>debian/patches/*</filename> file using <command>interdiff</command>, too.
4636 </para>
4637 </section>
4638 <section id="mc"><title><command>mc</command> command</title>
4639 <para>
4640 Many of these file inspection operations can be made into an intuitive process
4641 by using a file manager like <citerefentry> <refentrytitle>mc</refentrytitle>
4642 <manvolnum>1</manvolnum> </citerefentry> which will let you browse not only the
4643 contents of <filename>*.deb</filename> package files but also
4644 <filename>*.udeb</filename>, <filename>*.debian.tar.gz</filename>,
4645 <filename>*.diff.gz</filename>, and <filename>*.orig.tar.gz</filename> files.
4646 </para>
4647 <para>
4648 Be on the lookout for extra unneeded files or zero length files, both in the
4649 binary and source package. Often cruft doesn't get cleaned up properly; adjust
4650 your <filename>rules</filename> file to compensate for that.
4651 </para>
4652 </section>
4653 </chapter>
4654 <chapter id="upload"><title>Uploading the package</title>
4655 <para>
4656 Now that you have tested your new package thoroughly, you want to release it to
4657 a public archive to share it.
4658 </para>
4659 <section id="upload-debian"><title>Uploading to the Debian archive</title>
4660 <para>
4661 Once you become an official developer,
4662 <footnote><para>
4663 See <xref linkend="socialdynamism"/>.
4664 </para></footnote>
4665 you can upload the package to the Debian archive.
4666 <footnote><para>
4667 There are publicly accessible archives such as <ulink url="&mentors-dn;"/>
4668 which work almost the same way as Debian archive and provide upload area for
4669 the non-DD. You can set up an equivalent archive by yourself using tools
4670 listed at <ulink url="&deb-archive;"/>. So this section is useful for the
4671 non-DD, too.
4672 </para></footnote>
4673 You can do this manually, but it's easier to use the existing
4674 automated tools, like <citerefentry> <refentrytitle>dupload</refentrytitle>
4675 <manvolnum>1</manvolnum> </citerefentry> or <citerefentry>
4676 <refentrytitle>dput</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>.
4677 We'll describe how it's done with <command>dupload</command>. <footnote><para>
4678 The <systemitem role="package">dput</systemitem> package seems to come with
4679 more features and becoming more popular than the <systemitem role="package">dupload</systemitem> package. It uses the
4680 <filename>/etc/dput</filename> file for the global configuration and the
4681 <filename>~/.dput.cf</filename> file for the per-user one. It supports Ubuntu
4682 related services out-of-box, too. </para> </footnote>
4683 </para>
4684 <para>
4685 First you have to set up <command>dupload</command>'s config file. You can
4686 either edit the system-wide <filename>/etc/dupload.conf</filename> file, or
4687 have your own <filename>~/.dupload.conf</filename> file override the few things
4688 you want to change.
4689 </para>
4690 <para>
4691 You can read the <citerefentry> <refentrytitle>dupload.conf</refentrytitle>
4692 <manvolnum>5</manvolnum> </citerefentry> manual page to understand what each of
4693 these options means.
4694 </para>
4695 <para>
4696 The <literal>$default_host</literal> option determines which of the upload
4697 queues will be used by default. <literal>anonymous-ftp-master</literal> is the
4698 primary one, but it's possible that you will want to use another one.
4699 <footnote><para>See <ulink url="&devref-upload;">Debian Developer's Reference 5.6. "Uploading a package"</ulink>.</para></footnote>
4700 </para>
4701 <para>
4702 While connected to the Internet, you can upload your package by the following:
4703 </para>
4704 <screen>
4705 $ dupload gentoo_0.9.12-1_i386.changes
4706 </screen>
4707 <para>
4708 <command>dupload</command> checks that the MD5/SHA1/SHA256 checksums of the
4709 files match those from the <filename>.changes</filename> file. If they do not
4710 match, it will warn you to rebuild it as described in <xref linkend="completebuild"/> so it can be properly uploaded.
4711 </para>
4712 <!--
4713 No more use of ftp-master nor faster queue. It is not so
4714 useful these days. If you upload to ftp-master, <command>dupload</command>
4715 will ask for your password on Debian machines, and then upload the packages.
4716 -->
4717 <para>
4718 If you encounter an upload problem at <ulink url="&uploadqueue;"/>, you can fix this
4719 by manually uploading GPG signed <filename>*.commands</filename> file to there
4720 with <command>ftp</command>. <footnote><para> See <ulink url="&uploadqueue-readme;"/>. Alternatively, you may
4721 use <command>dcut</command> command from the <systemitem role="package">dput</systemitem> package. </para> </footnote> For example, use
4722 <filename>hello.commands</filename>:
4723 </para>
4724 <screen>
4725 -----BEGIN PGP SIGNED MESSAGE-----
4726 Uploader: Foo Bar &lt;Foo.Bar@example.org&gt;
4727 Commands:
4728 rm hello_1.0-1_i386.deb
4729 mv hello_1.0-1.dsx hello_1.0-1.dsc
4730 -----BEGIN PGP SIGNATURE-----
4731 Version: 2.6.3ia
4732 iQCVAwUBNFiQSXVhJ0HiWnvJAQG58AP+IDJVeSWmDvzMUphScg1EK0mvChgnuD7h
4733 BRiVQubXkB2DphLJW5UUSRnjw1iuFcYwH/lFpNpl7XP95LkLX3iFza9qItw4k2/q
4734 tvylZkmIA9jxCyv/YB6zZCbHmbvUnL473eLRoxlnYZd3JFaCZMJ86B0Ph4GFNPAf
4735 Z4jxNrgh7Bc=
4736 =pH94
4737 -----END PGP SIGNATURE-----
4738 </screen>
4739 </section>
4740 <section id="skipped-uploads"><title>Skipped uploads</title>
4741 <para>
4742 If you created multiple entries in <filename>debian/changelog</filename> by
4743 skipping uploads, you must create a proper <filename>*_.changes</filename> file
4744 which includes all changes from the last upload.
4745 </para>
4746 <para>
4747 This can be done by specifying <literal>-v</literal> option to the package
4748 building programs such as <command>dpkg-buildpackage</command>,
4749 <command>debuild</command>, <command>pdebuild</command>, etc.
4750 </para>
4751 </section>
4752 </chapter>
4753 <chapter id="update"><title>Updating the package</title>
4754 <para>
4755 Once you release a package, you need to update it soon.
4756 </para>
4757 <section id="newrevision"><title>New Debian revision</title>
4758 <para>
4759 Let's say that a bug report was filed against your package as
4760 <literal>#54321</literal>, and it describes a problem that you can solve. To
4761 create a new Debian revision of the package, you need to:
4762 </para>
4763 <itemizedlist>
4764 <listitem>
4765 <para>
4766 If this is to be recorded as a new patch, do the following.
4767 </para>
4768 <itemizedlist>
4769 <listitem>
4770 <para>
4771 <literal>dquilt new <replaceable>bugname.patch</replaceable></literal> to set
4772 patch name;
4773 </para>
4774 </listitem>
4775 <listitem>
4776 <para>
4777 <literal>dquilt add <replaceable>buggy-file</replaceable></literal> to declare
4778 file to be modified;
4779 </para>
4780 </listitem>
4781 <listitem>
4782 <para>
4783 Correct the problem in the package source for the upstream bug;
4784 </para>
4785 </listitem>
4786 <listitem>
4787 <para>
4788 <literal>dquilt refresh</literal> to record to
4789 <filename><replaceable>bugname.patch</replaceable></filename>;
4790 </para>
4791 </listitem>
4792 <listitem>
4793 <para>
4794 <literal>dquilt header -e</literal> to add its description;
4795 </para>
4796 </listitem>
4797 </itemizedlist>
4798 </listitem>
4799 <listitem>
4800 <para>
4801 If this is to update an existing patch, do the following.
4802 </para>
4803 <itemizedlist>
4804 <listitem>
4805 <para>
4806 <literal>dquilt pop <replaceable>foo.patch</replaceable></literal> to recall
4807 existing <filename><replaceable>foo.patch</replaceable></filename>;
4808 </para>
4809 </listitem>
4810 <listitem>
4811 <para>
4812 Correct the problem in the old
4813 <filename><replaceable>foo.patch</replaceable></filename>;
4814 </para>
4815 </listitem>
4816 <listitem>
4817 <para>
4818 <literal>dquilt refresh</literal> to update
4819 <filename><replaceable>foo.patch</replaceable></filename>;
4820 </para>
4821 </listitem>
4822 <listitem>
4823 <para>
4824 <literal>dquilt header -e</literal> to update its description;
4825 </para>
4826 </listitem>
4827 <listitem>
4828 <para>
4829 <literal>while dquilt push; do dquilt refresh; done</literal> to apply all
4830 patches while removing <emphasis>fuzz</emphasis>;
4831 </para>
4832 </listitem>
4833 </itemizedlist>
4834 </listitem>
4835 <listitem>
4836 <para>
4837 Add a new revision at the top of the Debian <filename>changelog</filename>
4838 file, for example with <literal>dch -i</literal>, or explicitly with
4839 <literal>dch -v
4840 <replaceable>version</replaceable>-<replaceable>revision</replaceable></literal>
4841 and then insert the comments using your preferred editor. <footnote><para> To
4842 get the date in the required format, use <literal>LANG=C date -R</literal>.
4843 </para> </footnote>
4844 </para>
4845 </listitem>
4846 <listitem>
4847 <para>
4848 Include a short description of the bug and the solution in the changelog entry,
4849 followed by <literal>Closes: #54321</literal>. That way, the bug report will
4850 be <emphasis>automagically</emphasis> closed by the archive maintenance
4851 software the moment your package gets accepted in the Debian archive.
4852 </para>
4853 </listitem>
4854 <listitem>
4855 <para>
4856 Repeat what you did in the above to fix more bugs while updating the Debian
4857 <filename>changelog</filename> file with <literal>dch</literal> as needed.
4858 </para>
4859 </listitem>
4860 <listitem>
4861 <para>
4862 Repeat what you did in <xref linkend="completebuild"/>, <xref linkend="checkit"/>, and <xref linkend="upload"/>. The difference is that
4863 this time, the original source archive won't be included, as it hasn't been
4864 changed and it already exists in the Debian archive.
4865 </para>
4866 </listitem>
4867 </itemizedlist>
4868 </section>
4869 <section id="inspectnewupstream"><title>Inspection of the new upstream release</title>
4870 <para>
4871 When preparing packages of the new upstream release for the Debian archive, you
4872 must check the new upstream release, first.
4873 </para>
4874 <para>
4875 You start this by reading the upstream <filename>changelog</filename>,
4876 <filename>NEWS</filename>, and whatever other documentations they may have
4877 released with the new version.
4878 </para>
4879 <para>
4880 You then inspect changes between the old and new upstream sources as follow to
4881 watch out for anything suspicious.
4882 </para>
4883 <screen>
4884 $ diff -urN <replaceable>foo</replaceable>-<replaceable>oldversion</replaceable> <replaceable>foo</replaceable>-<replaceable>newversion</replaceable>
4885 </screen>
4886 <para>
4887 Changes to some auto-generated files by Autotools such as
4888 <filename>missing</filename>, <filename>aclocal.m4</filename>,
4889 <filename>config.guess</filename>, <filename>config.h.in</filename>,
4890 <filename>config.sub</filename>, <filename>configure</filename>,
4891 <filename>depcomp</filename>, <filename>install-sh</filename>,
4892 <filename>ltmain.sh</filename>, and <filename>Makefile.in</filename> may be
4893 ignored. You may erase them before running <command>diff</command> to the
4894 source for inspection.
4895 </para>
4896 </section>
4897 <section id="newupstream"><title>New upstream release</title>
4898 <para>
4899 If a package <systemitem role="package"><replaceable>foo</replaceable></systemitem> is properly packaged
4900 in the newer <literal>3.0 (native)</literal> or <literal>3.0 (quilt)</literal>
4901 formats, packaging a new upstream version is essentially moving the old
4902 <filename>debian</filename> directory to the new source. This can be done by
4903 running <literal>tar xvzf
4904 /<replaceable>path</replaceable>/<replaceable>to</replaceable>/<replaceable>foo</replaceable>_<replaceable>oldversion</replaceable>.debian.tar.gz</literal>
4905 in the new extracted source. <footnote><para> If a package <systemitem role="package"><replaceable>foo</replaceable></systemitem> is packaged in the
4906 old <literal>1.0</literal> format, this can be done by running <literal>zcat
4907 /<replaceable>path</replaceable>/<replaceable>to</replaceable>/<replaceable>foo</replaceable>_<replaceable>oldversion</replaceable>.diff.gz|patch
4908 -p1</literal> in the new extracted source, instead. </para> </footnote> Of
4909 course, you need to do few obvious chores.
4910 </para>
4911 <itemizedlist>
4912 <listitem>
4913 <para>
4914 Create a copy of upstream source as the
4915 <filename>foo_<replaceable>newversion</replaceable>.tar.gz</filename> file.
4916 </para>
4917 </listitem>
4918 <listitem>
4919 <para>
4920 Update the Debian <filename>changelog</filename> file with <literal>dch -v
4921 <replaceable>newversion</replaceable>-<replaceable>1</replaceable></literal>.
4922 </para>
4923 <itemizedlist>
4924 <listitem>
4925 <para>
4926 Add an entry with <literal>New upstream release</literal>.
4927 </para>
4928 </listitem>
4929 <listitem>
4930 <para>
4931 Describe concisely the changes <emphasis>in the new upstream release</emphasis>
4932 that fix reported bugs and close those bugs by adding <literal>Closes: #<replaceable>bug_number</replaceable></literal>.
4933 </para>
4934 </listitem>
4935 <listitem>
4936 <para>
4937 Describe concisely the changes <emphasis>to the new upstream release</emphasis>
4938 by the maintainer that fix reported bugs and close those bugs by adding <literal>Closes: #<replaceable>bug_number</replaceable></literal>.
4939 </para>
4940 </listitem>
4941 </itemizedlist>
4942 </listitem>
4943 <listitem>
4944 <para>
4945 <literal>while dquilt push; do dquilt refresh; done</literal> to apply all
4946 patches while removing <emphasis>fuzz</emphasis>.
4947 </para>
4948 </listitem>
4949 </itemizedlist>
4950 <para>
4951 If the patch/merge did not apply cleanly, inspect the situation (clues are left
4952 in <filename>.rej</filename> files).
4953 </para>
4954 <itemizedlist>
4955 <listitem>
4956 <para>
4957 If a patch you applied to the source was integrated to the upstream source,
4958 </para>
4959 <itemizedlist>
4960 <listitem>
4961 <para>
4962 <literal>dquilt delete</literal> to remove it.
4963 </para>
4964 </listitem>
4965 </itemizedlist>
4966 </listitem>
4967 <listitem>
4968 <para>
4969 If a patch you applied to the source conflicted with new changes in the
4970 upstream source,
4971 </para>
4972 <itemizedlist>
4973 <listitem>
4974 <para>
4975 <literal>dquilt push -f</literal> to apply old patches while forcing rejects as
4976 <filename><replaceable>baz</replaceable>.rej</filename>.
4977 </para>
4978 </listitem>
4979 <listitem>
4980 <para>
4981 Edit the <filename><replaceable>baz</replaceable></filename> file manually to
4982 realize intended effect of
4983 <filename><replaceable>baz</replaceable>.rej</filename>.
4984 </para>
4985 </listitem>
4986 <listitem>
4987 <para>
4988 <literal>dquilt refresh</literal> to update the patch.
4989 </para>
4990 </listitem>
4991 </itemizedlist>
4992 </listitem>
4993 <listitem>
4994 <para>
4995 Continue back to <literal>while dquilt push; do dquilt refresh; done</literal>.
4996 </para>
4997 </listitem>
4998 </itemizedlist>
4999 <para>
5000 This process can be automated using the <citerefentry>
5001 <refentrytitle>uupdate</refentrytitle> <manvolnum>1</manvolnum> </citerefentry>
5002 command as follows:
5003 </para>
5004 <screen>
5005 $ apt-get source <replaceable>foo</replaceable>
5006 ...
5007 dpkg-source: info: extracting <replaceable>foo</replaceable> in <replaceable>foo</replaceable>-<replaceable>oldversion</replaceable>
5008 dpkg-source: info: unpacking <replaceable>foo</replaceable>_<replaceable>oldversion</replaceable>.orig.tar.gz
5009 dpkg-source: info: applying <replaceable>foo</replaceable>_<replaceable>oldversion</replaceable>-1.debian.tar.gz
5010 $ ls -F
5011 <replaceable>foo</replaceable>-<replaceable>oldversion</replaceable>/
5012 <replaceable>foo</replaceable>_<replaceable>oldversion</replaceable>-1.debian.tar.gz
5013 <replaceable>foo</replaceable>_<replaceable>oldversion</replaceable>-1.dsc
5014 <replaceable>foo</replaceable>_<replaceable>oldversion</replaceable>.orig.tar.gz
5015 $ wget http://example.org/<replaceable>foo</replaceable>/<replaceable>foo</replaceable>-<replaceable>newversion</replaceable>.tar.gz
5016 $ cd <replaceable>foo</replaceable>-<replaceable>oldversion</replaceable>
5017 $ uupdate -v <replaceable>newversion</replaceable> ../<replaceable>foo</replaceable>-<replaceable>newversion</replaceable>.tar.gz
5018 $ cd ../<replaceable>foo</replaceable>-<replaceable>newversion</replaceable>
5019 $ while dquilt push; do dquilt refresh; done
5020 $ dch
5021 ... document changes made
5022 </screen>
5023 <para>
5024 If you set up a <filename>debian/watch</filename> file as described in <xref linkend="watch"/>, you can skip the <command>wget</command> command. You
5025 simply run <citerefentry> <refentrytitle>uscan</refentrytitle>
5026 <manvolnum>1</manvolnum> </citerefentry> in the
5027 <filename><replaceable>foo</replaceable>-<replaceable>oldversion</replaceable></filename>
5028 directory instead of the <command>uupdate</command> command. This will
5029 <emphasis>automagically</emphasis> look for the updated source, download it,
5030 and run the <command>uupdate</command> command. <footnote><para> If the
5031 <command>uscan</command> command downloads the updated source but it does not
5032 run the <command>uupdate</command> command, you should correct the
5033 <filename>debian/watch</filename> file to have <literal>debian
5034 uupdate</literal> at the end of the URL. </para> </footnote>
5035 </para>
5036 <para>
5037 You can release this updated source by repeating what you did in <xref linkend="completebuild"/>, <xref linkend="checkit"/>, and <xref linkend="upload"/>.
5038 </para>
5039 </section>
5040 <section id="packagestyle"><title>Updating the packaging style</title>
5041 <para>
5042 Updating the package style is not a required activity for the update of a
5043 package. But, you can use the full capability of the modern <systemitem role="package">debhelper</systemitem> system and the <literal>3.0</literal>
5044 source format by doing this. <footnote><para> If your sponsor or other
5045 maintainers object to updating the existing packaging style, it is not worth
5046 bothering nor arguing. There are more important things to do. </para>
5047 </footnote>
5048 </para>
5049 <itemizedlist>
5050 <listitem>
5051 <para>
5052 If you need to add erased template files for any reason, you may run
5053 <command>dh_make</command> again in the same Debian package source tree with
5054 <literal>--addmissing</literal> option. Then edit them properly.
5055 </para>
5056 </listitem>
5057 <listitem>
5058 <para>
5059 If the package has not updated to use the <systemitem role="package">debhelper</systemitem> V7 <command>dh</command> syntax for the
5060 <filename>debian/rules</filename> file, update it to use <command>dh</command>.
5061 Update the <filename>debian/control</filename> file accordingly.
5062 </para>
5063 </listitem>
5064 <listitem>
5065 <para>
5066 If you want to update the <filename>rules</filename> file created with the
5067 <filename>Makefile</filename> inclusion mechanism of the Common Debian Build
5068 System (<systemitem role="package">cdbs</systemitem>) to the
5069 <command>dh</command> syntax, see
5070 <ulink url="&cdbs-doc;">cdbs-doc.pdf.gz</ulink> and understand its
5071 <literal>DEB_*</literal> configuration variables. <footnote><para> In the
5072 <systemitem role="package">cdbs</systemitem> (0.4.74) package, there are some
5073 negative descriptions of the <filename>rules</filename> file created by the
5074 <command>dh_make</command> command for the non-<systemitem role="package">cdbs</systemitem> choices. Do not worry about it. It applies
5075 only for <literal>lenny</literal> which created explicit targets with long list
5076 of <command>dh_*</command> commands. </para> </footnote>
5077 </para>
5078 </listitem>
5079 <listitem>
5080 <para>
5081 If you have a <literal>1.0</literal> source package without the
5082 <filename><replaceable>foo</replaceable>.diff.gz</filename> file, you can
5083 update it to the newer <literal>3.0 (native)</literal> source format by
5084 creating <filename>debian/source/format</filename> with <literal>3.0
5085 (native)</literal>. The rest of <filename>debian/*</filename> files can be
5086 just copied.
5087 </para>
5088 </listitem>
5089 <listitem>
5090 <para>
5091 If you have a <literal>1.0</literal> source package with the
5092 <filename><replaceable>foo</replaceable>.diff.gz</filename> file, you can
5093 update it to the newer <literal>3.0 (quilt)</literal> source format by creating
5094 <filename>debian/source/format</filename> with <literal>3.0 (quilt)</literal>.
5095 The rest of <filename>debian/*</filename> files can be just copied. Import the
5096 <filename>big.diff</filename> file generated by the <literal>filterdiff -z -x
5097 '*/debian/*' <replaceable>foo</replaceable>.diff.gz &gt; big.diff</literal>
5098 command to your <command>quilt</command> system, if needed. <footnote><para>
5099 You may split <filename>big.diff</filename> into many small incremental patches
5100 using the <command>splitdiff</command> command. </para> </footnote>
5101 </para>
5102 </listitem>
5103 <listitem>
5104 <para>
5105 If it was packaged with another patch system such as <systemitem role="package">dpatch</systemitem>, <systemitem role="package">dbs</systemitem>, or <systemitem role="package">cdbs</systemitem> with <literal>-p0</literal>,
5106 <literal>-p1</literal>, or <literal>-p2</literal>, convert it to the
5107 <systemitem role="package">quilt</systemitem> command using
5108 <filename>deb3</filename> at <ulink url="&deb3;"/>.
5109 </para>
5110 </listitem>
5111 <listitem>
5112 <para>
5113 If it was packaged with the <command>dh</command> command with the
5114 <literal>--with quilt</literal> option or with the
5115 <command>dh_quilt_patch</command> and <command>dh_quilt_unpatch</command>
5116 commands, remove such things and make it use the newer <literal>3.0
5117 (native)</literal> source format.
5118 </para>
5119 </listitem>
5120 </itemizedlist>
5121 <para>
5122 You need to do other tasks described in <xref linkend="newupstream"/>, too.
5123 </para>
5124 </section>
5125 <section id="reminders"><title>Reminders for updating packages</title>
5126 <para>
5127 Here are few reminders for updating packages.
5128 </para>
5129 <itemizedlist>
5130 <listitem>
5131 <para>
5132 Preserve old <filename>changelog</filename> entries (sounds obvious, but there
5133 have been incidents to type <literal>dch</literal> when you should have typed
5134 <literal>dch -i</literal>.)
5135 </para>
5136 </listitem>
5137 <listitem>
5138 <para>
5139 Existing Debian changes need to be reevaluated; throw away stuff that upstream
5140 has incorporated (in one form or another) and remember to keep stuff that
5141 hasn't been incorporated by upstream, unless there is a compelling reason not
5142 to.
5143 </para>
5144 </listitem>
5145 <listitem>
5146 <para>
5147 If any changes were made to the build system (hopefully you'd know from
5148 inspecting upstream changes) then update the <filename>debian/rules</filename>
5149 and <filename>debian/control</filename> build dependencies if necessary.
5150 </para>
5151 </listitem>
5152 <listitem>
5153 <para>
5154 Check to see <ulink url="&bts;">Debian Bug Tracking
5155 System (BTS)</ulink> if someone have provided patches to bugs that are
5156 currently open in it.
5157 </para>
5158 </listitem>
5159 <listitem>
5160 <para>
5161 Check the contents of the <filename>.changes</filename> file to make sure you
5162 are uploading to the correct distribution, the proper bugs closures are listed
5163 in the <literal>Closes</literal> field, the <literal>Maintainer</literal> and
5164 <literal>Changed-By</literal> fields match, the file is GPG-signed, etc.
5165 </para>
5166 </listitem>
5167 </itemizedlist>
5168 </section>
5169 </chapter>
5170 </book>

  ViewVC Help
Powered by ViewVC 1.1.5