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