]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
* Add "links" to Build-Depends list
[debian/debian-policy.git] / policy.sgml
1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3      within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
5 ]>
6 <debiandoc>
7   <!--
8   Debian GNU/Linux Policy Manual.
9   Copyright (C)1996,1997,1998 Ian Jackson and Christian Schwarz;
10   released under the terms of the GNU
11   General Public License, version 2 or (at your option) any later.
12   Initial version 1996, Ian Jackson, ijackson@gnu.ai.mit.edu
13   Revised November 27, 1996, David A. Morris, bweaver@debian.org
14   New sections March 15, 1997, Christian Schwarz, schwarz@debian.org
15   Reworked/Restructured April-July 1997, Christian Schwarz, schwarz@debian.org
16   Maintainer since 1997, Christian Schwarz, schwarz@debian.org
17   Christoph Lameter contributed the "Web Standard"
18   The debian-policy mailing list has taken responsibility for the
19   contents of this document since September 1998, with the package
20   maintainers responsible for packaging administrivia only.
21   -->
22
23   <book>
24     <titlepag>
25       <title>Debian Policy Manual</title>
26       <author>
27         <name>Ian Jackson </name>
28         <email>ijackson@gnu.ai.mit.edu</email>
29       </author>
30       <author>
31         <name>Christian Schwarz</name>
32         <email>schwarz@debian.org</email>
33       </author>
34       <author>
35         <name>revised: David A. Morris</name>
36         <email>bweaver@debian.org</email>
37       </author>
38       <author>
39         <name>The Debian Policy mailing List</name>
40         <email>debian-policy@lists.debian.org</email>
41       </author>
42       <version>version &version;, &date;</version>
43
44       <abstract>
45         This manual describes the policy requirements for the Debian
46         GNU/Linux distribution. This includes the structure and
47         contents of the Debian archive, several design issues of the
48         operating system, as well as technical requirements that each
49         package must satisfy to be included in the distribution. The
50         policy package itself is maintained by a group of maintainers
51         that have no editorial powers. At the moment, the list of
52         maintainers is:
53         <enumlist>
54           <item>
55             <p>Michael Alan Dorman <email>mdorman@debian.org</email></p>
56           </item>
57           <item>
58             <p>Philip Hands <email>phil@hands.com</email></p>
59           </item>
60           <item>
61             <p>Julian Gilbey <email>J.D.Gilbey@qmw.ac.uk</email></p>
62           </item>
63           <item>
64             <p>Manoj Srivastava <email>srivasta@debian.org</email></p>
65           </item>
66         </enumlist>
67       </abstract>
68
69
70       <copyright>
71         <copyrightsummary>
72           Copyright &copy;1996,1997,1998 Ian Jackson
73           and Christian Schwarz.
74         </copyrightsummary>
75         <p>
76           This manual is free software; you may redistribute it and/or
77           modify it under the terms of the GNU General Public License
78           as published by the Free Software Foundation; either version
79           2, or (at your option) any later version.
80         </p>
81
82         <p>
83           This is distributed in the hope that it will be useful, but
84           <em>without any warranty</em>; without even the implied
85           warranty of merchantability or fitness for a particular
86           purpose.  See the GNU General Public License for more
87           details.
88         </p>
89
90         <p>
91           A copy of the GNU General Public License is available as
92           <tt>/usr/share/common-licences/GPL</tt> in the Debian GNU/Linux
93           distribution or on the World Wide Web at
94           <url id="http://www.gnu.org/copyleft/gpl.html"
95                name="The GNU Public Licence">. You can also obtain it by writing to the
96           Free Software Foundation, Inc., 59 Temple Place - Suite 330,
97           Boston, MA 02111-1307, USA.
98         </p>
99       </copyright>
100     </titlepag>
101
102     <toc detail="sect">
103
104     <chapt id="scope">
105       <heading>About this manual</heading>
106       <sect>
107         <heading>Scope</heading>
108         <p>
109           This manual describes the policy requirements for the Debian
110           GNU/Linux distribution. This includes the structure and
111           contents of the Debian archive, several design issues of the
112           operating system, as well as technical requirements that
113           each package must satisfy to be included in the
114           distribution.
115         </p>
116
117
118         <p>
119           This manual also describes Debian policy as it relates to
120           creating Debian packages. It is not a tutorial on how to build
121           packages, nor is it exhaustive where it comes to describing
122           the behavior of the packaging system. Instead, this manual
123           attempts to define the interface to the package management
124           system that the developers have to be conversant with.
125           <footnote>
126             <p>
127               Informally, the criteria used for inclusion is that the
128               material meet one of the following requirements:
129               <taglist>
130                 <tag>Standard interfaces</tag>
131                 <item>
132                   <p>
133                     The material presented represents an interface to
134                     the packaging system that is mandated for use, and
135                     is used by, a significant number of packages, and
136                     should not be changed without peer review. Package
137                     maintainers can then rely on this interfaces not
138                     changing, and the package management software
139                     authors need to ensure compatibility with these
140                     interface definitions. (control file and and
141                     changelog file formats are one example)
142                   </p>
143                 </item>
144                 <tag>Chosen Convention</tag>
145                 <item>
146                   <p>
147                     If there are a number of technically viable choices
148                     that can be made, but one needs to select one of
149                     these options for inter-operability. The version
150                     number format is one example.
151                   </p>
152                 </item>
153               </taglist>
154               Please note that these are not mutually exclusive;
155               selected conventions often become parts of standard
156               interfaces.
157             </p>
158           </footnote>
159         </p>
160
161         <p>
162           Please note that the footnotes present in this manual are
163           merely informative, and are not part of Debian policy itself.
164         </p>
165
166
167         <p>
168           In this manual, the words <em>must</em>, <em>should</em> and
169           <em>may</em>, and the adjectives <em>required</em>,
170           <em>recommended</em> and <em>optional</em>, are used to
171           distinguish the significance of the various guidelines in
172           this policy document. Packages that do not conform the the
173           guidelines denoted by <em>must</em> (or <em>required</em>)
174           will generally not be considered acceptable for the Debian
175           distribution. Non-conformance with guidelines denoted by
176           <em>should</em> (or <em>recommended</em>) will generally be
177           considered a bug, but will not necessarily render a package
178           unsuitable for distribution. Guidelines denoted by
179           <em>may</em> (or <em>optional</em>) are truly optional and
180           adherence is left to the maintainer's discretion.
181         </p>
182         <p>
183           These classifications are roughly equivalent to the bug
184           severities <em>important</em> (for <em>must</em> or
185           <em>required</em> directive violations), <em>normal</em>
186           (for <em>should</em> or <em>recommended</em> directive
187           violations) and <em>wishlist</em> (for <em>optional</em>
188           items). <footnote>
189             <p>Also see RFC 2119.</p>
190           </footnote>
191         </p>
192         <p>
193           Much of the information presented in this manual will be
194           useful even when building a package which is to be
195           distributed in some other way or is for local use.
196         </p>
197       </sect>
198       <sect>
199         <heading>New versions of this document</heading>
200         <p>
201           The current version of this document is always accessible from the
202           Debian FTP server <ftpsite>ftp.debian.org</ftpsite> at
203           <ftppath>/debian/doc/package-developer/debian-policy.html.tar.gz</ftppath>
204           or from the Debian WWW server at
205           <url id="http://www.debian.org/doc/debian-policy/"
206                name="The Debian Policy Manual">.</p>
207
208         <p>
209           In addition, this manual is distributed via the Debian package
210           <tt>debian-policy</tt>.
211         </p>
212       </sect>
213       <sect>
214         <heading>Feedback</heading>
215
216         <p>
217           As the Debian GNU/Linux system is continuously evolving this
218           manual is changed from time to time.
219         </p>
220         <p>
221           While the authors of this document tried hard not to include
222           any typos or other errors these still occur. If you discover
223           an error in this manual or if you want to tell us any
224           comments, suggestions, or critics please send an email to
225           the Debian Policy List,
226           <email>debian-policy@lists.debian.org</email>, or submit a
227           bug report against the <tt>debian-policy</tt> package.
228         </p>
229       </sect>
230     </chapt>
231     <chapt>
232       <heading>The Debian Archive</heading>
233       <p>
234         The Debian GNU/Linux system is maintained and distributed as a
235         collection of <em>packages</em>. Since there are so many of them (over
236         5000) they are split into <em>sections</em> and <em>priorities</em> to
237         simplify handling of them.
238       </p>
239       <p>
240         The effort of the Debian project is to build a free operating
241         system, but not every package we want to make accessible is
242         <em>free</em> in our sense (see Debian Free Software
243         Guidelines, below), or may be imported/exported without
244         restrictions. Thus, the archive is split into the sections
245         <em>main</em>, <em>non-free</em>, <em>contrib</em>,
246         <em>non-US/main</em>, <em>non-US/non-free</em>, and
247         <em>non-US/contrib</em>.</p>
248
249       <p>
250         The <em>main</em> and the <em>non-US/main</em> sections form
251         the <em>Debian GNU/Linux distribution</em>.
252       </p>
253
254       <p>
255         Packages in the other sections are not considered as part of
256         the Debian distribution, though we support their use, and we
257         provide infrastructure for them (such as our bug-tracking
258         system and mailing lists). This Debian Policy Manual applies
259         to these packages as well.</p>
260
261       <sect id="pkgcopyright">
262         <heading>Package copyright and sections</heading>
263         <p>
264           The aims of this policy are:
265
266           <list compact="compact">
267             <item>
268               <p>We want to make as much software available as we
269                 can.</p>
270             </item>
271             <item>
272               <p>We want to encourage everyone to write free software.</p>
273             </item>
274             <item>
275               <p> We want to make it easy for people to produce
276                 CD-ROMs of our system without violating any licenses,
277                 import/export restrictions, or any other laws.</p>
278             </item>
279           </list>
280         </p>
281         <sect1>
282           <heading>The Debian Free Software Guidelines</heading>
283           <p>
284             The Debian Free Software Guidelines (DFSG) is our
285             definition of `free' software.
286             <taglist>
287               <tag>Free Redistribution
288               </tag>
289               <item>
290                 <p>
291                   The license of a Debian component may not restrict any
292                   party from selling or giving away the software as a
293                   component of an aggregate software distribution
294                   containing programs from several different
295                   sources. The license may not require a royalty or
296                   other fee for such sale.
297                 </p>
298               </item>
299               <tag>Source Code
300               </tag>
301               <item>
302                 <p>
303                   The program must include source code, and must allow
304                   distribution in source code as well as compiled form.
305                 </p>
306               </item>
307               <tag>Derived Works
308               </tag>
309               <item>
310                 <p>
311                   The license must allow modifications and derived
312                   works, and must allow them to be distributed under the
313                   same terms as the license of the original software.
314                 </p>
315               </item>
316               <tag>Integrity of The Author's Source Code
317               </tag>
318               <item>
319                 <p>
320                   The license may restrict source-code from being
321                   distributed in modified form <em>only</em> if the
322                   license allows the distribution of ``patch files''
323                   with the source code for the purpose of modifying the
324                   program at build time. The license must explicitly
325                   permit distribution of software built from modified
326                   source code. The license may require derived works to
327                   carry a different name or version number from the
328                   original software.  (This is a compromise. The Debian
329                   group encourages all authors to not restrict any
330                   files, source or binary, from being modified.)
331                 </p>
332               </item>
333               <tag>No Discrimination Against Persons or Groups
334               </tag>
335               <item>
336                 <p>
337                   The license must not discriminate against any person
338                   or group of persons.
339                 </p>
340               </item>
341               <tag>No Discrimination Against Fields of Endeavor
342               </tag>
343               <item>
344                 <p>
345                   The license must not restrict anyone from making use
346                   of the program in a specific field of endeavor. For
347                   example, it may not restrict the program from being
348                   used in a business, or from being used for genetic
349                   research.
350                 </p>
351               </item>
352               <tag>Distribution of License
353               </tag>
354               <item>
355                 <p>
356                   The rights attached to the program must apply to all
357                   to whom the program is redistributed without the need
358                   for execution of an additional license by those
359                   parties.
360                 </p>
361               </item>
362               <tag>License Must Not Be Specific to Debian
363               </tag>
364               <item>
365                 <p>
366                   The rights attached to the program must not depend on
367                   the program's being part of a Debian system. If the
368                   program is extracted from Debian and used or
369                   distributed without Debian but otherwise within the
370                   terms of the program's license, all parties to whom
371                   the program is redistributed must have the same
372                   rights as those that are granted in conjunction with
373                   the Debian system.
374                 </p>
375               </item>
376               <tag>License Must Not Contaminate Other Software
377               </tag>
378               <item>
379                 <p>
380                   The license must not place restrictions on other
381                   software that is distributed along with the licensed
382                   software. For example, the license must not insist
383                   that all other programs distributed on the same medium
384                   must be free software.
385                 </p>
386               </item>
387               <tag>Example Licenses
388               </tag>
389               <item>
390                 <p>
391                   The ``GPL,'' ``BSD,'' and ``Artistic'' licenses are
392                   examples of licenses that we consider <em>free</em>.
393                 </p>
394               </item>
395             </taglist>
396           </p>
397         </sect1>
398         <sect1>
399           <heading>The main section</heading>
400           <p>
401             Every package in "main"  and "non-US/main" must comply with
402             the DFSG (Debian  Free Software Guidelines).</p>
403
404           <p>
405             In addition, the packages in "main"
406             <list compact="compact">
407               <item>
408                 <p>
409                   must not require a package outside of "main" for
410                   compilation or execution (thus, the package must not
411                   declare a "Depends", "Recommends", or
412                   "Build-Depends" relationship on a non-main package),
413                 </p>
414               </item>
415               <item>
416                 <p>
417                   must not be so buggy that we refuse to support them,
418                 </p>
419               </item>
420               <item>
421                 <p>
422                   must meet all policy requirements presented in this
423                   manual.
424                 </p>
425               </item>
426             </list>
427           </p>
428           <p>
429             Similarly, the packages in "non-US/main"
430             <list compact="compact">
431               <item>
432                 <p>
433                    must not require a package outside of "main" or
434                    "non-US/main" for compilation or execution,
435                 </p>
436               </item>
437               <item>
438                 <p>
439                   must not be so buggy that we refuse to support them,
440                 </p>
441               </item>
442               <item>
443                 <p>
444                   must meet all policy requirements presented in this
445                   manual.
446                 </p>
447               </item>
448             </list>
449           </p>
450         </sect1>
451         <sect1>
452           <heading>The contrib section</heading>
453           <p>
454             Every package in "contrib"  and "non-US/contrib" must
455             comply with the DFSG.
456           </p>
457
458           <p>
459             Examples of packages which would be included in "contrib"
460             or "non-US/contrib" are
461             <list compact="compact">
462               <item>
463                 <p>
464                   free packages which require "contrib", "non-free"
465                   packages or packages which are not in our
466                   archive at all for compilation or execution,
467                 </p>
468               </item>
469               <item>
470                 <p>
471                   wrapper packages or other sorts of free accessories for
472                   non-free programs,
473                 </p>
474               </item>
475             </list>
476           </p>
477         </sect1>
478         <sect1>
479           <heading>The non-free section and non-US/non-free </heading>
480           <p>
481             Packages must be placed in "non-free" or "non-US/non-free"
482             if they are not compliant with the DFSG or are encumbered
483             by patents or other legal issues that make their
484             distribution problematic.
485           </p>
486         </sect1>
487         <sect1>
488           <heading>The non-US sections</heading>
489           <p>
490             Some programs with cryptographic program code need to be stored
491             on the "non-US" server because of export restrictions of the
492             U.S. Such programs must be distributed in the appropriate
493             non-US section, either non-US/main, non-US/contrib or
494             non-US/non-free. </p>
495           <p>
496             This applies only to packages which contain cryptographic
497             code. A package containing a program with an interface to a
498             cryptographic program or a program that's dynamically linked
499             against a cryptographic library should not be distributed
500             via the non-us server if it is capable of running without the
501             cryptography library or program.
502           </p>
503         </sect1>
504         <sect1>
505           <heading>Further copyright considerations</heading>
506           <p>
507             Every package must be accompanied by a verbatim copy of its
508             copyright and distribution license in the file
509             /usr/share/doc/&lt;package-name&gt;/copyright (see
510             <ref id="copyrightfile"> for details).</p>
511           <p>
512             We reserve the right to restrict files from being included
513             anywhere in our archives if
514             <list compact="compact">
515               <item>
516                 <p>
517                   their use or distribution would break a law,
518                 </p>
519               </item>
520               <item>
521                 <p>
522                   there is an ethical conflict in their distribution or
523                   use,
524                 </p>
525               </item>
526               <item>
527                 <p>
528                   we would have to sign a license for them, or
529                 </p>
530               </item>
531               <item>
532                 <p>
533                   their distribution would conflict with other project
534                   policies.
535                 </p>
536               </item>
537             </list>
538           </p>
539
540           <p>
541             Programs whose authors encourage the user to make donations
542             are fine for the main distribution, provided that the
543             authors do not claim that not donating is immoral,
544             unethical, illegal or something similar; otherwise they must
545             go in non-free.</p>
546
547           <p>
548             Packages whose copyright permission notices (or patent
549             problems) do not allow redistribution even of only binaries,
550             and where no special permission has been obtained, must not be
551             placed on the Debian FTP site and its mirrors at all.</p>
552
553           <p>
554             Note, that under international copyright law (this applies
555             in the United States, too) <em>no</em> distribution or
556             modification of a work is allowed without an explicit notice
557             saying so.  Therefore a program without a copyright notice
558             <em>is</em> copyrighted and you may not do anything to it
559             without risking being sued! Likewise if a program has a
560             copyright notice but no statement saying what is permitted
561             then nothing is permitted.</p>
562
563           <p>
564             Many authors are unaware of the problems that restrictive
565             copyrights (or lack of copyright notices) can cause for the
566             users of their supposedly-free software.  It is often
567             worthwhile contacting such authors diplomatically to ask
568             them to modify their license terms. However, this is a
569             politically difficult thing to do and you should ask for
570             advice on <tt>debian-legal</tt> first.</p>
571
572           <p>
573             When in doubt, send mail to
574             <email>debian-legal@lists.debian.org</email>.  Be prepared
575             to provide us with the copyright statement.  Software
576             covered by the GPL, public domain software and BSD-like
577             copyrights are safe; be wary of the phrases `commercial use
578             prohibited' and `distribution restricted'.</p>
579         </sect1>
580         <sect1>
581           <heading>Subsections</heading>
582
583           <p>
584             The packages in all the sections (<em>main</em>,
585             <em>contrib</em>, <em>non-US/main</em>, <em>non-free</em>,
586             <em>non-US/contrib</em>, and <em>non-US/non-free</em>) are
587             grouped further into <em>subsections</em> to simplify
588             handling.</p>
589
590           <p>
591             The section for each package should be specified in the
592             package's <em>control record</em>. However, the maintainer of
593             the Debian archive may override this selection to assure the
594             consistency of the Debian distribution. </p>
595
596           <p>
597             Please check the current Debian distribution to see which
598             sections are available.</p>
599         </sect1>
600       <sect>
601         <heading>Priorities</heading>
602
603         <p>
604           Each package should have a <em>priority</em> value,
605           which is included in the package's <em>control
606             record</em>. This information is used in the Debian package
607           management tool to separate high-priority packages from
608           less-important packages.</p>
609
610         <p>
611           The following <em>priority levels</em> are supported by the
612           Debian package management system, <prgn>dpkg</prgn>.
613           <taglist>
614             <tag><tt>required</tt></tag>
615             <item>
616               <p>
617                 <tt>required</tt> packages are necessary for the
618                 proper functioning of the system.  You must not remove
619                 these packages or your system may become totally
620                 broken and you may not even be able to use
621                 <prgn>dpkg</prgn> to put things back.  Systems with
622                 only the <tt>required</tt> packages are probably
623                 unusable, but they do have enough functionality to
624                 allow the sysadmin to boot and install more
625                 software.</p>
626             </item>
627             <tag><tt>important</tt></tag>
628             <item>
629               <p>
630                 Important programs, including those which one would
631                 expect to find on any Unix-like system.  If the
632                 expectation is that an experienced Unix person who
633                 found it missing would say `What the F*!@&lt;+ is
634                 going on, where is <prgn>foo</prgn>', it must be in
635                 <tt>important</tt>.  This is an important criterion
636                 because we are trying to produce, amongst other
637                 things, a free Unix.  Other packages without which the
638                 system will not run well or be usable must also be
639                 here.  This does <em>not</em> include Emacs, the X
640                 Window System, TeX or any other large applications.
641                 The <tt>important</tt> packages are just a bare
642                 minimum of commonly-expected and necessary tools.</p>
643             </item>
644             <tag><tt>standard</tt></tag>
645             <item>
646               <p>
647                 These packages provide a reasonably small but not too
648                 limited character-mode system.  This is what will
649                 install by default if the user doesn't select anything
650                 else.  It doesn't include many large applications, but
651                 it does include Emacs (this is more of a piece of
652                 infrastructure than an application) and a reasonable
653                 subset of TeX and LaTeX (if this is possible without
654                 X).</p>
655             </item>
656             <tag><tt>optional</tt></tag>
657             <item>
658               <p>
659                 (In a sense everything is optional that isn't
660                 required, but that's not what is meant here.) This is
661                 all the software that you might reasonably want to
662                 install if you didn't know what it was or don't have
663                 specialized requirements. This is a much larger system
664                 and includes the X Window System, a full TeX distribution,
665                 and many applications. Note that optional packages should
666                 not conflict with each other.
667               </p>
668             </item>
669             <tag><tt>extra</tt></tag>
670             <item>
671               <p>
672                 This contains all packages that conflict with others
673                 with required, important, standard or optional
674                 priorities, or are only likely to be useful if you
675                 already know what they are or have specialised
676                 requirements.
677               </p>
678             </item>
679           </taglist></p>
680
681         <p>
682           Packages must not depend on packages with lower priority
683           values (excluding build-time dependencies).  In order to
684           ensure this, the priorities of one or more packages must
685           be adjusted.
686         </p>
687       </sect>
688
689       <sect>
690         <heading>Binary packages</heading>
691
692         <p>
693           The Debian GNU/Linux distribution is based on the Debian
694           package management system, called <prgn>dpkg</prgn>. Thus,
695           all packages in the Debian distribution must be provided
696           in the <tt>.deb</tt> file format.</p>
697
698
699         <sect1>
700           <heading>The package name</heading>
701
702           <p>
703             Every package must have a name that's unique within the Debian
704             archive.</p>
705
706           <p>
707             Package names must only consist of lower case letters, digits (0-9),
708             plus (+) or minus (-) signs, and periods (.).</p>
709
710           <p>
711             The package name is part of the file name of the
712             <tt>.deb</tt> file and is included in the control field
713             information.
714           </p>
715         </sect1>
716
717         <sect1>
718           <heading>The maintainer of a package</heading>
719          <p>
720             Every package must have a maintainer (the maintainer may
721             be one person or a group of people reachable from a common
722             email address, such as a mailing list).  The maintainer is
723             responsible for ensuring that the  package is placed in
724             the appropriate distribution
725           </p>
726
727           <p>
728             The maintainer must be specified in the
729             <tt>Maintainer</tt> control field with the correct name
730             and a working email address for the Debian maintainer of
731             the package.  If one person maintains several packages
732             he/she should try to avoid having different forms of their
733             name and email address in different <tt>Maintainer</tt>
734             fields.</p>
735
736           <p>
737             If the maintainer of a package quits from the Debian
738             project the Debian QA Group
739             <email>debian-qa@lists.debian.org</email> takes over the
740             maintainership of the package until someone else
741             volunteers for that task. These packages are called
742             <em>orphaned packages</em>.
743           </p>
744         </sect1>
745
746
747         <sect1>
748           <heading>The description of a package</heading>
749
750           <p>
751             Every Debian package must have an extended description
752             stored in the appropriate field of the control record.</p>
753
754           <p>
755             The description should be written so that it tells the user
756             what they need to know to decide whether to install the
757             package. This description should not just be copied from
758             the blurb for the program.  Instructions for configuring
759             or using the package should not be included -- that is what
760             installation scripts, manual pages, Info files, etc. are
761             for.  Copyright statements and other administrivia should
762             not be included -- that is what the copyright file is
763             for.</p>
764         </sect1>
765
766
767         <sect1>
768           <heading>Dependencies</heading>
769
770           <p>
771             Every package must specify the dependency information
772             about other packages that are required for the first to
773             work correctly.</p>
774
775           <p>
776             For example, a dependency entry must be provided for any
777             shared libraries required by a dynamically-linked executable
778             binary in a package.</p>
779
780           <p>
781             Packages are not required to declare any dependencies they
782             have on other packages which are marked <tt>Essential</tt>
783             (see below), and should not do so unless they depend on a
784             particular version of that package.</p>
785
786           <p>
787             Sometimes, a package requires another package to be installed
788             <em>and</em> configured before it can be installed. In this
789             case, you must specify a <tt>Pre-Depends</tt> entry for
790             the package.</p>
791
792           <p>
793             You should not specify a <tt>Pre-Depends</tt> entry for a
794             package before this has been discussed on the
795             <tt>debian-devel</tt> mailing list and a consensus about
796             doing that has been reached.</p></sect1>
797
798
799         <sect1>
800           <heading>Virtual packages</heading>
801
802           <p>
803             Sometimes, there are several packages doing more-or-less
804             the same job. In this case, it's useful to define a
805             <em>virtual package</em> whose name describes the function
806             the packages have. (The virtual packages just exist
807             logically, not physically--that's why they are called
808             <em>virtual</em>.) The packages with this particular
809             function will then <em>provide</em> the virtual
810             package. Thus, any other package requiring that function
811             can simply depend on the virtual package without having to
812             specify all possible packages individually.</p>
813
814           <p>
815             All packages should use virtual package names where
816             appropriate, and arrange to create new ones if necessary.
817             They should not use virtual package names (except privately,
818             amongst a cooperating group of packages) unless they have
819             been agreed upon and appear in the list of virtual package
820             names.</p>
821
822           <p>
823             The latest version of the authoritative list of virtual
824             package names can be found on
825             <ftpsite>ftp.debian.org</ftpsite> in
826             <ftppath>/debian/doc/package-developer/virtual-package-names-list.text</ftppath>
827             or your local mirror. In addition, it is included in the
828             <tt>debian-policy</tt> package. The procedure for updating
829             the list is described at the top of the file.</p></sect1>
830
831
832         <sect1>
833           <heading>Base packages</heading>
834
835           <p>
836             The packages included in the <tt>base</tt> section have a
837             special function. They form a minimum subset of the Debian
838             GNU/Linux system that is installed before everything else
839             on a new system. Thus, only very few packages are allowed
840             to go into the <tt>base</tt> section to keep the required
841             disk usage very small.</p>
842
843           <p>
844             Most of these packages will have the priority value
845             <tt>required</tt> or at least <tt>important</tt>, and many
846             of them will be tagged <tt>essential</tt> (see below).</p>
847
848           <p>
849             You must not place any packages into the <tt>base</tt>
850             section before this has been discussed on the
851             <tt>debian-devel</tt> mailing list and a consensus about
852             doing that has been reached.</p></sect1>
853
854
855         <sect1>
856           <heading>Essential packages</heading>
857
858           <p>
859             Some packages are tagged <tt>essential</tt>. (They have
860             <tt>Essential: yes</tt> in their package control record.)
861             This flag is used for packages that are <em>essential</em>
862             for a system.</p>
863
864           <p>
865             Since these packages can not easily be removed (you'll
866             have to specify an extra <em>force option</em> to
867             <prgn>dpkg</prgn>) this flag must not be used unless
868             absolutely necessary.  A shared library package must not
869             be tagged <tt>essential</tt>--the dependencies will
870             prevent its premature removal, and we need to be able to
871             remove it when it has been superseded.
872           </p>
873
874           <p>
875             Since dpkg will not prevent upgrading of other packages
876             while an <tt>essential</tt> package is in an unconfigured
877             state, all <tt>essential</tt> packages must supply all
878             their core functionality even when unconfigured. If the
879             package cannot satisfy this requirement it must not be
880             tagged as essential, and any packages depending on this
881             package must instead have explicit dependency fields as
882             appropriate.
883           </p>
884
885           <p>
886             You must not tag any packages <tt>essential</tt> before
887             this has been discussed on the <tt>debian-devel</tt>
888             mailing and a consensus about doing that has been
889             reached.</p></sect1>
890
891
892         <sect1>
893           <heading>Maintainer scripts</heading>
894
895           <p>
896             The package installation scripts should avoid producing
897             output which it is unnecessary for the user to see and
898             should rely on <prgn>dpkg</prgn> to stave off boredom on
899             the part of a user installing many packages.  This means,
900             amongst other things, using the <tt>--quiet</tt> option on
901             <prgn>install-info</prgn>.</p>
902
903           <p>
904             Errors which occur during the execution of an installation
905             script must be checked and the installation must not
906             continue after an error.
907           </p>
908
909           <p>
910             Note, that <ref id="scripts">, in general applies to package
911             maintainer scripts, too.
912           </p>
913
914           <p>
915             You should not use <tt>dpkg-divert</tt> on a file
916             belonging to another package without consulting the
917             maintainer of that package first.
918           </p>
919           <p>
920             All packages which supply an instance of a common command
921             name (or, in general, filename) should generally use
922             <prgn>update-alternatives</prgn>, so that they may be
923             installed together.  If <prgn>update-alternatives</prgn>
924             is not used, then each package must use
925             <var>Conflicts</var> to ensure that other packages are
926             de-installed.  (In this case, it may be appropriate to
927             specify a conflict against earlier versions of something
928             that previously did not use
929             <prgn>update-alternatives</prgn> - this is an exception to
930             the usual rule that this not allowed).
931           </p>
932
933
934           <sect2>
935             <heading>Prompting in maintainer scripts</heading>
936             <p>
937               Package maintainer scripts may prompt the user if
938               necessary. Prompting may be accomplished by hand, or by
939               communicating with a program, such as
940               <prgn>debconf</prgn>, which conforms to the Debian
941               Configuration management specification, version 2 or
942               higher. (Included in the
943               <file>debconf_specification</file> files in the
944               <package>debian-policy</package> package.)
945               You may also find this file on the FTP site
946               <ftpsite>ftp.debian.org</ftpsite> in
947               <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
948               or your local mirror.
949               <footnote>
950                 <p>
951                   2.5% of Debian packages
952                   [<url id="http://kitenet.net/programs/debconf/stats/">]
953                   use debconf to prompt the user at install time, and
954                   this number is growing daily. The benefits of using
955                   debconf are briefly explained at
956                   <url id="http://kitenet.net/doc/debconf-doc/introduction.html">;
957                   they include preconfiguration, (mostly)
958                   noninteractive installation, elimination of
959                   redundant prompting, consistency of user interface,
960                   etc.
961                 </p>
962                 <p>
963                   With this increasing number of packages using
964                   debconf, plus the existance of a nascent second
965                   implementation of the Debian configuration
966                   management system (<package>cdebconf</package>), and
967                   the stabalization of the protocol these things use,
968                   the time has finally come to reflect the use of
969                   these things in policy.
970
971                 </p>
972               </footnote>
973             </p>
974             <p>
975               Packages which use the Debian Configuration management
976               specification may contain an additional
977               <file>config</file> script and a <file>templates</file>
978               file in their control archive. The <prgn>config</prgn>
979               script can be run before the preinst, and before the
980               package is unpacked or any of its dependancies or
981               pre-dependancies are satisfied, so it must work using
982               only the tools present in the <em>Essential</em>
983               packages.
984               <footnote>
985                 <p>
986                   Debconf or another tool that implements the Debian
987                   Configuration management specification will also be
988                   installed, and any versioned dependancies on it will
989                   be satisfied before preconfiguration begins.
990                 </p>
991               </footnote>
992             </p>
993
994             <p>
995               Packages should try to minimize the amount of prompting
996               they need to do, and they should ensure that the user
997               will only ever be asked each question once.  This means
998               that packages should try to use appropriate shared
999               configuration files (such as <tt>/etc/papersize</tt> and
1000               <tt>/etc/news/server</tt>), and shared debconf variables
1001               rather than each prompting for their own list of
1002               required pieces of information.
1003             </p>
1004
1005             <p>
1006             It also means that an upgrade should not ask the same
1007             questions again, unless the user has used <tt>dpkg
1008               --purge</tt> to remove the package's configuration.  The
1009             answers to configuration questions should be stored in an
1010             appropriate place in <tt>/etc</tt> so that the user can
1011             modify them, and how this has been done should be
1012             documented.</p>
1013
1014           <p>
1015               If a package has a vitally important piece of
1016               information to pass to the user (such as "don't run me
1017               as I am, you must edit the following configuration files
1018               first or you risk your system emitting badly-formatted
1019               messages"), it should display this in the
1020               <prgn>config</prgn> or <prgn>postinst</prgn> script and
1021               prompt the user to hit return to acknowledge the
1022               message.  Copyright messages do not count as vitally
1023               important (they belong in
1024               <tt>/usr/share/doc/<var>package</var>/copyright</tt>);
1025               neither do instructions on how to use a program (these
1026               should be in on line documentation, where all the users
1027               can see them).</p>
1028
1029           <p>
1030             Any necessary prompting should almost always be confined
1031             to the <prgn>config</prgn> or <prgn>postinst</prgn>
1032             script. If it is done in the <prgn>postinst</prgn>, it
1033             should be protected with a conditional so that unnecessary
1034             prompting doesn't happen if a package's installation fails
1035             and the <prgn>postinst</prgn> is called with
1036             <tt>abort-upgrade</tt>, <tt>abort-remove</tt> or
1037             <tt>abort-deconfigure</tt>.</p>
1038
1039         </sect1>
1040       </sect>
1041       <sect>
1042         <heading>Source packages</heading>
1043
1044         <sect1>
1045           <heading>Standards conformance</heading>
1046
1047           <p>
1048             You should specify the most recent version of the
1049             packaging standards with which your package complies in
1050             the source package's <tt>Standards-Version</tt> field.</p>
1051
1052           <p>
1053             This value will be used to file bug reports automatically
1054             if your package becomes too much out of date.</p>
1055
1056           <p>
1057             The value corresponds to a version of the Debian manuals,
1058             as can be found on the title page or page headers and
1059             footers (depending on the format).</p>
1060
1061           <p>
1062             The version number has four components--major and minor
1063             number and major and minor patch level.  When the
1064             standards change in a way that requires every package to
1065             change the major number will be changed.  Significant
1066             changes that will require work in many packages will be
1067             signaled by a change to the minor number.  The major patch
1068             level will be changed for any change to the meaning of the
1069             standards, however small; the minor patch level will be
1070             changed when only cosmetic, typographical or other edits
1071             which do not change the meaning are made, or changes which
1072             do not affect the contents of packages.</p>
1073
1074           <p>
1075             For package maintainers, only the first 3 digits of the
1076             manual version are significant in representing the
1077             <em>Standards-Version</em>, and either these 3 digits or
1078             the complete 4 digits may be specified.
1079             <footnote>
1080               <p>
1081                 In the past, people specified 4 digits in the
1082                 Standards-Version field, like `2.3.0.0'.  Since any
1083                 `patch-level changes' don't introduce new policy, it
1084                 was thought it would be better to relax policy and
1085                 only require that the first 3 digits are specified. (4
1086                 digits may still be used if someone wants to do so.)
1087               </p>
1088             </footnote>
1089           </p>
1090
1091           <p>
1092             You should regularly, and especially if your package has
1093             become out of date, check for the newest Policy Manual
1094             available and update your package, if necessary. When your
1095             package complies with the new standards you should update the
1096             <tt>Standards-Version</tt> source package field and
1097             release it.</p></sect1>
1098
1099
1100         <sect1>
1101           <heading>Package relationships</heading>
1102
1103           <p>
1104             Source packages should specify which binary packages they
1105             require to be installed or not to be installed in order to
1106             build correctly.  For example, if building a package
1107             requires a certain compiler, then the compiler should be
1108             specified as a build-time dependency.
1109           </p>
1110
1111           <p>
1112             It is not necessary to explicitly specify build-time
1113             relationships on a minimal set of packages that are always
1114             needed to compile, link and put in a Debian package a
1115             standard "Hello World!" program written in C or C++.  The
1116             required packages are called <em>build-essential</em>, and
1117             an informational list can be found in
1118             <tt>/usr/share/doc/build-essential/list</tt> (which is
1119             contained in the <tt>build-essential</tt>
1120             package).
1121             <footnote>
1122               <p>Rationale:
1123                 <list>
1124                   <item>
1125                     <p>This allows maintaining the list separately
1126                       from the policy documents (the list does not
1127                       need the kind of control that the policy
1128                       documents do)
1129                     </p>
1130                   </item>
1131                   <item>
1132                     <p>
1133                       Having a separate package allows one to install
1134                       the build essential packages on a machine, as
1135                       well as allowing other packages (think task
1136                       packages) to bring in the build-essential
1137                       packages using the depends relation
1138                     </p>
1139                   </item>
1140                   <item>
1141                     <p>
1142                       The separate package allows bug reports against
1143                       the package to be categorized separately from
1144                       the policy management process that uses the BTS
1145                     </p>
1146                   </item>
1147                 </list>
1148               </p>
1149
1150             </footnote>
1151           </p>
1152
1153           <p>
1154             When specifying the set of build-time dependencies, one
1155             should list only those packages explicitly required by the
1156             build.  It is not necessary to list packages which are
1157             required merely because some other package in the list of
1158             build-time dependencies depends on them.  The reason is
1159             that dependencies change, and you should list only those
1160             <em>you</em> need.  What others need is their business.
1161           </p>
1162
1163           <p>
1164             If build-time dependencies are specified, it must be
1165             possible to build the package and produce working binaries
1166             on a system with the build-essential packages installed
1167             and satisfying the build-time relationships (including any
1168             implied relationships).  This
1169             means in particular that version clauses should be used
1170             rigorously in build-time relationships so that one cannot
1171             produce bad or inconsistently configured packages when the
1172             relationships are properly satisfied.
1173           </p>
1174
1175         <sect1>
1176           <heading>Changes to the upstream sources</heading>
1177
1178           <p>
1179             If changes to the source code are made that are generally
1180             applicable, they should be sent to the upstream authors
1181             in whatever form they prefer so as to be included in the
1182             upstream version of the package.</p>
1183
1184           <p>
1185             If you need to configure the package differently for
1186             Debian or for Linux, and the upstream source doesn't
1187             provide a way to configure it the way you need to, you
1188             should add such configuration facilities (for example, a new
1189             <prgn>autoconf</prgn> test or <tt>#define</tt>) and send
1190             the patch to the upstream authors, with the default set to
1191             the way they originally had it.  You can then easily
1192             override the default in your <tt>debian/rules</tt> or
1193             wherever is appropriate.</p>
1194
1195           <p>
1196             You should make sure that the <prgn>configure</prgn> utility
1197             detects the correct architecture specification string
1198             (refer to <ref id="arch-spec"> for details).</p>
1199
1200           <p>
1201             If you need to edit a <prgn>Makefile</prgn> where
1202             GNU-style <prgn>configure</prgn> scripts are used, you
1203             should edit the <tt>.in</tt> files rather than editing the
1204             <prgn>Makefile</prgn> directly.  This allows the user to
1205             reconfigure the package if necessary.  You should
1206             <em>not</em> configure the package and edit the generated
1207             <prgn>Makefile</prgn>!  This makes it impossible for
1208             someone else to later reconfigure the package.</p></sect1>
1209
1210
1211         <sect1>
1212           <heading>Documenting your changes</heading>
1213
1214           <p>
1215             You should document your changes and updates to the source
1216             package properly in the <tt>debian/changelog</tt> file. (Note
1217             that mistakes in changelogs are usually best rectified by
1218             making  a new changelog entry rather than "rewriting history"
1219             by editing old changelog entries)</p>
1220
1221           <p>
1222             In non-experimental packages you must only use a format for
1223             <tt>debian/changelog</tt> which is supported by the most
1224             recent released version of <prgn>dpkg</prgn>.  If your
1225             format is not supported and there is general support for
1226             it you should contact the <prgn>dpkg</prgn> maintainer to
1227             have the parser script for your format included in the
1228             <prgn>dpkg</prgn> package. (You will need to agree that
1229             the parser and its manpage may be distributed under the
1230             GNU GPL, just as the rest of <prgn>dpkg</prgn>
1231             is.)</p></sect1>
1232
1233
1234         <sect1>
1235           <heading>Error trapping in makefiles</heading>
1236
1237           <p>
1238             When <prgn>make</prgn> invokes a command in a makefile
1239             (including your package's upstream makefiles and the
1240             <tt>debian/rules</tt>) it does so using <tt>sh</tt>.  This
1241             means that <tt>sh</tt>'s usual bad error handling
1242             properties apply: if you include a miniature script as one
1243             of the commands in your makefile you'll find that if you
1244             don't do anything about it then errors are not detected
1245             and <prgn>make</prgn> will blithely continue after
1246             problems.</p>
1247
1248           <p>
1249             Every time you put more than one shell command (this
1250             includes using a loop) in a makefile command you
1251             must make sure that errors are trapped.  For
1252             simple compound commands, such as changing directory and
1253             then running a program, using <tt>&amp;&amp;</tt> rather
1254             than semicolon as a command separator is sufficient.  For
1255             more complex commands including most loops and
1256             conditionals you should include a separate <tt>set -e</tt>
1257             command at the start of every makefile command that's
1258             actually one of these miniature shell scripts.</p></sect1>
1259
1260
1261         <sect1>
1262           <heading>Obsolete constructs and libraries</heading>
1263
1264           <p>
1265             The include file <prgn>&lt;varargs.h&gt;</prgn> is
1266             provided to support end-users compiling very old software;
1267             the library <tt>libtermcap</tt> is provided to support the
1268             execution of software which has been linked against it
1269             (either old programs or those such as Netscape which are
1270             only available in binary form).</p>
1271
1272           <p>
1273             Debian packages should be ported to include
1274             <prgn>&lt;stdarg.h&gt;</prgn> and <tt>ncurses</tt> when
1275             they are built.</p>
1276         </sect1>
1277       </sect>
1278     </chapt>
1279
1280     <chapt id="controlfields"><heading>Control files and their fields</heading>
1281
1282       <p>
1283         Many of the tools in the package management suite manipulate
1284         data in a common format, known as control files.  Binary and
1285         source packages have control data as do the <tt>.changes</tt>
1286         files which control the installation of uploaded files, and
1287         <prgn>dpkg</prgn>'s internal databases are in a similar
1288         format.
1289       </p>
1290
1291       <sect><heading>Syntax of control files</heading>
1292
1293         <p>
1294           A file consists of one or more paragraphs of fields.  The
1295           paragraphs are separated by blank lines.  Some control files
1296           only allow one paragraph; others allow several, in which
1297           case each paragraph often refers to a different package.
1298         </p>
1299
1300         <p>
1301           Each paragraph is a series of fields and values; each field
1302           consists of a name, followed by a colon and the value.  It
1303           ends at the end of the line.  Horizontal whitespace (spaces
1304           and tabs) may occur immediately before or after the value
1305           and is ignored there; it is conventional to put a single
1306           space after the colon.
1307         </p>
1308
1309         <p>
1310           Some fields' values may span several lines; in this case
1311           each continuation line <em>must</em> start with a space or
1312           tab.  Any trailing spaces or tabs at the end of individual
1313           lines of a field value are ignored.
1314         </p>
1315
1316         <p>
1317           Except where otherwise stated only a single line of data is
1318           allowed and whitespace is not significant in a field body.
1319           Whitespace may never appear inside names (of packages,
1320           architectures, files or anything else), version numbers or
1321           in between the characters of multi-character version
1322           relationships.
1323         </p>
1324
1325         <p>
1326           Field names are not case-sensitive, but it is usual to
1327           capitalize the field names using mixed case as shown below.
1328         </p>
1329
1330         <p>
1331           Blank lines, or lines consisting only of spaces and tabs,
1332           are not allowed within field values or between fields - that
1333           would mean a new paragraph.
1334         </p>
1335
1336         <p>
1337           It is important to note that there are several fields which
1338           are optional as far as <prgn>dpkg</prgn> and the related
1339           tools are concerned, but which must appear in every Debian
1340           package, or whose omission may cause problems.  When writing
1341           the control files for Debian packages you <em>must</em> read
1342           the Debian policy manual in conjunction with the details
1343           below and the list of fields for the particular file.</p>
1344       </sect>
1345
1346       <sect><heading>List of fields</heading>
1347         <p>
1348           This list here is not supposed to be exhaustive. Most fields
1349           are dealt with elsewhere in this document and in the
1350           packaging manual.
1351         </p>
1352         <sect1 id="f-Package"><heading><tt>Package</tt>
1353           </heading>
1354
1355           <p>
1356             The name of the binary package.  Package names consist of
1357             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
1358             (plus, minus and full stop).
1359           </p>
1360
1361           <p>
1362             They must be at least two characters long and must start
1363             with an alphanumeric character.  The use of lowercase
1364             package names is strongly recommended unless the package
1365             you're building (or referring to, in other fields) is
1366             already using uppercase.</p>
1367         </sect1>
1368
1369         <sect1 id="f-Version"><heading><tt>Version</tt>
1370           </heading>
1371
1372           <p>
1373             This lists the source or binary package's version number -
1374             see <ref id="versions">.
1375           </p>
1376
1377         </sect1>
1378
1379         <sect1
1380                id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1381           </heading>
1382
1383           <p>
1384             The most recent version of the standards (the policy
1385             manual and associated texts) with which the package
1386             complies.  This is updated manually when editing the
1387             source package to conform to newer standards; it can
1388             sometimes be used to tell when a package needs attention.
1389           </p>
1390
1391           <p>
1392             Its format is the same as that of a version number except
1393             that no epoch or Debian revision is allowed - see <ref
1394                                                                    id="versions">.</p>
1395         </sect1>
1396
1397
1398         <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1399           </heading>
1400
1401           <p>
1402             In a <tt>.changes</tt> file or parsed changelog output
1403             this contains the (space-separated) name(s) of the
1404             distribution(s) where this version of the package should
1405             be or was installed.  Distribution names follow the rules
1406             for package names.  (See <ref id="f-Package">).
1407           </p>
1408
1409           <p>
1410             <footnote>
1411                 Current distribution values are:
1412                 <taglist>
1413                   <tag><em>stable</em></tag>
1414                   <item>
1415                     <p>
1416                       This is the current `released' version of Debian
1417                       GNU/Linux.  Once the
1418                       distribution is <em>stable</em> only major bug fixes
1419                       are allowed. When changes are made to this
1420                       distribution, the release number is increased
1421                       (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
1422                     </p>
1423                   </item>
1424
1425                   <tag><em>unstable</em></tag>
1426                   <item>
1427                     <p>
1428                       This distribution value refers to the
1429                       <em>developmental</em> part of the Debian
1430                       distribution tree. New packages, new upstream
1431                       versions of packages and bug fixes go into the
1432                       <em>unstable</em> directory tree. Download from
1433                       this distribution at your own risk.
1434                     </p>
1435                   </item>
1436
1437                   <tag><em>frozen</em></tag>
1438                   <item>
1439                     <p>
1440                       From time to time, the <em>unstable</em>
1441                       distribution enters a state of `code-freeze' in
1442                       anticipation of release as a <em>stable</em>
1443                       version. During this period of testing only
1444                       fixes for existing or newly-discovered bugs will
1445                       be allowed.
1446                     </p>
1447                   </item>
1448
1449                   <tag><em>experimental</em></tag>
1450                   <item>
1451                     <p>
1452                       The packages with this distribution value are deemed
1453                       by their maintainers to be high risk. Oftentimes they
1454                       represent early beta or developmental packages from
1455                       various sources that the maintainers want people to
1456                       try, but are not ready to be a part of the other parts
1457                       of the Debian distribution tree. Download at your own
1458                       risk.
1459                     </p>
1460                   </item>
1461                 </taglist>
1462                 There are several sections in each
1463                 distribution. Currently, these sections are:
1464
1465                 <taglist>
1466                   <tag><em>main</em></tag>
1467                   <item>
1468                     <p>
1469                       The packages in this section are those in the
1470                       main Debian distribution.  They are all free
1471                       (according to the Debian free software
1472                       guidelines) and meet any other criteria for
1473                       inclusion described in this manual.</p>
1474                   </item>
1475
1476                   <tag><em>contrib</em></tag>
1477                   <item>
1478                     <p>
1479                       The packages in this section do not meet the
1480                       criteria for inclusion in the main Debian
1481                       distribution as defined by this manual, but are
1482                       otherwise free, as defined by the Debian free
1483                       software guidelines.</p>
1484                   </item>
1485
1486                   <tag><em>non-free</em></tag>
1487                   <item>
1488                     <p>
1489                       Packages in <em>non-free</em> do not meet the
1490                       criteria of free software, as defined by the
1491                       Debian free software guidelines. Again, use your
1492                       best judgment in downloading from this
1493                       Distribution.</p>
1494                   </item>
1495
1496                 </taglist> You should list <em>all</em> distributions that
1497                 the package should be installed into. Except in unusual
1498                 circumstances, installations to <em>stable</em> should also
1499                 go into <em>frozen</em> (if it exists) and
1500                 <em>unstable</em>. Likewise, installations into
1501                 <em>frozen</em> should also go into <em>unstable</em>.
1502             </footnote>
1503           </p>
1504         </sect1>
1505
1506
1507       </sect>
1508     </chapt>
1509
1510     <chapt id="versions"><heading>Version numbering    </heading>
1511
1512       <p>
1513         Every package has a version number, in its <tt>Version</tt>
1514         control file field.
1515       </p>
1516
1517       <p>
1518         The package management system imposes an ordering on version
1519         numbers, so that it can tell whether packages are being up- or
1520         downgraded and so that package system front end applications
1521         can tell whether a package it finds available is newer than
1522         the one installed on the system.  The version number format
1523         has the most significant parts (as far as comparison is
1524         concerned) at the beginning.
1525       </p>
1526
1527       <p>
1528         The version number format is:
1529         &lsqb<var>epoch</var><tt>:</tt>&rsqb;<var>upstream-version</var>&lsqb;<tt>-</tt><var>debian-revision</var>&rsqb;
1530       </p>
1531
1532       <p>
1533         The three components here are:
1534         <taglist>
1535           <tag><var>epoch</var></tag>
1536           <item>
1537
1538             <p>
1539               This is a single (generally small) unsigned integer.  It
1540               may be omitted, in which case zero is assumed.  If it is
1541               omitted then the <var>upstream-version</var> may not
1542               contain any colons.
1543             </p>
1544
1545             <p>
1546               It is provided to allow mistakes in the version numbers
1547               of older versions of a package, and also a package's
1548               previous version numbering schemes, to be left behind.
1549             </p>
1550
1551           </item>
1552
1553           <tag><var>upstream-version</var></tag>
1554           <item>
1555
1556             <p>
1557               This is the main part of the version.  It is usually the
1558               version number of the original (`upstream') package from
1559               which the <tt>.deb</tt> file has been made, if this is
1560               applicable.  Usually this will be in the same format as
1561               that specified by the upstream author(s); however, it
1562               may need to be reformatted to fit into the package
1563               management system's format and comparison scheme.
1564             </p>
1565
1566             <p>
1567               The comparison behavior of the package management system
1568               with respect to the <var>upstream-version</var> is
1569               described below.  The <var>upstream-version</var>
1570               portion of the version number is mandatory.
1571             </p>
1572
1573             <p>
1574               The <var>upstream-version</var> may contain only
1575               alphanumerics and the characters <tt>.</tt> <tt>+</tt>
1576               <tt>-</tt> <tt>:</tt> (full stop, plus, hyphen, colon)
1577               and should start with a digit.  If there is no
1578               <var>debian-revision</var> then hyphens are not allowed;
1579               if there is no <var>epoch</var> then colons are not
1580               allowed.</p>
1581           </item>
1582
1583           <tag><var>debian-revision</var></tag>
1584           <item>
1585
1586             <p>
1587               This part of the version represents the version of the
1588               modifications that were made to the package to make it a
1589               Debian binary package.  It is in the same format as the
1590               <var>upstream-version</var> and is compared in the same
1591               way.
1592             </p>
1593
1594             <p>
1595               It is optional; if it isn't present then the
1596               <var>upstream-version</var> may not contain a hyphen.
1597               This format represents the case where a piece of
1598               software was written specifically to be turned into a
1599               Debian binary package, and so there is only one
1600               `debianization' of it and therefore no revision
1601               indication is required.
1602             </p>
1603
1604             <p>
1605               It is conventional to restart the
1606               <var>debian-revision</var> at <tt>1</tt> each time the
1607               <var>upstream-version</var> is increased.
1608             </p>
1609
1610             <p>
1611               The package management system will break the
1612               <var>upstream-version</var> and
1613               <var>debian-revision</var> apart at the last hyphen in
1614               the string.  The absence of a <var>debian-revision</var>
1615               compares earlier than the presence of one (but note that
1616               the <var>debian-revision</var> is the least significant
1617               part of the version number).
1618             </p>
1619
1620             <p>
1621               The <var>debian-revision</var> may contain only
1622               alphanumerics and the characters <tt>+</tt> and
1623               <tt>.</tt> (plus and full stop).
1624             </p>
1625           </item>
1626         </taglist>
1627         The <var>upstream-version</var> and <var>debian-revision</var>
1628         parts are compared by the package management system using the
1629         same algorithm:
1630       </p>
1631
1632       <p>
1633         The strings are compared from left to right.
1634       </p>
1635
1636       <p>
1637         First the initial part of each string consisting entirely of
1638         non-digit characters is determined.  These two parts (one of
1639         which may be empty) are compared lexically.  If a difference
1640         is found it is returned.  The lexical comparison is a
1641         comparison of ASCII values modified so that all the letters
1642         sort earlier than all the non-letters.
1643       </p>
1644
1645       <p>
1646         Then the initial part of the remainder of each string which
1647         consists entirely of digit characters is determined.  The
1648         numerical values of these two parts are compared, and any
1649         difference found is returned as the result of the comparison.
1650         For these purposes an empty string (which can only occur at
1651         the end of one or both version strings being compared) counts
1652         as zero.
1653       </p>
1654
1655       <p>
1656         These two steps are repeated (chopping initial non-digit
1657         strings and initial digit strings off from the start) until a
1658         difference is found or both strings are exhausted.
1659       </p>
1660
1661       <p>
1662         Note that the purpose of epochs is to allow us to leave behind
1663         mistakes in version numbering, and to cope with situations
1664         where the version numbering changes.  It is <em>not</em> there
1665         to cope with version numbers containing strings of letters
1666         which the package management system cannot interpret (such as
1667         <tt>ALPHA</tt> or <tt>pre-</tt>), or with silly orderings (the
1668         author of this manual has heard of a package whose versions
1669         went <tt>1.1</tt>, <tt>1.2</tt>, <tt>1.3</tt>, <tt>1</tt>,
1670         <tt>2.1</tt>, <tt>2.2</tt>, <tt>2</tt> and so forth).
1671       </p>
1672
1673       <p>
1674         If an upstream package has problematic version numbers they
1675         should be converted to a sane form for use in the
1676         <tt>Version</tt> field.
1677       </p>
1678
1679       <sect>
1680         <heading>Version numbers based on dates</heading>
1681         <p>
1682           In general, Debian packages should use the same version
1683           numbers as the upstream sources.</p>
1684
1685         <p>
1686           However, in some cases where the upstream version number is
1687           based on a date (e.g., a development `snapshot' release) the
1688           package management system cannot handle these version
1689           numbers without epochs. For example, dpkg will consider
1690           `96May01' to be greater than `96Dec24'.</p>
1691
1692         <p>
1693           To prevent having to use epochs for every new upstream
1694           version, the version number should be changed to the
1695           following format in such cases: `19960501', `19961224'. It
1696           is up to the maintainer whether he/she wants to bother the
1697           upstream maintainer to change the version numbers upstream,
1698           too.</p>
1699
1700         <p>
1701           Note, that other version formats based on dates which are
1702           parsed correctly by the package management system should
1703           <em>not</em> be changed.</p>
1704
1705         <p>
1706           Native Debian packages (i.e., packages which have been
1707           written especially for Debian) whose version numbers include
1708           dates should always use the `YYYYMMDD' format.</p>
1709       </sect>
1710     </chapt>
1711
1712     <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1713
1714       <sect id="timestamps"><heading>Time Stamps</heading>
1715         <p>
1716           Maintainers are encouraged to preserve the modification
1717           times of the upstream source files in a package, as far as
1718           is reasonably possible. Even though this is optional, this
1719           is still a good idea.
1720           <footnote>
1721             <p>
1722               The rationale is that there is some information conveyed
1723               by knowing the age of the file, for example, you could
1724               recognize that some documentation is very old by looking
1725               at the modification time, so it would be nice if the
1726               modification time of the upstream source would be
1727               preserved.
1728             </p>
1729           </footnote>
1730         </p>
1731       </sect>
1732
1733       <sect id="debianrules"><heading><tt>debian/rules</tt> - the
1734           main building script    </heading>
1735
1736         <p>
1737           This file must be an executable makefile, and contains the
1738           package-specific recipes for compiling the package and
1739           building binary package(s) out of the source.
1740         </p>
1741
1742         <p>
1743           It must start with the line <tt>#!/usr/bin/make -f</tt>,
1744           so that it can be invoked by saying its name rather than
1745           invoking <prgn>make</prgn> explicitly.
1746         </p>
1747
1748         <p>
1749           Since an interactive <tt>debian/rules</tt> script makes it
1750           impossible to auto-compile that package and also makes it
1751           hard for other people to reproduce the same binary
1752           package, all <strong>required targets</strong> MUST be
1753           non-interactive. At a minimum, required targets are the
1754           ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1755           <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1756           <em>binary-indep</em>, and <em>build</em>. It also follows
1757           that any target that these targets depend on must also be
1758           non-interactive.
1759         </p>
1760
1761         <p>
1762           The targets which must be present are:
1763           <taglist>
1764             <tag><tt>build</tt></tag>
1765             <item>
1766               <p>
1767                 This should perform all non-interactive
1768                 configuration and compilation of the package.  If a
1769                 package has an interactive pre-build configuration
1770                 routine, the Debianised source package should be
1771                 built after this has taken place, so that it can be
1772                 built without rerunning the configuration.
1773               </p>
1774
1775               <p>
1776                 For some packages, notably ones where the same
1777                 source tree is compiled in different ways to produce
1778                 two binary packages, the <prgn>build</prgn> target
1779                 does not make much sense.  For these packages it is
1780                 good enough to provide two (or more) targets
1781                 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1782                 for each of the ways of building the package, and a
1783                 <prgn>build</prgn> target that does nothing.  The
1784                 <prgn>binary</prgn> target will have to build the
1785                 package in each of the possible ways and make the
1786                 binary package out of each.
1787               </p>
1788
1789               <p>
1790                 The <prgn>build</prgn> target must not do anything
1791                 that might require root privilege.
1792               </p>
1793
1794               <p>
1795                 The <prgn>build</prgn> target may need to run
1796                 <prgn>clean</prgn> first - see below.
1797               </p>
1798
1799               <p>
1800                 When a package has a configuration routine that
1801                 takes a long time, or when the makefiles are poorly
1802                 designed, or when <prgn>build</prgn> needs to run
1803                 <prgn>clean</prgn> first, it is a good idea to
1804                 <tt>touch build</tt> when the build process is
1805                 complete.  This will ensure that if <tt>debian/rules
1806                   build</tt> is run again it will not rebuild the
1807                 whole program.
1808               </p>
1809             </item>
1810
1811             <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1812               <tt>binary-indep</tt>
1813             </tag>
1814             <item>
1815               <p>
1816                 The <prgn>binary</prgn> target must be all that is
1817                 necessary for the user to build the binary
1818                 package. All these targets are required to be
1819                 non-interactive.  It is split into two parts:
1820                 <prgn>binary-arch</prgn> builds the packages' output
1821                 files which are specific to a particular
1822                 architecture, and <prgn>binary-indep</prgn> builds
1823                 those which are not.
1824               </p>
1825
1826               <p>
1827                 <prgn>binary</prgn> may be (and commonly is) a target
1828                 with no commands which simply depends on
1829                 <prgn>binary-arch</prgn> and
1830                 <prgn>binary-indep</prgn>.
1831               </p>
1832
1833               <p>
1834                 Both <prgn>binary-*</prgn> targets should depend on
1835                 the <prgn>build</prgn> target, above, so that the
1836                 package is built if it has not been already.  It
1837                 should then create the relevant binary package(s),
1838                 using <prgn>dpkg-gencontrol</prgn> to make their
1839                 control files and <prgn>dpkg-deb</prgn> to build
1840                 them and place them in the parent of the top level
1841                 directory.
1842               </p>
1843
1844               <p>
1845                 If one of the <prgn>binary-*</prgn> targets has
1846                 nothing to do (this will be always be the case if
1847                 the source generates only a single binary package,
1848                 whether architecture-dependent or not) it
1849                 <em>must</em> still exist, and must always
1850                 succeed.
1851               </p>
1852
1853               <p>
1854                 The <prgn>binary</prgn> targets must be invoked as
1855                 root.
1856               </p>
1857             </item>
1858
1859             <tag><tt>clean</tt></tag>
1860             <item>
1861
1862               <p>
1863                 This must undo any effects that the
1864                 <prgn>build</prgn> and <prgn>binary</prgn> targets
1865                 may have had, except that it should leave alone any
1866                 output files created in the parent directory by a
1867                 run of <prgn>binary</prgn>. This target must be
1868                 non-interactive.
1869               </p>
1870
1871               <p>
1872                 If a <prgn>build</prgn> file is touched at the end
1873                 of the <prgn>build</prgn> target, as suggested
1874                 above, it should be removed as the first thing that
1875                 <prgn>clean</prgn> does, so that running
1876                 <prgn>build</prgn> again after an interrupted
1877                 <prgn>clean</prgn> doesn't think that everything is
1878                 already done.
1879               </p>
1880
1881               <p>
1882                 The <prgn>clean</prgn> target may need to be
1883                 invoked as root if <prgn>binary</prgn> has been
1884                 invoked since the last <prgn>clean</prgn>, or if
1885                 <prgn>build</prgn> has been invoked as root (since
1886                 <prgn>build</prgn> may create directories, for
1887                 example).
1888               </p>
1889             </item>
1890
1891             <tag><tt>get-orig-source</tt> (optional)</tag>
1892             <item>
1893
1894               <p>
1895                 This target fetches the most recent version of the
1896                 original source package from a canonical archive site
1897                 (via FTP or WWW, for example), does any necessary
1898                 rearrangement to turn it into the original source
1899                 tar file format described below, and leaves it in the
1900                 current directory.
1901               </p>
1902
1903               <p>
1904                 This target may be invoked in any directory, and
1905                 should take care to clean up any temporary files it
1906                 may have left.
1907               </p>
1908
1909               <p>
1910                 This target is optional, but providing it if
1911                 possible is a good idea.
1912               </p>
1913             </item>
1914           </taglist>
1915
1916         <p>
1917           The <prgn>build</prgn>, <prgn>binary</prgn> and
1918           <prgn>clean</prgn> targets must be invoked with a current
1919           directory of the package's top-level directory.
1920         </p>
1921
1922
1923         <p>
1924           Additional targets may exist in <tt>debian/rules</tt>,
1925           either as published or undocumented interfaces or for the
1926           package's internal use.
1927         </p>
1928
1929         <p>
1930           The architecture we build on and build for is determined by
1931           make variables via dpkg-architecture. You can get the Debian
1932           architecture and the GNU style architecture specification
1933           string for the build machine as well as the host
1934           machine. Here is a list of supported make variables:
1935           <list compact="compact">
1936             <item>
1937               <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
1938             </item>
1939             <item>
1940               <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
1941                 specification string)</p>
1942             </item>
1943             <item>
1944               <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
1945             </item>
1946             <item>
1947               <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
1948                 DEB_*_GNU_TYPE)</p>
1949           </list>
1950         </p>
1951
1952         <p>
1953           where <tt>*</tt> is either <tt>BUILD</tt> for specification of
1954           the build machine or <tt>HOST</tt> for specification of the machine
1955           we build for.
1956         </p>
1957
1958         <p>
1959           Backward compatibility can be provided in the rules file
1960           by setting the needed variables to suitable default
1961           values, please refer to the documentation of
1962           dpkg-architecture for details.
1963         </p>
1964
1965         <p>
1966           It is important to understand that the <tt>DEB_*_ARCH</tt>
1967           string only determines which Debian architecture we are
1968           building on or for. It should not be used to get the CPU
1969           or system information; the GNU style variables should be
1970           used for that.
1971         </p>
1972       </sect>
1973
1974       <sect id="dpkgchangelog"><heading><tt>debian/changelog</tt>
1975         </heading>
1976
1977         <p>
1978           This file records the changes to the Debian-specific parts of the
1979           package
1980           <footnote>
1981             <p>
1982               Though there is nothing stopping an author who is also
1983               the Debian maintainer from using it for all their
1984               changes, it will have to be renamed if the Debian and
1985               upstream maintainers become different
1986               people.
1987             </p>
1988           </footnote>.
1989         </p>
1990
1991         <p>
1992           It has a special format which allows the package building
1993           tools to discover which version of the package is being
1994           built and find out other release-specific information.
1995         </p>
1996
1997         <p>
1998           That format is a series of entries like this:
1999           <example>
2000             <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2001
2002             * <var>change details</var>
2003             <var>more change details</var>
2004             * <var>even more change details</var>
2005
2006             -- <var>maintainer name and email address</var>  <var>date</var>
2007           </example>
2008         </p>
2009
2010         <p>
2011           <var>package</var> and <var>version</var> are the source
2012           package name and version number.
2013         </p>
2014
2015         <p>
2016           <var>distribution(s)</var> lists the distributions where
2017           this version should be installed when it is uploaded - it
2018           is copied to the <tt>Distribution</tt> field in the
2019           <tt>.changes</tt> file.  See <ref id="f-Distribution">.
2020         </p>
2021
2022         <p>
2023           <var>urgency</var> is the value for the <tt>Urgency</tt>
2024           field in the <tt>.changes</tt> file for the upload. It is
2025           not possible to specify an urgency containing commas; commas
2026           are used to separate
2027           <tt><var>keyword</var>=<var>value</var></tt> settings in the
2028           <prgn>dpkg</prgn> changelog format (though there is
2029           currently only one useful <var>keyword</var>,
2030           <tt>urgency</tt>).
2031         </p>
2032
2033         <p>
2034           The change details may in fact be any series of lines
2035           starting with at least two spaces, but conventionally each
2036           change starts with an asterisk and a separating space and
2037           continuation lines are indented so as to bring them in
2038           line with the start of the text above.  Blank lines may be
2039           used here to separate groups of changes, if desired.
2040         </p>
2041
2042         <p>
2043           The maintainer name and email address need <em>not</em>
2044           necessarily be those of the usual package maintainer.
2045           They should be the details of the person doing
2046           <em>this</em> version.  The information here will be
2047           copied to the <tt>.changes</tt> file, and then later used
2048           to send an acknowledgement when the upload has been
2049           installed.
2050         </p>
2051
2052         <p>
2053           The <var>date</var> should be in RFC822 format
2054           <footnote>
2055             <p>
2056               This is generated by the <prgn>822-date</prgn>
2057               program.
2058             </p>
2059           </footnote>; it should include the time zone specified
2060           numerically, with the time zone name or abbreviation
2061           optionally present as a comment.
2062         </p>
2063
2064         <p>
2065           The first `title' line with the package name should start
2066           at the left hand margin; the `trailer' line with the
2067           maintainer and date details should be preceded by exactly
2068           one space.  The maintainer details and the date must be
2069           separated by exactly two spaces.
2070         </p>
2071
2072         <sect1><heading>Defining alternative changelog formats</heading>
2073
2074           <p>
2075             It is possible to use a different format to the standard
2076             one, by providing a parser for the format you wish to
2077             use.
2078           </p>
2079           <p>
2080             A changelog parser must not interact with the user at
2081             all.
2082           </p>
2083         </sect1>
2084       </sect>
2085
2086       <sect id="srcsubstvars"><heading><tt>debian/substvars</tt>
2087           and variable substitutions      </heading>
2088
2089         <p>
2090           When <prgn>dpkg-gencontrol</prgn>,
2091           <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2092           generate control files they do variable substitutions on
2093           their output just before writing it.  Variable
2094           substitutions have the form
2095           <tt>${<var>variable-name</var>}</tt>.  The optional file
2096           <tt>debian/substvars</tt> contains variable substitutions
2097           to be used; variables can also be set directly from
2098           <tt>debian/rules</tt> using the <tt>-V</tt> option to the
2099           source packaging commands, and certain predefined
2100           variables are available.
2101         </p>
2102
2103         <p>
2104           The is usually generated and modified dynamically by
2105           <tt>debian/rules</tt> targets; in this case it must be
2106           removed by the <prgn>clean</prgn> target.
2107         </p>
2108
2109         <p>
2110           See <manref name="dpkg-source" section="1"> for full
2111           details about source variable substitutions, including the
2112           format of <tt>debian/substvars</tt>.</p>
2113       </sect>
2114
2115       <sect id="debianfiles"><heading><tt>debian/files</tt>
2116         </heading>
2117
2118         <p>
2119           This file is not a permanent part of the source tree; it
2120           is used while building packages to record which files are
2121           being generated.  <prgn>dpkg-genchanges</prgn> uses it
2122           when it generates a <tt>.changes</tt> file.
2123         </p>
2124
2125         <p>
2126           It should not exist in a shipped source package, and so it
2127           (and any backup files or temporary files such as
2128           <tt>files.new</tt>
2129           <footnote>
2130             <p>
2131               <tt>files.new</tt> is used as a temporary file by
2132               <prgn>dpkg-gencontrol</prgn> and
2133               <prgn>dpkg-distaddfile</prgn> - they write a new
2134               version of <tt>files</tt> here before renaming it,
2135               to avoid leaving a corrupted copy if an error
2136               occurs
2137             </p>
2138           </footnote>) should be removed by the
2139           <prgn>clean</prgn> target.  It may also be wise to
2140           ensure a fresh start by emptying or removing it at the
2141           start of the <prgn>binary</prgn> target.
2142         </p>
2143
2144         <p>
2145           <prgn>dpkg-gencontrol</prgn> adds an entry to this file
2146           for the <tt>.deb</tt> file that will be created by
2147           <prgn>dpkg-deb</prgn> from the control file that it
2148           generates, so for most packages all that needs to be done
2149           with this file is to delete it in <prgn>clean</prgn>.
2150         </p>
2151
2152         <p>
2153           If a package upload includes files besides the source
2154           package and any binary packages whose control files were
2155           made with <prgn>dpkg-gencontrol</prgn> then they should be
2156           placed in the parent of the package's top-level directory
2157           and <prgn>dpkg-distaddfile</prgn> should be called to add
2158           the file to the list in <tt>debian/files</tt>.</p>
2159       </sect>
2160
2161       <sect id="restrictions"><heading>Restrictions on objects in source packages
2162         </heading>
2163
2164         <p>
2165           The source package may not contain any hard links
2166           <footnote>
2167             <p>
2168               This is not currently detected when building source
2169               packages, but only when extracting
2170               them.
2171             </p>
2172           </footnote>
2173           <footnote>
2174             <p>
2175               Hard links may be permitted at some point in the
2176               future, but would require a fair amount of
2177               work.
2178             </p>
2179           </footnote>, device special files, sockets or setuid or
2180           setgid files.
2181           <footnote>
2182             <p>
2183               Setgid directories are allowed.
2184             </p>
2185           </footnote>
2186         </p>
2187       </sect>
2188       <sect id="descriptions"><heading>Descriptions of packages - the
2189           <tt>Description</tt> field </heading>
2190
2191         <p>
2192           The description is intended to describe the program to a user
2193           who has never met it before so that they know whether they
2194           want to install it.  It should also give information about the
2195           significant dependencies and conflicts between this package
2196           and others, so that the user knows why these dependencies and
2197           conflicts have been declared.
2198         </p>
2199
2200         <sect1><heading>Notes about writing descriptions
2201           </heading>
2202
2203           <p>
2204             The single line synopsis should be kept brief - certainly
2205             under 80 characters.
2206           </p>
2207
2208           <p>
2209             Do not include the package name in the synopsis line.  The
2210             display software knows how to display this already, and you
2211             do not need to state it.  Remember that in many situations
2212             the user may only see the synopsis line - make it as
2213             informative as you can.
2214           </p>
2215
2216           <p>
2217             Do not try to continue the single line synopsis into the
2218             extended description.  This will not work correctly when
2219             the full description is displayed, and makes no sense
2220             where only the summary (the single line synopsis) is
2221             available.
2222           </p>
2223
2224           <p>
2225             The extended description should describe what the package
2226             does and how it relates to the rest of the system (in terms
2227             of, for example, which subsystem it is which part of).
2228           </p>
2229
2230           <p>
2231             The description field needs to make sense to anyone, even
2232             people who have no idea about any of the things the
2233             package deals with.
2234             <footnote>
2235               <p>
2236                 The blurb that comes with a program in its
2237                 announcements and/or <prgn>README</prgn> files is
2238                 rarely suitable for use in a description.  It is
2239                 usually aimed at people who are already in the
2240                 community where the package is used.
2241               </p>
2242             </footnote>
2243           </p>
2244
2245           <p>
2246             Put important information first, both in the synopsis and
2247             extended description.  Sometimes only the first part of the
2248             synopsis or of the description will be displayed.  You can
2249             assume that there will usually be a way to see the whole
2250             extended description.
2251           </p>
2252
2253           <p>
2254             You may include information about dependencies and so forth
2255             in the extended description, if you wish.
2256           </p>
2257
2258           <p>
2259             Do not use tab characters.  Their effect is not predictable.
2260           </p>
2261
2262         </sect1>
2263       </sect>
2264     </chapt>
2265
2266
2267     <chapt id="maintainerscripts"><heading>Package maintainer scripts
2268         and installation procedure
2269       </heading>
2270
2271       <sect><heading>Introduction to package maintainer scripts
2272         </heading>
2273
2274         <p>
2275           It is possible to supply scripts as part of a package which
2276           the package management system will run for you when your
2277           package is installed, upgraded or removed.
2278         </p>
2279
2280         <p>
2281           These scripts should be the files <tt>preinst</tt>,
2282           <tt>postinst</tt>, <tt>prerm</tt> and <tt>postrm</tt> in the
2283           control area of the package.  They must be proper executable
2284           files; if they are scripts (which is recommended) they must
2285           start with the usual <tt>#!</tt> convention.  They should be
2286           readable and executable by anyone, and not world-writable.
2287         </p>
2288
2289         <p>
2290           The package management system looks at the exit status from
2291           these scripts.  It is important that they exit with a
2292           non-zero status if there is an error, so that the package
2293           management system can stop its processing.  For shell
2294           scripts this means that you <em>almost always</em> need to
2295           use <tt>set -e</tt> (this is usually true when writing shell
2296           scripts, in fact).  It is also important, of course, that
2297           they don't exit with a non-zero status if everything went
2298           well.
2299         </p>
2300
2301         <p>
2302           It is necessary for the error recovery procedures that the
2303           scripts be idempotent: i.e., invoking the same script several
2304           times in the same situation should do no harm.  If the first
2305           call failed, or aborted half way through for some reason,
2306           the second call should merely do the things that were left
2307           undone the first time, if any, and exit with a success
2308           status.
2309         </p>
2310
2311         <p>
2312           When a package is upgraded a combination of the scripts from
2313           the old and new packages is called in amongst the other
2314           steps of the upgrade procedure.  If your scripts are going
2315           to be at all complicated you need to be aware of this, and
2316           may need to check the arguments to your scripts.
2317         </p>
2318
2319         <p>
2320           Broadly speaking the <prgn>preinst</prgn> is called before
2321           (a particular version of) a package is installed, and the
2322           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2323           before (a version of) a package is removed and the
2324           <prgn>postrm</prgn> afterwards.
2325         </p>
2326
2327         <p> Programs called from maintainer scripts should not
2328           normally have a path prepended to them. Before installation
2329           is started the package management system checks to see if
2330           the programs <prgn>ldconfig</prgn>,
2331           <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2332           and <prgn>update-rc.d</prgn> can be found via the
2333           <tt>PATH</tt> environment variable. Those programs, and any
2334           other program that one would expect to on the <tt>PATH</tt>,
2335           should thus be invoked without an absolute
2336           pathname. Maintainer scripts should also not reset the
2337           <tt>PATH</tt>, though they might choose to modify it by pre-
2338           or appending package-specific directories. These
2339           considerations really apply to all shell scripts.</p>
2340       </sect>
2341       <sect>
2342         <heading>Maintainer scripts Idempotency</heading>
2343
2344         <p>
2345           It is very important to make maintainer scripts
2346           idempotent.
2347           <footnote>
2348             <p>
2349               That means that if it runs successfully or fails
2350               and then you call it again it doesn't bomb out,
2351               but just ensures that everything is the way it
2352               ought to be.
2353             </p>
2354           </footnote> This is so that if an error occurs, the
2355           user interrupts <prgn>dpkg</prgn> or some other
2356           unforeseen circumstance happens you don't leave the
2357           user with a badly-broken package.
2358         </p>
2359       </sect>
2360       <sect>
2361         <heading>Controlling terminal for maintainer scripts</heading>
2362
2363         <p>
2364           The maintainer scripts are guaranteed to run with a
2365           controlling terminal and can interact with the user.
2366           If they need to prompt for passwords, do full-screen
2367           interaction or something similar you should do these
2368           things to and from <tt>/dev/tty</tt>, since
2369           <prgn>dpkg</prgn> will at some point redirect scripts'
2370           standard input and output so that it can log the
2371           installation process.  Likewise, because these scripts
2372           may be executed with standard output redirected into a
2373           pipe for logging purposes, Perl scripts should set
2374           unbuffered output by setting <tt>$|=1</tt> so that the
2375           output is printed immediately rather than being
2376           buffered.
2377         </p>
2378
2379         <p>
2380           Each script should return a zero exit status for
2381           success, or a nonzero one for failure.
2382         </p>
2383       </sect>
2384
2385       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2386           scripts are called
2387         </heading>
2388
2389         <p>
2390           <list compact="compact">
2391             <item>
2392               <p><var>new-preinst</var> <tt>install</tt></p>
2393             </item>
2394             <item>
2395               <p><var>new-preinst</var> <tt>install</tt>
2396                 <var>old-version</var></p>
2397             </item>
2398             <item>
2399               <p><var>new-preinst</var> <tt>upgrade</tt>
2400                 <var>old-version</var></p>
2401             </item>
2402             <item>
2403               <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2404                 <var>new-version</var>
2405               </p>
2406             </item>
2407           </list>
2408
2409         <p>
2410           <list compact="compact">
2411             <item>
2412               <p><var>postinst</var> <tt>configure</tt>
2413                 <var>most-recently-configured-version</var></p>
2414             </item>
2415             <item>
2416               <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2417                 <var>new version</var></p>
2418             </item>
2419             <item>
2420               <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2421                 <tt>in-favour</tt> <var>package</var>
2422                 <var>new-version</var></p>
2423             </item>
2424             <item>
2425               <p>
2426                 <var>deconfigured's-postinst</var>
2427                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2428                 <var>failed-install-package</var> <var>version</var>
2429                 <tt>removing</tt> <var>conflicting-package</var>
2430                 <var>version</var>
2431               </p>
2432             </item>
2433           </list>
2434
2435         <p>
2436           <list compact="compact">
2437             <item>
2438               <p><var>prerm</var> <tt>remove</tt></p>
2439             </item>
2440             <item>
2441               <p><var>old-prerm</var> <tt>upgrade</tt>
2442                 <var>new-version</var></p>
2443             </item>
2444             <item>
2445               <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2446                 <var>old-version</var></p>
2447             </item>
2448             <item>
2449               <p><var>conflictor's-prerm</var> <tt>remove</tt>
2450                 <tt>in-favour</tt> <var>package</var>
2451                 <var>new-version</var></p>
2452             </item>
2453             <item>
2454               <p>
2455                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2456                 <tt>in-favour</tt> <var>package-being-installed</var>
2457                 <var>version</var> <tt>removing</tt>
2458                 <var>conflicting-package</var>
2459                 <var>version</var>
2460               </p>
2461             </item>
2462           </list>
2463
2464         <p>
2465           <list compact="compact">
2466             <item>
2467               <p><var>postrm</var> <tt>remove</tt></p>
2468             </item>
2469             <item>
2470               <p><var>postrm</var> <tt>purge</tt></p>
2471             </item>
2472             <item>
2473               <p>
2474                 <var>old-postrm</var> <tt>upgrade</tt>
2475                 <var>new-version</var></p>
2476             </item>
2477             <item>
2478               <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2479                 <var>old-version</var></p>
2480             </item>
2481             <item>
2482               <p><var>new-postrm</var> <tt>abort-install</tt></p>
2483             </item>
2484             <item>
2485               <p><var>new-postrm</var> <tt>abort-install</tt>
2486                 <var>old-version</var></p>
2487             </item>
2488             <item>
2489               <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2490                 <var>old-version</var></p>
2491             </item>
2492             <item>
2493               <p>
2494                 <var>disappearer's-postrm</var> <tt>disappear</tt>
2495                 <var>overwriter</var>
2496                 <var>overwriter-version</var></p></item>
2497           </list>
2498         </p>
2499
2500
2501       <sect id="unpackphase"><heading>Details of unpack phase of
2502           installation or upgrade
2503         </heading>
2504
2505         <p>
2506           The procedure on installation/upgrade/overwrite/disappear
2507           (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2508           stage of <tt>dpkg --install</tt>) is as follows.  In each
2509           case if an error occurs the actions are, in general, run
2510           backwards - this means that the maintainer scripts are run
2511           with different arguments in reverse order.  These are the
2512           `error unwind' calls listed below.
2513
2514           <enumlist>
2515             <item>
2516               <p>
2517                 <enumlist>
2518                   <item>
2519                     <p>If a version of the package is already
2520                       installed, call
2521                       <example>
2522                         <var>old-prerm</var> upgrade <var>new-version</var>
2523                       </example></p>
2524                   </item>
2525                   <item>
2526                     <p>
2527                       If the script runs but exits with a non-zero
2528                       exit status, <prgn>dpkg</prgn> will attempt:
2529                       <example>
2530                         <var>new-prerm</var> failed-upgrade <var>old-version</var>
2531                       </example>
2532                       Error unwind, for both the above cases:
2533                       <example>
2534                         <var>old-postinst</var> abort-upgrade <var>new-version</var>
2535                       </example>
2536                     </p>
2537                   </item>
2538                 </enumlist>
2539               </p>
2540             </item>
2541             <item>
2542               <p>If a `conflicting' package is being removed at the same time:
2543                 <enumlist>
2544                   <item>
2545                     <p>
2546                       If any packages depended on that conflicting
2547                       package and <tt>--auto-deconfigure</tt> is
2548                       specified, call, for each such package:
2549                       <example>
2550                         <var>deconfigured's-prerm</var> deconfigure \
2551                         in-favour <var>package-being-installed</var> <var>version</var> \
2552                         removing <var>conflicting-package</var> <var>version</var>
2553                       </example>
2554                       Error unwind:
2555                       <example>
2556                         <var>deconfigured's-postinst</var> abort-deconfigure \
2557                         in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2558                         removing <var>conflicting-package</var> <var>version</var>
2559                       </example>
2560                       The deconfigured packages are marked as
2561                       requiring configuration, so that if
2562                       <tt>--install</tt> is used they will be
2563                       configured again if possible.</p>
2564                   </item>
2565                   <item>
2566                     <p>To prepare for removal of the conflicting package, call:
2567                       <example>
2568                         <var>conflictor's-prerm</var> remove in-favour <var>package</var> <var>new-version</var>
2569                       </example>
2570                       Error unwind:
2571                       <example>
2572                         <var>conflictor's-postinst</var> abort-remove \
2573                         in-favour <var>package</var> <var>new-version</var>
2574                       </example>
2575                     </p>
2576                   </item>
2577                 </enumlist>
2578               </p>
2579             </item>
2580             <item>
2581               <p>
2582                 <enumlist>
2583                   <item>
2584                     <p>If the package is being upgraded, call:
2585                       <example>
2586                         <var>new-preinst</var> upgrade <var>old-version</var>
2587                       </example></p>
2588                   </item>
2589                   <item>
2590                     <p>
2591                       Otherwise, if the package had some configuration
2592                       files from a previous version installed (i.e., it
2593                       is in the `configuration files only' state):
2594                       <example>
2595                         <var>new-preinst</var> install <var>old-version</var>
2596                       </example></p>
2597
2598                   <item>
2599                     <p>Otherwise (i.e., the package was completely purged):
2600                       <example>
2601                         <var>new-preinst</var> install
2602                       </example>
2603                       Error unwind versions, respectively:
2604                       <example>
2605                         <var>new-postrm</var> abort-upgrade <var>old-version</var>
2606                         <var>new-postrm</var> abort-install <var>old-version</var>
2607                         <var>new-postrm</var> abort-install
2608                       </example>
2609                     </p>
2610                   </item>
2611                 </enumlist>
2612               </p>
2613             </item>
2614             <item>
2615
2616               <p>
2617                 The new package's files are unpacked, overwriting any
2618                 that may be on the system already, for example any
2619                 from the old version of the same package or from
2620                 another package (backups of the old files are left
2621                 around, and if anything goes wrong the package
2622                 management system will attempt to put them back as
2623                 part of the error unwind).
2624               </p>
2625
2626               <p>
2627                 It is an error for a package to contains files which
2628                 are on the system in another package, unless
2629                 <tt>Replaces</tt> is used (see <ref id="replaces">).
2630                 Currently the <tt>--force-overwrite</tt> flag is
2631                 enabled, downgrading it to a warning, but this may not
2632                 always be the case.
2633               </p>
2634
2635               <p>
2636                 It is a more serious error for a package to contain a
2637                 plain file or other kind of non-directory where another
2638                 package has a directory (again, unless
2639                 <tt>Replaces</tt> is used).  This error can be
2640                 overridden if desired using
2641                 <tt>--force-overwrite-dir</tt>, but this is not
2642                 advisable.
2643               </p>
2644
2645               <p>
2646                 Packages which overwrite each other's files produce
2647                 behavior which though deterministic is hard for the
2648                 system administrator to understand.  It can easily
2649                 lead to `missing' programs if, for example, a package
2650                 is installed which overwrites a file from another
2651                 package, and is then removed again.
2652                 <footnote>
2653                   <p>
2654                     Part of the problem is due to what is arguably a
2655                     bug in <prgn>dpkg</prgn>.
2656                   </p>
2657                 </footnote>
2658               </p>
2659
2660               <p>
2661                 A directory will never be replaced by a symbolic links
2662                 to a directory or vice versa; instead, the existing
2663                 state (symlink or not) will be left alone and
2664                 <prgn>dpkg</prgn> will follow the symlink if there is
2665                 one.</p>
2666             </item>
2667
2668             <item>
2669
2670               <p><enumlist>
2671                   <item>
2672                     <p>If the package is being upgraded, call
2673                       <example>
2674                         <var>old-postrm</var> upgrade <var>new-version</var>
2675                       </example></p>
2676                   </item>
2677                   <item>
2678                     <p>If this fails, <prgn>dpkg</prgn> will attempt:
2679                       <example>
2680                         <var>new-postrm</var> failed-upgrade <var>old-version</var>
2681                       </example>
2682                       Error unwind, for both cases:
2683                       <example>
2684                         <var>old-preinst</var> abort-upgrade <var>new-version</var>
2685                       </example>
2686                     </p>
2687                   </item>
2688                 </enumlist>
2689               <p>
2690                 This is the point of no return - if
2691                 <prgn>dpkg</prgn> gets this far, it won't back off
2692                 past this point if an error occurs.  This will
2693                 leave the package in a fairly bad state, which
2694                 will require a successful re-installation to clear
2695                 up, but it's when <prgn>dpkg</prgn> starts doing
2696                 things that are irreversible.
2697               </p>
2698             </item>
2699             <item>
2700               <p>
2701                 Any files which were in the old version of the package
2702                 but not in the new are removed.</p>
2703             </item>
2704             <item>
2705               <p>The new file list replaces the old.</p>
2706             </item>
2707             <item>
2708               <p>The new maintainer scripts replace the old.</p>
2709             </item>
2710
2711             <item>
2712               <p>Any packages all of whose files have been overwritten during the
2713                 installation, and which aren't required for
2714                 dependencies, are considered to have been removed.
2715                 For each such package,
2716                 <enumlist>
2717                   <item>
2718                     <p><prgn>dpkg</prgn> calls:
2719                       <example>
2720                         <var>disappearer's-postrm</var> disappear \
2721                         <var>overwriter</var> <var>overwriter-version</var>
2722                       </example>
2723                     </p>
2724                   </item>
2725                   <item>
2726                     <p>The package's maintainer scripts are removed.
2727                     </p>
2728                   </item>
2729                   <item>
2730                     <p>
2731                       It is noted in the status database as being in a
2732                       sane state, namely not installed (any conffiles
2733                       it may have are ignored, rather than being
2734                       removed by <prgn>dpkg</prgn>).  Note that
2735                       disappearing packages do not have their prerm
2736                       called, because <prgn>dpkg</prgn> doesn't know
2737                       in advance that the package is going to
2738                       vanish.
2739                     </p>
2740                   </item>
2741                 </enumlist>
2742               </p>
2743             </item>
2744             <item>
2745               <p>
2746                 Any files in the package we're unpacking that are also
2747                 listed in the file lists of other packages are removed
2748                 from those lists.  (This will lobotomize the file list
2749                 of the `conflicting' package if there is one.)
2750               </p>
2751             </item>
2752             <item>
2753               <p>
2754                 The backup files made during installation, above, are
2755                 deleted.
2756               </p>
2757             </item>
2758
2759             <item>
2760               <p>
2761                 The new package's status is now sane, and recorded as
2762                 `unpacked'.  Here is another point of no return - if
2763                 the conflicting package's removal fails we do not
2764                 unwind the rest of the installation; the conflicting
2765                 package is left in a half-removed limbo.
2766               </p>
2767             </item>
2768             <item>
2769               <p>
2770                 If there was a conflicting package we go and do the
2771                 removal actions (described below), starting with the
2772                 removal of the conflicting package's files (any that
2773                 are also in the package being installed have already
2774                 been removed from the conflicting package's file list,
2775                 and so do not get removed now).
2776               </p>
2777             </item>
2778           </enumlist>
2779         </p>
2780       </sect>
2781
2782       <sect><heading>Details of configuration</heading>
2783
2784         <p>
2785           When we configure a package (this happens with <tt>dpkg
2786             --install</tt>, or with <tt>--configure</tt>), we first
2787           update the conffiles and then call:
2788           <example>
2789             <var>postinst</var> configure <var>most-recently-configured-version</var>
2790           </example>
2791         </p>
2792
2793         <p>
2794           No attempt is made to unwind after errors during
2795           configuration.
2796         </p>
2797
2798         <p>
2799           If there is no most recently configured version
2800           <prgn>dpkg</prgn> will pass a null argument; older versions
2801           of dpkg may pass <tt>&lt;unknown&gt;</tt> (including the
2802           angle brackets) in this case.  Even older ones do not pass a
2803           second argument at all, under any circumstances.
2804         </p>
2805       </sect>
2806
2807       <sect><heading>Details of removal and/or configuration purging
2808         </heading>
2809
2810         <p>
2811           <enumlist>
2812             <item>
2813               <p>
2814                 <example>
2815                   <var>prerm</var> remove
2816                 </example>
2817               </p>
2818             </item>
2819             <item>
2820               <p>
2821                 The package's files are removed (except conffiles).
2822               </p>
2823             </item>
2824             <item>
2825               <p><example>
2826                   <var>postrm</var> remove
2827                 </example></p>
2828             </item>
2829             <item>
2830               <p>All the maintainer scripts except the postrm are removed.
2831               </p>
2832
2833               <p>
2834                 If we aren't purging the package we stop here.  Note
2835                 that packages which have no postrm and no conffiles
2836                 are automatically purged when removed, as there is no
2837                 difference except for the <prgn>dpkg</prgn>
2838                 status.</p>
2839             </item>
2840             <item>
2841               <p>
2842                 The conffiles and any backup files (<tt>~</tt>-files,
2843                 <tt>#*#</tt> files, <tt>%</tt>-files,
2844                 <tt>.dpkg-{old,new,tmp}</tt>, etc.) are removed.</p>
2845             </item>
2846             <item>
2847               <p><example>
2848                   <var>postrm</var> purge
2849                 </example></p>
2850             </item>
2851             <item>
2852               <p>The package's file list is removed.</p>
2853             </item>
2854           </enumlist>
2855           No attempt is made to unwind after errors during
2856           removal.</p>
2857       </sect>
2858     </chapt>
2859
2860
2861     <chapt id="relationships"><heading>Declaring relationships between
2862         packages      </heading>
2863
2864       <p>
2865         Packages can declare in their control file that they have
2866         certain relationships to other packages - for example, that
2867         they may not be installed at the same time as certain other
2868         packages, and/or that they depend on the presence of others,
2869         or that they should overwrite files in certain other packages
2870         if present.
2871       </p>
2872
2873       <p>
2874         This is done using the <tt>Depends</tt>, <tt>Recommends</tt>,
2875         <tt>Suggests</tt>, <tt>Enhances</tt>, <tt>Conflicts</tt>,
2876         <tt>Provides</tt> and <tt>Replaces</tt> control file fields.
2877       </p>
2878
2879       <p>
2880         Source packages may declare relationships to binary packages,
2881         saying that they require certain binary packages to be
2882         installed or absent at the time of building the package.
2883       </p>
2884
2885       <p>
2886         This is done using the <tt>Build-Depends</tt>,
2887         <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt>, and
2888         <tt>Build-Conflicts-Indep</tt> control file fields.
2889       </p>
2890
2891       <sect id="depsyntax"><heading>Syntax of relationship fields
2892         </heading>
2893
2894         <p>
2895           These fields all have a uniform syntax.  They are a list of
2896           package names separated by commas.
2897         </p>
2898
2899         <p>
2900           In the <tt>Depends</tt>, <tt>Recommends</tt>,
2901           <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
2902           <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
2903           control file fields of the package, which declare
2904           dependencies on other packages, the package names listed may
2905           also include lists of alternative package names, separated
2906           by vertical bar symbols <tt>|</tt> (pipe symbols).  In such
2907           a case, the presence of any one of the alternative packages
2908           is installed, that part of the dependency is considered to
2909           be satisfied.
2910         </p>
2911
2912         <p>
2913           All the fields except <tt>Provides</tt> may restrict their
2914           applicability to particular versions of each named package.
2915           This is done in parentheses after each individual package
2916           name; the parentheses should contain a relation from the
2917           list below followed by a version number, in the format
2918           described in <ref id="versions">.
2919         </p>
2920
2921         <p>
2922           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
2923           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
2924           strictly earlier, earlier or equal, exactly equal, later or
2925           equal and strictly later, respectively.  The forms
2926           <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
2927           earlier/later or equal, rather than strictly earlier/later,
2928           so they should not appear in new packages (though
2929           <prgn>dpkg</prgn> still supports them).
2930         </p>
2931
2932         <p>
2933           Whitespace may appear at any point in the version
2934           specification, and must appear where it's necessary to
2935           disambiguate; it is not otherwise significant.  For
2936           consistency and in case of future changes to
2937           <prgn>dpkg</prgn> it is recommended that a single space be
2938           used after a version relationship and before a version
2939           number; it is usual also to put a single space after each
2940           comma, on either side of each vertical bar, and before each
2941           open parenthesis.
2942         </p>
2943
2944         <p>
2945           For example:
2946           <example>
2947             Package: metamail
2948             Version: 2.7-3
2949             Depends: libc5 (>= 5.2.18-4), mime-support, csh | tcsh
2950           </example>
2951         </p>
2952
2953         <p>
2954           All fields that specify build-time relationships
2955           (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
2956           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
2957           may be restricted to a certain set of architectures.  This
2958           is done in brackets after each individual package name and
2959           the optional version specification.  The brackets enclose a
2960           list of Debian architecture names separated by whitespace.
2961           An exclamation mark may be prepended to each name. If the
2962           current Debian host architecture is not in this list and
2963           there are no exclamation marks in the list, or it is in the
2964           list with a prepended exclamation mark, the package name and
2965           the associated version specification are ignored completely
2966           for the purposes of defining the relationships.
2967         </p>
2968
2969         <p>
2970           For example:
2971           <example>
2972             Source: glibc
2973             Build-Depends-Indep: texinfo
2974             Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
2975             hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
2976           </example>
2977         </p>
2978       </sect>
2979
2980       <sect>
2981         <heading>Binary Dependencies - <tt>Depends</tt>,
2982           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
2983           <tt>Pre-Depends</tt>
2984         </heading>
2985
2986         <p>
2987           These five fields are used to declare a dependency
2988           relationship by one package on another.  They appear in the
2989           depending package's control file.
2990         </p>
2991
2992         <p>
2993           All but <tt>Pre-Depends</tt> and <tt>Conflicts</tt>
2994           (discussed below) take effect <em>only</em> when a package
2995           is to be configured.  They do not prevent a package being on
2996           the system in an unconfigured state while its dependencies
2997           are unsatisfied, and it is possible to replace a package
2998           whose dependencies are satisfied and which is properly
2999           installed with a different version whose dependencies are
3000           not and cannot be satisfied; when this is done the depending
3001           package will be left unconfigured (since attempts to
3002           configure it will give errors) and will not function
3003           properly.
3004         </p>
3005
3006         <p>
3007           For this reason packages in an installation run are usually
3008           all unpacked first and all configured later; this gives
3009           later versions of packages with dependencies on later
3010           versions of other packages the opportunity to have their
3011           dependencies satisfied.
3012         </p>
3013
3014         <p>
3015           Thus <tt>Depends</tt> allows package maintainers to impose
3016           an order in which packages should be configured.
3017           <taglist>
3018             <tag><tt>Depends</tt></tag>
3019             <item>
3020
3021               <p>This declares an absolute dependency.
3022               </p>
3023
3024               <p>
3025                 The <tt>Depends</tt> field should be used if the
3026                 depended-on package is required for the depending
3027                 package to provide a significant amount of
3028                 functionality.</p>
3029             </item>
3030
3031             <tag><tt>Recommends</tt></tag>
3032             <item>
3033               <p>This declares a strong, but not absolute, dependency.
3034               </p>
3035
3036               <p>
3037                 The <tt>Recommends</tt> field should list packages
3038                 that would be found together with this one in all but
3039                 unusual installations.</p>
3040             </item>
3041
3042             <tag><tt>Suggests</tt></tag>
3043             <item>
3044
3045               <p>
3046                 This is used to declare that one package may be more
3047                 useful with one or more others.  Using this field
3048                 tells the packaging system and the user that the
3049                 listed packages are related to this one and can
3050                 perhaps enhance its usefulness, but that installing
3051                 this one without them is perfectly reasonable.
3052               </p>
3053             </item>
3054
3055             <tag><tt>Enhances</tt></tag>
3056             <item>
3057               <p>
3058                 This field is similar to Suggests but works in the
3059                 opposite direction. It is used to declare that a
3060                 package can enhance the functionality of another
3061                 package.
3062               </p>
3063             </item>
3064
3065             <tag><tt>Pre-Depends</tt></tag>
3066             <item>
3067
3068               <p>
3069                 This field is like <tt>Depends</tt>, except that it
3070                 also forces <prgn>dpkg</prgn> to complete installation
3071                 of the packages named before even starting the
3072                 installation of the package which declares the
3073                 Pre-dependency.
3074               </p>
3075
3076               <p>
3077                 <tt>Pre-Depends</tt> should be used sparingly,
3078                 preferably only by packages whose premature upgrade or
3079                 installation would hamper the ability of the system to
3080                 continue with any upgrade that might be in progress.
3081               </p>
3082
3083               <p>
3084                 When the package declaring it is being configured, a
3085                 <tt>Pre-Dependency</tt> will be considered satisfied
3086                 only if the depending package has been correctly
3087                 configured, just as if an ordinary <tt>Depends</tt>
3088                 had been used.
3089               </p>
3090
3091               <p>
3092                 However, when a package declaring a Pre-dependency is
3093                 being unpacked the predependency can be satisfied even
3094                 if the depended-on package(s) are only unpacked or
3095                 half-configured, provided that they have been
3096                 configured correctly at some point in the past (and
3097                 not removed or partially removed since).  In this case
3098                 both the previously-configured and currently unpacked
3099                 or half-configured versions must satisfy any version
3100                 clause in the <tt>Pre-Depends</tt> field.
3101               </p>
3102             </item>
3103           </taglist>
3104         </p>
3105         <p>
3106           When selecting which level of dependency to use you should
3107           consider how important the depended-on package is to the
3108           functionality of the one declaring the dependency.  Some
3109           packages are composed of components of varying degrees of
3110           importance.  Such a package should list using
3111           <tt>Depends</tt> the package(s) which are required by the
3112           more important components.  The other components'
3113           requirements may be mentioned as Suggestions or
3114           Recommendations, as appropriate to the components' relative
3115           importance.
3116         </p>
3117
3118
3119       <sect id="conflicts"><heading>Alternative binary packages -
3120           <tt>Conflicts</tt> and <tt>Replaces</tt>
3121         </heading>
3122
3123         <p>
3124           When one binary package declares a conflict with another
3125           <prgn>dpkg</prgn> will refuse to allow them to be installed
3126           on the system at the same time.
3127         </p>
3128
3129         <p>
3130           If one package is to be installed, the other must be removed
3131           first - if the package being installed is marked as
3132           replacing (<ref id="replaces">) the one on the system, or
3133           the one on the system is marked as deselected, or both
3134           packages are marked <tt>Essential</tt>, then
3135           <prgn>dpkg</prgn> will automatically remove the package
3136           which is causing the conflict, otherwise it will halt the
3137           installation of the new package with an error. This
3138           mechanism specifically doesn't work when the installed
3139           package is <tt>Essential</tt>, but the new package is not.
3140         </p>
3141
3142
3143         <p>
3144           A package will not cause a conflict merely because its
3145           configuration files are still installed; it must be at least
3146           half-installed.
3147         </p>
3148
3149         <p>
3150           A special exception is made for packages which declare a
3151           conflict with their own package name, or with a virtual
3152           package which they provide (see below): this does not
3153           prevent their installation, and allows a package to conflict
3154           with others providing a replacement for it.  You use this
3155           feature when you want the package in question to be the only
3156           package providing something.
3157         </p>
3158
3159         <p>
3160           A <tt>Conflicts</tt> entry should almost never have an
3161           `earlier than' version clause.  This would prevent
3162           <prgn>dpkg</prgn> from upgrading or installing the package
3163           which declared such a conflict until the upgrade or removal
3164           of the conflicted-with package had been completed.
3165         </p>
3166       </sect>
3167
3168       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3169         </heading>
3170
3171         <p>
3172           As well as the names of actual (`concrete') packages, the
3173           package relationship fields <tt>Depends</tt>,
3174           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3175           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Conflicts</tt>,
3176           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt> may
3177           mention virtual packages.
3178         </p>
3179
3180         <p>
3181           A virtual package is one which appears in the
3182           <tt>Provides</tt> control file field of another package.
3183           The effect is as if the package(s) which provide a
3184           particular virtual package name had been listed by name
3185           everywhere the virtual package name appears.
3186         </p>
3187
3188         <p>
3189           If there are both a real and a virtual package of the same
3190           name then the dependency may be satisfied (or the conflict
3191           caused) by either the real package or any of the virtual
3192           packages which provide it.  This is so that, for example,
3193           supposing we have
3194           <example>
3195             Package: vm
3196             Depends: emacs
3197           </example>
3198           and someone else releases an xemacs package they can say
3199           <example>
3200             Package: xemacs
3201             Provides: emacs
3202           </example> and all will work in the interim (until a purely
3203           virtual package name is decided on and the <tt>emacs</tt>
3204           and <tt>vm</tt> packages are changed to use it).
3205         </p>
3206
3207         <p>
3208           If a dependency or a conflict has a version number attached
3209           then only real packages will be considered to see whether
3210           the relationship is satisfied (or the prohibition violated,
3211           for a conflict) - it is assumed that a real package which
3212           provides the virtual package is not of the `right' version.
3213           So, a <tt>Provides</tt> field may not contain version
3214           numbers, and the version number of the concrete package
3215           which provides a particular virtual package will not be
3216           looked at when considering a dependency on or conflict with
3217           the virtual package name.
3218         </p>
3219
3220         <p>
3221           It is likely that the ability will be added in a future
3222           release of <prgn>dpkg</prgn> to specify a version number for
3223           each virtual package it provides.  This feature is not yet
3224           present, however, and is expected to be used only
3225           infrequently.
3226         </p>
3227
3228         <p>
3229           If you want to specify which of a set of real packages should be the
3230           default to satisfy a particular dependency on a virtual package, you
3231           should list the real package as an alternative before the virtual.
3232         </p>
3233       </sect>
3234
3235
3236       <sect id="replaces"><heading><tt>Replaces</tt> - overwriting
3237           files and replacing packages
3238         </heading>
3239
3240         <p>
3241           The <tt>Replaces</tt> control file field has two purposes,
3242           which come into play in different situations.
3243         </p>
3244
3245         <p>
3246           Virtual packages (<ref id="virtual">) are not considered
3247           when looking at a <tt>Replaces</tt> field - the packages
3248           declared as being replaced must be mentioned by their real
3249           names.
3250         </p>
3251
3252         <sect1><heading>Overwriting files in other packages
3253           </heading>
3254
3255           <p>
3256             Firstly, as mentioned before, it is usually an error for a
3257             package to contain files which are on the system in
3258             another package, though currently the
3259             <tt>--force-overwrite</tt> flag is enabled by default,
3260             downgrading the error to a warning,
3261           </p>
3262
3263           <p>
3264             If the overwriting package declares that it replaces the
3265             one containing the file being overwritten then
3266             <prgn>dpkg</prgn> will proceed, and replace the file from
3267             the old package with that from the new.  The file will no
3268             longer be listed as `owned' by the old package.
3269           </p>
3270
3271           <p>
3272             If a package is completely replaced in this way, so that
3273             <prgn>dpkg</prgn> does not know of any files it still
3274             contains, it is considered to have disappeared.  It will
3275             be marked as not wanted on the system (selected for
3276             removal) and not installed.  Any conffiles details noted
3277             in the package will be ignored, as they will have been
3278             taken over by the replacing package(s).  The package's
3279             <prgn>postrm</prgn> script will be run to allow the
3280             package to do any final cleanup required.  See <ref
3281                                                                 id="mscriptsinstact">.
3282           </p>
3283
3284           <p>
3285             In the future <prgn>dpkg</prgn> will discard files which
3286             would overwrite those from an already installed package
3287             which declares that it replaces the package being
3288             installed.  This is so that you can install an older
3289             version of a package without problems.
3290           </p>
3291
3292           <p>
3293             This usage of <tt>Replaces</tt> only takes effect when
3294             both packages are at least partially on the system at
3295             once, so that it can only happen if they do not conflict
3296             or if the conflict has been overridden.</p>
3297         </sect1>
3298
3299         <sect1><heading>Replacing whole packages, forcing their
3300             removal
3301           </heading>
3302
3303           <p>
3304             Secondly, <tt>Replaces</tt> allows the packaging system to
3305             resolve which package should be removed when there is a
3306             conflict - see <ref id="conflicts">.  This usage only
3307             takes effect when the two packages <em>do</em> conflict,
3308             so that the two effects do not interfere with each other.
3309           </p>
3310         </sect1>
3311       </sect>
3312
3313       <sect><heading>Relationships between source and binary packages -
3314           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3315           <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3316         </heading>
3317
3318         <p>
3319           A source package may declare a dependency or a conflict on a
3320           binary package.  This is done with the control file fields
3321           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3322           <tt>Build-Conflicts</tt>, and
3323           <tt>Build-Conflicts-Indep</tt>.  Their semantics are that
3324           the dependencies and conflicts they define must be satisfied
3325           (as defined earlier for binary packages), when one of the
3326           targets in <tt>debian/rules</tt> that the particular field
3327           applies to is invoked.
3328
3329           <taglist>
3330             <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3331             <item>
3332               <p>
3333                 The <tt>Build-Depends</tt> and
3334                 <tt>Build-Conflicts</tt> fields apply to the targets
3335                 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>
3336                 and <tt>binary-indep</tt>.
3337               </p>
3338             </item>
3339             <tag><tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt></tag>
3340             <item>
3341               <p>
3342                 The <tt>Build-Depends-Indep</tt> and
3343                 <tt>Build-Conflicts-Indep</tt> fields apply to the
3344                 targets <tt>binary</tt> and <tt>binary-indep</tt>.
3345               </p>
3346             </item>
3347           </taglist>
3348
3349         </p>
3350
3351       </sect>
3352     </chapt>
3353
3354
3355     <chapt id="conffiles"><heading>Configuration file handling
3356       </heading>
3357
3358       <p>
3359         <prgn>dpkg</prgn> can do a certain amount of automatic
3360         handling of package configuration files.
3361       </p>
3362
3363       <p>
3364         Whether this mechanism is appropriate depends on a number of
3365         factors, but basically there are two approaches to any
3366         particular configuration file.
3367       </p>
3368
3369       <p>
3370         The easy method is to ship a best-effort configuration in the
3371         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
3372         handle updates.  If the user is unlikely to want to edit the
3373         file, but you need them to be able to without losing their
3374         changes, and a new package with a changed version of the file
3375         is only released infrequently, this is a good approach.
3376       </p>
3377
3378       <p>
3379         The hard method is to build the configuration file from
3380         scratch in the <prgn>postinst</prgn> script, and to take the
3381         responsibility for fixing any mistakes made in earlier
3382         versions of the package automatically.  This will be
3383         appropriate if the file is likely to need to be different on
3384         each system.
3385       </p>
3386
3387
3388     <chapt id="sharedlibs"><heading>Shared libraries
3389       </heading>
3390
3391       <p>
3392         Packages containing shared libraries must be constructed with
3393         a little care to make sure that the shared library is always
3394         available.  This is especially important for packages whose
3395         shared libraries are vitally important, such as the libc.
3396       </p>
3397
3398       <p>
3399         Firstly, your package should install the shared libraries
3400         under their normal names.  For example, the
3401         <prgn>libgdbm1</prgn> package should install
3402         <tt>libgdbm.so.1.7.3</tt> as
3403         <tt>/usr/lib/libgdbm.so.1.7.3</tt>.  The files should not be
3404         renamed or re-linked by any prerm or postrm scripts;
3405         <prgn>dpkg</prgn> will take care of renaming things safely
3406         without affecting running programs, and attempts to interfere
3407         with this are likely to lead to problems.
3408       </p>
3409
3410       <p>
3411         Secondly, your package should include the symlink that
3412         <prgn>ldconfig</prgn> would create for the shared libraries.
3413         For example, the <prgn>libgdbm1</prgn> package should include
3414         a symlink from <tt>/usr/lib/libgdbm.so.1</tt> to
3415         <tt>libgdbm.so.1.7.3</tt>.  This is needed so that
3416         <prgn>ld.so</prgn> can find the library in between the time
3417         <prgn>dpkg</prgn> installs it and <prgn>ldconfig</prgn> is run
3418         in the <prgn>postinst</prgn> script.  Furthermore, older
3419         versions of the package management system required the library
3420         must be placed before the symlink pointing to it in the
3421         <tt>.deb</tt> file.  This is so that by the time
3422         <prgn>dpkg</prgn> comes to install the symlink (overwriting
3423         the previous symlink pointing at an older version of the
3424         library) the new shared library is already in place.
3425         Unfortunately, this was not not always possible, since it
3426         highly depends on the behavior of the file system. Some
3427         file systems (such as reiserfs) will reorder the files so it
3428         doesn't matter in what order you create them. Starting with
3429         release <tt>1.7.0</tt> <prgn>dpkg</prgn> will reorder the
3430         files itself when building a package.
3431       </p>
3432
3433       <p>
3434         Thirdly, the development package should contain a symlink for
3435         the shared library without a version number.  For example, the
3436         <tt>libgdbm1-dev</tt> package should include a symlink from
3437         <tt>/usr/lib/libgdm.so</tt> to <tt>libgdm.so.1.7.3</tt>.  This
3438         symlink is needed by <prgn>ld</prgn> when compiling packages
3439         as it will only look for <tt>libgdm.so</tt> and
3440         <tt>libgdm.a</tt> when compiling dynamically or statically,
3441         respectively.
3442       </p>
3443
3444       <p>
3445         Any package installing shared libraries in a directory that's listed
3446         in <tt>/etc/ld.so.conf</tt> or in one of the default library
3447         directories of <prgn>ld.so</prgn> (currently, these are <tt>/usr/lib</tt>
3448         and <tt>/lib</tt>) must call <prgn>ldconfig</prgn> in its <prgn>postinst</prgn>
3449         script if and only if the first argument is `configure'. However, it
3450         is important not to call <prgn>ldconfig</prgn> in the postrm or preinst
3451         scripts in the case where the package is being upgraded (see <ref
3452                                                                           id="unpackphase">), as <prgn>ldconfig</prgn> will see the temporary names
3453         that <prgn>dpkg</prgn> uses for the files while it is
3454         installing them and will make the shared library links point
3455         to them, just before <prgn>dpkg</prgn> continues the
3456         installation and removes the links!
3457       </p>
3458
3459       <sect id="shlibs"><heading>The <tt>shlibs</tt> File Format
3460         </heading>
3461
3462         <p>
3463           This file is for use by <prgn>dpkg-shlibdeps</prgn> and is
3464           required when your package provides shared libraries.
3465         </p>
3466
3467         <p>
3468           Each line is of the form:
3469           <example>
3470             <var>library-name</var> <var>version-or-soname</var> <var>dependencies ...</var>
3471           </example>
3472         </p>
3473
3474         <p>
3475           <var>library-name</var> is the name of the shared library,
3476           for example <tt>libc5</tt>.
3477         </p>
3478
3479         <p>
3480           <var>version-or-soname</var> is the soname of the library -
3481           i.e., the thing that must exactly match for the library to be
3482           recognized by <prgn>ld.so</prgn>.  Usually this is the major
3483           version number of the library.
3484         </p>
3485
3486         <p>
3487           <var>dependencies</var> has the same syntax as a dependency
3488           field in a binary package control file.  It should give
3489           details of which package(s) are required to satisfy a binary
3490           built against the version of the library contained in the
3491           package.  See <ref id="depsyntax">.
3492         </p>
3493
3494         <p>
3495           For example, if the package <tt>foo</tt> contains
3496           <tt>libfoo.so.1.2.3</tt>, where the soname of the library is
3497           <tt>libfoo.so.1</tt>, and the first version of the package
3498           which contained a minor number of at least <tt>2.3</tt> was
3499           <var>1.2.3-1</var>, then the package's <var>shlibs</var>
3500           could say:
3501           <example>
3502             libfoo 1    foo (>= 1.2.3-1)
3503           </example>
3504         </p>
3505
3506         <p>
3507           The version-specific dependency is to avoid warnings from
3508           <prgn>ld.so</prgn> about using older shared libraries with
3509           newer binaries.</p>
3510       </sect>
3511
3512       <sect><heading>Further Technical information on
3513           <tt>shlibs</tt></heading>
3514
3515         <sect1><heading><em>What</em> are the <tt>shlibs</tt> files?
3516           </heading>
3517
3518           <p>
3519             The <tt>debian/shlibs</tt> file provides a way of checking
3520             for shared library dependencies on packaged binaries.
3521             They are intended to be used by package maintainers to
3522             make their lives easier.
3523           </p>
3524
3525           <p>
3526             Other <tt>shlibs</tt> files that exist on a Debian system are
3527             <list>
3528               <item> <p><tt>/etc/dpkg/shlibs.default</tt></p></item>
3529               <item> <p><tt>/etc/dpkg/shlibs.override</tt></p></item>
3530               <item> <p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
3531               <item> <p><tt>debian/shlibs.local</tt></p></item>
3532             </list>
3533             These files are used by <prgn>dpkg-shlibdeps</prgn> when
3534             creating a binary package.</p>
3535         </sect1>
3536
3537         <sect1><heading><em>How</em> does <prgn>dpkg-shlibdeps</prgn>
3538             work?
3539           </heading>
3540           <p>
3541             <prgn>dpkg-shlibdeps</prgn>
3542             determines the shared libraries directly
3543             <footnote>
3544               <p>
3545                 It used to do this by calling <prgn>ldd</prgn>, but it
3546                 now calls <prgn>objdump</prgn> to to this. This
3547                 requires a couple of changes in the way that packages
3548                 are built.
3549               </p>
3550               <p>
3551                 A binary <tt>foo</tt> directly uses a library
3552                 <tt>libbar</tt> if it is linked with that
3553                 library. Other libraries that are needed by
3554                 <tt>libbar</tt> are linked indirectly to <tt>foo</tt>,
3555                 and the dynamic linker will load them automatically
3556                 when it loads <tt>libbar</tt>. Running<prgn>ldd</prgn>
3557                 lists all of the libraries used, both directly and
3558                 indirectly; but <prgn>objdump</prgn> only lists the
3559                 directly linked libraries. A package only needs to
3560                 depend on the libraries it is directly linked to,
3561                 since the dependencies for those libraries should
3562                 automatically pull in the other libraries.
3563               </p>
3564               <p>
3565                 This change does mean a change in the way packages are
3566                 build though: currently <prgn>dpkg-shlibdeps</prgn> is
3567                 only run on binaries. But since we will now rely on the
3568                 libraries depending on the libraries they themselves
3569                 need, the packages containing those libraries will
3570                 need to run <prgn>dpkg-shlibdeps</prgn> on the
3571                 libraries.
3572               </p>
3573               <p>
3574                 A good example where this would help us is the current
3575                 mess with multiple version of the <tt>mesa</tt>
3576                 library. With the <prgn>ldd</prgn>-based system, every
3577                 package that uses <tt>mesa</tt> needs to add a
3578                 dependency on <tt>svgalib|svgalib-dummy</tt> in order
3579                 to handle the glide <tt>mesa</tt> variant.  With an
3580                 <prgn>objdump</prgn>-based system this isn't necessary
3581                 anymore and would have saved everyone a lot of work.
3582               </p>
3583               <p>
3584                 Another example: we could update <tt>libimlib</tt>
3585                 with a new version that supports a new graphics format
3586                 called dgf. If we use the old <prgn>ldd</prgn> method,
3587                 every package that uses <tt>libimlib</tt> would need
3588                 to be recompiled so it would also depend on
3589                 <tt>libdgf</tt> or it wouldn't run due to missing
3590                 symbols. However with the new system, packages using
3591                 <tt>libimlib</tt> can rely on <tt>libimlib</tt> itself
3592                 having the dependency on <tt>libdgf</tt> and wouldn't
3593                 need to be updated.
3594               </p>
3595             </footnote>
3596             used by the compiled binaries and libraries passed through
3597             on its command line.
3598           </p>
3599
3600           <p>
3601             For each shared library linked to,
3602             <prgn>dpkg-shlibdeps</prgn> needs to know
3603             <list compact="compact">
3604               <item><p>the package containing the library, and</p></item>
3605               <item><p>the library version number,</p></item>
3606             </list>
3607             and it scans the following files in this order:
3608             <enumlist compact="compact">
3609               <item><p><tt>debian/shlibs.local</tt></p></item>
3610               <item><p><tt>/etc/dpkg/shlibs.override</tt></p></item>
3611               <item><p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
3612               <item><p><tt>/etc/dpkg/shlibs.default</tt></p></item>
3613             </enumlist>
3614           </p>
3615         </sect1>
3616
3617         <sect1><heading><em>Who</em> maintains the various
3618             <tt>shlibs</tt> files?
3619           </heading>
3620
3621           <p>
3622             <list compact="compact">
3623               <item>
3624                 <p><tt>/etc/dpkg/shlibs.default</tt> - the maintainer
3625                   of dpkg</p>
3626               </item>
3627               <item>
3628                 <p>
3629                   <tt>/var/lib/dpkg/info/<var>package</var>.shlibs</tt>
3630                   - the maintainer of each package</p>
3631               </item>
3632               <item>
3633                 <p>
3634                   <tt>/etc/dpkg/shlibs.override</tt> - the local
3635                   system administrator</p>
3636               </item>
3637               <item>
3638                 <p><tt>debian/shlibs.local</tt> - the maintainer of
3639                   the package
3640                 </p>
3641               </item>
3642             </list>
3643             The <tt>shlibs.default</tt> file is managed by
3644             <prgn>dpkg</prgn>. The entries in <tt>shlibs.default</tt>
3645             that are provided by <prgn>dpkg</prgn> are just there to
3646             fix things until the shared library packages all have
3647             <tt>shlibs</tt> files.
3648           </p>
3649         </sect1>
3650
3651         <sect1><heading><em>How</em> to use <prgn>dpkg-shlibdeps</prgn> and
3652             the <tt>shlibs</tt> files
3653           </heading>
3654
3655           <sect2><heading>If your package doesn't provide a shared
3656               library
3657             </heading>
3658
3659             <p>
3660               Put a call to <prgn>dpkg-shlibdeps</prgn> into your
3661               <tt>debian/rules</tt> file.  If your package contains
3662               only binaries (e.g. no scripts) use:
3663               <example>
3664                 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/*
3665               </example>
3666               If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
3667               done. If it does complain you might need to create your
3668               own <tt>debian/shlibs.local</tt> file.</p>
3669           </sect2>
3670
3671           <sect2><heading>If your package provides a shared library
3672             </heading>
3673
3674             <p>
3675               Create a <tt>debian/shlibs</tt> file and let
3676               <tt>debian/rules</tt> install it in the control area:
3677               <example>
3678                 install -m644 debian/shlibs debian/tmp/DEBIAN
3679               </example>
3680               If your package contains additional binaries see above.
3681             </p>
3682           </sect2>
3683         </sect1>
3684
3685         <sect1><heading><em>How</em> to write
3686             <tt>debian/shlibs.local</tt>
3687           </heading>
3688
3689           <p>
3690             This file is intended only as a <em>temporary</em> fix if
3691             your binaries depend on a library which doesn't provide
3692             its own <tt>/var/lib/dpkg/info/*.shlibs</tt> file yet.
3693           </p>
3694
3695           <p>
3696             Let's assume you are packaging a binary <tt>foo</tt>. Your
3697             output in building the package might look like this.
3698             <example>
3699               $ ldd foo
3700               libbar.so.1 => /usr/X11R6/lib/libbar.so.1.0 (0x4001e000)
3701               libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4002c000)
3702               libc.so.6 => /lib/libc.so.6 (0x40114000)
3703               /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
3704             </example>
3705             And when you ran <prgn>dpkg-shlibdeps</prgn>
3706             <example>
3707               $ dpkg-shlibdeps -O foo
3708               dpkg-shlibdeps: warning: unable to find dependency information for shared library libbar
3709               (soname 1, path /usr/X11R6/lib/libbar.so.1.0, dependency field Depends)
3710               shlibs:Depends=libc6 (>= 2.2.1), xlibs (>= 4.0.1-11)
3711             </example>
3712             The <prgn>foo</prgn> binary depends on the
3713             <prgn>libbar</prgn> shared library, but no package seems
3714             to provide a <tt>*.shlibs</tt> file in
3715             <tt>/var/lib/dpkg/info/</tt>.  Let's determine the package
3716             responsible:
3717           </p>
3718
3719           <p>
3720             <example>
3721               $ dpkg -S /usr/X11R6/lib/libbar.so.1.0
3722               bar1: /usr/X11R6/lib/libbar.so.1.0
3723               $ dpkg -s bar1 | grep Version
3724               Version: 1.0-1
3725             </example>
3726             This tells us that the <prgn>bar1</prgn> package, version
3727             1.0-1 is the one we are using. Now we can create our own
3728             <tt>debian/shlibs.local</tt> to temporarily fix the above
3729             problem. Include the following line into your
3730             <tt>debian/shlibs.local</tt> file.
3731             <example>
3732               libbar 1 bar1 (>= 1.0-1)
3733             </example>
3734             Now your package build should work. As soon as the
3735             maintainer of <prgn>libbar1</prgn> provides a
3736             <tt>shlibs</tt> file, you can remove your
3737             <tt>debian/shlibs.local</tt> file.
3738           </p>
3739         </sect1>
3740       </sect>
3741     </chapt>
3742
3743     <chapt><heading>The Operating System</heading>
3744
3745
3746       <sect>
3747         <heading>File system hierarchy</heading>
3748
3749
3750         <sect1>
3751           <heading>Linux File system Structure</heading>
3752
3753           <p>
3754             The location of all installed files and directories must
3755             comply  with the Linux File system Hierarchy Standard
3756             (FHS).  The latest version of this document can be found
3757             alongside this manual or on
3758             <url id="http://www.pathname.com/fhs/">.
3759             Specific questions about following the standard may be
3760             asked on <prgn>debian-devel</prgn>, or referred to Daniel
3761             Quinlan, the FHS coordinator, at
3762             <email>quinlan@pathname.com</email>.</p></sect1>
3763
3764
3765         <sect1>
3766           <heading>Site-specific programs</heading>
3767
3768           <p>
3769             As mandated by the FHS, packages must not place any
3770             files in <tt>/usr/local</tt>, either by putting them in
3771             the file system archive to be unpacked by <prgn>dpkg</prgn>
3772             or by manipulating them in their maintainer scripts.</p>
3773
3774           <p>
3775             However, the package may create empty directories below
3776             <tt>/usr/local</tt> so that the system administrator knows
3777             where to place site-specific files. These directories
3778             should be removed on package removal if they are
3779             empty.</p>
3780
3781           <p>
3782             Note, that this applies only to directories <em>below</em>
3783             <tt>/usr/local</tt>, not <em>in</em>
3784             <tt>/usr/local</tt>. Packages must not create sub-directories
3785             in the directory <tt>/usr/local</tt> itself, except those listed in
3786             FHS, section 4.5. However, you may create directories
3787             below them as you wish. You must not remove any of the
3788             directories listed in 4.5, even if you created them.</p>
3789
3790           <p>
3791             Since <tt>/usr/local</tt> can be mounted read-only from a
3792             remote server, these directories must be created and
3793             removed by the <tt>postinst</tt> and <tt>prerm</tt>
3794             maintainer scripts. These scripts must not fail if either
3795             of these operations fail. (In the future, it will be
3796             possible to tell <prgn>dpkg</prgn> not to unpack files
3797             matching certain patterns, so that the directories can be
3798             included in the <tt>.deb</tt> packages and system
3799             administrators who do not wish these directories in
3800             /usr/local do not need to have them.)</p>
3801
3802           <p>
3803             For example, the <prgn>emacs</prgn> package will contain
3804             <example>
3805               mkdir -p /usr/local/lib/emacs/site-lisp || true
3806             </example>
3807             in the <tt>postinst</tt> script, and
3808             <example>
3809               rmdir /usr/local/lib/emacs/site-lisp || true
3810               rmdir /usr/local/lib/emacs || true
3811             </example>
3812             in the <tt>prerm</tt> script.</p>
3813
3814           <p>
3815             If you do create a directory in <tt>/usr/local</tt> for
3816             local additions to a package, you should ensure that
3817             settings in <tt>/usr/local</tt> take precedence over the
3818             equivalents in <tt>/usr</tt>.</p>
3819
3820           <p>
3821             However, because '/usr/local' and its contents are for
3822             exclusive use of the local administrator, a package must
3823             not rely on the presence or absence of files or
3824             directories in '/usr/local' for normal operation.</p>
3825
3826           <p>
3827             The <tt>/usr/local</tt> directory itself and all the
3828             subdirectories created by the package should (by default) have
3829             permissions 2775 (group-writable and set-group-id) and be
3830             owned by <tt>root.staff</tt>.</p>
3831         </sect1>
3832       </sect>
3833
3834       <sect>
3835         <heading>Users and groups</heading>
3836
3837         <p>
3838           The Debian system can be configured to use either plain or
3839           shadow passwords.</p>
3840
3841         <p>
3842           Some user ids (UIDs) and group ids (GIDs) are reserved
3843           globally for use by certain packages.  Because some packages
3844           need to include files which are owned by these users or
3845           groups, or need the ids compiled into binaries, these ids
3846           must be used on any Debian system only for the purpose for
3847           which they are allocated. This is a serious restriction, and
3848           we should avoid getting in the way of local administration
3849           policies. In particular, many sites allocate users and/or
3850           local system groups starting at 100.</p>
3851
3852         <p>
3853           Apart from this we should have dynamically allocated ids,
3854           which should by default be arranged in some sensible
3855           order--but the behavior should be configurable.</p>
3856
3857         <p>
3858           Packages other than <tt>base-passwd</tt> must not modify
3859           <tt>/etc/passwd</tt>, <tt>/etc/shadow</tt>,
3860           <tt>/etc/group</tt> or <tt>/etc/gshadow</tt>.</p>
3861
3862         <p>
3863           The UID and GID ranges are as follows:
3864           <taglist>
3865             <tag>0-99:</tag>
3866             <item>
3867               <p>
3868                 Globally allocated by the Debian project, the
3869                 same on every Debian system.  These ids will appear in
3870                 the <tt>passwd</tt> and <tt>group</tt> files of all
3871                 Debian systems, new ids in this range being added
3872                 automatically as the <tt>base-passwd</tt> package is
3873                 updated.</p>
3874
3875               <p>
3876                 Packages which need a single statically allocated uid
3877                 or gid should use one of these; their maintainers
3878                 should ask the <tt>base-passwd</tt> maintainer for
3879                 ids.</p>
3880             </item>
3881
3882             <tag>100-999:</tag>
3883             <item>
3884               <p>
3885                 Dynamically allocated system users and groups.
3886                 Packages which need a user or group, but can have this
3887                 user or group allocated dynamically and differently on
3888                 each system, should use `<tt>adduser --system</tt>' to
3889                 create the group and/or user.  <prgn>adduser</prgn>
3890                 will check for the existence of the user or group, and
3891                 if necessary choose an unused id based on the ranges
3892                 specified in <tt>adduser.conf</tt>.</p></item>
3893
3894
3895             <tag>1000-29999:</tag>
3896             <item>
3897               <p>
3898                 Dynamically allocated user accounts.  By default
3899                 <prgn>adduser</prgn> will choose UIDs and GIDs for
3900                 user accounts in this range, though
3901                 <tt>adduser.conf</tt> may be used to modify this
3902                 behavior.</p>
3903             </item>
3904
3905             <tag>30000-59999:</tag>
3906             <item>
3907               <p>Reserved.</p></item>
3908
3909
3910             <tag>60000-64999:</tag>
3911             <item>
3912               <p>
3913                 Globally allocated by the Debian project, but only
3914                 created on demand. The ids are allocated centrally and
3915                 statically, but the actual accounts are only created
3916                 on users' systems on demand.</p>
3917
3918               <p>
3919                 These ids are for packages which are obscure or which
3920                 require many statically-allocated ids.  These packages
3921                 should check for and create the accounts in
3922                 <tt>/etc/passwd</tt> or <tt>/etc/group</tt> (using
3923                 <prgn>adduser</prgn> if it has this facility) if
3924                 necessary.  Packages which are likely to require
3925                 further allocations should have a `hole' left after
3926                 them in the allocation, to give them room to
3927                 grow.</p></item>
3928
3929
3930             <tag>65000-65533:</tag>
3931             <item>
3932               <p>Reserved.</p></item>
3933
3934
3935             <tag>65534:</tag>
3936             <item>
3937               <p>User `<tt>nobody</tt>.' The corresponding gid refers
3938               to the group  `<tt>nogroup</tt>.'</p></item>
3939
3940
3941             <tag>65535:</tag>
3942             <item>
3943               <p>
3944                 <tt>(uid_t)(-1) == (gid_t)(-1)</tt>. NOT TO BE USED,
3945                 because it is the error return sentinel value.</p>
3946             </item>
3947           </taglist>
3948         </p>
3949       </sect>
3950       <sect id="sysvinit">
3951         <heading>System run levels</heading>
3952
3953
3954         <sect1 id="/etc/init.d">
3955           <heading>Introduction</heading>
3956
3957           <p>
3958             The <tt>/etc/init.d</tt> directory contains the scripts
3959             executed by <prgn>init</prgn> at boot time and when init
3960             state (or `runlevel') is changed (see <manref name="init"
3961                                                           section="8">).</p>
3962
3963           <p>
3964             There are at least two different, yet functionally
3965             equivalent, ways of handling these scripts.  For the sake
3966             of simplicity, this document describes only the symbolic
3967             link method. However, it must not be assumed by maintainer
3968             scripts that this method is being used, and any automated
3969             manipulation of the various runlevel behaviours by
3970             maintainer scripts must be performed using `update-rc.d'
3971             as described below and not by manually installing or
3972             removing symlinks.  For  information on the
3973             implementation details of the other method, implemented in
3974             the <tt>file-rc</tt> package, please refer to the
3975             documentation of that package.</p>
3976
3977           <p>
3978             These scripts are referenced by symbolic links in
3979             the <tt>/etc/rc<var>n</var>.d</tt> directories.  When
3980             changing runlevels, <prgn>init</prgn> looks in the
3981             directory <tt>/etc/rc<var>n</var>.d</tt> for the scripts
3982             it should execute, where <var>n</var> is the runlevel that
3983             is being changed to, or `S' for the boot-up scripts.</p>
3984
3985           <p>
3986             The names of the links all have the form
3987             <tt>S<var>mm</var><var>script</var></tt> or
3988             <tt>K<var>mm</var><var>script</var></tt> where
3989             <var>mm</var> is a two-digit number and <var>script</var>
3990             is the name of the script (this should be the same as the
3991             name of the actual script in <tt>/etc/init.d</tt>.</p>
3992
3993           <p>
3994             When <prgn>init</prgn> changes runlevel first the targets
3995             of the links whose names starting with a <tt>K</tt> are
3996             executed, each with the single argument <tt>stop</tt>,
3997             followed by the scripts prefixed with an <tt>S</tt>, each
3998             with the single argument <tt>start</tt>.  The <tt>K</tt>
3999             links are responsible for killing services and the
4000             <tt>S</tt> link for starting services upon entering the
4001             runlevel.</p>
4002
4003           <p>
4004             For example, if we are changing from runlevel 2 to
4005             runlevel 3, init will first execute all of the <tt>K</tt>
4006             prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
4007             all of the <tt>S</tt> prefixed scripts.  The links
4008             starting with <tt>K</tt> will cause the referred-to file
4009             to be executed with an argument of <tt>stop</tt>, and the
4010             <tt>S</tt> links with an argument of <tt>start</tt>.</p>
4011
4012           <p>
4013             The two-digit number <var>mm</var> is used to decide which
4014             order to start and stop things in--low-numbered links have
4015             their scripts run first.  For example, the <tt>K20</tt>
4016             scripts will be executed before the <tt>K30</tt> scripts.
4017             This is used when a certain service must be started before
4018             another.  For example, the name server <prgn>bind</prgn>
4019             might need to be started before the news server
4020             <prgn>inn</prgn> so that <prgn>inn</prgn> can set up its
4021             access lists.  In this case, the script that starts
4022             <prgn>bind</prgn> would have a lower number than the
4023             script that starts <prgn>inn</prgn> so that it runs first:
4024             <example>
4025               /etc/rc2.d/S17bind
4026               /etc/rc2.d/S70inn
4027             </example>
4028           </p>
4029         </sect1>
4030
4031         <sect1>
4032           <heading>Writing the scripts</heading>
4033
4034           <p>
4035             Packages that include daemons for system services should
4036             place scripts in <tt>/etc/init.d</tt> to start or stop
4037             services at boot time or during a change of runlevel.
4038             These scripts should be named
4039             <tt>/etc/init.d/<var>package</var></tt>, and they should
4040             accept one argument, saying what to do:
4041
4042             <taglist>
4043               <tag><tt>start</tt></tag>
4044               <item><p>start the service,</p></item>
4045
4046               <tag><tt>stop</tt></tag>
4047               <item><p>stop the service,</p></item>
4048
4049               <tag><tt>restart</tt></tag>
4050               <item><p>stop and restart the service,</p></item>
4051
4052               <tag><tt>reload</tt></tag>
4053               <item><p>cause the configuration of the service to be
4054                   reloaded without actually stopping and restarting
4055                   the service,</p></item>
4056
4057               <tag><tt>force-reload</tt></tag> <item><p>cause the
4058                   configuration to be reloaded if the service supports
4059                   this, otherwise restart the service.</p></item>
4060             </taglist>
4061
4062             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4063             <tt>force-reload</tt> options should be supported by all
4064             scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
4065             option is optional.</p>
4066
4067           <p>
4068             The <tt>init.d</tt> scripts should ensure that they will
4069             behave sensibly if invoked with <tt>start</tt> when the
4070             service is already running, or with <tt>stop</tt> when it
4071             isn't, and that they don't kill unfortunately-named user
4072             processes.  The best way to achieve this is usually to use
4073             <prgn>start-stop-daemon</prgn>.</p>
4074
4075           <p>
4076             If a service reloads its configuration automatically (as
4077             in the case of <prgn>cron</prgn>, for example), the
4078             <tt>reload</tt> option of the <tt>init.d</tt> script
4079             should behave as if the configuration has been reloaded
4080             successfully.</p>
4081
4082           <p>
4083             These scripts should not fail obscurely when the
4084             configuration files remain but the package has been
4085             removed, as configuration files remain on the system after
4086             the package has been removed. Only when <prgn>dpkg</prgn>
4087             is executed with the <tt>--purge</tt> option will
4088             configuration files be removed. In particular, the init
4089             script itself is usually a configuration file (see
4090             <ref id="init.d notes">), and will remain on the system if
4091             the package is removed but not purged. Therefore, you
4092             should include a <tt>test</tt> statement at the top of the
4093             script, like this:
4094             <example>
4095               test -f <var>program-executed-later-in-script</var> || exit 0
4096             </example></p>
4097
4098           <p>
4099             Often there are some values in the `<tt>init.d</tt>'
4100             scripts that a system administrator will frequently want
4101             to change. While the scripts are frequently conffiles,
4102             modifying them requires that the administrator merge in
4103             their changes each time the package is upgraded and the
4104             conffile changes. To ease the burden on the system
4105             administrator, such configurable values should not be
4106             placed directly in the script.  Instead, they should be
4107             placed in a file in `<tt>/etc/default</tt>', which
4108             typically will have the same base name as the
4109             `<tt>init.d</tt>' script. This extra file can be sourced
4110             by the script when the script runs. It must contain only
4111             variable settings and comments.
4112           </p>
4113
4114           <p>
4115             To ensure that vital configurable values are always
4116             available, the `<tt>init.d</tt>' script should set default
4117             values for each of the shell variables it uses before
4118             sourcing the <tt>/etc/default/</tt> file. Also, since the
4119             `<tt>/etc/default/</tt>' file is often a conffile, the
4120             `<tt>init.d</tt>' script must behave sensibly without
4121             failing if it is deleted.
4122           </p>
4123
4124         </sect1>
4125
4126         <sect1>
4127           <heading>Managing the links</heading>
4128
4129           <p>
4130             The program <prgn>update-rc.d</prgn> is provided to make
4131             it easier for package maintainers to arrange for the
4132             proper creation and removal of
4133             <tt>/etc/rc<var>n</var>.d</tt> symbolic links, or their
4134             functional equivalent if another method is being used.
4135             This may be used by maintainers in their packages'
4136             <tt>postinst</tt> and <tt>postrm</tt> scripts.</p>
4137
4138           <p>
4139             You must use this script to make changes to
4140             <tt>/etc/rc<var>n</var>.d</tt> and <em>never</em> either
4141             include any <tt>/etc/rc<var>n</var>.d</tt> symbolic links
4142             in the actual archive or manually create or remove the
4143             symbolic links in maintainer scripts.  (The latter will
4144             fail if an alternative method of maintaining runlevel
4145             information is being used.)</p>
4146
4147           <p>
4148             By default <prgn>update-rc.d</prgn> will start services in
4149             each of the multi-user state runlevels (2, 3, 4, and 5)
4150             and stop them in the halt runlevel (0), the single-user
4151             runlevel (1) and the reboot runlevel (6).  The system
4152             administrator will have the opportunity to customize
4153             runlevels by either running <prgn>update-rc.d</prgn>, by
4154             simply adding, moving, or removing the symbolic links in
4155             <tt>/etc/rc<var>n</var>.d</tt> if symbolic links are being
4156             used, or by modifying <tt>/etc/runlevel.conf</tt> if the
4157             <tt>file-rc</tt> method is being used.</p>
4158
4159           <p>
4160             To get the default behavior for your package, put in your
4161             <tt>postinst</tt> script
4162             <example>
4163               update-rc.d <var>package</var> defaults &gt;/dev/null
4164             </example>
4165             and in your <tt>postrm</tt>
4166             <example>
4167               if [ purge = "$1" ]; then
4168               update-rc.d <var>package</var> remove &gt;/dev/null
4169               fi
4170             </example></p>
4171
4172           <p>
4173             This will use a default sequence number of 20.  If it does
4174             not matter when or in which order the script is run, use
4175             this default.  If it does, then you should talk to the
4176             maintainer of the <prgn>sysvinit</prgn> package or post to
4177             <tt>debian-devel</tt>, and they will help you choose a
4178             number.</p>
4179
4180           <p>
4181             For more information about using <tt>update-rc.d</tt>,
4182             please consult its manpage <manref name="update-rc.d"
4183                                                section="8">.</p></sect1>
4184
4185
4186         <sect1>
4187           <heading>Boot-time initialization</heading>
4188
4189           <p>
4190             There used to be another directory, <tt>/etc/rc.boot</tt>,
4191             which contained scripts which were run once per machine
4192             boot. This has been deprecated in favour of links from
4193             <tt>/etc/rcS.d</tt> to files in <tt>/etc/init.d</tt> as
4194             described in <ref id="/etc/init.d">.  Packages must not
4195             place files in <tt>/etc/rc.boot</tt>.</p>
4196
4197         <sect1 id="init.d notes">
4198           <heading>Notes</heading>
4199
4200           <p>
4201             <em>Do not</em> include the
4202             <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in the
4203             <tt>.deb</tt> file system archive!  <em>This will cause
4204               problems!</em> You must create them with
4205             <prgn>update-rc.d</prgn>, as above.</p>
4206
4207           <p>
4208             <em>Do not</em> include the
4209             <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in
4210             <prgn>dpkg</prgn>'s conffiles list!  <em>This will cause
4211               problems!</em> You should, however, treat the
4212             <tt>/etc/init.d</tt> scripts as configuration files,
4213             either by marking them as conffiles or managing them
4214             correctly in the maintainer scripts (see
4215             <ref id="config files">). (This is important since we want
4216             to give the local system administrator the chance to adapt
4217             the scripts to the local system--e.g., to disable a
4218             service without de-installing the package, or to specify
4219             some special command line options when starting a
4220             service--while making sure her changes aren't lost during
4221             the next package upgrade.)</p>
4222         </sect1>
4223
4224         <sect1>
4225           <heading>Example</heading>
4226
4227           <p>
4228             The <prgn>bind</prgn> DNS (nameserver) package wants to
4229             make sure that the nameserver is running in multiuser
4230             runlevels, and is properly shut down with the system.  It
4231             puts a script in <tt>/etc/init.d</tt>, naming the script
4232             appropriately <tt>bind</tt>.  As you can see, the script
4233             interprets the argument <tt>reload</tt> to send the
4234             nameserver a <tt>HUP</tt> signal (causing it to reload its
4235             configuration); this way the user can say
4236             <tt>/etc/init.d/bind reload</tt> to reload the name
4237             server.  The script has one configurable value, which can
4238             be used to pass parameters to the named program at
4239             startup.
4240           </p>
4241
4242           <p>
4243             <example>
4244               #!/bin/sh
4245               #
4246               # Original version by Robert Leslie
4247               # &lt;rob@mars.org&gt;, edited by iwj and cs
4248
4249               test -x /usr/sbin/named || exit 0
4250
4251               # Source defaults file.
4252               PARAMS=''
4253               if [ -f /etc/default/bind ]; then
4254                 . /etc/default/bind
4255               fi
4256
4257
4258               case "$1" in
4259               start)
4260               echo -n "Starting domain name service: named"
4261               start-stop-daemon --start --quiet --exec /usr/sbin/named \
4262                                 -- $PARAMS
4263               echo "."
4264               ;;
4265               stop)
4266               echo -n "Stopping domain name service: named"
4267               start-stop-daemon --stop --quiet  \
4268               --pidfile /var/run/named.pid --exec /usr/sbin/named
4269               echo "."
4270               ;;
4271               restart)
4272               echo -n "Restarting domain name service: named"
4273               start-stop-daemon --stop --quiet  \
4274               --pidfile /var/run/named.pid --exec /usr/sbin/named
4275               start-stop-daemon --start --verbose --exec /usr/sbin/named \
4276                                 -- $PARAMS
4277               echo "."
4278               ;;
4279               force-reload|reload)
4280               echo -n "Reloading configuration of domain name service: named"
4281               start-stop-daemon --stop --signal 1 --quiet  \
4282               --pidfile /var/run/named.pid --exec /usr/sbin/named
4283               echo "."
4284               ;;
4285               *)
4286               echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
4287               exit 1
4288               ;;
4289               esac
4290
4291               exit 0
4292             </example>
4293           </p>
4294
4295           <p>
4296             Complementing the above init script is a file
4297             '<tt>/etc/default/bind</tt>', which contains configurable
4298             parameters used by the script.
4299           </p>
4300           <p>
4301             <example>
4302               # Specified parameters to pass to named. See named(8).
4303               # You may uncomment the following line, and edit to taste.
4304               #PARAMS="-u nobody"
4305             </example>
4306           </p>
4307
4308           <p>
4309             Another example on which to base your <tt>/etc/init.d</tt>
4310             scripts is in <tt>/etc/init.d/skeleton</tt>.</p>
4311
4312           <p>
4313             If this package is happy with the default setup from
4314             <prgn>update-rc.d</prgn>, namely an ordering number of 20
4315             and having named running in all runlevels, it can say in
4316             its <tt>postinst</tt>:
4317             <example>
4318               update-rc.d bind defaults >/dev/null
4319             </example>
4320             And in its <tt>postrm</tt>, to remove the links when the
4321             package is purged:
4322             <example>
4323               if [ purge = "$1" ]; then
4324               update-rc.d bind remove >/dev/null
4325               fi
4326             </example></p>
4327         </sect1></sect>
4328
4329       <sect>
4330         <heading>Cron jobs</heading>
4331
4332         <p>
4333           Packages must not modify the configuration file
4334           <tt>/etc/crontab</tt>, and they must not modify the files in
4335           <tt>/var/spool/cron/crontabs</tt>.</p>
4336
4337         <p>
4338           If a package wants to install a job that has to be executed
4339           via cron, it should place a file with the name of the
4340           package in one of the following directories:
4341           <example>
4342             /etc/cron.daily
4343             /etc/cron.weekly
4344             /etc/cron.monthly
4345           </example>
4346           As these directory names imply, the files within them are
4347           executed on a daily, weekly, or monthly basis,
4348           respectively. The exact times are listed in
4349           <tt>/etc/crontab</tt>.</p>
4350
4351         <p>
4352           All files installed in any of these directories must be
4353           scripts (shell scripts, Perl scripts, etc.) so that they can
4354           easily be modified by the local system administrator. In
4355           addition, they should be treated as configuration files.</p>
4356
4357         <p>
4358           If a certain job has to be executed more frequently than
4359           daily, the package should install a file
4360           <tt>/etc/cron.d/<var>package-name</var></tt>. This file uses
4361           the same syntax as <tt>/etc/crontab</tt> and is processed by
4362           <prgn>cron</prgn> automatically. The file must also be
4363           treated as a configuration file. (Note, that entries in the
4364           <tt>/etc/cron.d</tt> directory are not handled by
4365           <prgn>anacron</prgn>. Thus, you should only use this
4366           directory for jobs which may be skipped if the system is not
4367           running.)</p>
4368
4369         <p>
4370           The scripts or crontab entries in these directories should
4371           check if all necessary programs are installed before they
4372           try to execute them. Otherwise, problems will arise when a
4373           package was removed but not purged since configuration files
4374           are kept on the system in this situation.</p>
4375       </sect>
4376
4377       <sect>
4378         <heading>Console messages</heading>
4379
4380         <p>
4381           This section describes different formats for messages
4382           written to standard output by the <tt>/etc/init.d</tt>
4383           scripts. The intent is to improve the consistency of
4384           Debian's startup and shutdown look and feel.</p>
4385
4386         <p>
4387           Please look very careful at the details. We want to get the
4388           messages to look exactly the same way concerning spaces,
4389           punctuation, and case of letters.</p>
4390
4391         <p>
4392           Here is a list of overall rules that you should use when you
4393           create output messages. They can be useful if you have a
4394           non-standard message that isn't covered in the sections
4395           below.</p>
4396
4397         <p>
4398           <list>
4399             <item>
4400               <p>
4401                 Every message should cover one line, start with a
4402                 capital letter and end with a period `.'.</p></item>
4403
4404
4405             <item>
4406               <p>
4407                 If you want to express that the computer is working on
4408                 something (performing a specific task, not starting or
4409                 stopping a program), we use an ``ellipsis'', namely
4410                 three dots `...'. Note that we don't insert spaces in
4411                 front of or behind the dots.  If the task has been
4412                 completed we write `done.' and a line feed.</p></item>
4413
4414
4415             <item>
4416               <p>
4417                 Design your messages as if the computer is telling you
4418                 what he is doing (let him be polite :-) but don't
4419                 mention ``him'' directly.  For example, if you think
4420                 of saying
4421                 <example>
4422                   I'm starting network daemons: nfsd mountd.
4423                 </example>
4424                 just say
4425                 <example>
4426                   Starting network daemons: nfsd mountd.
4427                 </example></p></item>
4428           </list></p>
4429
4430         <p>
4431           The following formats should be used</p>
4432
4433         <p>
4434           <list>
4435             <item>
4436               <p>when daemons get started.</p>
4437
4438               <p>
4439                 Use this format if your script starts one or more
4440                 daemons.  The output should look like this (a single
4441                 line, no leading spaces):
4442                 <example>
4443                   Starting &lt;description&gt;: &lt;daemon-1&gt; &lt;daemon-2&gt; &lt;...&gt; &lt;daemon-n&gt;.
4444                 </example>
4445                 The &lt;description&gt; should describe the subsystem
4446                 the daemon or set of daemons are part of, while
4447                 &lt;daemon-1&gt; up to &lt;daemon-n&gt; denote each
4448                 daemon's name (typically the file name of the
4449                 program).</p>
4450
4451               <p>
4452                 For example, the output of /etc/init.d/lpd would look like:
4453                 <example>
4454                   Starting printer spooler: lpd.
4455                 </example></p>
4456
4457               <p>
4458                 This can be achieved by saying
4459                 <example>
4460                   echo -n "Starting printer spooler: lpd"
4461                   start-stop-daemon --start --quiet lpd
4462                   echo "."
4463                 </example>
4464                 in the script. If you have more than one daemon to
4465                 start, you should do the following:
4466                 <example>
4467                   echo -n "Starting remote file system services:"
4468                   echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
4469                   echo -n " mountd"; start-stop-daemon --start --quiet mountd
4470                   echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
4471                   echo "."
4472                 </example>
4473                 This makes it possible for the user to see what takes
4474                 so long and when the final daemon has been
4475                 started. You should be careful where to put spaces: In the
4476                 example above the system administrator can easily
4477                 comment out a line if he don't wants to start a
4478                 specific daemon, while the displayed message still
4479                 looks good.</p></item>
4480
4481
4482             <item>
4483               <p>when something needs to be configured.</p>
4484
4485               <p>
4486                 If you have to set up different parameters of the
4487                 system upon boot up, you should use this format:
4488                 <example>
4489                   Setting &lt;parameter&gt; to `&lt;value&gt;'.
4490                 </example></p>
4491
4492               <p>
4493                 You can use the following echo statement to get the quotes right:
4494                 <example>
4495                   echo "Setting DNS domainname to \`"value"'."
4496                 </example></p>
4497
4498               <p>
4499                 Note that the left quotation mark (`) is different
4500                 from the right (').</p></item>
4501
4502             <item>
4503               <p>when a daemon is stopped.</p>
4504
4505               <p>
4506                 When you stop a daemon you should issue a message
4507                 similar to the startup message, except that `Starting'
4508                 is replaced with `Stopping'.</p>
4509
4510               <p>
4511                 So stopping the printer daemon will like like this:
4512                 <example>
4513                   Stopping printer spooler: lpd.
4514                 </example></p></item>
4515
4516             <item>
4517               <p>when something is executed.</p>
4518
4519               <p>
4520                 There are several examples where you have to run a
4521                 program at system startup or shutdown to perform a
4522                 specific task. For example, setting the system's clock
4523                 via `netdate' or killing all processes when the system
4524                 comes down. Your message should like this:
4525                 <example>
4526                   Doing something very useful...done.
4527                 </example>
4528                 You should print the `done.' right after the job has been completed,
4529                 so that the user gets informed why he has to wait. You can get this
4530                 behavior by saying
4531                 <example>
4532                   echo -n "Doing something very useful..."
4533                   do_something
4534                   echo "done."
4535                 </example>
4536                 in your script.</p></item>
4537
4538             <item>
4539               <p>when the configuration is reloaded.</p>
4540
4541               <p>
4542                 When a daemon is forced to reload its configuration
4543                 files you should use the following format:
4544                 <example>
4545                   Reloading &lt;daemon's-name&gt; configuration...done.
4546                 </example></p></item>
4547
4548             <item>
4549               <p>when none of the above rules apply.</p>
4550
4551               <p>
4552                 If you have to print a message that doesn't fit into
4553                 the styles described above, you can use something
4554                 appropriate, but please have a look at the overall
4555                 rules listed above.</p></item>
4556           </list></p></sect>
4557
4558
4559       <sect>
4560         <heading>Menus</heading>
4561
4562         <p>
4563           Menu entries should follow the current menu policy as
4564           defined in the file <ftpsite>ftp.debian.org</ftpsite> in
4565           <ftppath>/debian/doc/package-developer/menu-policy.text.gz</ftppath>
4566           or your local mirror. In addition, it is included in the
4567           <tt>debian-policy</tt> package.
4568         </p>
4569
4570         <p>
4571           The Debian <tt>menu</tt> packages provides a unique
4572           interface between packages providing applications and
4573           documents, and <em>menu programs</em> (either X window
4574           managers or text-based menu programs as
4575           <prgn>pdmenu</prgn>).</p>
4576
4577         <p>
4578           All packages that provide applications that need not be
4579           passed any special command line arguments for normal
4580           operation should register a menu entry for those
4581           applications, so that users of the <tt>menu</tt> package
4582           will automatically get menu entries in their window
4583           managers, as well in shells like <tt>pdmenu</tt>.</p>
4584
4585         <p>
4586           Please refer to the <em>Debian Menu System</em> document
4587           that comes with the <tt>menu</tt> package for information
4588           about how to register your applications and web
4589           documents.</p>
4590       </sect>
4591
4592
4593       <sect>
4594         <heading>Multimedia handlers</heading>
4595
4596         <p>
4597           Packages which provide the ability to view/show/play,
4598           compose, edit or print MIME types should register themselves
4599           as such following the current MIME support policy as defined
4600           in the file found on <ftpsite>ftp.debian.org</ftpsite> in
4601           <ftppath>/debian/doc/package-developer/mime-policy.text.gz</ftppath>
4602           or your local mirror. In addition, it is included in the
4603           <tt>debian-policy</tt> package.
4604         </p>
4605
4606         <p>
4607           MIME (Multipurpose Internet Mail Extensions, RFC 1521) is a
4608           mechanism for encoding files and data streams and providing
4609           meta-information about them, in particular their type (e.g.
4610           audio or video) and format (e.g. PNG, HTML, MP3).
4611         </p>
4612
4613         <p>
4614           Registration of MIME type handlers allows programs like mail
4615           user agents and web browsers to to invoke these handlers to
4616           view, edit or display MIME types they don't support
4617           directly.
4618         </p>
4619       </sect>
4620
4621       <sect>
4622         <heading>Keyboard configuration</heading>
4623
4624         <p>
4625           To achieve a consistent keyboard configuration (i.e., all
4626           applications interpret a keyboard event the same way) all
4627           programs in the Debian distribution must be configured to
4628           comply with the following guidelines.</p>
4629
4630         <p>
4631           Here is a list that contains certain keys and their interpretation:
4632
4633           <taglist>
4634             <tag><tt>&lt;--</tt></tag>
4635             <item><p>delete the character to the left of the cursor</p></item>
4636
4637             <tag><tt>Delete</tt></tag>
4638             <item><p>delete the character to the right of the cursor</p></item>
4639
4640             <tag><tt>Control+H</tt></tag>
4641             <item><p>emacs: the help prefix</p></item>
4642           </taglist>
4643
4644           The interpretation of any keyboard events should be independent
4645           of the terminal that's used, be it a virtual console, an X
4646           terminal emulator, an rlogin/telnet session, etc.</p>
4647
4648         <p>
4649           The following list explains how the different programs
4650           should be set up to achieve this:</p>
4651
4652         <p>
4653           <list compact="compact">
4654             <item><p>`<tt>&lt;--</tt>' generates KB_Backspace in
4655                 X.</p></item>
4656
4657             <item><p>`<tt>Delete</tt>' generates KB_Delete in X.</p></item>
4658
4659             <item>
4660               <p>
4661                 X translations are set up to make KB_Backspace
4662                 generate ASCII DEL, and to make KB_Delete generate
4663                 <tt>ESC [ 3 ~</tt> (this is the vt220 escape code for
4664                 the `delete character' key).  This must be done by
4665                 loading the resources using xrdb on all local X
4666                 displays, not using the application defaults, so that
4667                 the translation resources used correspond to the
4668                 xmodmap settings.</p></item>
4669
4670             <item>
4671               <p>
4672                 The Linux console is configured to make
4673                 `<tt>&lt;--</tt>' generate DEL, and `Delete' generate
4674                 <tt>ESC [ 3 ~</tt> (this is the case at the
4675                 moment).</p></item>
4676
4677             <item><p>
4678                 X applications are configured so that Backspace
4679                 deletes left, and Delete deletes right.  Motif
4680                 applications already work like this.</p></item>
4681
4682             <item><p>stty erase <tt>^?</tt> .</p></item>
4683
4684             <item><p>
4685                 The `xterm' terminfo entry should have <tt>ESC [ 3
4686                   ~</tt> for kdch1, just like TERM=linux and
4687                 TERM=vt220.</p></item>
4688
4689             <item><p>
4690                 Emacs is programmed to map KB_Backspace or the `stty
4691                 erase' character to delete-backward-char, and
4692                 KB_Delete or kdch1 to delete-forward-char, and
4693                 <tt>^H</tt> to help as always.</p></item>
4694
4695             <item><p>
4696                 Other applications use the `stty erase' character and
4697                 kdch1 for the two delete keys, with ASCII DEL being
4698                 `delete previous character' and kdch1 being `delete
4699                 character under cursor'.</p></item>
4700           </list></p>
4701
4702         <p>
4703           This will solve the problem except for:</p>
4704
4705         <p>
4706           <list compact="compact">
4707             <item><p>
4708                 Some terminals have a <tt>&lt;--</tt> key that cannot
4709                 be made to produce anything except <tt>^H</tt>.  On
4710                 these terminals Emacs help will be unavailable on
4711                 <tt>^H</tt> (assuming that the `stty erase' character
4712                 takes precedence in Emacs, and has been set
4713                 correctly).  M-x help or F1 (if available) can be used
4714                 instead.</p></item>
4715
4716             <item><p>
4717                 Some operating systems use <tt>^H</tt> for stty erase.
4718                 However, modern telnet versions and all rlogin
4719                 versions propagate stty settings, and almost all UNIX
4720                 versions honour stty erase.  Where the stty settings
4721                 are not propagated correctly things can be made to
4722                 work by using stty manually.</p></item>
4723
4724             <item><p>
4725                 Some systems (including previous Debian versions) use
4726                 xmodmap to arrange for both <tt>&lt;--</tt> and Delete
4727                 to generate KB_Delete.  We can change the behavior
4728                 of their X clients via the same X resources that we
4729                 use to do it for our own, or have our clients be
4730                 configured via their resources when things are the
4731                 other way around.  On displays configured like this
4732                 Delete will not work, but <tt>&lt;--</tt>
4733                 will.</p></item>
4734
4735             <item><p>
4736                 Some operating systems have different kdch1 settings
4737                 in their terminfo for xterm and others.  On these
4738                 systems the Delete key will not work correctly when
4739                 you log in from a system conforming to our policy, but
4740                 <tt>&lt;--</tt> will.</p></item>
4741           </list>
4742         </p>
4743       </sect>
4744
4745
4746       <sect>
4747         <heading>Environment variables</heading>
4748
4749         <p>
4750           A program must not depend on environment variables to get
4751           reasonable defaults. (That's because these environment
4752           variables would have to be set in a system-wide
4753           configuration file like /etc/profile, which is not supported
4754           by all shells.)</p>
4755
4756         <p>
4757           If a program usually depends on environment variables for its
4758           configuration, the program should be changed to fall back to
4759           a reasonable default configuration if these environment
4760           variables are not present. If this cannot be done easily
4761           (e.g., if the source code of a non-free program is not
4762           available), the program must be replaced by a small
4763           `wrapper' shell script which sets the environment variables
4764           if they are not already defined, and calls the original program.</p>
4765
4766         <p>
4767           Here is an example of a wrapper script for this purpose:
4768
4769           <example>
4770             #!/bin/sh
4771             BAR=${BAR:-/var/lib/fubar}
4772             export BAR
4773             exec /usr/lib/foo/foo "$@"
4774           </example></p>
4775
4776         <p>
4777           Furthermore, as <tt>/etc/profile</tt> is a configuration
4778           file of the <prgn>base-files</prgn> package, other packages must not
4779           put any environment variables or other commands into that
4780           file.</p>
4781       </sect>
4782     </chapt>
4783     <chapt>
4784       <heading>Files</heading>
4785
4786
4787       <sect>
4788         <heading>Binaries</heading>
4789
4790         <p>
4791           Two different packages must not install programs with
4792           different functionality but with the same filenames. (The
4793           case of two programs having the same functionality but
4794           different implementations is handled via `alternatives.')
4795           If this case happens, one of the programs must be
4796           renamed. The maintainers should report this to the
4797           developers' mailing and try to find a consensus about
4798           which package will have to be renamed.  If a consensus can
4799           not be reached, <em>both</em> programs must be
4800           renamed.</p>
4801
4802         <p>
4803           Generally the following compilation parameters should be used:
4804           <example>
4805             CC = gcc
4806             CFLAGS = -O2 -Wall # sane warning options vary between programs
4807             LDFLAGS = # none
4808             install -s # (or use strip on the files in debian/tmp)
4809           </example></p>
4810
4811         <p>
4812           Note that by default all installed binaries should be stripped,
4813           either by using the <tt>-s</tt> flag to
4814           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
4815           the binaries after they have been copied into
4816           <tt>debian/tmp</tt> but before the tree is made into a
4817           package.</p>
4818
4819         <p>
4820           The <tt>-N</tt> flag should not be used.  On a.out systems
4821           it may have been useful for some very small binaries, but
4822           for ELF it has no good effect.</p>
4823
4824         <p>
4825           Debugging symbols are useful for error diagnosis,
4826           investigation of core dumps (which may be submitted by users
4827           in bug reports), or testing and developing the
4828           software. Therefore it is recommended to support building
4829           the package with debugging information through the following
4830           interface: If the environment variable
4831           <tt>DEB_BUILD_OPTIONS</tt> contains the string
4832           <tt>debug</tt>, compile the software with debugging
4833           information (usually this involves adding the <tt>-g</tt>
4834           flag to <tt>CFLAGS</tt>). This allows the generation of a
4835           build tree with debugging information. If the environment
4836           variable <tt>DEB_BUILD_OPTIONS</tt> contains the string
4837           <tt>nostrip</tt>, do not strip the files at installation
4838           time. This allows one to generate a package with debugging
4839           information included. The following makefile snippet is only
4840           an example of how one may test for either condition:
4841           <footnote>
4842             <p>
4843               Rationale: Building by default with -g causes more
4844               wasted CPU cycles since the information is stripped away
4845               anyway. The package can by default build without -g if
4846               it also provides a mechanism to easily be rebuilt with
4847               debugging information. This can be done by providing a
4848               "build-debug" make target, or allowing the user to
4849               specify "DEB_BUILD_OPTIONS=debug" in the environment while
4850               compiling that package.
4851             </p>
4852             <p>Now this has several added benefits:
4853               <list>
4854                 <item>
4855                   <p>
4856                     It is actually easier to build debugging bins and
4857                     libraries this way (no more editing debian/rules
4858                     or similar) since it provides a documented way of
4859                     getting this type of build.</p>
4860                 </item>
4861                 <item>
4862                   <p>
4863                     There will be much less wasted CPU time for the
4864                     autobuilders since not having debugging
4865                     information (and hence also not having to strip
4866                     it) will increase the speed of compiles. This
4867                     skips an entire pass of the compiler.
4868                   </p>
4869                 </item>
4870               </list>
4871             </p>
4872           </footnote>
4873
4874
4875           <example>
4876             CFLAGS = -O2 -Wall
4877             INSTALL = install
4878             INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
4879             INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
4880             INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
4881             INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
4882
4883             ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
4884             CFLAGS += -g
4885             endif
4886             ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
4887             INSTALL_PROGRAM += -s
4888             endif
4889           </example>
4890
4891           Please note that the above example is merely informative,
4892           and is not a policy mandate. You may have to massage this
4893           example in order to make it work for your package.
4894
4895         </p>
4896
4897         <p>
4898           It is up to the package maintainer to decide what
4899           compilation options are best for the package.  Certain
4900           binaries (such as computationally-intensive programs) will
4901           function better with certain flags (<tt>-O3</tt>, for
4902           example); feel free to use them.  Please use good judgment
4903           here.  Don't use flags for the sake of it; only use them
4904           if there is good reason to do so.  Feel free to override
4905           the upstream author's ideas about which compilation
4906           options are best--they are often inappropriate for our
4907           environment.</p></sect>
4908
4909
4910       <sect>
4911         <heading>Libraries</heading>
4912
4913         <p>
4914           All libraries must have a shared version in the lib
4915           package and a static version in the lib-dev package. The
4916           shared version must be compiled with <tt>-fPIC</tt>, and
4917           the static version must not be. In other words, each
4918           <tt>*.c</tt> file will need to be compiled twice.</p>
4919
4920         <p>
4921           You must specify the gcc option <tt>-D_REENTRANT</tt>
4922           when building a library (either static or shared) to make
4923           the library compatible with LinuxThreads.</p>
4924
4925         <p>
4926           Note that all installed shared libraries should be
4927           stripped with
4928           <example>
4929             strip --strip-unneeded &lt;your-lib&gt;
4930           </example>
4931           (The option `--strip-unneeded' makes <tt>strip</tt> remove
4932           only the symbols which aren't needed for relocation
4933           processing.)  Shared libraries can function perfectly well
4934           when stripped, since the symbols for dynamic linking are
4935           in a separate part of the ELF object file.</p>
4936
4937         <p>
4938           Note that under some circumstances it may be useful to
4939           install a shared library unstripped, for example when
4940           building a separate package to support debugging.
4941         </p>
4942
4943         <p>
4944           An ever increasing number of packages are using libtool to
4945           do their linking. The latest GNU libtools (>= 1.3a) can take
4946           advantage of the metadata in the installed libtool archive
4947           files (`*.la'). The main advantage of libtool's .la files is
4948           that it allows libtool to store and subsequently access
4949           metadata with respect to the libraries it builds.  libtool
4950           will search for those files, which contain a lot of useful
4951           information about a library (e.g. dependency libraries for
4952           static linking). Also, they're <em>essential</em> for
4953           programs using libltdl.
4954         </p>
4955
4956         <p>
4957           Certainly libtool is fully capable of linking against shared
4958           libraries which don't have .la files, but being a mere shell
4959           script it can add considerably to the build time of a
4960           libtool using package if that shell-script has to derive all
4961           this information from first principles for each library every
4962           time it is linked. With the advent of libtool-1.4 (and to a
4963           lesser extent libtool-1.3), the .la files will also store
4964           information about inter-library dependencies which cannot
4965           necessarily be derived after the .la file is deleted.
4966         </p>
4967
4968         <p>
4969           Packages that use libtool to create shared libraries should
4970           include the <em>.la</em> files in the <em>-dev</em>
4971           packages, with the exception that if the package relies on
4972           libtool's <em>libltdl</em> library, in which case the .la
4973           files must go in the run-time library package.  This is a
4974           good idea in general, and especially for static linking
4975           issues.
4976         </p>
4977
4978         <p>
4979           You must make sure that you use only released versions of
4980           shared libraries to build your packages; otherwise other
4981           users will not be able to run your binaries
4982           properly. Producing source packages that depend on
4983           unreleased compilers is also usually a bad
4984           idea.
4985         </p>
4986       </sect>
4987
4988
4989       <sect>
4990         <heading>Shared libraries</heading>
4991
4992         <p>
4993           Packages involving shared libraries should be split up
4994           into several binary packages.</p>
4995
4996         <p>
4997           For a straightforward library which has a development
4998           environment and a runtime kit including just shared
4999           libraries you need to create two packages:
5000           <tt><var>libraryname</var><var>soname</var></tt>
5001           (<var>soname</var> is the shared object name of the shared
5002           library--it's the thing that has to match exactly between
5003           building an executable and running it for the dynamic
5004           linker to be able run the program; usually the
5005           <var>soname</var> is the major number of the library) and
5006           <tt><var>libraryname</var><var>soname</var>-dev</tt>.</p>
5007
5008         <p>
5009           If you prefer only to support one development version at a
5010           time you may name the development package
5011           <tt><var>libraryname</var>-dev</tt>; otherwise you may
5012           wish to use <prgn>dpkg</prgn>'s conflicts mechanism to
5013           ensure that the user only installs one development version
5014           at a time (after all, different development versions are
5015           likely to have the same header files in them, causing a
5016           filename clash if both are installed).  Typically the
5017           development version should  also have an exact version
5018           dependency on the runtime library, to make sure that
5019           compilation and linking happens correctly.</p>
5020
5021         <p>
5022           Packages which use the shared library should have a
5023           dependency on the name of the shared library package,
5024           <tt><var>libraryname</var><var>soname</var></tt>.  When
5025           the <var>soname</var> changes you can have both versions
5026           of the library installed while moving from the old library
5027           to the new.</p>
5028
5029         <p>
5030           If your package has some run-time support programs which
5031           use the shared library you must not put them in
5032           the shared library package.  If you do that then you won't
5033           be able to install several versions of the shared library
5034           without getting filename clashes.  Instead, either create
5035           a third package for the runtime binaries (this package
5036           might typically be named
5037           <tt><var>libraryname</var>-runtime</tt>--note the absence
5038           of the <var>soname</var> in the package name) or if the
5039           development package is small include them in there.</p>
5040
5041         <p>
5042           If you have several shared libraries built from the same
5043           source tree you may lump them all together into a single
5044           shared library package, provided that you change all their
5045           <var>soname</var>s at once (so that you don't get filename
5046           clashes if you try to install different versions of the
5047           combined shared libraries package).</p>
5048
5049         <p>
5050           You should follow the directions in the <em>Debian Packaging
5051             Manual</em> for putting the shared library in its package,
5052           and you must include a <tt>shlibs</tt> control area
5053           file with details of the dependencies for packages which
5054           use the library.</p>
5055
5056         <p>
5057           Shared libraries should not be installed
5058           executable, since <prgn>ld.so</prgn> does not require this
5059           and trying to execute a shared library results in a core
5060           dump.</p></sect>
5061
5062
5063       <sect id="scripts">
5064         <heading>Scripts</heading>
5065
5066         <p>
5067           All command scripts, including the package maintainer
5068           scripts inside the package and used by <prgn>dpkg</prgn>,
5069           should have a <tt>#!</tt> line naming the shell to be used
5070           to interpret them.</p>
5071
5072         <p>
5073           In the case of Perl scripts this should be
5074           <tt>#!/usr/bin/perl</tt>.</p>
5075
5076         <p>
5077           Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5078           should almost certainly start with <tt>set -e</tt> so that
5079           errors are detected.  Every script should use
5080           <tt>set -e</tt> or check the exit status of <em>every</em>
5081           command.</p>
5082
5083         <p>
5084           The standard shell interpreter `<tt>/bin/sh</tt>' can be a
5085           symbolic link to any POSIX compatible shell, if <tt>echo
5086             -n</tt> does not generate a newline.
5087           <footnote>
5088             <p>
5089               Debian policy specifies POSIX behavior for /bin/sh, but
5090               echo -n has widespread use in the Linux community
5091               (including especially debian policy, the linux kernel
5092               source, many debian scripts, etc.).  This echo -n
5093               mechanism is valid but not required under POSIX, hence
5094               this explicit addition. Also, rumour has it that this
5095               shall be mandated under the LSB anyway.
5096             </p>
5097           </footnote>
5098           Thus, shell scripts
5099           specifying `<tt>/bin/sh</tt>' as interpreter should only
5100           use POSIX features. If a script requires non-POSIX
5101           features from the shell interpreter, the appropriate shell
5102           must be specified in the first line of the script (e.g.,
5103           `<tt>#!/bin/bash</tt>') and the package must depend on the
5104           package providing the shell (unless the shell package is
5105           marked `Essential', e.g., in the case of
5106           <prgn>bash</prgn>).
5107         </p>
5108
5109         <p>
5110           You may wish to restrict your script to POSIX features when possible so
5111           that it may use <tt>/bin/sh</tt> as its interpreter. If
5112           your script works with <prgn>ash</prgn>, it's probably
5113           POSIX compliant, but if you are in doubt, use
5114           <tt>/bin/bash</tt>.</p>
5115
5116         <p>
5117           Perl scripts should check for errors when making any
5118           system calls, including <tt>open</tt>, <tt>print</tt>,
5119           <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.</p>
5120
5121         <p>
5122           <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided
5123           as scripting languages.  See <em>Csh Programming
5124             Considered Harmful</em>, one of the <tt>comp.unix.*</tt>
5125           FAQs.  It can be found on
5126           <url id="http://language.perl.com/versus/csh.whynot">, or
5127           <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5128           or even on <ftpsite>ftp.cpan.org</ftpsite>
5129           <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5130           If an upstream package comes with <prgn>csh</prgn> scripts
5131           then you must make sure that they start with
5132           <tt>#!/bin/csh</tt> and make your package depend on the
5133           <prgn>c-shell</prgn> virtual package.</p>
5134
5135         <p>
5136           Any scripts which create files in world-writeable
5137           directories (e.g., in <tt>/tmp</tt>) must use a
5138           mechanism which will fail if a file with the same name
5139           already exists.</p>
5140
5141         <p>
5142           The Debian base distribution provides the
5143           <prgn>tempfile</prgn> and <prgn>mktemp</prgn> utilities
5144           for use by scripts for this purpose.</p></sect>
5145
5146
5147       <sect>
5148         <heading>Symbolic links</heading>
5149
5150         <p>
5151           In general, symbolic links within a top-level directory
5152           should be relative, and symbolic links pointing from one
5153           top-level directory into another should be absolute. (A
5154           top-level directory is a sub-directory of the root
5155           directory `/'.)</p>
5156
5157         <p>
5158           In addition, symbolic links should be specified as short
5159           as possible, i.e., link targets like `foo/../bar' are
5160           deprecated.</p>
5161
5162         <p>
5163           Note that when creating a relative link using
5164           <prgn>ln</prgn> it is not necessary for the target of the
5165           link to exist relative to the working directory you're
5166           running <prgn>ln</prgn> from; nor is it necessary to
5167           change directory to the directory where the link is to be
5168           made.  Simply include the string that should appear as the
5169           target of the link (this will be a pathname relative to
5170           the directory in which the link resides) as the first
5171           argument to <prgn>ln</prgn>.</p>
5172
5173         <p>
5174           For example, in your <prgn>Makefile</prgn> or
5175           <tt>debian/rules</tt>, do things like:
5176           <example>
5177             ln -fs gcc $(prefix)/bin/cc
5178             ln -fs gcc debian/tmp/usr/bin/cc
5179             ln -fs ../sbin/sendmail $(prefix)/bin/runq
5180             ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5181           </example></p>
5182
5183         <p>
5184           A symbolic link pointing to a compressed file should
5185           always have the same file extension as the referenced
5186           file. (For example, if a file `<tt>foo.gz</tt>' is
5187           referenced by a symbolic link, the filename of the link
5188           has to end with `<tt>.gz</tt>' too, as in
5189           `bar.gz.')</p></sect>
5190
5191
5192       <sect>
5193         <heading>Device files</heading>
5194
5195         <p>
5196           Packages must not include device files in the package file
5197           tree.</p>
5198
5199         <p>
5200           If a package needs any special device files that are not
5201           included in the base system, it must call
5202           <prgn>MAKEDEV</prgn> in the <tt>postinst</tt> script,
5203           after asking the user for permission to do so.</p>
5204
5205         <p>
5206           Packages must not remove any device files in the
5207           <tt>postrm</tt> or any other script. This is left to the
5208           system administrator.</p>
5209
5210         <p>
5211           Debian uses the serial devices
5212           <tt>/dev/ttyS*</tt>. Programs using the old
5213           <tt>/dev/cu*</tt> devices should be changed to use
5214           <tt>/dev/ttyS*</tt>.</p>
5215       </sect>
5216
5217       <sect id="config files">
5218         <heading>Configuration files</heading>
5219         <sect1>
5220           <heading>Definitions</heading>
5221           <p>
5222             <taglist>
5223               <tag>configuration file</tag>
5224               <item><p>
5225                   A file that affects the operation of program, or
5226                   provides site- or host-specific information, or
5227                   otherwise customizes the behavior of program.
5228                   Typically, configuration files are intended to be
5229                   modified by the system administrator (if needed or
5230                   desired) to conform to local policy or provide more
5231                   useful site-specific behavior.</p>
5232               </item>
5233
5234               <tag><tt>conffile</tt></tag>
5235               <item><p>
5236                   A file listed in a package's <tt>conffiles</tt>
5237                   file, and is treated specially by <prgn>dpkg</prgn>
5238                   (see the <em>Debian Packaging Manual</em>).</p>
5239               </item>
5240             </taglist>
5241           </p>
5242
5243           <p>
5244             The distinction between these two is important; they are
5245             not interchangeable concepts. Almost all
5246             <tt>conffiles</tt> are configuration files, but many
5247             configuration files are not <tt>conffiles</tt>.</p>
5248
5249           <p>
5250             Note that a script that embeds configuration information
5251             (such as most of the files in <tt>/etc/init.d</tt> and
5252             <tt>/etc/cron.{daily,weekly,monthly}</tt>) is de-facto a
5253             configuration file and should be treated as such.</p>
5254         </sect1>
5255
5256         <sect1>
5257           <heading>Location</heading>
5258           <p>
5259             Any configuration files created or used by your package
5260             must reside in <tt>/etc</tt>. If there are several you
5261             should consider creating a subdirectory of <tt>/etc</tt>
5262             named after your package.</p>
5263
5264           <p>
5265             If your package creates or uses configuration files
5266             outside of <tt>/etc</tt>, and it is not feasible to modify
5267             the package to use the <tt>/etc</tt>, you should still put
5268             the files in <tt>/etc</tt> and create symbolic links to
5269             those files from the location that the package
5270             requires.</p>
5271         </sect1>
5272
5273         <sect1>
5274           <heading>Behavior</heading>
5275           <p>
5276             Configuration file handling must conform to the following
5277             behavior:
5278             <list>
5279               <item>
5280                 <p>local changes must be preserved during a package
5281                   upgrade</p>
5282               </item>
5283               <item>
5284                 <p>configuration files must be preserved when the
5285                   package is removed, and only deleted when the
5286                   package is purged.</p>
5287               </item>
5288             </list></p>
5289
5290           <p>
5291             The easy way to achieve this behavior is to make the
5292             configuration file a <tt>conffile</tt>. This is
5293             appropriate only if it is possible to distribute a default
5294             version that will work for most installations, although
5295             some system administrators may choose to modify it. This
5296             implies that the default version will be part of the
5297             package distribution, and must not be modified by the
5298             maintainer scripts during installation (or at any other
5299             time).
5300           </p>
5301
5302           <p>
5303             In order to ensure that local changes are preserved
5304             correctly, no package may contain or make hard links to
5305             conffiles.
5306             <footnote>
5307               <p>
5308                 Rationale: There are two problems with hard links.
5309                 The first is that some editors break the link while
5310                 editing one of the files, so that the two files may
5311                 unwittingly become different.  The second is that
5312                 <prgn>dpkg</prgn> might break the hard link while
5313                 upgrading <tt>conffile</tt>s.
5314               </p>
5315             </footnote>
5316
5317           <p>
5318             The other way to do it is via the maintainer scripts.
5319             In this case, the configuration file must not be listed as
5320             a <tt>conffile</tt> and must not be part of the package
5321             distribution. If the existence of a file is required for
5322             the package to be sensibly configured it is the
5323             responsibility of the package maintainer to write scripts
5324             which correctly create, update, maintain and
5325             remove-on-purge the file. These scripts must be idempotent
5326             (i.e., must work correctly if <prgn>dpkg</prgn> needs to
5327             re-run them due to errors during installation or removal),
5328             must cope with all the variety of ways <prgn>dpkg</prgn>
5329             can call maintainer scripts, must not overwrite or
5330             otherwise mangle the user's configuration without asking,
5331             must not ask unnecessary questions (particularly during
5332             upgrades), and otherwise be good citizens.</p>
5333
5334           <p>
5335             The scripts are not required to configure every possible option for
5336             the package, but only those necessary to get the package
5337             running on a given system. Ideally the sysadmin should not
5338             have to do any configuration other than that done
5339             (semi-)automatically by the <tt>postinst</tt> script.</p>
5340
5341           <p>
5342             A common practice is to create a script called
5343             <tt><var>package</var>-configure</tt> and have the
5344             package's <tt>postinst</tt> call it if and only if the
5345             configuration file does not already exist. In certain
5346             cases it is useful for there to be an example or template
5347             file which the maintainer scripts use. Such files should
5348             be in <tt>/usr/share/doc</tt> if they are examples or
5349             <tt>/usr/lib</tt> if they are templates, and should be
5350             perfectly ordinary <prgn>dpkg</prgn>-handled files
5351             (<em>not</em> <tt>conffiles</tt>).</p>
5352
5353           <p>
5354             These two styles of configuration file handling must
5355             not be mixed, for that way lies madness:
5356             <prgn>dpkg</prgn> will ask about overwriting the file
5357             every time the package is upgraded.</p>
5358
5359         </sect1>
5360
5361         <sect1>
5362           <heading>Sharing configuration files</heading>
5363           <p>
5364             Packages which specify the same file as
5365             `<tt>conffile</tt>' must be tagged as <em>conflicting</em>
5366             with each other.
5367             </p>
5368
5369           <p>
5370             The maintainer scripts must not alter the conffile of
5371             <em>any</em> package, including the one the scripts belong
5372             to.</p>
5373
5374           <p>
5375             If two or more packages use the same configuration file
5376             and it is reasonable for both to be installed at the same
5377             time, one of these packages must be defined as
5378             <em>owner</em> of the configuration file, i.e., it will be
5379             the package to list that distributes the file and lists it
5380             as a <tt>conffile</tt>. Other packages that use the
5381             configuration file must depend on the owning package if
5382             they require the configuration file to operate. If the
5383             other package will use the configuration file if present,
5384             but is capable of operating without it, no dependency need
5385             be declared.</p>
5386
5387           <p>
5388             If it is desirable for two or more related packages to
5389             share a configuration file <em>and</em> for all of the
5390             related packages to be able to modify that configuration
5391             file, then the following should be done:
5392             <enumlist>
5393               <item>
5394                 <p>
5395                   have one of the related packages (the "core"
5396                   package) manage the configuration file with
5397                   maintainer scripts as described in the previous
5398                   section.</p>
5399               </item>
5400               <item><p>
5401                   the core package should also provide a program that
5402                   the other packages may use to modify the
5403                   configuration file.</p>
5404               </item>
5405               <item>
5406                 <p>
5407                   the related packages must use the provided program
5408                   to make any modifications to the configuration file.
5409                   They should either depend on the core package to
5410                   guarantee that the configuration modifier program is
5411                   available or accept gracefully that they cannot
5412                   modify the configuration file if it is not.</p>
5413               </item>
5414             </enumlist></p>
5415
5416           <p>
5417             Sometimes it's appropriate to create a new package which
5418             provides the basic infrastructure for the other packages
5419             and which manages the shared configuration files. (Check
5420             out the <tt>sgml-base</tt> package as an example.)</p>
5421         </sect1>
5422
5423         <sect1>
5424           <heading>User configuration files ("dotfiles")</heading>
5425
5426           <p>
5427             Files in <tt>/etc/skel</tt> will automatically be copied
5428             into new user accounts by <prgn>adduser</prgn>. They
5429             should not be referenced there by any program.</p>
5430
5431           <p>
5432             Therefore, if a program needs a dotfile to exist in
5433             advance in <tt>$HOME</tt> to work sensibly, that dotfile
5434             should be installed in <tt>/etc/skel</tt> (and listed in
5435             conffiles, if it is not generated and modified dynamically
5436             by the package's installation scripts).</p>
5437
5438           <p>
5439             However, programs that require dotfiles in order to
5440             operate sensibly (dotfiles that they do not create
5441             themselves automatically, that is) are a bad thing, and
5442             programs should be configured by the Debian default
5443             installation as close to normal as possible.</p>
5444
5445           <p>
5446             Therefore, if a program in a Debian package needs to be
5447             configured in some way in order to operate sensibly that
5448             configuration should be done in a site-wide global
5449             configuration file elsewhere in <tt>/etc</tt>. Only if the
5450             program doesn't support a site-wide default configuration
5451             and the package maintainer doesn't have time to add it
5452             may a default per-user file be placed in
5453             <tt>/etc/skel</tt>.</p>
5454
5455           <p>
5456             <tt>/etc/skel</tt> should be as empty as we can make it.
5457             This is particularly true because there is no easy
5458             mechanism for ensuring that the appropriate dotfiles are
5459             copied into the accounts of existing users when a package
5460             is installed.</p>
5461         </sect1>
5462       </sect>
5463
5464       <sect>
5465         <heading>Log files</heading>
5466         <p>
5467           The traditional approach to log files has been to set up ad
5468           hoc log rotation schemes using simple shell scripts and
5469           cron. While this approach is highly customizable, it
5470           requires quite a lot of sysadmin work. Even though the
5471           original Debian system helped a little by automatically
5472           installing a system which can be used as a template, this
5473           was deemed not enough.
5474         </p>
5475
5476         <p>
5477           A better scheme is to use logrotate, a GPL'd program
5478           developed by Red Hat, which centralizes log management. It
5479           has both a configuration file (<tt>/etc/logrotate.conf</tt>)
5480           and a directory where packages can drop logrotation info
5481           (<tt>/etc/logrotate.d</tt>).
5482         </p>
5483
5484         <p>
5485           Log files should usually be named
5486           <tt>/var/log/<var>package</var>.log</tt>.  If you have many
5487           log files, or need a separate directory for permissions
5488           reasons (<tt>/var/log</tt> is writable only by
5489           <tt>root</tt>), you should usually create a directory named
5490           <tt>/var/log/<var>package</var></tt>.</p>
5491
5492         <p>
5493           Log files must be rotated occasionally so
5494           that they don't grow indefinitely; the best way to do this
5495           is to drop a script into the directory
5496           <tt>/etc/logrotate.d</tt> and use the facilities provided by
5497           logrotate. Here is a good example for a logrotate config
5498           file (for more information see <manref name="logrotate"
5499                                                  section="8">):
5500           <example>
5501             /var/log/foo/* {
5502             rotate 12
5503             weekly
5504             compress
5505             postrotate
5506             /etc/init.d/foo force-reload
5507             endscript
5508             }
5509           </example>
5510           Which rotates all files under `/var/log/foo', saves 12
5511           compressed generations, and sends a HUP signal at the end of
5512           rotation.
5513
5514         </p>
5515
5516         <p>
5517           Log files should be removed when the package is
5518           purged (but not when it is only removed), by checking the
5519           argument to the <tt>postrm</tt> script (see the <em>Debian
5520             Packaging Manual</em> for details).</p>
5521       </sect>
5522
5523
5524       <sect>
5525         <heading>Permissions and owners</heading>
5526
5527         <p>
5528           The rules in this section are guidelines for general use.
5529           If necessary you may deviate from the details below.
5530           However, if you do so you must make sure that what is done
5531           is secure and you should try to be as consistent as possible
5532           with the rest of the system.  You should probably also
5533           discuss it on <prgn>debian-devel</prgn> first.</p>
5534
5535         <p>
5536           Files should be owned by <tt>root.root</tt>, and made
5537           writable only by the owner and universally readable (and
5538           executable, if appropriate).</p>
5539
5540         <p>
5541           Directories should be mode 755 or (for group-writability)
5542           mode 2775.  The ownership of the directory should be
5543           consistent with its mode--if a directory is mode 2775, it
5544           should be owned by the group that needs write access to
5545           it.</p>
5546
5547         <p>
5548           Setuid and setgid executables should be mode 4755 or 2755
5549           respectively, and owned by the appropriate user or group.
5550           They should not be made unreadable (modes like 4711 or
5551           2711 or even 4111); doing so achieves no extra security,
5552           because anyone can find the binary in the freely available
5553           Debian package--it is merely inconvenient.  For the same
5554           reason you should not restrict read or execute permissions
5555           on non-set-id executables.</p>
5556
5557         <p>
5558           Some setuid programs need to be restricted to particular
5559           sets of users, using file permissions.  In this case they
5560           should be owned by the uid to which they are set-id, and
5561           by the group which should be allowed to execute them.
5562           They should have mode 4754; there is no point in making
5563           them unreadable to those users who must not be allowed to
5564           execute them.</p>
5565
5566         <p>
5567           You must not arrange that the system administrator can only
5568           reconfigure the package to correspond to their local
5569           security policy by changing the permissions on a binary.
5570           Ordinary files installed by <prgn>dpkg</prgn> (as opposed
5571           to conffiles and other similar objects) have their
5572           permissions reset to the distributed permissions when the
5573           package is reinstalled.  Instead you should consider (for
5574           example) creating a group for people allowed to use the
5575           program(s) and making any setuid executables executable
5576           only by that group.</p>
5577
5578         <p>
5579           If you need to create a new user or group for your package
5580           there are two possibilities.  Firstly, you may need to
5581           make some files in the binary package be owned by this
5582           user or group, or you may need to compile the user or
5583           group id (rather than just the name) into the binary
5584           (though this latter should be avoided if possible, as in
5585           this case you need a statically allocated id).</p>
5586
5587         <p>
5588           If you need a statically allocated id, you must ask for a
5589           user or group id from the base system
5590           maintainer, and must not release the package until you
5591           have been allocated one.  Once you have been allocated one
5592           you must make the package depend on a version of the base
5593           system with the id present in <tt>/etc/passwd</tt> or
5594           <tt>/etc/group</tt>, or alternatively arrange for your
5595           package to create the user or group itself with the
5596           correct id (using <tt>adduser</tt>) in its pre- or
5597           post-installation script (the latter is to be preferred if
5598           it is possible).</p>
5599
5600         <p>
5601           On the other hand, the program might be able to determine the
5602           uid or gid from the group name at runtime, so that a
5603           dynamic id can be used.  In this case you should choose an
5604           appropriate user or group name, discussing this on
5605           <prgn>debian-devel</prgn> and checking with the base
5606           system maintainer that it is unique and that they do not
5607           wish you to use a statically allocated id instead.  When
5608           this has been checked you must arrange for your package to
5609           create the user or group if necessary using
5610           <prgn>adduser</prgn> in the pre- or post-installation
5611           script (again, the latter is to be preferred if it is
5612           possible).</p>
5613
5614         <p>
5615           Note that changing the numeric value of an id associated with a name
5616           is very difficult, and involves searching the file system for all
5617           appropriate files.  You need to think carefully whether a static or
5618           dynamic id is required, since changing your mind later will cause
5619           problems.</p>
5620       </sect>
5621     </chapt>
5622
5623     <chapt>
5624       <heading>Customized programs</heading>
5625
5626       <sect id="arch-spec">
5627         <heading>Architecture specification strings</heading>
5628
5629         <p>
5630           If a program needs to specify an <em>architecture specification
5631             string</em> in some place, the following format should be used:
5632           <example>
5633             &lt;arch&gt;-&lt;os&gt;
5634           </example>
5635           where `&lt;arch&gt;' is one of the following: i386, alpha, arm, m68k,
5636           powerpc, sparc and `&lt;os&gt;' is one of: linux, gnu.  Use
5637           of <em>gnu</em> in this string is reserved for the GNU/Hurd
5638           operating system.</p>
5639         <p>
5640           Note, that we don't want to use `&lt;arch&gt;-debian-linux'
5641           to apply to the rule `architecture-vendor-os' since this
5642           would make our programs incompatible to other Linux
5643           distributions. Also note, that we don't use
5644           `&lt;arch&gt;-unknown-linux', since the `unknown' does not
5645           look very good.</p></sect>
5646
5647
5648       <sect>
5649         <heading>Daemons</heading>
5650
5651         <p>
5652           The configuration files <tt>/etc/services</tt>,
5653           <tt>/etc/protocols</tt>, and <tt>/etc/rpc</tt> are managed
5654           by the <prgn>netbase</prgn> package and may not be modified
5655           by other packages.</p>
5656
5657         <p>
5658           If a package requires a new entry in one of these files, the
5659           maintainer should get in contact with the
5660           <prgn>netbase</prgn> maintainer, who will add the entries
5661           and release a new version of the <prgn>netbase</prgn>
5662           package.</p>
5663
5664         <p>
5665           The configuration file <tt>/etc/inetd.conf</tt> must not be
5666           modified by the package's scripts except via the
5667           <prgn>update-inetd</prgn> script or the
5668           <prgn>DebianNet.pm</prgn> Perl module.</p>
5669
5670         <p>
5671           If a package wants to install an example entry into
5672           <tt>/etc/inetd.conf</tt>, the entry must be preceded with
5673           exactly one hash character (<tt>#</tt>). Such lines are
5674           treated as `commented out by user' by the
5675           <prgn>update-inetd</prgn> script and are not changed or
5676           activated during a package updates.</p></sect>
5677
5678
5679       <sect>
5680         <heading>Using pseudo-ttys and modifying wtmp, utmp and lastlog</heading>
5681
5682         <p>
5683           Some programs need to create pseudo-ttys. This should be done
5684           using Unix98 ptys if the C library supports it. The resulting
5685           program must not be installed setuid root, unless that
5686           is required for other functionality.
5687         </p>
5688
5689         <p>
5690           The files <tt>/var/run/utmp</tt>, <tt>/var/log/wtmp</tt> and
5691           <tt>/var/log/lastlog</tt> must be installed writeable by
5692           group utmp.  Programs who need to modify those files must
5693           be installed setgid utmp.
5694         </p>
5695       </sect>
5696
5697       <sect>
5698         <heading>Editors and pagers</heading>
5699
5700         <p>
5701           Some programs have the ability to launch an editor or pager
5702           program to edit or display a text document. Since there are
5703           lots of different editors and pagers available in the Debian
5704           distribution, the system administrator and each user should
5705           have the possibility to choose his/her preferred editor and
5706           pager.</p>
5707
5708         <p>
5709           In addition, every program should choose a good default
5710           editor/pager if none is selected by the user or system
5711           administrator.</p>
5712
5713         <p>
5714           Thus, every program that launches an editor or pager must
5715           use the EDITOR or PAGER environment variables to determine
5716           the editor/pager the user wants to get started. If these
5717           variables are not set, the programs <tt>/usr/bin/editor</tt>
5718           and <tt>/usr/bin/pager</tt> should be used, respectively.</p>
5719
5720         <p>
5721           These two files are managed through `alternatives.' That is,
5722           every package providing an editor or pager must call the
5723           <prgn>update-alternatives</prgn> script to register these
5724           programs.</p>
5725
5726         <p>
5727           If it is very hard to adapt a program to make us of the
5728           EDITOR and PAGER variables, that program may be configured
5729           to use <tt>/usr/bin/sensible-editor</tt> and
5730           <tt>/usr/bin/sensible-pager</tt> as editor or pager program,
5731           respectively. These are two scripts provided in the Debian
5732           base system that check the EDITOR and PAGER variables and
5733           launch the appropriate program or fall back to
5734           <tt>/usr/bin/editor</tt> and <tt>/usr/bin/pager</tt>,
5735           automatically.</p>
5736
5737         <p>
5738           A program may also use the VISUAL environment variable to
5739           determine the user's choice of editor. If it exists, it
5740           should take precedence over EDITOR. This is in fact what
5741           <tt>/usr/bin/sensible-editor</tt> does.</p>
5742
5743         <p>
5744           It is not required for a package to depend on
5745           `editor' and `pager', nor is it required for a package to
5746           provide such virtual packages.
5747           <footnote>
5748             <p>
5749               The Debian base system already provides an editor and
5750               a pager program,
5751             </p>
5752           </footnote>
5753         </p>
5754
5755       </sect>
5756
5757
5758       <sect id="web-appl">
5759         <heading>Web servers and applications</heading>
5760
5761         <p>
5762           This section describes the locations and URLs that should
5763           be used by all web servers and web application in the Debian
5764           system.</p>
5765
5766         <p>
5767           <enumlist>
5768             <item>
5769               <p>Cgi-bin executable files are installed in the
5770                 directory
5771                 <example>
5772                   /usr/lib/cgi-bin/&lt;cgi-bin-name&gt;
5773                 </example>
5774                 and should be referred to as
5775                 <example>
5776                   http://localhost/cgi-bin/&lt;cgi-bin-name&gt;
5777                 </example></p></item>
5778
5779
5780             <item><p>Access to html documents</p>
5781
5782               <p>
5783                 Html documents for a package are stored in
5784                 <tt>/usr/share/doc/<var>package</var></tt> but should
5785                 be accessed via symlinks as
5786                 <tt>/usr/doc/<var>package</var></tt><footnote> for
5787                     backward compatibility, see <ref id="usrdoc"></footnote>
5788                 and can be referred to as
5789                 <example>
5790                   http://localhost/doc/&lt;package&gt;/&lt;filename&gt;
5791                 </example></p></item>
5792
5793
5794             <item><p>Web Document Root</p>
5795
5796               <p>
5797                 Web Applications should try to avoid storing files in
5798                 the Web Document Root.  Instead they should use the
5799                 /usr/share/doc/&lt;package&gt; directory for documents and
5800                 register the Web Application via the menu package. If
5801                 access to the web-root is unavoidable then use
5802                 <example>
5803                   /var/www
5804                 </example>
5805                 as the Document Root. This might be just a
5806                 symbolic link to the location where the sysadmin has
5807                 put the real document root.</p>
5808             </item>
5809
5810           </enumlist></p></sect>
5811
5812
5813       <sect>
5814         <heading>Mail transport, delivery and user agents</heading>
5815
5816         <p>
5817           Debian packages which process electronic mail, whether
5818           mail-user-agents (MUAs) or mail-transport-agents (MTAs),
5819           must make sure that they are compatible with the
5820           configuration decisions below.  Failure to do this may
5821           result in lost mail, broken <tt>From:</tt> lines, and other
5822           serious brain damage!</p>
5823
5824         <p>
5825           The mail spool is <tt>/var/spool/mail</tt> and the interface
5826           to send a mail message is <tt>/usr/sbin/sendmail</tt> (as
5827           per the FHS).  The mail spool is part of the base system
5828           and not part of the MTA package.</p>
5829
5830         <p>
5831           All Debian MUAs, MTAs, MDAs and other mailbox accessing
5832           programs (like IMAP daemons) must lock the mailbox in an
5833           NFS-safe way. This means that <tt>fcntl()</tt> locking must
5834           be combined with dot locking.  To avoid deadlocks, a
5835           program should use <tt>fcntl()</tt> first and dot locking
5836           after this or alternatively implement the two locking
5837           methods in a non blocking way<footnote>
5838             <p>
5839               If it is not possible to establish both locks, the
5840               system shouldn't wait for the second lock to be
5841               established, but remove the first lock, wait a (random)
5842               time, and start over locking again.</p>
5843           </footnote>. Using the functions <tt>maillock</tt> and
5844           <tt>mailunlock</tt> provided by the
5845           <tt>liblockfile*</tt><footnote>
5846             <p>
5847               <tt>liblockfile</tt> version &gt;&gt;1.01</p>
5848           </footnote> packages is the recommended way to realize this.
5849         </p>
5850
5851         <p>
5852           Mailboxes are generally 660 <tt><var>user</var>.mail</tt>
5853           unless the user has chosen otherwise.  A MUA may remove a
5854           mailbox (unless it has nonstandard permissions) in which
5855           case the MTA or another MUA must recreate it if needed.
5856           Mailboxes must be writable by group mail.</p>
5857
5858         <p>
5859           The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
5860           be setgid mail to do the locking mentioned above (and
5861           must obviously avoid accessing other users' mailboxes
5862           using this privilege).</p>
5863
5864         <p>
5865           <tt>/etc/aliases</tt> is the source file for the system mail
5866           aliases (e.g., postmaster, usenet, etc.)--it is the one
5867           which the sysadmin and <tt>postinst</tt> scripts may edit.
5868           After <tt>/etc/aliases</tt> is edited the program or human
5869           editing it must call <prgn>newaliases</prgn>.  All MTA
5870           packages must come with a <prgn>newaliases</prgn> program,
5871           even if it does nothing, but older MTA packages do not do
5872           this so programs should not fail if <prgn>newaliases</prgn>
5873           cannot be found.</p>
5874
5875         <p>
5876           The convention of writing <tt>forward to
5877             <var>address</var></tt> in the mailbox itself is not
5878           supported.  Use a <tt>.forward</tt> file instead.</p>
5879
5880         <p>
5881           The <prgn>rmail</prgn> program used by UUCP
5882           for incoming mail should be  <tt>/usr/sbin/rmail</tt>.
5883           Likewise, <prgn>rsmtp</prgn>, for receiving
5884           batch-SMTP-over-UUCP, should be <tt>/usr/sbin/rsmtp</tt> if it
5885           is supported.</p>
5886
5887         <p>
5888           If you need to know what name to use (for example) on
5889           outgoing news and mail messages which are generated locally,
5890           you should use the file <tt>/etc/mailname</tt>.  It will
5891           contain the portion after the username and <tt>@</tt> (at)
5892           sign for email addresses of users on the machine (followed
5893           by a newline).</p>
5894
5895         <p>
5896           A package should check for the existence of this file.  If
5897           it exists it should use it without comment. (An MTA's
5898           prompting configuration script may wish to prompt the user
5899           even if it finds this file exists.) If it does not exist it
5900           should prompt the user for the value and store it in
5901           <tt>/etc/mailname</tt> as well as using it in the package's
5902           configuration.  The prompt should make it clear that the
5903           name will not just be used by that package.  For example, in
5904           this situation the INN package says:
5905           <example>
5906             Please enter the `mail name' of your system.  This is the
5907             hostname portion of the address to be shown on outgoing
5908             news and mail messages.  The default is
5909             <var>syshostname</var>, your system's host name.  Mail
5910             name [`<var>syshostname</var>']:
5911           </example>
5912           where <var>syshostname</var> is the output of <tt>hostname
5913             --fqdn</tt>.</p></sect>
5914
5915
5916       <sect>
5917         <heading>News system configuration</heading>
5918
5919         <p>
5920           All the configuration files related to the NNTP (news)
5921           servers and clients should be located under
5922           <tt>/etc/news</tt>.</p>
5923
5924         <p>
5925           There are some configuration issues that apply to a number
5926           of news clients and server packages on the machine. These
5927           are:
5928
5929           <taglist>
5930             <tag>/etc/news/organization</tag>
5931             <item><p>A string which should appear as the
5932                 organization header for all messages posted
5933                 by NNTP clients on the machine</p></item>
5934
5935             <tag>/etc/news/server</tag>
5936             <item><p>Contains the FQDN of the upstream NNTP
5937                 server, or localhost if the local machine is
5938                 an NNTP server.</p></item>
5939           </taglist>
5940
5941           Other global files may be added as required for cross-package news
5942           configuration.</p></sect>
5943
5944
5945       <sect>
5946         <heading>Programs for the X Window System</heading>
5947
5948         <p>
5949           <em>Programs that may be configured with support for the X Window
5950             System</em> must be configured to do so and must declare any
5951           package dependencies necessary to satisfy their runtime
5952           requirements when using the X Window System, unless the package
5953           in question is of standard or higher priority, in which case
5954           X-specific binaries may be split into a separate package, or
5955           alternative versions of the package with X support may be
5956           provided.
5957         </p>
5958
5959
5960         <p>
5961           <em>Packages which provide an X server</em> that, directly or
5962           indirectly, communicates with real input and display hardware
5963           should declare in their control data that they provide the
5964           virtual package <tt>xserver</tt>.
5965           <footnote>
5966             <p>
5967               This implements current practice, and provides an actual
5968               policy for usage of the "xserver" virtual package which
5969               appears in the virtual packages list.  In a nutshell, X
5970               servers that interface directly with the display and input
5971               hardware or via another subsystem (e.g., GGI) should provide
5972               xserver.  Things like Xvfb, Xnest, and Xprt should not.
5973             </p>
5974           </footnote>
5975         </p>
5976
5977         <p>
5978           <em>Packages that provide a terminal emulator</em> for the X
5979           Window System which support a terminal type with a terminfo
5980           description provided in the <tt>ncurses-base</tt> package
5981           should declare in their control data that they provide the
5982           virtual package <tt>x-terminal-emulator</tt>.  They should
5983           also register themselves as an alternative for
5984           <tt>/usr/bin/x-terminal-emulator</tt>, with a priority of
5985           20.
5986         </p>
5987
5988         <p>
5989           <em>Packages that provide window managers</em> should declare in
5990           their control data that they provide the virtual package
5991           <tt>x-window-manager</tt>.  They should also register themselves as an
5992           alternative for <tt>/usr/bin/x-window-manager</tt>, with a priority
5993           calculated as follows:
5994           <list>
5995             <item>Start with a priority of 20.</item>
5996             <item>If the window manager supports the Debian menu system,
5997                 add 20 points if this support is available in the
5998                 package's default configuration (i.e., no
5999                 configuration files belonging to the system or user
6000                 have to be edited to activate the feature); if
6001                 configuration files must be modified, add only 10
6002                 points.</item>
6003             <item>If the window manager permits the X session to be
6004                 restarted using a <em>different</em> window manager
6005                 (without killing the X server) in its default
6006                 configuration, add 10 points; otherwise add
6007                 none.</item>
6008           </list>
6009         </p>
6010
6011         <p>
6012           <em>Packages that provide fonts for the X Window System</em>
6013           must do a number of things to ensure that they are both
6014           available without modification of the X or font server
6015           configuration, and that they do not corrupt files used by
6016           other font packages to register information about themselves.
6017           <enumlist>
6018             <item>
6019                 Fonts of any type supported by the X Window System
6020                 should be be in a separate binary package from any
6021                 executables, libraries, or documentation (except that
6022                 specific to the fonts shipped); if a program or
6023                 library is <em>unusable</em> without one or more
6024                 specific fonts, the package containing the program or
6025                 library should declare a dependency on the package(s)
6026                 containing the font(s) it requires.
6027             </item>
6028             <item>
6029                 BDF fonts should be converted to PCF fonts with the
6030                 <tt>bdftopcf</tt> utility (available in the
6031                 <tt>xutils</tt> package, <tt>gzip</tt>ped, and
6032                 placed in a directory that corresponds to their
6033                 resolution:
6034                 <list>
6035                   <item>
6036                       100 dpi fonts should be placed in
6037                       <tt>/usr/X11R6/lib/X11/fonts/100dpi/</tt>.
6038                   </item>
6039                   <item>
6040                       75 dpi fonts should be placed in
6041                       <tt>/usr/X11R6/lib/X11/fonts/75dpi/</tt>.
6042                   </item>
6043                   <item>
6044                       Character-cell fonts, cursor fonts, and other
6045                       low-resolution fonts should be placed in
6046                       <tt>/usr/X11R6/lib/X11/fonts/misc/</tt>.
6047                   </item>
6048                 </list>
6049             </item>
6050             <item>
6051                 Speedo fonts should be placed in
6052                 <tt>/usr/X11R6/lib/X11/fonts/Speedo/</tt>.
6053             </item>
6054             <item>
6055                 Type 1 fonts should be placed in
6056                 <tt>/usr/X11R6/lib/X11/fonts/Type1/</tt>.  If font
6057                 metric files are available, they may be placed here as
6058                 well.
6059             </item>
6060             <item>
6061                 Subdirectories of <tt>/usr/X11R6/lib/X11/fonts/</tt>
6062                 other than those listed above should be neither created nor
6063                 used.  (The <tt>PEX</tt> and <tt>cyrillic</tt> directories are
6064                 excepted for historical reasons, but installation of files into
6065                 these directories remains discouraged.)
6066             </item>
6067             <item>
6068                 Font packages may, instead of placing files directly in
6069                 the X font directories listed above, provide symbolic links in
6070                 the font directory which point to the files' actual location
6071                 in the filesystem.  Such a location should comply with the
6072                 FHS.
6073             </item>
6074             <item>
6075                 Font packages should not contain both 75dpi and 100dpi
6076                 versions of a font.  If both are available, they should be
6077                 provided in separate binary packages with "-75dpi" or "-100dpi"
6078                 appended to the names of the packages containing the
6079                 corresponding fonts.
6080             </item>
6081             <item>
6082                 Fonts destined for the <tt>misc</tt> subdirectory should
6083                 not be included in the same package as 75dpi or 100dpi fonts;
6084                 instead, they should be provided in a separate package with
6085                 "-misc" appended to its name.
6086             </item>
6087             <item>
6088                 Font packages <em>must not</em> provide the files
6089                 <tt>fonts.dir</tt>, <tt>fonts.alias</tt>, or
6090                 <tt>fonts.scale</tt> in a font directory.
6091                 <list>
6092                   <item>
6093                       <tt>fonts.dir</tt> files must not be provided at
6094                       all.
6095                   </item>
6096                   <item>
6097                       <tt>fonts.alias</tt> and <tt>fonts.scale</tt>
6098                       files, if needed, should be provided in the
6099                       directory
6100                       <tt>/etc/X11/fonts/<em>fontdir</em>/<em>package</em>.<em>extension</em></tt>,
6101                       where <em>fontdir</em> is the name of the
6102                       subdirectory of
6103                       <tt>/usr/X11R6/lib/X11/fonts/</tt> where the
6104                       package's corresponding fonts are stored (e.g.,
6105                       <tt>75dpi</tt> or <tt>misc</tt>),
6106                       <em>package</em> is the name of the package that
6107                       provides these fonts, and <em>extension</em> is
6108                       either <tt>scale</tt> or <tt>alias</tt>,
6109                       whichever corresponds to the file
6110                       contents.
6111                   </item>
6112                 </list>
6113             </item>
6114             <item>
6115                 Font packages must declare a dependency on
6116                 <tt>xutils</tt> and, in the package
6117                 post-installation and post-removal scripts, invoke the
6118                 <tt>mkfontdir</tt> command on each directory into
6119                 which they installed fonts.
6120             </item>
6121             <item>
6122                 Font packages that provide one or more
6123                 <tt>fonts.scale</tt> files as described above must declare a
6124                 versioned dependency on <tt>xutils (&gt;=
6125                   4.0.2)</tt> and invoke <tt>update-fonts-scale</tt> on each
6126                 directory into which they installed fonts
6127                 <em>before</em> invoking <tt>mkfontdir</tt> on that
6128                 directory.  This invocation must occur in both the
6129                 post-installation and post-removal scripts.
6130             </item>
6131             <item>
6132                 Font packages that provide one or more
6133                 <tt>fonts.alias</tt> files as described above must
6134                 declare a versioned dependency on <tt>xutils
6135                   (&gt;= 4.0.2)</tt> and, in the package
6136                 post-installation and post-removal scripts, invoke
6137                 <tt>update-fonts-alias</tt> on each directory into
6138                 which they installed fonts.
6139             </item>
6140             <item>
6141                 Font packages must not provide alias names for the
6142                 fonts they include which collide with alias names already in
6143                 use by fonts already packaged.
6144             </item>
6145             <item>
6146                 Font packages must not provide fonts with the same XLFD
6147                 registry name as another font already packaged.
6148             </item>
6149           </enumlist>
6150         </p>
6151
6152         <p>
6153           <em>Application defaults</em> files must be installed in the
6154           directory <tt>/usr/X11R6/lib/X11/app-defaults/</tt>.
6155           <footnote>
6156             <p>Note: This shall change very shortly.</p>
6157           </footnote>
6158           They should not be registered as <em>conffile</em>s or
6159           otherwise treated as configuration files.  Customization of
6160           programs' X resources may be supported with the provision of
6161           a file with the same name as that of the package placed in
6162           the <tt>/etc/X11/Xresources/</tt> directory, which must
6163           registered as a <em>conffile</em>.  <em>Important:</em>
6164           packages that install files into the
6165           <tt>/etc/X11/Xresources/</tt> directory <em>must</em>
6166           declare a conflict with <tt>xbase (&lt;&lt;
6167             3.3.2.3a-2)</tt>; if this is not done it is possible for the
6168           installing package to destroy a previously-existing
6169           <tt>/etc/X11/Xresources</tt> <em>file</em> which had been
6170           customized by the system administrator.
6171           <footnote>
6172             <p>Rationale: clarifies the language to properly
6173               address the package maintainer, not the system
6174               administrator, as to how to manage
6175               /etc/X11/Xresources.</p>
6176           </footnote>
6177         </p>
6178
6179
6180         <p>
6181           <em>Packages using the X Window System should abide by the FHS
6182             standard whenever possible</em>; they should install binaries,
6183           libraries, manual pages, and other files in FHS-mandated
6184           locations wherever possible.  This means that files must
6185           not be installed into <tt>/usr/X11R6/bin/</tt>,
6186           <tt>/usr/X11R6/lib/</tt>, or <tt>/usr/X11R6/man/</tt> unless
6187           this is necessary for the package to operate properly.
6188           Configuration files for window managers and display managers
6189           should be placed in a subdirectory of <tt>/etc/X11/</tt>
6190           corresponding to the package name due to these programs'
6191           tight integration with the mechanisms of the X Window
6192           System.  Application-level programs should use the
6193           <tt>/etc/</tt> directory unless otherwise mandated by
6194           policy.  The installation of files into subdirectories of
6195           <tt>/usr/X11R6/include/X11/</tt> and
6196           <tt>/usr/X11R6/lib/X11/</tt> is permitted but discouraged;
6197           package maintainers should determine if subdirectories of
6198           <tt>/usr/lib/</tt> and <tt>/usr/share/</tt> can be used
6199           instead (symlinks from the X11R6 directories to
6200           FHS-compliant locations is encouraged if the program is not
6201           easily configured to look elsewhere for its files).
6202           Packages must not provide -- or install files into -- the
6203           directories <tt>/usr/bin/X11/</tt>,
6204           <tt>/usr/include/X11/</tt>, or <tt>/usr/lib/X11/</tt>.
6205           Files within a package should, however, make reference to
6206           these directories, rather than their X11R6-named
6207           counterparts <tt>/usr/X11R6/bin/</tt>,
6208           <tt>/usr/X11R6/include/X11/</tt>, and
6209           <tt>/usr/X11R6/lib/X11/</tt>, if the resources being
6210           referred to have not been moved to FHS-compliant locations.
6211         </p>
6212
6213         <p>
6214           <em>Programs that require the non-DFSG-compliant OSF/Motif
6215             library</em> should be compiled against and tested with
6216           LessTif (a free re-implementation of Motif) instead.  If the
6217           maintainer judges that the program or programs do not work
6218           sufficiently well with LessTif to be distributed and
6219           supported, but do so when compiled against Motif, then two
6220           versions of the package should be created; one linked
6221           statically against Motif and with <tt>-smotif</tt> appended
6222           to the package name, and one linked dynamically against
6223           Motif and with <tt>-dmotif</tt> appended to the package
6224           name.  Both Motif-linked versions are dependent upon
6225           non-DFSG-compliant software and thus cannot be uploaded to
6226           the main distribution; if the software is itself
6227           DFSG-compliant it may be uploaded to the contrib
6228           distribution.  While known existing versions of OSF/Motif
6229           permit unlimited redistribution of binaries linked against
6230           the library (whether statically or dynamically), it is the
6231           package maintainer's responsibility to determine whether
6232           this is permitted by the license of the copy of OSF/Motif in
6233           his or her possession.
6234         </p>
6235       </sect>
6236
6237
6238       <sect>
6239         <heading>Emacs lisp programs</heading>
6240
6241         <p>
6242           Please refer to the `Debian Emacs Policy' (documented in
6243           <tt>debian-emacs-policy.gz</tt> of the
6244           <prgn>emacsen-common</prgn> package) for details of how to
6245           package emacs lisp programs.</p></sect>
6246
6247
6248       <sect>
6249         <heading>Games</heading>
6250
6251         <p>
6252           The permissions on /var/games are 755
6253           <tt>root.root</tt>.</p>
6254
6255         <p>
6256           Each game decides on its own security policy.</p>
6257
6258         <p>
6259           Games which require protected, privileged access to
6260           high-score files, savegames, etc., may be made
6261           set-<em>group</em>-id (mode 2755) and owned by
6262           <tt>root.games</tt>, and use files and directories with
6263           appropriate permissions (770 <tt>root.games</tt>, for
6264           example).  They must not be made
6265           set-<em>user</em>-id, as this causes security problems. (If
6266           an attacker can subvert any set-user-id game they can
6267           overwrite the executable of any other, causing other players
6268           of these games to run a Trojan horse program.  With a
6269           set-group-id game the attacker only gets access to less
6270           important game data, and if they can get at the other
6271           players' accounts at all it will take considerably more
6272           effort.)</p>
6273
6274         <p>
6275           Some packages, for example some fortune cookie programs, are
6276           configured by the upstream authors to install with their
6277           data files or other static information made unreadable so
6278           that they can only be accessed through set-id programs
6279           provided.  You should not do this in a Debian package: anyone can
6280           download the <tt>.deb</tt> file and read the data from it,
6281           so there is no point making the files unreadable.  Not
6282           making the files unreadable also means that you don't have
6283           to make so many programs set-id, which reduces the risk of a
6284           security hole.</p>
6285
6286         <p>
6287           As described in the FHS, binaries of games should be
6288           installed in the directory <tt>/usr/games</tt>. This also
6289           applies to games that use the X Window System. Manual pages
6290           for games (X and non-X games) should be installed in
6291           <tt>/usr/share/man/man6</tt>.</p>
6292       </sect>
6293     </chapt>
6294
6295     <chapt><heading>Documentation</heading>
6296
6297
6298       <sect>
6299         <heading>Manual pages</heading>
6300
6301         <p>
6302           You should install manual pages in <prgn>nroff</prgn> source
6303           form, in appropriate places under <tt>/usr/share/man</tt>.  You
6304           should only use sections 1 to 9 (see the FHS for more
6305           details).  You must not install a preformatted `cat
6306           page'.</p>
6307
6308         <p>
6309           Each program, utility, and function should have an
6310           associated manpage included in the same package. It is
6311           suggested that all configuration files also have a manual
6312           page included as well.
6313         </p>
6314
6315         <p>
6316           If no manual page is available for a particular program,
6317           utility, function or configuration file and this is reported as a bug on
6318           debian-bugs, a symbolic link from the requested manual page
6319           to the <manref name="undocumented" section="7"> manual page
6320           may be provided.  This symbolic link can be created from
6321           <tt>debian/rules</tt> like this:
6322           <example>
6323             ln -s ../man7/undocumented.7.gz \
6324             debian/tmp/usr/share/man/man[1-9]/the_requested_manpage.[1-9].gz
6325           </example>
6326           This manpage claims that the lack of a manpage has been
6327           reported as a bug, so you may only do this if it really has
6328           (you can report it yourself, if you like).  Do not close the
6329           bug report until a proper manpage is available.</p>
6330
6331         <p>
6332           You may forward a complaint about a missing manpage to the
6333           upstream authors, and mark the bug as forwarded in the
6334           Debian bug tracking system.  Even though the GNU Project do
6335           not in general consider the lack of a manpage to be a bug,
6336           we do--if they tell you that they don't consider it a bug
6337           you should leave the bug in our bug tracking system open
6338           anyway.</p>
6339
6340         <p>
6341           Manual pages should be installed compressed using <tt>gzip
6342             -9</tt>.</p>
6343
6344         <p>
6345           If one manpage needs to be accessible via several names it
6346           is better to use a symbolic link than the <tt>.so</tt>
6347           feature, but there is no need to fiddle with the relevant
6348           parts of the upstream source to change from <tt>.so</tt> to
6349           symlinks--don't do it unless it's easy.  You should not create hard
6350           links in the manual page directories, nor put
6351           absolute filenames in <tt>.so</tt> directives.  The filename
6352           in a <tt>.so</tt> in a manpage should be relative to the
6353           base of the manpage tree (usually
6354           <tt>/usr/share/man</tt>).</p></sect>
6355
6356
6357       <sect>
6358         <heading>Info documents</heading>
6359
6360         <p>
6361           Info documents should be installed in <tt>/usr/share/info</tt>.
6362           They should be compressed with <tt>gzip -9</tt>.</p>
6363
6364         <p>
6365           Your package should call <prgn>install-info</prgn> to update the Info
6366           <tt>dir</tt>
6367           file, in its post-installation script:
6368           <example>
6369             install-info --quiet --section Development Development \
6370             /usr/share/info/foobar.info
6371           </example></p>
6372
6373         <p>
6374           It is a good idea to specify a section for the location of
6375           your program; this is done with the <tt>--section</tt>
6376           switch.  To determine which section to use, you should look
6377           at <tt>/usr/share/info/dir</tt> on your system and choose the most
6378           relevant (or create a new section if none of the current
6379           sections are relevant).  Note that the <tt>--section</tt>
6380           flag takes two arguments; the first is a regular expression
6381           to match (case-insensitively) against an existing section,
6382           the second is used when creating a new one.</p>
6383
6384         <p>
6385           You should remove the entries in the pre-removal script:
6386           <example>
6387             install-info --quiet --remove /usr/share/info/foobar.info
6388           </example></p>
6389
6390         <p>
6391           If <prgn>install-info</prgn> cannot find a description entry
6392           in the Info file you must supply one.  See <manref
6393                                                              name="install-info" section="8"> for details.</p>
6394       </sect>
6395
6396       <sect>
6397         <heading>Additional documentation</heading>
6398
6399         <p>
6400           Any additional documentation that comes with the package may
6401           be installed at the discretion of the package maintainer.
6402           Text documentation should be installed in a directory
6403           <tt>/usr/share/doc/<var>package</var></tt>, where
6404           <var>package</var> is the name of the package, and
6405           compressed with <tt>gzip -9</tt> unless it is small.</p>
6406
6407         <p>
6408           If a package comes with large amounts of documentation which
6409           many users of the package will not require you should create
6410           a separate binary package to contain it, so that it does not
6411           take up disk space on the machines of users who do not need
6412           or want it installed.</p>
6413
6414         <p>
6415           It is often a good idea to put text information files
6416           (<tt>README</tt>s, changelogs, and so forth) that come with
6417           the source package in <tt>/usr/share/doc/<var>package</var></tt>
6418           in the binary package.  However, you don't need to install
6419           the instructions for building and installing the package, of
6420           course!</p>
6421
6422         <p>
6423           Files in <tt>/usr/share/doc</tt> should not be referenced by
6424           any program, and the system administrator should be able to
6425           delete them without causing any programs to break. Any files
6426           that are referenced by programs but are also useful as
6427           standalone documentation should be installed under
6428           <tt>/usr/share/&lt;package&gt;/</tt> and symlinked in
6429           <tt>/usr/share/doc/&lt;package&gt;/</tt>.
6430         </p>
6431
6432       </sect>
6433
6434       <sect id="usrdoc">
6435         <heading>Accessing the documentation</heading>
6436
6437         <p>
6438           Former Debian releases placed all additional documentation
6439           in <tt>/usr/doc/<var>package</var></tt>.  To realize a
6440           smooth migration to
6441           <tt>/usr/share/doc/<var>package</var></tt>, each package
6442           must maintain a symlink <tt>/usr/doc/<var>package</var></tt>
6443           that points to the new location of its documentation in
6444           <tt>/usr/share/doc/<var>package</var></tt><footnote>These
6445               symlinks will be removed in the future, but they have to be
6446               there for compatibility reasons until all packages have
6447               moved and the policy is changed accordingly.</footnote>.
6448           The symlink must be created when the package is installed;
6449           it cannot be contained in the package itself due to problems
6450           with <prgn>dpkg</prgn>. One reasonable way to accomplish
6451           this is to put the following in the package's
6452           <prgn>postinst</prgn>:
6453           <example>
6454             if [ "$1" = "configure" ]; then
6455             if [ -d /usr/doc -a ! -e /usr/doc/#PACKAGE# \
6456             -a -d /usr/share/doc/#PACKAGE# ]; then
6457             ln -sf ../share/doc/#PACKAGE# /usr/doc/#PACKAGE#
6458             fi
6459             fi
6460           </example>
6461           And the following in the package's <prgn>prerm</prgn>:
6462           <example>
6463             if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \
6464             -a -L /usr/doc/#PACKAGE# ]; then
6465             rm -f /usr/doc/#PACKAGE#
6466             fi
6467           </example>
6468         </p>
6469       </sect>
6470
6471       <sect>
6472         <heading>Preferred documentation formats</heading>
6473
6474         <p>
6475           The unification of Debian documentation is being carried out
6476           via HTML.</p>
6477
6478         <p>
6479           If your package comes with extensive documentation in a
6480           mark up format that can be converted to various other formats
6481           you should if possible ship HTML versions in a binary
6482           package, in the directory
6483           <tt>/usr/share/doc/<var>appropriate package</var></tt> or its
6484           subdirectories.
6485           <footnote>
6486             <p>The rationale: The important thing here is that HTML
6487               docs should be available in <em>some</em> package, not
6488               necessarily in the main binary package, though. </p>
6489           </footnote>
6490         </p>
6491
6492         <p>
6493           Other formats such as PostScript may be provided at your
6494           option.</p>
6495       </sect>
6496
6497       <sect id="copyrightfile">
6498         <heading>Copyright information</heading>
6499
6500         <p>
6501           Every package must be accompanied by a verbatim copy of its
6502           copyright and distribution license in the file
6503           /usr/share/doc/&lt;package-name&gt;/copyright. This file must
6504           neither be compressed nor be a symbolic link.</p>
6505
6506         <p>
6507           In addition, the copyright file must say where the upstream
6508           sources (if any) were obtained, and should explain briefly what
6509           modifications were made in the Debian version of the package
6510           compared to the upstream one.  It should name the original
6511           authors of the package and the Debian maintainer(s) who were
6512           involved with its creation.</p>
6513
6514         <p>
6515           A copy of the file which will be installed in
6516           <tt>/usr/share/doc/<var>package</var>/copyright</tt> should be
6517           in <tt>debian/copyright</tt>.</p>
6518
6519
6520         <p>
6521           /usr/share/doc/&lt;package-name&gt; may be a symbolic link to a
6522           directory in /usr/share/doc only if two packages both come from
6523           the same source and the first package has a "Depends"
6524           relationship on the second.  These rules are important
6525           because copyrights must be extractable by mechanical
6526           means.</p>
6527
6528         <p>
6529           Packages distributed under the UCB BSD license, the Artistic
6530           license, the GNU GPL, and the GNU LGPL should refer to the
6531           files /usr/share/common-licenses/BSD,
6532           /usr/share/common-licenses/Artistic,
6533           /usr/share/common-licenses/GPL, and
6534           /usr/share/common-licenses/LGPL.
6535           <footnote>
6536             <p>
6537               Why "licenses" and not "copyright"? Because
6538               <tt>/usr/doc/copyright</tt> used to contain all the
6539               copyright files, plus the four common licenses GPL,
6540               LGPL, Artistic and BSD. Now individual copyright files
6541               for packages are no longer in a common directory. Once
6542               <tt>/usr/doc/copyright</tt> is almost empty it makes
6543               sense to rename "copyright" to "licenses"
6544             </p>
6545             <p>
6546               Why "common-licenses" and not "licenses"? Because if I
6547               put just "licenses" I'm sure I will receive a bug report
6548               saying "license foo is not included in the licenses
6549               directory. They are not all the licenses, just a few
6550               common ones. I could use /usr/share/doc/common-licenses
6551               but I think this is too long, and, after all, the GPL
6552               does not "document" anything, it is merely a license.
6553             </p>
6554           </footnote>
6555         </p>
6556
6557         <p>
6558           You should not use the copyright file as a general <tt>README</tt>
6559           file.  If your package has such a file it should be
6560           installed in <tt>/usr/share/doc/<var>package</var>/README</tt> or
6561           <tt>README.Debian</tt> or some other appropriate place.</p>
6562       </sect>
6563
6564       <sect>
6565         <heading>Examples</heading>
6566
6567         <p>
6568           Any examples (configurations, source files, whatever),
6569           should be installed in a directory
6570           <tt>/usr/share/doc/<var>package</var>/examples</tt>.  These
6571           files should not be referenced by any program--they're there
6572           for the benefit of the system administrator and users, as
6573           documentation only. Architecture-specific example files
6574           should be installed in a directory
6575           <tt>/usr/lib/<var>package</var>/examples</tt>, and files in
6576           <tt>/usr/share/doc/<var>package</var>/examples</tt> symlink
6577           to files in it. Or the latter directory may be a symlink to
6578           the former.</p>
6579       </sect>
6580
6581       <sect id="instchangelog">
6582         <heading>Changelog files</heading>
6583
6584         <p>
6585           Packages that are not Debian-native must contain a copy of
6586           <tt>debian/changelog</tt> file from the Debian source tree
6587           in <tt>/usr/share/doc/<var>package</var></tt> as
6588           <tt>changelog.Debian.gz</tt>. If an upstream changelog is
6589           available, it should be accessible as
6590           <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt> in
6591           plain text. If the upstream changelog is distributed in
6592           HTML, it should be made available in that form as
6593           <tt>/usr/share/doc/<var>package</var>/changelog.html.gz</tt>
6594           and the <tt>changelog.gz</tt> should be generated using, eg,
6595           <tt>lynx -dump -nolist</tt>. If the upstream changelog files
6596           do not already conform to this naming convention, then this
6597           may be achieved either by renaming the files, or adding a
6598           symbolic link, at the maintainer's discretion.
6599           <footnote>
6600             <p>
6601               Rationale: People should not have to look into two
6602               places for upstream changelogs merely because they are
6603               in HTML format.
6604             </p>
6605           </footnote>
6606         </p>
6607
6608
6609         <p>
6610           All these files should be installed compressed using <tt>gzip -9</tt>,
6611           as they will become large with time even if they start out
6612           small.
6613         </p>
6614
6615         <p>
6616           If the package has only one changelog which is used both as
6617           the Debian changelog and the upstream one because there is
6618           no separate upstream maintainer then that changelog should
6619           usually be installed as
6620           <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>; if
6621           there is a separate upstream maintainer, but no upstream
6622           changelog, then the Debian changelog should still be called
6623           <tt>changelog.Debian.gz</tt>.</p>
6624       </sect>
6625     </chapt>
6626   </book>
6627 </debiandoc>