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