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