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