chiark / gitweb /
fix 526410 (Applied patch from Charles Plessy about providing information to the...
[developers-reference.git] / best-pkging-practices.dbk
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3     "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4   <!ENTITY % commondata SYSTEM "common.ent" > %commondata;
5 ]>
6 <chapter id="best-pkging-practices">
7 <title>Best Packaging Practices</title>
8 <para>
9 Debian's quality is largely due to the <ulink
10 url="&url-debian-policy;">Debian Policy</ulink>, which
11 defines explicit baseline requirements which all Debian packages must fulfill.
12 Yet there is also a shared history of experience which goes beyond the Debian
13 Policy, an accumulation of years of experience in packaging.  Many very
14 talented people have created great tools, tools which help you, the Debian
15 maintainer, create and maintain excellent packages.
16 </para>
17 <para>
18 This chapter provides some best practices for Debian developers.  All
19 recommendations are merely that, and are not requirements or policy.  These are
20 just some subjective hints, advice and pointers collected from Debian
21 developers.  Feel free to pick and choose whatever works best for you.
22 </para>
23 <section id="bpp-debian-rules">
24 <title>Best practices for <filename>debian/rules</filename></title>
25 <para>
26 The following recommendations apply to the <filename>debian/rules</filename>
27 file.  Since <filename>debian/rules</filename> controls the build process and
28 selects the files which go into the package (directly or indirectly), it's
29 usually the file maintainers spend the most time on.
30 </para>
31 <section id="helper-scripts">
32 <title>Helper scripts</title>
33 <para>
34 The rationale for using helper scripts in <filename>debian/rules</filename> is
35 that they let maintainers use and share common logic among many packages.  Take
36 for instance the question of installing menu entries: you need to put the file
37 into <filename>/usr/share/menu</filename> (or <filename>/usr/lib/menu</filename>
38 for executable binary menufiles, if this is needed), and add commands to the
39 maintainer scripts to register and unregister the menu entries.  Since this is
40 a very common thing for packages to do, why should each maintainer rewrite all
41 this on their own, sometimes with bugs?  Also, supposing the menu directory
42 changed, every package would have to be changed.
43 </para>
44 <para>
45 Helper scripts take care of these issues.  Assuming you comply with the
46 conventions expected by the helper script, the helper takes care of all the
47 details.  Changes in policy can be made in the helper script; then packages
48 just need to be rebuilt with the new version of the helper and no other
49 changes.
50 </para>
51 <para>
52 <xref linkend="tools"/> contains a couple of different helpers.  The most
53 common and best (in our opinion) helper system is <systemitem
54 role="package">debhelper</systemitem>.  Previous helper systems, such as
55 <systemitem role="package">debmake</systemitem>, were monolithic: you couldn't
56 pick and choose which part of the helper you found useful, but had to use the
57 helper to do everything.  <systemitem role="package">debhelper</systemitem>,
58 however, is a number of separate little <command>dh_*</command> programs.  For
59 instance, <command>dh_installman</command> installs and compresses man pages,
60 <command>dh_installmenu</command> installs menu files, and so on.  Thus, it
61 offers enough flexibility to be able to use the little helper scripts, where
62 useful, in conjunction with hand-crafted commands in
63 <filename>debian/rules</filename>.
64 </para>
65 <para>
66 You can get started with <systemitem role="package">debhelper</systemitem> by
67 reading <citerefentry> <refentrytitle>debhelper</refentrytitle>
68 <manvolnum>1</manvolnum> </citerefentry>, and looking at the examples that come
69 with the package.  <command>dh_make</command>, from the <systemitem
70 role="package">dh-make</systemitem> package (see <xref linkend="dh-make"/> ),
71 can be used to convert a vanilla source package to a <systemitem
72 role="package">debhelper</systemitem>ized package.  This shortcut, though,
73 should not convince you that you do not need to bother understanding the
74 individual <command>dh_*</command> helpers.  If you are going to use a helper,
75 you do need to take the time to learn to use that helper, to learn its
76 expectations and behavior.
77 </para>
78 <para>
79 Some people feel that vanilla <filename>debian/rules</filename> files are
80 better, since you don't have to learn the intricacies of any helper system.
81 This decision is completely up to you.  Use what works for you.  Many examples
82 of vanilla <filename>debian/rules</filename> files are available at <ulink
83 url="&url-rules-files;"></ulink>.
84 </para>
85 </section>
86
87 <section id="multiple-patches">
88 <title>Separating your patches into multiple files</title>
89 <para>
90 Big, complex packages may have many bugs that you need to deal with.  If you
91 correct a number of bugs directly in the source, and you're not careful, it can
92 get hard to differentiate the various patches that you applied.  It can get
93 quite messy when you have to update the package to a new upstream version which
94 integrates some of the fixes (but not all).  You can't take the total set of
95 diffs (e.g., from <filename>.diff.gz</filename>) and work out which patch sets
96 to back out as a unit as bugs are fixed upstream.
97 </para>
98 <para>
99 Unfortunately, the packaging system as such currently doesn't provide for
100 separating the patches into several files.  Nevertheless, there are ways to
101 separate patches: the patch files are shipped within the Debian patch file
102 (<filename>.diff.gz</filename>), usually within the
103 <filename>debian/</filename> directory.  The only difference is that they
104 aren't applied immediately by dpkg-source, but by the <literal>build</literal>
105 rule of <filename>debian/rules</filename>.  Conversely, they are reverted in
106 the <literal>clean</literal> rule.
107 </para>
108 <para>
109 <command>dbs</command> is one of the more popular approaches to this.  It does
110 all of the above, and provides a facility for creating new and updating old
111 patches.  See the package <systemitem role="package">dbs</systemitem> for more
112 information and <systemitem role="package">hello-dbs</systemitem> for an
113 example.
114 </para>
115 <para>
116 <command>dpatch</command> also provides these facilities, but it's intended to
117 be even easier to use.  See the package <systemitem
118 role="package">dpatch</systemitem> for documentation and examples (in
119 <filename>/usr/share/doc/dpatch</filename>).
120 </para>
121 </section>
122
123 <section id="multiple-binary">
124 <title>Multiple binary packages</title>
125 <para>
126 A single source package will often build several binary packages, either to
127 provide several flavors of the same software (e.g., the <systemitem
128 role="package">vim</systemitem> source package) or to make several small
129 packages instead of a big one (e.g., so the user can install only the subset
130 needed, and thus save some disk space).
131 </para>
132 <para>
133 The second case can be easily managed in <filename>debian/rules</filename>.
134 You just need to move the appropriate files from the build directory into the
135 package's temporary trees.  You can do this using <command>install</command> or
136 <command>dh_install</command> from <systemitem
137 role="package">debhelper</systemitem>.  Be sure to check the different
138 permutations of the various packages, ensuring that you have the inter-package
139 dependencies set right in <filename>debian/control</filename>.
140 </para>
141 <para>
142 The first case is a bit more difficult since it involves multiple recompiles of
143 the same software but with different configuration options.  The <systemitem
144 role="package">vim</systemitem> source package is an example of how to manage
145 this using an hand-crafted <filename>debian/rules</filename> file.
146 </para>
147 <!-- FIXME: Find a good debhelper example with multiple configure/make
148      cycles -->
149 </section>
150
151 </section>
152
153 <section id="bpp-debian-control">
154 <title>Best practices for <filename>debian/control</filename></title>
155 <para>
156 The following practices are relevant to the <filename>debian/control</filename>
157 file.  They supplement the <ulink
158 url="&url-debian-policy;ch-binary.html#s-descriptions">Policy
159 on package descriptions</ulink>.
160 </para>
161 <para>
162 The description of the package, as defined by the corresponding field in the
163 <filename>control</filename> file, contains both the package synopsis and the
164 long description for the package.  <xref linkend="bpp-desc-basics"/> describes
165 common guidelines for both parts of the package description.  Following that,
166 <xref linkend="bpp-pkg-synopsis"/> provides guidelines specific to the
167 synopsis, and <xref linkend="bpp-pkg-desc"/> contains guidelines specific to
168 the description.
169 </para>
170 <section id="bpp-desc-basics">
171 <title>General guidelines for package descriptions</title>
172 <para>
173 The package description should be written for the average likely user, the
174 average person who will use and benefit from the package.  For instance,
175 development packages are for developers, and can be technical in their
176 language.  More general-purpose applications, such as editors, should be
177 written for a less technical user.
178 </para>
179 <para>
180 Our review of package descriptions lead us to conclude that most package
181 descriptions are technical, that is, are not written to make sense for
182 non-technical users.  Unless your package really is only for technical users,
183 this is a problem.
184 </para>
185 <para>
186 How do you write for non-technical users?  Avoid jargon.  Avoid referring to
187 other applications or frameworks that the user might not be familiar with â€”
188 GNOME or KDE is fine, since users are probably familiar with these terms, but
189 GTK+ is probably not.  Try not to assume any knowledge at all.  If you must use
190 technical terms, introduce them.
191 </para>
192 <para>
193 Be objective.  Package descriptions are not the place for advocating your
194 package, no matter how much you love it.  Remember that the reader may not care
195 about the same things you care about.
196 </para>
197 <para>
198 References to the names of any other software packages, protocol names,
199 standards, or specifications should use their canonical forms, if one exists.
200 For example, use X Window System, X11, or X; not X Windows, X-Windows, or X
201 Window.  Use GTK+, not GTK or gtk.  Use GNOME, not Gnome.  Use PostScript, not
202 Postscript or postscript.
203 </para>
204 <para>
205 If you are having problems writing your description, you may wish to send it
206 along to &email-debian-l10n-english; and request feedback.
207 </para>
208 </section>
209
210 <section id="bpp-pkg-synopsis">
211 <title>The package synopsis, or short description</title>
212 <para>
213 Policy says the synopsis line (the short description) must be concise, not
214 repeating the package name, but also informative.
215 </para>
216 <para>
217 The synopsis functions as a phrase describing the package, not a complete
218 sentence, so sentential punctuation is inappropriate: it does not need extra
219 capital letters or a final period (full stop). It should also omit any initial
220 indefinite or definite article - "a", "an", or "the". Thus for instance:
221 </para>
222 <screen>
223 Package: libeg0
224 Description: exemplification support library
225 </screen>
226 <para>
227 Technically this is a noun phrase minus articles, as opposed to a verb phrase.
228 A good heuristic is that it should be possible to substitute the package name
229 and synopsis into this formula:
230 </para>
231 <para>
232 The package <replaceable>name</replaceable> provides {a,an,the,some}
233 <replaceable>synopsis</replaceable>.
234 </para>
235 <para>
236 Sets of related packages may use an alternative scheme that divides the
237 synopsis into two parts, the first a description of the whole suite and the
238 second a summary of the package's role within it:
239 </para>
240 <screen>
241 Package: eg-tools
242 Description: simple exemplification system (utilities)
243                                       
244 Package: eg-doc
245 Description: simple exemplification system - documentation
246 </screen>
247 <para>
248 These synopses follow a modified formula. Where a package
249 "<replaceable>name</replaceable>" has a synopsis
250 "<replaceable>suite</replaceable> (<replaceable>role</replaceable>)" or
251 "<replaceable>suite</replaceable> - <replaceable>role</replaceable>", the
252 elements should be phrased so that they fit into the formula:
253 </para>
254 <para>
255 The package <replaceable>name</replaceable> provides {a,an,the}
256 <replaceable>role</replaceable> for the <replaceable>suite</replaceable>.
257 </para>
258 </section>
259
260 <section id="bpp-pkg-desc">
261 <title>The long description</title>
262 <para>
263 The long description is the primary information available to the user about a
264 package before they install it.  It should provide all the information needed
265 to let the user decide whether to install the package.  Assume that the user
266 has already read the package synopsis.
267 </para>
268 <para>
269 The long description should consist of full and complete sentences.
270 </para>
271 <para>
272 The first paragraph of the long description should answer the following
273 questions: what does the package do?  what task does it help the user
274 accomplish?  It is important to describe this in a non-technical way, unless of
275 course the audience for the package is necessarily technical.
276 </para>
277 <para>
278 The following paragraphs should answer the following questions: Why do I as a
279 user need this package?  What other features does the package have?  What
280 outstanding features and deficiencies are there compared to other packages
281 (e.g., if you need X, use Y instead)?  Is this package related to other
282 packages in some way that is not handled by the package manager (e.g., this is
283 the client for the foo server)?
284 </para>
285 <para>
286 Be careful to avoid spelling and grammar mistakes.  Ensure that you spell-check
287 it.  Both <command>ispell</command> and <command>aspell</command> have special
288 modes for checking <filename>debian/control</filename> files:
289 </para>
290 <screen>
291 ispell -d american -g debian/control
292 </screen>
293 <screen>
294 aspell -d en -D -c debian/control
295 </screen>
296 <para>
297 Users usually expect these questions to be answered in the package description:
298 </para>
299 <itemizedlist>
300 <listitem>
301 <para>
302 What does the package do?  If it is an add-on to another package, then the
303 short description of the package we are an add-on to should be put in here.
304 </para>
305 </listitem>
306 <listitem>
307 <para>
308 Why should I want this package?  This is related to the above, but not the same
309 (this is a mail user agent; this is cool, fast, interfaces with PGP and LDAP
310 and IMAP, has features X, Y, and Z).
311 </para>
312 </listitem>
313 <listitem>
314 <para>
315 If this package should not be installed directly, but is pulled in by another
316 package, this should be mentioned.
317 </para>
318 </listitem>
319 <listitem>
320 <para>
321 If the package is <literal>experimental</literal>, or there are other reasons
322 it should not be used, if there are other packages that should be used instead,
323 it should be here as well.
324 </para>
325 </listitem>
326 <listitem>
327 <para>
328 How is this package different from the competition?  Is it a better
329 implementation?  more features?  different features?  Why should I choose this
330 package.
331 </para>
332 </listitem>
333 <!-- FIXME: what's this?
334 (the second questions is about the class of packages, and
335 this about this particular package, if you have information related to both).
336 -->
337 </itemizedlist>
338 </section>
339
340 <section id="bpp-upstream-info">
341 <title>Upstream home page</title>
342 <para>
343 We recommend that you add the URL for the package's home page in the
344 <literal>Homepage</literal> field of the <literal>Source</literal> section
345 in <filename>debian/control</filename>.  Adding this information in the
346 package description itself is considered deprecated.
347 </para>
348 </section>
349
350 <section id="bpp-vcs">
351 <title>Version Control System location</title>
352 <para>
353 There are additional fields for the location of the Version Control System in
354 <filename>debian/control</filename>.
355 </para>
356 <section id="s6.2.5.1">
357 <title>Vcs-Browser</title>
358 <para>
359 Value of this field should be a <literal>http://</literal> URL pointing to a
360 web-browsable copy of the Version Control System repository used to maintain
361 the given package, if available.
362 </para>
363 <para>
364 The information is meant to be useful for the final user, willing to browse the
365 latest work done on the package (e.g.  when looking for the patch fixing a bug
366 tagged as <literal>pending</literal> in the bug tracking system).
367 </para>
368 </section>
369
370 <section id="s6.2.5.2">
371 <title>Vcs-*</title>
372 <para>
373 Value of this field should be a string identifying unequivocally the location
374 of the Version Control System repository used to maintain the given package, if
375 available.  <literal>*</literal> identify the Version Control System; currently
376 the following systems are supported by the package tracking system:
377 <literal>arch</literal>, <literal>bzr</literal> (Bazaar),
378 <literal>cvs</literal>, <literal>darcs</literal>, <literal>git</literal>,
379 <literal>hg</literal> (Mercurial), <literal>mtn</literal> (Monotone),
380 <literal>svn</literal> (Subversion).  It is allowed to specify different VCS
381 fields for the same package: they will all be shown in the PTS web interface.
382 </para>
383 <para>
384 The information is meant to be useful for a user knowledgeable in the given
385 Version Control System and willing to build the current version of a package
386 from the VCS sources.  Other uses of this information might include automatic
387 building of the latest VCS version of the given package.  To this end the
388 location pointed to by the field should better be version agnostic and point to
389 the main branch (for VCSs supporting such a concept).  Also, the location
390 pointed to should be accessible to the final user; fulfilling this requirement
391 might imply pointing to an anonymous access of the repository instead of
392 pointing to an SSH-accessible version of the same.
393 </para>
394 <para>
395 In the following example, an instance of the field for a Subversion repository
396 of the <systemitem role="package">vim</systemitem> package is shown.  Note how
397 the URL is in the <literal>svn://</literal> scheme (instead of
398 <literal>svn+ssh://</literal>) and how it points to the
399 <filename>trunk/</filename> branch.  The use of the
400 <literal>Vcs-Browser</literal> and <literal>Homepage</literal> fields
401 described above is also shown.
402 </para>
403 <screen>
404   Source: vim
405   Section: editors
406   Priority: optional
407   &lt;snip&gt;
408   Vcs-Svn: svn://svn.debian.org/svn/pkg-vim/trunk/packages/vim
409   Vcs-Browser: http://svn.debian.org/wsvn/pkg-vim/trunk/packages/vim
410   Homepage: http://www.vim.org
411 </screen>
412 </section>
413
414 </section>
415
416 </section>
417
418 <section id="bpp-debian-changelog">
419 <title>Best practices for <filename>debian/changelog</filename></title>
420 <para>
421 The following practices supplement the <ulink
422 url="&url-debian-policy;ch-docs.html#s-changelogs">Policy
423 on changelog files</ulink>.
424 </para>
425 <section id="bpp-changelog-do">
426 <title>Writing useful changelog entries</title>
427 <para>
428 The changelog entry for a package revision documents changes in that revision,
429 and only them.  Concentrate on describing significant and user-visible changes
430 that were made since the last version.
431 </para>
432 <para>
433 Focus on <emphasis>what</emphasis> was changed â€” who, how and when are
434 usually less important.  Having said that, remember to politely attribute
435 people who have provided notable help in making the package (e.g., those who
436 have sent in patches).
437 </para>
438 <para>
439 There's no need to elaborate the trivial and obvious changes.  You can also
440 aggregate several changes in one entry.  On the other hand, don't be overly
441 terse if you have undertaken a major change.  Be especially clear if there are
442 changes that affect the behaviour of the program.  For further explanations,
443 use the <filename>README.Debian</filename> file.
444 </para>
445 <para>
446 Use common English so that the majority of readers can comprehend it.  Avoid
447 abbreviations, tech-speak and jargon when explaining changes that close bugs,
448 especially for bugs filed by users that did not strike you as particularly
449 technically savvy.  Be polite, don't swear.
450 </para>
451 <para>
452 It is sometimes desirable to prefix changelog entries with the names of the
453 files that were changed.  However, there's no need to explicitly list each and
454 every last one of the changed files, especially if the change was small or
455 repetitive.  You may use wildcards.
456 </para>
457 <para>
458 When referring to bugs, don't assume anything.  Say what the problem was, how
459 it was fixed, and append the closes: #nnnnn string.  See <xref
460 linkend="upload-bugfix"/> for more information.
461 </para>
462 </section>
463
464 <section id="bpp-changelog-misconceptions">
465 <title>Common misconceptions about changelog entries</title>
466 <para>
467 The changelog entries should <emphasis role="strong">not</emphasis> document
468 generic packaging issues (Hey, if you're looking for foo.conf, it's in
469 /etc/blah/.), since administrators and users are supposed to be at least
470 remotely acquainted with how such things are generally arranged on Debian
471 systems.  Do, however, mention if you change the location of a configuration
472 file.
473 </para>
474 <para>
475 The only bugs closed with a changelog entry should be those that are actually
476 fixed in the same package revision.  Closing unrelated bugs in the changelog is
477 bad practice.  See <xref linkend="upload-bugfix"/> .
478 </para>
479 <para>
480 The changelog entries should <emphasis role="strong">not</emphasis> be used for
481 random discussion with bug reporters (I don't see segfaults when starting foo
482 with option bar; send in more info), general statements on life, the universe
483 and everything (sorry this upload took me so long, but I caught the flu), or
484 pleas for help (the bug list on this package is huge, please lend me a hand).
485 Such things usually won't be noticed by their target audience, but may annoy
486 people who wish to read information about actual changes in the package.  See
487 <xref linkend="bug-answering"/> for more information on how to use the bug
488 tracking system.
489 </para>
490 <para>
491 It is an old tradition to acknowledge bugs fixed in non-maintainer uploads in
492 the first changelog entry of the proper maintainer upload.  As we have version
493 tracking now, it is enough to keep the NMUed changelog entries and just mention
494 this fact in your own changelog entry.
495 </para>
496 </section>
497
498 <section id="bpp-changelog-errors">
499 <title>Common errors in changelog entries</title>
500 <para>
501 The following examples demonstrate some common errors or examples of bad style
502 in changelog entries.
503 </para>
504 <screen>
505   * Fixed all outstanding bugs.
506 </screen>
507 <para>
508 This doesn't tell readers anything too useful, obviously.
509 </para>
510 <screen>
511   * Applied patch from Jane Random.
512 </screen>
513 <para>
514 What was the patch about?
515 </para>
516 <screen>
517   * Late night install target overhaul.
518 </screen>
519 <para>
520 Overhaul which accomplished what?  Is the mention of late night supposed to
521 remind us that we shouldn't trust that code?
522 </para>
523 <screen>
524   * Fix vsync FU w/ ancient CRTs.
525 </screen>
526 <para>
527 Too many acronyms, and it's not overly clear what the, uh, fsckup (oops, a
528 curse word!) was actually about, or how it was fixed.
529 </para>
530 <screen>
531   * This is not a bug, closes: #nnnnnn.
532 </screen>
533 <para>
534 First of all, there's absolutely no need to upload the package to convey this
535 information; instead, use the bug tracking system.  Secondly, there's no
536 explanation as to why the report is not a bug.
537 </para>
538 <screen>
539   * Has been fixed for ages, but I forgot to close; closes: #54321.
540 </screen>
541 <para>
542 If for some reason you didn't mention the bug number in a previous changelog
543 entry, there's no problem, just close the bug normally in the BTS.  There's no
544 need to touch the changelog file, presuming the description of the fix is
545 already in (this applies to the fixes by the upstream authors/maintainers as
546 well, you don't have to track bugs that they fixed ages ago in your changelog).
547 </para>
548 <screen>
549   * Closes: #12345, #12346, #15432
550 </screen>
551 <para>
552 Where's the description?  If you can't think of a descriptive message, start by
553 inserting the title of each different bug.
554 </para>
555 </section>
556
557 <section id="bpp-news-debian">
558 <title>Supplementing changelogs with NEWS.Debian files</title>
559 <para>
560 Important news about changes in a package can also be put in <filename>
561 NEWS.Debian</filename> files.
562 The news will be displayed by tools like apt-listchanges, before all the rest
563 of the changelogs.  This is the preferred means to let the user know about
564 significant changes in a package.  It is better than using debconf notes since
565 it is less annoying and the user can go back and refer to the <filename>
566 NEWS.Debian</filename> file after the install.  And it's better than listing
567 major changes in <filename>README.Debian</filename>, since the user can easily
568 miss such notes.
569 </para>
570 <para>
571 The file format is the same as a debian changelog file, but leave off the
572 asterisks and describe each news item with a full paragraph when necessary
573 rather than the more concise summaries that would go in a changelog.  It's a
574 good idea to run your file through <literal>dpkg-parsechangelog</literal> to
575 check its formatting as it will not be automatically checked during build as
576 the changelog is.  Here is an example of a real <filename>NEWS.Debian
577 </filename> file:
578 </para>
579 <screen>
580 cron (3.0pl1-74) unstable; urgency=low
581
582     The checksecurity script is no longer included with the cron package:
583     it now has its own package, checksecurity. If you liked the
584     functionality provided with that script, please install the new
585     package.
586
587  -- Steve Greenland &lt;stevegr@debian.org&gt;  Sat,  6 Sep 2003 17:15:03 -0500
588 </screen>
589 <para>
590 The <filename>NEWS.Debian</filename> file is installed as <filename>
591 /usr/share/doc/<replaceable>package</replaceable>/NEWS.Debian.gz</filename>.
592 It is compressed, and always has that name even in Debian native packages.
593 If you use <literal>debhelper</literal>, <literal>dh_installchangelogs
594 </literal> will install <filename>debian/NEWS</filename> files for you.
595 </para>
596 <para>
597 Unlike changelog files, you need not update <filename>NEWS.Debian</filename>
598 files with every release.  Only update them if you have something particularly
599 newsworthy that user should know about.  If you have no news at all, there's no
600 need to ship a <filename>NEWS.Debian</filename> file in your package.  No news
601 is good news!
602 </para>
603 </section>
604
605 </section>
606
607 <!--
608 <section id="pkg-mgmt-cvs">
609 <title>Managing a package with CVS</title>
610 <para>
611 FIXME: presentation of cvs-buildpackage, updating sources
612 via CVS (debian/rules refresh).
613 <ulink url="&url-devel-docs;cvs_packages">"&url-devel-docs;cvs_packages"</ulink>
614 </para>
615 </section>
616 -->
617
618 <section id="bpp-debian-maint-scripts">
619 <title>Best practices for maintainer scripts</title>
620 <para>
621 Maintainer scripts include the files <filename>debian/postinst</filename>,
622 <filename>debian/preinst</filename>, <filename>debian/prerm</filename> and
623 <filename>debian/postrm</filename>.  These scripts take care of any package
624 installation or deinstallation setup which isn't handled merely by the creation
625 or removal of files and directories.  The following instructions supplement the
626 <ulink url="&url-debian-policy;">Debian Policy</ulink>.
627 </para>
628 <para>
629 Maintainer scripts must be idempotent.  That means that you need to make sure
630 nothing bad will happen if the script is called twice where it would usually be
631 called once.
632 </para>
633 <para>
634 Standard input and output may be redirected (e.g.  into pipes) for logging
635 purposes, so don't rely on them being a tty.
636 </para>
637 <para>
638 All prompting or interactive configuration should be kept to a minimum.  When
639 it is necessary, you should use the <systemitem
640 role="package">debconf</systemitem> package for the interface.  Remember that
641 prompting in any case can only be in the <literal>configure</literal> stage of
642 the <filename>postinst</filename> script.
643 </para>
644 <para>
645 Keep the maintainer scripts as simple as possible.  We suggest you use pure
646 POSIX shell scripts.  Remember, if you do need any bash features, the
647 maintainer script must have a bash shebang line.  POSIX shell or Bash are
648 preferred to Perl, since they enable <systemitem
649 role="package">debhelper</systemitem> to easily add bits to the scripts.
650 </para>
651 <para>
652 If you change your maintainer scripts, be sure to test package removal, double
653 installation, and purging.  Be sure that a purged package is completely gone,
654 that is, it must remove any files created, directly or indirectly, in any
655 maintainer script.
656 </para>
657 <para>
658 If you need to check for the existence of a command, you should use something
659 like
660 </para>
661 <programlisting>if [ -x /usr/sbin/install-docs ]; then ...</programlisting>
662 <para>
663 If you don't wish to hard-code the path of a command in your maintainer script,
664 the following POSIX-compliant shell function may help:
665 </para>
666 &example-pathfind;
667 <para>
668 You can use this function to search <literal>$PATH</literal> for a command
669 name, passed as an argument.  It returns true (zero) if the command was found,
670 and false if not.  This is really the most portable way, since <literal>command
671 -v</literal>, <command>type</command>, and <command>which</command> are not
672 POSIX.
673 </para>
674 <para>
675 While <command>which</command> is an acceptable alternative, since it is from
676 the required <systemitem role="package">debianutils</systemitem> package, it's
677 not on the root partition.  That is, it's in <filename>/usr/bin</filename>
678 rather than <filename>/bin</filename>, so one can't use it in scripts which are
679 run before the <filename>/usr</filename> partition is mounted.  Most scripts
680 won't have this problem, though.
681 </para>
682 </section>
683
684 <section id="bpp-config-mgmt">
685 <title>Configuration management with <systemitem role="package">debconf</systemitem></title>
686 <para>
687 <systemitem role="package">Debconf</systemitem> is a configuration management
688 system which can be used by all the various packaging scripts
689 (<filename>postinst</filename> mainly) to request feedback from the user
690 concerning how to configure the package.  Direct user interactions must now be
691 avoided in favor of <systemitem role="package">debconf</systemitem>
692 interaction.  This will enable non-interactive installations in the future.
693 </para>
694 <para>
695 Debconf is a great tool but it is often poorly used.  Many common mistakes are
696 listed in the <citerefentry> <refentrytitle>debconf-devel</refentrytitle>
697 <manvolnum>7</manvolnum> </citerefentry> man page.  It is something that you
698 must read if you decide to use debconf.  Also, we document some best practices
699 here.
700 </para>
701 <para>
702 These guidelines include some writing style and typography recommendations,
703 general considerations about debconf usage as well as more specific
704 recommendations for some parts of the distribution (the installation system for
705 instance).
706 </para>
707 <section id="s6.5.1">
708 <title>Do not abuse debconf</title>
709 <para>
710 Since debconf appeared in Debian, it has been widely abused and several
711 criticisms received by the Debian distribution come from debconf abuse with the
712 need of answering a wide bunch of questions before getting any little thing
713 installed.
714 </para>
715 <para>
716 Keep usage notes to what they belong: the NEWS.Debian, or README.Debian file.
717 Only use notes for important notes which may directly affect the package
718 usability.  Remember that notes will always block the install until confirmed
719 or bother the user by email.
720 </para>
721 <para>
722 Carefully choose the questions priorities in maintainer scripts.  See
723 <citerefentry> <refentrytitle>debconf-devel</refentrytitle>
724 <manvolnum>7</manvolnum> </citerefentry> for details about priorities.  Most
725 questions should use medium and low priorities.
726 </para>
727 </section>
728
729 <section id="s6.5.2">
730 <title>General recommendations for authors and translators</title>
731 <section id="s6.5.2.1">
732 <title>Write correct English</title>
733 <para>
734 Most Debian package maintainers are not native English speakers.  So, writing
735 properly phrased templates may not be easy for them.
736 </para>
737 <para>
738 Please use (and abuse) &email-debian-l10n-english; mailing
739 list.  Have your templates proofread.
740 </para>
741 <para>
742 Badly written templates give a poor image of your package, of your work...or
743 even of Debian itself.
744 </para>
745 <para>
746 Avoid technical jargon as much as possible.  If some terms sound common to you,
747 they may be impossible to understand for others.  If you cannot avoid them, try
748 to explain them (use the extended description).  When doing so, try to balance
749 between verbosity and simplicity.
750 </para>
751 </section>
752
753 <section id="s6.5.2.2">
754 <title>Be kind to translators</title>
755 <para>
756 Debconf templates may be translated.  Debconf, along with its sister package
757 <command>po-debconf</command> offers a simple framework for getting templates
758 translated by translation teams or even individuals.
759 </para>
760 <para>
761 Please use gettext-based templates.  Install <systemitem
762 role="package">po-debconf</systemitem> on your development system and read its
763 documentation (<literal>man po-debconf</literal> is a good start).
764 </para>
765 <para>
766 Avoid changing templates too often.  Changing templates text induces more work
767 to translators which will get their translation fuzzied.  A fuzzy translation is
768 a string for which the original changed since it was translated, therefore
769 requiring some update by a translator to be usable.  When changes are small
770 enough, the original translation is kept in PO files but marked as
771 <literal>fuzzy</literal>.
772 </para>
773 <para>
774 If you plan to do changes
775 to your original templates, please use the notification system provided with
776 the <systemitem
777 role="package">po-debconf</systemitem> package, namely the <command>
778 podebconf-report-po</command>, to contact translators.  Most active
779 translators are very responsive and getting their work included along with your
780 modified templates will save you additional uploads.  If you use gettext-based
781 templates, the translator's name and e-mail addresses are mentioned in the PO
782 files headers and will be used by <command>
783 podebconf-report-po</command>.
784 </para>
785 <para>
786 A recommended use of that utility is:
787 </para>
788 <programlisting>cd debian/po &amp;&amp; podebconf-report-po --languageteam --withtranslators --call --deadline="+10 days"</programlisting>
789 <para>
790 This command will first synchronize the PO and POT files in debian/po with
791 the templates files listed in <filename>debian/po/POTFILES.in</filename>.
792 Then, it will send a call for translation updates to the language team
793 (mentioned in the <literal>Language-Team</literal> field of each PO file)
794 as well as the last translator (mentioned in
795 <literal>Last-translator</literal>). Finally, it will also send a call for
796 new translations, in the &email-debian-i18n; mailing list.
797 </para>
798 <para>
799 Giving a deadline to translators is always appreciated, so that they can
800 organize their work. Please remember that some translation teams have a
801 formalized translate/review process and a delay lower than 10 days is
802 considered as unreasonable. A shorter delay puts too much pressure on translation
803 teams and should be kept for very minor changes.
804 </para>
805 <para>
806 If in doubt, you may also contact the translation team for a given language
807 (debian-l10n-xxxxx@&lists-host;), or the
808 &email-debian-i18n; mailing list.
809 </para>
810 </section>
811
812 <section id="s6.5.2.3">
813 <title>Unfuzzy complete translations when correcting typos and spelling</title>
814 <para>
815 When the text of a debconf template is corrected and you are <emphasis
816 role="strong">sure</emphasis> that the change does <emphasis
817 role="strong">not</emphasis> affect translations, please be kind to translators
818 and <emphasis>unfuzzy</emphasis> their translations.
819 </para>
820 <para>
821 If you don't do so, the whole template will not be translated as long as a
822 translator will send you an update.
823 </para>
824 <para>
825 To <emphasis>unfuzzy</emphasis> translations, you can use two methods. The first
826 method does <emphasis>preventive</emphasis> search and replace actions in the
827 PO files. The latter uses <command>gettext</command> utilities to <emphasis>unfuzzy</emphasis>
828 strings.
829 </para>
830 <para>
831 <emphasis>Preventive unfuzzy</emphasis> method:
832 </para>
833 <orderedlist numeration="arabic">
834 <listitem>
835 <para>
836 Try finding a complete translation file <emphasis role="strong"> before</emphasis>
837 the change:
838 </para>
839 <programlisting>for i in debian/po/*po; do echo -n $i: ; msgfmt -o /dev/null
840 --statistics $i; done</programlisting>
841 <para>
842 The file only showing <emphasis>translated</emphasis> items will be used
843 as the reference file. If there is none (which should not happen if you take
844 care to properly interact with translators), you should use the file
845 with the most translated strings.
846 </para>
847 </listitem>
848 <listitem>
849 <para>
850 Identify the needed change. In this example, let's assume the change is about
851 fixing a typo in the word <literal>typo</literal> which was inadvertently
852 written as <literal>tpyo</literal>. Therefore, the change is
853 <command>s/tpyo/typo</command>.
854 </para>
855 </listitem>
856 <listitem>
857 <para>
858 Check that this change is only applied to the place where you really intend
859 to make it and <emphasis role="strong">not</emphasis> in any other place
860 where the original string is appropriate. This specifically applies to
861 change in punctuation, for instance.
862 </para>
863 </listitem>
864 <listitem>
865 <para>
866 Modify all PO files by using <command>sed</command>. The use of that command
867 is recommended over any text editor to guarantee that the files encoding will
868 not be broken by the edit action.
869 </para>
870 <programlisting>
871 cd debian/po
872 for i in *.po; do sed -i 's/tpyo/typo/g' $i; done
873 </programlisting>
874 </listitem>
875 <listitem>
876 <para>
877 Change the debconf template file to fix the typo.
878 </para>
879 </listitem>
880 <listitem>
881 <para>
882 Run <command>debconf-updatepo</command>
883 </para>
884 </listitem>
885 <listitem>
886 <para>
887 Check the <filename>foo.po</filename> reference file. Its statistics should
888 not be changed:
889 </para>
890 <programlisting>
891 msgfmt -o /dev/null --statistics debian/po/foo.po
892 </programlisting>
893 </listitem>
894 <listitem>
895 If the file's statistics changed, you did something wrong. Try again
896 or ask for help on the &email-debian-i18n; mailing list.
897 </listitem>
898 </orderedlist>
899 <para>
900 Gettext utilities method:
901 </para>
902 <orderedlist numeration="arabic">
903 <listitem>
904 <para>
905 Put all incomplete PO files out of the way.  You can check the completeness by
906 using (needs the <systemitem role="package">gettext</systemitem> package
907 installed):
908 </para>
909 <programlisting>for i in debian/po/*po; do echo -n $i: ; msgfmt -o /dev/null
910 --statistics $i; done</programlisting>
911 </listitem>
912 <listitem>
913 <para>
914 move all files which report either fuzzy strings to a temporary place.  Files
915 which report no fuzzy strings (only translated and untranslated) will be kept
916 in place.
917 </para>
918 </listitem>
919 <listitem>
920 <para>
921 now <emphasis role="strong">and now only</emphasis>, modify the template for
922 the typos and check again that translation are not impacted (typos, spelling
923 errors, sometimes typographical corrections are usually OK)
924 </para>
925 </listitem>
926 <listitem>
927 <para>
928 run <command>debconf-updatepo</command>.  This will fuzzy all strings you
929 modified in translations.  You can see this by running the above again
930 </para>
931 </listitem>
932 <listitem>
933 <para>
934 use the following command:
935 </para>
936 <programlisting>for i in debian/po/*po; do msgattrib --output-file=$i --clear-fuzzy $i; done</programlisting>
937 </listitem>
938 <listitem>
939 <para>
940 move back to debian/po the files which showed fuzzy strings in the first step
941 </para>
942 </listitem>
943 <listitem>
944 <para>
945 run <command>debconf-updatepo</command> again
946 </para>
947 </listitem>
948 </orderedlist>
949 </section>
950
951 <section id="s6.5.2.4">
952 <title>Do not make assumptions about interfaces</title>
953 <para>
954 Templates text should not make reference to widgets belonging to some debconf
955 interfaces.  Sentences like <emphasis>If you answer Yes...</emphasis> have no meaning for users of
956 graphical interfaces which use checkboxes for boolean questions.
957 </para>
958 <para>
959 String templates should also avoid mentioning the default values in their
960 description.  First, because this is redundant with the values seen by the
961 users.  Also, because these default values may be different from the maintainer
962 choices (for instance, when the debconf database was preseeded).
963 </para>
964 <para>
965 More generally speaking, try to avoid referring to user actions.  Just give
966 facts.
967 </para>
968 </section>
969
970 <section id="s6.5.2.5">
971 <title>Do not use first person</title>
972 <para>
973 You should avoid the use of first person (<emphasis>I will do this...</emphasis> or <emphasis>We
974 recommend...</emphasis>).  The computer is not a person and the Debconf templates do not
975 speak for the Debian developers.  You should use neutral construction.  Those
976 of you who already wrote scientific publications, just write your templates
977 like you would write a scientific paper.  However, try using active voice if
978 still possible, like <emphasis>Enable this if ...</emphasis> instead of <emphasis>This can be enabled if...</emphasis>.
979 </para>
980 </section>
981
982 <section id="s6.5.2.6">
983 <title>Be gender neutral</title>
984 <para>
985 The world is made of men and women.  Please use gender-neutral constructions in
986 your writing.
987 </para>
988 </section>
989
990 </section>
991
992 <section id="s6.5.3">
993 <title>Templates fields definition</title>
994 <para>
995 This part gives some information which is mostly taken from the <citerefentry>
996 <refentrytitle>debconf-devel</refentrytitle> <manvolnum>7</manvolnum>
997 </citerefentry> manual page.
998 </para>
999 <section id="s6.5.3.1">
1000 <title>Type</title>
1001 <section id="s6.5.3.1.1">
1002 <title>string:</title>
1003 <para>
1004 Results in a free-form input field that the user can type any string into.
1005 </para>
1006 </section>
1007
1008 <section id="s6.5.3.1.2">
1009 <title>password:</title>
1010 <para>
1011 Prompts the user for a password.  Use this with caution; be aware that the
1012 password the user enters will be written to debconf's database.  You should
1013 probably clean that value out of the database as soon as is possible.
1014 </para>
1015 </section>
1016
1017 <section id="s6.5.3.1.3">
1018 <title>boolean:</title>
1019 <para>
1020 A true/false choice.  Remember: true/false, <emphasis role="strong">not
1021 yes/no</emphasis>...
1022 </para>
1023 </section>
1024
1025 <section id="s6.5.3.1.4">
1026 <title>select:</title>
1027 <para>
1028 A choice between one of a number of values.  The choices must be specified in a
1029 field named 'Choices'.  Separate the possible values with commas and spaces,
1030 like this: <literal>Choices: yes, no, maybe</literal>.
1031 </para>
1032 <para>
1033 If choices are translatable strings, the 'Choices' field may be marked as
1034 translatable by using <literal>__Choices</literal>. The double underscore will split out
1035 each choice in a separate string.
1036 </para>
1037 <para>
1038 The <command>po-debconf</command> system also offers interesting possibilities
1039 to only mark <emphasis role="strong">some</emphasis> choices as translatable.
1040 Example:
1041 </para>
1042 <programlisting>
1043 Template: foo/bar
1044 Type: Select
1045 #flag:translate:3
1046 __Choices: PAL, SECAM, Other
1047 _Description: TV standard:
1048  Please choose the TV standard used in your country.
1049 </programlisting>
1050 <para>
1051 In that example, only the 'Other' string is translatable while others
1052 are acronyms that should not be translated. The above allows only
1053 'Other' to be included in PO and POT files.
1054 </para>
1055 <para>
1056 The debconf templates flag system offers many such possibilities. The
1057 <citerefentry>
1058 <refentrytitle>po-debconf</refentrytitle> <manvolnum>7</manvolnum>
1059 </citerefentry> manual page lists all these possibilities.
1060 </para>
1061 </section>
1062
1063 <section id="s6.5.3.1.5">
1064 <title>multiselect:</title>
1065 <para>
1066 Like the select data type, except the user can choose any number of items from
1067 the choices list (or chose none of them).
1068 </para>
1069 </section>
1070
1071 <section id="s6.5.3.1.6">
1072 <title>note:</title>
1073 <para>
1074 Rather than being a question per se, this datatype indicates a note that can be
1075 displayed to the user.  It should be used only for important notes that the
1076 user really should see, since debconf will go to great pains to make sure the
1077 user sees it; halting the install for them to press a key, and even mailing the
1078 note to them in some cases.
1079 </para>
1080 </section>
1081
1082 <section id="s6.5.3.1.7">
1083 <title>text:</title>
1084 <para>
1085 This type is now considered obsolete: don't use it.
1086 </para>
1087 </section>
1088
1089 <section id="s6.5.3.1.8">
1090 <title>error:</title>
1091 <para>
1092 This type is designed to handle error messages.  It is mostly similar to the
1093 note type.  Frontends may present it differently (for instance, the dialog
1094 frontend of cdebconf draws a red screen instead of the usual blue one).
1095 </para>
1096 <para>
1097 It is recommended to use this type for any message that needs user attention
1098 for a correction of any kind.
1099 </para>
1100 </section>
1101
1102 </section>
1103
1104 <section id="s6.5.3.2">
1105 <title>Description: short and extended description</title>
1106 <para>
1107 Template descriptions have two parts: short and extended.  The short
1108 description is in the Description: line of the template.
1109 </para>
1110 <para>
1111 The short description should be kept short (50 characters or so) so that it may
1112 be accomodated by most debconf interfaces.  Keeping it short also helps
1113 translators, as usually translations tend to end up being longer than the
1114 original.
1115 </para>
1116 <para>
1117 The short description should be able to stand on its own.  Some interfaces do
1118 not show the long description by default, or only if the user explicitely asks
1119 for it or even do not show it at all.  Avoid things like What do you want to
1120 do?
1121 </para>
1122 <para>
1123 The short description does not necessarily have to be a full sentence.  This is
1124 part of the keep it short and efficient recommendation.
1125 </para>
1126 <para>
1127 The extended description should not repeat the short description word for word.
1128 If you can't think up a long description, then first, think some more.  Post to
1129 debian-devel.  Ask for help.  Take a writing class!  That extended description
1130 is important.  If after all that you still can't come up with anything, leave
1131 it blank.
1132 </para>
1133 <para>
1134 The extended description should use complete sentences.  Paragraphs should be
1135 kept short for improved readability.  Do not mix two ideas in the same
1136 paragraph but rather use another paragraph.
1137 </para>
1138 <para>
1139 Don't be too verbose.  User tend to ignore too long screens.  20 lines are by
1140 experience a border you shouldn't cross, because that means that in the
1141 classical dialog interface, people will need to scroll, and lot of people just
1142 don't do that.
1143 </para>
1144 <para>
1145 The extended description should <emphasis role="strong">never</emphasis>
1146 include a question.
1147 </para>
1148 <para>
1149 For specific rules depending on templates type (string, boolean, etc.), please
1150 read below.
1151 </para>
1152 </section>
1153
1154 <section id="s6.5.3.3">
1155 <title>Choices</title>
1156 <para>
1157 This field should be used for Select and Multiselect types.  It contains the
1158 possible choices which will be presented to users.  These choices should be
1159 separated by commas.
1160 </para>
1161 </section>
1162
1163 <section id="s6.5.3.4">
1164 <title>Default</title>
1165 <para>
1166 This field is optional.  It contains the default answer for string, select and
1167 multiselect templates.  For multiselect templates, it may contain a
1168 comma-separated list of choices.
1169 </para>
1170 </section>
1171
1172 </section>
1173
1174 <section id="s6.5.4">
1175 <title>Templates fields specific style guide</title>
1176 <section id="s6.5.4.1">
1177 <title>Type field</title>
1178 <para>
1179 No specific indication except: use the appropriate type by referring to the
1180 previous section.
1181 </para>
1182 </section>
1183
1184 <section id="s6.5.4.2">
1185 <title>Description field</title>
1186 <para>
1187 Below are specific instructions for properly writing the Description (short and
1188 extended) depending on the template type.
1189 </para>
1190 <section id="s6.5.4.2.1">
1191 <title>String/password templates</title>
1192 <itemizedlist>
1193 <listitem>
1194 <para>
1195 The short description is a prompt and <emphasis role="strong">not</emphasis> a
1196 title.  Avoid question style prompts (IP Address?) in favour of opened prompts
1197 (IP address:).  The use of colons is recommended.
1198 </para>
1199 </listitem>
1200 <listitem>
1201 <para>
1202 The extended description is a complement to the short description.  In the
1203 extended part, explain what is being asked, rather than ask the same question
1204 again using longer words.  Use complete sentences.  Terse writing style is
1205 strongly discouraged.
1206 </para>
1207 </listitem>
1208 </itemizedlist>
1209 </section>
1210
1211 <section id="s6.5.4.2.2">
1212 <title>Boolean templates</title>
1213 <itemizedlist>
1214 <listitem>
1215 <para>
1216 The short description should be phrased in the form of a question which should
1217 be kept short and should generally end with a question mark.  Terse writing
1218 style is permitted and even encouraged if the question is rather long (remember
1219 that translations are often longer than original versions)
1220 </para>
1221 </listitem>
1222 <listitem>
1223 <para>
1224 Again, please avoid referring to specific interface widgets.  A common mistake
1225 for such templates is if you answer Yes-type constructions.
1226 </para>
1227 </listitem>
1228 </itemizedlist>
1229 </section>
1230
1231 <section id="s6.5.4.2.3">
1232 <title>Select/Multiselect</title>
1233 <itemizedlist>
1234 <listitem>
1235 <para>
1236 The short description is a prompt and <emphasis role="strong">not</emphasis> a
1237 title.  Do <emphasis role="strong">not</emphasis> use useless Please choose...
1238 constructions.  Users are clever enough to figure out they have to choose
1239 something...:)
1240 </para>
1241 </listitem>
1242 <listitem>
1243 <para>
1244 The extended description will complete the short description.  It may refer to
1245 the available choices.  It may also mention that the user may choose more than
1246 one of the available choices, if the template is a multiselect one (although
1247 the interface often makes this clear).
1248 </para>
1249 </listitem>
1250 </itemizedlist>
1251 </section>
1252
1253 <section id="s6.5.4.2.4">
1254 <title>Notes</title>
1255 <itemizedlist>
1256 <listitem>
1257 <para>
1258 The short description should be considered to be a *title*.
1259 </para>
1260 </listitem>
1261 <listitem>
1262 <para>
1263 The extended description is what will be displayed as a more detailed
1264 explanation of the note.  Phrases, no terse writing style.
1265 </para>
1266 </listitem>
1267 <listitem>
1268 <para>
1269 <emphasis role="strong">Do not abuse debconf.</emphasis> Notes are the most
1270 common way to abuse debconf.  As written in debconf-devel manual page: it's
1271 best to use them only for warning about very serious problems.  The NEWS.Debian
1272 or README.Debian files are the appropriate location for a lot of notes.  If, by
1273 reading this, you consider converting your Note type templates to entries in
1274 NEWS/Debian or README.Debian, plus consider keeping existing translations for
1275 the future.
1276 </para>
1277 </listitem>
1278 </itemizedlist>
1279 </section>
1280
1281 </section>
1282
1283 <section id="s6.5.4.3">
1284 <title>Choices field</title>
1285 <para>
1286 If the Choices are likely to change often, please consider using the __Choices
1287 trick.  This will split each individual choice into a single string, which will
1288 considerably help translators for doing their work.
1289 </para>
1290 </section>
1291
1292 <section id="s6.5.4.4">
1293 <title>Default field</title>
1294 <para>
1295 If the default value, for a select template, is likely to vary depending on the
1296 user language (for instance, if the choice is a language choice), please use
1297 the _DefaultChoice trick.
1298 </para>
1299 <para>
1300 This special field allow translators to put the most appropriate choice
1301 according to their own language.  It will become the default choice when their
1302 language is used while your own mentioned Default Choice will be used when
1303 using English.
1304 </para>
1305 <para>
1306 Example, taken from the geneweb package templates:
1307 </para>
1308 <screen>
1309 Template: geneweb/lang
1310 Type: select
1311 __Choices: Afrikaans (af), Bulgarian (bg), Catalan (ca), Chinese (zh), Czech (cs), Danish (da), Dutch (nl), English (en), Esperanto (eo), Estonian (et), Finnish (fi), French (fr), German (de), Hebrew (he), Icelandic (is), Italian (it), Latvian (lv), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swedish (sv)
1312 # This is the default choice. Translators may put their own language here
1313 # instead of the default.
1314 # WARNING : you MUST use the ENGLISH FORM of your language
1315 # For instance, the french translator will need to put French (fr) here.
1316 _DefaultChoice: English (en)[ translators, please see comment in PO files]
1317 _Description: Geneweb default language:
1318 </screen>
1319 <para>
1320 Note the use of brackets which allow internal comments in debconf fields.  Also
1321 note the use of comments which will show up in files the translators will work
1322 with.
1323 </para>
1324 <para>
1325 The comments are needed as the DefaultChoice trick is a bit confusing: the
1326 translators may put their own choice
1327 </para>
1328 </section>
1329
1330 <section id="s6.5.4.5">
1331 <title>Default field</title>
1332 <para>
1333 Do NOT use empty default field.  If you don't want to use default values, do
1334 not use Default at all.
1335 </para>
1336 <para>
1337 If you use po-debconf (and you <emphasis role="strong">should</emphasis>, see
1338 2.2), consider making this field translatable, if you think it may be
1339 translated.
1340 </para>
1341 <para>
1342 If the default value may vary depending on language/country (for instance the
1343 default value for a language choice), consider using the special _DefaultChoice
1344 type documented in <citerefentry> <refentrytitle>po-debconf</refentrytitle>
1345 <manvolnum>7</manvolnum> </citerefentry>).
1346 </para>
1347 </section>
1348
1349 </section>
1350
1351 </section>
1352
1353 <section id="bpp-i18n">
1354 <title>Internationalization</title>
1355 <section id="bpp-i18n-debconf">
1356 <title>Handling debconf translations</title>
1357 <para>
1358 Like porters, translators have a difficult task.  They work on many packages
1359 and must collaborate with many different maintainers.  Moreover, most of the
1360 time, they are not native English speakers, so you may need to be particularly
1361 patient with them.
1362 </para>
1363 <para>
1364 The goal of <systemitem role="package">debconf</systemitem> was to make
1365 packages configuration easier for maintainers and for users.  Originally,
1366 translation of debconf templates was handled with
1367 <command>debconf-mergetemplate</command>.  However, that technique is now
1368 deprecated; the best way to accomplish <systemitem
1369 role="package">debconf</systemitem> internationalization is by using the
1370 <systemitem role="package">po-debconf</systemitem> package.  This method is
1371 easier both for maintainer and translators; transition scripts are provided.
1372 </para>
1373 <para>
1374 Using <systemitem role="package">po-debconf</systemitem>, the translation is
1375 stored in <filename>po</filename> files (drawing from
1376 <command>gettext</command> translation techniques).  Special template files
1377 contain the original messages and mark which fields are translatable.  When you
1378 change the value of a translatable field, by calling
1379 <command>debconf-updatepo</command>, the translation is marked as needing
1380 attention from the translators.  Then, at build time, the
1381 <command>dh_installdebconf</command> program takes care of all the needed magic
1382 to add the template along with the up-to-date translations into the binary
1383 packages.  Refer to the <citerefentry>
1384 <refentrytitle>po-debconf</refentrytitle> <manvolnum>7</manvolnum>
1385 </citerefentry> manual page for details.
1386 </para>
1387 </section>
1388
1389 <section id="bpp-i18n-docs">
1390 <title>Internationalized documentation</title>
1391 <para>
1392 Internationalizing documentation is crucial for users, but a lot of labor.
1393 There's no way to eliminate all that work, but you can make things easier for
1394 translators.
1395 </para>
1396 <para>
1397 If you maintain documentation of any size, its easier for translators if they
1398 have access to a source control system.  That lets translators see the
1399 differences between two versions of the documentation, so, for instance, they
1400 can see what needs to be retranslated.  It is recommended that the translated
1401 documentation maintain a note about what source control revision the
1402 translation is based on.  An interesting system is provided by <ulink
1403 url="&url-i18n-doc-check;">doc-check</ulink> in the
1404 <systemitem role="package">boot-floppies</systemitem> package, which shows an
1405 overview of the translation status for any given language, using structured
1406 comments for the current revision of the file to be translated and, for a
1407 translated file, the revision of the original file the translation is based on.
1408 You might wish to adapt and provide that in your CVS area.
1409 </para>
1410 <para>
1411 If you maintain XML or SGML documentation, we suggest that you isolate any
1412 language-independent information and define those as entities in a separate
1413 file which is included by all the different translations.  This makes it much
1414 easier, for instance, to keep URLs up to date across multiple files.
1415 </para>
1416 </section>
1417
1418 </section>
1419
1420 <section id="bpp-common-situations">
1421 <title>Common packaging situations</title>
1422 <!--
1423 <section id="bpp-kernel">
1424 <title>Kernel modules/patches</title>
1425 <para>
1426 FIXME: Heavy use of kernel-package. provide files in
1427 /etc/modutils/ for module configuration.
1428 </para>
1429 </section>
1430 -->
1431 <section id="bpp-autotools">
1432 <title>Packages using <command>autoconf</command>/<command>automake</command></title>
1433 <para>
1434 Keeping <command>autoconf</command>'s <filename>config.sub</filename> and
1435 <filename>config.guess</filename> files up to date is critical for porters,
1436 especially on more volatile architectures.  Some very good packaging practices
1437 for any package using <command>autoconf</command> and/or
1438 <command>automake</command> have been synthesized in
1439 &file-bpp-autotools; from the
1440 <systemitem role="package">autotools-dev</systemitem> package.  You're strongly
1441 encouraged to read this file and to follow the given recommendations.
1442 </para>
1443 </section>
1444
1445 <section id="bpp-libraries">
1446 <title>Libraries</title>
1447 <para>
1448 Libraries are always difficult to package for various reasons.  The policy
1449 imposes many constraints to ease their maintenance and to make sure upgrades
1450 are as simple as possible when a new upstream version comes out.  Breakage in a
1451 library can result in dozens of dependent packages breaking.
1452 </para>
1453 <para>
1454 Good practices for library packaging have been grouped in <ulink
1455 url="&url-libpkg-guide;">the library
1456 packaging guide</ulink>.
1457 </para>
1458 </section>
1459
1460 <section id="bpp-docs">
1461 <title>Documentation</title>
1462 <para>
1463 Be sure to follow the <ulink
1464 url="&url-debian-policy;ch-docs.html">Policy on
1465 documentation</ulink>.
1466 </para>
1467 <para>
1468 If your package contains documentation built from XML or SGML, we recommend you
1469 not ship the XML or SGML source in the binary package(s).  If users want the
1470 source of the documentation, they should retrieve the source package.
1471 </para>
1472 <para>
1473 Policy specifies that documentation should be shipped in HTML format.  We also
1474 recommend shipping documentation in PDF and plain text format if convenient and
1475 if output of reasonable quality is possible.  However, it is generally not
1476 appropriate to ship plain text versions of documentation whose source format is
1477 HTML.
1478 </para>
1479 <para>
1480 Major shipped manuals should register themselves with <systemitem
1481 role="package">doc-base</systemitem> on installation.  See the <systemitem
1482 role="package">doc-base</systemitem> package documentation for more
1483 information.
1484 </para>
1485 </section>
1486
1487 <section id="bpp-other">
1488 <title>Specific types of packages</title>
1489 <para>
1490 Several specific types of packages have special sub-policies and corresponding
1491 packaging rules and practices:
1492 </para>
1493 <itemizedlist>
1494 <listitem>
1495 <para>
1496 Perl related packages have a <ulink
1497 url="&url-perl-policy;">Perl
1498 policy</ulink>, some examples of packages following that policy are <systemitem
1499 role="package">libdbd-pg-perl</systemitem> (binary perl module) or <systemitem
1500 role="package">libmldbm-perl</systemitem> (arch independent perl module).
1501 </para>
1502 </listitem>
1503 <listitem>
1504 <para>
1505 Python related packages have their python policy; see
1506 &file-python-policy; in the <systemitem
1507 role="package">python</systemitem> package.
1508 </para>
1509 </listitem>
1510 <listitem>
1511 <para>
1512 Emacs related packages have the <ulink
1513 url="&url-emacs-policy;">emacs
1514 policy</ulink>.
1515 </para>
1516 </listitem>
1517 <listitem>
1518 <para>
1519 Java related packages have their <ulink
1520 url="&url-java-policy;">java
1521 policy</ulink>.
1522 </para>
1523 </listitem>
1524 <listitem>
1525 <para>
1526 Ocaml related packages have their own policy, found in
1527 &file-ocaml-policy; from the <systemitem
1528 role="package">ocaml</systemitem> package.  A good example is the <systemitem
1529 role="package">camlzip</systemitem> source package.
1530 </para>
1531 </listitem>
1532 <listitem>
1533 <para>
1534 Packages providing XML or SGML DTDs should conform to the recommendations found
1535 in the <systemitem role="package">sgml-base-doc</systemitem> package.
1536 </para>
1537 </listitem>
1538 <listitem>
1539 <para>
1540 Lisp packages should register themselves with <systemitem
1541 role="package">common-lisp-controller</systemitem>, about which see
1542 &file-lisp-controller;.
1543 </para>
1544 </listitem>
1545 <!-- TODO: mozilla extension policy, once that becomes available -->
1546 </itemizedlist>
1547 </section>
1548
1549 <!--
1550 <section id="custom-config-files">
1551 <title>Custom configuration files</title>
1552 <para>
1553 FIXME: speak of "ucf", explain solution with a template,
1554 explain conf.d directories
1555 </para>
1556 </section>
1557 <section id="config-with-db">
1558 <title>Use of an external database</title>
1559 <para>
1560 FIXME: The software may require a database that you need to setup.
1561 But the database may be local or distant. Thus you can't depend
1562 on a database server but just on the corresponding library.
1563
1564 sympa may be an example package
1565 </para>
1566 </section>
1567 -->
1568
1569 <section id="bpp-archindepdata">
1570 <title>Architecture-independent data</title>
1571 <para>
1572 It is not uncommon to have a large amount of architecture-independent data
1573 packaged with a program.  For example, audio files, a collection of icons,
1574 wallpaper patterns, or other graphic files.  If the size of this data is
1575 negligible compared to the size of the rest of the package, it's probably best
1576 to keep it all in a single package.
1577 </para>
1578 <para>
1579 However, if the size of the data is considerable, consider splitting it out
1580 into a separate, architecture-independent package (_all.deb).  By doing this,
1581 you avoid needless duplication of the same data into eleven or more .debs, one
1582 per each architecture.  While this adds some extra overhead into the
1583 <filename>Packages</filename> files, it saves a lot of disk space on Debian
1584 mirrors.  Separating out architecture-independent data also reduces processing
1585 time of <command>lintian</command> (see <xref
1586 linkend="tools-lint"/> ) when run over the entire Debian archive.
1587 </para>
1588 </section>
1589
1590 <section id="bpp-locale">
1591 <title>Needing a certain locale during build</title>
1592 <para>
1593 If you need a certain locale during build, you can create a temporary file via
1594 this trick:
1595 </para>
1596 <para>
1597 If you set <varname>LOCPATH</varname> to the equivalent of <filename>/usr/lib/locale</filename>, and <varname>LC_ALL</varname> to the name
1598 of the locale you generate, you should get what you want without being root.
1599 Something like this:
1600 </para>
1601 <screen>
1602 LOCALE_PATH=debian/tmpdir/usr/lib/locale
1603 LOCALE_NAME=en_IN
1604 LOCALE_CHARSET=UTF-8
1605
1606 mkdir -p $LOCALE_PATH
1607 localedef -i $LOCALE_NAME.$LOCALE_CHARSET -f $LOCALE_CHARSET $LOCALE_PATH/$LOCALE_NAME.$LOCALE_CHARSET
1608
1609 # Using the locale
1610 LOCPATH=$LOCALE_PATH LC_ALL=$LOCALE_NAME.$LOCALE_CHARSET date
1611 </screen>
1612 </section>
1613
1614 <section id="bpp-transition">
1615 <title>Make transition packages deborphan compliant</title>
1616 <para>
1617 Deborphan is a program for helping users to detect which packages can safely be
1618 removed from the system, i.e.  the ones that have no packages depending on
1619 them.  The default operation is to search only within the libs and oldlibs
1620 sections, to hunt down unused libraries.  But when passed the right argument,
1621 it tries to catch other useless packages.
1622 </para>
1623 <para>
1624 For example, with <literal>--guess-dummy</literal>, <command>deborphan</command>
1625 tries to search all transitional packages which were needed for upgrade but
1626 which can now safely be removed.
1627 For that, it looks for the string dummy or transitional in their short
1628 description.
1629 </para>
1630 <para>
1631 So, when you are creating such a package, please make sure to add this text to
1632 your short description.  If you are looking for examples, just run:
1633 <command>apt-cache search .|grep dummy</command> or
1634 <command>apt-cache search .|grep transitional</command>.
1635 </para>
1636 </section>
1637
1638 <section id="bpp-origtargz">
1639 <title>Best practices for <filename>orig.tar.gz</filename> files</title>
1640 <para>
1641 There are two kinds of original source tarballs: Pristine source and repackaged
1642 upstream source.
1643 </para>
1644 <section id="pristinesource">
1645 <title>Pristine source</title>
1646 <para>
1647 The defining characteristic of a pristine source tarball is that the
1648 <literal>.orig.tar.gz</literal> file is byte-for-byte identical to a tarball officially
1649 distributed by the upstream author.  <footnote><para> We cannot prevent
1650 upstream authors from changing the tarball they distribute without also
1651 incrementing the version number, so there can be no guarantee that a pristine
1652 tarball is identical to what upstream <emphasis>currently</emphasis>
1653 distributing at any point in time.  All that can be expected is that it is
1654 identical to something that upstream once <emphasis>did</emphasis> distribute.
1655 If a difference arises later (say, if upstream notices that he wasn't using
1656 maximal compression in his original distribution and then
1657 re-<command>gzip</command>s it), that's just too bad.  Since there is no good
1658 way to upload a new <literal>.orig.tar.gz</literal> for the same version, there is not even any
1659 point in treating this situation as a bug.  </para> </footnote> This makes it
1660 possible to use checksums to easily verify that all changes between Debian's
1661 version and upstream's are contained in the Debian diff.  Also, if the original
1662 source is huge, upstream authors and others who already have the upstream
1663 tarball can save download time if they want to inspect your packaging in
1664 detail.
1665 </para>
1666 <para>
1667 There is no universally accepted guidelines that upstream authors follow
1668 regarding to the directory structure inside their tarball, but
1669 <command>dpkg-source</command> is nevertheless able to deal with most upstream
1670 tarballs as pristine source.  Its strategy is equivalent to the following:
1671 </para>
1672 <orderedlist numeration="arabic">
1673 <listitem>
1674 <para>
1675 It unpacks the tarball in an empty temporary directory by doing
1676 </para>
1677 <screen>
1678 zcat path/to/&lt;packagename&gt;_&lt;upstream-version&gt;.orig.tar.gz | tar xf -
1679 </screen>
1680 </listitem>
1681 <listitem>
1682 <para>
1683 If, after this, the temporary directory contains nothing but one directory and
1684 no other files, <command>dpkg-source</command> renames that directory to
1685 <literal>&lt;packagename&gt;-&lt;upstream-version&gt;(.orig)</literal>.  The
1686 name of the top-level directory in the tarball does not matter, and is
1687 forgotten.
1688 </para>
1689 </listitem>
1690 <listitem>
1691 <para>
1692 Otherwise, the upstream tarball must have been packaged without a common
1693 top-level directory (shame on the upstream author!).  In this case,
1694 <command>dpkg-source</command> renames the temporary directory
1695 <emphasis>itself</emphasis> to
1696 <literal>&lt;packagename&gt;-&lt;upstream-version&gt;(.orig)</literal>.
1697 </para>
1698 </listitem>
1699 </orderedlist>
1700 </section>
1701
1702 <section id="repackagedorigtargz">
1703 <title>Repackaged upstream source</title>
1704 <para>
1705 You <emphasis role="strong">should</emphasis> upload packages with a pristine
1706 source tarball if possible, but there are various reasons why it might not be
1707 possible.  This is the case if upstream does not distribute the source as
1708 gzipped tar at all, or if upstream's tarball contains non-DFSG-free material
1709 that you must remove before uploading.
1710 </para>
1711 <para>
1712 In these cases the developer must construct a suitable <literal>.orig.tar.gz
1713 </literal> file himself.  We refer to such a tarball as a repackaged upstream 
1714 source.  Note that a repackaged upstream source is different from a 
1715 Debian-native package.  A repackaged source still comes with Debian-specific
1716 changes in a separate <literal>.diff.gz</literal> and still has a version
1717 number composed of <literal>&lt;upstream-version&gt;</literal> and
1718 <literal>&lt;debian-revision&gt;</literal>.
1719 </para>
1720 <para>
1721 There may be cases where it is desirable to repackage the source even though
1722 upstream distributes a <literal>.tar.gz</literal> that could in principle be
1723 used in its pristine form.  The most obvious is if
1724 <emphasis>significant</emphasis> space savings can be achieved by recompressing
1725 the tar archive or by removing genuinely useless cruft from the upstream
1726 archive.  Use your own discretion here, but be prepared to defend your decision
1727 if you repackage source that could have been pristine.
1728 </para>
1729 <para>
1730 A repackaged <literal>.orig.tar.gz</literal>
1731 </para>
1732 <orderedlist numeration="arabic">
1733 <listitem>
1734 <para>
1735 <emphasis role="strong">must</emphasis> be documented in the resulting source package.
1736 Detailed information on how the repackaged source was obtained,
1737 and on how this can be reproduced must be provided in
1738 <filename>debian/copyright</filename>.  It is also a good idea to provide a
1739 <literal>get-orig-source</literal> target in your
1740 <filename>debian/rules</filename> file that repeats the process, as described
1741 in the Policy Manual, <ulink
1742 url="&url-debian-policy;ch-source.html#s-debianrules">Main
1743 building script: debian/rules</ulink>.
1744 </para>
1745 </listitem>
1746 <listitem>
1747 <para>
1748 <emphasis role="strong">should not</emphasis> contain any file that does not
1749 come from the upstream author(s), or whose contents has been changed by you.
1750 <footnote><para> As a special exception, if the omission of non-free files
1751 would lead to the source failing to build without assistance from the Debian
1752 diff, it might be appropriate to instead edit the files, omitting only the
1753 non-free parts of them, and/or explain the situation in a README.Debian-source
1754 <!-- or similarly named -->
1755 file in the root of the source tree.  But in that case please also urge the
1756 upstream author to make the non-free components easier seperable from the rest
1757 of the source.  </para> </footnote>
1758 </para>
1759 </listitem>
1760 <listitem>
1761 <para>
1762 <emphasis role="strong">should</emphasis>, except where impossible for legal
1763 reasons, preserve the entire building and portablility infrastructure provided
1764 by the upstream author.  For example, it is not a sufficient reason for
1765 omitting a file that it is used only when building on MS-DOS.  Similarly, a
1766 Makefile provided by upstream should not be omitted even if the first thing
1767 your <filename>debian/rules</filename> does is to overwrite it by running a
1768 configure script.
1769 </para>
1770 <para>
1771 (<emphasis>Rationale:</emphasis> It is common for Debian users who need to
1772 build software for non-Debian platforms to fetch the source from a Debian
1773 mirror rather than trying to locate a canonical upstream distribution point).
1774 </para>
1775 </listitem>
1776 <listitem>
1777 <para>
1778 <emphasis role="strong">should</emphasis> use
1779 <literal>&lt;packagename&gt;-&lt;upstream-version&gt;.orig</literal> as the
1780 name of the top-level directory in its tarball.  This makes it possible to
1781 distinguish pristine tarballs from repackaged ones.
1782 </para>
1783 </listitem>
1784 <listitem>
1785 <para>
1786 <emphasis role="strong">should</emphasis> be gzipped with maximal compression.
1787 </para>
1788 </listitem>
1789 </orderedlist>
1790 <para>
1791 The canonical way to meet the latter two points is to let <literal>dpkg-source
1792 -b</literal> construct the repackaged tarball from an unpacked directory.
1793 </para>
1794 </section>
1795
1796 <section id="changed-binfiles">
1797 <title>Changing binary files in <literal>diff.gz</literal></title>
1798 <para>
1799 Sometimes it is necessary to change binary files contained in the original
1800 tarball, or to add binary files that are not in it.  If this is done by simply
1801 copying the files into the debianized source tree,
1802 <command>dpkg-source</command> will not be able to handle this.  On the other
1803 hand, according to the guidelines given above, you cannot include such a
1804 changed binary file in a repackaged <filename>orig.tar.gz</filename>.  Instead,
1805 include the file in the <filename>debian</filename> directory in
1806 <command>uuencode</command>d (or similar) form <footnote><para> The file should
1807 have a name that makes it clear which binary file it encodes.  Usually, some
1808 postfix indicating the encoding should be appended to the original filename.
1809 Note that you don't need to depend on <systemitem
1810 role="package">sharutils</systemitem> to get the <command>uudecode</command>
1811 program if you use <command>perl</command>'s <literal>pack</literal> function.
1812 The code could look like
1813 </para>
1814 &example-uu;
1815 </footnote>.  The file would then be
1816 decoded and copied to its place during the build process.  Thus the change will
1817 be visible quite easy.
1818 </para>
1819 <para>
1820 Some packages use <command>dbs</command> to manage patches to their upstream
1821 source, and always create a new <literal>orig.tar.gz</literal> file that
1822 contains the real <literal>orig.tar.gz</literal> in its toplevel directory.
1823 This is questionable with respect to the preference for pristine source.  On
1824 the other hand, it is easy to modify or add binary files in this case: Just put
1825 them into the newly created <literal>orig.tar.gz</literal> file, besides the
1826 real one, and copy them to the right place during the build process.
1827 </para>
1828 </section>
1829
1830 </section>
1831
1832 <section id="bpp-dbg">
1833 <title>Best practices for debug packages</title>
1834 <para>
1835 A debug package is a package with a name ending in -dbg, that contains
1836 additional information that gdb can use.  Since Debian binaries are stripped by
1837 default, debugging information, including function names and line numbers, is
1838 otherwise not available when running gdb on Debian binaries.  Debug packages
1839 allow users who need this additional debugging information to install it,
1840 without bloating a regular system with the information.
1841 </para>
1842 <para>
1843 It is up to a package's maintainer whether to create a debug package or not.
1844 Maintainers are encouraged to create debug packages for library packages, since
1845 this can aid in debugging many programs linked to a library.  In general, debug
1846 packages do not need to be added for all programs; doing so would bloat the
1847 archive.  But if a maintainer finds that users often need a debugging version
1848 of a program, it can be worthwhile to make a debug package for it.  Programs
1849 that are core infrastructure, such as apache and the X server are also good
1850 candidates for debug packages.
1851 </para>
1852 <para>
1853 Some debug packages may contain an entire special debugging build of a library
1854 or other binary, but most of them can save space and build time by instead
1855 containing separated debugging symbols that gdb can find and load on the fly
1856 when debugging a program or library.  The convention in Debian is to keep these
1857 symbols in <filename>/usr/lib/debug/<replaceable>path</replaceable></filename>, where
1858 <replaceable>path</replaceable> is the path to the executable or library.  For
1859 example, debugging symbols for <filename>/usr/bin/foo</filename> go in
1860 <filename>/usr/lib/debug/usr/bin/foo</filename>, and debugging symbols for
1861 <filename>/usr/lib/libfoo.so.1</filename> go in
1862 <filename>/usr/lib/debug/usr/lib/libfoo.so.1</filename>.
1863 </para>
1864 <para>
1865 The debugging symbols can be extracted from an object file using <command>
1866 objcopy --only-keep-debug</command>.  Then the object file can be stripped,
1867 and <command>objcopy --add-gnu-debuglink</command> used to specify the path
1868 to the debugging symbol file. 
1869 <citerefentry> <refentrytitle>objcopy</refentrytitle> <manvolnum>1</manvolnum>
1870 </citerefentry> explains in detail how this works.
1871 </para>
1872 <para>
1873 The <command>dh_strip</command> command in debhelper supports creating debug
1874 packages, and can take care of using <command>objcopy</command> to separate
1875 out the debugging symbols for you.  If your package uses debhelper, all you
1876 need to do is call <command>dh_strip --dbg-package=libfoo-dbg</command>, and
1877 add an entry to <filename>debian/control</filename> for the debug package.
1878 </para>
1879 <para>
1880 Note that the debug package should depend on the package that it provides
1881 debugging symbols for, and this dependency should be versioned.  For example:
1882 </para>
1883 <screen>
1884 Depends: libfoo (= ${binary:Version})
1885 </screen>
1886 </section>
1887
1888 </section>
1889
1890 </chapter>
1891