]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
* Improvements to section 7.1
[debian/debian-policy.git] / policy.sgml
1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3      within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
5 ]>
6 <debiandoc>
7   <!--
8   Debian GNU/Linux Policy Manual.
9   Copyright (C)1996,1997,1998 Ian Jackson and Christian Schwarz;
10   released under the terms of the GNU
11   General Public License, version 2 or (at your option) any later.
12   Initial version 1996, Ian Jackson, ijackson@gnu.ai.mit.edu
13   Revised November 27, 1996, David A. Morris, bweaver@debian.org
14   New sections March 15, 1997, Christian Schwarz, schwarz@debian.org
15   Reworked/Restructured April-July 1997, Christian Schwarz, schwarz@debian.org
16   Maintainer since 1997, Christian Schwarz, schwarz@debian.org
17   Christoph Lameter contributed the "Web Standard"
18   The debian-policy mailing list has taken responsibility for the
19   contents of this document since September 1998, with the package
20   maintainers responsible for packaging administrivia only.
21   -->
22
23   <book>
24     <titlepag>
25       <title>Debian Policy Manual</title>
26       <author>
27         <name>Ian Jackson </name>
28         <email>ijackson@gnu.ai.mit.edu</email>
29       </author>
30       <author>
31         <name>Christian Schwarz</name>
32         <email>schwarz@debian.org</email>
33       </author>
34       <author>
35         <name>revised: David A. Morris</name>
36         <email>bweaver@debian.org</email>
37       </author>
38       <author>
39         <name>The Debian Policy mailing List</name>
40         <email>debian-policy@lists.debian.org</email>
41       </author>
42       <version>version &version;, &date;</version>
43
44       <abstract>
45         This manual describes the policy requirements for the Debian
46         GNU/Linux distribution. This includes the structure and
47         contents of the Debian archive and several design issues of the
48         operating system, as well as technical requirements that each
49         package must satisfy to be included in the distribution. The
50         policy package itself is maintained by a group of maintainers
51         that have no editorial powers. At the moment, the list of
52         maintainers is:
53         <enumlist>
54           <item>
55             <p>Julian Gilbey <email>jdg@debian.org</email></p>
56           </item>
57           <item>
58             <p>Manoj Srivastava <email>srivasta@debian.org</email></p>
59           </item>
60         </enumlist>
61       </abstract>
62
63
64       <copyright>
65         <copyrightsummary>
66           Copyright &copy;1996,1997,1998 Ian Jackson
67           and Christian Schwarz.
68         </copyrightsummary>
69         <p>
70           This manual is free software; you may redistribute it and/or
71           modify it under the terms of the GNU General Public License
72           as published by the Free Software Foundation; either version
73           2, or (at your option) any later version.
74         </p>
75
76         <p>
77           This is distributed in the hope that it will be useful, but
78           <em>without any warranty</em>; without even the implied
79           warranty of merchantability or fitness for a particular
80           purpose.  See the GNU General Public License for more
81           details.
82         </p>
83
84         <p>
85           A copy of the GNU General Public License is available as
86           <tt>/usr/share/common-licenses/GPL</tt> in the Debian GNU/Linux
87           distribution or on the World Wide Web at
88           <url id="http://www.gnu.org/copyleft/gpl.html"
89                name="The GNU General Public Licence">. You can also
90           obtain it by writing to the Free Software Foundation, Inc.,
91           59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
92         </p>
93       </copyright>
94     </titlepag>
95
96     <toc detail="sect">
97
98     <chapt id="scope">
99       <heading>About this manual</heading>
100       <sect>
101         <heading>Scope</heading>
102         <p>
103           This manual describes the policy requirements for the Debian
104           GNU/Linux distribution. This includes the structure and
105           contents of the Debian archive and several design issues of the
106           operating system, as well as technical requirements that
107           each package must satisfy to be included in the
108           distribution.
109         </p>
110
111
112         <p>
113           This manual also describes Debian policy as it relates to
114           creating Debian packages. It is not a tutorial on how to build
115           packages, nor is it exhaustive where it comes to describing
116           the behavior of the packaging system. Instead, this manual
117           attempts to define the interface to the package management
118           system that the developers have to be conversant with.
119           <footnote>
120             <p>
121               Informally, the criteria used for inclusion is that the
122               material meet one of the following requirements:
123               <taglist>
124                 <tag>Standard interfaces</tag>
125                 <item>
126                   <p>
127                     The material presented represents an interface to
128                     the packaging system that is mandated for use, and
129                     is used by, a significant number of packages, and
130                     therefore should not be changed without peer
131                     review. Package maintainers can then rely on this
132                     interfaces not changing, and the package
133                     management software authors need to ensure
134                     compatibility with these interface
135                     definitions. (Control file and changelog file
136                     formats are examples.)
137                   </p>
138                 </item>
139                 <tag>Chosen Convention</tag>
140                 <item>
141                   <p>
142                     If there are a number of technically viable choices
143                     that can be made, but one needs to select one of
144                     these options for inter-operability. The version
145                     number format is one example.
146                   </p>
147                 </item>
148               </taglist>
149               Please note that these are not mutually exclusive;
150               selected conventions often become parts of standard
151               interfaces.
152             </p>
153           </footnote>
154         </p>
155
156         <p>
157           The footnotes present in this manual are
158           merely informative, and are not part of Debian policy itself.
159         </p>
160
161
162         <p>
163           In this manual, the words <em>must</em>, <em>should</em> and
164           <em>may</em>, and the adjectives <em>required</em>,
165           <em>recommended</em> and <em>optional</em>, are used to
166           distinguish the significance of the various guidelines in
167           this policy document. Packages that do not conform to the
168           guidelines denoted by <em>must</em> (or <em>required</em>)
169           will generally not be considered acceptable for the Debian
170           distribution. Non-conformance with guidelines denoted by
171           <em>should</em> (or <em>recommended</em>) will generally be
172           considered a bug, but will not necessarily render a package
173           unsuitable for distribution. Guidelines denoted by
174           <em>may</em> (or <em>optional</em>) are truly optional and
175           adherence is left to the maintainer's discretion.
176         </p>
177         <p>
178           These classifications are roughly equivalent to the bug
179           severities <em>serious</em> (for <em>must</em> or
180           <em>required</em> directive violations), <em>minor</em>,
181           <em>normal</em> or <em>important</em>
182           (for <em>should</em> or <em>recommended</em> directive
183           violations) and <em>wishlist</em> (for <em>optional</em>
184           items). <footnote>
185             <p>Compare RFC 2119.  Note, however, that these words are
186           used in a different way in this document.</p>
187           </footnote>
188         </p>
189         <p>
190           Much of the information presented in this manual will be
191           useful even when building a package which is to be
192           distributed in some other way or is intended for local use
193           only.
194         </p>
195       </sect>
196       <sect>
197         <heading>New versions of this document</heading>
198         <p>
199           The current version of this document is always accessible
200           from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
201           as
202           <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
203           (also available from the same directory are several other
204           formats: <tt>policy.html.tar.gz</tt>, <tt>policy.pdf.gz</tt>
205           and <tt>policy.ps.gz</tt>) or from the <url
206           id="http://www.debian.org/doc/debian-policy/" name="Debian
207           Policy Manual"> webpage.</p>
208
209         <p>
210           In addition, this manual is distributed via the Debian package
211           <tt>debian-policy</tt>.
212         </p>
213
214         <p>
215           The <tt>debian-policy</tt> package also includes the file
216           <tt>upgrading-checklist.txt</tt> which indicates policy
217           changes between versions of this document.
218         </p>
219       </sect>
220       <sect>
221         <heading>Feedback</heading>
222
223         <p>
224           As the Debian GNU/Linux system is continuously evolving this
225           manual does so too.
226         </p>
227         <p>
228           While the authors of this document have tried hard to avoid
229           typos and other errors, these do still occur. If you discover
230           an error in this manual or if you want to give any
231           comments, suggestions, or criticisms please send an email to
232           the Debian Policy List,
233           <email>debian-policy@lists.debian.org</email>, or submit a
234           bug report against the <tt>debian-policy</tt> package.
235         </p>
236       </sect>
237     </chapt>
238     <chapt>
239       <heading>The Debian Archive</heading>
240       <p>
241         The Debian GNU/Linux system is maintained and distributed as a
242         collection of <em>packages</em>. Since there are so many of
243         them (currently well over 6000), they are split into
244         <em>sections</em> and given <em>priorities</em> to simplify
245         the handling of them.
246       </p>
247       <p>
248         The effort of the Debian project is to build a free operating
249         system, but not every package we want to make accessible is
250         <em>free</em> in our sense (see the Debian Free Software
251         Guidelines, below), or may be imported/exported without
252         restrictions. Thus, the archive is split into the sections
253         <em>main</em>, <em>non-free</em>, <em>contrib</em>,
254         <em>non-US/main</em>, <em>non-US/non-free</em>, and
255         <em>non-US/contrib</em>.  The sections are explained in detail
256         below.
257       </p>
258
259       <p>
260         The <em>main</em> and the <em>non-US/main</em> sections
261         together form the <em>Debian GNU/Linux distribution</em>.
262       </p>
263
264       <p>
265         Packages in the other sections are not considered to be part
266         of the Debian distribution, although we support their use and
267         provide infrastructure for them (such as our bug-tracking
268         system and mailing lists). This Debian Policy Manual applies
269         to these packages as well.</p>
270
271       <sect id="pkgcopyright">
272         <heading>Package copyright and sections</heading>
273         <p>
274           The aims of this section are:
275
276           <list compact="compact">
277             <item>
278               <p>to allow us to make as much software available as we
279                 can,</p>
280             </item>
281             <item>
282               <p>to allow us to encourage everyone to write free
283               software, and</p>
284             </item>
285             <item>
286               <p>to allow us to make it easy for people to produce
287                 CD-ROMs of our system without violating any licenses,
288                 import/export restrictions, or any other laws.</p>
289             </item>
290           </list>
291         </p>
292         <sect1>
293           <heading>The Debian Free Software Guidelines</heading>
294           <p>
295             The Debian Free Software Guidelines (DFSG) form our
296             definition of `free software'.  These are:
297             <taglist>
298               <tag>Free Redistribution
299               </tag>
300               <item>
301                 <p>
302                   The license of a Debian component may not restrict any
303                   party from selling or giving away the software as a
304                   component of an aggregate software distribution
305                   containing programs from several different
306                   sources. The license may not require a royalty or
307                   other fee for such sale.
308                 </p>
309               </item>
310               <tag>Source Code
311               </tag>
312               <item>
313                 <p>
314                   The program must include source code, and must allow
315                   distribution in source code as well as compiled form.
316                 </p>
317               </item>
318               <tag>Derived Works
319               </tag>
320               <item>
321                 <p>
322                   The license must allow modifications and derived
323                   works, and must allow them to be distributed under the
324                   same terms as the license of the original software.
325                 </p>
326               </item>
327               <tag>Integrity of The Author's Source Code
328               </tag>
329               <item>
330                 <p>
331                   The license may restrict source-code from being
332                   distributed in modified form <em>only</em> if the
333                   license allows the distribution of ``patch files''
334                   with the source code for the purpose of modifying the
335                   program at build time. The license must explicitly
336                   permit distribution of software built from modified
337                   source code. The license may require derived works to
338                   carry a different name or version number from the
339                   original software.  (This is a compromise. The Debian
340                   Project encourages all authors to not restrict any
341                   files, source or binary, from being modified.)
342                 </p>
343               </item>
344               <tag>No Discrimination Against Persons or Groups
345               </tag>
346               <item>
347                 <p>
348                   The license must not discriminate against any person
349                   or group of persons.
350                 </p>
351               </item>
352               <tag>No Discrimination Against Fields of Endeavor
353               </tag>
354               <item>
355                 <p>
356                   The license must not restrict anyone from making use
357                   of the program in a specific field of endeavor. For
358                   example, it may not restrict the program from being
359                   used in a business, or from being used for genetic
360                   research.
361                 </p>
362               </item>
363               <tag>Distribution of License
364               </tag>
365               <item>
366                 <p>
367                   The rights attached to the program must apply to all
368                   to whom the program is redistributed without the need
369                   for execution of an additional license by those
370                   parties.
371                 </p>
372               </item>
373               <tag>License Must Not Be Specific to Debian
374               </tag>
375               <item>
376                 <p>
377                   The rights attached to the program must not depend on
378                   the program's being part of a Debian system. If the
379                   program is extracted from Debian and used or
380                   distributed without Debian but otherwise within the
381                   terms of the program's license, all parties to whom
382                   the program is redistributed must have the same
383                   rights as those that are granted in conjunction with
384                   the Debian system.
385                 </p>
386               </item>
387               <tag>License Must Not Contaminate Other Software
388               </tag>
389               <item>
390                 <p>
391                   The license must not place restrictions on other
392                   software that is distributed along with the licensed
393                   software. For example, the license must not insist
394                   that all other programs distributed on the same medium
395                   must be free software.
396                 </p>
397               </item>
398               <tag>Example Licenses
399               </tag>
400               <item>
401                 <p>
402                   The ``GPL,'' ``BSD,'' and ``Artistic'' licenses are
403                   examples of licenses that we consider <em>free</em>.
404                 </p>
405               </item>
406             </taglist>
407           </p>
408         </sect1>
409         <sect1>
410           <heading>The main section</heading>
411           <p>
412             Every package in <em>main</em> and <em>non-US/main</em>
413             must comply with the DFSG (Debian Free Software
414             Guidelines).</p>
415
416           <p>
417             In addition, the packages in <em>main</em>
418             <list compact="compact">
419               <item>
420                 <p>
421                   must not require a package outside of <em>main</em>
422                   for compilation or execution (thus, the package must
423                   not declare a "Depends", "Recommends", or
424                   "Build-Depends" relationship on a non-<em>main</em>
425                   package),
426                 </p>
427               </item>
428               <item>
429                 <p>
430                   must not be so buggy that we refuse to support them,
431                   and
432                 </p>
433               </item>
434               <item>
435                 <p>
436                   must meet all policy requirements presented in this
437                   manual.
438                 </p>
439               </item>
440             </list>
441           </p>
442           <p>
443             Similarly, the packages in <em>non-US/main</em>
444             <list compact="compact">
445               <item>
446                 <p>
447                    must not require a package outside of <em>main</em>
448                    or <em>non-US/main</em> for compilation or
449                    execution,
450                 </p>
451               </item>
452               <item>
453                 <p>
454                   must not be so buggy that we refuse to support them,
455                 </p>
456               </item>
457               <item>
458                 <p>
459                   must meet all policy requirements presented in this
460                   manual.
461                 </p>
462               </item>
463             </list>
464           </p>
465         </sect1>
466         <sect1>
467           <heading>The contrib section</heading>
468           <p>
469             Every package in <em>contrib</em> and
470             <em>non-US/contrib</em> must comply with the DFSG.
471           </p>
472
473           <p>
474             In addition, the packages in <em>contrib</em> and
475             <em>non-US/contrib</em>
476             <list compact="compact">
477               <item>
478                 <p>
479                   must not be so buggy that we refuse to support them,
480                   and
481                 </p>
482               </item>
483               <item>
484                 <p>
485                   must meet all policy requirements presented in this
486                   manual.
487                 </p>
488               </item>
489             </list>
490           </p>
491
492           <p>
493             Furthermore, packages in <em>contrib</em> must not require
494             a package in a <em>non-US</em> section for compilation or
495             execution.
496           </p>
497
498           <p>
499             Examples of packages which would be included in
500             <em>contrib</em> or <em>non-US/contrib</em> are:
501             <list compact="compact">
502               <item>
503                 <p>
504                   free packages which require <em>contrib</em>,
505                   <em>non-free</em> packages or packages which are not
506                   in our archive at all for compilation or execution,
507                   and
508                 </p>
509               </item>
510               <item>
511                 <p>
512                   wrapper packages or other sorts of free accessories for
513                   non-free programs.
514                 </p>
515               </item>
516             </list>
517           </p>
518         </sect1>
519         <sect1>
520           <heading>The non-free section</heading>
521           <p>
522             Packages must be placed in <em>non-free</em> or
523             <em>non-US/non-free</em> if they are not compliant with
524             the DFSG or are encumbered by patents or other legal
525             issues that make their distribution problematic.
526           </p>
527           <p>
528             In addition, the packages in <em>non-free</em> and
529             <em>non-US/non-free</em>
530             <list compact="compact">
531               <item>
532                 <p>
533                   must not be so buggy that we refuse to support them,
534                   and
535                 </p>
536               </item>
537               <item>
538                 <p>
539                   must meet all policy requirements presented in this
540                   manual that it is possible for them to meet.
541                   <footnote>
542                     <p>
543                       It is possible that there are policy
544                       requirements which the package is unable to
545                       meet, for example, if the source is
546                       unavailable.  These situations will need to be
547                       handled on a case-by-case basis.
548                     </p>
549                   </footnote>
550                 </p>
551               </item>
552             </list>
553           </p>
554         </sect1>
555
556         <sect1>
557           <heading>The non-US sections</heading>
558           <p>
559             Some programs with cryptographic program code need to be
560             stored on the <em>non-US</em> server because of United
561             States export restrictions.  Such programs must be
562             distributed in the appropriate <em>non-US</em> section,
563             either <em>non-US/main</em>, <em>non-US/contrib</em> or
564             <em>non-US/non-free</em>.
565           </p>
566           <p>
567             This applies only to packages which contain cryptographic
568             code. A package containing a program with an interface to
569             a cryptographic program or a program that's dynamically
570             linked against a cryptographic library should not be
571             distributed via the <em>non-US</em> server if it is
572             capable of running without the cryptographic library or
573             program.
574           </p>
575         </sect1>
576         <sect1>
577           <heading>Further copyright considerations</heading>
578           <p>
579             Every package must be accompanied by a verbatim copy of
580             its copyright and distribution license in the file
581             <tt>/usr/share/doc/<em>&lt;package-name&gt;</em>/copyright</tt>
582             (see <ref id="copyrightfile"> for further details).
583           </p>
584           <p>
585             We reserve the right to restrict files from being included
586             anywhere in our archives if
587             <list compact="compact">
588               <item>
589                 <p>
590                   their use or distribution would break a law,
591                 </p>
592               </item>
593               <item>
594                 <p>
595                   there is an ethical conflict in their distribution or
596                   use,
597                 </p>
598               </item>
599               <item>
600                 <p>
601                   we would have to sign a license for them, or
602                 </p>
603               </item>
604               <item>
605                 <p>
606                   their distribution would conflict with other project
607                   policies.
608                 </p>
609               </item>
610             </list>
611           </p>
612
613           <p>
614             Programs whose authors encourage the user to make
615             donations are fine for the main distribution, provided
616             that the authors do not claim that not donating is
617             immoral, unethical, illegal or something similar; in such
618             a case they must go in <em>non-free</em>.</p>
619
620           <p>
621             Packages whose copyright permission notices (or patent
622             problems) do not even allow redistribution of binaries
623             only, and where no special permission has been obtained,
624             must not be placed on the Debian FTP site and its mirrors
625             at all.</p>
626
627           <p>
628             Note that under international copyright law (this applies
629             in the United States, too), <em>no</em> distribution or
630             modification of a work is allowed without an explicit
631             notice saying so.  Therefore a program without a copyright
632             notice <em>is</em> copyrighted and you may not do anything
633             to it without risking being sued! Likewise if a program
634             has a copyright notice but no statement saying what is
635             permitted then nothing is permitted.</p>
636
637           <p>
638             Many authors are unaware of the problems that restrictive
639             copyrights (or lack of copyright notices) can cause for
640             the users of their supposedly-free software.  It is often
641             worthwhile contacting such authors diplomatically to ask
642             them to modify their license terms. However, this can be a
643             politically difficult thing to do and you should ask for
644             advice on the <tt>debian-legal</tt> mailing list first, as
645             explained below.
646           </p>
647
648           <p>
649             When in doubt about a copyright, send mail to
650             <email>debian-legal@lists.debian.org</email>.  Be prepared
651             to provide us with the copyright statement.  Software
652             covered by the GPL, public domain software and BSD-like
653             copyrights are safe; be wary of the phrases `commercial
654             use prohibited' and `distribution restricted'.
655           </p>
656         </sect1>
657         <sect1>
658           <heading>Subsections</heading>
659
660           <p>
661             The packages in the sections <em>main</em>,
662             <em>contrib</em> and <em>non-free</em> are grouped further
663             into <em>subsections</em> to simplify handling.
664           </p>
665
666           <p>
667             The section and subsection for each package should be
668             specified in the package's <tt>Section</tt> control
669             record.  However, the maintainer of the Debian archive
670             may override this selection to ensure the consistency of
671             the Debian distribution.  The <tt>Section</tt> field
672             should be of the form:
673             <list compact="compact">
674               <item>
675                 <p>
676                   <em>subsection</em> if the package is in the
677                   <em>main</em> section,
678                 </p>
679               </item>
680               <item>
681                 <p>
682                   <em>section/subsection</em> if the package is in
683                   the <em>contrib</em> or <em>non-free</em> section,
684                   and
685                 </p>
686               </item>
687               <item>
688                 <p>
689                   <tt>non-US</tt>, <tt>non-US/contrib</tt> or
690                   <tt>non-US/non-free</tt> if the package is in
691                   <em>non-US/main</em>, <em>non-US/contrib</em> or
692                   <em>non-US/non-free</em> respectively.
693                 </p>
694               </item>
695             </list>
696           </p>
697
698           <p>
699             The Debian archive maintainers provide the authoritative
700             list of subsections.  At present, they are:
701             <em>admin</em>, <em>base</em>, <em>comm</em>,
702             <em>contrib</em>, <em>devel</em>, <em>doc</em>,
703             <em>editors</em>, <em>electronics</em>, <em>games</em>,
704             <em>graphics</em>, <em>hamradio</em>,
705             <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
706             <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
707             <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
708             <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
709             <em>sound</em>, <em>tex</em>, <em>text</em>,
710             <em>utils</em>, <em>web</em>, <em>x11</em>.
711           </p>
712         </sect1>
713       <sect>
714         <heading>Priorities</heading>
715
716         <p>
717           Each package should have a <em>priority</em> value, which is
718           included in the package's <em>control record</em>. This
719           information is used by the Debian package management tools
720           to separate high-priority packages from less-important
721           packages.</p>
722
723         <p>
724           The following <em>priority levels</em> are recognised by the
725           Debian package management tools.
726           <taglist>
727             <tag><tt>required</tt></tag>
728             <item>
729               <p>
730                 Packages which are necessary for the proper
731                 functioning of the system.  You must not remove these
732                 packages or your system may become totally broken and
733                 you may not even be able to use <prgn>dpkg</prgn> to
734                 put things back.  Systems with only the
735                 <tt>required</tt> packages are probably unusable, but
736                 they do have enough functionality to allow the
737                 sysadmin to boot and install more software.</p>
738             </item>
739             <tag><tt>important</tt></tag>
740             <item>
741               <p>
742                 Important programs, including those which one would
743                 expect to find on any Unix-like system.  If the
744                 expectation is that an experienced Unix person who
745                 found it missing would say `What on earth is going on,
746                 where is <prgn>foo</prgn>?', it must be an
747                 <tt>important</tt> package.
748                 <footnote>
749                   <p>
750                     This is an important criterion because we are
751                     trying to produce, amongst other things, a free
752                     Unix.
753                   </p>
754                 </footnote>
755                 Other packages without which the system will not run
756                 well or be usable must also have priority
757                 <tt>important</tt>.  This does
758                 <em>not</em> include Emacs, the X Window System, TeX
759                 or any other large applications.  The
760                 <tt>important</tt> packages are just a bare minimum of
761                 commonly-expected and necessary tools.</p>
762             </item>
763             <tag><tt>standard</tt></tag>
764             <item>
765               <p>
766                 These packages provide a reasonably small but not too
767                 limited character-mode system.  This is what will be
768                 installed by default if the user doesn't select anything
769                 else.  It doesn't include many large applications, but
770                 it does include Emacs (this is more of a piece of
771                 infrastructure than an application) and a reasonable
772                 subset of TeX and LaTeX.</p>
773             </item>
774             <tag><tt>optional</tt></tag>
775             <item>
776               <p>
777                 (In a sense everything that isn't required is
778                 optional, but that's not what is meant here.) This is
779                 all the software that you might reasonably want to
780                 install if you didn't know what it was and don't have
781                 specialized requirements. This is a much larger system
782                 and includes the X Window System, a full TeX
783                 distribution, and many applications. Note that
784                 optional packages should not conflict with each other.
785               </p>
786             </item>
787             <tag><tt>extra</tt></tag>
788             <item>
789               <p>
790                 This contains all packages that conflict with others
791                 with required, important, standard or optional
792                 priorities, or are only likely to be useful if you
793                 already know what they are or have specialised
794                 requirements.
795               </p>
796             </item>
797           </taglist></p>
798
799         <p>
800           Packages must not depend on packages with lower priority
801           values (excluding build-time dependencies).  In order to
802           ensure this, the priorities of one or more packages may need
803           to be adjusted.
804         </p>
805       </sect>
806
807       <sect>
808         <heading>Binary packages</heading>
809
810         <p>
811           The Debian GNU/Linux distribution is based on the Debian
812           package management system, called <prgn>dpkg</prgn>. Thus,
813           all packages in the Debian distribution must be provided
814           in the <tt>.deb</tt> file format.</p>
815
816
817         <sect1>
818           <heading>The package name</heading>
819
820           <p>
821             Every package must have a name that's unique within the Debian
822             archive.</p>
823
824           <p>
825             Package names must consist of lower case letters (a-z),
826             digits (0-9), plus (+) and minus (-) signs, and periods
827             (.).  They must be at least two characters long and must
828             contain at least one letter.
829           </p>
830
831           <p>
832             The package name is part of the file name of the
833             <tt>.deb</tt> file and is included in the control field
834             information.
835           </p>
836         </sect1>
837
838         <sect1>
839           <heading>The maintainer of a package</heading>
840          <p>
841             Every package must have a Debian maintainer (the
842             maintainer may be one person or a group of people
843             reachable from a common email address, such as a mailing
844             list).  The maintainer is responsible for ensuring that
845             the package is placed in the appropriate distributions.
846           </p>
847
848           <p>
849             The maintainer must be specified in the
850             <tt>Maintainer</tt> control field with their correct name
851             and a working email address.  If one person maintains
852             several packages, he/she should try to avoid having
853             different forms of their name and email address in
854             the <tt>Maintainer</tt> fields of those packages.
855           </p>
856
857           <p>
858             If the maintainer of a package quits from the Debian
859             project, "Debian QA Group"
860             <email>packages@qa.debian.org</email> takes over the
861             maintainership of the package until someone else
862             volunteers for that task. These packages are called
863             <em>orphaned packages</em>.
864             <footnote>
865               <p>
866                 The detailed procedure for doing this gracefully can
867                 be found in the Debian Developer's Reference, either
868                 in the <tt>developers-reference</tt> package, or on
869                 the Debian FTP server
870                 <ftpsite>ftp.debian.org</ftpsite> as
871                 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
872                 or from the <url
873                 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
874                 name="Debian Developer's Reference"> webpage.
875               </p>
876             </footnote>
877           </p>
878         </sect1>
879
880
881         <sect1>
882           <heading>The description of a package</heading>
883
884           <p>
885             Every Debian package must have an extended description
886             stored in the appropriate field of the control record.</p>
887
888           <p>
889             The description should be written so that it gives the
890             system administrator enough information to decide whether
891             to install the package. This description should not just
892             be copied verbatim from the program's documentation.
893             Instructions for configuring or using the package should
894             not be included -- that is what installation scripts,
895             manual pages, info files, etc., are for.  Copyright
896             statements and other administrivia should not be included
897             either -- that is what the copyright file is for.</p>
898         </sect1>
899
900
901         <sect1>
902           <heading>Dependencies</heading>
903
904           <p>
905             Every package must specify the dependency information
906             about other packages that are required for the first to
907             work correctly.</p>
908
909           <p>
910             For example, a dependency entry must be provided for any
911             shared libraries required by a dynamically-linked executable
912             binary in a package.</p>
913
914           <p>
915             Packages are not required to declare any dependencies they
916             have on other packages which are marked <tt>Essential</tt>
917             (see below), and should not do so unless they depend on a
918             particular version of that package.</p>
919
920           <p>
921             Sometimes, a package requires another package to be installed
922             <em>and</em> configured before it can be installed. In this
923             case, you must specify a <tt>Pre-Depends</tt> entry for
924             the package.</p>
925
926           <p>
927             You should not specify a <tt>Pre-Depends</tt> entry for a
928             package before this has been discussed on the
929             <tt>debian-devel</tt> mailing list and a consensus about
930             doing that has been reached.</p></sect1>
931
932
933         <sect1>
934           <heading>Virtual packages</heading>
935
936           <p>
937             Sometimes, there are several packages which offer
938             more-or-less the same functionality. In this case, it's
939             useful to define a <em>virtual package</em> whose name
940             describes that common functionality.  (The virtual
941             packages only exist logically, not physically--that's why
942             they are called <em>virtual</em>.) The packages with this
943             particular function will then <em>provide</em> the virtual
944             package. Thus, any other package requiring that function
945             can simply depend on the virtual package without having to
946             specify all possible packages individually.</p>
947
948           <p>
949             All packages should use virtual package names where
950             appropriate, and arrange to create new ones if necessary.
951             They should not use virtual package names (except privately,
952             amongst a cooperating group of packages) unless they have
953             been agreed upon and appear in the list of virtual package
954             names.</p>
955
956           <p>
957             The latest version of the authoritative list of virtual
958             package names can be found on
959             <ftpsite>ftp.debian.org</ftpsite> in
960             <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
961             or your local mirror. In addition, it is included in the
962             <tt>debian-policy</tt> package. The procedure for updating
963             the list is described at the top of the file.</p></sect1>
964
965
966         <sect1>
967           <heading>Base packages</heading>
968
969           <p>
970             The packages included in the <tt>base</tt> section have a
971             special function. They form a minimum subset of the Debian
972             GNU/Linux system that is installed before everything else
973             on a new system. Thus, only very few packages are allowed
974             to go into the <tt>base</tt> section to keep the required
975             disk usage very small.</p>
976
977           <p>
978             Most of these packages will have the priority value
979             <tt>required</tt> or at least <tt>important</tt>, and many
980             of them will be tagged <tt>essential</tt> (see below).</p>
981
982           <p>
983             You must not place any packages into the <tt>base</tt>
984             section before this has been discussed on the
985             <tt>debian-devel</tt> mailing list and a consensus about
986             doing that has been reached.</p></sect1>
987
988
989         <sect1>
990           <heading>Essential packages</heading>
991
992           <p>
993             Some packages are tagged <tt>essential</tt>. (They have
994             <tt>Essential: yes</tt> in their package control record.)
995             This flag is used for packages that are <em>essential</em>
996             for a system.</p>
997
998           <p>
999             Since these packages cannot be easily removed (one has to
1000             specify an extra <em>force option</em> to
1001             <prgn>dpkg</prgn> to do so), this flag must not be used
1002             unless absolutely necessary.  A shared library package
1003             must not be tagged <tt>essential</tt>--dependencies will
1004             prevent its premature removal, and we need to be able to
1005             remove it when it has been superseded.
1006           </p>
1007
1008           <p>
1009             Since dpkg will not prevent upgrading of other packages
1010             while an <tt>essential</tt> package is in an unconfigured
1011             state, all <tt>essential</tt> packages must supply all of
1012             their core functionality even when unconfigured. If the
1013             package cannot satisfy this requirement it must not be
1014             tagged as essential, and any packages depending on this
1015             package must instead have explicit dependency fields as
1016             appropriate.
1017           </p>
1018
1019           <p>
1020             You must not tag any packages <tt>essential</tt> before
1021             this has been discussed on the <tt>debian-devel</tt>
1022             mailing list and a consensus about doing that has been
1023             reached.
1024           </p>
1025         </sect1>
1026
1027         <sect1>
1028           <heading>Maintainer scripts</heading>
1029
1030           <p>
1031             The package installation scripts should avoid producing
1032             output which it is unnecessary for the user to see and
1033             should rely on <prgn>dpkg</prgn> to stave off boredom on
1034             the part of a user installing many packages.  This means,
1035             amongst other things, using the <tt>--quiet</tt> option on
1036             <prgn>install-info</prgn>.</p>
1037
1038           <p>
1039             Errors which occur during the execution of an installation
1040             script must be checked and the installation must not
1041             continue after an error.
1042           </p>
1043
1044           <p>
1045             Note that in general <ref id="scripts"> applies to package
1046             maintainer scripts, too.
1047           </p>
1048
1049           <p>
1050             You should not use <tt>dpkg-divert</tt> on a file
1051             belonging to another package without consulting the
1052             maintainer of that package first.
1053           </p>
1054           <p>
1055             All packages which supply an instance of a common command
1056             name (or, in general, filename) should generally use
1057             <prgn>update-alternatives</prgn>, so that they may be
1058             installed together.  If <prgn>update-alternatives</prgn>
1059             is not used, then each package must use
1060             <var>Conflicts</var> to ensure that other packages are
1061             de-installed.  (In this case, it may be appropriate to
1062             specify a conflict against earlier versions of something
1063             that previously did not use
1064             <prgn>update-alternatives</prgn> - this is an exception to
1065             the usual rule that versioned conflicts should be
1066             avoided).
1067           </p>
1068
1069
1070           <sect2>
1071             <heading>Prompting in maintainer scripts</heading>
1072             <p>
1073               Package maintainer scripts may prompt the user if
1074               necessary. Prompting may be accomplished by hand, or by
1075               communicating with a program, such as
1076               <prgn>debconf</prgn>, which conforms to the Debian
1077               Configuration management specification, version 2 or
1078               higher.  These are included in the
1079               <file>debconf_specification</file> files in the
1080               <package>debian-policy</package> package.
1081               You may also find this file on the FTP site
1082               <ftpsite>ftp.debian.org</ftpsite> in
1083               <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1084               or on your local mirror.
1085               <footnote>
1086                 <p>
1087                   2.5% of Debian packages [see <url
1088                   id="http://kitenet.net/programs/debconf/stats/">]
1089                   currently use <package>debconf</package> to prompt
1090                   the user at install time, and this number is growing
1091                   daily. The benefits of using debconf are briefly
1092                   explained at <url
1093                   id="http://kitenet.net/doc/debconf-doc/introduction.html">;
1094                   they include preconfiguration, (mostly)
1095                   noninteractive installation, elimination of
1096                   redundant prompting, consistency of user interface,
1097                   etc.
1098                 </p>
1099                 <p>
1100                   With this increasing number of packages using
1101                   <package>debconf</package>, plus the existance of a
1102                   nascent second implementation of the Debian
1103                   configuration management system
1104                   (<package>cdebconf</package>), and the stabalization
1105                   of the protocol these things use, the time has
1106                   finally come to reflect the use of these things in
1107                   policy.
1108
1109                 </p>
1110               </footnote>
1111             </p>
1112             <p>
1113               Packages which use the Debian Configuration management
1114               specification may contain an additional
1115               <file>config</file> script and a <file>templates</file>
1116               file in their control archive. The <prgn>config</prgn>
1117               script might be run before the <prgn>preinst</prgn>
1118               script, and before the package is unpacked or any of its
1119               dependancies or pre-dependancies are satisfied.
1120               Therefore it must work using only the tools present in
1121               <em>essential</em> packages.
1122               <footnote>
1123                 <p>
1124                   <package>Debconf</package> or another tool that
1125                   implements the Debian Configuration management
1126                   specification will also be installed, and any
1127                   versioned dependencies on it will be satisfied
1128                   before preconfiguration begins.
1129                 </p>
1130               </footnote>
1131             </p>
1132
1133             <p>
1134               Packages should try to minimize the amount of prompting
1135               they need to do, and they should ensure that the user
1136               will only ever be asked each question once.  This means
1137               that packages should try to use appropriate shared
1138               configuration files (such as <tt>/etc/papersize</tt> and
1139               <tt>/etc/news/server</tt>), and shared
1140               <package>debconf</package> variables rather than each
1141               prompting for their own list of required pieces of
1142               information.
1143             </p>
1144
1145             <p>
1146             It also means that an upgrade should not ask the same
1147             questions again, unless the user has used <tt>dpkg
1148               --purge</tt> to remove the package's configuration.  The
1149             answers to configuration questions should be stored in an
1150             appropriate place in <tt>/etc</tt> so that the user can
1151             modify them, and how this has been done should be
1152             documented.</p>
1153
1154           <p>
1155               If a package has a vitally important piece of
1156               information to pass to the user (such as "don't run me
1157               as I am, you must edit the following configuration files
1158               first or you risk your system emitting badly-formatted
1159               messages"), it should display this in the
1160               <prgn>config</prgn> or <prgn>postinst</prgn> script and
1161               prompt the user to hit return to acknowledge the
1162               message.  Copyright messages do not count as vitally
1163               important (they belong in
1164               <tt>/usr/share/doc/<var>package</var>/copyright</tt>);
1165               neither do instructions on how to use a program (these
1166               should be in on-line documentation, where all the users
1167               can see them).</p>
1168
1169           <p>
1170             Any necessary prompting should almost always be confined
1171             to the <prgn>config</prgn> or <prgn>postinst</prgn>
1172             script. If it is done in the <prgn>postinst</prgn>, it
1173             should be protected with a conditional so that unnecessary
1174             prompting doesn't happen if a package's installation fails
1175             and the <prgn>postinst</prgn> is called with
1176             <tt>abort-upgrade</tt>, <tt>abort-remove</tt> or
1177             <tt>abort-deconfigure</tt>.</p>
1178
1179         </sect1>
1180       </sect>
1181       <sect>
1182         <heading>Source packages</heading>
1183
1184         <sect1 id="standardsversion">
1185           <heading>Standards conformance</heading>
1186
1187           <p>
1188             In the source package's <tt>Standards-Version</tt> control
1189             field, you must specify the most recent version number of
1190             this policy document with which your package complies.
1191             The current version number is &version;.
1192           </p>
1193
1194           <p>
1195             This information may be used to file bug reports
1196             automatically if your package becomes too much out of
1197             date.
1198           </p>
1199
1200           <p>
1201             The version number has four components--major and minor
1202             version number and major and minor patch level.  When the
1203             standards change in a way that requires every package to
1204             change the major number will be changed.  Significant
1205             changes that will require work in many packages will be
1206             signaled by a change to the minor number.  The major patch
1207             level will be changed for any change to the meaning of the
1208             standards, however small; the minor patch level will be
1209             changed when only cosmetic, typographical or other edits
1210             are made which neither change the meaning of the document
1211             nor affect the contents of packages.</p>
1212
1213           <p>
1214             Thus only the first three components of the policy version
1215             are significant in the <em>Standards-Version</em> control
1216             field, and so either these three components or the all
1217             four components may be specified.
1218             <footnote>
1219               <p>
1220                 In the past, people specified the full version number
1221                 in the Standards-Version field, for example `2.3.0.0'.
1222                 Since minor patch-level changes don't introduce new
1223                 policy, it was thought it would be better to relax
1224                 policy and only require the first 3 components to be
1225                 specified, in this example `2.3.0'.  All four
1226                 components may still be used if someone wishes to do
1227                 so.
1228               </p>
1229             </footnote>
1230           </p>
1231
1232           <p>
1233             You should regularly, and especially if your package has
1234             become out of date, check for the newest Policy Manual
1235             available and update your package, if necessary. When your
1236             package complies with the new standards you should update the
1237             <tt>Standards-Version</tt> source package field and
1238             release it.
1239             <footnote>
1240               <p>
1241                 See the file <tt>upgrading-checklist</tt> for
1242                 information about policy which has changed between
1243                 different versions of this document.
1244               </p>
1245             </footnote>
1246           </p>
1247         </sect1>
1248
1249
1250         <sect1>
1251           <heading>Package relationships</heading>
1252
1253           <p>
1254             Source packages should specify which binary packages they
1255             require to be installed or not to be installed in order to
1256             build correctly.  For example, if building a package
1257             requires a certain compiler, then the compiler should be
1258             specified as a build-time dependency.
1259           </p>
1260
1261           <p>
1262             It is not necessary to explicitly specify build-time
1263             relationships on a minimal set of packages that are always
1264             needed to compile, link and put in a Debian package a
1265             standard "Hello World!" program written in C or C++.  The
1266             required packages are called <em>build-essential</em>, and
1267             an informational list can be found in
1268             <tt>/usr/share/doc/build-essential/list</tt> (which is
1269             contained in the <tt>build-essential</tt>
1270             package).
1271             <footnote>
1272               <p>Rationale:
1273                 <list>
1274                   <item>
1275                     <p>This allows maintaining the list separately
1276                       from the policy documents (the list does not
1277                       need the kind of control that the policy
1278                       documents do).
1279                     </p>
1280                   </item>
1281                   <item>
1282                     <p>
1283                       Having a separate package allows one to install
1284                       the build-essential packages on a machine, as
1285                       well as allowing other packages such as task
1286                       packages to require installation of the
1287                       build-essential packages using the depends
1288                       relation.
1289                     </p>
1290                   </item>
1291                   <item>
1292                     <p>
1293                       The separate package allows bug reports against
1294                       the list to be categorized separately from
1295                       the policy management process in the BTS.
1296                     </p>
1297                   </item>
1298                 </list>
1299               </p>
1300
1301             </footnote>
1302           </p>
1303
1304           <p>
1305             When specifying the set of build-time dependencies, one
1306             should list only those packages explicitly required by the
1307             build.  It is not necessary to list packages which are
1308             required merely because some other package in the list of
1309             build-time dependencies depends on them.
1310             <footnote>
1311               <p>
1312                 The reason for this is that dependencies change, and
1313                 you should list all those packages, and <em>only</em>
1314                 those packages that <em>you</em> need directly.  What
1315                 others need is their business.  For example, if you
1316                 only link against <tt>libimlib</tt>, you will need to
1317                 build-depend on <package>libimlib2-dev</package> but
1318                 not against any <tt>libjpeg*</tt> packages, even
1319                 though <tt>libimlib2-dev</tt> currently depends on
1320                 them: installation of <package>libimlib2-dev</package>
1321                 will automatically ensure that all of its run-time
1322                 dependencies are satisfied.
1323               </p>
1324             </footnote>
1325           </p>
1326
1327           <p>
1328             If build-time dependencies are specified, it must be
1329             possible to build the package and produce working binaries
1330             on a system with only essential and build-essential
1331             packages installed and also those required to satisfy the
1332             build-time relationships (including any implied
1333             relationships).  In particular, this means that version
1334             clauses should be used rigorously in build-time
1335             relationships so that one cannot produce bad or
1336             inconsistently configured packages when the relationships
1337             are properly satisfied.
1338           </p>
1339
1340         <sect1>
1341           <heading>Changes to the upstream sources</heading>
1342
1343           <p>
1344             If changes to the source code are made that are not
1345             specific to the needs of the Debian system, they should be
1346             sent to the upstream authors in whatever form they prefer
1347             so as to be included in the upstream version of the
1348             package.</p>
1349
1350           <p>
1351             If you need to configure the package differently for
1352             Debian or for Linux, and the upstream source doesn't
1353             provide a way to do so, you should add such configuration
1354             facilities (for example, a new <prgn>autoconf</prgn> test
1355             or <tt>#define</tt>) and send the patch to the upstream
1356             authors, with the default set to the way they originally
1357             had it.  You can then easily override the default in your
1358             <tt>debian/rules</tt> or wherever is appropriate.</p>
1359
1360           <p>
1361             You should make sure that the <prgn>configure</prgn> utility
1362             detects the correct architecture specification string
1363             (refer to <ref id="arch-spec"> for details).</p>
1364
1365           <p>
1366             If you need to edit a <prgn>Makefile</prgn> where
1367             GNU-style <prgn>configure</prgn> scripts are used, you
1368             should edit the <tt>.in</tt> files rather than editing the
1369             <prgn>Makefile</prgn> directly.  This allows the user to
1370             reconfigure the package if necessary.  You should
1371             <em>not</em> configure the package and edit the generated
1372             <prgn>Makefile</prgn>!  This makes it impossible for
1373             someone else to later reconfigure the package.</p></sect1>
1374
1375
1376         <sect1>
1377           <heading>Documenting your changes</heading>
1378
1379           <p>
1380             You should document your changes and updates to the source
1381             package properly in the <tt>debian/changelog</tt> file. (Note
1382             that mistakes in changelogs are usually best rectified by
1383             making a new changelog entry rather than "rewriting history"
1384             by editing old changelog entries.)</p>
1385
1386           <p>
1387             In non-experimental packages you must use a format for
1388             <tt>debian/changelog</tt> which is supported by the most
1389             recent released version of <prgn>dpkg</prgn>.
1390             <footnote>
1391               <p>
1392                 If you wish to use an alternative format, you may do
1393                 so as long as you include a parser for it in your
1394                 source package.  The parser must have an API
1395                 compatible with that expected by
1396                 <prgn>dpkg-genchanges</prgn> and
1397                 <prgn>dpkg-gencontrol</prgn>.  If there is general
1398                 interest in the new format, you should contact the
1399                 <package>dpkg</package> maintainer to have the parser
1400                 script for it included in the <prgn>dpkg</prgn>
1401                 package.  (You will need to agree that the parser and
1402                 its manpage may be distributed under the GNU GPL, just
1403                 as the rest of `dpkg' is.)
1404               </p>
1405             </footnote>
1406           </p>
1407         </sect1>
1408
1409
1410         <sect1>
1411           <heading>Error trapping in makefiles</heading>
1412
1413           <p>
1414             When <prgn>make</prgn> invokes a command in a makefile
1415             (including your package's upstream makefiles and
1416             <tt>debian/rules</tt>), it does so using <tt>sh</tt>.  This
1417             means that <tt>sh</tt>'s usual bad error handling
1418             properties apply: if you include a miniature script as one
1419             of the commands in your makefile you'll find that if you
1420             don't do anything about it then errors are not detected
1421             and <prgn>make</prgn> will blithely continue after
1422             problems.</p>
1423
1424           <p>
1425             Every time you put more than one shell command (this
1426             includes using a loop) in a makefile command you
1427             must make sure that errors are trapped.  For
1428             simple compound commands, such as changing directory and
1429             then running a program, using <tt>&amp;&amp;</tt> rather
1430             than semicolon as a command separator is sufficient.  For
1431             more complex commands including most loops and
1432             conditionals you should include a separate <tt>set -e</tt>
1433             command at the start of every makefile command that's
1434             actually one of these miniature shell scripts.</p></sect1>
1435
1436
1437         <sect1>
1438           <heading>Obsolete constructs and libraries</heading>
1439
1440           <p>
1441             The include file <prgn>&lt;varargs.h&gt;</prgn> is
1442             provided to support end-users compiling very old software;
1443             the library <tt>libtermcap</tt> is provided to support the
1444             execution of software which has been linked against it
1445             (either old programs or those such as Netscape which are
1446             only available in binary form).</p>
1447
1448           <p>
1449             Debian packages should be patched to use
1450             <prgn>&lt;stdarg.h&gt;</prgn> and <tt>ncurses</tt>
1451             instead.
1452           </p>
1453         </sect1>
1454       </sect>
1455     </chapt>
1456
1457     <chapt id="controlfields"><heading>Control files and their fields</heading>
1458
1459       <p>
1460         Many of the tools in the package management suite manipulate
1461         data represented in a common format, known as <em>control
1462         data</em>.  The data is often stored in <em>control
1463         files</em>.  Binary and source packages have control files,
1464         and the <tt>.changes</tt> files which control the installation
1465         of uploaded files are also in control file format.
1466         <prgn>Dpkg</prgn>'s internal databases are in a similar
1467         format.
1468       </p>
1469
1470       <sect id="controlsyntax"><heading>Syntax of control files</heading>
1471
1472         <p>
1473           A control file consists of one or more paragraphs of fields.
1474           The paragraphs are separated by blank lines.  Some control
1475           files allow only one paragraph; others allow several, in
1476           which case each paragraph usually refers to a different
1477           package.  (For example, in source packages, the first
1478           paragraph refers to the source package, and later paragraphs
1479           refer to binary packages generated from the source.)
1480         </p>
1481
1482         <p>
1483           Each paragraph consists of a series of data fields; each
1484           field consists of the field name, followed by a colon and
1485           then the data/value associated with that field.  It ends at
1486           the end of the line.  Horizontal whitespace (spaces and
1487           tabs) may occur immediately before or after the value and is
1488           ignored there; it is conventional to put a single space
1489           after the colon.  For example, a field might be:
1490           <example>
1491             Package: libc6
1492           </example>
1493           the field name is <tt>Package</tt> and the field value
1494           <tt>libc6</tt>.
1495         </p>
1496
1497         <p>
1498           Some fields' values may span several lines; in this case
1499           each continuation line <em>must</em> start with a space or
1500           tab.  Any trailing spaces or tabs at the end of individual
1501           lines of a field value are ignored.
1502         </p>
1503
1504         <p>
1505           Except where otherwise stated only a single line of data is
1506           allowed and whitespace is not significant in a field body.
1507           Whitespace must not appear inside names (of packages,
1508           architectures, files or anything else) or version numbers,
1509           or between the characters of multi-character version
1510           relationships.
1511         </p>
1512
1513         <p>
1514           Field names are not case-sensitive, but it is usual to
1515           capitalize the field names using mixed case as shown below.
1516         </p>
1517
1518         <p>
1519           Blank lines, or lines consisting only of spaces and tabs,
1520           are not allowed within field values or between fields - that
1521           would mean a new paragraph.
1522         </p>
1523
1524       </sect>
1525
1526       <sect><heading>List of fields</heading>
1527         <p>
1528           This list here is not supposed to be exhaustive. Most fields
1529           are dealt with elsewhere in this document.
1530         </p>
1531         <sect1 id="f-Package"><heading><tt>Package</tt>
1532           </heading>
1533
1534           <p>
1535             The name of the binary package.  Package names consist of
1536             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
1537             (plus, minus and full stop).
1538           </p>
1539
1540           <p>
1541             They must be at least two characters long and must start
1542             with an alphanumeric character and not be all digits.  The
1543             use of lowercase package names is strongly recommended
1544             unless the package you're building (or referring to, in
1545             other fields) is already using uppercase.</p>
1546         </sect1>
1547
1548         <sect1 id="f-Version"><heading><tt>Version</tt>
1549           </heading>
1550
1551           <p>
1552             This lists the source or binary package's version number -
1553             see <ref id="versions">.
1554           </p>
1555
1556         </sect1>
1557
1558         <sect1
1559                id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1560           </heading>
1561
1562           <p>
1563             The most recent version of the standards (the policy
1564             manual and associated texts) with which the package
1565             complies.  This is updated manually when editing the
1566             source package to conform to newer standards; it can
1567             sometimes be used to tell when a package needs attention.
1568             Its format is described above; see
1569             <ref id="standardsversion">.
1570           </p>
1571         </sect1>
1572
1573
1574         <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1575           </heading>
1576
1577           <p>
1578             In a <tt>.changes</tt> file or parsed changelog output
1579             this contains the (space-separated) name(s) of the
1580             distribution(s) where this version of the package should
1581             be installed.  Valid distributions are determined by the
1582             archive maintainers.
1583             <footnote>
1584                 Current distribution names are:
1585                 <taglist>
1586                   <tag><em>stable</em></tag>
1587                   <item>
1588                     <p>
1589                       This is the current `released' version of Debian
1590                       GNU/Linux.  Once the distribution is
1591                       <em>stable</em> only security fixes and other
1592                       major bug fixes are allowed. When changes are
1593                       made to this distribution, the release number is
1594                       increased (for example: 2.2r1 becomes 2.2r2 then
1595                       2.2r3, etc).
1596                     </p>
1597                   </item>
1598
1599                   <tag><em>unstable</em></tag>
1600                   <item>
1601                     <p>
1602                       This distribution value refers to the
1603                       <em>developmental</em> part of the Debian
1604                       distribution tree. New packages, new upstream
1605                       versions of packages and bug fixes go into the
1606                       <em>unstable</em> directory tree. Download from
1607                       this distribution at your own risk.
1608                     </p>
1609                   </item>
1610
1611                   <tag><em>testing</em></tag>
1612                   <item>
1613                     <p>
1614                       This distribution value refers to the
1615                       <em>testing</em> part of the Debian distribution
1616                       tree.  It receives its packages from the
1617                       unstable distribution after a short time lag to
1618                       ensure that there are no major issues with the
1619                       unstable packages.  It is less prone to breakage
1620                       than unstable, but still risky.  It is not
1621                       possible to upload packages directly to
1622                       <em>testing</em>.
1623                     </p>
1624                   </item>
1625
1626                   <tag><em>frozen</em></tag>
1627                   <item>
1628                     <p>
1629                       From time to time, the <em>frozen</em>
1630                       distribution enters a state of `code-freeze' in
1631                       anticipation of release as a <em>stable</em>
1632                       version. During this period of testing only
1633                       fixes for existing or newly-discovered bugs will
1634                       be allowed.  The exact details of this stage are
1635                       determined by the Release Manager.
1636                     </p>
1637                   </item>
1638
1639                   <tag><em>experimental</em></tag>
1640                   <item>
1641                     <p>
1642                       The packages with this distribution value are
1643                       deemed by their maintainers to be high
1644                       risk. Oftentimes they represent early beta or
1645                       developmental packages from various sources that
1646                       the maintainers want people to try, but are not
1647                       ready to be a part of the other parts of the
1648                       Debian distribution tree. Download at your own
1649                       risk.
1650                     </p>
1651                   </item>
1652                 </taglist>
1653
1654                 You should list <em>all</em> distributions that the
1655                 package should be installed into.
1656             </footnote>
1657           </p>
1658         </sect1>
1659
1660
1661       </sect>
1662     </chapt>
1663
1664     <chapt id="versions"><heading>Version numbering</heading>
1665
1666       <p>
1667         Every package has a version number recorded in its
1668         <tt>Version</tt> control file field.
1669       </p>
1670
1671       <p>
1672         The package management system imposes an ordering on version
1673         numbers, so that it can tell whether packages are being up- or
1674         downgraded and so that package system front end applications
1675         can tell whether a package it finds available is newer than
1676         the one installed on the system.  The version number format
1677         has the most significant parts (as far as comparison is
1678         concerned) at the beginning.
1679       </p>
1680
1681       <p>
1682         The version number format is:
1683         &lsqb<var>epoch</var><tt>:</tt>&rsqb;<var>upstream_version</var>&lsqb;<tt>-</tt><var>debian_revision</var>&rsqb;
1684       </p>
1685
1686       <p>
1687         The three components here are:
1688         <taglist>
1689           <tag><var>epoch</var></tag>
1690           <item>
1691
1692             <p>
1693               This is a single (generally small) unsigned integer.  It
1694               may be omitted, in which case zero is assumed.  If it is
1695               omitted then the <var>upstream_version</var> may not
1696               contain any colons.
1697             </p>
1698
1699             <p>
1700               It is provided to allow mistakes in the version numbers
1701               of older versions of a package, and also a package's
1702               previous version numbering schemes, to be left behind.
1703             </p>
1704
1705           </item>
1706
1707           <tag><var>upstream_version</var></tag>
1708           <item>
1709
1710             <p>
1711               This is the main part of the version number.  It is
1712               usually the version number of the original (`upstream')
1713               package from which the <tt>.deb</tt> file has been made,
1714               if this is applicable.  Usually this will be in the same
1715               format as that specified by the upstream author(s);
1716               however, it may need to be reformatted to fit into the
1717               package management system's format and comparison
1718               scheme.
1719             </p>
1720
1721             <p>
1722               The comparison behavior of the package management system
1723               with respect to the <var>upstream_version</var> is
1724               described below.  The <var>upstream_version</var>
1725               portion of the version number is mandatory.
1726             </p>
1727
1728             <p>
1729               The <var>upstream_version</var> may contain only
1730               alphanumerics
1731               <footnote>
1732                 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1733               </footnote>
1734               and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1735               <tt>:</tt> (full stop, plus, hyphen, colon) and should
1736               start with a digit.  If there is no
1737               <var>debian_revision</var> then hyphens are not allowed;
1738               if there is no <var>epoch</var> then colons are not
1739               allowed.</p>
1740           </item>
1741
1742           <tag><var>debian_revision</var></tag>
1743           <item>
1744
1745             <p>
1746               This part of the version number specifies the version of
1747               the Debian package based on the upstream version.  It
1748               may contain only alphanumerics and the characters
1749               <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1750               compared in the same way as the
1751               <var>upstream_version</var> is.
1752             </p>
1753
1754             <p>
1755               It is optional; if it isn't present then the
1756               <var>upstream_version</var> may not contain a hyphen.
1757               This format represents the case where a piece of
1758               software was written specifically to be turned into a
1759               Debian package, and so there is only one `debianization'
1760               of it and therefore no revision indication is required.
1761             </p>
1762
1763             <p>
1764               It is conventional to restart the
1765               <var>debian_revision</var> at <tt>1</tt> each time the
1766               <var>upstream_version</var> is increased.
1767             </p>
1768
1769             <p>
1770               The package management system will break the version
1771               number apart at the last hyphen in the string (if there
1772               is one) to determine the <var>upstream_version</var> and
1773               <var>debian_revision</var>.  The absence of a
1774               <var>debian_revision</var> compares earlier than the
1775               presence of one (but note that the
1776               <var>debian_revision</var> is the least significant part
1777               of the version number).
1778             </p>
1779           </item>
1780         </taglist>
1781         The <var>upstream_version</var> and <var>debian_revision</var>
1782         parts are compared by the package management system using the
1783         same algorithm:
1784       </p>
1785
1786       <p>
1787         The strings are compared from left to right.
1788       </p>
1789
1790       <p>
1791         First the initial part of each string consisting entirely of
1792         non-digit characters is determined.  These two parts (one of
1793         which may be empty) are compared lexically.  If a difference
1794         is found it is returned.  The lexical comparison is a
1795         comparison of ASCII values modified so that all the letters
1796         sort earlier than all the non-letters.
1797       </p>
1798
1799       <p>
1800         Then the initial part of the remainder of each string which
1801         consists entirely of digit characters is determined.  The
1802         numerical values of these two parts are compared, and any
1803         difference found is returned as the result of the comparison.
1804         For these purposes an empty string (which can only occur at
1805         the end of one or both version strings being compared) counts
1806         as zero.
1807       </p>
1808
1809       <p>
1810         These two steps (comparing and removing initial non-digit
1811         strings and initial digit strings) are repeated until a
1812         difference is found or both strings are exhausted.
1813       </p>
1814
1815       <p>
1816         Note that the purpose of epochs is to allow us to leave behind
1817         mistakes in version numbering, and to cope with situations
1818         where the version numbering scheme changes.  It is
1819         <em>not</em> intended to cope with version numbers containing
1820         strings of letters which the package management system cannot
1821         interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1822         silly orderings (the author of this manual has heard of a
1823         package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1824         <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1825         <tt>2</tt> and so forth).
1826       </p>
1827
1828       <p>
1829         If an upstream package has problematic version numbers they
1830         should be converted to a sane form for use in the
1831         <tt>Version</tt> field.
1832       </p>
1833
1834       <sect>
1835         <heading>Version numbers based on dates</heading>
1836         <p>
1837           In general, Debian packages should use the same version
1838           numbers as the upstream sources.</p>
1839
1840         <p>
1841           However, in some cases where the upstream version number is
1842           based on a date (e.g., a development `snapshot' release) the
1843           package management system cannot handle these version
1844           numbers without epochs. For example, dpkg will consider
1845           `96May01' to be greater than `96Dec24'.</p>
1846
1847         <p>
1848           To prevent having to use epochs for every new upstream
1849           version, the version number should be changed to the
1850           following format in such cases: `19960501', `19961224'. It
1851           is up to the maintainer whether he/she wants to bother the
1852           upstream maintainer to change the version numbers upstream,
1853           too.</p>
1854
1855         <p>
1856           Note that other version formats based on dates which are
1857           parsed correctly by the package management system should
1858           <em>not</em> be changed.</p>
1859
1860         <p>
1861           Native Debian packages (i.e., packages which have been
1862           written especially for Debian) whose version numbers include
1863           dates should always use the `YYYYMMDD' format.</p>
1864       </sect>
1865     </chapt>
1866
1867     <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1868
1869       <sect id="timestamps"><heading>Time Stamps</heading>
1870         <p>
1871           Maintainers should preserve the modification times of the
1872           upstream source files in a package, as far as is reasonably
1873           possible.
1874           <footnote>
1875             <p>
1876               The rationale is that there is some information conveyed
1877               by knowing the age of the file, for example, you could
1878               recognize that some documentation is very old by looking
1879               at the modification time, so it would be nice if the
1880               modification time of the upstream source would be
1881               preserved.
1882             </p>
1883           </footnote>
1884         </p>
1885       </sect>
1886
1887       <sect id="debianrules"><heading><tt>debian/rules</tt> - the
1888           main building script</heading>
1889
1890         <p>
1891           This file must be an executable makefile, and contains the
1892           package-specific recipes for compiling the package and
1893           building binary package(s) from the source.
1894         </p>
1895
1896         <p>
1897           It must start with the line <tt>#!/usr/bin/make -f</tt>,
1898           so that it can be invoked by saying its name rather than
1899           invoking <prgn>make</prgn> explicitly.
1900         </p>
1901
1902         <p>
1903           Since an interactive <tt>debian/rules</tt> script makes it
1904           impossible to auto-compile that package and also makes it
1905           hard for other people to reproduce the same binary
1906           package, all <em>required targets</em> MUST be
1907           non-interactive. At a minimum, required targets are the
1908           ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1909           <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1910           <em>binary-indep</em>, and <em>build</em>. It also follows
1911           that any target that these targets depend on must also be
1912           non-interactive.
1913         </p>
1914
1915         <p>
1916           The required and optional targets are as follows:
1917           <taglist>
1918             <tag><tt>build</tt></tag>
1919             <item>
1920               <p>
1921                 This should perform all non-interactive configuration
1922                 and compilation of the package.  If a package has an
1923                 interactive pre-build configuration routine, the
1924                 Debianized source package must either be built after
1925                 this has taken place (so that the binary package can
1926                 be built without rerunning the configuration) or the
1927                 configuration routine modified to become
1928                 non-interactive.  (The latter is preferable if there
1929                 are architecture-specific features detected by the
1930                 configuration routine.)
1931               </p>
1932
1933               <p>
1934                 For some packages, notably ones where the same
1935                 source tree is compiled in different ways to produce
1936                 two binary packages, the <prgn>build</prgn> target
1937                 does not make much sense.  For these packages it is
1938                 good enough to provide two (or more) targets
1939                 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1940                 for each of the ways of building the package, and a
1941                 <prgn>build</prgn> target that does nothing.  The
1942                 <prgn>binary</prgn> target will have to build the
1943                 package in each of the possible ways and make the
1944                 binary package out of each.
1945               </p>
1946
1947               <p>
1948                 The <prgn>build</prgn> target must not do anything
1949                 that might require root privilege.
1950               </p>
1951
1952               <p>
1953                 The <prgn>build</prgn> target may need to run the
1954                 <prgn>clean</prgn> target first - see below.
1955               </p>
1956
1957               <p>
1958                 When a package has a configuration and build routine
1959                 which takes a long time, or when the makefiles are
1960                 poorly designed, or when <prgn>build</prgn> needs to
1961                 run <prgn>clean</prgn> first, it is a good idea to
1962                 <tt>touch build</tt> when the build process is
1963                 complete.  This will ensure that if <tt>debian/rules
1964                 build</tt> is run again it will not rebuild the whole
1965                 program.
1966                 <footnote>
1967                   <p>
1968                     Another common way to do this is for <prgn>build</prgn>
1969                     to depend on <prgn>build-stamp</prgn> and to do
1970                     nothing else, and for the <prgn>build-stamp</prgn>
1971                     target to do the building and to <tt>touch
1972                     build-stamp</tt> on completion.  This is
1973                     especially useful if the build routine creates a
1974                     file or directory called <tt>build</tt>; in such a
1975                     case, <prgn>build</prgn> will need to be listed as
1976                     a phony target (i.e., as a dependency of the
1977                     <tt>.PHONY</tt> target).  See the documentation of
1978                     <prgn>make</prgn> for more information on phony
1979                     targets.
1980                   </p>
1981                 </footnote>
1982               </p>
1983             </item>
1984
1985             <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1986               <tt>binary-indep</tt>
1987             </tag>
1988             <item>
1989               <p>
1990                 The <prgn>binary</prgn> target must be all that is
1991                 necessary for the user to build the binary package(s)
1992                 produced from this source package.  All of these
1993                 targets are required to be non-interactive.  It is
1994                 split into two parts: <prgn>binary-arch</prgn> builds
1995                 the binary packages which are specific to a particular
1996                 architecture, and <prgn>binary-indep</prgn> builds
1997                 those which are not.
1998               </p>
1999
2000               <p>
2001                 <prgn>binary</prgn> may be (and commonly is) a target
2002                 with no commands which simply depends on
2003                 <prgn>binary-arch</prgn> and
2004                 <prgn>binary-indep</prgn>.
2005               </p>
2006
2007               <p>
2008                 Each <prgn>binary-*</prgn> target should depend on
2009                 the <prgn>build</prgn> target, above, so that the
2010                 package is built if it has not been already.  It
2011                 should then create the relevant binary package(s),
2012                 using <prgn>dpkg-gencontrol</prgn> to make their
2013                 control files and <prgn>dpkg-deb</prgn> to build
2014                 them and place them in the parent of the top level
2015                 directory.
2016               </p>
2017
2018               <p>
2019                 Both the <prgn>binary-arch</prgn> and
2020                 <prgn>binary-indep</prgn> targets <em>must</em> exist.
2021                 If one of them has nothing to do (which will always be
2022                 the case if the source generates only a single binary
2023                 package, whether architecture-dependent or not), it
2024                 must still exist and must always succeed.
2025               </p>
2026
2027               <p>
2028                 The <prgn>binary</prgn> targets must be invoked as
2029                 root.
2030                 <footnote>
2031                   <p>
2032                     The <prgn>fakeroot</prgn> package often allows one
2033                     to build a package correctly even without being
2034                     root.
2035                   </p>
2036                 </footnote>
2037               </p>
2038             </item>
2039
2040             <tag><tt>clean</tt></tag>
2041             <item>
2042
2043               <p>
2044                 This must undo any effects that the <prgn>build</prgn>
2045                 and <prgn>binary</prgn> targets may have had, except
2046                 that it should leave alone any output files created in
2047                 the parent directory by a run of a <prgn>binary</prgn>
2048                 target. This target must be non-interactive.
2049               </p>
2050
2051               <p>
2052                 If a <prgn>build</prgn> file is touched at the end of
2053                 the <prgn>build</prgn> target, as suggested above, it
2054                 should be removed as the first action that
2055                 <prgn>clean</prgn> performs, so that running
2056                 <prgn>build</prgn> again after an interrupted
2057                 <prgn>clean</prgn> doesn't think that everything is
2058                 already done.
2059               </p>
2060
2061               <p>
2062                 The <prgn>clean</prgn> target may need to be
2063                 invoked as root if <prgn>binary</prgn> has been
2064                 invoked since the last <prgn>clean</prgn>, or if
2065                 <prgn>build</prgn> has been invoked as root (since
2066                 <prgn>build</prgn> may create directories, for
2067                 example).
2068               </p>
2069             </item>
2070
2071             <tag><tt>get-orig-source</tt> (optional)</tag>
2072             <item>
2073
2074               <p>
2075                 This target fetches the most recent version of the
2076                 original source package from a canonical archive site
2077                 (via FTP or WWW, for example), does any necessary
2078                 rearrangement to turn it into the original source
2079                 tar file format described below, and leaves it in the
2080                 current directory.
2081               </p>
2082
2083               <p>
2084                 This target may be invoked in any directory, and
2085                 should take care to clean up any temporary files it
2086                 may have left.
2087               </p>
2088
2089               <p>
2090                 This target is optional, but providing it if
2091                 possible is a good idea.
2092               </p>
2093             </item>
2094           </taglist>
2095
2096         <p>
2097           The <prgn>build</prgn>, <prgn>binary</prgn> and
2098           <prgn>clean</prgn> targets must be invoked with the current
2099           directory being the package's top-level directory.
2100         </p>
2101
2102
2103         <p>
2104           Additional targets may exist in <tt>debian/rules</tt>,
2105           either as published or undocumented interfaces or for the
2106           package's internal use.
2107         </p>
2108
2109         <p>
2110           The architectures we build on and build for are determined
2111           by <prgn>make</prgn> variables using the utility
2112           <prgn>dpkg-architecture</prgn>.  You can determine the
2113           Debian architecture and the GNU style architecture
2114           specification string for the build machine (the machine type
2115           we are building on) as well as for the host machine (the
2116           machine type we are building for).  Here is a list of
2117           supported <prgn>make</prgn> variables:
2118           <list compact="compact">
2119             <item>
2120               <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2121             </item>
2122             <item>
2123               <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2124                 specification string)</p>
2125             </item>
2126             <item>
2127               <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2128               <tt>DEB_*_GNU_TYPE</tt>)</p>
2129             </item>
2130             <item>
2131               <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2132                 <tt>DEB_*_GNU_TYPE</tt>)</p>
2133           </list>
2134           where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2135           the build machine or <tt>HOST</tt> for specification of the
2136           host machine.
2137         </p>
2138
2139         <p>
2140           Backward compatibility can be provided in the rules file
2141           by setting the needed variables to suitable default
2142           values; please refer to the documentation of
2143           <prgn>dpkg-architecture</prgn> for details.
2144         </p>
2145
2146         <p>
2147           It is important to understand that the <tt>DEB_*_ARCH</tt>
2148           string only determines which Debian architecture we are
2149           building on or for. It should not be used to get the CPU
2150           or system information; the GNU style variables should be
2151           used for that.
2152         </p>
2153       </sect>
2154
2155       <sect id="dpkgchangelog"><heading><tt>debian/changelog</tt>
2156         </heading>
2157
2158         <p>
2159           This file records the changes to the Debian-specific parts of the
2160           package
2161           <footnote>
2162             <p>
2163               Though there is nothing stopping an author who is also
2164               the Debian maintainer from using it for all their
2165               changes, it will have to be renamed if the Debian and
2166               upstream maintainers become different people.  In such a
2167               case, however, it might be better to maintain the
2168               package as a non-native package.
2169             </p>
2170           </footnote>.
2171         </p>
2172
2173         <p>
2174           It has a special format which allows the package building
2175           tools to discover which version of the package is being
2176           built and find out other release-specific information.
2177         </p>
2178
2179         <p>
2180           That format is a series of entries like this:
2181           <example>
2182 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2183
2184   * <var>change details</var>
2185     <var>more change details</var>
2186   * <var>even more change details</var>
2187
2188  -- <var>maintainer name and email address</var>  <var>date</var>
2189           </example>
2190         </p>
2191
2192         <p>
2193           <var>package</var> and <var>version</var> are the source
2194           package name and version number.
2195         </p>
2196
2197         <p>
2198           <var>distribution(s)</var> lists the distributions where
2199           this version should be installed when it is uploaded - it
2200           is copied to the <tt>Distribution</tt> field in the
2201           <tt>.changes</tt> file.  See <ref id="f-Distribution">.
2202         </p>
2203
2204         <p>
2205           <var>urgency</var> is the value for the <tt>Urgency</tt>
2206           field in the <tt>.changes</tt> file for the upload. It is
2207           not possible to specify an urgency containing commas; commas
2208           are used to separate
2209           <tt><var>keyword</var>=<var>value</var></tt> settings in the
2210           <prgn>dpkg</prgn> changelog format (though there is
2211           currently only one useful <var>keyword</var>,
2212           <tt>urgency</tt>).
2213           <footnote>
2214             <p>
2215               Usual urgency values are <tt>low</tt>, <tt>medium</tt>,
2216               <tt>high</tt> and <tt>critical</tt>.  They have an
2217               effect on how quickly a package will be considered for
2218               inclusion into the <tt>testing</tt> distribution, and
2219               give an indication of the importance of any fixes
2220               included in this upload.
2221             </p>
2222           </footnote>
2223         </p>
2224
2225         <p>
2226           The change details may in fact be any series of lines
2227           starting with at least two spaces, but conventionally each
2228           change starts with an asterisk and a separating space and
2229           continuation lines are indented so as to bring them in
2230           line with the start of the text above.  Blank lines may be
2231           used here to separate groups of changes, if desired.
2232         </p>
2233
2234         <p>
2235           If this upload resolves bugs recorded in the Bug Tracking
2236           System (BTS), they may be automatically closed on the
2237           inclusion of this package into the Debian archive by
2238           including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2239           in the change details.
2240           <footnote>
2241             <p>
2242               To be precise, the string should match the following
2243               Perl regular expression (where $pound=<tt>#</tt>;):
2244               <example>
2245 /closes:\s*(?:bug)?${pound}?\s?\d+(?:,\s*(?:bug)?\${pound}?\s?\d+)*/i
2246               </example>
2247               <footnote>
2248                 <p>We had to introduce the $pound variable in the
2249                   regexp above because otherwise the utilities
2250                   rendering the policy documents gor confused by a
2251                   backslashed "#" symbol.
2252                 </p>
2253               </footnote>
2254               Then all of the bug numbers listed will be closed by the
2255               archive maintenance script (<prgn>katie</prgn>), or in
2256               the case of an NMU, marked as fixed.
2257             </p>
2258           </footnote>
2259         </p>
2260
2261         <p>
2262           The maintainer name and email address used in the changelog
2263           should be the details of the person uploading <em>this</em>
2264           version.  They are <em>not</em> necessarily those of the
2265           usual package maintainer.  The information here will be
2266           copied to the <tt>Changed-By</tt> field in the
2267           <tt>.changes</tt> file, and then later used to send an
2268           acknowledgement when the upload has been installed.
2269         </p>
2270
2271         <p>
2272           The <var>date</var> should be in RFC822 format
2273           <footnote>
2274             <p>
2275               This is generated by the <prgn>822-date</prgn>
2276               program.
2277             </p>
2278           </footnote>; it should include the time zone specified
2279           numerically, with the time zone name or abbreviation
2280           optionally present as a comment in parentheses.
2281         </p>
2282
2283         <p>
2284           The first `title' line with the package name should start
2285           at the left hand margin; the `trailer' line with the
2286           maintainer and date details should be preceded by exactly
2287           one space.  The maintainer details and the date must be
2288           separated by exactly two spaces.
2289         </p>
2290
2291         <sect1><heading>Defining alternative changelog formats</heading>
2292
2293           <p>
2294             It is possible to use a different format to the standard
2295             one, by providing a parser for the format you wish to
2296             use.
2297           </p>
2298           <p>
2299             A changelog parser must not interact with the user at
2300             all.
2301           </p>
2302         </sect1>
2303       </sect>
2304
2305       <sect id="srcsubstvars"><heading><tt>debian/substvars</tt>
2306           and variable substitutions      </heading>
2307
2308         <p>
2309           When <prgn>dpkg-gencontrol</prgn>,
2310           <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2311           generate control files they perform variable substitutions
2312           on their output just before writing it.  Variable
2313           substitutions have the form
2314           <tt>${<var>variable-name</var>}</tt>.  The optional file
2315           <tt>debian/substvars</tt> contains variable substitutions to
2316           be used; variables can also be set directly from
2317           <tt>debian/rules</tt> using the <tt>-V</tt> option to the
2318           source packaging commands, and certain predefined variables
2319           are also available.
2320         </p>
2321
2322         <p>
2323           The <tt>debian/substvars</tt> file is usually generated and
2324           modified dynamically by <tt>debian/rules</tt> targets; in
2325           this case it must be removed by the <prgn>clean</prgn>
2326           target.
2327         </p>
2328
2329         <p>
2330           See <manref name="dpkg-source" section="1"> for full
2331           details about source variable substitutions, including the
2332           format of <tt>debian/substvars</tt>.</p>
2333       </sect>
2334
2335       <sect id="debianfiles"><heading><tt>debian/files</tt>
2336         </heading>
2337
2338         <p>
2339           This file is not a permanent part of the source tree; it
2340           is used while building packages to record which files are
2341           being generated.  <prgn>dpkg-genchanges</prgn> uses it
2342           when it generates a <tt>.changes</tt> file.
2343         </p>
2344
2345         <p>
2346           It should not exist in a shipped source package, and so it
2347           (and any backup files or temporary files such as
2348           <tt>files.new</tt>
2349           <footnote>
2350             <p>
2351               <tt>files.new</tt> is used as a temporary file by
2352               <prgn>dpkg-gencontrol</prgn> and
2353               <prgn>dpkg-distaddfile</prgn> - they write a new
2354               version of <tt>files</tt> here before renaming it,
2355               to avoid leaving a corrupted copy if an error
2356               occurs
2357             </p>
2358           </footnote>) should be removed by the
2359           <prgn>clean</prgn> target.  It may also be wise to
2360           ensure a fresh start by emptying or removing it at the
2361           start of the <prgn>binary</prgn> target.
2362         </p>
2363
2364         <p>
2365           When <prgn>dpkg-gencontrol</prgn> is run for a binary
2366           package, it adds an entry to <tt>debian/files</tt> for the
2367           <tt>.deb</tt> file that will be created when <prgn>dpkg-deb
2368           --build</prgn> is run for that binary package.  So for most
2369           packages all that needs to be done with this file is to
2370           delete it in the <prgn>clean</prgn> target.
2371         </p>
2372
2373         <p>
2374           If a package upload includes files besides the source
2375           package and any binary packages whose control files were
2376           made with <prgn>dpkg-gencontrol</prgn> then they should be
2377           placed in the parent of the package's top-level directory
2378           and <prgn>dpkg-distaddfile</prgn> should be called to add
2379           the file to the list in <tt>debian/files</tt>.</p>
2380       </sect>
2381
2382       <sect id="restrictions"><heading>Restrictions on objects in source packages
2383         </heading>
2384
2385         <p>
2386           The source package may not contain any hard links
2387           <footnote>
2388             <p>
2389               This is not currently detected when building source
2390               packages, but only when extracting
2391               them.
2392             </p>
2393             <p>
2394               Hard links may be permitted at some point in the
2395               future, but would require a fair amount of
2396               work.
2397             </p>
2398           </footnote>, device special files, sockets or setuid or
2399           setgid files.
2400           <footnote>
2401             <p>
2402               Setgid directories are allowed.
2403             </p>
2404           </footnote>
2405         </p>
2406       </sect>
2407       <sect id="descriptions"><heading>Descriptions of packages - the
2408           <tt>Description</tt> field </heading>
2409
2410         <p>
2411           The description is intended to describe the program to a user
2412           who has never met it before so that they know whether they
2413           want to install it.  It should also give information about the
2414           significant dependencies and conflicts between this package
2415           and others, so that the user knows why these dependencies and
2416           conflicts have been declared.
2417         </p>
2418
2419         <sect1><heading>Notes about writing descriptions
2420           </heading>
2421
2422           <p>
2423             The single line synopsis should be kept brief - certainly
2424             under 80 characters.
2425           </p>
2426
2427           <p>
2428             Do not include the package name in the synopsis line.  The
2429             display software knows how to display this already, and you
2430             do not need to state it.  Remember that in many situations
2431             the user may only see the synopsis line - make it as
2432             informative as you can.
2433           </p>
2434
2435           <p>
2436             Do not try to continue the single line synopsis into the
2437             extended description.  This will not work correctly when
2438             the full description is displayed, and makes no sense
2439             where only the summary (the single line synopsis) is
2440             available.
2441           </p>
2442
2443           <p>
2444             The extended description should describe what the package
2445             does and how it relates to the rest of the system (in terms
2446             of, for example, which subsystem it is which part of).
2447           </p>
2448
2449           <p>
2450             The description field needs to make sense to anyone, even
2451             people who have no idea about any of the things the
2452             package deals with.
2453             <footnote>
2454               <p>
2455                 The blurb that comes with a program in its
2456                 announcements and/or <prgn>README</prgn> files is
2457                 rarely suitable for use in a description.  It is
2458                 usually aimed at people who are already in the
2459                 community where the package is used.
2460               </p>
2461             </footnote>
2462           </p>
2463
2464           <p>
2465             Put important information first, both in the synopsis and
2466             extended description.  Sometimes only the first part of the
2467             synopsis or of the description will be displayed.  You can
2468             assume that there will usually be a way to see the whole
2469             extended description.
2470           </p>
2471
2472           <p>
2473             You may include information about dependencies and so forth
2474             in the extended description, if you wish.
2475           </p>
2476
2477           <p>
2478             Do not use tab characters.  Their effect is not predictable.
2479           </p>
2480
2481         </sect1>
2482       </sect>
2483     </chapt>
2484
2485
2486     <chapt id="maintainerscripts"><heading>Package maintainer scripts
2487         and installation procedure
2488       </heading>
2489
2490       <sect><heading>Introduction to package maintainer scripts
2491         </heading>
2492
2493         <p>
2494           It is possible to supply scripts as part of a package which
2495           the package management system will run for you when your
2496           package is installed, upgraded or removed.
2497         </p>
2498
2499         <p>
2500           These scripts are the files <tt>preinst</tt>,
2501           <tt>postinst</tt>, <tt>prerm</tt> and <tt>postrm</tt> in the
2502           control area of the package.  They must be proper executable
2503           files; if they are scripts (which is recommended), they must
2504           start with the usual <tt>#!</tt> convention.  They should be
2505           readable and executable by anyone, and not world-writable.
2506         </p>
2507
2508         <p>
2509           The package management system looks at the exit status from
2510           these scripts.  It is important that they exit with a
2511           non-zero status if there is an error, so that the package
2512           management system can stop its processing.  For shell
2513           scripts this means that you <em>almost always</em> need to
2514           use <tt>set -e</tt> (this is usually true when writing shell
2515           scripts, in fact).  It is also important, of course, that
2516           they don't exit with a non-zero status if everything went
2517           well.
2518         </p>
2519
2520         <p>
2521           When a package is upgraded a combination of the scripts from
2522           the old and new packages is called during the upgrade
2523           procedure.  If your scripts are going to be at all
2524           complicated you need to be aware of this, and may need to
2525           check the arguments to your scripts.
2526         </p>
2527
2528         <p>
2529           Broadly speaking the <prgn>preinst</prgn> is called before
2530           (a particular version of) a package is installed, and the
2531           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2532           before (a version of) a package is removed and the
2533           <prgn>postrm</prgn> afterwards.
2534         </p>
2535
2536         <p>
2537           Programs called from maintainer scripts should not normally
2538           have a path prepended to them. Before installation is
2539           started, the package management system checks to see if the
2540           programs <prgn>ldconfig</prgn>,
2541           <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2542           and <prgn>update-rc.d</prgn> can be found via the
2543           <tt>PATH</tt> environment variable. Those programs, and any
2544           other program that one would expect to be on the
2545           <tt>PATH</tt>, should thus be invoked without an absolute
2546           pathname. Maintainer scripts should also not reset the
2547           <tt>PATH</tt>, though they might choose to modify it by
2548           prepending or appending package-specific directories. These
2549           considerations really apply to all shell scripts.</p>
2550       </sect>
2551
2552       <sect>
2553         <heading>Maintainer scripts Idempotency</heading>
2554
2555         <p>
2556           It is necessary for the error recovery procedures that the
2557           scripts be idempotent.  This means that if it is run
2558           successfully, and then it is called again, it doesn't bomb
2559           out or cause any harm, but just ensures that everything is
2560           the way it ought to be.  If the first call failed, or
2561           aborted half way through for some reason, the second call
2562           should merely do the things that were left undone the first
2563           time, if any, and exit with a success status if everything
2564           is OK.
2565           <footnote> 
2566             <p>
2567               This is so that if an error occurs, the user interrupts
2568               <prgn>dpkg</prgn> or some other unforeseen circumstance
2569               happens you don't leave the user with a badly-broken
2570               package when <prgn>dpkg</prgn> attempts to repeat the
2571               action.
2572             </p>
2573           </footnote>
2574         </p>
2575       </sect>
2576
2577       <sect>
2578         <heading>Controlling terminal for maintainer scripts</heading>
2579
2580         <p>
2581           The maintainer scripts are guaranteed to run with a
2582           controlling terminal and can interact with the user.
2583           If they need to prompt for passwords, do full-screen
2584           interaction or something similar you should do these
2585           things to and from <tt>/dev/tty</tt>, since
2586           <prgn>dpkg</prgn> will at some point redirect scripts'
2587           standard input and output so that it can log the
2588           installation process.  Likewise, because these scripts
2589           may be executed with standard output redirected into a
2590           pipe for logging purposes, Perl scripts should set
2591           unbuffered output by setting <tt>$|=1</tt> so that the
2592           output is printed immediately rather than being
2593           buffered.
2594         </p>
2595
2596         <p>
2597           Each script should return a zero exit status for
2598           success, or a nonzero one for failure.
2599         </p>
2600       </sect>
2601
2602       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2603           scripts are called
2604         </heading>
2605
2606         <p>
2607           <list compact="compact">
2608             <item>
2609               <p><var>new-preinst</var> <tt>install</tt></p>
2610             </item>
2611             <item>
2612               <p><var>new-preinst</var> <tt>install</tt>
2613                 <var>old-version</var></p>
2614             </item>
2615             <item>
2616               <p><var>new-preinst</var> <tt>upgrade</tt>
2617                 <var>old-version</var></p>
2618             </item>
2619             <item>
2620               <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2621                 <var>new-version</var>
2622               </p>
2623             </item>
2624           </list>
2625
2626         <p>
2627           <list compact="compact">
2628             <item>
2629               <p><var>postinst</var> <tt>configure</tt>
2630                 <var>most-recently-configured-version</var></p>
2631             </item>
2632             <item>
2633               <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2634                 <var>new-version</var></p>
2635             </item>
2636             <item>
2637               <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2638                 <tt>in-favour</tt> <var>package</var>
2639                 <var>new-version</var></p>
2640             </item>
2641             <item>
2642               <p>
2643                 <var>deconfigured's-postinst</var>
2644                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2645                 <var>failed-install-package</var> <var>version</var>
2646                 <tt>removing</tt> <var>conflicting-package</var>
2647                 <var>version</var>
2648               </p>
2649             </item>
2650           </list>
2651
2652         <p>
2653           <list compact="compact">
2654             <item>
2655               <p><var>prerm</var> <tt>remove</tt></p>
2656             </item>
2657             <item>
2658               <p><var>old-prerm</var> <tt>upgrade</tt>
2659                 <var>new-version</var></p>
2660             </item>
2661             <item>
2662               <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2663                 <var>old-version</var></p>
2664             </item>
2665             <item>
2666               <p><var>conflictor's-prerm</var> <tt>remove</tt>
2667                 <tt>in-favour</tt> <var>package</var>
2668                 <var>new-version</var></p>
2669             </item>
2670             <item>
2671               <p>
2672                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2673                 <tt>in-favour</tt> <var>package-being-installed</var>
2674                 <var>version</var> <tt>removing</tt>
2675                 <var>conflicting-package</var>
2676                 <var>version</var>
2677               </p>
2678             </item>
2679           </list>
2680
2681         <p>
2682           <list compact="compact">
2683             <item>
2684               <p><var>postrm</var> <tt>remove</tt></p>
2685             </item>
2686             <item>
2687               <p><var>postrm</var> <tt>purge</tt></p>
2688             </item>
2689             <item>
2690               <p>
2691                 <var>old-postrm</var> <tt>upgrade</tt>
2692                 <var>new-version</var></p>
2693             </item>
2694             <item>
2695               <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2696                 <var>old-version</var></p>
2697             </item>
2698             <item>
2699               <p><var>new-postrm</var> <tt>abort-install</tt></p>
2700             </item>
2701             <item>
2702               <p><var>new-postrm</var> <tt>abort-install</tt>
2703                 <var>old-version</var></p>
2704             </item>
2705             <item>
2706               <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2707                 <var>old-version</var></p>
2708             </item>
2709             <item>
2710               <p>
2711                 <var>disappearer's-postrm</var> <tt>disappear</tt>
2712                 <var>overwriter</var>
2713                 <var>overwriter-version</var></p></item>
2714           </list>
2715         </p>
2716
2717
2718       <sect id="unpackphase"><heading>Details of unpack phase of
2719           installation or upgrade
2720         </heading>
2721
2722         <p>
2723           The procedure on installation/upgrade/overwrite/disappear
2724           (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2725           stage of <tt>dpkg --install</tt>) is as follows.  In each
2726           case, if a major error occurs (unless listed below) the
2727           actions are, in general, run backwards - this means that the
2728           maintainer scripts are run with different arguments in
2729           reverse order.  These are the `error unwind' calls listed
2730           below.
2731
2732           <enumlist>
2733             <item>
2734               <p>
2735                 <enumlist>
2736                   <item>
2737                     <p>If a version of the package is already
2738                       installed, call
2739                       <example>
2740                         <var>old-prerm</var> upgrade <var>new-version</var>
2741                       </example></p>
2742                   </item>
2743                   <item>
2744                     <p>
2745                       If the script runs but exits with a non-zero
2746                       exit status, <prgn>dpkg</prgn> will attempt:
2747                       <example>
2748                         <var>new-prerm</var> failed-upgrade <var>old-version</var>
2749                       </example>
2750                       Error unwind, for both the above cases:
2751                       <example>
2752                         <var>old-postinst</var> abort-upgrade <var>new-version</var>
2753                       </example>
2754                     </p>
2755                   </item>
2756                 </enumlist>
2757               </p>
2758             </item>
2759             <item>
2760               <p>If a `conflicting' package is being removed at the same time:
2761                 <enumlist>
2762                   <item>
2763                     <p>
2764                       If any packages depended on that conflicting
2765                       package and <tt>--auto-deconfigure</tt> is
2766                       specified, call, for each such package:
2767                       <example>
2768                         <var>deconfigured's-prerm</var> deconfigure \
2769                         in-favour <var>package-being-installed</var> <var>version</var> \
2770                         removing <var>conflicting-package</var> <var>version</var>
2771                       </example>
2772                       Error unwind:
2773                       <example>
2774                         <var>deconfigured's-postinst</var> abort-deconfigure \
2775                         in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2776                         removing <var>conflicting-package</var> <var>version</var>
2777                       </example>
2778                       The deconfigured packages are marked as
2779                       requiring configuration, so that if
2780                       <tt>--install</tt> is used they will be
2781                       configured again if possible.</p>
2782                   </item>
2783                   <item>
2784                     <p>To prepare for removal of the conflicting package, call:
2785                       <example>
2786                         <var>conflictor's-prerm</var> remove in-favour <var>package</var> <var>new-version</var>
2787                       </example>
2788                       Error unwind:
2789                       <example>
2790                         <var>conflictor's-postinst</var> abort-remove \
2791                         in-favour <var>package</var> <var>new-version</var>
2792                       </example>
2793                     </p>
2794                   </item>
2795                 </enumlist>
2796               </p>
2797             </item>
2798             <item>
2799               <p>
2800                 <enumlist>
2801                   <item>
2802                     <p>If the package is being upgraded, call:
2803                       <example>
2804                         <var>new-preinst</var> upgrade <var>old-version</var>
2805                       </example></p>
2806                   </item>
2807                   <item>
2808                     <p>
2809                       Otherwise, if the package had some configuration
2810                       files from a previous version installed (i.e., it
2811                       is in the `configuration files only' state):
2812                       <example>
2813                         <var>new-preinst</var> install <var>old-version</var>
2814                       </example></p>
2815
2816                   <item>
2817                     <p>Otherwise (i.e., the package was completely purged):
2818                       <example>
2819                         <var>new-preinst</var> install
2820                       </example>
2821                       Error unwind actions, respectively:
2822                       <example>
2823                         <var>new-postrm</var> abort-upgrade <var>old-version</var>
2824                         <var>new-postrm</var> abort-install <var>old-version</var>
2825                         <var>new-postrm</var> abort-install
2826                       </example>
2827                     </p>
2828                   </item>
2829                 </enumlist>
2830               </p>
2831             </item>
2832             <item>
2833
2834               <p>
2835                 The new package's files are unpacked, overwriting any
2836                 that may be on the system already, for example any
2837                 from the old version of the same package or from
2838                 another package.  Backups of the old files are kept
2839                 temporarily, and if anything goes wrong the package
2840                 management system will attempt to put them back as
2841                 part of the error unwind.
2842               </p>
2843
2844               <p>
2845                 It is an error for a package to contains files which
2846                 are on the system in another package, unless
2847                 <tt>Replaces</tt> is used (see <ref id="replaces">).
2848                 <!--
2849                 The following paragraph is not currently the case:
2850                 Currently the <tt>- - force-overwrite</tt> flag is
2851                 enabled, downgrading it to a warning, but this may not
2852                 always be the case.
2853                 -->
2854               </p>
2855
2856               <p>
2857                 It is a more serious error for a package to contain a
2858                 plain file or other kind of non-directory where another
2859                 package has a directory (again, unless
2860                 <tt>Replaces</tt> is used).  This error can be
2861                 overridden if desired using
2862                 <tt>--force-overwrite-dir</tt>, but this is not
2863                 advisable.
2864               </p>
2865
2866               <p>
2867                 Packages which overwrite each other's files produce
2868                 behavior which, though deterministic, is hard for the
2869                 system administrator to understand.  It can easily
2870                 lead to `missing' programs if, for example, a package
2871                 is installed which overwrites a file from another
2872                 package, and is then removed again.
2873                 <footnote>
2874                   <p>
2875                     Part of the problem is due to what is arguably a
2876                     bug in <prgn>dpkg</prgn>.
2877                   </p>
2878                 </footnote>
2879               </p>
2880
2881               <p>
2882                 A directory will never be replaced by a symbolic link
2883                 to a directory or vice versa; instead, the existing
2884                 state (symlink or not) will be left alone and
2885                 <prgn>dpkg</prgn> will follow the symlink if there is
2886                 one.</p>
2887             </item>
2888
2889             <item>
2890
2891               <p><enumlist>
2892                   <item>
2893                     <p>If the package is being upgraded, call
2894                       <example>
2895                         <var>old-postrm</var> upgrade <var>new-version</var>
2896                       </example></p>
2897                   </item>
2898                   <item>
2899                     <p>If this fails, <prgn>dpkg</prgn> will attempt:
2900                       <example>
2901                         <var>new-postrm</var> failed-upgrade <var>old-version</var>
2902                       </example>
2903                       Error unwind, for both cases:
2904                       <example>
2905                         <var>old-preinst</var> abort-upgrade <var>new-version</var>
2906                       </example>
2907                     </p>
2908                   </item>
2909                 </enumlist>
2910               <p>
2911                 This is the point of no return - if
2912                 <prgn>dpkg</prgn> gets this far, it won't back off
2913                 past this point if an error occurs.  This will
2914                 leave the package in a fairly bad state, which
2915                 will require a successful re-installation to clear
2916                 up, but it's when <prgn>dpkg</prgn> starts doing
2917                 things that are irreversible.
2918               </p>
2919             </item>
2920             <item>
2921               <p>
2922                 Any files which were in the old version of the package
2923                 but not in the new are removed.</p>
2924             </item>
2925             <item>
2926               <p>The new file list replaces the old.</p>
2927             </item>
2928             <item>
2929               <p>The new maintainer scripts replace the old.</p>
2930             </item>
2931
2932             <item>
2933               <p>Any packages all of whose files have been overwritten during the
2934                 installation, and which aren't required for
2935                 dependencies, are considered to have been removed.
2936                 For each such package
2937                 <enumlist>
2938                   <item>
2939                     <p><prgn>dpkg</prgn> calls:
2940                       <example>
2941                         <var>disappearer's-postrm</var> disappear \
2942                         <var>overwriter</var> <var>overwriter-version</var>
2943                       </example>
2944                     </p>
2945                   </item>
2946                   <item>
2947                     <p>The package's maintainer scripts are removed.
2948                     </p>
2949                   </item>
2950                   <item>
2951                     <p>
2952                       It is noted in the status database as being in a
2953                       sane state, namely not installed (any conffiles
2954                       it may have are ignored, rather than being
2955                       removed by <prgn>dpkg</prgn>).  Note that
2956                       disappearing packages do not have their prerm
2957                       called, because <prgn>dpkg</prgn> doesn't know
2958                       in advance that the package is going to
2959                       vanish.
2960                     </p>
2961                   </item>
2962                 </enumlist>
2963               </p>
2964             </item>
2965             <item>
2966               <p>
2967                 Any files in the package we're unpacking that are also
2968                 listed in the file lists of other packages are removed
2969                 from those lists.  (This will lobotomize the file list
2970                 of the `conflicting' package if there is one.)
2971               </p>
2972             </item>
2973             <item>
2974               <p>
2975                 The backup files made during installation, above, are
2976                 deleted.
2977               </p>
2978             </item>
2979
2980             <item>
2981               <p>
2982                 The new package's status is now sane, and recorded as
2983                 `unpacked'.
2984               </p>
2985
2986               <p>
2987                 Here is another point of no return - if the
2988                 conflicting package's removal fails we do not unwind
2989                 the rest of the installation; the conflicting package
2990                 is left in a half-removed limbo.
2991               </p>
2992             </item>
2993
2994             <item>
2995               <p>
2996                 If there was a conflicting package we go and do the
2997                 removal actions (described below), starting with the
2998                 removal of the conflicting package's files (any that
2999                 are also in the package being installed have already
3000                 been removed from the conflicting package's file list,
3001                 and so do not get removed now).
3002               </p>
3003             </item>
3004           </enumlist>
3005         </p>
3006       </sect>
3007
3008       <sect><heading>Details of configuration</heading>
3009
3010         <p>
3011           When we configure a package (this happens with <tt>dpkg
3012             --install</tt>, or with <tt>--configure</tt>), we first
3013           update any <tt>conffile</tt>s and then call:
3014           <example>
3015             <var>postinst</var> configure <var>most-recently-configured-version</var>
3016           </example>
3017         </p>
3018
3019         <p>
3020           No attempt is made to unwind after errors during
3021           configuration.
3022         </p>
3023
3024         <p>
3025           If there is no most recently configured version
3026           <prgn>dpkg</prgn> will pass a null argument; older versions
3027           of dpkg may pass <tt>&lt;unknown&gt;</tt> (including the
3028           angle brackets) in this case.  Even older ones do not pass a
3029           second argument at all, under any circumstances.
3030         </p>
3031       </sect>
3032
3033       <sect><heading>Details of removal and/or configuration purging
3034         </heading>
3035
3036         <p>
3037           <enumlist>
3038             <item>
3039               <p>
3040                 <example>
3041                   <var>prerm</var> remove
3042                 </example>
3043               </p>
3044             </item>
3045             <item>
3046               <p>
3047                 The package's files are removed (except <tt>conffile</tt>s).
3048               </p>
3049             </item>
3050             <item>
3051               <p><example>
3052                   <var>postrm</var> remove
3053                 </example></p>
3054             </item>
3055             <item>
3056               <p>
3057                 All the maintainer scripts except the <tt>postrm</tt>
3058                 are removed.
3059               </p>
3060
3061               <p>
3062                 If we aren't purging the package we stop here.  Note
3063                 that packages which have no <tt>postrm</tt> and no
3064                 <tt>conffile</tt>s are automatically purged when
3065                 removed, as there is no difference except for the
3066                 <prgn>dpkg</prgn> status.</p>
3067             </item>
3068             <item>
3069               <p>
3070                 The conffiles and any backup files (<tt>~</tt>-files,
3071                 <tt>#*#</tt> files, <tt>%</tt>-files,
3072                 <tt>.dpkg-{old,new,tmp}</tt>, etc.) are removed.</p>
3073             </item>
3074             <item>
3075               <p><example>
3076                   <var>postrm</var> purge
3077                 </example></p>
3078             </item>
3079             <item>
3080               <p>The package's file list is removed.</p>
3081             </item>
3082           </enumlist>
3083           No attempt is made to unwind after errors during
3084           removal.
3085         </p>
3086       </sect>
3087     </chapt>
3088
3089
3090     <chapt id="relationships"><heading>Declaring relationships between
3091         packages</heading>
3092
3093       <p>
3094         Packages can declare in their control file that they have
3095         certain relationships to other packages - for example, that
3096         they may not be installed at the same time as certain other
3097         packages, and/or that they depend on the presence of others,
3098         or that they should overwrite files in certain other packages
3099         if present.
3100       </p>
3101
3102       <p>
3103         This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3104         <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3105         <tt>Conflicts</tt>, <tt>Provides</tt> and <tt>Replaces</tt>
3106         control file fields.
3107       </p>
3108
3109       <p>
3110         Source packages may declare relationships to binary packages,
3111         saying that they require certain binary packages to be
3112         installed or absent at the time of building the package.
3113       </p>
3114
3115       <p>
3116         This is done using the <tt>Build-Depends</tt>,
3117         <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3118         <tt>Build-Conflicts-Indep</tt> control file fields.
3119       </p>
3120
3121       <sect id="depsyntax"><heading>Syntax of relationship fields
3122         </heading>
3123
3124         <p>
3125           These fields all have a uniform syntax.  They are a list of
3126           package names separated by commas.
3127         </p>
3128
3129         <p>
3130           In the <tt>Depends</tt>, <tt>Recommends</tt>,
3131           <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3132           <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3133           control file fields of the package, which declare
3134           dependencies on other packages, the package names listed may
3135           also include lists of alternative package names, separated
3136           by vertical bar (pipe) symbols <tt>|</tt>.  In such a case,
3137           if any one of the alternative packages is installed, that
3138           part of the dependency is considered to be satisfied.
3139         </p>
3140
3141         <p>
3142           All of the fields except for <tt>Provides</tt> may restrict
3143           their applicability to particular versions of each named
3144           package.  This is done in parentheses after each individual
3145           package name; the parentheses should contain a relation from
3146           the list below followed by a version number, in the format
3147           described in <ref id="versions">.
3148         </p>
3149
3150         <p>
3151           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
3152           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
3153           strictly earlier, earlier or equal, exactly equal, later or
3154           equal and strictly later, respectively.  The deprecated
3155           forms <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
3156           earlier/later or equal, rather than strictly earlier/later,
3157           so they should not appear in new packages (though
3158           <prgn>dpkg</prgn> still supports them).
3159         </p>
3160
3161         <p>
3162           Whitespace may appear at any point in the version
3163           specification subject to the rules in <ref
3164           id="controlsyntax">, and must appear where it's necessary to
3165           disambiguate; it is not otherwise significant.  For
3166           consistency and in case of future changes to
3167           <prgn>dpkg</prgn> it is recommended that a single space be
3168           used after a version relationship and before a version
3169           number; it is also conventional to put a single space after
3170           each comma, on either side of each vertical bar, and before
3171           each open parenthesis.
3172         </p>
3173
3174         <p>
3175           For example, a list of dependencies might appear as:
3176           <example>
3177             Package: mutt
3178             Version: 1.3.17-1
3179             Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3180           </example>
3181         </p>
3182
3183         <p>
3184           All fields that specify build-time relationships
3185           (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3186           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3187           may be restricted to a certain set of architectures.  This
3188           is indicated in brackets after each individual package name and
3189           the optional version specification.  The brackets enclose a
3190           list of Debian architecture names separated by whitespace.
3191           Exclamation marks may be prepended to each of the names.
3192           (It is not permitted for some names to be prepended with
3193           exclamation marks and others not.) If the current Debian
3194           host architecture is not in this list and there are no
3195           exclamation marks in the list, or it is in the list with a
3196           prepended exclamation mark, the package name and the
3197           associated version specification are ignored completely for
3198           the purposes of defining the relationships.
3199         </p>
3200
3201         <p>
3202           For example:
3203           <example>
3204             Source: glibc
3205             Build-Depends-Indep: texinfo
3206             Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3207             hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3208           </example>
3209         </p>
3210       </sect>
3211
3212       <sect>
3213         <heading>Binary Dependencies - <tt>Depends</tt>,
3214           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3215           <tt>Pre-Depends</tt>
3216         </heading>
3217
3218         <p>
3219           These five fields are used to declare a dependency
3220           relationship by one package on another.  They appear in the
3221           depending package's control file.
3222         </p>
3223
3224         <p>
3225           All but <tt>Pre-Depends</tt> and <tt>Conflicts</tt>
3226           (discussed below) take effect <em>only</em> when a package
3227           is to be configured.  They do not prevent a package being on
3228           the system in an unconfigured state while its dependencies
3229           are unsatisfied, and it is possible to replace a package
3230           whose dependencies are satisfied and which is properly
3231           installed with a different version whose dependencies are
3232           not and cannot be satisfied; when this is done the depending
3233           package will be left unconfigured (since attempts to
3234           configure it will give errors) and will not function
3235           properly.
3236         </p>
3237
3238         <p>
3239           For this reason packages in an installation run are usually
3240           all unpacked first and all configured later; this gives
3241           later versions of packages with dependencies on later
3242           versions of other packages the opportunity to have their
3243           dependencies satisfied.
3244         </p>
3245
3246         <p>
3247           Thus <tt>Depends</tt> allows package maintainers to impose
3248           an order in which packages should be configured.
3249           <taglist>
3250             <tag><tt>Depends</tt></tag>
3251             <item>
3252
3253               <p>This declares an absolute dependency.
3254               </p>
3255
3256               <p>
3257                 The <tt>Depends</tt> field should be used if the
3258                 depended-on package is required for the depending
3259                 package to provide a significant amount of
3260                 functionality.</p>
3261             </item>
3262
3263             <tag><tt>Recommends</tt></tag>
3264             <item>
3265               <p>This declares a strong, but not absolute, dependency.
3266               </p>
3267
3268               <p>
3269                 The <tt>Recommends</tt> field should list packages
3270                 that would be found together with this one in all but
3271                 unusual installations.</p>
3272             </item>
3273
3274             <tag><tt>Suggests</tt></tag>
3275             <item>
3276
3277               <p>
3278                 This is used to declare that one package may be more
3279                 useful with one or more others.  Using this field
3280                 tells the packaging system and the user that the
3281                 listed packages are related to this one and can
3282                 perhaps enhance its usefulness, but that installing
3283                 this one without them is perfectly reasonable.
3284               </p>
3285             </item>
3286
3287             <tag><tt>Enhances</tt></tag>
3288             <item>
3289               <p>
3290                 This field is similar to Suggests but works in the
3291                 opposite direction. It is used to declare that a
3292                 package can enhance the functionality of another
3293                 package.
3294               </p>
3295             </item>
3296
3297             <tag><tt>Pre-Depends</tt></tag>
3298             <item>
3299
3300               <p>
3301                 This field is like <tt>Depends</tt>, except that it
3302                 also forces <prgn>dpkg</prgn> to complete installation
3303                 of the packages named before even starting the
3304                 installation of the package which declares the
3305                 Pre-dependency.
3306               </p>
3307
3308               <p>
3309                 <tt>Pre-Depends</tt> should be used sparingly,
3310                 preferably only by packages whose premature upgrade or
3311                 installation would hamper the ability of the system to
3312                 continue with any upgrade that might be in progress.
3313               </p>
3314
3315               <p>
3316                 When the package declaring it is being configured, a
3317                 <tt>Pre-Dependency</tt> will be considered satisfied
3318                 only if the depending package has been correctly
3319                 configured, just as if an ordinary <tt>Depends</tt>
3320                 had been used.
3321               </p>
3322
3323               <p>
3324                 However, when a package declaring a Pre-dependency is
3325                 being unpacked the predependency can be satisfied even
3326                 if the depended-on package(s) are only unpacked or
3327                 half-configured, provided that they have been
3328                 configured correctly at some point in the past (and
3329                 not removed or partially removed since).  In this case
3330                 both the previously-configured and currently unpacked
3331                 or half-configured versions must satisfy any version
3332                 clause in the <tt>Pre-Depends</tt> field.
3333               </p>
3334             </item>
3335           </taglist>
3336         </p>
3337         <p>
3338           When selecting which level of dependency to use you should
3339           consider how important the depended-on package is to the
3340           functionality of the one declaring the dependency.  Some
3341           packages are composed of components of varying degrees of
3342           importance.  Such a package should list using
3343           <tt>Depends</tt> the package(s) which are required by the
3344           more important components.  The other components'
3345           requirements may be mentioned as Suggestions or
3346           Recommendations, as appropriate to the components' relative
3347           importance.
3348         </p>
3349
3350
3351       <sect id="conflicts"><heading>Alternative binary packages -
3352           <tt>Conflicts</tt> and <tt>Replaces</tt>
3353         </heading>
3354
3355         <p>
3356           When one binary package declares a conflict with another
3357           <prgn>dpkg</prgn> will refuse to allow them to be installed
3358           on the system at the same time.
3359         </p>
3360
3361         <p>
3362           If one package is to be installed, the other must be removed
3363           first - if the package being installed is marked as
3364           replacing (<ref id="replaces">) the one on the system, or
3365           the one on the system is marked as deselected, or both
3366           packages are marked <tt>Essential</tt>, then
3367           <prgn>dpkg</prgn> will automatically remove the package
3368           which is causing the conflict, otherwise it will halt the
3369           installation of the new package with an error. This
3370           mechanism specifically doesn't work when the installed
3371           package is <tt>Essential</tt>, but the new package is not.
3372         </p>
3373
3374
3375         <p>
3376           A package will not cause a conflict merely because its
3377           configuration files are still installed; it must be at least
3378           half-installed.
3379         </p>
3380
3381         <p>
3382           A special exception is made for packages which declare a
3383           conflict with their own package name, or with a virtual
3384           package which they provide (see below): this does not
3385           prevent their installation, and allows a package to conflict
3386           with others providing a replacement for it.  You use this
3387           feature when you want the package in question to be the only
3388           package providing something.
3389         </p>
3390
3391         <p>
3392           A <tt>Conflicts</tt> entry should almost never have an
3393           `earlier than' version clause.  This would prevent
3394           <prgn>dpkg</prgn> from upgrading or installing the package
3395           which declared such a conflict until the upgrade or removal
3396           of the conflicted-with package had been completed.
3397         </p>
3398       </sect>
3399
3400       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3401         </heading>
3402
3403         <p>
3404           As well as the names of actual (`concrete') packages, the
3405           package relationship fields <tt>Depends</tt>,
3406           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3407           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Conflicts</tt>,
3408           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt> may
3409           mention virtual packages.
3410         </p>
3411
3412         <p>
3413           A virtual package is one which appears in the
3414           <tt>Provides</tt> control file field of another package.
3415           The effect is as if the package(s) which provide a
3416           particular virtual package name had been listed by name
3417           everywhere the virtual package name appears.
3418         </p>
3419
3420         <p>
3421           If there are both a real and a virtual package of the same
3422           name then the dependency may be satisfied (or the conflict
3423           caused) by either the real package or any of the virtual
3424           packages which provide it.  This is so that, for example,
3425           supposing we have
3426           <example>
3427             Package: vm
3428             Depends: emacs
3429           </example>
3430           and someone else releases an xemacs package they can say
3431           <example>
3432             Package: xemacs
3433             Provides: emacs
3434           </example> and all will work in the interim (until a purely
3435           virtual package name is decided on and the <tt>emacs</tt>
3436           and <tt>vm</tt> packages are changed to use it).
3437         </p>
3438
3439         <p>
3440           If a dependency or a conflict has a version number attached
3441           then only real packages will be considered to see whether
3442           the relationship is satisfied (or the prohibition violated,
3443           for a conflict) - it is assumed that a real package which
3444           provides the virtual package is not of the `right' version.
3445           So, a <tt>Provides</tt> field may not contain version
3446           numbers, and the version number of the concrete package
3447           which provides a particular virtual package will not be
3448           looked at when considering a dependency on or conflict with
3449           the virtual package name.
3450         </p>
3451
3452         <p>
3453           It is likely that the ability will be added in a future
3454           release of <prgn>dpkg</prgn> to specify a version number for
3455           each virtual package it provides.  This feature is not yet
3456           present, however, and is expected to be used only
3457           infrequently.
3458         </p>
3459
3460         <p>
3461           If you want to specify which of a set of real packages should be the
3462           default to satisfy a particular dependency on a virtual package, you
3463           should list the real package as an alternative before the virtual.
3464         </p>
3465       </sect>
3466
3467
3468       <sect id="replaces"><heading><tt>Replaces</tt> - overwriting
3469           files and replacing packages
3470         </heading>
3471
3472         <p>
3473           The <tt>Replaces</tt> control file field has two purposes,
3474           which come into play in different situations.
3475         </p>
3476
3477         <p>
3478           Virtual packages (<ref id="virtual">) are not considered
3479           when looking at a <tt>Replaces</tt> field - the packages
3480           declared as being replaced must be mentioned by their real
3481           names.
3482         </p>
3483
3484         <sect1><heading>Overwriting files in other packages
3485           </heading>
3486
3487           <p>
3488             Firstly, as mentioned before, it is usually an error for a
3489             package to contain files which are on the system in
3490             another package, though currently the
3491             <tt>--force-overwrite</tt> flag is enabled by default,
3492             downgrading the error to a warning,
3493           </p>
3494
3495           <p>
3496             If the overwriting package declares that it replaces the
3497             one containing the file being overwritten then
3498             <prgn>dpkg</prgn> will proceed, and replace the file from
3499             the old package with that from the new.  The file will no
3500             longer be listed as `owned' by the old package.
3501           </p>
3502
3503           <p>
3504             If a package is completely replaced in this way, so that
3505             <prgn>dpkg</prgn> does not know of any files it still
3506             contains, it is considered to have disappeared.  It will
3507             be marked as not wanted on the system (selected for
3508             removal) and not installed.  Any conffiles details noted
3509             in the package will be ignored, as they will have been
3510             taken over by the replacing package(s).  The package's
3511             <prgn>postrm</prgn> script will be run to allow the
3512             package to do any final cleanup required.  See <ref
3513                                                                 id="mscriptsinstact">.
3514           </p>
3515
3516           <p>
3517             In the future <prgn>dpkg</prgn> will discard files which
3518             would overwrite those from an already installed package
3519             which declares that it replaces the package being
3520             installed.  This is so that you can install an older
3521             version of a package without problems.
3522           </p>
3523
3524           <p>
3525             This usage of <tt>Replaces</tt> only takes effect when
3526             both packages are at least partially on the system at
3527             once, so that it can only happen if they do not conflict
3528             or if the conflict has been overridden.</p>
3529         </sect1>
3530
3531         <sect1><heading>Replacing whole packages, forcing their
3532             removal
3533           </heading>
3534
3535           <p>
3536             Secondly, <tt>Replaces</tt> allows the packaging system to
3537             resolve which package should be removed when there is a
3538             conflict - see <ref id="conflicts">.  This usage only
3539             takes effect when the two packages <em>do</em> conflict,
3540             so that the two effects do not interfere with each other.
3541           </p>
3542         </sect1>
3543       </sect>
3544
3545       <sect><heading>Relationships between source and binary packages -
3546           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3547           <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3548         </heading>
3549
3550         <p>
3551           A source package may declare a dependency or a conflict on a
3552           binary package.  This is done with the control file fields
3553           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3554           <tt>Build-Conflicts</tt>, and
3555           <tt>Build-Conflicts-Indep</tt>.  Their semantics are that
3556           the dependencies and conflicts they define must be satisfied
3557           (as defined earlier for binary packages), when one of the
3558           targets in <tt>debian/rules</tt> that the particular field
3559           applies to is invoked.
3560
3561           <taglist>
3562             <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3563             <item>
3564               <p>
3565                 The <tt>Build-Depends</tt> and
3566                 <tt>Build-Conflicts</tt> fields apply to the targets
3567                 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>
3568                 and <tt>binary-indep</tt>.
3569               </p>
3570             </item>
3571             <tag><tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt></tag>
3572             <item>
3573               <p>
3574                 The <tt>Build-Depends-Indep</tt> and
3575                 <tt>Build-Conflicts-Indep</tt> fields apply to the
3576                 targets <tt>binary</tt> and <tt>binary-indep</tt>.
3577               </p>
3578             </item>
3579           </taglist>
3580
3581         </p>
3582
3583       </sect>
3584     </chapt>
3585
3586
3587     <chapt id="conffiles"><heading>Configuration file handling
3588       </heading>
3589
3590       <p>
3591         <prgn>dpkg</prgn> can do a certain amount of automatic
3592         handling of package configuration files.
3593       </p>
3594
3595       <p>
3596         Whether this mechanism is appropriate depends on a number of
3597         factors, but basically there are two approaches to any
3598         particular configuration file.
3599       </p>
3600
3601       <p>
3602         The easy method is to ship a best-effort configuration in the
3603         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
3604         handle updates.  If the user is unlikely to want to edit the
3605         file, but you need them to be able to without losing their
3606         changes, and a new package with a changed version of the file
3607         is only released infrequently, this is a good approach.
3608       </p>
3609
3610       <p>
3611         The hard method is to build the configuration file from
3612         scratch in the <prgn>postinst</prgn> script, and to take the
3613         responsibility for fixing any mistakes made in earlier
3614         versions of the package automatically.  This will be
3615         appropriate if the file is likely to need to be different on
3616         each system.
3617       </p>
3618
3619
3620     <chapt id="sharedlibs"><heading>Shared libraries
3621       </heading>
3622
3623       <p>
3624         Packages containing shared libraries must be constructed with
3625         a little care to make sure that the shared library is always
3626         available.  This is especially important for packages whose
3627         shared libraries are vitally important, such as the libc.
3628       </p>
3629
3630       <p>
3631         Firstly, your package should install the shared libraries
3632         under their normal names.  For example, the
3633         <prgn>libgdbm1</prgn> package should install
3634         <tt>libgdbm.so.1.7.3</tt> as
3635         <tt>/usr/lib/libgdbm.so.1.7.3</tt>.  The files should not be
3636         renamed or re-linked by any prerm or postrm scripts;
3637         <prgn>dpkg</prgn> will take care of renaming things safely
3638         without affecting running programs, and attempts to interfere
3639         with this are likely to lead to problems.
3640       </p>
3641
3642       <p>
3643         Secondly, your package should include the symlink that
3644         <prgn>ldconfig</prgn> would create for the shared libraries.
3645         For example, the <prgn>libgdbm1</prgn> package should include
3646         a symlink from <tt>/usr/lib/libgdbm.so.1</tt> to
3647         <tt>libgdbm.so.1.7.3</tt>.  This is needed so that
3648         <prgn>ld.so</prgn> can find the library in between the time
3649         <prgn>dpkg</prgn> installs it and <prgn>ldconfig</prgn> is run
3650         in the <prgn>postinst</prgn> script.  Furthermore, older
3651         versions of the package management system required the library
3652         must be placed before the symlink pointing to it in the
3653         <tt>.deb</tt> file.  This is so that by the time
3654         <prgn>dpkg</prgn> comes to install the symlink (overwriting
3655         the previous symlink pointing at an older version of the
3656         library) the new shared library is already in place.
3657         Unfortunately, this was not not always possible, since it
3658         highly depends on the behavior of the file system. Some
3659         file systems (such as reiserfs) will reorder the files so it
3660         doesn't matter in what order you create them. Starting with
3661         release <tt>1.7.0</tt> <prgn>dpkg</prgn> will reorder the
3662         files itself when building a package.
3663       </p>
3664
3665       <p>
3666         Thirdly, the development package should contain a symlink for
3667         the shared library without a version number.  For example, the
3668         <tt>libgdbm1-dev</tt> package should include a symlink from
3669         <tt>/usr/lib/libgdm.so</tt> to <tt>libgdm.so.1.7.3</tt>.  This
3670         symlink is needed by <prgn>ld</prgn> when compiling packages
3671         as it will only look for <tt>libgdm.so</tt> and
3672         <tt>libgdm.a</tt> when compiling dynamically or statically,
3673         respectively.
3674       </p>
3675
3676       <p>
3677         Any package installing shared libraries in a directory that's listed
3678         in <tt>/etc/ld.so.conf</tt> or in one of the default library
3679         directories of <prgn>ld.so</prgn> (currently, these are <tt>/usr/lib</tt>
3680         and <tt>/lib</tt>) must call <prgn>ldconfig</prgn> in its <prgn>postinst</prgn>
3681         script if and only if the first argument is `configure'. However, it
3682         is important not to call <prgn>ldconfig</prgn> in the postrm or preinst
3683         scripts in the case where the package is being upgraded (see <ref
3684                                                                           id="unpackphase">), as <prgn>ldconfig</prgn> will see the temporary names
3685         that <prgn>dpkg</prgn> uses for the files while it is
3686         installing them and will make the shared library links point
3687         to them, just before <prgn>dpkg</prgn> continues the
3688         installation and removes the links!
3689       </p>
3690
3691       <sect id="shlibs"><heading>The <tt>shlibs</tt> File Format
3692         </heading>
3693
3694         <p>
3695           This file is for use by <prgn>dpkg-shlibdeps</prgn> and is
3696           required when your package provides shared libraries.
3697         </p>
3698
3699         <p>
3700           Each line is of the form:
3701           <example>
3702             <var>library-name</var> <var>version-or-soname</var> <var>dependencies ...</var>
3703           </example>
3704         </p>
3705
3706         <p>
3707           <var>library-name</var> is the name of the shared library,
3708           for example <tt>libc5</tt>.
3709         </p>
3710
3711         <p>
3712           <var>version-or-soname</var> is the soname of the library -
3713           i.e., the thing that must exactly match for the library to be
3714           recognized by <prgn>ld.so</prgn>.  Usually this is the major
3715           version number of the library.
3716         </p>
3717
3718         <p>
3719           <var>dependencies</var> has the same syntax as a dependency
3720           field in a binary package control file.  It should give
3721           details of which package(s) are required to satisfy a binary
3722           built against the version of the library contained in the
3723           package.  See <ref id="depsyntax">.
3724         </p>
3725
3726         <p>
3727           For example, if the package <tt>foo</tt> contains
3728           <tt>libfoo.so.1.2.3</tt>, where the soname of the library is
3729           <tt>libfoo.so.1</tt>, and the first version of the package
3730           which contained a minor number of at least <tt>2.3</tt> was
3731           <var>1.2.3-1</var>, then the package's <var>shlibs</var>
3732           could say:
3733           <example>
3734             libfoo 1    foo (>= 1.2.3-1)
3735           </example>
3736         </p>
3737
3738         <p>
3739           The version-specific dependency is to avoid warnings from
3740           <prgn>ld.so</prgn> about using older shared libraries with
3741           newer binaries.</p>
3742       </sect>
3743
3744       <sect><heading>Further Technical information on
3745           <tt>shlibs</tt></heading>
3746
3747         <sect1><heading><em>What</em> are the <tt>shlibs</tt> files?
3748           </heading>
3749
3750           <p>
3751             The <tt>debian/shlibs</tt> file provides a way of checking
3752             for shared library dependencies on packaged binaries.
3753             They are intended to be used by package maintainers to
3754             make their lives easier.
3755           </p>
3756
3757           <p>
3758             Other <tt>shlibs</tt> files that exist on a Debian system are
3759             <list>
3760               <item> <p><tt>/etc/dpkg/shlibs.default</tt></p></item>
3761               <item> <p><tt>/etc/dpkg/shlibs.override</tt></p></item>
3762               <item> <p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
3763               <item> <p><tt>debian/shlibs.local</tt></p></item>
3764             </list>
3765             These files are used by <prgn>dpkg-shlibdeps</prgn> when
3766             creating a binary package.</p>
3767         </sect1>
3768
3769         <sect1><heading><em>How</em> does <prgn>dpkg-shlibdeps</prgn>
3770             work?
3771           </heading>
3772           <p>
3773             <prgn>dpkg-shlibdeps</prgn>
3774             determines the shared libraries directly
3775             <footnote>
3776               <p>
3777                 It used to do this by calling <prgn>ldd</prgn>, but it
3778                 now calls <prgn>objdump</prgn> to do this. This
3779                 requires a couple of changes in the way that packages
3780                 are built.
3781               </p>
3782               <p>
3783                 A binary <tt>foo</tt> directly uses a library
3784                 <tt>libbar</tt> if it is linked with that
3785                 library. Other libraries that are needed by
3786                 <tt>libbar</tt> are linked indirectly to <tt>foo</tt>,
3787                 and the dynamic linker will load them automatically
3788                 when it loads <tt>libbar</tt>. Running<prgn>ldd</prgn>
3789                 lists all of the libraries used, both directly and
3790                 indirectly; but <prgn>objdump</prgn> only lists the
3791                 directly linked libraries. A package only needs to
3792                 depend on the libraries it is directly linked to,
3793                 since the dependencies for those libraries should
3794                 automatically pull in the other libraries.
3795               </p>
3796               <p>
3797                 This change does mean a change in the way packages are
3798                 build though: currently <prgn>dpkg-shlibdeps</prgn> is
3799                 only run on binaries. But since we will now rely on the
3800                 libraries depending on the libraries they themselves
3801                 need, the packages containing those libraries will
3802                 need to run <prgn>dpkg-shlibdeps</prgn> on the
3803                 libraries.
3804               </p>
3805               <p>
3806                 A good example where this would help us is the current
3807                 mess with multiple version of the <tt>mesa</tt>
3808                 library. With the <prgn>ldd</prgn>-based system, every
3809                 package that uses <tt>mesa</tt> needs to add a
3810                 dependency on <tt>svgalib|svgalib-dummy</tt> in order
3811                 to handle the glide <tt>mesa</tt> variant.  With an
3812                 <prgn>objdump</prgn>-based system this isn't necessary
3813                 anymore and would have saved everyone a lot of work.
3814               </p>
3815               <p>
3816                 Another example: we could update <tt>libimlib</tt>
3817                 with a new version that supports a new graphics format
3818                 called dgf. If we use the old <prgn>ldd</prgn> method,
3819                 every package that uses <tt>libimlib</tt> would need
3820                 to be recompiled so it would also depend on
3821                 <tt>libdgf</tt> or it wouldn't run due to missing
3822                 symbols. However with the new system, packages using
3823                 <tt>libimlib</tt> can rely on <tt>libimlib</tt> itself
3824                 having the dependency on <tt>libdgf</tt> and wouldn't
3825                 need to be updated.
3826               </p>
3827             </footnote>
3828             used by the compiled binaries and libraries passed through
3829             on its command line.
3830           </p>
3831
3832           <p>
3833             For each shared library linked to,
3834             <prgn>dpkg-shlibdeps</prgn> needs to know
3835             <list compact="compact">
3836               <item><p>the package containing the library, and</p></item>
3837               <item><p>the library version number,</p></item>
3838             </list>
3839             and it scans the following files in this order:
3840             <enumlist compact="compact">
3841               <item><p><tt>debian/shlibs.local</tt></p></item>
3842               <item><p><tt>/etc/dpkg/shlibs.override</tt></p></item>
3843               <item><p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
3844               <item><p><tt>/etc/dpkg/shlibs.default</tt></p></item>
3845             </enumlist>
3846           </p>
3847         </sect1>
3848
3849         <sect1><heading><em>Who</em> maintains the various
3850             <tt>shlibs</tt> files?
3851           </heading>
3852
3853           <p>
3854             <list compact="compact">
3855               <item>
3856                 <p><tt>/etc/dpkg/shlibs.default</tt> - the maintainer
3857                   of dpkg</p>
3858               </item>
3859               <item>
3860                 <p>
3861                   <tt>/var/lib/dpkg/info/<var>package</var>.shlibs</tt>
3862                   - the maintainer of each package</p>
3863               </item>
3864               <item>
3865                 <p>
3866                   <tt>/etc/dpkg/shlibs.override</tt> - the local
3867                   system administrator</p>
3868               </item>
3869               <item>
3870                 <p><tt>debian/shlibs.local</tt> - the maintainer of
3871                   the package
3872                 </p>
3873               </item>
3874             </list>
3875             The <tt>shlibs.default</tt> file is managed by
3876             <prgn>dpkg</prgn>. The entries in <tt>shlibs.default</tt>
3877             that are provided by <prgn>dpkg</prgn> are just there to
3878             fix things until the shared library packages all have
3879             <tt>shlibs</tt> files.
3880           </p>
3881         </sect1>
3882
3883         <sect1><heading><em>How</em> to use <prgn>dpkg-shlibdeps</prgn> and
3884             the <tt>shlibs</tt> files
3885           </heading>
3886
3887           <sect2><heading>If your package doesn't provide a shared
3888               library
3889             </heading>
3890
3891             <p>
3892               Put a call to <prgn>dpkg-shlibdeps</prgn> into your
3893               <tt>debian/rules</tt> file.  If your package contains
3894               only binaries (e.g. no scripts) use:
3895               <example>
3896                 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/*
3897               </example>
3898               If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
3899               done. If it does complain you might need to create your
3900               own <tt>debian/shlibs.local</tt> file.</p>
3901           </sect2>
3902
3903           <sect2><heading>If your package provides a shared library
3904             </heading>
3905
3906             <p>
3907               Create a <tt>debian/shlibs</tt> file and let
3908               <tt>debian/rules</tt> install it in the control area:
3909               <example>
3910                 install -m644 debian/shlibs debian/tmp/DEBIAN
3911               </example>
3912               If your package contains additional binaries see above.
3913             </p>
3914           </sect2>
3915         </sect1>
3916
3917         <sect1><heading><em>How</em> to write
3918             <tt>debian/shlibs.local</tt>
3919           </heading>
3920
3921           <p>
3922             This file is intended only as a <em>temporary</em> fix if
3923             your binaries depend on a library which doesn't provide
3924             its own <tt>/var/lib/dpkg/info/*.shlibs</tt> file yet.
3925           </p>
3926
3927           <p>
3928             Let's assume you are packaging a binary <tt>foo</tt>. Your
3929             output in building the package might look like this.
3930             <example>
3931               $ ldd foo
3932               libbar.so.1 => /usr/X11R6/lib/libbar.so.1.0 (0x4001e000)
3933               libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4002c000)
3934               libc.so.6 => /lib/libc.so.6 (0x40114000)
3935               /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
3936             </example>
3937             And when you ran <prgn>dpkg-shlibdeps</prgn>
3938             <example>
3939               $ dpkg-shlibdeps -O foo
3940               dpkg-shlibdeps: warning: unable to find dependency information for shared library libbar
3941               (soname 1, path /usr/X11R6/lib/libbar.so.1.0, dependency field Depends)
3942               shlibs:Depends=libc6 (>= 2.2.1), xlibs (>= 4.0.1-11)
3943             </example>
3944             The <prgn>foo</prgn> binary depends on the
3945             <prgn>libbar</prgn> shared library, but no package seems
3946             to provide a <tt>*.shlibs</tt> file in
3947             <tt>/var/lib/dpkg/info/</tt>.  Let's determine the package
3948             responsible:
3949           </p>
3950
3951           <p>
3952             <example>
3953               $ dpkg -S /usr/X11R6/lib/libbar.so.1.0
3954               bar1: /usr/X11R6/lib/libbar.so.1.0
3955               $ dpkg -s bar1 | grep Version
3956               Version: 1.0-1
3957             </example>
3958             This tells us that the <prgn>bar1</prgn> package, version
3959             1.0-1 is the one we are using. Now we can create our own
3960             <tt>debian/shlibs.local</tt> to temporarily fix the above
3961             problem. Include the following line into your
3962             <tt>debian/shlibs.local</tt> file.
3963             <example>
3964               libbar 1 bar1 (>= 1.0-1)
3965             </example>
3966             Now your package build should work. As soon as the
3967             maintainer of <prgn>libbar1</prgn> provides a
3968             <tt>shlibs</tt> file, you can remove your
3969             <tt>debian/shlibs.local</tt> file.
3970           </p>
3971         </sect1>
3972       </sect>
3973     </chapt>
3974
3975     <chapt><heading>The Operating System</heading>
3976
3977
3978       <sect>
3979         <heading>File system hierarchy</heading>
3980
3981
3982         <sect1>
3983           <heading>Linux File system Structure</heading>
3984
3985           <p>
3986             The location of all installed files and directories must
3987             comply  with the Linux File system Hierarchy Standard
3988             (FHS).  The latest version of this document can be found
3989             alongside this manual or on
3990             <url id="http://www.pathname.com/fhs/">.
3991             Specific questions about following the standard may be
3992             asked on <prgn>debian-devel</prgn>, or referred to Daniel
3993             Quinlan, the FHS coordinator, at
3994             <email>quinlan@pathname.com</email>.</p></sect1>
3995
3996
3997         <sect1>
3998           <heading>Site-specific programs</heading>
3999
4000           <p>
4001             As mandated by the FHS, packages must not place any
4002             files in <tt>/usr/local</tt>, either by putting them in
4003             the file system archive to be unpacked by <prgn>dpkg</prgn>
4004             or by manipulating them in their maintainer scripts.</p>
4005
4006           <p>
4007             However, the package may create empty directories below
4008             <tt>/usr/local</tt> so that the system administrator knows
4009             where to place site-specific files. These directories
4010             should be removed on package removal if they are
4011             empty.</p>
4012
4013           <p>
4014             Note, that this applies only to directories <em>below</em>
4015             <tt>/usr/local</tt>, not <em>in</em>
4016             <tt>/usr/local</tt>. Packages must not create sub-directories
4017             in the directory <tt>/usr/local</tt> itself, except those listed in
4018             FHS, section 4.5. However, you may create directories
4019             below them as you wish. You must not remove any of the
4020             directories listed in 4.5, even if you created them.</p>
4021
4022           <p>
4023             Since <tt>/usr/local</tt> can be mounted read-only from a
4024             remote server, these directories must be created and
4025             removed by the <tt>postinst</tt> and <tt>prerm</tt>
4026             maintainer scripts. These scripts must not fail if either
4027             of these operations fail. (In the future, it will be
4028             possible to tell <prgn>dpkg</prgn> not to unpack files
4029             matching certain patterns, so that the directories can be
4030             included in the <tt>.deb</tt> packages and system
4031             administrators who do not wish these directories in
4032             /usr/local do not need to have them.)</p>
4033
4034           <p>
4035             For example, the <prgn>emacs</prgn> package will contain
4036             <example>
4037               mkdir -p /usr/local/lib/emacs/site-lisp || true
4038             </example>
4039             in the <tt>postinst</tt> script, and
4040             <example>
4041               rmdir /usr/local/lib/emacs/site-lisp || true
4042               rmdir /usr/local/lib/emacs || true
4043             </example>
4044             in the <tt>prerm</tt> script.</p>
4045
4046           <p>
4047             If you do create a directory in <tt>/usr/local</tt> for
4048             local additions to a package, you should ensure that
4049             settings in <tt>/usr/local</tt> take precedence over the
4050             equivalents in <tt>/usr</tt>.</p>
4051
4052           <p>
4053             However, because '/usr/local' and its contents are for
4054             exclusive use of the local administrator, a package must
4055             not rely on the presence or absence of files or
4056             directories in '/usr/local' for normal operation.</p>
4057
4058           <p>
4059             The <tt>/usr/local</tt> directory itself and all the
4060             subdirectories created by the package should (by default) have
4061             permissions 2775 (group-writable and set-group-id) and be
4062             owned by <tt>root.staff</tt>.</p>
4063         </sect1>
4064         <sect1>
4065           <heading>The system-wide mail directory</heading>
4066           <p>
4067             The system-wide mail directory is <tt>/var/mail</tt>. This
4068             directory is part of the base system and should not owned
4069             by any particular mail agents.  The use of the old
4070             location <tt>/var/spool/mail</tt> is deprecated, even
4071             though the spool may still be physically located there.
4072             To maintain partial upgrade compatibility for systems
4073             which have <tt>/var/spool/mail</tt> as their physical mail
4074             spool, packages using <tt>/var/mail</tt> must depend on
4075             either <package>libc6</package> (&gt;= 2.1.3-13), or on
4076             <package>base-files</package> (&gt;= 2.2.0), or on later
4077             versions of either one of these packages.
4078           </p>
4079         </sect1>
4080
4081       </sect>
4082
4083
4084
4085       <sect>
4086         <heading>Users and groups</heading>
4087
4088         <p>
4089           The Debian system can be configured to use either plain or
4090           shadow passwords.</p>
4091
4092         <p>
4093           Some user ids (UIDs) and group ids (GIDs) are reserved
4094           globally for use by certain packages.  Because some packages
4095           need to include files which are owned by these users or
4096           groups, or need the ids compiled into binaries, these ids
4097           must be used on any Debian system only for the purpose for
4098           which they are allocated. This is a serious restriction, and
4099           we should avoid getting in the way of local administration
4100           policies. In particular, many sites allocate users and/or
4101           local system groups starting at 100.</p>
4102
4103         <p>
4104           Apart from this we should have dynamically allocated ids,
4105           which should by default be arranged in some sensible
4106           order--but the behavior should be configurable.</p>
4107
4108         <p>
4109           Packages other than <tt>base-passwd</tt> must not modify
4110           <tt>/etc/passwd</tt>, <tt>/etc/shadow</tt>,
4111           <tt>/etc/group</tt> or <tt>/etc/gshadow</tt>.</p>
4112
4113         <p>
4114           The UID and GID ranges are as follows:
4115           <taglist>
4116             <tag>0-99:</tag>
4117             <item>
4118               <p>
4119                 Globally allocated by the Debian project, the
4120                 same on every Debian system.  These ids will appear in
4121                 the <tt>passwd</tt> and <tt>group</tt> files of all
4122                 Debian systems, new ids in this range being added
4123                 automatically as the <tt>base-passwd</tt> package is
4124                 updated.</p>
4125
4126               <p>
4127                 Packages which need a single statically allocated uid
4128                 or gid should use one of these; their maintainers
4129                 should ask the <tt>base-passwd</tt> maintainer for
4130                 ids.</p>
4131             </item>
4132
4133             <tag>100-999:</tag>
4134             <item>
4135               <p>
4136                 Dynamically allocated system users and groups.
4137                 Packages which need a user or group, but can have this
4138                 user or group allocated dynamically and differently on
4139                 each system, should use `<tt>adduser --system</tt>' to
4140                 create the group and/or user.  <prgn>adduser</prgn>
4141                 will check for the existence of the user or group, and
4142                 if necessary choose an unused id based on the ranges
4143                 specified in <tt>adduser.conf</tt>.</p></item>
4144
4145
4146             <tag>1000-29999:</tag>
4147             <item>
4148               <p>
4149                 Dynamically allocated user accounts.  By default
4150                 <prgn>adduser</prgn> will choose UIDs and GIDs for
4151                 user accounts in this range, though
4152                 <tt>adduser.conf</tt> may be used to modify this
4153                 behavior.</p>
4154             </item>
4155
4156             <tag>30000-59999:</tag>
4157             <item>
4158               <p>Reserved.</p></item>
4159
4160
4161             <tag>60000-64999:</tag>
4162             <item>
4163               <p>
4164                 Globally allocated by the Debian project, but only
4165                 created on demand. The ids are allocated centrally and
4166                 statically, but the actual accounts are only created
4167                 on users' systems on demand.</p>
4168
4169               <p>
4170                 These ids are for packages which are obscure or which
4171                 require many statically-allocated ids.  These packages
4172                 should check for and create the accounts in
4173                 <tt>/etc/passwd</tt> or <tt>/etc/group</tt> (using
4174                 <prgn>adduser</prgn> if it has this facility) if
4175                 necessary.  Packages which are likely to require
4176                 further allocations should have a `hole' left after
4177                 them in the allocation, to give them room to
4178                 grow.</p></item>
4179
4180
4181             <tag>65000-65533:</tag>
4182             <item>
4183               <p>Reserved.</p></item>
4184
4185
4186             <tag>65534:</tag>
4187             <item>
4188               <p>User `<tt>nobody</tt>.' The corresponding gid refers
4189               to the group  `<tt>nogroup</tt>.'</p></item>
4190
4191
4192             <tag>65535:</tag>
4193             <item>
4194               <p>
4195                 <tt>(uid_t)(-1) == (gid_t)(-1)</tt>. NOT TO BE USED,
4196                 because it is the error return sentinel value.</p>
4197             </item>
4198           </taglist>
4199         </p>
4200       </sect>
4201       <sect id="sysvinit">
4202         <heading>System run levels</heading>
4203
4204
4205         <sect1 id="/etc/init.d">
4206           <heading>Introduction</heading>
4207
4208           <p>
4209             The <tt>/etc/init.d</tt> directory contains the scripts
4210             executed by <prgn>init</prgn> at boot time and when init
4211             state (or `runlevel') is changed (see <manref name="init"
4212                                                           section="8">).</p>
4213
4214           <p>
4215             There are at least two different, yet functionally
4216             equivalent, ways of handling these scripts.  For the sake
4217             of simplicity, this document describes only the symbolic
4218             link method. However, it must not be assumed by maintainer
4219             scripts that this method is being used, and any automated
4220             manipulation of the various runlevel behaviours by
4221             maintainer scripts must be performed using `update-rc.d'
4222             as described below and not by manually installing or
4223             removing symlinks.  For  information on the
4224             implementation details of the other method, implemented in
4225             the <tt>file-rc</tt> package, please refer to the
4226             documentation of that package.</p>
4227
4228           <p>
4229             These scripts are referenced by symbolic links in
4230             the <tt>/etc/rc<var>n</var>.d</tt> directories.  When
4231             changing runlevels, <prgn>init</prgn> looks in the
4232             directory <tt>/etc/rc<var>n</var>.d</tt> for the scripts
4233             it should execute, where <var>n</var> is the runlevel that
4234             is being changed to, or `S' for the boot-up scripts.</p>
4235
4236           <p>
4237             The names of the links all have the form
4238             <tt>S<var>mm</var><var>script</var></tt> or
4239             <tt>K<var>mm</var><var>script</var></tt> where
4240             <var>mm</var> is a two-digit number and <var>script</var>
4241             is the name of the script (this should be the same as the
4242             name of the actual script in <tt>/etc/init.d</tt>.</p>
4243
4244           <p>
4245             When <prgn>init</prgn> changes runlevel first the targets
4246             of the links whose names starting with a <tt>K</tt> are
4247             executed, each with the single argument <tt>stop</tt>,
4248             followed by the scripts prefixed with an <tt>S</tt>, each
4249             with the single argument <tt>start</tt>.  The <tt>K</tt>
4250             links are responsible for killing services and the
4251             <tt>S</tt> link for starting services upon entering the
4252             runlevel.</p>
4253
4254           <p>
4255             For example, if we are changing from runlevel 2 to
4256             runlevel 3, init will first execute all of the <tt>K</tt>
4257             prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
4258             all of the <tt>S</tt> prefixed scripts.  The links
4259             starting with <tt>K</tt> will cause the referred-to file
4260             to be executed with an argument of <tt>stop</tt>, and the
4261             <tt>S</tt> links with an argument of <tt>start</tt>.</p>
4262
4263           <p>
4264             The two-digit number <var>mm</var> is used to decide which
4265             order to start and stop things in--low-numbered links have
4266             their scripts run first.  For example, the <tt>K20</tt>
4267             scripts will be executed before the <tt>K30</tt> scripts.
4268             This is used when a certain service must be started before
4269             another.  For example, the name server <prgn>bind</prgn>
4270             might need to be started before the news server
4271             <prgn>inn</prgn> so that <prgn>inn</prgn> can set up its
4272             access lists.  In this case, the script that starts
4273             <prgn>bind</prgn> would have a lower number than the
4274             script that starts <prgn>inn</prgn> so that it runs first:
4275             <example>
4276               /etc/rc2.d/S17bind
4277               /etc/rc2.d/S70inn
4278             </example>
4279           </p>
4280         </sect1>
4281
4282         <sect1>
4283           <heading>Writing the scripts</heading>
4284
4285           <p>
4286             Packages that include daemons for system services should
4287             place scripts in <tt>/etc/init.d</tt> to start or stop
4288             services at boot time or during a change of runlevel.
4289             These scripts should be named
4290             <tt>/etc/init.d/<var>package</var></tt>, and they should
4291             accept one argument, saying what to do:
4292
4293             <taglist>
4294               <tag><tt>start</tt></tag>
4295               <item><p>start the service,</p></item>
4296
4297               <tag><tt>stop</tt></tag>
4298               <item><p>stop the service,</p></item>
4299
4300               <tag><tt>restart</tt></tag>
4301               <item><p>stop and restart the service,</p></item>
4302
4303               <tag><tt>reload</tt></tag>
4304               <item><p>cause the configuration of the service to be
4305                   reloaded without actually stopping and restarting
4306                   the service,</p></item>
4307
4308               <tag><tt>force-reload</tt></tag> <item><p>cause the
4309                   configuration to be reloaded if the service supports
4310                   this, otherwise restart the service.</p></item>
4311             </taglist>
4312
4313             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4314             <tt>force-reload</tt> options should be supported by all
4315             scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
4316             option is optional.</p>
4317
4318           <p>
4319             The <tt>init.d</tt> scripts should ensure that they will
4320             behave sensibly if invoked with <tt>start</tt> when the
4321             service is already running, or with <tt>stop</tt> when it
4322             isn't, and that they don't kill unfortunately-named user
4323             processes.  The best way to achieve this is usually to use
4324             <prgn>start-stop-daemon</prgn>.</p>
4325
4326           <p>
4327             If a service reloads its configuration automatically (as
4328             in the case of <prgn>cron</prgn>, for example), the
4329             <tt>reload</tt> option of the <tt>init.d</tt> script
4330             should behave as if the configuration has been reloaded
4331             successfully.</p>
4332
4333           <p>
4334             These scripts should not fail obscurely when the
4335             configuration files remain but the package has been
4336             removed, as configuration files remain on the system after
4337             the package has been removed. Only when <prgn>dpkg</prgn>
4338             is executed with the <tt>--purge</tt> option will
4339             configuration files be removed. In particular, the init
4340             script itself is usually a configuration file (see
4341             <ref id="init.d notes">), and will remain on the system if
4342             the package is removed but not purged. Therefore, you
4343             should include a <tt>test</tt> statement at the top of the
4344             script, like this:
4345             <example>
4346               test -f <var>program-executed-later-in-script</var> || exit 0
4347             </example></p>
4348
4349           <p>
4350             Often there are some values in the `<tt>init.d</tt>'
4351             scripts that a system administrator will frequently want
4352             to change. While the scripts are frequently conffiles,
4353             modifying them requires that the administrator merge in
4354             their changes each time the package is upgraded and the
4355             conffile changes. To ease the burden on the system
4356             administrator, such configurable values should not be
4357             placed directly in the script.  Instead, they should be
4358             placed in a file in `<tt>/etc/default</tt>', which
4359             typically will have the same base name as the
4360             `<tt>init.d</tt>' script. This extra file can be sourced
4361             by the script when the script runs. It must contain only
4362             variable settings and comments.
4363           </p>
4364
4365           <p>
4366             To ensure that vital configurable values are always
4367             available, the `<tt>init.d</tt>' script should set default
4368             values for each of the shell variables it uses before
4369             sourcing the <tt>/etc/default/</tt> file. Also, since the
4370             `<tt>/etc/default/</tt>' file is often a conffile, the
4371             `<tt>init.d</tt>' script must behave sensibly without
4372             failing if it is deleted.
4373           </p>
4374
4375         </sect1>
4376
4377         <sect1>
4378           <heading>Managing the links</heading>
4379
4380           <p>
4381             The program <prgn>update-rc.d</prgn> is provided to make
4382             it easier for package maintainers to arrange for the
4383             proper creation and removal of
4384             <tt>/etc/rc<var>n</var>.d</tt> symbolic links, or their
4385             functional equivalent if another method is being used.
4386             This may be used by maintainers in their packages'
4387             <tt>postinst</tt> and <tt>postrm</tt> scripts.</p>
4388
4389           <p>
4390             You must use this script to make changes to
4391             <tt>/etc/rc<var>n</var>.d</tt> and <em>never</em> either
4392             include any <tt>/etc/rc<var>n</var>.d</tt> symbolic links
4393             in the actual archive or manually create or remove the
4394             symbolic links in maintainer scripts.  (The latter will
4395             fail if an alternative method of maintaining runlevel
4396             information is being used.)</p>
4397
4398           <p>
4399             By default <prgn>update-rc.d</prgn> will start services in
4400             each of the multi-user state runlevels (2, 3, 4, and 5)
4401             and stop them in the halt runlevel (0), the single-user
4402             runlevel (1) and the reboot runlevel (6).  The system
4403             administrator will have the opportunity to customize
4404             runlevels by either running <prgn>update-rc.d</prgn>, by
4405             simply adding, moving, or removing the symbolic links in
4406             <tt>/etc/rc<var>n</var>.d</tt> if symbolic links are being
4407             used, or by modifying <tt>/etc/runlevel.conf</tt> if the
4408             <tt>file-rc</tt> method is being used.</p>
4409
4410           <p>
4411             To get the default behavior for your package, put in your
4412             <tt>postinst</tt> script
4413             <example>
4414               update-rc.d <var>package</var> defaults &gt;/dev/null
4415             </example>
4416             and in your <tt>postrm</tt>
4417             <example>
4418               if [ purge = "$1" ]; then
4419               update-rc.d <var>package</var> remove &gt;/dev/null
4420               fi
4421             </example></p>
4422
4423           <p>
4424             This will use a default sequence number of 20.  If it does
4425             not matter when or in which order the script is run, use
4426             this default.  If it does, then you should talk to the
4427             maintainer of the <prgn>sysvinit</prgn> package or post to
4428             <tt>debian-devel</tt>, and they will help you choose a
4429             number.</p>
4430
4431           <p>
4432             For more information about using <tt>update-rc.d</tt>,
4433             please consult its manpage <manref name="update-rc.d"
4434                                                section="8">.</p></sect1>
4435
4436
4437         <sect1>
4438           <heading>Boot-time initialization</heading>
4439
4440           <p>
4441             There used to be another directory, <tt>/etc/rc.boot</tt>,
4442             which contained scripts which were run once per machine
4443             boot. This has been deprecated in favour of links from
4444             <tt>/etc/rcS.d</tt> to files in <tt>/etc/init.d</tt> as
4445             described in <ref id="/etc/init.d">.  Packages must not
4446             place files in <tt>/etc/rc.boot</tt>.</p>
4447
4448         <sect1 id="init.d notes">
4449           <heading>Notes</heading>
4450
4451           <p>
4452             <em>Do not</em> include the
4453             <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in the
4454             <tt>.deb</tt> file system archive!  <em>This will cause
4455               problems!</em> You must create them with
4456             <prgn>update-rc.d</prgn>, as above.</p>
4457
4458           <p>
4459             <em>Do not</em> include the
4460             <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in
4461             <prgn>dpkg</prgn>'s conffiles list!  <em>This will cause
4462               problems!</em> You should, however, treat the
4463             <tt>/etc/init.d</tt> scripts as configuration files,
4464             either by marking them as conffiles or managing them
4465             correctly in the maintainer scripts (see
4466             <ref id="config files">). (This is important since we want
4467             to give the local system administrator the chance to adapt
4468             the scripts to the local system--e.g., to disable a
4469             service without de-installing the package, or to specify
4470             some special command line options when starting a
4471             service--while making sure her changes aren't lost during
4472             the next package upgrade.)</p>
4473         </sect1>
4474
4475         <sect1>
4476           <heading>Example</heading>
4477
4478           <p>
4479             The <prgn>bind</prgn> DNS (nameserver) package wants to
4480             make sure that the nameserver is running in multiuser
4481             runlevels, and is properly shut down with the system.  It
4482             puts a script in <tt>/etc/init.d</tt>, naming the script
4483             appropriately <tt>bind</tt>.  As you can see, the script
4484             interprets the argument <tt>reload</tt> to send the
4485             nameserver a <tt>HUP</tt> signal (causing it to reload its
4486             configuration); this way the user can say
4487             <tt>/etc/init.d/bind reload</tt> to reload the name
4488             server.  The script has one configurable value, which can
4489             be used to pass parameters to the named program at
4490             startup.
4491           </p>
4492
4493           <p>
4494             <example>
4495               #!/bin/sh
4496               #
4497               # Original version by Robert Leslie
4498               # &lt;rob@mars.org&gt;, edited by iwj and cs
4499
4500               test -x /usr/sbin/named || exit 0
4501
4502               # Source defaults file.
4503               PARAMS=''
4504               if [ -f /etc/default/bind ]; then
4505                 . /etc/default/bind
4506               fi
4507
4508
4509               case "$1" in
4510               start)
4511               echo -n "Starting domain name service: named"
4512               start-stop-daemon --start --quiet --exec /usr/sbin/named \
4513                                 -- $PARAMS
4514               echo "."
4515               ;;
4516               stop)
4517               echo -n "Stopping domain name service: named"
4518               start-stop-daemon --stop --quiet  \
4519               --pidfile /var/run/named.pid --exec /usr/sbin/named
4520               echo "."
4521               ;;
4522               restart)
4523               echo -n "Restarting domain name service: named"
4524               start-stop-daemon --stop --quiet  \
4525               --pidfile /var/run/named.pid --exec /usr/sbin/named
4526               start-stop-daemon --start --verbose --exec /usr/sbin/named \
4527                                 -- $PARAMS
4528               echo "."
4529               ;;
4530               force-reload|reload)
4531               echo -n "Reloading configuration of domain name service: named"
4532               start-stop-daemon --stop --signal 1 --quiet  \
4533               --pidfile /var/run/named.pid --exec /usr/sbin/named
4534               echo "."
4535               ;;
4536               *)
4537               echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
4538               exit 1
4539               ;;
4540               esac
4541
4542               exit 0
4543             </example>
4544           </p>
4545
4546           <p>
4547             Complementing the above init script is a file
4548             '<tt>/etc/default/bind</tt>', which contains configurable
4549             parameters used by the script.
4550           </p>
4551           <p>
4552             <example>
4553               # Specified parameters to pass to named. See named(8).
4554               # You may uncomment the following line, and edit to taste.
4555               #PARAMS="-u nobody"
4556             </example>
4557           </p>
4558
4559           <p>
4560             Another example on which to base your <tt>/etc/init.d</tt>
4561             scripts is in <tt>/etc/init.d/skeleton</tt>.</p>
4562
4563           <p>
4564             If this package is happy with the default setup from
4565             <prgn>update-rc.d</prgn>, namely an ordering number of 20
4566             and having named running in all runlevels, it can say in
4567             its <tt>postinst</tt>:
4568             <example>
4569               update-rc.d bind defaults >/dev/null
4570             </example>
4571             And in its <tt>postrm</tt>, to remove the links when the
4572             package is purged:
4573             <example>
4574               if [ purge = "$1" ]; then
4575               update-rc.d bind remove >/dev/null
4576               fi
4577             </example></p>
4578         </sect1></sect>
4579
4580       <sect>
4581         <heading>Cron jobs</heading>
4582
4583         <p>
4584           Packages must not modify the configuration file
4585           <tt>/etc/crontab</tt>, and they must not modify the files in
4586           <tt>/var/spool/cron/crontabs</tt>.</p>
4587
4588         <p>
4589           If a package wants to install a job that has to be executed
4590           via cron, it should place a file with the name of the
4591           package in one of the following directories:
4592           <example>
4593             /etc/cron.daily
4594             /etc/cron.weekly
4595             /etc/cron.monthly
4596           </example>
4597           As these directory names imply, the files within them are
4598           executed on a daily, weekly, or monthly basis,
4599           respectively. The exact times are listed in
4600           <tt>/etc/crontab</tt>.</p>
4601
4602         <p>
4603           All files installed in any of these directories must be
4604           scripts (shell scripts, Perl scripts, etc.) so that they can
4605           easily be modified by the local system administrator. In
4606           addition, they should be treated as configuration files.</p>
4607
4608         <p>
4609           If a certain job has to be executed more frequently than
4610           daily, the package should install a file
4611           <tt>/etc/cron.d/<var>package-name</var></tt>. This file uses
4612           the same syntax as <tt>/etc/crontab</tt> and is processed by
4613           <prgn>cron</prgn> automatically. The file must also be
4614           treated as a configuration file. (Note, that entries in the
4615           <tt>/etc/cron.d</tt> directory are not handled by
4616           <prgn>anacron</prgn>. Thus, you should only use this
4617           directory for jobs which may be skipped if the system is not
4618           running.)</p>
4619
4620         <p>
4621           The scripts or crontab entries in these directories should
4622           check if all necessary programs are installed before they
4623           try to execute them. Otherwise, problems will arise when a
4624           package was removed but not purged since configuration files
4625           are kept on the system in this situation.</p>
4626       </sect>
4627
4628       <sect>
4629         <heading>Console messages</heading>
4630
4631         <p>
4632           This section describes different formats for messages
4633           written to standard output by the <tt>/etc/init.d</tt>
4634           scripts. The intent is to improve the consistency of
4635           Debian's startup and shutdown look and feel.</p>
4636
4637         <p>
4638           Please look very careful at the details. We want to get the
4639           messages to look exactly the same way concerning spaces,
4640           punctuation, and case of letters.</p>
4641
4642         <p>
4643           Here is a list of overall rules that you should use when you
4644           create output messages. They can be useful if you have a
4645           non-standard message that isn't covered in the sections
4646           below.</p>
4647
4648         <p>
4649           <list>
4650             <item>
4651               <p>
4652                 Every message should cover one line, start with a
4653                 capital letter and end with a period `.'.</p></item>
4654
4655
4656             <item>
4657               <p>
4658                 If you want to express that the computer is working on
4659                 something (performing a specific task, not starting or
4660                 stopping a program), we use an ``ellipsis'', namely
4661                 three dots `...'. Note that we don't insert spaces in
4662                 front of or behind the dots.  If the task has been
4663                 completed we write `done.' and a line feed.</p></item>
4664
4665
4666             <item>
4667               <p>
4668                 Design your messages as if the computer is telling you
4669                 what he is doing (let him be polite :-) but don't
4670                 mention ``him'' directly.  For example, if you think
4671                 of saying
4672                 <example>
4673                   I'm starting network daemons: nfsd mountd.
4674                 </example>
4675                 just say
4676                 <example>
4677                   Starting network daemons: nfsd mountd.
4678                 </example></p></item>
4679           </list></p>
4680
4681         <p>
4682           The following formats should be used</p>
4683
4684         <p>
4685           <list>
4686             <item>
4687               <p>when daemons get started.</p>
4688
4689               <p>
4690                 Use this format if your script starts one or more
4691                 daemons.  The output should look like this (a single
4692                 line, no leading spaces):
4693                 <example>
4694                   Starting &lt;description&gt;: &lt;daemon-1&gt; &lt;daemon-2&gt; &lt;...&gt; &lt;daemon-n&gt;.
4695                 </example>
4696                 The &lt;description&gt; should describe the subsystem
4697                 the daemon or set of daemons are part of, while
4698                 &lt;daemon-1&gt; up to &lt;daemon-n&gt; denote each
4699                 daemon's name (typically the file name of the
4700                 program).</p>
4701
4702               <p>
4703                 For example, the output of /etc/init.d/lpd would look like:
4704                 <example>
4705                   Starting printer spooler: lpd.
4706                 </example></p>
4707
4708               <p>
4709                 This can be achieved by saying
4710                 <example>
4711                   echo -n "Starting printer spooler: lpd"
4712                   start-stop-daemon --start --quiet lpd
4713                   echo "."
4714                 </example>
4715                 in the script. If you have more than one daemon to
4716                 start, you should do the following:
4717                 <example>
4718                   echo -n "Starting remote file system services:"
4719                   echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
4720                   echo -n " mountd"; start-stop-daemon --start --quiet mountd
4721                   echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
4722                   echo "."
4723                 </example>
4724                 This makes it possible for the user to see what takes
4725                 so long and when the final daemon has been
4726                 started. You should be careful where to put spaces: In the
4727                 example above the system administrator can easily
4728                 comment out a line if he don't wants to start a
4729                 specific daemon, while the displayed message still
4730                 looks good.</p></item>
4731
4732
4733             <item>
4734               <p>when something needs to be configured.</p>
4735
4736               <p>
4737                 If you have to set up different parameters of the
4738                 system upon boot up, you should use this format:
4739                 <example>
4740                   Setting &lt;parameter&gt; to `&lt;value&gt;'.
4741                 </example></p>
4742
4743               <p>
4744                 You can use the following echo statement to get the quotes right:
4745                 <example>
4746                   echo "Setting DNS domainname to \`"value"'."
4747                 </example></p>
4748
4749               <p>
4750                 Note that the left quotation mark (`) is different
4751                 from the right (').</p></item>
4752
4753             <item>
4754               <p>when a daemon is stopped.</p>
4755
4756               <p>
4757                 When you stop a daemon you should issue a message
4758                 similar to the startup message, except that `Starting'
4759                 is replaced with `Stopping'.</p>
4760
4761               <p>
4762                 So stopping the printer daemon will like like this:
4763                 <example>
4764                   Stopping printer spooler: lpd.
4765                 </example></p></item>
4766
4767             <item>
4768               <p>when something is executed.</p>
4769
4770               <p>
4771                 There are several examples where you have to run a
4772                 program at system startup or shutdown to perform a
4773                 specific task. For example, setting the system's clock
4774                 via `netdate' or killing all processes when the system
4775                 comes down. Your message should like this:
4776                 <example>
4777                   Doing something very useful...done.
4778                 </example>
4779                 You should print the `done.' right after the job has been completed,
4780                 so that the user gets informed why he has to wait. You can get this
4781                 behavior by saying
4782                 <example>
4783                   echo -n "Doing something very useful..."
4784                   do_something
4785                   echo "done."
4786                 </example>
4787                 in your script.</p></item>
4788
4789             <item>
4790               <p>when the configuration is reloaded.</p>
4791
4792               <p>
4793                 When a daemon is forced to reload its configuration
4794                 files you should use the following format:
4795                 <example>
4796                   Reloading &lt;daemon's-name&gt; configuration...done.
4797                 </example></p></item>
4798
4799             <item>
4800               <p>when none of the above rules apply.</p>
4801
4802               <p>
4803                 If you have to print a message that doesn't fit into
4804                 the styles described above, you can use something
4805                 appropriate, but please have a look at the overall
4806                 rules listed above.</p></item>
4807           </list></p></sect>
4808
4809
4810       <sect>
4811         <heading>Menus</heading>
4812
4813         <p>
4814           Menu entries should follow the current menu policy as
4815           defined in the file <ftpsite>ftp.debian.org</ftpsite> in
4816           <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>
4817           or your local mirror. In addition, it is included in the
4818           <tt>debian-policy</tt> package.
4819         </p>
4820
4821         <p>
4822           The Debian <tt>menu</tt> packages provides a unique
4823           interface between packages providing applications and
4824           documents, and <em>menu programs</em> (either X window
4825           managers or text-based menu programs as
4826           <prgn>pdmenu</prgn>).</p>
4827
4828         <p>
4829           All packages that provide applications that need not be
4830           passed any special command line arguments for normal
4831           operation should register a menu entry for those
4832           applications, so that users of the <tt>menu</tt> package
4833           will automatically get menu entries in their window
4834           managers, as well in shells like <tt>pdmenu</tt>.</p>
4835
4836         <p>
4837           Please refer to the <em>Debian Menu System</em> document
4838           that comes with the <tt>menu</tt> package for information
4839           about how to register your applications and web
4840           documents.</p>
4841       </sect>
4842
4843
4844       <sect>
4845         <heading>Multimedia handlers</heading>
4846
4847         <p>
4848           Packages which provide the ability to view/show/play,
4849           compose, edit or print MIME types should register themselves
4850           as such following the current MIME support policy as defined
4851           in the file found on <ftpsite>ftp.debian.org</ftpsite> in
4852           <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>
4853           or your local mirror. In addition, it is included in the
4854           <tt>debian-policy</tt> package.
4855         </p>
4856
4857         <p>
4858           MIME (Multipurpose Internet Mail Extensions, RFC 1521) is a
4859           mechanism for encoding files and data streams and providing
4860           meta-information about them, in particular their type (e.g.
4861           audio or video) and format (e.g. PNG, HTML, MP3).
4862         </p>
4863
4864         <p>
4865           Registration of MIME type handlers allows programs like mail
4866           user agents and web browsers to to invoke these handlers to
4867           view, edit or display MIME types they don't support
4868           directly.
4869         </p>
4870       </sect>
4871
4872       <sect>
4873         <heading>Keyboard configuration</heading>
4874
4875         <p>
4876           To achieve a consistent keyboard configuration (i.e., all
4877           applications interpret a keyboard event the same way) all
4878           programs in the Debian distribution must be configured to
4879           comply with the following guidelines.</p>
4880
4881         <p>
4882           Here is a list that contains certain keys and their interpretation:
4883
4884           <taglist>
4885             <tag><tt>&lt;--</tt></tag>
4886             <item><p>delete the character to the left of the cursor</p></item>
4887
4888             <tag><tt>Delete</tt></tag>
4889             <item><p>delete the character to the right of the cursor</p></item>
4890
4891             <tag><tt>Control+H</tt></tag>
4892             <item><p>emacs: the help prefix</p></item>
4893           </taglist>
4894
4895           The interpretation of any keyboard events should be independent
4896           of the terminal that's used, be it a virtual console, an X
4897           terminal emulator, an rlogin/telnet session, etc.</p>
4898
4899         <p>
4900           The following list explains how the different programs
4901           should be set up to achieve this:</p>
4902
4903         <p>
4904           <list compact="compact">
4905             <item><p>`<tt>&lt;--</tt>' generates KB_Backspace in
4906                 X.</p></item>
4907
4908             <item><p>`<tt>Delete</tt>' generates KB_Delete in X.</p></item>
4909
4910             <item>
4911               <p>
4912                 X translations are set up to make KB_Backspace
4913                 generate ASCII DEL, and to make KB_Delete generate
4914                 <tt>ESC [ 3 ~</tt> (this is the vt220 escape code for
4915                 the `delete character' key).  This must be done by
4916                 loading the resources using xrdb on all local X
4917                 displays, not using the application defaults, so that
4918                 the translation resources used correspond to the
4919                 xmodmap settings.</p></item>
4920
4921             <item>
4922               <p>
4923                 The Linux console is configured to make
4924                 `<tt>&lt;--</tt>' generate DEL, and `Delete' generate
4925                 <tt>ESC [ 3 ~</tt> (this is the case at the
4926                 moment).</p></item>
4927
4928             <item><p>
4929                 X applications are configured so that Backspace
4930                 deletes left, and Delete deletes right.  Motif
4931                 applications already work like this.</p></item>
4932
4933             <item><p>stty erase <tt>^?</tt> .</p></item>
4934
4935             <item><p>
4936                 The `xterm' terminfo entry should have <tt>ESC [ 3
4937                   ~</tt> for kdch1, just like TERM=linux and
4938                 TERM=vt220.</p></item>
4939
4940             <item><p>
4941                 Emacs is programmed to map KB_Backspace or the `stty
4942                 erase' character to delete-backward-char, and
4943                 KB_Delete or kdch1 to delete-forward-char, and
4944                 <tt>^H</tt> to help as always.</p></item>
4945
4946             <item><p>
4947                 Other applications use the `stty erase' character and
4948                 kdch1 for the two delete keys, with ASCII DEL being
4949                 `delete previous character' and kdch1 being `delete
4950                 character under cursor'.</p></item>
4951           </list></p>
4952
4953         <p>
4954           This will solve the problem except for:</p>
4955
4956         <p>
4957           <list compact="compact">
4958             <item><p>
4959                 Some terminals have a <tt>&lt;--</tt> key that cannot
4960                 be made to produce anything except <tt>^H</tt>.  On
4961                 these terminals Emacs help will be unavailable on
4962                 <tt>^H</tt> (assuming that the `stty erase' character
4963                 takes precedence in Emacs, and has been set
4964                 correctly).  M-x help or F1 (if available) can be used
4965                 instead.</p></item>
4966
4967             <item><p>
4968                 Some operating systems use <tt>^H</tt> for stty erase.
4969                 However, modern telnet versions and all rlogin
4970                 versions propagate stty settings, and almost all UNIX
4971                 versions honour stty erase.  Where the stty settings
4972                 are not propagated correctly things can be made to
4973                 work by using stty manually.</p></item>
4974
4975             <item><p>
4976                 Some systems (including previous Debian versions) use
4977                 xmodmap to arrange for both <tt>&lt;--</tt> and Delete
4978                 to generate KB_Delete.  We can change the behavior
4979                 of their X clients via the same X resources that we
4980                 use to do it for our own, or have our clients be
4981                 configured via their resources when things are the
4982                 other way around.  On displays configured like this
4983                 Delete will not work, but <tt>&lt;--</tt>
4984                 will.</p></item>
4985
4986             <item><p>
4987                 Some operating systems have different kdch1 settings
4988                 in their terminfo for xterm and others.  On these
4989                 systems the Delete key will not work correctly when
4990                 you log in from a system conforming to our policy, but
4991                 <tt>&lt;--</tt> will.</p></item>
4992           </list>
4993         </p>
4994       </sect>
4995
4996
4997       <sect>
4998         <heading>Environment variables</heading>
4999
5000         <p>
5001           A program must not depend on environment variables to get
5002           reasonable defaults. (That's because these environment
5003           variables would have to be set in a system-wide
5004           configuration file like /etc/profile, which is not supported
5005           by all shells.)</p>
5006
5007         <p>
5008           If a program usually depends on environment variables for its
5009           configuration, the program should be changed to fall back to
5010           a reasonable default configuration if these environment
5011           variables are not present. If this cannot be done easily
5012           (e.g., if the source code of a non-free program is not
5013           available), the program must be replaced by a small
5014           `wrapper' shell script which sets the environment variables
5015           if they are not already defined, and calls the original program.</p>
5016
5017         <p>
5018           Here is an example of a wrapper script for this purpose:
5019
5020           <example>
5021             #!/bin/sh
5022             BAR=${BAR:-/var/lib/fubar}
5023             export BAR
5024             exec /usr/lib/foo/foo "$@"
5025           </example></p>
5026
5027         <p>
5028           Furthermore, as <tt>/etc/profile</tt> is a configuration
5029           file of the <prgn>base-files</prgn> package, other packages must not
5030           put any environment variables or other commands into that
5031           file.</p>
5032       </sect>
5033     </chapt>
5034     <chapt>
5035       <heading>Files</heading>
5036
5037
5038       <sect>
5039         <heading>Binaries</heading>
5040
5041         <p>
5042           Two different packages must not install programs with
5043           different functionality but with the same filenames. (The
5044           case of two programs having the same functionality but
5045           different implementations is handled via `alternatives.')
5046           If this case happens, one of the programs must be
5047           renamed. The maintainers should report this to the
5048           developers' mailing and try to find a consensus about
5049           which package will have to be renamed.  If a consensus can
5050           not be reached, <em>both</em> programs must be
5051           renamed.</p>
5052
5053         <p>
5054           Generally the following compilation parameters should be used:
5055           <example>
5056             CC = gcc
5057             CFLAGS = -O2 -Wall # sane warning options vary between programs
5058             LDFLAGS = # none
5059             install -s # (or use strip on the files in debian/tmp)
5060           </example></p>
5061
5062         <p>
5063           Note that by default all installed binaries should be stripped,
5064           either by using the <tt>-s</tt> flag to
5065           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5066           the binaries after they have been copied into
5067           <tt>debian/tmp</tt> but before the tree is made into a
5068           package.</p>
5069
5070         <p>
5071           The <tt>-N</tt> flag should not be used.  On a.out systems
5072           it may have been useful for some very small binaries, but
5073           for ELF it has no good effect.</p>
5074
5075         <p>
5076           Debugging symbols are useful for error diagnosis,
5077           investigation of core dumps (which may be submitted by users
5078           in bug reports), or testing and developing the
5079           software. Therefore it is recommended to support building
5080           the package with debugging information through the following
5081           interface: If the environment variable
5082           <tt>DEB_BUILD_OPTIONS</tt> contains the string
5083           <tt>debug</tt>, compile the software with debugging
5084           information (usually this involves adding the <tt>-g</tt>
5085           flag to <tt>CFLAGS</tt>). This allows the generation of a
5086           build tree with debugging information. If the environment
5087           variable <tt>DEB_BUILD_OPTIONS</tt> contains the string
5088           <tt>nostrip</tt>, do not strip the files at installation
5089           time. This allows one to generate a package with debugging
5090           information included. The following makefile snippet is only
5091           an example of how one may test for either condition:
5092           <footnote>
5093             <p>
5094               Rationale: Building by default with -g causes more
5095               wasted CPU cycles since the information is stripped away
5096               anyway. The package can by default build without -g if
5097               it also provides a mechanism to easily be rebuilt with
5098               debugging information. This can be done by providing a
5099               "build-debug" make target, or allowing the user to
5100               specify "DEB_BUILD_OPTIONS=debug" in the environment while
5101               compiling that package.
5102             </p>
5103             <p>Now this has several added benefits:
5104               <list>
5105                 <item>
5106                   <p>
5107                     It is actually easier to build debugging bins and
5108                     libraries this way (no more editing debian/rules
5109                     or similar) since it provides a documented way of
5110                     getting this type of build.</p>
5111                 </item>
5112                 <item>
5113                   <p>
5114                     There will be much less wasted CPU time for the
5115                     autobuilders since not having debugging
5116                     information (and hence also not having to strip
5117                     it) will increase the speed of compiles. This
5118                     skips an entire pass of the compiler.
5119                   </p>
5120                 </item>
5121               </list>
5122             </p>
5123           </footnote>
5124
5125
5126           <example>
5127             CFLAGS = -O2 -Wall
5128             INSTALL = install
5129             INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
5130             INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
5131             INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
5132             INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
5133
5134             ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
5135             CFLAGS += -g
5136             endif
5137             ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5138             INSTALL_PROGRAM += -s
5139             endif
5140           </example>
5141
5142           Please note that the above example is merely informative,
5143           and is not a policy mandate. You may have to massage this
5144           example in order to make it work for your package.
5145
5146         </p>
5147
5148         <p>
5149           It is up to the package maintainer to decide what
5150           compilation options are best for the package.  Certain
5151           binaries (such as computationally-intensive programs) will
5152           function better with certain flags (<tt>-O3</tt>, for
5153           example); feel free to use them.  Please use good judgment
5154           here.  Don't use flags for the sake of it; only use them
5155           if there is good reason to do so.  Feel free to override
5156           the upstream author's ideas about which compilation
5157           options are best--they are often inappropriate for our
5158           environment.</p></sect>
5159
5160
5161       <sect>
5162         <heading>Libraries</heading>
5163
5164         <p>
5165           All libraries must have a shared version in the lib
5166           package and a static version in the lib-dev package. The
5167           shared version must be compiled with <tt>-fPIC</tt>, and
5168           the static version must not be. In other words, each
5169           <tt>*.c</tt> file will need to be compiled twice.</p>
5170
5171         <p>
5172           You must specify the gcc option <tt>-D_REENTRANT</tt>
5173           when building a library (either static or shared) to make
5174           the library compatible with LinuxThreads.</p>
5175
5176         <p>
5177           Note that all installed shared libraries should be
5178           stripped with
5179           <example>
5180             strip --strip-unneeded &lt;your-lib&gt;
5181           </example>
5182           (The option `--strip-unneeded' makes <tt>strip</tt> remove
5183           only the symbols which aren't needed for relocation
5184           processing.)  Shared libraries can function perfectly well
5185           when stripped, since the symbols for dynamic linking are
5186           in a separate part of the ELF object file.</p>
5187
5188         <p>
5189           Note that under some circumstances it may be useful to
5190           install a shared library unstripped, for example when
5191           building a separate package to support debugging.
5192         </p>
5193
5194         <p>
5195           An ever increasing number of packages are using libtool to
5196           do their linking. The latest GNU libtools (>= 1.3a) can take
5197           advantage of the metadata in the installed libtool archive
5198           files (`*.la'). The main advantage of libtool's .la files is
5199           that it allows libtool to store and subsequently access
5200           metadata with respect to the libraries it builds.  libtool
5201           will search for those files, which contain a lot of useful
5202           information about a library (e.g. dependency libraries for
5203           static linking). Also, they're <em>essential</em> for
5204           programs using libltdl.
5205         </p>
5206
5207         <p>
5208           Certainly libtool is fully capable of linking against shared
5209           libraries which don't have .la files, but being a mere shell
5210           script it can add considerably to the build time of a
5211           libtool using package if that shell-script has to derive all
5212           this information from first principles for each library every
5213           time it is linked. With the advent of libtool-1.4 (and to a
5214           lesser extent libtool-1.3), the .la files will also store
5215           information about inter-library dependencies which cannot
5216           necessarily be derived after the .la file is deleted.
5217         </p>
5218
5219         <p>
5220           Packages that use libtool to create shared libraries should
5221           include the <em>.la</em> files in the <em>-dev</em>
5222           packages, with the exception that if the package relies on
5223           libtool's <em>libltdl</em> library, in which case the .la
5224           files must go in the run-time library package.  This is a
5225           good idea in general, and especially for static linking
5226           issues.
5227         </p>
5228
5229         <p>
5230           You must make sure that you use only released versions of
5231           shared libraries to build your packages; otherwise other
5232           users will not be able to run your binaries
5233           properly. Producing source packages that depend on
5234           unreleased compilers is also usually a bad
5235           idea.
5236         </p>
5237       </sect>
5238
5239
5240       <sect>
5241         <heading>Shared libraries</heading>
5242
5243         <p>
5244           Packages involving shared libraries should be split up
5245           into several binary packages.</p>
5246
5247         <p>
5248           For a straightforward library which has a development
5249           environment and a runtime kit including just shared
5250           libraries you need to create two packages:
5251           <tt><var>libraryname</var><var>soname</var></tt>
5252           (<var>soname</var> is the shared object name of the shared
5253           library--it's the thing that has to match exactly between
5254           building an executable and running it for the dynamic
5255           linker to be able run the program; usually the
5256           <var>soname</var> is the major number of the library) and
5257           <tt><var>libraryname</var><var>soname</var>-dev</tt>.</p>
5258
5259         <p>
5260           If you prefer only to support one development version at a
5261           time you may name the development package
5262           <tt><var>libraryname</var>-dev</tt>; otherwise you may
5263           wish to use <prgn>dpkg</prgn>'s conflicts mechanism to
5264           ensure that the user only installs one development version
5265           at a time (after all, different development versions are
5266           likely to have the same header files in them, causing a
5267           filename clash if both are installed).  Typically the
5268           development version should  also have an exact version
5269           dependency on the runtime library, to make sure that
5270           compilation and linking happens correctly.</p>
5271
5272         <p>
5273           Packages which use the shared library should have a
5274           dependency on the name of the shared library package,
5275           <tt><var>libraryname</var><var>soname</var></tt>.  When
5276           the <var>soname</var> changes you can have both versions
5277           of the library installed while moving from the old library
5278           to the new.</p>
5279
5280         <p>
5281           If your package has some run-time support programs which
5282           use the shared library you must not put them in
5283           the shared library package.  If you do that then you won't
5284           be able to install several versions of the shared library
5285           without getting filename clashes.  Instead, either create
5286           a third package for the runtime binaries (this package
5287           might typically be named
5288           <tt><var>libraryname</var>-runtime</tt>--note the absence
5289           of the <var>soname</var> in the package name) or if the
5290           development package is small include them in there.</p>
5291
5292         <p>
5293           If you have several shared libraries built from the same
5294           source tree you may lump them all together into a single
5295           shared library package, provided that you change all their
5296           <var>soname</var>s at once (so that you don't get filename
5297           clashes if you try to install different versions of the
5298           combined shared libraries package).</p>
5299
5300         <p>
5301           You should follow the directions in the <em>Debian Packaging
5302             Manual</em> (or other documentation of the Debian
5303           packaging tools) for putting the shared library in its
5304           package, and you must include a <tt>shlibs</tt> control area
5305           file with details of the dependencies for packages which use
5306           the library.</p>
5307
5308         <p>
5309           Shared libraries should not be installed
5310           executable, since <prgn>ld.so</prgn> does not require this
5311           and trying to execute a shared library results in a core
5312           dump.</p></sect>
5313
5314
5315       <sect id="scripts">
5316         <heading>Scripts</heading>
5317
5318         <p>
5319           All command scripts, including the package maintainer
5320           scripts inside the package and used by <prgn>dpkg</prgn>,
5321           should have a <tt>#!</tt> line naming the shell to be used
5322           to interpret them.</p>
5323
5324         <p>
5325           In the case of Perl scripts this should be
5326           <tt>#!/usr/bin/perl</tt>.</p>
5327
5328         <p>
5329           Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5330           should almost certainly start with <tt>set -e</tt> so that
5331           errors are detected.  Every script should use
5332           <tt>set -e</tt> or check the exit status of <em>every</em>
5333           command.</p>
5334
5335         <p>
5336           The standard shell interpreter `<tt>/bin/sh</tt>' can be a
5337           symbolic link to any POSIX compatible shell, if <tt>echo
5338             -n</tt> does not generate a newline.
5339           <footnote>
5340             <p>
5341               Debian policy specifies POSIX behavior for /bin/sh, but
5342               echo -n has widespread use in the Linux community
5343               (including especially debian policy, the linux kernel
5344               source, many debian scripts, etc.).  This echo -n
5345               mechanism is valid but not required under POSIX, hence
5346               this explicit addition. Also, rumour has it that this
5347               shall be mandated under the LSB anyway.
5348             </p>
5349           </footnote>
5350           Thus, shell scripts
5351           specifying `<tt>/bin/sh</tt>' as interpreter should only
5352           use POSIX features. If a script requires non-POSIX
5353           features from the shell interpreter, the appropriate shell
5354           must be specified in the first line of the script (e.g.,
5355           `<tt>#!/bin/bash</tt>') and the package must depend on the
5356           package providing the shell (unless the shell package is
5357           marked `Essential', e.g., in the case of
5358           <prgn>bash</prgn>).
5359         </p>
5360
5361         <p>
5362           You may wish to restrict your script to POSIX features when possible so
5363           that it may use <tt>/bin/sh</tt> as its interpreter. If
5364           your script works with <prgn>ash</prgn>, it's probably
5365           POSIX compliant, but if you are in doubt, use
5366           <tt>/bin/bash</tt>.</p>
5367
5368         <p>
5369           Perl scripts should check for errors when making any
5370           system calls, including <tt>open</tt>, <tt>print</tt>,
5371           <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.</p>
5372
5373         <p>
5374           <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided
5375           as scripting languages.  See <em>Csh Programming
5376             Considered Harmful</em>, one of the <tt>comp.unix.*</tt>
5377           FAQs.  It can be found on
5378           <url id="http://language.perl.com/versus/csh.whynot">, or
5379           <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5380           or even on <ftpsite>ftp.cpan.org</ftpsite>
5381           <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5382           If an upstream package comes with <prgn>csh</prgn> scripts
5383           then you must make sure that they start with
5384           <tt>#!/bin/csh</tt> and make your package depend on the
5385           <prgn>c-shell</prgn> virtual package.</p>
5386
5387         <p>
5388           Any scripts which create files in world-writeable
5389           directories (e.g., in <tt>/tmp</tt>) must use a
5390           mechanism which will fail if a file with the same name
5391           already exists.</p>
5392
5393         <p>
5394           The Debian base distribution provides the
5395           <prgn>tempfile</prgn> and <prgn>mktemp</prgn> utilities
5396           for use by scripts for this purpose.</p></sect>
5397
5398
5399       <sect>
5400         <heading>Symbolic links</heading>
5401
5402         <p>
5403           In general, symbolic links within a top-level directory
5404           should be relative, and symbolic links pointing from one
5405           top-level directory into another should be absolute. (A
5406           top-level directory is a sub-directory of the root
5407           directory `/'.)</p>
5408
5409         <p>
5410           In addition, symbolic links should be specified as short
5411           as possible, i.e., link targets like `foo/../bar' are
5412           deprecated.</p>
5413
5414         <p>
5415           Note that when creating a relative link using
5416           <prgn>ln</prgn> it is not necessary for the target of the
5417           link to exist relative to the working directory you're
5418           running <prgn>ln</prgn> from; nor is it necessary to
5419           change directory to the directory where the link is to be
5420           made.  Simply include the string that should appear as the
5421           target of the link (this will be a pathname relative to
5422           the directory in which the link resides) as the first
5423           argument to <prgn>ln</prgn>.</p>
5424
5425         <p>
5426           For example, in your <prgn>Makefile</prgn> or
5427           <tt>debian/rules</tt>, do things like:
5428           <example>
5429             ln -fs gcc $(prefix)/bin/cc
5430             ln -fs gcc debian/tmp/usr/bin/cc
5431             ln -fs ../sbin/sendmail $(prefix)/bin/runq
5432             ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5433           </example></p>
5434
5435         <p>
5436           A symbolic link pointing to a compressed file should
5437           always have the same file extension as the referenced
5438           file. (For example, if a file `<tt>foo.gz</tt>' is
5439           referenced by a symbolic link, the filename of the link
5440           has to end with `<tt>.gz</tt>' too, as in
5441           `bar.gz.')</p></sect>
5442
5443
5444       <sect>
5445         <heading>Device files</heading>
5446
5447         <p>
5448           Packages must not include device files in the package file
5449           tree.</p>
5450
5451         <p>
5452           If a package needs any special device files that are not
5453           included in the base system, it must call
5454           <prgn>MAKEDEV</prgn> in the <tt>postinst</tt> script,
5455           after asking the user for permission to do so.</p>
5456
5457         <p>
5458           Packages must not remove any device files in the
5459           <tt>postrm</tt> or any other script. This is left to the
5460           system administrator.</p>
5461
5462         <p>
5463           Debian uses the serial devices
5464           <tt>/dev/ttyS*</tt>. Programs using the old
5465           <tt>/dev/cu*</tt> devices should be changed to use
5466           <tt>/dev/ttyS*</tt>.</p>
5467       </sect>
5468
5469       <sect id="config files">
5470         <heading>Configuration files</heading>
5471         <sect1>
5472           <heading>Definitions</heading>
5473           <p>
5474             <taglist>
5475               <tag>configuration file</tag>
5476               <item><p>
5477                   A file that affects the operation of program, or
5478                   provides site- or host-specific information, or
5479                   otherwise customizes the behavior of program.
5480                   Typically, configuration files are intended to be
5481                   modified by the system administrator (if needed or
5482                   desired) to conform to local policy or provide more
5483                   useful site-specific behavior.</p>
5484               </item>
5485
5486               <tag><tt>conffile</tt></tag>
5487               <item><p>
5488                   A file listed in a package's <tt>conffiles</tt>
5489                   file, and is treated specially by <prgn>dpkg</prgn>
5490                   (see the <em>Debian Packaging Manual</em>).</p>
5491               </item>
5492             </taglist>
5493           </p>
5494
5495           <p>
5496             The distinction between these two is important; they are
5497             not interchangeable concepts. Almost all
5498             <tt>conffiles</tt> are configuration files, but many
5499             configuration files are not <tt>conffiles</tt>.</p>
5500
5501           <p>
5502             Note that a script that embeds configuration information
5503             (such as most of the files in <tt>/etc/init.d</tt> and
5504             <tt>/etc/cron.{daily,weekly,monthly}</tt>) is de-facto a
5505             configuration file and should be treated as such.</p>
5506         </sect1>
5507
5508         <sect1>
5509           <heading>Location</heading>
5510           <p>
5511             Any configuration files created or used by your package
5512             must reside in <tt>/etc</tt>. If there are several you
5513             should consider creating a subdirectory of <tt>/etc</tt>
5514             named after your package.</p>
5515
5516           <p>
5517             If your package creates or uses configuration files
5518             outside of <tt>/etc</tt>, and it is not feasible to modify
5519             the package to use the <tt>/etc</tt>, you should still put
5520             the files in <tt>/etc</tt> and create symbolic links to
5521             those files from the location that the package
5522             requires.</p>
5523         </sect1>
5524
5525         <sect1>
5526           <heading>Behavior</heading>
5527           <p>
5528             Configuration file handling must conform to the following
5529             behavior:
5530             <list>
5531               <item>
5532                 <p>local changes must be preserved during a package
5533                   upgrade</p>
5534               </item>
5535               <item>
5536                 <p>configuration files must be preserved when the
5537                   package is removed, and only deleted when the
5538                   package is purged.</p>
5539               </item>
5540             </list></p>
5541
5542           <p>
5543             The easy way to achieve this behavior is to make the
5544             configuration file a <tt>conffile</tt>. This is
5545             appropriate only if it is possible to distribute a default
5546             version that will work for most installations, although
5547             some system administrators may choose to modify it. This
5548             implies that the default version will be part of the
5549             package distribution, and must not be modified by the
5550             maintainer scripts during installation (or at any other
5551             time).
5552           </p>
5553
5554           <p>
5555             In order to ensure that local changes are preserved
5556             correctly, no package may contain or make hard links to
5557             conffiles.
5558             <footnote>
5559               <p>
5560                 Rationale: There are two problems with hard links.
5561                 The first is that some editors break the link while
5562                 editing one of the files, so that the two files may
5563                 unwittingly become different.  The second is that
5564                 <prgn>dpkg</prgn> might break the hard link while
5565                 upgrading <tt>conffile</tt>s.
5566               </p>
5567             </footnote>
5568             </p>
5569
5570             <p>
5571             The other way to do it is via the maintainer scripts.
5572             In this case, the configuration file must not be listed as
5573             a <tt>conffile</tt> and must not be part of the package
5574             distribution. If the existence of a file is required for
5575             the package to be sensibly configured it is the
5576             responsibility of the package maintainer to write scripts
5577             which correctly create, update, maintain and
5578             remove-on-purge the file. These scripts must be idempotent
5579             (i.e., must work correctly if <prgn>dpkg</prgn> needs to
5580             re-run them due to errors during installation or removal),
5581             must cope with all the variety of ways <prgn>dpkg</prgn>
5582             can call maintainer scripts, must not overwrite or
5583             otherwise mangle the user's configuration without asking,
5584             must not ask unnecessary questions (particularly during
5585             upgrades), and otherwise be good citizens.</p>
5586
5587           <p>
5588             The scripts are not required to configure every possible option for
5589             the package, but only those necessary to get the package
5590             running on a given system. Ideally the sysadmin should not
5591             have to do any configuration other than that done
5592             (semi-)automatically by the <tt>postinst</tt> script.</p>
5593
5594             <p>
5595                 A common practice is to create a script called
5596                 <tt><var>package</var>-configure</tt> and have the
5597                 package's <tt>postinst</tt> call it if and only if the
5598                 configuration file does not already exist. In certain
5599                 cases it is useful for there to be an example or template
5600                 file which the maintainer scripts use. Such files should
5601                 be in <tt>/usr/share/&lt;package&gt;</tt> or
5602                 <tt>/usr/lib/&lt;package&gt;</tt> with a symbolic link
5603                 from <tt>/usr/share/doc/&lt;package&gt;/examples</tt>
5604                 if they are examples, and should be
5605                 perfectly ordinary <prgn>dpkg</prgn>-handled files
5606                 (<em>not</em> <tt>conffiles</tt>).
5607               </p>
5608
5609           <p>
5610             These two styles of configuration file handling must
5611             not be mixed, for that way lies madness:
5612             <prgn>dpkg</prgn> will ask about overwriting the file
5613             every time the package is upgraded.</p>
5614
5615         </sect1>
5616
5617         <sect1>
5618           <heading>Sharing configuration files</heading>
5619           <p>
5620             Packages which specify the same file as
5621             `<tt>conffile</tt>' must be tagged as <em>conflicting</em>
5622             with each other.
5623             </p>
5624
5625           <p>
5626             The maintainer scripts must not alter the conffile of
5627             <em>any</em> package, including the one the scripts belong
5628             to.</p>
5629
5630           <p>
5631             If two or more packages use the same configuration file
5632             and it is reasonable for both to be installed at the same
5633             time, one of these packages must be defined as
5634             <em>owner</em> of the configuration file, i.e., it will be
5635             the package to list that distributes the file and lists it
5636             as a <tt>conffile</tt>. Other packages that use the
5637             configuration file must depend on the owning package if
5638             they require the configuration file to operate. If the
5639             other package will use the configuration file if present,
5640             but is capable of operating without it, no dependency need
5641             be declared.</p>
5642
5643           <p>
5644             If it is desirable for two or more related packages to
5645             share a configuration file <em>and</em> for all of the
5646             related packages to be able to modify that configuration
5647             file, then the following should be done:
5648             <enumlist>
5649               <item>
5650                 <p>
5651                   have one of the related packages (the "core"
5652                   package) manage the configuration file with
5653                   maintainer scripts as described in the previous
5654                   section.</p>
5655               </item>
5656               <item><p>
5657                   the core package should also provide a program that
5658                   the other packages may use to modify the
5659                   configuration file.</p>
5660               </item>
5661               <item>
5662                 <p>
5663                   the related packages must use the provided program
5664                   to make any modifications to the configuration file.
5665                   They should either depend on the core package to
5666                   guarantee that the configuration modifier program is
5667                   available or accept gracefully that they cannot
5668                   modify the configuration file if it is not.</p>
5669               </item>
5670             </enumlist></p>
5671
5672           <p>
5673             Sometimes it's appropriate to create a new package which
5674             provides the basic infrastructure for the other packages
5675             and which manages the shared configuration files. (Check
5676             out the <tt>sgml-base</tt> package as an example.)</p>
5677         </sect1>
5678
5679         <sect1>
5680           <heading>User configuration files ("dotfiles")</heading>
5681
5682           <p>
5683             Files in <tt>/etc/skel</tt> will automatically be copied
5684             into new user accounts by <prgn>adduser</prgn>. They
5685             should not be referenced there by any program.</p>
5686
5687           <p>
5688             Therefore, if a program needs a dotfile to exist in
5689             advance in <tt>$HOME</tt> to work sensibly, that dotfile
5690             should be installed in <tt>/etc/skel</tt> (and listed in
5691             conffiles, if it is not generated and modified dynamically
5692             by the package's installation scripts).</p>
5693
5694           <p>
5695             However, programs that require dotfiles in order to
5696             operate sensibly (dotfiles that they do not create
5697             themselves automatically, that is) are a bad thing, and
5698             programs should be configured by the Debian default
5699             installation as close to normal as possible.</p>
5700
5701           <p>
5702             Therefore, if a program in a Debian package needs to be
5703             configured in some way in order to operate sensibly that
5704             configuration should be done in a site-wide global
5705             configuration file elsewhere in <tt>/etc</tt>. Only if the
5706             program doesn't support a site-wide default configuration
5707             and the package maintainer doesn't have time to add it
5708             may a default per-user file be placed in
5709             <tt>/etc/skel</tt>.</p>
5710
5711           <p>
5712             <tt>/etc/skel</tt> should be as empty as we can make it.
5713             This is particularly true because there is no easy
5714             mechanism for ensuring that the appropriate dotfiles are
5715             copied into the accounts of existing users when a package
5716             is installed.</p>
5717         </sect1>
5718       </sect>
5719
5720       <sect>
5721         <heading>Log files</heading>
5722         <p>
5723           The traditional approach to log files has been to set up ad
5724           hoc log rotation schemes using simple shell scripts and
5725           cron. While this approach is highly customizable, it
5726           requires quite a lot of sysadmin work. Even though the
5727           original Debian system helped a little by automatically
5728           installing a system which can be used as a template, this
5729           was deemed not enough.
5730         </p>
5731
5732         <p>
5733           A better scheme is to use logrotate, a GPL'd program
5734           developed by Red Hat, which centralizes log management. It
5735           has both a configuration file (<tt>/etc/logrotate.conf</tt>)
5736           and a directory where packages can drop logrotation info
5737           (<tt>/etc/logrotate.d</tt>).
5738         </p>
5739
5740         <p>
5741           Log files should usually be named
5742           <tt>/var/log/<var>package</var>.log</tt>.  If you have many
5743           log files, or need a separate directory for permissions
5744           reasons (<tt>/var/log</tt> is writable only by
5745           <tt>root</tt>), you should usually create a directory named
5746           <tt>/var/log/<var>package</var></tt>.</p>
5747
5748         <p>
5749           Log files must be rotated occasionally so
5750           that they don't grow indefinitely; the best way to do this
5751           is to drop a script into the directory
5752           <tt>/etc/logrotate.d</tt> and use the facilities provided by
5753           logrotate. Here is a good example for a logrotate config
5754           file (for more information see <manref name="logrotate"
5755                                                  section="8">):
5756           <example>
5757             /var/log/foo/* {
5758             rotate 12
5759             weekly
5760             compress
5761             postrotate
5762             /etc/init.d/foo force-reload
5763             endscript
5764             }
5765           </example>
5766           Which rotates all files under `/var/log/foo', saves 12
5767           compressed generations, and sends a HUP signal at the end of
5768           rotation.
5769
5770         </p>
5771
5772         <p>
5773           Log files should be removed when the package is
5774           purged (but not when it is only removed), by checking the
5775           argument to the <tt>postrm</tt> script (see the <em>Debian
5776             Packaging Manual</em> for details).</p>
5777       </sect>
5778
5779
5780       <sect>
5781         <heading>Permissions and owners</heading>
5782
5783         <p>
5784           The rules in this section are guidelines for general use.
5785           If necessary you may deviate from the details below.
5786           However, if you do so you must make sure that what is done
5787           is secure and you should try to be as consistent as possible
5788           with the rest of the system.  You should probably also
5789           discuss it on <prgn>debian-devel</prgn> first.</p>
5790
5791         <p>
5792           Files should be owned by <tt>root.root</tt>, and made
5793           writable only by the owner and universally readable (and
5794           executable, if appropriate).</p>
5795
5796         <p>
5797           Directories should be mode 755 or (for group-writability)
5798           mode 2775.  The ownership of the directory should be
5799           consistent with its mode--if a directory is mode 2775, it
5800           should be owned by the group that needs write access to
5801           it.</p>
5802
5803         <p>
5804           Setuid and setgid executables should be mode 4755 or 2755
5805           respectively, and owned by the appropriate user or group.
5806           They should not be made unreadable (modes like 4711 or
5807           2711 or even 4111); doing so achieves no extra security,
5808           because anyone can find the binary in the freely available
5809           Debian package--it is merely inconvenient.  For the same
5810           reason you should not restrict read or execute permissions
5811           on non-set-id executables.</p>
5812
5813         <p>
5814           Some setuid programs need to be restricted to particular
5815           sets of users, using file permissions.  In this case they
5816           should be owned by the uid to which they are set-id, and
5817           by the group which should be allowed to execute them.
5818           They should have mode 4754; there is no point in making
5819           them unreadable to those users who must not be allowed to
5820           execute them.</p>
5821
5822         <p>
5823           You must not arrange that the system administrator can only
5824           reconfigure the package to correspond to their local
5825           security policy by changing the permissions on a binary.
5826           Ordinary files installed by <prgn>dpkg</prgn> (as opposed
5827           to conffiles and other similar objects) have their
5828           permissions reset to the distributed permissions when the
5829           package is reinstalled.  Instead you should consider (for
5830           example) creating a group for people allowed to use the
5831           program(s) and making any setuid executables executable
5832           only by that group.</p>
5833
5834         <p>
5835           If you need to create a new user or group for your package
5836           there are two possibilities.  Firstly, you may need to
5837           make some files in the binary package be owned by this
5838           user or group, or you may need to compile the user or
5839           group id (rather than just the name) into the binary
5840           (though this latter should be avoided if possible, as in
5841           this case you need a statically allocated id).</p>
5842
5843         <p>
5844           If you need a statically allocated id, you must ask for a
5845           user or group id from the base system
5846           maintainer, and must not release the package until you
5847           have been allocated one.  Once you have been allocated one
5848           you must make the package depend on a version of the base
5849           system with the id present in <tt>/etc/passwd</tt> or
5850           <tt>/etc/group</tt>, or alternatively arrange for your
5851           package to create the user or group itself with the
5852           correct id (using <tt>adduser</tt>) in its pre- or
5853           post-installation script (the latter is to be preferred if
5854           it is possible).</p>
5855
5856         <p>
5857           On the other hand, the program might be able to determine the
5858           uid or gid from the group name at runtime, so that a
5859           dynamic id can be used.  In this case you should choose an
5860           appropriate user or group name, discussing this on
5861           <prgn>debian-devel</prgn> and checking with the base
5862           system maintainer that it is unique and that they do not
5863           wish you to use a statically allocated id instead.  When
5864           this has been checked you must arrange for your package to
5865           create the user or group if necessary using
5866           <prgn>adduser</prgn> in the pre- or post-installation
5867           script (again, the latter is to be preferred if it is
5868           possible).</p>
5869
5870         <p>
5871           Note that changing the numeric value of an id associated with a name
5872           is very difficult, and involves searching the file system for all
5873           appropriate files.  You need to think carefully whether a static or
5874           dynamic id is required, since changing your mind later will cause
5875           problems.</p>
5876       </sect>
5877     </chapt>
5878
5879     <chapt id="customized-programs">
5880       <heading>Customized programs</heading>
5881
5882       <sect id="arch-spec">
5883         <heading>Architecture specification strings</heading>
5884
5885         <p>
5886           If a program needs to specify an <em>architecture specification
5887             string</em> in some place, the following format should be used:
5888           <example>
5889             &lt;arch&gt;-&lt;os&gt;
5890           </example>
5891           where `&lt;arch&gt;' is one of the following: i386, alpha, arm, m68k,
5892           powerpc, sparc and `&lt;os&gt;' is one of: linux, gnu.  Use
5893           of <em>gnu</em> in this string is reserved for the GNU/Hurd
5894           operating system.</p>
5895         <p>
5896           Note, that we don't want to use `&lt;arch&gt;-debian-linux'
5897           to apply to the rule `architecture-vendor-os' since this
5898           would make our programs incompatible to other Linux
5899           distributions. Also note, that we don't use
5900           `&lt;arch&gt;-unknown-linux', since the `unknown' does not
5901           look very good.</p></sect>
5902
5903
5904       <sect>
5905         <heading>Daemons</heading>
5906
5907         <p>
5908           The configuration files <tt>/etc/services</tt>,
5909           <tt>/etc/protocols</tt>, and <tt>/etc/rpc</tt> are managed
5910           by the <prgn>netbase</prgn> package and may not be modified
5911           by other packages.</p>
5912
5913         <p>
5914           If a package requires a new entry in one of these files, the
5915           maintainer should get in contact with the
5916           <prgn>netbase</prgn> maintainer, who will add the entries
5917           and release a new version of the <prgn>netbase</prgn>
5918           package.</p>
5919
5920         <p>
5921           The configuration file <tt>/etc/inetd.conf</tt> must not be
5922           modified by the package's scripts except via the
5923           <prgn>update-inetd</prgn> script or the
5924           <prgn>DebianNet.pm</prgn> Perl module.</p>
5925
5926         <p>
5927           If a package wants to install an example entry into
5928           <tt>/etc/inetd.conf</tt>, the entry must be preceded with
5929           exactly one hash character (<tt>#</tt>). Such lines are
5930           treated as `commented out by user' by the
5931           <prgn>update-inetd</prgn> script and are not changed or
5932           activated during a package updates.</p></sect>
5933
5934
5935       <sect>
5936         <heading>Using pseudo-ttys and modifying wtmp, utmp and lastlog</heading>
5937
5938         <p>
5939           Some programs need to create pseudo-ttys. This should be done
5940           using Unix98 ptys if the C library supports it. The resulting
5941           program must not be installed setuid root, unless that
5942           is required for other functionality.
5943         </p>
5944
5945         <p>
5946           The files <tt>/var/run/utmp</tt>, <tt>/var/log/wtmp</tt> and
5947           <tt>/var/log/lastlog</tt> must be installed writeable by
5948           group utmp.  Programs who need to modify those files must
5949           be installed setgid utmp.
5950         </p>
5951       </sect>
5952
5953       <sect>
5954         <heading>Editors and pagers</heading>
5955
5956         <p>
5957           Some programs have the ability to launch an editor or pager
5958           program to edit or display a text document. Since there are
5959           lots of different editors and pagers available in the Debian
5960           distribution, the system administrator and each user should
5961           have the possibility to choose his/her preferred editor and
5962           pager.</p>
5963
5964         <p>
5965           In addition, every program should choose a good default
5966           editor/pager if none is selected by the user or system
5967           administrator.</p>
5968
5969         <p>
5970           Thus, every program that launches an editor or pager must
5971           use the EDITOR or PAGER environment variables to determine
5972           the editor/pager the user wants to get started. If these
5973           variables are not set, the programs <tt>/usr/bin/editor</tt>
5974           and <tt>/usr/bin/pager</tt> should be used, respectively.</p>
5975
5976         <p>
5977           These two files are managed through `alternatives.' That is,
5978           every package providing an editor or pager must call the
5979           <prgn>update-alternatives</prgn> script to register these
5980           programs.</p>
5981
5982         <p>
5983           If it is very hard to adapt a program to make us of the
5984           EDITOR and PAGER variables, that program may be configured
5985           to use <tt>/usr/bin/sensible-editor</tt> and
5986           <tt>/usr/bin/sensible-pager</tt> as editor or pager program,
5987           respectively. These are two scripts provided in the Debian
5988           base system that check the EDITOR and PAGER variables and
5989           launch the appropriate program or fall back to
5990           <tt>/usr/bin/editor</tt> and <tt>/usr/bin/pager</tt>,
5991           automatically.</p>
5992
5993         <p>
5994           A program may also use the VISUAL environment variable to
5995           determine the user's choice of editor. If it exists, it
5996           should take precedence over EDITOR. This is in fact what
5997           <tt>/usr/bin/sensible-editor</tt> does.</p>
5998
5999         <p>
6000           It is not required for a package to depend on
6001           `editor' and `pager', nor is it required for a package to
6002           provide such virtual packages.
6003           <footnote>
6004             <p>
6005               The Debian base system already provides an editor and
6006               a pager program,
6007             </p>
6008           </footnote>
6009         </p>
6010
6011       </sect>
6012
6013
6014       <sect id="web-appl">
6015         <heading>Web servers and applications</heading>
6016
6017         <p>
6018           This section describes the locations and URLs that should
6019           be used by all web servers and web application in the Debian
6020           system.</p>
6021
6022         <p>
6023           <enumlist>
6024             <item>
6025               <p>Cgi-bin executable files are installed in the
6026                 directory
6027                 <example>
6028                   /usr/lib/cgi-bin/&lt;cgi-bin-name&gt;
6029                 </example>
6030                 and should be referred to as
6031                 <example>
6032                   http://localhost/cgi-bin/&lt;cgi-bin-name&gt;
6033                 </example></p></item>
6034
6035
6036             <item><p>Access to html documents</p>
6037
6038               <p>
6039                 Html documents for a package are stored in
6040                 <tt>/usr/share/doc/<var>package</var></tt> but should
6041                 be accessed via symlinks as
6042                 <tt>/usr/doc/<var>package</var></tt><footnote> for
6043                     backward compatibility, see <ref id="usrdoc"></footnote>
6044                 and can be referred to as
6045                 <example>
6046                   http://localhost/doc/&lt;package&gt;/&lt;filename&gt;
6047                 </example></p></item>
6048
6049
6050             <item><p>Web Document Root</p>
6051
6052               <p>
6053                 Web Applications should try to avoid storing files in
6054                 the Web Document Root.  Instead they should use the
6055                 /usr/share/doc/&lt;package&gt; directory for documents and
6056                 register the Web Application via the menu package. If
6057                 access to the web-root is unavoidable then use
6058                 <example>
6059                   /var/www
6060                 </example>
6061                 as the Document Root. This might be just a
6062                 symbolic link to the location where the sysadmin has
6063                 put the real document root.</p>
6064             </item>
6065
6066           </enumlist></p></sect>
6067
6068
6069       <sect id="mail-transport-agents">
6070         <heading>Mail transport, delivery and user agents</heading>
6071
6072         <p>
6073           Debian packages which process electronic mail, whether
6074           mail-user-agents (MUAs) or mail-transport-agents (MTAs),
6075           must make sure that they are compatible with the
6076           configuration decisions below.  Failure to do this may
6077           result in lost mail, broken <tt>From:</tt> lines, and other
6078           serious brain damage!</p>
6079
6080         <p>
6081           The mail spool is <tt>/var/mail</tt> and the interface
6082           to send a mail message is <tt>/usr/sbin/sendmail</tt> (as
6083           per the FHS).  On older systems, the mail spool may be
6084           physically located in /var/spool/mail, but all access to the
6085           mail spool should be via the /var/mail symlink. The mail
6086           spool is part of the base system and not part of the MTA
6087           package.
6088         </p> 
6089
6090         <p>
6091           All Debian MUAs, MTAs, MDAs and other mailbox accessing
6092           programs (like IMAP daemons) must lock the mailbox in an
6093           NFS-safe way. This means that <tt>fcntl()</tt> locking must
6094           be combined with dot locking.  To avoid deadlocks, a
6095           program should use <tt>fcntl()</tt> first and dot locking
6096           after this or alternatively implement the two locking
6097           methods in a non blocking way<footnote>
6098             <p>
6099               If it is not possible to establish both locks, the
6100               system shouldn't wait for the second lock to be
6101               established, but remove the first lock, wait a (random)
6102               time, and start over locking again.</p>
6103           </footnote>. Using the functions <tt>maillock</tt> and
6104           <tt>mailunlock</tt> provided by the
6105           <tt>liblockfile*</tt><footnote>
6106             <p>
6107               <tt>liblockfile</tt> version &gt;&gt;1.01</p>
6108           </footnote> packages is the recommended way to realize this.
6109         </p>
6110
6111         <p>
6112           Mailboxes are generally 660 <tt><var>user</var>.mail</tt>
6113           unless the user has chosen otherwise.  A MUA may remove a
6114           mailbox (unless it has nonstandard permissions) in which
6115           case the MTA or another MUA must recreate it if needed.
6116           Mailboxes must be writable by group mail.</p>
6117
6118         <p>
6119           The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6120           be setgid mail to do the locking mentioned above (and
6121           must obviously avoid accessing other users' mailboxes
6122           using this privilege).</p>
6123
6124         <p>
6125           <tt>/etc/aliases</tt> is the source file for the system mail
6126           aliases (e.g., postmaster, usenet, etc.)--it is the one
6127           which the sysadmin and <tt>postinst</tt> scripts may edit.
6128           After <tt>/etc/aliases</tt> is edited the program or human
6129           editing it must call <prgn>newaliases</prgn>.  All MTA
6130           packages must come with a <prgn>newaliases</prgn> program,
6131           even if it does nothing, but older MTA packages do not do
6132           this so programs should not fail if <prgn>newaliases</prgn>
6133           cannot be found.</p>
6134
6135         <p>
6136           The convention of writing <tt>forward to
6137             <var>address</var></tt> in the mailbox itself is not
6138           supported.  Use a <tt>.forward</tt> file instead.</p>
6139
6140         <p>
6141           The <prgn>rmail</prgn> program used by UUCP
6142           for incoming mail should be  <tt>/usr/sbin/rmail</tt>.
6143           Likewise, <prgn>rsmtp</prgn>, for receiving
6144           batch-SMTP-over-UUCP, should be <tt>/usr/sbin/rsmtp</tt> if it
6145           is supported.</p>
6146
6147         <p>
6148           If you need to know what name to use (for example) on
6149           outgoing news and mail messages which are generated locally,
6150           you should use the file <tt>/etc/mailname</tt>.  It will
6151           contain the portion after the username and <tt>@</tt> (at)
6152           sign for email addresses of users on the machine (followed
6153           by a newline).</p>
6154
6155         <p>
6156           A package should check for the existence of this file.  If
6157           it exists it should use it without comment. (An MTA's
6158           prompting configuration script may wish to prompt the user
6159           even if it finds this file exists.) If it does not exist it
6160           should prompt the user for the value and store it in
6161           <tt>/etc/mailname</tt> as well as using it in the package's
6162           configuration.  The prompt should make it clear that the
6163           name will not just be used by that package.  For example, in
6164           this situation the INN package says:
6165           <example>
6166             Please enter the `mail name' of your system.  This is the
6167             hostname portion of the address to be shown on outgoing
6168             news and mail messages.  The default is
6169             <var>syshostname</var>, your system's host name.  Mail
6170             name [`<var>syshostname</var>']:
6171           </example>
6172           where <var>syshostname</var> is the output of <tt>hostname
6173             --fqdn</tt>.</p></sect>
6174
6175
6176       <sect>
6177         <heading>News system configuration</heading>
6178
6179         <p>
6180           All the configuration files related to the NNTP (news)
6181           servers and clients should be located under
6182           <tt>/etc/news</tt>.</p>
6183
6184         <p>
6185           There are some configuration issues that apply to a number
6186           of news clients and server packages on the machine. These
6187           are:
6188
6189           <taglist>
6190             <tag>/etc/news/organization</tag>
6191             <item><p>A string which should appear as the
6192                 organization header for all messages posted
6193                 by NNTP clients on the machine</p></item>
6194
6195             <tag>/etc/news/server</tag>
6196             <item><p>Contains the FQDN of the upstream NNTP
6197                 server, or localhost if the local machine is
6198                 an NNTP server.</p></item>
6199           </taglist>
6200
6201           Other global files may be added as required for cross-package news
6202           configuration.</p></sect>
6203
6204
6205       <sect>
6206         <heading>Programs for the X Window System</heading>
6207
6208         <p>
6209           <em>Programs that may be configured with support for the X Window
6210             System</em> must be configured to do so and must declare any
6211           package dependencies necessary to satisfy their runtime
6212           requirements when using the X Window System, unless the package
6213           in question is of standard or higher priority, in which case
6214           X-specific binaries may be split into a separate package, or
6215           alternative versions of the package with X support may be
6216           provided.
6217         </p>
6218
6219
6220         <p>
6221           <em>Packages which provide an X server</em> that, directly or
6222           indirectly, communicates with real input and display hardware
6223           should declare in their control data that they provide the
6224           virtual package <tt>xserver</tt>.
6225           <footnote>
6226             <p>
6227               This implements current practice, and provides an actual
6228               policy for usage of the "xserver" virtual package which
6229               appears in the virtual packages list.  In a nutshell, X
6230               servers that interface directly with the display and input
6231               hardware or via another subsystem (e.g., GGI) should provide
6232               xserver.  Things like Xvfb, Xnest, and Xprt should not.
6233             </p>
6234           </footnote>
6235         </p>
6236
6237         <p>
6238           <em>Packages that provide a terminal emulator</em> for the X
6239           Window System which support a terminal type with a terminfo
6240           description provided in the <tt>ncurses-base</tt> package
6241           should declare in their control data that they provide the
6242           virtual package <tt>x-terminal-emulator</tt>.  They should
6243           also register themselves as an alternative for
6244           <tt>/usr/bin/x-terminal-emulator</tt>, with a priority of
6245           20.
6246         </p>
6247
6248         <p>
6249           <em>Packages that provide window managers</em> should declare in
6250           their control data that they provide the virtual package
6251           <tt>x-window-manager</tt>.  They should also register themselves as an
6252           alternative for <tt>/usr/bin/x-window-manager</tt>, with a priority
6253           calculated as follows:
6254           <list>
6255             <item>Start with a priority of 20.</item>
6256             <item>If the window manager supports the Debian menu system,
6257                 add 20 points if this support is available in the
6258                 package's default configuration (i.e., no
6259                 configuration files belonging to the system or user
6260                 have to be edited to activate the feature); if
6261                 configuration files must be modified, add only 10
6262                 points.</item>
6263             <item>If the window manager permits the X session to be
6264                 restarted using a <em>different</em> window manager
6265                 (without killing the X server) in its default
6266                 configuration, add 10 points; otherwise add
6267                 none.</item>
6268           </list>
6269         </p>
6270
6271         <p>
6272           <em>Packages that provide fonts for the X Window System</em>
6273           must do a number of things to ensure that they are both
6274           available without modification of the X or font server
6275           configuration, and that they do not corrupt files used by
6276           other font packages to register information about themselves.
6277           <enumlist>
6278             <item>
6279                 Fonts of any type supported by the X Window System
6280                 should be be in a separate binary package from any
6281                 executables, libraries, or documentation (except that
6282                 specific to the fonts shipped); if a program or
6283                 library is <em>unusable</em> without one or more
6284                 specific fonts, the package containing the program or
6285                 library should declare a dependency on the package(s)
6286                 containing the font(s) it requires.
6287             </item>
6288             <item>
6289                 BDF fonts should be converted to PCF fonts with the
6290                 <tt>bdftopcf</tt> utility (available in the
6291                 <tt>xutils</tt> package, <tt>gzip</tt>ped, and
6292                 placed in a directory that corresponds to their
6293                 resolution:
6294                 <list>
6295                   <item>
6296                       100 dpi fonts should be placed in
6297                       <tt>/usr/X11R6/lib/X11/fonts/100dpi/</tt>.
6298                   </item>
6299                   <item>
6300                       75 dpi fonts should be placed in
6301                       <tt>/usr/X11R6/lib/X11/fonts/75dpi/</tt>.
6302                   </item>
6303                   <item>
6304                       Character-cell fonts, cursor fonts, and other
6305                       low-resolution fonts should be placed in
6306                       <tt>/usr/X11R6/lib/X11/fonts/misc/</tt>.
6307                   </item>
6308                 </list>
6309             </item>
6310             <item>
6311                 Speedo fonts should be placed in
6312                 <tt>/usr/X11R6/lib/X11/fonts/Speedo/</tt>.
6313             </item>
6314             <item>
6315                 Type 1 fonts should be placed in
6316                 <tt>/usr/X11R6/lib/X11/fonts/Type1/</tt>.  If font
6317                 metric files are available, they may be placed here as
6318                 well.
6319             </item>
6320             <item>
6321                 Subdirectories of <tt>/usr/X11R6/lib/X11/fonts/</tt>
6322                 other than those listed above should be neither created nor
6323                 used.  (The <tt>PEX</tt> and <tt>cyrillic</tt> directories are
6324                 excepted for historical reasons, but installation of files into
6325                 these directories remains discouraged.)
6326             </item>
6327             <item>
6328                 Font packages may, instead of placing files directly in
6329                 the X font directories listed above, provide symbolic links in
6330                 the font directory which point to the files' actual location
6331                 in the filesystem.  Such a location should comply with the
6332                 FHS.
6333             </item>
6334             <item>
6335                 Font packages should not contain both 75dpi and 100dpi
6336                 versions of a font.  If both are available, they should be
6337                 provided in separate binary packages with "-75dpi" or "-100dpi"
6338                 appended to the names of the packages containing the
6339                 corresponding fonts.
6340             </item>
6341             <item>
6342                 Fonts destined for the <tt>misc</tt> subdirectory should
6343                 not be included in the same package as 75dpi or 100dpi fonts;
6344                 instead, they should be provided in a separate package with
6345                 "-misc" appended to its name.
6346             </item>
6347             <item>
6348                 Font packages <em>must not</em> provide the files
6349                 <tt>fonts.dir</tt>, <tt>fonts.alias</tt>, or
6350                 <tt>fonts.scale</tt> in a font directory.
6351                 <list>
6352                   <item>
6353                       <tt>fonts.dir</tt> files must not be provided at
6354                       all.
6355                   </item>
6356                   <item>
6357                       <tt>fonts.alias</tt> and <tt>fonts.scale</tt>
6358                       files, if needed, should be provided in the
6359                       directory
6360                       <tt>/etc/X11/fonts/<em>fontdir</em>/<em>package</em>.<em>extension</em></tt>,
6361                       where <em>fontdir</em> is the name of the
6362                       subdirectory of
6363                       <tt>/usr/X11R6/lib/X11/fonts/</tt> where the
6364                       package's corresponding fonts are stored (e.g.,
6365                       <tt>75dpi</tt> or <tt>misc</tt>),
6366                       <em>package</em> is the name of the package that
6367                       provides these fonts, and <em>extension</em> is
6368                       either <tt>scale</tt> or <tt>alias</tt>,
6369                       whichever corresponds to the file
6370                       contents.
6371                   </item>
6372                 </list>
6373             </item>
6374             <item>
6375                 Font packages must declare a dependency on
6376                 <tt>xutils</tt> and, in the package
6377                 post-installation and post-removal scripts, invoke the
6378                 <tt>mkfontdir</tt> command on each directory into
6379                 which they installed fonts.
6380             </item>
6381             <item>
6382                 Font packages that provide one or more
6383                 <tt>fonts.scale</tt> files as described above must declare a
6384                 versioned dependency on <tt>xutils (&gt;=
6385                   4.0.2)</tt> and invoke <tt>update-fonts-scale</tt> on each
6386                 directory into which they installed fonts
6387                 <em>before</em> invoking <tt>mkfontdir</tt> on that
6388                 directory.  This invocation must occur in both the
6389                 post-installation and post-removal scripts.
6390             </item>
6391             <item>
6392                 Font packages that provide one or more
6393                 <tt>fonts.alias</tt> files as described above must
6394                 declare a versioned dependency on <tt>xutils
6395                   (&gt;= 4.0.2)</tt> and, in the package
6396                 post-installation and post-removal scripts, invoke
6397                 <tt>update-fonts-alias</tt> on each directory into
6398                 which they installed fonts.
6399             </item>
6400             <item>
6401                 Font packages must not provide alias names for the
6402                 fonts they include which collide with alias names already in
6403                 use by fonts already packaged.
6404             </item>
6405             <item>
6406                 Font packages must not provide fonts with the same XLFD
6407                 registry name as another font already packaged.
6408             </item>
6409           </enumlist>
6410         </p>
6411
6412         <p>
6413           <em>Application defaults</em> files must be installed in the
6414           directory <tt>/etc/X11/app-defaults/</tt> (use of a
6415           localized subdirectory of <tt>/etc/X11/</tt> as described in
6416           the <em>X Toolkit Intrinsics - C Language Interface</em>
6417           manual is also permitted).  They must be registered as
6418           <em>conffile</em>s or handled as configuration files.  For
6419           programs that are not linked against the X Toolkit (Xt)
6420           library, customization of programs' X resources may also be
6421           supported with the provision of a file with the same name as
6422           that of the package placed in the
6423           <tt>/etc/X11/Xresources/</tt> directory, which must
6424           registered as a <em>conffile</em> or handled as a
6425           configuration file.  <em>Important:</em> packages that
6426           install files into the <tt>/etc/X11/Xresources/</tt>
6427           directory <em>must</em> declare a conflict with <tt>xbase
6428           (&lt;&lt; 3.3.2.3a-2)</tt>; if this is not done it is
6429           possible for the installing package to destroy a
6430           previously-existing <tt>/etc/X11/Xresources</tt> file which
6431           had been customized by the system administrator.
6432         </p>
6433
6434         <p>
6435           <em>Packages using the X Window System should abide by the FHS
6436             standard whenever possible</em>; they should install binaries,
6437           libraries, manual pages, and other files in FHS-mandated
6438           locations wherever possible.  This means that files must
6439           not be installed into <tt>/usr/X11R6/bin/</tt>,
6440           <tt>/usr/X11R6/lib/</tt>, or <tt>/usr/X11R6/man/</tt> unless
6441           this is necessary for the package to operate properly.
6442           Configuration files for window managers and display managers
6443           should be placed in a subdirectory of <tt>/etc/X11/</tt>
6444           corresponding to the package name due to these programs'
6445           tight integration with the mechanisms of the X Window
6446           System.  Application-level programs should use the
6447           <tt>/etc/</tt> directory unless otherwise mandated by
6448           policy.  The installation of files into subdirectories of
6449           <tt>/usr/X11R6/include/X11/</tt> and
6450           <tt>/usr/X11R6/lib/X11/</tt> is permitted but discouraged;
6451           package maintainers should determine if subdirectories of
6452           <tt>/usr/lib/</tt> and <tt>/usr/share/</tt> can be used
6453           instead (symlinks from the X11R6 directories to
6454           FHS-compliant locations is encouraged if the program is not
6455           easily configured to look elsewhere for its files).
6456           Packages must not provide -- or install files into -- the
6457           directories <tt>/usr/bin/X11/</tt>,
6458           <tt>/usr/include/X11/</tt>, or <tt>/usr/lib/X11/</tt>.
6459           Files within a package should, however, make reference to
6460           these directories, rather than their X11R6-named
6461           counterparts <tt>/usr/X11R6/bin/</tt>,
6462           <tt>/usr/X11R6/include/X11/</tt>, and
6463           <tt>/usr/X11R6/lib/X11/</tt>, if the resources being
6464           referred to have not been moved to FHS-compliant locations.
6465         </p>
6466
6467         <p>
6468           <em>Programs that require the non-DFSG-compliant OSF/Motif
6469             library</em> should be compiled against and tested with
6470           LessTif (a free re-implementation of Motif) instead.  If the
6471           maintainer judges that the program or programs do not work
6472           sufficiently well with LessTif to be distributed and
6473           supported, but do so when compiled against Motif, then two
6474           versions of the package should be created; one linked
6475           statically against Motif and with <tt>-smotif</tt> appended
6476           to the package name, and one linked dynamically against
6477           Motif and with <tt>-dmotif</tt> appended to the package
6478           name.  Both Motif-linked versions are dependent upon
6479           non-DFSG-compliant software and thus cannot be uploaded to
6480           the main distribution; if the software is itself
6481           DFSG-compliant it may be uploaded to the contrib
6482           distribution.  While known existing versions of OSF/Motif
6483           permit unlimited redistribution of binaries linked against
6484           the library (whether statically or dynamically), it is the
6485           package maintainer's responsibility to determine whether
6486           this is permitted by the license of the copy of OSF/Motif in
6487           his or her possession.
6488         </p>
6489       </sect>
6490
6491       <sect>
6492         <heading>Perl programs and modules</heading>
6493         <p>
6494           Perl programs and modules should follow the current Perl             
6495           policy as defined in the file found on                               
6496           <ftpsite>ftp.debian.org</ftpsite> in                                 
6497           <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>  
6498           or your local mirror.  In addition, it is included in the            
6499           <tt>debian-policy</tt> package.                                
6500         </p>
6501       </sect>
6502
6503       <sect>
6504         <heading>Emacs lisp programs</heading>
6505
6506         <p>
6507           Please refer to the `Debian Emacs Policy' (documented in
6508           <tt>debian-emacs-policy.gz</tt> of the
6509           <prgn>emacsen-common</prgn> package) for details of how to
6510           package emacs lisp programs.</p></sect>
6511
6512
6513       <sect>
6514         <heading>Games</heading>
6515
6516         <p>
6517           The permissions on /var/games are 755
6518           <tt>root.root</tt>.</p>
6519
6520         <p>
6521           Each game decides on its own security policy.</p>
6522
6523         <p>
6524           Games which require protected, privileged access to
6525           high-score files, savegames, etc., may be made
6526           set-<em>group</em>-id (mode 2755) and owned by
6527           <tt>root.games</tt>, and use files and directories with
6528           appropriate permissions (770 <tt>root.games</tt>, for
6529           example).  They must not be made
6530           set-<em>user</em>-id, as this causes security problems. (If
6531           an attacker can subvert any set-user-id game they can
6532           overwrite the executable of any other, causing other players
6533           of these games to run a Trojan horse program.  With a
6534           set-group-id game the attacker only gets access to less
6535           important game data, and if they can get at the other
6536           players' accounts at all it will take considerably more
6537           effort.)</p>
6538
6539         <p>
6540           Some packages, for example some fortune cookie programs, are
6541           configured by the upstream authors to install with their
6542           data files or other static information made unreadable so
6543           that they can only be accessed through set-id programs
6544           provided.  You should not do this in a Debian package: anyone can
6545           download the <tt>.deb</tt> file and read the data from it,
6546           so there is no point making the files unreadable.  Not
6547           making the files unreadable also means that you don't have
6548           to make so many programs set-id, which reduces the risk of a
6549           security hole.</p>
6550
6551         <p>
6552           As described in the FHS, binaries of games should be
6553           installed in the directory <tt>/usr/games</tt>. This also
6554           applies to games that use the X Window System. Manual pages
6555           for games (X and non-X games) should be installed in
6556           <tt>/usr/share/man/man6</tt>.</p>
6557       </sect>
6558     </chapt>
6559
6560     <chapt><heading>Documentation</heading>
6561
6562
6563       <sect>
6564         <heading>Manual pages</heading>
6565
6566         <p>
6567           You should install manual pages in <prgn>nroff</prgn> source
6568           form, in appropriate places under <tt>/usr/share/man</tt>.  You
6569           should only use sections 1 to 9 (see the FHS for more
6570           details).  You must not install a preformatted `cat
6571           page'.</p>
6572
6573         <p>
6574           Each program, utility, and function should have an
6575           associated manpage included in the same package. It is
6576           suggested that all configuration files also have a manual
6577           page included as well.
6578         </p>
6579
6580         <p>
6581           If no manual page is available for a particular program,
6582           utility, function or configuration file and this is reported as a bug on
6583           debian-bugs, a symbolic link from the requested manual page
6584           to the <manref name="undocumented" section="7"> manual page
6585           may be provided.  This symbolic link can be created from
6586           <tt>debian/rules</tt> like this:
6587           <example>
6588             ln -s ../man7/undocumented.7.gz \
6589             debian/tmp/usr/share/man/man[1-9]/the_requested_manpage.[1-9].gz
6590           </example>
6591           This manpage claims that the lack of a manpage has been
6592           reported as a bug, so you may only do this if it really has
6593           (you can report it yourself, if you like).  Do not close the
6594           bug report until a proper manpage is available.</p>
6595
6596         <p>
6597           You may forward a complaint about a missing manpage to the
6598           upstream authors, and mark the bug as forwarded in the
6599           Debian bug tracking system.  Even though the GNU Project do
6600           not in general consider the lack of a manpage to be a bug,
6601           we do--if they tell you that they don't consider it a bug
6602           you should leave the bug in our bug tracking system open
6603           anyway.</p>
6604
6605         <p>
6606           Manual pages should be installed compressed using <tt>gzip
6607             -9</tt>.</p>
6608
6609         <p>
6610           If one manpage needs to be accessible via several names it
6611           is better to use a symbolic link than the <tt>.so</tt>
6612           feature, but there is no need to fiddle with the relevant
6613           parts of the upstream source to change from <tt>.so</tt> to
6614           symlinks--don't do it unless it's easy.  You should not create hard
6615           links in the manual page directories, nor put
6616           absolute filenames in <tt>.so</tt> directives.  The filename
6617           in a <tt>.so</tt> in a manpage should be relative to the
6618           base of the manpage tree (usually
6619           <tt>/usr/share/man</tt>).</p></sect>
6620
6621
6622       <sect>
6623         <heading>Info documents</heading>
6624
6625         <p>
6626           Info documents should be installed in <tt>/usr/share/info</tt>.
6627           They should be compressed with <tt>gzip -9</tt>.</p>
6628
6629         <p>
6630           Your package should call <prgn>install-info</prgn> to update the Info
6631           <tt>dir</tt>
6632           file, in its post-installation script:
6633           <example>
6634             install-info --quiet --section Development Development \
6635             /usr/share/info/foobar.info
6636           </example></p>
6637
6638         <p>
6639           It is a good idea to specify a section for the location of
6640           your program; this is done with the <tt>--section</tt>
6641           switch.  To determine which section to use, you should look
6642           at <tt>/usr/share/info/dir</tt> on your system and choose the most
6643           relevant (or create a new section if none of the current
6644           sections are relevant).  Note that the <tt>--section</tt>
6645           flag takes two arguments; the first is a regular expression
6646           to match (case-insensitively) against an existing section,
6647           the second is used when creating a new one.</p>
6648
6649         <p>
6650           You should remove the entries in the pre-removal script:
6651           <example>
6652             install-info --quiet --remove /usr/share/info/foobar.info
6653           </example></p>
6654
6655         <p>
6656           If <prgn>install-info</prgn> cannot find a description entry
6657           in the Info file you must supply one.  See <manref
6658                                                              name="install-info" section="8"> for details.</p>
6659       </sect>
6660
6661       <sect>
6662         <heading>Additional documentation</heading>
6663
6664         <p>
6665           Any additional documentation that comes with the package may
6666           be installed at the discretion of the package maintainer.
6667           Text documentation should be installed in a directory
6668           <tt>/usr/share/doc/<var>package</var></tt>, where
6669           <var>package</var> is the name of the package, and
6670           compressed with <tt>gzip -9</tt> unless it is small.</p>
6671
6672         <p>
6673           If a package comes with large amounts of documentation which
6674           many users of the package will not require you should create
6675           a separate binary package to contain it, so that it does not
6676           take up disk space on the machines of users who do not need
6677           or want it installed.</p>
6678
6679         <p>
6680           It is often a good idea to put text information files
6681           (<tt>README</tt>s, changelogs, and so forth) that come with
6682           the source package in <tt>/usr/share/doc/<var>package</var></tt>
6683           in the binary package.  However, you don't need to install
6684           the instructions for building and installing the package, of
6685           course!</p>
6686
6687         <p>
6688           Files in <tt>/usr/share/doc</tt> should not be referenced by
6689           any program, and the system administrator should be able to
6690           delete them without causing any programs to break. Any files
6691           that are referenced by programs but are also useful as
6692           standalone documentation should be installed under
6693           <tt>/usr/share/&lt;package&gt;/</tt> and symlinked in
6694           <tt>/usr/share/doc/&lt;package&gt;/</tt>.
6695         </p>
6696
6697       </sect>
6698
6699       <sect id="usrdoc">
6700         <heading>Accessing the documentation</heading>
6701
6702         <p>
6703           Former Debian releases placed all additional documentation
6704           in <tt>/usr/doc/<var>package</var></tt>.  To realize a
6705           smooth migration to
6706           <tt>/usr/share/doc/<var>package</var></tt>, each package
6707           must maintain a symlink <tt>/usr/doc/<var>package</var></tt>
6708           that points to the new location of its documentation in
6709           <tt>/usr/share/doc/<var>package</var></tt><footnote>These
6710               symlinks will be removed in the future, but they have to be
6711               there for compatibility reasons until all packages have
6712               moved and the policy is changed accordingly.</footnote>.
6713           The symlink must be created when the package is installed;
6714           it cannot be contained in the package itself due to problems
6715           with <prgn>dpkg</prgn>. One reasonable way to accomplish
6716           this is to put the following in the package's
6717           <prgn>postinst</prgn>:
6718           <example>
6719             if [ "$1" = "configure" ]; then
6720             if [ -d /usr/doc -a ! -e /usr/doc/#PACKAGE# \
6721             -a -d /usr/share/doc/#PACKAGE# ]; then
6722             ln -sf ../share/doc/#PACKAGE# /usr/doc/#PACKAGE#
6723             fi
6724             fi
6725           </example>
6726           And the following in the package's <prgn>prerm</prgn>:
6727           <example>
6728             if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \
6729             -a -L /usr/doc/#PACKAGE# ]; then
6730             rm -f /usr/doc/#PACKAGE#
6731             fi
6732           </example>
6733         </p>
6734       </sect>
6735
6736       <sect>
6737         <heading>Preferred documentation formats</heading>
6738
6739         <p>
6740           The unification of Debian documentation is being carried out
6741           via HTML.</p>
6742
6743         <p>
6744           If your package comes with extensive documentation in a
6745           mark up format that can be converted to various other formats
6746           you should if possible ship HTML versions in a binary
6747           package, in the directory
6748           <tt>/usr/share/doc/<var>appropriate package</var></tt> or its
6749           subdirectories.
6750           <footnote>
6751             <p>The rationale: The important thing here is that HTML
6752               docs should be available in <em>some</em> package, not
6753               necessarily in the main binary package, though. </p>
6754           </footnote>
6755         </p>
6756
6757         <p>
6758           Other formats such as PostScript may be provided at your
6759           option.</p>
6760       </sect>
6761
6762       <sect id="copyrightfile">
6763         <heading>Copyright information</heading>
6764
6765         <p>
6766           Every package must be accompanied by a verbatim copy of its
6767           copyright and distribution license in the file
6768           /usr/share/doc/&lt;package-name&gt;/copyright. This file must
6769           neither be compressed nor be a symbolic link.</p>
6770
6771         <p>
6772           In addition, the copyright file must say where the upstream
6773           sources (if any) were obtained, and should explain briefly what
6774           modifications were made in the Debian version of the package
6775           compared to the upstream one.  It should name the original
6776           authors of the package and the Debian maintainer(s) who were
6777           involved with its creation.</p>
6778
6779         <p>
6780           A copy of the file which will be installed in
6781           <tt>/usr/share/doc/<var>package</var>/copyright</tt> should be
6782           in <tt>debian/copyright</tt>.</p>
6783
6784
6785         <p>
6786           /usr/share/doc/&lt;package-name&gt; may be a symbolic link to a
6787           directory in /usr/share/doc only if two packages both come from
6788           the same source and the first package has a "Depends"
6789           relationship on the second.  These rules are important
6790           because copyrights must be extractable by mechanical
6791           means.</p>
6792
6793         <p>
6794           Packages distributed under the UCB BSD license, the Artistic
6795           license, the GNU GPL, and the GNU LGPL should refer to the
6796           files /usr/share/common-licenses/BSD,
6797           /usr/share/common-licenses/Artistic,
6798           /usr/share/common-licenses/GPL, and
6799           /usr/share/common-licenses/LGPL.
6800           <footnote>
6801             <p>
6802               Why "licenses" and not "copyright"? Because
6803               <tt>/usr/doc/copyright</tt> used to contain all the
6804               copyright files, plus the four common licenses GPL,
6805               LGPL, Artistic and BSD. Now individual copyright files
6806               for packages are no longer in a common directory. Once
6807               <tt>/usr/doc/copyright</tt> is almost empty it makes
6808               sense to rename "copyright" to "licenses"
6809             </p>
6810             <p>
6811               Why "common-licenses" and not "licenses"? Because if I
6812               put just "licenses" I'm sure I will receive a bug report
6813               saying "license foo is not included in the licenses
6814               directory. They are not all the licenses, just a few
6815               common ones. I could use /usr/share/doc/common-licenses
6816               but I think this is too long, and, after all, the GPL
6817               does not "document" anything, it is merely a license.
6818             </p>
6819           </footnote>
6820         </p>
6821
6822         <p>
6823           You should not use the copyright file as a general <tt>README</tt>
6824           file.  If your package has such a file it should be
6825           installed in <tt>/usr/share/doc/<var>package</var>/README</tt> or
6826           <tt>README.Debian</tt> or some other appropriate place.</p>
6827       </sect>
6828
6829       <sect>
6830         <heading>Examples</heading>
6831
6832         <p>
6833           Any examples (configurations, source files, whatever),
6834           should be installed in a directory
6835           <tt>/usr/share/doc/<var>package</var>/examples</tt>.  These
6836           files should not be referenced by any program--they're there
6837           for the benefit of the system administrator and users, as
6838           documentation only. Architecture-specific example files
6839           should be installed in a directory
6840           <tt>/usr/lib/<var>package</var>/examples</tt>, and files in
6841           <tt>/usr/share/doc/<var>package</var>/examples</tt> symlink
6842           to files in it. Or the latter directory may be a symlink to
6843           the former.</p>
6844       </sect>
6845
6846       <sect id="instchangelog">
6847         <heading>Changelog files</heading>
6848
6849         <p>
6850           Packages that are not Debian-native must contain a copy of
6851           <tt>debian/changelog</tt> file from the Debian source tree
6852           in <tt>/usr/share/doc/<var>package</var></tt> as
6853           <tt>changelog.Debian.gz</tt>. If an upstream changelog is
6854           available, it should be accessible as
6855           <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt> in
6856           plain text. If the upstream changelog is distributed in
6857           HTML, it should be made available in that form as
6858           <tt>/usr/share/doc/<var>package</var>/changelog.html.gz</tt>
6859           and the <tt>changelog.gz</tt> should be generated using, eg,
6860           <tt>lynx -dump -nolist</tt>. If the upstream changelog files
6861           do not already conform to this naming convention, then this
6862           may be achieved either by renaming the files, or adding a
6863           symbolic link, at the maintainer's discretion.
6864           <footnote>
6865             <p>
6866               Rationale: People should not have to look into two
6867               places for upstream changelogs merely because they are
6868               in HTML format.
6869             </p>
6870           </footnote>
6871         </p>
6872
6873
6874         <p>
6875           All these files should be installed compressed using <tt>gzip -9</tt>,
6876           as they will become large with time even if they start out
6877           small.
6878         </p>
6879
6880         <p>
6881           If the package has only one changelog which is used both as
6882           the Debian changelog and the upstream one because there is
6883           no separate upstream maintainer then that changelog should
6884           usually be installed as
6885           <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>; if
6886           there is a separate upstream maintainer, but no upstream
6887           changelog, then the Debian changelog should still be called
6888           <tt>changelog.Debian.gz</tt>.</p>
6889       </sect>
6890     </chapt>
6891   </book>
6892 </debiandoc>