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