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