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

  ViewVC Help
Powered by ViewVC 1.1.5