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