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