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