/[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 8651 - (show annotations) (download)
Sun Apr 10 06:02:06 2011 UTC (2 years, 1 month ago) by osamu
File size: 197410 byte(s)
Add Stefano Zacchiroli's PDF as reference

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

  ViewVC Help
Powered by ViewVC 1.1.5