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