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