]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
* Fixed a couple of typos closes
[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
48         the operating system, as well as technical requirements that
49         each package must satisfy to be included in the distribution.
50         The policy package itself is maintained by a group of
51         maintainers that have no editorial powers.  The current list
52         of 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           <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
87           distribution or on the World Wide Web at
88           <url id="http://www.gnu.org/copyleft/gpl.html"
89                name="The GNU General Public Licence">. You can also
90           obtain it by writing to the Free Software Foundation, Inc.,
91           59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
92         </p>
93       </copyright>
94     </titlepag>
95
96     <toc detail="sect">
97
98     <chapt id="scope">
99       <heading>About this manual</heading>
100       <sect>
101         <heading>Scope</heading>
102         <p>
103           This manual describes the policy requirements for the Debian
104           GNU/Linux distribution. This includes the structure and
105           contents of the Debian archive and several design issues of the
106           operating system, as well as technical requirements that
107           each package must satisfy to be included in the
108           distribution.
109         </p>
110
111
112         <p>
113           This manual also describes Debian policy as it relates to
114           creating Debian packages. It is not a tutorial on how to build
115           packages, nor is it exhaustive where it comes to describing
116           the behavior of the packaging system. Instead, this manual
117           attempts to define the interface to the package management
118           system that the developers have to be conversant with.<footnote>
119             <p>
120               Informally, the criteria used for inclusion is that the
121               material meet one of the following requirements:
122               <taglist compact="compact">
123                 <tag>Standard interfaces</tag>
124                 <item>
125                   <p>
126                     The material presented represents an interface to
127                     the packaging system that is mandated for use, and
128                     is used by, a significant number of packages, and
129                     therefore should not be changed without peer
130                     review. Package maintainers can then rely on this
131                     interfaces not changing, and the package
132                     management software authors need to ensure
133                     compatibility with these interface
134                     definitions. (Control file and changelog file
135                     formats are examples.)
136                   </p>
137                 </item>
138                 <tag>Chosen Convention</tag>
139                 <item>
140                   <p>
141                     If there are a number of technically viable choices
142                     that can be made, but one needs to select one of
143                     these options for inter-operability. The version
144                     number format is one example.
145                   </p>
146                 </item>
147               </taglist>
148               Please note that these are not mutually exclusive;
149               selected conventions often become parts of standard
150               interfaces.
151             </p>
152           </footnote>
153         </p>
154
155         <p>
156           The footnotes present in this manual are
157           merely informative, and are not part of Debian policy itself.
158         </p>
159
160
161         <p>
162           In this manual, the words <em>must</em>, <em>should</em> and
163           <em>may</em>, and the adjectives <em>required</em>,
164           <em>recommended</em> and <em>optional</em>, are used to
165           distinguish the significance of the various guidelines in
166           this policy document. Packages that do not conform to the
167           guidelines denoted by <em>must</em> (or <em>required</em>)
168           will generally not be considered acceptable for the Debian
169           distribution. Non-conformance with guidelines denoted by
170           <em>should</em> (or <em>recommended</em>) will generally be
171           considered a bug, but will not necessarily render a package
172           unsuitable for distribution. Guidelines denoted by
173           <em>may</em> (or <em>optional</em>) are truly optional and
174           adherence is left to the maintainer's discretion.
175         </p>
176         <p>
177           These classifications are roughly equivalent to the bug
178           severities <em>serious</em> (for <em>must</em> or
179           <em>required</em> directive violations), <em>minor</em>,
180           <em>normal</em> or <em>important</em>
181           (for <em>should</em> or <em>recommended</em> directive
182           violations) and <em>wishlist</em> (for <em>optional</em>
183           items).<footnote>
184             <p>Compare RFC 2119.  Note, however, that these words are
185           used in a different way in this document.</p>
186           </footnote>
187         </p>
188         <p>
189           Much of the information presented in this manual will be
190           useful even when building a package which is to be
191           distributed in some other way or is intended for local use
192           only.
193         </p>
194       </sect>
195       <sect>
196         <heading>New versions of this document</heading>
197         <p>
198           The current version of this document is always accessible
199           from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
200           as
201           <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
202           (also available from the same directory are several other
203           formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
204           and <file>policy.ps.gz</file>) or from the <url
205           id="http://www.debian.org/doc/debian-policy/" name="Debian
206           Policy Manual"> webpage.</p>
207
208         <p>
209           In addition, this manual is distributed via the Debian package
210           <file>debian-policy</file>.
211         </p>
212
213         <p>
214           The <tt>debian-policy</tt> package also includes the file
215           <file>upgrading-checklist.txt</file> which indicates policy
216           changes between versions of this document.
217         </p>
218       </sect>
219       <sect>
220         <heading>Feedback</heading>
221
222         <p>
223           As the Debian GNU/Linux system is continuously evolving this
224           manual does so too.
225         </p>
226         <p>
227           While the authors of this document have tried hard to avoid
228           typos and other errors, these do still occur. If you discover
229           an error in this manual or if you want to give any
230           comments, suggestions, or criticisms please send an email to
231           the Debian Policy List,
232           <email>debian-policy@lists.debian.org</email>, or submit a
233           bug report against the <tt>debian-policy</tt> package.
234         </p>
235       </sect>
236     </chapt>
237
238     <chapt id="archive">
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.<footnote>
541                     <p>
542                       It is possible that there are policy
543                       requirements which the package is unable to
544                       meet, for example, if the source is
545                       unavailable.  These situations will need to be
546                       handled on a case-by-case basis.
547                     </p>
548                   </footnote>
549                 </p>
550               </item>
551             </list>
552           </p>
553         </sect1>
554
555         <sect1>
556           <heading>The non-US sections</heading>
557           <p>
558             Some programs with cryptographic program code need to be
559             stored on the <em>non-US</em> server because of United
560             States export restrictions.  Such programs must be
561             distributed in the appropriate <em>non-US</em> section,
562             either <em>non-US/main</em>, <em>non-US/contrib</em> or
563             <em>non-US/non-free</em>.
564           </p>
565           <p>
566             This applies only to packages which contain cryptographic
567             code. A package containing a program with an interface to
568             a cryptographic program or a program that's dynamically
569             linked against a cryptographic library should not be
570             distributed via the <em>non-US</em> server if it is
571             capable of running without the cryptographic library or
572             program.
573           </p>
574         </sect1>
575         <sect1>
576           <heading>Further copyright considerations</heading>
577           <p>
578             Every package must be accompanied by a verbatim copy of
579             its copyright and distribution license in the file
580             <file>/usr/share/doc/<var>package</var>/copyright</file>
581             (see <ref id="copyrightfile"> for further details).
582           </p>
583           <p>
584             We reserve the right to restrict files from being included
585             anywhere in our archives if
586             <list compact="compact">
587               <item>
588                 <p>
589                   their use or distribution would break a law,
590                 </p>
591               </item>
592               <item>
593                 <p>
594                   there is an ethical conflict in their distribution or
595                   use,
596                 </p>
597               </item>
598               <item>
599                 <p>
600                   we would have to sign a license for them, or
601                 </p>
602               </item>
603               <item>
604                 <p>
605                   their distribution would conflict with other project
606                   policies.
607                 </p>
608               </item>
609             </list>
610           </p>
611
612           <p>
613             Programs whose authors encourage the user to make
614             donations are fine for the main distribution, provided
615             that the authors do not claim that not donating is
616             immoral, unethical, illegal or something similar; in such
617             a case they must go in <em>non-free</em>.</p>
618
619           <p>
620             Packages whose copyright permission notices (or patent
621             problems) do not even allow redistribution of binaries
622             only, and where no special permission has been obtained,
623             must not be placed on the Debian FTP site and its mirrors
624             at all.</p>
625
626           <p>
627             Note that under international copyright law (this applies
628             in the United States, too), <em>no</em> distribution or
629             modification of a work is allowed without an explicit
630             notice saying so.  Therefore a program without a copyright
631             notice <em>is</em> copyrighted and you may not do anything
632             to it without risking being sued! Likewise if a program
633             has a copyright notice but no statement saying what is
634             permitted then nothing is permitted.</p>
635
636           <p>
637             Many authors are unaware of the problems that restrictive
638             copyrights (or lack of copyright notices) can cause for
639             the users of their supposedly-free software.  It is often
640             worthwhile contacting such authors diplomatically to ask
641             them to modify their license terms. However, this can be a
642             politically difficult thing to do and you should ask for
643             advice on the <tt>debian-legal</tt> mailing list first, as
644             explained below.
645           </p>
646
647           <p>
648             When in doubt about a copyright, send mail to
649             <email>debian-legal@lists.debian.org</email>.  Be prepared
650             to provide us with the copyright statement.  Software
651             covered by the GPL, public domain software and BSD-like
652             copyrights are safe; be wary of the phrases `commercial
653             use prohibited' and `distribution restricted'.
654           </p>
655         </sect1>
656         <sect1>
657           <heading>Subsections</heading>
658
659           <p>
660             The packages in the sections <em>main</em>,
661             <em>contrib</em> and <em>non-free</em> are grouped further
662             into <em>subsections</em> to simplify handling.
663           </p>
664
665           <p>
666             The section and subsection for each package should be
667             specified in the package's <tt>Section</tt> control
668             record.  However, the maintainer of the Debian archive
669             may override this selection to ensure the consistency of
670             the Debian distribution.  The <tt>Section</tt> field
671             should be of the form:
672             <list compact="compact">
673               <item>
674                 <p>
675                   <em>subsection</em> if the package is in the
676                   <em>main</em> section,
677                 </p>
678               </item>
679               <item>
680                 <p>
681                   <em>section/subsection</em> if the package is in
682                   the <em>contrib</em> or <em>non-free</em> section,
683                   and
684                 </p>
685               </item>
686               <item>
687                 <p>
688                   <tt>non-US</tt>, <tt>non-US/contrib</tt> or
689                   <tt>non-US/non-free</tt> if the package is in
690                   <em>non-US/main</em>, <em>non-US/contrib</em> or
691                   <em>non-US/non-free</em> respectively.
692                 </p>
693               </item>
694             </list>
695           </p>
696
697           <p>
698             The Debian archive maintainers provide the authoritative
699             list of subsections.  At present, they are:
700             <em>admin</em>, <em>base</em>, <em>comm</em>,
701             <em>contrib</em>, <em>devel</em>, <em>doc</em>,
702             <em>editors</em>, <em>electronics</em>, <em>games</em>,
703             <em>graphics</em>, <em>hamradio</em>,
704             <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
705             <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
706             <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
707             <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
708             <em>sound</em>, <em>tex</em>, <em>text</em>,
709             <em>utils</em>, <em>web</em>, <em>x11</em>.
710           </p>
711         </sect1>
712       <sect>
713         <heading>Priorities</heading>
714
715         <p>
716           Each package should have a <em>priority</em> value, which is
717           included in the package's <em>control record</em>. This
718           information is used by the Debian package management tools
719           to separate high-priority packages from less-important
720           packages.</p>
721
722         <p>
723           The following <em>priority levels</em> are recognised by the
724           Debian package management tools.
725           <taglist>
726             <tag><tt>required</tt></tag>
727             <item>
728               <p>
729                 Packages which are necessary for the proper
730                 functioning of the system.  You must not remove these
731                 packages or your system may become totally broken and
732                 you may not even be able to use <prgn>dpkg</prgn> to
733                 put things back.  Systems with only the
734                 <tt>required</tt> packages are probably unusable, but
735                 they do have enough functionality to allow the
736                 sysadmin to boot and install more software.</p>
737             </item>
738             <tag><tt>important</tt></tag>
739             <item>
740               <p>
741                 Important programs, including those which one would
742                 expect to find on any Unix-like system.  If the
743                 expectation is that an experienced Unix person who
744                 found it missing would say `What on earth is going on,
745                 where is <prgn>foo</prgn>?', it must be an
746                 <tt>important</tt> package.<footnote>
747                   <p>
748                     This is an important criterion because we are
749                     trying to produce, amongst other things, a free
750                     Unix.
751                   </p>
752                 </footnote>
753                 Other packages without which the system will not run
754                 well or be usable must also have priority
755                 <tt>important</tt>.  This does
756                 <em>not</em> include Emacs, the X Window System, TeX
757                 or any other large applications.  The
758                 <tt>important</tt> packages are just a bare minimum of
759                 commonly-expected and necessary tools.</p>
760             </item>
761             <tag><tt>standard</tt></tag>
762             <item>
763               <p>
764                 These packages provide a reasonably small but not too
765                 limited character-mode system.  This is what will be
766                 installed by default if the user doesn't select anything
767                 else.  It doesn't include many large applications.</p>
768             </item>
769             <tag><tt>optional</tt></tag>
770             <item>
771               <p>
772                 (In a sense everything that isn't required is
773                 optional, but that's not what is meant here.) This is
774                 all the software that you might reasonably want to
775                 install if you didn't know what it was and don't have
776                 specialized requirements. This is a much larger system
777                 and includes the X Window System, a full TeX
778                 distribution, and many applications. Note that
779                 optional packages should not conflict with each other.
780               </p>
781             </item>
782             <tag><tt>extra</tt></tag>
783             <item>
784               <p>
785                 This contains all packages that conflict with others
786                 with required, important, standard or optional
787                 priorities, or are only likely to be useful if you
788                 already know what they are or have specialised
789                 requirements.
790               </p>
791             </item>
792           </taglist></p>
793
794         <p>
795           Packages must not depend on packages with lower priority
796           values (excluding build-time dependencies).  In order to
797           ensure this, the priorities of one or more packages may need
798           to be adjusted.
799         </p>
800       </sect>
801
802       <sect>
803         <heading>Binary packages</heading>
804
805         <p>
806           The Debian GNU/Linux distribution is based on the Debian
807           package management system, called <prgn>dpkg</prgn>. Thus,
808           all packages in the Debian distribution must be provided
809           in the <tt>.deb</tt> file format.</p>
810
811
812         <sect1>
813           <heading>The package name</heading>
814
815           <p>
816             Every package must have a name that's unique within the Debian
817             archive.</p>
818
819           <p>
820             Package names must consist of lower case letters
821             (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
822             and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
823             They must be at least two characters long and must contain
824             at least one letter.
825           </p>
826
827           <p>
828             The package name is part of the file name of the
829             <tt>.deb</tt> file and is included in the control field
830             information.
831           </p>
832         </sect1>
833
834         <sect1>
835           <heading>The maintainer of a package</heading>
836          <p>
837             Every package must have a Debian maintainer (the
838             maintainer may be one person or a group of people
839             reachable from a common email address, such as a mailing
840             list).  The maintainer is responsible for ensuring that
841             the package is placed in the appropriate distributions.
842           </p>
843
844           <p>
845             The maintainer must be specified in the
846             <tt>Maintainer</tt> control field with their correct name
847             and a working email address.  If one person maintains
848             several packages, he/she should try to avoid having
849             different forms of their name and email address in
850             the <tt>Maintainer</tt> fields of those packages.
851           </p>
852
853           <p>
854             If the maintainer of a package quits from the Debian
855             project, "Debian QA Group"
856             <email>packages@qa.debian.org</email> takes over the
857             maintainership of the package until someone else
858             volunteers for that task. These packages are called
859             <em>orphaned packages</em>.<footnote>
860               <p>
861                 The detailed procedure for doing this gracefully can
862                 be found in the Debian Developer's Reference, either
863                 in the <tt>developers-reference</tt> package, or on
864                 the Debian FTP server
865                 <ftpsite>ftp.debian.org</ftpsite> as
866                 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
867                 or from the <url
868                 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
869                 name="Debian Developer's Reference"> webpage.
870               </p>
871             </footnote>
872           </p>
873         </sect1>
874
875
876         <sect1>
877           <heading>The description of a package</heading>
878
879           <p>
880             Every Debian package must have an extended description
881             stored in the appropriate field of the control record.</p>
882
883           <p>
884             The description should be written so that it gives the
885             system administrator enough information to decide whether
886             to install the package. This description should not just
887             be copied verbatim from the program's documentation.
888             Instructions for configuring or using the package should
889             not be included (that is what installation scripts,
890             manual pages, info files, etc., are for).  Copyright
891             statements and other administrivia should not be included
892             either (that is what the copyright file is for).
893           </p>
894         </sect1>
895
896
897         <sect1>
898           <heading>Dependencies</heading>
899
900           <p>
901             Every package must specify the dependency information
902             about other packages that are required for the first to
903             work correctly.</p>
904
905           <p>
906             For example, a dependency entry must be provided for any
907             shared libraries required by a dynamically-linked executable
908             binary in a package.</p>
909
910           <p>
911             Packages are not required to declare any dependencies they
912             have on other packages which are marked <tt>Essential</tt>
913             (see below), and should not do so unless they depend on a
914             particular version of that package.</p>
915
916           <p>
917             Sometimes, a package requires another package to be installed
918             <em>and</em> configured before it can be installed. In this
919             case, you must specify a <tt>Pre-Depends</tt> entry for
920             the package.</p>
921
922           <p>
923             You should not specify a <tt>Pre-Depends</tt> entry for a
924             package before this has been discussed on the
925             <tt>debian-devel</tt> mailing list and a consensus about
926             doing that has been reached.</p></sect1>
927
928
929         <sect1>
930           <heading>Virtual packages</heading>
931
932           <p>
933             Sometimes, there are several packages which offer
934             more-or-less the same functionality. In this case, it's
935             useful to define a <em>virtual package</em> whose name
936             describes that common functionality.  (The virtual
937             packages only exist logically, not physically; that's why
938             they are called <em>virtual</em>.) The packages with this
939             particular function will then <em>provide</em> the virtual
940             package. Thus, any other package requiring that function
941             can simply depend on the virtual package without having to
942             specify all possible packages individually.</p>
943
944           <p>
945             All packages should use virtual package names where
946             appropriate, and arrange to create new ones if necessary.
947             They should not use virtual package names (except privately,
948             amongst a cooperating group of packages) unless they have
949             been agreed upon and appear in the list of virtual package
950             names.</p>
951
952           <p>
953             The latest version of the authoritative list of virtual
954             package names can be found on
955             <ftpsite>ftp.debian.org</ftpsite> in
956             <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
957             or your local mirror. In addition, it is included in the
958             <tt>debian-policy</tt> package. The procedure for updating
959             the list is described at the top of the file.</p></sect1>
960
961
962         <sect1>
963           <heading>Base packages</heading>
964
965           <p>
966             The packages included in the <tt>base</tt> section have a
967             special function. They form a minimum subset of the Debian
968             GNU/Linux system that is installed before everything else
969             on a new system. Thus, only very few packages are allowed
970             to go into the <tt>base</tt> section to keep the required
971             disk usage very small.</p>
972
973           <p>
974             Most of these packages will have the priority value
975             <tt>required</tt> or at least <tt>important</tt>, and many
976             of them will be tagged <tt>essential</tt> (see below).</p>
977
978           <p>
979             You must not place any packages into the <tt>base</tt>
980             section before this has been discussed on the
981             <tt>debian-devel</tt> mailing list and a consensus about
982             doing that has been reached.</p></sect1>
983
984
985         <sect1>
986           <heading>Essential packages</heading>
987
988           <p>
989             Some packages are tagged <tt>essential</tt>. (They have
990             <tt>Essential: yes</tt> in their package control record.)
991             This flag is used for packages that are <em>essential</em>
992             for a system.</p>
993
994           <p>
995             Since these packages cannot be easily removed (one has to
996             specify an extra <em>force option</em> to
997             <prgn>dpkg</prgn> to do so), this flag must not be used
998             unless absolutely necessary.  A shared library package
999             must not be tagged <tt>essential</tt>; dependencies will
1000             prevent its premature removal, and we need to be able to
1001             remove it when it has been superseded.
1002           </p>
1003
1004           <p>
1005             Since dpkg will not prevent upgrading of other packages
1006             while an <tt>essential</tt> package is in an unconfigured
1007             state, all <tt>essential</tt> packages must supply all of
1008             their core functionality even when unconfigured. If the
1009             package cannot satisfy this requirement it must not be
1010             tagged as essential, and any packages depending on this
1011             package must instead have explicit dependency fields as
1012             appropriate.
1013           </p>
1014
1015           <p>
1016             You must not tag any packages <tt>essential</tt> before
1017             this has been discussed on the <tt>debian-devel</tt>
1018             mailing list and a consensus about doing that has been
1019             reached.
1020           </p>
1021         </sect1>
1022
1023         <sect1 id="maintscripts">
1024           <heading>Maintainer scripts</heading>
1025
1026           <p>
1027             The package installation scripts should avoid producing
1028             output which it is unnecessary for the user to see and
1029             should rely on <prgn>dpkg</prgn> to stave off boredom on
1030             the part of a user installing many packages.  This means,
1031             amongst other things, using the <tt>--quiet</tt> option on
1032             <prgn>install-info</prgn>.</p>
1033
1034           <p>
1035             Errors which occur during the execution of an installation
1036             script must be checked and the installation must not
1037             continue after an error.
1038           </p>
1039
1040           <p>
1041             Note that in general <ref id="scripts"> applies to package
1042             maintainer scripts, too.
1043           </p>
1044
1045           <p>
1046             You should not use <prgn>dpkg-divert</prgn> on a file
1047             belonging to another package without consulting the
1048             maintainer of that package first.
1049           </p>
1050
1051           <p>
1052             All packages which supply an instance of a common command
1053             name (or, in general, filename) should generally use
1054             <prgn>update-alternatives</prgn>, so that they may be
1055             installed together.  If <prgn>update-alternatives</prgn>
1056             is not used, then each package must use
1057             <tt>Conflicts</tt> to ensure that other packages are
1058             de-installed.  (In this case, it may be appropriate to
1059             specify a conflict against earlier versions of something
1060             that previously did not use
1061             <prgn>update-alternatives</prgn>; this is an exception to
1062             the usual rule that versioned conflicts should be
1063             avoided.)
1064           </p>
1065
1066
1067           <sect2>
1068             <heading>Prompting in maintainer scripts</heading>
1069             <p>
1070               Package maintainer scripts may prompt the user if
1071               necessary. Prompting may be accomplished by hand, or by
1072               communicating with a program, such as
1073               <prgn>debconf</prgn>, which conforms to the Debian
1074               Configuration management specification, version 2 or
1075               higher.  These are included in the
1076               <file>debconf_specification</file> files in the
1077               <package>debian-policy</package> package.
1078               You may also find this file on the FTP site
1079               <ftpsite>ftp.debian.org</ftpsite> in
1080               <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1081               or on your local mirror.<footnote>
1082                 <p>
1083                   4% of Debian packages [see <url
1084                   id="http://kitenet.net/programs/debconf/stats/"
1085                   name="Debconf stats">] currently use
1086                   <package>debconf</package> to prompt the user at
1087                   install time, and this number is growing daily. The
1088                   benefits of using debconf are briefly explained at
1089                   <url
1090                   id="http://kitenet.net/doc/debconf-doc/introduction.html"
1091                   name="Debconf introduction">; they include
1092                   preconfiguration, (mostly) noninteractive
1093                   installation, elimination of redundant prompting,
1094                   consistency of user interface, etc.
1095                 </p>
1096                 <p>
1097                   With this increasing number of packages using
1098                   <package>debconf</package>, plus the existance of a
1099                   nascent second implementation of the Debian
1100                   configuration management system
1101                   (<package>cdebconf</package>), and the stabilization
1102                   of the protocol these things use, the time has
1103                   finally come to reflect the use of these things in
1104                   policy.
1105
1106                 </p>
1107               </footnote>
1108             </p>
1109             <p>
1110               Packages which use the Debian Configuration management
1111               specification may contain an additional
1112               <prgn>config</prgn> script and a <tt>templates</tt>
1113               file in their control archive. The <prgn>config</prgn>
1114               script might be run before the <prgn>preinst</prgn>
1115               script, and before the package is unpacked or any of its
1116               dependencies or pre-dependancies are satisfied.
1117               Therefore it must work using only the tools present in
1118               <em>essential</em> packages.<footnote>
1119                 <p>
1120                   <package>Debconf</package> or another tool that
1121                   implements the Debian Configuration management
1122                   specification will also be installed, and any
1123                   versioned dependencies on it will be satisfied
1124                   before preconfiguration begins.
1125                 </p>
1126               </footnote>
1127             </p>
1128
1129             <p>
1130               Packages should try to minimize the amount of prompting
1131               they need to do, and they should ensure that the user
1132               will only ever be asked each question once.  This means
1133               that packages should try to use appropriate shared
1134               configuration files (such as <file>/etc/papersize</file> and
1135               <file>/etc/news/server</file>), and shared
1136               <package>debconf</package> variables rather than each
1137               prompting for their own list of required pieces of
1138               information.
1139             </p>
1140
1141             <p>
1142               It also means that an upgrade should not ask the same
1143               questions again, unless the user has used <tt>dpkg
1144                 --purge</tt> to remove the package's configuration.  The
1145               answers to configuration questions should be stored in an
1146               appropriate place in <file>/etc</file> so that the user can
1147               modify them, and how this has been done should be
1148               documented.</p>
1149
1150             <p>
1151               If a package has a vitally important piece of
1152               information to pass to the user (such as "don't run me
1153               as I am, you must edit the following configuration files
1154               first or you risk your system emitting badly-formatted
1155               messages"), it should display this in the
1156               <prgn>config</prgn> or <prgn>postinst</prgn> script and
1157               prompt the user to hit return to acknowledge the
1158               message.  Copyright messages do not count as vitally
1159               important (they belong in
1160               <file>/usr/share/doc/<var>package</var>/copyright</file>);
1161               neither do instructions on how to use a program (these
1162               should be in on-line documentation, where all the users
1163               can see them).</p>
1164
1165             <p>
1166               Any necessary prompting should almost always be confined
1167               to the <prgn>config</prgn> or <prgn>postinst</prgn>
1168               script. If it is done in the <prgn>postinst</prgn>, it
1169               should be protected with a conditional so that
1170               unnecessary prompting doesn't happen if a package's
1171               installation fails and the <prgn>postinst</prgn> is
1172               called with <tt>abort-upgrade</tt>,
1173               <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1174         </sect1>
1175       </sect>
1176
1177       <sect>
1178         <heading>Source packages</heading>
1179
1180         <sect1 id="standardsversion">
1181           <heading>Standards conformance</heading>
1182
1183           <p>
1184             In the source package's <tt>Standards-Version</tt> control
1185             field, you should specify the most recent version number
1186             of this policy document with which your package complied
1187             when it was last updated.  The current version number is
1188             &version;.
1189           </p>
1190
1191           <p>
1192             This information may be used to file bug reports
1193             automatically if your package becomes too much out of
1194             date.
1195           </p>
1196
1197           <p>
1198             The version number has four components: major and minor
1199             version number and major and minor patch level.  When the
1200             standards change in a way that requires every package to
1201             change the major number will be changed.  Significant
1202             changes that will require work in many packages will be
1203             signaled by a change to the minor number.  The major patch
1204             level will be changed for any change to the meaning of the
1205             standards, however small; the minor patch level will be
1206             changed when only cosmetic, typographical or other edits
1207             are made which neither change the meaning of the document
1208             nor affect the contents of packages.</p>
1209
1210           <p>
1211             Thus only the first three components of the policy version
1212             are significant in the <em>Standards-Version</em> control
1213             field, and so either these three components or the all
1214             four components may be specified.<footnote>
1215               <p>
1216                 In the past, people specified the full version number
1217                 in the Standards-Version field, for example `2.3.0.0'.
1218                 Since minor patch-level changes don't introduce new
1219                 policy, it was thought it would be better to relax
1220                 policy and only require the first 3 components to be
1221                 specified, in this example `2.3.0'.  All four
1222                 components may still be used if someone wishes to do
1223                 so.
1224               </p>
1225             </footnote>
1226           </p>
1227
1228           <p>
1229             You should regularly, and especially if your package has
1230             become out of date, check for the newest Policy Manual
1231             available and update your package, if necessary. When your
1232             package complies with the new standards you should update the
1233             <tt>Standards-Version</tt> source package field and
1234             release it.<footnote>
1235               <p>
1236                 See the file <file>upgrading-checklist</file> for
1237                 information about policy which has changed between
1238                 different versions of this document.
1239               </p>
1240             </footnote>
1241           </p>
1242         </sect1>
1243
1244
1245         <sect1>
1246           <heading>Package relationships</heading>
1247
1248           <p>
1249             Source packages should specify which binary packages they
1250             require to be installed or not to be installed in order to
1251             build correctly.  For example, if building a package
1252             requires a certain compiler, then the compiler should be
1253             specified as a build-time dependency.
1254           </p>
1255
1256           <p>
1257             It is not necessary to explicitly specify build-time
1258             relationships on a minimal set of packages that are always
1259             needed to compile, link and put in a Debian package a
1260             standard "Hello World!" program written in C or C++.  The
1261             required packages are called <em>build-essential</em>, and
1262             an informational list can be found in
1263             <file>/usr/share/doc/build-essential/list</file> (which is
1264             contained in the <tt>build-essential</tt>
1265             package).<footnote>
1266               <p>Rationale:
1267                 <list compact="compact">
1268                   <item>
1269                     <p>This allows maintaining the list separately
1270                       from the policy documents (the list does not
1271                       need the kind of control that the policy
1272                       documents do).
1273                     </p>
1274                   </item>
1275                   <item>
1276                     <p>
1277                       Having a separate package allows one to install
1278                       the build-essential packages on a machine, as
1279                       well as allowing other packages such as task
1280                       packages to require installation of the
1281                       build-essential packages using the depends
1282                       relation.
1283                     </p>
1284                   </item>
1285                   <item>
1286                     <p>
1287                       The separate package allows bug reports against
1288                       the list to be categorized separately from
1289                       the policy management process in the BTS.
1290                     </p>
1291                   </item>
1292                 </list>
1293               </p>
1294
1295             </footnote>
1296           </p>
1297
1298           <p>
1299             When specifying the set of build-time dependencies, one
1300             should list only those packages explicitly required by the
1301             build.  It is not necessary to list packages which are
1302             required merely because some other package in the list of
1303             build-time dependencies depends on them.<footnote>
1304               <p>
1305                 The reason for this is that dependencies change, and
1306                 you should list all those packages, and <em>only</em>
1307                 those packages that <em>you</em> need directly.  What
1308                 others need is their business.  For example, if you
1309                 only link against <file>libimlib</file>, you will need to
1310                 build-depend on <package>libimlib2-dev</package> but
1311                 not against any <tt>libjpeg*</tt> packages, even
1312                 though <tt>libimlib2-dev</tt> currently depends on
1313                 them: installation of <package>libimlib2-dev</package>
1314                 will automatically ensure that all of its run-time
1315                 dependencies are satisfied.
1316               </p>
1317             </footnote>
1318           </p>
1319
1320           <p>
1321             If build-time dependencies are specified, it must be
1322             possible to build the package and produce working binaries
1323             on a system with only essential and build-essential
1324             packages installed and also those required to satisfy the
1325             build-time relationships (including any implied
1326             relationships).  In particular, this means that version
1327             clauses should be used rigorously in build-time
1328             relationships so that one cannot produce bad or
1329             inconsistently configured packages when the relationships
1330             are properly satisfied.
1331           </p>
1332
1333         <sect1>
1334           <heading>Changes to the upstream sources</heading>
1335
1336           <p>
1337             If changes to the source code are made that are not
1338             specific to the needs of the Debian system, they should be
1339             sent to the upstream authors in whatever form they prefer
1340             so as to be included in the upstream version of the
1341             package.</p>
1342
1343           <p>
1344             If you need to configure the package differently for
1345             Debian or for Linux, and the upstream source doesn't
1346             provide a way to do so, you should add such configuration
1347             facilities (for example, a new <prgn>autoconf</prgn> test
1348             or <tt>#define</tt>) and send the patch to the upstream
1349             authors, with the default set to the way they originally
1350             had it.  You can then easily override the default in your
1351             <file>debian/rules</file> or wherever is appropriate.</p>
1352
1353           <p>
1354             You should make sure that the <prgn>configure</prgn> utility
1355             detects the correct architecture specification string
1356             (refer to <ref id="arch-spec"> for details).</p>
1357
1358           <p>
1359             If you need to edit a <prgn>Makefile</prgn> where
1360             GNU-style <prgn>configure</prgn> scripts are used, you
1361             should edit the <file>.in</file> files rather than editing the
1362             <prgn>Makefile</prgn> directly.  This allows the user to
1363             reconfigure the package if necessary.  You should
1364             <em>not</em> configure the package and edit the generated
1365             <prgn>Makefile</prgn>!  This makes it impossible for
1366             someone else to later reconfigure the package.</p></sect1>
1367
1368
1369         <sect1>
1370           <heading>Documenting your changes</heading>
1371
1372           <p>
1373             You should document your changes and updates to the source
1374             package properly in the <file>debian/changelog</file> file. (Note
1375             that mistakes in changelogs are usually best rectified by
1376             making a new changelog entry rather than "rewriting history"
1377             by editing old changelog entries.)</p>
1378
1379           <p>
1380             In non-experimental packages you must use a format for
1381             <file>debian/changelog</file> which is supported by the most
1382             recent released version of <prgn>dpkg</prgn>.<footnote>
1383               <p>
1384                 If you wish to use an alternative format, you may do
1385                 so as long as you include a parser for it in your
1386                 source package.  The parser must have an API
1387                 compatible with that expected by
1388                 <prgn>dpkg-genchanges</prgn> and
1389                 <prgn>dpkg-gencontrol</prgn>.  If there is general
1390                 interest in the new format, you should contact the
1391                 <package>dpkg</package> maintainer to have the parser
1392                 script for it included in the <prgn>dpkg</prgn>
1393                 package.  (You will need to agree that the parser and
1394                 its manpage may be distributed under the GNU GPL, just
1395                 as the rest of `dpkg' is.)
1396               </p>
1397             </footnote>
1398           </p>
1399         </sect1>
1400
1401
1402         <sect1>
1403           <heading>Error trapping in makefiles</heading>
1404
1405           <p>
1406             When <prgn>make</prgn> invokes a command in a makefile
1407             (including your package's upstream makefiles and
1408             <file>debian/rules</file>), it does so using <prgn>sh</prgn>.  This
1409             means that <prgn>sh</prgn>'s usual bad error handling
1410             properties apply: if you include a miniature script as one
1411             of the commands in your makefile you'll find that if you
1412             don't do anything about it then errors are not detected
1413             and <prgn>make</prgn> will blithely continue after
1414             problems.</p>
1415
1416           <p>
1417             Every time you put more than one shell command (this
1418             includes using a loop) in a makefile command you
1419             must make sure that errors are trapped.  For
1420             simple compound commands, such as changing directory and
1421             then running a program, using <tt>&amp;&amp;</tt> rather
1422             than semicolon as a command separator is sufficient.  For
1423             more complex commands including most loops and
1424             conditionals you should include a separate <tt>set -e</tt>
1425             command at the start of every makefile command that's
1426             actually one of these miniature shell scripts.</p></sect1>
1427
1428
1429         <sect1>
1430           <heading>Obsolete constructs and libraries</heading>
1431
1432           <p>
1433             The include file <tt>&lt;varargs.h&gt;</tt> is
1434             provided to support end-users compiling very old software;
1435             the library <tt>libtermcap</tt> is provided to support the
1436             execution of software which has been linked against it
1437             (either old programs or those such as Netscape which are
1438             only available in binary form).</p>
1439
1440           <p>
1441             Debian packages should be patched to use
1442             <tt>&lt;stdarg.h&gt;</tt> and <tt>ncurses</tt>
1443             instead.
1444           </p>
1445         </sect1>
1446       </sect>
1447     </chapt>
1448
1449     <chapt id="controlfields"><heading>Control files and their fields</heading>
1450
1451       <p>
1452         Many of the tools in the package management suite manipulate
1453         data represented in a common format, known as <em>control
1454         data</em>.  The data is often stored in <em>control
1455         files</em>.  Binary and source packages have control files,
1456         and the <file>.changes</file> files which control the installation
1457         of uploaded files are also in control file format.
1458         <prgn>Dpkg</prgn>'s internal databases are in a similar
1459         format.
1460       </p>
1461
1462       <sect id="controlsyntax"><heading>Syntax of control files</heading>
1463
1464         <p>
1465           A control file consists of one or more paragraphs of fields.
1466           The paragraphs are separated by blank lines.  Some control
1467           files allow only one paragraph; others allow several, in
1468           which case each paragraph usually refers to a different
1469           package.  (For example, in source packages, the first
1470           paragraph refers to the source package, and later paragraphs
1471           refer to binary packages generated from the source.)
1472         </p>
1473
1474         <p>
1475           Each paragraph consists of a series of data fields; each
1476           field consists of the field name, followed by a colon and
1477           then the data/value associated with that field.  It ends at
1478           the end of the line.  Horizontal whitespace (spaces and
1479           tabs) may occur immediately before or after the value and is
1480           ignored there; it is conventional to put a single space
1481           after the colon.  For example, a field might be:
1482           <example compact="compact">
1483 Package: libc6
1484           </example>
1485           the field name is <tt>Package</tt> and the field value
1486           <tt>libc6</tt>.
1487         </p>
1488
1489         <p>
1490           Some fields' values may span several lines; in this case
1491           each continuation line <em>must</em> start with a space or
1492           tab.  Any trailing spaces or tabs at the end of individual
1493           lines of a field value are ignored.
1494         </p>
1495
1496         <p>
1497           Except where otherwise stated only a single line of data is
1498           allowed and whitespace is not significant in a field body.
1499           Whitespace must not appear inside names (of packages,
1500           architectures, files or anything else) or version numbers,
1501           or between the characters of multi-character version
1502           relationships.
1503         </p>
1504
1505         <p>
1506           Field names are not case-sensitive, but it is usual to
1507           capitalize the field names using mixed case as shown below.
1508         </p>
1509
1510         <p>
1511           Blank lines, or lines consisting only of spaces and tabs,
1512           are not allowed within field values or between fields - that
1513           would mean a new paragraph.
1514         </p>
1515
1516       </sect>
1517
1518       <sect><heading>List of fields</heading>
1519         <p>
1520           This list here is not supposed to be exhaustive. Most fields
1521           are dealt with elsewhere in this document.
1522         </p>
1523         <sect1 id="f-Package"><heading><tt>Package</tt>
1524           </heading>
1525
1526           <p>
1527             The name of the binary package.  Package names consist of
1528             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
1529             (plus, minus and full stop).
1530           </p>
1531
1532           <p>
1533             They must be at least two characters long and must start
1534             with an alphanumeric character and not be all digits.  The
1535             use of lowercase package names is strongly recommended
1536             unless the package you're building (or referring to, in
1537             other fields) is already using uppercase.</p>
1538         </sect1>
1539
1540         <sect1 id="f-Version"><heading><tt>Version</tt>
1541           </heading>
1542
1543           <p>
1544             This lists the source or binary package's version number -
1545             see <ref id="versions">.
1546           </p>
1547
1548         </sect1>
1549
1550         <sect1
1551                id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1552           </heading>
1553
1554           <p>
1555             The most recent version of the standards (the policy
1556             manual and associated texts) with which the package
1557             complies.  This is updated manually when editing the
1558             source package to conform to newer standards; it can
1559             sometimes be used to tell when a package needs attention.
1560             Its format is described above; see
1561             <ref id="standardsversion">.
1562           </p>
1563         </sect1>
1564
1565
1566         <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1567           </heading>
1568
1569           <p>
1570             In a <file>.changes</file> file or parsed changelog output
1571             this contains the (space-separated) name(s) of the
1572             distribution(s) where this version of the package should
1573             be installed.  Valid distributions are determined by the
1574             archive maintainers.<footnote>
1575                 Current distribution names are:
1576                 <taglist compact="compact">
1577                   <tag><em>stable</em></tag>
1578                   <item>
1579                     <p>
1580                       This is the current `released' version of Debian
1581                       GNU/Linux.  Once the distribution is
1582                       <em>stable</em> only security fixes and other
1583                       major bug fixes are allowed. When changes are
1584                       made to this distribution, the release number is
1585                       increased (for example: 2.2r1 becomes 2.2r2 then
1586                       2.2r3, etc).
1587                     </p>
1588                   </item>
1589
1590                   <tag><em>unstable</em></tag>
1591                   <item>
1592                     <p>
1593                       This distribution value refers to the
1594                       <em>developmental</em> part of the Debian
1595                       distribution tree. New packages, new upstream
1596                       versions of packages and bug fixes go into the
1597                       <em>unstable</em> directory tree. Download from
1598                       this distribution at your own risk.
1599                     </p>
1600                   </item>
1601
1602                   <tag><em>testing</em></tag>
1603                   <item>
1604                     <p>
1605                       This distribution value refers to the
1606                       <em>testing</em> part of the Debian distribution
1607                       tree.  It receives its packages from the
1608                       unstable distribution after a short time lag to
1609                       ensure that there are no major issues with the
1610                       unstable packages.  It is less prone to breakage
1611                       than unstable, but still risky.  It is not
1612                       possible to upload packages directly to
1613                       <em>testing</em>.
1614                     </p>
1615                   </item>
1616
1617                   <tag><em>frozen</em></tag>
1618                   <item>
1619                     <p>
1620                       From time to time, the <em>testing</em>
1621                       distribution enters a state of `code-freeze' in
1622                       anticipation of release as a <em>stable</em>
1623                       version. During this period of testing only
1624                       fixes for existing or newly-discovered bugs will
1625                       be allowed.  The exact details of this stage are
1626                       determined by the Release Manager.
1627                     </p>
1628                   </item>
1629
1630                   <tag><em>experimental</em></tag>
1631                   <item>
1632                     <p>
1633                       The packages with this distribution value are
1634                       deemed by their maintainers to be high
1635                       risk. Oftentimes they represent early beta or
1636                       developmental packages from various sources that
1637                       the maintainers want people to try, but are not
1638                       ready to be a part of the other parts of the
1639                       Debian distribution tree. Download at your own
1640                       risk.
1641                     </p>
1642                   </item>
1643                 </taglist>
1644
1645                 You should list <em>all</em> distributions that the
1646                 package should be installed into.
1647             </footnote>
1648           </p>
1649         </sect1>
1650
1651
1652       </sect>
1653     </chapt>
1654
1655     <chapt id="versions"><heading>Version numbering</heading>
1656
1657       <p>
1658         Every package has a version number recorded in its
1659         <tt>Version</tt> control file field.
1660       </p>
1661
1662       <p>
1663         The package management system imposes an ordering on version
1664         numbers, so that it can tell whether packages are being up- or
1665         downgraded and so that package system front end applications
1666         can tell whether a package it finds available is newer than
1667         the one installed on the system.  The version number format
1668         has the most significant parts (as far as comparison is
1669         concerned) at the beginning.
1670       </p>
1671
1672       <p>
1673         The version number format is:
1674         &lsqb;<var>epoch</var><tt>:</tt>&rsqb;<var>upstream_version</var>&lsqb;<tt>-</tt><var>debian_revision</var>&rsqb;
1675       </p>
1676
1677       <p>
1678         The three components here are:
1679         <taglist>
1680           <tag><var>epoch</var></tag>
1681           <item>
1682             <p>
1683               This is a single (generally small) unsigned integer.  It
1684               may be omitted, in which case zero is assumed.  If it is
1685               omitted then the <var>upstream_version</var> may not
1686               contain any colons.
1687             </p>
1688
1689             <p>
1690               It is provided to allow mistakes in the version numbers
1691               of older versions of a package, and also a package's
1692               previous version numbering schemes, to be left behind.
1693             </p>
1694           </item>
1695
1696           <tag><var>upstream_version</var></tag>
1697           <item>
1698             <p>
1699               This is the main part of the version number.  It is
1700               usually the version number of the original (`upstream')
1701               package from which the <file>.deb</file> file has been made,
1702               if this is applicable.  Usually this will be in the same
1703               format as that specified by the upstream author(s);
1704               however, it may need to be reformatted to fit into the
1705               package management system's format and comparison
1706               scheme.
1707             </p>
1708
1709             <p>
1710               The comparison behavior of the package management system
1711               with respect to the <var>upstream_version</var> is
1712               described below.  The <var>upstream_version</var>
1713               portion of the version number is mandatory.
1714             </p>
1715
1716             <p>
1717               The <var>upstream_version</var> may contain only
1718               alphanumerics<footnote>
1719                 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1720               </footnote>
1721               and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1722               <tt>:</tt> (full stop, plus, hyphen, colon) and should
1723               start with a digit.  If there is no
1724               <var>debian_revision</var> then hyphens are not allowed;
1725               if there is no <var>epoch</var> then colons are not
1726               allowed.</p>
1727           </item>
1728
1729           <tag><var>debian_revision</var></tag>
1730           <item>
1731             <p>
1732               This part of the version number specifies the version of
1733               the Debian package based on the upstream version.  It
1734               may contain only alphanumerics and the characters
1735               <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1736               compared in the same way as the
1737               <var>upstream_version</var> is.
1738             </p>
1739
1740             <p>
1741               It is optional; if it isn't present then the
1742               <var>upstream_version</var> may not contain a hyphen.
1743               This format represents the case where a piece of
1744               software was written specifically to be turned into a
1745               Debian package, and so there is only one `debianization'
1746               of it and therefore no revision indication is required.
1747             </p>
1748
1749             <p>
1750               It is conventional to restart the
1751               <var>debian_revision</var> at <tt>1</tt> each time the
1752               <var>upstream_version</var> is increased.
1753             </p>
1754
1755             <p>
1756               The package management system will break the version
1757               number apart at the last hyphen in the string (if there
1758               is one) to determine the <var>upstream_version</var> and
1759               <var>debian_revision</var>.  The absence of a
1760               <var>debian_revision</var> compares earlier than the
1761               presence of one (but note that the
1762               <var>debian_revision</var> is the least significant part
1763               of the version number).
1764             </p>
1765           </item>
1766         </taglist>
1767       </p>
1768
1769       <p>
1770         The <var>upstream_version</var> and <var>debian_revision</var>
1771         parts are compared by the package management system using the
1772         same algorithm:
1773       </p>
1774
1775       <p>
1776         The strings are compared from left to right.
1777       </p>
1778
1779       <p>
1780         First the initial part of each string consisting entirely of
1781         non-digit characters is determined.  These two parts (one of
1782         which may be empty) are compared lexically.  If a difference
1783         is found it is returned.  The lexical comparison is a
1784         comparison of ASCII values modified so that all the letters
1785         sort earlier than all the non-letters.
1786       </p>
1787
1788       <p>
1789         Then the initial part of the remainder of each string which
1790         consists entirely of digit characters is determined.  The
1791         numerical values of these two parts are compared, and any
1792         difference found is returned as the result of the comparison.
1793         For these purposes an empty string (which can only occur at
1794         the end of one or both version strings being compared) counts
1795         as zero.
1796       </p>
1797
1798       <p>
1799         These two steps (comparing and removing initial non-digit
1800         strings and initial digit strings) are repeated until a
1801         difference is found or both strings are exhausted.
1802       </p>
1803
1804       <p>
1805         Note that the purpose of epochs is to allow us to leave behind
1806         mistakes in version numbering, and to cope with situations
1807         where the version numbering scheme changes.  It is
1808         <em>not</em> intended to cope with version numbers containing
1809         strings of letters which the package management system cannot
1810         interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1811         silly orderings (the author of this manual has heard of a
1812         package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1813         <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1814         <tt>2</tt> and so forth).
1815       </p>
1816
1817       <p>
1818         If an upstream package has problematic version numbers they
1819         should be converted to a sane form for use in the
1820         <tt>Version</tt> field.
1821       </p>
1822
1823       <sect>
1824         <heading>Version numbers based on dates</heading>
1825         <p>
1826           In general, Debian packages should use the same version
1827           numbers as the upstream sources.</p>
1828
1829         <p>
1830           However, in some cases where the upstream version number is
1831           based on a date (e.g., a development `snapshot' release) the
1832           package management system cannot handle these version
1833           numbers without epochs. For example, dpkg will consider
1834           `96May01' to be greater than `96Dec24'.</p>
1835
1836         <p>
1837           To prevent having to use epochs for every new upstream
1838           version, the version number should be changed to the
1839           following format in such cases: `19960501', `19961224'. It
1840           is up to the maintainer whether he/she wants to bother the
1841           upstream maintainer to change the version numbers upstream,
1842           too.</p>
1843
1844         <p>
1845           Note that other version formats based on dates which are
1846           parsed correctly by the package management system should
1847           <em>not</em> be changed.</p>
1848
1849         <p>
1850           Native Debian packages (i.e., packages which have been
1851           written especially for Debian) whose version numbers include
1852           dates should always use the `YYYYMMDD' format.</p>
1853       </sect>
1854     </chapt>
1855
1856     <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1857
1858       <sect id="timestamps"><heading>Time Stamps</heading>
1859         <p>
1860           Maintainers should preserve the modification times of the
1861           upstream source files in a package, as far as is reasonably
1862           possible.<footnote>
1863             <p>
1864               The rationale is that there is some information conveyed
1865               by knowing the age of the file, for example, you could
1866               recognize that some documentation is very old by looking
1867               at the modification time, so it would be nice if the
1868               modification time of the upstream source would be
1869               preserved.
1870             </p>
1871           </footnote>
1872         </p>
1873       </sect>
1874
1875       <sect id="debianrules"><heading><file>debian/rules</file> - the
1876           main building script</heading>
1877
1878         <p>
1879           This file must be an executable makefile, and contains the
1880           package-specific recipes for compiling the package and
1881           building binary package(s) from the source.
1882         </p>
1883
1884         <p>
1885           It must start with the line <tt>#!/usr/bin/make -f</tt>,
1886           so that it can be invoked by saying its name rather than
1887           invoking <prgn>make</prgn> explicitly.
1888         </p>
1889
1890         <p>
1891           Since an interactive <file>debian/rules</file> script makes it
1892           impossible to auto-compile that package and also makes it
1893           hard for other people to reproduce the same binary
1894           package, all <em>required targets</em> MUST be
1895           non-interactive. At a minimum, required targets are the
1896           ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1897           <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1898           <em>binary-indep</em>, and <em>build</em>. It also follows
1899           that any target that these targets depend on must also be
1900           non-interactive.
1901         </p>
1902
1903         <p>
1904           The required and optional targets are as follows:
1905           <taglist>
1906             <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1907               <tt>build-indep</tt> (optional)</tag>
1908             <item>
1909               <p>
1910                 The <tt>build</tt> target should perform all
1911                 non-interactive configuration and compilation of the
1912                 package.  If a package has an interactive pre-build
1913                 configuration routine, the Debianized source package
1914                 must either be built after this has taken place (so
1915                 that the binary package can be built without rerunning
1916                 the configuration) or the configuration routine
1917                 modified to become non-interactive.  (The latter is
1918                 preferable if there are architecture-specific features
1919                 detected by the configuration routine.)
1920               </p>
1921
1922               <p>
1923                 For some packages, notably ones where the same
1924                 source tree is compiled in different ways to produce
1925                 two binary packages, the <tt>build</tt> target
1926                 does not make much sense.  For these packages it is
1927                 good enough to provide two (or more) targets
1928                 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1929                 for each of the ways of building the package, and a
1930                 <tt>build</tt> target that does nothing.  The
1931                 <tt>binary</tt> target will have to build the
1932                 package in each of the possible ways and make the
1933                 binary package out of each.
1934               </p>
1935
1936               <p>
1937                 The <tt>build</tt> target must not do anything
1938                 that might require root privilege.
1939               </p>
1940
1941               <p>
1942                 The <tt>build</tt> target may need to run the
1943                 <tt>clean</tt> target first - see below.
1944               </p>
1945
1946               <p>
1947                 When a package has a configuration and build routine
1948                 which takes a long time, or when the makefiles are
1949                 poorly designed, or when <tt>build</tt> needs to
1950                 run <tt>clean</tt> first, it is a good idea to
1951                 <tt>touch build</tt> when the build process is
1952                 complete.  This will ensure that if <tt>debian/rules
1953                 build</tt> is run again it will not rebuild the whole
1954                 program.<footnote>
1955                   <p>
1956                     Another common way to do this is for <tt>build</tt>
1957                     to depend on <prgn>build-stamp</prgn> and to do
1958                     nothing else, and for the <prgn>build-stamp</prgn>
1959                     target to do the building and to <tt>touch
1960                     build-stamp</tt> on completion.  This is
1961                     especially useful if the build routine creates a
1962                     file or directory called <tt>build</tt>; in such a
1963                     case, <tt>build</tt> will need to be listed as
1964                     a phony target (i.e., as a dependency of the
1965                     <tt>.PHONY</tt> target).  See the documentation of
1966                     <prgn>make</prgn> for more information on phony
1967                     targets.
1968                   </p>
1969                 </footnote>
1970               </p>
1971             </item>
1972
1973             <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1974               <tt>binary-indep</tt>
1975             </tag>
1976             <item>
1977               <p>
1978                 The <tt>binary</tt> target must be all that is
1979                 necessary for the user to build the binary package(s)
1980                 produced from this source package.  All of these
1981                 targets are required to be non-interactive.  It is
1982                 split into two parts: <prgn>binary-arch</prgn> builds
1983                 the binary packages which are specific to a particular
1984                 architecture, and <tt>binary-indep</tt> builds
1985                 those which are not.
1986               </p>
1987               <p>
1988                 <tt>binary</tt> may be (and commonly is) a target with
1989                 no commands which simply depends on
1990                 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
1991               </p>
1992               <p>
1993                 Both <tt>binary-*</tt> targets should depend on the
1994                 <tt>build</tt> target, or on the appropriate
1995                 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
1996                 provided, so that the package is built if it has not
1997                 been already.  It should then create the relevant
1998                 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
1999                 make their control files and <prgn>dpkg-deb</prgn> to
2000                 build them and place them in the parent of the top
2001                 level directory.
2002               </p>
2003
2004               <p>
2005                 Both the <tt>binary-arch</tt> and
2006                 <tt>binary-indep</tt> targets <em>must</em> exist.
2007                 If one of them has nothing to do (which will always be
2008                 the case if the source generates only a single binary
2009                 package, whether architecture-dependent or not), it
2010                 must still exist and must always succeed.
2011               </p>
2012
2013               <p>
2014                 The <tt>binary</tt> targets must be invoked as
2015                 root.<footnote>
2016                   <p>
2017                     The <prgn>fakeroot</prgn> package often allows one
2018                     to build a package correctly even without being
2019                     root.
2020                   </p>
2021                 </footnote>
2022               </p>
2023             </item>
2024
2025             <tag><tt>clean</tt></tag>
2026             <item>
2027               <p>
2028                 This must undo any effects that the <tt>build</tt>
2029                 and <tt>binary</tt> targets may have had, except
2030                 that it should leave alone any output files created in
2031                 the parent directory by a run of a <tt>binary</tt>
2032                 target. This target must be non-interactive.
2033               </p>
2034
2035               <p>
2036                 If a <tt>build</tt> file is touched at the end of
2037                 the <tt>build</tt> target, as suggested above, it
2038                 should be removed as the first action that
2039                 <tt>clean</tt> performs, so that running
2040                 <tt>build</tt> again after an interrupted
2041                 <tt>clean</tt> doesn't think that everything is
2042                 already done.
2043               </p>
2044
2045               <p>
2046                 The <tt>clean</tt> target may need to be
2047                 invoked as root if <tt>binary</tt> has been
2048                 invoked since the last <tt>clean</tt>, or if
2049                 <tt>build</tt> has been invoked as root (since
2050                 <tt>build</tt> may create directories, for
2051                 example).
2052               </p>
2053             </item>
2054
2055             <tag><tt>get-orig-source</tt> (optional)</tag>
2056             <item>
2057               <p>
2058                 This target fetches the most recent version of the
2059                 original source package from a canonical archive site
2060                 (via FTP or WWW, for example), does any necessary
2061                 rearrangement to turn it into the original source
2062                 tar file format described below, and leaves it in the
2063                 current directory.
2064               </p>
2065
2066               <p>
2067                 This target may be invoked in any directory, and
2068                 should take care to clean up any temporary files it
2069                 may have left.
2070               </p>
2071
2072               <p>
2073                 This target is optional, but providing it if
2074                 possible is a good idea.
2075               </p>
2076             </item>
2077           </taglist>
2078
2079         <p>
2080           The <tt>build</tt>, <tt>binary</tt> and
2081           <tt>clean</tt> targets must be invoked with the current
2082           directory being the package's top-level directory.
2083         </p>
2084
2085
2086         <p>
2087           Additional targets may exist in <file>debian/rules</file>,
2088           either as published or undocumented interfaces or for the
2089           package's internal use.
2090         </p>
2091
2092         <p>
2093           The architectures we build on and build for are determined
2094           by <prgn>make</prgn> variables using the utility
2095           <prgn>dpkg-architecture</prgn>.  You can determine the
2096           Debian architecture and the GNU style architecture
2097           specification string for the build machine (the machine type
2098           we are building on) as well as for the host machine (the
2099           machine type we are building for).  Here is a list of
2100           supported <prgn>make</prgn> variables:
2101           <list compact="compact">
2102             <item>
2103               <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2104             </item>
2105             <item>
2106               <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2107                 specification string)</p>
2108             </item>
2109             <item>
2110               <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2111               <tt>DEB_*_GNU_TYPE</tt>)</p>
2112             </item>
2113             <item>
2114               <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2115                 <tt>DEB_*_GNU_TYPE</tt>)</p>
2116           </list>
2117           where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2118           the build machine or <tt>HOST</tt> for specification of the
2119           host machine.
2120         </p>
2121
2122         <p>
2123           Backward compatibility can be provided in the rules file
2124           by setting the needed variables to suitable default
2125           values; please refer to the documentation of
2126           <prgn>dpkg-architecture</prgn> for details.
2127         </p>
2128
2129         <p>
2130           It is important to understand that the <tt>DEB_*_ARCH</tt>
2131           string only determines which Debian architecture we are
2132           building on or for. It should not be used to get the CPU
2133           or system information; the GNU style variables should be
2134           used for that.
2135         </p>
2136       </sect>
2137
2138       <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2139         </heading>
2140
2141         <p>
2142           This file records the changes to the Debian-specific parts of the
2143           package<footnote>
2144             <p>
2145               Though there is nothing stopping an author who is also
2146               the Debian maintainer from using it for all their
2147               changes, it will have to be renamed if the Debian and
2148               upstream maintainers become different people.  In such a
2149               case, however, it might be better to maintain the
2150               package as a non-native package.
2151             </p>
2152           </footnote>.
2153         </p>
2154
2155         <p>
2156           It has a special format which allows the package building
2157           tools to discover which version of the package is being
2158           built and find out other release-specific information.
2159         </p>
2160
2161         <p>
2162           That format is a series of entries like this:
2163           <example compact="compact">
2164 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2165             <comment>
2166               <p>[optional blank line(s), stripped]</p>
2167             </comment>
2168   * <var>change details</var>
2169     <var>more change details</var>
2170             <comment>
2171               <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2172             </comment>
2173   * <var>even more change details</var>
2174             <comment>
2175               <p>[optional blank line(s), stripped]</p>
2176             </comment>
2177             -- <var>maintainer name</var> &lt;<var>email
2178               address</var>&gt;<var>[two spaces]</var>  <var>date</var>
2179           </example>
2180         </p>
2181
2182         <p>
2183           <var>package</var> and <var>version</var> are the source
2184           package name and version number.
2185         </p>
2186
2187         <p>
2188           <var>distribution(s)</var> lists the distributions where
2189           this version should be installed when it is uploaded - it
2190           is copied to the <tt>Distribution</tt> field in the
2191           <file>.changes</file> file.  See <ref id="f-Distribution">.
2192         </p>
2193
2194         <p>
2195           <var>urgency</var> is the value for the <tt>Urgency</tt>
2196           field in the <file>.changes</file> file for the upload. It is
2197           not possible to specify an urgency containing commas; commas
2198           are used to separate
2199           <tt><var>keyword</var>=<var>value</var></tt> settings in the
2200           <prgn>dpkg</prgn> changelog format (though there is
2201           currently only one useful <var>keyword</var>,
2202           <tt>urgency</tt>).<footnote>
2203             <p>
2204               Recognised urgency values are <tt>low</tt>,
2205               <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2206               They have an effect on how quickly a package will be
2207               considered for inclusion into the <tt>testing</tt>
2208               distribution, and give an indication of the importance
2209               of any fixes included in this upload.
2210             </p>
2211           </footnote>
2212         </p>
2213
2214         <p>
2215           The change details may in fact be any series of lines
2216           starting with at least two spaces, but conventionally each
2217           change starts with an asterisk and a separating space and
2218           continuation lines are indented so as to bring them in
2219           line with the start of the text above.  Blank lines may be
2220           used here to separate groups of changes, if desired.
2221         </p>
2222
2223         <p>
2224           If this upload resolves bugs recorded in the Bug Tracking
2225           System (BTS), they may be automatically closed on the
2226           inclusion of this package into the Debian archive by
2227           including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2228           in the change details.<footnote>
2229             <p>
2230               To be precise, the string should match the following
2231               Perl regular expression:
2232               <example>
2233 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2234               </example>
2235               Then all of the bug numbers listed will be closed by the
2236               archive maintenance script (<prgn>katie</prgn>), or in
2237               the case of an NMU, marked as fixed.
2238             </p>
2239           </footnote>
2240         </p>
2241
2242         <p>
2243           The maintainer name and email address used in the changelog
2244           should be the details of the person uploading <em>this</em>
2245           version.  They are <em>not</em> necessarily those of the
2246           usual package maintainer.  The information here will be
2247           copied to the <tt>Changed-By</tt> field in the
2248           <tt>.changes</tt> file, and then later used to send an
2249           acknowledgement when the upload has been installed.
2250         </p>
2251
2252         <p>
2253           The <var>date</var> should be in RFC822 format<footnote>
2254             <p>
2255               This is generated by the <prgn>822-date</prgn>
2256               program.
2257             </p>
2258           </footnote>; it should include the time zone specified
2259           numerically, with the time zone name or abbreviation
2260           optionally present as a comment in parentheses.
2261         </p>
2262
2263         <p>
2264           The first `title' line with the package name should start
2265           at the left hand margin; the `trailer' line with the
2266           maintainer and date details should be preceded by exactly
2267           one space.  The maintainer details and the date must be
2268           separated by exactly two spaces.
2269         </p>
2270
2271         <sect1><heading>Defining alternative changelog formats</heading>
2272
2273           <p>
2274             It is possible to use a different format to the standard
2275             one, by providing a parser for the format you wish to
2276             use.
2277           </p>
2278           <p>
2279             A changelog parser must not interact with the user at
2280             all.
2281           </p>
2282         </sect1>
2283       </sect>
2284
2285       <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2286           and variable substitutions      </heading>
2287
2288         <p>
2289           When <prgn>dpkg-gencontrol</prgn>,
2290           <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2291           generate control files they perform variable substitutions
2292           on their output just before writing it.  Variable
2293           substitutions have the form <tt>${<var>variable</var>}</tt>.
2294           The optional file <file>debian/substvars</file> contains
2295           variable substitutions to be used; variables can also be set
2296           directly from <file>debian/rules</file> using the <tt>-V</tt>
2297           option to the source packaging commands, and certain
2298           predefined variables are also available.
2299         </p>
2300
2301         <p>
2302           The <file>debian/substvars</file> file is usually generated and
2303           modified dynamically by <file>debian/rules</file> targets; in
2304           this case it must be removed by the <tt>clean</tt>
2305           target.
2306         </p>
2307
2308         <p>
2309           See <manref name="dpkg-source" section="1"> for full
2310           details about source variable substitutions, including the
2311           format of <file>debian/substvars</file>.</p>
2312       </sect>
2313
2314       <sect id="debianfiles"><heading><file>debian/files</file>
2315         </heading>
2316
2317         <p>
2318           This file is not a permanent part of the source tree; it
2319           is used while building packages to record which files are
2320           being generated.  <prgn>dpkg-genchanges</prgn> uses it
2321           when it generates a <file>.changes</file> file.
2322         </p>
2323
2324         <p>
2325           It should not exist in a shipped source package, and so it
2326           (and any backup files or temporary files such as
2327           <file>files.new</file><footnote>
2328             <p>
2329               <file>files.new</file> is used as a temporary file by
2330               <prgn>dpkg-gencontrol</prgn> and
2331               <prgn>dpkg-distaddfile</prgn> - they write a new
2332               version of <tt>files</tt> here before renaming it,
2333               to avoid leaving a corrupted copy if an error
2334               occurs
2335             </p>
2336           </footnote>) should be removed by the
2337           <tt>clean</tt> target.  It may also be wise to
2338           ensure a fresh start by emptying or removing it at the
2339           start of the <tt>binary</tt> target.
2340         </p>
2341
2342         <p>
2343           When <prgn>dpkg-gencontrol</prgn> is run for a binary
2344           package, it adds an entry to <file>debian/files</file> for the
2345           <file>.deb</file> file that will be created when <tt>dpkg-deb
2346           --build</tt> is run for that binary package.  So for most
2347           packages all that needs to be done with this file is to
2348           delete it in the <tt>clean</tt> target.
2349         </p>
2350
2351         <p>
2352           If a package upload includes files besides the source
2353           package and any binary packages whose control files were
2354           made with <prgn>dpkg-gencontrol</prgn> then they should be
2355           placed in the parent of the package's top-level directory
2356           and <prgn>dpkg-distaddfile</prgn> should be called to add
2357           the file to the list in <file>debian/files</file>.</p>
2358       </sect>
2359
2360       <sect id="restrictions"><heading>Restrictions on objects in source packages
2361         </heading>
2362
2363         <p>
2364           The source package may not contain any hard links<footnote>
2365             <p>
2366               This is not currently detected when building source
2367               packages, but only when extracting
2368               them.
2369             </p>
2370             <p>
2371               Hard links may be permitted at some point in the
2372               future, but would require a fair amount of
2373               work.
2374             </p>
2375           </footnote>, device special files, sockets or setuid or
2376           setgid files.<footnote>
2377             <p>
2378               Setgid directories are allowed.
2379             </p>
2380           </footnote>
2381         </p>
2382       </sect>
2383       <sect id="descriptions"><heading>Descriptions of packages - the
2384           <tt>Description</tt> field </heading>
2385
2386         <p>
2387           The description is intended to describe the program to a user
2388           who has never met it before so that they know whether they
2389           want to install it.  It should also give information about the
2390           significant dependencies and conflicts between this package
2391           and others, so that the user knows why these dependencies and
2392           conflicts have been declared.
2393         </p>
2394
2395         <sect1><heading>Notes about writing descriptions
2396           </heading>
2397
2398           <p>
2399             The single line synopsis should be kept brief - certainly
2400             under 80 characters.
2401           </p>
2402
2403           <p>
2404             Do not include the package name in the synopsis line.  The
2405             display software knows how to display this already, and you
2406             do not need to state it.  Remember that in many situations
2407             the user may only see the synopsis line - make it as
2408             informative as you can.
2409           </p>
2410
2411           <p>
2412             Do not try to continue the single line synopsis into the
2413             extended description.  This will not work correctly when
2414             the full description is displayed, and makes no sense
2415             where only the summary (the single line synopsis) is
2416             available.
2417           </p>
2418
2419           <p>
2420             The extended description should describe what the package
2421             does and how it relates to the rest of the system (in terms
2422             of, for example, which subsystem it is which part of).
2423           </p>
2424
2425           <p>
2426             The description field needs to make sense to anyone, even
2427             people who have no idea about any of the things the
2428             package deals with.<footnote>
2429               <p>
2430                 The blurb that comes with a program in its
2431                 announcements and/or <prgn>README</prgn> files is
2432                 rarely suitable for use in a description.  It is
2433                 usually aimed at people who are already in the
2434                 community where the package is used.
2435               </p>
2436             </footnote>
2437           </p>
2438
2439           <p>
2440             Put important information first, both in the synopsis and
2441             extended description.  Sometimes only the first part of the
2442             synopsis or of the description will be displayed.  You can
2443             assume that there will usually be a way to see the whole
2444             extended description.
2445           </p>
2446
2447           <p>
2448             You may include information about dependencies and so forth
2449             in the extended description, if you wish.
2450           </p>
2451
2452           <p>
2453             Do not use tab characters.  Their effect is not predictable.
2454           </p>
2455
2456         </sect1>
2457       </sect>
2458     </chapt>
2459
2460
2461     <chapt id="maintainerscripts"><heading>Package maintainer scripts
2462         and installation procedure
2463       </heading>
2464
2465       <sect><heading>Introduction to package maintainer scripts
2466         </heading>
2467
2468         <p>
2469           It is possible to supply scripts as part of a package which
2470           the package management system will run for you when your
2471           package is installed, upgraded or removed.
2472         </p>
2473
2474         <p>
2475           These scripts are the files <prgn>preinst</prgn>,
2476           <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2477           control area of the package.  They must be proper executable
2478           files; if they are scripts (which is recommended), they must
2479           start with the usual <tt>#!</tt> convention.  They should be
2480           readable and executable by anyone, and not world-writable.
2481         </p>
2482
2483         <p>
2484           The package management system looks at the exit status from
2485           these scripts.  It is important that they exit with a
2486           non-zero status if there is an error, so that the package
2487           management system can stop its processing.  For shell
2488           scripts this means that you <em>almost always</em> need to
2489           use <tt>set -e</tt> (this is usually true when writing shell
2490           scripts, in fact).  It is also important, of course, that
2491           they don't exit with a non-zero status if everything went
2492           well.
2493         </p>
2494
2495         <p>
2496           When a package is upgraded a combination of the scripts from
2497           the old and new packages is called during the upgrade
2498           procedure.  If your scripts are going to be at all
2499           complicated you need to be aware of this, and may need to
2500           check the arguments to your scripts.
2501         </p>
2502
2503         <p>
2504           Broadly speaking the <prgn>preinst</prgn> is called before
2505           (a particular version of) a package is installed, and the
2506           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2507           before (a version of) a package is removed and the
2508           <prgn>postrm</prgn> afterwards.
2509         </p>
2510
2511         <p>
2512           Programs called from maintainer scripts should not normally
2513           have a path prepended to them. Before installation is
2514           started, the package management system checks to see if the
2515           programs <prgn>ldconfig</prgn>,
2516           <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2517           and <prgn>update-rc.d</prgn> can be found via the
2518           <tt>PATH</tt> environment variable. Those programs, and any
2519           other program that one would expect to be on the
2520           <tt>PATH</tt>, should thus be invoked without an absolute
2521           pathname. Maintainer scripts should also not reset the
2522           <tt>PATH</tt>, though they might choose to modify it by
2523           prepending or appending package-specific directories. These
2524           considerations really apply to all shell scripts.</p>
2525       </sect>
2526
2527       <sect>
2528         <heading>Maintainer scripts Idempotency</heading>
2529
2530         <p>
2531           It is necessary for the error recovery procedures that the
2532           scripts be idempotent.  This means that if it is run
2533           successfully, and then it is called again, it doesn't bomb
2534           out or cause any harm, but just ensures that everything is
2535           the way it ought to be.  If the first call failed, or
2536           aborted half way through for some reason, the second call
2537           should merely do the things that were left undone the first
2538           time, if any, and exit with a success status if everything
2539           is OK.<footnote> 
2540             <p>
2541               This is so that if an error occurs, the user interrupts
2542               <prgn>dpkg</prgn> or some other unforeseen circumstance
2543               happens you don't leave the user with a badly-broken
2544               package when <prgn>dpkg</prgn> attempts to repeat the
2545               action.
2546             </p>
2547           </footnote>
2548         </p>
2549       </sect>
2550
2551       <sect>
2552         <heading>Controlling terminal for maintainer scripts</heading>
2553
2554         <p>
2555           The maintainer scripts are guaranteed to run with a
2556           controlling terminal and can interact with the user.
2557           If they need to prompt for passwords, do full-screen
2558           interaction or something similar you should do these
2559           things to and from <file>/dev/tty</file>, since
2560           <prgn>dpkg</prgn> will at some point redirect scripts'
2561           standard input and output so that it can log the
2562           installation process.  Likewise, because these scripts
2563           may be executed with standard output redirected into a
2564           pipe for logging purposes, Perl scripts should set
2565           unbuffered output by setting <tt>$|=1</tt> so that the
2566           output is printed immediately rather than being
2567           buffered.
2568         </p>
2569
2570         <p>
2571           Each script should return a zero exit status for
2572           success, or a nonzero one for failure.
2573         </p>
2574       </sect>
2575
2576       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2577           scripts are called
2578         </heading>
2579
2580         <p>
2581           <list compact="compact">
2582             <item>
2583               <p><var>new-preinst</var> <tt>install</tt></p>
2584             </item>
2585             <item>
2586               <p><var>new-preinst</var> <tt>install</tt>
2587                 <var>old-version</var></p>
2588             </item>
2589             <item>
2590               <p><var>new-preinst</var> <tt>upgrade</tt>
2591                 <var>old-version</var></p>
2592             </item>
2593             <item>
2594               <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2595                 <var>new-version</var>
2596               </p>
2597             </item>
2598           </list>
2599
2600         <p>
2601           <list compact="compact">
2602             <item>
2603               <p><var>postinst</var> <tt>configure</tt>
2604                 <var>most-recently-configured-version</var></p>
2605             </item>
2606             <item>
2607               <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2608                 <var>new-version</var></p>
2609             </item>
2610             <item>
2611               <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2612                 <tt>in-favour</tt> <var>package</var>
2613                 <var>new-version</var></p>
2614             </item>
2615             <item>
2616               <p>
2617                 <var>deconfigured's-postinst</var>
2618                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2619                 <var>failed-install-package</var> <var>version</var>
2620                 <tt>removing</tt> <var>conflicting-package</var>
2621                 <var>version</var>
2622               </p>
2623             </item>
2624           </list>
2625
2626         <p>
2627           <list compact="compact">
2628             <item>
2629               <p><var>prerm</var> <tt>remove</tt></p>
2630             </item>
2631             <item>
2632               <p><var>old-prerm</var> <tt>upgrade</tt>
2633                 <var>new-version</var></p>
2634             </item>
2635             <item>
2636               <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2637                 <var>old-version</var></p>
2638             </item>
2639             <item>
2640               <p><var>conflictor's-prerm</var> <tt>remove</tt>
2641                 <tt>in-favour</tt> <var>package</var>
2642                 <var>new-version</var></p>
2643             </item>
2644             <item>
2645               <p>
2646                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2647                 <tt>in-favour</tt> <var>package-being-installed</var>
2648                 <var>version</var> <tt>removing</tt>
2649                 <var>conflicting-package</var>
2650                 <var>version</var>
2651               </p>
2652             </item>
2653           </list>
2654
2655         <p>
2656           <list compact="compact">
2657             <item>
2658               <p><var>postrm</var> <tt>remove</tt></p>
2659             </item>
2660             <item>
2661               <p><var>postrm</var> <tt>purge</tt></p>
2662             </item>
2663             <item>
2664               <p>
2665                 <var>old-postrm</var> <tt>upgrade</tt>
2666                 <var>new-version</var></p>
2667             </item>
2668             <item>
2669               <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2670                 <var>old-version</var></p>
2671             </item>
2672             <item>
2673               <p><var>new-postrm</var> <tt>abort-install</tt></p>
2674             </item>
2675             <item>
2676               <p><var>new-postrm</var> <tt>abort-install</tt>
2677                 <var>old-version</var></p>
2678             </item>
2679             <item>
2680               <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2681                 <var>old-version</var></p>
2682             </item>
2683             <item>
2684               <p>
2685                 <var>disappearer's-postrm</var> <tt>disappear</tt>
2686                 <var>overwriter</var>
2687                 <var>overwriter-version</var></p></item>
2688           </list>
2689         </p>
2690
2691
2692       <sect id="unpackphase"><heading>Details of unpack phase of
2693           installation or upgrade
2694         </heading>
2695
2696         <p>
2697           The procedure on installation/upgrade/overwrite/disappear
2698           (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2699           stage of <tt>dpkg --install</tt>) is as follows.  In each
2700           case, if a major error occurs (unless listed below) the
2701           actions are, in general, run backwards - this means that the
2702           maintainer scripts are run with different arguments in
2703           reverse order.  These are the `error unwind' calls listed
2704           below.
2705
2706           <enumlist>
2707             <item>
2708               <p>
2709                 <enumlist>
2710                   <item>
2711                     <p>If a version of the package is already
2712                       installed, call
2713                       <example compact="compact">
2714 <var>old-prerm</var> upgrade <var>new-version</var>
2715                       </example></p>
2716                   </item>
2717                   <item>
2718                     <p>
2719                       If the script runs but exits with a non-zero
2720                       exit status, <prgn>dpkg</prgn> will attempt:
2721                       <example compact="compact">
2722 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2723                       </example>
2724                       Error unwind, for both the above cases:
2725                       <example compact="compact">
2726 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2727                       </example>
2728                     </p>
2729                   </item>
2730                 </enumlist>
2731               </p>
2732             </item>
2733             <item>
2734               <p>If a `conflicting' package is being removed at the same time:
2735                 <enumlist>
2736                   <item>
2737                     <p>
2738                       If any packages depended on that conflicting
2739                       package and <tt>--auto-deconfigure</tt> is
2740                       specified, call, for each such package:
2741                       <example compact="compact">
2742 <var>deconfigured's-prerm</var> deconfigure \
2743   in-favour <var>package-being-installed</var> <var>version</var> \
2744     removing <var>conflicting-package</var> <var>version</var>
2745                       </example>
2746                       Error unwind:
2747                       <example compact="compact">
2748 <var>deconfigured's-postinst</var> abort-deconfigure \
2749   in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2750     removing <var>conflicting-package</var> <var>version</var>
2751                       </example>
2752                       The deconfigured packages are marked as
2753                       requiring configuration, so that if
2754                       <tt>--install</tt> is used they will be
2755                       configured again if possible.</p>
2756                   </item>
2757                   <item>
2758                     <p>To prepare for removal of the conflicting package, call:
2759                       <example compact="compact">
2760 <var>conflictor's-prerm</var> remove \
2761   in-favour <var>package</var> <var>new-version</var>
2762                       </example>
2763                       Error unwind:
2764                       <example compact="compact">
2765 <var>conflictor's-postinst</var> abort-remove \
2766   in-favour <var>package</var> <var>new-version</var>
2767                       </example>
2768                     </p>
2769                   </item>
2770                 </enumlist>
2771               </p>
2772             </item>
2773             <item>
2774               <p>
2775                 <enumlist>
2776                   <item>
2777                     <p>If the package is being upgraded, call:
2778                       <example compact="compact">
2779 <var>new-preinst</var> upgrade <var>old-version</var>
2780                       </example></p>
2781                   </item>
2782                   <item>
2783                     <p>
2784                       Otherwise, if the package had some configuration
2785                       files from a previous version installed (i.e., it
2786                       is in the `configuration files only' state):
2787                       <example compact="compact">
2788 <var>new-preinst</var> install <var>old-version</var>
2789                       </example></p>
2790
2791                   <item>
2792                     <p>Otherwise (i.e., the package was completely purged):
2793                       <example compact="compact">
2794 <var>new-preinst</var> install
2795                       </example>
2796                       Error unwind actions, respectively:
2797                       <example compact="compact">
2798 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2799 <var>new-postrm</var> abort-install <var>old-version</var>
2800 <var>new-postrm</var> abort-install
2801                       </example>
2802                     </p>
2803                   </item>
2804                 </enumlist>
2805               </p>
2806             </item>
2807             <item>
2808               <p>
2809                 The new package's files are unpacked, overwriting any
2810                 that may be on the system already, for example any
2811                 from the old version of the same package or from
2812                 another package.  Backups of the old files are kept
2813                 temporarily, and if anything goes wrong the package
2814                 management system will attempt to put them back as
2815                 part of the error unwind.
2816               </p>
2817
2818               <p>
2819                 It is an error for a package to contains files which
2820                 are on the system in another package, unless
2821                 <tt>Replaces</tt> is used (see <ref id="replaces">).
2822                 <!--
2823                 The following paragraph is not currently the case:
2824                 Currently the <tt>- - force-overwrite</tt> flag is
2825                 enabled, downgrading it to a warning, but this may not
2826                 always be the case.
2827                 -->
2828               </p>
2829
2830               <p>
2831                 It is a more serious error for a package to contain a
2832                 plain file or other kind of non-directory where another
2833                 package has a directory (again, unless
2834                 <tt>Replaces</tt> is used).  This error can be
2835                 overridden if desired using
2836                 <tt>--force-overwrite-dir</tt>, but this is not
2837                 advisable.
2838               </p>
2839
2840               <p>
2841                 Packages which overwrite each other's files produce
2842                 behavior which, though deterministic, is hard for the
2843                 system administrator to understand.  It can easily
2844                 lead to `missing' programs if, for example, a package
2845                 is installed which overwrites a file from another
2846                 package, and is then removed again.<footnote>
2847                   <p>
2848                     Part of the problem is due to what is arguably a
2849                     bug in <prgn>dpkg</prgn>.
2850                   </p>
2851                 </footnote>
2852               </p>
2853
2854               <p>
2855                 A directory will never be replaced by a symbolic link
2856                 to a directory or vice versa; instead, the existing
2857                 state (symlink or not) will be left alone and
2858                 <prgn>dpkg</prgn> will follow the symlink if there is
2859                 one.</p>
2860             </item>
2861
2862             <item>
2863               <p>
2864                 <enumlist>
2865                   <item>
2866                     <p>If the package is being upgraded, call
2867                       <example compact="compact">
2868 <var>old-postrm</var> upgrade <var>new-version</var>
2869                       </example>
2870                     </p>
2871                   </item>
2872                   <item>
2873                     <p>If this fails, <prgn>dpkg</prgn> will attempt:
2874                       <example compact="compact">
2875 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2876                       </example>
2877                       Error unwind, for both cases:
2878                       <example compact="compact">
2879 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2880                       </example>
2881                     </p>
2882                   </item>
2883                 </enumlist>
2884               </p>
2885               <p>
2886                 This is the point of no return - if
2887                 <prgn>dpkg</prgn> gets this far, it won't back off
2888                 past this point if an error occurs.  This will
2889                 leave the package in a fairly bad state, which
2890                 will require a successful re-installation to clear
2891                 up, but it's when <prgn>dpkg</prgn> starts doing
2892                 things that are irreversible.
2893               </p>
2894             </item>
2895             <item>
2896               <p>
2897                 Any files which were in the old version of the package
2898                 but not in the new are removed.</p>
2899             </item>
2900             <item>
2901               <p>The new file list replaces the old.</p>
2902             </item>
2903             <item>
2904               <p>The new maintainer scripts replace the old.</p>
2905             </item>
2906
2907             <item>
2908               <p>Any packages all of whose files have been overwritten during the
2909                 installation, and which aren't required for
2910                 dependencies, are considered to have been removed.
2911                 For each such package
2912                 <enumlist>
2913                   <item>
2914                     <p><prgn>dpkg</prgn> calls:
2915                       <example compact="compact">
2916 <var>disappearer's-postrm</var> disappear \
2917   <var>overwriter</var> <var>overwriter-version</var>
2918                       </example>
2919                     </p>
2920                   </item>
2921                   <item>
2922                     <p>The package's maintainer scripts are removed.
2923                     </p>
2924                   </item>
2925                   <item>
2926                     <p>
2927                       It is noted in the status database as being in a
2928                       sane state, namely not installed (any conffiles
2929                       it may have are ignored, rather than being
2930                       removed by <prgn>dpkg</prgn>).  Note that
2931                       disappearing packages do not have their prerm
2932                       called, because <prgn>dpkg</prgn> doesn't know
2933                       in advance that the package is going to
2934                       vanish.
2935                     </p>
2936                   </item>
2937                 </enumlist>
2938               </p>
2939             </item>
2940             <item>
2941               <p>
2942                 Any files in the package we're unpacking that are also
2943                 listed in the file lists of other packages are removed
2944                 from those lists.  (This will lobotomize the file list
2945                 of the `conflicting' package if there is one.)
2946               </p>
2947             </item>
2948             <item>
2949               <p>
2950                 The backup files made during installation, above, are
2951                 deleted.
2952               </p>
2953             </item>
2954
2955             <item>
2956               <p>
2957                 The new package's status is now sane, and recorded as
2958                 `unpacked'.
2959               </p>
2960
2961               <p>
2962                 Here is another point of no return - if the
2963                 conflicting package's removal fails we do not unwind
2964                 the rest of the installation; the conflicting package
2965                 is left in a half-removed limbo.
2966               </p>
2967             </item>
2968
2969             <item>
2970               <p>
2971                 If there was a conflicting package we go and do the
2972                 removal actions (described below), starting with the
2973                 removal of the conflicting package's files (any that
2974                 are also in the package being installed have already
2975                 been removed from the conflicting package's file list,
2976                 and so do not get removed now).
2977               </p>
2978             </item>
2979           </enumlist>
2980         </p>
2981       </sect>
2982
2983       <sect id="configdetails"><heading>Details of configuration</heading>
2984
2985         <p>
2986           When we configure a package (this happens with <tt>dpkg
2987             --install</tt> and <tt>dpkg --configure</tt>), we first
2988           update any <tt>conffile</tt>s and then call:
2989           <example compact="compact">
2990 <var>postinst</var> configure <var>most-recently-configured-version</var>
2991           </example>
2992         </p>
2993
2994         <p>
2995           No attempt is made to unwind after errors during
2996           configuration.
2997         </p>
2998
2999         <p>
3000           If there is no most recently configured version
3001           <prgn>dpkg</prgn> will pass a null argument; older versions
3002           of dpkg may pass <tt>&lt;unknown&gt;</tt> (including the
3003           angle brackets) in this case.  Even older ones do not pass a
3004           second argument at all, under any circumstances.
3005         </p>
3006       </sect>
3007
3008       <sect id="removedetails"><heading>Details of removal and/or
3009       configuration purging</heading>
3010
3011         <p>
3012           <enumlist>
3013             <item>
3014               <p>
3015                 <example compact="compact">
3016 <var>prerm</var> remove
3017                 </example>
3018               </p>
3019             </item>
3020             <item>
3021               <p>
3022                 The package's files are removed (except <tt>conffile</tt>s).
3023               </p>
3024             </item>
3025             <item>
3026               <p>
3027                 <example compact="compact">
3028 <var>postrm</var> remove
3029                 </example>
3030               </p>
3031             </item>
3032             <item>
3033               <p>
3034                 All the maintainer scripts except the <prgn>postrm</prgn>
3035                 are removed.
3036               </p>
3037
3038               <p>
3039                 If we aren't purging the package we stop here.  Note
3040                 that packages which have no <prgn>postrm</prgn> and no
3041                 <tt>conffile</tt>s are automatically purged when
3042                 removed, as there is no difference except for the
3043                 <prgn>dpkg</prgn> status.</p>
3044             </item>
3045             <item>
3046               <p>
3047                 The <tt>conffile</tt>s and any backup files
3048                 (<tt>~</tt>-files, <tt>#*#</tt> files,
3049                 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3050                 are removed.</p>
3051             </item>
3052             <item>
3053               <p>
3054                 <example compact="compact">
3055 <var>postrm</var> purge
3056                 </example>
3057               </p>
3058             </item>
3059             <item>
3060               <p>The package's file list is removed.</p>
3061             </item>
3062           </enumlist>
3063           No attempt is made to unwind after errors during
3064           removal.
3065         </p>
3066       </sect>
3067     </chapt>
3068
3069
3070     <chapt id="relationships"><heading>Declaring relationships between
3071         packages</heading>
3072
3073       <p>
3074         Packages can declare in their control file that they have
3075         certain relationships to other packages - for example, that
3076         they may not be installed at the same time as certain other
3077         packages, and/or that they depend on the presence of others,
3078         or that they should overwrite files in certain other packages
3079         if present.
3080       </p>
3081
3082       <p>
3083         This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3084         <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3085         <tt>Conflicts</tt>, <tt>Provides</tt> and <tt>Replaces</tt>
3086         control file fields.
3087       </p>
3088
3089       <p>
3090         Source packages may declare relationships to binary packages,
3091         saying that they require certain binary packages to be
3092         installed or absent at the time of building the package.
3093       </p>
3094
3095       <p>
3096         This is done using the <tt>Build-Depends</tt>,
3097         <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3098         <tt>Build-Conflicts-Indep</tt> control file fields.
3099       </p>
3100
3101       <sect id="depsyntax"><heading>Syntax of relationship fields
3102         </heading>
3103
3104         <p>
3105           These fields all have a uniform syntax.  They are a list of
3106           package names separated by commas.
3107         </p>
3108
3109         <p>
3110           In the <tt>Depends</tt>, <tt>Recommends</tt>,
3111           <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3112           <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3113           control file fields of the package, which declare
3114           dependencies on other packages, the package names listed may
3115           also include lists of alternative package names, separated
3116           by vertical bar (pipe) symbols <tt>|</tt>.  In such a case,
3117           if any one of the alternative packages is installed, that
3118           part of the dependency is considered to be satisfied.
3119         </p>
3120
3121         <p>
3122           All of the fields except for <tt>Provides</tt> may restrict
3123           their applicability to particular versions of each named
3124           package.  This is done in parentheses after each individual
3125           package name; the parentheses should contain a relation from
3126           the list below followed by a version number, in the format
3127           described in <ref id="versions">.
3128         </p>
3129
3130         <p>
3131           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
3132           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
3133           strictly earlier, earlier or equal, exactly equal, later or
3134           equal and strictly later, respectively.  The deprecated
3135           forms <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
3136           earlier/later or equal, rather than strictly earlier/later,
3137           so they should not appear in new packages (though
3138           <prgn>dpkg</prgn> still supports them).
3139         </p>
3140
3141         <p>
3142           Whitespace may appear at any point in the version
3143           specification subject to the rules in <ref
3144           id="controlsyntax">, and must appear where it's necessary to
3145           disambiguate; it is not otherwise significant.  For
3146           consistency and in case of future changes to
3147           <prgn>dpkg</prgn> it is recommended that a single space be
3148           used after a version relationship and before a version
3149           number; it is also conventional to put a single space after
3150           each comma, on either side of each vertical bar, and before
3151           each open parenthesis.
3152         </p>
3153
3154         <p>
3155           For example, a list of dependencies might appear as:
3156           <example compact="compact">
3157 Package: mutt
3158 Version: 1.3.17-1
3159 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3160           </example>
3161         </p>
3162
3163         <p>
3164           All fields that specify build-time relationships
3165           (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3166           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3167           may be restricted to a certain set of architectures.  This
3168           is indicated in brackets after each individual package name and
3169           the optional version specification.  The brackets enclose a
3170           list of Debian architecture names separated by whitespace.
3171           Exclamation marks may be prepended to each of the names.
3172           (It is not permitted for some names to be prepended with
3173           exclamation marks and others not.) If the current Debian
3174           host architecture is not in this list and there are no
3175           exclamation marks in the list, or it is in the list with a
3176           prepended exclamation mark, the package name and the
3177           associated version specification are ignored completely for
3178           the purposes of defining the relationships.
3179         </p>
3180
3181         <p>
3182           For example:
3183           <example compact="compact">
3184 Source: glibc
3185 Build-Depends-Indep: texinfo
3186 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3187   hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3188           </example>
3189         </p>
3190
3191         <p>
3192           Note that the binary package relationship fields such as
3193           <tt>Depends</tt> appear in one of the binary package
3194           sections of the control file, whereas the build-time
3195           relationships such as <tt>Build-Depends</tt> appear in the
3196           source package section of the control file (which is the
3197           first section).
3198         </p>
3199       </sect>
3200
3201       <sect>
3202         <heading>Binary Dependencies - <tt>Depends</tt>,
3203           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3204           <tt>Pre-Depends</tt>
3205         </heading>
3206
3207         <p>
3208           These five fields are used to declare a dependency
3209           relationship by one package on another.  Except for
3210           <tt>Enhances</tt>, they appear in the depending (binary)
3211           package's control file.  (<tt>Enhances</tt> appears in the
3212           recommending package's control file.)
3213         </p>
3214
3215         <p>
3216           A <tt>Depends</tt> field takes effect <em>only</em> when a
3217           package is to be configured.  It does not prevent a package
3218           being on the system in an unconfigured state while its
3219           dependencies are unsatisfied, and it is possible to replace
3220           a package whose dependencies are satisfied and which is
3221           properly installed with a different version whose
3222           dependencies are not and cannot be satisfied; when this is
3223           done the depending package will be left unconfigured (since
3224           attempts to configure it will give errors) and will not
3225           function properly.  If it is necessary, a
3226           <tt>Pre-Depends</tt> field can be used, which has a partial
3227           effect even when a package is being unpacked, as explained
3228           in detail below.  (The other three dependency fields,
3229           <tt>Recommends</tt>, <tt>Suggests</tt> and
3230           <tt>Enhances</tt>, are only used by the various front-ends
3231           to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3232         </p>
3233
3234         <p>
3235           For this reason packages in an installation run are usually
3236           all unpacked first and all configured later; this gives
3237           later versions of packages with dependencies on later
3238           versions of other packages the opportunity to have their
3239           dependencies satisfied.
3240         </p>
3241
3242         <p>
3243           The <tt>Depends</tt> field thus allows package maintainers
3244           to impose an order in which packages should be configured.
3245         </p>
3246
3247         <p>
3248           The meaning of the five dependency fields is as follows:
3249           <taglist>
3250             <tag><tt>Depends</tt></tag>
3251             <item>
3252               <p>
3253                 This declares an absolute dependency.  A package will
3254                 not be configured unless all of the packages listed in
3255                 its <tt>Depends</tt> field have been correctly
3256                 configured.
3257               </p>
3258
3259               <p>
3260                 The <tt>Depends</tt> field should be used if the
3261                 depended-on package is required for the depending
3262                 package to provide a significant amount of
3263                 functionality.
3264               </p>
3265               <p>
3266                 The <tt>Depends</tt> field should also be used if the
3267                 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3268                 <prgn>postrm</prgn> scripts require the package to be
3269                 present in order to run.  Note, however, that the
3270                 <prgn>postrm</prgn> cannot rely on any non-essential
3271                 packages to be present during the <tt>purge</tt>
3272                 phase.
3273             </item>
3274
3275             <tag><tt>Recommends</tt></tag>
3276             <item>
3277               <p>This declares a strong, but not absolute, dependency.
3278               </p>
3279
3280               <p>
3281                 The <tt>Recommends</tt> field should list packages
3282                 that would be found together with this one in all but
3283                 unusual installations.</p>
3284             </item>
3285
3286             <tag><tt>Suggests</tt></tag>
3287             <item>
3288               <p>
3289                 This is used to declare that one package may be more
3290                 useful with one or more others.  Using this field
3291                 tells the packaging system and the user that the
3292                 listed packages are related to this one and can
3293                 perhaps enhance its usefulness, but that installing
3294                 this one without them is perfectly reasonable.
3295               </p>
3296             </item>
3297
3298             <tag><tt>Enhances</tt></tag>
3299             <item>
3300               <p>
3301                 This field is similar to Suggests but works in the
3302                 opposite direction. It is used to declare that a
3303                 package can enhance the functionality of another
3304                 package.
3305               </p>
3306             </item>
3307
3308             <tag><tt>Pre-Depends</tt></tag>
3309             <item>
3310               <p>
3311                 This field is like <tt>Depends</tt>, except that it
3312                 also forces <prgn>dpkg</prgn> to complete installation
3313                 of the packages named before even starting the
3314                 installation of the package which declares the
3315                 pre-dependency, as follows:
3316               </p>
3317
3318               <p>
3319                 When a package declaring a pre-dependency is about to
3320                 be <em>unpacked</em> the pre-dependency can be
3321                 satisfied if the depended-on package is either fully
3322                 configured, <em>or even if</em> the depended-on
3323                 package(s) are only unpacked or half-configured,
3324                 provided that they have been configured correctly at
3325                 some point in the past (and not removed or partially
3326                 removed since).  In this case, both the
3327                 previously-configured and currently unpacked or
3328                 half-configured versions must satisfy any version
3329                 clause in the <tt>Pre-Depends</tt> field.
3330               </p>
3331
3332               <p>
3333                 When the package declaring a pre-dependency is about
3334                 to be <em>configured</em>, the pre-dependency will be
3335                 treated as a normal <tt>Depends</tt>, that is, it will
3336                 be considered satisfied only if the depended-on
3337                 package has been correctly configured.
3338               </p>
3339
3340               <p>
3341                 <tt>Pre-Depends</tt> should be used sparingly,
3342                 preferably only by packages whose premature upgrade or
3343                 installation would hamper the ability of the system to
3344                 continue with any upgrade that might be in progress.
3345               </p>
3346
3347               <p>
3348                 <tt>Pre-Depends</tt> are also required if the
3349                 <prgn>preinst</prgn> script depends on the named
3350                 package.  It is best to avoid this situation if
3351                 possible.
3352             </item>
3353           </taglist>
3354         </p>
3355         <p>
3356           When selecting which level of dependency to use you should
3357           consider how important the depended-on package is to the
3358           functionality of the one declaring the dependency.  Some
3359           packages are composed of components of varying degrees of
3360           importance.  Such a package should list using
3361           <tt>Depends</tt> the package(s) which are required by the
3362           more important components.  The other components'
3363           requirements may be mentioned as Suggestions or
3364           Recommendations, as appropriate to the components' relative
3365           importance.
3366         </p>
3367
3368
3369       <sect id="conflicts"><heading>Conflicting binary packages -
3370            <tt>Conflicts</tt></heading>
3371
3372         <p>
3373           When one binary package declares a conflict with another
3374           using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3375           refuse to allow them to be installed on the system at the
3376           same time.
3377         </p>
3378
3379         <p>
3380           If one package is to be installed, the other must be removed
3381           first - if the package being installed is marked as
3382           replacing (see <ref id="replaces">) the one on the system,
3383           or the one on the system is marked as deselected, or both
3384           packages are marked <tt>Essential</tt>, then
3385           <prgn>dpkg</prgn> will automatically remove the package
3386           which is causing the conflict, otherwise it will halt the
3387           installation of the new package with an error.  This
3388           mechanism is specifically designed to produce an error when
3389           the installed package is <tt>Essential</tt>, but the new
3390           package is not.
3391         </p>
3392
3393         <p>
3394           A package will not cause a conflict merely because its
3395           configuration files are still installed; it must be at least
3396           half-installed.
3397         </p>
3398
3399         <p>
3400           A special exception is made for packages which declare a
3401           conflict with their own package name, or with a virtual
3402           package which they provide (see below): this does not
3403           prevent their installation, and allows a package to conflict
3404           with others providing a replacement for it.  You use this
3405           feature when you want the package in question to be the only
3406           package providing some feature.
3407         </p>
3408
3409         <p>
3410           A <tt>Conflicts</tt> entry should almost never have an
3411           `earlier than' version clause.  This would prevent
3412           <prgn>dpkg</prgn> from upgrading or installing the package
3413           which declared such a conflict until the upgrade or removal
3414           of the conflicted-with package had been completed.
3415         </p>
3416       </sect>
3417
3418       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3419         </heading>
3420
3421         <p>
3422           As well as the names of actual (`concrete') packages, the
3423           package relationship fields <tt>Depends</tt>,
3424           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3425           <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3426           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3427           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3428           may mention `virtual packages'.
3429         </p>
3430
3431         <p>
3432           A <em>virtual package</em> is one which appears in the
3433           <tt>Provides</tt> control file field of another package.
3434           The effect is as if the package(s) which provide a
3435           particular virtual package name had been listed by name
3436           everywhere the virtual package name appears.
3437         </p>
3438
3439         <p>
3440           If there are both a real and a virtual package of the same
3441           name then the dependency may be satisfied (or the conflict
3442           caused) by either the real package or any of the virtual
3443           packages which provide it.  This is so that, for example,
3444           supposing we have
3445           <example compact="compact">
3446 Package: foo
3447 Depends: bar
3448           </example>
3449           and someone else releases an enhanced version of the
3450           <tt>bar</tt> package (for example, a non-US variant), they
3451           can say:
3452           <example compact="compact">
3453 Package: bar-plus
3454 Provides: bar
3455           </example>
3456           and the <tt>bar-plus</tt> package will now also satisfy the
3457           dependency for the <tt>foo</tt> package.
3458         </p>
3459
3460         <p>
3461           If a dependency or a conflict has a version number attached
3462           then only real packages will be considered to see whether
3463           the relationship is satisfied (or the prohibition violated,
3464           for a conflict) - it is assumed that a real package which
3465           provides the virtual package is not of the `right' version.
3466           So, a <tt>Provides</tt> field may not contain version
3467           numbers, and the version number of the concrete package
3468           which provides a particular virtual package will not be
3469           looked at when considering a dependency on or conflict with
3470           the virtual package name.
3471         </p>
3472
3473         <p>
3474           It is likely that the ability will be added in a future
3475           release of <prgn>dpkg</prgn> to specify a version number for
3476           each virtual package it provides.  This feature is not yet
3477           present, however, and is expected to be used only
3478           infrequently.
3479         </p>
3480
3481         <p>
3482           If you want to specify which of a set of real packages
3483           should be the default to satisfy a particular dependency on
3484           a virtual package, you should list the real package as an
3485           alternative before the virtual one.
3486         </p>
3487       </sect>
3488
3489
3490       <sect id="replaces"><heading>Overwriting files and replacing
3491           packages - <tt>Replaces</tt></heading>
3492
3493         <p>
3494           The <tt>Replaces</tt> control file field has two distinct
3495           purposes, which come into play in different situations.
3496         </p>
3497
3498         <sect1><heading>Overwriting files in other packages</heading>
3499
3500           <p>
3501             Firstly, as mentioned before, it is usually an error for a
3502             package to contain files which are on the system in
3503             another package.
3504           </p>
3505
3506           <p>
3507             However, if the overwriting package declares that it
3508             <tt>Replaces</tt> the one containing the file being
3509             overwritten, then <prgn>dpkg</prgn> will replace the file
3510             from the old package with that from the new.  The file
3511             will no longer be listed as `owned' by the old package.
3512           </p>
3513
3514           <p>
3515             If a package is completely replaced in this way, so that
3516             <prgn>dpkg</prgn> does not know of any files it still
3517             contains, it is considered to have `disappeared'.  It will
3518             be marked as not wanted on the system (selected for
3519             removal) and not installed.  Any <tt>conffile</tt>s
3520             details noted for the package will be ignored, as they
3521             will have been taken over by the overwriting package.  The
3522             package's <prgn>postrm</prgn> script will be run with a
3523             special argument to allow the package to do any final
3524             cleanup required.  See <ref id="mscriptsinstact">.
3525           </p>
3526
3527           <p>
3528             If an installed package, <tt>foo</tt> say, declares that
3529             it replaces another, <tt>bar</tt>, and an attempt is made
3530             to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3531             files in the <tt>bar</tt> package which would overwrite
3532             those already present in <tt>foo</tt>.  This is so that
3533             you can install an older version of a package without
3534             problems.
3535           </p>
3536
3537           <p>
3538             For this usage of <tt>Replaces</tt>, virtual packages (see
3539             <ref id="virtual">) are not considered when looking at a
3540             <tt>Replaces</tt> field - the packages declared as being
3541             replaced must be mentioned by their real names.
3542           </p>
3543
3544           <p>
3545             Furthermore, this usage of <tt>Replaces</tt> only takes
3546             effect when both packages are at least partially on the
3547             system at once, so that it can only happen if they do not
3548             conflict or if the conflict has been overridden.
3549           </p>
3550
3551         </sect1>
3552
3553         <sect1><heading>Replacing whole packages, forcing their
3554             removal</heading>
3555
3556           <p>
3557             Secondly, <tt>Replaces</tt> allows the packaging system to
3558             resolve which package should be removed when there is a
3559             conflict - see <ref id="conflicts">.  This usage only
3560             takes effect when the two packages <em>do</em> conflict,
3561             so that the two usages of this field do not interfere with
3562             each other.
3563           </p>
3564
3565           <p>
3566             In this situation, the package declared as being replaced
3567             can be a virtual package, so for example, all mail
3568             transport agents (MTAs) would have the following fields in
3569             their control files:
3570             <example compact="compact">
3571 Provides: mail-transport-agent
3572 Conflicts: mail-transport-agent
3573 Replaces: mail-transport-agent
3574             </example>
3575             ensuring that only one MTA can be installed at any one
3576             time.
3577         </sect1>
3578       </sect>
3579
3580       <sect><heading>Relationships between source and binary packages -
3581           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3582           <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3583         </heading>
3584
3585         <p>
3586           A source package may declare a dependency or a conflict on a
3587           binary package, indicating which packages are required to be
3588           present on the system in order to build the binary packages
3589           from the source package.  This is done with the control file
3590           fields <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3591           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>.
3592           The dependencies and conflicts they define must be satisfied
3593           (as defined earlier for binary packages) in order to invoke
3594           the targets in <tt>debian/rules</tt>, as follows:
3595
3596           <taglist>
3597             <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3598             <item>
3599               <p>
3600                 The <tt>Build-Depends</tt> and
3601                 <tt>Build-Conflicts</tt> fields must be satisfied when
3602                 any of the following targets is invoked:
3603                 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>
3604                 and <tt>binary-indep</tt>.
3605               </p>
3606             </item>
3607             <tag><tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt></tag>
3608             <item>
3609               <p>
3610                 The <tt>Build-Depends-Indep</tt> and
3611                 <tt>Build-Conflicts-Indep</tt> fields must be
3612                 satisfied when any of the following targets is
3613                 invoked: <tt>binary</tt> and <tt>binary-indep</tt>.
3614               </p>
3615             </item>
3616           </taglist>
3617
3618         </p>
3619
3620       </sect>
3621     </chapt>
3622
3623
3624     <chapt id="conffiles"><heading>Configuration file handling
3625       </heading>
3626
3627       <p>
3628         This chapter has been superseded by <ref id="config-files">.
3629       </p>
3630
3631
3632     <chapt id="sharedlibs"><heading>Shared libraries</heading>
3633
3634       <p>
3635         Packages containing shared libraries must be constructed with
3636         a little care to make sure that the shared library is always
3637         available.  This is especially important for packages whose
3638         shared libraries are vitally important, such as the C library
3639         (currently <tt>libc6</tt>).
3640       </p>
3641
3642       <p>
3643         Firstly, the package should install the shared libraries under
3644         their normal names.  For example, the <tt>libgdbmg1</tt>
3645         package should install <tt>libgdbm.so.1.7.3</tt> as
3646         <file>/usr/lib/libgdbm.so.1.7.3</file>.  The files should not be
3647         renamed or re-linked by any <prgn>prerm</prgn> or
3648         <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3649         of renaming things safely without affecting running programs,
3650         and attempts to interfere with this are likely to lead to
3651         problems.
3652       </p>
3653
3654       <p>
3655         Secondly, the package should include the symbolic link that
3656         <prgn>ldconfig</prgn> would create for the shared libraries.
3657         For example, the <prgn>libgdbmg1</prgn> package should include
3658         a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3659         <file>libgdbm.so.1.7.3</file>.  This is needed so that the dynamic
3660         linker (for example <prgn>ld.so</prgn> or
3661         <prgn>ld-linux.so.*</prgn>) can find the library between the
3662         time that <prgn>dpkg</prgn> installs it and the time that
3663         <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3664         script.<footnote>
3665           <p>
3666             The package management system requires the library to be
3667             placed before the symbolic link pointing to it in the
3668             <file>.deb</file> file.  This is so that when
3669             <prgn>dpkg</prgn> comes to install the symlink
3670             (overwriting the previous symlink pointing at an older
3671             version of the library), the new shared library is already
3672             in place.  In the past, this was achieved by creating the
3673             library in the temporary packaging directory before
3674             creating the symlink.  Unfortunately, this was not always
3675             effective, since the building of the tar file in the
3676             <file>.deb</file> depended on the behavior of the underlying
3677             file system.  Some file systems (such as reiserfs) reorder
3678             the files so that the order of creation is forgotten.
3679             Starting with release <tt>1.7.0</tt>, <prgn>dpkg</prgn>
3680             will reorder the files itself as necessary when building a
3681             package.  Thus it is no longer important to concern
3682             oneself with the order of file creation.
3683           </p>
3684         </footnote>
3685       </p>
3686
3687       <p>
3688         Thirdly, the associated development package should contain a
3689         symlink for the shared library without a version number.  For
3690         example, the <tt>libgdbmg1-dev</tt> package should include a
3691         symlink from <tt>/usr/lib/libgdbm.so</tt> to
3692         <file>libgdbm.so.1.7.3</file>.  This symlink is needed by the
3693         linker (<prgn>ld</prgn>) when compiling packages, as it will
3694         only look for <file>libgdbm.so</file> when compiling dynamically.
3695       </p>
3696
3697       <p>
3698         Any package installing shared libraries in one of the default
3699         library directories of the dynamic linker (which are currently
3700         <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3701         listed in <file>/etc/ld.so.conf</file><footnote>
3702           <p>
3703             These are currently
3704             <list compact="compact">
3705               <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3706               <item><p>/usr/local/lib</p></item>
3707               <item><p>/usr/lib/libc5-compat</p></item>
3708               <item><p>/lib/libc5-compat</p></item>
3709               <item><p>/usr/X11R6/lib</p></item>
3710             </list>
3711           </p>
3712         </footnote>
3713         must call <prgn>ldconfig</prgn> in its <prgn>postinst</prgn>
3714         script if the first argument is <tt>configure</tt> and should
3715         call it in the <prgn>postrm</prgn> script if the first
3716         argument is <tt>remove</tt>.
3717       </p>
3718
3719       <p>
3720         However, <prgn>postrm</prgn> and <prgn>preinst</prgn> scripts
3721         <em>must not</em> call <prgn>ldconfig</prgn> in the case where
3722         the package is being upgraded (see <ref id="unpackphase"> for
3723         details), as <prgn>ldconfig</prgn> will see the temporary
3724         names that <prgn>dpkg</prgn> uses for the files while it is
3725         installing them and will make the shared library links point
3726         to them, just before <prgn>dpkg</prgn> continues the
3727         installation and renames the temporary files!
3728       </p>
3729
3730       <sect>
3731         <heading>Handling shared library dependencies - the
3732           <tt>shlibs</tt> system</heading>
3733
3734         <p>
3735           If a package contains a binary or library which links to a
3736           shared library, we must ensure that when the package is
3737           installed on the system, all of the libraries needed are
3738           also installed.  This requirement led to the creation of the
3739           <tt>shlibs</tt> system, which is very simple in its design:
3740           any package which <em>provides</em> a shared library also
3741           provides information on the package dependencies required to
3742           ensure the presence of this library, and any package which
3743           <em>uses</em> a shared library uses this information to
3744           determine the dependencies it requires.  The files which
3745           contain the mapping from shared libraries to the necessary
3746           dependency information are called <file>shlibs</file> files.
3747         </p>
3748
3749         <p>
3750           Thus, when a package is built which contains any shared
3751           libraries, it must provide a <file>shlibs</file> file for other
3752           packages to use, and when a package is built which contains
3753           any shared libraries or compiled binaries, it must run
3754           <prgn>dpkg-shlibdeps</prgn> on these to determine the
3755           libraries used and hence the dependencies needed by this
3756           package.<footnote>
3757             <p>
3758               In the past, the shared libraries linked to were
3759               determined by calling <prgn>ldd</prgn>, but now
3760               <prgn>objdump</prgn> is used to do this.  The only
3761               change this makes to package building is that
3762               <prgn>dpkg-shlibdeps</prgn> must also be run on shared
3763               libraries, whereas in the past this was unnecessary.
3764               The rest of this footnote explains the advantage that
3765               this method gives.
3766             </p>
3767
3768             <p>
3769               We say that a binary <tt>foo</tt> <em>directly</em> uses
3770               a library <tt>libbar</tt> if it is explicitly linked
3771               with that library (that is, it uses the flag
3772               <tt>-lbar</tt> during the linking stage).  Other
3773               libraries that are needed by <tt>libbar</tt> are linked
3774               <em>indirectly</em> to <tt>foo</tt>, and the dynamic
3775               linker will load them automatically when it loads
3776               <tt>libbar</tt>.  A package should depend on
3777               the libraries it directly uses, and the dependencies for
3778               those libraries should automatically pull in the other
3779               libraries.
3780             </p>
3781
3782             <p>
3783               Unfortunately, the <prgn>ldd</prgn> program shows both
3784               the directly and indirectly used libraries, meaning that
3785               the dependencies determined included both direct and
3786               indirect dependencies.  The use of <prgn>objdump</prgn>
3787               avoids this problem by determining only the directly
3788               used libraries.
3789             </p>
3790
3791             <p>
3792               A good example of where this helps is the following.  We
3793               could update <tt>libimlib</tt> with a new version that
3794               supports a new graphics format called dgf (but retaining
3795               the same major version number).  If we used the old
3796               <prgn>ldd</prgn> method, every package that uses
3797               <tt>libimlib</tt> would need to be recompiled so it
3798               would also depend on <tt>libdgf</tt> or it wouldn't run
3799               due to missing symbols.  However with the new system,
3800               packages using <tt>libimlib</tt> can rely on
3801               <tt>libimlib</tt> itself having the dependency on
3802               <tt>libdgf</tt> and so they would not need rebuilding.
3803             </p>
3804           </footnote>
3805         </p>
3806
3807         <p>
3808           In the following sections, we will first describe where the
3809           various <tt>shlibs</tt> files are to be found, then how to
3810           use <prgn>dpkg-shlibdeps</prgn>, and finally the
3811           <tt>shlibs</tt> file format and how to create them if your
3812           package contains a shared library.
3813         </p>
3814       </sect>
3815
3816       <sect><heading>The <tt>shlibs</tt> files present on the system
3817         </heading>
3818
3819         <p>
3820           There are several places where <tt>shlibs</tt> files are
3821           found.  The following list gives them in the order in which
3822           they are read by <prgn>dpkg-shlibdeps</prgn>.  (The first
3823           one which gives the required information is used.)
3824         </p>
3825
3826         <p>
3827           <list>
3828             <item>
3829               <p><file>debian/shlibs.local</file></p>
3830               <p>
3831                 This lists overrides for this package.  Its use is
3832                 described below (see <ref id="shlibslocal">).
3833               </p>
3834             </item>
3835
3836             <item>
3837               <p><file>/etc/dpkg/shlibs.override</file></p>
3838               <p>
3839                 This lists global overrides.  This list is normally
3840                 empty.  It is maintained by the local system
3841                 administrator.
3842               </p>
3843             </item>
3844
3845             <item>
3846               <p><file>DEBIAN/shlibs</file> files in the `build directory'</p>
3847               <p>
3848                 When packages are being built, any
3849                 <file>debian/shlibs</file> files are copied into the
3850                 control file area of the temporary build directory and
3851                 given the name <file>shlibs</file>.  These files give
3852                 details of any shared libraries included in the
3853                 package.<footnote>
3854                   <p>
3855                     An example may help here.  Let us say that the
3856                     source package <tt>foo</tt> generates two binary
3857                     packages, <tt>libfoo2</tt> and
3858                     <tt>foo-runtime</tt>.  When building the binary
3859                     packages, the two packages are created in the
3860                     directories <file>debian/libfoo2</file> and
3861                     <file>debian/foo-runtime</file> respectively.
3862                     (<file>debian/tmp</file> could be used instead of one
3863                     of these.)  Since <tt>libfoo2</tt> provides the
3864                     <tt>libfoo</tt> shared library, it will require a
3865                     <tt>shlibs</tt> file, which will be installed in
3866                     <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
3867                     to become
3868                     <file>/var/lib/dpkg/info/libfoo2.shlibs</file>.  Then
3869                     when <prgn>dpkg-shlibdeps</prgn> is run on the
3870                     executable
3871                     <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
3872                     will examine the
3873                     <file>debian/libfoo2/DEBIAN/shlibs</file> file to
3874                     determine whether <tt>foo-prog</tt>'s library
3875                     dependencies are satisfied by any of the libraries
3876                     provided by <tt>libfoo2</tt>.  For this reason,
3877                     <prgn>dpkg-shlibdeps</prgn> must only be run once
3878                     all of the individual binary packages'
3879                     <tt>shlibs</tt> files have been installed into the
3880                     build directory.
3881                   </p>
3882                 </footnote>
3883               </p>
3884             </item>
3885
3886             <item>
3887               <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
3888               <p>
3889                 These are the <file>shlibs</file> files corresponding to
3890                 all of the packages installed on the system, and are
3891                 maintained by the relevant package maintainers.
3892               </p>
3893             </item>
3894
3895             <item>
3896               <p><file>/etc/dpkg/shlibs.default</file></p>
3897               <p>
3898                 This file lists any shared libraries whose packages
3899                 have failed to provide correct <file>shlibs</file> files.
3900                 It was used when the <file>shlibs</file> setup was first
3901                 introduced, but it is now normally empty.  It is
3902                 maintained by the <tt>dpkg</tt> maintainer.
3903               </p>
3904             </item>
3905           </list>
3906         </p>
3907       </sect>
3908
3909       <sect>
3910         <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
3911             <file>shlibs</file> files</heading>
3912
3913         <p>
3914           Put a call to <prgn>dpkg-shlibdeps</prgn> into your
3915           <file>debian/rules</file> file.  If your package contains only
3916           compiled binaries and libraries (but no scripts), you can
3917           use a command such as:
3918           <example compact="compact">
3919 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
3920   debian/tmp/usr/lib/*
3921           </example>
3922           Otherwise, you will need to explicitly list the compiled
3923           binaries and libraries.<footnote>
3924             <p>
3925               If you are using <tt>debhelper</tt>, the
3926               <prgn>dh_shlibdeps</prgn> program will do this work for
3927               you.  It will also correctly handle multi-binary
3928               packages.
3929             </p>
3930           </footnote>
3931         </p>
3932
3933         <p>
3934           This command puts the dependency information into the
3935           <file>debian/substvars</file> file, which is then used by
3936           <prgn>dpkg-gencontrol</prgn>.  You will need to place a
3937           <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
3938           field in the control file for this to work.
3939         </p>
3940
3941         <p>
3942           If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
3943           done.  If it does complain you might need to create your own
3944           <file>debian/shlibs.local</file> file, as explained below (see
3945           <ref id="shlibslocal">).
3946         </p>
3947
3948         <p>
3949           If you have multiple binary packages, you will need to call
3950           <prgn>dpkg-shlibdeps</prgn> on each one which contains
3951           compiled libraries or binaries.  In such a case, you will
3952           need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
3953           utilities to specify a different <file>substvars</file> file.
3954           For more details on this and other options, see <manref
3955           name="dpkg-shlibdeps" section="1">.
3956         </p>
3957       </sect>
3958
3959       <sect id="shlibs"><heading>The <file>shlibs</file> File Format
3960         </heading>
3961
3962         <p>
3963           Each <file>shlibs</file> file has the same format.  Lines
3964           beginning with <tt>#</tt> are considered to be comments and
3965           are ignored.  Each line is of the form:
3966           <example compact="compact">
3967 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
3968           </example>
3969         </p>
3970
3971         <p>
3972           We will explain this by reference to the example of the
3973           <tt>zlib1g</tt> package, which (at the time of writing)
3974           installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
3975         </p>
3976
3977         <p>
3978           <var>library-name</var> is the name of the shared library,
3979           in this case <tt>libz</tt>.  (This must match the name part
3980           of the soname, see below.)
3981         </p>
3982
3983         <p>
3984           <var>soname-version-number</var> is the version part of the
3985           soname of the library.  The soname is the thing that must
3986           exactly match for the library to be recognized by the
3987           dynamic linker, and is usually of the form
3988           <tt><var>name</var>.so.<var>major-version</var></tt>, in our
3989           example, <tt>libz.so.1</tt>.<footnote>
3990             <p>
3991               This can be determined using the command
3992               <example compact="compact">
3993 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
3994               </example>
3995             </p>
3996           </footnote>
3997           The version part is the part which comes after
3998           <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
3999         </p>
4000
4001         <p>
4002           <var>dependencies</var> has the same syntax as a dependency
4003           field in a binary package control file.  It should give
4004           details of which packages are required to satisfy a binary
4005           built against the version of the library contained in the
4006           package.  See <ref id="depsyntax"> for details.
4007         </p>
4008
4009         <p>
4010           In our example, if the first version of the <tt>zlib1g</tt>
4011           package which contained a minor number of at least
4012           <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4013           <tt>shlibs</tt> entry for this library could say:
4014           <example compact="compact">
4015 libz 1 zlib1g (>= 1:1.1.3)
4016           </example>
4017           The version-specific dependency is to avoid warnings from
4018           the dynamic linker about using older shared libraries with
4019           newer binaries.
4020         </p>
4021       </sect>
4022
4023       <sect>
4024         <heading>Providing a <file>shlibs</file> file</heading>
4025
4026         <p>
4027           If your package provides a shared library, you should create
4028           a <file>shlibs</file> file following the format described above.
4029           It is usual to call this file <file>debian/shlibs</file> (but if
4030           you have multiple binary packages, you might want to call it
4031           <file>debian/shlibs.<var>package</var></file> instead).  Then
4032           let <file>debian/rules</file> install it in the control area:
4033           <example compact="compact">
4034 install -m644 debian/shlibs debian/tmp/DEBIAN
4035           </example>
4036           or, in the case of a multi-binary package:
4037           <example compact="compact">
4038 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4039           </example>
4040           An alternative way of doing this is to create the
4041           <file>shlibs</file> file in the control area directly from
4042           <file>debian/rules</file> without using a <file>debian/shlibs</file>
4043           file at all,<footnote>
4044             <p>
4045               This is what <prgn>dh_makeshlibs</prgn> in the
4046               <tt>debhelper</tt> suite does.
4047             </p>
4048           </footnote>
4049           since the <file>debian/shlibs</file> file itself is ignored by
4050           <prgn>dpkg-shlibdeps</prgn>.
4051         </p>
4052
4053         <p>
4054           As <prgn>dpkg-shlibdeps</prgn> reads the
4055           <file>DEBIAN/shlibs</file> files in all of the binary packages
4056           being built from this source package, all of the
4057           <file>DEBIAN/shlibs</file> files should be installed before
4058           <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4059           packages.
4060         </p>
4061       </sect>
4062
4063       <sect id="shlibslocal">
4064         <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4065
4066         <p>
4067           This file is intended only as a <em>temporary</em> fix if
4068           your binaries or libraries depend on a library whose package
4069           does not yet provide a correct <file>shlibs</file> file.
4070         </p>
4071
4072         <p>
4073           We will assume that you are trying to package a binary
4074           <tt>foo</tt>.  When you try running
4075           <prgn>dpkg-shlibdeps</prgn> you get the following error
4076           message (<tt>-O</tt> displays the dependency information on
4077           <tt>stdout</tt> instead of writing it to
4078           <tt>debian/substvars</tt>, and the lines have been wrapped
4079           for ease of reading):
4080           <example compact="compact">
4081 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4082 dpkg-shlibdeps: warning: unable to find dependency
4083   information for shared library libbar (soname 1,
4084   path /usr/lib/libbar.so.1, dependency field Depends)
4085 shlibs:Depends=libc6 (>= 2.2.2-2)
4086           </example>
4087           You can then run <prgn>ldd</prgn> on the binary to find the
4088           full location of the library concerned:
4089           <example compact="compact">
4090 $ ldd foo
4091 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4092 libc.so.6 => /lib/libc.so.6 (0x40032000)
4093 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4094           </example>
4095           So the <prgn>foo</prgn> binary depends on the
4096           <prgn>libbar</prgn> shared library, but no package seems to
4097           provide a <file>*.shlibs</file> file handling
4098           <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>.  Let's
4099           determine the package responsible:
4100           <example compact="compact">
4101 $ dpkg -S /usr/lib/libbar.so.1
4102 bar1: /usr/lib/libbar.so.1
4103 $ dpkg -s bar1 | grep Version
4104 Version: 1.0-1
4105           </example>
4106           This tells us that the <tt>bar1</tt> package, version 1.0-1,
4107           is the one we are using.  Now we can file a bug against the
4108           <tt>bar1</tt> package and create our own
4109           <file>debian/shlibs.local</file> to locally fix the problem.
4110           Including the following line into your
4111           <file>debian/shlibs.local</file> file:
4112           <example compact="compact">
4113 libbar 1 bar1 (>= 1.0-1)
4114           </example>
4115           should allow the package build to work.
4116         </p>
4117
4118         <p>
4119           As soon as the maintainer of <tt>bar1</tt> provides a
4120           correct <file>shlibs</file> file, you should remove this line
4121           from your <file>debian/shlibs.local</file> file.  (You should
4122           probably also then have a versioned <tt>Build-Depends</tt>
4123           on <tt>bar1</tt> to help ensure that others do not have the
4124           same problem building your package.)
4125         </p>
4126       </sect>
4127     </chapt>
4128
4129     <chapt id="opersys"><heading>The Operating System</heading>
4130
4131       <sect>
4132         <heading>Filesystem hierarchy</heading>
4133
4134
4135         <sect1>
4136           <heading>Filesystem Structure</heading>
4137
4138           <p>
4139             The location of all installed files and directories must
4140             comply with the Filesystem Hierarchy Standard (FHS),
4141             version 2.1, except where doing so would violate other
4142             terms of Debian Policy. The version of this document
4143             referred here can be found in the <tt>debian-policy</tt>
4144             package or on 
4145             <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4146               name="FHS (Debian copy)"> alongside this manual. The
4147             latest version, which may be a more recent version, may
4148             be found on
4149             <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4150             Specific questions about following the standard may be
4151             asked on the <tt>debian-devel</tt> mailing list, or
4152             referred to the FHS mailing list (see the 
4153             <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4154             more information). 
4155           </p>
4156         </sect1>
4157
4158         <sect1>
4159           <heading>Site-specific programs</heading>
4160
4161           <p>
4162             As mandated by the FHS, packages must not place any
4163             files in <file>/usr/local</file>, either by putting them in
4164             the file system archive to be unpacked by <prgn>dpkg</prgn>
4165             or by manipulating them in their maintainer scripts.
4166           </p>
4167
4168           <p>
4169             However, the package may create empty directories below
4170             <file>/usr/local</file> so that the system administrator knows
4171             where to place site-specific files.  These directories
4172             should be removed on package removal if they are
4173             empty.
4174           </p>
4175
4176           <p>
4177             Note, that this applies only to directories <em>below</em>
4178             <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4179             Packages must not create sub-directories in the directory
4180             <file>/usr/local</file> itself, except those listed in FHS,
4181             section 4.5.  However, you may create directories below
4182             them as you wish. You must not remove any of the
4183             directories listed in 4.5, even if you created them.
4184           </p>
4185
4186           <p>
4187             Since <file>/usr/local</file> can be mounted read-only from a
4188             remote server, these directories must be created and
4189             removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4190             maintainer scripts and not be included in the
4191             <file>.deb</file> archive.  These scripts must not fail if
4192             either of these operations fail.
4193           </p>
4194
4195           <p>
4196             For example, the <tt>emacsen-common</tt> package could
4197             contain something like
4198             <example compact="compact">
4199 if [ ! -e /usr/local/share/emacs ]
4200 then
4201   if mkdir /usr/local/share/emacs 2>/dev/null
4202   then
4203     chown root:staff /usr/local/share/emacs
4204     chmod 2775 /usr/local/share/emacs
4205   fi
4206 fi
4207             </example>
4208             in its <prgn>postinst</prgn> script, and
4209             <example compact="compact">
4210 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4211 rmdir /usr/local/share/emacs 2>/dev/null || true
4212             </example>
4213             in the <prgn>prerm</prgn> script.  (Note that this form is
4214             used to ensure that if the script is interrupted, the
4215             directory <file>/usr/local/share/emacs</file> will still be
4216             removed.)
4217           </p>
4218
4219           <p>
4220             If you do create a directory in <file>/usr/local</file> for
4221             local additions to a package, you should ensure that
4222             settings in <file>/usr/local</file> take precedence over the
4223             equivalents in <file>/usr</file>.
4224           </p>
4225
4226           <p>
4227             However, because <file>/usr/local</file> and its contents are
4228             for exclusive use of the local administrator, a package
4229             must not rely on the presence or absence of files or
4230             directories in <file>/usr/local</file> for normal operation.
4231           </p>
4232
4233           <p>
4234             The <file>/usr/local</file> directory itself and all the
4235             subdirectories created by the package should (by default) have
4236             permissions 2775 (group-writable and set-group-id) and be
4237             owned by <tt>root.staff</tt>.
4238           </p>
4239         </sect1>
4240
4241         <sect1>
4242           <heading>The system-wide mail directory</heading>
4243           <p>
4244             The system-wide mail directory is <file>/var/mail</file>. This
4245             directory is part of the base system and should not owned
4246             by any particular mail agents.  The use of the old
4247             location <file>/var/spool/mail</file> is deprecated, even
4248             though the spool may still be physically located there.
4249             To maintain partial upgrade compatibility for systems
4250             which have <file>/var/spool/mail</file> as their physical mail
4251             spool, packages using <file>/var/mail</file> must depend on
4252             either <package>libc6</package> (&gt;= 2.1.3-13), or on
4253             <package>base-files</package> (&gt;= 2.2.0), or on later
4254             versions of either one of these packages.
4255           </p>
4256         </sect1>
4257       </sect>
4258
4259       <sect>
4260         <heading>Users and groups</heading>
4261
4262         <sect1>
4263           <heading>Introduction</heading>
4264           <p>
4265             The Debian system can be configured to use either plain or
4266             shadow passwords.
4267           </p>
4268
4269           <p>
4270             Some user ids (UIDs) and group ids (GIDs) are reserved
4271             globally for use by certain packages.  Because some
4272             packages need to include files which are owned by these
4273             users or groups, or need the ids compiled into binaries,
4274             these ids must be used on any Debian system only for the
4275             purpose for which they are allocated. This is a serious
4276             restriction, and we should avoid getting in the way of
4277             local administration policies. In particular, many sites
4278             allocate users and/or local system groups starting at 100.
4279           </p>
4280
4281           <p>
4282             Apart from this we should have dynamically allocated ids,
4283             which should by default be arranged in some sensible
4284             order, but the behavior should be configurable.
4285           </p>
4286
4287           <p>
4288             Packages other than <tt>base-passwd</tt> must not modify
4289             <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4290             <file>/etc/group</file> or <file>/etc/gshadow</file>.
4291           </p>
4292         </sect1>
4293
4294         <sect1>
4295           <heading>UID and GID classes</heading>
4296           <p>
4297             The UID and GID numbers are divided into classes as
4298             follows:
4299             <taglist>
4300               <tag>0-99:</tag>
4301               <item>
4302                 <p>
4303                   Globally allocated by the Debian project, the same
4304                   on every Debian system.  These ids will appear in
4305                   the <file>passwd</file> and <file>group</file> files of all
4306                   Debian systems, new ids in this range being added
4307                   automatically as the <tt>base-passwd</tt> package is
4308                   updated.
4309                 </p>
4310
4311                 <p>
4312                   Packages which need a single statically allocated
4313                   uid or gid should use one of these; their
4314                   maintainers should ask the <tt>base-passwd</tt>
4315                   maintainer for ids.
4316                 </p>
4317               </item>
4318
4319               <tag>100-999:</tag>
4320               <item>
4321                 <p>
4322                   Dynamically allocated system users and groups.
4323                   Packages which need a user or group, but can have
4324                   this user or group allocated dynamically and
4325                   differently on each system, should use <tt>adduser
4326                   --system</tt> to create the group and/or user.
4327                   <prgn>adduser</prgn> will check for the existence of
4328                   the user or group, and if necessary choose an unused
4329                   id based on the ranges specified in
4330                   <file>adduser.conf</file>.
4331                 </p>
4332               </item>
4333
4334               <tag>1000-29999:</tag>
4335               <item>
4336                 <p>
4337                   Dynamically allocated user accounts.  By default
4338                   <prgn>adduser</prgn> will choose UIDs and GIDs for
4339                   user accounts in this range, though
4340                   <file>adduser.conf</file> may be used to modify this
4341                   behavior.
4342                 </p>
4343               </item>
4344
4345               <tag>30000-59999:</tag>
4346               <item>
4347                 <p>Reserved.</p>
4348               </item>
4349
4350               <tag>60000-64999:</tag>
4351               <item>
4352                 <p>
4353                   Globally allocated by the Debian project, but only
4354                   created on demand. The ids are allocated centrally
4355                   and statically, but the actual accounts are only
4356                   created on users' systems on demand.
4357                 </p>
4358
4359                 <p>
4360                   These ids are for packages which are obscure or
4361                   which require many statically-allocated ids.  These
4362                   packages should check for and create the accounts in
4363                   <file>/etc/passwd</file> or <file>/etc/group</file> (using
4364                   <prgn>adduser</prgn> if it has this facility) if
4365                   necessary.  Packages which are likely to require
4366                   further allocations should have a `hole' left after
4367                   them in the allocation, to give them room to
4368                   grow.
4369                 </p>
4370               </item>
4371
4372               <tag>65000-65533:</tag>
4373               <item>
4374                 <p>Reserved.</p>
4375               </item>
4376
4377               <tag>65534:</tag>
4378               <item>
4379                 <p>
4380                   User <tt>nobody</tt>. The corresponding gid refers
4381                   to the group <tt>nogroup</tt>.
4382                 </p>
4383               </item>
4384
4385               <tag>65535:</tag>
4386               <item>
4387                 <p>
4388                   <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4389                   not</em> be used, because it is the error return
4390                   sentinel value.
4391                 </p>
4392               </item>
4393             </taglist>
4394           </p>
4395         </sect1>
4396       </sect>
4397
4398       <sect id="sysvinit">
4399         <heading>System run levels and <file>init.d</file> scripts</heading>
4400
4401         <sect1 id="/etc/init.d">
4402           <heading>Introduction</heading>
4403
4404           <p>
4405             The <file>/etc/init.d</file> directory contains the scripts
4406             executed by <prgn>init</prgn> at boot time and when the
4407             init state (or `runlevel') is changed (see <manref
4408             name="init" section="8">).
4409           </p>
4410
4411           <p>
4412             There are at least two different, yet functionally
4413             equivalent, ways of handling these scripts.  For the sake
4414             of simplicity, this document describes only the symbolic
4415             link method. However, it must not be assumed by maintainer
4416             scripts that this method is being used, and any automated
4417             manipulation of the various runlevel behaviours by
4418             maintainer scripts must be performed using
4419             <prgn>update-rc.d</prgn> as described below and not by
4420             manually installing or removing symlinks.  For information
4421             on the implementation details of the other method,
4422             implemented in the <tt>file-rc</tt> package, please refer
4423             to the documentation of that package.
4424           </p>
4425
4426           <p>
4427             These scripts are referenced by symbolic links in the
4428             <file>/etc/rc<var>n</var>.d</file> directories.  When changing
4429             runlevels, <prgn>init</prgn> looks in the directory
4430             <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4431             execute, where <tt><var>n</var></tt> is the runlevel that
4432             is being changed to, or <tt>S</tt> for the boot-up
4433             scripts.
4434           </p>
4435
4436           <p>
4437             The names of the links all have the form
4438             <file>S<var>mm</var><var>script</var></file> or
4439             <file>K<var>mm</var><var>script</var></file> where
4440             <var>mm</var> is a two-digit number and <var>script</var>
4441             is the name of the script (this should be the same as the
4442             name of the actual script in <file>/etc/init.d</file>).
4443           </p>
4444
4445           <p>
4446             When <prgn>init</prgn> changes runlevel first the targets
4447             of the links whose names start with a <tt>K</tt> are
4448             executed, each with the single argument <tt>stop</tt>,
4449             followed by the scripts prefixed with an <tt>S</tt>, each
4450             with the single argument <tt>start</tt>.  (The links are
4451             those in the <file>/etc/rc<var>n</var>.d</file> directory
4452             corresponding to the new runlevel.)  The <tt>K</tt> links
4453             are responsible for killing services and the <tt>S</tt>
4454             link for starting services upon entering the runlevel.
4455           </p>
4456
4457           <p>
4458             For example, if we are changing from runlevel 2 to
4459             runlevel 3, init will first execute all of the <tt>K</tt>
4460             prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4461             all of the <tt>S</tt> prefixed scripts in that directory.
4462             The links starting with <tt>K</tt> will cause the
4463             referred-to file to be executed with an argument of
4464             <tt>stop</tt>, and the <tt>S</tt> links with an argument
4465             of <tt>start</tt>.
4466           </p>
4467
4468           <p>
4469             The two-digit number <var>mm</var> is used to determine
4470             the order in which to run the scripts: low-numbered links
4471             have their scripts run first.  For example, the
4472             <tt>K20</tt> scripts will be executed before the
4473             <tt>K30</tt> scripts.  This is used when a certain service
4474             must be started before another.  For example, the name
4475             server <prgn>bind</prgn> might need to be started before
4476             the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4477             can set up its access lists.  In this case, the script
4478             that starts <prgn>bind</prgn> would have a lower number
4479             than the script that starts <prgn>inn</prgn> so that it
4480             runs first:
4481             <example compact="compact">
4482 /etc/rc2.d/S17bind
4483 /etc/rc2.d/S70inn
4484             </example>
4485           </p>
4486
4487           <p>
4488             The two runlevels 0 (halt) and 6 (reboot) are slightly
4489             different.  In these runlevels, the links with an
4490             <tt>S</tt> prefix are still called after those with a
4491             <tt>K</tt> prefix, but they too are called with the single
4492             argument <tt>stop</tt>.
4493           </p>
4494
4495           <p>
4496             Also, if the script name ends <tt>.sh</tt>, the script
4497             will be sourced in runlevel <tt>S</tt> rather that being
4498             run in a forked subprocess, but will be explicitly run by
4499             <prgn>sh</prgn> in all other runlevels.
4500           </p>
4501         </sect1>
4502
4503         <sect1>
4504           <heading>Writing the scripts</heading>
4505
4506           <p>
4507             Packages that include daemons for system services should
4508             place scripts in <file>/etc/init.d</file> to start or stop
4509             services at boot time or during a change of runlevel.
4510             These scripts should be named
4511             <file>/etc/init.d/<var>package</var></file>, and they should
4512             accept one argument, saying what to do:
4513
4514             <taglist>
4515               <tag><tt>start</tt></tag>
4516               <item><p>start the service,</p></item>
4517
4518               <tag><tt>stop</tt></tag>
4519               <item><p>stop the service,</p></item>
4520
4521               <tag><tt>restart</tt></tag>
4522               <item><p>stop and restart the service,</p></item>
4523
4524               <tag><tt>reload</tt></tag>
4525               <item><p>cause the configuration of the service to be
4526                   reloaded without actually stopping and restarting
4527                   the service,</p></item>
4528
4529               <tag><tt>force-reload</tt></tag>
4530               <item><p>cause the configuration to be reloaded if the
4531                   service supports this, otherwise restart the
4532                   service.</p></item>
4533             </taglist>
4534
4535             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4536             <tt>force-reload</tt> options should be supported by all
4537             scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4538             option is optional.</p>
4539
4540           <p>
4541             The <file>init.d</file> scripts should ensure that they will
4542             behave sensibly if invoked with <tt>start</tt> when the
4543             service is already running, or with <tt>stop</tt> when it
4544             isn't, and that they don't kill unfortunately-named user
4545             processes.  The best way to achieve this is usually to use
4546             <prgn>start-stop-daemon</prgn>.</p>
4547
4548           <p>
4549             If a service reloads its configuration automatically (as
4550             in the case of <prgn>cron</prgn>, for example), the
4551             <tt>reload</tt> option of the <file>init.d</file> script
4552             should behave as if the configuration has been reloaded
4553             successfully.</p>
4554
4555           <p>
4556             The <file>/etc/init.d</file> scripts must be treated as
4557             configuration files, either (if they are present in the
4558             package, that is, in the .deb file) by marking them as
4559             <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4560             by managing them correctly in the maintainer scripts (see
4561             <ref id="config-files">).  This is important since we want
4562             to give the local system administrator the chance to adapt
4563             the scripts to the local system, e.g., to disable a
4564             service without de-installing the package, or to specify
4565             some special command line options when starting a service,
4566             while making sure her changes aren't lost during the next
4567             package upgrade.
4568           </p>
4569
4570           <p>
4571             These scripts should not fail obscurely when the
4572             configuration files remain but the package has been
4573             removed, as configuration files remain on the system after
4574             the package has been removed.  Only when <prgn>dpkg</prgn>
4575             is executed with the <tt>--purge</tt> option will
4576             configuration files be removed.  In particular, as the
4577             <file>/etc/init.d/<var>package</var></file> script itself is
4578             usually a <tt>conffile</tt>, it will remain on the system
4579             if the package is removed but not purged.  Therefore, you
4580             should include a <tt>test</tt> statement at the top of the
4581             script, like this:
4582             <example compact="compact">
4583 test -f <var>program-executed-later-in-script</var> || exit 0
4584             </example>
4585           </p>
4586
4587           <p>
4588             Often there are some variables in the <file>init.d</file>
4589             scripts whose values control the behaviour of the scripts,
4590             and which a system administrator is likely to want to
4591             change.  As the scripts themselves are frequently
4592             <tt>conffile</tt>s, modifying them requires that the
4593             administrator merge in their changes each time the package
4594             is upgraded and the <tt>conffile</tt> changes.  To ease
4595             the burden on the system administrator, such configurable
4596             values should not be placed directly in the script.
4597             Instead, they should be placed in a file in
4598             <file>/etc/default</file>, which typically will have the same
4599             base name as the <file>init.d</file> script.  This extra file
4600             should be sourced by the script when the script runs.  It
4601             must contain only variable settings and comments in POSIX
4602             <prgn>sh</prgn> format.  It may either be a
4603             <tt>conffile</tt> or a configuration file maintained by
4604             the package maintainer scripts.  See <ref id="config-files"> 
4605             for more details. 
4606           </p>
4607
4608           <p>
4609             To ensure that vital configurable values are always
4610             available, the <file>init.d</file> script should set default
4611             values for each of the shell variables it uses, either
4612             before sourcing the <file>/etc/default/</file> file or
4613             afterwards using something like the <tt>:
4614             ${VAR:=default}</tt> syntax.  Also, the <file>init.d</file>
4615             script must behave sensibly and not fail if the
4616             <file>/etc/default</file> file is deleted.
4617           </p>
4618         </sect1>
4619
4620         <sect1>
4621           <heading>Managing the links</heading>
4622
4623           <p>
4624             The program <prgn>update-rc.d</prgn> is provided for
4625             package maintainers to arrange for the proper creation and
4626             removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4627             or their functional equivalent if another method is being
4628             used.  This may be used by maintainers in their packages'
4629             <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4630
4631           <p>
4632             You must not include any <file>/etc/rc<var>n</var>.d</file>
4633             symbolic links in the actual archive or manually create or
4634             remove the symbolic links in maintainer scripts; you must
4635             use the <prgn>update-rc.d</prgn> program instead.  (The
4636             former will fail if an alternative method of maintaining
4637             runlevel information is being used.)  You must not include
4638             the <file>/etc/rc<var>n</var>.d</file> directories themselves
4639             in the archive either.  (Only the <tt>sysvinit</tt>
4640             package may do so.)
4641           </p>
4642
4643           <p>
4644             By default <prgn>update-rc.d</prgn> will start services in
4645             each of the multi-user state runlevels (2, 3, 4, and 5)
4646             and stop them in the halt runlevel (0), the single-user
4647             runlevel (1) and the reboot runlevel (6).  The system
4648             administrator will have the opportunity to customize
4649             runlevels by simply adding, moving, or removing the
4650             symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4651             symbolic links are being used, or by modifying
4652             <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4653             is being used.
4654           </p>
4655
4656           <p>
4657             To get the default behavior for your package, put in your
4658             <prgn>postinst</prgn> script
4659             <example compact="compact">
4660 update-rc.d <var>package</var> defaults &gt;/dev/null
4661             </example>
4662             and in your <prgn>postrm</prgn>
4663             <example compact="compact">
4664 if [ "$1" = purge ]; then
4665   update-rc.d <var>package</var> remove &gt;/dev/null
4666 fi
4667             </example></p>
4668
4669           <p>
4670             This will use a default sequence number of 20.  If it does
4671             not matter when or in which order the <file>init.d</file>
4672             script is run, use this default.  If it does, then you
4673             should talk to the maintainer of the <prgn>sysvinit</prgn>
4674             package or post to <tt>debian-devel</tt>, and they will
4675             help you choose a number.
4676           </p>
4677
4678           <p>
4679             For more information about using <tt>update-rc.d</tt>,
4680             please consult its manpage <manref name="update-rc.d"
4681               section="8">.
4682           </p>
4683         </sect1>
4684
4685
4686         <sect1>
4687           <heading>Boot-time initialization</heading>
4688
4689           <p>
4690             There used to be another directory, <file>/etc/rc.boot</file>,
4691             which contained scripts which were run once per machine
4692             boot. This has been deprecated in favour of links from
4693             <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
4694             described in <ref id="/etc/init.d">.  Packages must not
4695             place files in <file>/etc/rc.boot</file>.</p>
4696
4697         <sect1>
4698           <heading>Example</heading>
4699
4700           <p>
4701             The <prgn>bind</prgn> DNS (nameserver) package wants to
4702             make sure that the nameserver is running in multiuser
4703             runlevels, and is properly shut down with the system.  It
4704             puts a script in <file>/etc/init.d</file>, naming the script
4705             appropriately <tt>bind</tt>.  As you can see, the script
4706             interprets the argument <tt>reload</tt> to send the
4707             nameserver a <tt>HUP</tt> signal (causing it to reload its
4708             configuration); this way the system administrator can say
4709             <file>/etc/init.d/bind reload</file> to reload the name
4710             server.  The script has one configurable value, which can
4711             be used to pass parameters to the named program at
4712             startup; this value is read from
4713             <file>/etc/default/bind</file> (see below).
4714           </p>
4715
4716           <p>
4717             <example compact="compact">
4718 #!/bin/sh
4719 #
4720 # Original version by Robert Leslie
4721 # &lt;rob@mars.org&gt;, edited by iwj and cs
4722
4723 test -x /usr/sbin/named || exit 0
4724
4725 # Source defaults file.
4726 PARAMS=''
4727 if [ -f /etc/default/bind ]; then
4728   . /etc/default/bind
4729 fi
4730
4731
4732 case "$1" in
4733 start)
4734   echo -n "Starting domain name service: named"
4735   start-stop-daemon --start --quiet --exec /usr/sbin/named \
4736                     -- $PARAMS
4737   echo "."
4738   ;;
4739 stop)
4740   echo -n "Stopping domain name service: named"
4741   start-stop-daemon --stop --quiet  \
4742     --pidfile /var/run/named.pid --exec /usr/sbin/named
4743   echo "."
4744   ;;
4745 restart)
4746   echo -n "Restarting domain name service: named"
4747   start-stop-daemon --stop --quiet  \
4748     --pidfile /var/run/named.pid --exec /usr/sbin/named
4749   start-stop-daemon --start --verbose --exec /usr/sbin/named \
4750                     -- $PARAMS
4751   echo "."
4752   ;;
4753 force-reload|reload)
4754   echo -n "Reloading configuration of domain name service: named"
4755   start-stop-daemon --stop --signal 1 --quiet  \
4756     --pidfile /var/run/named.pid --exec /usr/sbin/named
4757   echo "."
4758   ;;
4759 *)
4760   echo "Usage: /etc/init.d/bind " \
4761          " {start|stop|restart|reload|force-reload}" >&2
4762   exit 1
4763   ;;
4764 esac
4765
4766 exit 0
4767             </example>
4768           </p>
4769
4770           <p>
4771             Complementing the above init script is a configuration
4772             file <file>/etc/default/bind</file>, which contains
4773             configurable parameters used by the script.  This would be
4774             created by the <prgn>postinst</prgn> script if it was not
4775             already present, and removed on purge by the
4776             <prgn>postrm</prgn> script.
4777             <example compact="compact">
4778 # Specified parameters to pass to named. See named(8).
4779 # You may uncomment the following line, and edit to taste.
4780 #PARAMS="-u nobody"
4781             </example>
4782           </p>
4783
4784           <p>
4785             Another example on which you can base your
4786             <file>/etc/init.d</file> scripts is found in
4787             <file>/etc/init.d/skeleton</file>.
4788           </p>
4789
4790           <p>
4791             If this package is happy with the default setup from
4792             <prgn>update-rc.d</prgn>, namely an ordering number of 20
4793             and having named running in all runlevels, it can say in
4794             its <prgn>postinst</prgn>:
4795             <example compact="compact">
4796 update-rc.d bind defaults >/dev/null
4797             </example>
4798             And in its <prgn>postrm</prgn>, to remove the links when the
4799             package is purged:
4800             <example compact="compact">
4801 if [ "$1" = purge ]; then
4802   update-rc.d bind remove >/dev/null
4803 fi
4804             </example>
4805           </p>
4806         </sect1>
4807       </sect>
4808
4809       <sect>
4810         <heading>Console messages from <file>init.d</file> scripts</heading>
4811
4812         <p>
4813           This section describes the formats to be used for messages
4814           written to standard output by the <file>/etc/init.d</file>
4815           scripts.  The intent is to improve the consistency of
4816           Debian's startup and shutdown look and feel.  For this
4817           reason, please look very carefully at the details.  We want
4818           the messages to have the same format in terms of wording,
4819           spaces, punctuation and case of letters.
4820         </p>
4821
4822         <p>
4823           Here is a list of overall rules that you should use when you
4824           create output messages.  They can be useful if you have a
4825           non-standard message that is not covered specifically in the
4826           sections below.
4827         </p>
4828
4829         <p>
4830           <list>
4831             <item>
4832               <p>
4833                 Every message should fit in one line (fewer than 80
4834                 characters), start with a capital letter and end with
4835                 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
4836               </p>
4837             </item>
4838
4839             <item>
4840               <p>
4841                 If you want to express that the computer is working on
4842                 something (that is, performing a specific task, not
4843                 starting or stopping a program), we use an "ellipsis"
4844                 (three dots: <tt>...</tt>).  Note that we don't insert
4845                 spaces before or after the dots.  If the task has been
4846                 completed we write <tt>done.</tt> and a line feed.
4847               </p>
4848             </item>
4849
4850             <item>
4851               <p>
4852                 Design your messages as if the computer is telling you
4853                 what he is doing (let him be polite :-), but don't
4854                 mention "him" directly.  For example, if you think of
4855                 saying
4856                 <example compact="compact">
4857 I'm starting network daemons: nfsd mountd.
4858                 </example>
4859                 just say
4860                 <example compact="compact">
4861 Starting network daemons: nfsd mountd.
4862                 </example>
4863               </p>
4864             </item>
4865           </list>
4866         </p>
4867
4868         <p>
4869           There are standard message formats for the following
4870           situations.  They should be used by the <tt>init.d</tt>
4871           scripts.
4872         </p>
4873
4874         <p>
4875           <list>
4876             <item>
4877               <p>When daemons are started</p>
4878
4879               <p>
4880                 If your script starts one or more daemons, the output
4881                 should look like this (a single line, no leading
4882                 spaces):
4883                 <example compact="compact">
4884 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
4885                 </example>
4886                 The <var>description</var> should describe the
4887                 subsystem the daemon or set of daemons are part of,
4888                 while <var>daemon-1</var> up to <var>daemon-n</var>
4889                 denote each daemon's name (typically the file name of
4890                 the program).
4891               </p>
4892
4893               <p>
4894                 For example, the output of <file>/etc/init.d/lpd</file>
4895                 would look like:
4896                 <example compact="compact">
4897 Starting printer spooler: lpd.
4898                 </example>
4899               </p>
4900
4901               <p>
4902                 This can be achieved by saying
4903                 <example compact="compact">
4904 echo -n "Starting printer spooler: lpd"
4905 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
4906 echo "."
4907                 </example>
4908                 in the script. If you have more than one daemon to
4909                 start, you should do the following:
4910                 <example compact="compact">
4911 echo -n "Starting remote file system services:"
4912 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
4913 echo -n " mountd"; start-stop-daemon --start --quiet mountd
4914 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
4915 echo "."
4916                 </example>
4917                 This makes it possible for the user to see what takes
4918                 so long and when the final daemon has been started.
4919                 You should be careful where to put spaces: in the
4920                 example above the system administrator can easily
4921                 comment out a line if he don't wants to start a
4922                 specific daemon, while the displayed message still
4923                 looks good.
4924               </p>
4925             </item>
4926
4927             <item>
4928               <p>When a system parameter is being set</p>
4929
4930               <p>
4931                 If you have to set up different system parameters
4932                 during the system boot, you should use this format:
4933                 <example compact="compact">
4934 Setting <var>parameter</var> to `<var>value</var>'.
4935                 </example>
4936               </p>
4937
4938               <p>
4939                 You can use a statement such as the following to get
4940                 the quotes right:
4941                 <example compact="compact">
4942 echo "Setting DNS domainname to \`$domainname'."
4943                 </example>
4944               </p>
4945
4946               <p>
4947                 Note that the left quotation mark (<tt>`</tt>) is
4948                 different from the right one (<tt>'</tt>).
4949               </p>
4950             </item>
4951
4952             <item>
4953               <p>When a daemon is stopped or restarted</p>
4954
4955               <p>
4956                 When you stop or restart a daemon, you should issue a
4957                 message identical to the startup message, except that
4958                 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
4959                 or <tt>Restarting</tt> respectively.
4960               </p>
4961
4962               <p>
4963                 For example, stopping the printer daemon will like
4964                 like this:
4965                 <example compact="compact">
4966 Stopping printer spooler: lpd.
4967                 </example>
4968               </p>
4969             </item>
4970
4971             <item>
4972               <p>When something is executed</p>
4973
4974               <p>
4975                 There are several examples where you have to run a
4976                 program at system startup or shutdown to perform a
4977                 specific task, for example, setting the system's clock
4978                 using <prgn>netdate</prgn> or killing all processes
4979                 when the system shuts down.  Your message should look
4980                 like this:
4981                 <example compact="compact">
4982 Doing something very useful...done.
4983                 </example>
4984                 You should print the <tt>done.</tt> immediately after
4985                 the job has been completed, so that the user is
4986                 informed why she has to wait.  You can get this
4987                 behavior by saying
4988                 <example compact="compact">
4989 echo -n "Doing something very useful..."
4990 do_something
4991 echo "done."
4992                 </example>
4993                 in your script.
4994               </p>
4995             </item>
4996
4997             <item>
4998               <p>When the configuration is reloaded</p>
4999
5000               <p>
5001                 When a daemon is forced to reload its configuration
5002                 files you should use the following format:
5003                 <example compact="compact">
5004 Reloading <var>description</var> configuration...done.
5005                 </example>
5006                 where <var>description</var> is the same as in the
5007                 daemon starting message.
5008               </p>
5009             </item>
5010           </list>
5011         </p>
5012       </sect>
5013
5014       <sect>
5015         <heading>Cron jobs</heading>
5016
5017         <p>
5018           Packages must not modify the configuration file
5019           <file>/etc/crontab</file>, and they must not modify the files in
5020           <file>/var/spool/cron/crontabs</file>.</p>
5021
5022         <p>
5023           If a package wants to install a job that has to be executed
5024           via cron, it should place a file with the name of the
5025           package in one or more of the following directories:
5026           <example compact="compact">
5027 /etc/cron.daily
5028 /etc/cron.weekly
5029 /etc/cron.monthly
5030           </example>
5031           As these directory names imply, the files within them are
5032           executed on a daily, weekly, or monthly basis,
5033           respectively. The exact times are listed in
5034           <file>/etc/crontab</file>.</p>
5035
5036         <p>
5037           All files installed in any of these directories must be
5038           scripts (e.g., shell scripts or Perl scripts) so that they
5039           can easily be modified by the local system administrator.
5040           In addition, they should be treated as configuration
5041           files.
5042         </p>
5043
5044         <p>
5045           If a certain job has to be executed more frequently than
5046           daily, the package should install a file
5047           <file>/etc/cron.d/<var>package</var></file>. This file uses the
5048           same syntax as <file>/etc/crontab</file> and is processed by
5049           <prgn>cron</prgn> automatically. The file must also be
5050           treated as a configuration file. (Note that entries in the
5051           <file>/etc/cron.d</file> directory are not handled by
5052           <prgn>anacron</prgn>. Thus, you should only use this
5053           directory for jobs which may be skipped if the system is not
5054           running.)</p>
5055
5056         <p>
5057           The scripts or crontab entries in these directories should
5058           check if all necessary programs are installed before they
5059           try to execute them. Otherwise, problems will arise when a
5060           package was removed but not purged since configuration files
5061           are kept on the system in this situation.</p>
5062       </sect>
5063
5064       <sect>
5065         <heading>Menus</heading>
5066
5067         <p>
5068           Menu entries should follow the current menu policy found in
5069           the <tt>menu-policy</tt> files in the <tt>debian-policy</tt>
5070           package.  It may also be found on the Debian FTP site
5071           <ftpsite>ftp.debian.org</ftpsite> as the file
5072           <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>,
5073           or in the equivalent location on your local mirror.
5074         </p>
5075
5076         <p>
5077           The Debian <tt>menu</tt> package provides a standard
5078           interface between packages providing applications and
5079           documents, and <em>menu programs</em> (either X window
5080           managers or text-based menu programs such as
5081           <prgn>pdmenu</prgn>).
5082         </p>
5083
5084         <p>
5085           All packages that provide applications that need not be
5086           passed any special command line arguments for normal
5087           operation should register a menu entry for those
5088           applications, so that users of the <tt>menu</tt> package
5089           will automatically get menu entries in their window
5090           managers, as well in shells like <tt>pdmenu</tt>.</p>
5091
5092         <p>
5093           Please also refer to the <em>Debian Menu System</em>
5094           documentation that comes with the <tt>menu</tt> package for
5095           information about how to register your applications and web
5096           documents.
5097         </p>
5098       </sect>
5099
5100       <sect>
5101         <heading>Multimedia handlers</heading>
5102
5103         <p>
5104           Packages which provide the ability to view/show/play,
5105           compose, edit or print MIME types should register themselves
5106           as such following the current MIME support policy found in
5107           the <tt>mime-policy</tt> files in the <tt>debian-policy</tt>
5108           package.  It may also be found on the Debian FTP site
5109           <ftpsite>ftp.debian.org</ftpsite> as the file
5110           <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>,
5111           or in the equivalent location on your local mirror.
5112         </p>
5113
5114         <p>
5115           MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5116           is a mechanism for encoding files and data streams and
5117           providing meta-information about them, in particular their
5118           type (e.g.  audio or video) and format (e.g. PNG, HTML,
5119           MP3).
5120         </p>
5121
5122         <p>
5123           Registration of MIME type handlers allows programs like mail
5124           user agents and web browsers to to invoke these handlers to
5125           view, edit or display MIME types they don't support
5126           directly.
5127         </p>
5128       </sect>
5129
5130       <sect>
5131         <heading>Keyboard configuration</heading>
5132
5133         <p>
5134           To achieve a consistent keyboard configuration so that all
5135           applications interpret a keyboard event the same way, all
5136           programs in the Debian distribution must be configured to
5137           comply with the following guidelines.
5138         </p>
5139
5140         <p>
5141           The following keys must have the specified interpretations:
5142
5143           <taglist>
5144             <tag><tt>&lt;--</tt></tag>
5145             <item><p>delete the character to the left of the cursor</p></item>
5146
5147             <tag><tt>Delete</tt></tag>
5148             <item><p>delete the character to the right of the cursor</p></item>
5149
5150             <tag><tt>Control+H</tt></tag>
5151             <item><p>emacs: the help prefix</p></item>
5152           </taglist>
5153
5154           The interpretation of any keyboard events should be
5155           independent of the terminal that is used, be it a virtual
5156           console, an X terminal emulator, an rlogin/telnet session,
5157           etc.
5158         </p>
5159
5160         <p>
5161           The following list explains how the different programs
5162           should be set up to achieve this:
5163         </p>
5164
5165         <p>
5166           <list>
5167             <item><p><tt>&lt;--</tt> generates <tt>KB_Backspace</tt>
5168                 in X.</p></item>
5169
5170             <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5171                 X.</p></item>
5172
5173             <item>
5174               <p>
5175                 X translations are set up to make
5176                 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5177                 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5178                 is the vt220 escape code for the `delete character'
5179                 key).  This must be done by loading the X resources
5180                 using <prgn>xrdb</prgn> on all local X displays, not
5181                 using the application defaults, so that the
5182                 translation resources used correspond to the
5183                 <prgn>xmodmap</prgn> settings.</p></item>
5184
5185             <item>
5186               <p>
5187                 The Linux console is configured to make
5188                 <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
5189                 generate <tt>ESC [ 3 ~</tt>.</p></item>
5190
5191             <item>
5192               <p>
5193                 X applications are configured so that <tt>&lt;</tt>
5194                 deletes left, and <tt>Delete</tt> deletes right.  Motif
5195                 applications already work like this.</p></item>
5196
5197             <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5198
5199             <item>
5200               <p>
5201                 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5202                 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5203                 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5204
5205             <item>
5206               <p>
5207                 Emacs is programmed to map <tt>KB_Backspace</tt> or
5208                 the <tt>stty erase</tt> character to
5209                 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5210                 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5211                 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5212
5213             <item>
5214               <p>
5215                 Other applications use the <tt>stty erase</tt>
5216                 character and <tt>kdch1</tt> for the two delete keys,
5217                 with ASCII DEL being `delete previous character' and
5218                 <tt>kdch1</tt> being `delete character under
5219                 cursor'.</p></item>
5220
5221           </list>
5222         </p>
5223
5224         <p>
5225           This will solve the problem except for the following
5226           cases:
5227         </p>
5228
5229         <p>
5230           <list>
5231             <item>
5232               <p>
5233                 Some terminals have a <tt>&lt;--</tt> key that cannot
5234                 be made to produce anything except <tt>^H</tt>.  On
5235                 these terminals Emacs help will be unavailable on
5236                 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5237                 character takes precedence in Emacs, and has been set
5238                 correctly).  <tt>M-x help</tt> or <tt>F1</tt> (if
5239                 available) can be used instead.</p></item>
5240
5241             <item>
5242               <p>
5243                 Some operating systems use <tt>^H</tt> for <tt>stty
5244                 erase</tt>.  However, modern telnet versions and all
5245                 rlogin versions propagate <tt>stty</tt> settings, and
5246                 almost all UNIX versions honour <tt>stty erase</tt>.
5247                 Where the <tt>stty</tt> settings are not propagated
5248                 correctly, things can be made to work by using
5249                 <tt>stty</tt> manually.</p></item>
5250
5251             <item>
5252               <p>
5253                 Some systems (including previous Debian versions) use
5254                 <prgn>xmodmap</prgn> to arrange for both
5255                 <tt>&lt;--</tt> and <tt>Delete</tt> to generate
5256                 <tt>KB_Delete</tt>.  We can change the behavior of
5257                 their X clients using the same X resources that we use
5258                 to do it for our own clients, or configure our clients
5259                 using their resources when things are the other way
5260                 around.  On displays configured like this
5261                 <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
5262                 will.</p></item>
5263
5264             <item>
5265               <p>
5266                 Some operating systems have different <tt>kdch1</tt>
5267                 settings in their <tt>terminfo</tt> database for
5268                 <tt>xterm</tt> and others.  On these systems the
5269                 <tt>Delete</tt> key will not work correctly when you
5270                 log in from a system conforming to our policy, but
5271                 <tt>&lt;--</tt> will.</p></item>
5272           </list>
5273         </p>
5274       </sect>
5275
5276       <sect>
5277         <heading>Environment variables</heading>
5278
5279         <p>
5280           A program must not depend on environment variables to get
5281           reasonable defaults.  (That's because these environment
5282           variables would have to be set in a system-wide
5283           configuration file like <file>/etc/profile</file>, which is not
5284           supported by all shells.)</p>
5285
5286         <p>
5287           If a program usually depends on environment variables for its
5288           configuration, the program should be changed to fall back to
5289           a reasonable default configuration if these environment
5290           variables are not present. If this cannot be done easily
5291           (e.g., if the source code of a non-free program is not
5292           available), the program must be replaced by a small
5293           `wrapper' shell script which sets the environment variables
5294           if they are not already defined, and calls the original program.</p>
5295
5296         <p>
5297           Here is an example of a wrapper script for this purpose:
5298
5299           <example compact="compact">
5300 #!/bin/sh
5301 BAR=${BAR:-/var/lib/fubar}
5302 export BAR
5303 exec /usr/lib/foo/foo "$@"
5304           </example>
5305         </p>
5306
5307         <p>
5308           Furthermore, as <file>/etc/profile</file> is a configuration
5309           file of the <prgn>base-files</prgn> package, other packages must not
5310           put any environment variables or other commands into that
5311           file.</p>
5312       </sect>
5313     </chapt>
5314
5315     <chapt id="files">
5316       <heading>Files</heading>
5317
5318       <sect>
5319         <heading>Binaries</heading>
5320
5321         <p>
5322           Two different packages must not install programs with
5323           different functionality but with the same filenames.  (The
5324           case of two programs having the same functionality but
5325           different implementations is handled via `alternatives' or
5326           the `Conflicts' mechanism.  See <ref id="maintscripts"> and
5327           <ref id="conflicts"> respectively.)  If this case happens,
5328           one of the programs must be renamed.  The maintainers should
5329           report this to the <tt>debian-devel</tt> mailing list and
5330           try to find a consensus about which program will have to be
5331           renamed.  If a consensus cannot be reached, <em>both</em>
5332           programs must be renamed.
5333         </p>
5334
5335         <p>
5336           Generally the following compilation parameters should be used:
5337           <example compact="compact">
5338 CC = gcc
5339 CFLAGS = -O2 -Wall # sane warning options vary between programs
5340 LDFLAGS = # none
5341 install -s # (or use strip on the files in debian/tmp)
5342           </example></p>
5343
5344         <p>
5345           Note that by default all installed binaries should be stripped,
5346           either by using the <tt>-s</tt> flag to
5347           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5348           the binaries after they have been copied into
5349           <file>debian/tmp</file> but before the tree is made into a
5350           package.</p>
5351
5352         <p>
5353           The <tt>-N</tt> flag should not be used.  On <file>a.out</file>
5354           systems it may have been useful for some very small
5355           binaries, but for ELF it has no good effect.</p>
5356
5357         <p>
5358           Debugging symbols are useful for error diagnosis,
5359           investigation of core dumps (which may be submitted by users
5360           in bug reports), or testing and developing the software.
5361           Therefore it is recommended to support building the package
5362           with debugging information through the following interface:
5363           If the environment variable <tt>DEB_BUILD_OPTIONS</tt>
5364           contains the string <tt>debug</tt>, compile the software
5365           with debugging information (usually this involves adding the
5366           <tt>-g</tt> flag to <tt>CFLAGS</tt>).  This allows the
5367           generation of a build tree with debugging information.  If
5368           the environment variable <tt>DEB_BUILD_OPTIONS</tt> contains
5369           the string <tt>nostrip</tt>, do not strip the files at
5370           installation time.  This allows one to generate a package
5371           with debugging information included.<footnote>
5372             <p>
5373               Rationale: Using <tt>-g</tt> by default causes wasted
5374               CPU cycles since the information is stripped away
5375               anyway; this can have a significant impact on the
5376               efficiency of the autobuilders.  Having a standard way
5377               to build a debugging variant also makes it easier to
5378               build debugging bins and libraries since it provides a
5379               documented way of getting this type of build; one does
5380               not have to manually edit <file>debian/rules</file> or
5381               <file>Makefile</file>s.
5382             </p>
5383           </footnote>
5384           The following makefile snippet is an example of how one may
5385           test for either condition; you will probably have to massage
5386           this example in order to make it work for your package.
5387           <example compact="compact">
5388 CFLAGS = -O2 -Wall
5389 INSTALL = install
5390 INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
5391 INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
5392 INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
5393 INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
5394
5395 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
5396 CFLAGS += -g
5397 endif
5398 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5399 INSTALL_PROGRAM += -s
5400 endif
5401           </example>
5402         </p>
5403
5404         <p>
5405           It is up to the package maintainer to decide what
5406           compilation options are best for the package.  Certain
5407           binaries (such as computationally-intensive programs) will
5408           function better with certain flags (<tt>-O3</tt>, for
5409           example); feel free to use them.  Please use good judgment
5410           here.  Don't use flags for the sake of it; only use them
5411           if there is good reason to do so.  Feel free to override
5412           the upstream author's ideas about which compilation
5413           options are best: they are often inappropriate for our
5414           environment.</p></sect>
5415
5416
5417       <sect>
5418         <heading>Libraries</heading>
5419
5420         <p>
5421           All libraries must have a shared version in the
5422           <tt>lib*</tt> package and a static version in the
5423           <tt>lib*-dev</tt> package.  The shared version must be
5424           compiled with <tt>-fPIC</tt>, and the static version must
5425           not be.  In other words, each <tt>*.c</tt> file will need to
5426           be compiled twice.</p>
5427
5428         <p>
5429           You must specify the gcc option <tt>-D_REENTRANT</tt>
5430           when building a library (either static or shared) to make
5431           the library compatible with LinuxThreads.</p>
5432
5433         <p>
5434           Note that all installed shared libraries should be
5435           stripped with
5436           <example compact="compact">
5437 strip --strip-unneeded <var>your-lib</var>
5438           </example>
5439           (The option <tt>--strip-unneeded</tt> makes
5440           <prgn>strip</prgn> remove only the symbols which aren't
5441           needed for relocation processing.)  Shared libraries can
5442           function perfectly well when stripped, since the symbols for
5443           dynamic linking are in a separate part of the ELF object
5444           file.<footnote>
5445             <p>
5446               You might also want to use the options
5447               <tt>--remove-section=.comment</tt> and
5448               <tt>--remove-section=.note</tt> on both shared libraries
5449               and executables, and <tt>--strip-debug</tt> on static
5450               libraries.
5451             </p>
5452           </footnote>
5453         </p>
5454
5455         <p>
5456           Note that under some circumstances it may be useful to
5457           install a shared library unstripped, for example when
5458           building a separate package to support debugging.
5459         </p>
5460
5461         <p>
5462           Shared object files (often <file>.so</file> files) that are not
5463           public libraries, that is, they are not meant to be linked
5464           to by third party executables (binaries of other packages),
5465           should be installed in subdirectories of the
5466           <file>/usr/lib</file> directory.  Such files are exempt from the
5467           rules that govern ordinary shared libraries, except that
5468           they must not be installed executable and should be
5469           stripped.<footnote>
5470             <p>
5471               A common example are the so-called ``plug-ins'',
5472               internal shared objects that are dynamically loaded by
5473               programs using <manref name="dlopen" section="3">.
5474             </p>
5475           </footnote>
5476         </p>
5477                                                                              
5478         <p>
5479           Packages containing shared libraries that may be linked to
5480           by other packages' binaries, but which for some
5481           <em>compelling</em> reason can not be installed in
5482           <file>/usr/lib</file> directory, may install the shared library
5483           files in subdirectories of the <file>/usr/lib</file> directory,
5484           in which case they should arrange to add that directory in
5485           <file>/etc/ld.so.conf</file> in the package's post-installation
5486           script, and remove it in the package's post-removal script.
5487         </p>
5488
5489         <p>
5490           An ever increasing number of packages are using
5491           <prgn>libtool</prgn> to do their linking.  The latest GNU
5492           libtools (>= 1.3a) can take advantage of the metadata in the
5493           installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5494           files).  The main advantage of <prgn>libtool</prgn>'s
5495           <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5496           store and subsequently access metadata with respect to the
5497           libraries it builds.  <prgn>libtool</prgn> will search for
5498           those files, which contain a lot of useful information about
5499           a library (such as library dependency information for static
5500           linking).  Also, they're <em>essential</em> for programs
5501           using <tt>libltdl</tt>.<footnote>
5502             <p>
5503               Although <prgn>libtool</prgn> is fully capable of
5504               linking against shared libraries which don't have
5505               <tt>.la</tt> files, as it is a mere shell script it can
5506               add considerably to the build time of a
5507               <prgn>libtool</prgn>-using package if that shell script
5508               has to derive all this information from first principles
5509               for each library every time it is linked.  With the
5510               advent of <prgn>libtool</prgn> version 1.4 (and to a
5511               lesser extent <prgn>libtool</prgn> version 1.3), the
5512               <file>.la</file> files also store information about
5513               inter-library dependencies which cannot necessarily be
5514               derived after the <file>.la</file> file is deleted.
5515             </p>
5516           </footnote>
5517         </p>
5518
5519         <p>
5520           Packages that use <prgn>libtool</prgn> to create shared
5521           libraries should include the <file>.la</file> files in the
5522           <tt>-dev</tt> package, unless the package relies on
5523           <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5524           the <tt>.la</tt> files must go in the run-time library
5525           package.
5526         </p>
5527
5528         <p>
5529           You must make sure that you use only released versions of
5530           shared libraries to build your packages; otherwise other
5531           users will not be able to run your binaries
5532           properly. Producing source packages that depend on
5533           unreleased compilers is also usually a bad
5534           idea.
5535         </p>
5536       </sect>
5537
5538       <sect>
5539         <heading>Shared libraries</heading>
5540
5541         <p>
5542           Packages involving shared libraries should be split up
5543           into several binary packages.</p>
5544
5545         <p>
5546           For a straightforward library which has a development
5547           environment and a runtime kit including just shared
5548           libraries you need to create two packages:
5549           <file><var>libraryname</var><var>soversion</var></file>, where
5550           <file><var>soversion</var></file> is the version number in the
5551           soname of the shared library<footnote>
5552             <p>
5553               The soname is the shared object name: it's the thing
5554               that has to match exactly between building an executable
5555               and running it for the dynamic linker to be able run the
5556               program.  For example, if the soname of the library is
5557               <file>libfoo.so.6</file>, the library package would be
5558               called <file>libfoo6</file>.
5559             </p>
5560           </footnote>
5561           and <tt><var>libraryname</var><var>soversion</var>-dev</tt>.
5562         </p>
5563
5564         <p>
5565           If you prefer only to support one development version at a
5566           time you may name the development package
5567           <file><var>libraryname</var>-dev</file>; otherwise you may need
5568           to use <prgn>dpkg</prgn>'s Conflicts mechanism (see <ref
5569           id="conflicts">) to ensure that the user only installs one
5570           development version at a time (as different development
5571           versions are likely to have the same header files in them,
5572           which would cause a filename clash if both were installed).
5573           Typically the development version should also have an exact
5574           version dependency on the runtime library, to make sure that
5575           compilation and linking happens correctly.  The
5576           <tt>${Source-Version}</tt> substitution variable can be
5577           useful for this purpose.
5578         </p>
5579
5580         <p>
5581           Packages which use the shared library should have a
5582           dependency on the name of the shared library package,
5583           <file><var>libraryname</var><var>soversion</var></file>.  When
5584           the soname changes you can have both versions of the library
5585           installed while migrating from the old library to the new.
5586         </p>
5587
5588         <p>
5589           If your package has some run-time support programs which use
5590           the shared library you must not put them in the shared
5591           library package.  If you do that then you won't be able to
5592           install several versions of the shared library without
5593           getting filename clashes.  Instead, either create a third
5594           package for the runtime binaries (this package might
5595           typically be named <tt><var>libraryname</var>-runtime</tt>;
5596           note the absence of the <var>soversion</var> in the package
5597           name), or if the development package is small you may
5598           include them in there.
5599         </p>
5600
5601         <p>
5602           If you have several shared libraries built from the same
5603           source tree you may lump them all together into a single
5604           shared library package, provided that you change all of
5605           their sonames at once (so that you don't get filename
5606           clashes if you try to install different versions of the
5607           combined shared libraries package).
5608         </p>
5609
5610         <p>
5611           Shared libraries should not be installed executable, since
5612           the dynamic linker does not require this and trying to
5613           execute a shared library usually results in a core dump.
5614         </p>
5615       </sect>
5616
5617       <sect id="scripts">
5618         <heading>Scripts</heading>
5619
5620         <p>
5621           All command scripts, including the package maintainer
5622           scripts inside the package and used by <prgn>dpkg</prgn>,
5623           should have a <tt>#!</tt> line naming the shell to be used
5624           to interpret them.</p>
5625
5626         <p>
5627           In the case of Perl scripts this should be
5628           <tt>#!/usr/bin/perl</tt>.</p>
5629
5630         <p>
5631           Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5632           should almost certainly start with <tt>set -e</tt> so that
5633           errors are detected.  Every script should use
5634           <tt>set -e</tt> or check the exit status of <em>every</em>
5635           command.</p>
5636
5637         <p>
5638           The standard shell interpreter <file>/bin/sh</file> can be a
5639           symbolic link to any POSIX compatible shell, if <tt>echo
5640           -n</tt> does not generate a newline.<footnote>
5641             <p>
5642               Debian policy specifies POSIX behavior for
5643               <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5644               use in the Linux community (in particular including this
5645               policy, the Linux kernel source, many Debian scripts,
5646               etc.).  This <tt>echo -n</tt> mechanism is valid but not
5647               required under POSIX, hence this explicit addition.
5648               Also, rumour has it that this shall be mandated under
5649               the LSB anyway.
5650             </p>
5651           </footnote>
5652           Thus, shell scripts specifying <file>/bin/sh</file> as
5653           interpreter should only use POSIX features. If a script
5654           requires non-POSIX features from the shell interpreter, the
5655           appropriate shell must be specified in the first line of the
5656           script (e.g., <tt>#!/bin/bash</tt>) and the package must
5657           depend on the package providing the shell (unless the shell
5658           package is marked `Essential', as in the case of
5659           <prgn>bash</prgn>).
5660         </p>
5661
5662         <p>
5663           You may wish to restrict your script to POSIX features when
5664           possible so that it may use <file>/bin/sh</file> as its
5665           interpreter. If your script works with <prgn>ash</prgn>,
5666           it's probably POSIX compliant, but if you are in doubt, use
5667           <file>/bin/bash</file>.
5668         </p>
5669
5670         <p>
5671           Perl scripts should check for errors when making any
5672           system calls, including <tt>open</tt>, <tt>print</tt>,
5673           <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5674         </p>
5675
5676         <p>
5677           <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5678           scripting languages.  See <em>Csh Programming Considered
5679           Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5680           can be found at <url
5681           id="http://language.perl.com/versus/csh.whynot">.<footnote>
5682             <p>
5683               It can also be found on
5684               <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5685               or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5686               <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5687               </p>
5688           </footnote>
5689           If an upstream package comes with <prgn>csh</prgn> scripts
5690           then you must make sure that they start with
5691           <tt>#!/bin/csh</tt> and make your package depend on the
5692           <prgn>c-shell</prgn> virtual package.
5693         </p>
5694
5695         <p>
5696           Any scripts which create files in world-writeable
5697           directories (e.g., in <file>/tmp</file>) must use a
5698           mechanism which will fail if a file with the same name
5699           already exists.</p>
5700
5701         <p>
5702           The Debian base system provides the <prgn>tempfile</prgn>
5703           and <prgn>mktemp</prgn> utilities for use by scripts for
5704           this purpose.</p></sect>
5705
5706
5707       <sect>
5708         <heading>Symbolic links</heading>
5709
5710         <p>
5711           In general, symbolic links within a top-level directory
5712           should be relative, and symbolic links pointing from one
5713           top-level directory into another should be absolute. (A
5714           top-level directory is a sub-directory of the root
5715           directory <file>/</file>.)</p>
5716
5717         <p>
5718           In addition, symbolic links should be specified as short as
5719           possible, i.e., link targets like <file>foo/../bar</file> are
5720           deprecated.</p>
5721
5722         <p>
5723           Note that when creating a relative link using
5724           <prgn>ln</prgn> it is not necessary for the target of the
5725           link to exist relative to the working directory you're
5726           running <prgn>ln</prgn> from, nor is it necessary to change
5727           directory to the directory where the link is to be made.
5728           Simply include the string that should appear as the target
5729           of the link (this will be a pathname relative to the
5730           directory in which the link resides) as the first argument
5731           to <prgn>ln</prgn>.</p>
5732
5733         <p>
5734           For example, in your <prgn>Makefile</prgn> or
5735           <file>debian/rules</file>, you can do things like:
5736           <example compact="compact">
5737 ln -fs gcc $(prefix)/bin/cc
5738 ln -fs gcc debian/tmp/usr/bin/cc
5739 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5740 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5741           </example></p>
5742
5743         <p>
5744           A symbolic link pointing to a compressed file should always
5745           have the same file extension as the referenced file. (For
5746           example, if a file <file>foo.gz</file> is referenced by a
5747           symbolic link, the filename of the link has to end with
5748           `<file>.gz</file>' too, as in <file>bar.gz</file>.)
5749         </p>
5750       </sect>
5751
5752       <sect>
5753         <heading>Device files</heading>
5754
5755         <p>
5756           Packages must not include device files in the package file
5757           tree.</p>
5758
5759         <p>
5760           If a package needs any special device files that are not
5761           included in the base system, it must call
5762           <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
5763           after asking the user for permission to do so.</p>
5764
5765         <p>
5766           Packages must not remove any device files in the
5767           <prgn>postrm</prgn> or any other script. This is left to the
5768           system administrator.</p>
5769
5770         <p>
5771           Debian uses the serial devices
5772           <file>/dev/ttyS*</file>. Programs using the old
5773           <file>/dev/cu*</file> devices should be changed to use
5774           <file>/dev/ttyS*</file>.</p>
5775       </sect>
5776
5777       <sect id="config-files">
5778         <heading>Configuration files</heading>
5779         <sect1>
5780           <heading>Definitions</heading>
5781           <p>
5782             <taglist>
5783               <tag>configuration file</tag>
5784               <item>
5785                 <p>
5786                   A file that affects the operation of a program, or
5787                   provides site- or host-specific information, or
5788                   otherwise customizes the behavior of a program.
5789                   Typically, configuration files are intended to be
5790                   modified by the system administrator (if needed or
5791                   desired) to conform to local policy or to provide
5792                   more useful site-specific behavior.
5793                 </p>
5794               </item>
5795
5796               <tag><tt>conffile</tt></tag>
5797               <item>
5798                 <p>
5799                   A file listed in a package's <tt>conffiles</tt>
5800                   file, and is treated specially by <prgn>dpkg</prgn>
5801                   (see <ref id="configdetails">).
5802                 </p>
5803               </item>
5804             </taglist>
5805           </p>
5806
5807           <p>
5808             The distinction between these two is important; they are
5809             not interchangeable concepts. Almost all
5810             <tt>conffile</tt>s are configuration files, but many
5811             configuration files are not <tt>conffiles</tt>.
5812           </p>
5813
5814           <p>
5815             Note that a script that embeds configuration information
5816             (such as most of the files in <file>/etc/default</file> and
5817             <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
5818             configuration file and should be treated as such.
5819           </p>
5820         </sect1>
5821
5822         <sect1>
5823           <heading>Location</heading>
5824           <p>
5825             Any configuration files created or used by your package
5826             must reside in <file>/etc</file>. If there are several you
5827             should consider creating a subdirectory of <file>/etc</file>
5828             named after your package.</p>
5829
5830           <p>
5831             If your package creates or uses configuration files
5832             outside of <file>/etc</file>, and it is not feasible to modify
5833             the package to use the <file>/etc</file>, you should still put
5834             the files in <file>/etc</file> and create symbolic links to
5835             those files from the location that the package
5836             requires.</p>
5837         </sect1>
5838
5839         <sect1>
5840           <heading>Behavior</heading>
5841           <p>
5842             Configuration file handling must conform to the following
5843             behavior:
5844             <list compact="compact">
5845               <item>
5846                 <p>
5847                   local changes must be preserved during a package
5848                   upgrade, and
5849                 </p>
5850               </item>
5851               <item>
5852                 <p>
5853                   configuration files must be preserved when the
5854                   package is removed, and only deleted when the
5855                   package is purged.
5856                 </p>
5857               </item>
5858             </list>
5859           </p>
5860
5861           <p>
5862             The easy way to achieve this behavior is to make the
5863             configuration file a <tt>conffile</tt>. This is
5864             appropriate only if it is possible to distribute a default
5865             version that will work for most installations, although
5866             some system administrators may choose to modify it. This
5867             implies that the default version will be part of the
5868             package distribution, and must not be modified by the
5869             maintainer scripts during installation (or at any other
5870             time).
5871           </p>
5872
5873           <p>
5874             In order to ensure that local changes are preserved
5875             correctly, no package may contain or make hard links to
5876             conffiles.<footnote>
5877               <p>
5878                 Rationale: There are two problems with hard links.
5879                 The first is that some editors break the link while
5880                 editing one of the files, so that the two files may
5881                 unwittingly become unlinked and different.  The second
5882                 is that <prgn>dpkg</prgn> might break the hard link
5883                 while upgrading <tt>conffile</tt>s.
5884               </p>
5885             </footnote>
5886             </p>
5887
5888             <p>
5889             The other way to do it is via the maintainer scripts.  In
5890             this case, the configuration file must not be listed as a
5891             <tt>conffile</tt> and must not be part of the package
5892             distribution. If the existence of a file is required for
5893             the package to be sensibly configured it is the
5894             responsibility of the package maintainer to provide
5895             maintainer scripts which correctly create, update and
5896             maintain the file and remove it on purge.  (See <ref
5897             id="maintainerscripts"> for more information.)  These
5898             scripts must be idempotent (i.e., must work correctly if
5899             <prgn>dpkg</prgn> needs to re-run them due to errors
5900             during installation or removal), must cope with all the
5901             variety of ways <prgn>dpkg</prgn> can call maintainer
5902             scripts, must not overwrite or otherwise mangle the user's
5903             configuration without asking, must not ask unnecessary
5904             questions (particularly during upgrades), and otherwise be
5905             good citizens.
5906           </p>
5907
5908           <p>
5909             The scripts are not required to configure every possible
5910             option for the package, but only those necessary to get
5911             the package running on a given system. Ideally the
5912             sysadmin should not have to do any configuration other
5913             than that done (semi-)automatically by the
5914             <prgn>postinst</prgn> script.
5915           </p>
5916
5917           <p>
5918             A common practice is to create a script called
5919             <file><var>package</var>-configure</file> and have the
5920             package's <prgn>postinst</prgn> call it if and only if the
5921             configuration file does not already exist.  In certain
5922             cases it is useful for there to be an example or template
5923             file which the maintainer scripts use.  Such files should
5924             be in <file>/usr/share/<var>package</var></file> or
5925             <file>/usr/lib/<var>package</var></file> (depending on whether
5926             they are architecture-independent or not).  There should
5927             be symbolic links to them from
5928             <file>/usr/share/doc/<var>package</var>/examples</file> if
5929             they are examples, and should be perfectly ordinary
5930             <prgn>dpkg</prgn>-handled files (<em>not</em>
5931             configuration files).
5932           </p>
5933
5934           <p>
5935             These two styles of configuration file handling must
5936             not be mixed, for that way lies madness:
5937             <prgn>dpkg</prgn> will ask about overwriting the file
5938             every time the package is upgraded.
5939           </p>
5940         </sect1>
5941
5942         <sect1>
5943           <heading>Sharing configuration files</heading>
5944           <p>
5945             Packages which specify the same file as a
5946             <tt>conffile</tt> must be tagged as <em>conflicting</em>
5947             with each other.  (This is an instance of the general rule
5948             about not sharing files.  Note that neither alternatives
5949             nor diversions are likely to be appropriate in this case;
5950             in particular, <prgn>dpkg</prgn> does not handle diverted
5951             <tt>conffile</tt>s well.)
5952           </p>
5953
5954           <p>
5955             The maintainer scripts must not alter a <tt>conffile</tt>
5956             of <em>any</em> package, including the one the scripts
5957             belong to.
5958           </p>
5959
5960           <p>
5961             If two or more packages use the same configuration file
5962             and it is reasonable for both to be installed at the same
5963             time, one of these packages must be defined as
5964             <em>owner</em> of the configuration file, i.e., it will be
5965             the package which handles that file as a configuration
5966             file.  Other packages that use the configuration file must
5967             depend on the owning package if they require the
5968             configuration file to operate. If the other package will
5969             use the configuration file if present, but is capable of
5970             operating without it, no dependency need be declared.</p>
5971
5972           <p>
5973             If it is desirable for two or more related packages to
5974             share a configuration file <em>and</em> for all of the
5975             related packages to be able to modify that configuration
5976             file, then the following should be done:
5977             <enumlist compact="compact">
5978               <item>
5979                 <p>
5980                   One of the related packages (the "owning" package)
5981                   will manage the configuration file with maintainer
5982                   scripts as described in the previous section.
5983                 </p>
5984               </item>
5985               <item>
5986                 <p>
5987                   The owning package should also provide a program
5988                   that the other packages may use to modify the
5989                   configuration file.
5990                 </p>
5991               </item>
5992               <item>
5993                 <p>
5994                   The related packages must use the provided program
5995                   to make any desired modifications to the
5996                   configuration file.  They should either depend on
5997                   the core package to guarantee that the configuration
5998                   modifier program is available or accept gracefully
5999                   that they cannot modify the configuration file if it
6000                   is not.  (This is in addition to the fact that the
6001                   configuration file may not even be present in the
6002                   latter scenario.)
6003                 </p>
6004               </item>
6005             </enumlist>
6006           </p>
6007
6008           <p>
6009             Sometimes it's appropriate to create a new package which
6010             provides the basic infrastructure for the other packages
6011             and which manages the shared configuration files.  (The
6012             <tt>sgml-base</tt> package is a good example.)
6013           </p>
6014         </sect1>
6015
6016         <sect1>
6017           <heading>User configuration files ("dotfiles")</heading>
6018
6019           <p>
6020             The files in <file>/etc/skel</file> will automatically be
6021             copied into new user accounts by <prgn>adduser</prgn>.
6022             No other program should reference the files in
6023             <file>/etc/skel</file>.
6024           </p>
6025
6026           <p>
6027             Therefore, if a program needs a dotfile to exist in
6028             advance in <file>$HOME</file> to work sensibly, that dotfile
6029             should be installed in <file>/etc/skel</file> and treated as a
6030             configuration file.
6031           </p>
6032
6033           <p>
6034             However, programs that require dotfiles in order to
6035             operate sensibly (dotfiles that they do not create
6036             themselves automatically, that is) are a bad thing.
6037             Furthermore, programs should be configured by the Debian
6038             default installation to behave as closely to the upstream
6039             default behaviour as possible.
6040           </p>
6041
6042           <p>
6043             Therefore, if a program in a Debian package needs to be
6044             configured in some way in order to operate sensibly, that
6045             should be done using a site-wide configuration file placed
6046             in <file>/etc</file>.  Only if the program doesn't support a
6047             site-wide default configuration and the package maintainer
6048             doesn't have time to add it may a default per-user file be
6049             placed in <file>/etc/skel</file>.
6050           </p>
6051
6052           <p>
6053             <file>/etc/skel</file> should be as empty as we can make it.
6054             This is particularly true because there is no easy (or
6055             necessarily desirable) mechanism for ensuring that the
6056             appropriate dotfiles are copied into the accounts of
6057             existing users when a package is installed.
6058           </p>
6059         </sect1>
6060       </sect>
6061
6062       <sect>
6063         <heading>Log files</heading>
6064         <p>
6065           Log files should usually be named
6066           <file>/var/log/<var>package</var>.log</file>.  If you have many
6067           log files, or need a separate directory for permission
6068           reasons (<file>/var/log</file> is writable only by
6069           <file>root</file>), you should usually create a directory named
6070           <file>/var/log/<var>package</var></file> and place your log
6071           files there.
6072         </p>
6073
6074         <p>
6075           Log files must be rotated occasionally so that they don't
6076           grow indefinitely; the best way to do this is to drop a log
6077           rotation configuration file into the directory
6078           <file>/etc/logrotate.d</file> and use the facilities provided by
6079           logrotate.<footnote>
6080             <p>
6081               The traditional approach to log files has been to set up
6082               <em>ad hoc</em> log rotation schemes using simple shell
6083               scripts and cron.  While this approach is highly
6084               customizable, it requires quite a lot of sysadmin work.
6085               Even though the original Debian system helped a little
6086               by automatically installing a system which can be used
6087               as a template, this was deemed not enough.
6088             </p>
6089
6090             <p>
6091               The use of <prgn>logrotate</prgn>, a program developed
6092               by Red Hat, is better, as it centralizes log management.
6093               It has both a configuration file
6094               (<file>/etc/logrotate.conf</file>) and a directory where
6095               packages can drop their individual log rotation
6096               configurations (<file>/etc/logrotate.d</file>).
6097             </p>
6098           </footnote>
6099           Here is a good example for a logrotate config
6100           file (for more information see <manref name="logrotate"
6101             section="8">):
6102           <example compact="compact">
6103 /var/log/foo/* {
6104 rotate 12
6105 weekly
6106 compress
6107 postrotate
6108 /etc/init.d/foo force-reload
6109 endscript
6110 }
6111           </example>
6112           This rotates all files under <file>/var/log/foo</file>, saves 12
6113           compressed generations, and forces the daemon to reload its
6114           configuration information after the log rotation.
6115         </p>
6116
6117         <p>
6118           Log files should be removed when the package is
6119           purged (but not when it is only removed).  This should be
6120           done by the <prgn>postrm</prgn> script when it is called
6121           with the argument <tt>purge</tt> (see <ref
6122           id="removedetails">).
6123         </p>
6124       </sect>
6125
6126       <sect>
6127         <heading>Permissions and owners</heading>
6128
6129         <p>
6130           The rules in this section are guidelines for general use.
6131           If necessary you may deviate from the details below.
6132           However, if you do so you must make sure that what is done
6133           is secure and you should try to be as consistent as possible
6134           with the rest of the system.  You should probably also
6135           discuss it on <prgn>debian-devel</prgn> first.
6136         </p>
6137
6138         <p>
6139           Files should be owned by <tt>root.root</tt>, and made
6140           writable only by the owner and universally readable (and
6141           executable, if appropriate), that is mode 644 or 755.
6142         </p>
6143
6144         <p>
6145           Directories should be mode 755 or (for group-writability)
6146           mode 2775.  The ownership of the directory should be
6147           consistent with its mode: if a directory is mode 2775, it
6148           should be owned by the group that needs write access to
6149           it.
6150         </p>
6151
6152         <p>
6153           Setuid and setgid executables should be mode 4755 or 2755
6154           respectively, and owned by the appropriate user or group.
6155           They should not be made unreadable (modes like 4711 or
6156           2711 or even 4111); doing so achieves no extra security,
6157           because anyone can find the binary in the freely available
6158           Debian package; it is merely inconvenient.  For the same
6159           reason you should not restrict read or execute permissions
6160           on non-set-id executables.
6161         </p>
6162
6163         <p>
6164           Some setuid programs need to be restricted to particular
6165           sets of users, using file permissions.  In this case they
6166           should be owned by the uid to which they are set-id, and by
6167           the group which should be allowed to execute them.  They
6168           should have mode 4754; again there is no point in making
6169           them unreadable to those users who must not be allowed to
6170           execute them.
6171         </p>
6172
6173         <p>
6174           It is possible to arrange that the system administrator can
6175           reconfigure the package to correspond to their local
6176           security policy by changing the permissions on a binary:
6177           they can do this by using <prgn>dpkg-statoverride</prgn>, as
6178           described below.<footnote>
6179             <p>
6180               Ordinary files installed by <prgn>dpkg</prgn> (as
6181               opposed to <tt>conffile</tt>s and other similar objects)
6182               normally have their permissions reset to the distributed
6183               permissions when the package is reinstalled.  However,
6184               the use of <prgn>dpkg-statoverride</prgn> overrides this
6185               default behaviour.  If you use this method, you should
6186               remember to describe <prgn>dpkg-statoverride</prgn> in
6187               the package documentation; being a relatively new
6188               addition to Debian, it is probably not yet well-known.
6189             </p>
6190           </footnote>
6191           Another method you should consider is to create a group for
6192           people allowed to use the program(s) and make any setuid
6193           executables executable only by that group.
6194         </p>
6195
6196         <p>
6197           If you need to create a new user or group for your package
6198           there are two possibilities.  Firstly, you may need to
6199           make some files in the binary package be owned by this
6200           user or group, or you may need to compile the user or
6201           group id (rather than just the name) into the binary
6202           (though this latter should be avoided if possible, as in
6203           this case you need a statically allocated id).</p>
6204
6205         <p>
6206           If you need a statically allocated id, you must ask for a
6207           user or group id from the <tt>base-passwd</tt> maintainer,
6208           and must not release the package until you have been
6209           allocated one.  Once you have been allocated one you must
6210           either make the package depend on a version of the
6211           <tt>base-passwd</tt> package with the id present in
6212           <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6213           your package to create the user or group itself with the
6214           correct id (using <tt>adduser</tt>) in its
6215           <prgn>preinst</prgn> or <prgn>postinst</prgn>.  (Doing it in
6216           the <prgn>postinst</prgn> is to be preferred if it is
6217           possible, otherwise a pre-dependency will be needed on the
6218           <tt>adduser</tt> package.)
6219         </p>
6220
6221         <p>
6222           On the other hand, the program might be able to determine
6223           the uid or gid from the user or group name at runtime, so
6224           that a dynamically allocated id can be used.  In this case
6225           you should choose an appropriate user or group name,
6226           discussing this on <prgn>debian-devel</prgn> and checking
6227           with the base system maintainer that it is unique and that
6228           they do not wish you to use a statically allocated id
6229           instead.  When this has been checked you must arrange for
6230           your package to create the user or group if necessary using
6231           <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6232           <prgn>postinst</prgn> script (again, the latter is to be
6233           preferred if it is possible).
6234         </p>
6235
6236         <p>
6237           Note that changing the numeric value of an id associated
6238           with a name is very difficult, and involves searching the
6239           file system for all appropriate files.  You need to think
6240           carefully whether a static or dynamic id is required, since
6241           changing your mind later will cause problems.
6242         </p>
6243
6244         <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6245           <p>
6246             This section is not intended as policy, but as a
6247             description of the use of <prgn>dpkg-statoverride</prgn>.
6248           </p>
6249
6250           <p>
6251             <prgn>dpkg-statoverride</prgn> is a replacement for the
6252             deprecated <tt>suidmanager</tt> package.  Packages which
6253             previously used <tt>suidmanager</tt> should have a
6254             <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6255             <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6256             and <tt>suidunregister</tt> should now be simply removed
6257             from the maintainer scripts.
6258           </p>
6259
6260           <p>
6261             If a system administrator wishes to have a file (or
6262             directory or other such thing) installed with owner and
6263             permissions different from those in the distributed Debian
6264             package, he can use the <prgn>dpkg-statoverride</prgn>
6265             program to instruct <prgn>dpkg</prgn> to use the different
6266             settings every time the file is installed.  Thus the
6267             package maintainer should distribute the files with their
6268             normal permissions, and leave it for the system
6269             administrator to make any desired changes.  For example, a
6270             daemon which is normally required to be setuid root, but
6271             in certain situations could be used without being setuid,
6272             should be installed setuid in the <tt>.deb</tt>.  Then the
6273             local system administrator can change this if they wish.
6274             If there are two standard ways of doing it, the package
6275             maintainer can use <tt>debconf</tt> to find out the
6276             preference, and call <prgn>dpkg-statoverride</prgn> in the
6277             maintainer script if necessary to accommodate the system
6278             administrator's choice.
6279           </p>
6280
6281           <p>
6282             Given the above, <prgn>dpkg-statoverride</prgn> is
6283             essentially a tool for system administrators and would not
6284             normally be needed in the maintainer scripts.  There is
6285             one type of situation, though, where calls to
6286             <prgn>dpkg-statoverride</prgn> would be needed in the
6287             maintainer scripts, and that involves packages which use
6288             dynamically allocated user or group ids.  In such a
6289             situation, something like the following idiom can be very
6290             helpful in the package's <prgn>postinst</prgn>, where
6291             <tt>sysuser</tt> is a dynamically allocated id:
6292             <example>
6293 for i in /usr/bin/foo /usr/sbin/bar
6294 do
6295   if ! dpkg-statoverride --list $i >/dev/null
6296   then
6297     dpkg-statoverride --update --add sysuser root 4755 $i
6298   fi
6299 done
6300             </example>
6301             The corresponding <tt>dpkg-statoverride --remove</tt>
6302             calls can then be made unconditionally when the package is
6303             purged.
6304           </p>
6305         </sect1>
6306       </sect>
6307     </chapt>
6308
6309     <chapt id="customized-programs">
6310       <heading>Customized programs</heading>
6311
6312       <sect id="arch-spec">
6313         <heading>Architecture specification strings</heading>
6314
6315         <p>
6316           If a program needs to specify an <em>architecture specification
6317             string</em> in some place, the following format should be
6318             used: <var>arch</var>-<var>os</var><footnote>
6319             <p>
6320               The following architectures and operating systems are
6321               currently recognised by <prgn>dpkg-archictecture</prgn>.
6322               The architecture, <tt><var>arch</var></tt>, is one of
6323               the following: <tt>alpha</tt>, <tt>arm</tt>,
6324               <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6325               <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6326               <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6327               <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>.  The
6328               operating system, <tt><var>os</var></tt>, is one of:
6329               <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6330               <tt>openbsd</tt>.  Use of <tt>gnu</tt> in this string is
6331               reserved for the GNU/Hurd operating system.
6332             </p>
6333           </footnote>.
6334         </p>
6335
6336         <p>
6337           Note that we don't want to use
6338           <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6339           <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6340           since this would make our programs incompatible with other
6341           Linux distributions.  We also don't use something like
6342           <tt><var>arch</var>-unknown-linux</tt>, since the
6343           <tt>unknown</tt> does not look very good.
6344         </p>
6345       </sect>
6346
6347       <sect>
6348         <heading>Daemons</heading>
6349
6350         <p>
6351           The configuration files <file>/etc/services</file>,
6352           <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6353           by the <prgn>netbase</prgn> package and must not be modified
6354           by other packages.
6355         </p>
6356
6357         <p>
6358           If a package requires a new entry in one of these files, the
6359           maintainer should get in contact with the
6360           <prgn>netbase</prgn> maintainer, who will add the entries
6361           and release a new version of the <prgn>netbase</prgn>
6362           package.
6363         </p>
6364
6365         <p>
6366           The configuration file <file>/etc/inetd.conf</file> must not be
6367           modified by the package's scripts except via the
6368           <prgn>update-inetd</prgn> script or the
6369           <file>DebianNet.pm</file> Perl module.  See their documentation
6370           for details on how to add entries.
6371         </p>
6372
6373         <p>
6374           If a package wants to install an example entry into
6375           <file>/etc/inetd.conf</file>, the entry must be preceded with
6376           exactly one hash character (<tt>#</tt>). Such lines are
6377           treated as `commented out by user' by the
6378           <prgn>update-inetd</prgn> script and are not changed or
6379           activated during package updates.
6380         </p>
6381       </sect>
6382
6383       <sect>
6384         <heading>Using pseudo-ttys and modifying wtmp, utmp and
6385         lastlog</heading>
6386
6387         <p>
6388           Some programs need to create pseudo-ttys. This should be done
6389           using Unix98 ptys if the C library supports it. The resulting
6390           program must not be installed setuid root, unless that
6391           is required for other functionality.
6392         </p>
6393
6394         <p>
6395           The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6396           <file>/var/log/lastlog</file> must be installed writeable by
6397           group <tt>utmp</tt>.  Programs which need to modify those
6398           files must be installed setgid <tt>utmp</tt>.
6399         </p>
6400       </sect>
6401
6402       <sect>
6403         <heading>Editors and pagers</heading>
6404
6405         <p>
6406           Some programs have the ability to launch an editor or pager
6407           program to edit or display a text document.  Since there are
6408           lots of different editors and pagers available in the Debian
6409           distribution, the system administrator and each user should
6410           have the possibility to choose his/her preferred editor and
6411           pager.
6412         </p>
6413
6414         <p>
6415           In addition, every program should choose a good default
6416           editor/pager if none is selected by the user or system
6417           administrator.
6418         </p>
6419
6420         <p>
6421           Thus, every program that launches an editor or pager must
6422           use the EDITOR or PAGER environment variable to determine
6423           the editor or pager the user wishes to use.  If these
6424           variables are not set, the programs <file>/usr/bin/editor</file>
6425           and <file>/usr/bin/pager</file> should be used, respectively.
6426         </p>
6427
6428         <p>
6429           These two files are managed through the <prgn>dpkg</prgn>
6430           `alternatives' mechanism.  Thus every package providing an
6431           editor or pager must call the
6432           <prgn>update-alternatives</prgn> script to register these
6433           programs.
6434         </p>
6435
6436         <p>
6437           If it is very hard to adapt a program to make use of the
6438           EDITOR or PAGER variables, that program may be configured to
6439           use <file>/usr/bin/sensible-editor</file> and
6440           <file>/usr/bin/sensible-pager</file> as the editor or pager
6441           program respectively.  These are two scripts provided in the
6442           Debian base system that check the EDITOR and PAGER variables
6443           and launch the appropriate program, and fall back to
6444           <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6445           variable is not set.
6446         </p>
6447
6448         <p>
6449           A program may also use the VISUAL environment variable to
6450           determine the user's choice of editor.  If it exists, it
6451           should take precedence over EDITOR.  This is in fact what
6452           <file>/usr/bin/sensible-editor</file> does.
6453         </p>
6454
6455         <p>
6456           It is not required for a package to depend on
6457           <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6458           package to provide such virtual packages.<footnote>
6459             <p>
6460               The Debian base system already provides an editor and a
6461               pager program,
6462             </p>
6463           </footnote>
6464         </p>
6465       </sect>
6466
6467       <sect id="web-appl">
6468         <heading>Web servers and applications</heading>
6469
6470         <p>
6471           This section describes the locations and URLs that should
6472           be used by all web servers and web applications in the
6473           Debian system.
6474         </p>
6475
6476         <p>
6477           <enumlist>
6478             <item>
6479               <p>
6480                 Cgi-bin executable files are installed in the
6481                 directory
6482                 <example compact="compact">
6483 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6484                 </example>
6485                 and should be referred to as
6486                 <example compact="compact">
6487 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6488                 </example>
6489               </p>
6490             </item>
6491
6492             <item><p>Access to HTML documents</p>
6493
6494               <p>
6495                 HTML documents for a package are stored in
6496                 <file>/usr/share/doc/<var>package</var></file>
6497                 and can be referred to as
6498                 <example compact="compact">
6499 http://localhost/doc/<var>package</var>/<var>filename</var>
6500                 </example>
6501               </p>
6502              <p>
6503                 The web server should restrict access to the document
6504                 tree so that only clients on the same host can read
6505                 the documents. If the web server does not support such
6506                 access controls, then it should not provide access at
6507                 all, or ask about providing access during installation.
6508               </p>
6509             </item>
6510
6511             <item><p>Web Document Root</p>
6512
6513               <p>
6514                 Web Applications should try to avoid storing files in
6515                 the Web Document Root.  Instead they should use the
6516                 /usr/share/doc/<var>package</var> directory for
6517                 documents and register the Web Application via the
6518                 menu package.  If access to the web document root is
6519                 unavoidable then use
6520                 <example compact="compact">
6521 /var/www
6522                 </example>
6523                 as the Document Root.  This might be just a symbolic
6524                 link to the location where the system administrator
6525                 has put the real document root.
6526               </p>
6527             </item>
6528
6529           </enumlist></p></sect>
6530
6531
6532       <sect id="mail-transport-agents">
6533         <heading>Mail transport, delivery and user agents</heading>
6534
6535         <p>
6536           Debian packages which process electronic mail, whether mail
6537           user agents (MUAs) or mail transport agents (MTAs), must
6538           ensure that they are compatible with the configuration
6539           decisions below.  Failure to do this may result in lost
6540           mail, broken <tt>From:</tt> lines, and other serious brain
6541           damage!
6542         </p>
6543
6544         <p>
6545           The mail spool is <file>/var/mail</file> and the interface to
6546           send a mail message is <file>/usr/sbin/sendmail</file> (as per
6547           the FHS).  On older systems, the mail spool may be
6548           physically located in <file>/var/spool/mail</file>, but all
6549           access to the mail spool should be via the
6550           <file>/var/mail</file> symlink.  The mail spool is part of the
6551           base system and not part of the MTA package.
6552         </p>
6553
6554         <p>
6555           All Debian MUAs, MTAs, MDAs and other mailbox accessing
6556           programs (such as IMAP daemons) must lock the mailbox in an
6557           NFS-safe way. This means that <tt>fcntl()</tt> locking must
6558           be combined with dot locking.  To avoid deadlocks, a program
6559           should use <tt>fcntl()</tt> first and dot locking after
6560           this, or alternatively implement the two locking methods in
6561           a non blocking way<footnote>
6562             <p>
6563               If it is not possible to establish both locks, the
6564               system shouldn't wait for the second lock to be
6565               established, but remove the first lock, wait a (random)
6566               time, and start over locking again.
6567             </p>
6568           </footnote>. Using the functions <tt>maillock</tt> and
6569           <tt>mailunlock</tt> provided by the
6570           <tt>liblockfile*</tt><footnote>
6571             <p>
6572               You will need to depend on <tt>liblockfile1
6573                 (&gt;&gt;1.01)</tt> to use these functions.
6574             </p>
6575           </footnote> packages is the recommended way to realize this.
6576         </p>
6577
6578         <p>
6579           Mailboxes are generally mode 660
6580           <tt><var>user</var>.mail</tt> unless the system
6581           administrator has chosen otherwise.  A MUA may remove a
6582           mailbox (unless it has nonstandard permissions) in which
6583           case the MTA or another MUA must recreate it if needed.
6584           Mailboxes must be writable by group mail.
6585         </p>
6586
6587         <p>
6588           The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6589           be setgid mail to do the locking mentioned above (and
6590           must obviously avoid accessing other users' mailboxes
6591           using this privilege).</p>
6592
6593         <p>
6594           <file>/etc/aliases</file> is the source file for the system mail
6595           aliases (e.g., postmaster, usenet, etc.), it is the one
6596           which the sysadmin and <prgn>postinst</prgn> scripts may
6597           edit.  After <file>/etc/aliases</file> is edited the program or
6598           human editing it must call <prgn>newaliases</prgn>.  All MTA
6599           packages must come with a <prgn>newaliases</prgn> program,
6600           even if it does nothing, but older MTA packages did not do
6601           this so programs should not fail if <prgn>newaliases</prgn>
6602           cannot be found.  Note that because of this, all MTA
6603           packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6604           <tt>Replaces: mail-transport-agent</tt> control file
6605           fields.
6606         </p>
6607
6608         <p>
6609           The convention of writing <tt>forward to
6610             <var>address</var></tt> in the mailbox itself is not
6611           supported.  Use a <tt>.forward</tt> file instead.</p>
6612
6613         <p>
6614           The <prgn>rmail</prgn> program used by UUCP
6615           for incoming mail should be  <file>/usr/sbin/rmail</file>.
6616           Likewise, <prgn>rsmtp</prgn>, for receiving
6617           batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6618           is supported.</p>
6619
6620         <p>
6621           If your package needs to know what hostname to use on (for
6622           example) outgoing news and mail messages which are generated
6623           locally, you should use the file <file>/etc/mailname</file>.  It
6624           will contain the portion after the username and <tt>@</tt>
6625           (at) sign for email addresses of users on the machine
6626           (followed by a newline).
6627         </p>
6628
6629         <p>
6630           Such package should check for the existence of this file
6631           when it is being configured.  If it exists, it should be
6632           used without comment, although an MTA's configuration script
6633           may wish to prompt the user even if it finds that this file
6634           exists.  If the file does not exist, the package should
6635           prompt the user for the value (preferably using
6636           <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6637           as well as using it in the package's configuration.  The
6638           prompt should make it clear that the name will not just be
6639           used by that package.  For example, in this situation the
6640           <tt>inn</tt> package could say something like:
6641           <example compact="compact">
6642 Please enter the `mail name' of your system.  This is the
6643 hostname portion of the address to be shown on outgoing
6644 news and mail messages.  The default is
6645 <var>syshostname</var>, your system's host name.  Mail
6646 name [`<var>syshostname</var>']:
6647           </example>
6648           where <var>syshostname</var> is the output of <tt>hostname
6649             --fqdn</tt>.
6650         </p>
6651       </sect>
6652
6653       <sect>
6654         <heading>News system configuration</heading>
6655
6656         <p>
6657           All the configuration files related to the NNTP (news)
6658           servers and clients should be located under
6659           <file>/etc/news</file>.</p>
6660
6661         <p>
6662           There are some configuration issues that apply to a number
6663           of news clients and server packages on the machine. These
6664           are:
6665
6666           <taglist>
6667             <tag><file>/etc/news/organization</file></tag>
6668             <item><p>A string which should appear as the
6669                 organization header for all messages posted
6670                 by NNTP clients on the machine</p></item>
6671
6672             <tag><file>/etc/news/server</file></tag>
6673             <item><p>Contains the FQDN of the upstream NNTP
6674                 server, or localhost if the local machine is
6675                 an NNTP server.</p></item>
6676           </taglist>
6677
6678           Other global files may be added as required for cross-package news
6679           configuration.</p></sect>
6680
6681
6682       <sect>
6683         <heading>Programs for the X Window System</heading>
6684
6685         <sect1>
6686           <heading>Providing X support and package priorities</heading>
6687
6688           <p>
6689             Programs that can be configured with support for the X
6690             Window System must be configured to do so and must declare
6691             any package dependencies necessary to satisfy their
6692             runtime requirements when using the X Window System.  If
6693             such a package is of higher priority than the X packages
6694             on which it depends, it is required that either the
6695             X-specific components be split into a separate package, or
6696             that an alternative version of the package, which includes
6697             X support, be provided, or that the package's priority be
6698             lowered.
6699           </p>
6700         </sect1>
6701
6702         <sect1>
6703           <heading>Packages providing an X server</heading>
6704
6705           <p>
6706             Packages that provide an X server that, directly or
6707             indirectly, communicates with real input and display
6708             hardware should declare in their control data that they
6709             provide the virtual package <tt>xserver</tt>.<footnote>
6710               <p>
6711                 This implements current practice, and provides an
6712                 actual policy for usage of the <tt>xserver</tt>
6713                 virtual package which appears in the virtual packages
6714                 list.  In a nutshell, X servers that interface
6715                 directly with the display and input hardware or via
6716                 another subsystem (e.g., GGI) should provide
6717                 <tt>xserver</tt>.  Things like <tt>Xvfb</tt>,
6718                 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
6719               </p>
6720             </footnote>
6721           </p>
6722         </sect1>
6723
6724         <sect1>
6725           <heading>Packages providing a terminal emulator</heading>
6726
6727           <p>
6728             Packages that provide a terminal emulator for the X Window
6729             System which meet the criteria listed below should declare
6730             in their control data that they provide the virtual
6731             package <tt>x-terminal-emulator</tt>.  They should also
6732             register themselves as an alternative for
6733             <file>/usr/bin/x-terminal-emulator</file>, with a priority of
6734             20.
6735           </p>
6736
6737           <p>
6738             To be an <tt>x-terminal-emulator</tt>, a program must:
6739             <list compact="compact">
6740               <item><p>
6741                   Be able to emulate a DEC VT100 terminal, or a
6742                   compatible terminal.
6743                 </p></item>
6744
6745               <item><p>
6746                   Support the command-line option <tt>-e
6747                     <var>command</var></tt>, which creates a new
6748                   terminal window<footnote>
6749                     <p>
6750                       "New terminal window" does not necessarily mean
6751                       a new top-level X window directly parented by
6752                       the window manager; it could, if the terminal
6753                       emulator application were so coded, be a new
6754                       "view" in a multiple-document interface (MDI).
6755                     </p>
6756                   </footnote>
6757                   and runs the specified <var>command</var>.
6758                 </p></item>
6759
6760               <item><p>
6761                   Support the command-line option <tt>-T
6762                     <var>title</var></tt>, which creates a new terminal
6763                   window with the window title <var>title</var>.
6764                 </p></item>
6765             </list>
6766           </p>
6767         </sect1>
6768
6769         <sect1>
6770           <heading>Packages providing a window manager</heading>
6771
6772           <p>
6773             Packages that provide a window manager should declare in
6774             their control data that they provide the virtual package
6775             <tt>x-window-manager</tt>.  They should also register
6776             themselves as an alternative for
6777             <file>/usr/bin/x-window-manager</file>, with a priority
6778             calculated as follows:
6779             <list compact="compact">
6780               <item><p>Start with a priority of 20.</p></item>
6781
6782               <item>
6783                 <p>
6784                   If the window manager supports the Debian menu
6785                   system, add 20 points if this support is available
6786                   in the package's default configuration (i.e., no
6787                   configuration files belonging to the system or user
6788                   have to be edited to activate the feature); if
6789                   configuration files must be modified, add only 10
6790                   points.
6791                 </p>
6792               </item>
6793
6794               <item>
6795                 <p>
6796                   If the window manager permits the X session to be
6797                   restarted using a <em>different</em> window manager
6798                   (without killing the X server) in its default
6799                   configuration, add 10 points; otherwise add none.
6800                 </p>
6801               </item>
6802             </list>
6803           </p>
6804         </sect1>
6805
6806         <sect1>
6807           <heading>Packages providing fonts</heading>
6808
6809           <p>
6810             Packages that provide fonts for the X Window
6811             System<footnote>
6812               <p>
6813                 For the purposes of Debian Policy, a "font for the X
6814                 Window System" is one which is accessed via X protocol
6815                 requests.  Fonts for the Linux console, for PostScript
6816                 renderers, or any other purpose, do not fit this
6817                 definition.  Any tool which makes such fonts available
6818                 to the X Window System, however, must abide by this
6819                 font policy.
6820               </p>
6821             </footnote>
6822             must do a number of things to ensure that they are both
6823             available without modification of the X or font server
6824             configuration, and that they do not corrupt files used by
6825             other font packages to register information about
6826             themselves.
6827             <enumlist>
6828               <item>
6829                 <p>
6830                   Fonts of any type supported by the X Window System
6831                   must be be in a separate binary package from any
6832                   executables, libraries, or documentation (except
6833                   that specific to the fonts shipped, such as their
6834                   license information).  If one or more of the fonts
6835                   so packaged are necessary for proper operation of
6836                   the package with which they are associated the font
6837                   package may be Recommended; if the fonts merely
6838                   provide an enhancement, a Suggests relationship may
6839                   be used.  Packages must not Depend on font
6840                   packages.<footnote>
6841                     <p>
6842                       This is because the X server may retrieve fonts
6843                       from the local filesystem or over the network
6844                       from an X font server; the Debian package system
6845                       is empowered to deal only with the local
6846                       filesystem.
6847                     </p>
6848                   </footnote>
6849                 </p>
6850               </item>
6851
6852               <item>
6853                 <p>
6854                   BDF fonts must be converted to PCF fonts with the
6855                   <prgn>bdftopcf</prgn> utility (available in the
6856                   <tt>xutils</tt> package, <tt>gzip</tt>ped, and
6857                   placed in a directory that corresponds to their
6858                   resolution:
6859                   <list compact="compact">
6860                     <item><p>
6861                         100 dpi fonts must be placed in
6862                         <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
6863                       </p></item>
6864
6865                     <item><p>
6866                         75 dpi fonts must be placed in
6867                         <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
6868                       </p></item>
6869
6870                     <item><p>
6871                         Character-cell fonts, cursor fonts, and other
6872                         low-resolution fonts must be placed in
6873                         <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
6874                       </p></item>
6875                   </list>
6876                 </p>
6877               </item>
6878
6879               <item><p>
6880                   Speedo fonts must be placed in
6881                   <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
6882                 </p></item>
6883
6884               <item><p>
6885                   Type 1 fonts must be placed in
6886                   <file>/usr/X11R6/lib/X11/fonts/Type1/</file>.  If font
6887                   metric files are available, they must be placed here
6888                   as well.
6889                 </p></item>
6890
6891               <item>
6892                 <p>
6893                   Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
6894                   other than those listed above must be neither
6895                   created nor used.  (The <file>PEX</file>, <file>CID</file>,
6896                   and <file>cyrillic</file> directories are excepted for
6897                   historical reasons, but installation of files into
6898                   these directories remains discouraged.)
6899                 </p>
6900               </item>
6901
6902               <item>
6903                 <p>
6904                   Font packages may, instead of placing files directly
6905                   in the X font directories listed above, provide
6906                   symbolic links in the font directory which point to
6907                   the files' actual location in the filesystem.  Such
6908                   a location must comply with the FHS.
6909                 </p>
6910               </item>
6911
6912               <item>
6913                 <p>
6914                   Font packages should not contain both 75dpi and
6915                   100dpi versions of a font.  If both are available,
6916                   they should be provided in separate binary packages
6917                   with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
6918                   the names of the packages containing the
6919                   corresponding fonts.
6920                 </p>
6921               </item>
6922
6923               <item>
6924                 <p>
6925                   Fonts destined for the <file>misc</file> subdirectory
6926                   should not be included in the same package as 75dpi
6927                   or 100dpi fonts; instead, they should be provided in
6928                   a separate package with <tt>-misc</tt> appended to
6929                   its name.
6930                 </p>
6931               </item>
6932
6933               <item>
6934                 <p>
6935                   Font packages must not provide the files
6936                   <file>fonts.dir</file>, <file>fonts.alias</file>, or
6937                   <file>fonts.scale</file> in a font directory:
6938                   <list>
6939                     <item><p>
6940                         <file>fonts.dir</file> files must not be provided at all.
6941                       </p></item>
6942
6943                     <item>
6944                       <p>
6945                         <file>fonts.alias</file> and <file>fonts.scale</file>
6946                         files, if needed, should be provided in the
6947                         directory
6948                         <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
6949                         where <var>fontdir</var> is the name of the
6950                         subdirectory of
6951                         <file>/usr/X11R6/lib/X11/fonts/</file> where the
6952                         package's corresponding fonts are stored
6953                         (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
6954                         <var>package</var> is the name of the package
6955                         that provides these fonts, and
6956                         <var>extension</var> is either <tt>scale</tt>
6957                         or <tt>alias</tt>, whichever corresponds to
6958                         the file contents.
6959                       </p>
6960                     </item>
6961                   </list>
6962                 </p>
6963               </item>
6964
6965               <item>
6966                 <p>
6967                   Font packages must declare a dependency on
6968                   <tt>xutils (&gt;&gt; 4.0.3)</tt> in their control
6969                   data.
6970                 </p>
6971               </item>
6972
6973               <item>
6974                 <p>
6975                   Font packages that provide one or more
6976                   <file>fonts.scale</file> files as described above must
6977                   invoke <prgn>update-fonts-scale</prgn> on each
6978                   directory into which they installed fonts
6979                   <em>before</em> invoking
6980                   <prgn>update-fonts-dir</prgn> on that directory.
6981                   This invocation must occur in both the
6982                   <prgn>postinst</prgn> (for all arguments) and
6983                   <prgn>postrm</prgn> (for all arguments except
6984                   <tt>upgrade</tt>) scripts.
6985                 </p>
6986               </item>
6987
6988               <item>
6989                 <p>
6990                   Font packages that provide one or more
6991                   <file>fonts.alias</file> files as described above must
6992                   invoke <prgn>update-fonts-alias</prgn> on each
6993                   directory into which they installed fonts.  This
6994                   invocation must occur in both the
6995                   <prgn>postinst</prgn> (for all arguments) and
6996                   <prgn>postrm</prgn> (for all arguments except
6997                   <tt>upgrade</tt>) scripts.
6998                 </p>
6999               </item>
7000
7001               <item>
7002                 <p>
7003                   Font packages must invoke
7004                   <prgn>update-fonts-dir</prgn> on each directory into
7005                   which they installed fonts.  This invocation must
7006                   occur in both the <prgn>postinst</prgn> (for all
7007                   arguments) and <prgn>postrm</prgn> (for all
7008                   arguments except <tt>upgrade</tt>) scripts.
7009                 </p>
7010               </item>
7011
7012               <item>
7013                 <p>
7014                   Font packages must not provide alias names for the
7015                   fonts they include which collide with alias names
7016                   already in use by fonts already packaged.
7017                 </p>
7018               </item>
7019
7020               <item>
7021                 <p>
7022                   Font packages must not provide fonts with the same
7023                   XLFD registry name as another font already packaged.
7024                 </p>
7025               </item>
7026             </enumlist>
7027           </p>
7028         </sect1>
7029
7030         <sect1>
7031           <heading>Application defaults files</heading>
7032
7033           <p>
7034             Application defaults files must be installed in the
7035             directory <file>/etc/X11/app-defaults/</file> (use of a
7036             localized subdirectory of <file>/etc/X11/</file> as described
7037             in the <em>X Toolkit Intrinsics - C Language
7038             Interface</em> manual is also permitted).  They must be
7039             registered as <tt>conffile</tt>s or handled as
7040             configuration files.  Packages must not provide the
7041             directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7042           </p>
7043
7044           <p>
7045             Customization of programs' X resources may also be
7046             supported with the provision of a file with the same name
7047             as that of the package placed in the
7048             <file>/etc/X11/Xresources/</file> directory, which must
7049             registered as a <tt>conffile</tt> or handled as a
7050             configuration file.<footnote>
7051               <p>
7052                 Note that this mechanism is not the same as using
7053                 app-defaults; app-defaults are tied to the client
7054                 binary on the local filesystem, whereas X resources
7055                 are stored in the X server and affect all connecting
7056                 clients.
7057               </p>
7058             </footnote>
7059             <em>Important:</em> packages that install files into the
7060             <file>/etc/X11/Xresources/</file> directory must conflict with
7061             <tt>xbase (&lt;&lt; 3.3.2.3a-2)</tt>; if this is not done
7062             it is possible for the installing package to destroy a
7063             previously-existing <file>/etc/X11/Xresources</file> file
7064             which had been customized by the system administrator.
7065           </p>
7066         </sect1>
7067
7068         <sect1>
7069           <heading>Installation directory issues</heading>
7070
7071           <p>
7072             Packages using the X Window System should not be
7073             configured to install files under the <file>/usr/X11R6/</file>
7074             directory unless they use <prgn>imake</prgn>. The
7075             <file>/usr/X11R6/</file> directory hierarchy should be
7076             regarded as deprecated for all packages except the X
7077             Window System itself, and those which use the
7078             <prgn>imake</prgn> program it provides, in which case the
7079             packages may transition out of the <file>/usr/X11R6/</file>
7080             directory at the maintainer's discretion.<footnote>
7081               <p>
7082                 <prgn>Imake</prgn>-using programs are exempt because,
7083                 as long as they are written correctly, the pathnames
7084                 they use to locate resources and install themselves
7085                 are derived wholly from the X Window System
7086                 configuration.  Thus, in the event that the X Window
7087                 System moves to <file>/usr/X11R7/</file>,
7088                 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7089                 that is required for these programs is a recompile
7090                 against the corresponding X Window System library
7091                 development packages.
7092               </p>
7093             </footnote>
7094             Programs that use GNU <prgn>autoconf</prgn> and
7095             <prgn>automake</prgn> are usually easily configured at
7096             compile time to use <file>/usr/</file> instead of
7097             <file>/usr/X11R6/</file>, and this should be done whenever
7098             possible.  Configuration files for window managers and
7099             display managers should be placed in a subdirectory of
7100             <file>/etc/X11/</file> corresponding to the package name due
7101             to these programs' tight integration with the mechanisms
7102             of the X Window System.  Application-level programs should
7103             use the <file>/etc/</file> directory unless otherwise mandated
7104             by policy.  The installation of files into subdirectories
7105             of <file>/usr/X11R6/include/X11/</file> and
7106             <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7107             package maintainers should determine if subdirectories of
7108             <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7109             instead.  (The use of symbolic links from the
7110             <file>X11R6</file> directories to other FHS-compliant
7111             locations is encouraged if the program is not easily
7112             configured to look elsewhere for its files.)  Packages
7113             must not provide or install files into the directories
7114             <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7115             <file>/usr/lib/X11/</file>.  Files within a package should,
7116             however, make reference to these directories, rather than
7117             their <tt>X11R6</tt>-named counterparts
7118             <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7119             and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7120             referred to have not been moved to other FHS-compliant
7121             locations.
7122           </p>
7123         </sect1>
7124
7125         <sect1>
7126           <heading>The OSF/Motif and OpenMotif libraries</heading>
7127
7128           <p>
7129             <em>Programs that require the non-DFSG-compliant OSF/Motif or
7130               OpenMotif libraries</em><footnote>
7131               <p>
7132                 OSF/Motif and OpenMotif are collectively referred to as
7133                 "Motif" in this policy document.
7134               </p>
7135             </footnote>
7136             should be compiled against and tested with LessTif (a free
7137             re-implementation of Motif) instead.  If the maintainer
7138             judges that the program or programs do not work
7139             sufficiently well with LessTif to be distributed and
7140             supported, but do so when compiled against Motif, then two
7141             versions of the package should be created; one linked
7142             statically against Motif and with <tt>-smotif</tt>
7143             appended to the package name, and one linked dynamically
7144             against Motif and with <tt>-dmotif</tt> appended to the
7145             package name.  Both Motif-linked versions are dependent
7146             upon non-DFSG-compliant software and thus cannot be
7147             uploaded to the <em>main</em> distribution; if the
7148             software is itself DFSG-compliant it may be uploaded to
7149             the <em>contrib</em> distribution.  While known existing
7150             versions of Motif permit unlimited redistribution of
7151             binaries linked against the library (whether statically or
7152             dynamically), it is the package maintainer's
7153             responsibility to determine whether this is permitted by
7154             the license of the copy of Motif in his or her possession.
7155           </p>
7156         </sect1>
7157       </sect>
7158
7159       <sect>
7160         <heading>Perl programs and modules</heading>
7161         <p>
7162           Perl programs and modules should follow the current Perl             
7163           policy as defined in the file found on                               
7164           <ftpsite>ftp.debian.org</ftpsite> in                                 
7165           <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>  
7166           or your local mirror.  In addition, it is included in the            
7167           <tt>debian-policy</tt> package.                                
7168         </p>
7169       </sect>
7170
7171       <sect>
7172         <heading>Emacs lisp programs</heading>
7173
7174         <p>
7175           Please refer to the `Debian Emacs Policy' (documented in
7176           <file>debian-emacs-policy.gz</file> of the
7177           <prgn>emacsen-common</prgn> package) for details of how to
7178           package emacs lisp programs.
7179         </p>
7180       </sect>
7181
7182       <sect>
7183         <heading>Games</heading>
7184
7185         <p>
7186           The permissions on <file>/var/games</file> are mode 755, owner
7187           <tt>root</tt> and group <tt>root</tt>.
7188         </p>
7189           
7190         <p>
7191           Each game decides on its own security policy.</p>
7192
7193         <p>
7194           Games which require protected, privileged access to
7195           high-score files, savegames, etc., may be made
7196           set-<em>group</em>-id (mode 2755) and owned by
7197           <tt>root.games</tt>, and use files and directories with
7198           appropriate permissions (770 <tt>root.games</tt>, for
7199           example).  They must not be made
7200           set-<em>user</em>-id, as this causes security problems. (If
7201           an attacker can subvert any set-user-id game they can
7202           overwrite the executable of any other, causing other players
7203           of these games to run a Trojan horse program.  With a
7204           set-group-id game the attacker only gets access to less
7205           important game data, and if they can get at the other
7206           players' accounts at all it will take considerably more
7207           effort.)</p>
7208
7209         <p>
7210           Some packages, for example some fortune cookie programs, are
7211           configured by the upstream authors to install with their
7212           data files or other static information made unreadable so
7213           that they can only be accessed through set-id programs
7214           provided.  You should not do this in a Debian package: anyone can
7215           download the <file>.deb</file> file and read the data from it,
7216           so there is no point making the files unreadable.  Not
7217           making the files unreadable also means that you don't have
7218           to make so many programs set-id, which reduces the risk of a
7219           security hole.</p>
7220
7221         <p>
7222           As described in the FHS, binaries of games should be
7223           installed in the directory <file>/usr/games</file>. This also
7224           applies to games that use the X Window System. Manual pages
7225           for games (X and non-X games) should be installed in
7226           <file>/usr/share/man/man6</file>.</p>
7227       </sect>
7228     </chapt>
7229
7230     <chapt id="docs"><heading>Documentation</heading>
7231
7232
7233       <sect>
7234         <heading>Manual pages</heading>
7235
7236         <p>
7237           You should install manual pages in <prgn>nroff</prgn> source
7238           form, in appropriate places under <file>/usr/share/man</file>.  You
7239           should only use sections 1 to 9 (see the FHS for more
7240           details).  You must not install a preformatted `cat
7241           page'.</p>
7242
7243         <p>
7244           Each program, utility, and function should have an
7245           associated manpage included in the same package. It is
7246           suggested that all configuration files also have a manual
7247           page included as well.
7248         </p>
7249
7250         <p>
7251           If no manual page is available for a particular program,
7252           utility, function or configuration file and this is reported
7253           as a bug to the Debian Bug Tracking System, a symbolic link
7254           from the requested manual page to the <manref
7255           name="undocumented" section="7"> manual page may be
7256           provided.  This symbolic link can be created from
7257           <file>debian/rules</file> like this:
7258           <example compact="compact">
7259 ln -s ../man7/undocumented.7.gz \
7260   debian/tmp/usr/share/man/man[1-9]/<var>requested_manpage</var>.[1-9].gz
7261           </example>
7262           This manpage claims that the lack of a manpage has been
7263           reported as a bug, so you may only do this if it really has
7264           (you can report it yourself, if you like).  Do not close the
7265           bug report until a proper manpage is available.</p>
7266
7267         <p>
7268           You may forward a complaint about a missing manpage to the
7269           upstream authors, and mark the bug as forwarded in the
7270           Debian bug tracking system.  Even though the GNU Project do
7271           not in general consider the lack of a manpage to be a bug,
7272           we do; if they tell you that they don't consider it a bug
7273           you should leave the bug in our bug tracking system open
7274           anyway.</p>
7275
7276         <p>
7277           Manual pages should be installed compressed using <tt>gzip
7278             -9</tt>.</p>
7279
7280         <p>
7281           If one manpage needs to be accessible via several names it
7282           is better to use a symbolic link than the <file>.so</file>
7283           feature, but there is no need to fiddle with the relevant
7284           parts of the upstream source to change from <file>.so</file> to
7285           symlinks: don't do it unless it's easy.  You should not
7286           create hard links in the manual page directories, nor put
7287           absolute filenames in <file>.so</file> directives.  The filename
7288           in a <file>.so</file> in a manpage should be relative to the
7289           base of the manpage tree (usually
7290           <file>/usr/share/man</file>). If you do not create any links
7291           (whether symlinks, hard links, or <tt>.so</tt> directives)
7292           in the filesystem to the alternate names of the manpage,
7293           then you should not rely on <prgn>man</prgn> finding your
7294           manpage under those names based solely on the information in
7295           the manpage's header.<footnote>
7296             <p>
7297               Supporting this in <prgn>man</prgn> often requires
7298               unreasonable processing time to find a manual page or to
7299               report that none exists, and moves knowledge into man's
7300               database that would be better left in the filesystem.
7301               This support is therefore deprecated and will cease to
7302               be present in the future.
7303             </p>
7304           </footnote>
7305         </p>
7306       </sect>
7307
7308       <sect>
7309         <heading>Info documents</heading>
7310
7311         <p>
7312           Info documents should be installed in <file>/usr/share/info</file>.
7313           They should be compressed with <tt>gzip -9</tt>.</p>
7314
7315         <p>
7316           Your package should call <prgn>install-info</prgn> to update
7317           the Info <file>dir</file> file in its <prgn>postinst</prgn>
7318           script when called with a <tt>configure</tt> argument, for
7319           example:
7320           <example compact="compact">
7321 install-info --quiet --section Development Development \
7322   /usr/share/info/foobar.info
7323           </example></p>
7324
7325         <p>
7326           It is a good idea to specify a section for the location of
7327           your program; this is done with the <tt>--section</tt>
7328           switch.  To determine which section to use, you should look
7329           at <file>/usr/share/info/dir</file> on your system and choose the most
7330           relevant (or create a new section if none of the current
7331           sections are relevant).  Note that the <tt>--section</tt>
7332           flag takes two arguments; the first is a regular expression
7333           to match (case-insensitively) against an existing section,
7334           the second is used when creating a new one.</p>
7335
7336         <p>
7337           You should remove the entries in the <prgn>prerm</prgn>
7338           script when called with a <tt>remove</tt> argument:
7339           <example compact="compact">
7340 install-info --quiet --remove /usr/share/info/foobar.info
7341           </example></p>
7342
7343         <p>
7344           If <prgn>install-info</prgn> cannot find a description entry
7345           in the Info file you must supply one.  See <manref
7346           name="install-info" section="8"> for details.</p>
7347       </sect>
7348
7349       <sect>
7350         <heading>Additional documentation</heading>
7351
7352         <p>
7353           Any additional documentation that comes with the package may
7354           be installed at the discretion of the package maintainer.
7355           Text documentation should be installed in the directory
7356           <file>/usr/share/doc/<var>package</var></file>, where
7357           <var>package</var> is the name of the package, and
7358           compressed with <tt>gzip -9</tt> unless it is small.</p>
7359
7360         <p>
7361           If a package comes with large amounts of documentation which
7362           many users of the package will not require you should create
7363           a separate binary package to contain it, so that it does not
7364           take up disk space on the machines of users who do not need
7365           or want it installed.</p>
7366
7367         <p>
7368           It is often a good idea to put text information files
7369           (<file>README</file>s, changelogs, and so forth) that come with
7370           the source package in <file>/usr/share/doc/<var>package</var></file>
7371           in the binary package.  However, you don't need to install
7372           the instructions for building and installing the package, of
7373           course!</p>
7374
7375         <p>
7376           Files in <file>/usr/share/doc</file> should not be referenced by
7377           any program, and the system administrator should be able to
7378           delete them without causing any programs to break. Any files
7379           that are referenced by programs but are also useful as
7380           standalone documentation should be installed under
7381           <file>/usr/share/<var>package</var>/</file> with symbolic links
7382           from <file>/usr/share/doc/<var>package</var>/</file>.
7383         </p>
7384
7385       </sect>
7386
7387       <sect id="usrdoc">
7388         <heading>Accessing the documentation</heading>
7389
7390         <p>
7391           Former Debian releases placed all additional documentation
7392           in <file>/usr/doc/<var>package</var></file>.  To realize a
7393           smooth migration to
7394           <file>/usr/share/doc/<var>package</var></file>, each package
7395           must maintain a symlink <file>/usr/doc/<var>package</var></file>
7396           that points to the new location of its documentation in
7397           <file>/usr/share/doc/<var>package</var></file><footnote>These
7398               symlinks will be removed in the future, but they have to be
7399               there for compatibility reasons until all packages have
7400               moved and the policy is changed accordingly.</footnote>.
7401           The symlink must be created when the package is installed;
7402           it cannot be contained in the package itself due to problems
7403           with <prgn>dpkg</prgn>. One reasonable way to accomplish
7404           this is to put the following in the package's
7405           <prgn>postinst</prgn><footnote>
7406             <p>
7407               The <tt>debhelper</tt> script
7408               <prgn>dh_installdocs</prgn> does this automatically.
7409             </p>
7410           </footnote>:
7411           <example compact="compact">
7412 if [ "$1" = "configure" ]; then
7413   if [ -d /usr/doc -a ! -e /usr/doc/<var>package</var> \
7414        -a -d /usr/share/doc/<var>package</var> ]; then
7415     ln -sf ../share/doc/<var>package</var> /usr/doc/<var>package</var>
7416   fi
7417 fi
7418           </example>
7419           and the following in the package's <prgn>prerm</prgn>:
7420           <example compact="compact">
7421 if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \
7422      -a -L /usr/doc/<var>package</var> ]; then
7423   rm -f /usr/doc/<var>package</var>
7424 fi
7425           </example>
7426         </p>
7427       </sect>
7428
7429       <sect>
7430         <heading>Preferred documentation formats</heading>
7431
7432         <p>
7433           The unification of Debian documentation is being carried out
7434           via HTML.</p>
7435
7436         <p>
7437           If your package comes with extensive documentation in a
7438           markup format that can be converted to various other formats
7439           you should if possible ship HTML versions in a binary
7440           package, in the directory
7441           <file>/usr/share/doc/<var>appropriate-package</var></file> or
7442           its subdirectories.<footnote>
7443             <p>
7444               The rationale: The important thing here is that HTML
7445               docs should be available in <em>some</em> package, not
7446               necessarily in the main binary package.
7447             </p>
7448           </footnote>
7449         </p>
7450
7451         <p>
7452           Other formats such as PostScript may be provided at the
7453           package maintainer's discretion.
7454         </p>
7455       </sect>
7456
7457       <sect id="copyrightfile">
7458         <heading>Copyright information</heading>
7459
7460         <p>
7461           Every package must be accompanied by a verbatim copy of its
7462           copyright and distribution license in the file
7463           <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7464           file must neither be compressed nor be a symbolic link.
7465         </p>
7466
7467         <p>
7468           In addition, the copyright file must say where the upstream
7469           sources (if any) were obtained, and should explain briefly what
7470           modifications were made in the Debian version of the package
7471           compared to the upstream one.  It should name the original
7472           authors of the package and the Debian maintainer(s) who were
7473           involved with its creation.</p>
7474
7475         <p>
7476           A copy of the file which will be installed in
7477           <file>/usr/share/doc/<var>package</var>/copyright</file> should
7478           be in <file>debian/copyright</file> in the source package.
7479         </p>
7480
7481         <p>
7482           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7483           link to another directory in <file>/usr/share/doc</file> only if
7484           the two packages both come from the same source and the
7485           first package Depends on the second.  These rules are
7486           important because copyrights must be extractable by
7487           mechanical means.
7488         </p>
7489
7490         <p>
7491           Packages distributed under the UCB BSD license, the Artistic
7492           license, the GNU GPL, and the GNU LGPL should refer to the
7493           files <file>/usr/share/common-licenses/BSD</file>,
7494           <file>/usr/share/common-licenses/Artistic</file>,
7495           <file>/usr/share/common-licenses/GPL</file>, and
7496           <file>/usr/share/common-licenses/LGPL</file> respectively,
7497           rather than quoting them in the copyright file.
7498         </p>
7499
7500         <p>
7501           You should not use the copyright file as a general <file>README</file>
7502           file.  If your package has such a file it should be
7503           installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7504           <file>README.Debian</file> or some other appropriate place.</p>
7505       </sect>
7506
7507       <sect>
7508         <heading>Examples</heading>
7509
7510         <p>
7511           Any examples (configurations, source files, whatever),
7512           should be installed in a directory
7513           <file>/usr/share/doc/<var>package</var>/examples</file>.  These
7514           files should not be referenced by any program: they're there
7515           for the benefit of the system administrator and users as
7516           documentation only.  Architecture-specific example files
7517           should be installed in a directory
7518           <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7519           links to them from
7520           <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7521           latter directory itself may be a symbolic link to the
7522           former.
7523         </p>
7524       </sect>
7525
7526       <sect id="instchangelog">
7527         <heading>Changelog files</heading>
7528
7529         <p>
7530           Packages that are not Debian-native must contain a
7531           compressed copy of the <file>debian/changelog</file> file from
7532           the Debian source tree in
7533           <file>/usr/share/doc/<var>package</var></file> with the name
7534           <file>changelog.Debian.gz</file>.  If an upstream changelog is
7535           available, it should be accessible as
7536           <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7537           plain text.  If the upstream changelog is distributed in
7538           HTML, it should be made available in that form as
7539           <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7540           and a plain text <file>changelog.gz</file> should be generated
7541           from it using, for example, <tt>lynx -dump -nolist</tt>.  If
7542           the upstream changelog files do not already conform to this
7543           naming convention, then this may be achieved either by
7544           renaming the files, or by adding a symbolic link, at the
7545           maintainer's discretion.<footnote>
7546             <p>
7547               Rationale: People should not have to look in places for
7548               upstream changelogs merely because they are given
7549               different names or are distributed in HTML format.
7550             </p>
7551           </footnote>
7552         </p>
7553
7554         <p>
7555           All of these files should be installed compressed using
7556           <tt>gzip -9</tt>, as they will become large with time even
7557           if they start out small.
7558         </p>
7559
7560         <p>
7561           If the package has only one changelog which is used both as
7562           the Debian changelog and the upstream one because there is
7563           no separate upstream maintainer then that changelog should
7564           usually be installed as
7565           <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7566           there is a separate upstream maintainer, but no upstream
7567           changelog, then the Debian changelog should still be called
7568           <file>changelog.Debian.gz</file>.</p>
7569       </sect>
7570     </chapt>
7571
7572     <appendix id="pkg-scope">
7573       <heading>Introduction and scope of these appendices</heading>
7574
7575       <p>
7576         These appendices are taken essentially verbatim from the
7577         now-deprecated Packaging Manual, version 3.2.1.0.  They are
7578         the chapters which are likely to be of use to package
7579         maintainers and which have not already been included in the
7580         policy document itself. Most of these sections are very likely
7581         not relevant to policy; they should be treated as
7582         documentation for the packaging system. Please note that these
7583         appendices are included for convenience, and for historical
7584         reasons: they used to be part of policy package, and they have
7585         not yet been incorporated into dpkg documentation. However,
7586         they still have value, and hence they are presented here.
7587       </p>
7588       <p>
7589         They have not yet been checked to ensure that they are
7590         compatible with the contents of policy, and if there are any
7591         contradictions, the version in the main policy document takes
7592         precedence.  The remaining chapters of the old Packaging
7593         Manual have also not been read in detail to ensure that there
7594         are not parts which have been left out.  Both of these will be
7595         done in due course. 
7596       </p>
7597
7598       <p>
7599         <prgn>dpkg</prgn> is a suite of programs for creating binary
7600         package files and installing and removing them on Unix
7601         systems.<footnote>
7602           <p>
7603             <prgn>dpkg</prgn> is targetted primarily at Debian
7604             GNU/Linux, but may work on or be ported to other
7605             systems.
7606           </p>
7607         </footnote>
7608       </p>
7609
7610       <p>
7611         The binary packages are designed for the management of
7612         installed executable programs (usually compiled binaries) and
7613         their associated data, though source code examples and
7614         documentation are provided as part of some packages.</p>
7615
7616       <p>
7617         This manual describes the technical aspects of creating Debian
7618         binary packages (<file>.deb</file> files).  It documents the
7619         behaviour of the package management programs
7620         <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7621         they interact with packages.</p>
7622
7623       <p>
7624         It also documents the interaction between
7625         <prgn>dselect</prgn>'s core and the access method scripts it
7626         uses to actually install the selected packages, and describes
7627         how to create a new access method.</p>
7628         
7629       <p>
7630         This manual does not go into detail about the options and
7631         usage of the package building and installation tools.  It
7632         should therefore be read in conjuction with those programs'
7633         manpages.
7634       </p>      
7635
7636       <p>
7637         The utility programs which are provided with <prgn>dpkg</prgn>
7638         for managing various system configuration and similar issues,
7639         such as <prgn>update-rc.d</prgn> and
7640         <prgn>install-info</prgn>, are not described in detail here -
7641         please see their manpages.
7642       </p>
7643         
7644       <p>
7645         It does <em>not</em> describe the policy requirements imposed
7646         on Debian packages, such as the permissions on files and
7647         directories, documentation requirements, upload procedure, and
7648         so on.  You should see the Debian packaging policy manual for
7649         these details.  (Many of them will probably turn out to be
7650         helpful even if you don't plan to upload your package and make
7651         it available as part of the distribution.)
7652       </p>
7653         
7654       <p>
7655         It is assumed that the reader is reasonably familiar with the
7656         <prgn>dpkg</prgn> System Administrators' manual.
7657         Unfortunately this manual does not yet exist.
7658       </p>
7659         
7660       <p>
7661         The Debian version of the FSF's GNU hello program is provided
7662         as an example for people wishing to create Debian
7663         packages. The Debian <prgn>debmake</prgn> package is
7664         recommended as a very helpful tool in creating and maintaining
7665         Debian packages. However, while the tools and examples are
7666         helpful, they do not replace the need to read and follow the
7667         Policy and Programmer's Manual.</p>
7668     </appendix>
7669
7670     <appendix id="pkg-binarypkg"><heading>Binary packages (from old
7671     Packaging Manual)
7672       </heading>
7673         
7674       <p>
7675         The binary package has two main sections.  The first part
7676         consists of various control information files and scripts used
7677         by <prgn>dpkg</prgn> when installing and removing.  See <ref
7678         id="pkg-controlarea">.
7679       </p>
7680         
7681       <p>
7682         The second part is an archive containing the files and
7683         directories to be installed.
7684       </p>
7685         
7686       <p>
7687         In the future binary packages may also contain other
7688         components, such as checksums and digital signatures. The
7689         format for the archive is described in full in the
7690         <file>deb(5)</file> manpage.
7691       </p>
7692         
7693         
7694       <sect id="pkg-bincreating"><heading>Creating package files -
7695       <prgn>dpkg-deb</prgn>
7696         </heading>
7697           
7698         <p>
7699           All manipulation of binary package files is done by
7700           <prgn>dpkg-deb</prgn>; it's the only program that has
7701           knowledge of the format.  (<prgn>dpkg-deb</prgn> may be
7702           invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
7703           will spot that the options requested are appropriate to
7704           <prgn>dpkg-deb</prgn> and invoke that instead with the same
7705           arguments.)
7706         </p>
7707           
7708         <p>
7709           In order to create a binary package you must make a
7710           directory tree which contains all the files and directories
7711           you want to have in the filesystem data part of the package.
7712           In Debian-format source packages this directory is usually
7713           <file>debian/tmp</file>, relative to the top of the package's
7714           source tree.
7715         </p>
7716           
7717         <p>
7718           They should have the locations (relative to the root of the
7719           directory tree you're constructing) ownerships and
7720           permissions which you want them to have on the system when
7721           they are installed.
7722         </p>
7723           
7724         <p>
7725           With current versions of <prgn>dpkg</prgn> the uid/username
7726           and gid/groupname mappings for the users and groups being
7727           used should be the same on the system where the package is
7728           built and the one where it is installed.
7729         </p>
7730           
7731         <p>
7732           You need to add one special directory to the root of the
7733           miniature filesystem tree you're creating:
7734           <prgn>DEBIAN</prgn>.  It should contain the control
7735           information files, notably the binary package control file
7736           (see <ref id="pkg-controlfile">).
7737         </p>
7738           
7739         <p>
7740           The <prgn>DEBIAN</prgn> directory will not appear in the
7741           filesystem archive of the package, and so won't be installed
7742           by <prgn>dpkg</prgn> when the package is installed.
7743         </p>
7744           
7745         <p>
7746           When you've prepared the package, you should invoke:
7747           <example>
7748   dpkg --build <var>directory</var>
7749           </example>
7750         </p>
7751           
7752         <p>
7753           This will build the package in
7754           <file><var>directory</var>.deb</file>.  (<prgn>dpkg</prgn> knows
7755           that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
7756           it invokes <prgn>dpkg-deb</prgn> with the same arguments to
7757           build the package.)
7758         </p>
7759           
7760         <p>
7761           See the manpage <manref name="dpkg-deb" section="8"> for details of how
7762           to examine the contents of this newly-created file.  You may find the
7763           output of following commands enlightening:
7764           <example>
7765   dpkg-deb --info <var>filename</var>.deb
7766   dpkg-deb --contents <var>filename</var>.deb
7767   dpkg --contents <var>filename</var>.deb
7768           </example>
7769           To view the copyright file for a package you could use this command:
7770           <example>
7771   dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
7772           </example>
7773         </p>
7774       </sect>
7775
7776       <sect id="pkg-controlarea">
7777         <heading>
7778           Package control information files
7779         </heading>
7780           
7781         <p>
7782           The control information portion of a binary package is a
7783           collection of files with names known to <prgn>dpkg</prgn>.
7784           It will treat the contents of these files specially - some
7785           of them contain information used by <prgn>dpkg</prgn> when
7786           installing or removing the package; others are scripts which
7787           the package maintainer wants <prgn>dpkg</prgn> to run.
7788         </p>
7789           
7790         <p>
7791           It is possible to put other files in the package control
7792           area, but this is not generally a good idea (though they
7793           will largely be ignored).
7794         </p>
7795           
7796         <p>
7797           Here is a brief list of the control info files supported by
7798           <prgn>dpkg</prgn> and a summary of what they're used for.
7799         </p>
7800           
7801         <p>
7802           <taglist>
7803             <tag><tt>control</tt>
7804             <item>
7805               
7806               <p>
7807                 This is the key description file used by
7808                 <prgn>dpkg</prgn>.  It specifies the package's name
7809                 and version, gives its description for the user,
7810                 states its relationships with other packages, and so
7811                 forth.  See <ref id="pkg-controlfile">.
7812               </p>
7813                 
7814               <p>
7815                 It is usually generated automatically from information
7816                 in the source package by the
7817                 <prgn>dpkg-gencontrol</prgn> program, and with
7818                 assistance from <prgn>dpkg-shlibdeps</prgn>.  See <ref
7819                 id="pkg-sourcetools">.</p>
7820             </item>
7821               
7822             <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
7823             <tt>prerm</tt>
7824             </tag>
7825             <item>
7826               
7827               <p>
7828                 These are exectuable files (usually scripts) which
7829                 <prgn>dpkg</prgn> runs during installation, upgrade
7830                 and removal of packages.  They allow the package to
7831                 deal with matters which are particular to that package
7832                 or require more complicated processing than that
7833                 provided by <prgn>dpkg</prgn>.  Details of when and
7834                 how they are called are in <ref
7835                 id="maintainerscripts">.
7836               </p>
7837                 
7838               <p>
7839                 It is very important to make these scripts
7840                 idempotent.
7841                 <footnote>
7842                   <p>
7843                     That means that if it runs successfully or fails
7844                     and then you call it again it doesn't bomb out,
7845                     but just ensures that everything is the way it
7846                     ought to be.
7847                   </p>
7848                 </footnote> This is so that if an error occurs, the
7849                 user interrupts <prgn>dpkg</prgn> or some other
7850                 unforeseen circumstance happens you don't leave the
7851                 user with a badly-broken package.
7852               </p>
7853                 
7854               <p>
7855                 The maintainer scripts are guaranteed to run with a
7856                 controlling terminal and can interact with the user.
7857                 If they need to prompt for passwords, do full-screen
7858                 interaction or something similar you should do these
7859                 things to and from <file>/dev/tty</file>, since
7860                 <prgn>dpkg</prgn> will at some point redirect scripts'
7861                 standard input and output so that it can log the
7862                 installation process.  Likewise, because these scripts
7863                 may be executed with standard output redirected into a
7864                 pipe for logging purposes, Perl scripts should set
7865                 unbuffered output by setting <tt>$|=1</tt> so that the
7866                 output is printed immediately rather than being
7867                 buffered.
7868               </p>
7869                 
7870               <p>
7871                 Each script should return a zero exit status for
7872                 success, or a nonzero one for failure.</p>
7873             </item>
7874               
7875             <tag><tt>conffiles</tt>
7876             </tag>
7877             <item>
7878               
7879               <p>
7880                 This file contains a list of configuration files which
7881                 are to be handled automatically by <prgn>dpkg</prgn>
7882                 (see <ref id="pkg-conffiles">).  Note that not necessarily
7883                 every configuration file should be listed here.</p>
7884             </item>
7885               
7886             <tag><tt>shlibs</tt>
7887             </tag>
7888             <item>
7889               
7890               <p>
7891                 This file contains a list of the shared libraries
7892                 supplied by the package, with dependency details for
7893                 each.  This is used by <prgn>dpkg-shlibdeps</prgn>
7894                 when it determines what dependencies are required in a
7895                 package control file. The <tt>shlibs</tt> file format
7896                 is described on <ref id="shlibs">.
7897               </p>
7898             </item>
7899           </taglist>
7900         </p>
7901         
7902       <sect id="pkg-controlfile">
7903         <heading>
7904           The main control information file: <tt>control</tt>
7905         </heading>
7906         <p>
7907           The most important control information file used by
7908           <prgn>dpkg</prgn> when it installs a package is
7909           <tt>control</tt>.  It contains all the package's `vital
7910           statistics'.
7911         </p>
7912
7913         <p>       
7914           The binary package control files of packages built from
7915           Debian sources are made by a special tool,
7916           <prgn>dpkg-gencontrol</prgn>, which reads
7917           <file>debian/control</file> and <file>debian/changelog</file> to
7918           find the information it needs.  See <ref id="pkg-sourcepkg"> for
7919           more details.
7920         </p>
7921
7922         <p>       
7923           The fields in binary package control files are:
7924           <list compact="compact">
7925             <item>
7926               <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
7927             </item>
7928             <item>
7929               <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
7930             </item>
7931             <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
7932                 (mandatory)
7933                 <footnote>
7934                   <p>
7935                     This field should appear in all packages, though
7936                     <prgn>dpkg</prgn> doesn't require it yet so that
7937                     old packages can still be installed.
7938                   </p>
7939                 </footnote>
7940               </p>
7941             </item>
7942             <item>
7943               <p><qref id="relationships"><tt>Depends</tt>,
7944                   <tt>Provides</tt> et al.</qref></p>
7945             </item>
7946             <item>
7947               <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
7948             </item>
7949             <item>
7950               <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
7951             </item>
7952             <item>
7953               <p><qref id="pkg-f-classification"><tt>Section</tt>,
7954                   <tt>Priority</tt></qref></p>
7955             </item>
7956             <item>
7957               <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
7958             </item>
7959             <item>
7960               <p><qref id="descriptions"><tt>Description</tt></qref></p>
7961             </item>
7962             <item>
7963               <p>
7964                 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
7965               </p>
7966             </item> 
7967           </list>
7968             
7969         <p>
7970           A description of the syntax of control files and the purpose
7971           of these fields is available in <ref id="pkg-controlfields">.
7972         </p>
7973       </sect>
7974
7975       <sect>
7976         <heading>Time Stamps</heading>
7977         <p>
7978           Maintainers are encouraged to preserve the modification
7979           times of the upstream source files in a package, as far as
7980           is reasonably possible. 
7981           <footnote>
7982             <p>
7983               The rationale is that there is some information conveyed
7984               by knowing the age of the file, for example, you could
7985               recognize that some documentation is very old by looking
7986               at the modification time, so it would be nice if the
7987               modification time of the upstream source would be
7988               preserved.
7989             </p>
7990           </footnote>
7991         </p>
7992       </sect>
7993     </appendix>
7994
7995     <appendix id="pkg-sourcepkg">
7996       <heading>Source packages (from old Packaging Manual) </heading>
7997
7998       <p>       
7999         The Debian binary packages in the distribution are generated
8000         from Debian sources, which are in a special format to assist
8001         the easy and automatic building of binaries.
8002       </p>
8003
8004       <p>       
8005         There was a previous version of the Debian source format,
8006         which is now being phased out.  Instructions for converting an
8007         old-style package are given in the Debian policy manual.
8008       </p>
8009         
8010       <sect id="pkg-sourcetools">
8011         <heading>Tools for processing source packages</heading> 
8012
8013         <p>       
8014           Various tools are provided for manipulating source packages;
8015           they pack and unpack sources and help build of binary
8016           packages and help manage the distribution of new versions.
8017         </p>
8018
8019         <p>       
8020           They are introduced and typical uses described here; see
8021           <manref name="dpkg-source" section="1"> for full
8022           documentation about their arguments and operation.
8023         </p>
8024
8025         <p>       
8026           For examples of how to construct a Debian source package,
8027           and how to use those utilities that are used by Debian
8028           source packages, please see the <prgn>hello</prgn> example
8029           package.
8030         </p>
8031           
8032         <sect1>
8033           <heading>
8034             <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8035             packages
8036           </heading>
8037
8038           <p>       
8039             This program is frequently used by hand, and is also
8040             called from package-independent automated building scripts
8041             such as <prgn>dpkg-buildpackage</prgn>.
8042           </p>
8043
8044           <p>       
8045             To unpack a package it is typically invoked with
8046             <example>
8047   dpkg-source -x <var>.../path/to/filename</var>.dsc
8048             </example> 
8049           </p>
8050
8051            <p>  
8052             with the <file><var>filename</var>.tar.gz</file> and
8053             <file><var>filename</var>.diff.gz</file> (if applicable) in
8054             the same directory.  It unpacks into
8055             <file><var>package</var>-<var>version</var></file>, and if
8056             applicable
8057             <file><var>package</var>-<var>version</var>.orig</file>, in
8058             the current directory.
8059           </p>
8060
8061           <p>       
8062             To create a packed source archive it is typically invoked:
8063             <example>
8064   dpkg-source -b <var>package</var>-<var>version</var>
8065           </example>
8066           </p>
8067
8068           <p>
8069             This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8070             <file>.diff.gz</file> (if appropriate) in the current
8071             directory.  <prgn>dpkg-source</prgn> does not clean the
8072             source tree first - this must be done separately if it is
8073             required.
8074           </p>
8075
8076           <p>       
8077             See also <ref id="pkg-sourcearchives">.</p>
8078         </sect1>
8079           
8080           
8081         <sect1>
8082           <heading>
8083             <prgn>dpkg-buildpackage</prgn> - overall package-building
8084             control script
8085           </heading>
8086
8087           <p>       
8088             <prgn>dpkg-buildpackage</prgn> is a script which invokes
8089             <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8090             targets <tt>clean</tt>, <tt>build</tt> and
8091             <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8092             <prgn>pgp</prgn> to build a signed source and binary
8093             package upload.
8094           </p>
8095
8096           <p>       
8097             It is usually invoked by hand from the top level of the
8098             built or unbuilt source directory.  It may be invoked with
8099             no arguments; useful arguments include:
8100             <taglist compact="compact">
8101               <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8102               <item>
8103                 <p>
8104                   Do not PGP-sign the <tt>.changes</tt> file or the
8105                   source package <tt>.dsc</tt> file, respectively.</p>
8106               </item>
8107               <tag><tt>-p<var>pgp-command</var></tt></tag>
8108               <item>
8109                 <p>
8110                   Invoke <var>pgp-command</var> instead of finding
8111                   <tt>pgp</tt> on the <prgn>PATH</prgn>.
8112                   <var>pgp-command</var> must behave just like
8113                   <prgn>pgp</prgn>.</p>
8114               </item>
8115               <tag><tt>-r<var>root-command</var></tt></tag>
8116               <item>
8117                 <p>
8118                   When root privilege is required, invoke the command
8119                   <var>root-command</var>.  <var>root-command</var>
8120                   should invoke its first argument as a command, from
8121                   the <prgn>PATH</prgn> if necessary, and pass its
8122                   second and subsequent arguments to the command it
8123                   calls.  If no <var>root-command</var> is supplied
8124                   then <var>dpkg-buildpackage</var> will take no
8125                   special action to gain root privilege, so that for
8126                   most packages it will have to be invoked as root to
8127                   start with.</p>
8128               </item>
8129               <tag><tt>-b</tt>, <tt>-B</tt></tag>
8130               <item>
8131                 <p>
8132                   Two types of binary-only build and upload - see
8133                   <manref name="dpkg-source" section="1">.
8134                 </p>
8135               </item>
8136             </taglist>
8137           </p>
8138         </sect1>
8139           
8140         <sect1>
8141           <heading>
8142             <prgn>dpkg-gencontrol</prgn> - generates binary package
8143             control files
8144           </heading>
8145
8146           <p>       
8147             This program is usually called from <file>debian/rules</file>
8148             (see <ref id="pkg-sourcetree">) in the top level of the source
8149             tree.
8150           </p>
8151
8152           <p>       
8153             This is usually done just before the files and directories in the
8154             temporary directory tree where the package is being built have their
8155             permissions and ownerships set and the package is constructed using
8156             <prgn>dpkg-deb/</prgn>
8157               <footnote>
8158               <p>
8159                 This is so that the control file which is produced has
8160                 the right permissions
8161               </p>
8162             </footnote>.
8163           </p>
8164
8165           <p>       
8166             <prgn>dpkg-gencontrol</prgn> must be called after all the
8167             files which are to go into the package have been placed in
8168             the temporary build directory, so that its calculation of
8169             the installed size of a package is correct.
8170           </p>
8171
8172           <p>       
8173             It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8174             be run after <prgn>dpkg-shlibdeps</prgn> so that the
8175             variable substitutions created by
8176             <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8177             are available.
8178           </p>
8179
8180           <p>       
8181             For a package which generates only one binary package, and
8182             which builds it in <file>debian/tmp</file> relative to the top
8183             of the source package, it is usually sufficient to call
8184             <prgn>dpkg-gencontrol</prgn>.
8185           </p>
8186
8187           <p>       
8188             Sources which build several binaries will typically need
8189             something like:
8190             <example>
8191   dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8192             </example> The <tt>-P</tt> tells
8193             <prgn>dpkg-gencontrol</prgn> that the package is being
8194             built in a non-default directory, and the <tt>-p</tt>
8195             tells it which package's control file should be generated.
8196           </p>
8197
8198           <p>       
8199             <prgn>dpkg-gencontrol</prgn> also adds information to the
8200             list of files in <file>debian/files</file>, for the benefit of
8201             (for example) a future invocation of
8202             <prgn>dpkg-genchanges</prgn>.</p>
8203         </sect1>
8204           
8205         <sect1>
8206           <heading>
8207             <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8208             dependencies
8209           </heading>
8210
8211           <p>       
8212             This program is usually called from <file>debian/rules</file>
8213             just before <prgn>dpkg-gencontrol</prgn> (see <ref
8214             id="pkg-sourcetree">), in the top level of the source tree.
8215           </p>
8216
8217           <p>       
8218             Its arguments are executables.
8219             <footnote>
8220               <p>
8221                 In a forthcoming dpkg version,
8222                 <prgn>dpkg-shlibdeps</prgn> would be required to be
8223                 called on shared libraries as well. 
8224               </p>
8225               <p>
8226                 They may be specified either in the locations in the
8227                 source tree where they are created or in the locations
8228                 in the temporary build tree where they are installed
8229                 prior to binary package creation.
8230               </p>
8231             </footnote> for which shared library dependencies should
8232             be included in the binary package's control file.
8233           </p>
8234
8235           <p>       
8236             If some of the found shared libraries should only
8237             warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8238             some warrant a <tt>Pre-Depends</tt>, this can be achieved
8239             by using the <tt>-d<var>dependency-field</var></tt> option
8240             before those executable(s).  (Each <tt>-d</tt> option
8241             takes effect until the next <tt>-d</tt>.)
8242           </p>
8243
8244           <p>       
8245             <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8246             output control file to be modified.  Instead by default it
8247             adds to the <file>debian/substvars</file> file variable
8248             settings like <tt>shlibs:Depends</tt>.  These variable
8249             settings must be referenced in dependency fields in the
8250             appropriate per-binary-package sections of the source
8251             control file.
8252           </p>
8253
8254           <p>       
8255             For example, the <prgn>procps</prgn> package generates two
8256             kinds of binaries, simple C binaries like <prgn>ps</prgn>
8257             which require a predependency and full-screen ncurses
8258             binaries like <prgn>top</prgn> which require only a
8259             recommendation.  It can say in its <file>debian/rules</file>:
8260             <example>
8261   dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8262             </example>
8263             and then in its main control file <file>debian/control</file>:
8264             <example>
8265   <var>...</var>
8266   Package: procps
8267   Pre-Depends: ${shlibs:Pre-Depends}
8268   Recommends: ${shlibs:Recommends}
8269   <var>...</var>
8270             </example>
8271           </p>
8272
8273           <p>       
8274             Sources which produce several binary packages with
8275             different shared library dependency requirements can use
8276             the <tt>-p<var>varnameprefix</var></tt> option to override
8277             the default <tt>shlib:</tt> prefix (one invocation of
8278             <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8279             They can thus produce several sets of dependency
8280             variables, each of the form
8281             <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8282             which can be referred to in the appropriate parts of the
8283             binary package control files.
8284           </p>
8285         </sect1>
8286           
8287           
8288         <sect1>
8289           <heading>
8290             <prgn>dpkg-distaddfile</prgn> - adds a file to
8291             <file>debian/files</file>
8292           </heading>
8293
8294           <p>       
8295             Some packages' uploads need to include files other than
8296             the source and binary package files.
8297           </p>
8298
8299           <p>       
8300             <prgn>dpkg-distaddfile</prgn> adds a file to the
8301             <file>debian/files</file> file so that it will be included in
8302             the <file>.changes</file> file when
8303             <prgn>dpkg-genchanges</prgn> is run.
8304           </p>
8305
8306           <p>       
8307             It is usually invoked from the <tt>binary</tt> target of
8308             <file>debian/rules</file>:
8309             <example>
8310   dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8311             </example>
8312             The <var>filename</var> is relative to the directory where
8313             <prgn>dpkg-genchanges</prgn> will expect to find it - this
8314             is usually the directory above the top level of the source
8315             tree.  The <file>debian/rules</file> target should put the
8316             file there just before or just after calling
8317             <prgn>dpkg-distaddfile</prgn>.
8318           </p>
8319
8320           <p>       
8321             The <var>section</var> and <var>priority</var> are passed
8322             unchanged into the resulting <file>.changes</file> file.  See
8323             <ref id="pkg-f-classification">.
8324           </p>
8325         </sect1>
8326           
8327           
8328         <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8329             control file
8330           </heading>
8331
8332           <p>       
8333             This program is usually called by package-independent
8334             automatic building scripts such as
8335             <prgn>dpkg-buildpackage</prgn>, but it may also be called
8336             by hand.
8337           </p>
8338
8339           <p>       
8340             It is usually called in the top level of a built source
8341             tree, and when invoked with no arguments will print out a
8342             straightforward <file>.changes</file> file based on the
8343             information in the source package's changelog and control
8344             file and the binary and source packages which should have
8345             been built.
8346           </p>
8347         </sect1>
8348           
8349           
8350         <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8351             a changelog
8352           </heading>
8353
8354           <p>       
8355             This program is used internally by
8356             <prgn>dpkg-source</prgn> et al.  It may also occasionally
8357             be useful in <file>debian/rules</file> and elsewhere.  It
8358             parses a changelog, <file>debian/changelog</file> by default,
8359             and prints a control-file format representation of the
8360             information in it to standard output.
8361           </p>
8362         </sect1>
8363  
8364         <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8365             information about the build and host system 
8366           </heading>
8367  
8368           <p>
8369             This program can be used manually, but is also invoked by
8370             <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8371             to set environment or make variables which specify the build and
8372             host architecture for the package building process.
8373           </p>
8374         </sect1>
8375       </sect>
8376         
8377       <sect id="pkg-sourcetree"><heading>The Debianised source tree
8378         </heading>
8379
8380         <p>       
8381           The source archive scheme described later is intended to
8382           allow a Debianised source tree with some associated control
8383           information to be reproduced and transported easily.  The
8384           Debianised source tree is a version of the original program
8385           with certain files added for the benefit of the
8386           Debianisation process, and with any other changes required
8387           made to the rest of the source code and installation
8388           scripts.
8389         </p>
8390
8391         <p>       
8392           The extra files created for Debian are in the subdirectory
8393           <file>debian</file> of the top level of the Debianised source
8394           tree.  They are described below.
8395         </p>
8396           
8397         <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8398         script
8399           </heading>
8400
8401           <p>       
8402             This file is an executable makefile, and contains the
8403             package-specific recipies for compiling the package and
8404             building binary package(s) out of the source.
8405           </p>
8406
8407           <p>       
8408             It must start with the line <tt>#!/usr/bin/make -f</tt>,
8409             so that it can be invoked by saying its name rather than
8410             invoking <prgn>make</prgn> explicitly.
8411           </p>
8412
8413           <p>
8414             Since an interactive <file>debian/rules</file> script makes it
8415             impossible to autocompile that package and also makes it
8416             hard for other people to reproduce the same binary
8417             package, all <strong>required targets</strong> have to be
8418             non-interactive. At a minimul, required targets are the
8419             ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8420             <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8421             <em>build</em>. It also follows that any target that these
8422             targets depend on must also be non-interactive.
8423           </p>
8424
8425           <p>       
8426             The targets which are required to be present are:       
8427             <taglist>
8428               <tag><tt>build</tt></tag>
8429               <item>
8430                 <p>
8431                   This should perform all non-interactive
8432                   configuration and compilation of the package.  If a
8433                   package has an interactive pre-build configuration
8434                   routine, the Debianised source package should be
8435                   built after this has taken place, so that it can be
8436                   built without rerunning the configuration.
8437                 </p>
8438                 
8439                 <p>
8440                   A package may also provide both of the targets
8441                   <tt>build-arch</tt> and <tt>build-indep</tt>.  The
8442                   <tt>build-arch</tt> target, if provided, should
8443                   perform all non-interactive configuration and
8444                   compilation required for producing all
8445                   architecture-dependant binary packages (those packages
8446                   for which the body of the <tt>Architecture</tt> field
8447                   in <tt>debian/control</tt> is not <tt>all</tt>).
8448                   Similarly, the <tt>build-indep</tt> target, if
8449                   provided, should perform all non-interactive
8450                   configuration and compilation required for producing
8451                   all architecture-independent binary packages (those
8452                   packages for which the body of the
8453                   <tt>Architecture</tt> field in <tt>debian/control</tt>
8454                   is <tt>all</tt>).  The <tt>build</tt> target should
8455                   depend on those of the targets <tt>build-arch</tt> and
8456                   <tt>build-indep</tt> that are provided in the rules
8457                   file.
8458                 </p>
8459                 
8460                 <p>               
8461                   If one or both of the targets <tt>build-arch</tt> and
8462                   <tt>build-indep</tt> are not provided, then invoking
8463                   <file>debian/rules</file> with one of the not-provided
8464                   targets as arguments should produce a exit status code
8465                   of 2.  Usually this is provided automatically by make
8466                   if the target is missing.
8467                 </p>
8468                 
8469                 <p>
8470                   For some packages, notably ones where the same
8471                   source tree is compiled in different ways to produce
8472                   two binary packages, the <tt>build</tt> target does
8473                   not make much sense.  For these packages it is good
8474                   enough to provide two (or more) targets
8475                   (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8476                   for each of the ways of building the package, and a
8477                   <tt>build</tt> target that does nothing.  The
8478                   <tt>binary</tt> target will have to build the
8479                   package in each of the possible ways and make the
8480                   binary package out of each.
8481                 </p>
8482
8483                 <p>               
8484                   The targets <tt>build</tt>, <tt>build-arch</tt>
8485                   and <tt>build-indep</tt> target must not do
8486                   anything that might require root privilege.
8487                 </p>
8488
8489                 <p>               
8490                   The <tt>build</tt> target may need to run
8491                   <tt>clean</tt> first - see below.
8492                 </p>
8493
8494                 <p>     
8495                   When a package has a configuration routine that takes
8496                   a long time, or when the makefiles are poorly
8497                   designed, or when <tt>build</tt> needs to run
8498                   <tt>clean</tt> first, it is a good idea to <tt>touch
8499                     build</tt> when the build process is complete.  This
8500                   will ensure that if <tt>debian/rules build</tt> is run
8501                   again it will not rebuild the whole program.
8502                 </p>
8503               </item>
8504                 
8505               <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8506                 <tt>binary-indep</tt>
8507               </tag> 
8508               <item>
8509                 <p>
8510                   The <tt>binary</tt> target should be all that is
8511                   necessary for the user to build the binary
8512                   package. All these targets are required to be
8513                   non-interactive.  It is split into two parts:
8514                   <tt>binary-arch</tt> builds the packages' output
8515                   files which are specific to a particular
8516                   architecture, and <tt>binary-indep</tt> builds
8517                   those which are not.
8518                 </p>
8519
8520                 <p>               
8521                   <tt>binary</tt> should usually be a target with
8522                   no commands which simply depends on
8523                   <prgn>binary-arch</prgn> and
8524                   <prgn>binary-indep</prgn>.
8525                 </p>
8526
8527                 <p>               
8528                   Both <prgn>binary-*</prgn> targets should depend on
8529                   the <tt>build</tt> target, above, so that the
8530                   package is built if it has not been already.  It
8531                   should then create the relevant binary package(s),
8532                   using <prgn>dpkg-gencontrol</prgn> to make their
8533                   control files and <prgn>dpkg-deb</prgn> to build
8534                   them and place them in the parent of the top level
8535                   directory.
8536                 </p>
8537
8538                 <p>               
8539                   If one of the <prgn>binary-*</prgn> targets has
8540                   nothing to do (this will be always be the case if
8541                   the source generates only a single binary package,
8542                   whether architecture-dependent or not) it
8543                   <em>must</em> still exist, but should always
8544                   succeed.
8545                 </p>
8546
8547                 <p>               
8548                   <ref id="pkg-binarypkg"> describes how to construct
8549                   binary packages.
8550                 </p>
8551
8552                 <p>               
8553                   The <tt>binary</tt> targets must be invoked as
8554                   root.
8555                 </p>
8556               </item>
8557                 
8558               <tag><tt>clean</tt></tag>
8559               <item>
8560                 
8561                 <p>
8562                   This should undo any effects that the
8563                   <tt>build</tt> and <tt>binary</tt> targets
8564                   may have had, except that it should leave alone any
8565                   output files created in the parent directory by a
8566                   run of <tt>binary</tt>. This target is required
8567                   to be non-interactive.
8568                 </p>
8569
8570                 <p>               
8571                   If a <tt>build</tt> file is touched at the end
8572                   of the <tt>build</tt> target, as suggested
8573                   above, it must be removed as the first thing that
8574                   <tt>clean</tt> does, so that running
8575                   <tt>build</tt> again after an interrupted
8576                   <tt>clean</tt> doesn't think that everything is
8577                   already done.
8578                 </p>
8579
8580                 <p>               
8581                   The <tt>clean</tt> target must be invoked as
8582                   root if <tt>binary</tt> has been invoked since
8583                   the last <tt>clean</tt>, or if
8584                   <tt>build</tt> has been invoked as root (since
8585                   <tt>build</tt> may create directories, for
8586                   example).
8587                 </p>
8588               </item>
8589                 
8590               <tag><tt>get-orig-source</tt> (optional)</tag>
8591               <item>
8592                 
8593                 <p>
8594                   This target fetches the most recent version of the
8595                   original source package from a canonical archive
8596                   site (via FTP or WWW, for example), does any
8597                   necessary rearrangement to turn it into the original
8598                   source tarfile format described below, and leaves it
8599                   in the current directory.
8600                 </p>
8601
8602                 <p>               
8603                   This target may be invoked in any directory, and
8604                   should take care to clean up any temporary files it
8605                   may have left.
8606                 </p>
8607
8608                 <p>               
8609                   This target is optional, but providing it if
8610                   possible is a good idea.
8611                 </p>
8612               </item>
8613             </taglist>
8614               
8615           <p>
8616             The <tt>build</tt>, <tt>binary</tt> and
8617             <tt>clean</tt> targets must be invoked with a current
8618             directory of the package's top-level directory.
8619           </p>
8620             
8621
8622           <p>       
8623             Additional targets may exist in <file>debian/rules</file>,
8624             either as published or undocumented interfaces or for the
8625             package's internal use.
8626           </p>
8627  
8628           <p>
8629             The architecture we build on and build for is determined by make
8630             variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8631             get the Debian architecture and the GNU style architecture
8632             specification string for the build machine as well as the host
8633             machine. Here is a list of supported make variables:
8634             <list compact="compact">
8635               <item>
8636                 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8637               </item>
8638               <item>
8639                 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8640                   specification string)</p> 
8641               </item>
8642               <item>
8643                 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8644               </item>
8645               <item>
8646                 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8647                   DEB_*_GNU_TYPE)</p>
8648             </list>
8649           </p>
8650  
8651           <p>
8652             where <tt>*</tt> is either <tt>BUILD</tt> for specification of
8653             the build machine or <tt>HOST</tt> for specification of the machine
8654             we build for.
8655           </p>
8656           
8657           <p>
8658             Backward compatibility can be provided in the rules file
8659             by setting the needed variables to suitable default
8660             values, please refer to the documentation of
8661             dpkg-architecture for details.
8662           </p>
8663  
8664           <p>
8665             It is important to understand that the <tt>DEB_*_ARCH</tt>
8666             string does only determine which Debian architecture we
8667             build on resp. for. It should not be used to get the CPU
8668             or System information, the GNU style variables should be
8669             used for that.
8670           </p>
8671         </sect1>
8672           
8673           
8674         <sect1><heading><file>debian/control</file>
8675           </heading>
8676
8677           <p>       
8678             This file contains version-independent details about the
8679             source package and about the binary packages it creates.
8680           </p>
8681
8682           <p>       
8683             It is a series of sets of control fields, each
8684             syntactically similar to a binary package control file.
8685             The sets are separated by one or more blank lines.  The
8686             first set is information about the source package in
8687             general; each subsequent set describes one binary package
8688             that the source tree builds.
8689           </p>
8690
8691           <p>       
8692             The syntax and semantics of the fields are described below
8693             in <ref id="pkg-controlfields">.
8694           </p>
8695
8696           <p>       
8697             The general (binary-package-independent) fields are:
8698             <list compact="compact">
8699               <item>
8700                 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
8701               </item>
8702               <item>
8703                 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8704               </item>
8705               <item>
8706                 <p>
8707                   <qref id="pkg-f-classification"><tt>Section</tt> and
8708                     <tt>Priority</tt></qref> 
8709                   (classification, mandatory)
8710                 </p>
8711               </item>
8712                <item>
8713                  <p>
8714                    <qref id="relationships"><tt>Build-Depends</tt> et
8715                      al.</qref> (source package interrelationships)
8716                  </p>
8717                </item>
8718               <item>
8719                 <p>
8720                   <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
8721                 </p>
8722               </item> 
8723             </list>
8724
8725           <p>       
8726             The per-binary-package fields are:
8727             <list compact="compact">
8728               <item>
8729                 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8730               </item>
8731               <item>
8732                 <p>
8733                   <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8734                   (mandatory)</p>
8735               </item>
8736               <item>
8737                 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8738               </item>
8739               <item>
8740                 <p>
8741                   <qref id="pkg-f-classification"><tt>Section</tt> and
8742                     <tt>Priority</tt></qref> (classification)</p>
8743               </item>
8744               <item>
8745                 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8746               </item>
8747               <item>
8748                 <p>
8749                   <qref id="relationships"><tt>Depends</tt> et
8750                   al.</qref> (binary package interrelationships)
8751                 </p>
8752               </item>
8753             </list>
8754
8755           <p>       
8756             These fields are used by <prgn>dpkg-gencontrol</prgn> to
8757             generate control files for binary packages (see below), by
8758             <prgn>dpkg-genchanges</prgn> to generate the
8759             <tt>.changes</tt> file to accompany the upload, and by
8760             <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
8761             source control file as part of a source archive.
8762           </p>
8763
8764           <p>       
8765             The fields here may contain variable references - their
8766             values will be substituted by
8767             <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
8768             or <prgn>dpkg-source</prgn> when they generate output
8769             control files.  See <ref id="pkg-srcsubstvars"> for details.
8770           </p>
8771
8772           <p> <sect2><heading>User-defined fields
8773             </heading>
8774
8775             <p>       
8776               Additional user-defined fields may be added to the
8777               source package control file.  Such fields will be
8778               ignored, and not copied to (for example) binary or
8779               source package control files or upload control files.
8780             </p>
8781
8782             <p>       
8783               If you wish to add additional unsupported fields to
8784               these output files you should use the mechanism
8785               described here.
8786             </p>
8787
8788             <p>       
8789               Fields in the main source control information file with
8790               names starting <tt>X</tt>, followed by one or more of
8791               the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
8792               be copied to the output files.  Only the part of the
8793               field name after the hyphen will be used in the output
8794               file.  Where the letter <tt>B</tt> is used the field
8795               will appear in binary package control files, where the
8796               letter <tt>S</tt> is used in source package control
8797               files and where <tt>C</tt> is used in upload control
8798               (<tt>.changes</tt>) files.
8799             </p>
8800
8801             <p>       
8802               For example, if the main source information control file
8803               contains the field
8804               <example>
8805   XBS-Comment: I stand between the candle and the star.
8806               </example>
8807               then the binary and source package control files will contain the
8808               field
8809               <example>
8810   Comment: I stand between the candle and the star.
8811               </example>
8812             </p>
8813           </sect2>
8814         
8815         </sect1>
8816
8817         <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
8818           </heading>
8819
8820           <p>       
8821             This file records the changes to the Debian-specific parts of the
8822             package
8823             <footnote>
8824               <p>
8825                 Though there is nothing stopping an author who is also
8826                 the Debian maintainer from using it for all their
8827                 changes, it will have to be renamed if the Debian and
8828                 upstream maintainers become different
8829                 people.
8830               </p>
8831             </footnote>.
8832           </p>
8833
8834           <p>       
8835             It has a special format which allows the package building
8836             tools to discover which version of the package is being
8837             built and find out other release-specific information.
8838           </p>
8839
8840           <p>
8841             That format is a series of entries like this:       
8842             <example>
8843   <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
8844
8845    * <var>change details</var>
8846    <var>more change details</var>
8847    * <var>even more change details</var>
8848               
8849   -- <var>maintainer name and email address</var>  <var>date</var>
8850             </example>
8851           </p>
8852
8853           <p>       
8854             <var>package</var> and <var>version</var> are the source
8855             package name and version number.
8856           </p> 
8857
8858           <p>       
8859             <var>distribution(s)</var> lists the distributions where
8860             this version should be installed when it is uploaded - it
8861             is copied to the <tt>Distribution</tt> field in the
8862             <tt>.changes</tt> file.  See <ref id="pkg-f-Distribution">.
8863           </p>
8864
8865           <p>       
8866             <var>urgency</var> is the value for the <tt>Urgency</tt>
8867             field in the <file>.changes</file> file for the upload.  See
8868             <ref id="pkg-f-Urgency">.  It is not possible to specify an
8869             urgency containing commas; commas are used to separate
8870             <tt><var>keyword</var>=<var>value</var></tt> settings in
8871             the <prgn>dpkg</prgn> changelog format (though there is
8872             currently only one useful <var>keyword</var>,
8873             <tt>urgency</tt>).
8874           </p>
8875
8876           <p>       
8877             The change details may in fact be any series of lines
8878             starting with at least two spaces, but conventionally each
8879             change starts with an asterisk and a separating space and
8880             continuation lines are indented so as to bring them in
8881             line with the start of the text above.  Blank lines may be
8882             used here to separate groups of changes, if desired.
8883           </p>
8884
8885           <p>       
8886             The maintainer name and email address should <em>not</em>
8887             necessarily be those of the usual package maintainer.
8888             They should be the details of the person doing
8889             <em>this</em> version.  The information here will be
8890             copied to the <file>.changes</file> file, and then later used
8891             to send an acknowledgement when the upload has been
8892             installed.
8893           </p>
8894
8895           <p>       
8896             The <var>date</var> should be in RFC822 format
8897             <footnote>
8898               <p>
8899                 This is generated by the <prgn>822-date</prgn>
8900                 program.
8901               </p>
8902             </footnote>; it should include the timezone specified
8903             numerically, with the timezone name or abbreviation
8904             optionally present as a comment.
8905           </p>
8906
8907           <p>       
8908             The first `title' line with the package name should start
8909             at the left hand margin; the `trailer' line with the
8910             maintainer and date details should be preceded by exactly
8911             one space.  The maintainer details and the date must be
8912             separated by exactly two spaces.
8913           </p>
8914
8915           <p>       
8916             An Emacs mode for editing this format is available: it is
8917             called <tt>debian-changelog-mode</tt>.  You can have this
8918             mode selected automatically when you edit a Debian
8919             changelog by adding a local variables clause to the end of
8920             the changelog.
8921           </p>
8922             
8923           <sect2><heading>Defining alternative changelog formats
8924             </heading>
8925
8926             <p>       
8927               It is possible to use a different format to the standard
8928               one, by providing a parser for the format you wish to
8929               use.
8930             </p>
8931
8932             <p>       
8933               In order to have <tt>dpkg-parsechangelog</tt> run your
8934               parser, you must include a line within the last 40 lines
8935               of your file matching the Perl regular expression:
8936               <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
8937               parentheses should be the name of the format.  For
8938               example, you might say:
8939               <example>
8940   @@@ changelog-format: joebloggs @@@
8941               </example>
8942               Changelog format names are non-empty strings of alphanumerics.
8943             </p>
8944
8945             <p>       
8946               If such a line exists then <tt>dpkg-parsechangelog</tt>
8947               will look for the parser as
8948               <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
8949               or
8950               <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
8951               it is an error for it not to find it, or for it not to
8952               be an executable program.  The default changelog format
8953               is <tt>dpkg</tt>, and a parser for it is provided with
8954               the <tt>dpkg</tt> package.
8955             </p>
8956
8957             <p>       
8958               The parser will be invoked with the changelog open on
8959               standard input at the start of the file.  It should read
8960               the file (it may seek if it wishes) to determine the
8961               information required and return the parsed information
8962               to standard output in the form of a series of control
8963               fields in the standard format.  By default it should
8964               return information about only the most recent version in
8965               the changelog; it should accept a
8966               <tt>-v<var>version</var></tt> option to return changes
8967               information from all versions present <em>strictly
8968               after</em> <var>version</var>, and it should then be an
8969               error for <var>version</var> not to be present in the
8970               changelog.
8971             </p>
8972
8973             <p>       
8974               The fields are:
8975               <list compact="compact">
8976                 <item>
8977                   <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8978                 </item>
8979                 <item>
8980                   <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8981                 </item>
8982                 <item>
8983                   <p>
8984                     <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
8985                     (mandatory)
8986                   </p> 
8987                 </item>
8988                 <item>
8989                   <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
8990                 </item>
8991                 <item>
8992                   <p>
8993                     <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
8994                     (mandatory)
8995                   </p>
8996                 </item>
8997                 <item>
8998                   <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
8999                 </item>
9000                 <item>
9001                   <p>
9002                     <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9003                     (mandatory)
9004                   </p>
9005                 </item>
9006               </list>
9007
9008             <p>       
9009               If several versions are being returned (due to the use
9010               of <tt>-v</tt>), the urgency value should be of the
9011               highest urgency code listed at the start of any of the
9012               versions requested followed by the concatenated
9013               (space-separated) comments from all the versions
9014               requested; the maintainer, version, distribution and
9015               date should always be from the most recent version.
9016             </p>
9017
9018             <p>       
9019               For the format of the <tt>Changes</tt> field see <ref
9020               id="pkg-f-Changes">.
9021             </p>
9022
9023             <p>       
9024               If the changelog format which is being parsed always or
9025               almost always leaves a blank line between individual
9026               change notes these blank lines should be stripped out,
9027               so as to make the resulting output compact.
9028             </p>
9029
9030             <p>       
9031               If the changelog format does not contain date or package
9032               name information this information should be omitted from
9033               the output.  The parser should not attempt to synthesise
9034               it or find it from other sources.
9035             </p>
9036
9037             <p>       
9038               If the changelog does not have the expected format the
9039               parser should exit with a nonzero exit status, rather
9040               than trying to muddle through and possibly generating
9041               incorrect output.
9042             </p>
9043
9044             <p>       
9045               A changelog parser may not interact with the user at
9046               all.</p></sect2>
9047         </sect1>
9048           
9049         <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9050         and variable substitutions
9051           </heading>
9052
9053           <p>       
9054             When <prgn>dpkg-gencontrol</prgn>,
9055             <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9056             generate control files they do variable substitutions on
9057             their output just before writing it.  Variable
9058             substitutions have the form
9059             <tt>${<var>variable-name</var>}</tt>.  The optional file
9060             <file>debian/substvars</file> contains variable substitutions
9061             to be used; variables can also be set directly from
9062             <file>debian/rules</file> using the <tt>-V</tt> option to the
9063             source packaging commands, and certain predefined
9064             variables are available.
9065           </p>
9066
9067           <p>       
9068             The is usually generated and modified dynamically by
9069             <file>debian/rules</file> targets; in this case it must be
9070             removed by the <tt>clean</tt> target.
9071           </p>
9072
9073           <p>
9074             See <manref name="dpkg-source" section="1"> for full
9075             details about source variable substitutions, including the
9076             format of <file>debian/substvars</file>.</p>
9077         </sect1>
9078           
9079         <sect1><heading><file>debian/files</file>
9080           </heading>
9081
9082           <p>       
9083             This file is not a permanent part of the source tree; it
9084             is used while building packages to record which files are
9085             being generated.  <prgn>dpkg-genchanges</prgn> uses it
9086             when it generates a <file>.changes</file> file.
9087           </p>
9088
9089           <p>       
9090             It should not exist in a shipped source package, and so it
9091             (and any backup files or temporary files such as
9092             <file>files.new</file>
9093               <footnote>
9094                 <p>
9095                   <file>files.new</file> is used as a temporary file by
9096                   <prgn>dpkg-gencontrol</prgn> and
9097                   <prgn>dpkg-distaddfile</prgn> - they write a new
9098                   version of <file>files</file> here before renaming it,
9099                   to avoid leaving a corrupted copy if an error
9100                   occurs
9101                 </p>
9102               </footnote>) should be removed by the
9103               <tt>clean</tt> target.  It may also be wise to
9104               ensure a fresh start by emptying or removing it at the
9105               start of the <tt>binary</tt> target.
9106           </p>
9107
9108           <p>       
9109             <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9110             for the <file>.deb</file> file that will be created by
9111             <prgn>dpkg-deb</prgn> from the control file that it
9112             generates, so for most packages all that needs to be done
9113             with this file is to delete it in <tt>clean</tt>.
9114           </p>
9115
9116           <p>       
9117             If a package upload includes files besides the source
9118             package and any binary packages whose control files were
9119             made with <prgn>dpkg-gencontrol</prgn> then they should be
9120             placed in the parent of the package's top-level directory
9121             and <prgn>dpkg-distaddfile</prgn> should be called to add
9122             the file to the list in <file>debian/files</file>.</p>
9123         </sect1>
9124           
9125         <sect1><heading><file>debian/tmp</file>
9126           </heading>
9127
9128           <p>       
9129             This is the canonical temporary location for the
9130             construction of binary packages by the <tt>binary</tt>
9131             target.  The directory <file>tmp</file> serves as the root of
9132             the filesystem tree as it is being constructed (for
9133             example, by using the package's upstream makefiles install
9134             targets and redirecting the output there), and it also
9135             contains the <tt>DEBIAN</tt> subdirectory.  See <ref
9136             id="pkg-bincreating">.
9137           </p>
9138
9139           <p>       
9140             If several binary packages are generated from the same
9141             source tree it is usual to use several
9142             <file>debian/tmp<var>something</var></file> directories, for
9143             example <file>tmp-a</file> or <file>tmp-doc</file>.
9144           </p>
9145
9146           <p>       
9147             Whatever <file>tmp</file> directories are created and used by
9148             <tt>binary</tt> must of course be removed by the
9149             <tt>clean</tt> target.</p></sect1>
9150       </sect>
9151         
9152         
9153       <sect id="pkg-sourcearchives"><heading>Source packages as archives
9154         </heading>
9155
9156         <p>       
9157           As it exists on the FTP site, a Debian source package
9158           consists of three related files.  You must have the right
9159           versions of all three to be able to use them.
9160         </p>
9161
9162         <p>       
9163           <taglist>
9164             <tag>Debian source control file - <tt>.dsc</tt></tag>
9165             <item>
9166               
9167               <p>
9168                 This file contains a series of fields, identified and
9169                 separated just like the fields in the control file of
9170                 a binary package.  The fields are listed below; their
9171                 syntax is described above, in <ref id="pkg-controlfields">.
9172                 <list compact="compact">
9173                   <item>
9174                     <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9175                   </item>
9176                   <item>
9177                     <p><qref id="versions"><tt>Version</tt></qref></p>
9178                   </item>
9179                   <item>
9180                     <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9181                   </item>
9182                   <item>
9183                     <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9184                   </item>
9185                   <item>
9186                     <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9187                   </item>
9188                   <item>
9189                      <p>
9190                        <qref id="relationships"><tt>Build-Depends</tt> et
9191                          al.</qref> (source package interrelationships)
9192                      </p>
9193                   </item>
9194                   <item>
9195                     <p>
9196                       <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9197                   </item>
9198                   <item>
9199                     <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9200                   </item>
9201                 </list>
9202
9203               <p>               
9204                 The source package control file is generated by
9205                 <prgn>dpkg-source</prgn> when it builds the source
9206                 archive, from other files in the source package,
9207                 described above.  When unpacking it is checked against
9208                 the files and directories in the other parts of the
9209                 source package, as described below.</p>
9210             </item>
9211               
9212             <tag>
9213               Original source archive -
9214               <file>
9215                 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9216               </file>
9217             </tag> 
9218
9219             <item>
9220               
9221               <p>
9222                 This is a compressed (with <tt>gzip -9</tt>)
9223                 <prgn>tar</prgn> file containing the source code from
9224                 the upstream authors of the program.  The tarfile
9225                 unpacks into a directory
9226                 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9227                 and does not contain files anywhere other than in
9228                 there or in its subdirectories.</p>
9229             </item>
9230               
9231             <tag>
9232               Debianisation diff -
9233               <file>
9234                 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9235               </file>
9236             </tag> 
9237             <item>
9238               
9239               <p>
9240                 This is a unified context diff (<tt>diff -u</tt>)
9241                 giving the changes which are required to turn the
9242                 original source into the Debian source.  These changes
9243                 may only include editing and creating plain files.
9244                 The permissions of files, the targets of symbolic
9245                 links and the characteristics of special files or
9246                 pipes may not be changed and no files may be removed
9247                 or renamed.
9248               </p>
9249
9250               <p>               
9251                 All the directories in the diff must exist, except the
9252                 <file>debian</file> subdirectory of the top of the source
9253                 tree, which will be created by
9254                 <prgn>dpkg-source</prgn> if necessary when unpacking.
9255               </p>
9256
9257               <p>               
9258                 The <prgn>dpkg-source</prgn> program will
9259                 automatically make the <file>debian/rules</file> file
9260                 executable (see below).</p></item>
9261           </taglist>
9262             
9263
9264         <p>       
9265           If there is no original source code - for example, if the
9266           package is specially prepared for Debian or the Debian
9267           maintainer is the same as the upstream maintainer - the
9268           format is slightly different: then there is no diff, and the
9269           tarfile is named
9270           <file><var>package</var>_<var>version</var>.tar.gz</file> and
9271           contains a directory
9272           <file><var>package</var>-<var>version</var></file>.
9273         </p>
9274       </sect>
9275         
9276       <sect><heading>Unpacking a Debian source package without
9277       <prgn>dpkg-source</prgn>
9278         </heading>
9279
9280         <p>       
9281           <tt>dpkg-source -x</tt> is the recommended way to unpack a
9282           Debian source package.  However, if it is not available it
9283           is possible to unpack a Debian source archive as follows:
9284         <enumlist compact="compact">
9285           <item> 
9286             <p>
9287               Untar the tarfile, which will create a <file>.orig</file>
9288               directory.</p>
9289           </item>
9290           <item>
9291             <p>Rename the <file>.orig</file> directory to
9292               <file><var>package</var>-<var>version</var></file>.</p>
9293           </item>
9294             <item>
9295             <p>
9296               Create the subdirectory <file>debian</file> at the top of
9297               the source tree.</p>
9298           </item>
9299           <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9300           </item>
9301           <item><p>Untar the tarfile again if you want a copy of the original
9302               source code alongside the Debianised version.</p>
9303           </item>
9304         </enumlist>
9305         
9306         <p>       
9307           It is not possible to generate a valid Debian source archive
9308           without using <prgn>dpkg-source</prgn>.  In particular,
9309           attempting to use <prgn>diff</prgn> directly to generate the
9310           <file>.diff.gz</file> file will not work.
9311         </p>
9312           
9313         <sect1><heading>Restrictions on objects in source packages
9314           </heading>
9315
9316           <p>       
9317             The source package may not contain any hard links
9318             <footnote>
9319               <p>
9320                 This is not currently detected when building source
9321                 packages, but only when extracting
9322                 them.
9323               </p>
9324             </footnote>
9325             <footnote>
9326               <p>
9327                 Hard links may be permitted at some point in the
9328                 future, but would require a fair amount of
9329                 work.
9330               </p>
9331             </footnote>, device special files, sockets or setuid or
9332             setgid files.
9333             <footnote>
9334               <p>
9335                 Setgid directories are allowed.
9336               </p>
9337             </footnote>
9338           </p>
9339
9340           <p>       
9341             The source packaging tools manage the changes between the
9342             original and Debianised source using <prgn>diff</prgn> and
9343             <prgn>patch</prgn>.  Turning the original source tree as
9344             included in the <file>.orig.tar.gz</file> into the debianised
9345             source must not involve any changes which cannot be
9346             handled by these tools.  Problematic changes which cause
9347             <prgn>dpkg-source</prgn> to halt with an error when
9348             building the source package are:
9349             <list compact="compact">
9350               <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9351               </item>
9352               <item><p>Changing the targets of symbolic links.</p>
9353               </item>
9354               <item><p>Creating directories, other than <file>debian</file>.</p>
9355               </item>
9356               <item><p>Changes to the contents of binary files.</p></item>
9357             </list> Changes which cause <prgn>dpkg-source</prgn> to
9358             print a warning but continue anyway are:
9359             <list compact="compact">
9360               <item>
9361                 <p>
9362                   Removing files, directories or symlinks.
9363                   <footnote>
9364                     <p>
9365                       Renaming a file is not treated specially - it is
9366                       seen as the removal of the old file (which
9367                       generates a warning, but is otherwise ignored),
9368                       and the creation of the new
9369                       one.</p>
9370                   </footnote>
9371                 </p>
9372               </item>
9373               <item>
9374                 <p>
9375                   Changed text files which are missing the usual final
9376                   newline (either in the original or the modified
9377                   source tree).
9378                 </p>
9379               </item>
9380             </list>
9381             Changes which are not represented, but which are not detected by
9382             <prgn>dpkg-source</prgn>, are:
9383             <list compact="compact">
9384               <item><p>Changing the permissions of files (other than
9385                   <file>debian/rules</file>) and directories.</p></item>
9386             </list>
9387           </p>
9388
9389           <p>       
9390             The <file>debian</file> directory and <file>debian/rules</file>
9391             are handled specially by <prgn>dpkg-source</prgn> - before
9392             applying the changes it will create the <file>debian</file>
9393             directory, and afterwards it will make
9394             <file>debian/rules</file> world-exectuable.
9395           </p>
9396         </sect1>
9397       </sect>
9398     </appendix>
9399
9400     <appendix id="pkg-controlfields"><heading>Control files and their
9401         fields (from old Packaging Manual)
9402       </heading>
9403
9404       <p>       
9405         Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9406         data in a common format, known as control files.  Binary and
9407         source packages have control data as do the <file>.changes</file>
9408         files which control the installation of uploaded files, and
9409         <prgn>dpkg</prgn>'s internal databases are in a similar
9410         format.
9411       </p>
9412         
9413       <sect><heading>Syntax of control files
9414         </heading>
9415
9416         <p>       
9417           A file consists of one or more paragraphs of fields.  The
9418           paragraphs are separated by blank lines.  Some control files
9419           only allow one paragraph; others allow several, in which
9420           case each paragraph often refers to a different package.
9421         </p>
9422
9423         <p>       
9424           Each paragraph is a series of fields and values; each field
9425           consists of a name, followed by a colon and the value.  It
9426           ends at the end of the line.  Horizontal whitespace (spaces
9427           and tabs) may occur before or after the value and is ignored
9428           there; it is conventional to put a single space after the
9429           colon.
9430         </p>
9431
9432         <p>       
9433           Some fields' values may span several lines; in this case
9434           each continuation line <em>must</em> start with a space or
9435           tab.  Any trailing spaces or tabs at the end of individual
9436           lines of a field value are ignored.
9437         </p>
9438
9439         <p>       
9440           Except where otherwise stated only a single line of data is
9441           allowed and whitespace is not significant in a field body.
9442           Whitespace may never appear inside names (of packages,
9443           architectures, files or anything else), version numbers or
9444           in between the characters of multi-character version
9445           relationships.
9446         </p>
9447
9448         <p>       
9449           Field names are not case-sensitive, but it is usual to
9450           capitalise the field names using mixed case as shown below.
9451         </p>
9452
9453         <p>       
9454           Blank lines, or lines consisting only of spaces and tabs,
9455           are not allowed within field values or between fields - that
9456           would mean a new paragraph.
9457         </p>
9458
9459         <p>       
9460           It is important to note that there are several fields which
9461           are optional as far as <prgn>dpkg</prgn> and the related
9462           tools are concerned, but which must appear in every Debian
9463           package, or whose omission may cause problems.  When writing
9464           the control files for Debian packages you <em>must</em> read
9465           the Debian policy manual in conjuction with the details
9466           below and the list of fields for the particular file.</p>
9467       </sect>
9468         
9469       <sect><heading>List of fields
9470         </heading>
9471           
9472         <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9473           </heading>
9474
9475           <p>       
9476             The name of the binary package.  Package names consist of
9477             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9478             (plus, minus and full stop).
9479             <footnote>
9480               <p>
9481                 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9482                 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9483                 and underscore) used to be legal and are still
9484                 accepted when found in a package file, but may not be
9485                 used in new packages
9486               </p>
9487             </footnote>
9488           </p>
9489
9490           <p>       
9491             They must be at least two characters and must start with
9492             an alphanumeric.  In current versions of dpkg they are
9493             sort of case-sensitive<footnote><p>This is a
9494             bug.</p></footnote>; use lowercase package names unless
9495             the package you're building (or referring to, in other
9496             fields) is already using uppercase.</p>
9497         </sect1>
9498           
9499         <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9500           </heading>
9501
9502           <p>       
9503             This lists the source or binary package's version number -
9504             see <ref id="versions">.
9505           </p>
9506
9507         </sect1>
9508           
9509         <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9510           </heading>
9511
9512           <p>       
9513             This is the architecture string; it is a single word for
9514             the Debian architecture.
9515           </p>
9516
9517           <p>       
9518             <prgn>dpkg</prgn> will check the declared architecture of
9519             a binary package against its own compiled-in value before
9520             it installs it.
9521           </p>
9522
9523           <p>       
9524             The special value <tt>all</tt> indicates that the package
9525             is architecture-independent.
9526           </p>
9527
9528           <p>       
9529             In the main <file>debian/control</file> file in the source
9530             package, or in the source package control file
9531             <file>.dsc</file>, a list of architectures (separated by
9532             spaces) is also allowed, as is the special value
9533             <tt>any</tt>.  A list indicates that the source will build
9534             an architecture-dependent package, and will only work
9535             correctly on the listed architectures.  <tt>any</tt>
9536             indicates that though the source package isn't dependent
9537             on any particular architecture and should compile fine on
9538             any one, the binary package(s) produced are not
9539             architecture-independent but will instead be specific to
9540             whatever the current build architecture is.
9541           </p>
9542
9543           <p>       
9544             In a <file>.changes</file> file the <tt>Architecture</tt>
9545             field lists the architecture(s) of the package(s)
9546             currently being uploaded.  This will be a list; if the
9547             source for the package is being uploaded too the special
9548             entry <tt>source</tt> is also present.
9549           </p>
9550
9551           <p>       
9552             See <ref id="pkg-debianrules"> for information how to get the
9553             architecture for the build process. 
9554           </p>
9555         </sect1>
9556           
9557         <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9558           </heading>
9559
9560           <p>       
9561             The package maintainer's name and email address.  The name
9562             should come first, then the email address inside angle
9563             brackets <tt>&lt;&gt</tt> (in RFC822 format).
9564           </p>
9565
9566           <p>       
9567             If the maintainer's name contains a full stop then the
9568             whole field will not work directly as an email address due
9569             to a misfeature in the syntax specified in RFC822; a
9570             program using this field as an address must check for this
9571             and correct the problem if necessary (for example by
9572             putting the name in round brackets and moving it to the
9573             end, and bringing the email address forward).
9574           </p>
9575
9576           <p>       
9577             In a <file>.changes</file> file or parsed changelog data this
9578             contains the name and email address of the person
9579             responsible for the particular version in question - this
9580             may not be the package's usual maintainer.
9581           </p>
9582
9583           <p>       
9584             This field is usually optional in as far as the
9585             <prgn>dpkg</prgn> are concerned, but its absence when
9586             building packages usually generates a warning.</p>
9587         </sect1>
9588           
9589         <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9590           </heading>
9591
9592           <p>       
9593             This field identifies the source package name.
9594           </p>
9595
9596           <p>       
9597             In a main source control information or a
9598             <file>.changes</file> or <file>.dsc</file> file or parsed
9599             changelog data this may contain only the name of the
9600             source package.
9601           </p>
9602
9603           <p>       
9604             In the control file of a binary package (or in a
9605             <file>Packages</file> file) it may be followed by a version
9606             number in parentheses.
9607             <footnote>
9608               <p>
9609                 It is usual to leave a space after the package name if
9610                 a version number is specified.
9611               </p>
9612             </footnote> This version number may be omitted (and is, by
9613             <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9614             the <tt>Version</tt> field of the binary package in
9615             question.  The field itself may be omitted from a binary
9616             package control file when the source package has the same
9617             name and version as the binary package.
9618           </p>
9619         </sect1>
9620           
9621         <sect1><heading>Package interrelationship fields:
9622             <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9623             <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9624             <tt>Provides</tt>, <tt>Replaces</tt>
9625           </heading>
9626
9627           <p>       
9628             These fields describe the package's relationships with
9629             other packages.  Their syntax and semantics are described
9630             in <ref id="relationships">.</p>
9631         </sect1>
9632           
9633         <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9634           </heading>
9635
9636           <p>       
9637             In a binary package <tt>Packages</tt> file or main source
9638             control file this field contains a description of the
9639             binary package, in a special format.  See <ref
9640             id="descriptions"> for details.
9641           </p>
9642
9643           <p>       
9644             In a <file>.changes</file> file it contains a summary of the
9645             descriptions for the packages being uploaded.  The part of
9646             the field before the first newline is empty; thereafter
9647             each line has the name of a binary package and the summary
9648             description line from that binary package.  Each line is
9649             indented by one space.</p>
9650         </sect1>
9651           
9652         <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
9653           </heading>
9654
9655           <p>       
9656             This is a boolean field which may occur only in the
9657             control file of a binary package (or in the
9658             <file>Packages</file> file) or in a per-package fields
9659             paragraph of a main source control data file.
9660           </p>
9661
9662           <p>       
9663             If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
9664             <prgn>dselect</prgn> will refuse to remove the package
9665             (though it can be upgraded and/or replaced).  The other
9666             possible value is <tt>no</tt>, which is the same as not
9667             having the field at all.</p>
9668         </sect1>
9669           
9670         <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
9671         <tt>Priority</tt>
9672           </heading>
9673
9674           <p>       
9675             These two fields classify the package.  The
9676             <tt>Priority</tt> represents how important that it is that
9677             the user have it installed; the <tt>Section</tt>
9678             represents an application area into which the package has
9679             been classified.
9680           </p>
9681
9682           <p>       
9683             When they appear in the <file>debian/control</file> file these
9684             fields give values for the section and priority subfields
9685             of the <tt>Files</tt> field of the <file>.changes</file> file,
9686             and give defaults for the section and priority of the
9687             binary packages.
9688           </p>
9689
9690           <p>       
9691             The section and priority are represented, though not as
9692             separate fields, in the information for each file in the
9693             <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
9694             <file>.changes</file> file.  The section value in a
9695             <file>.changes</file> file is used to decide where to install
9696             a package in the FTP archive.
9697           </p>
9698
9699           <p>       
9700             These fields are not used by by <prgn>dpkg</prgn> proper,
9701             but by <prgn>dselect</prgn> when it sorts packages and
9702             selects defaults.  See the Debian policy manual for the
9703             priorities in use and the criteria for selecting the
9704             priority for a Debian package, and look at the Debian FTP
9705             archive for a list of currently in-use priorities.
9706           </p>
9707
9708           <p>       
9709             These fields may appear in binary package control files,
9710             in which case they provide a default value in case the
9711             <file>Packages</file> files are missing the information.
9712             <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
9713             the value from a <file>.deb</file> file if they have no other
9714             information; a value listed in a <file>Packages</file> file
9715             will always take precedence.  By default
9716             <prgn>dpkg-gencontrol</prgn> does not include the section
9717             and priority in the control file of a binary package - use
9718             the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
9719             achieve this effect.</p>
9720         </sect1>
9721           
9722         <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
9723           </heading>
9724
9725           <p>       
9726             This field is a list of binary packages.
9727           </p>
9728
9729           <p>       
9730             When it appears in the <file>.dsc</file> file it is the list
9731             of binary packages which a source package can produce.  It
9732             does not necessarily produce all of these binary packages
9733             for every architecture.  The source control file doesn't
9734             contain details of which architectures are appropriate for
9735             which of the binary packages.
9736           </p>
9737
9738           <p>       
9739             When it appears in a <file>.changes</file> file it lists the
9740             names of the binary packages actually being uploaded.
9741           </p>
9742
9743           <p>       
9744             The syntax is a list of binary packages separated by
9745             commas.
9746             <footnote>
9747               <p>
9748                 A space after each comma is conventional.
9749               </p>
9750             </footnote> Currently the packages must be separated using
9751             only spaces in the <file>.changes</file> file.</p>
9752         </sect1>
9753           
9754         <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
9755           </heading>
9756
9757           <p>       
9758             This field appears in the control files of binary
9759             packages, and in the <file>Packages</file> files.  It gives
9760             the total amount of disk space required to install the
9761             named package.
9762           </p>
9763
9764           <p>       
9765             The disk space is represented in kilobytes as a simple
9766             decimal number.</p>
9767         </sect1>
9768           
9769         <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
9770           </heading>
9771
9772           <p>       
9773             This field contains a list of files with information about
9774             each one.  The exact information and syntax varies with
9775             the context.  In all cases the the part of the field
9776             contents on the same line as the field name is empty.  The
9777             remainder of the field is one line per file, each line
9778             being indented by one space and containing a number of
9779             sub-fields separated by spaces.
9780           </p>
9781
9782           <p>       
9783             In the <file>.dsc</file> (Debian source control) file each
9784             line contains the MD5 checksum, size and filename of the
9785             tarfile and (if applicable) diff file which make up the
9786             remainder of the source package.
9787             <footnote>
9788               <p>
9789                 That is, the parts which are not the
9790                 <tt>.dsc</tt>.
9791               </p>
9792             </footnote> The exact forms of the filenames are described
9793             in <ref id="pkg-sourcearchives">.
9794           </p>
9795
9796           <p>       
9797             In the <file>.changes</file> file this contains one line per
9798             file being uploaded.  Each line contains the MD5 checksum,
9799             size, section and priority and the filename.  The section
9800             and priority are the values of the corresponding fields in
9801             the main source control file - see <ref
9802             id="pkg-f-classification">.  If no section or priority is
9803             specified then <tt>-</tt> should be used, though section
9804             and priority values must be specified for new packages to
9805             be installed properly.
9806           </p>
9807
9808           <p>       
9809             The special value <tt>byhand</tt> for the section in a
9810             <tt>.changes</tt> file indicates that the file in question
9811             is not an ordinary package file and must by installed by
9812             hand by the distribution maintainers.  If the section is
9813             <tt>byhand</tt> the priority should be <tt>-</tt>.
9814           </p>
9815
9816           <p>       
9817             If a new Debian revision of a package is being shipped and
9818             no new original source archive is being distributed the
9819             <tt>.dsc</tt> must still contain the <tt>Files</tt> field
9820             entry for the original source archive
9821             <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
9822             but the <file>.changes</file> file should leave it out.  In
9823             this case the original source archive on the distribution
9824             site must match exactly, byte-for-byte, the original
9825             source archive which was used to generate the
9826             <file>.dsc</file> file and diff which are being uploaded.</p>
9827         </sect1>
9828           
9829           
9830         <sect1
9831         id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
9832           </heading>
9833
9834           <p>       
9835             The most recent version of the standards (the
9836             <prgn>dpkg</prgn> programmers' and policy manuals and
9837             associated texts) with which the package complies.  This
9838             is updated manually when editing the source package to
9839             conform to newer standards; it can sometimes be used to
9840             tell when a package needs attention.
9841           </p>
9842
9843           <p>       
9844             Its format is the same as that of a version number except
9845             that no epoch or Debian revision is allowed - see <ref
9846             id="versions">.</p>
9847         </sect1>
9848           
9849           
9850         <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
9851           </heading>
9852
9853           <p>       
9854             In a <file>.changes</file> file or parsed changelog output
9855             this contains the (space-separated) name(s) of the
9856             distribution(s) where this version of the package should
9857             be or was installed.  Distribution names follow the rules
9858             for package names.  (See <ref id="pkg-f-Package">).
9859           </p>
9860
9861           <p>       
9862             Current distribution values are:
9863           <taglist>
9864             <tag><em>stable</em></tag>
9865             <item>
9866               <p> 
9867                 This is the current `released' version of Debian
9868                 GNU/Linux.  A new version is released approximately
9869                 every 3 months after the <em>development</em> code has
9870                 been <em>frozen</em> for a month of testing.  Once the
9871                 distribution is <em>stable</em> only major bug fixes
9872                 are allowed. When changes are made to this
9873                 distribution, the release number is increased
9874                 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
9875               </p>
9876             </item>
9877                 
9878             <tag><em>unstable</em></tag>
9879             <item>
9880               <p>
9881                 This distribution value refers to the
9882                 <em>developmental</em> part of the Debian distribution
9883                 tree. New packages, new upstream versions of packages
9884                 and bug fixes go into the <em>unstable</em> directory
9885                 tree. Download from this distribution at your own
9886                 risk.</p>
9887             </item>
9888             
9889             <tag><em>contrib</em></tag>
9890             <item>
9891               <p>
9892                 The packages with this distribution value do not meet
9893                 the criteria for inclusion in the main Debian
9894                 distribution as defined by the Policy Manual, but meet
9895                 the criteria for the <em>contrib</em>
9896                 Distribution. There is currently no distinction
9897                 between stable and unstable packages in the
9898                 <em>contrib</em> or <em>non-free</em>
9899                 distributions. Use your best judgement in downloading
9900                 from this Distribution.</p>
9901             </item>
9902                 
9903             <tag><em>non-free</em></tag>
9904             <item>
9905               <p>
9906                 Like the packages in the <em>contrib</em> seciton,
9907                 the packages in <em>non-free</em> do not meet the
9908                 criteria for inclusion in the main Debian distribution
9909                 as defined by the Policy Manual. Again, use your best
9910                 judgement in downloading from this Distribution.</p>
9911               
9912             <tag><em>experimental</em></tag>
9913             <item>
9914               <p>
9915                 The packages with this distribution value are deemed
9916                 by their maintainers to be high risk. Oftentimes they
9917                 represent early beta or developmental packages from
9918                 various sources that the maintainers want people to
9919                 try, but are not ready to be a part of the other parts
9920                 of the Debian distribution tree. Download at your own
9921                 risk.</p>
9922             </item>
9923                 
9924             <tag><em>frozen</em></tag>
9925             <item>
9926               <p>
9927                 From time to time, (currently, every 3 months) the
9928                 <em>unstable</em> distribution enters a state of
9929                 `code-freeze' in anticipation of release as a
9930                 <em>stable</em> version. During this period of testing
9931                 (usually 4 weeks) only fixes for existing or
9932                 newly-discovered bugs will be allowed.
9933               </p>
9934             </item>
9935           </taglist> You should list <em>all</em> distributions that
9936           the package should be installed into. Except in unusual
9937           circumstances, installations to <em>stable</em> should also
9938           go into <em>frozen</em> (if it exists) and
9939           <em>unstable</em>. Likewise, installations into
9940           <em>frozen</em> should also go into <em>unstable</em>.</p>
9941         </sect1>
9942           
9943         <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
9944           </heading>
9945
9946           <p>       
9947             This is a description of how important it is to upgrade to
9948             this version from previous ones.  It consists of a single
9949             keyword usually taking one of the values <tt>LOW</tt>,
9950             <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
9951             commentary (separated by a space) which is usually in
9952             parentheses.  For example:
9953             <example>
9954   Urgency: LOW (HIGH for diversions users)
9955             </example>
9956           </p>
9957
9958           <p>       
9959             This field appears in the <file>.changes</file> file and in
9960             parsed changelogs; its value appears as the value of the
9961             <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
9962             changelog (see <ref id="pkg-dpkgchangelog">).
9963           </p>
9964
9965           <p>       
9966             Urgency keywords are not case-sensitive.</p>
9967         </sect1>
9968           
9969         <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
9970           </heading>
9971
9972           <p>       
9973             In <tt>.changes</tt> files and parsed changelogs, this
9974             gives the date the package was built or last edited.</p>
9975         </sect1>
9976           
9977         <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
9978           </heading>
9979
9980           <p>       
9981             This field occurs in <file>.changes</file> files, and
9982             specifies a format revision for the file.  The format
9983             described here is version <tt>1.5</tt>.  The syntax of the
9984             format value is the same as that of a package version
9985             number except that no epoch or Debian revision is allowed
9986             - see <ref id="versions">.</p>
9987         </sect1>
9988           
9989         <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
9990           </heading>
9991
9992           <p>       
9993             In a <file>.changes</file> file or parsed changelog this field
9994             contains the human-readable changes data, describing the
9995             differences between the last version and the current one.
9996           </p>
9997
9998           <p>       
9999             There should be nothing in this field before the first
10000             newline; all the subsequent lines must be indented by at
10001             least one space; blank lines must be represented by a line
10002             consiting only of a space and a full stop.
10003           </p>
10004
10005           <p>       
10006             Each version's change information should be preceded by a
10007             `title' line giving at least the version, distribution(s)
10008             and urgency, in a human-readable way.
10009           </p>
10010
10011           <p>       
10012             If data from several versions is being returned the entry
10013             for the most recent version should be returned first, and
10014             entries should be separated by the representation of a
10015             blank line (the `title' line may also be followed by the
10016             representation of blank line).</p>
10017         </sect1>
10018           
10019         <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10020         <tt>MSDOS-Filename</tt>
10021           </heading>
10022
10023           <p>       
10024             These fields in <tt>Packages</tt> files give the
10025             filename(s) of (the parts of) a package in the
10026             distribution directories, relative to the root of the
10027             Debian hierarchy.  If the package has been split into
10028             several parts the parts are all listed in order, separated
10029             by spaces.</p>
10030         </sect1>
10031           
10032         <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10033           </heading>
10034
10035           <p>       
10036             These fields in <file>Packages</file> files give the size (in
10037             bytes, expressed in decimal) and MD5 checksum of the
10038             file(s) which make(s) up a binary package in the
10039             distribution.  If the package is split into several parts
10040             the values for the parts are listed in order, separated by
10041             spaces.</p>
10042         </sect1>
10043           
10044         <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10045           </heading>
10046
10047           <p>       
10048             This field in <prgn>dpkg</prgn>'s status file records
10049             whether the user wants a package installed, removed or
10050             left alone, whether it is broken (requiring
10051             reinstallation) or not and what its current state on the
10052             system is.  Each of these pieces of information is a
10053             single word.</p>
10054         </sect1>
10055           
10056         <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10057           </heading>
10058
10059           <p>       
10060             If a package is not installed or not configured, this
10061             field in <prgn>dpkg</prgn>'s status file records the last
10062             version of the package which was successfully
10063             configured.</p>
10064         </sect1>
10065           
10066         <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10067           </heading>
10068
10069           <p>       
10070             This field in <prgn>dpkg</prgn>'s status file contains
10071             information about the automatically-managed configuration
10072             files held by a package.  This field should <em>not</em>
10073             appear anywhere in a package!</p>
10074         </sect1>
10075           
10076         <sect1><heading>Obsolete fields
10077           </heading>
10078
10079           <p>       
10080             These are still recognised by <prgn>dpkg</prgn> but should
10081             not appear anywhere any more.
10082             <taglist compact="compact">
10083               
10084               <tag><tt>Revision</tt></tag>
10085               <tag><tt>Package-Revision</tt></tag>
10086               <tag><tt>Package_Revision</tt></tag>
10087               <item>
10088                 <p>
10089                   The Debian revision part of the package version was
10090                   at one point in a separate control file field.  This
10091                   field went through several names.</p>
10092               </item>
10093                   
10094               <tag><tt>Recommended</tt></tag>
10095               <item><p>Old name for <tt>Recommends</tt></p>
10096               </item>
10097                 
10098               <tag><tt>Optional</tt></tag>
10099               <item><p>Old name for <tt>Suggests</tt>.</p>
10100               </item>
10101               <tag><tt>Class</tt></tag>
10102               <item><p>Old name for <tt>Priority</tt>.</p>
10103               </item>
10104             </taglist>
10105           </p>
10106         </sect1>
10107       </sect>
10108     </appendix>
10109
10110     <appendix id="pkg-conffiles"><heading>Configuration file handling
10111     (from old Packaging Manual)
10112       </heading>
10113
10114       <p>       
10115         <prgn>dpkg</prgn> can do a certain amount of automatic
10116         handling of package configuration files.
10117       </p>
10118
10119       <p>       
10120         Whether this mechanism is appropriate depends on a number of
10121         factors, but basically there are two approaches to any
10122         particular configuration file.
10123       </p>
10124
10125       <p>       
10126         The easy method is to ship a best-effort configuration in the
10127         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10128         handle updates.  If the user is unlikely to want to edit the
10129         file, but you need them to be able to without losing their
10130         changes, and a new package with a changed version of the file
10131         is only released infrequently, this is a good approach.
10132       </p>
10133
10134       <p>       
10135         The hard method is to build the configuration file from
10136         scratch in the <prgn>postinst</prgn> script, and to take the
10137         responsibility for fixing any mistakes made in earlier
10138         versions of the package automatically.  This will be
10139         appropriate if the file is likely to need to be different on
10140         each system.
10141       </p>
10142         
10143       <sect><heading>Automatic handling of configuration files by
10144       <prgn>dpkg</prgn>
10145         </heading>
10146
10147         <p>       
10148           A package may contain a control area file called
10149           <tt>conffiles</tt>.  This file should be a list of filenames
10150           of configuration files needing automatic handling, separated
10151           by newlines.  The filenames should be absolute pathnames,
10152           and the files referred to should actually exist in the
10153           package.
10154         </p>
10155
10156         <p>       
10157           When a package is upgraded <prgn>dpkg</prgn> will process
10158           the configuration files during the configuration stage,
10159           shortly before it runs the package's <prgn>postinst</prgn>
10160           script,
10161         </p>
10162
10163         <p>       
10164           For each file it checks to see whether the version of the
10165           file included in the package is the same as the one that was
10166           included in the last version of the package (the one that is
10167           being upgraded from); it also compares the version currently
10168           installed on the system with the one shipped with the last
10169           version.
10170         </p>
10171
10172         <p>       
10173           If neither the user nor the package maintainer has changed
10174           the file, it is left alone.  If one or the other has changed
10175           their version, then the changed version is preferred - i.e.,
10176           if the user edits their file, but the package maintainer
10177           doesn't ship a different version, the user's changes will
10178           stay, silently, but if the maintainer ships a new version
10179           and the user hasn't edited it the new version will be
10180           installed (with an informative message).  If both have
10181           changed their version the user is prompted about the problem
10182           and must resolve the differences themselves.
10183         </p>
10184
10185         <p>       
10186           The comparisons are done by calculating the MD5 message
10187           digests of the files, and storing the MD5 of the file as it
10188           was included in the most recent version of the package.
10189         </p>
10190
10191         <p>       
10192           When a package is installed for the first time
10193           <prgn>dpkg</prgn> will install the file that comes with it,
10194           unless that would mean overwriting a file already on the
10195           filesystem.
10196         </p>
10197
10198         <p>       
10199           However, note that <prgn>dpkg</prgn> will <em>not</em>
10200           replace a conffile that was removed by the user (or by a
10201           script).  This is necessary because with some programs a
10202           missing file produces an effect hard or impossible to
10203           achieve in another way, so that a missing file needs to be
10204           kept that way if the user did it.
10205         </p>
10206
10207         <p>       
10208           Note that a package should <em>not</em> modify a
10209           <prgn>dpkg</prgn>-handled conffile in its maintainer
10210           scripts.  Doing this will lead to <prgn>dpkg</prgn> giving
10211           the user confusing and possibly dangerous options for
10212           conffile update when the package is upgraded.</p>
10213       </sect>
10214         
10215       <sect><heading>Fully-featured maintainer script configuration
10216       handling
10217         </heading>
10218
10219         <p>       
10220           For files which contain site-specific information such as
10221           the hostname and networking details and so forth, it is
10222           better to create the file in the package's
10223           <prgn>postinst</prgn> script.
10224         </p>
10225
10226         <p>       
10227           This will typically involve examining the state of the rest
10228           of the system to determine values and other information, and
10229           may involve prompting the user for some information which
10230           can't be obtained some other way.
10231         </p>
10232
10233         <p>       
10234           When using this method there are a couple of important
10235           issues which should be considered:
10236         </p>
10237
10238         <p>       
10239           If you discover a bug in the program which generates the
10240           configuration file, or if the format of the file changes
10241           from one version to the next, you will have to arrange for
10242           the postinst script to do something sensible - usually this
10243           will mean editing the installed configuration file to remove
10244           the problem or change the syntax.  You will have to do this
10245           very carefully, since the user may have changed the file,
10246           perhaps to fix the very problem that your script is trying
10247           to deal with - you will have to detect these situations and
10248           deal with them correctly.
10249         </p>
10250
10251         <p>       
10252           If you do go down this route it's probably a good idea to
10253           make the program that generates the configuration file(s) a
10254           separate program in <file>/usr/sbin</file>, by convention called
10255           <file><var>package</var>config</file> and then run that if
10256           appropriate from the post-installation script.  The
10257           <tt><var>package</var>config</tt> program should not
10258           unquestioningly overwrite an existing configuration - if its
10259           mode of operation is geared towards setting up a package for
10260           the first time (rather than any arbitrary reconfiguration
10261           later) you should have it check whether the configuration
10262           already exists, and require a <tt>--force</tt> flag to
10263           overwrite it.</p></sect>
10264     </appendix>
10265       
10266     <appendix id="pkg-alternatives"><heading>Alternative versions of
10267         an interface - <prgn>update-alternatives</prgn> (from old
10268     Packaging Manual)
10269       </heading>
10270
10271       <p>       
10272         When several packages all provide different versions of the
10273         same program or file it is useful to have the system select a
10274         default, but to allow the system administrator to change it
10275         and have their decisions respected.
10276       </p>
10277
10278       <p>       
10279         For example, there are several versions of the <prgn>vi</prgn>
10280         editor, and there is no reason to prevent all of them from
10281         being installed at once, each under their own name
10282         (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10283         Nevertheless it is desirable to have the name <tt>vi</tt>
10284         refer to something, at least by default.
10285       </p>
10286
10287       <p>       
10288         If all the packages involved cooperate, this can be done with
10289         <prgn>update-alternatives</prgn>.
10290       </p>
10291
10292       <p>       
10293         Each package provides its own version under its own name, and
10294         calls <prgn>update-alternatives</prgn> in its postinst to
10295         register its version (and again in its prerm to deregister
10296         it).
10297       </p>
10298
10299       <p>       
10300         See the manpage <manref name="update-alternatives"
10301         section="8"> for details.
10302       </p>
10303
10304       <p>       
10305         If <prgn>update-alternatives</prgn> does not seem appropriate
10306         you may wish to consider using diversions instead.</p>
10307     </appendix>
10308       
10309     <appendix id="pkg-diversions"><heading>Diversions - overriding a
10310     package's version of a file (from old Packaging Manual)
10311       </heading>
10312
10313       <p>       
10314         It is possible to have <prgn>dpkg</prgn> not overwrite a file
10315         when it reinstalls the package it belongs to, and to have it
10316         put the file from the package somewhere else instead.
10317       </p>
10318
10319       <p>       
10320         This can be used locally to override a package's version of a
10321         file, or by one package to override another's version (or
10322         provide a wrapper for it).
10323       </p>
10324
10325       <p>       
10326         Before deciding to use a diversion, read <ref
10327         id="pkg-alternatives"> to see if you really want a diversion
10328         rather than several alternative versions of a program.
10329       </p>
10330
10331       <p>       
10332         There is a diversion list, which is read by <prgn>dpkg</prgn>,
10333         and updated by a special program <prgn>dpkg-divert</prgn>.
10334         Please see <manref name="dpkg-divert" section="8"> for full
10335         details of its operation.
10336       </p>
10337
10338       <p>       
10339         When a package wishes to divert a file from another, it should
10340         call <prgn>dpkg-divert</prgn> in its preinst to add the
10341         diversion and rename the existing file.  For example,
10342         supposing that a <prgn>smailwrapper</prgn> package wishes to
10343         install a wrapper around <file>/usr/sbin/smail</file>:
10344         <example>
10345   if [ install = "$1" -o upgrade = "$1" ]; then
10346      dpkg-divert --package smailwrapper --add --rename \
10347         --divert /usr/sbin/smail.real /usr/sbin/smail
10348   fi
10349         </example> Testing <tt>$1</tt> is necessary so that the script
10350         doesn't try to add the diversion again when
10351         <prgn>smailwrapper</prgn> is upgraded.  The <tt>--package
10352         smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10353         copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10354         get installed as the true version.
10355       </p>
10356
10357       <p>       
10358         The postrm has to do the reverse:
10359         <example>
10360   if [ remove = "$1" ]; then
10361      dpkg-divert --package smailwrapper --remove --rename \
10362         --divert /usr/sbin/smail.real /usr/sbin/smail
10363   fi
10364         </example>
10365       </p>
10366
10367       <p>       
10368         Do not attempt to divert a file which is vitally important for
10369         the system's operation - when using <prgn>dpkg-divert</prgn>
10370         there is a time, after it has been diverted but before
10371         <prgn>dpkg</prgn> has installed the new version, when the file
10372         does not exist.</p>
10373     </appendix>
10374
10375   </book>
10376 </debiandoc>