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