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

  ViewVC Help
Powered by ViewVC 1.1.5