]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
Merge branch 'master' into bug473439-rra
[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   <book>
9     <titlepag>
10       <title>Debian Policy Manual</title>
11       <author><qref id="authors">The Debian Policy Mailing List</qref></author>
12       <version>version &version;, &date;</version>
13
14       <abstract>
15         This manual describes the policy requirements for the Debian
16         GNU/Linux distribution.  This includes the structure and
17         contents of the Debian archive and several design issues of
18         the operating system, as well as technical requirements that
19         each package must satisfy to be included in the distribution.
20       </abstract>
21
22       <copyright>
23         <copyrightsummary>
24           Copyright &copy; 1996,1997,1998 Ian Jackson
25           and Christian Schwarz.
26         </copyrightsummary>
27         <p>
28           This manual is free software; you may redistribute it and/or
29           modify it under the terms of the GNU General Public License
30           as published by the Free Software Foundation; either version
31           2, or (at your option) any later version.
32         </p>
33
34         <p>
35           This is distributed in the hope that it will be useful, but
36           <em>without any warranty</em>; without even the implied
37           warranty of merchantability or fitness for a particular
38           purpose.  See the GNU General Public License for more
39           details.
40         </p>
41
42         <p>
43           A copy of the GNU General Public License is available as
44           <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
45           distribution or on the World Wide Web at
46           <url id="http://www.gnu.org/copyleft/gpl.html"
47                name="the GNU General Public Licence">. You can also
48           obtain it by writing to the Free Software Foundation, Inc.,
49           51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
50         </p>
51       </copyright>
52     </titlepag>
53
54     <toc detail="sect1">
55
56     <chapt id="scope">
57       <heading>About this manual</heading>
58       <sect>
59         <heading>Scope</heading>
60         <p>
61           This manual describes the policy requirements for the Debian
62           GNU/Linux distribution. This includes the structure and
63           contents of the Debian archive and several design issues of the
64           operating system, as well as technical requirements that
65           each package must satisfy to be included in the
66           distribution.
67         </p>
68
69         <p>
70           This manual also describes Debian policy as it relates to
71           creating Debian packages. It is not a tutorial on how to build
72           packages, nor is it exhaustive where it comes to describing
73           the behavior of the packaging system. Instead, this manual
74           attempts to define the interface to the package management
75           system that the developers have to be conversant with.<footnote>
76               Informally, the criteria used for inclusion is that the
77               material meet one of the following requirements:
78               <taglist compact="compact">
79                 <tag>Standard interfaces</tag>
80                 <item>
81                     The material presented represents an interface to
82                     the packaging system that is mandated for use, and
83                     is used by, a significant number of packages, and
84                     therefore should not be changed without peer
85                     review. Package maintainers can then rely on this
86                     interfaces not changing, and the package
87                     management software authors need to ensure
88                     compatibility with these interface
89                     definitions. (Control file and changelog file
90                     formats are examples.)
91                 </item>
92                 <tag>Chosen Convention</tag>
93                 <item>
94                     If there are a number of technically viable choices
95                     that can be made, but one needs to select one of
96                     these options for inter-operability. The version
97                     number format is one example.
98                 </item>
99               </taglist>
100               Please note that these are not mutually exclusive;
101               selected conventions often become parts of standard
102               interfaces.
103           </footnote>
104         </p>
105
106         <p>
107           The footnotes present in this manual are
108           merely informative, and are not part of Debian policy itself.
109         </p>
110
111         <p>
112           The appendices to this manual are not necessarily normative,
113           either. Please see <ref id="pkg-scope"> for more information.
114         </p>
115
116         <p>
117           In the normative part of this manual,
118           the words <em>must</em>, <em>should</em> and
119           <em>may</em>, and the adjectives <em>required</em>,
120           <em>recommended</em> and <em>optional</em>, are used to
121           distinguish the significance of the various guidelines in
122           this policy document. Packages that do not conform to the
123           guidelines denoted by <em>must</em> (or <em>required</em>)
124           will generally not be considered acceptable for the Debian
125           distribution. Non-conformance with guidelines denoted by
126           <em>should</em> (or <em>recommended</em>) will generally be
127           considered a bug, but will not necessarily render a package
128           unsuitable for distribution. Guidelines denoted by
129           <em>may</em> (or <em>optional</em>) are truly optional and
130           adherence is left to the maintainer's discretion.
131         </p>
132
133         <p>
134           These classifications are roughly equivalent to the bug
135           severities <em>serious</em> (for <em>must</em> or
136           <em>required</em> directive violations), <em>minor</em>,
137           <em>normal</em> or <em>important</em>
138           (for <em>should</em> or <em>recommended</em> directive
139           violations) and <em>wishlist</em> (for <em>optional</em>
140           items).
141           <footnote>
142                 Compare RFC 2119.  Note, however, that these words are
143                 used in a different way in this document.
144           </footnote>
145         </p>
146
147         <p>
148           Much of the information presented in this manual will be
149           useful even when building a package which is to be
150           distributed in some other way or is intended for local use
151           only.
152         </p>
153       </sect>
154
155       <sect>
156         <heading>New versions of this document</heading>
157
158         <p>
159           This manual is distributed via the Debian package
160           <package><url name="debian-policy"
161               id="http://packages.debian.org/debian-policy"></package> 
162           (<httpsite>packages.debian.org</httpsite> 
163           <httppath>/debian-policy</httppath>).
164         </p>
165
166         <p>
167           The current version of this document is also available from
168           the Debian web mirrors at
169           <tt><url name="/doc/debian-policy/"
170                 id="http://www.debian.org/doc/debian-policy/"></tt>.
171           (
172           <httpsite>www.debian.org</httpsite>
173           <httppath>/doc/debian-policy/</httppath>)
174           Also available from the same directory are several other
175           formats: <file>policy.html.tar.gz</file>
176           (<httppath>/doc/debian-policy/policy.html.tar.gz</httppath>),
177           <file>policy.pdf.gz</file> 
178           (<httppath>/doc/debian-policy/policy.pdf.gz</httppath>)
179           and <file>policy.ps.gz</file>
180           (<httppath>/doc/debian-policy/policy.ps.gz</httppath>).
181         </p>
182
183         <p>
184           The <package>debian-policy</package> package also includes the file
185           <file>upgrading-checklist.txt.gz</file> which indicates policy
186           changes between versions of this document.
187         </p>
188       </sect>
189
190       <sect id="authors">
191         <heading>Authors and Maintainers</heading>
192
193         <p>
194           Originally called "Debian GNU/Linux Policy Manual", this
195           manual was initially written in 1996 by Ian Jackson.
196           It was revised on November 27th, 1996 by David A. Morris.
197           Christian Schwarz added new sections on March 15th, 1997,
198           and reworked/restructured it in April-July 1997.
199           Christoph Lameter contributed the "Web Standard".
200           Julian Gilbey largely restructured it in 2001.
201         </p>
202
203         <p>
204           Since September 1998, the responsibility for the contents of
205           this document lies on the <url name="debian-policy mailing list"
206           id="mailto:debian-policy@lists.debian.org">. Proposals
207           are discussed there and inserted into policy after a certain
208           consensus is established.
209           <!-- insert shameless policy-process plug here eventually -->
210           The actual editing is done by a group of maintainers that have
211           no editorial powers. These are the current maintainers:
212
213           <enumlist>
214             <item>Julian Gilbey</item>
215             <item>Branden Robinson</item>
216             <item>Josip Rodin</item>
217             <item>Manoj Srivastava</item>
218           </enumlist>
219         </p>
220
221         <p>
222           While the authors of this document have tried hard to avoid
223           typos and other errors, these do still occur. If you discover
224           an error in this manual or if you want to give any
225           comments, suggestions, or criticisms please send an email to
226           the Debian Policy List,
227           <email>debian-policy@lists.debian.org</email>, or submit a
228           bug report against the <tt>debian-policy</tt> package.
229         </p>
230
231         <p>
232           Please do not try to reach the individual authors or maintainers
233           of the Policy Manual regarding changes to the Policy.
234         </p>
235       </sect>
236
237       <sect id="related">
238         <heading>Related documents</heading>
239
240         <p>
241           There are several other documents other than this Policy Manual
242           that are necessary to fully understand some Debian policies and
243           procedures.
244         </p>
245
246         <p>
247           The external "sub-policy" documents are referred to in:
248           <list compact="compact">
249             <item><ref id="fhs"></item>
250             <item><ref id="virtual_pkg"></item>
251             <item><ref id="menus"></item>
252             <item><ref id="mime"></item>
253             <item><ref id="perl"></item>
254             <item><ref id="maintscriptprompt"></item>
255             <item><ref id="emacs"></item>
256           </list>
257         </p>
258
259         <p>
260           In addition to those, which carry the weight of policy, there
261           is the Debian Developer's Reference. This document describes
262           procedures and resources for Debian developers, but it is
263           <em>not</em> normative; rather, it includes things that don't
264           belong in the Policy, such as best practices for developers.
265         </p>
266
267         <p>
268           The Developer's Reference is available in the
269           <package>developers-reference</package> package.
270           It's also available from the Debian web mirrors at
271           <tt><url name="/doc/developers-reference/"
272                 id="http://www.debian.org/doc/developers-reference/"></tt>.
273         </p>
274       </sect>
275
276       <sect id="definitions">
277         <heading>Definitions</heading>
278
279         <p>
280           The following terms are used in this Policy Manual:
281           <taglist>
282             <tag>ASCII</tag>
283             <item>
284               The character encoding specified by ANSI X3.4-1986 and its
285               predecessor standards, referred to in MIME as US-ASCII, and
286               corresponding to an encoding in eight bits per character of
287               the first 128 <url id="http://www.unicode.org/"
288               name="Unicode"> characters, with the eighth bit always zero.
289             </item>
290             <tag>UTF-8</tag>
291             <item>
292               The transformation format (sometimes called encoding) of
293               <url id="http://www.unicode.org/" name="Unicode"> defined by
294               <url id="http://www.rfc-editor.org/rfc/rfc3629.txt"
295               name="RFC 3629">.  UTF-8 has the useful property of having
296               ASCII as a subset, so any text encoded in ASCII is trivially
297               also valid UTF-8.
298             </item>
299           </taglist>
300         </p>
301       </sect>
302     </chapt>
303
304
305     <chapt id="archive">
306       <heading>The Debian Archive</heading>
307
308       <p>
309         The Debian GNU/Linux system is maintained and distributed as a
310         collection of <em>packages</em>. Since there are so many of
311         them (currently well over 15000), they are split into
312         <em>sections</em> and given <em>priorities</em> to simplify
313         the handling of them.
314       </p>
315
316       <p>
317         The effort of the Debian project is to build a free operating
318         system, but not every package we want to make accessible is
319         <em>free</em> in our sense (see the Debian Free Software
320         Guidelines, below), or may be imported/exported without
321         restrictions. Thus, the archive is split into the distribution
322         areas or components<footnote>
323           The Debian archive software uses the term "component" internally
324           and in the Release file format to refer to the division of an
325           archive.  The Debian Social Contract refers to distribution
326           areas.  This document uses the same terminology as the Social
327           Contract.
328         </footnote> based on their licenses and other restrictions.
329       </p>
330
331       <p>
332         The aims of this are:
333
334         <list compact="compact">
335           <item>to allow us to make as much software available as we can</item>
336           <item>to allow us to encourage everyone to write free software,
337                 and</item>
338           <item>to allow us to make it easy for people to produce
339                 CD-ROMs of our system without violating any licenses,
340                 import/export restrictions, or any other laws.</item>
341         </list>
342       </p>
343
344       <p>
345         The <em>main</em> distribution area forms the <em>Debian GNU/Linux
346         distribution</em>.
347       </p>
348
349       <p>
350         Packages in the other distribution areas (<tt>contrib</tt>,
351         <tt>non-free</tt>) are not considered to be part of the Debian
352         distribution, although we support their use and provide
353         infrastructure for them (such as our bug-tracking system and
354         mailing lists). This Debian Policy Manual applies to these
355         packages as well.
356       </p>
357
358       <sect id="dfsg">
359         <heading>The Debian Free Software Guidelines</heading>
360         <p>
361           The Debian Free Software Guidelines (DFSG) form our
362           definition of "free software".  These are:
363             <taglist>
364               <tag>Free Redistribution
365               </tag>
366               <item>
367                   The license of a Debian component may not restrict any
368                   party from selling or giving away the software as a
369                   component of an aggregate software distribution
370                   containing programs from several different
371                   sources. The license may not require a royalty or
372                   other fee for such sale.
373               </item>
374               <tag>Source Code
375               </tag>
376               <item>
377                   The program must include source code, and must allow
378                   distribution in source code as well as compiled form.
379               </item>
380               <tag>Derived Works
381               </tag>
382               <item>
383                   The license must allow modifications and derived
384                   works, and must allow them to be distributed under the
385                   same terms as the license of the original software.
386               </item>
387               <tag>Integrity of The Author's Source Code
388               </tag>
389               <item>
390                   The license may restrict source-code from being
391                   distributed in modified form <em>only</em> if the
392                   license allows the distribution of "patch files"
393                   with the source code for the purpose of modifying the
394                   program at build time. The license must explicitly
395                   permit distribution of software built from modified
396                   source code. The license may require derived works to
397                   carry a different name or version number from the
398                   original software.  (This is a compromise. The Debian
399                   Project encourages all authors to not restrict any
400                   files, source or binary, from being modified.)
401               </item>
402               <tag>No Discrimination Against Persons or Groups
403               </tag>
404               <item>
405                   The license must not discriminate against any person
406                   or group of persons.
407               </item>
408               <tag>No Discrimination Against Fields of Endeavor
409               </tag>
410               <item>
411                   The license must not restrict anyone from making use
412                   of the program in a specific field of endeavor. For
413                   example, it may not restrict the program from being
414                   used in a business, or from being used for genetic
415                   research.
416               </item>
417               <tag>Distribution of License
418               </tag>
419               <item>
420                   The rights attached to the program must apply to all
421                   to whom the program is redistributed without the need
422                   for execution of an additional license by those
423                   parties.
424               </item>
425               <tag>License Must Not Be Specific to Debian
426               </tag>
427               <item>
428                   The rights attached to the program must not depend on
429                   the program's being part of a Debian system. If the
430                   program is extracted from Debian and used or
431                   distributed without Debian but otherwise within the
432                   terms of the program's license, all parties to whom
433                   the program is redistributed must have the same
434                   rights as those that are granted in conjunction with
435                   the Debian system.
436               </item>
437               <tag>License Must Not Contaminate Other Software
438               </tag>
439               <item>
440                   The license must not place restrictions on other
441                   software that is distributed along with the licensed
442                   software. For example, the license must not insist
443                   that all other programs distributed on the same medium
444                   must be free software.
445               </item>
446               <tag>Example Licenses
447               </tag>
448               <item>
449                   The "GPL," "BSD," and "Artistic" licenses are examples of
450                   licenses that we consider <em>free</em>.
451               </item>
452             </taglist>
453         </p>
454       </sect>
455
456       <sect id="sections">
457         <heading>Distribution areas</heading>
458
459         <sect1 id="main">
460           <heading>The main distribution area</heading>
461
462           <p>
463             Every package in <em>main</em> must comply with the DFSG
464             (Debian Free Software Guidelines).
465           </p>
466
467           <p>
468             In addition, the packages in <em>main</em>
469             <list compact="compact">
470               <item>
471                   must not require a package outside of <em>main</em>
472                   for compilation or execution (thus, the package must
473                   not declare a "Depends", "Recommends", or
474                   "Build-Depends" relationship on a non-<em>main</em>
475                   package),
476               </item>
477               <item>
478                   must not be so buggy that we refuse to support them,
479                   and
480               </item>
481               <item>
482                   must meet all policy requirements presented in this
483                   manual.
484               </item>
485             </list>
486           </p>
487
488         </sect1>
489
490         <sect1 id="contrib">
491           <heading>The contrib distribution area</heading>
492
493           <p>
494             Every package in <em>contrib</em> must comply with the DFSG.
495           </p>
496
497           <p>
498             In addition, the packages in <em>contrib</em>
499             <list compact="compact">
500               <item>
501                   must not be so buggy that we refuse to support them,
502                   and
503               </item>
504               <item>
505                   must meet all policy requirements presented in this
506                   manual.
507               </item>
508             </list>
509           </p>
510
511
512           <p>
513             Examples of packages which would be included in
514             <em>contrib</em> are:
515             <list compact="compact">
516               <item>
517                   free packages which require <em>contrib</em>,
518                   <em>non-free</em> packages or packages which are not
519                   in our archive at all for compilation or execution,
520                   and
521               </item>
522               <item>
523                   wrapper packages or other sorts of free accessories for
524                   non-free programs.
525               </item>
526             </list>
527           </p>
528         </sect1>
529
530         <sect1 id="non-free">
531           <heading>The non-free distribution area</heading>
532
533           <p>
534             Packages must be placed in <em>non-free</em> if they are
535             not compliant with the DFSG or are encumbered by patents
536             or other legal issues that make their distribution
537             problematic.
538           </p>
539
540           <p>
541             In addition, the packages in <em>non-free</em>
542             <list compact="compact">
543               <item>
544                   must not be so buggy that we refuse to support them,
545                   and
546               </item>
547               <item>
548                   must meet all policy requirements presented in this
549                   manual that it is possible for them to meet.
550                   <footnote>
551                       It is possible that there are policy
552                       requirements which the package is unable to
553                       meet, for example, if the source is
554                       unavailable.  These situations will need to be
555                       handled on a case-by-case basis.
556                   </footnote>
557               </item>
558             </list>
559           </p>
560         </sect1>
561
562       </sect>
563
564       <sect id="pkgcopyright">
565         <heading>Copyright considerations</heading>
566
567         <p>
568           Every package must be accompanied by a verbatim copy of
569           its copyright and distribution license in the file
570           <file>/usr/share/doc/<var>package</var>/copyright</file>
571           (see <ref id="copyrightfile"> for further details).
572         </p>
573
574         <p>
575           We reserve the right to restrict files from being included
576           anywhere in our archives if
577           <list compact="compact">
578             <item>
579                   their use or distribution would break a law,
580             </item>
581             <item>
582                   there is an ethical conflict in their distribution or
583                   use,
584             </item>
585             <item>
586                   we would have to sign a license for them, or
587             </item>
588             <item>
589                   their distribution would conflict with other project
590                   policies.
591             </item>
592           </list>
593         </p>
594
595         <p>
596           Programs whose authors encourage the user to make
597           donations are fine for the main distribution, provided
598           that the authors do not claim that not donating is
599           immoral, unethical, illegal or something similar; in such
600           a case they must go in <em>non-free</em>.
601         </p>
602
603         <p>
604           Packages whose copyright permission notices (or patent
605           problems) do not even allow redistribution of binaries
606           only, and where no special permission has been obtained,
607           must not be placed on the Debian FTP site and its mirrors
608           at all.
609         </p>
610
611         <p>
612           Note that under international copyright law (this applies
613           in the United States, too), <em>no</em> distribution or
614           modification of a work is allowed without an explicit
615           notice saying so.  Therefore a program without a copyright
616           notice <em>is</em> copyrighted and you may not do anything
617           to it without risking being sued! Likewise if a program
618           has a copyright notice but no statement saying what is
619           permitted then nothing is permitted.
620         </p>
621
622         <p>
623           Many authors are unaware of the problems that restrictive
624           copyrights (or lack of copyright notices) can cause for
625           the users of their supposedly-free software.  It is often
626           worthwhile contacting such authors diplomatically to ask
627           them to modify their license terms. However, this can be a
628           politically difficult thing to do and you should ask for
629           advice on the <tt>debian-legal</tt> mailing list first, as
630           explained below.
631         </p>
632
633         <p>
634           When in doubt about a copyright, send mail to
635           <email>debian-legal@lists.debian.org</email>.  Be prepared
636           to provide us with the copyright statement.  Software
637           covered by the GPL, public domain software and BSD-like
638           copyrights are safe; be wary of the phrases "commercial
639           use prohibited" and "distribution restricted".
640         </p>
641       </sect>
642
643       <sect id="subsections">
644         <heading>Sections</heading>
645
646         <p>
647           The packages in the distribution areas <em>main</em>,
648           <em>contrib</em> and <em>non-free</em> are grouped further
649           into <em>sections</em> to simplify handling.
650         </p>
651
652         <p>
653           The distribution area and section for each package should be
654           specified in the package's <tt>Section</tt> control record
655           (see <ref id="f-Section">).  However, the maintainer of the
656           Debian archive may override this selection to ensure the
657           consistency of the Debian distribution.  The
658           <tt>Section</tt> field should be of the form:
659           <list compact="compact">
660             <item>
661                   <em>section</em> if the package is in the
662                   <em>main</em> distribution area,
663             </item>
664             <item>
665                   <em>area/section</em> if the package is in
666                   the <em>contrib</em> or <em>non-free</em>
667                   distribution areas.
668             </item>
669           </list>
670         </p>
671
672         <p>
673           The Debian archive maintainers provide the authoritative
674           list of sections.  At present, they are:
675           <em>admin</em>, <em>comm</em>,
676           <em>devel</em>, <em>doc</em>,
677           <em>editors</em>, <em>electronics</em>, <em>embedded</em>,
678           <em>games</em>, <em>gnome</em>, <em>graphics</em>,
679           <em>hamradio</em>, <em>interpreters</em>, <em>kde</em>,
680           <em>libs</em>, <em>libdevel</em>, <em>mail</em>,
681           <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
682           <em>oldlibs</em>,
683           <em>otherosfs</em>, <em>perl</em>, <em>python</em>,
684           <em>science</em>, <em>shells</em>,
685           <em>sound</em>, <em>tex</em>, <em>text</em>,
686           <em>utils</em>, <em>web</em>, <em>x11</em>.
687         </p>
688       </sect>
689
690       <sect id="priorities">
691         <heading>Priorities</heading>
692
693         <p>
694           Each package should have a <em>priority</em> value, which is
695           included in the package's <em>control record</em>
696           (see <ref id="f-Priority">).
697           This information is used by the Debian package management tools to
698           separate high-priority packages from less-important packages.
699         </p>
700
701         <p>
702           The following <em>priority levels</em> are recognized by the
703           Debian package management tools.
704           <taglist>
705             <tag><tt>required</tt></tag>
706             <item>
707                 Packages which are necessary for the proper
708                 functioning of the system (usually, this means that
709                 dpkg functionality depends on these packages).
710                 Removing a <tt>required</tt> package may cause your
711                 system to become totally broken and you may not even
712                 be able to use <prgn>dpkg</prgn> to put things back,
713                 so only do so if you know what you are doing.  Systems
714                 with only the <tt>required</tt> packages are probably
715                 unusable, but they do have enough functionality to
716                 allow the sysadmin to boot and install more software.
717             </item>
718             <tag><tt>important</tt></tag>
719             <item>
720                 Important programs, including those which one would
721                 expect to find on any Unix-like system.  If the
722                 expectation is that an experienced Unix person who
723                 found it missing would say "What on earth is going on,
724                 where is <prgn>foo</prgn>?", it must be an
725                 <tt>important</tt> package.<footnote>
726                     This is an important criterion because we are
727                     trying to produce, amongst other things, a free
728                     Unix.
729                 </footnote>
730                 Other packages without which the system will not run
731                 well or be usable must also have priority
732                 <tt>important</tt>.  This does
733                 <em>not</em> include Emacs, the X Window System, TeX
734                 or any other large applications.  The
735                 <tt>important</tt> packages are just a bare minimum of
736                 commonly-expected and necessary tools.
737             </item>
738             <tag><tt>standard</tt></tag>
739             <item>
740                 These packages provide a reasonably small but not too
741                 limited character-mode system.  This is what will be
742                 installed by default if the user doesn't select anything
743                 else.  It doesn't include many large applications.
744             </item>
745             <tag><tt>optional</tt></tag>
746             <item>
747                 (In a sense everything that isn't required is
748                 optional, but that's not what is meant here.) This is
749                 all the software that you might reasonably want to
750                 install if you didn't know what it was and don't have
751                 specialized requirements. This is a much larger system
752                 and includes the X Window System, a full TeX
753                 distribution, and many applications. Note that
754                 optional packages should not conflict with each other.
755             </item>
756             <tag><tt>extra</tt></tag>
757             <item>
758                 This contains all packages that conflict with others
759                 with required, important, standard or optional
760                 priorities, or are only likely to be useful if you
761                 already know what they are or have specialized
762                 requirements (such as packages containing only detached
763                 debugging symbols).
764             </item>
765           </taglist>
766         </p>
767
768         <p>
769           Packages must not depend on packages with lower priority
770           values (excluding build-time dependencies).  In order to
771           ensure this, the priorities of one or more packages may need
772           to be adjusted.
773         </p>
774       </sect>
775
776     </chapt>
777
778
779     <chapt id="binary">
780       <heading>Binary packages</heading>
781
782       <p>
783         The Debian GNU/Linux distribution is based on the Debian
784         package management system, called <prgn>dpkg</prgn>. Thus,
785         all packages in the Debian distribution must be provided
786         in the <tt>.deb</tt> file format.
787       </p>
788
789       <sect>
790         <heading>The package name</heading>
791
792         <p>
793           Every package must have a name that's unique within the Debian
794           archive.
795         </p>
796
797         <p>
798           The package name is included in the control field
799           <tt>Package</tt>, the format of which is described
800           in <ref id="f-Package">.
801           The package name is also included as a part of the file name
802           of the <tt>.deb</tt> file.
803         </p>
804       </sect>
805
806       <sect id="versions">
807         <heading>The version of a package</heading>
808
809         <p>
810           Every package has a version number recorded in its
811           <tt>Version</tt> control file field, described in
812           <ref id="f-Version">.
813         </p>
814
815         <p>
816           The package management system imposes an ordering on version
817           numbers, so that it can tell whether packages are being up- or
818           downgraded and so that package system front end applications
819           can tell whether a package it finds available is newer than
820           the one installed on the system.  The version number format
821           has the most significant parts (as far as comparison is
822           concerned) at the beginning.
823         </p>
824
825         <p>
826           If an upstream package has problematic version numbers they
827           should be converted to a sane form for use in the
828           <tt>Version</tt> field.
829         </p>
830
831         <sect1>
832           <heading>Version numbers based on dates</heading>
833
834           <p>
835             In general, Debian packages should use the same version
836             numbers as the upstream sources.
837           </p>
838
839           <p>
840             However, in some cases where the upstream version number is
841             based on a date (e.g., a development "snapshot" release) the
842             package management system cannot handle these version
843             numbers without epochs. For example, dpkg will consider
844             "96May01" to be greater than "96Dec24".
845           </p>
846
847           <p>
848             To prevent having to use epochs for every new upstream
849             version, the date based portion of the version number
850             should be changed to the following format in such cases:
851             "19960501", "19961224". It is up to the maintainer whether
852             they want to bother the upstream maintainer to change
853             the version numbers upstream, too.
854           </p>
855
856           <p>
857             Note that other version formats based on dates which are
858             parsed correctly by the package management system should
859             <em>not</em> be changed.
860           </p>
861
862           <p>
863             Native Debian packages (i.e., packages which have been
864             written especially for Debian) whose version numbers include
865             dates should always use the "YYYYMMDD" format.
866           </p>
867         </sect1>
868
869       </sect>
870
871       <sect>
872         <heading>The maintainer of a package</heading>
873
874         <p>
875           Every package must have a Debian maintainer (the
876           maintainer may be one person or a group of people
877           reachable from a common email address, such as a mailing
878           list).  The maintainer is responsible for ensuring that
879           the package is placed in the appropriate distributions.
880         </p>
881
882         <p>
883           The maintainer must be specified in the
884           <tt>Maintainer</tt> control field with their correct name
885           and a working email address.  If one person maintains
886           several packages, they should try to avoid having
887           different forms of their name and email address in
888           the <tt>Maintainer</tt> fields of those packages.
889         </p>
890
891         <p>
892           The format of the <tt>Maintainer</tt> control field is
893           described in <ref id="f-Maintainer">.
894         </p>
895
896         <p>
897           If the maintainer of a package quits from the Debian
898           project, "Debian QA Group"
899           <email>packages@qa.debian.org</email> takes over the
900           maintainer-ship of the package until someone else
901           volunteers for that task. These packages are called
902           <em>orphaned packages</em>.<footnote>
903                 The detailed procedure for doing this gracefully can
904                 be found in the Debian Developer's Reference,
905                 see <ref id="related">.
906           </footnote>
907         </p>
908       </sect>
909
910       <sect id="descriptions">
911         <heading>The description of a package</heading>
912
913         <p>
914           Every Debian package must have an extended description
915           stored in the appropriate field of the control record.
916           The technical information about the format of the
917           <tt>Description</tt> field is in <ref id="f-Description">.
918         </p>
919
920         <p>
921           The description should describe the package (the program) to a
922           user (system administrator) who has never met it before so that
923           they have enough information to decide whether they want to
924           install it. This description should not just be copied verbatim
925           from the program's documentation.
926         </p>
927
928         <p>
929           Put important information first, both in the synopsis and
930           extended description.  Sometimes only the first part of the
931           synopsis or of the description will be displayed.  You can
932           assume that there will usually be a way to see the whole
933           extended description.
934         </p>
935
936         <p>
937           The description should also give information about the
938           significant dependencies and conflicts between this package
939           and others, so that the user knows why these dependencies and
940           conflicts have been declared.
941         </p>
942
943         <p>
944           Instructions for configuring or using the package should
945           not be included (that is what installation scripts,
946           manual pages, info files, etc., are for).  Copyright
947           statements and other administrivia should not be included
948           either (that is what the copyright file is for).
949         </p>
950
951         <sect1 id="synopsis"><heading>The single line synopsis</heading>
952
953           <p>
954             The single line synopsis should be kept brief - certainly
955             under 80 characters.
956           </p>
957
958           <p>
959             Do not include the package name in the synopsis line.  The
960             display software knows how to display this already, and you
961             do not need to state it.  Remember that in many situations
962             the user may only see the synopsis line - make it as
963             informative as you can.
964           </p>
965
966         </sect1>
967
968         <sect1 id="extendeddesc"><heading>The extended description</heading>
969
970           <p>
971             Do not try to continue the single line synopsis into the
972             extended description.  This will not work correctly when
973             the full description is displayed, and makes no sense
974             where only the summary (the single line synopsis) is
975             available.
976           </p>
977
978           <p>
979             The extended description should describe what the package
980             does and how it relates to the rest of the system (in terms
981             of, for example, which subsystem it is which part of).
982           </p>
983
984           <p>
985             The description field needs to make sense to anyone, even
986             people who have no idea about any of the things the
987             package deals with.<footnote>
988                 The blurb that comes with a program in its
989                 announcements and/or <prgn>README</prgn> files is
990                 rarely suitable for use in a description.  It is
991                 usually aimed at people who are already in the
992                 community where the package is used.
993             </footnote>
994           </p>
995
996         </sect1>
997
998       </sect>
999
1000       <sect>
1001         <heading>Dependencies</heading>
1002
1003         <p>
1004           Every package must specify the dependency information
1005           about other packages that are required for the first to
1006           work correctly.
1007         </p>
1008
1009         <p>
1010           For example, a dependency entry must be provided for any
1011           shared libraries required by a dynamically-linked executable
1012           binary in a package.
1013         </p>
1014
1015         <p>
1016           Packages are not required to declare any dependencies they
1017           have on other packages which are marked <tt>Essential</tt>
1018           (see below), and should not do so unless they depend on a
1019           particular version of that package.<footnote>
1020             <p>
1021               Essential is defined as the minimal set of functionality
1022               that must be available and usable on the system even
1023               when packages are in an unconfigured (but unpacked)
1024               state.  This is needed to avoid unresolvable dependency
1025               loops on upgrade.  If packages add unnecessary
1026               dependencies on packages in this set, the chances that
1027               there <strong>will</strong> be an unresolvable
1028               dependency loop caused by forcing these Essential
1029               packages to be configured first before they need to be
1030               is greatly increased.  It also increases the chances
1031               that frontends will be unable to
1032               <strong>calculate</strong> an upgrade path, even if one
1033               exists.
1034             </p>
1035             <p>
1036               Also, it's pretty unlikely that functionality from
1037               Essential shall ever be removed (which is one reason why
1038               care must be taken before adding to the Essential
1039               packages set), but <em>packages</em> have been removed
1040               from the Essential set when the functionality moved to a
1041               different package. So depending on these packages
1042               <em>just in case</em> they stop being essential does way
1043               more harm than good.
1044             </p>
1045           </footnote>
1046         </p>
1047
1048         <p>
1049           Sometimes, a package requires another package to be installed
1050           <em>and</em> configured before it can be installed. In this
1051           case, you must specify a <tt>Pre-Depends</tt> entry for
1052           the package.
1053         </p>
1054
1055         <p>
1056           You should not specify a <tt>Pre-Depends</tt> entry for a
1057           package before this has been discussed on the
1058           <tt>debian-devel</tt> mailing list and a consensus about
1059           doing that has been reached.
1060         </p>
1061
1062         <p>
1063           The format of the package interrelationship control fields is
1064           described in <ref id="relationships">.
1065         </p>
1066       </sect>
1067
1068       <sect id="virtual_pkg">
1069         <heading>Virtual packages</heading>
1070
1071         <p>
1072           Sometimes, there are several packages which offer
1073           more-or-less the same functionality. In this case, it's
1074           useful to define a <em>virtual package</em> whose name
1075           describes that common functionality.  (The virtual
1076           packages only exist logically, not physically; that's why
1077           they are called <em>virtual</em>.) The packages with this
1078           particular function will then <em>provide</em> the virtual
1079           package. Thus, any other package requiring that function
1080           can simply depend on the virtual package without having to
1081           specify all possible packages individually.
1082         </p>
1083
1084         <p>
1085           All packages should use virtual package names where
1086           appropriate, and arrange to create new ones if necessary.
1087           They should not use virtual package names (except privately,
1088           amongst a cooperating group of packages) unless they have
1089           been agreed upon and appear in the list of virtual package
1090           names. (See also <ref id="virtual">)
1091         </p>
1092
1093         <p>
1094           The latest version of the authoritative list of virtual
1095           package names can be found in the <tt>debian-policy</tt> package.
1096           It is also available from the Debian web mirrors at
1097           <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
1098                 id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>.
1099         </p>
1100
1101         <p>
1102           The procedure for updating the list is described in the preface
1103           to the list.
1104         </p>
1105
1106       </sect>
1107
1108       <sect>
1109         <heading>Base system</heading>
1110
1111         <p>
1112           The <tt>base system</tt> is a minimum subset of the Debian
1113           GNU/Linux system that is installed before everything else
1114           on a new system. Only very few packages are allowed to form
1115           part of the base system, in order to keep the required disk
1116           usage very small.
1117         </p>
1118
1119         <p>
1120           The base system consists of all those packages with priority
1121           <tt>required</tt> or <tt>important</tt>. Many of them will
1122           be tagged <tt>essential</tt> (see below).
1123         </p>
1124       </sect>
1125
1126       <sect>
1127         <heading>Essential packages</heading>
1128
1129         <p>
1130           Some packages are tagged <tt>essential</tt> for a system
1131           using the <tt>Essential</tt> control file field.
1132           The format of the <tt>Essential</tt> control field is
1133           described in <ref id="f-Essential">.
1134         </p>
1135
1136         <p>
1137           Since these packages cannot be easily removed (one has to
1138           specify an extra <em>force option</em> to
1139           <prgn>dpkg</prgn> to do so), this flag must not be used
1140           unless absolutely necessary.  A shared library package
1141           must not be tagged <tt>essential</tt>; dependencies will
1142           prevent its premature removal, and we need to be able to
1143           remove it when it has been superseded.
1144         </p>
1145
1146         <p>
1147           Since dpkg will not prevent upgrading of other packages
1148           while an <tt>essential</tt> package is in an unconfigured
1149             state, all <tt>essential</tt> packages must supply all of
1150             their core functionality even when unconfigured. If the
1151             package cannot satisfy this requirement it must not be
1152             tagged as essential, and any packages depending on this
1153             package must instead have explicit dependency fields as
1154             appropriate.
1155         </p>
1156
1157         <p>
1158           You must not tag any packages <tt>essential</tt> before
1159           this has been discussed on the <tt>debian-devel</tt>
1160           mailing list and a consensus about doing that has been
1161           reached.
1162         </p>
1163       </sect>
1164
1165       <sect id="maintscripts">
1166         <heading>Maintainer Scripts</heading>
1167
1168         <p>
1169           The package installation scripts should avoid producing
1170           output which is unnecessary for the user to see and
1171           should rely on <prgn>dpkg</prgn> to stave off boredom on
1172           the part of a user installing many packages.  This means,
1173           amongst other things, using the <tt>--quiet</tt> option on
1174           <prgn>install-info</prgn>.
1175         </p>
1176
1177         <p>
1178           Errors which occur during the execution of an installation
1179           script must be checked and the installation must not
1180           continue after an error.
1181         </p>
1182
1183         <p>
1184           Note that in general <ref id="scripts"> applies to package
1185           maintainer scripts, too.
1186         </p>
1187
1188         <p>
1189           You should not use <prgn>dpkg-divert</prgn> on a file
1190           belonging to another package without consulting the
1191           maintainer of that package first.
1192         </p>
1193
1194         <p>
1195           All packages which supply an instance of a common command
1196           name (or, in general, filename) should generally use
1197           <prgn>update-alternatives</prgn>, so that they may be
1198           installed together.  If <prgn>update-alternatives</prgn>
1199           is not used, then each package must use
1200           <tt>Conflicts</tt> to ensure that other packages are
1201           de-installed.  (In this case, it may be appropriate to
1202           specify a conflict against earlier versions of something
1203           that previously did not use
1204           <prgn>update-alternatives</prgn>; this is an exception to
1205           the usual rule that versioned conflicts should be
1206           avoided.)
1207         </p>
1208
1209         <sect1 id="maintscriptprompt">
1210           <heading>Prompting in maintainer scripts</heading>
1211           <p>
1212             Package maintainer scripts may prompt the user if
1213             necessary. Prompting should be done by communicating
1214             through a program, such as <prgn>debconf</prgn>, which
1215             conforms to the Debian Configuration Management
1216             Specification, version 2 or higher.  Prompting the user by
1217             other means, such as by hand<footnote>
1218                 From the Jargon file: by hand 2. By extension,
1219                 writing code which does something in an explicit or
1220                 low-level way for which a presupplied library
1221                 (<em>debconf, in this instance</em>) routine ought
1222                 to have been available.
1223             </footnote>, is now deprecated.
1224           </p>
1225
1226           <p>
1227             The Debian Configuration Management Specification is included
1228             in the <file>debconf_specification</file> files in the
1229             <package>debian-policy</package> package.
1230             It is also available from the Debian web mirrors at
1231             <tt><url name="/doc/packaging-manuals/debconf_specification.html"
1232                 id="http://www.debian.org/doc/packaging-manuals/debconf_specification.html"></tt>.
1233           </p>
1234
1235           <p>
1236             Packages which use the Debian Configuration Management
1237             Specification may contain an additional
1238             <prgn>config</prgn> script and a <tt>templates</tt>
1239             file in their control archive<footnote>
1240                 The control.tar.gz inside the .deb.
1241                 See <manref name="deb" section="5">.
1242             </footnote>.
1243             The <prgn>config</prgn> script might be run before the
1244             <prgn>preinst</prgn> script, and before the package is unpacked
1245             or any of its dependencies or pre-dependencies are satisfied.
1246             Therefore it must work using only the tools present in
1247             <em>essential</em> packages.<footnote>
1248                   <package>Debconf</package> or another tool that
1249                   implements the Debian Configuration Management
1250                   Specification will also be installed, and any
1251                   versioned dependencies on it will be satisfied
1252                   before preconfiguration begins.
1253             </footnote>
1254           </p>
1255
1256           <p>
1257             Packages which use the Debian Configuration Management
1258             Specification must allow for translation of their user-visible
1259             messages by using a gettext-based system such as the one
1260             provided by the <package>po-debconf</package> package.
1261           </p>
1262
1263           <p>
1264             Packages should try to minimize the amount of prompting
1265             they need to do, and they should ensure that the user
1266             will only ever be asked each question once.  This means
1267             that packages should try to use appropriate shared
1268             configuration files (such as <file>/etc/papersize</file> and
1269             <file>/etc/news/server</file>), and shared
1270             <package>debconf</package> variables rather than each
1271             prompting for their own list of required pieces of
1272             information.
1273           </p>
1274
1275           <p>
1276             It also means that an upgrade should not ask the same
1277             questions again, unless the user has used
1278             <tt>dpkg --purge</tt> to remove the package's configuration.
1279             The answers to configuration questions should be stored in an
1280             appropriate place in <file>/etc</file> so that the user can
1281             modify them, and how this has been done should be
1282             documented.
1283           </p>
1284
1285           <p>
1286             If a package has a vitally important piece of
1287             information to pass to the user (such as "don't run me
1288             as I am, you must edit the following configuration files
1289             first or you risk your system emitting badly-formatted
1290             messages"), it should display this in the
1291             <prgn>config</prgn> or <prgn>postinst</prgn> script and
1292             prompt the user to hit return to acknowledge the
1293             message.  Copyright messages do not count as vitally
1294             important (they belong in
1295             <file>/usr/share/doc/<var>package</var>/copyright</file>);
1296             neither do instructions on how to use a program (these
1297             should be in on-line documentation, where all the users
1298             can see them).
1299           </p>
1300
1301           <p>
1302             Any necessary prompting should almost always be confined
1303             to the <prgn>config</prgn> or <prgn>postinst</prgn>
1304             script. If it is done in the <prgn>postinst</prgn>, it
1305             should be protected with a conditional so that
1306             unnecessary prompting doesn't happen if a package's
1307             installation fails and the <prgn>postinst</prgn> is
1308             called with <tt>abort-upgrade</tt>,
1309             <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.
1310           </p>
1311         </sect1>
1312
1313       </sect>
1314
1315     </chapt>
1316
1317
1318     <chapt id="source">
1319       <heading>Source packages</heading>
1320
1321       <sect id="standardsversion">
1322         <heading>Standards conformance</heading>
1323
1324         <p>
1325           Source packages should specify the most recent version number
1326           of this policy document with which your package complied
1327           when it was last updated.
1328         </p>
1329
1330         <p>
1331           This information may be used to file bug reports
1332           automatically if your package becomes too much out of date.
1333         </p>
1334
1335         <p>
1336           The version is specified in the <tt>Standards-Version</tt>
1337           control field.
1338           The format of the <tt>Standards-Version</tt> field is
1339           described in <ref id="f-Standards-Version">.
1340         </p>
1341
1342         <p>
1343           You should regularly, and especially if your package has
1344           become out of date, check for the newest Policy Manual
1345           available and update your package, if necessary. When your
1346           package complies with the new standards you should update the
1347           <tt>Standards-Version</tt> source package field and
1348           release it.<footnote>
1349                 See the file <file>upgrading-checklist</file> for
1350                 information about policy which has changed between
1351                 different versions of this document.
1352           </footnote>
1353         </p>
1354
1355       </sect>
1356
1357       <sect id="pkg-relations">
1358         <heading>Package relationships</heading>
1359
1360         <p>
1361           Source packages should specify which binary packages they
1362           require to be installed or not to be installed in order to
1363           build correctly.  For example, if building a package
1364           requires a certain compiler, then the compiler should be
1365           specified as a build-time dependency.
1366         </p>
1367
1368         <p>
1369           It is not necessary to explicitly specify build-time
1370           relationships on a minimal set of packages that are always
1371           needed to compile, link and put in a Debian package a
1372           standard "Hello World!" program written in C or C++.  The
1373           required packages are called <em>build-essential</em>, and
1374           an informational list can be found in
1375           <file>/usr/share/doc/build-essential/list</file> (which is
1376           contained in the <tt>build-essential</tt>
1377           package).<footnote>
1378             Rationale:
1379                 <list compact="compact">
1380                   <item>
1381                       This allows maintaining the list separately
1382                       from the policy documents (the list does not
1383                       need the kind of control that the policy
1384                       documents do).
1385                   </item>
1386                   <item>
1387                       Having a separate package allows one to install
1388                       the build-essential packages on a machine, as
1389                       well as allowing other packages such as tasks to
1390                       require installation of the build-essential
1391                       packages using the depends relation.
1392                   </item>
1393                   <item>
1394                       The separate package allows bug reports against
1395                       the list to be categorized separately from
1396                       the policy management process in the BTS.
1397                   </item>
1398                 </list>
1399           </footnote>
1400         </p>
1401
1402         <p>
1403           When specifying the set of build-time dependencies, one
1404           should list only those packages explicitly required by the
1405           build.  It is not necessary to list packages which are
1406           required merely because some other package in the list of
1407           build-time dependencies depends on them.<footnote>
1408                 The reason for this is that dependencies change, and
1409                 you should list all those packages, and <em>only</em>
1410                 those packages that <em>you</em> need directly.  What
1411                 others need is their business.  For example, if you
1412                 only link against <file>libimlib</file>, you will need to
1413                 build-depend on <package>libimlib2-dev</package> but
1414                 not against any <tt>libjpeg*</tt> packages, even
1415                 though <tt>libimlib2-dev</tt> currently depends on
1416                 them: installation of <package>libimlib2-dev</package>
1417                 will automatically ensure that all of its run-time
1418                 dependencies are satisfied.
1419           </footnote>
1420         </p>
1421
1422         <p>
1423           If build-time dependencies are specified, it must be
1424           possible to build the package and produce working binaries
1425           on a system with only essential and build-essential
1426           packages installed and also those required to satisfy the
1427           build-time relationships (including any implied
1428           relationships).  In particular, this means that version
1429           clauses should be used rigorously in build-time
1430           relationships so that one cannot produce bad or
1431           inconsistently configured packages when the relationships
1432           are properly satisfied.
1433         </p>
1434
1435         <p>
1436           <ref id="relationships"> explains the technical details.
1437         </p>
1438       </sect>
1439
1440       <sect>
1441         <heading>Changes to the upstream sources</heading>
1442
1443         <p>
1444           If changes to the source code are made that are not
1445           specific to the needs of the Debian system, they should be
1446           sent to the upstream authors in whatever form they prefer
1447           so as to be included in the upstream version of the
1448           package.
1449         </p>
1450
1451         <p>
1452           If you need to configure the package differently for
1453           Debian or for Linux, and the upstream source doesn't
1454           provide a way to do so, you should add such configuration
1455           facilities (for example, a new <prgn>autoconf</prgn> test
1456           or <tt>#define</tt>) and send the patch to the upstream
1457           authors, with the default set to the way they originally
1458           had it.  You can then easily override the default in your
1459           <file>debian/rules</file> or wherever is appropriate.
1460         </p>
1461
1462         <p>
1463           You should make sure that the <prgn>configure</prgn> utility
1464           detects the correct architecture specification string
1465           (refer to <ref id="arch-spec"> for details).
1466         </p>
1467
1468         <p>
1469           If you need to edit a <prgn>Makefile</prgn> where GNU-style
1470           <prgn>configure</prgn> scripts are used, you should edit the
1471           <file>.in</file> files rather than editing the
1472           <prgn>Makefile</prgn> directly.  This allows the user to
1473           reconfigure the package if necessary.  You should
1474           <em>not</em> configure the package and edit the generated
1475           <prgn>Makefile</prgn>!  This makes it impossible for someone
1476           else to later reconfigure the package without losing the
1477           changes you made.
1478         </p>
1479
1480       </sect>
1481
1482       <sect id="dpkgchangelog">
1483         <heading>Debian changelog: <file>debian/changelog</file></heading>
1484
1485         <p>
1486           Changes in the Debian version of the package should be
1487           briefly explained in the Debian changelog file
1488           <file>debian/changelog</file>.<footnote>
1489             <p>
1490               Mistakes in changelogs are usually best rectified by
1491               making a new changelog entry rather than "rewriting
1492               history" by editing old changelog entries.
1493             </p>
1494           </footnote>
1495           This includes modifications
1496           made in the Debian package compared to the upstream one
1497           as well as other changes and updates to the package.
1498           <footnote>
1499               Although there is nothing stopping an author who is also
1500               the Debian maintainer from using this changelog for all
1501               their changes, it will have to be renamed if the Debian
1502               and upstream maintainers become different people. In such
1503               a case, however, it might be better to maintain the package
1504               as a non-native package.
1505           </footnote>
1506         </p>
1507
1508         <p>
1509           The format of the <file>debian/changelog</file> allows the
1510           package building tools to discover which version of the package
1511           is being built and find out other release-specific information.
1512         </p>
1513
1514         <p>
1515           That format is a series of entries like this:
1516
1517 <example compact="compact">
1518 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
1519             <var>
1520               [optional blank line(s), stripped]
1521             </var>
1522   * <var>change details</var>
1523     <var>more change details</var>
1524             <var>
1525               [blank line(s), included in output of dpkg-parsechangelog]
1526             </var>
1527   * <var>even more change details</var>
1528             <var>
1529               [optional blank line(s), stripped]
1530             </var>
1531  -- <var>maintainer name</var> &lt;<var>email address</var>&gt;<var>[two spaces]</var>  <var>date</var>
1532 </example>
1533         </p>
1534
1535         <p>
1536           <var>package</var> and <var>version</var> are the source
1537           package name and version number.
1538         </p>
1539
1540         <p>
1541           <var>distribution(s)</var> lists the distributions where
1542           this version should be installed when it is uploaded - it
1543           is copied to the <tt>Distribution</tt> field in the
1544           <file>.changes</file> file.  See <ref id="f-Distribution">.
1545         </p>
1546
1547         <p>
1548           <var>urgency</var> is the value for the <tt>Urgency</tt>
1549           field in the <file>.changes</file> file for the upload
1550           (see <ref id="f-Urgency">). It is not possible to specify
1551           an urgency containing commas; commas are used to separate
1552           <tt><var>keyword</var>=<var>value</var></tt> settings in the
1553           <prgn>dpkg</prgn> changelog format (though there is
1554           currently only one useful <var>keyword</var>,
1555           <tt>urgency</tt>).
1556         </p>
1557
1558         <p>
1559           The change details may in fact be any series of lines
1560           starting with at least two spaces, but conventionally each
1561           change starts with an asterisk and a separating space and
1562           continuation lines are indented so as to bring them in
1563           line with the start of the text above.  Blank lines may be
1564           used here to separate groups of changes, if desired.
1565         </p>
1566
1567         <p>
1568           If this upload resolves bugs recorded in the Bug Tracking
1569           System (BTS), they may be automatically closed on the
1570           inclusion of this package into the Debian archive by
1571           including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
1572           in the change details.<footnote>
1573               To be precise, the string should match the following
1574               Perl regular expression:
1575               <example>
1576 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
1577               </example>
1578               Then all of the bug numbers listed will be closed by the
1579               archive maintenance script (<prgn>katie</prgn>) using the
1580               <var>version</var> of the changelog entry.
1581           </footnote>
1582           This information is conveyed via the <tt>Closes</tt> field
1583           in the <tt>.changes</tt> file (see <ref id="f-Closes">).
1584         </p>
1585
1586         <p>
1587           The maintainer name and email address used in the changelog
1588           should be the details of the person uploading <em>this</em>
1589           version.  They are <em>not</em> necessarily those of the
1590           usual package maintainer.  The information here will be
1591           copied to the <tt>Changed-By</tt> field in the
1592           <tt>.changes</tt> file (see <ref id="f-Changed-By">),
1593           and then later used to send an acknowledgement when the
1594           upload has been installed.
1595         </p>
1596
1597         <p>
1598           The <var>date</var> must be in RFC822 format<footnote>
1599               This is generated by <tt>date -R</tt>.
1600           </footnote>; it must include the time zone specified
1601           numerically, with the time zone name or abbreviation
1602           optionally present as a comment in parentheses.
1603         </p>
1604
1605         <p>
1606           The first "title" line with the package name must start
1607           at the left hand margin.  The "trailer" line with the
1608           maintainer and date details must be preceded by exactly
1609           one space.  The maintainer details and the date must be
1610           separated by exactly two spaces.
1611         </p>
1612
1613         <p>
1614           The entire changelog must be encoded in UTF-8.
1615         </p>
1616
1617         <p>
1618           For more information on placement of the changelog files
1619           within binary packages, please see <ref id="changelogs">.
1620         </p>
1621       </sect>
1622
1623       <sect id="dpkgcopyright">
1624         <heading>Copyright: <file>debian/copyright</file></heading>
1625         <p>
1626           Every package must be accompanied by a verbatim copy of
1627           its copyright and distribution license in the file
1628           <file>/usr/share/doc/<var>package</var>/copyright</file>
1629           (see <ref id="copyrightfile"> for further details). Also see
1630           <ref id="pkgcopyright"> for further considerations relayed
1631           to copyrights for packages.
1632         </p>
1633       </sect>
1634       <sect>
1635         <heading>Error trapping in makefiles</heading>
1636
1637         <p>
1638           When <prgn>make</prgn> invokes a command in a makefile
1639           (including your package's upstream makefiles and
1640           <file>debian/rules</file>), it does so using <prgn>sh</prgn>.  This
1641           means that <prgn>sh</prgn>'s usual bad error handling
1642           properties apply: if you include a miniature script as one
1643           of the commands in your makefile you'll find that if you
1644           don't do anything about it then errors are not detected
1645           and <prgn>make</prgn> will blithely continue after
1646           problems.
1647         </p>
1648
1649         <p>
1650           Every time you put more than one shell command (this
1651           includes using a loop) in a makefile command you
1652           must make sure that errors are trapped.  For
1653           simple compound commands, such as changing directory and
1654           then running a program, using <tt>&amp;&amp;</tt> rather
1655           than semicolon as a command separator is sufficient.  For
1656           more complex commands including most loops and
1657           conditionals you should include a separate <tt>set -e</tt>
1658           command at the start of every makefile command that's
1659           actually one of these miniature shell scripts.
1660         </p>
1661       </sect>
1662
1663       <sect id="timestamps">
1664         <heading>Time Stamps</heading>
1665         <p>
1666           Maintainers should preserve the modification times of the
1667           upstream source files in a package, as far as is reasonably
1668           possible.<footnote>
1669               The rationale is that there is some information conveyed
1670               by knowing the age of the file, for example, you could
1671               recognize that some documentation is very old by looking
1672               at the modification time, so it would be nice if the
1673               modification time of the upstream source would be
1674               preserved.
1675           </footnote>
1676         </p>
1677       </sect>
1678
1679       <sect id="restrictions">
1680         <heading>Restrictions on objects in source packages</heading>
1681
1682         <p>
1683           The source package may not contain any hard links<footnote>
1684             <p>
1685               This is not currently detected when building source
1686               packages, but only when extracting
1687               them.
1688             </p>
1689             <p>
1690               Hard links may be permitted at some point in the
1691               future, but would require a fair amount of
1692               work.
1693             </p>
1694           </footnote>, device special files, sockets or setuid or
1695           setgid files.<footnote>
1696               Setgid directories are allowed.
1697           </footnote>
1698         </p>
1699       </sect>
1700
1701       <sect id="debianrules">
1702         <heading>Main building script: <file>debian/rules</file></heading>
1703
1704         <p>
1705           This file must be an executable makefile, and contains the
1706           package-specific recipes for compiling the package and
1707           building binary package(s) from the source.
1708         </p>
1709
1710         <p>
1711           It must start with the line <tt>#!/usr/bin/make -f</tt>,
1712           so that it can be invoked by saying its name rather than
1713           invoking <prgn>make</prgn> explicitly.
1714         </p>
1715
1716         <p>
1717           Since an interactive <file>debian/rules</file> script makes it
1718           impossible to auto-compile that package and also makes it
1719           hard for other people to reproduce the same binary
1720           package, all <em>required targets</em> MUST be
1721           non-interactive. At a minimum, required targets are the
1722           ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1723           <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1724           <em>binary-indep</em>, and <em>build</em>. It also follows
1725           that any target that these targets depend on must also be
1726           non-interactive.
1727         </p>
1728
1729         <p>
1730           The targets are as follows (required unless stated otherwise):
1731           <taglist>
1732             <tag><tt>build</tt></tag>
1733             <item>
1734               <p>
1735                 The <tt>build</tt> target should perform all the
1736                 configuration and compilation of the package.
1737                 If a package has an interactive pre-build
1738                 configuration routine, the Debianized source package
1739                 must either be built after this has taken place (so
1740                 that the binary package can be built without rerunning
1741                 the configuration) or the configuration routine
1742                 modified to become non-interactive.  (The latter is
1743                 preferable if there are architecture-specific features
1744                 detected by the configuration routine.)
1745               </p>
1746
1747               <p>
1748                 For some packages, notably ones where the same
1749                 source tree is compiled in different ways to produce
1750                 two binary packages, the <tt>build</tt> target
1751                 does not make much sense.  For these packages it is
1752                 good enough to provide two (or more) targets
1753                 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1754                 for each of the ways of building the package, and a
1755                 <tt>build</tt> target that does nothing.  The
1756                 <tt>binary</tt> target will have to build the
1757                 package in each of the possible ways and make the
1758                 binary package out of each.
1759               </p>
1760
1761               <p>
1762                 The <tt>build</tt> target must not do anything
1763                 that might require root privilege.
1764               </p>
1765
1766               <p>
1767                 The <tt>build</tt> target may need to run the
1768                 <tt>clean</tt> target first - see below.
1769               </p>
1770
1771               <p>
1772                 When a package has a configuration and build routine
1773                 which takes a long time, or when the makefiles are
1774                 poorly designed, or when <tt>build</tt> needs to
1775                 run <tt>clean</tt> first, it is a good idea to
1776                 <tt>touch build</tt> when the build process is
1777                 complete.  This will ensure that if <tt>debian/rules
1778                 build</tt> is run again it will not rebuild the whole
1779                 program.<footnote>
1780                     Another common way to do this is for <tt>build</tt>
1781                     to depend on <prgn>build-stamp</prgn> and to do
1782                     nothing else, and for the <prgn>build-stamp</prgn>
1783                     target to do the building and to <tt>touch
1784                     build-stamp</tt> on completion.  This is
1785                     especially useful if the build routine creates a
1786                     file or directory called <tt>build</tt>; in such a
1787                     case, <tt>build</tt> will need to be listed as
1788                     a phony target (i.e., as a dependency of the
1789                     <tt>.PHONY</tt> target).  See the documentation of
1790                     <prgn>make</prgn> for more information on phony
1791                     targets.
1792                 </footnote>
1793               </p>
1794             </item>
1795
1796             <tag><tt>build-arch</tt> (optional),
1797                  <tt>build-indep</tt> (optional)
1798             </tag>
1799             <item>
1800               <p>
1801                 A package may also provide both of the targets
1802                 <tt>build-arch</tt> and <tt>build-indep</tt>.
1803                 The <tt>build-arch</tt> target, if provided, should
1804                 perform all the configuration and compilation required
1805                 for producing all architecture-dependant binary packages
1806                 (those packages for which the body of the
1807                 <tt>Architecture</tt> field in <tt>debian/control</tt>
1808                 is not <tt>all</tt>).
1809                 Similarly, the <tt>build-indep</tt> target, if
1810                 provided, should perform all the configuration and
1811                 compilation required for producing all
1812                 architecture-independent binary packages
1813                 (those packages for which the body of the
1814                 <tt>Architecture</tt> field in <tt>debian/control</tt>
1815                 is <tt>all</tt>).
1816                 The <tt>build</tt> target should depend on those of the
1817                 targets <tt>build-arch</tt> and <tt>build-indep</tt> that
1818                 are provided in the rules file.
1819               </p>
1820
1821               <p>
1822                 If one or both of the targets <tt>build-arch</tt> and
1823                 <tt>build-indep</tt> are not provided, then invoking
1824                 <file>debian/rules</file> with one of the not-provided
1825                 targets as arguments should produce a exit status code
1826                 of 2.  Usually this is provided automatically by make
1827                 if the target is missing.
1828               </p>
1829
1830               <p>
1831                 The <tt>build-arch</tt> and <tt>build-indep</tt> targets
1832                 must not do anything that might require root privilege.
1833               </p>
1834             </item>
1835
1836             <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1837               <tt>binary-indep</tt>
1838             </tag>
1839             <item>
1840               <p>
1841                 The <tt>binary</tt> target must be all that is
1842                 necessary for the user to build the binary package(s)
1843                 produced from this source package.  It is
1844                 split into two parts: <prgn>binary-arch</prgn> builds
1845                 the binary packages which are specific to a particular
1846                 architecture, and <tt>binary-indep</tt> builds
1847                 those which are not.
1848               </p>
1849               <p>
1850                 <tt>binary</tt> may be (and commonly is) a target with
1851                 no commands which simply depends on
1852                 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
1853               </p>
1854               <p>
1855                 Both <tt>binary-*</tt> targets should depend on the
1856                 <tt>build</tt> target, or on the appropriate
1857                 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
1858                 provided, so that the package is built if it has not
1859                 been already.  It should then create the relevant
1860                 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
1861                 make their control files and <prgn>dpkg-deb</prgn> to
1862                 build them and place them in the parent of the top
1863                 level directory.
1864               </p>
1865
1866               <p>
1867                 Both the <tt>binary-arch</tt> and
1868                 <tt>binary-indep</tt> targets <em>must</em> exist.
1869                 If one of them has nothing to do (which will always be
1870                 the case if the source generates only a single binary
1871                 package, whether architecture-dependent or not), it
1872                 must still exist and must always succeed.
1873               </p>
1874
1875               <p>
1876                 The <tt>binary</tt> targets must be invoked as
1877                 root.<footnote>
1878                     The <prgn>fakeroot</prgn> package often allows one
1879                     to build a package correctly even without being
1880                     root.
1881                 </footnote>
1882               </p>
1883             </item>
1884
1885             <tag><tt>clean</tt></tag>
1886             <item>
1887               <p>
1888                 This must undo any effects that the <tt>build</tt>
1889                 and <tt>binary</tt> targets may have had, except
1890                 that it should leave alone any output files created in
1891                 the parent directory by a run of a <tt>binary</tt>
1892                 target.
1893               </p>
1894
1895               <p>
1896                 If a <tt>build</tt> file is touched at the end of
1897                 the <tt>build</tt> target, as suggested above, it
1898                 should be removed as the first action that
1899                 <tt>clean</tt> performs, so that running
1900                 <tt>build</tt> again after an interrupted
1901                 <tt>clean</tt> doesn't think that everything is
1902                 already done.
1903               </p>
1904
1905               <p>
1906                 The <tt>clean</tt> target may need to be
1907                 invoked as root if <tt>binary</tt> has been
1908                 invoked since the last <tt>clean</tt>, or if
1909                 <tt>build</tt> has been invoked as root (since
1910                 <tt>build</tt> may create directories, for
1911                 example).
1912               </p>
1913             </item>
1914
1915             <tag><tt>get-orig-source</tt> (optional)</tag>
1916             <item>
1917               <p>
1918                 This target fetches the most recent version of the
1919                 original source package from a canonical archive site
1920                 (via FTP or WWW, for example), does any necessary
1921                 rearrangement to turn it into the original source
1922                 tar file format described below, and leaves it in the
1923                 current directory.
1924               </p>
1925
1926               <p>
1927                 This target may be invoked in any directory, and
1928                 should take care to clean up any temporary files it
1929                 may have left.
1930               </p>
1931
1932               <p>
1933                 This target is optional, but providing it if
1934                 possible is a good idea.
1935               </p>
1936             </item>
1937
1938             <tag><tt>patch</tt> (optional)</tag>
1939             <item>
1940               <p>
1941                 This target performs whatever additional actions are
1942                 required to make the source ready for editing (unpacking
1943                 additional upstream archives, applying patches, etc.).
1944                 It is recommended to be implemented for any package where
1945                 <tt>dpkg-source -x</tt> does not result in source ready
1946                 for additional modification.  See
1947                 <ref id="readmesource">.
1948               </p>
1949             </item>
1950           </taglist>
1951
1952         <p>
1953           The <tt>build</tt>, <tt>binary</tt> and
1954           <tt>clean</tt> targets must be invoked with the current
1955           directory being the package's top-level directory.
1956         </p>
1957
1958
1959         <p>
1960           Additional targets may exist in <file>debian/rules</file>,
1961           either as published or undocumented interfaces or for the
1962           package's internal use.
1963         </p>
1964
1965         <p>
1966           The architectures we build on and build for are determined
1967           by <prgn>make</prgn> variables using the utility
1968           <qref id="pkg-dpkg-architecture"><prgn>dpkg-architecture</prgn></qref>.
1969           You can determine the
1970           Debian architecture and the GNU style architecture
1971           specification string for the build machine (the machine type
1972           we are building on) as well as for the host machine (the
1973           machine type we are building for).  Here is a list of
1974           supported <prgn>make</prgn> variables:
1975           <list compact="compact">
1976             <item>
1977                 <tt>DEB_*_ARCH</tt> (the Debian architecture)
1978             </item>
1979             <item>
1980                 <tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
1981                 specification string)
1982             </item>
1983             <item>
1984                 <tt>DEB_*_GNU_CPU</tt> (the CPU part of
1985                 <tt>DEB_*_GNU_TYPE</tt>)
1986             </item>
1987             <item>
1988                 <tt>DEB_*_GNU_SYSTEM</tt> (the System part of
1989                 <tt>DEB_*_GNU_TYPE</tt>)
1990           </list>
1991           where <tt>*</tt> is either <tt>BUILD</tt> for specification of
1992           the build machine or <tt>HOST</tt> for specification of the
1993           host machine.
1994         </p>
1995
1996         <p>
1997           Backward compatibility can be provided in the rules file
1998           by setting the needed variables to suitable default
1999           values; please refer to the documentation of
2000           <prgn>dpkg-architecture</prgn> for details.
2001         </p>
2002
2003         <p>
2004           It is important to understand that the <tt>DEB_*_ARCH</tt>
2005           string only determines which Debian architecture we are
2006           building on or for. It should not be used to get the CPU
2007           or system information; the GNU style variables should be
2008           used for that.
2009         </p>
2010
2011         <sect1 id="debianrules-options">
2012           <heading><file>debian/rules</file> and
2013             <tt>DEB_BUILD_OPTIONS</tt></heading>
2014
2015           <p>
2016             Supporting the standardized environment variable
2017             <tt>DEB_BUILD_OPTIONS</tt> is recommended.  This variable can
2018             contain several flags to change how a package is compiled and
2019             built.  Each flag must be in the form <var>flag</var> or
2020             <var>flag</var>=<var>options</var>.  If multiple flags are
2021             given, they must be separated by whitespace.<footnote>
2022               Some packages support any delimiter, but whitespace is the
2023               easiest to parse inside a makefile and avoids ambiguity with
2024               flag values that contain commas.
2025             </footnote>
2026             <var>flag</var> must start with a lowercase letter
2027             (<tt>a-z</tt>) and consist only of lowercase letters,
2028             numbers (<tt>0-9</tt>), and the characters
2029             <tt>-</tt> and <tt>_</tt> (hyphen and underscore).
2030             <var>options</var> must not contain whitespace.  The same
2031             tag should not be given multiple times with conflicting
2032             values.  Package maintainers may assume that
2033             <tt>DEB_BUILD_OPTIONS</tt> will not contain conflicting tags.
2034           </p>
2035
2036           <p>
2037             The meaning of the following tags has been standardized:
2038             <taglist>
2039               <tag>nocheck</tag>
2040               <item>
2041                   This tag says to not run any build-time test suite
2042                   provided by the package.
2043               </item>
2044               <tag>noopt</tag>
2045               <item>
2046                   The presence of this tag means that the package should
2047                   be compiled with a minimum of optimization.  For C
2048                   programs, it is best to add <tt>-O0</tt> to
2049                   <tt>CFLAGS</tt> (although this is usually the default).
2050                   Some programs might fail to build or run at this level
2051                   of optimization; it may be necessary to use
2052                   <tt>-O1</tt>, for example.
2053               </item>
2054               <tag>nostrip</tag>
2055               <item>
2056                   This tag means that the debugging symbols should not be
2057                   stripped from the binary during installation, so that
2058                   debugging information may be included in the package.
2059               </item>
2060               <tag>parallel=n</tag>
2061               <item>
2062                   This tag means that the package should be built using up
2063                   to <tt>n</tt> parallel processes if the package build
2064                   system supports this.<footnote>
2065                       Packages built with <tt>make</tt> can often implement
2066                       this by passing the <tt>-j</tt><var>n</var> option to
2067                       <tt>make</tt>.
2068                   </footnote>
2069                   If the package build system does not support parallel
2070                   builds, this string must be ignored.  If the package
2071                   build system only supports a lower level of concurrency
2072                   than <var>n</var>, the package should be built using as
2073                   many parallel processes as the package build system
2074                   supports.  It is up to the package maintainer to decide
2075                   whether the package build times are long enough and the
2076                   package build system is robust enough to make supporting
2077                   parallel builds worthwhile.
2078                </item>
2079             </taglist>
2080           </p>
2081
2082           <p>
2083             Unknown flags must be ignored by <file>debian/rules</file>.
2084           </p>
2085
2086           <p>
2087             The following makefile snippet is an example of how one may
2088             implement the build options; you will probably have to
2089             massage this example in order to make it work for your
2090             package.
2091             <example compact="compact">
2092 CFLAGS = -Wall -g
2093 INSTALL = install
2094 INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
2095 INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
2096 INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
2097 INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
2098
2099 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
2100     CFLAGS += -O0
2101 else
2102     CFLAGS += -O2
2103 endif
2104 ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
2105     INSTALL_PROGRAM += -s
2106 endif
2107 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
2108     NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
2109     MAKEFLAGS += -j$(NUMJOBS)
2110 endif
2111
2112 build:
2113         # ...
2114 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
2115         # Code to run the package test suite.
2116 endif
2117             </example>
2118           </p>
2119         </sect1>
2120       </sect>
2121
2122 <!-- FIXME: section pkg-srcsubstvars is the same as substvars -->
2123       <sect id="substvars">
2124         <heading>Variable substitutions: <file>debian/substvars</file></heading>
2125
2126         <p>
2127           When <prgn>dpkg-gencontrol</prgn>,
2128           <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2129           generate control files they perform variable substitutions
2130           on their output just before writing it.  Variable
2131           substitutions have the form <tt>${<var>variable</var>}</tt>.
2132           The optional file <file>debian/substvars</file> contains
2133           variable substitutions to be used; variables can also be set
2134           directly from <file>debian/rules</file> using the <tt>-V</tt>
2135           option to the source packaging commands, and certain
2136           predefined variables are also available.
2137         </p>
2138
2139         <p>
2140           The <file>debian/substvars</file> file is usually generated and
2141           modified dynamically by <file>debian/rules</file> targets, in
2142           which case it must be removed by the <tt>clean</tt> target.
2143         </p>
2144
2145         <p>
2146           See <manref name="deb-substvars" section="5"> for full
2147           details about source variable substitutions, including the
2148           format of <file>debian/substvars</file>.</p>
2149       </sect>
2150
2151       <sect id="debianwatch">
2152         <heading>Optional upstream source location: <file>debian/watch</file></heading>
2153
2154         <p>
2155           This is an optional, recommended control file for the
2156           <tt>uscan</tt> utility which defines how to automatically
2157           scan ftp or http sites for newly available updates of the
2158           package. This is used by <url id="
2159           http://dehs.alioth.debian.org/"> and other Debian QA tools
2160           to help with quality control and maintenance of the
2161           distribution as a whole.
2162         </p>
2163
2164       </sect>
2165
2166       <sect id="debianfiles">
2167         <heading>Generated files list: <file>debian/files</file></heading>
2168
2169         <p>
2170           This file is not a permanent part of the source tree; it
2171           is used while building packages to record which files are
2172           being generated.  <prgn>dpkg-genchanges</prgn> uses it
2173           when it generates a <file>.changes</file> file.
2174         </p>
2175
2176         <p>
2177           It should not exist in a shipped source package, and so it
2178           (and any backup files or temporary files such as
2179           <file>files.new</file><footnote>
2180               <file>files.new</file> is used as a temporary file by
2181               <prgn>dpkg-gencontrol</prgn> and
2182               <prgn>dpkg-distaddfile</prgn> - they write a new
2183               version of <tt>files</tt> here before renaming it,
2184               to avoid leaving a corrupted copy if an error
2185               occurs.
2186           </footnote>) should be removed by the
2187           <tt>clean</tt> target.  It may also be wise to
2188           ensure a fresh start by emptying or removing it at the
2189           start of the <tt>binary</tt> target.
2190         </p>
2191
2192         <p>
2193           When <prgn>dpkg-gencontrol</prgn> is run for a binary
2194           package, it adds an entry to <file>debian/files</file> for the
2195           <file>.deb</file> file that will be created when <tt>dpkg-deb
2196           --build</tt> is run for that binary package.  So for most
2197           packages all that needs to be done with this file is to
2198           delete it in the <tt>clean</tt> target.
2199         </p>
2200
2201         <p>
2202           If a package upload includes files besides the source
2203           package and any binary packages whose control files were
2204           made with <prgn>dpkg-gencontrol</prgn> then they should be
2205           placed in the parent of the package's top-level directory
2206           and <prgn>dpkg-distaddfile</prgn> should be called to add
2207           the file to the list in <file>debian/files</file>.</p>
2208       </sect>
2209
2210       <sect id="embeddedfiles">
2211         <heading>Convenience copies of code</heading>
2212
2213         <p>
2214           Some software packages include in their distribution convenience
2215           copies of code from other software packages, generally so that
2216           users compiling from source don't have to download multiple
2217           packages.  Debian packages should not make use of these
2218           convenience copies unless the included package is explicitly
2219           intended to be used in this way.<footnote>
2220             For example, parts of the GNU build system work like this.
2221           </footnote>
2222           If the included code is already in the Debian archive in the
2223           form of a library, the Debian packaging should ensure that
2224           binary packages reference the libraries already in Debian and
2225           the convenience copy is not used.  If the included code is not
2226           already in Debian, it should be packaged separately as a
2227           prerequisite if possible.
2228           <footnote>
2229             Having multiple copies of the same code in Debian is
2230             inefficient, often creates either static linking or shared
2231             library conflicts, and, most importantly, increases the
2232             difficulty of handling security vulnerabilities in the
2233             duplicated code.
2234           </footnote>
2235         </p>
2236       </sect>
2237
2238       <sect id="readmesource">
2239         <heading>Source package handling:
2240           <file>debian/README.source</file></heading>
2241
2242         <p>
2243           If running <prgn>dpkg-source -x</prgn> on a source package
2244           doesn't produce the source of the package, ready for editing,
2245           and allow one to make changes and run
2246           <prgn>dpkg-buildpackage</prgn> to produce a modified package
2247           without taking any additional steps, creating a
2248           <file>debian/README.source</file> documentation file is
2249           recommended.  This file should explain how to do all of the
2250           following:
2251             <enumlist>
2252               <item>Generate the fully patched source, in a form ready for
2253               editing, that would be built to create Debian
2254               packages.  Doing this with a <tt>patch</tt> target in
2255               <file>debian/rules</file> is recommended; see
2256               <ref id="debianrules">.</item>
2257               <item>Modify the source and save those modifications so that
2258               they will be applied when building the package.</item>
2259               <item>Remove source modifications that are currently being
2260               applied when building the package.</item>
2261               <item>Optionally, document what steps are necessary to
2262               upgrade the Debian source package to a new upstream version,
2263               if applicable.</item>
2264             </enumlist>
2265           This explanation should include specific commands and mention
2266           any additional required Debian packages.  It should not assume
2267           familiarity with any specific Debian packaging system or patch
2268           management tools.
2269         </p>
2270
2271         <p>
2272           This explanation may refer to a documentation file installed by
2273           one of the package's build dependencies provided that the
2274           referenced documentation clearly explains these tasks and is not
2275           a general reference manual.
2276         </p>
2277
2278         <p>
2279           <file>debian/README.source</file> may also include any other
2280           information that would be helpful to someone modifying the
2281           source package.  Even if the package doesn't fit the above
2282           description, maintainers are encouraged to document in a
2283           <file>debian/README.source</file> file any source package with a
2284           particularly complex or unintuitive source layout or build
2285           system (for example, a package that builds the same source
2286           multiple times to generate different binary packages).
2287         </p>
2288       </sect>
2289     </chapt>
2290
2291
2292     <chapt id="controlfields">
2293       <heading>Control files and their fields</heading>
2294
2295       <p>
2296         The package management system manipulates data represented in
2297         a common format, known as <em>control data</em>, stored in
2298         <em>control files</em>.
2299         Control files are used for source packages, binary packages and
2300         the <file>.changes</file> files which control the installation
2301         of uploaded files<footnote>
2302             <prgn>dpkg</prgn>'s internal databases are in a similar
2303             format.
2304         </footnote>.
2305       </p>
2306
2307       <sect id="controlsyntax">
2308         <heading>Syntax of control files</heading>
2309
2310         <p>
2311           A control file consists of one or more paragraphs of
2312           fields<footnote>
2313                 The paragraphs are also sometimes referred to as stanzas.
2314           </footnote>.
2315           The paragraphs are separated by blank lines.  Some control
2316           files allow only one paragraph; others allow several, in
2317           which case each paragraph usually refers to a different
2318           package.  (For example, in source packages, the first
2319           paragraph refers to the source package, and later paragraphs
2320           refer to binary packages generated from the source.)
2321         </p>
2322
2323         <p>
2324           Each paragraph consists of a series of data fields; each
2325           field consists of the field name, followed by a colon and
2326           then the data/value associated with that field.  It ends at
2327           the end of the (logical) line.  Horizontal whitespace
2328           (spaces and tabs) may occur immediately before or after the
2329           value and is ignored there; it is conventional to put a
2330           single space after the colon.  For example, a field might
2331           be:
2332           <example compact="compact">
2333 Package: libc6
2334           </example>
2335           the field name is <tt>Package</tt> and the field value
2336           <tt>libc6</tt>.
2337         </p>
2338
2339         <p>
2340           Many fields' values may span several lines; in this case
2341           each continuation line must start with a space or a tab.
2342           Any trailing spaces or tabs at the end of individual
2343           lines of a field value are ignored. 
2344         </p>
2345
2346         <p>
2347           In fields where it is specified that lines may not wrap,
2348           only a single line of data is allowed and whitespace is not
2349           significant in a field body. Whitespace must not appear
2350           inside names (of packages, architectures, files or anything
2351           else) or version numbers, or between the characters of
2352           multi-character version relationships.
2353         </p>
2354
2355         <p>
2356           Field names are not case-sensitive, but it is usual to
2357           capitalize the field names using mixed case as shown below.
2358         </p>
2359
2360         <p>
2361           Blank lines, or lines consisting only of spaces and tabs,
2362           are not allowed within field values or between fields - that
2363           would mean a new paragraph.
2364         </p>
2365
2366         <p>
2367           All control files must be encoded in UTF-8.
2368         </p>
2369       </sect>
2370
2371       <sect id="sourcecontrolfiles">
2372         <heading>Source package control files -- <file>debian/control</file></heading>
2373
2374         <p>
2375           The <file>debian/control</file> file contains the most vital
2376           (and version-independent) information about the source package
2377           and about the binary packages it creates.
2378         </p>
2379
2380         <p>
2381           The first paragraph of the control file contains information about
2382           the source package in general. The subsequent sets each describe a
2383           binary package that the source tree builds.
2384         </p>
2385
2386         <p>
2387           The fields in the general paragraph (the first one, for the source
2388           package) are:
2389
2390           <list compact="compact">
2391             <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2392             <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2393             <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
2394             <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2395             <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2396             <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
2397             <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
2398             <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2399           </list>
2400         </p>
2401
2402         <p>
2403           The fields in the binary package paragraphs are:
2404
2405           <list compact="compact">
2406             <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
2407             <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2408             <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2409             <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2410             <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
2411             <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
2412             <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2413             <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2414           </list>
2415         </p>
2416
2417         <p>
2418           The syntax and semantics of the fields are described below.
2419         </p>
2420
2421 <!-- stuff -->
2422
2423         <p>
2424           These fields are used by <prgn>dpkg-gencontrol</prgn> to
2425           generate control files for binary packages (see below), by
2426           <prgn>dpkg-genchanges</prgn> to generate the
2427           <tt>.changes</tt> file to accompany the upload, and by
2428           <prgn>dpkg-source</prgn> when it creates the
2429           <file>.dsc</file> source control file as part of a source
2430           archive. Many fields are permitted to span multiple lines in
2431           <file>debian/control</file> but not in any other control
2432           file. These tools are responsible for removing the line
2433           breaks from such fields when using fields from
2434           <file>debian/control</file> to generate other control files.
2435         </p>
2436
2437         <p>
2438           The fields here may contain variable references - their
2439           values will be substituted by <prgn>dpkg-gencontrol</prgn>,
2440           <prgn>dpkg-genchanges</prgn> or <prgn>dpkg-source</prgn>
2441           when they generate output control files.
2442           See <ref id="substvars"> for details.
2443         </p>
2444
2445       </sect>
2446
2447       <sect id="binarycontrolfiles">
2448         <heading>Binary package control files -- <file>DEBIAN/control</file></heading>
2449
2450         <p>
2451           The <file>DEBIAN/control</file> file contains the most vital
2452           (and version-dependent) information about a binary package.
2453         </p>
2454
2455         <p>
2456           The fields in this file are:
2457
2458           <list compact="compact">
2459             <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
2460             <item><qref id="f-Source"><tt>Source</tt></qref></item>
2461             <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2462             <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2463             <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2464             <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2465             <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
2466             <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
2467             <item><qref id="f-Installed-Size"><tt>Installed-Size</tt></qref></item>
2468             <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2469             <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2470             <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2471           </list>
2472         </p>
2473       </sect>
2474
2475       <sect id="debiansourcecontrolfiles">
2476         <heading>Debian source control files -- <tt>.dsc</tt></heading>
2477
2478         <p>
2479           This file contains a series of fields, identified and
2480           separated just like the fields in the control file of
2481           a binary package.  The fields are listed below; their
2482           syntax is described above, in <ref id="pkg-controlfields">.
2483
2484         <list compact="compact">
2485           <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
2486           <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2487           <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2488           <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2489           <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
2490           <item><qref id="f-Binary"><tt>Binary</tt></qref></item>
2491           <item><qref id="f-Architecture"><tt>Architecture</tt></qref></item>
2492           <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
2493           <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
2494           <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
2495           <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2496         </list>
2497         </p>
2498
2499         <p>
2500           The source package control file is generated by
2501           <prgn>dpkg-source</prgn> when it builds the source
2502           archive, from other files in the source package,
2503           described above.  When unpacking, it is checked against
2504           the files and directories in the other parts of the
2505           source package.
2506         </p>
2507
2508       </sect>
2509
2510       <sect id="debianchangesfiles">
2511         <heading>Debian changes files -- <file>.changes</file></heading>
2512
2513         <p>
2514           The .changes files are used by the Debian archive maintenance
2515           software to process updates to packages. They contain one
2516           paragraph which contains information from the
2517           <tt>debian/control</tt> file and other data about the
2518           source package gathered via <tt>debian/changelog</tt>
2519           and <tt>debian/rules</tt>.
2520         </p>
2521
2522         <p>
2523           The fields in this file are:
2524
2525           <list compact="compact">
2526             <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
2527             <item><qref id="f-Date"><tt>Date</tt></qref> (mandatory)</item>
2528             <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2529             <item><qref id="f-Binary"><tt>Binary</tt></qref> (mandatory)</item>
2530             <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2531             <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2532             <item><qref id="f-Distribution"><tt>Distribution</tt></qref> (mandatory)</item>
2533             <item><qref id="f-Urgency"><tt>Urgency</tt></qref> (recommended)</item>
2534             <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2535             <item><qref id="f-Changed-By"><tt>Changed-By</tt></qref></item>
2536             <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2537             <item><qref id="f-Closes"><tt>Closes</tt></qref></item>
2538             <item><qref id="f-Changes"><tt>Changes</tt></qref> (mandatory)</item>
2539             <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
2540           </list>
2541         </p>
2542       </sect>
2543
2544       <sect id="controlfieldslist">
2545         <heading>List of fields</heading>
2546
2547         <sect1 id="f-Source">
2548           <heading><tt>Source</tt></heading>
2549
2550           <p>
2551             This field identifies the source package name.
2552           </p>
2553
2554           <p>
2555             In <file>debian/control</file> or a <file>.dsc</file> file,
2556             this field must contain only the name of the source package.
2557           </p>
2558
2559           <p>
2560             In a binary package control file or a <file>.changes</file>
2561             file, the source package name may be followed by a version
2562             number in parentheses<footnote>
2563                 It is customary to leave a space after the package name
2564                 if a version number is specified.
2565             </footnote>.
2566             This version number may be omitted (and is, by
2567             <prgn>dpkg-gencontrol</prgn>) if it has the same value as
2568             the <tt>Version</tt> field of the binary package in
2569             question.  The field itself may be omitted from a binary
2570             package control file when the source package has the same
2571             name and version as the binary package.
2572           </p>
2573         </sect1>
2574
2575         <sect1 id="f-Maintainer">
2576           <heading><tt>Maintainer</tt></heading>
2577
2578           <p>
2579             The package maintainer's name and email address.  The name
2580             should come first, then the email address inside angle
2581             brackets <tt>&lt;&gt</tt> (in RFC822 format).
2582           </p>
2583
2584           <p>
2585             If the maintainer's name contains a full stop then the
2586             whole field will not work directly as an email address due
2587             to a misfeature in the syntax specified in RFC822; a
2588             program using this field as an address must check for this
2589             and correct the problem if necessary (for example by
2590             putting the name in round brackets and moving it to the
2591             end, and bringing the email address forward).
2592           </p>
2593         </sect1>
2594
2595         <sect1 id="f-Uploaders">
2596           <heading><tt>Uploaders</tt></heading>
2597
2598           <p>
2599             List of the names and email addresses of co-maintainers of
2600             the package, if any. If the package has other maintainers
2601             beside the one named in the 
2602             <qref id="f-Maintainer">Maintainer field</qref>, their
2603             names and email addresses should be listed here. The
2604             format is the same as that of the Maintainer tag, and
2605             multiple entries should be comma separated. Currently,
2606             this field is restricted to a single line of data.  This
2607             is an optional field.
2608           </p>
2609           <p>
2610             Any parser that interprets the Uploaders field in
2611             <file>debian/control</file> must permit it to span multiple
2612             lines.  Line breaks in an Uploaders field that spans multiple
2613             lines are not significant and the semantics of the field are
2614             the same as if the line breaks had not been present.
2615           </p>
2616         </sect1>
2617
2618         <sect1 id="f-Changed-By">
2619           <heading><tt>Changed-By</tt></heading>
2620
2621           <p>
2622             The name and email address of the person who changed the
2623             said package. Usually the name of the maintainer.
2624             All the rules for the Maintainer field apply here, too.
2625           </p>
2626         </sect1>
2627
2628         <sect1 id="f-Section">
2629           <heading><tt>Section</tt></heading>
2630
2631           <p>
2632             This field specifies an application area into which the package
2633             has been classified. See <ref id="subsections">.
2634           </p>
2635
2636           <p>
2637             When it appears in the <file>debian/control</file> file,
2638             it gives the value for the subfield of the same name in
2639             the <tt>Files</tt> field of the <file>.changes</file> file.
2640             It also gives the default for the same field in the binary
2641             packages.
2642           </p>
2643         </sect1>
2644
2645         <sect1 id="f-Priority">
2646           <heading><tt>Priority</tt></heading>
2647
2648           <p>
2649             This field represents how important that it is that the user
2650             have the package installed. See <ref id="priorities">.
2651           </p>
2652
2653           <p>
2654             When it appears in the <file>debian/control</file> file,
2655             it gives the value for the subfield of the same name in
2656             the <tt>Files</tt> field of the <file>.changes</file> file.
2657             It also gives the default for the same field in the binary
2658             packages.
2659           </p>
2660         </sect1>
2661
2662         <sect1 id="f-Package">
2663           <heading><tt>Package</tt></heading>
2664
2665           <p>
2666             The name of the binary package.
2667           </p>
2668
2669           <p>
2670             Package names must consist only of lower case letters
2671             (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
2672             and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
2673             They must be at least two characters long and must start
2674             with an alphanumeric character.
2675           </p>
2676         </sect1>
2677
2678         <sect1 id="f-Architecture">
2679           <heading><tt>Architecture</tt></heading>
2680
2681           <p>
2682             Depending on context and the control file used, the
2683             <tt>Architecture</tt> field can include the following sets of
2684             values:
2685             <list>
2686                 <item>A unique single word identifying a Debian machine
2687                       architecture, see <ref id="arch-spec">.
2688                 <item><tt>all</tt>, which indicates an
2689                       architecture-independent package.
2690                 <item><tt>any</tt>, which indicates a package available
2691                       for building on any architecture.
2692                 <item><tt>source</tt>, which indicates a source package.
2693             </list>
2694           </p>
2695
2696           <p>
2697             In the main <file>debian/control</file> file in the source
2698             package, or in the source package control file
2699             <file>.dsc</file>, one may specify a list of architectures
2700             separated by spaces, or the special values <tt>any</tt> or
2701             <tt>all</tt>.
2702           </p>
2703
2704           <p>
2705             Specifying <tt>any</tt> indicates that the source package
2706             isn't dependent on any particular architecture and should
2707             compile fine on any one. The produced binary package(s)
2708             will be specific to whatever the current build architecture
2709             is.<footnote>
2710                 This is the most often used setting, and is recommended
2711                 for new packages that aren't <tt>Architecture: all</tt>.
2712             </footnote>
2713           </p>
2714
2715           <p>
2716             Specifying a list of architectures indicates that the source
2717             will build an architecture-dependent package, and will only
2718             work correctly on the listed architectures.<footnote>
2719                 This is a setting used for a minority of cases where the
2720                 program is not portable. Generally, it should not be used
2721                 for new packages.
2722             </footnote>
2723           </p>
2724
2725           <p>
2726             In a <file>.changes</file> file, the <tt>Architecture</tt>
2727             field lists the architecture(s) of the package(s)
2728             currently being uploaded.  This will be a list; if the
2729             source for the package is also being uploaded, the special
2730             entry <tt>source</tt> is also present.
2731           </p>
2732
2733           <p>
2734             See <ref id="debianrules"> for information how to get the
2735             architecture for the build process.
2736           </p>
2737         </sect1>
2738
2739         <sect1 id="f-Essential">
2740           <heading><tt>Essential</tt></heading>
2741
2742           <p>
2743             This is a boolean field which may occur only in the
2744             control file of a binary package or in a per-package fields
2745             paragraph of a main source control data file.
2746           </p>
2747
2748           <p>
2749             If set to <tt>yes</tt> then the package management system
2750             will refuse to remove the package (upgrading and replacing
2751             it is still possible). The other possible value is <tt>no</tt>,
2752             which is the same as not having the field at all.
2753           </p>
2754         </sect1>
2755
2756         <sect1>
2757           <heading>Package interrelationship fields:
2758             <tt>Depends</tt>, <tt>Pre-Depends</tt>,
2759             <tt>Recommends</tt>, <tt>Suggests</tt>,
2760             <tt>Breaks</tt>, <tt>Conflicts</tt>,
2761             <tt>Provides</tt>, <tt>Replaces</tt>, <tt>Enhances</tt>
2762           </heading>
2763
2764           <p>
2765             These fields describe the package's relationships with
2766             other packages.  Their syntax and semantics are described
2767             in <ref id="relationships">.</p>
2768         </sect1>
2769
2770         <sect1 id="f-Standards-Version">
2771           <heading><tt>Standards-Version</tt></heading>
2772
2773           <p>
2774             The most recent version of the standards (the policy
2775             manual and associated texts) with which the package
2776             complies.
2777           </p>
2778
2779           <p>
2780             The version number has four components: major and minor
2781             version number and major and minor patch level.  When the
2782             standards change in a way that requires every package to
2783             change the major number will be changed.  Significant
2784             changes that will require work in many packages will be
2785             signaled by a change to the minor number.  The major patch
2786             level will be changed for any change to the meaning of the
2787             standards, however small; the minor patch level will be
2788             changed when only cosmetic, typographical or other edits
2789             are made which neither change the meaning of the document
2790             nor affect the contents of packages.
2791           </p>
2792
2793           <p>
2794             Thus only the first three components of the policy version
2795             are significant in the <em>Standards-Version</em> control
2796             field, and so either these three components or the all
2797             four components may be specified.<footnote>
2798                 In the past, people specified the full version number
2799                 in the Standards-Version field, for example "2.3.0.0".
2800                 Since minor patch-level changes don't introduce new
2801                 policy, it was thought it would be better to relax
2802                 policy and only require the first 3 components to be
2803                 specified, in this example "2.3.0".  All four
2804                 components may still be used if someone wishes to do so.
2805             </footnote>
2806           </p>
2807
2808         </sect1>
2809
2810         <sect1 id="f-Version">
2811           <heading><tt>Version</tt></heading>
2812
2813           <p>
2814             The version number of a package. The format is:
2815             [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
2816           </p>
2817
2818           <p>
2819             The three components here are:
2820             <taglist>
2821               <tag><var>epoch</var></tag>
2822               <item>
2823                 <p>
2824                   This is a single (generally small) unsigned integer.  It
2825                   may be omitted, in which case zero is assumed.  If it is
2826                   omitted then the <var>upstream_version</var> may not
2827                   contain any colons.
2828                 </p>
2829
2830                 <p>
2831                   It is provided to allow mistakes in the version numbers
2832                   of older versions of a package, and also a package's
2833                   previous version numbering schemes, to be left behind.
2834                 </p>
2835               </item>
2836
2837               <tag><var>upstream_version</var></tag>
2838               <item>
2839                 <p>
2840                   This is the main part of the version number.  It is
2841                   usually the version number of the original ("upstream")
2842                   package from which the <file>.deb</file> file has been made,
2843                   if this is applicable.  Usually this will be in the same
2844                   format as that specified by the upstream author(s);
2845                   however, it may need to be reformatted to fit into the
2846                   package management system's format and comparison
2847                   scheme.
2848                 </p>
2849
2850                 <p>
2851                   The comparison behavior of the package management system
2852                   with respect to the <var>upstream_version</var> is
2853                   described below.  The <var>upstream_version</var>
2854                   portion of the version number is mandatory.
2855                 </p>
2856
2857                 <p>
2858                   The <var>upstream_version</var> may contain only
2859                   alphanumerics<footnote>
2860                         Alphanumerics are <tt>A-Za-z0-9</tt> only.
2861                   </footnote>
2862                   and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
2863                   <tt>:</tt> <tt>~</tt> (full stop, plus, hyphen, colon,
2864                   tilde) and should start with a digit.  If there is no
2865                   <var>debian_revision</var> then hyphens are not allowed;
2866                   if there is no <var>epoch</var> then colons are not
2867                   allowed.
2868                 </p>
2869               </item>
2870
2871               <tag><var>debian_revision</var></tag>
2872               <item>
2873                 <p>
2874                   This part of the version number specifies the version of
2875                   the Debian package based on the upstream version.  It
2876                   may contain only alphanumerics and the characters
2877                   <tt>+</tt> <tt>.</tt> <tt>~</tt> (plus, full stop,
2878                   tilde) and is compared in the same way as the
2879                   <var>upstream_version</var> is.
2880                 </p>
2881
2882                 <p>
2883                   It is optional; if it isn't present then the
2884                   <var>upstream_version</var> may not contain a hyphen.
2885                   This format represents the case where a piece of
2886                   software was written specifically to be turned into a
2887                   Debian package, and so there is only one "debianisation"
2888                   of it and therefore no revision indication is required.
2889                 </p>
2890
2891                 <p>
2892                   It is conventional to restart the
2893                   <var>debian_revision</var> at <tt>1</tt> each time the
2894                   <var>upstream_version</var> is increased.
2895                 </p>
2896
2897                 <p>
2898                   The package management system will break the version
2899                   number apart at the last hyphen in the string (if there
2900                   is one) to determine the <var>upstream_version</var> and
2901                   <var>debian_revision</var>.  The absence of a
2902                   <var>debian_revision</var> is equivalent to a
2903                   <var>debian_revision</var> of <tt>0</tt>.
2904                 </p>
2905               </item>
2906             </taglist>
2907           </p>
2908
2909           <p>
2910             When comparing two version numbers, first the <var>epoch</var>
2911             of each are compared, then the <var>upstream_version</var> if
2912             <var>epoch</var> is equal, and then <var>debian_revision</var>
2913             if <var>upstream_version</var> is also equal.
2914             <var>epoch</var> is compared numerically.  The
2915             <var>upstream_version</var> and <var>debian_revision</var>
2916             parts are compared by the package management system using the
2917             following algorithm:
2918           </p>
2919
2920           <p>
2921             The strings are compared from left to right.
2922           </p>
2923
2924           <p>
2925             First the initial part of each string consisting entirely of
2926             non-digit characters is determined.  These two parts (one of
2927             which may be empty) are compared lexically.  If a difference
2928             is found it is returned.  The lexical comparison is a
2929             comparison of ASCII values modified so that all the letters
2930             sort earlier than all the non-letters and so that a tilde
2931             sorts before anything, even the end of a part.  For example,
2932             the following parts are in sorted order from earliest to
2933             latest: <tt>~~</tt>, <tt>~~a</tt>, <tt>~</tt>, the empty part,
2934             <tt>a</tt>.<footnote>
2935               One common use of <tt>~</tt> is for upstream pre-releases.
2936               For example, <tt>1.0~beta1~svn1245</tt> sorts earlier than
2937               <tt>1.0~beta1</tt>, which sorts earlier than <tt>1.0</tt>.
2938             </footnote>
2939           </p>
2940
2941           <p>
2942             Then the initial part of the remainder of each string which
2943             consists entirely of digit characters is determined.  The
2944             numerical values of these two parts are compared, and any
2945             difference found is returned as the result of the comparison.
2946             For these purposes an empty string (which can only occur at
2947             the end of one or both version strings being compared) counts
2948             as zero.
2949           </p>
2950
2951           <p>
2952             These two steps (comparing and removing initial non-digit
2953             strings and initial digit strings) are repeated until a
2954             difference is found or both strings are exhausted.
2955           </p>
2956
2957           <p>
2958             Note that the purpose of epochs is to allow us to leave behind
2959             mistakes in version numbering, and to cope with situations
2960             where the version numbering scheme changes.  It is
2961             <em>not</em> intended to cope with version numbers containing
2962             strings of letters which the package management system cannot
2963             interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
2964             silly orderings (the author of this manual has heard of a
2965             package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
2966             <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
2967             <tt>2</tt> and so forth).
2968           </p>
2969         </sect1>
2970
2971         <sect1 id="f-Description">
2972           <heading><tt>Description</tt></heading>
2973
2974           <p>
2975             In a source or binary control file, the <tt>Description</tt>
2976             field contains a description of the binary package, consisting
2977             of two parts, the synopsis or the short description, and the
2978             long description. The field's format is as follows:
2979           </p>
2980
2981           <p>
2982 <example>
2983         Description: &lt;single line synopsis&gt;
2984          &lt;extended description over several lines&gt;
2985 </example>
2986           </p>
2987
2988           <p>
2989             The lines in the extended description can have these formats:
2990           </p>
2991
2992           <p><list>
2993
2994             <item>
2995               Those starting with a single space are part of a paragraph.
2996               Successive lines of this form will be word-wrapped when
2997               displayed. The leading space will usually be stripped off.
2998             </item>
2999
3000             <item>
3001               Those starting with two or more spaces. These will be
3002               displayed verbatim. If the display cannot be panned
3003               horizontally, the displaying program will line wrap them "hard"
3004               (i.e., without taking account of word breaks). If it can they
3005               will be allowed to trail off to the right. None, one or two
3006               initial spaces may be deleted, but the number of spaces
3007               deleted from each line will be the same (so that you can have
3008               indenting work correctly, for example).
3009             </item>
3010
3011             <item>
3012               Those containing a single space followed by a single full stop
3013               character. These are rendered as blank lines. This is the
3014               <em>only</em> way to get a blank line<footnote>
3015                 Completely empty lines will not be rendered as blank lines.
3016                 Instead, they will cause the parser to think you're starting
3017                 a whole new record in the control file, and will therefore
3018                 likely abort with an error.
3019               </footnote>.
3020             </item>
3021
3022             <item>
3023               Those containing a space, a full stop and some more characters.
3024               These are for future expansion. Do not use them.
3025             </item>
3026
3027           </list></p>
3028
3029           <p>
3030             Do not use tab characters.  Their effect is not predictable.
3031           </p>
3032
3033           <p>
3034             See <ref id="descriptions"> for further information on this.
3035           </p>
3036
3037           <p>
3038             In a <file>.changes</file> file, the <tt>Description</tt> field
3039             contains a summary of the descriptions for the packages being
3040             uploaded.
3041           </p>
3042
3043           <p>
3044             The part of the field before the first newline is empty;
3045             thereafter each line has the name of a binary package and
3046             the summary description line from that binary package.
3047             Each line is indented by one space.
3048           </p>
3049
3050         </sect1>
3051
3052         <sect1 id="f-Distribution">
3053           <heading><tt>Distribution</tt></heading>
3054
3055           <p>
3056             In a <file>.changes</file> file or parsed changelog output
3057             this contains the (space-separated) name(s) of the
3058             distribution(s) where this version of the package should
3059             be installed.  Valid distributions are determined by the
3060             archive maintainers.<footnote>
3061                 Current distribution names are:
3062                 <taglist compact="compact">
3063                   <tag><em>stable</em></tag>
3064                   <item>
3065                       This is the current "released" version of Debian
3066                       GNU/Linux.  Once the distribution is
3067                       <em>stable</em> only security fixes and other
3068                       major bug fixes are allowed. When changes are
3069                       made to this distribution, the release number is
3070                       increased (for example: 2.2r1 becomes 2.2r2 then
3071                       2.2r3, etc).
3072                   </item>
3073
3074                   <tag><em>unstable</em></tag>
3075                   <item>
3076                       This distribution value refers to the
3077                       <em>developmental</em> part of the Debian
3078                       distribution tree. New packages, new upstream
3079                       versions of packages and bug fixes go into the
3080                       <em>unstable</em> directory tree. Download from
3081                       this distribution at your own risk.
3082                   </item>
3083
3084                   <tag><em>testing</em></tag>
3085                   <item>
3086                       This distribution value refers to the
3087                       <em>testing</em> part of the Debian distribution
3088                       tree.  It receives its packages from the
3089                       unstable distribution after a short time lag to
3090                       ensure that there are no major issues with the
3091                       unstable packages.  It is less prone to breakage
3092                       than unstable, but still risky.  It is not
3093                       possible to upload packages directly to
3094                       <em>testing</em>.
3095                   </item>
3096
3097                   <tag><em>frozen</em></tag>
3098                   <item>
3099                       From time to time, the <em>testing</em>
3100                       distribution enters a state of "code-freeze" in
3101                       anticipation of release as a <em>stable</em>
3102                       version. During this period of testing only
3103                       fixes for existing or newly-discovered bugs will
3104                       be allowed.  The exact details of this stage are
3105                       determined by the Release Manager.
3106                   </item>
3107
3108                   <tag><em>experimental</em></tag>
3109                   <item>
3110                       The packages with this distribution value are
3111                       deemed by their maintainers to be high
3112                       risk. Oftentimes they represent early beta or
3113                       developmental packages from various sources that
3114                       the maintainers want people to try, but are not
3115                       ready to be a part of the other parts of the
3116                       Debian distribution tree. Download at your own
3117                       risk.
3118                   </item>
3119                 </taglist>
3120
3121                 <p>
3122                   You should list <em>all</em> distributions that the
3123                   package should be installed into.
3124                 </p>
3125
3126                 <p>
3127                   More information is available in the Debian Developer's
3128                   Reference, section "The Debian archive".
3129                 </p>
3130             </footnote>
3131           </p>
3132         </sect1>
3133
3134         <sect1 id="f-Date">
3135           <heading><tt>Date</tt></heading>
3136
3137           <p>
3138             This field includes the date the package was built or last edited.
3139           </p>
3140
3141           <p>
3142             The value of this field is usually extracted from the
3143             <file>debian/changelog</file> file - see
3144             <ref id="dpkgchangelog">).
3145           </p>
3146         </sect1>
3147
3148         <sect1 id="f-Format">
3149           <heading><tt>Format</tt></heading>
3150
3151           <p>
3152             This field specifies a format revision for the file.
3153             The most current format described in the Policy Manual
3154             is version <strong>1.5</strong>.  The syntax of the
3155             format value is the same as that of a package version
3156             number except that no epoch or Debian revision is allowed
3157             - see <ref id="f-Version">.
3158           </p>
3159         </sect1>
3160
3161         <sect1 id="f-Urgency">
3162           <heading><tt>Urgency</tt></heading>
3163
3164           <p>
3165             This is a description of how important it is to upgrade to
3166             this version from previous ones.  It consists of a single
3167             keyword taking one of the values <tt>low</tt>,
3168             <tt>medium</tt>, <tt>high</tt>, <tt>emergency</tt>, or
3169             <tt>critical</tt><footnote>
3170               Other urgency values are supported with configuration
3171               changes in the archive software but are not used in Debian.
3172               The urgency affects how quickly a package will be considered
3173               for inclusion into the <tt>testing</tt> distribution and
3174               gives an indication of the importance of any fixes included
3175               in the upload.  <tt>Emergency</tt> and <tt>critical</tt> are
3176               treated as synonymous.
3177             </footnote> (not case-sensitive) followed by an optional
3178             commentary (separated by a space) which is usually in
3179             parentheses.  For example:
3180
3181             <example>
3182   Urgency: low (HIGH for users of diversions)
3183             </example>
3184
3185           </p>
3186
3187           <p>
3188             The value of this field is usually extracted from the
3189             <file>debian/changelog</file> file - see
3190             <ref id="dpkgchangelog">.
3191           </p>
3192         </sect1>
3193
3194         <sect1 id="f-Changes">
3195           <heading><tt>Changes</tt></heading>
3196
3197           <p>
3198             This field contains the human-readable changes data, describing
3199             the differences between the last version and the current one.
3200           </p>
3201
3202           <p>
3203             There should be nothing in this field before the first
3204             newline; all the subsequent lines must be indented by at
3205             least one space; blank lines must be represented by a line
3206             consisting only of a space and a full stop.
3207           </p>
3208
3209           <p>
3210             The value of this field is usually extracted from the
3211             <file>debian/changelog</file> file - see
3212             <ref id="dpkgchangelog">).
3213           </p>
3214
3215           <p>
3216             Each version's change information should be preceded by a
3217             "title" line giving at least the version, distribution(s)
3218             and urgency, in a human-readable way.
3219           </p>
3220
3221           <p>
3222             If data from several versions is being returned the entry
3223             for the most recent version should be returned first, and
3224             entries should be separated by the representation of a
3225             blank line (the "title" line may also be followed by the
3226             representation of blank line).
3227           </p>
3228         </sect1>
3229
3230         <sect1 id="f-Binary">
3231           <heading><tt>Binary</tt></heading>
3232
3233           <p>
3234             This field is a list of binary packages.
3235           </p>
3236
3237           <p>
3238             When it appears in the <file>.dsc</file> file it is the list
3239             of binary packages which a source package can produce.  It
3240             does not necessarily produce all of these binary packages
3241             for every architecture.  The source control file doesn't
3242             contain details of which architectures are appropriate for
3243             which of the binary packages.
3244           </p>
3245
3246           <p>
3247             When it appears in a <file>.changes</file> file it lists the
3248             names of the binary packages actually being uploaded.
3249           </p>
3250
3251           <p>
3252             The syntax is a list of binary packages separated by
3253             commas<footnote>
3254                 A space after each comma is conventional.
3255             </footnote>. Currently the packages must be separated using
3256             only spaces in the <file>.changes</file> file.
3257           </p>
3258         </sect1>
3259
3260         <sect1 id="f-Installed-Size">
3261           <heading><tt>Installed-Size</tt></heading>
3262
3263           <p>
3264             This field appears in the control files of binary
3265             packages, and in the <file>Packages</file> files.  It gives
3266             the total amount of disk space required to install the
3267             named package.
3268           </p>
3269
3270           <p>
3271             The disk space is represented in kilobytes as a simple
3272             decimal number.
3273           </p>
3274         </sect1>
3275
3276         <sect1 id="f-Files">
3277           <heading><tt>Files</tt></heading>
3278
3279           <p>
3280             This field contains a list of files with information about
3281             each one.  The exact information and syntax varies with
3282             the context.  In all cases the part of the field
3283             contents on the same line as the field name is empty.  The
3284             remainder of the field is one line per file, each line
3285             being indented by one space and containing a number of
3286             sub-fields separated by spaces.
3287           </p>
3288
3289           <p>
3290             In the <file>.dsc</file> file, each line contains the MD5
3291             checksum, size and filename of the tar file and (if applicable)
3292             diff file which make up the remainder of the source
3293             package<footnote>
3294                 That is, the parts which are not the <tt>.dsc</tt>.
3295             </footnote>.
3296             The exact forms of the filenames are described
3297             in <ref id="pkg-sourcearchives">.
3298           </p>
3299
3300           <p>
3301             In the <file>.changes</file> file this contains one line per
3302             file being uploaded.  Each line contains the MD5 checksum,
3303             size, section and priority and the filename.
3304             The <qref id="f-Section">section</qref>
3305             and <qref id="f-Priority">priority</qref>
3306             are the values of the corresponding fields in
3307             the main source control file.  If no section or priority is
3308             specified then <tt>-</tt> should be used, though section
3309             and priority values must be specified for new packages to
3310             be installed properly.
3311           </p>
3312
3313           <p>
3314             The special value <tt>byhand</tt> for the section in a
3315             <tt>.changes</tt> file indicates that the file in question
3316             is not an ordinary package file and must by installed by
3317             hand by the distribution maintainers.  If the section is
3318             <tt>byhand</tt> the priority should be <tt>-</tt>.
3319           </p>
3320
3321           <p>
3322             If a new Debian revision of a package is being shipped and
3323             no new original source archive is being distributed the
3324             <tt>.dsc</tt> must still contain the <tt>Files</tt> field
3325             entry for the original source archive
3326             <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
3327             but the <file>.changes</file> file should leave it out.  In
3328             this case the original source archive on the distribution
3329             site must match exactly, byte-for-byte, the original
3330             source archive which was used to generate the
3331             <file>.dsc</file> file and diff which are being uploaded.</p>
3332         </sect1>
3333
3334         <sect1 id="f-Closes">
3335           <heading><tt>Closes</tt></heading>
3336
3337           <p>
3338             A space-separated list of bug report numbers that the upload
3339             governed by the .changes file closes.
3340           </p>
3341         </sect1>
3342
3343         <sect1 id="f-Homepage">
3344           <heading><tt>Homepage</tt></heading>
3345
3346           <p>
3347             The URL of the web site for this package, preferably (when
3348             applicable) the site from which the original source can be
3349             obtained and any additional upstream documentation or
3350             information may be found.  The content of this field is a
3351             simple URL without any surrounding characters such as
3352             <tt>&lt;&gt;</tt>.
3353           </p>
3354         </sect1>
3355
3356       </sect>
3357
3358       <sect>
3359         <heading>User-defined fields</heading>
3360
3361         <p>
3362           Additional user-defined fields may be added to the
3363           source package control file.  Such fields will be
3364           ignored, and not copied to (for example) binary or
3365           source package control files or upload control files.
3366         </p>
3367
3368         <p>
3369           If you wish to add additional unsupported fields to
3370           these output files you should use the mechanism
3371           described here.
3372         </p>
3373
3374         <p>
3375           Fields in the main source control information file with
3376           names starting <tt>X</tt>, followed by one or more of
3377           the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
3378           be copied to the output files.  Only the part of the
3379           field name after the hyphen will be used in the output
3380           file.  Where the letter <tt>B</tt> is used the field
3381           will appear in binary package control files, where the
3382           letter <tt>S</tt> is used in source package control
3383           files and where <tt>C</tt> is used in upload control
3384           (<tt>.changes</tt>) files.
3385         </p>
3386
3387         <p>
3388           For example, if the main source information control file
3389           contains the field
3390           <example>
3391   XBS-Comment: I stand between the candle and the star.
3392           </example>
3393           then the binary and source package control files will contain the
3394           field
3395           <example>
3396   Comment: I stand between the candle and the star.
3397           </example>
3398         </p>
3399
3400       </sect>
3401
3402     </chapt>
3403
3404
3405     <chapt id="maintainerscripts">
3406       <heading>Package maintainer scripts and installation procedure</heading>
3407
3408       <sect>
3409         <heading>Introduction to package maintainer scripts</heading>
3410
3411         <p>
3412           It is possible to supply scripts as part of a package which
3413           the package management system will run for you when your
3414           package is installed, upgraded or removed.
3415         </p>
3416
3417         <p>
3418           These scripts are the files <prgn>preinst</prgn>,
3419           <prgn>postinst</prgn>, <prgn>prerm</prgn> and
3420           <prgn>postrm</prgn> in the control area of the package.
3421           They must be proper executable files; if they are scripts
3422           (which is recommended), they must start with the usual
3423           <tt>#!</tt> convention.  They should be readable and
3424           executable by anyone, and must not be world-writable.
3425         </p>
3426
3427         <p>
3428           The package management system looks at the exit status from
3429           these scripts.  It is important that they exit with a
3430           non-zero status if there is an error, so that the package
3431           management system can stop its processing.  For shell
3432           scripts this means that you <em>almost always</em> need to
3433           use <tt>set -e</tt> (this is usually true when writing shell
3434           scripts, in fact).  It is also important, of course, that
3435           they don't exit with a non-zero status if everything went
3436           well.
3437         </p>
3438
3439         <p>
3440           Additionally, packages interacting with users using
3441           <tt>debconf</tt> in the <prgn>postinst</prgn> script should
3442           install a <prgn>config</prgn> script  in the control area,
3443           see <ref id="maintscriptprompt"> for details.
3444         </p>
3445
3446         <p>
3447           When a package is upgraded a combination of the scripts from
3448           the old and new packages is called during the upgrade
3449           procedure.  If your scripts are going to be at all
3450           complicated you need to be aware of this, and may need to
3451           check the arguments to your scripts.
3452         </p>
3453
3454         <p>
3455           Broadly speaking the <prgn>preinst</prgn> is called before
3456           (a particular version of) a package is installed, and the
3457           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
3458           before (a version of) a package is removed and the
3459           <prgn>postrm</prgn> afterwards.
3460         </p>
3461
3462         <p>
3463           Programs called from maintainer scripts should not normally
3464           have a path prepended to them. Before installation is
3465           started, the package management system checks to see if the
3466           programs <prgn>ldconfig</prgn>,
3467           <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
3468           and <prgn>update-rc.d</prgn> can be found via the
3469           <tt>PATH</tt> environment variable. Those programs, and any
3470           other program that one would expect to be in the
3471           <tt>PATH</tt>, should thus be invoked without an absolute
3472           pathname. Maintainer scripts should also not reset the
3473           <tt>PATH</tt>, though they might choose to modify it by
3474           prepending or appending package-specific directories. These
3475           considerations really apply to all shell scripts.</p>
3476       </sect>
3477
3478       <sect id="idempotency">
3479         <heading>Maintainer scripts idempotency</heading>
3480
3481         <p>
3482           It is necessary for the error recovery procedures that the
3483           scripts be idempotent.  This means that if it is run
3484           successfully, and then it is called again, it doesn't bomb
3485           out or cause any harm, but just ensures that everything is
3486           the way it ought to be.  If the first call failed, or
3487           aborted half way through for some reason, the second call
3488           should merely do the things that were left undone the first
3489           time, if any, and exit with a success status if everything
3490           is OK.<footnote>
3491               This is so that if an error occurs, the user interrupts
3492               <prgn>dpkg</prgn> or some other unforeseen circumstance
3493               happens you don't leave the user with a badly-broken
3494               package when <prgn>dpkg</prgn> attempts to repeat the
3495               action.
3496           </footnote>
3497         </p>
3498       </sect>
3499
3500       <sect id="controllingterminal">
3501         <heading>Controlling terminal for maintainer scripts</heading>
3502
3503         <p>
3504           The maintainer scripts are guaranteed to run with a
3505           controlling terminal and can interact with the user.
3506           Because these scripts may be executed with standard output
3507           redirected into a pipe for logging purposes, Perl scripts
3508           should set unbuffered output by setting <tt>$|=1</tt> so
3509           that the output is printed immediately rather than being
3510           buffered.
3511         </p>
3512       </sect>
3513       <sect id="exitstatus">
3514         <heading>Exit status</heading>
3515
3516         <p>
3517           Each script must return a zero exit status for
3518           success, or a nonzero one for failure, since the package
3519           management system looks for the exit status of these scripts
3520           and determines what action to take next based on that datum.
3521         </p>
3522       </sect>
3523
3524       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
3525           scripts are called
3526         </heading>
3527
3528         <p>
3529           <list compact="compact">
3530             <item>
3531               <var>new-preinst</var> <tt>install</tt>
3532             </item>
3533             <item>
3534               <var>new-preinst</var> <tt>install</tt> <var>old-version</var>
3535             </item>
3536             <item>
3537                 <var>new-preinst</var> <tt>upgrade</tt> <var>old-version</var>
3538             </item>
3539             <item>
3540                 <var>old-preinst</var> <tt>abort-upgrade</tt>
3541                 <var>new-version</var>
3542             </item>
3543           </list>
3544
3545         <p>
3546           <list compact="compact">
3547             <item>
3548                 <var>postinst</var> <tt>configure</tt>
3549                 <var>most-recently-configured-version</var>
3550             </item>
3551             <item>
3552                 <var>old-postinst</var> <tt>abort-upgrade</tt>
3553                 <var>new-version</var>
3554             </item>
3555             <item>
3556                 <var>conflictor's-postinst</var> <tt>abort-remove</tt>
3557                 <tt>in-favour</tt> <var>package</var>
3558                 <var>new-version</var>
3559             </item>
3560             <item>
3561                 <var>postinst</var> <tt>abort-remove</tt>
3562             </item>
3563             <item>
3564                 <var>deconfigured's-postinst</var>
3565                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
3566                 <var>failed-install-package</var> <var>version</var>
3567                 [<tt>removing</tt> <var>conflicting-package</var>
3568                 <var>version</var>]
3569             </item>
3570           </list>
3571
3572         <p>
3573           <list compact="compact">
3574             <item>
3575                 <var>prerm</var> <tt>remove</tt>
3576             </item>
3577             <item>
3578                 <var>old-prerm</var> <tt>upgrade</tt>
3579                 <var>new-version</var>
3580             </item>
3581             <item>
3582                 <var>new-prerm</var> <tt>failed-upgrade</tt>
3583                 <var>old-version</var>
3584             </item>
3585             <item>
3586                 <var>conflictor's-prerm</var> <tt>remove</tt>
3587                 <tt>in-favour</tt> <var>package</var>
3588                 <var>new-version</var>
3589             </item>
3590             <item>
3591                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
3592                 <tt>in-favour</tt> <var>package-being-installed</var>
3593                 <var>version</var> [<tt>removing</tt>
3594                 <var>conflicting-package</var>
3595                 <var>version</var>]
3596             </item>
3597           </list>
3598
3599         <p>
3600           <list compact="compact">
3601             <item>
3602                 <var>postrm</var> <tt>remove</tt>
3603             </item>
3604             <item>
3605                 <var>postrm</var> <tt>purge</tt>
3606             </item>
3607             <item>
3608                 <var>old-postrm</var> <tt>upgrade</tt>
3609                 <var>new-version</var>
3610             </item>
3611             <item>
3612                 <var>new-postrm</var> <tt>failed-upgrade</tt>
3613                 <var>old-version</var>
3614             </item>
3615             <item>
3616                 <var>new-postrm</var> <tt>abort-install</tt>
3617             </item>
3618             <item>
3619                 <var>new-postrm</var> <tt>abort-install</tt>
3620                 <var>old-version</var>
3621             </item>
3622             <item>
3623                 <var>new-postrm</var> <tt>abort-upgrade</tt>
3624                 <var>old-version</var>
3625             </item>
3626             <item>
3627                 <var>disappearer's-postrm</var> <tt>disappear</tt>
3628                 <var>overwriter</var>
3629                 <var>overwriter-version</var>
3630             </item>
3631           </list>
3632         </p>
3633
3634
3635       <sect id="unpackphase">
3636         <heading>Details of unpack phase of installation or upgrade</heading>
3637
3638         <p>
3639           The procedure on installation/upgrade/overwrite/disappear
3640           (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
3641           stage of <tt>dpkg --install</tt>) is as follows.  In each
3642           case, if a major error occurs (unless listed below) the
3643           actions are, in general, run backwards - this means that the
3644           maintainer scripts are run with different arguments in
3645           reverse order.  These are the "error unwind" calls listed
3646           below.
3647
3648           <enumlist>
3649             <item>
3650                 <enumlist>
3651                   <item>
3652                       If a version of the package is already installed, call
3653                       <example compact="compact">
3654 <var>old-prerm</var> upgrade <var>new-version</var>
3655                       </example>
3656                   </item>
3657                   <item>
3658                       If the script runs but exits with a non-zero
3659                       exit status, <prgn>dpkg</prgn> will attempt:
3660                       <example compact="compact">
3661 <var>new-prerm</var> failed-upgrade <var>old-version</var>
3662                       </example>
3663                       If this works, the upgrade continues. If this
3664                       does not work, the error unwind:
3665                       <example compact="compact">
3666 <var>old-postinst</var> abort-upgrade <var>new-version</var>
3667                       </example>
3668                       If this works, then the old-version is
3669                       "Installed", if not, the old version is in a
3670                       "Failed-Config" state.
3671                   </item>
3672                 </enumlist>
3673             </item>
3674
3675             <item>
3676                 If a "conflicting" package is being removed at the same time,
3677                 or if any package will be broken (due to <tt>Breaks</tt>):
3678                 <enumlist>
3679                   <item>
3680                       If <tt>--auto-deconfigure</tt> is
3681                       specified, call, for each package to be deconfigured
3682                       due to <tt>Breaks</tt>:
3683                       <example compact="compact">
3684 <var>deconfigured's-prerm</var> deconfigure \
3685   in-favour <var>package-being-installed</var> <var>version</var>
3686                       </example>
3687                       Error unwind:
3688                       <example compact="compact">
3689 <var>deconfigured's-postinst</var> abort-deconfigure \
3690   in-favour <var>package-being-installed-but-failed</var> <var>version</var>
3691                       </example>
3692                       The deconfigured packages are marked as
3693                       requiring configuration, so that if
3694                       <tt>--install</tt> is used they will be
3695                       configured again if possible.
3696                   </item>
3697                   <item>
3698                       If any packages depended on a conflicting
3699                       package being removed and <tt>--auto-deconfigure</tt> is
3700                       specified, call, for each such package:
3701                       <example compact="compact">
3702 <var>deconfigured's-prerm</var> deconfigure \
3703   in-favour <var>package-being-installed</var> <var>version</var> \
3704     removing <var>conflicting-package</var> <var>version</var>
3705                       </example>
3706                       Error unwind:
3707                       <example compact="compact">
3708 <var>deconfigured's-postinst</var> abort-deconfigure \
3709   in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
3710     removing <var>conflicting-package</var> <var>version</var>
3711                       </example>
3712                       The deconfigured packages are marked as
3713                       requiring configuration, so that if
3714                       <tt>--install</tt> is used they will be
3715                       configured again if possible.
3716                   </item>
3717                   <item>
3718                       To prepare for removal of each conflicting package, call:
3719                       <example compact="compact">
3720 <var>conflictor's-prerm</var> remove \
3721   in-favour <var>package</var> <var>new-version</var>
3722                       </example>
3723                       Error unwind:
3724                       <example compact="compact">
3725 <var>conflictor's-postinst</var> abort-remove \
3726   in-favour <var>package</var> <var>new-version</var>
3727                       </example>
3728                   </item>
3729                 </enumlist>
3730             </item>
3731
3732             <item>
3733                 <enumlist>
3734                   <item>
3735                       If the package is being upgraded, call:
3736                       <example compact="compact">
3737 <var>new-preinst</var> upgrade <var>old-version</var>
3738                       </example>
3739                       If this fails, we call:
3740                       <example>
3741 <var>new-postrm</var> abort-upgrade <var>old-version</var>
3742                       </example>
3743                       <enumlist>
3744                         <item>
3745                           <p>
3746                             If that works, then
3747                             <example>
3748 <var>old-postinst</var> abort-upgrade <var>new-version</var>
3749                             </example>
3750                             is called. If this works, then the old version
3751                             is in an "Installed" state, or else it is left
3752                             in an "Unpacked" state.
3753                           </p>
3754                         </item>
3755                         <item>
3756                           <p>
3757                             If it fails, then the old version is left
3758                             in an "Half-Installed" state.
3759                           </p>
3760                         </item>
3761                       </enumlist>
3762                       
3763                   </item>
3764                   <item>
3765                       Otherwise, if the package had some configuration
3766                       files from a previous version installed (i.e., it
3767                       is in the "configuration files only" state):
3768                       <example compact="compact">
3769 <var>new-preinst</var> install <var>old-version</var>
3770                       </example>
3771                       Error unwind:
3772                       <example>
3773 <var>new-postrm</var> abort-install <var>old-version</var>
3774                       </example>
3775                       If this fails, the package is left in a
3776                       "Half-Installed" state, which requires a
3777                       reinstall. If it works, the packages is left in
3778                       a "Config Files" state.
3779                   </item>
3780                   <item>
3781                       Otherwise (i.e., the package was completely purged):
3782                       <example compact="compact">
3783 <var>new-preinst</var> install
3784                       </example>
3785                       Error unwind:
3786                       <example compact="compact">
3787 <var>new-postrm</var> abort-install
3788                       </example>
3789                       If the error-unwind fails, the package is in a
3790                       "Half Installed" phase, and requires a
3791                       reinstall. If the error unwind works, the
3792                       package is in a not installed state.
3793                   </item>
3794                 </enumlist>
3795             </item>
3796
3797             <item>
3798               <p>
3799                 The new package's files are unpacked, overwriting any
3800                 that may be on the system already, for example any
3801                 from the old version of the same package or from
3802                 another package.  Backups of the old files are kept
3803                 temporarily, and if anything goes wrong the package
3804                 management system will attempt to put them back as
3805                 part of the error unwind.
3806               </p>
3807
3808               <p>
3809                 It is an error for a package to contain files which
3810                 are on the system in another package, unless
3811                 <tt>Replaces</tt> is used (see <ref id="replaces">).
3812                 <!--
3813                 The following paragraph is not currently the case:
3814                 Currently the <tt>- - force-overwrite</tt> flag is
3815                 enabled, downgrading it to a warning, but this may not
3816                 always be the case.
3817                 -->
3818               </p>
3819
3820               <p>
3821                 It is a more serious error for a package to contain a
3822                 plain file or other kind of non-directory where another
3823                 package has a directory (again, unless
3824                 <tt>Replaces</tt> is used).  This error can be
3825                 overridden if desired using
3826                 <tt>--force-overwrite-dir</tt>, but this is not
3827                 advisable.
3828               </p>
3829
3830               <p>
3831                 Packages which overwrite each other's files produce
3832                 behavior which, though deterministic, is hard for the
3833                 system administrator to understand.  It can easily
3834                 lead to "missing" programs if, for example, a package
3835                 is installed which overwrites a file from another
3836                 package, and is then removed again.<footnote>
3837                     Part of the problem is due to what is arguably a
3838                     bug in <prgn>dpkg</prgn>.
3839                 </footnote>
3840               </p>
3841
3842               <p>
3843                 A directory will never be replaced by a symbolic link
3844                 to a directory or vice versa; instead, the existing
3845                 state (symlink or not) will be left alone and
3846                 <prgn>dpkg</prgn> will follow the symlink if there is
3847                 one.
3848               </p>
3849             </item>
3850
3851             <item>
3852               <p>
3853                 <enumlist>
3854                   <item>
3855                       If the package is being upgraded, call
3856                       <example compact="compact">
3857 <var>old-postrm</var> upgrade <var>new-version</var>
3858                       </example>
3859                   </item>
3860                   <item>
3861                       If this fails, <prgn>dpkg</prgn> will attempt:
3862                       <example compact="compact">
3863 <var>new-postrm</var> failed-upgrade <var>old-version</var>
3864                       </example>
3865                       If this works, installation continues. If not, 
3866                       Error unwind:
3867                       <example compact="compact">
3868 <var>old-preinst</var> abort-upgrade <var>new-version</var>
3869                       </example>
3870                       If this fails, the old version is left in an
3871                       "Half Installed" state. If it works, dpkg now
3872                       calls:
3873                       <example compact="compact">
3874 <var>new-postrm</var> abort-upgrade <var>old-version</var>
3875                       </example>
3876                       If this fails, the old version is left in an
3877                       "Half Installed" state. If it works, dpkg now
3878                       calls:
3879                       <example compact="compact">
3880 <var>old-postinst</var> abort-upgrade <var>new-version</var>
3881                       </example>
3882                       If this fails, the old version is in an
3883                       "Unpacked" state.
3884                   </item>
3885                 </enumlist>
3886               </p>
3887
3888               <p>
3889                 This is the point of no return - if
3890                 <prgn>dpkg</prgn> gets this far, it won't back off
3891                 past this point if an error occurs.  This will
3892                 leave the package in a fairly bad state, which
3893                 will require a successful re-installation to clear
3894                 up, but it's when <prgn>dpkg</prgn> starts doing
3895                 things that are irreversible.
3896               </p>
3897             </item>
3898
3899             <item>
3900                 Any files which were in the old version of the package
3901                 but not in the new are removed.
3902             </item>
3903
3904             <item>
3905                 The new file list replaces the old.
3906             </item>
3907
3908             <item>
3909                 The new maintainer scripts replace the old.
3910             </item>
3911
3912             <item>
3913                 Any packages all of whose files have been overwritten
3914                 during the installation, and which aren't required for
3915                 dependencies, are considered to have been removed.
3916                 For each such package
3917                 <enumlist>
3918                   <item>
3919                       <prgn>dpkg</prgn> calls:
3920                       <example compact="compact">
3921 <var>disappearer's-postrm</var> disappear \
3922   <var>overwriter</var> <var>overwriter-version</var>
3923                       </example>
3924                   </item>
3925                   <item>
3926                       The package's maintainer scripts are removed.
3927                   </item>
3928                   <item>
3929                       It is noted in the status database as being in a
3930                       sane state, namely not installed (any conffiles
3931                       it may have are ignored, rather than being
3932                       removed by <prgn>dpkg</prgn>).  Note that
3933                       disappearing packages do not have their prerm
3934                       called, because <prgn>dpkg</prgn> doesn't know
3935                       in advance that the package is going to
3936                       vanish.
3937                   </item>
3938                 </enumlist>
3939             </item>
3940
3941             <item>
3942                 Any files in the package we're unpacking that are also
3943                 listed in the file lists of other packages are removed
3944                 from those lists.  (This will lobotomize the file list
3945                 of the "conflicting" package if there is one.)
3946             </item>
3947
3948             <item>
3949                 The backup files made during installation, above, are
3950                 deleted.
3951             </item>
3952
3953             <item>
3954               <p>
3955                 The new package's status is now sane, and recorded as
3956                 "unpacked".
3957               </p>
3958
3959               <p>
3960                 Here is another point of no return - if the
3961                 conflicting package's removal fails we do not unwind
3962                 the rest of the installation; the conflicting package
3963                 is left in a half-removed limbo.
3964               </p>
3965             </item>
3966
3967             <item>
3968                 If there was a conflicting package we go and do the
3969                 removal actions (described below), starting with the
3970                 removal of the conflicting package's files (any that
3971                 are also in the package being installed have already
3972                 been removed from the conflicting package's file list,
3973                 and so do not get removed now).
3974             </item>
3975           </enumlist>
3976         </p>
3977       </sect>
3978
3979       <sect id="configdetails"><heading>Details of configuration</heading>
3980
3981         <p>
3982           When we configure a package (this happens with <tt>dpkg
3983             --install</tt> and <tt>dpkg --configure</tt>), we first
3984           update any <tt>conffile</tt>s and then call:
3985           <example compact="compact">
3986 <var>postinst</var> configure <var>most-recently-configured-version</var>
3987           </example>
3988         </p>
3989
3990         <p>
3991           No attempt is made to unwind after errors during
3992           configuration. If the configuration fails, the package is in
3993           a "Failed Config" state, and an error message is generated.
3994         </p>
3995
3996         <p>
3997           If there is no most recently configured version
3998           <prgn>dpkg</prgn> will pass a null argument.
3999           <footnote>
4000             <p>
4001               Historical note: Truly ancient (pre-1997) versions of
4002               <prgn>dpkg</prgn> passed <tt>&lt;unknown&gt;</tt>
4003               (including the angle brackets) in this case.  Even older
4004               ones did not pass a second argument at all, under any
4005               circumstance.  Note that upgrades using such an old dpkg
4006               version are unlikely to work for other reasons, even if
4007               this old argument behavior is handled by your postinst script.
4008             </p>
4009           </footnote>     
4010         </p>
4011       </sect>
4012
4013       <sect id="removedetails"><heading>Details of removal and/or
4014       configuration purging</heading>
4015
4016         <p>
4017           <enumlist>
4018             <item>
4019               <p>
4020                 <example compact="compact">
4021 <var>prerm</var> remove
4022                 </example>
4023               </p>
4024               <p>
4025                 If prerm fails during replacement due to conflict
4026                 <example>
4027 <var>conflictor's-postinst</var> abort-remove \
4028   in-favour <var>package</var> <var>new-version</var>
4029                 </example>
4030                 Or else we call:
4031                 <example>
4032 <var>postinst</var> abort-remove
4033                 </example>
4034               </p>
4035               <p>
4036                 If this fails, the package is in a "Failed-Config"
4037                 state, or else it remains "Installed".
4038               </p>
4039             </item>
4040             <item>
4041                 The package's files are removed (except <tt>conffile</tt>s).
4042             </item>
4043             <item>
4044                 <example compact="compact">
4045 <var>postrm</var> remove
4046                 </example>
4047
4048               <p>
4049                 If it fails, there's no error unwind, and the package is in
4050                 an "Half-Installed" state.
4051               </p>
4052             </item>
4053             <item>
4054               <p>
4055                 All the maintainer scripts except the <prgn>postrm</prgn>
4056                 are removed.
4057               </p>
4058
4059               <p>
4060                 If we aren't purging the package we stop here.  Note
4061                 that packages which have no <prgn>postrm</prgn> and no
4062                 <tt>conffile</tt>s are automatically purged when
4063                 removed, as there is no difference except for the
4064                 <prgn>dpkg</prgn> status.
4065               </p>
4066             </item>
4067             <item>
4068                 The <tt>conffile</tt>s and any backup files
4069                 (<tt>~</tt>-files, <tt>#*#</tt> files,
4070                 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
4071                 are removed.
4072             </item>
4073             <item>
4074               <p>
4075                 <example compact="compact">
4076 <var>postrm</var> purge
4077                 </example>
4078               </p>
4079               <p>
4080                 If this fails, the package remains in a "Config-Files"
4081                 state.
4082               </p>
4083             </item>
4084             <item>
4085                 The package's file list is removed.
4086             </item>
4087           </enumlist>
4088
4089         </p>
4090       </sect>
4091     </chapt>
4092
4093
4094     <chapt id="relationships">
4095       <heading>Declaring relationships between packages</heading>
4096
4097       <sect id="depsyntax">
4098         <heading>Syntax of relationship fields</heading>
4099
4100         <p>
4101           These fields all have a uniform syntax.  They are a list of
4102           package names separated by commas.
4103         </p>
4104
4105         <p>
4106           In the <tt>Depends</tt>, <tt>Recommends</tt>,
4107           <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
4108           <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
4109           control file fields of the package, which declare
4110           dependencies on other packages, the package names listed may
4111           also include lists of alternative package names, separated
4112           by vertical bar (pipe) symbols <tt>|</tt>.  In such a case,
4113           if any one of the alternative packages is installed, that
4114           part of the dependency is considered to be satisfied.
4115         </p>
4116
4117         <p>
4118           All of the fields except for <tt>Provides</tt> may restrict
4119           their applicability to particular versions of each named
4120           package.  This is done in parentheses after each individual
4121           package name; the parentheses should contain a relation from
4122           the list below followed by a version number, in the format
4123           described in <ref id="f-Version">.
4124         </p>
4125
4126         <p>
4127           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
4128           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
4129           strictly earlier, earlier or equal, exactly equal, later or
4130           equal and strictly later, respectively.  The deprecated
4131           forms <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
4132           earlier/later or equal, rather than strictly earlier/later,
4133           so they should not appear in new packages (though
4134           <prgn>dpkg</prgn> still supports them).
4135         </p>
4136
4137         <p>
4138           Whitespace may appear at any point in the version
4139           specification subject to the rules in <ref
4140           id="controlsyntax">, and must appear where it's necessary to
4141           disambiguate; it is not otherwise significant.  All of the
4142           relationship fields may span multiple lines.  For
4143           consistency and in case of future changes to
4144           <prgn>dpkg</prgn> it is recommended that a single space be
4145           used after a version relationship and before a version
4146           number; it is also conventional to put a single space after
4147           each comma, on either side of each vertical bar, and before
4148           each open parenthesis.  When wrapping a relationship field, it
4149           is conventional to do so after a comma and before the space
4150           following that comma.
4151         </p>
4152
4153         <p>
4154           For example, a list of dependencies might appear as:
4155           <example compact="compact">
4156 Package: mutt
4157 Version: 1.3.17-1
4158 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
4159           </example>
4160         </p>
4161
4162         <p>
4163           All fields that specify build-time relationships
4164           (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
4165           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
4166           may be restricted to a certain set of architectures.  This
4167           is indicated in brackets after each individual package name and
4168           the optional version specification.  The brackets enclose a
4169           list of Debian architecture names separated by whitespace.
4170           Exclamation marks may be prepended to each of the names.
4171           (It is not permitted for some names to be prepended with
4172           exclamation marks while others aren't.) If the current Debian
4173           host architecture is not in this list and there are no
4174           exclamation marks in the list, or it is in the list with a
4175           prepended exclamation mark, the package name and the
4176           associated version specification are ignored completely for
4177           the purposes of defining the relationships.
4178         </p>
4179
4180         <p>
4181           For example:
4182           <example compact="compact">
4183 Source: glibc
4184 Build-Depends-Indep: texinfo
4185 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
4186   hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
4187           </example>
4188         </p>
4189
4190         <p>
4191           Note that the binary package relationship fields such as
4192           <tt>Depends</tt> appear in one of the binary package
4193           sections of the control file, whereas the build-time
4194           relationships such as <tt>Build-Depends</tt> appear in the
4195           source package section of the control file (which is the
4196           first section).
4197         </p>
4198       </sect>
4199
4200       <sect id="binarydeps">
4201         <heading>Binary Dependencies - <tt>Depends</tt>,
4202           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
4203           <tt>Pre-Depends</tt>
4204         </heading>
4205
4206         <p>
4207           Packages can declare in their control file that they have
4208           certain relationships to other packages - for example, that
4209           they may not be installed at the same time as certain other
4210           packages, and/or that they depend on the presence of others.
4211         </p>
4212
4213         <p>
4214           This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
4215           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
4216           <tt>Breaks</tt> and <tt>Conflicts</tt> control file fields.
4217         </p>
4218
4219         <p>
4220           These seven fields are used to declare a dependency
4221           relationship by one package on another.  Except for
4222           <tt>Enhances</tt> and <tt>Breaks</tt>, they appear in the
4223           depending (binary) package's control file.
4224           (<tt>Enhances</tt> appears in the recommending package's
4225           control file, and <tt>Breaks</tt> appears in the version of
4226           depended-on package which causes the named package to
4227           break).
4228         </p>
4229
4230         <p>
4231           A <tt>Depends</tt> field takes effect <em>only</em> when a
4232           package is to be configured.  It does not prevent a package
4233           being on the system in an unconfigured state while its
4234           dependencies are unsatisfied, and it is possible to replace
4235           a package whose dependencies are satisfied and which is
4236           properly installed with a different version whose
4237           dependencies are not and cannot be satisfied; when this is
4238           done the depending package will be left unconfigured (since
4239           attempts to configure it will give errors) and will not
4240           function properly.  If it is necessary, a
4241           <tt>Pre-Depends</tt> field can be used, which has a partial
4242           effect even when a package is being unpacked, as explained
4243           in detail below.  (The other three dependency fields,
4244           <tt>Recommends</tt>, <tt>Suggests</tt> and
4245           <tt>Enhances</tt>, are only used by the various front-ends
4246           to <prgn>dpkg</prgn> such as <prgn>apt-get</prgn>,
4247           <prgn>aptitude</prgn>, and <prgn>dselect</prgn>.)
4248         </p>
4249
4250         <p>
4251           For this reason packages in an installation run are usually
4252           all unpacked first and all configured later; this gives
4253           later versions of packages with dependencies on later
4254           versions of other packages the opportunity to have their
4255           dependencies satisfied.
4256         </p>
4257
4258         <p>
4259           In case of circular dependencies, since installation or
4260           removal order honoring the dependency order can't be
4261           established, dependency loops are broken at some point
4262           (based on rules below), and some packages may not be able to
4263           rely on their dependencies being present when being
4264           installed or removed, depending on which side of the break
4265           of the circular dependency loop they happen to be on.  If one
4266           of the packages in the loop has no postinst script, then the
4267           cycle will be broken at that package, so as to ensure that
4268           all postinst scripts run with the dependencies properly
4269           configured if this is possible. Otherwise the breaking point
4270           is arbitrary.
4271         </p>
4272
4273         <p>
4274           The <tt>Depends</tt> field thus allows package maintainers
4275           to impose an order in which packages should be configured.
4276         </p>
4277
4278         <p>
4279           The meaning of the five dependency fields is as follows:
4280           <taglist>
4281             <tag><tt>Depends</tt></tag>
4282             <item>
4283               <p>
4284                 This declares an absolute dependency.  A package will
4285                 not be configured unless all of the packages listed in
4286                 its <tt>Depends</tt> field have been correctly
4287                 configured.
4288               </p>
4289
4290               <p>
4291                 The <tt>Depends</tt> field should be used if the
4292                 depended-on package is required for the depending
4293                 package to provide a significant amount of
4294                 functionality.
4295               </p>
4296
4297               <p>
4298                 The <tt>Depends</tt> field should also be used if the
4299                 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
4300                 <prgn>postrm</prgn> scripts require the package to be
4301                 present in order to run.  Note, however, that the
4302                 <prgn>postrm</prgn> cannot rely on any non-essential
4303                 packages to be present during the <tt>purge</tt>
4304                 phase.
4305             </item>
4306
4307             <tag><tt>Recommends</tt></tag>
4308             <item>
4309               <p>
4310                 This declares a strong, but not absolute, dependency.
4311               </p>
4312
4313               <p>
4314                 The <tt>Recommends</tt> field should list packages
4315                 that would be found together with this one in all but
4316                 unusual installations.
4317               </p>
4318             </item>
4319
4320             <tag><tt>Suggests</tt></tag>
4321             <item>
4322                 This is used to declare that one package may be more
4323                 useful with one or more others.  Using this field
4324                 tells the packaging system and the user that the
4325                 listed packages are related to this one and can
4326                 perhaps enhance its usefulness, but that installing
4327                 this one without them is perfectly reasonable.
4328             </item>
4329
4330             <tag><tt>Enhances</tt></tag>
4331             <item>
4332                 This field is similar to Suggests but works in the
4333                 opposite direction. It is used to declare that a
4334                 package can enhance the functionality of another
4335                 package.
4336             </item>
4337
4338             <tag><tt>Pre-Depends</tt></tag>
4339             <item>
4340               <p>
4341                 This field is like <tt>Depends</tt>, except that it
4342                 also forces <prgn>dpkg</prgn> to complete installation
4343                 of the packages named before even starting the
4344                 installation of the package which declares the
4345                 pre-dependency, as follows:
4346               </p>
4347
4348               <p>
4349                 When a package declaring a pre-dependency is about to
4350                 be <em>unpacked</em> the pre-dependency can be
4351                 satisfied if the depended-on package is either fully
4352                 configured, <em>or even if</em> the depended-on
4353                 package(s) are only unpacked or half-configured,
4354                 provided that they have been configured correctly at
4355                 some point in the past (and not removed or partially
4356                 removed since).  In this case, both the
4357                 previously-configured and currently unpacked or
4358                 half-configured versions must satisfy any version
4359                 clause in the <tt>Pre-Depends</tt> field.
4360               </p>
4361
4362               <p>
4363                 When the package declaring a pre-dependency is about
4364                 to be <em>configured</em>, the pre-dependency will be
4365                 treated as a normal <tt>Depends</tt>, that is, it will
4366                 be considered satisfied only if the depended-on
4367                 package has been correctly configured.
4368               </p>
4369
4370               <p>
4371                 <tt>Pre-Depends</tt> should be used sparingly,
4372                 preferably only by packages whose premature upgrade or
4373                 installation would hamper the ability of the system to
4374                 continue with any upgrade that might be in progress.
4375               </p>
4376
4377               <p>
4378                 <tt>Pre-Depends</tt> are also required if the
4379                 <prgn>preinst</prgn> script depends on the named
4380                 package.  It is best to avoid this situation if
4381                 possible.
4382               </p>
4383             </item>
4384           </taglist>
4385         </p>
4386
4387         <p>
4388           When selecting which level of dependency to use you should
4389           consider how important the depended-on package is to the
4390           functionality of the one declaring the dependency.  Some
4391           packages are composed of components of varying degrees of
4392           importance.  Such a package should list using
4393           <tt>Depends</tt> the package(s) which are required by the
4394           more important components.  The other components'
4395           requirements may be mentioned as Suggestions or
4396           Recommendations, as appropriate to the components' relative
4397           importance.
4398         </p>
4399       </sect>
4400
4401       <sect id="breaks">
4402         <heading>Packages which break other packages - <tt>Breaks</tt></heading>
4403
4404         <p>
4405           Using <tt>Breaks</tt> may cause problems for upgrades from older
4406           versions of Debian and should not be used until the stable
4407           release of Debian supports <tt>Breaks</tt>.
4408         </p>
4409
4410         <p>
4411           When one binary package declares that it breaks another,
4412           <prgn>dpkg</prgn> will refuse to allow the package which
4413           declares <tt>Breaks</tt> be installed unless the broken
4414           package is deconfigured first, and it will refuse to
4415           allow the broken package to be reconfigured.
4416         </p>
4417
4418         <p>
4419           A package will not be regarded as causing breakage merely
4420           because its configuration files are still installed; it must
4421           be at least half-installed.
4422         </p>
4423
4424         <p>
4425           A special exception is made for packages which declare that
4426           they break their own package name or a virtual package which
4427           they provide (see below): this does not count as a real
4428           breakage.
4429         </p>
4430
4431         <p>
4432           Normally a <tt>Breaks</tt> entry will have an "earlier than"
4433           version clause; such a <tt>Breaks</tt> is introduced in the
4434           version of an (implicit or explicit) dependency which
4435           violates an assumption or reveals a bug in earlier versions
4436           of the broken package.  This use of <tt>Breaks</tt> will
4437           inform higher-level package management tools that broken
4438           package must be upgraded before the new one.
4439         </p>
4440
4441         <p>
4442           If the breaking package also overwrites some files from the
4443           older package, it should use <tt>Replaces</tt> (not
4444           <tt>Conflicts</tt>) to ensure this goes smoothly.
4445         </p>
4446       </sect>
4447
4448       <sect id="conflicts">
4449         <heading>Conflicting binary packages - <tt>Conflicts</tt></heading>
4450
4451         <p>
4452           When one binary package declares a conflict with another
4453           using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
4454           refuse to allow them to be installed on the system at the
4455           same time.
4456         </p>
4457
4458         <p>
4459           If one package is to be installed, the other must be removed
4460           first - if the package being installed is marked as
4461           replacing (see <ref id="replaces">) the one on the system,
4462           or the one on the system is marked as deselected, or both
4463           packages are marked <tt>Essential</tt>, then
4464           <prgn>dpkg</prgn> will automatically remove the package
4465           which is causing the conflict, otherwise it will halt the
4466           installation of the new package with an error.  This
4467           mechanism is specifically designed to produce an error when
4468           the installed package is <tt>Essential</tt>, but the new
4469           package is not.
4470         </p>
4471
4472         <p>
4473           A package will not cause a conflict merely because its
4474           configuration files are still installed; it must be at least
4475           half-installed.
4476         </p>
4477
4478         <p>
4479           A special exception is made for packages which declare a
4480           conflict with their own package name, or with a virtual
4481           package which they provide (see below): this does not
4482           prevent their installation, and allows a package to conflict
4483           with others providing a replacement for it.  You use this
4484           feature when you want the package in question to be the only
4485           package providing some feature.
4486         </p>
4487
4488         <p>
4489           A <tt>Conflicts</tt> entry should almost never have an
4490           "earlier than" version clause.  This would prevent
4491           <prgn>dpkg</prgn> from upgrading or installing the package
4492           which declared such a conflict until the upgrade or removal
4493           of the conflicted-with package had been completed.  Instead,
4494           <tt>Breaks</tt> may be used (once <tt>Breaks</tt> is supported
4495           by the stable release of Debian).
4496         </p>
4497       </sect>
4498
4499       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
4500         </heading>
4501
4502         <p>
4503           As well as the names of actual ("concrete") packages, the
4504           package relationship fields <tt>Depends</tt>,
4505           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
4506           <tt>Pre-Depends</tt>, <tt>Breaks</tt>, <tt>Conflicts</tt>,
4507           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
4508           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
4509           may mention "virtual packages".
4510         </p>
4511
4512         <p>
4513           A <em>virtual package</em> is one which appears in the
4514           <tt>Provides</tt> control file field of another package.
4515           The effect is as if the package(s) which provide a
4516           particular virtual package name had been listed by name
4517           everywhere the virtual package name appears. (See also <ref
4518             id="virtual_pkg">)
4519         </p>
4520
4521         <p>
4522           If there are both concrete and virtual packages of the same
4523           name, then the dependency may be satisfied (or the conflict
4524           caused) by either the concrete package with the name in
4525           question or any other concrete package which provides the
4526           virtual package with the name in question.  This is so that,
4527           for example, supposing we have
4528           <example compact="compact">
4529 Package: foo
4530 Depends: bar
4531           </example> and someone else releases an enhanced version of
4532           the <tt>bar</tt> package they can say:
4533           <example compact="compact">
4534 Package: bar-plus
4535 Provides: bar
4536           </example>
4537           and the <tt>bar-plus</tt> package will now also satisfy the
4538           dependency for the <tt>foo</tt> package.
4539         </p>
4540
4541         <p>
4542           If a relationship field has a version number attached
4543           then only real packages will be considered to see whether
4544           the relationship is satisfied (or the prohibition violated,
4545           for a conflict or breakage) - it is assumed that a real
4546           package which provides the virtual package is not of the
4547           "right" version.  So, a <tt>Provides</tt> field may not
4548           contain version numbers, and the version number of the
4549           concrete package which provides a particular virtual package
4550           will not be looked at when considering a dependency on or
4551           conflict with the virtual package name.
4552         </p>
4553
4554         <p>
4555           It is likely that the ability will be added in a future
4556           release of <prgn>dpkg</prgn> to specify a version number for
4557           each virtual package it provides.  This feature is not yet
4558           present, however, and is expected to be used only
4559           infrequently.
4560         </p>
4561
4562         <p>
4563           If you want to specify which of a set of real packages
4564           should be the default to satisfy a particular dependency on
4565           a virtual package, you should list the real package as an
4566           alternative before the virtual one.
4567         </p>
4568       </sect>
4569
4570
4571       <sect id="replaces"><heading>Overwriting files and replacing
4572           packages - <tt>Replaces</tt></heading>
4573
4574         <p>
4575           Packages can declare in their control file that they should
4576           overwrite files in certain other packages, or completely
4577           replace other packages. The <tt>Replaces</tt> control file
4578           field has these two distinct purposes.
4579         </p>
4580
4581         <sect1><heading>Overwriting files in other packages</heading>
4582
4583           <p>
4584             Firstly, as mentioned before, it is usually an error for a
4585             package to contain files which are on the system in
4586             another package.
4587           </p>
4588
4589           <p>
4590             However, if the overwriting package declares that it
4591             <tt>Replaces</tt> the one containing the file being
4592             overwritten, then <prgn>dpkg</prgn> will replace the file
4593             from the old package with that from the new.  The file
4594             will no longer be listed as "owned" by the old package.
4595           </p>
4596
4597           <p>
4598             If a package is completely replaced in this way, so that
4599             <prgn>dpkg</prgn> does not know of any files it still
4600             contains, it is considered to have "disappeared".  It will
4601             be marked as not wanted on the system (selected for
4602             removal) and not installed.  Any <tt>conffile</tt>s
4603             details noted for the package will be ignored, as they
4604             will have been taken over by the overwriting package.  The
4605             package's <prgn>postrm</prgn> script will be run with a
4606             special argument to allow the package to do any final
4607             cleanup required.  See <ref id="mscriptsinstact">.
4608             <footnote>
4609               <p>
4610                 Replaces is a one way relationship -- you have to              
4611                 install the replacing package after the replaced
4612                 package.
4613               </p>
4614             </footnote>
4615           </p>
4616
4617           <p>
4618             For this usage of <tt>Replaces</tt>, virtual packages (see
4619             <ref id="virtual">) are not considered when looking at a
4620             <tt>Replaces</tt> field - the packages declared as being
4621             replaced must be mentioned by their real names.
4622           </p>
4623
4624           <p>
4625             Furthermore, this usage of <tt>Replaces</tt> only takes
4626             effect when both packages are at least partially on the
4627             system at once, so that it can only happen if they do not
4628             conflict or if the conflict has been overridden.
4629           </p>
4630
4631         </sect1>
4632
4633         <sect1><heading>Replacing whole packages, forcing their
4634             removal</heading>
4635
4636           <p>
4637             Secondly, <tt>Replaces</tt> allows the packaging system to
4638             resolve which package should be removed when there is a
4639             conflict - see <ref id="conflicts">.  This usage only
4640             takes effect when the two packages <em>do</em> conflict,
4641             so that the two usages of this field do not interfere with
4642             each other.
4643           </p>
4644
4645           <p>
4646             In this situation, the package declared as being replaced
4647             can be a virtual package, so for example, all mail
4648             transport agents (MTAs) would have the following fields in
4649             their control files:
4650             <example compact="compact">
4651 Provides: mail-transport-agent
4652 Conflicts: mail-transport-agent
4653 Replaces: mail-transport-agent
4654             </example>
4655             ensuring that only one MTA can be installed at any one
4656             time.
4657         </sect1>
4658       </sect>
4659
4660       <sect id="sourcebinarydeps">
4661         <heading>Relationships between source and binary packages -
4662           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
4663           <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
4664         </heading>
4665
4666         <p>
4667           Source packages that require certain binary packages to be
4668           installed or absent at the time of building the package
4669           can declare relationships to those binary packages.
4670         </p>
4671
4672         <p>
4673           This is done using the <tt>Build-Depends</tt>,
4674           <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
4675           <tt>Build-Conflicts-Indep</tt> control file fields.
4676         </p>
4677
4678         <p>
4679           Build-dependencies on "build-essential" binary packages can be
4680           omitted. Please see <ref id="pkg-relations"> for more information.
4681         </p>
4682
4683         <p>
4684           The dependencies and conflicts they define must be satisfied
4685           (as defined earlier for binary packages) in order to invoke
4686           the targets in <tt>debian/rules</tt>, as follows:<footnote>
4687             <p>
4688               If you make "build-arch" or "binary-arch", you need
4689               Build-Depends.  If you make "build-indep" or
4690               "binary-indep", you need Build-Depends and
4691               Build-Depends-Indep.  If you make "build" or "binary",
4692               you need both.
4693             </p>
4694             <p>
4695               There is no Build-Depends-Arch; this role is essentially
4696               met with Build-Depends.  Anyone building the
4697               <tt>build-indep</tt> and binary-indep<tt></tt> targets
4698               is basically assumed to be building the whole package
4699               anyway and so installs all build dependencies.  The
4700               autobuilders use <tt>dpkg-buildpackage -B</tt>, which
4701               calls <tt>build</tt> (not <tt>build-arch</tt>, since it
4702               does not yet know how to check for its existence) and
4703               <tt>binary-arch</tt>.
4704             </p>
4705             <p>
4706               The purpose of the original split, I recall, was so that
4707               the autobuilders wouldn't need to install extra packages
4708               needed only for the binary-indep targets.  But without a
4709               build-arch/build-indep split, this didn't work, since
4710               most of the work is done in the build target, not in the
4711               binary target.
4712             </p>
4713           </footnote>
4714
4715           <taglist>
4716             <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
4717             <item>
4718                 The <tt>Build-Depends</tt> and
4719                 <tt>Build-Conflicts</tt> fields must be satisfied when
4720                 any of the following targets is invoked:
4721                 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
4722                 <tt>binary-arch</tt>, <tt>build-arch</tt>,
4723                 <tt>build-indep</tt> and <tt>binary-indep</tt>.
4724             </item>
4725             <tag><tt>Build-Depends-Indep</tt>,
4726               <tt>Build-Conflicts-Indep</tt></tag>
4727             <item>
4728                 The <tt>Build-Depends-Indep</tt> and
4729                 <tt>Build-Conflicts-Indep</tt> fields must be
4730                 satisfied when any of the following targets is
4731                 invoked: <tt>build</tt>, <tt>build-indep</tt>,
4732                 <tt>binary</tt> and <tt>binary-indep</tt>.
4733             </item>
4734           </taglist>
4735         </p>
4736
4737       </sect>
4738
4739     </chapt>
4740
4741
4742     <chapt id="sharedlibs"><heading>Shared libraries</heading>
4743
4744       <p>
4745         Packages containing shared libraries must be constructed with
4746         a little care to make sure that the shared library is always
4747         available.  This is especially important for packages whose
4748         shared libraries are vitally important, such as the C library
4749         (currently <tt>libc6</tt>).
4750       </p>
4751
4752       <p>
4753         Packages involving shared libraries should be split up into
4754         several binary packages. This section mostly deals with how
4755         this separation is to be accomplished; rules for files within
4756         the shared library packages are in <ref id="libraries"> instead.
4757       </p>
4758
4759       <sect id="sharedlibs-runtime">
4760         <heading>Run-time shared libraries</heading>
4761
4762       <p>
4763         The run-time shared library needs to be placed in a package
4764         whose name changes whenever the shared object version
4765         changes.<footnote>
4766             <p>
4767               Since it is common place to install several versions of a
4768               package that just provides shared libraries, it is a
4769               good idea that the library package should not
4770               contain any extraneous non-versioned files, unless they
4771               happen to be in versioned directories.</p>
4772           </footnote>
4773           The most common mechanism is to place it in a package
4774         called
4775         <package><var>libraryname</var><var>soversion</var></package>,
4776         where <file><var>soversion</var></file> is the version number
4777         in the soname of the shared library<footnote>
4778               The soname is the shared object name: it's the thing
4779               that has to match exactly between building an executable
4780               and running it for the dynamic linker to be able run the
4781               program.  For example, if the soname of the library is
4782               <file>libfoo.so.6</file>, the library package would be
4783               called <file>libfoo6</file>.
4784           </footnote>.
4785         Alternatively, if it would be confusing to directly append
4786         <var>soversion</var> to <var>libraryname</var> (e.g. because
4787         <var>libraryname</var> itself ends in a number), you may use
4788         <package><var>libraryname</var>-<var>soversion</var></package> and
4789         <package><var>libraryname</var>-<var>soversion</var>-dev</package>
4790         instead.
4791       </p>
4792
4793       <p>
4794         If you have several shared libraries built from the same
4795         source tree you may lump them all together into a single
4796         shared library package, provided that you change all of
4797         their sonames at once (so that you don't get filename
4798         clashes if you try to install different versions of the
4799         combined shared libraries package).
4800       </p>
4801
4802       <p>
4803         The package should install the shared libraries under
4804         their normal names.  For example, the <package>libgdbm3</package>
4805         package should install <file>libgdbm.so.3.0.0</file> as
4806         <file>/usr/lib/libgdbm.so.3.0.0</file>.  The files should not be
4807         renamed or re-linked by any <prgn>prerm</prgn> or
4808         <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
4809         of renaming things safely without affecting running programs,
4810         and attempts to interfere with this are likely to lead to
4811         problems.
4812       </p>
4813
4814       <p>
4815         Shared libraries should not be installed executable, since
4816         the dynamic linker does not require this and trying to
4817         execute a shared library usually results in a core dump.
4818       </p>
4819
4820       <p>
4821         The run-time library package should include the symbolic link that
4822         <prgn>ldconfig</prgn> would create for the shared libraries.
4823         For example, the <package>libgdbm3</package> package should include
4824         a symbolic link from <file>/usr/lib/libgdbm.so.3</file> to
4825         <file>libgdbm.so.3.0.0</file>.  This is needed so that the dynamic
4826         linker (for example <prgn>ld.so</prgn> or
4827         <prgn>ld-linux.so.*</prgn>) can find the library between the
4828         time that <prgn>dpkg</prgn> installs it and the time that
4829         <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
4830         script.<footnote>
4831             The package management system requires the library to be
4832             placed before the symbolic link pointing to it in the
4833             <file>.deb</file> file.  This is so that when
4834             <prgn>dpkg</prgn> comes to install the symlink
4835             (overwriting the previous symlink pointing at an older
4836             version of the library), the new shared library is already
4837             in place.  In the past, this was achieved by creating the
4838             library in the temporary packaging directory before
4839             creating the symlink.  Unfortunately, this was not always
4840             effective, since the building of the tar file in the
4841             <file>.deb</file> depended on the behavior of the underlying
4842             file system.  Some file systems (such as reiserfs) reorder
4843             the files so that the order of creation is forgotten.
4844             Since version 1.7.0, <prgn>dpkg</prgn>
4845             reorders the files itself as necessary when building a
4846             package.  Thus it is no longer important to concern
4847             oneself with the order of file creation.
4848         </footnote>
4849       </p>
4850
4851         <sect1 id="ldconfig">
4852           <heading><tt>ldconfig</tt></heading>
4853
4854         <p>
4855           Any package installing shared libraries in one of the default
4856           library directories of the dynamic linker (which are currently
4857           <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
4858           listed in <file>/etc/ld.so.conf</file><footnote>
4859             These are currently
4860             <list compact="compact">
4861               <item>/usr/local/lib</item>
4862               <item>/usr/lib/libc5-compat</item>
4863               <item>/lib/libc5-compat</item>
4864             </list>
4865           </footnote>
4866           must use <prgn>ldconfig</prgn> to update the shared library
4867           system.
4868         </p>
4869
4870         <p>
4871             The package maintainer scripts must only call
4872             <prgn>ldconfig</prgn> under these circumstances:
4873             <list compact="compact">
4874               <item>When the <prgn>postinst</prgn> script is run with a
4875                   first argument of <tt>configure</tt>, the script must call
4876                   <prgn>ldconfig</prgn>, and may optionally invoke
4877                   <prgn>ldconfig</prgn> at other times.
4878               </item>
4879               <item>When the <prgn>postrm</prgn> script is run with a
4880                   first argument of <tt>remove</tt>, the script should call
4881                   <prgn>ldconfig</prgn>.
4882               </item>
4883             </list>
4884          <footnote>
4885             <p>
4886               During install or upgrade, the preinst is called before
4887               the new files are installed, so calling "ldconfig" is
4888               pointless.  The preinst of an existing package can also be
4889               called if an upgrade fails.  However, this happens during
4890               the critical time when a shared libs may exist on-disk
4891               under a temporary name.  Thus, it is dangerous and
4892               forbidden by current policy to call "ldconfig" at this
4893               time.
4894             </p>
4895
4896             <p>
4897               When a package is installed or upgraded, "postinst
4898               configure" runs after the new files are safely on-disk.
4899               Since it is perfectly safe to invoke ldconfig
4900               unconditionally in a postinst, it is OK for a package to
4901               simply put ldconfig in its postinst without checking the
4902               argument.  The postinst can also be called to recover from
4903               a failed upgrade.  This happens before any new files are
4904               unpacked, so there is no reason to call "ldconfig" at this
4905               point.
4906             </p>
4907
4908             <p>
4909               For a package that is being removed, prerm is
4910               called with all the files intact, so calling ldconfig is
4911               useless.  The other calls to "prerm" happen in the case of
4912               upgrade at a time when all the files of the old package
4913               are on-disk, so again calling "ldconfig" is pointless.
4914             </p>
4915
4916             <p>
4917               postrm, on the other hand, is called with the "remove"
4918               argument just after the files are removed, so this is
4919               the proper time to call "ldconfig" to notify the system
4920               of the fact that the shared libraries from the package
4921               are removed.  The postrm can be called at several other
4922               times.  At the time of "postrm purge", "postrm
4923               abort-install", or "postrm abort-upgrade", calling
4924               "ldconfig" is useless because the shared lib files are
4925               not on-disk.  However, when "postrm" is invoked with
4926               arguments "upgrade", "failed-upgrade", or "disappear", a
4927               shared lib may exist on-disk under a temporary filename.
4928             </p>
4929           </footnote>
4930         </p>
4931         </sect1>
4932
4933       </sect>
4934
4935       <sect id="sharedlibs-support-files">
4936         <heading>Shared library support files</heading>
4937
4938         <p>
4939           If your package contains files whose names do not change with
4940           each change in the library shared object version, you must not
4941           put them in the shared library package.  Otherwise, several
4942           versions of the shared library cannot be installed at the same
4943           time without filename clashes, making upgrades and transitions
4944           unnecessarily difficult.
4945         </p>
4946
4947         <p>
4948           It is recommended that supporting files and run-time support
4949           programs that do not need to be invoked manually by users, but
4950           are nevertheless required for the package to function, be placed
4951           (if they are binary) in a subdirectory of <file>/usr/lib</file>,
4952           preferably under <file>/usr/lib/</file><var>package-name</var>.
4953           If the program or file is architecture independent, the
4954           recommendation is for it to be placed in a subdirectory of
4955           <file>/usr/share</file> instead, preferably under
4956           <file>/usr/share/</file><var>package-name</var>.  Following the
4957           <var>package-name</var> naming convention ensures that the file
4958           names change when the shared object version changes.
4959         </p>
4960
4961         <p>
4962           Run-time support programs that use the shared library but are
4963           not required for the library to function or files used by the
4964           shared library that can be used by any version of the shared
4965           library package should instead be put in a separate package.
4966           This package might typically be named
4967           <package><var>libraryname</var>-tools</package>; note the
4968           absence of the <var>soversion</var> in the package name.
4969         </p>
4970
4971         <p>
4972           Files and support programs only useful when compiling software
4973           against the library should be included in the development
4974           package for the library.<footnote>
4975             For example, a <file><var>package-name</var>-config</file>
4976             script or <package>pkg-config</package> configuration files.
4977           </footnote>
4978         </p>
4979       </sect>
4980
4981       <sect id="sharedlibs-static">
4982         <heading>Static libraries</heading>
4983
4984       <p>
4985         The static library (<file><var>libraryname.a</var></file>)
4986         is usually provided in addition to the shared version.
4987         It is placed into the development package (see below).
4988       </p>
4989
4990       <p>
4991         In some cases, it is acceptable for a library to be
4992         available in static form only; these cases include:
4993         <list>
4994           <item>libraries for languages whose shared library support
4995                 is immature or unstable</item>
4996           <item>libraries whose interfaces are in flux or under
4997                 development (commonly the case when the library's
4998                 major version number is zero, or where the ABI breaks
4999                 across patchlevels)</item>
5000           <item>libraries which are explicitly intended to be
5001                 available only in static form by their upstream
5002                 author(s)</item>
5003         </list>
5004       </p>
5005
5006       <sect id="sharedlibs-dev">
5007         <heading>Development files</heading>
5008
5009       <p>
5010         The development files associated to a shared library need to be
5011         placed in a package called
5012         <package><var>libraryname</var><var>soversion</var>-dev</package>,
5013         or if you prefer only to support one development version at a
5014         time, <package><var>libraryname</var>-dev</package>.
5015       </p>
5016
5017       <p>
5018         In case several development versions of a library exist, you may
5019         need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
5020         <ref id="conflicts">) to ensure that the user only installs one
5021         development version at a time (as different development versions are
5022         likely to have the same header files in them, which would cause a
5023         filename clash if both were installed).
5024       </p>
5025
5026       <p>
5027         The development package should contain a symlink for the associated
5028         shared library without a version number. For example, the
5029         <package>libgdbm-dev</package> package should include a symlink
5030         from <file>/usr/lib/libgdbm.so</file> to
5031         <file>libgdbm.so.3.0.0</file>.  This symlink is needed by the linker
5032         (<prgn>ld</prgn>) when compiling packages, as it will only look for
5033         <file>libgdbm.so</file> when compiling dynamically.
5034       </p>
5035       </sect>
5036
5037       <sect id="sharedlibs-intradeps">
5038         <heading>Dependencies between the packages of the same library</heading>
5039
5040         <p>
5041           Typically the development version should have an exact
5042           version dependency on the runtime library, to make sure that
5043           compilation and linking happens correctly.  The
5044           <tt>${binary:Version}</tt> substitution variable can be
5045           useful for this purpose.
5046           <footnote>
5047             Previously, <tt>${Source-Version}</tt> was used, but its name
5048             was confusing and it has been deprecated since dpkg 1.13.19.
5049           </footnote>
5050         </p>
5051       </sect>
5052
5053       <sect id="sharedlibs-shlibdeps">
5054         <heading>Dependencies between the library and other packages -
5055         the <tt>shlibs</tt> system</heading>
5056
5057         <p>
5058           If a package contains a binary or library which links to a
5059           shared library, we must ensure that when the package is
5060           installed on the system, all of the libraries needed are
5061           also installed.  This requirement led to the creation of the
5062           <tt>shlibs</tt> system, which is very simple in its design:
5063           any package which <em>provides</em> a shared library also
5064           provides information on the package dependencies required to
5065           ensure the presence of this library, and any package which
5066           <em>uses</em> a shared library uses this information to
5067           determine the dependencies it requires.  The files which
5068           contain the mapping from shared libraries to the necessary
5069           dependency information are called <file>shlibs</file> files.
5070         </p>
5071
5072         <p>
5073           Thus, when a package is built which contains any shared
5074           libraries, it must provide a <file>shlibs</file> file for other
5075           packages to use, and when a package is built which contains
5076           any shared libraries or compiled binaries, it must run
5077           <qref id="pkg-dpkg-shlibdeps"><prgn>dpkg-shlibdeps</prgn></qref>
5078           on these to determine the libraries used and hence the
5079           dependencies needed by this package.<footnote>
5080             <p>
5081               In the past, the shared libraries linked to were
5082               determined by calling <prgn>ldd</prgn>, but now
5083               <prgn>objdump</prgn> is used to do this.  The only
5084               change this makes to package building is that
5085               <prgn>dpkg-shlibdeps</prgn> must also be run on shared
5086               libraries, whereas in the past this was unnecessary.
5087               The rest of this footnote explains the advantage that
5088               this method gives.
5089             </p>
5090
5091             <p>
5092               We say that a binary <tt>foo</tt> <em>directly</em> uses
5093               a library <tt>libbar</tt> if it is explicitly linked
5094               with that library (that is, it uses the flag
5095               <tt>-lbar</tt> during the linking stage).  Other
5096               libraries that are needed by <tt>libbar</tt> are linked
5097               <em>indirectly</em> to <tt>foo</tt>, and the dynamic
5098               linker will load them automatically when it loads
5099               <tt>libbar</tt>.  A package should depend on
5100               the libraries it directly uses, and the dependencies for
5101               those libraries should automatically pull in the other
5102               libraries.
5103             </p>
5104
5105             <p>
5106               Unfortunately, the <prgn>ldd</prgn> program shows both
5107               the directly and indirectly used libraries, meaning that
5108               the dependencies determined included both direct and
5109               indirect dependencies.  The use of <prgn>objdump</prgn>
5110               avoids this problem by determining only the directly
5111               used libraries.
5112             </p>
5113
5114             <p>
5115               A good example of where this helps is the following.  We
5116               could update <tt>libimlib</tt> with a new version that
5117               supports a new graphics format called dgf (but retaining
5118               the same major version number).  If we used the old
5119               <prgn>ldd</prgn> method, every package that uses
5120               <tt>libimlib</tt> would need to be recompiled so it
5121               would also depend on <tt>libdgf</tt> or it wouldn't run
5122               due to missing symbols.  However with the new system,
5123               packages using <tt>libimlib</tt> can rely on
5124               <tt>libimlib</tt> itself having the dependency on
5125               <tt>libdgf</tt> and so they would not need rebuilding.
5126             </p>
5127           </footnote>
5128         </p>
5129
5130         <p>
5131           In the following sections, we will first describe where the
5132           various <tt>shlibs</tt> files are to be found, then how to
5133           use <prgn>dpkg-shlibdeps</prgn>, and finally the <tt>shlibs</tt>
5134           file format and how to create them if your package contains a
5135           shared library.
5136         </p>
5137
5138       <sect1>
5139         <heading>The <tt>shlibs</tt> files present on the system</heading>
5140
5141         <p>
5142           There are several places where <tt>shlibs</tt> files are
5143           found.  The following list gives them in the order in which
5144           they are read by
5145           <qref id="pkg-dpkg-shlibdeps"><prgn>dpkg-shlibdeps</prgn></qref>.
5146           (The first one which gives the required information is used.)
5147         </p>
5148
5149         <p>
5150           <list>
5151             <item>
5152               <p><file>debian/shlibs.local</file></p>
5153
5154               <p>
5155                 This lists overrides for this package.  Its use is
5156                 described below (see <ref id="shlibslocal">).
5157               </p>
5158             </item>
5159
5160             <item>
5161               <p><file>/etc/dpkg/shlibs.override</file></p>
5162
5163               <p>
5164                 This lists global overrides.  This list is normally
5165                 empty.  It is maintained by the local system
5166                 administrator.
5167               </p>
5168             </item>
5169
5170             <item>
5171               <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
5172
5173               <p>
5174                 When packages are being built, any
5175                 <file>debian/shlibs</file> files are copied into the
5176                 control file area of the temporary build directory and
5177                 given the name <file>shlibs</file>.  These files give
5178                 details of any shared libraries included in the
5179                 package.<footnote>
5180                     An example may help here.  Let us say that the
5181                     source package <tt>foo</tt> generates two binary
5182                     packages, <tt>libfoo2</tt> and
5183                     <tt>foo-runtime</tt>.  When building the binary
5184                     packages, the two packages are created in the
5185                     directories <file>debian/libfoo2</file> and
5186                     <file>debian/foo-runtime</file> respectively.
5187                     (<file>debian/tmp</file> could be used instead of one
5188                     of these.)  Since <tt>libfoo2</tt> provides the
5189                     <tt>libfoo</tt> shared library, it will require a
5190                     <tt>shlibs</tt> file, which will be installed in
5191                     <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
5192                     to become
5193                     <file>/var/lib/dpkg/info/libfoo2.shlibs</file>.  Then
5194                     when <prgn>dpkg-shlibdeps</prgn> is run on the
5195                     executable
5196                     <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
5197                     will examine the
5198                     <file>debian/libfoo2/DEBIAN/shlibs</file> file to
5199                     determine whether <tt>foo-prog</tt>'s library
5200                     dependencies are satisfied by any of the libraries
5201                     provided by <tt>libfoo2</tt>.  For this reason,
5202                     <prgn>dpkg-shlibdeps</prgn> must only be run once
5203                     all of the individual binary packages'
5204                     <tt>shlibs</tt> files have been installed into the
5205                     build directory.
5206                 </footnote>
5207               </p>
5208             </item>
5209
5210             <item>
5211               <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
5212
5213               <p>
5214                 These are the <file>shlibs</file> files corresponding to
5215                 all of the packages installed on the system, and are
5216                 maintained by the relevant package maintainers.
5217               </p>
5218             </item>
5219
5220             <item>
5221               <p><file>/etc/dpkg/shlibs.default</file></p>
5222
5223               <p>
5224                 This file lists any shared libraries whose packages
5225                 have failed to provide correct <file>shlibs</file> files.
5226                 It was used when the <file>shlibs</file> setup was first
5227                 introduced, but it is now normally empty.  It is
5228                 maintained by the <tt>dpkg</tt> maintainer.
5229               </p>
5230             </item>
5231           </list>
5232         </p>
5233       </sect1>
5234
5235       <sect1>
5236         <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
5237             <file>shlibs</file> files</heading>
5238
5239         <p>
5240           Put a call to
5241           <qref id="pkg-dpkg-shlibdeps"><prgn>dpkg-shlibdeps</prgn></qref>
5242           into your <file>debian/rules</file> file.  If your package
5243           contains only compiled binaries and libraries (but no scripts),
5244           you can use a command such as:
5245           <example compact="compact">
5246 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
5247   debian/tmp/usr/lib/*
5248           </example>
5249           Otherwise, you will need to explicitly list the compiled
5250           binaries and libraries.<footnote>
5251               If you are using <tt>debhelper</tt>, the
5252               <prgn>dh_shlibdeps</prgn> program will do this work for
5253               you.  It will also correctly handle multi-binary
5254               packages.
5255           </footnote>
5256         </p>
5257
5258         <p>
5259           This command puts the dependency information into the
5260           <file>debian/substvars</file> file, which is then used by
5261           <prgn>dpkg-gencontrol</prgn>.  You will need to place a
5262           <tt>${shlibs:Depends}</tt> variable in the <tt>Depends</tt>
5263           field in the control file for this to work.
5264         </p>
5265
5266         <p>
5267           If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
5268           done.  If it does complain you might need to create your own
5269           <file>debian/shlibs.local</file> file, as explained below (see
5270           <ref id="shlibslocal">).
5271         </p>
5272
5273         <p>
5274           If you have multiple binary packages, you will need to call
5275           <prgn>dpkg-shlibdeps</prgn> on each one which contains
5276           compiled libraries or binaries.  In such a case, you will
5277           need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
5278           utilities to specify a different <file>substvars</file> file.
5279         </p>
5280
5281         <p>
5282           If you are creating a udeb for use in the Debian Installer, you
5283           will need to specify that <prgn>dpkg-shlibdeps</prgn> should use
5284           the dependency line of type <tt>udeb</tt> by adding
5285           <tt>-tudeb</tt> as option<footnote>
5286               <prgn>dh_shlibdeps</prgn> from the <tt>debhelper</tt> suite
5287               will automatically add this option if it knows it is
5288               processing a udeb.
5289           </footnote>. If there is no dependency line of type <tt>udeb</tt>
5290           in the <file>shlibs</file> file, <prgn>dpkg-shlibdeps</prgn> will
5291           fall back to the regular dependency line.
5292         </p>
5293
5294         <p>
5295           For more details on dpkg-shlibdeps, please see
5296           <ref id="pkg-dpkg-shlibdeps"> and
5297           <manref name="dpkg-shlibdeps" section="1">.
5298         </p>
5299       </sect1>
5300
5301       <sect1 id="shlibs">
5302         <heading>The <file>shlibs</file> File Format</heading>
5303
5304         <p>
5305           Each <file>shlibs</file> file has the same format.  Lines
5306           beginning with <tt>#</tt> are considered to be comments and
5307           are ignored.  Each line is of the form:
5308           <example compact="compact">
5309 [<var>type</var>: ]<var>library-name</var> <var>soname-version</var> <var>dependencies ...</var>
5310           </example>
5311         </p>
5312
5313         <p>
5314           We will explain this by reference to the example of the
5315           <tt>zlib1g</tt> package, which (at the time of writing)
5316           installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
5317         </p>
5318
5319         <p>
5320           <var>type</var> is an optional element that indicates the type
5321           of package for which the line is valid. The only type currently
5322           in use is <tt>udeb</tt>. The colon and space after the type are
5323           required.
5324         </p>
5325
5326         <p>
5327           <var>library-name</var> is the name of the shared library,
5328           in this case <tt>libz</tt>.  (This must match the name part
5329           of the soname, see below.)
5330         </p>
5331
5332         <p>
5333           <var>soname-version</var> is the version part of the soname of
5334           the library.  The soname is the thing that must exactly match
5335           for the library to be recognized by the dynamic linker, and is
5336           usually of the form
5337           <tt><var>name</var>.so.<var>major-version</var></tt>, in our
5338           example, <tt>libz.so.1</tt>.<footnote>
5339               This can be determined using the command
5340               <example compact="compact">
5341 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
5342               </example>
5343           </footnote>
5344           The version part is the part which comes after
5345           <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
5346         </p>
5347
5348         <p>
5349           <var>dependencies</var> has the same syntax as a dependency
5350           field in a binary package control file.  It should give
5351           details of which packages are required to satisfy a binary
5352           built against the version of the library contained in the
5353           package.  See <ref id="depsyntax"> for details.
5354         </p>
5355
5356         <p>
5357           In our example, if the first version of the <tt>zlib1g</tt>
5358           package which contained a minor number of at least
5359           <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
5360           <tt>shlibs</tt> entry for this library could say:
5361           <example compact="compact">
5362 libz 1 zlib1g (>= 1:1.1.3)
5363           </example>
5364           The version-specific dependency is to avoid warnings from
5365           the dynamic linker about using older shared libraries with
5366           newer binaries.
5367         </p>
5368
5369         <p>
5370           As zlib1g also provides a udeb containing the shared library,
5371           there would also be a second line:
5372           <example compact="compact">
5373 udeb: libz 1 zlib1g-udeb (>= 1:1.1.3)
5374           </example>
5375         </p>
5376       </sect1>
5377
5378       <sect1>
5379         <heading>Providing a <file>shlibs</file> file</heading>
5380
5381         <p>
5382           If your package provides a shared library, you need to create
5383           a <file>shlibs</file> file following the format described above.
5384           It is usual to call this file <file>debian/shlibs</file> (but if
5385           you have multiple binary packages, you might want to call it
5386           <file>debian/shlibs.<var>package</var></file> instead).  Then
5387           let <file>debian/rules</file> install it in the control area:
5388           <example compact="compact">
5389 install -m644 debian/shlibs debian/tmp/DEBIAN
5390           </example>
5391           or, in the case of a multi-binary package:
5392           <example compact="compact">
5393 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
5394           </example>
5395           An alternative way of doing this is to create the
5396           <file>shlibs</file> file in the control area directly from
5397           <file>debian/rules</file> without using a <file>debian/shlibs</file>
5398           file at all,<footnote>
5399               This is what <prgn>dh_makeshlibs</prgn> in the
5400               <tt>debhelper</tt> suite does. If your package also has a udeb
5401               that provides a shared library, <prgn>dh_makeshlibs</prgn> can
5402               automatically generate the <tt>udeb:</tt> lines if you specify
5403               the name of the udeb with the <tt>--add-udeb</tt> option.
5404           </footnote>
5405           since the <file>debian/shlibs</file> file itself is ignored by
5406           <prgn>dpkg-shlibdeps</prgn>.
5407         </p>
5408
5409         <p>
5410           As <prgn>dpkg-shlibdeps</prgn> reads the
5411           <file>DEBIAN/shlibs</file> files in all of the binary packages
5412           being built from this source package, all of the
5413           <file>DEBIAN/shlibs</file> files should be installed before
5414           <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
5415           packages.
5416         </p>
5417       </sect1>
5418
5419       <sect1 id="shlibslocal">
5420         <heading>Writing the <file>debian/shlibs.local</file> file</heading>
5421
5422         <p>
5423           This file is intended only as a <em>temporary</em> fix if
5424           your binaries or libraries depend on a library whose package
5425           does not yet provide a correct <file>shlibs</file> file.
5426         </p>
5427
5428         <p>
5429           We will assume that you are trying to package a binary
5430           <tt>foo</tt>.  When you try running
5431           <prgn>dpkg-shlibdeps</prgn> you get the following error
5432           message (<tt>-O</tt> displays the dependency information on
5433           <tt>stdout</tt> instead of writing it to
5434           <tt>debian/substvars</tt>, and the lines have been wrapped
5435           for ease of reading):
5436           <example compact="compact">
5437 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
5438 dpkg-shlibdeps: warning: unable to find dependency
5439   information for shared library libbar (soname 1,
5440   path /usr/lib/libbar.so.1, dependency field Depends)
5441 shlibs:Depends=libc6 (>= 2.2.2-2)
5442           </example>
5443           You can then run <prgn>ldd</prgn> on the binary to find the
5444           full location of the library concerned:
5445           <example compact="compact">
5446 $ ldd foo
5447 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
5448 libc.so.6 => /lib/libc.so.6 (0x40032000)
5449 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
5450           </example>
5451           So the <prgn>foo</prgn> binary depends on the
5452           <prgn>libbar</prgn> shared library, but no package seems to
5453           provide a <file>*.shlibs</file> file handling
5454           <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>.  Let's
5455           determine the package responsible:
5456           <example compact="compact">
5457 $ dpkg -S /usr/lib/libbar.so.1
5458 bar1: /usr/lib/libbar.so.1
5459 $ dpkg -s bar1 | grep Version
5460 Version: 1.0-1
5461           </example>
5462           This tells us that the <tt>bar1</tt> package, version 1.0-1,
5463           is the one we are using.  Now we can file a bug against the
5464           <tt>bar1</tt> package and create our own
5465           <file>debian/shlibs.local</file> to locally fix the problem.
5466           Including the following line into your
5467           <file>debian/shlibs.local</file> file:
5468           <example compact="compact">
5469 libbar 1 bar1 (>= 1.0-1)
5470           </example>
5471           should allow the package build to work.
5472         </p>
5473
5474         <p>
5475           As soon as the maintainer of <tt>bar1</tt> provides a
5476           correct <file>shlibs</file> file, you should remove this line
5477           from your <file>debian/shlibs.local</file> file.  (You should
5478           probably also then have a versioned <tt>Build-Depends</tt>
5479           on <tt>bar1</tt> to help ensure that others do not have the
5480           same problem building your package.)
5481         </p>
5482       </sect1>
5483
5484       </sect>
5485
5486     </chapt>
5487
5488
5489     <chapt id="opersys"><heading>The Operating System</heading>
5490
5491       <sect>
5492         <heading>File system hierarchy</heading>
5493
5494
5495         <sect1 id="fhs">
5496           <heading>File system Structure</heading>
5497
5498           <p>
5499             The location of all installed files and directories must
5500             comply with the File system Hierarchy Standard (FHS),
5501             version 2.3, with the exceptions noted below, and except
5502             where doing so would violate other terms of Debian
5503             Policy.  The following exceptions to the FHS apply:
5504
5505             <enumlist>
5506               <item>
5507                 <p>
5508                   Legacy XFree86 servers are permitted to retain the
5509                   configuration file location 
5510                   <file>/etc/X11/XF86Config-4</file>.
5511                 </p>
5512               </item>
5513               <item>
5514                 <p>
5515                   The optional rules related to user specific
5516                   configuration files for applications are stored in
5517                   the user's home directory are relaxed.  It is
5518                   recommended that such files start with the
5519                   '<tt>.</tt>' character (a "dot file"), and if an
5520                   application needs to create more than one dot file
5521                   then the preferred placement is in a subdirectory
5522                   with a name starting with a '.' character, (a "dot
5523                   directory"). In this case it is recommended the
5524                   configuration files not start with the '.'
5525                   character.
5526                 </p>
5527               </item>
5528               <item>
5529                 <p>
5530                   The requirement for amd64 to use <file>/lib64</file>
5531                   for 64 bit binaries is removed.
5532                 </p>
5533               </item>
5534               <item>
5535                 <p>
5536                   The requirement that
5537                   <file>/usr/local/share/man</file> be "synonymous"
5538                   with <file>/usr/local/man</file> is relaxed to a
5539                   recommendation</p>
5540               </item>
5541               <item>
5542                 <p>
5543                   The requirement that windowmanagers with a single
5544                   configuration file call it <file>system.*wmrc</file>
5545                   is removed, as is the restriction that the window
5546                   manager subdirectory be named identically to the
5547                   window manager name itself.
5548                 </p>
5549               </item>
5550               <item>
5551                 <p>
5552                   The requirement that boot manager configuration
5553                   files live in <file>/etc</file>, or at least are
5554                   symlinked there, is relaxed to a recommendation.
5555                 </p>
5556               </item>
5557             </enumlist>
5558
5559           </p>
5560           <p>
5561             The version of this document referred here can be
5562             found in the <tt>debian-policy</tt> package or on <url
5563             id="http://www.debian.org/doc/packaging-manuals/fhs/"
5564               name="FHS (Debian copy)"> alongside this manual (or, if
5565             you have the <package>debian-policy</package> installed,
5566             you can try <url
5567               id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
5568               (local copy)">). The
5569             latest version, which may be a more recent version, may
5570             be found on
5571             <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
5572             Specific questions about following the standard may be
5573             asked on the <tt>debian-devel</tt> mailing list, or
5574             referred to the FHS mailing list (see the
5575             <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
5576             more information).
5577           </p>
5578         </sect1>
5579
5580         <sect1>
5581           <heading>Site-specific programs</heading>
5582
5583           <p>
5584             As mandated by the FHS, packages must not place any
5585             files in <file>/usr/local</file>, either by putting them in
5586             the file system archive to be unpacked by <prgn>dpkg</prgn>
5587             or by manipulating them in their maintainer scripts.
5588           </p>
5589
5590           <p>
5591             However, the package may create empty directories below
5592             <file>/usr/local</file> so that the system administrator knows
5593             where to place site-specific files.  These are not
5594             directories <em>in</em> <file>/usr/local</file>, but are
5595             children of directories in <file>/usr/local</file>.  These
5596             directories (<file>/usr/local/*/dir/</file>)
5597             should be removed on package removal if they are
5598             empty.
5599           </p>
5600
5601           <p>
5602             Note, that this applies only to directories <em>below</em>
5603             <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
5604             Packages must not create sub-directories in the directory
5605             <file>/usr/local</file> itself, except those listed in FHS,
5606             section 4.5.  However, you may create directories below
5607             them as you wish. You must not remove any of the
5608             directories listed in 4.5, even if you created them.
5609           </p>
5610
5611           <p>
5612             Since <file>/usr/local</file> can be mounted read-only from a
5613             remote server, these directories must be created and
5614             removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
5615             maintainer scripts and not be included in the
5616             <file>.deb</file> archive.  These scripts must not fail if
5617             either of these operations fail.
5618           </p>
5619
5620           <p>
5621             For example, the <tt>emacsen-common</tt> package could
5622             contain something like
5623             <example compact="compact">
5624 if [ ! -e /usr/local/share/emacs ]
5625 then
5626   if mkdir /usr/local/share/emacs 2>/dev/null
5627   then
5628     chown root:staff /usr/local/share/emacs
5629     chmod 2775 /usr/local/share/emacs
5630   fi
5631 fi
5632             </example>
5633             in its <prgn>postinst</prgn> script, and
5634             <example compact="compact">
5635 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
5636 rmdir /usr/local/share/emacs 2>/dev/null || true
5637             </example>
5638             in the <prgn>prerm</prgn> script.  (Note that this form is
5639             used to ensure that if the script is interrupted, the
5640             directory <file>/usr/local/share/emacs</file> will still be
5641             removed.)
5642           </p>
5643
5644           <p>
5645             If you do create a directory in <file>/usr/local</file> for
5646             local additions to a package, you should ensure that
5647             settings in <file>/usr/local</file> take precedence over the
5648             equivalents in <file>/usr</file>.
5649           </p>
5650
5651           <p>
5652             However, because <file>/usr/local</file> and its contents are
5653             for exclusive use of the local administrator, a package
5654             must not rely on the presence or absence of files or
5655             directories in <file>/usr/local</file> for normal operation.
5656           </p>
5657
5658           <p>
5659             The <file>/usr/local</file> directory itself and all the
5660             subdirectories created by the package should (by default) have
5661             permissions 2775 (group-writable and set-group-id) and be
5662             owned by <tt>root:staff</tt>.
5663           </p>
5664         </sect1>
5665
5666         <sect1>
5667           <heading>The system-wide mail directory</heading>
5668           <p>
5669             The system-wide mail directory is <file>/var/mail</file>. This
5670             directory is part of the base system and should not owned
5671             by any particular mail agents.  The use of the old
5672             location <file>/var/spool/mail</file> is deprecated, even
5673             though the spool may still be physically located there.
5674             To maintain partial upgrade compatibility for systems
5675             which have <file>/var/spool/mail</file> as their physical mail
5676             spool, packages using <file>/var/mail</file> must depend on
5677             either <package>libc6</package> (&gt;= 2.1.3-13), or on
5678             <package>base-files</package> (&gt;= 2.2.0), or on later
5679             versions of either one of these packages.
5680           </p>
5681         </sect1>
5682       </sect>
5683
5684       <sect>
5685         <heading>Users and groups</heading>
5686
5687         <sect1>
5688           <heading>Introduction</heading>
5689           <p>
5690             The Debian system can be configured to use either plain or
5691             shadow passwords.
5692           </p>
5693
5694           <p>
5695             Some user ids (UIDs) and group ids (GIDs) are reserved
5696             globally for use by certain packages.  Because some
5697             packages need to include files which are owned by these
5698             users or groups, or need the ids compiled into binaries,
5699             these ids must be used on any Debian system only for the
5700             purpose for which they are allocated. This is a serious
5701             restriction, and we should avoid getting in the way of
5702             local administration policies. In particular, many sites
5703             allocate users and/or local system groups starting at 100.
5704           </p>
5705
5706           <p>
5707             Apart from this we should have dynamically allocated ids,
5708             which should by default be arranged in some sensible
5709             order, but the behavior should be configurable.
5710           </p>
5711
5712           <p>
5713             Packages other than <tt>base-passwd</tt> must not modify
5714             <file>/etc/passwd</file>, <file>/etc/shadow</file>,
5715             <file>/etc/group</file> or <file>/etc/gshadow</file>.
5716           </p>
5717         </sect1>
5718
5719         <sect1>
5720           <heading>UID and GID classes</heading>
5721           <p>
5722             The UID and GID numbers are divided into classes as
5723             follows:
5724             <taglist>
5725               <tag>0-99:</tag>
5726               <item>
5727                 <p>
5728                   Globally allocated by the Debian project, the same
5729                   on every Debian system.  These ids will appear in
5730                   the <file>passwd</file> and <file>group</file> files of all
5731                   Debian systems, new ids in this range being added
5732                   automatically as the <tt>base-passwd</tt> package is
5733                   updated.
5734                 </p>
5735
5736                 <p>
5737                   Packages which need a single statically allocated
5738                   uid or gid should use one of these; their
5739                   maintainers should ask the <tt>base-passwd</tt>
5740                   maintainer for ids.
5741                 </p>
5742               </item>
5743
5744               <tag>100-999:</tag>
5745               <item>
5746                 <p>
5747                   Dynamically allocated system users and groups.
5748                   Packages which need a user or group, but can have
5749                   this user or group allocated dynamically and
5750                   differently on each system, should use <tt>adduser
5751                   --system</tt> to create the group and/or user.
5752                   <prgn>adduser</prgn> will check for the existence of
5753                   the user or group, and if necessary choose an unused
5754                   id based on the ranges specified in
5755                   <file>adduser.conf</file>.
5756                 </p>
5757               </item>
5758
5759               <tag>1000-29999:</tag>
5760               <item>
5761                 <p>
5762                   Dynamically allocated user accounts.  By default
5763                   <prgn>adduser</prgn> will choose UIDs and GIDs for
5764                   user accounts in this range, though
5765                   <file>adduser.conf</file> may be used to modify this
5766                   behavior.
5767                 </p>
5768               </item>
5769
5770               <tag>30000-59999:</tag>
5771               <item>
5772                 <p>Reserved.</p>
5773               </item>
5774
5775               <tag>60000-64999:</tag>
5776               <item>
5777                 <p>
5778                   Globally allocated by the Debian project, but only
5779                   created on demand. The ids are allocated centrally
5780                   and statically, but the actual accounts are only
5781                   created on users' systems on demand.
5782                 </p>
5783
5784                 <p>
5785                   These ids are for packages which are obscure or
5786                   which require many statically-allocated ids.  These
5787                   packages should check for and create the accounts in
5788                   <file>/etc/passwd</file> or <file>/etc/group</file> (using
5789                   <prgn>adduser</prgn> if it has this facility) if
5790                   necessary.  Packages which are likely to require
5791                   further allocations should have a "hole" left after
5792                   them in the allocation, to give them room to
5793                   grow.
5794                 </p>
5795               </item>
5796
5797               <tag>65000-65533:</tag>
5798               <item>
5799                 <p>Reserved.</p>
5800               </item>
5801
5802               <tag>65534:</tag>
5803               <item>
5804                 <p>
5805                   User <tt>nobody</tt>. The corresponding gid refers
5806                   to the group <tt>nogroup</tt>.
5807                 </p>
5808               </item>
5809
5810               <tag>65535:</tag>
5811               <item>
5812                 <p>
5813                   <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
5814                   not</em> be used, because it is the error return
5815                   sentinel value.
5816                 </p>
5817               </item>
5818             </taglist>
5819           </p>
5820         </sect1>
5821       </sect>
5822
5823       <sect id="sysvinit">
5824         <heading>System run levels and <file>init.d</file> scripts</heading>
5825
5826         <sect1 id="/etc/init.d">
5827           <heading>Introduction</heading>
5828
5829           <p>
5830             The <file>/etc/init.d</file> directory contains the scripts
5831             executed by <prgn>init</prgn> at boot time and when the
5832             init state (or "runlevel") is changed (see <manref
5833             name="init" section="8">).
5834           </p>
5835
5836           <p>
5837             There are at least two different, yet functionally
5838             equivalent, ways of handling these scripts.  For the sake
5839             of simplicity, this document describes only the symbolic
5840             link method. However, it must not be assumed by maintainer
5841             scripts that this method is being used, and any automated
5842             manipulation of the various runlevel behaviors by
5843             maintainer scripts must be performed using
5844             <prgn>update-rc.d</prgn> as described below and not by
5845             manually installing or removing symlinks.  For information
5846             on the implementation details of the other method,
5847             implemented in the <tt>file-rc</tt> package, please refer
5848             to the documentation of that package.
5849           </p>
5850
5851           <p>
5852             These scripts are referenced by symbolic links in the
5853             <file>/etc/rc<var>n</var>.d</file> directories.  When changing
5854             runlevels, <prgn>init</prgn> looks in the directory
5855             <file>/etc/rc<var>n</var>.d</file> for the scripts it should
5856             execute, where <tt><var>n</var></tt> is the runlevel that
5857             is being changed to, or <tt>S</tt> for the boot-up
5858             scripts.
5859           </p>
5860
5861           <p>
5862             The names of the links all have the form
5863             <file>S<var>mm</var><var>script</var></file> or
5864             <file>K<var>mm</var><var>script</var></file> where
5865             <var>mm</var> is a two-digit number and <var>script</var>
5866             is the name of the script (this should be the same as the
5867             name of the actual script in <file>/etc/init.d</file>).
5868           </p>
5869
5870           <p>
5871             When <prgn>init</prgn> changes runlevel first the targets
5872             of the links whose names start with a <tt>K</tt> are
5873             executed, each with the single argument <tt>stop</tt>,
5874             followed by the scripts prefixed with an <tt>S</tt>, each
5875             with the single argument <tt>start</tt>.  (The links are
5876             those in the <file>/etc/rc<var>n</var>.d</file> directory
5877             corresponding to the new runlevel.)  The <tt>K</tt> links
5878             are responsible for killing services and the <tt>S</tt>
5879             link for starting services upon entering the runlevel.
5880           </p>
5881
5882           <p>
5883             For example, if we are changing from runlevel 2 to
5884             runlevel 3, init will first execute all of the <tt>K</tt>
5885             prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
5886             all of the <tt>S</tt> prefixed scripts in that directory.
5887             The links starting with <tt>K</tt> will cause the
5888             referred-to file to be executed with an argument of
5889             <tt>stop</tt>, and the <tt>S</tt> links with an argument
5890             of <tt>start</tt>.
5891           </p>
5892
5893           <p>
5894             The two-digit number <var>mm</var> is used to determine
5895             the order in which to run the scripts: low-numbered links
5896             have their scripts run first.  For example, the
5897             <tt>K20</tt> scripts will be executed before the
5898             <tt>K30</tt> scripts.  This is used when a certain service
5899             must be started before another.  For example, the name
5900             server <prgn>bind</prgn> might need to be started before
5901             the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
5902             can set up its access lists.  In this case, the script
5903             that starts <prgn>bind</prgn> would have a lower number
5904             than the script that starts <prgn>inn</prgn> so that it
5905             runs first:
5906             <example compact="compact">
5907 /etc/rc2.d/S17bind
5908 /etc/rc2.d/S70inn
5909             </example>
5910           </p>
5911
5912           <p>
5913             The two runlevels 0 (halt) and 6 (reboot) are slightly
5914             different.  In these runlevels, the links with an
5915             <tt>S</tt> prefix are still called after those with a
5916             <tt>K</tt> prefix, but they too are called with the single
5917             argument <tt>stop</tt>.
5918           </p>
5919
5920           <p>
5921             Also, if the script name ends in <tt>.sh</tt>, the script
5922             will be sourced in runlevel <tt>S</tt> rather than being
5923             run in a forked subprocess, but will be explicitly run by
5924             <prgn>sh</prgn> in all other runlevels.
5925           </p>
5926         </sect1>
5927
5928         <sect1>
5929           <heading>Writing the scripts</heading>
5930
5931           <p>
5932             Packages that include daemons for system services should
5933             place scripts in <file>/etc/init.d</file> to start or stop
5934             services at boot time or during a change of runlevel.
5935             These scripts should be named
5936             <file>/etc/init.d/<var>package</var></file>, and they should
5937             accept one argument, saying what to do:
5938
5939             <taglist>
5940               <tag><tt>start</tt></tag>
5941               <item>start the service,</item>
5942
5943               <tag><tt>stop</tt></tag>
5944               <item>stop the service,</item>
5945
5946               <tag><tt>restart</tt></tag>
5947               <item>stop and restart the service if it's already running,
5948                   otherwise start the service</item>
5949
5950               <tag><tt>reload</tt></tag>
5951               <item><p>cause the configuration of the service to be
5952                   reloaded without actually stopping and restarting
5953                   the service,</item>
5954
5955               <tag><tt>force-reload</tt></tag>
5956               <item>cause the configuration to be reloaded if the
5957                   service supports this, otherwise restart the
5958                   service.</item>
5959             </taglist>
5960
5961             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
5962             <tt>force-reload</tt> options should be supported by all
5963             scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
5964             option is optional.
5965           </p>
5966
5967           <p>
5968             The <file>init.d</file> scripts must ensure that they will
5969             behave sensibly (i.e., returning success and not starting
5970             multiple copies of a service) if invoked with <tt>start</tt>
5971             when the service is already running, or with <tt>stop</tt>
5972             when it isn't, and that they don't kill unfortunately-named
5973             user processes.  The best way to achieve this is usually to
5974             use <prgn>start-stop-daemon</prgn> with the <tt>--oknodo</tt>
5975             option.
5976           </p>
5977
5978           <p>
5979             If a service reloads its configuration automatically (as
5980             in the case of <prgn>cron</prgn>, for example), the
5981             <tt>reload</tt> option of the <file>init.d</file> script
5982             should behave as if the configuration has been reloaded
5983             successfully.
5984           </p>
5985
5986           <p>
5987             The <file>/etc/init.d</file> scripts must be treated as
5988             configuration files, either (if they are present in the
5989             package, that is, in the .deb file) by marking them as
5990             <tt>conffile</tt>s, or, (if they do not exist in the .deb)
5991             by managing them correctly in the maintainer scripts (see
5992             <ref id="config-files">).  This is important since we want
5993             to give the local system administrator the chance to adapt
5994             the scripts to the local system, e.g., to disable a
5995             service without de-installing the package, or to specify
5996             some special command line options when starting a service,
5997             while making sure their changes aren't lost during the next
5998             package upgrade.
5999           </p>
6000
6001           <p>
6002             These scripts should not fail obscurely when the
6003             configuration files remain but the package has been
6004             removed, as configuration files remain on the system after
6005             the package has been removed.  Only when <prgn>dpkg</prgn>
6006             is executed with the <tt>--purge</tt> option will
6007             configuration files be removed.  In particular, as the
6008             <file>/etc/init.d/<var>package</var></file> script itself is
6009             usually a <tt>conffile</tt>, it will remain on the system
6010             if the package is removed but not purged.  Therefore, you
6011             should include a <tt>test</tt> statement at the top of the
6012             script, like this:
6013             <example compact="compact">
6014 test -f <var>program-executed-later-in-script</var> || exit 0
6015             </example>
6016           </p>
6017
6018           <p>
6019             Often there are some variables in the <file>init.d</file>
6020             scripts whose values control the behavior of the scripts,
6021             and which a system administrator is likely to want to
6022             change.  As the scripts themselves are frequently
6023             <tt>conffile</tt>s, modifying them requires that the
6024             administrator merge in their changes each time the package
6025             is upgraded and the <tt>conffile</tt> changes.  To ease
6026             the burden on the system administrator, such configurable
6027             values should not be placed directly in the script.
6028             Instead, they should be placed in a file in
6029             <file>/etc/default</file>, which typically will have the same
6030             base name as the <file>init.d</file> script.  This extra file
6031             should be sourced by the script when the script runs.  It
6032             must contain only variable settings and comments in SUSv3
6033             <prgn>sh</prgn> format.  It may either be a
6034             <tt>conffile</tt> or a configuration file maintained by
6035             the package maintainer scripts.  See <ref id="config-files">
6036             for more details.
6037           </p>
6038
6039           <p>
6040             To ensure that vital configurable values are always
6041             available, the <file>init.d</file> script should set default
6042             values for each of the shell variables it uses, either
6043             before sourcing the <file>/etc/default/</file> file or
6044             afterwards using something like the <tt>:
6045             ${VAR:=default}</tt> syntax.  Also, the <file>init.d</file>
6046             script must behave sensibly and not fail if the
6047             <file>/etc/default</file> file is deleted.
6048           </p>
6049         </sect1>
6050
6051         <sect1>
6052           <heading>Interfacing with the initscript system</heading>
6053
6054           <p>
6055             Maintainers should use the abstraction layer provided by
6056             the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
6057             programs to deal with initscripts in their packages'
6058             scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
6059             and <prgn>postrm</prgn>.
6060           </p>
6061
6062           <p>
6063             Directly managing the /etc/rc?.d links and directly
6064             invoking the <file>/etc/init.d/</file> initscripts should
6065             be done only by packages providing the initscript
6066             subsystem (such as <prgn>sysv-rc</prgn> and
6067             <prgn>file-rc</prgn>).
6068           </p>
6069
6070           <sect2>
6071             <heading>Managing the links</heading>
6072
6073             <p>
6074               The program <prgn>update-rc.d</prgn> is provided for
6075               package maintainers to arrange for the proper creation and
6076               removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
6077               or their functional equivalent if another method is being
6078               used.  This may be used by maintainers in their packages'
6079               <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.
6080             </p>
6081
6082             <p>
6083               You must not include any <file>/etc/rc<var>n</var>.d</file>
6084               symbolic links in the actual archive or manually create or
6085               remove the symbolic links in maintainer scripts; you must
6086               use the <prgn>update-rc.d</prgn> program instead.  (The
6087               former will fail if an alternative method of maintaining
6088               runlevel information is being used.)  You must not include
6089               the <file>/etc/rc<var>n</var>.d</file> directories themselves
6090               in the archive either.  (Only the <tt>sysvinit</tt>
6091               package may do so.)
6092             </p>
6093
6094             <p>
6095               By default <prgn>update-rc.d</prgn> will start services in
6096               each of the multi-user state runlevels (2, 3, 4, and 5)
6097               and stop them in the halt runlevel (0), the single-user
6098               runlevel (1) and the reboot runlevel (6).  The system
6099               administrator will have the opportunity to customize
6100               runlevels by simply adding, moving, or removing the
6101               symbolic links in <file>/etc/rc<var>n</var>.d</file> if
6102               symbolic links are being used, or by modifying
6103               <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
6104               is being used.
6105             </p>
6106
6107             <p>
6108               To get the default behavior for your package, put in your
6109               <prgn>postinst</prgn> script
6110               <example compact="compact">
6111                 update-rc.d <var>package</var> defaults
6112               </example>
6113               and in your <prgn>postrm</prgn>
6114               <example compact="compact">
6115                 if [ "$1" = purge ]; then
6116                 update-rc.d <var>package</var> remove
6117                 fi
6118               </example>. Note that if your package changes runlevels
6119               or priority, you may have to remove and recreate the links,
6120               since otherwise the old links may persist. Refer to the
6121               documentation of <prgn>update-rc.d</prgn>.
6122             </p>
6123
6124             <p>
6125               This will use a default sequence number of 20.  If it does
6126               not matter when or in which order the <file>init.d</file>
6127               script is run, use this default.  If it does, then you
6128               should talk to the maintainer of the <prgn>sysvinit</prgn>
6129               package or post to <tt>debian-devel</tt>, and they will
6130               help you choose a number.
6131             </p>
6132
6133             <p>
6134               For more information about using <tt>update-rc.d</tt>,
6135               please consult its man page <manref name="update-rc.d"
6136                 section="8">.
6137             </p>
6138           </sect2>
6139
6140           <sect2>
6141             <heading>Running initscripts</heading>
6142             <p>
6143               The program <prgn>invoke-rc.d</prgn> is provided to make
6144               it easier for package maintainers to properly invoke an
6145               initscript, obeying runlevel and other locally-defined
6146               constraints that might limit a package's right to start,
6147               stop and otherwise manage services. This program may be
6148               used by maintainers in their packages' scripts.
6149             </p>
6150
6151             <p>
6152               The package maintainer scripts must use
6153               <prgn>invoke-rc.d</prgn> to invoke the
6154               <file>/etc/init.d/*</file> initscripts, instead of
6155               calling them directly.
6156             </p>
6157
6158             <p>
6159               By default, <prgn>invoke-rc.d</prgn> will pass any
6160               action requests (start, stop, reload, restart...) to the
6161               <file>/etc/init.d</file> script, filtering out requests
6162               to start or restart a service out of its intended
6163               runlevels.
6164             </p>
6165
6166             <p>
6167               Most packages will simply need to change:
6168               <example compact="compact">/etc/init.d/&lt;package&gt;
6169               &lt;action&gt;</example> in their <prgn>postinst</prgn>
6170               and <prgn>prerm</prgn> scripts to:
6171               <example compact="compact">
6172         if which invoke-rc.d >/dev/null 2>&1; then
6173                 invoke-rc.d <var>package</var> &lt;action&gt;
6174         else
6175                 /etc/init.d/<var>package</var> &lt;action&gt;
6176         fi
6177               </example>
6178             </p>
6179
6180             <p>
6181               A package should register its initscript services using
6182               <prgn>update-rc.d</prgn> before it tries to invoke them
6183               using <prgn>invoke-rc.d</prgn>. Invocation of
6184               unregistered services may fail.
6185             </p>
6186
6187             <p>
6188               For more information about using
6189               <prgn>invoke-rc.d</prgn>, please consult its man page
6190               <manref name="invoke-rc.d" section="8">.
6191             </p>
6192           </sect2>
6193         </sect1>
6194
6195         <sect1>
6196           <heading>Boot-time initialization</heading>
6197
6198           <p>
6199             There used to be another directory, <file>/etc/rc.boot</file>,
6200             which contained scripts which were run once per machine
6201             boot. This has been deprecated in favour of links from
6202             <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
6203             described in <ref id="/etc/init.d">.  Packages must not
6204             place files in <file>/etc/rc.boot</file>.
6205           </p>
6206         </sect1>
6207
6208         <sect1>
6209           <heading>Example</heading>
6210
6211           <p>
6212             An example on which you can base your
6213             <file>/etc/init.d</file> scripts is found in
6214             <file>/etc/init.d/skeleton</file>.
6215           </p>
6216
6217         </sect1>
6218       </sect>
6219
6220       <sect>
6221         <heading>Console messages from <file>init.d</file> scripts</heading>
6222
6223         <p>
6224           This section describes the formats to be used for messages
6225           written to standard output by the <file>/etc/init.d</file>
6226           scripts.  The intent is to improve the consistency of
6227           Debian's startup and shutdown look and feel.  For this
6228           reason, please look very carefully at the details.  We want
6229           the messages to have the same format in terms of wording,
6230           spaces, punctuation and case of letters.
6231         </p>
6232
6233         <p>
6234           Here is a list of overall rules that should be used for
6235           messages generated by <file>/etc/init.d</file> scripts.  
6236         </p>
6237
6238         <p>
6239           <list>
6240             <item>
6241                 The message should fit in one line (fewer than 80
6242                 characters), start with a capital letter and end with
6243                 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
6244             </item>
6245
6246             <item>
6247               If the script is performing some time consuming task in
6248               the background (not merely starting or stopping a
6249               program, for instance), an ellipsis (three dots:
6250               <tt>...</tt>) should be output to the screen, with no
6251               leading or tailing whitespace or line feeds.
6252             </item>
6253
6254             <item>
6255               The messages should appear as if the computer is telling
6256               the user what it is doing (politely :-), but should not
6257                 mention "it" directly.  For example, instead of:
6258                 <example compact="compact">
6259 I'm starting network daemons: nfsd mountd.
6260                 </example>
6261                 the message should say
6262                 <example compact="compact">
6263 Starting network daemons: nfsd mountd.
6264                 </example>
6265             </item>
6266           </list>
6267         </p>
6268
6269         <p>
6270           <tt>init.d</tt> script should use the following  standard
6271           message formats for the situations enumerated below.
6272         </p>
6273
6274         <p>
6275           <list>
6276             <item>
6277               <p>When daemons are started</p>
6278
6279               <p>
6280                 If the script starts one or more daemons, the output
6281                 should look like this (a single line, no leading
6282                 spaces):
6283                 <example compact="compact">
6284 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
6285                 </example>
6286                 The <var>description</var> should describe the
6287                 subsystem the daemon or set of daemons are part of,
6288                 while <var>daemon-1</var> up to <var>daemon-n</var>
6289                 denote each daemon's name (typically the file name of
6290                 the program).
6291               </p>
6292
6293               <p>
6294                 For example, the output of <file>/etc/init.d/lpd</file>
6295                 would look like:
6296                 <example compact="compact">
6297 Starting printer spooler: lpd.
6298                 </example>
6299               </p>
6300
6301               <p>
6302                 This can be achieved by saying
6303                 <example compact="compact">
6304 echo -n "Starting printer spooler: lpd"
6305 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
6306 echo "."
6307                 </example>
6308                 in the script. If there are more than one daemon to
6309                 start, the output should look like this:
6310                 <example compact="compact">
6311 echo -n "Starting remote file system services:"
6312 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
6313 echo -n " mountd"; start-stop-daemon --start --quiet mountd
6314 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
6315 echo "."
6316                 </example>
6317                 This makes it possible for the user to see what is
6318                 happening and when the final daemon has been started.
6319                 Care should be taken in the placement of white spaces:
6320                 in the example above the system administrators can
6321                 easily comment out a line if they don't want to start
6322                 a specific daemon, while the displayed message still
6323                 looks good.
6324               </p>
6325             </item>
6326
6327             <item>
6328               <p>When a system parameter is being set</p>
6329
6330               <p>
6331                 If you have to set up different system parameters
6332                 during the system boot, you should use this format:
6333                 <example compact="compact">
6334 Setting <var>parameter</var> to "<var>value</var>".
6335                 </example>
6336               </p>
6337
6338               <p>
6339                 You can use a statement such as the following to get
6340                 the quotes right:
6341                 <example compact="compact">
6342 echo "Setting DNS domainname to \"$domainname\"."
6343                 </example>
6344               </p>
6345
6346               <p>
6347                 Note that the same symbol (<tt>"</tt>) is used for the left
6348                 and right quotation marks.  A grave accent (<tt>`</tt>) is
6349                 not a quote character; neither is an apostrophe
6350                 (<tt>'</tt>).
6351               </p>
6352             </item>
6353
6354             <item>
6355               <p>When a daemon is stopped or restarted</p>
6356
6357               <p>
6358                 When you stop or restart a daemon, you should issue a
6359                 message identical to the startup message, except that
6360                 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
6361                 or <tt>Restarting</tt> respectively.
6362               </p>
6363
6364               <p>
6365                 For example, stopping the printer daemon will look like
6366                 this:
6367                 <example compact="compact">
6368 Stopping printer spooler: lpd.
6369                 </example>
6370               </p>
6371             </item>
6372
6373             <item>
6374               <p>When something is executed</p>
6375
6376               <p>
6377                 There are several examples where you have to run a
6378                 program at system startup or shutdown to perform a
6379                 specific task, for example, setting the system's clock
6380                 using <prgn>netdate</prgn> or killing all processes
6381                 when the system shuts down.  Your message should look
6382                 like this:
6383                 <example compact="compact">
6384 Doing something very useful...done.
6385                 </example>
6386                 You should print the <tt>done.</tt> immediately after
6387                 the job has been completed, so that the user is
6388                 informed why they have to wait.  You can get this
6389                 behavior by saying
6390                 <example compact="compact">
6391 echo -n "Doing something very useful..."
6392 do_something
6393 echo "done."
6394                 </example>
6395                 in your script.
6396               </p>
6397             </item>
6398
6399             <item>
6400               <p>When the configuration is reloaded</p>
6401
6402               <p>
6403                 When a daemon is forced to reload its configuration
6404                 files you should use the following format:
6405                 <example compact="compact">
6406 Reloading <var>description</var> configuration...done.
6407                 </example>
6408                 where <var>description</var> is the same as in the
6409                 daemon starting message.
6410               </p>
6411             </item>
6412           </list>
6413         </p>
6414       </sect>
6415
6416       <sect>
6417         <heading>Cron jobs</heading>
6418
6419         <p>
6420           Packages must not modify the configuration file
6421           <file>/etc/crontab</file>, and they must not modify the files in
6422           <file>/var/spool/cron/crontabs</file>.</p>
6423
6424         <p>
6425           If a package wants to install a job that has to be executed
6426           via cron, it should place a file with the name of the
6427           package in one or more of the following directories:
6428           <example compact="compact">
6429 /etc/cron.hourly
6430 /etc/cron.daily
6431 /etc/cron.weekly
6432 /etc/cron.monthly
6433           </example>
6434           As these directory names imply, the files within them are
6435           executed on an hourly, daily, weekly, or monthly basis,
6436           respectively. The exact times are listed in
6437           <file>/etc/crontab</file>.</p>
6438
6439         <p>
6440           All files installed in any of these directories must be
6441           scripts (e.g., shell scripts or Perl scripts) so that they
6442           can easily be modified by the local system administrator.
6443           In addition, they must be treated as configuration files.
6444         </p>
6445
6446         <p>
6447           If a certain job has to be executed at some other frequency or
6448           at a specific time, the package should install a file
6449           <file>/etc/cron.d/<var>package</var></file>. This file uses the
6450           same syntax as <file>/etc/crontab</file> and is processed by
6451           <prgn>cron</prgn> automatically. The file must also be
6452           treated as a configuration file. (Note that entries in the
6453           <file>/etc/cron.d</file> directory are not handled by
6454           <prgn>anacron</prgn>. Thus, you should only use this
6455           directory for jobs which may be skipped if the system is not
6456           running.)</p>
6457
6458         <p>
6459           The scripts or crontab entries in these directories should
6460           check if all necessary programs are installed before they
6461           try to execute them. Otherwise, problems will arise when a
6462           package was removed but not purged since configuration files
6463           are kept on the system in this situation.</p>
6464       </sect>
6465
6466       <sect id="menus">
6467         <heading>Menus</heading>
6468
6469         <p>
6470           The Debian <tt>menu</tt> package provides a standard
6471           interface between packages providing applications and
6472           <em>menu programs</em> (either X window managers or
6473           text-based menu programs such as <prgn>pdmenu</prgn>).
6474         </p>
6475
6476         <p>
6477           All packages that provide applications that need not be
6478           passed any special command line arguments for normal
6479           operation should register a menu entry for those
6480           applications, so that users of the <tt>menu</tt> package
6481           will automatically get menu entries in their window
6482           managers, as well in shells like <tt>pdmenu</tt>.
6483         </p>
6484
6485         <p>
6486           Menu entries should follow the current menu policy.
6487         </p>
6488
6489         <p>
6490           The menu policy can be found in the <tt>menu-policy</tt>
6491           files in the <tt>debian-policy</tt> package.
6492           It is also available from the Debian web mirrors at
6493           <tt><url name="/doc/packaging-manuals/menu-policy/"
6494                 id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>.
6495         </p>
6496
6497         <p>
6498           Please also refer to the <em>Debian Menu System</em>
6499           documentation that comes with the <package>menu</package>
6500           package for information about how to register your
6501           applications.
6502         </p>
6503       </sect>
6504
6505       <sect id="mime">
6506         <heading>Multimedia handlers</heading>
6507
6508         <p>
6509           MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
6510           is a mechanism for encoding files and data streams and
6511           providing meta-information about them, in particular their
6512           type (e.g.  audio or video) and format (e.g. PNG, HTML,
6513           MP3).
6514         </p>
6515
6516         <p>
6517           Registration of MIME type handlers allows programs like mail
6518           user agents and web browsers to invoke these handlers to
6519           view, edit or display MIME types they don't support directly.
6520         </p>
6521
6522         <p>
6523           Packages which provide the ability to view/show/play,
6524           compose, edit or print MIME types should register themselves
6525           as such following the current MIME support policy.
6526         </p>
6527
6528         <p>
6529           The MIME support policy can be found in the <tt>mime-policy</tt>
6530           files in the <tt>debian-policy</tt> package.
6531           It is also available from the Debian web mirrors at
6532           <tt><url name="/doc/packaging-manuals/mime-policy/"
6533                 id="http://www.debian.org/doc/packaging-manuals/mime-policy/"></tt>.
6534         </p>
6535
6536       </sect>
6537
6538       <sect>
6539         <heading>Keyboard configuration</heading>
6540
6541         <p>
6542           To achieve a consistent keyboard configuration so that all
6543           applications interpret a keyboard event the same way, all
6544           programs in the Debian distribution must be configured to
6545           comply with the following guidelines.
6546         </p>
6547
6548         <p>
6549           The following keys must have the specified interpretations:
6550
6551           <taglist>
6552             <tag><tt>&lt;--</tt></tag>
6553             <item>delete the character to the left of the cursor</item>
6554
6555             <tag><tt>Delete</tt></tag>
6556             <item>delete the character to the right of the cursor</item>
6557
6558             <tag><tt>Control+H</tt></tag>
6559             <item>emacs: the help prefix</item>
6560           </taglist>
6561
6562           The interpretation of any keyboard events should be
6563           independent of the terminal that is used, be it a virtual
6564           console, an X terminal emulator, an rlogin/telnet session,
6565           etc.
6566         </p>
6567
6568         <p>
6569           The following list explains how the different programs
6570           should be set up to achieve this:
6571         </p>
6572
6573         <p>
6574           <list>
6575             <item>
6576                 <tt>&lt;--</tt> generates <tt>KB_BackSpace</tt> in X.
6577             </item>
6578
6579             <item>
6580                 <tt>Delete</tt> generates <tt>KB_Delete</tt> in X.
6581             </item>
6582
6583             <item>
6584                 X translations are set up to make
6585                 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
6586                 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
6587                 is the vt220 escape code for the "delete character"
6588                 key).  This must be done by loading the X resources
6589                 using <prgn>xrdb</prgn> on all local X displays, not
6590                 using the application defaults, so that the
6591                 translation resources used correspond to the
6592                 <prgn>xmodmap</prgn> settings.
6593             </item>
6594
6595             <item>
6596                 The Linux console is configured to make
6597                 <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
6598                 generate <tt>ESC [ 3 ~</tt>.
6599             </item>
6600
6601             <item>
6602                 X applications are configured so that <tt>&lt;</tt>
6603                 deletes left, and <tt>Delete</tt> deletes right.  Motif
6604                 applications already work like this.
6605             </item>
6606
6607             <item>
6608                 Terminals should have <tt>stty erase ^?</tt> .
6609             </item>
6610
6611             <item>
6612                 The <tt>xterm</tt> terminfo entry should have <tt>ESC
6613                 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
6614                 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.
6615             </item>
6616
6617             <item>
6618                 Emacs is programmed to map <tt>KB_Backspace</tt> or
6619                 the <tt>stty erase</tt> character to
6620                 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
6621                 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
6622                 <tt>^H</tt> to <tt>help</tt> as always.
6623             </item>
6624
6625             <item>
6626                 Other applications use the <tt>stty erase</tt>
6627                 character and <tt>kdch1</tt> for the two delete keys,
6628                 with ASCII DEL being "delete previous character" and
6629                 <tt>kdch1</tt> being "delete character under
6630                 cursor".
6631             </item>
6632
6633           </list>
6634         </p>
6635
6636         <p>
6637           This will solve the problem except for the following
6638           cases:
6639         </p>
6640
6641         <p>
6642           <list>
6643             <item>
6644                 Some terminals have a <tt>&lt;--</tt> key that cannot
6645                 be made to produce anything except <tt>^H</tt>.  On
6646                 these terminals Emacs help will be unavailable on
6647                 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
6648                 character takes precedence in Emacs, and has been set
6649                 correctly).  <tt>M-x help</tt> or <tt>F1</tt> (if
6650                 available) can be used instead.
6651             </item>
6652
6653             <item>
6654                 Some operating systems use <tt>^H</tt> for <tt>stty
6655                 erase</tt>.  However, modern telnet versions and all
6656                 rlogin versions propagate <tt>stty</tt> settings, and
6657                 almost all UNIX versions honour <tt>stty erase</tt>.
6658                 Where the <tt>stty</tt> settings are not propagated
6659                 correctly, things can be made to work by using
6660                 <tt>stty</tt> manually.
6661             </item>
6662
6663             <item>
6664                 Some systems (including previous Debian versions) use
6665                 <prgn>xmodmap</prgn> to arrange for both
6666                 <tt>&lt;--</tt> and <tt>Delete</tt> to generate
6667                 <tt>KB_Delete</tt>.  We can change the behavior of
6668                 their X clients using the same X resources that we use
6669                 to do it for our own clients, or configure our clients
6670                 using their resources when things are the other way
6671                 around.  On displays configured like this
6672                 <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
6673                 will.
6674             </item>
6675
6676             <item>
6677                 Some operating systems have different <tt>kdch1</tt>
6678                 settings in their <tt>terminfo</tt> database for
6679                 <tt>xterm</tt> and others.  On these systems the
6680                 <tt>Delete</tt> key will not work correctly when you
6681                 log in from a system conforming to our policy, but
6682                 <tt>&lt;--</tt> will.
6683             </item>
6684           </list>
6685         </p>
6686       </sect>
6687
6688       <sect>
6689         <heading>Environment variables</heading>
6690
6691         <p>
6692           A program must not depend on environment variables to get
6693           reasonable defaults.  (That's because these environment
6694           variables would have to be set in a system-wide
6695           configuration file like <file>/etc/profile</file>, which is not
6696           supported by all shells.)
6697         </p>
6698
6699         <p>
6700           If a program usually depends on environment variables for its
6701           configuration, the program should be changed to fall back to
6702           a reasonable default configuration if these environment
6703           variables are not present. If this cannot be done easily
6704           (e.g., if the source code of a non-free program is not
6705           available), the program must be replaced by a small
6706           "wrapper" shell script which sets the environment variables
6707           if they are not already defined, and calls the original program.
6708         </p>
6709
6710         <p>
6711           Here is an example of a wrapper script for this purpose:
6712
6713           <example compact="compact">
6714 #!/bin/sh
6715 BAR=${BAR:-/var/lib/fubar}
6716 export BAR
6717 exec /usr/lib/foo/foo "$@"
6718           </example>
6719         </p>
6720
6721         <p>
6722           Furthermore, as <file>/etc/profile</file> is a configuration
6723           file of the <prgn>base-files</prgn> package, other packages must
6724           not put any environment variables or other commands into that
6725           file.
6726         </p>
6727       </sect>
6728
6729       <sect id="doc-base">
6730         <heading>Registering Documents using doc-base</heading>
6731
6732         <p>
6733           The <package>doc-base</package> package implements a
6734           flexible mechanism for handling and presenting
6735           documentation. The recommended practice is for every Debian
6736           package that provides online documentation (other than just
6737           manual pages) to register these documents with
6738           <package>doc-base</package> by installing a
6739           <package>doc-base</package> control file via the
6740           <prgn/install-docs/ script at installation time and
6741           de-register the manuals again when the package is removed.
6742         </p> 
6743         <p>
6744           Please refer to the documentation that comes with the
6745           <package>doc-base</package>  package for information and
6746           details. 
6747         </p>
6748       </sect>
6749
6750     </chapt>
6751
6752
6753     <chapt id="files">
6754       <heading>Files</heading>
6755
6756       <sect>
6757         <heading>Binaries</heading>
6758
6759         <p>
6760           Two different packages must not install programs with
6761           different functionality but with the same filenames.  (The
6762           case of two programs having the same functionality but
6763           different implementations is handled via "alternatives" or
6764           the "Conflicts" mechanism.  See <ref id="maintscripts"> and
6765           <ref id="conflicts"> respectively.)  If this case happens,
6766           one of the programs must be renamed.  The maintainers should
6767           report this to the <tt>debian-devel</tt> mailing list and
6768           try to find a consensus about which program will have to be
6769           renamed.  If a consensus cannot be reached, <em>both</em>
6770           programs must be renamed.
6771         </p>
6772
6773         <p>
6774          By default, when a package is being built, any binaries
6775          created should include debugging information, as well as
6776          being compiled with optimization.  You should also turn on
6777          as many reasonable compilation warnings as possible; this
6778          makes life easier for porters, who can then look at build
6779          logs for possible problems.  For the C programming language,
6780          this means the following compilation parameters should be
6781          used:
6782           <example compact="compact">
6783 CC = gcc
6784 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
6785 LDFLAGS = # none
6786 INSTALL = install -s # (or use strip on the files in debian/tmp)
6787           </example>
6788         </p>
6789
6790         <p>
6791           Note that by default all installed binaries should be stripped,
6792           either by using the <tt>-s</tt> flag to
6793           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
6794           the binaries after they have been copied into
6795           <file>debian/tmp</file> but before the tree is made into a
6796           package.
6797         </p>
6798
6799         <p>
6800           Although binaries in the build tree should be compiled with
6801           debugging information by default, it can often be difficult to
6802           debug programs if they are also subjected to compiler
6803           optimization.  For this reason, it is recommended to support the
6804           standardized environment variable <tt>DEB_BUILD_OPTIONS</tt>
6805           (see <ref id="debianrules-options">).  This variable can contain
6806           several flags to change how a package is compiled and built.
6807         </p>
6808
6809         <p>
6810           It is up to the package maintainer to decide what
6811           compilation options are best for the package.  Certain
6812           binaries (such as computationally-intensive programs) will
6813           function better with certain flags (<tt>-O3</tt>, for
6814           example); feel free to use them.  Please use good judgment
6815           here.  Don't use flags for the sake of it; only use them
6816           if there is good reason to do so.  Feel free to override
6817           the upstream author's ideas about which compilation
6818           options are best: they are often inappropriate for our
6819           environment.
6820         </p>
6821       </sect>
6822
6823
6824       <sect id="libraries">
6825         <heading>Libraries</heading>
6826
6827         <p>
6828           If the package is <strong>architecture: any</strong>, then
6829           the shared library compilation and linking flags must have
6830           <tt>-fPIC</tt>, or the package shall not build on some of
6831           the supported architectures<footnote>
6832             <p>
6833               If you are using GCC, <tt>-fPIC</tt> produces code with
6834               relocatable position independent code, which is required for
6835               most architectures to create a shared library, with i386 and
6836               perhaps some others where non position independent code is
6837               permitted in a shared library.
6838             </p>
6839             <p>
6840               Position independent code may have a performance penalty,
6841               especially on <tt>i386</tt>. However, in most cases the
6842               speed penalty must be measured against the memory wasted on
6843               the few architectures where non position independent code is
6844               even possible.
6845             </p>
6846           </footnote>. Any exception to this rule must be discussed on
6847           the mailing list <em>debian-devel@lists.debian.org</em>, and
6848           a rough consensus obtained.  The reasons for not compiling
6849           with <tt>-fPIC</tt> flag must be recorded in the file
6850           <tt>README.Debian</tt>, and care must be taken to either
6851           restrict the architecture or arrange for <tt>-fPIC</tt> to
6852           be used on architectures where it is required.<footnote>
6853             <p>
6854               Some of the reasons why this might be required is if the
6855               library contains hand crafted assembly code that is not
6856               relocatable, the speed penalty is excessive for compute
6857               intensive libs, and similar reasons.
6858             </p>
6859           </footnote>
6860         </p>
6861         <p>
6862           As to the static libraries, the common case is not to have
6863           relocatable code, since there is no benefit, unless in specific
6864           cases; therefore the static version must not be compiled
6865           with the <tt>-fPIC</tt> flag. Any exception to this rule
6866           should be discussed on the mailing list
6867           <em>debian-devel@lists.debian.org</em>,  and the reasons for
6868           compiling with the <tt>-fPIC</tt> flag must be recorded in
6869           the file <tt>README.Debian</tt>. <footnote>
6870             <p>
6871               Some of the reasons for linking static libraries with
6872               the <tt>-fPIC</tt> flag are if, for example, one needs a
6873               Perl API for a library that is under rapid development,
6874               and has an unstable API, so shared libraries are
6875               pointless at this phase of the library's development. In
6876               that case, since Perl needs a library with relocatable
6877               code, it may make sense to create a static library with
6878               relocatable code. Another reason cited is if you are
6879               distilling various libraries into a common shared
6880               library, like <tt>mklibs</tt> does in the Debian
6881               installer project.
6882             </p>
6883           </footnote>
6884         </p>
6885         <p>
6886           In other words, if both a shared and a static library is
6887           being built, each source unit (<tt>*.c</tt>, for example,
6888           for C files) will need to be compiled twice, for the normal
6889           case. 
6890         </p>
6891         <p>
6892           You must specify the gcc option <tt>-D_REENTRANT</tt>
6893           when building a library (either static or shared) to make
6894           the library compatible with LinuxThreads.
6895         </p>
6896
6897         <p>
6898           Although not enforced by the build tools, shared libraries
6899           must be linked against all libraries that they use symbols from
6900           in the same way that binaries are.  This ensures the correct
6901           functioning of the <qref id="sharedlibs-shlibdeps">shlibs</qref>
6902           system and guarantees that all libraries can be safely opened
6903           with <tt>dlopen()</tt>.  Packagers may wish to use the gcc
6904           option <tt>-Wl,-z,defs</tt> when building a shared library.
6905           Since this option enforces symbol resolution at build time,
6906           a missing library reference will be caught early as a fatal
6907           build error.
6908         </p>
6909
6910         <p>
6911           All installed shared libraries should be stripped with
6912           <example compact="compact">
6913 strip --strip-unneeded <var>your-lib</var>
6914           </example>
6915           (The option <tt>--strip-unneeded</tt> makes
6916           <prgn>strip</prgn> remove only the symbols which aren't
6917           needed for relocation processing.)  Shared libraries can
6918           function perfectly well when stripped, since the symbols for
6919           dynamic linking are in a separate part of the ELF object
6920           file.<footnote>
6921               You might also want to use the options
6922               <tt>--remove-section=.comment</tt> and
6923               <tt>--remove-section=.note</tt> on both shared libraries
6924               and executables, and <tt>--strip-debug</tt> on static
6925               libraries.
6926           </footnote>
6927         </p>
6928
6929         <p>
6930           Note that under some circumstances it may be useful to
6931           install a shared library unstripped, for example when
6932           building a separate package to support debugging.
6933         </p>
6934
6935         <p>
6936           Shared object files (often <file>.so</file> files) that are not
6937           public libraries, that is, they are not meant to be linked
6938           to by third party executables (binaries of other packages),
6939           should be installed in subdirectories of the
6940           <file>/usr/lib</file> directory.  Such files are exempt from the
6941           rules that govern ordinary shared libraries, except that
6942           they must not be installed executable and should be
6943           stripped.<footnote>
6944               A common example are the so-called "plug-ins",
6945               internal shared objects that are dynamically loaded by
6946               programs using <manref name="dlopen" section="3">.
6947           </footnote>
6948         </p>
6949
6950         <p>
6951           Packages containing shared libraries that may be linked to
6952           by other packages' binaries, but which for some
6953           <em>compelling</em> reason can not be installed in
6954           <file>/usr/lib</file> directory, may install the shared library
6955           files in subdirectories of the <file>/usr/lib</file> directory,
6956           in which case they should arrange to add that directory in
6957           <file>/etc/ld.so.conf</file> in the package's post-installation
6958           script, and remove it in the package's post-removal script.
6959         </p>
6960
6961         <p>
6962           An ever increasing number of packages are using
6963           <prgn>libtool</prgn> to do their linking.  The latest GNU
6964           libtools (>= 1.3a) can take advantage of the metadata in the
6965           installed <prgn>libtool</prgn> archive files (<file>*.la</file>
6966           files).  The main advantage of <prgn>libtool</prgn>'s
6967           <file>.la</file> files is that it allows <prgn>libtool</prgn> to
6968           store and subsequently access metadata with respect to the
6969           libraries it builds.  <prgn>libtool</prgn> will search for
6970           those files, which contain a lot of useful information about
6971           a library (such as library dependency information for static
6972           linking).  Also, they're <em>essential</em> for programs
6973           using <tt>libltdl</tt>.<footnote>
6974               Although <prgn>libtool</prgn> is fully capable of
6975               linking against shared libraries which don't have
6976               <tt>.la</tt> files, as it is a mere shell script it can
6977               add considerably to the build time of a
6978               <prgn>libtool</prgn>-using package if that shell script
6979               has to derive all this information from first principles
6980               for each library every time it is linked.  With the
6981               advent of <prgn>libtool</prgn> version 1.4 (and to a
6982               lesser extent <prgn>libtool</prgn> version 1.3), the
6983               <file>.la</file> files also store information about
6984               inter-library dependencies which cannot necessarily be
6985               derived after the <file>.la</file> file is deleted.
6986           </footnote>
6987         </p>
6988
6989         <p>
6990           Packages that use <prgn>libtool</prgn> to create shared
6991           libraries should include the <file>.la</file> files in the
6992           <tt>-dev</tt> package, unless the package relies on
6993           <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
6994           the <tt>.la</tt> files must go in the run-time library
6995           package.
6996         </p>
6997
6998         <p>
6999           You must make sure that you use only released versions of
7000           shared libraries to build your packages; otherwise other
7001           users will not be able to run your binaries
7002           properly. Producing source packages that depend on
7003           unreleased compilers is also usually a bad
7004           idea.
7005         </p>
7006       </sect>
7007
7008
7009       <sect>
7010         <heading>Shared libraries</heading>
7011         <p>
7012           This section has moved to <ref id="sharedlibs">.
7013         </p>
7014       </sect>
7015
7016
7017       <sect id="scripts">
7018         <heading>Scripts</heading>
7019
7020         <p>
7021           All command scripts, including the package maintainer
7022           scripts inside the package and used by <prgn>dpkg</prgn>,
7023           should have a <tt>#!</tt> line naming the shell to be used
7024           to interpret them.
7025         </p>
7026
7027         <p>
7028           In the case of Perl scripts this should be
7029           <tt>#!/usr/bin/perl</tt>.
7030         </p>
7031
7032         <p>
7033           When scripts are installed into a directory in the system
7034           PATH, the script name should not include an extension such
7035           as <tt>.sh</tt> or <tt>.pl</tt> that denotes the scripting
7036           language currently used to implement it.
7037         </p>
7038         <p>
7039           Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
7040           should almost certainly start with <tt>set -e</tt> so that
7041           errors are detected.  Every script should use
7042           <tt>set -e</tt> or check the exit status of <em>every</em>
7043           command.
7044         </p>
7045
7046         <p>
7047           Scripts may assume that <file>/bin/sh</file> implements the
7048           SUSv3 Shell Command Language<footnote>
7049             Single UNIX Specification, version 3, which is also IEEE
7050             1003.1-2004 (POSIX), and is available on the World Wide Web
7051             from <url id="http://www.unix.org/version3/online.html"
7052                       name="The Open Group"> after free
7053             registration.</footnote>
7054           plus the following additional features not mandated by
7055           SUSv3:<footnote>
7056             These features are in widespread use in the Linux community
7057             and are implemented in all of bash, dash, and ksh, the most
7058             common shells users may wish to use as <file>/bin/sh</file>.
7059           </footnote>
7060           <list>
7061             <item><tt>echo -n</tt>, if implemented as a shell built-in,
7062               must not generate a newline.</item>
7063             <item><tt>test</tt>, if implemented as a shell built-in, must
7064               support <tt>-a</tt> and <tt>-o</tt> as binary logical
7065               operators.</item>
7066             <item><tt>local</tt> to create a scoped variable must be
7067               supported, including listing multiple variables in a single
7068               local command and assigning a value to a variable at the
7069               same time as localizing it.  <tt>local</tt> may or
7070               may not preserve the variable value from an outer scope if
7071               no assignment is present.  Uses such as:
7072 <example compact>
7073 fname () {
7074     local a b c=delta d
7075     # ... use a, b, c, d ...
7076 }
7077 </example>
7078               must be supported and must set the value of <tt>c</tt> to
7079               <tt>delta</tt>.
7080             </item>
7081           </list>
7082           If a shell script requires non-SUSv3 features from the shell
7083           interpreter other than those listed above, the appropriate shell
7084           must be specified in the first line of the script (e.g.,
7085           <tt>#!/bin/bash</tt>) and the package must depend on the package
7086           providing the shell (unless the shell package is marked
7087           "Essential", as in the case of <prgn>bash</prgn>).
7088         </p>
7089
7090         <p>
7091           You may wish to restrict your script to SUSv3 features plus the
7092           above set when possible so that it may use <file>/bin/sh</file>
7093           as its interpreter. If your script works with <prgn>dash</prgn>
7094           (originally called <prgn>ash</prgn>), it probably complies with
7095           the above requirements, but if you are in doubt, use
7096           <file>/bin/bash</file>.
7097         </p>
7098
7099         <p>
7100           Perl scripts should check for errors when making any
7101           system calls, including <tt>open</tt>, <tt>print</tt>,
7102           <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
7103         </p>
7104
7105         <p>
7106           <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
7107           scripting languages.  See <em>Csh Programming Considered
7108           Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
7109           can be found at <url id="http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/">.
7110           If an upstream package comes with <prgn>csh</prgn> scripts
7111           then you must make sure that they start with
7112           <tt>#!/bin/csh</tt> and make your package depend on the
7113           <prgn>c-shell</prgn> virtual package.
7114         </p>
7115
7116         <p>
7117           Any scripts which create files in world-writeable
7118           directories (e.g., in <file>/tmp</file>) must use a
7119           mechanism which will fail atomically if a file with the same
7120           name already exists.
7121         </p>
7122
7123         <p>
7124           The Debian base system provides the <prgn>tempfile</prgn>
7125           and <prgn>mktemp</prgn> utilities for use by scripts for
7126           this purpose.
7127         </p>
7128       </sect>
7129
7130
7131       <sect>
7132         <heading>Symbolic links</heading>
7133
7134         <p>
7135           In general, symbolic links within a top-level directory
7136           should be relative, and symbolic links pointing from one
7137           top-level directory into another should be absolute. (A
7138           top-level directory is a sub-directory of the root
7139           directory <file>/</file>.)
7140         </p>
7141
7142         <p>
7143           In addition, symbolic links should be specified as short as
7144           possible, i.e., link targets like <file>foo/../bar</file> are
7145           deprecated.
7146         </p>
7147
7148         <p>
7149           Note that when creating a relative link using
7150           <prgn>ln</prgn> it is not necessary for the target of the
7151           link to exist relative to the working directory you're
7152           running <prgn>ln</prgn> from, nor is it necessary to change
7153           directory to the directory where the link is to be made.
7154           Simply include the string that should appear as the target
7155           of the link (this will be a pathname relative to the
7156           directory in which the link resides) as the first argument
7157           to <prgn>ln</prgn>.
7158         </p>
7159
7160         <p>
7161           For example, in your <prgn>Makefile</prgn> or
7162           <file>debian/rules</file>, you can do things like:
7163           <example compact="compact">
7164 ln -fs gcc $(prefix)/bin/cc
7165 ln -fs gcc debian/tmp/usr/bin/cc
7166 ln -fs ../sbin/sendmail $(prefix)/bin/runq
7167 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
7168           </example>
7169         </p>
7170
7171         <p>
7172           A symbolic link pointing to a compressed file should always
7173           have the same file extension as the referenced file. (For
7174           example, if a file <file>foo.gz</file> is referenced by a
7175           symbolic link, the filename of the link has to end with
7176           "<file>.gz</file>" too, as in <file>bar.gz</file>.)
7177         </p>
7178       </sect>
7179
7180       <sect>
7181         <heading>Device files</heading>
7182
7183         <p>
7184           Packages must not include device files in the package file
7185           tree.
7186         </p>
7187
7188         <p>
7189           If a package needs any special device files that are not
7190           included in the base system, it must call
7191           <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
7192           after notifying the user<footnote>
7193               This notification could be done via a (low-priority)
7194               debconf message, or an echo (printf) statement.
7195           </footnote>.
7196         </p>
7197
7198         <p>
7199           Packages must not remove any device files in the
7200           <prgn>postrm</prgn> or any other script. This is left to the
7201           system administrator.
7202         </p>
7203
7204         <p>
7205           Debian uses the serial devices
7206           <file>/dev/ttyS*</file>. Programs using the old
7207           <file>/dev/cu*</file> devices should be changed to use
7208           <file>/dev/ttyS*</file>.
7209         </p>
7210       </sect>
7211
7212       <sect id="config-files">
7213         <heading>Configuration files</heading>
7214
7215         <sect1>
7216           <heading>Definitions</heading>
7217
7218           <p>
7219             <taglist>
7220               <tag>configuration file</tag>
7221               <item>
7222                   A file that affects the operation of a program, or
7223                   provides site- or host-specific information, or
7224                   otherwise customizes the behavior of a program.
7225                   Typically, configuration files are intended to be
7226                   modified by the system administrator (if needed or
7227                   desired) to conform to local policy or to provide
7228                   more useful site-specific behavior.
7229               </item>
7230
7231               <tag><tt>conffile</tt></tag>
7232               <item>
7233                   A file listed in a package's <tt>conffiles</tt>
7234                   file, and is treated specially by <prgn>dpkg</prgn>
7235                   (see <ref id="configdetails">).
7236               </item>
7237             </taglist>
7238           </p>
7239
7240           <p>
7241             The distinction between these two is important; they are
7242             not interchangeable concepts. Almost all
7243             <tt>conffile</tt>s are configuration files, but many
7244             configuration files are not <tt>conffiles</tt>.
7245           </p>
7246
7247           <p>
7248             As noted elsewhere, <file>/etc/init.d</file> scripts,
7249             <file>/etc/default</file> files, scripts installed in
7250             <file>/etc/cron.{hourly,daily,weekly,monthly}</file>, and cron
7251             configuration installed in <file>/etc/cron.d</file> must be
7252             treated as configuration files.  In general, any script that
7253             embeds configuration information is de-facto a configuration
7254             file and should be treated as such.
7255           </p>
7256         </sect1>
7257
7258         <sect1>
7259           <heading>Location</heading>
7260
7261           <p>
7262             Any configuration files created or used by your package
7263             must reside in <file>/etc</file>. If there are several,
7264             consider creating a subdirectory of <file>/etc</file>
7265             named after your package.
7266           </p>
7267
7268           <p>
7269             If your package creates or uses configuration files
7270             outside of <file>/etc</file>, and it is not feasible to modify
7271             the package to use <file>/etc</file> directly, put the files
7272             in <file>/etc</file> and create symbolic links to those files
7273             from the location that the package requires.
7274           </p>
7275         </sect1>
7276
7277         <sect1>
7278           <heading>Behavior</heading>
7279
7280           <p>
7281             Configuration file handling must conform to the following
7282             behavior:
7283             <list compact="compact">
7284               <item>
7285                   local changes must be preserved during a package
7286                   upgrade, and
7287               </item>
7288               <item>
7289                   configuration files must be preserved when the
7290                   package is removed, and only deleted when the
7291                   package is purged.
7292               </item>
7293             </list>
7294           </p>
7295
7296           <p>
7297             The easy way to achieve this behavior is to make the
7298             configuration file a <tt>conffile</tt>. This is
7299             appropriate only if it is possible to distribute a default
7300             version that will work for most installations, although
7301             some system administrators may choose to modify it. This
7302             implies that the default version will be part of the
7303             package distribution, and must not be modified by the
7304             maintainer scripts during installation (or at any other
7305             time).
7306           </p>
7307
7308           <p>
7309             In order to ensure that local changes are preserved
7310             correctly, no package may contain or make hard links to
7311             conffiles.<footnote>
7312                 Rationale: There are two problems with hard links.
7313                 The first is that some editors break the link while
7314                 editing one of the files, so that the two files may
7315                 unwittingly become unlinked and different.  The second
7316                 is that <prgn>dpkg</prgn> might break the hard link
7317                 while upgrading <tt>conffile</tt>s.
7318             </footnote>
7319           </p>
7320
7321           <p>
7322             The other way to do it is via the maintainer scripts.  In
7323             this case, the configuration file must not be listed as a
7324             <tt>conffile</tt> and must not be part of the package
7325             distribution. If the existence of a file is required for
7326             the package to be sensibly configured it is the
7327             responsibility of the package maintainer to provide
7328             maintainer scripts which correctly create, update and
7329             maintain the file and remove it on purge.  (See <ref
7330             id="maintainerscripts"> for more information.)  These
7331             scripts must be idempotent (i.e., must work correctly if
7332             <prgn>dpkg</prgn> needs to re-run them due to errors
7333             during installation or removal), must cope with all the
7334             variety of ways <prgn>dpkg</prgn> can call maintainer
7335             scripts, must not overwrite or otherwise mangle the user's
7336             configuration without asking, must not ask unnecessary
7337             questions (particularly during upgrades), and must
7338             otherwise be good citizens.
7339           </p>
7340
7341           <p>
7342             The scripts are not required to configure every possible
7343             option for the package, but only those necessary to get
7344             the package running on a given system. Ideally the
7345             sysadmin should not have to do any configuration other
7346             than that done (semi-)automatically by the
7347             <prgn>postinst</prgn> script.
7348           </p>
7349
7350           <p>
7351             A common practice is to create a script called
7352             <file><var>package</var>-configure</file> and have the
7353             package's <prgn>postinst</prgn> call it if and only if the
7354             configuration file does not already exist.  In certain
7355             cases it is useful for there to be an example or template
7356             file which the maintainer scripts use.  Such files should
7357             be in <file>/usr/share/<var>package</var></file> or
7358             <file>/usr/lib/<var>package</var></file> (depending on whether
7359             they are architecture-independent or not).  There should
7360             be symbolic links to them from
7361             <file>/usr/share/doc/<var>package</var>/examples</file> if
7362             they are examples, and should be perfectly ordinary
7363             <prgn>dpkg</prgn>-handled files (<em>not</em>
7364             configuration files).
7365           </p>
7366
7367           <p>
7368             These two styles of configuration file handling must
7369             not be mixed, for that way lies madness:
7370             <prgn>dpkg</prgn> will ask about overwriting the file
7371             every time the package is upgraded.
7372           </p>
7373         </sect1>
7374
7375         <sect1>
7376           <heading>Sharing configuration files</heading>
7377
7378           <p>
7379             Packages which specify the same file as a
7380             <tt>conffile</tt> must be tagged as <em>conflicting</em>
7381             with each other.  (This is an instance of the general rule
7382             about not sharing files.  Note that neither alternatives
7383             nor diversions are likely to be appropriate in this case;
7384             in particular, <prgn>dpkg</prgn> does not handle diverted
7385             <tt>conffile</tt>s well.)
7386           </p>
7387
7388           <p>
7389             The maintainer scripts must not alter a <tt>conffile</tt>
7390             of <em>any</em> package, including the one the scripts
7391             belong to.
7392           </p>
7393
7394           <p>
7395             If two or more packages use the same configuration file
7396             and it is reasonable for both to be installed at the same
7397             time, one of these packages must be defined as
7398             <em>owner</em> of the configuration file, i.e., it will be
7399             the package which handles that file as a configuration
7400             file.  Other packages that use the configuration file must
7401             depend on the owning package if they require the
7402             configuration file to operate. If the other package will
7403             use the configuration file if present, but is capable of
7404             operating without it, no dependency need be declared.
7405           </p>
7406
7407           <p>
7408             If it is desirable for two or more related packages to
7409             share a configuration file <em>and</em> for all of the
7410             related packages to be able to modify that configuration
7411             file, then the following should be done:
7412             <enumlist compact="compact">
7413               <item>
7414                   One of the related packages (the "owning" package)
7415                   will manage the configuration file with maintainer
7416                   scripts as described in the previous section.
7417               </item>
7418               <item>
7419                   The owning package should also provide a program
7420                   that the other packages may use to modify the
7421                   configuration file.
7422               </item>
7423               <item>
7424                   The related packages must use the provided program
7425                   to make any desired modifications to the
7426                   configuration file.  They should either depend on
7427                   the core package to guarantee that the configuration
7428                   modifier program is available or accept gracefully
7429                   that they cannot modify the configuration file if it
7430                   is not.  (This is in addition to the fact that the
7431                   configuration file may not even be present in the
7432                   latter scenario.)
7433               </item>
7434             </enumlist>
7435           </p>
7436
7437           <p>
7438             Sometimes it's appropriate to create a new package which
7439             provides the basic infrastructure for the other packages
7440             and which manages the shared configuration files.  (The
7441             <tt>sgml-base</tt> package is a good example.)
7442           </p>
7443         </sect1>
7444
7445         <sect1>
7446           <heading>User configuration files ("dotfiles")</heading>
7447
7448           <p>
7449             The files in <file>/etc/skel</file> will automatically be
7450             copied into new user accounts by <prgn>adduser</prgn>.
7451             No other program should reference the files in
7452             <file>/etc/skel</file>.
7453           </p>
7454
7455           <p>
7456             Therefore, if a program needs a dotfile to exist in
7457             advance in <file>$HOME</file> to work sensibly, that dotfile
7458             should be installed in <file>/etc/skel</file> and treated as a
7459             configuration file.
7460           </p>
7461
7462           <p>
7463             However, programs that require dotfiles in order to
7464             operate sensibly are a bad thing, unless they do create
7465             the dotfiles themselves automatically.
7466           </p>
7467
7468           <p>
7469             Furthermore, programs should be configured by the Debian
7470             default installation to behave as closely to the upstream
7471             default behavior as possible.
7472           </p>
7473
7474           <p>
7475             Therefore, if a program in a Debian package needs to be
7476             configured in some way in order to operate sensibly, that
7477             should be done using a site-wide configuration file placed
7478             in <file>/etc</file>.  Only if the program doesn't support a
7479             site-wide default configuration and the package maintainer
7480             doesn't have time to add it may a default per-user file be
7481             placed in <file>/etc/skel</file>.
7482           </p>
7483
7484           <p>
7485             <file>/etc/skel</file> should be as empty as we can make it.
7486             This is particularly true because there is no easy (or
7487             necessarily desirable) mechanism for ensuring that the
7488             appropriate dotfiles are copied into the accounts of
7489             existing users when a package is installed.
7490           </p>
7491         </sect1>
7492       </sect>
7493
7494       <sect>
7495         <heading>Log files</heading>
7496         <p>
7497           Log files should usually be named
7498           <file>/var/log/<var>package</var>.log</file>.  If you have many
7499           log files, or need a separate directory for permission
7500           reasons (<file>/var/log</file> is writable only by
7501           <file>root</file>), you should usually create a directory named
7502           <file>/var/log/<var>package</var></file> and place your log
7503           files there.
7504         </p>
7505
7506         <p>
7507           Log files must be rotated occasionally so that they don't
7508           grow indefinitely; the best way to do this is to drop a log
7509           rotation configuration file into the directory
7510           <file>/etc/logrotate.d</file> and use the facilities provided by
7511           logrotate.<footnote>
7512             <p>
7513               The traditional approach to log files has been to set up
7514               <em>ad hoc</em> log rotation schemes using simple shell
7515               scripts and cron.  While this approach is highly
7516               customizable, it requires quite a lot of sysadmin work.
7517               Even though the original Debian system helped a little
7518               by automatically installing a system which can be used
7519               as a template, this was deemed not enough.
7520             </p>
7521
7522             <p>
7523               The use of <prgn>logrotate</prgn>, a program developed
7524               by Red Hat, is better, as it centralizes log management.
7525               It has both a configuration file
7526               (<file>/etc/logrotate.conf</file>) and a directory where
7527               packages can drop their individual log rotation
7528               configurations (<file>/etc/logrotate.d</file>).
7529             </p>
7530           </footnote>
7531           Here is a good example for a logrotate config
7532           file (for more information see <manref name="logrotate"
7533             section="8">):
7534           <example compact="compact">
7535 /var/log/foo/*.log {
7536 rotate 12
7537 weekly
7538 compress
7539 postrotate
7540 /etc/init.d/foo force-reload
7541 endscript
7542 }
7543           </example>
7544           This rotates all files under <file>/var/log/foo</file>, saves 12
7545           compressed generations, and forces the daemon to reload its
7546           configuration information after the log rotation.
7547         </p>
7548
7549         <p>
7550           Log files should be removed when the package is
7551           purged (but not when it is only removed).  This should be
7552           done by the <prgn>postrm</prgn> script when it is called
7553           with the argument <tt>purge</tt> (see <ref
7554           id="removedetails">).
7555         </p>
7556       </sect>
7557
7558       <sect>
7559         <heading>Permissions and owners</heading>
7560
7561         <p>
7562           The rules in this section are guidelines for general use.
7563           If necessary you may deviate from the details below.
7564           However, if you do so you must make sure that what is done
7565           is secure and you should try to be as consistent as possible
7566           with the rest of the system.  You should probably also
7567           discuss it on <prgn>debian-devel</prgn> first.
7568         </p>
7569
7570         <p>
7571           Files should be owned by <tt>root:root</tt>, and made
7572           writable only by the owner and universally readable (and
7573           executable, if appropriate), that is mode 644 or 755.
7574         </p>
7575
7576         <p>
7577           Directories should be mode 755 or (for group-writability)
7578           mode 2775.  The ownership of the directory should be
7579           consistent with its mode: if a directory is mode 2775, it
7580           should be owned by the group that needs write access to
7581           it.<footnote>
7582             <p>
7583               When a package is upgraded, and the owner or permissions
7584               of a file included in the package has changed, dpkg
7585               arranges for the ownership and permissions to be
7586               correctly set upon installation. However, this does not
7587               extend to directories; the permissions and ownership of
7588               directories already on the system does not change on
7589               install or upgrade of packages.  This makes sense, since
7590               otherwise common directories like <tt>/usr</tt> would
7591               always be in flux.  To correctly change permissions of a
7592               directory the package owns, explicit action is required,
7593               usually in the <tt>postinst</tt> script. Care must be
7594               taken to handle downgrades as well, in that case.
7595             </p>
7596           </footnote>
7597         </p>
7598
7599
7600         <p>
7601           Setuid and setgid executables should be mode 4755 or 2755
7602           respectively, and owned by the appropriate user or group.
7603           They should not be made unreadable (modes like 4711 or
7604           2711 or even 4111); doing so achieves no extra security,
7605           because anyone can find the binary in the freely available
7606           Debian package; it is merely inconvenient.  For the same
7607           reason you should not restrict read or execute permissions
7608           on non-set-id executables.
7609         </p>
7610
7611         <p>
7612           Some setuid programs need to be restricted to particular
7613           sets of users, using file permissions.  In this case they
7614           should be owned by the uid to which they are set-id, and by
7615           the group which should be allowed to execute them.  They
7616           should have mode 4754; again there is no point in making
7617           them unreadable to those users who must not be allowed to
7618           execute them.
7619         </p>
7620
7621         <p>
7622           It is possible to arrange that the system administrator can
7623           reconfigure the package to correspond to their local
7624           security policy by changing the permissions on a binary:
7625           they can do this by using <prgn>dpkg-statoverride</prgn>, as
7626           described below.<footnote>
7627               Ordinary files installed by <prgn>dpkg</prgn> (as
7628               opposed to <tt>conffile</tt>s and other similar objects)
7629               normally have their permissions reset to the distributed
7630               permissions when the package is reinstalled.  However,
7631               the use of <prgn>dpkg-statoverride</prgn> overrides this
7632               default behavior.  If you use this method, you should
7633               remember to describe <prgn>dpkg-statoverride</prgn> in
7634               the package documentation; being a relatively new
7635               addition to Debian, it is probably not yet well-known.
7636           </footnote>
7637           Another method you should consider is to create a group for
7638           people allowed to use the program(s) and make any setuid
7639           executables executable only by that group.
7640         </p>
7641
7642         <p>
7643           If you need to create a new user or group for your package
7644           there are two possibilities.  Firstly, you may need to
7645           make some files in the binary package be owned by this
7646           user or group, or you may need to compile the user or
7647           group id (rather than just the name) into the binary
7648           (though this latter should be avoided if possible, as in
7649           this case you need a statically allocated id).</p>
7650
7651         <p>
7652           If you need a statically allocated id, you must ask for a
7653           user or group id from the <tt>base-passwd</tt> maintainer,
7654           and must not release the package until you have been
7655           allocated one.  Once you have been allocated one you must
7656           either make the package depend on a version of the
7657           <tt>base-passwd</tt> package with the id present in
7658           <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
7659           your package to create the user or group itself with the
7660           correct id (using <tt>adduser</tt>) in its
7661           <prgn>preinst</prgn> or <prgn>postinst</prgn>.  (Doing it in
7662           the <prgn>postinst</prgn> is to be preferred if it is
7663           possible, otherwise a pre-dependency will be needed on the
7664           <tt>adduser</tt> package.)
7665         </p>
7666
7667         <p>
7668           On the other hand, the program might be able to determine
7669           the uid or gid from the user or group name at runtime, so
7670           that a dynamically allocated id can be used.  In this case
7671           you should choose an appropriate user or group name,
7672           discussing this on <prgn>debian-devel</prgn> and checking
7673           with the <package/base-passwd/ maintainer that it is unique and that
7674           they do not wish you to use a statically allocated id
7675           instead.  When this has been checked you must arrange for
7676           your package to create the user or group if necessary using
7677           <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
7678           <prgn>postinst</prgn> script (again, the latter is to be
7679           preferred if it is possible).
7680         </p>
7681
7682         <p>
7683           Note that changing the numeric value of an id associated
7684           with a name is very difficult, and involves searching the
7685           file system for all appropriate files.  You need to think
7686           carefully whether a static or dynamic id is required, since
7687           changing your mind later will cause problems.
7688         </p>
7689
7690         <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
7691           <p>
7692             This section is not intended as policy, but as a
7693             description of the use of <prgn>dpkg-statoverride</prgn>.
7694           </p>
7695
7696           <p>
7697             If a system administrator wishes to have a file (or
7698             directory or other such thing) installed with owner and
7699             permissions different from those in the distributed Debian
7700             package, they can use the <prgn>dpkg-statoverride</prgn>
7701             program to instruct <prgn>dpkg</prgn> to use the different
7702             settings every time the file is installed.  Thus the
7703             package maintainer should distribute the files with their
7704             normal permissions, and leave it for the system
7705             administrator to make any desired changes.  For example, a
7706             daemon which is normally required to be setuid root, but
7707             in certain situations could be used without being setuid,
7708             should be installed setuid in the <tt>.deb</tt>.  Then the
7709             local system administrator can change this if they wish.
7710             If there are two standard ways of doing it, the package
7711             maintainer can use <tt>debconf</tt> to find out the
7712             preference, and call <prgn>dpkg-statoverride</prgn> in the
7713             maintainer script if necessary to accommodate the system
7714             administrator's choice. Care must be taken during
7715             upgrades to not override an existing setting.
7716           </p>
7717
7718           <p>
7719             Given the above, <prgn>dpkg-statoverride</prgn> is
7720             essentially a tool for system administrators and would not
7721             normally be needed in the maintainer scripts.  There is
7722             one type of situation, though, where calls to
7723             <prgn>dpkg-statoverride</prgn> would be needed in the
7724             maintainer scripts, and that involves packages which use
7725             dynamically allocated user or group ids.  In such a
7726             situation, something like the following idiom can be very
7727             helpful in the package's <prgn>postinst</prgn>, where
7728             <tt>sysuser</tt> is a dynamically allocated id:
7729             <example>
7730 for i in /usr/bin/foo /usr/sbin/bar
7731 do
7732   # only do something when no setting exists
7733   if ! dpkg-statoverride --list $i >/dev/null 2>&1
7734   then
7735     #include: debconf processing, question about foo and bar
7736     if [ "$RET" = "true" ] ; then
7737       dpkg-statoverride --update --add sysuser root 4755 $i
7738     fi
7739   fi
7740 done
7741             </example>
7742             The corresponding <tt>dpkg-statoverride --remove</tt>
7743             calls can then be made unconditionally when the package is
7744             purged.
7745           </p>
7746         </sect1>
7747       </sect>
7748     </chapt>
7749
7750
7751     <chapt id="customized-programs">
7752       <heading>Customized programs</heading>
7753
7754       <sect id="arch-spec">
7755         <heading>Architecture specification strings</heading>
7756
7757         <p>
7758           If a program needs to specify an <em>architecture specification
7759             string</em> in some place, it should select one of the
7760           strings provided by <tt>dpkg-architecture -L</tt>. The
7761           strings are in the format
7762           <tt><var>os</var>-<var>arch</var></tt>, though the OS part
7763           is sometimes elided, as when the OS is Linux.<footnote>
7764             <p>Currently, the strings are:
7765               i386 ia64 alpha amd64 armeb arm hppa m32r m68k mips
7766               mipsel powerpc ppc64 s390 s390x sh3 sh3eb sh4 sh4eb
7767               sparc darwin-i386 darwin-ia64 darwin-alpha darwin-amd64
7768               darwin-armeb darwin-arm darwin-hppa darwin-m32r
7769               darwin-m68k darwin-mips darwin-mipsel darwin-powerpc
7770               darwin-ppc64 darwin-s390 darwin-s390x darwin-sh3
7771               darwin-sh3eb darwin-sh4 darwin-sh4eb darwin-sparc
7772               freebsd-i386 freebsd-ia64 freebsd-alpha freebsd-amd64
7773               freebsd-armeb freebsd-arm freebsd-hppa freebsd-m32r
7774               freebsd-m68k freebsd-mips freebsd-mipsel freebsd-powerpc
7775               freebsd-ppc64 freebsd-s390 freebsd-s390x freebsd-sh3
7776               freebsd-sh3eb freebsd-sh4 freebsd-sh4eb freebsd-sparc
7777               kfreebsd-i386 kfreebsd-ia64 kfreebsd-alpha
7778               kfreebsd-amd64 kfreebsd-armeb kfreebsd-arm kfreebsd-hppa
7779               kfreebsd-m32r kfreebsd-m68k kfreebsd-mips
7780               kfreebsd-mipsel kfreebsd-powerpc kfreebsd-ppc64
7781               kfreebsd-s390 kfreebsd-s390x kfreebsd-sh3 kfreebsd-sh3eb
7782               kfreebsd-sh4 kfreebsd-sh4eb kfreebsd-sparc knetbsd-i386
7783               knetbsd-ia64 knetbsd-alpha knetbsd-amd64 knetbsd-armeb
7784               knetbsd-arm knetbsd-hppa knetbsd-m32r knetbsd-m68k
7785               knetbsd-mips knetbsd-mipsel knetbsd-powerpc
7786               knetbsd-ppc64 knetbsd-s390 knetbsd-s390x knetbsd-sh3
7787               knetbsd-sh3eb knetbsd-sh4 knetbsd-sh4eb knetbsd-sparc
7788               netbsd-i386 netbsd-ia64 netbsd-alpha netbsd-amd64
7789               netbsd-armeb netbsd-arm netbsd-hppa netbsd-m32r
7790               netbsd-m68k netbsd-mips netbsd-mipsel netbsd-powerpc
7791               netbsd-ppc64 netbsd-s390 netbsd-s390x netbsd-sh3
7792               netbsd-sh3eb netbsd-sh4 netbsd-sh4eb netbsd-sparc
7793               openbsd-i386 openbsd-ia64 openbsd-alpha openbsd-amd64
7794               openbsd-armeb openbsd-arm openbsd-hppa openbsd-m32r
7795               openbsd-m68k openbsd-mips openbsd-mipsel openbsd-powerpc
7796               openbsd-ppc64 openbsd-s390 openbsd-s390x openbsd-sh3
7797               openbsd-sh3eb openbsd-sh4 openbsd-sh4eb openbsd-sparc
7798               hurd-i386 hurd-ia64 hurd-alpha hurd-amd64 hurd-armeb
7799               hurd-arm hurd-hppa hurd-m32r hurd-m68k hurd-mips
7800               hurd-mipsel hurd-powerpc hurd-ppc64 hurd-s390 hurd-s390x
7801               hurd-sh3 hurd-sh3eb hurd-sh4 hurd-sh4eb hurd-sparc
7802             </p>
7803           </footnote>
7804         </p>
7805
7806         <p>
7807           Note that we don't want to use
7808           <tt><var>arch</var>-debian-linux</tt> to apply to the rule
7809           <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
7810           since this would make our programs incompatible with other
7811           Linux distributions.  We also don't use something like
7812           <tt><var>arch</var>-unknown-linux</tt>, since the
7813           <tt>unknown</tt> does not look very good.
7814         </p>
7815       </sect>
7816
7817       <sect>
7818         <heading>Daemons</heading>
7819
7820         <p>
7821           The configuration files <file>/etc/services</file>,
7822           <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
7823           by the <prgn>netbase</prgn> package and must not be modified
7824           by other packages.
7825         </p>
7826
7827         <p>
7828           If a package requires a new entry in one of these files, the
7829           maintainer should get in contact with the
7830           <prgn>netbase</prgn> maintainer, who will add the entries
7831           and release a new version of the <prgn>netbase</prgn>
7832           package.
7833         </p>
7834
7835         <p>
7836           The configuration file <file>/etc/inetd.conf</file> must not be
7837           modified by the package's scripts except via the
7838           <prgn>update-inetd</prgn> script or the
7839           <file>DebianNet.pm</file> Perl module.  See their documentation
7840           for details on how to add entries.
7841         </p>
7842
7843         <p>
7844           If a package wants to install an example entry into
7845           <file>/etc/inetd.conf</file>, the entry must be preceded with
7846           exactly one hash character (<tt>#</tt>). Such lines are
7847           treated as "commented out by user" by the
7848           <prgn>update-inetd</prgn> script and are not changed or
7849           activated during package updates.
7850         </p>
7851       </sect>
7852
7853       <sect>
7854         <heading>Using pseudo-ttys and modifying wtmp, utmp and
7855         lastlog</heading>
7856
7857         <p>
7858           Some programs need to create pseudo-ttys. This should be done
7859           using Unix98 ptys if the C library supports it. The resulting
7860           program must not be installed setuid root, unless that
7861           is required for other functionality.
7862         </p>
7863
7864         <p>
7865           The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
7866           <file>/var/log/lastlog</file> must be installed writable by
7867           group <tt>utmp</tt>.  Programs which need to modify those
7868           files must be installed setgid <tt>utmp</tt>.
7869         </p>
7870       </sect>
7871
7872       <sect>
7873         <heading>Editors and pagers</heading>
7874
7875         <p>
7876           Some programs have the ability to launch an editor or pager
7877           program to edit or display a text document.  Since there are
7878           lots of different editors and pagers available in the Debian
7879           distribution, the system administrator and each user should
7880           have the possibility to choose their preferred editor and
7881           pager.
7882         </p>
7883
7884         <p>
7885           In addition, every program should choose a good default
7886           editor/pager if none is selected by the user or system
7887           administrator.
7888         </p>
7889
7890         <p>
7891           Thus, every program that launches an editor or pager must
7892           use the EDITOR or PAGER environment variable to determine
7893           the editor or pager the user wishes to use.  If these
7894           variables are not set, the programs <file>/usr/bin/editor</file>
7895           and <file>/usr/bin/pager</file> should be used, respectively.
7896         </p>
7897
7898         <p>
7899           These two files are managed through the <prgn>dpkg</prgn>
7900           "alternatives" mechanism.  Thus every package providing an
7901           editor or pager must call the
7902           <prgn>update-alternatives</prgn> script to register these
7903           programs.
7904         </p>
7905
7906         <p>
7907           If it is very hard to adapt a program to make use of the
7908           EDITOR or PAGER variables, that program may be configured to
7909           use <file>/usr/bin/sensible-editor</file> and
7910           <file>/usr/bin/sensible-pager</file> as the editor or pager
7911           program respectively.  These are two scripts provided in the
7912           Debian base system that check the EDITOR and PAGER variables
7913           and launch the appropriate program, and fall back to
7914           <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
7915           variable is not set.
7916         </p>
7917
7918         <p>
7919           A program may also use the VISUAL environment variable to
7920           determine the user's choice of editor.  If it exists, it
7921           should take precedence over EDITOR.  This is in fact what
7922           <file>/usr/bin/sensible-editor</file> does.
7923         </p>
7924
7925         <p>
7926           It is not required for a package to depend on
7927           <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
7928           package to provide such virtual packages.<footnote>
7929               The Debian base system already provides an editor and a
7930               pager program.
7931           </footnote>
7932         </p>
7933       </sect>
7934
7935       <sect id="web-appl">
7936         <heading>Web servers and applications</heading>
7937
7938         <p>
7939           This section describes the locations and URLs that should
7940           be used by all web servers and web applications in the
7941           Debian system.
7942         </p>
7943
7944         <p>
7945           <enumlist>
7946             <item>
7947                 Cgi-bin executable files are installed in the
7948                 directory
7949                 <example compact="compact">
7950 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
7951                 </example>
7952                 and should be referred to as
7953                 <example compact="compact">
7954 http://localhost/cgi-bin/<var>cgi-bin-name</var>
7955                 </example>
7956
7957             </item>
7958
7959             <item>
7960               <p>Access to HTML documents</p>
7961
7962               <p>
7963                 HTML documents for a package are stored in
7964                 <file>/usr/share/doc/<var>package</var></file>
7965                 and can be referred to as
7966                 <example compact="compact">
7967 http://localhost/doc/<var>package</var>/<var>filename</var>
7968                 </example>
7969               </p>
7970
7971               <p>
7972                 The web server should restrict access to the document
7973                 tree so that only clients on the same host can read
7974                 the documents. If the web server does not support such
7975                 access controls, then it should not provide access at
7976                 all, or ask about providing access during installation.
7977               </p>
7978             </item>
7979
7980             <item>
7981               <p>Access to images</p>
7982               <p>
7983                 It is recommended that images for a package be stored
7984                 in <tt>/usr/share/images/<var>package</var></tt> and
7985                 may be referred to through an alias <tt>/images/</tt>
7986                 as
7987                 <example>
7988                   http://localhost/images/&lt;package&gt;/&lt;filename&gt;     
7989                 </example>
7990                 
7991               </p>
7992             </item>
7993
7994             <item>
7995               <p>Web Document Root</p>
7996
7997               <p>
7998                 Web Applications should try to avoid storing files in
7999                 the Web Document Root.  Instead they should use the
8000                 /usr/share/doc/<var>package</var> directory for
8001                 documents and register the Web Application via the
8002                 <package>doc-base</package> package.  If access to the
8003                 web document root is unavoidable then use
8004                 <example compact="compact">
8005 /var/www
8006                 </example>
8007                 as the Document Root.  This might be just a symbolic
8008                 link to the location where the system administrator
8009                 has put the real document root.
8010               </p>
8011             </item>
8012             <item><p>Providing httpd and/or httpd-cgi</p>
8013               <p>
8014                 All web servers should provide the virtual package
8015                 <tt>httpd</tt>. If a web server has CGI support it should
8016                 provide <tt>httpd-cgi</tt> additionally.
8017               </p>
8018               <p>
8019                 All web applications which do not contain CGI scripts should
8020                 depend on <tt>httpd</tt>, all those web applications which
8021                 <tt>do</tt> contain CGI scripts, should depend on
8022                 <tt>httpd-cgi</tt>.
8023               </p>
8024             </item>
8025           </enumlist>
8026         </p>
8027       </sect>
8028
8029       <sect id="mail-transport-agents">
8030         <heading>Mail transport, delivery and user agents</heading>
8031
8032         <p>
8033           Debian packages which process electronic mail, whether mail
8034           user agents (MUAs) or mail transport agents (MTAs), must
8035           ensure that they are compatible with the configuration
8036           decisions below.  Failure to do this may result in lost
8037           mail, broken <tt>From:</tt> lines, and other serious brain
8038           damage!
8039         </p>
8040
8041         <p>
8042           The mail spool is <file>/var/mail</file> and the interface to
8043           send a mail message is <file>/usr/sbin/sendmail</file> (as per
8044           the FHS).  On older systems, the mail spool may be
8045           physically located in <file>/var/spool/mail</file>, but all
8046           access to the mail spool should be via the
8047           <file>/var/mail</file> symlink.  The mail spool is part of the
8048           base system and not part of the MTA package.
8049         </p>
8050
8051         <p>
8052           All Debian MUAs, MTAs, MDAs and other mailbox accessing
8053           programs (such as IMAP daemons) must lock the mailbox in an
8054           NFS-safe way. This means that <tt>fcntl()</tt> locking must
8055           be combined with dot locking.  To avoid deadlocks, a program
8056           should use <tt>fcntl()</tt> first and dot locking after
8057           this, or alternatively implement the two locking methods in
8058           a non blocking way<footnote>
8059               If it is not possible to establish both locks, the
8060               system shouldn't wait for the second lock to be
8061               established, but remove the first lock, wait a (random)
8062               time, and start over locking again.
8063           </footnote>. Using the functions <tt>maillock</tt> and
8064           <tt>mailunlock</tt> provided by the
8065           <tt>liblockfile*</tt><footnote>
8066               You will need to depend on <tt>liblockfile1 (&gt;&gt;1.01)</tt>
8067               to use these functions.
8068           </footnote> packages is the recommended way to realize this.
8069         </p>
8070
8071         <p>
8072           Mailboxes are generally mode 660
8073           <tt><var>user</var>:mail</tt> unless the system
8074           administrator has chosen otherwise.  A MUA may remove a
8075           mailbox (unless it has nonstandard permissions) in which
8076           case the MTA or another MUA must recreate it if needed.
8077           Mailboxes must be writable by group mail.
8078         </p>
8079
8080         <p>
8081           The mail spool is 2775 <tt>root:mail</tt>, and MUAs should
8082           be setgid mail to do the locking mentioned above (and
8083           must obviously avoid accessing other users' mailboxes
8084           using this privilege).</p>
8085
8086         <p>
8087           <file>/etc/aliases</file> is the source file for the system mail
8088           aliases (e.g., postmaster, usenet, etc.), it is the one
8089           which the sysadmin and <prgn>postinst</prgn> scripts may
8090           edit.  After <file>/etc/aliases</file> is edited the program or
8091           human editing it must call <prgn>newaliases</prgn>.  All MTA
8092           packages must come with a <prgn>newaliases</prgn> program,
8093           even if it does nothing, but older MTA packages did not do
8094           this so programs should not fail if <prgn>newaliases</prgn>
8095           cannot be found.  Note that because of this, all MTA
8096           packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
8097           <tt>Replaces: mail-transport-agent</tt> control file
8098           fields.
8099         </p>
8100
8101         <p>
8102           The convention of writing <tt>forward to
8103             <var>address</var></tt> in the mailbox itself is not
8104           supported.  Use a <tt>.forward</tt> file instead.</p>
8105
8106         <p>
8107           The <prgn>rmail</prgn> program used by UUCP
8108           for incoming mail should be  <file>/usr/sbin/rmail</file>.
8109           Likewise, <prgn>rsmtp</prgn>, for receiving
8110           batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
8111           is supported.</p>
8112
8113         <p>
8114           If your package needs to know what hostname to use on (for
8115           example) outgoing news and mail messages which are generated
8116           locally, you should use the file <file>/etc/mailname</file>.  It
8117           will contain the portion after the username and <tt>@</tt>
8118           (at) sign for email addresses of users on the machine
8119           (followed by a newline).
8120         </p>
8121
8122         <p>
8123           Such a package should check for the existence of this file
8124           when it is being configured.  If it exists, it should be
8125           used without comment, although an MTA's configuration script
8126           may wish to prompt the user even if it finds that this file
8127           exists.  If the file does not exist, the package should
8128           prompt the user for the value (preferably using
8129           <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
8130           as well as using it in the package's configuration.  The
8131           prompt should make it clear that the name will not just be
8132           used by that package.  For example, in this situation the
8133           <tt>inn</tt> package could say something like:
8134           <example compact="compact">
8135 Please enter the "mail name" of your system.  This is the
8136 hostname portion of the address to be shown on outgoing
8137 news and mail messages.  The default is
8138 <var>syshostname</var>, your system's host name.  Mail
8139 name ["<var>syshostname</var>"]:
8140           </example>
8141           where <var>syshostname</var> is the output of <tt>hostname
8142             --fqdn</tt>.
8143         </p>
8144       </sect>
8145
8146       <sect>
8147         <heading>News system configuration</heading>
8148
8149         <p>
8150           All the configuration files related to the NNTP (news)
8151           servers and clients should be located under
8152           <file>/etc/news</file>.</p>
8153
8154         <p>
8155           There are some configuration issues that apply to a number
8156           of news clients and server packages on the machine. These
8157           are:
8158
8159           <taglist>
8160             <tag><file>/etc/news/organization</file></tag>
8161             <item>
8162                 A string which should appear as the
8163                 organization header for all messages posted
8164                 by NNTP clients on the machine
8165             </item>
8166
8167             <tag><file>/etc/news/server</file></tag>
8168             <item>
8169                 Contains the FQDN of the upstream NNTP
8170                 server, or localhost if the local machine is
8171                 an NNTP server.
8172             </item>
8173           </taglist>
8174
8175           Other global files may be added as required for cross-package news
8176           configuration.
8177         </p>
8178       </sect>
8179
8180
8181       <sect>
8182         <heading>Programs for the X Window System</heading>
8183
8184         <sect1>
8185           <heading>Providing X support and package priorities</heading>
8186
8187           <p>
8188             Programs that can be configured with support for the X
8189             Window System must be configured to do so and must declare
8190             any package dependencies necessary to satisfy their
8191             runtime requirements when using the X Window System.  If
8192             such a package is of higher priority than the X packages
8193             on which it depends, it is required that either the
8194             X-specific components be split into a separate package, or
8195             that an alternative version of the package, which includes
8196             X support, be provided, or that the package's priority be
8197             lowered.
8198           </p>
8199         </sect1>
8200
8201         <sect1>
8202           <heading>Packages providing an X server</heading>
8203
8204           <p>
8205             Packages that provide an X server that, directly or
8206             indirectly, communicates with real input and display
8207             hardware should declare in their control data that they
8208             provide the virtual package <tt>xserver</tt>.<footnote>
8209                 This implements current practice, and provides an
8210                 actual policy for usage of the <tt>xserver</tt>
8211                 virtual package which appears in the virtual packages
8212                 list.  In a nutshell, X servers that interface
8213                 directly with the display and input hardware or via
8214                 another subsystem (e.g., GGI) should provide
8215                 <tt>xserver</tt>.  Things like <tt>Xvfb</tt>,
8216                 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
8217             </footnote>
8218           </p>
8219         </sect1>
8220
8221         <sect1>
8222           <heading>Packages providing a terminal emulator</heading>
8223
8224           <p>
8225             Packages that provide a terminal emulator for the X Window
8226             System which meet the criteria listed below should declare
8227             in their control data that they provide the virtual
8228             package <tt>x-terminal-emulator</tt>.  They should also
8229             register themselves as an alternative for
8230             <file>/usr/bin/x-terminal-emulator</file>, with a priority of
8231             20.
8232           </p>
8233
8234           <p>
8235             To be an <tt>x-terminal-emulator</tt>, a program must:
8236             <list compact="compact">
8237               <item>
8238                   Be able to emulate a DEC VT100 terminal, or a
8239                   compatible terminal.
8240               </item>
8241
8242               <item>
8243                   Support the command-line option <tt>-e
8244                     <var>command</var></tt>, which creates a new
8245                   terminal window<footnote>
8246                       "New terminal window" does not necessarily mean
8247                       a new top-level X window directly parented by
8248                       the window manager; it could, if the terminal
8249                       emulator application were so coded, be a new
8250                       "view" in a multiple-document interface (MDI).
8251                   </footnote>
8252                   and runs the specified <var>command</var>,
8253                   interpreting the entirety of the rest of the command
8254                   line as a command to pass straight to exec, in the
8255                   manner that <tt>xterm</tt> does.
8256               </item>
8257
8258               <item>
8259                   Support the command-line option <tt>-T
8260                     <var>title</var></tt>, which creates a new terminal
8261                   window with the window title <var>title</var>.
8262               </item>
8263             </list>
8264           </p>
8265         </sect1>
8266
8267         <sect1>
8268           <heading>Packages providing a window manager</heading>
8269
8270           <p>
8271             Packages that provide a window manager should declare in
8272             their control data that they provide the virtual package
8273             <tt>x-window-manager</tt>.  They should also register
8274             themselves as an alternative for
8275             <file>/usr/bin/x-window-manager</file>, with a priority
8276             calculated as follows:
8277             <list compact="compact">
8278               <item>
8279                   Start with a priority of 20.
8280               </item>
8281
8282               <item>
8283                   If the window manager supports the Debian menu
8284                   system, add 20 points if this support is available
8285                   in the package's default configuration (i.e., no
8286                   configuration files belonging to the system or user
8287                   have to be edited to activate the feature); if
8288                   configuration files must be modified, add only 10
8289                   points.
8290                 </p>
8291               </item>
8292
8293               <item>
8294                   If the window manager complies with <url
8295                     id="http://www.freedesktop.org/Standards/wm-spec"
8296                     name="The Window Manager Specification Project">,
8297                   written by the <url id="http://www.freedesktop.org/"
8298                     name="Free Desktop Group">, add 40 points.
8299               </item>
8300
8301               <item>
8302                   If the window manager permits the X session to be
8303                   restarted using a <em>different</em> window manager
8304                   (without killing the X server) in its default
8305                   configuration, add 10 points; otherwise add none.
8306               </item>
8307             </list>
8308           </p>
8309         </sect1>
8310
8311         <sect1>
8312           <heading>Packages providing fonts</heading>
8313
8314           <p>
8315             Packages that provide fonts for the X Window
8316             System<footnote>
8317                 For the purposes of Debian Policy, a "font for the X
8318                 Window System" is one which is accessed via X protocol
8319                 requests.  Fonts for the Linux console, for PostScript
8320                 renderer, or any other purpose, do not fit this
8321                 definition.  Any tool which makes such fonts available
8322                 to the X Window System, however, must abide by this
8323                 font policy.
8324             </footnote>
8325             must do a number of things to ensure that they are both
8326             available without modification of the X or font server
8327             configuration, and that they do not corrupt files used by
8328             other font packages to register information about
8329             themselves.
8330             <enumlist>
8331               <item>
8332                   Fonts of any type supported by the X Window System
8333                   must be in a separate binary package from any
8334                   executables, libraries, or documentation (except
8335                   that specific to the fonts shipped, such as their
8336                   license information).  If one or more of the fonts
8337                   so packaged are necessary for proper operation of
8338                   the package with which they are associated the font
8339                   package may be Recommended; if the fonts merely
8340                   provide an enhancement, a Suggests relationship may
8341                   be used.  Packages must not Depend on font
8342                   packages.<footnote>
8343                       This is because the X server may retrieve fonts
8344                       from the local file system or over the network
8345                       from an X font server; the Debian package system
8346                       is empowered to deal only with the local
8347                       file system.
8348                   </footnote>
8349               </item>
8350
8351               <item>
8352                   BDF fonts must be converted to PCF fonts with the
8353                   <prgn>bdftopcf</prgn> utility (available in the
8354                   <tt>xfonts-utils</tt> package, <prgn>gzip</prgn>ped, and
8355                   placed in a directory that corresponds to their
8356                   resolution:
8357                   <list compact="compact">
8358                     <item>
8359                         100 dpi fonts must be placed in
8360                         <file>/usr/share/fonts/X11/100dpi/</file>.
8361                     </item>
8362
8363                     <item>
8364                         75 dpi fonts must be placed in
8365                         <file>/usr/share/fonts/X11/75dpi/</file>.
8366                     </item>
8367
8368                     <item>
8369                         Character-cell fonts, cursor fonts, and other
8370                         low-resolution fonts must be placed in
8371                         <file>/usr/share/fonts/X11/misc/</file>.
8372                     </item>
8373                   </list>
8374               </item>
8375
8376               <item>
8377                   Speedo fonts must be placed in
8378                   <file>/usr/share/fonts/X11/Speedo/</file>.
8379               </item>
8380
8381               <item>
8382                   Type 1 fonts must be placed in
8383                   <file>/usr/share/fonts/X11/Type1/</file>.  If font
8384                   metric files are available, they must be placed here
8385                   as well.
8386               </item>
8387
8388               <item>
8389                   Subdirectories of <file>/usr/share/fonts/X11/</file>
8390                   other than those listed above must be neither
8391                   created nor used.  (The <file>PEX</file>, <file>CID</file>,
8392                   and <file>cyrillic</file> directories are excepted for
8393                   historical reasons, but installation of files into
8394                   these directories remains discouraged.)
8395               </item>
8396
8397               <item>
8398                   Font packages may, instead of placing files directly
8399                   in the X font directories listed above, provide
8400                   symbolic links in that font directory pointing to
8401                   the files' actual location in the filesystem.  Such
8402                   a location must comply with the FHS.
8403               </item>
8404
8405               <item>
8406                   Font packages should not contain both 75dpi and
8407                   100dpi versions of a font.  If both are available,
8408                   they should be provided in separate binary packages
8409                   with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
8410                   the names of the packages containing the
8411                   corresponding fonts.
8412               </item>
8413
8414               <item>
8415                   Fonts destined for the <file>misc</file> subdirectory
8416                   should not be included in the same package as 75dpi
8417                   or 100dpi fonts; instead, they should be provided in
8418                   a separate package with <tt>-misc</tt> appended to
8419                   its name.
8420               </item>
8421
8422               <item>
8423                   Font packages must not provide the files
8424                   <file>fonts.dir</file>, <file>fonts.alias</file>, or
8425                   <file>fonts.scale</file> in a font directory:
8426                   <list>
8427                     <item>
8428                         <file>fonts.dir</file> files must not be provided at all.
8429                     </item>
8430
8431                     <item>
8432                         <file>fonts.alias</file> and <file>fonts.scale</file>
8433                         files, if needed, should be provided in the
8434                         directory
8435                         <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
8436                         where <var>fontdir</var> is the name of the
8437                         subdirectory of
8438                         <file>/usr/share/fonts/X11/</file> where the
8439                         package's corresponding fonts are stored
8440                         (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
8441                         <var>package</var> is the name of the package
8442                         that provides these fonts, and
8443                         <var>extension</var> is either <tt>scale</tt>
8444                         or <tt>alias</tt>, whichever corresponds to
8445                         the file contents.
8446                     </item>
8447                   </list>
8448               </item>
8449
8450               <item>
8451                   Font packages must declare a dependency on
8452                   <tt>xfonts-utils</tt> in their control
8453                   data.
8454               </item>
8455
8456               <item>
8457                   Font packages that provide one or more
8458                   <file>fonts.scale</file> files as described above must
8459                   invoke <prgn>update-fonts-scale</prgn> on each
8460                   directory into which they installed fonts
8461                   <em>before</em> invoking
8462                   <prgn>update-fonts-dir</prgn> on that directory.
8463                   This invocation must occur in both the
8464                   <prgn>postinst</prgn> (for all arguments) and
8465                   <prgn>postrm</prgn> (for all arguments except
8466                   <tt>upgrade</tt>) scripts.
8467               </item>
8468
8469               <item>
8470                   Font packages that provide one or more
8471                   <file>fonts.alias</file> files as described above must
8472                   invoke <prgn>update-fonts-alias</prgn> on each
8473                   directory into which they installed fonts.  This
8474                   invocation must occur in both the
8475                   <prgn>postinst</prgn> (for all arguments) and
8476                   <prgn>postrm</prgn> (for all arguments except
8477                   <tt>upgrade</tt>) scripts.
8478               </item>
8479
8480               <item>
8481                   Font packages must invoke
8482                   <prgn>update-fonts-dir</prgn> on each directory into
8483                   which they installed fonts.  This invocation must
8484                   occur in both the <prgn>postinst</prgn> (for all
8485                   arguments) and <prgn>postrm</prgn> (for all
8486                   arguments except <tt>upgrade</tt>) scripts.
8487               </item>
8488
8489               <item>
8490                   Font packages must not provide alias names for the
8491                   fonts they include which collide with alias names
8492                   already in use by fonts already packaged.
8493               </item>
8494
8495               <item>
8496                   Font packages must not provide fonts with the same
8497                   XLFD registry name as another font already packaged.
8498               </item>
8499             </enumlist>
8500           </p>
8501         </sect1>
8502
8503         <sect1>
8504           <heading>Application defaults files</heading>
8505
8506           <p>
8507             Application defaults files must be installed in the
8508             directory <file>/etc/X11/app-defaults/</file> (use of a
8509             localized subdirectory of <file>/etc/X11/</file> as described
8510             in the <em>X Toolkit Intrinsics - C Language
8511             Interface</em> manual is also permitted).  They must be
8512             registered as <tt>conffile</tt>s or handled as
8513             configuration files.
8514           </p>
8515
8516           <p>
8517             Customization of programs' X resources may also be
8518             supported with the provision of a file with the same name
8519             as that of the package placed in the
8520             <file>/etc/X11/Xresources/</file> directory, which must
8521             registered as a <tt>conffile</tt> or handled as a
8522             configuration file.<footnote>
8523                 Note that this mechanism is not the same as using
8524                 app-defaults; app-defaults are tied to the client
8525                 binary on the local file system, whereas X resources
8526                 are stored in the X server and affect all connecting
8527                 clients.
8528             </footnote>
8529           </p>
8530         </sect1>
8531
8532         <sect1>
8533           <heading>Installation directory issues</heading>
8534
8535           <p>
8536             Packages using the X Window System should not be
8537             configured to install files under the
8538             <file>/usr/X11R6/</file> directory. The
8539             <file>/usr/X11R6/</file> directory hierarchy should be
8540             regarded as obsolete.
8541           </p>
8542
8543           <p>
8544             Programs that use GNU <prgn>autoconf</prgn> and
8545             <prgn>automake</prgn> are usually easily configured at
8546             compile time to use <file>/usr/</file> instead of
8547             <file>/usr/X11R6/</file>, and this should be done whenever
8548             possible.  Configuration files for window managers and
8549             display managers should be placed in a subdirectory of
8550             <file>/etc/X11/</file> corresponding to the package name due
8551             to these programs' tight integration with the mechanisms
8552             of the X Window System.  Application-level programs should
8553             use the <file>/etc/</file> directory unless otherwise mandated
8554             by policy.
8555           </p>
8556
8557           <p>
8558             The installation of files into subdirectories
8559             of <file>/usr/X11R6/include/X11/</file> and
8560             <file>/usr/X11R6/lib/X11/</file> is now prohibited;
8561             package maintainers should determine if subdirectories of
8562             <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
8563             instead. 
8564           </p>
8565
8566           <p>
8567             Packages should install any relevant files into the
8568             directories <file>/usr/include/X11/</file> and
8569             <file>/usr/lib/X11/</file>, but if they do so, they must
8570             pre-depend on <tt>x11-common (&gt;=
8571             1:7.0.0)</tt><footnote>
8572               <p>
8573                 These libraries used to be all symbolic
8574                 links. However, with <tt>X11R7</tt>,
8575                 <tt>/usr/include/X11</tt> and <tt>/usr/lib/X11</tt>
8576                 are now real directories, and packages
8577                 <strong>should</strong> ship their files here instead
8578                 of in <tt>/usr/X11R6/{include,lib}/X11</tt>.
8579                 <tt>x11-common (&gt;= 1:7.0.0) </tt> is the package
8580                 responsible for converting these symlinks into
8581                 directories.
8582               </p>
8583             </footnote>
8584           </p>
8585         </sect1>
8586
8587         <sect1>
8588           <heading>The OSF/Motif and OpenMotif libraries</heading>
8589
8590           <p>
8591             <em>Programs that require the non-DFSG-compliant OSF/Motif or
8592               OpenMotif libraries</em><footnote>
8593                 OSF/Motif and OpenMotif are collectively referred to as
8594                 "Motif" in this policy document.
8595             </footnote>
8596             should be compiled against and tested with LessTif (a free
8597             re-implementation of Motif) instead.  If the maintainer
8598             judges that the program or programs do not work
8599             sufficiently well with LessTif to be distributed and
8600             supported, but do so when compiled against Motif, then two
8601             versions of the package should be created; one linked
8602             statically against Motif and with <tt>-smotif</tt>
8603             appended to the package name, and one linked dynamically
8604             against Motif and with <tt>-dmotif</tt> appended to the
8605             package name.
8606           </p>
8607
8608           <p>
8609             Both Motif-linked versions are dependent
8610             upon non-DFSG-compliant software and thus cannot be
8611             uploaded to the <em>main</em> distribution; if the
8612             software is itself DFSG-compliant it may be uploaded to
8613             the <em>contrib</em> distribution.  While known existing
8614             versions of Motif permit unlimited redistribution of
8615             binaries linked against the library (whether statically or
8616             dynamically), it is the package maintainer's
8617             responsibility to determine whether this is permitted by
8618             the license of the copy of Motif in their possession.
8619           </p>
8620         </sect1>
8621       </sect>
8622
8623       <sect id="perl">
8624         <heading>Perl programs and modules</heading>
8625
8626         <p>
8627           Perl programs and modules should follow the current Perl policy.
8628         </p>
8629
8630         <p>
8631           The Perl policy can be found in the <tt>perl-policy</tt>
8632           files in the <tt>debian-policy</tt> package.
8633           It is also available from the Debian web mirrors at
8634           <tt><url name="/doc/packaging-manuals/perl-policy/"
8635                 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>.
8636         </p>
8637       </sect>
8638
8639       <sect id="emacs">
8640         <heading>Emacs lisp programs</heading>
8641
8642         <p>
8643           Please refer to the "Debian Emacs Policy" for details of how to
8644           package emacs lisp programs.
8645         </p>
8646
8647         <p>
8648           The Emacs policy is available in
8649           <file>debian-emacs-policy.gz</file> of the
8650           <package>emacsen-common</package> package.
8651           It is also available from the Debian web mirrors at
8652           <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
8653                 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
8654         </p>
8655       </sect>
8656
8657       <sect>
8658         <heading>Games</heading>
8659
8660         <p>
8661           The permissions on <file>/var/games</file> are mode 755, owner
8662           <tt>root</tt> and group <tt>root</tt>.
8663         </p>
8664
8665         <p>
8666           Each game decides on its own security policy.</p>
8667
8668         <p>
8669           Games which require protected, privileged access to
8670           high-score files, saved games, etc., may be made
8671           set-<em>group</em>-id (mode 2755) and owned by
8672           <tt>root:games</tt>, and use files and directories with
8673           appropriate permissions (770 <tt>root:games</tt>, for
8674           example).  They must not be made
8675           set-<em>user</em>-id, as this causes security problems. (If
8676           an attacker can subvert any set-user-id game they can
8677           overwrite the executable of any other, causing other players
8678           of these games to run a Trojan horse program.  With a
8679           set-group-id game the attacker only gets access to less
8680           important game data, and if they can get at the other
8681           players' accounts at all it will take considerably more
8682           effort.)</p>
8683
8684         <p>
8685           Some packages, for example some fortune cookie programs, are
8686           configured by the upstream authors to install with their
8687           data files or other static information made unreadable so
8688           that they can only be accessed through set-id programs
8689           provided.  You should not do this in a Debian package: anyone can
8690           download the <file>.deb</file> file and read the data from it,
8691           so there is no point making the files unreadable.  Not
8692           making the files unreadable also means that you don't have
8693           to make so many programs set-id, which reduces the risk of a
8694           security hole.</p>
8695
8696         <p>
8697           As described in the FHS, binaries of games should be
8698           installed in the directory <file>/usr/games</file>. This also
8699           applies to games that use the X Window System. Manual pages
8700           for games (X and non-X games) should be installed in
8701           <file>/usr/share/man/man6</file>.</p>
8702       </sect>
8703     </chapt>
8704
8705
8706     <chapt id="docs">
8707       <heading>Documentation</heading>
8708
8709       <sect>
8710         <heading>Manual pages</heading>
8711
8712         <p>
8713           You should install manual pages in <prgn>nroff</prgn> source
8714           form, in appropriate places under <file>/usr/share/man</file>.
8715           You should only use sections 1 to 9 (see the FHS for more
8716           details).  You must not install a pre-formatted "cat page".
8717         </p>
8718
8719         <p>
8720           Each program, utility, and function should have an
8721           associated manual page included in the same package. It is
8722           suggested that all configuration files also have a manual
8723           page included as well. Manual pages for protocols and other
8724           auxiliary things are optional.
8725         </p>
8726
8727         <p>
8728           If no manual page is available, this is considered as a bug
8729           and should be reported to the Debian Bug Tracking System (the
8730           maintainer of the package is allowed to write this bug report
8731           themselves, if they so desire).  Do not close the bug report
8732           until a proper man page is available.<footnote>
8733               It is not very hard to write a man page. See the
8734               <url id="http://www.schweikhardt.net/man_page_howto.html"
8735                 name="Man-Page-HOWTO">,
8736               <manref name="man" section="7">, the examples
8737               created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
8738               the helper programs <prgn>help2man</prgn>, or the
8739               directory <file>/usr/share/doc/man-db/examples</file>.
8740           </footnote>
8741         </p>
8742
8743         <p>
8744           You may forward a complaint about a missing man page to the
8745           upstream authors, and mark the bug as forwarded in the
8746           Debian bug tracking system.  Even though the GNU Project do
8747           not in general consider the lack of a man page to be a bug,
8748           we do; if they tell you that they don't consider it a bug
8749           you should leave the bug in our bug tracking system open
8750           anyway.
8751         </p>
8752
8753         <p>
8754           Manual pages should be installed compressed using <tt>gzip -9</tt>.
8755         </p>
8756
8757         <p>
8758           If one man page needs to be accessible via several names it
8759           is better to use a symbolic link than the <file>.so</file>
8760           feature, but there is no need to fiddle with the relevant
8761           parts of the upstream source to change from <file>.so</file> to
8762           symlinks: don't do it unless it's easy.  You should not
8763           create hard links in the manual page directories, nor put
8764           absolute filenames in <file>.so</file> directives.  The filename
8765           in a <file>.so</file> in a man page should be relative to the
8766           base of the man page tree (usually
8767           <file>/usr/share/man</file>). If you do not create any links
8768           (whether symlinks, hard links, or <tt>.so</tt> directives)
8769           in the file system to the alternate names of the man page,
8770           then you should not rely on <prgn>man</prgn> finding your
8771           man page under those names based solely on the information in
8772           the man page's header.<footnote>
8773               Supporting this in <prgn>man</prgn> often requires
8774               unreasonable processing time to find a manual page or to
8775               report that none exists, and moves knowledge into man's
8776               database that would be better left in the file system.
8777               This support is therefore deprecated and will cease to
8778               be present in the future.
8779           </footnote>
8780         </p>
8781
8782         <p>
8783           Manual pages in locale-specific subdirectories of
8784           <file>/usr/share/man</file> should use either UTF-8 or the usual
8785           legacy encoding for that language (normally the one corresponding
8786           to the shortest relevant locale name in
8787           <file>/usr/share/i18n/SUPPORTED</file>). For example, pages under
8788           <file>/usr/share/man/fr</file> should use either UTF-8 or
8789           ISO-8859-1.<footnote>
8790             <prgn>man</prgn> will automatically detect whether UTF-8 is in
8791             use. In future, all manual pages will be required to use
8792             UTF-8.
8793           </footnote>
8794         </p>
8795
8796         <p>
8797           A country name (the <tt>DE</tt> in <tt>de_DE</tt>) should not be
8798           included in the subdirectory name unless it indicates a
8799           significant difference in the language, as this excludes
8800           speakers of the language in other countries.<footnote>
8801             At the time of writing, Chinese and Portuguese are the main
8802             languages with such differences, so <file>pt_BR</file>,
8803             <file>zh_CN</file>, and <file>zh_TW</file> are all allowed.
8804           </footnote>
8805         </p>
8806
8807         <p>
8808           Due to limitations in current implementations, all characters
8809           in the manual page source should be representable in the usual
8810           legacy encoding for that language, even if the file is
8811           actually encoded in UTF-8. Safe alternative ways to write many
8812           characters outside that range may be found in
8813           <manref name="groff_char" section="7">.
8814         </p>
8815       </sect>
8816
8817       <sect>
8818         <heading>Info documents</heading>
8819
8820         <p>
8821           Info documents should be installed in <file>/usr/share/info</file>.
8822           They should be compressed with <tt>gzip -9</tt>.
8823         </p>
8824
8825         <p>
8826           Your package should call <prgn>install-info</prgn> to update
8827           the Info <file>dir</file> file in its <prgn>postinst</prgn>
8828           script when called with a <tt>configure</tt> argument, for
8829           example:
8830           <example compact="compact">
8831 install-info --quiet --section Development Development \
8832   /usr/share/info/foobar.info
8833           </example></p>
8834
8835         <p>
8836           It is a good idea to specify a section for the location of
8837           your program; this is done with the <tt>--section</tt>
8838           switch.  To determine which section to use, you should look
8839           at <file>/usr/share/info/dir</file> on your system and choose the most
8840           relevant (or create a new section if none of the current
8841           sections are relevant).  Note that the <tt>--section</tt>
8842           flag takes two arguments; the first is a regular expression
8843           to match (case-insensitively) against an existing section,
8844           the second is used when creating a new one.</p>
8845
8846         <p>
8847           You should remove the entries in the <prgn>prerm</prgn>
8848           script when called with a <tt>remove</tt> argument:
8849           <example compact="compact">
8850 install-info --quiet --remove /usr/share/info/foobar.info
8851           </example></p>
8852
8853         <p>
8854           If <prgn>install-info</prgn> cannot find a description entry
8855           in the Info file you must supply one.  See <manref
8856           name="install-info" section="8"> for details.</p>
8857       </sect>
8858
8859       <sect>
8860         <heading>Additional documentation</heading>
8861
8862         <p>
8863           Any additional documentation that comes with the package may
8864           be installed at the discretion of the package maintainer.
8865           Plain text documentation should be installed in the directory
8866           <file>/usr/share/doc/<var>package</var></file>, where
8867           <var>package</var> is the name of the package, and
8868           compressed with <tt>gzip -9</tt> unless it is small.
8869         </p>
8870
8871         <p>
8872           If a package comes with large amounts of documentation which
8873           many users of the package will not require you should create
8874           a separate binary package to contain it, so that it does not
8875           take up disk space on the machines of users who do not need
8876           or want it installed.</p>
8877
8878         <p>
8879           It is often a good idea to put text information files
8880           (<file>README</file>s, changelogs, and so forth) that come with
8881           the source package in <file>/usr/share/doc/<var>package</var></file>
8882           in the binary package.  However, you don't need to install
8883           the instructions for building and installing the package, of
8884           course!</p>
8885
8886         <p>
8887           Packages must not require the existence of any files in
8888           <file>/usr/share/doc/</file> in order to function
8889           <footnote>
8890               The system administrator should be able to
8891               delete files in <file>/usr/share/doc/</file> without causing
8892               any programs to break.
8893           </footnote>.
8894           Any files that are referenced by programs but are also
8895           useful as stand alone documentation should be installed under
8896           <file>/usr/share/<var>package</var>/</file> with symbolic links from
8897           <file>/usr/share/doc/<var>package</var></file>.
8898         </p>
8899
8900         <p>
8901           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
8902           link to another directory in <file>/usr/share/doc</file> only if
8903           the two packages both come from the same source and the
8904           first package Depends on the second.<footnote>
8905             <p>
8906               Please note that this does not override the section on
8907               changelog files below, so the file 
8908               <file>/usr/share/<var>package</var>/changelog.Debian.gz</file>
8909               must refer to the changelog for the current version of
8910               <var>package</var> in question. In practice, this means
8911               that the sources of the target and the destination of the
8912               symlink must be the same (same source package and
8913               version). 
8914             </p>
8915           </footnote>
8916         </p>
8917
8918         <p>
8919           Former Debian releases placed all additional documentation
8920           in <file>/usr/doc/<var>package</var></file>.  This has been
8921           changed to <file>/usr/share/doc/<var>package</var></file>,
8922           and packages must not put documentation in the directory
8923           <file>/usr/doc/<var>package</var></file>. <footnote>
8924             At this phase of the transition, we no longer require a
8925             symbolic link in <file>/usr/doc/</file>. At a later point,
8926             policy shall change to make the symbolic links a bug.
8927           </footnote>
8928         </p>
8929       </sect>
8930
8931       <sect>
8932         <heading>Preferred documentation formats</heading>
8933
8934         <p>
8935           The unification of Debian documentation is being carried out
8936           via HTML.</p>
8937
8938         <p>
8939           If your package comes with extensive documentation in a
8940           markup format that can be converted to various other formats
8941           you should if possible ship HTML versions in a binary
8942           package, in the directory
8943           <file>/usr/share/doc/<var>appropriate-package</var></file> or
8944           its subdirectories.<footnote>
8945               The rationale: The important thing here is that HTML
8946               docs should be available in <em>some</em> package, not
8947               necessarily in the main binary package.
8948           </footnote>
8949         </p>
8950
8951         <p>
8952           Other formats such as PostScript may be provided at the
8953           package maintainer's discretion.
8954         </p>
8955       </sect>
8956
8957       <sect id="copyrightfile">
8958         <heading>Copyright information</heading>
8959
8960         <p>
8961           Every package must be accompanied by a verbatim copy of its
8962           copyright and distribution license in the file
8963           <file>/usr/share/doc/<var>package</var>/copyright</file>. This
8964           file must neither be compressed nor be a symbolic link.
8965         </p>
8966
8967         <p>
8968           In addition, the copyright file must say where the upstream
8969           sources (if any) were obtained.  It should name the original
8970           authors of the package and the Debian maintainer(s) who were
8971           involved with its creation.
8972         </p>
8973
8974         <p>
8975           Packages in the <em>contrib</em> or <em>non-free</em>
8976           distribution areas should state in the copyright file that the
8977           package is not part of the Debian GNU/Linux distribution and
8978           briefly explain why.
8979         </p>
8980
8981         <p>
8982           A copy of the file which will be installed in
8983           <file>/usr/share/doc/<var>package</var>/copyright</file> should
8984           be in <file>debian/copyright</file> in the source package.
8985         </p>
8986
8987         <p>
8988           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
8989           link to another directory in <file>/usr/share/doc</file> only if
8990           the two packages both come from the same source and the
8991           first package Depends on the second.  These rules are
8992           important because copyrights must be extractable by
8993           mechanical means.
8994         </p>
8995
8996         <p>
8997           Packages distributed under the UCB BSD license, the Apache
8998           license (version 2.0), the Artistic license, the GNU GPL
8999           (version 2 or 3), the GNU LGPL (versions 2, 2.1, or 3), and
9000           the GNU FDL (version 1.2) should refer to the corresponding
9001           files under <file>/usr/share/common-licenses</file>,<footnote>
9002             <p>
9003               In particular,
9004               <file>/usr/share/common-licenses/BSD</file>,
9005               <file>/usr/share/common-licenses/Apache-2.0</file>,
9006               <file>/usr/share/common-licenses/Artistic</file>,
9007               <file>/usr/share/common-licenses/GPL-2</file>,
9008               <file>/usr/share/common-licenses/GPL-3</file>,
9009               <file>/usr/share/common-licenses/LGPL-2</file>,
9010               <file>/usr/share/common-licenses/LGPL-2.1</file>,
9011               <file>/usr/share/common-licenses/LGPL-3</file>, and
9012               <file>/usr/share/common-licenses/GFDL-1.2</file>
9013               respectively.
9014             </p>
9015           </footnote> rather than quoting them in the copyright
9016           file. 
9017         </p>
9018
9019         <p>
9020           You should not use the copyright file as a general <file>README</file>
9021           file.  If your package has such a file it should be
9022           installed in <file>/usr/share/doc/<var>package</var>/README</file> or
9023           <file>README.Debian</file> or some other appropriate place.</p>
9024       </sect>
9025
9026       <sect>
9027         <heading>Examples</heading>
9028
9029         <p>
9030           Any examples (configurations, source files, whatever),
9031           should be installed in a directory
9032           <file>/usr/share/doc/<var>package</var>/examples</file>.  These
9033           files should not be referenced by any program: they're there
9034           for the benefit of the system administrator and users as
9035           documentation only.  Architecture-specific example files
9036           should be installed in a directory
9037           <file>/usr/lib/<var>package</var>/examples</file> with symbolic
9038           links to them from
9039           <file>/usr/share/doc/<var>package</var>/examples</file>, or the
9040           latter directory itself may be a symbolic link to the
9041           former.
9042         </p>
9043
9044         <p>
9045           If the purpose of a package is to provide examples, then the
9046           example files may be installed into
9047           <file>/usr/share/doc/<var>package</var></file>.
9048         </p>
9049       </sect>
9050
9051       <sect id="changelogs">
9052         <heading>Changelog files</heading>
9053
9054         <p>
9055           Packages that are not Debian-native must contain a
9056           compressed copy of the <file>debian/changelog</file> file from
9057           the Debian source tree in
9058           <file>/usr/share/doc/<var>package</var></file> with the name
9059           <file>changelog.Debian.gz</file>.
9060         </p>
9061
9062         <p>
9063           If an upstream changelog is available, it should be accessible as
9064           <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
9065           plain text.  If the upstream changelog is distributed in
9066           HTML, it should be made available in that form as
9067           <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
9068           and a plain text <file>changelog.gz</file> should be generated
9069           from it using, for example, <tt>lynx -dump -nolist</tt>.  If
9070           the upstream changelog files do not already conform to this
9071           naming convention, then this may be achieved either by
9072           renaming the files, or by adding a symbolic link, at the
9073           maintainer's discretion.<footnote>
9074               Rationale: People should not have to look in places for
9075               upstream changelogs merely because they are given
9076               different names or are distributed in HTML format.
9077           </footnote>
9078         </p>
9079
9080         <p>
9081           All of these files should be installed compressed using
9082           <tt>gzip -9</tt>, as they will become large with time even
9083           if they start out small.
9084         </p>
9085
9086         <p>
9087           If the package has only one changelog which is used both as
9088           the Debian changelog and the upstream one because there is
9089           no separate upstream maintainer then that changelog should
9090           usually be installed as
9091           <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
9092           there is a separate upstream maintainer, but no upstream
9093           changelog, then the Debian changelog should still be called
9094           <file>changelog.Debian.gz</file>.
9095         </p>
9096
9097         <p>
9098           For details about the format and contents of the Debian
9099           changelog file, please see <ref id="dpkgchangelog">.
9100         </p>
9101       </sect>
9102     </chapt>
9103
9104     <appendix id="pkg-scope">
9105       <heading>Introduction and scope of these appendices</heading>
9106
9107       <p>
9108         These appendices are taken essentially verbatim from the
9109         now-deprecated Packaging Manual, version 3.2.1.0.  They are
9110         the chapters which are likely to be of use to package
9111         maintainers and which have not already been included in the
9112         policy document itself. Most of these sections are very likely
9113         not relevant to policy; they should be treated as
9114         documentation for the packaging system. Please note that these
9115         appendices are included for convenience, and for historical
9116         reasons: they used to be part of policy package, and they have
9117         not yet been incorporated into dpkg documentation. However,
9118         they still have value, and hence they are presented here.
9119       </p>
9120
9121       <p>
9122         They have not yet been checked to ensure that they are
9123         compatible with the contents of policy, and if there are any
9124         contradictions, the version in the main policy document takes
9125         precedence.  The remaining chapters of the old Packaging
9126         Manual have also not been read in detail to ensure that there
9127         are not parts which have been left out.  Both of these will be
9128         done in due course.
9129       </p>
9130
9131       <p>
9132         Certain parts of the Packaging manual were integrated into the
9133         Policy Manual proper, and removed from the appendices. Links
9134         have been placed from the old locations to the new ones.
9135       </p>
9136
9137       <p>
9138         <prgn>dpkg</prgn> is a suite of programs for creating binary
9139         package files and installing and removing them on Unix
9140         systems.<footnote>
9141             <prgn>dpkg</prgn> is targeted primarily at Debian
9142             GNU/Linux, but may work on or be ported to other
9143             systems.
9144         </footnote>
9145       </p>
9146
9147       <p>
9148         The binary packages are designed for the management of
9149         installed executable programs (usually compiled binaries) and
9150         their associated data, though source code examples and
9151         documentation are provided as part of some packages.</p>
9152
9153       <p>
9154         This manual describes the technical aspects of creating Debian
9155         binary packages (<file>.deb</file> files).  It documents the
9156         behavior of the package management programs
9157         <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
9158         they interact with packages.</p>
9159
9160       <p>
9161         It also documents the interaction between
9162         <prgn>dselect</prgn>'s core and the access method scripts it
9163         uses to actually install the selected packages, and describes
9164         how to create a new access method.</p>
9165
9166       <p>
9167         This manual does not go into detail about the options and
9168         usage of the package building and installation tools.  It
9169         should therefore be read in conjunction with those programs'
9170         man pages.
9171       </p>
9172
9173       <p>
9174         The utility programs which are provided with <prgn>dpkg</prgn>
9175         for managing various system configuration and similar issues,
9176         such as <prgn>update-rc.d</prgn> and
9177         <prgn>install-info</prgn>, are not described in detail here -
9178         please see their man pages.
9179       </p>
9180
9181       <p>
9182         It is assumed that the reader is reasonably familiar with the
9183         <prgn>dpkg</prgn> System Administrators' manual.
9184         Unfortunately this manual does not yet exist.
9185       </p>
9186
9187       <p>
9188         The Debian version of the FSF's GNU hello program is provided
9189         as an example for people wishing to create Debian
9190         packages. The Debian <prgn>debmake</prgn> package is
9191         recommended as a very helpful tool in creating and maintaining
9192         Debian packages. However, while the tools and examples are
9193         helpful, they do not replace the need to read and follow the
9194         Policy and Programmer's Manual.</p>
9195     </appendix>
9196
9197     <appendix id="pkg-binarypkg">
9198       <heading>Binary packages (from old Packaging Manual)</heading>
9199
9200       <p>
9201         The binary package has two main sections.  The first part
9202         consists of various control information files and scripts used
9203         by <prgn>dpkg</prgn> when installing and removing.  See <ref
9204         id="pkg-controlarea">.
9205       </p>
9206
9207       <p>
9208         The second part is an archive containing the files and
9209         directories to be installed.
9210       </p>
9211
9212       <p>
9213         In the future binary packages may also contain other
9214         components, such as checksums and digital signatures. The
9215         format for the archive is described in full in the
9216         <file>deb(5)</file> man page.
9217       </p>
9218
9219
9220       <sect id="pkg-bincreating"><heading>Creating package files -
9221       <prgn>dpkg-deb</prgn>
9222         </heading>
9223
9224         <p>
9225           All manipulation of binary package files is done by
9226           <prgn>dpkg-deb</prgn>; it's the only program that has
9227           knowledge of the format.  (<prgn>dpkg-deb</prgn> may be
9228           invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
9229           will spot that the options requested are appropriate to
9230           <prgn>dpkg-deb</prgn> and invoke that instead with the same
9231           arguments.)
9232         </p>
9233
9234         <p>
9235           In order to create a binary package you must make a
9236           directory tree which contains all the files and directories
9237           you want to have in the file system data part of the package.
9238           In Debian-format source packages this directory is usually
9239           <file>debian/tmp</file>, relative to the top of the package's
9240           source tree.
9241         </p>
9242
9243         <p>
9244           They should have the locations (relative to the root of the
9245           directory tree you're constructing) ownerships and
9246           permissions which you want them to have on the system when
9247           they are installed.
9248         </p>
9249
9250         <p>
9251           With current versions of <prgn>dpkg</prgn> the uid/username
9252           and gid/groupname mappings for the users and groups being
9253           used should be the same on the system where the package is
9254           built and the one where it is installed.
9255         </p>
9256
9257         <p>
9258           You need to add one special directory to the root of the
9259           miniature file system tree you're creating:
9260           <prgn>DEBIAN</prgn>.  It should contain the control
9261           information files, notably the binary package control file
9262           (see <ref id="pkg-controlfile">).
9263         </p>
9264
9265         <p>
9266           The <prgn>DEBIAN</prgn> directory will not appear in the
9267           file system archive of the package, and so won't be installed
9268           by <prgn>dpkg</prgn> when the package is installed.
9269         </p>
9270
9271         <p>
9272           When you've prepared the package, you should invoke:
9273           <example>
9274   dpkg --build <var>directory</var>
9275           </example>
9276         </p>
9277
9278         <p>
9279           This will build the package in
9280           <file><var>directory</var>.deb</file>.  (<prgn>dpkg</prgn> knows
9281           that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
9282           it invokes <prgn>dpkg-deb</prgn> with the same arguments to
9283           build the package.)
9284         </p>
9285
9286         <p>
9287           See the man page <manref name="dpkg-deb" section="8"> for details of how
9288           to examine the contents of this newly-created file.  You may find the
9289           output of following commands enlightening:
9290           <example>
9291   dpkg-deb --info <var>filename</var>.deb
9292   dpkg-deb --contents <var>filename</var>.deb
9293   dpkg --contents <var>filename</var>.deb
9294           </example>
9295           To view the copyright file for a package you could use this command:
9296           <example>
9297   dpkg --fsys-tarfile <var>filename</var>.deb | tar xOf - \*/copyright | pager
9298           </example>
9299         </p>
9300       </sect>
9301
9302       <sect id="pkg-controlarea">
9303         <heading>Package control information files</heading>
9304
9305         <p>
9306           The control information portion of a binary package is a
9307           collection of files with names known to <prgn>dpkg</prgn>.
9308           It will treat the contents of these files specially - some
9309           of them contain information used by <prgn>dpkg</prgn> when
9310           installing or removing the package; others are scripts which
9311           the package maintainer wants <prgn>dpkg</prgn> to run.
9312         </p>
9313
9314         <p>
9315           It is possible to put other files in the package control
9316           area, but this is not generally a good idea (though they
9317           will largely be ignored).
9318         </p>
9319
9320         <p>
9321           Here is a brief list of the control info files supported by
9322           <prgn>dpkg</prgn> and a summary of what they're used for.
9323         </p>
9324
9325         <p>
9326           <taglist>
9327             <tag><tt>control</tt>
9328             <item>
9329               <p>
9330                 This is the key description file used by
9331                 <prgn>dpkg</prgn>.  It specifies the package's name
9332                 and version, gives its description for the user,
9333                 states its relationships with other packages, and so
9334                 forth.  See <ref id="sourcecontrolfiles"> and
9335                 <ref id="binarycontrolfiles">.
9336               </p>
9337
9338               <p>
9339                 It is usually generated automatically from information
9340                 in the source package by the
9341                 <prgn>dpkg-gencontrol</prgn> program, and with
9342                 assistance from <prgn>dpkg-shlibdeps</prgn>.
9343                 See <ref id="pkg-sourcetools">.
9344               </p>
9345             </item>
9346
9347             <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
9348                  <tt>prerm</tt>
9349             </tag>
9350             <item>
9351               <p>
9352                 These are executable files (usually scripts) which
9353                 <prgn>dpkg</prgn> runs during installation, upgrade
9354                 and removal of packages.  They allow the package to
9355                 deal with matters which are particular to that package
9356                 or require more complicated processing than that
9357                 provided by <prgn>dpkg</prgn>.  Details of when and
9358                 how they are called are in <ref id="maintainerscripts">.
9359               </p>
9360
9361               <p>
9362                 It is very important to make these scripts idempotent.
9363                 See <ref id="idempotency">.
9364               </p>
9365
9366               <p>
9367                 The maintainer scripts are guaranteed to run with a
9368                 controlling terminal and can interact with the user.
9369                 See <ref id="controllingterminal">.
9370               </p>
9371             </item>
9372
9373             <tag><tt>conffiles</tt>
9374             </tag>
9375             <item>
9376                 This file contains a list of configuration files which
9377                 are to be handled automatically by <prgn>dpkg</prgn>
9378                 (see <ref id="pkg-conffiles">).  Note that not necessarily
9379                 every configuration file should be listed here.
9380             </item>
9381
9382             <tag><tt>shlibs</tt>
9383             </tag>
9384             <item>
9385                 This file contains a list of the shared libraries
9386                 supplied by the package, with dependency details for
9387                 each.  This is used by <prgn>dpkg-shlibdeps</prgn>
9388                 when it determines what dependencies are required in a
9389                 package control file. The <tt>shlibs</tt> file format
9390                 is described on <ref id="shlibs">.
9391             </item>
9392           </taglist>
9393         </p>
9394
9395       <sect id="pkg-controlfile">
9396         <heading>The main control information file: <tt>control</tt></heading>
9397
9398         <p>
9399           The most important control information file used by
9400           <prgn>dpkg</prgn> when it installs a package is
9401           <tt>control</tt>.  It contains all the package's "vital
9402           statistics".
9403         </p>
9404
9405         <p>
9406           The binary package control files of packages built from
9407           Debian sources are made by a special tool,
9408           <prgn>dpkg-gencontrol</prgn>, which reads
9409           <file>debian/control</file> and <file>debian/changelog</file> to
9410           find the information it needs.  See <ref id="pkg-sourcepkg"> for
9411           more details.
9412         </p>
9413
9414         <p>
9415           The fields in binary package control files are listed in
9416           <ref id="binarycontrolfiles">.
9417         </p>
9418
9419         <p>
9420           A description of the syntax of control files and the purpose
9421           of the fields is available in <ref id="controlfields">.
9422         </p>
9423       </sect>
9424
9425       <sect>
9426         <heading>Time Stamps</heading>
9427
9428         <p>
9429           See <ref id="timestamps">.
9430         </p>
9431       </sect>
9432     </appendix>
9433
9434     <appendix id="pkg-sourcepkg">
9435       <heading>Source packages (from old Packaging Manual) </heading>
9436
9437       <p>
9438         The Debian binary packages in the distribution are generated
9439         from Debian sources, which are in a special format to assist
9440         the easy and automatic building of binaries.
9441       </p>
9442
9443       <sect id="pkg-sourcetools">
9444         <heading>Tools for processing source packages</heading>
9445
9446         <p>
9447           Various tools are provided for manipulating source packages;
9448           they pack and unpack sources and help build of binary
9449           packages and help manage the distribution of new versions.
9450         </p>
9451
9452         <p>
9453           They are introduced and typical uses described here; see
9454           <manref name="dpkg-source" section="1"> for full
9455           documentation about their arguments and operation.
9456         </p>
9457
9458         <p>
9459           For examples of how to construct a Debian source package,
9460           and how to use those utilities that are used by Debian
9461           source packages, please see the <prgn>hello</prgn> example
9462           package.
9463         </p>
9464
9465         <sect1 id="pkg-dpkg-source">
9466           <heading>
9467             <prgn>dpkg-source</prgn> - packs and unpacks Debian source
9468             packages
9469           </heading>
9470
9471           <p>
9472             This program is frequently used by hand, and is also
9473             called from package-independent automated building scripts
9474             such as <prgn>dpkg-buildpackage</prgn>.
9475           </p>
9476
9477           <p>
9478             To unpack a package it is typically invoked with
9479             <example>
9480   dpkg-source -x <var>.../path/to/filename</var>.dsc
9481             </example>
9482           </p>
9483
9484            <p>
9485             with the <file><var>filename</var>.tar.gz</file> and
9486             <file><var>filename</var>.diff.gz</file> (if applicable) in
9487             the same directory.  It unpacks into
9488             <file><var>package</var>-<var>version</var></file>, and if
9489             applicable
9490             <file><var>package</var>-<var>version</var>.orig</file>, in
9491             the current directory.
9492           </p>
9493
9494           <p>
9495             To create a packed source archive it is typically invoked:
9496             <example>
9497   dpkg-source -b <var>package</var>-<var>version</var>
9498           </example>
9499           </p>
9500
9501           <p>
9502             This will create the <file>.dsc</file>, <file>.tar.gz</file> and
9503             <file>.diff.gz</file> (if appropriate) in the current
9504             directory.  <prgn>dpkg-source</prgn> does not clean the
9505             source tree first - this must be done separately if it is
9506             required.
9507           </p>
9508
9509           <p>
9510             See also <ref id="pkg-sourcearchives">.</p>
9511         </sect1>
9512
9513
9514         <sect1 id="pkg-dpkg-buildpackage">
9515           <heading>
9516             <prgn>dpkg-buildpackage</prgn> - overall package-building
9517             control script
9518           </heading>
9519
9520           <p>
9521             <prgn>dpkg-buildpackage</prgn> is a script which invokes
9522             <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
9523             targets <tt>clean</tt>, <tt>build</tt> and
9524             <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
9525             <prgn>gpg</prgn> (or <prgn>pgp</prgn>) to build a signed
9526             source and binary package upload.
9527           </p>
9528
9529           <p>
9530             It is usually invoked by hand from the top level of the
9531             built or unbuilt source directory.  It may be invoked with
9532             no arguments; useful arguments include:
9533             <taglist compact="compact">
9534               <tag><tt>-uc</tt>, <tt>-us</tt></tag>
9535               <item>
9536                 <p>
9537                   Do not sign the <tt>.changes</tt> file or the
9538                   source package <tt>.dsc</tt> file, respectively.</p>
9539               </item>
9540               <tag><tt>-p<var>sign-command</var></tt></tag>
9541               <item>
9542                 <p>
9543                   Invoke <var>sign-command</var> instead of finding
9544                   <tt>gpg</tt> or <tt>pgp</tt> on the <prgn>PATH</prgn>.
9545                   <var>sign-command</var> must behave just like
9546                   <prgn>gpg</prgn> or <tt>pgp</tt>.</p>
9547               </item>
9548               <tag><tt>-r<var>root-command</var></tt></tag>
9549               <item>
9550                 <p>
9551                   When root privilege is required, invoke the command
9552                   <var>root-command</var>.  <var>root-command</var>
9553                   should invoke its first argument as a command, from
9554                   the <prgn>PATH</prgn> if necessary, and pass its
9555                   second and subsequent arguments to the command it
9556                   calls.  If no <var>root-command</var> is supplied
9557                   then <var>dpkg-buildpackage</var> will take no
9558                   special action to gain root privilege, so that for
9559                   most packages it will have to be invoked as root to
9560                   start with.</p>
9561               </item>
9562               <tag><tt>-b</tt>, <tt>-B</tt></tag>
9563               <item>
9564                 <p>
9565                   Two types of binary-only build and upload - see
9566                   <manref name="dpkg-source" section="1">.
9567                 </p>
9568               </item>
9569             </taglist>
9570           </p>
9571         </sect1>
9572
9573         <sect1 id="pkg-dpkg-gencontrol">
9574           <heading>
9575             <prgn>dpkg-gencontrol</prgn> - generates binary package
9576             control files
9577           </heading>
9578
9579           <p>
9580             This program is usually called from <file>debian/rules</file>
9581             (see <ref id="pkg-sourcetree">) in the top level of the source
9582             tree.
9583           </p>
9584
9585           <p>
9586             This is usually done just before the files and directories in the
9587             temporary directory tree where the package is being built have their
9588             permissions and ownerships set and the package is constructed using
9589             <prgn>dpkg-deb/</prgn>
9590               <footnote>
9591                 This is so that the control file which is produced has
9592                 the right permissions
9593             </footnote>.
9594           </p>
9595
9596           <p>
9597             <prgn>dpkg-gencontrol</prgn> must be called after all the
9598             files which are to go into the package have been placed in
9599             the temporary build directory, so that its calculation of
9600             the installed size of a package is correct.
9601           </p>
9602
9603           <p>
9604             It is also necessary for <prgn>dpkg-gencontrol</prgn> to
9605             be run after <prgn>dpkg-shlibdeps</prgn> so that the
9606             variable substitutions created by
9607             <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
9608             are available.
9609           </p>
9610
9611           <p>
9612             For a package which generates only one binary package, and
9613             which builds it in <file>debian/tmp</file> relative to the top
9614             of the source package, it is usually sufficient to call
9615             <prgn>dpkg-gencontrol</prgn>.
9616           </p>
9617
9618           <p>
9619             Sources which build several binaries will typically need
9620             something like:
9621             <example>
9622   dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
9623             </example> The <tt>-P</tt> tells
9624             <prgn>dpkg-gencontrol</prgn> that the package is being
9625             built in a non-default directory, and the <tt>-p</tt>
9626             tells it which package's control file should be generated.
9627           </p>
9628
9629           <p>
9630             <prgn>dpkg-gencontrol</prgn> also adds information to the
9631             list of files in <file>debian/files</file>, for the benefit of
9632             (for example) a future invocation of
9633             <prgn>dpkg-genchanges</prgn>.</p>
9634         </sect1>
9635
9636         <sect1 id="pkg-dpkg-shlibdeps">
9637           <heading>
9638             <prgn>dpkg-shlibdeps</prgn> - calculates shared library
9639             dependencies
9640           </heading>
9641
9642           <p>
9643             This program is usually called from <file>debian/rules</file>
9644             just before <prgn>dpkg-gencontrol</prgn> (see <ref
9645             id="pkg-sourcetree">), in the top level of the source tree.
9646           </p>
9647
9648           <p>
9649             Its arguments are executables and shared libraries
9650             <footnote>
9651               <p>
9652                 They may be specified either in the locations in the
9653                 source tree where they are created or in the locations
9654                 in the temporary build tree where they are installed
9655                 prior to binary package creation.
9656               </p>
9657             </footnote> for which shared library dependencies should
9658             be included in the binary package's control file.
9659           </p>
9660
9661           <p>
9662             If some of the found shared libraries should only
9663             warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
9664             some warrant a <tt>Pre-Depends</tt>, this can be achieved
9665             by using the <tt>-d<var>dependency-field</var></tt> option
9666             before those executable(s).  (Each <tt>-d</tt> option
9667             takes effect until the next <tt>-d</tt>.)
9668           </p>
9669
9670           <p>
9671             <prgn>dpkg-shlibdeps</prgn> does not directly cause the
9672             output control file to be modified.  Instead by default it
9673             adds to the <file>debian/substvars</file> file variable
9674             settings like <tt>shlibs:Depends</tt>.  These variable
9675             settings must be referenced in dependency fields in the
9676             appropriate per-binary-package sections of the source
9677             control file.
9678           </p>
9679
9680           <p>
9681             For example, a package that generates an essential part
9682             which requires dependencies, and optional parts that 
9683             which only require a recommendation, would separate those
9684             two sets of dependencies into two different fields.<footnote>
9685                 At the time of writing, an example for this was the
9686                 <package/xmms/ package, with Depends used for the xmms
9687                 executable, Recommends for the plug-ins and Suggests for
9688                 even more optional features provided by unzip.
9689             </footnote>
9690             It can say in its <file>debian/rules</file>:
9691             <example>
9692   dpkg-shlibdeps -dDepends <var>program anotherprogram ...</var> \
9693                  -dRecommends <var>optionalpart anotheroptionalpart</var>
9694             </example>
9695             and then in its main control file <file>debian/control</file>:
9696             <example>
9697   <var>...</var>
9698   Depends: ${shlibs:Depends}
9699   Recommends: ${shlibs:Recommends}
9700   <var>...</var>
9701             </example>
9702           </p>
9703
9704           <p>
9705             Sources which produce several binary packages with
9706             different shared library dependency requirements can use
9707             the <tt>-p<var>varnameprefix</var></tt> option to override
9708             the default <tt>shlibs:</tt> prefix (one invocation of
9709             <prgn>dpkg-shlibdeps</prgn> per setting of this option).
9710             They can thus produce several sets of dependency
9711             variables, each of the form
9712             <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
9713             which can be referred to in the appropriate parts of the
9714             binary package control files.
9715           </p>
9716         </sect1>
9717
9718
9719         <sect1 id="pkg-dpkg-distaddfile">
9720           <heading>
9721             <prgn>dpkg-distaddfile</prgn> - adds a file to
9722             <file>debian/files</file>
9723           </heading>
9724
9725           <p>
9726             Some packages' uploads need to include files other than
9727             the source and binary package files.
9728           </p>
9729
9730           <p>
9731             <prgn>dpkg-distaddfile</prgn> adds a file to the
9732             <file>debian/files</file> file so that it will be included in
9733             the <file>.changes</file> file when
9734             <prgn>dpkg-genchanges</prgn> is run.
9735           </p>
9736
9737           <p>
9738             It is usually invoked from the <tt>binary</tt> target of
9739             <file>debian/rules</file>:
9740             <example>
9741   dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
9742             </example>
9743             The <var>filename</var> is relative to the directory where
9744             <prgn>dpkg-genchanges</prgn> will expect to find it - this
9745             is usually the directory above the top level of the source
9746             tree.  The <file>debian/rules</file> target should put the
9747             file there just before or just after calling
9748             <prgn>dpkg-distaddfile</prgn>.
9749           </p>
9750
9751           <p>
9752             The <var>section</var> and <var>priority</var> are passed
9753             unchanged into the resulting <file>.changes</file> file.
9754           </p>
9755         </sect1>
9756
9757
9758         <sect1 id="pkg-dpkg-genchanges">
9759           <heading>
9760             <prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file>
9761             upload control file
9762           </heading>
9763
9764           <p>
9765             This program is usually called by package-independent
9766             automatic building scripts such as
9767             <prgn>dpkg-buildpackage</prgn>, but it may also be called
9768             by hand.
9769           </p>
9770
9771           <p>
9772             It is usually called in the top level of a built source
9773             tree, and when invoked with no arguments will print out a
9774             straightforward <file>.changes</file> file based on the
9775             information in the source package's changelog and control
9776             file and the binary and source packages which should have
9777             been built.
9778           </p>
9779         </sect1>
9780
9781
9782         <sect1 id="pkg-dpkg-parsechangelog">
9783           <heading>
9784             <prgn>dpkg-parsechangelog</prgn> - produces parsed
9785             representation of a changelog
9786           </heading>
9787
9788           <p>
9789             This program is used internally by
9790             <prgn>dpkg-source</prgn> et al.  It may also occasionally
9791             be useful in <file>debian/rules</file> and elsewhere.  It
9792             parses a changelog, <file>debian/changelog</file> by default,
9793             and prints a control-file format representation of the
9794             information in it to standard output.
9795           </p>
9796         </sect1>
9797
9798         <sect1 id="pkg-dpkg-architecture">
9799           <heading>
9800             <prgn>dpkg-architecture</prgn> - information about the build and
9801             host system
9802           </heading>
9803
9804           <p>
9805             This program can be used manually, but is also invoked by
9806             <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
9807             environment or make variables which specify the build and host
9808             architecture for the package building process.
9809           </p>
9810         </sect1>
9811       </sect>
9812
9813       <sect id="pkg-sourcetree">
9814         <heading>The Debianised source tree</heading>
9815
9816         <p>
9817           The source archive scheme described later is intended to
9818           allow a Debianised source tree with some associated control
9819           information to be reproduced and transported easily.  The
9820           Debianised source tree is a version of the original program
9821           with certain files added for the benefit of the
9822           Debianisation process, and with any other changes required
9823           made to the rest of the source code and installation
9824           scripts.
9825         </p>
9826
9827         <p>
9828           The extra files created for Debian are in the subdirectory
9829           <file>debian</file> of the top level of the Debianised source
9830           tree.  They are described below.
9831         </p>
9832
9833         <sect1 id="pkg-debianrules">
9834           <heading><file>debian/rules</file> - the main building script</heading>
9835
9836           <p>
9837             See <ref id="debianrules">.
9838           </p>
9839         </sect1>
9840
9841
9842         <sect1 id="pkg-dpkgchangelog">
9843           <heading><file>debian/changelog</file></heading>
9844
9845           <p>
9846             See <ref id="dpkgchangelog">.
9847           </p>
9848
9849           <sect2><heading>Defining alternative changelog formats
9850             </heading>
9851
9852             <p>
9853               It is possible to use a different format to the standard
9854               one, by providing a parser for the format you wish to
9855               use.
9856             </p>
9857
9858             <p>
9859               In order to have <tt>dpkg-parsechangelog</tt> run your
9860               parser, you must include a line within the last 40 lines
9861               of your file matching the Perl regular expression:
9862               <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9863               parentheses should be the name of the format.  For
9864               example, you might say:
9865               <example>
9866   @@@ changelog-format: joebloggs @@@
9867               </example>
9868               Changelog format names are non-empty strings of alphanumerics.
9869             </p>
9870
9871             <p>
9872               If such a line exists then <tt>dpkg-parsechangelog</tt>
9873               will look for the parser as
9874               <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9875               or
9876               <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9877               it is an error for it not to find it, or for it not to
9878               be an executable program.  The default changelog format
9879               is <tt>dpkg</tt>, and a parser for it is provided with
9880               the <tt>dpkg</tt> package.
9881             </p>
9882
9883             <p>
9884               The parser will be invoked with the changelog open on
9885               standard input at the start of the file.  It should read
9886               the file (it may seek if it wishes) to determine the
9887               information required and return the parsed information
9888               to standard output in the form of a series of control
9889               fields in the standard format.  By default it should
9890               return information about only the most recent version in
9891               the changelog; it should accept a
9892               <tt>-v<var>version</var></tt> option to return changes
9893               information from all versions present <em>strictly
9894               after</em> <var>version</var>, and it should then be an
9895               error for <var>version</var> not to be present in the
9896               changelog.
9897             </p>
9898
9899             <p>
9900               The fields are:
9901               <list compact="compact">
9902                 <item><qref id="f-Source"><tt>Source</tt></qref></item>
9903                 <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
9904                 <item><qref id="f-Distribution"><tt>Distribution</tt></qref> (mandatory)</item>
9905                 <item><qref id="f-Urgency"><tt>Urgency</tt></qref> (mandatory)</item>
9906                 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
9907                 <item><qref id="f-Date"><tt>Date</tt></qref></item>
9908                 <item><qref id="f-Changes"><tt>Changes</tt></qref> (mandatory)</item>
9909               </list>
9910             </p>
9911
9912             <p>
9913               If several versions are being returned (due to the use
9914               of <tt>-v</tt>), the urgency value should be of the
9915               highest urgency code listed at the start of any of the
9916               versions requested followed by the concatenated
9917               (space-separated) comments from all the versions
9918               requested; the maintainer, version, distribution and
9919               date should always be from the most recent version.
9920             </p>
9921
9922             <p>
9923               For the format of the <tt>Changes</tt> field see
9924               <ref id="f-Changes">.
9925             </p>
9926
9927             <p>
9928               If the changelog format which is being parsed always or
9929               almost always leaves a blank line between individual
9930               change notes these blank lines should be stripped out,
9931               so as to make the resulting output compact.
9932             </p>
9933
9934             <p>
9935               If the changelog format does not contain date or package
9936               name information this information should be omitted from
9937               the output.  The parser should not attempt to synthesize
9938               it or find it from other sources.
9939             </p>
9940
9941             <p>
9942               If the changelog does not have the expected format the
9943               parser should exit with a nonzero exit status, rather
9944               than trying to muddle through and possibly generating
9945               incorrect output.
9946             </p>
9947
9948             <p>
9949               A changelog parser may not interact with the user at
9950               all.
9951             </p>
9952           </sect2>
9953         </sect1>
9954
9955         <sect1 id="pkg-srcsubstvars">
9956           <heading><file>debian/substvars</file> and variable substitutions</heading>
9957
9958           <p>
9959             See <ref id="substvars">.
9960           </p>
9961
9962         </sect1>
9963
9964         <sect1>
9965           <heading><file>debian/files</file></heading>
9966
9967           <p>
9968             See <ref id="debianfiles">.
9969           </p>
9970         </sect1>
9971
9972         <sect1><heading><file>debian/tmp</file>
9973           </heading>
9974
9975           <p>
9976             This is the canonical temporary location for the
9977             construction of binary packages by the <tt>binary</tt>
9978             target.  The directory <file>tmp</file> serves as the root of
9979             the file system tree as it is being constructed (for
9980             example, by using the package's upstream makefiles install
9981             targets and redirecting the output there), and it also
9982             contains the <tt>DEBIAN</tt> subdirectory.  See <ref
9983             id="pkg-bincreating">.
9984           </p>
9985
9986           <p>
9987             If several binary packages are generated from the same
9988             source tree it is usual to use several
9989             <file>debian/tmp<var>something</var></file> directories, for
9990             example <file>tmp-a</file> or <file>tmp-doc</file>.
9991           </p>
9992
9993           <p>
9994             Whatever <file>tmp</file> directories are created and used by
9995             <tt>binary</tt> must of course be removed by the
9996             <tt>clean</tt> target.</p></sect1>
9997       </sect>
9998
9999
10000       <sect id="pkg-sourcearchives"><heading>Source packages as archives
10001         </heading>
10002
10003         <p>
10004           As it exists on the FTP site, a Debian source package
10005           consists of three related files.  You must have the right
10006           versions of all three to be able to use them.
10007         </p>
10008
10009         <p>
10010           <taglist>
10011             <tag>Debian source control file - <tt>.dsc</tt></tag>
10012             <item>
10013                 This file is a control file used by <prgn>dpkg-source</prgn>
10014                 to extract a source package.
10015                 See <ref id="debiansourcecontrolfiles">.
10016             </item>
10017
10018             <tag>
10019               Original source archive -
10020               <file>
10021                 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
10022               </file>
10023             </tag>
10024
10025             <item>
10026               <p>
10027                 This is a compressed (with <tt>gzip -9</tt>)
10028                 <prgn>tar</prgn> file containing the source code from
10029                 the upstream authors of the program.
10030               </p>
10031             </item>
10032
10033             <tag>
10034               Debianisation diff -
10035               <file>
10036                 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
10037               </file>
10038             </tag>
10039             <item>
10040
10041               <p>
10042                 This is a unified context diff (<tt>diff -u</tt>)
10043                 giving the changes which are required to turn the
10044                 original source into the Debian source.  These changes
10045                 may only include editing and creating plain files.
10046                 The permissions of files, the targets of symbolic
10047                 links and the characteristics of special files or
10048                 pipes may not be changed and no files may be removed
10049                 or renamed.
10050               </p>
10051
10052               <p>
10053                 All the directories in the diff must exist, except the
10054                 <file>debian</file> subdirectory of the top of the source
10055                 tree, which will be created by
10056                 <prgn>dpkg-source</prgn> if necessary when unpacking.
10057               </p>
10058
10059               <p>
10060                 The <prgn>dpkg-source</prgn> program will
10061                 automatically make the <file>debian/rules</file> file
10062                 executable (see below).</p></item>
10063           </taglist>
10064         </p>
10065
10066         <p>
10067           If there is no original source code - for example, if the
10068           package is specially prepared for Debian or the Debian
10069           maintainer is the same as the upstream maintainer - the
10070           format is slightly different: then there is no diff, and the
10071           tarfile is named
10072           <file><var>package</var>_<var>version</var>.tar.gz</file>,
10073           and preferably contains a directory named
10074           <file><var>package</var>-<var>version</var></file>.
10075         </p>
10076       </sect>
10077
10078       <sect>
10079         <heading>Unpacking a Debian source package without <prgn>dpkg-source</prgn></heading>
10080
10081         <p>
10082           <tt>dpkg-source -x</tt> is the recommended way to unpack a
10083           Debian source package.  However, if it is not available it
10084           is possible to unpack a Debian source archive as follows:
10085         <enumlist compact="compact">
10086           <item>
10087             <p>
10088               Untar the tarfile, which will create a <file>.orig</file>
10089               directory.</p>
10090           </item>
10091           <item>
10092             <p>Rename the <file>.orig</file> directory to
10093               <file><var>package</var>-<var>version</var></file>.</p>
10094           </item>
10095             <item>
10096             <p>
10097               Create the subdirectory <file>debian</file> at the top of
10098               the source tree.</p>
10099           </item>
10100           <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
10101           </item>
10102           <item><p>Untar the tarfile again if you want a copy of the original
10103               source code alongside the Debianised version.</p>
10104           </item>
10105         </enumlist>
10106
10107         <p>
10108           It is not possible to generate a valid Debian source archive
10109           without using <prgn>dpkg-source</prgn>.  In particular,
10110           attempting to use <prgn>diff</prgn> directly to generate the
10111           <file>.diff.gz</file> file will not work.
10112         </p>
10113
10114         <sect1>
10115           <heading>Restrictions on objects in source packages</heading>
10116
10117           <p>
10118             The source package may not contain any hard links
10119             <footnote>
10120                 This is not currently detected when building source
10121                 packages, but only when extracting
10122                 them.
10123             </footnote>
10124             <footnote>
10125                 Hard links may be permitted at some point in the
10126                 future, but would require a fair amount of
10127                 work.
10128             </footnote>, device special files, sockets or setuid or
10129             setgid files.
10130             <footnote>
10131                 Setgid directories are allowed.
10132             </footnote>
10133           </p>
10134
10135           <p>
10136             The source packaging tools manage the changes between the
10137             original and Debianised source using <prgn>diff</prgn> and
10138             <prgn>patch</prgn>.  Turning the original source tree as
10139             included in the <file>.orig.tar.gz</file> into the debianised
10140             source must not involve any changes which cannot be
10141             handled by these tools.  Problematic changes which cause
10142             <prgn>dpkg-source</prgn> to halt with an error when
10143             building the source package are:
10144             <list compact="compact">
10145               <item><p>Adding or removing symbolic links, sockets or pipes.</p>
10146               </item>
10147               <item><p>Changing the targets of symbolic links.</p>
10148               </item>
10149               <item><p>Creating directories, other than <file>debian</file>.</p>
10150               </item>
10151               <item><p>Changes to the contents of binary files.</p></item>
10152             </list> Changes which cause <prgn>dpkg-source</prgn> to
10153             print a warning but continue anyway are:
10154             <list compact="compact">
10155               <item>
10156                 <p>
10157                   Removing files, directories or symlinks.
10158                   <footnote>
10159                       Renaming a file is not treated specially - it is
10160                       seen as the removal of the old file (which
10161                       generates a warning, but is otherwise ignored),
10162                       and the creation of the new one.
10163                   </footnote>
10164                 </p>
10165               </item>
10166               <item>
10167                 <p>
10168                   Changed text files which are missing the usual final
10169                   newline (either in the original or the modified
10170                   source tree).
10171                 </p>
10172               </item>
10173             </list>
10174             Changes which are not represented, but which are not detected by
10175             <prgn>dpkg-source</prgn>, are:
10176             <list compact="compact">
10177               <item><p>Changing the permissions of files (other than
10178                   <file>debian/rules</file>) and directories.</p></item>
10179             </list>
10180           </p>
10181
10182           <p>
10183             The <file>debian</file> directory and <file>debian/rules</file>
10184             are handled specially by <prgn>dpkg-source</prgn> - before
10185             applying the changes it will create the <file>debian</file>
10186             directory, and afterwards it will make
10187             <file>debian/rules</file> world-executable.
10188           </p>
10189         </sect1>
10190       </sect>
10191     </appendix>
10192
10193     <appendix id="pkg-controlfields">
10194       <heading>Control files and their fields (from old Packaging Manual)</heading>
10195
10196       <p>
10197         Many of the tools in the <prgn>dpkg</prgn> suite manipulate
10198         data in a common format, known as control files.  Binary and
10199         source packages have control data as do the <file>.changes</file>
10200         files which control the installation of uploaded files, and
10201         <prgn>dpkg</prgn>'s internal databases are in a similar
10202         format.
10203       </p>
10204
10205       <sect>
10206         <heading>Syntax of control files</heading>
10207
10208         <p>
10209           See <ref id="controlsyntax">.
10210         </p>
10211
10212         <p>
10213           It is important to note that there are several fields which
10214           are optional as far as <prgn>dpkg</prgn> and the related
10215           tools are concerned, but which must appear in every Debian
10216           package, or whose omission may cause problems.
10217         </p>
10218       </sect>
10219
10220       <sect>
10221         <heading>List of fields</heading>
10222
10223         <p>
10224           See <ref id="controlfieldslist">.
10225         </p>
10226
10227         <p>
10228           This section now contains only the fields that didn't belong
10229           to the Policy manual.
10230         </p>
10231
10232         <sect1 id="pkg-f-Filename">
10233           <heading><tt>Filename</tt> and <tt>MSDOS-Filename</tt></heading>
10234
10235           <p>
10236             These fields in <tt>Packages</tt> files give the
10237             filename(s) of (the parts of) a package in the
10238             distribution directories, relative to the root of the
10239             Debian hierarchy.  If the package has been split into
10240             several parts the parts are all listed in order, separated
10241             by spaces.
10242           </p>
10243         </sect1>
10244
10245         <sect1 id="pkg-f-Size">
10246           <heading><tt>Size</tt> and <tt>MD5sum</tt></heading>
10247
10248           <p>
10249             These fields in <file>Packages</file> files give the size (in
10250             bytes, expressed in decimal) and MD5 checksum of the
10251             file(s) which make(s) up a binary package in the
10252             distribution.  If the package is split into several parts
10253             the values for the parts are listed in order, separated by
10254             spaces.
10255           </p>
10256         </sect1>
10257
10258         <sect1 id="pkg-f-Status">
10259           <heading><tt>Status</tt></heading>
10260
10261           <p>
10262             This field in <prgn>dpkg</prgn>'s status file records
10263             whether the user wants a package installed, removed or
10264             left alone, whether it is broken (requiring
10265             re-installation) or not and what its current state on the
10266             system is.  Each of these pieces of information is a
10267             single word.
10268           </p>
10269         </sect1>
10270
10271         <sect1 id="pkg-f-Config-Version">
10272           <heading><tt>Config-Version</tt></heading>
10273
10274           <p>
10275             If a package is not installed or not configured, this
10276             field in <prgn>dpkg</prgn>'s status file records the last
10277             version of the package which was successfully
10278             configured.
10279           </p>
10280         </sect1>
10281
10282         <sect1 id="pkg-f-Conffiles">
10283           <heading><tt>Conffiles</tt></heading>
10284
10285           <p>
10286             This field in <prgn>dpkg</prgn>'s status file contains
10287             information about the automatically-managed configuration
10288             files held by a package.  This field should <em>not</em>
10289             appear anywhere in a package!
10290           </p>
10291         </sect1>
10292
10293         <sect1>
10294           <heading>Obsolete fields</heading>
10295
10296           <p>
10297             These are still recognized by <prgn>dpkg</prgn> but should
10298             not appear anywhere any more.
10299
10300             <taglist compact="compact">
10301
10302               <tag><tt>Revision</tt></tag>
10303               <tag><tt>Package-Revision</tt></tag>
10304               <tag><tt>Package_Revision</tt></tag>
10305               <item>
10306                   The Debian revision part of the package version was
10307                   at one point in a separate control file field.  This
10308                   field went through several names.
10309               </item>
10310
10311               <tag><tt>Recommended</tt></tag>
10312               <item>Old name for <tt>Recommends</tt>.</item>
10313
10314               <tag><tt>Optional</tt></tag>
10315               <item>Old name for <tt>Suggests</tt>.</item>
10316
10317               <tag><tt>Class</tt></tag>
10318               <item>Old name for <tt>Priority</tt>.</item>
10319
10320             </taglist>
10321           </p>
10322         </sect1>
10323       </sect>
10324
10325     </appendix>
10326
10327     <appendix id="pkg-conffiles">
10328       <heading>Configuration file handling (from old Packaging Manual)</heading>
10329
10330       <p>
10331         <prgn>dpkg</prgn> can do a certain amount of automatic
10332         handling of package configuration files.
10333       </p>
10334
10335       <p>
10336         Whether this mechanism is appropriate depends on a number of
10337         factors, but basically there are two approaches to any
10338         particular configuration file.
10339       </p>
10340
10341       <p>
10342         The easy method is to ship a best-effort configuration in the
10343         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10344         handle updates.  If the user is unlikely to want to edit the
10345         file, but you need them to be able to without losing their
10346         changes, and a new package with a changed version of the file
10347         is only released infrequently, this is a good approach.
10348       </p>
10349
10350       <p>
10351         The hard method is to build the configuration file from
10352         scratch in the <prgn>postinst</prgn> script, and to take the
10353         responsibility for fixing any mistakes made in earlier
10354         versions of the package automatically.  This will be
10355         appropriate if the file is likely to need to be different on
10356         each system.
10357       </p>
10358
10359       <sect><heading>Automatic handling of configuration files by
10360       <prgn>dpkg</prgn>
10361         </heading>
10362
10363         <p>
10364           A package may contain a control area file called
10365           <tt>conffiles</tt>.  This file should be a list of filenames
10366           of configuration files needing automatic handling, separated
10367           by newlines.  The filenames should be absolute pathnames,
10368           and the files referred to should actually exist in the
10369           package.
10370         </p>
10371
10372         <p>
10373           When a package is upgraded <prgn>dpkg</prgn> will process
10374           the configuration files during the configuration stage,
10375           shortly before it runs the package's <prgn>postinst</prgn>
10376           script,
10377         </p>
10378
10379         <p>
10380           For each file it checks to see whether the version of the
10381           file included in the package is the same as the one that was
10382           included in the last version of the package (the one that is
10383           being upgraded from); it also compares the version currently
10384           installed on the system with the one shipped with the last
10385           version.
10386         </p>
10387
10388         <p>
10389           If neither the user nor the package maintainer has changed
10390           the file, it is left alone.  If one or the other has changed
10391           their version, then the changed version is preferred - i.e.,
10392           if the user edits their file, but the package maintainer
10393           doesn't ship a different version, the user's changes will
10394           stay, silently, but if the maintainer ships a new version
10395           and the user hasn't edited it the new version will be
10396           installed (with an informative message).  If both have
10397           changed their version the user is prompted about the problem
10398           and must resolve the differences themselves.
10399         </p>
10400
10401         <p>
10402           The comparisons are done by calculating the MD5 message
10403           digests of the files, and storing the MD5 of the file as it
10404           was included in the most recent version of the package.
10405         </p>
10406
10407         <p>
10408           When a package is installed for the first time
10409           <prgn>dpkg</prgn> will install the file that comes with it,
10410           unless that would mean overwriting a file already on the
10411           file system.
10412         </p>
10413
10414         <p>
10415           However, note that <prgn>dpkg</prgn> will <em>not</em>
10416           replace a conffile that was removed by the user (or by a
10417           script).  This is necessary because with some programs a
10418           missing file produces an effect hard or impossible to
10419           achieve in another way, so that a missing file needs to be
10420           kept that way if the user did it.
10421         </p>
10422
10423         <p>
10424           Note that a package should <em>not</em> modify a
10425           <prgn>dpkg</prgn>-handled conffile in its maintainer
10426           scripts.  Doing this will lead to <prgn>dpkg</prgn> giving
10427           the user confusing and possibly dangerous options for
10428           conffile update when the package is upgraded.</p>
10429       </sect>
10430
10431       <sect><heading>Fully-featured maintainer script configuration
10432       handling
10433         </heading>
10434
10435         <p>
10436           For files which contain site-specific information such as
10437           the hostname and networking details and so forth, it is
10438           better to create the file in the package's
10439           <prgn>postinst</prgn> script.
10440         </p>
10441
10442         <p>
10443           This will typically involve examining the state of the rest
10444           of the system to determine values and other information, and
10445           may involve prompting the user for some information which
10446           can't be obtained some other way.
10447         </p>
10448
10449         <p>
10450           When using this method there are a couple of important
10451           issues which should be considered:
10452         </p>
10453
10454         <p>
10455           If you discover a bug in the program which generates the
10456           configuration file, or if the format of the file changes
10457           from one version to the next, you will have to arrange for
10458           the postinst script to do something sensible - usually this
10459           will mean editing the installed configuration file to remove
10460           the problem or change the syntax.  You will have to do this
10461           very carefully, since the user may have changed the file,
10462           perhaps to fix the very problem that your script is trying
10463           to deal with - you will have to detect these situations and
10464           deal with them correctly.
10465         </p>
10466
10467         <p>
10468           If you do go down this route it's probably a good idea to
10469           make the program that generates the configuration file(s) a
10470           separate program in <file>/usr/sbin</file>, by convention called
10471           <file><var>package</var>config</file> and then run that if
10472           appropriate from the post-installation script.  The
10473           <tt><var>package</var>config</tt> program should not
10474           unquestioningly overwrite an existing configuration - if its
10475           mode of operation is geared towards setting up a package for
10476           the first time (rather than any arbitrary reconfiguration
10477           later) you should have it check whether the configuration
10478           already exists, and require a <tt>--force</tt> flag to
10479           overwrite it.</p></sect>
10480     </appendix>
10481
10482     <appendix id="pkg-alternatives"><heading>Alternative versions of
10483         an interface - <prgn>update-alternatives</prgn> (from old
10484     Packaging Manual)
10485       </heading>
10486
10487       <p>
10488         When several packages all provide different versions of the
10489         same program or file it is useful to have the system select a
10490         default, but to allow the system administrator to change it
10491         and have their decisions respected.
10492       </p>
10493
10494       <p>
10495         For example, there are several versions of the <prgn>vi</prgn>
10496         editor, and there is no reason to prevent all of them from
10497         being installed at once, each under their own name
10498         (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10499         Nevertheless it is desirable to have the name <tt>vi</tt>
10500         refer to something, at least by default.
10501       </p>
10502
10503       <p>
10504         If all the packages involved cooperate, this can be done with
10505         <prgn>update-alternatives</prgn>.
10506       </p>
10507
10508       <p>
10509         Each package provides its own version under its own name, and
10510         calls <prgn>update-alternatives</prgn> in its postinst to
10511         register its version (and again in its prerm to deregister
10512         it).
10513       </p>
10514
10515       <p>
10516         See the man page <manref name="update-alternatives"
10517         section="8"> for details.
10518       </p>
10519
10520       <p>
10521         If <prgn>update-alternatives</prgn> does not seem appropriate
10522         you may wish to consider using diversions instead.</p>
10523     </appendix>
10524
10525     <appendix id="pkg-diversions"><heading>Diversions - overriding a
10526     package's version of a file (from old Packaging Manual)
10527       </heading>
10528
10529       <p>
10530         It is possible to have <prgn>dpkg</prgn> not overwrite a file
10531         when it reinstalls the package it belongs to, and to have it
10532         put the file from the package somewhere else instead.
10533       </p>
10534
10535       <p>
10536         This can be used locally to override a package's version of a
10537         file, or by one package to override another's version (or
10538         provide a wrapper for it).
10539       </p>
10540
10541       <p>
10542         Before deciding to use a diversion, read <ref
10543         id="pkg-alternatives"> to see if you really want a diversion
10544         rather than several alternative versions of a program.
10545       </p>
10546
10547       <p>
10548         There is a diversion list, which is read by <prgn>dpkg</prgn>,
10549         and updated by a special program <prgn>dpkg-divert</prgn>.
10550         Please see <manref name="dpkg-divert" section="8"> for full
10551         details of its operation.
10552       </p>
10553
10554       <p>
10555         When a package wishes to divert a file from another, it should
10556         call <prgn>dpkg-divert</prgn> in its preinst to add the
10557         diversion and rename the existing file.  For example,
10558         supposing that a <prgn>smailwrapper</prgn> package wishes to
10559         install a wrapper around <file>/usr/sbin/smail</file>:
10560         <example>
10561    dpkg-divert --package smailwrapper --add --rename \
10562       --divert /usr/sbin/smail.real /usr/sbin/smail
10563         </example> The <tt>--package smailwrapper</tt> ensures that
10564         <prgn>smailwrapper</prgn>'s copy of <file>/usr/sbin/smail</file>
10565         can bypass the diversion and get installed as the true version.
10566         It's safe to add the diversion unconditionally on upgrades since
10567         it will be left unchanged if it already exists, but
10568         <prgn>dpkg-divert</prgn> will display a message.  To suppress that
10569         message, make the command conditional on the version from which
10570         the package is being upgraded:
10571         <example>
10572    if [ upgrade != "$1" ] || dpkg --compare-versions "$2" lt 1.0-2; then
10573       dpkg-divert --package smailwrapper --add --rename \
10574          --divert /usr/sbin/smail.real /usr/sbin/smail
10575    fi
10576         </example> where <tt>1.0-2</tt> is the version at which the
10577         diversion was first added to the package.  Running the command
10578         during abort-upgrade is pointless but harmless.
10579       </p>
10580
10581       <p>
10582         The postrm has to do the reverse:
10583         <example>
10584   if [ remove = "$1" -o abort-install = "$1" -o disappear = "$1" ]; then
10585      dpkg-divert --package smailwrapper --remove --rename \
10586         --divert /usr/sbin/smail.real /usr/sbin/smail
10587   fi
10588         </example> If the diversion was added at a particular version, the
10589         postrm should also handle the failure case of upgrading from an
10590         older version (unless the older version is so old that direct
10591         upgrades are no longer supported):
10592         <example>
10593   if [ abort-upgrade = "$1" ] && dpkg --compare-versions "$2" lt 1.0-2; then
10594      dpkg-divert --package smailwrapper --remove --rename \
10595         --divert /usr/sbin/smail.real /usr/sbin/smail
10596   fi
10597         </example> where <tt>1.02-2</tt> is the version at which the
10598         diversion was first added to the package.  The postrm should not
10599         remove the diversion on upgrades both because there's no reason to
10600         remove the diversion only to immediately re-add it and since the
10601         postrm of the old package is run after unpacking so the removal of
10602         the diversion will fail.
10603       </p>
10604
10605       <p>
10606         Do not attempt to divert a file which is vitally important for
10607         the system's operation - when using <prgn>dpkg-divert</prgn>
10608         there is a time, after it has been diverted but before
10609         <prgn>dpkg</prgn> has installed the new version, when the file
10610         does not exist.</p>
10611     </appendix>
10612
10613   </book>
10614 </debiandoc>
10615 <!-- Local variables: -->
10616 <!-- indent-tabs-mode: t -->
10617 <!-- End: -->
10618 <!-- vim:set ai et sts=2 sw=2 tw=76: -->