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