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

  ViewVC Help
Powered by ViewVC 1.1.5