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

  ViewVC Help
Powered by ViewVC 1.1.5