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