]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
Added must/should/may stuff, typo fixes in the policy and rules files, as well as...
[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>Richard Braakman <email>dark@xs4all.nl</email></p>
59           </item>
60           <item>
61             <p>Philip Hands <email>phil@hands.com</email></p>
62           </item>
63           <item>
64             <p>Julian Gilbey <email>J.D.Gilbey@qmw.ac.uk</email></p>
65           </item>
66           <item>
67             <p>Manoj Srivastava <email>srivasta@debian.org</email></p>
68           </item>
69         </enumlist>
70       </abstract>
71
72
73       <copyright>
74         <copyrightsummary>
75           Copyright &copy;1996,1997,1998 Ian Jackson
76           and Christian Schwarz.
77         </copyrightsummary>
78         <p>
79           This manual is free software; you may redistribute it and/or
80           modify it under the terms of the GNU General Public License
81           as published by the Free Software Foundation; either version
82           2, or (at your option) any later version.
83         </p>
84
85         <p>
86           This is distributed in the hope that it will be useful, but
87           <em>without any warranty</em>; without even the implied
88           warranty of merchantability or fitness for a particular
89           purpose.  See the GNU General Public License for more
90           details.
91         </p>
92
93         <p>
94           A copy of the GNU General Public License is available as
95           <tt>/usr/share/common-licences/GPL</tt> in the Debian GNU/Linux
96           distribution or on the World Wide Web at 
97           <url id="http://www.gnu.org/copyleft/gpl.html" 
98           name="The GNU Public Licence">. You can also obtain it by writing to the
99           Free Software Foundation, Inc., 59 Temple Place - Suite 330,
100           Boston, MA 02111-1307, USA.
101         </p>
102       </copyright>
103     </titlepag>
104
105     <toc detail="sect">
106     
107     <chapt id="scope">
108       <heading>About this manual</heading>
109       <sect>
110         <heading>Scope</heading>
111         <p>
112           This manual describes the policy requirements for the Debian
113           GNU/Linux distribution. This includes the structure and
114           contents of the Debian archive, several design issues of the
115           operating system, as well as technical requirements that
116           each package must satisfy to be included in the
117           distribution.
118           </p>
119         <p>
120           In this manual, the words <em>must</em>, <em>should</em> and
121           <em>may</em>, and the adjectives <em>required></em>,
122           <em>recommended</em> and <em>optional</em>, are used to
123           distinguish the significance of the various guidelines in
124           this policy document. Packages that do not conform the the
125           guidelines denoted by <em>must</em> (or <em>required</em>)
126           will generally not be considered acceptable for the Debian
127           distribution. Non-conformance with guidelines denoted by
128           <em>should</em> (or <em>recommended</em>) will generally be
129           considered a bug, but will not necessarily render a package
130           unsuitable for distribution. Guidelines denoted by
131           <em>may</em> (or <em>optional</em>) are truly optional and
132           adherence is left to the maintainer's discretion.
133         </p>
134         <p>
135           These classifications are roughly equivalent to the bug
136           severities <em>important</em> (for <em>must</em> or
137           <em>required</em> directive violations), <em>normal</em>
138           (for <em>should</em> or <em>recommended</em> directive
139           violations) and <em>wishlist</em> (for <em>optional</em>
140           items). <footnote>
141             <p>Also see RFC 2119.</p>
142           </footnote>
143         </p>
144         <p>
145           This manual does <em>not</em> describe the technical
146           mechanisms involved in package creation, installation, and
147           removal.  This information can be found in the <em>Debian
148           Packaging Manual</em> and the <em>Debian System
149             Administrators' Manual</em>. Please note that the
150           footnotes present in this manual are merely informative,
151           and are not part of Debian policy itself. 
152         </p>
153         <p>
154           This document assumes familiarity with these other two
155           manuals.  Unfortunately, the <em>System Administrators'
156           Manual</em> does not exist yet.
157         </p>
158         <p>
159           Much of the information presented in this manual will be
160           useful even when building a package which is to be
161           distributed in some other way or is for local use.
162         </p>
163       </sect>
164       <sect>
165         <heading>New versions of this document</heading>
166         <p>
167           The current version of this document is always accessible from the
168           Debian FTP server <ftpsite>ftp.debian.org</ftpsite> at
169           <ftppath>/debian/doc/package-developer/debian-policy.html.tar.gz</ftppath>
170           or from the Debian WWW server at
171           <url id="http://www.debian.org/doc/debian-policy/"
172           name="The Debian Policy Manual">.</p>
173
174         <p>
175           In addition, this manual is distributed via the Debian package
176           <tt>debian-policy</tt>.
177         </p>
178       </sect>
179       <sect>
180         <heading>Feedback</heading>
181
182         <p>
183           As the Debian GNU/Linux system is continuously evolving this
184           manual is changed from time to time.
185         </p>
186         <p>
187           While the authors of this document tried hard not to include
188           any typos or other errors these still occur. If you discover
189           an error in this manual or if you want to tell us any
190           comments, suggestions, or critics please send an email to
191           the Debian Policy List,
192           <email>debian-policy@lists.debian.org</email>, or submit a
193           bug report against the <tt>debian-policy</tt> package.
194         </p>
195       </sect>
196     </chapt>
197     <chapt>
198       <heading>The Debian Archive</heading>
199       <p>
200         The Debian GNU/Linux system is maintained and distributed as a
201         collection of <em>packages</em>. Since there are so many of them (over
202         2600) they are split into <em>sections</em> and <em>priorities</em> to
203         simplify handling of them.
204       </p>
205       <p>
206         The effort of the Debian project is to build a free operating
207         system, but not every package we want to make accessible is
208         <em>free</em> in our sense (see Debian Free Software
209         Guidelines, below), or may be imported/exported without
210         restrictions. Thus, the archive is split into the sections
211         <em>main</em>, <em>non-us</em>, <em>non-free</em>, and
212         <em>contrib</em>.</p>
213       <p>
214         The <em>main</em> section forms the <em>Debian GNU/Linux
215         distribution</em>. </p>
216       <p>
217         Packages in the other sections are not considered as part of
218         the Debian distribution, though we support their use, and we
219         provide infrastructure for them (such as our bug-tracking
220         system and mailing lists). This Debian Policy Manual applies
221         to these packages as well.</p>
222
223       <sect id="pkgcopyright">
224         <heading>Package copyright and sections</heading>
225         <p>
226           The aims of this policy are:
227
228           <list compact="compact">
229             <item>
230               <p>We want to make as much software available as we
231                 can.</p>
232             </item>
233             <item>
234               <p>We want to encourage everyone to write free software.</p>
235             </item>
236             <item>
237                 <p> We want to make it easy for people to produce
238                 CD-ROMs of our system without violating any licenses,
239                 import/export restrictions, or any other laws.</p>
240             </item>
241           </list>
242         </p>
243       <sect1>
244         <heading>The Debian Free Software Guidelines</heading>
245         <p>
246           The Debian Free Software Guidelines (DFSG) is our
247           definition of `free' software.
248           <taglist>
249             <tag>Free Redistribution
250             </tag>
251             <item>
252               <p>
253                 The license of a Debian component may not restrict any
254                 party from selling or giving away the software as a
255                 component of an aggregate software distribution
256                 containing programs from several different
257                 sources. The license may not require a royalty or
258                 other fee for such sale.
259               </p>
260             </item>
261             <tag>Source Code
262             </tag>
263             <item>
264               <p>
265                 The program must include source code, and must allow
266                 distribution in source code as well as compiled form.
267               </p>
268             </item>
269             <tag>Derived Works
270             </tag>
271             <item>
272               <p>
273                 The license must allow modifications and derived
274                 works, and must allow them to be distributed under the
275                 same terms as the license of the original software.
276               </p>
277             </item>
278             <tag>Integrity of The Author's Source Code
279             </tag>
280             <item>
281               <p>
282                 The license may restrict source-code from being
283                 distributed in modified form <em>only</em> if the
284                 license allows the distribution of ``patch files''
285                 with the source code for the purpose of modifying the
286                 program at build time. The license must explicitly
287                 permit distribution of software built from modified
288                 source code. The license may require derived works to
289                 carry a different name or version number from the
290                 original software.  (This is a compromise. The Debian
291                 group encourages all authors to not restrict any
292                 files, source or binary, from being modified.)
293               </p>
294             </item>
295             <tag>No Discrimination Against Persons or Groups
296             </tag>
297             <item>
298               <p>
299                 The license must not discriminate against any person
300                 or group of persons.
301               </p>
302             </item>
303             <tag>No Discrimination Against Fields of Endeavor
304             </tag>
305             <item>
306               <p>
307                 The license must not restrict anyone from making use
308                 of the program in a specific field of endeavor. For
309                 example, it may not restrict the program from being
310                 used in a business, or from being used for genetic
311                 research.
312               </p>
313             </item>
314             <tag>Distribution of License
315             </tag>
316             <item>
317               <p>
318                 The rights attached to the program must apply to all
319                 to whom the program is redistributed without the need
320                 for execution of an additional license by those
321                 parties.
322               </p>
323             </item>
324             <tag>License Must Not Be Specific to Debian
325             </tag>
326             <item>
327               <p>
328                 The rights attached to the program must not depend on
329                 the program's being part of a Debian system. If the
330                 program is extracted from Debian and used or
331                 distributed without Debian but otherwise within the
332                 terms of the program's license, all parties to whom
333                 the program is redistributed must have the same
334                 rights as those that are granted in conjunction with
335                 the Debian system.
336               </p>
337             </item>
338             <tag>License Must Not Contaminate Other Software
339             </tag>
340             <item>
341               <p>
342                 The license must not place restrictions on other
343                 software that is distributed along with the licensed
344                 software. For example, the license must not insist
345                 that all other programs distributed on the same medium
346                 must be free software.
347               </p>
348             </item>
349             <tag>Example Licenses
350             </tag>
351             <item>
352               <p>
353                 The ``GPL,'' ``BSD,'' and ``Artistic'' licenses are
354                 examples of licenses that we consider <em>free</em>.
355               </p>
356             </item>
357           </taglist>
358         </p>
359       </sect1>
360       <sect1>
361         <heading>The main section</heading>
362         <p>
363           Every package in "main" must comply with the DFSG (Debian
364           Free Software Guidelines).</p>
365
366         <p>
367           In addition, the packages in "main"
368           <list compact="compact">
369             <item>
370               <p>
371                 must not require a package outside of "main" for
372                 compilation or execution (thus, the package must not
373                 declare a "Depends" or "Recommends" relationship on a
374                 non-main package),
375               </p>
376             </item>
377             <item>
378               <p>
379                 should not be so buggy that we refuse to support them,
380               </p>
381             </item>
382             <item>
383               <p>
384                 should meet all policy requirements presented in this
385                 manual.
386               </p>
387             </item>
388           </list>
389         </p>
390       </sect1>
391       <sect1>
392         <heading>The contrib section</heading>
393         <p>
394           Every package in "contrib" must comply with the DFSG.
395         </p>
396
397         <p>
398           Examples of packages which would be included in "contrib" are
399           <list compact="compact">
400             <item>
401               <p>
402                 free packages which require "contrib", "non-free", or
403                 "non-US" packages or packages which are not in our
404                 archive at all for compilation or execution,
405               </p>
406             </item>
407             <item>
408               <p>
409                 wrapper packages or other sorts of free accessories for
410                 non-free programs,
411               </p>
412             </item>
413           </list>
414         </p>
415       </sect1>
416       <sect1>
417         <heading>The non-free section</heading>
418         <p>
419           `Non-free' contains packages which are not compliant with
420           the DFSG or which are encumbered by patents or other legal
421           issues that make their distribution problematic.</p>
422         <p>
423           All packages in `non-free' must be electronically
424           distributable across international borders.
425         </p>
426       </sect1>
427       <sect1>
428         <heading>The non-us server</heading>
429         <p>
430           Some programs with cryptographic program code need to be stored
431           on the "non-us" server because of export restrictions of the
432           U.S.</p>
433         <p>
434           This applies only to packages which contain cryptographic
435           code. A package containing a program with an interface to a
436           cryptographic program or a program that's dynamically linked
437           against a cryptographic library should not be distributed
438           via the non-us server if it is capable of running without the
439           cryptography library or program.
440         </p>
441       </sect1>
442       <sect1>
443         <heading>Further copyright considerations</heading>
444         <p>
445           Every package must be accompanied by a verbatim copy of its
446           copyright and distribution license in the file
447           /usr/share/doc/&lt;package-name&gt;/copyright (see <ref
448           id="copyrightfile"> for details).</p>
449         <p>
450           We reserve the right to restrict files from being included
451           anywhere in our archives if
452           <list compact="compact">
453             <item>
454               <p>
455                 their use or distribution would break a law,
456               </p>
457             </item>
458             <item>
459               <p>
460                 there is an ethical conflict in their distribution or
461                 use,
462               </p>
463             </item>
464             <item>
465               <p>
466                 we would have to sign a license for them, or
467               </p>
468             </item>
469             <item>
470               <p>
471                 their distribution would conflict with other project
472                 policies.
473               </p>
474             </item>
475           </list>
476         </p>
477
478         <p>
479           Programs whose authors encourage the user to make donations
480           are fine for the main distribution, provided that the
481           authors do not claim that not donating is immoral,
482           unethical, illegal or something similar; otherwise they must
483           go in non-free.</p>
484
485         <p>
486           Packages whose copyright permission notices (or patent
487           problems) do not allow redistribution even of only binaries,
488           and where no special permission has been obtained, must not be
489           placed on the Debian FTP site and its mirrors at all.</p>
490
491         <p>
492           Note, that under international copyright law (this applies
493           in the United States, too) <em>no</em> distribution or
494           modification of a work is allowed without an explicit notice
495           saying so.  Therefore a program without a copyright notice
496           <em>is</em> copyrighted and you may not do anything to it
497           without risking being sued! Likewise if a program has a
498           copyright notice but no statement saying what is permitted
499           then nothing is permitted.</p>
500
501         <p>
502           Many authors are unaware of the problems that restrictive
503           copyrights (or lack of copyright notices) can cause for the
504           users of their supposedly-free software.  It is often
505           worthwhile contacting such authors diplomatically to ask
506           them to modify their license terms. However, this is a
507           politically difficult thing to do and you should ask for
508           advice on <tt>debian-devel</tt> first.</p>
509
510         <p>
511           When in doubt, send mail to
512           <email>debian-devel@lists.debian.org</email>.  Be prepared
513           to provide us with the copyright statement.  Software
514           covered by the GPL, public domain software and BSD-like
515           copyrights are safe; be wary of the phrases `commercial use
516           prohibited' and `distribution restricted'.</p>
517       </sect1>
518       <sect1>
519         <heading>Subsections</heading>
520
521         <p>
522           The packages in all the sections (<em>main</em>,
523           <em>contrib</em>, <em>non-US/main</em>, <em>non-free</em>,
524           <em>non-US/contrib</em>, and <em>non-US/non-free</em>) are
525           grouped further into <em>subsections</em> to simplify
526           handling.</p>
527
528         <p>
529           The section for each package should be specified in the
530           package's <em>control record</em>. However, the maintainer of
531           the Debian archive may override this selection to assure the
532           consistency of the Debian distribution. </p>
533
534         <p>
535           Please check the current Debian distribution to see which
536           sections are available.</p>
537       </sect1>
538       <sect>
539         <heading>Priorities</heading>
540           
541         <p>
542           Each package should have a <em>priority</em> value,
543           which is included in the package's <em>control
544           record</em>. This information is used in the Debian package
545           management tool to separate high-priority packages from
546           less-important packages.</p>
547           
548         <p>
549           The following <em>priority levels</em> are supported by the
550           Debian package management system, <prgn>dpkg</prgn>.
551           <taglist>
552             <tag><tt>required</tt></tag>
553             <item>
554               <p>
555                 <tt>required</tt> packages are necessary for the
556                 proper functioning of the system.  You must not remove
557                 these packages or your system may become totally
558                 broken and you may not even be able to use
559                 <prgn>dpkg</prgn> to put things back.  Systems with
560                 only the <tt>required</tt> packages are probably
561                 unusable, but they do have enough functionality to
562                 allow the sysadmin to boot and install more
563                 software.</p>
564             </item>
565             <tag><tt>important</tt></tag>
566             <item>
567               <p>
568                 Important programs, including those which one would
569                 expect to find on any Unix-like system.  If the
570                 expectation is that an experienced Unix person who
571                 found it missing would say `What the F*!@&lt;+ is
572                 going on, where is <prgn>foo</prgn>', it must be in
573                 <tt>important</tt>.  This is an important criterion
574                 because we are trying to produce, amongst other
575                 things, a free Unix.  Other packages without which the
576                 system will not run well or be usable must also be
577                 here.  This does <em>not</em> include Emacs, the X
578                 Window System, TeX or any other large applications.
579                 The <tt>important</tt> packages are just a bare
580                 minimum of commonly-expected and necessary tools.</p>
581             </item>
582             <tag><tt>standard</tt></tag>
583             <item>
584               <p>               
585                 These packages provide a reasonably small but not too
586                 limited character-mode system.  This is what will
587                 install by default if the user doesn't select anything
588                 else.  It doesn't include many large applications, but
589                 it does include Emacs (this is more of a piece of
590                 infrastructure than an application) and a reasonable
591                 subset of TeX and LaTeX (if this is possible without
592                 X).</p>
593             </item>
594             <tag><tt>optional</tt></tag>
595             <item>
596               <p>               
597                 (In a sense everything is optional that isn't
598                 required, but that's not what is meant here.) This is
599                 all the software that you might reasonably want to
600                 install if you didn't know what it was or don't have
601                 specialized requirements. This is a much larger system
602                 and includes the X Window System, a full TeX distribution,
603                 and many applications. Note that optional packages should
604                 not conflict with each other.
605               </p>
606             </item>
607             <tag><tt>extra</tt></tag>
608             <item>
609               <p>
610                 This contains all packages that conflict with others
611                 with required, important, standard or optional
612                 priorities, or are only likely to be useful if you
613                 already know what they are or have specialised
614                 requirements.
615               </p>
616             </item>
617           </taglist></p>
618           
619         <p>
620           Packages must not depend on packages with lower priority
621           values (excluding build-time dependencies).  In order to
622           ensure this, the priorities of one or more packages must
623           be adjusted.
624         </p>
625       </sect>
626           
627       <sect>
628         <heading>Binary packages</heading>
629           
630         <p>
631           The Debian GNU/Linux distribution is based on the Debian
632           package management system, called <prgn>dpkg</prgn>. Thus,
633           all packages in the Debian distribution must be provided
634           in the <tt>.deb</tt> file format.</p>
635           
636         
637         <sect1>
638           <heading>The package name</heading>
639             
640           <p>
641             Every package must have a name that's unique within the Debian
642             archive.</p>
643             
644           <p>
645             Package names must only consist of lower case letters, digits (0-9),
646             plus (+) or minus (-) signs, and periods (.).</p>
647             
648           <p>
649             The package name is part of the file name of the
650             <tt>.deb</tt> file and is included in the control field
651             information.
652           </p>
653         </sect1>
654                 
655         <sect1>
656           <heading>The maintainer of a package</heading>
657             
658           <p>
659             Every package should have exactly one maintainer at a
660             time. This person is responsible that the license of the
661             package's software complies with the policy of the
662             distribution this package is included in.</p>
663             
664           <p>
665             The maintainer must be specified in the
666             <tt>Maintainer</tt> control field with the correct name
667             and a working email address for the Debian maintainer of
668             the package.  If one person maintains several packages
669             he/she should try to avoid having different forms of their
670             name and email address in different <tt>Maintainer</tt>
671             fields.</p>
672             
673           <p>
674             If the maintainer of a package quits from the Debian
675             project the Debian QA Group
676             <email>debian-qa@lists.debian.org</email> takes over the
677             maintainership of the package until someone else
678             volunteers for that task. These packages are called
679             <em>orphaned packages</em>.
680           </p>
681         </sect1>
682             
683             
684         <sect1>
685           <heading>The description of a package</heading>
686             
687           <p>
688             Every Debian package must have an extended description
689             stored in the appropriate field of the control record.</p>
690             
691           <p>
692             The description should be written so that it tells the user
693             what they need to know to decide whether to install the
694             package. This description should not just be copied from
695             the blurb for the program.  Instructions for configuring
696             or using the package should not be included -- that is what
697             installation scripts, manual pages, Info files, etc. are
698             for.  Copyright statements and other administrivia should
699             not be included -- that is what the copyright file is
700             for.</p>
701         </sect1>
702             
703             
704         <sect1>
705           <heading>Dependencies</heading>
706             
707           <p>
708             Every package must specify the dependency information
709             about other packages that are required for the first to
710             work correctly.</p>
711             
712           <p>
713             For example, a dependency entry must be provided for any
714             shared libraries required by a dynamically-linked executable
715             binary in a package.</p>
716             
717           <p>
718             Packages are not required to declare any dependencies they
719             have on other packages which are marked <tt>Essential</tt>
720             (see below), and should not do so unless they depend on a
721             particular version of that package.</p>
722             
723           <p>
724             Sometimes, a package requires another package to be installed
725             <em>and</em> configured before it can be installed. In this
726             case, you must specify a <tt>Pre-Depends</tt> entry for
727             the package.</p>
728             
729           <p>
730             You should not specify a <tt>Pre-Depends</tt> entry for a
731             package before this has been discussed on the
732             <tt>debian-devel</tt> mailing list and a consensus about
733             doing that has been reached.</p></sect1>
734             
735             
736         <sect1>
737           <heading>Virtual packages</heading>
738             
739           <p>
740             Sometimes, there are several packages doing more-or-less
741             the same job. In this case, it's useful to define a
742             <em>virtual package</em> whose name describes the function
743             the packages have. (The virtual packages just exist
744             logically, not physically--that's why they are called
745             <em>virtual</em>.) The packages with this particular
746             function will then <em>provide</em> the virtual
747             package. Thus, any other package requiring that function
748             can simply depend on the virtual package without having to
749             specify all possible packages individually.</p>
750             
751           <p>
752             All packages should use virtual package names where
753             appropriate, and arrange to create new ones if necessary.
754             They should not use virtual package names (except privately,
755             amongst a cooperating group of packages) unless they have
756             been agreed upon and appear in the list of virtual package
757             names.</p>
758             
759           <p>
760             The latest version of the authoritative list of virtual
761             package names can be found on
762             <ftpsite>ftp.debian.org</ftpsite> in
763             <ftppath>/debian/doc/package-developer/virtual-package-names-list.text</ftppath>
764             or your local mirror. In addition, it is included in the
765             <tt>debian-policy</tt> package. The procedure for updating
766             the list is described at the top of the file.</p></sect1>
767             
768             
769         <sect1>
770           <heading>Base packages</heading>
771             
772           <p>
773             The packages included in the <tt>base</tt> section have a
774             special function. They form a minimum subset of the Debian
775             GNU/Linux system that is installed before everything else
776             on a new system. Thus, only very few packages are allowed
777             to go into the <tt>base</tt> section to keep the required
778             disk usage very small.</p>
779             
780           <p>
781             Most of these packages will have the priority value
782             <tt>required</tt> or at least <tt>important</tt>, and many
783             of them will be tagged <tt>essential</tt> (see below).</p>
784             
785           <p>
786             You must not place any packages into the <tt>base</tt>
787             section before this has been discussed on the
788             <tt>debian-devel</tt> mailing list and a consensus about
789             doing that has been reached.</p></sect1>
790             
791             
792         <sect1>
793           <heading>Essential packages</heading>
794             
795           <p>
796             Some packages are tagged <tt>essential</tt>. (They have
797             <tt>Essential: yes</tt> in their package control record.)
798             This flag is used for packages that are <em>essential</em>
799             for a system.</p>
800             
801           <p>
802             Since these packages can not easily be removed (you'll
803             have to specify an extra <em>force option</em> to
804             <prgn>dpkg</prgn>) this flag must not be used unless
805             absolutely necessary.
806             
807             A shared library package must not be tagged
808             <em>essential</em>--the dependencies will prevent its
809             premature removal, and we need to be able to remove it
810             when it has been superseded.</p>
811             
812           <p>
813             You must not tag any packages <tt>essential</tt> before
814             this has been discussed on the <tt>debian-devel</tt>
815             mailing and a consensus about doing that has been
816             reached.</p></sect1>
817             
818             
819         <sect1>
820           <heading>Maintainer scripts</heading>
821             
822           <p>
823             The package installation scripts should avoid producing
824             output which it is unnecessary for the user to see and
825             should rely on <prgn>dpkg</prgn> to stave off boredom on
826             the part of a user installing many packages.  This means,
827             amongst other things, using the <tt>--quiet</tt> option on
828             <prgn>install-info</prgn>.</p>
829             
830           <p>
831             Packages should try to minimize the amount of prompting
832             they need to do, and they should ensure that the user will
833             only ever be asked each question once.  This means that
834             packages should try to use appropriate shared
835             configuration files (such as <tt>/etc/papersize</tt> and
836             <tt>/etc/news/server</tt>), rather than each prompting for
837             their own list of required pieces of information.</p>
838             
839           <p>
840             It also means that an upgrade should not ask the same
841             questions again, unless the user has used <tt>dpkg
842             --purge</tt> to remove the package's configuration.  The
843             answers to configuration questions should be stored in an
844             appropriate place in <tt>/etc</tt> so that the user can
845             modify them, and how this has been done should be
846             documented.</p>
847             
848           <p>
849             If a package has a vitally important piece of information
850             to pass to the user (such as "don't run me as I am, you
851             must edit the following configuration files first or you
852             risk your system emitting badly-formatted messages"), it
853             should display this in the <prgn>postinst</prgn> script
854             and prompt the user to hit return to acknowledge the
855             message.  Copyright messages do not count as vitally
856             important (they belong in
857             <tt>/usr/share/doc/<var>package</var>/copyright</tt>); neither
858             do instructions on how to use a program (these should be
859             in on line documentation, where all the users can see
860             them).</p>
861             
862           <p>
863             Any necessary prompting should almost always be confined
864             to the post-installation script, and should be protected
865             with a conditional so that unnecessary prompting doesn't
866             happen if a package's installation fails and the
867             <prgn>postinst</prgn> is called with
868             <tt>abort-upgrade</tt>, <tt>abort-remove</tt> or
869             <tt>abort-deconfigure</tt>.</p>
870             
871           <p>
872             Errors which occur during the execution of an installation
873             script should be checked and the installation should not
874             continue after an error.</p>
875             
876           <p>
877             Note, that <ref id="scripts">, in general applies to
878             package maintainer scripts, too.</p>
879             
880           <p>
881             You should not use <prgn>dpkg-divert</prgn> on a file
882             belonging to another package without consulting the maintainer
883             of that package first.</p>
884             
885           <p>
886             All packages which supply an instance of a common command
887             name (or, in general, filename) should generally use
888             <prgn>update-alternatives</prgn>, so that they may be
889             installed together. If <prgn>update-alternatives</prgn>
890             is not used, then each package must use <tt>Conflicts</tt>
891             to ensure that other packages are de-installed. (In this
892             case, it may be appropriate to specify a conflict against
893             earlier versions of something that previously did not use
894             <prgn>update-alternatives</prgn> -- this is an exception to
895             the usual rule that this not allowed).
896           </p>
897         </sect1>
898       </sect>
899       <sect>
900         <heading>Source packages</heading>
901           
902         <sect1>
903           <heading>Standards conformance</heading>
904             
905           <p>
906             You should specify the most recent version of the
907             packaging standards with which your package complies in
908             the source package's <tt>Standards-Version</tt> field.</p>
909             
910           <p>
911             This value will be used to file bug reports automatically
912             if your package becomes too much out of date.</p>
913             
914           <p>
915             The value corresponds to a version of the Debian manuals,
916             as can be found on the title page or page headers and
917             footers (depending on the format).</p>
918             
919           <p>
920             The version number has four components--major and minor
921             number and major and minor patch level.  When the
922             standards change in a way that requires every package to
923             change the major number will be changed.  Significant
924             changes that will require work in many packages will be
925             signaled by a change to the minor number.  The major patch
926             level will be changed for any change to the meaning of the
927             standards, however small; the minor patch level will be
928             changed when only cosmetic, typographical or other edits
929             which do not change the meaning are made, or changes which
930             do not affect the contents of packages.</p>
931
932           <p>
933             For package maintainers, only the first 3 digits of the
934             manual version are significant in representing the
935             <em>Standards-Version</em>, and either these 3 digits or
936             the complete 4 digits may be specified.
937             <footnote>
938               <p>
939                 In the past, people specified 4 digits in the
940                 Standards-Version field, like `2.3.0.0'.  Since any
941                 `patch-level changes' don't introduce new policy, it
942                 was thought it would be better to relax policy and
943                 only require that the first 3 digits are specified. (4
944                 digits may still be used if someone wants to do so.)
945               </p>
946             </footnote>
947           </p>
948             
949           <p>
950             You should regularly, and especially if your package has
951             become out of date, check for the newest Policy Manual
952             available and update your package, if necessary. When your
953             package complies with the new standards you should update the
954             <tt>Standards-Version</tt> source package field and
955             release it.</p></sect1>
956             
957             
958          <sect1>
959            <heading>Package relationships</heading>
960  
961            <p>
962              Source packages should specify which binary packages they
963              require to be installed or not to be installed in order to
964              build correctly.  For example, if building a package
965              requires a certain compiler, then the compiler should be
966              specified as a build-time dependency.
967            </p>
968  
969            <p>
970              It is not be necessary to explicitly specify build-time
971              relationships on a minimal set of packages that are always
972              needed to compile, link and put in a Debian package a
973              standard "Hello World!" program written in C or C++.  The
974              required packages are called <em>build-essential</em>, and
975              an informational list can be found in
976              <tt>/usr/share/doc/build-essential/list</tt> (which is
977              contained in the <tt>build-essential</tt> package).
978            </p>
979  
980            <p>
981              When specifying the set of build-time dependencies, one
982              should list only those packages explicitly required by the
983              build.  It is not necessary to list packages which are
984              required merely because some other package in the list of
985              build-time dependencies depends on them.  The reason is
986              that dependencies change, and you should list only those
987              <em>you</em> need.  What others need is their business.
988            </p>
989  
990            <p>
991              If build-time dependencies are specified, it must be
992              possible to build the package and produce working binaries
993              on a system with the build-essential packages installed
994              and satisfying the build-time relationships (including any
995              implied relationships).  This
996              means in particular that version clauses should be used
997              rigorously in build-time relationships so that one cannot
998              produce bad or inconsistently configured packages when the
999              relationships are properly satisfied.
1000            </p>
1001  
1002         <sect1>
1003           <heading>Changes to the upstream sources</heading>
1004             
1005           <p>
1006             If changes to the source code are made that are generally
1007             applicable, they should be sent to the upstream authors
1008             in whatever form they prefer so as to be included in the
1009             upstream version of the package.</p>
1010             
1011           <p>
1012             If you need to configure the package differently for
1013             Debian or for Linux, and the upstream source doesn't
1014             provide a way to configure it the way you need to, you
1015             should add such configuration facilities (for example, a new
1016             <prgn>autoconf</prgn> test or <tt>#define</tt>) and send
1017             the patch to the upstream authors, with the default set to
1018             the way they originally had it.  You can then easily
1019             override the default in your <tt>debian/rules</tt> or
1020             wherever is appropriate.</p>
1021             
1022           <p>
1023             You should make sure that the <prgn>configure</prgn> utility
1024             detects the correct architecture specification string
1025             (refer to <ref id="arch-spec"> for details).</p>
1026             
1027           <p>
1028             If you need to edit a <prgn>Makefile</prgn> where
1029             GNU-style <prgn>configure</prgn> scripts are used, you
1030             should edit the <tt>.in</tt> files rather than editing the
1031             <prgn>Makefile</prgn> directly.  This allows the user to
1032             reconfigure the package if necessary.  You should
1033             <em>not</em> configure the package and edit the generated
1034             <prgn>Makefile</prgn>!  This makes it impossible for
1035             someone else to later reconfigure the package.</p></sect1>
1036             
1037             
1038         <sect1>
1039           <heading>Documenting your changes</heading>
1040             
1041           <p>
1042             You should document your changes and updates to the source
1043             package properly in the <tt>debian/changelog</tt> file. (Note
1044             that mistakes in changelogs are usually best rectified by
1045             making  a new changelog entry rather than "rewriting history"
1046             by editing old changelog entries)</p>
1047             
1048           <p>
1049             A copy of the file which will be installed in
1050             <tt>/usr/share/doc/<var>package</var>/copyright</tt> should be
1051             in <tt>debian/copyright</tt>.</p>
1052             
1053           <p>
1054             In non-experimental packages you must only use a format for
1055             <tt>debian/changelog</tt> which is supported by the most
1056             recent released version of <prgn>dpkg</prgn>.  If your
1057             format is not supported and there is general support for
1058             it you should contact the <prgn>dpkg</prgn> maintainer to
1059             have the parser script for your format included in the
1060             <prgn>dpkg</prgn> package. (You will need to agree that
1061             the parser and its manpage may be distributed under the
1062             GNU GPL, just as the rest of <prgn>dpkg</prgn>
1063             is.)</p></sect1>
1064             
1065             
1066         <sect1>
1067           <heading>Error trapping in makefiles</heading>
1068             
1069           <p>
1070             When <prgn>make</prgn> invokes a command in a makefile
1071             (including your package's upstream makefiles and the
1072             <tt>debian/rules</tt>) it does so using <tt>sh</tt>.  This
1073             means that <tt>sh</tt>'s usual bad error handling
1074             properties apply: if you include a miniature script as one
1075             of the commands in your makefile you'll find that if you
1076             don't do anything about it then errors are not detected
1077             and <prgn>make</prgn> will blithely continue after
1078             problems.</p>
1079             
1080           <p>
1081             Every time you put more than one shell command (this
1082             includes using a loop) in a makefile command you
1083             must make sure that errors are trapped.  For
1084             simple compound commands, such as changing directory and
1085             then running a program, using <tt>&amp;&amp;</tt> rather
1086             than semicolon as a command separator is sufficient.  For
1087             more complex commands including most loops and
1088             conditionals you should include a separate <tt>set -e</tt>
1089             command at the start of every makefile command that's
1090             actually one of these miniature shell scripts.</p></sect1>
1091             
1092             
1093         <sect1>
1094           <heading>Obsolete constructs and libraries</heading>
1095             
1096           <p>
1097             The include file <prgn>&lt;varargs.h&gt;</prgn> is
1098             provided to support end-users compiling very old software;
1099             the library <tt>libtermcap</tt> is provided to support the
1100             execution of software which has been linked against it
1101             (either old programs or those such as Netscape which are
1102             only available in binary form).</p>
1103             
1104           <p>
1105             Debian packages should be ported to include
1106             <prgn>&lt;stdarg.h&gt;</prgn> and <tt>ncurses</tt> when
1107             they are built.</p>
1108         </sect1>
1109       </sect></chapt>
1110       
1111     <chapt><heading>The Operating System</heading>
1112         
1113       
1114       <sect>
1115         <heading>File system hierarchy</heading>
1116           
1117         
1118         <sect1>
1119           <heading>Linux File system Structure</heading>
1120             
1121           <p>
1122             The location of all installed files and directories must
1123             comply  with the Linux File system Hierarchy Standard
1124             (FHS).  The latest version of this document can be found
1125             alongside this manual or on
1126             <url id="http://www.pathname.com/fhs/">.<footnote>
1127               <p>The Debian distribution currently distributes a draft
1128                 version of FHS 2.1 because several significant details
1129                 have changed between the currently released 2.0
1130                 version and the to-be-released 2.1 version.</p>
1131             </footnote>
1132             Specific questions about following the standard may be
1133             asked on <prgn>debian-devel</prgn>, or referred to Daniel
1134             Quinlan, the FHS coordinator, at
1135             <email>quinlan@pathname.com</email>.</p></sect1>
1136             
1137             
1138         <sect1>
1139           <heading>Site-specific programs</heading>
1140             
1141           <p>
1142             As mandated by the FHS, packages must not place any
1143             files in <tt>/usr/local</tt>, either by putting them in
1144             the file system archive to be unpacked by <prgn>dpkg</prgn>
1145             or by manipulating them in their maintainer scripts.</p>
1146             
1147           <p>
1148             However, the package may create empty directories below
1149             <tt>/usr/local</tt> so that the system administrator knows
1150             where to place site-specific files. These directories
1151             should be removed on package removal if they are
1152             empty.</p>
1153             
1154           <p>
1155             Note, that this applies only to directories <em>below</em>
1156             <tt>/usr/local</tt>, not <em>in</em>
1157             <tt>/usr/local</tt>. Packages must not create sub-directories 
1158             in the directory <tt>/usr/local</tt> itself, except those listed in
1159             FHS, section 4.6. However, you may create directories
1160             below them as you wish. You must not remove any of the
1161             directories listed in 4.6, even if you created them.</p>
1162             
1163           <p>
1164             Since <tt>/usr/local</tt> can be mounted read-only from a
1165             remote server, these directories must be created and
1166             removed by the <tt>postinst</tt> and <tt>prerm</tt>
1167             maintainer scripts. These scripts must not fail if either
1168             of these operations fail. (In the future, it will be
1169             possible to tell <prgn>dpkg</prgn> not to unpack files
1170             matching certain patterns, so that the directories can be
1171             included in the <tt>.deb</tt> packages and system
1172             administrators who do not wish these directories in
1173             /usr/local do not need to have them.)</p>
1174             
1175           <p>
1176             For example, the <prgn>emacs</prgn> package will contain
1177             <example>
1178               mkdir -p /usr/local/lib/emacs/site-lisp || true
1179             </example>
1180             in the <tt>postinst</tt> script, and
1181             <example>
1182               rmdir /usr/local/lib/emacs/site-lisp && \
1183               rmdir /usr/local/lib/emacs || \
1184               true
1185             </example>
1186             in the <tt>prerm</tt> script.</p>
1187             
1188           <p>
1189             If you do create a directory in <tt>/usr/local</tt> for
1190             local additions to a package, you should ensure that
1191             settings in <tt>/usr/local</tt> take precedence over the
1192             equivalents in <tt>/usr</tt>.</p>
1193
1194           <p>
1195             However, because '/usr/local' and its contents are for
1196             exclusive use of the local administrator, a package must
1197             not rely on the presence or absence of files or
1198             directories in '/usr/local' for normal operation.</p>
1199     
1200           <p>
1201             The <tt>/usr/local</tt> directory itself and all the
1202             subdirectories created by the package should (by default) have
1203             permissions 2775 (group-writable and set-group-id) and be
1204             owned by <tt>root.staff</tt>.</p>
1205         </sect1>
1206       </sect>
1207         
1208       <sect>
1209         <heading>Users and groups</heading>
1210           
1211         <p>
1212           The Debian system can be configured to use either plain or
1213           shadow passwords.</p>
1214           
1215         <p>
1216           Some user ids (UIDs) and group ids (GIDs) are reserved
1217           globally for use by certain packages.  Because some packages
1218           need to include files which are owned by these users or
1219           groups, or need the ids compiled into binaries, these ids
1220           must be used on any Debian system only for the purpose for
1221           which they are allocated. This is a serious restriction, and
1222           we should avoid getting in the way of local administration
1223           policies. In particular, many sites allocate users and/or
1224           local system groups starting at 100.</p>
1225           
1226         <p>
1227           Apart from this we should have dynamically allocated ids,
1228           which should by default be arranged in some sensible
1229           order--but the behavior should be configurable.</p>
1230           
1231         <p>
1232           Packages other than <tt>base-passwd</tt> must not modify
1233           <tt>/etc/passwd</tt>, <tt>/etc/shadow</tt>,
1234           <tt>/etc/group</tt> or <tt>/etc/gshadow</tt>.</p>
1235           
1236         <p>
1237           The UID and GID ranges are as follows:
1238           <taglist>
1239             <tag>0-99:</tag>
1240             <item>
1241               <p>
1242                 Globally allocated by the Debian project, the
1243                 same on every Debian system.  These ids will appear in
1244                 the <tt>passwd</tt> and <tt>group</tt> files of all
1245                 Debian systems, new ids in this range being added
1246                 automatically as the <tt>base-passwd</tt> package is
1247                 updated.</p>
1248                 
1249               <p>
1250                 Packages which need a single statically allocated uid
1251                 or gid should use one of these; their maintainers
1252                 should ask the <tt>base-passwd</tt> maintainer for
1253                 ids.</p>
1254             </item>
1255                 
1256             <tag>100-999:</tag>
1257             <item>
1258               <p>
1259                 Dynamically allocated system users and groups.
1260                 Packages which need a user or group, but can have this
1261                 user or group allocated dynamically and differently on
1262                 each system, should use `<tt>adduser --system</tt>' to
1263                 create the group and/or user.  <prgn>adduser</prgn>
1264                 will check for the existence of the user or group, and
1265                 if necessary choose an unused id based on the ranged
1266                 specified in <tt>adduser.conf</tt>.</p></item>
1267                 
1268                 
1269             <tag>1000-29999:</tag>
1270             <item>
1271               <p>
1272                 Dynamically allocated user accounts.  By default
1273                 <prgn>adduser</prgn> will choose UIDs and GIDs for
1274                 user accounts in this range, though
1275                 <tt>adduser.conf</tt> may be used to modify this
1276                 behavior.</p>
1277             </item>
1278                 
1279             <tag>30000-59999:</tag>
1280             <item>
1281               <p>Reserved.</p></item>
1282                 
1283                 
1284             <tag>60000-64999:</tag>
1285             <item>
1286               <p>
1287                 Globally allocated by the Debian project, but only
1288                 created on demand. The ids are allocated centrally and
1289                 statically, but the actual accounts are only created
1290                 on users' systems on demand.</p>
1291                 
1292               <p>
1293                 These ids are for packages which are obscure or which
1294                 require many statically-allocated ids.  These packages
1295                 should check for and create the accounts in
1296                 <tt>/etc/passwd</tt> or <tt>/etc/group</tt> (using
1297                 <prgn>adduser</prgn> if it has this facility) if
1298                 necessary.  Packages which are likely to require
1299                 further allocations should have a `hole' left after
1300                 them in the allocation, to give them room to
1301                 grow.</p></item>
1302                 
1303                 
1304             <tag>65000-65533:</tag>
1305             <item>
1306               <p>Reserved.</p></item>
1307                 
1308                 
1309             <tag>65534:</tag>
1310             <item>
1311               <p>User `<tt>nobody</tt>.'</p></item>
1312                 
1313                 
1314             <tag>65535:</tag>
1315             <item>
1316               <p>
1317                 <tt>(uid_t)(-1) == (gid_t)(-1)</tt>. NOT TO BE USED,
1318                 because it is the error return sentinel value.</p>
1319             </item>
1320           </taglist>
1321         </p>
1322       </sect>
1323       <sect id="sysvinit">
1324         <heading>System run levels</heading>
1325           
1326         
1327         <sect1 id="/etc/init.d">
1328           <heading>Introduction</heading>
1329             
1330           <p>
1331             The <tt>/etc/init.d</tt> directory contains the scripts
1332             executed by <prgn>init</prgn> at boot time and when init
1333             state (or `runlevel') is changed (see <manref name="init"
1334             section="8">).</p>
1335
1336           <p>
1337             There are at least two different, yet functionally
1338             equivalent, ways of handling these scripts.  For the sake
1339             of simplicity, this document describes only the symbolic
1340             link method. However, it must not be assumed that this
1341             method is being used, and any manipulation of the various
1342             runlevel behaviours must be performed using
1343             <prgn>update-rc.d</prgn> as described below and not by
1344             manually installing symlinks.  For information on the
1345             implementation details of the other method, implemented in
1346             the <tt>file-rc</tt> package, please refer to the
1347             documentation of that package.</p>
1348
1349           <p>
1350             These scripts are referenced by symbolic links in
1351             the <tt>/etc/rc<var>n</var>.d</tt> directories.  When
1352             changing runlevels, <prgn>init</prgn> looks in the
1353             directory <tt>/etc/rc<var>n</var>.d</tt> for the scripts
1354             it should execute, where <var>n</var> is the runlevel that
1355             is being changed to, or `S' for the boot-up scripts.</p>
1356             
1357           <p>
1358             The names of the links all have the form
1359             <tt>S<var>mm</var><var>script</var></tt> or
1360             <tt>K<var>mm</var><var>script</var></tt> where
1361             <var>mm</var> is a two-digit number and <var>script</var>
1362             is the name of the script (this should be the same as the
1363             name of the actual script in <tt>/etc/init.d</tt>.</p>
1364             
1365           <p>
1366             When <prgn>init</prgn> changes runlevel first the targets
1367             of the links whose names starting with a <tt>K</tt> are
1368             executed, each with the single argument <tt>stop</tt>,
1369             followed by the scripts prefixed with an <tt>S</tt>, each
1370             with the single argument <tt>start</tt>.  The <tt>K</tt>
1371             links are responsible for killing services and the
1372             <tt>S</tt> link for starting services upon entering the
1373             runlevel.</p>
1374             
1375           <p>
1376             For example, if we are changing from runlevel 2 to
1377             runlevel 3, init will first execute all of the <tt>K</tt>
1378             prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
1379             all of the <tt>S</tt> prefixed scripts.  The links
1380             starting with <tt>K</tt> will cause the referred-to file
1381             to be executed with an argument of <tt>stop</tt>, and the
1382             <tt>S</tt> links with an argument of <tt>start</tt>.</p>
1383             
1384           <p>
1385             The two-digit number <var>mm</var> is used to decide which
1386             order to start and stop things in--low-numbered links have
1387             their scripts run first.  For example, the <tt>K20</tt>
1388             scripts will be executed before the <tt>K30</tt> scripts.
1389             This is used when a certain service must be started before
1390             another.  For example, the name server <prgn>bind</prgn>
1391             might need to be started before the news server
1392             <prgn>inn</prgn> so that <prgn>inn</prgn> can set up its
1393             access lists.  In this case, the script that starts
1394             <prgn>bind</prgn> would have a lower number than the
1395             script that starts <prgn>inn</prgn> so that it runs first:
1396             <example>
1397               /etc/rc2.d/S17bind
1398               /etc/rc2.d/S70inn
1399             </example>
1400           </p>
1401         </sect1>
1402           
1403         <sect1>
1404           <heading>Writing the scripts</heading>
1405             
1406           <p>
1407             Packages that include daemons for system services should
1408             place scripts in <tt>/etc/init.d</tt> to start or stop
1409             services at boot time or during a change of runlevel.
1410             These scripts should be named
1411             <tt>/etc/init.d/<var>package</var></tt>, and they should
1412             accept one argument, saying what to do:
1413             
1414             <taglist>
1415               <tag><tt>start</tt></tag>
1416               <item><p>start the service,</p></item>
1417                   
1418               <tag><tt>stop</tt></tag>
1419               <item><p>stop the service,</p></item>
1420                   
1421               <tag><tt>restart</tt></tag>
1422               <item><p>stop and restart the service,</p></item>
1423                   
1424               <tag><tt>reload</tt></tag>
1425               <item><p>cause the configuration of the service to be
1426                   reloaded without actually stopping and restarting
1427                   the service,</p></item>
1428                   
1429               <tag><tt>force-reload</tt></tag> <item><p>cause the
1430               configuration to be reloaded if the service supports
1431                   this, otherwise restart the service.</p></item>
1432             </taglist>
1433             
1434             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
1435             <tt>force-reload</tt> options should be supported by all
1436             scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
1437             option is optional.</p>
1438             
1439           <p>
1440             The <tt>init.d</tt> scripts should ensure that they will
1441             behave sensibly if invoked with <tt>start</tt> when the
1442             service is already running, or with <tt>stop</tt> when it
1443             isn't, and that they don't kill unfortunately-named user
1444             processes.  The best way to achieve this is usually to use
1445             <prgn>start-stop-daemon</prgn>.</p>
1446             
1447           <p>
1448             If a service reloads its configuration automatically (as
1449             in the case of <prgn>cron</prgn>, for example), the
1450             <tt>reload</tt> option of the <tt>init.d</tt> script
1451             should behave as if the configuration has been reloaded
1452             successfully.</p>
1453             
1454           <p>
1455             These scripts should not fail obscurely when the
1456             configuration files remain but the package has been
1457             removed, as configuration files remain on the system after
1458             the package has been removed. Only when <prgn>dpkg</prgn>
1459             is executed with the <tt>--purge</tt> option will
1460             configuration files be removed. In particular, the init
1461             script itself is usually a configuration file (see
1462             <ref id="init.d notes">), and will remain on the system if
1463             the package is removed but not purged. Therefore, you
1464             should include a <tt>test</tt> statement at the top of the
1465             script, like this:
1466             <example>
1467   test -f <var>program-executed-later-in-script</var> || exit 0
1468             </example></p>
1469         </sect1>
1470           
1471         <sect1>
1472           <heading>Managing the links</heading>
1473             
1474           <p>
1475             The program <prgn>update-rc.d</prgn> is provided to make
1476             it easier for package maintainers to arrange for the
1477             proper creation and removal of
1478             <tt>/etc/rc<var>n</var>.d</tt> symbolic links, or their
1479             functional equivalent if another method is being used.
1480             This may be used by maintainers in their packages'
1481             <tt>postinst</tt> and <tt>postrm</tt> scripts.</p>
1482             
1483           <p>
1484             You must use this script to make changes to
1485             <tt>/etc/rc<var>n</var>.d</tt> and <em>never</em> either
1486             include any <tt>/etc/rc<var>n</var>.d</tt> symbolic links
1487             in the actual archive or manually create or remove the
1488             symbolic links in maintainer scripts.  (The latter will
1489             fail if an alternative method of maintaining runlevel
1490             information is being used.)</p>
1491             
1492           <p>
1493             By default <prgn>update-rc.d</prgn> will start services in
1494             each of the multi-user state runlevels (2, 3, 4, and 5)
1495             and stop them in the halt runlevel (0), the single-user
1496             runlevel (1) and the reboot runlevel (6).  The system
1497             administrator will have the opportunity to customize
1498             runlevels by either running <prgn>update-rc.d</prgn>, by
1499             simply adding, moving, or removing the symbolic links in
1500             <tt>/etc/rc<var>n</var>.d</tt> if symbolic links are being
1501             used, or by modifying <tt>/etc/runlevel.conf</tt> if the
1502             <tt>file-rc</tt> method is being used.</p>
1503             
1504           <p>
1505             To get the default behavior for your package, put in your
1506             <tt>postinst</tt> script
1507             <example>
1508               update-rc.d <var>package</var> defaults &gt;/dev/null
1509             </example>
1510             and in your <tt>postrm</tt>
1511             <example>
1512               if [ purge = "$1" ]; then
1513               update-rc.d <var>package</var> remove &gt;/dev/null
1514               fi
1515             </example></p>
1516             
1517           <p>
1518             This will use a default sequence number of 20.  If it does
1519             not matter when or in which order the script is run, use
1520             this default.  If it does, then you should talk to the
1521             maintainer of the <prgn>sysvinit</prgn> package or post to
1522             <tt>debian-devel</tt>, and they will help you choose a
1523             number.</p>
1524             
1525           <p>
1526             For more information about using <tt>update-rc.d</tt>,
1527             please consult its manpage <manref name="update-rc.d"
1528             section="8">.</p></sect1>
1529             
1530             
1531         <sect1>
1532           <heading>Boot-time initialization</heading>
1533             
1534           <p>
1535             There used to be another directory, <tt>/etc/rc.boot</tt>,
1536             which contained scripts which were run once per machine
1537             boot. This has been deprecated in favour of links from
1538             <tt>/etc/rcS.d</tt> to files in <tt>/etc/init.d</tt> as
1539             described in <ref id="/etc/init.d">.  Packages must not
1540             place files in <tt>/etc/rc.boot</tt>.</p>
1541
1542         <sect1 id="init.d notes">
1543           <heading>Notes</heading>
1544             
1545           <p>
1546             <em>Do not</em> include the
1547             <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in the
1548             <tt>.deb</tt> file system archive!  <em>This will cause
1549             problems!</em> You must create them with
1550             <prgn>update-rc.d</prgn>, as above.</p>
1551         
1552           <p>
1553             <em>Do not</em> include the
1554             <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in
1555             <prgn>dpkg</prgn>'s conffiles list!  <em>This will cause
1556             problems!</em> You should, however, treat the
1557             <tt>/etc/init.d</tt> scripts as configuration files,
1558             either by marking them as conffiles or managing them
1559             correctly in the maintainer scripts (see
1560             <ref id="config files">). (This is important since we want
1561             to give the local system administrator the chance to adapt
1562             the scripts to the local system--e.g., to disable a
1563             service without de-installing the package, or to specify
1564             some special command line options when starting a
1565             service--while making sure her changes aren't lost during
1566             the next package upgrade.)</p>
1567         </sect1>
1568             
1569         <sect1>
1570           <heading>Example</heading>
1571             
1572           <p>
1573             The <prgn>bind</prgn> DNS (nameserver) package wants to
1574             make sure that the nameserver is running in multiuser
1575             runlevels, and is properly shut down with the system.  It
1576             puts a script in <tt>/etc/init.d</tt>, naming the script
1577             appropriately <tt>bind</tt>.  As you can see, the script
1578             interprets the argument <tt>reload</tt> to send the
1579             nameserver a <tt>HUP</tt> signal (causing it to reload its
1580             configuration); this way the user can say
1581             <tt>/etc/init.d/bind reload</tt> to reload the name
1582             server.</p>
1583             
1584           <p>
1585             <example>
1586               #!/bin/sh
1587               #
1588               # Original version by Robert Leslie
1589               # &lt;rob@mars.org&gt;, edited by iwj and cs
1590               
1591               test -x /usr/sbin/named || exit 0
1592               
1593               case "$1" in
1594               start)
1595               echo -n "Starting domain name service: named"
1596               start-stop-daemon --start --quiet --exec /usr/sbin/named
1597               echo "."
1598               ;;
1599               stop)
1600               echo -n "Stopping domain name service: named"
1601               start-stop-daemon --stop --quiet  \
1602               --pidfile /var/run/named.pid --exec /usr/sbin/named
1603               echo "."
1604               ;;
1605               restart)
1606               echo -n "Restarting domain name service: named"
1607               start-stop-daemon --stop --quiet  \
1608               --pidfile /var/run/named.pid --exec /usr/sbin/named
1609               start-stop-daemon --start --verbose --exec /usr/sbin/named
1610               echo "."
1611               ;;
1612               force-reload|reload)
1613               echo -n "Reloading configuration of domain name service: named"
1614               start-stop-daemon --stop --signal 1 --quiet  \
1615               --pidfile /var/run/named.pid --exec /usr/sbin/named
1616               echo "."
1617               ;;
1618               *)
1619               echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
1620               exit 1
1621               ;;
1622               esac
1623               
1624               exit 0
1625             </example></p>
1626             
1627           <p>
1628             Another example on which to base your <tt>/etc/init.d</tt>
1629             scripts is in <tt>/etc/init.d/skeleton</tt>.</p>
1630             
1631           <p>
1632             If this package is happy with the default setup from
1633             <prgn>update-rc.d</prgn>, namely an ordering number of 20
1634             and having named running in all runlevels, it can say in
1635             its <tt>postinst</tt>:
1636             <example>
1637               update-rc.d bind defaults >/dev/null
1638             </example>
1639             And in its <tt>postrm</tt>, to remove the links when the
1640             package is purged: 
1641             <example>
1642               if [ purge = "$1" ]; then
1643               update-rc.d bind remove >/dev/null
1644               fi
1645             </example></p>
1646         </sect1></sect>
1647         
1648       <sect>
1649         <heading>Cron jobs</heading>
1650           
1651         <p>
1652           Packages must not modify the configuration file
1653           <tt>/etc/crontab</tt>, and they must not modify the files in
1654           <tt>/var/spool/cron/crontabs</tt>.</p>
1655           
1656         <p>
1657           If a package wants to install a job that has to be executed
1658           via cron, it should place a file with the name if the
1659           package in one of the following directories:
1660           <example>
1661             /etc/cron.daily
1662             /etc/cron.weekly
1663             /etc/cron.monthly
1664           </example>
1665           As these directory names imply, the files within them are
1666           executed on a daily, weekly, or monthly basis,
1667           respectively. The exact times are listed in
1668           <tt>/etc/crontab</tt>.</p>
1669
1670         <p>
1671           All files installed in any of these directories must be
1672           scripts (shell scripts, Perl scripts, etc.) so that they can
1673           easily be modified by the local system administrator. In
1674           addition, they should be treated as configuration files.</p>
1675
1676         <p>
1677           If a certain job has to be executed more frequently than
1678           daily, the package should install a file
1679           <tt>/etc/cron.d/<var>package-name</var></tt>. This file uses
1680           the same syntax as <tt>/etc/crontab</tt> and is processed by
1681           <prgn>cron</prgn> automatically. The file must also be
1682           treated as a configuration file. (Note, that entries in the
1683           <tt>/etc/cron.d</tt> directory are not handled by
1684           <prgn>anacron</prgn>. Thus, you should only use this
1685           directory for jobs which may be skipped if the system is not
1686           running.)</p>
1687
1688         <p>
1689           The scripts or crontab entries in these directories should
1690           check if all necessary programs are installed before they
1691           try to execute them. Otherwise, problems will arise when a
1692           package was removed but not purged since configuration files
1693           are kept on the system in this situation.</p>
1694       </sect>
1695
1696       <sect>
1697         <heading>Console messages</heading>
1698           
1699         <p>
1700           This section describes different formats for messages
1701           written to standard output by the <tt>/etc/init.d</tt>
1702           scripts. The intent is to improve the consistency of
1703           Debian's startup and shutdown look and feel.</p>
1704           
1705         <p>
1706           Please look very careful at the details. We want to get the
1707           messages to look exactly the same way concerning spaces,
1708           punctuation, and case of letters.</p>
1709           
1710         <p>
1711           Here is a list of overall rules that you should use when you
1712           create output messages. They can be useful if you have a
1713           non-standard message that isn't covered in the sections
1714           below.</p>
1715           
1716         <p>
1717           <list>
1718             <item>
1719               <p>
1720                 Every message should cover one line, start with a
1721                 capital letter and end with a period `.'.</p></item>
1722                 
1723                 
1724             <item>  
1725               <p>
1726                 If you want to express that the computer is working on
1727                 something (performing a specific task, not starting or
1728                 stopping a program), we use an ``ellipsis'', namely
1729                 three dots `...'. Note that we don't insert spaces in
1730                 front of or behind the dots.  If the task has been
1731                 completed we write `done.' and a line feed.</p></item>
1732                 
1733                 
1734             <item>
1735               <p>
1736                 Design your messages as if the computer is telling you
1737                 what he is doing (let him be polite :-) but don't
1738                 mention ``him'' directly.  For example, if you think
1739                 of saying
1740                 <example>
1741                   I'm starting network daemons: nfsd mountd.
1742                 </example>
1743                 just say
1744                 <example>
1745                   Starting network daemons: nfsd mountd.
1746                 </example></p></item>
1747           </list></p>
1748           
1749         <p>
1750           The following formats should be used</p>
1751           
1752         <p>
1753           <list>
1754             <item>
1755               <p>when daemons get started.</p>
1756                 
1757               <p>
1758                 Use this format if your script starts one or more
1759                 daemons.  The output should look like this (a single
1760                 line, no leading spaces):
1761                 <example>
1762                   Starting &lt;description&gt;: &lt;daemon-1&gt; &lt;daemon-2&gt; &lt;...&gt; &lt;daemon-n&gt;.
1763                 </example>
1764                 The &lt;description&gt; should describe the subsystem
1765                 the daemon or set of daemons are part of, while
1766                 &lt;daemon-1&gt; up to &lt;daemon-n&gt; denote each
1767                 daemon's name (typically the file name of the
1768                 program).</p>
1769                 
1770               <p>
1771                 For example, the output of /etc/init.d/lpd would look like:
1772                 <example>
1773                   Starting printer spooler: lpd.
1774                 </example></p>
1775                 
1776               <p>
1777                 This can be achieved by saying
1778                 <example>
1779                   echo -n "Starting printer spooler: lpd"
1780                   start-stop-daemon --start --quiet lpd
1781                   echo "."
1782                 </example>
1783                 in the script. If you have more than one daemon to
1784                 start, you should do the following:
1785                 <example>
1786                   echo -n "Starting remote file system services:"
1787                   echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
1788                   echo -n " mountd"; start-stop-daemon --start --quiet mountd
1789                   echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
1790                   echo "."
1791                 </example>
1792                 This makes it possible for the user to see what takes
1793                 so long and when the final daemon has been
1794                 started. You should be careful where to put spaces: In the
1795                 example above the system administrator can easily
1796                 comment out a line if he don't wants to start a
1797                 specific daemon, while the displayed message still
1798                 looks good.</p></item>
1799                 
1800                 
1801             <item>
1802               <p>when something needs to be configured.</p>
1803                 
1804               <p>
1805                 If you have to set up different parameters of the
1806                 system upon boot up, you should use this format:
1807                 <example>
1808                   Setting &lt;parameter&gt; to `&lt;value&gt;'.
1809                 </example></p>
1810                 
1811               <p>
1812                 You can use the following echo statement to get the quotes right:
1813                 <example>
1814                   echo "Setting DNS domainname to \`"value"'."
1815                 </example></p>
1816                 
1817               <p>
1818                 Note that the left quotation mark (`) is different
1819                 from the right (').</p></item> 
1820               
1821             <item>
1822               <p>when a daemon is stopped.</p>
1823                 
1824               <p>
1825                 When you stop a daemon you should issue a message
1826                 similar to the startup message, except that `Starting'
1827                 is replaced with `Stopping'.</p>
1828                 
1829               <p>
1830                 So stopping the printer daemon will like like this:
1831                 <example>
1832                   Stopping printer spooler: lpd.
1833                 </example></p></item>
1834               
1835             <item>
1836               <p>when something is executed.</p>
1837                 
1838               <p>
1839                 There are several examples where you have to run a
1840                 program at system startup or shutdown to perform a
1841                 specific task. For example, setting the system's clock
1842                 via `netdate' or killing all processes when the system
1843                 comes down. Your message should like this:
1844                 <example>
1845                   Doing something very useful...done.
1846                 </example>
1847                 You should print the `done.' right after the job has been completed,
1848                 so that the user gets informed why he has to wait. You can get this
1849                 behavior by saying
1850                 <example>
1851                   echo -n "Doing something very useful..."
1852                   do_something
1853                   echo "done."
1854                 </example>
1855                 in your script.</p></item>
1856               
1857             <item>
1858               <p>when the configuration is reloaded.</p>
1859                 
1860               <p>
1861                 When a daemon is forced to reload its configuration
1862                 files you should use the following format:
1863                 <example>
1864                   Reloading &lt;daemon's-name&gt; configuration...done.
1865                 </example></p></item>
1866               
1867             <item>
1868               <p>when none of the above rules apply.</p>
1869                 
1870               <p>
1871                 If you have to print a message that doesn't fit into
1872                 the styles described above, you can use something
1873                 appropriate, but please have a look at the overall
1874                 rules listed above.</p></item>
1875           </list></p></sect>
1876           
1877           
1878       <sect>
1879         <heading>Menus</heading>
1880
1881         <p>
1882           Menu entries should follow the current menu policy as
1883           defined in the file <ftpsite>ftp.debian.org</ftpsite> in
1884           <ftppath>/debian/doc/package-developer/menu-policy.txt</ftppath>
1885           or your local mirror. In addition, it is included in the
1886           <tt>debian-policy</tt> package.
1887         </p>
1888
1889         <p>
1890           The Debian <tt>menu</tt> packages provides a unique
1891           interface between packages providing applications and
1892           documents, and <em>menu programs</em> (either X window
1893           managers or text-based menu programs as
1894           <prgn>pdmenu</prgn>).</p>
1895           
1896         <p>
1897           All packages that provide applications that need not be
1898           passed any special command line arguments for normal
1899           operation should register a menu entry for those
1900           applications, so that users of the <tt>menu</tt> package
1901           will automatically get menu entries in their window
1902           managers, as well in shells like <tt>pdmenu</tt>.</p>
1903           
1904         <p>
1905           Please refer to the <em>Debian Menu System</em> document
1906           that comes with the <tt>menu</tt> package for information
1907           about how to register your applications and web
1908           documents.</p>
1909       </sect>
1910           
1911         
1912       <sect>
1913         <heading>Multimedia handlers</heading>
1914         
1915         <p>
1916           Packages which provide the ability to view/show/play,
1917           compose, edit or print MIME types should register themselves
1918           as such following the current MIME support policy as defined
1919           in the file found on <ftpsite>ftp.debian.org</ftpsite> in
1920           <ftppath>/debian/doc/package-developer/mime_policy.txt</ftppath>
1921           or your local mirror. In addition, it is included in the
1922           <tt>debian-policy</tt> package. 
1923         </p>
1924
1925         <p>
1926           MIME (Multipurpose Internet Mail Extensions, RFC 1521) is a
1927           mechanism for encoding files and data streams and providing
1928           meta-information about them, in particular their type (e.g.
1929           audio or video) and format (e.g. PNG, HTML, MP3).
1930         </p>
1931         
1932         <p>
1933           Registration of MIME type handlers allows programs like mail
1934           user agents and web browsers to to invoke these handlers to
1935           view, edit or display MIME types they don't support
1936           directly.
1937         </p>
1938       </sect>
1939
1940       <sect>
1941         <heading>Keyboard configuration</heading>
1942           
1943         <p>
1944           To achieve a consistent keyboard configuration (i.e., all
1945           applications interpret a keyboard event the same way) all
1946           programs in the Debian distribution must be configured to
1947           comply with the following guidelines.</p>
1948           
1949         <p>
1950           Here is a list that contains certain keys and their interpretation:
1951           
1952           <taglist>
1953             <tag><tt>&lt;--</tt></tag>
1954             <item><p>delete the character to the left of the cursor</p></item>
1955                 
1956             <tag><tt>Delete</tt></tag>
1957             <item><p>delete the character to the right of the cursor</p></item>
1958                 
1959             <tag><tt>Control+H</tt></tag>
1960             <item><p>emacs: the help prefix</p></item>
1961           </taglist>
1962           
1963           The interpretation of any keyboard events should be independent
1964           of the terminal that's used, be it a virtual console, an X
1965           terminal emulator, an rlogin/telnet session, etc.</p>
1966           
1967         <p>
1968           The following list explains how the different programs
1969           should be set up to achieve this:</p>
1970           
1971         <p>
1972           <list compact="compact">
1973             <item><p>`<tt>&lt;--</tt>' generates KB_Backspace in
1974                 X.</p></item> 
1975                 
1976             <item><p>`<tt>Delete</tt>' generates KB_Delete in X.</p></item>
1977                 
1978             <item>
1979               <p>
1980                 X translations are set up to make KB_Backspace
1981                 generate ASCII DEL, and to make KB_Delete generate
1982                 <tt>ESC [ 3 ~</tt> (this is the vt220 escape code for
1983                 the `delete character' key).  This must be done by
1984                 loading the resources using xrdb on all local X
1985                 displays, not using the application defaults, so that
1986                 the translation resources used correspond to the
1987                 xmodmap settings.</p></item>
1988                 
1989             <item>
1990               <p>
1991                 The Linux console is configured to make
1992                 `<tt>&lt;--</tt>' generate DEL, and `Delete' generate
1993                 <tt>ESC [ 3 ~</tt> (this is the case at the
1994                 moment).</p></item>
1995                 
1996             <item><p>
1997                 X applications are configured so that Backspace
1998                 deletes left, and Delete deletes right.  Motif
1999                 applications already work like this.</p></item>
2000                 
2001             <item><p>stty erase <tt>^?</tt> .</p></item>
2002                 
2003             <item><p>
2004                 The `xterm' terminfo entry should have <tt>ESC [ 3
2005                 ~</tt> for kdch1, just like TERM=linux and
2006                 TERM=vt220.</p></item>
2007                 
2008             <item><p>
2009                 Emacs is programmed to map KB_Backspace or the `stty
2010                 erase' character to delete-backward-char, and
2011                 KB_Delete or kdch1 to delete-forward-char, and
2012                 <tt>^H</tt> to help as always.</p></item>
2013                 
2014             <item><p>
2015                 Other applications use the `stty erase' character and
2016                 kdch1 for the two delete keys, with ASCII DEL being
2017                 `delete previous character' and kdch1 being `delete
2018                 character under cursor'.</p></item>
2019           </list></p>
2020           
2021         <p>
2022           This will solve the problem except for:</p>
2023           
2024         <p>
2025           <list compact="compact">
2026             <item><p>
2027                 Some terminals have a <tt>&lt;--</tt> key that cannot
2028                 be made to produce anything except <tt>^H</tt>.  On
2029                 these terminals Emacs help will be unavailable on
2030                 <tt>^H</tt> (assuming that the `stty erase' character
2031                 takes precedence in Emacs, and has been set
2032                 correctly).  M-x help or F1 (if available) can be used
2033                 instead.</p></item>
2034                 
2035             <item><p>
2036                 Some operating systems use <tt>^H</tt> for stty erase.
2037                 However, modern telnet versions and all rlogin
2038                 versions propagate stty settings, and almost all UNIX
2039                 versions honour stty erase.  Where the stty settings
2040                 are not propagated correctly things can be made to
2041                 work by using stty manually.</p></item>
2042                 
2043             <item><p>
2044                 Some systems (including previous Debian versions) use
2045                 xmodmap to arrange for both <tt>&lt;--</tt> and Delete
2046                 to generate KB_Delete.  We can change the behavior
2047                 of their X clients via the same X resources that we
2048                 use to do it for our own, or have our clients be
2049                 configured via their resources when things are the
2050                 other way around.  On displays configured like this
2051                 Delete will not work, but <tt>&lt;--</tt>
2052                 will.</p></item>
2053                 
2054             <item><p>
2055                 Some operating systems have different kdch1 settings
2056                 in their terminfo for xterm and others.  On these
2057                 systems the Delete key will not work correctly when
2058                 you log in from a system conforming to our policy, but
2059                 <tt>&lt;--</tt> will.</p></item>
2060           </list>
2061         </p>
2062       </sect>
2063           
2064           
2065       <sect>
2066         <heading>Environment variables</heading>
2067           
2068         <p>
2069           A program must not depend on environment variables to get
2070           reasonable defaults. (That's because these environment
2071           variables would have to be set in a system-wide
2072           configuration file like /etc/profile, which is not supported
2073           by all shells.)</p>
2074           
2075         <p>
2076           If a program usually depends on environment variables for its
2077           configuration, the program should be changed to fall back to
2078           a reasonable default configuration if these environment
2079           variables are not present. If this cannot be done easily
2080           (e.g., if the source code of a non-free program is not
2081           available), the program must be replaced by a small
2082           `wrapper' shell script which sets the environment variables
2083           if they are not already defined, and calls the original program.</p>
2084           
2085         <p>
2086           Here is an example of a wrapper script for this purpose:
2087           
2088           <example>
2089             #!/bin/sh
2090             BAR=${BAR:-/var/lib/fubar}
2091             export BAR
2092             exec /usr/lib/foo/foo "$@"
2093           </example></p>
2094           
2095         <p>
2096           Furthermore, as <tt>/etc/profile</tt> is a configuration
2097           file of the <prgn>bash</prgn> package, other packages must not
2098           put any environment variables or other commands into that
2099           file.</p>
2100       </sect>
2101     </chapt>
2102     <chapt>
2103       <heading>Files</heading>
2104       
2105       
2106       <sect>
2107         <heading>Binaries</heading>
2108         
2109         <p>
2110           Two different packages must not install programs with
2111           different functionality but with the same filenames. (The
2112           case of two programs having the same functionality but
2113           different implementations is handled via `alternatives.')
2114           If this case happens, one of the programs must be
2115           renamed. The maintainers should report this to the
2116           developers' mailing and try to find a consensus about
2117           which package will have to be renamed.  If a consensus can
2118           not be reached, <em>both</em> programs must be
2119           renamed.</p>
2120         
2121         <p>
2122           Generally the following compilation parameters should be used:
2123           <example>
2124             CC = gcc 
2125             CFLAGS = -O2 -Wall # sane warning options vary between programs 
2126             LDFLAGS = # none 
2127             install -s # (or use strip on the files in debian/tmp)
2128           </example></p>
2129         
2130         <p>
2131           Note that by default all installed binaries should be stripped,
2132           either by using the <tt>-s</tt> flag to
2133           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
2134           the binaries after they have been copied into
2135           <tt>debian/tmp</tt> but before the tree is made into a
2136           package.</p>
2137         
2138         <p>
2139           The <tt>-N</tt> flag should not be used.  On a.out systems
2140           it may have been useful for some very small binaries, but
2141           for ELF it has no good effect.</p>
2142             
2143         <p>
2144           Debugging symbols are useful for error diagnosis,
2145           investigation of core dumps (which may be submitted by users
2146           in bug reports), or testing and developing the
2147           software. Therefore it is recommended to support building
2148           the package with debugging information through the following
2149           interface: If the environment variable
2150           <tt>DEB_BUILD_OPTIONS</tt> contains the string
2151           <tt>debug</tt>, compile the software with debugging
2152           information (usually this involves adding the <tt>-g</tt>
2153           flag to <tt>CFLAGS</tt>). This allows the generation of a
2154           build tree with debugging information. If the environment
2155           variable <tt>DEB_BUILD_OPTIONS</tt> contains the string
2156           <tt>nostrip</tt>, do not strip the files at installation
2157           time. This allows to generate a package with debugging
2158           information included. The following makefile snippet is only
2159           an example how to test for either condition:
2160           <footnote>
2161             <p>
2162               Rationale: Building by default with -g causes more
2163               wasted CPU cycles since the information is stripped away
2164               anyway. The package can by default build without -g if
2165               it also provides a mechanism to easily be rebuilt with
2166               debugging information. This can be done by providing a
2167               "build-debug" make target, or allowing the user to
2168               specify "BUILD_DEBUG=yes" in the environment while
2169               compiling that package.
2170             </p>
2171             <p>Now this has several added benefits:
2172               <list>
2173                 <item>
2174                   <p>
2175                     It is actually easier to build debugging bins and
2176                     libraries this way (no more editing debian/rules
2177                     or similar) since it provides a documented way of
2178                     getting this type of build.</p>
2179                 </item>
2180                 <item>
2181                   <p>
2182                     There will be much less wasted cpu time for the
2183                     autobuilders since not having debugging
2184                     information (and hence also not having to strip
2185                     it) will increase the speed of compiles. This
2186                     skips an entire pass of the compiler,
2187                   </p>
2188                 </item>
2189               </list>
2190             </p>
2191           </footnote>
2192
2193            <example>
2194              CFLAGS = -O2 -Wall
2195              INSTALL = install
2196
2197              ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
2198                CFLAGS += -g
2199              ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
2200                INSTALL += -s
2201              endif
2202              endif
2203            </example></p>
2204
2205           <p>
2206             It is up to the package maintainer to decide what
2207             compilation options are best for the package.  Certain
2208             binaries (such as computationally-intensive programs) will
2209             function better with certain flags (<tt>-O3</tt>, for
2210             example); feel free to use them.  Please use good judgment
2211             here.  Don't use flags for the sake of it; only use them
2212             if there is good reason to do so.  Feel free to override
2213             the upstream author's ideas about which compilation
2214             options are best--they are often inappropriate for our
2215             environment.</p></sect>
2216             
2217             
2218         <sect>
2219           <heading>Libraries</heading>
2220             
2221           <p>
2222             All libraries must have a shared version in the lib
2223             package and a static version in the lib-dev package. The
2224             shared version must be compiled with <tt>-fPIC</tt>, and
2225             the static version must not be. In other words, each
2226             <tt>*.c</tt> file will need to be compiled twice.</p>
2227             
2228           <p>
2229             You must specify the gcc option <tt>-D_REENTRANT</tt>
2230             when building a library (either static or shared) to make
2231             the library compatible with LinuxThreads.</p>
2232             
2233           <p>
2234             Note that all installed shared libraries should be
2235             stripped with
2236             <example>
2237               strip --strip-unneeded &lt;your-lib&gt;
2238             </example> 
2239             (The option `--strip-unneeded' makes <tt>strip</tt> remove
2240             only the symbols which aren't needed for relocation
2241             processing.)  Shared libraries can function perfectly well
2242             when stripped, since the symbols for dynamic linking are
2243             in a separate part of the ELF object file.</p>
2244             
2245           <p>
2246             Note that under some circumstances it may be useful to
2247             install a shared library unstripped, for example when
2248             building a separate package to support debugging.
2249         </p>
2250         
2251         <p>
2252           An ever increasing number of packages are using libtool to
2253           do their linking. The latest GNU libtools (>= 1.3a) can take
2254           advantage of the metadata in the installed libtool archive
2255           files (`*.la'). The main advantage of libtool's .la files is
2256           that it allows libtool to store and subsequently access
2257           metadata with respect to the libraries it builds.  libtool
2258           will search for those files, which contain a lot of useful
2259           information about a library (e.g. dependency libraries for
2260           static linking). Also, they're <em>essential</em> for
2261           programs using libltdl.
2262         </p>
2263
2264         <p>
2265           Certainly libtool is fully capable of linking against shared
2266           libraries which don't have .la files, but being a mere shell
2267           script it can add considerably to the build time of a
2268           libtool using package if that shell-script has to derive all
2269           this information from first principles for each library every
2270           time it is linked. With the advent of libtool-1.4 (and to a
2271           lesser extent libtool-1.3), the .la files will also store
2272           information about inter-library dependencies which cannot
2273           necessarily be derived after the .la file is deleted.
2274         </p>
2275
2276         <p>
2277           Packages that use libtool to create shared libraries should
2278           include the <em>.la</em> files in the <em>-dev</em>
2279           packages, with the exception that if the package relies on
2280           libtool's <em>libltdl</em> library, in which case the .la
2281           files must go in the run-time library package.  This is a
2282           good idea in general, and especially for static linking
2283           issues.
2284         </p>
2285         
2286         <p>
2287           You must make sure that you use only released versions of
2288           shared libraries to build your packages; otherwise other
2289           users will not be able to run your binaries
2290           properly. Producing source packages that depend on
2291           unreleased compilers is also usually a bad
2292           idea.
2293         </p>
2294       </sect>
2295             
2296             
2297         <sect>
2298           <heading>Shared libraries</heading>
2299             
2300           <p>
2301             Packages involving shared libraries should be split up
2302             into several binary packages.</p>
2303             
2304           <p>
2305             For a straightforward library which has a development
2306             environment and a runtime kit including just shared
2307             libraries you need to create two packages:
2308             <tt><var>libraryname</var><var>soname</var></tt>
2309             (<var>soname</var> is the shared object name of the shared
2310             library--it's the thing that has to match exactly between
2311             building an executable and running it for the dynamic
2312             linker to be able run the program; usually the
2313             <var>soname</var> is the major number of the library) and
2314             <tt><var>libraryname</var><var>soname</var>-dev</tt>.</p>
2315             
2316           <p>
2317             If you prefer only to support one development version at a
2318             time you may name the development package
2319             <tt><var>libraryname</var>-dev</tt>; otherwise you may
2320             wish to use <prgn>dpkg</prgn>'s conflicts mechanism to
2321             ensure that the user only installs one development version
2322             at a time (after all, different development versions are
2323             likely to have the same header files in them, causing a
2324             filename clash if both are installed).  Typically the
2325             development version should  also have an exact version
2326             dependency on the runtime library, to make sure that
2327             compilation and linking happens correctly.</p>
2328             
2329           <p>
2330             Packages which use the shared library should have a
2331             dependency on the name of the shared library package,
2332             <tt><var>libraryname</var><var>soname</var></tt>.  When
2333             the <var>soname</var> changes you can have both versions
2334             of the library installed while moving from the old library
2335             to the new.</p>
2336             
2337           <p>
2338             If your package has some run-time support programs which
2339             use the shared library you must not put them in
2340             the shared library package.  If you do that then you won't
2341             be able to install several versions of the shared library
2342             without getting filename clashes.  Instead, either create
2343             a third package for the runtime binaries (this package
2344             might typically be named
2345             <tt><var>libraryname</var>-runtime</tt>--note the absence
2346             of the <var>soname</var> in the package name) or if the
2347             development package is small include them in there.</p>
2348             
2349           <p>
2350             If you have several shared libraries built from the same
2351             source tree you may lump them all together into a single
2352             shared library package, provided that you change all their
2353             <var>soname</var>s at once (so that you don't get filename
2354             clashes if you try to install different versions of the
2355             combined shared libraries package).</p>
2356             
2357           <p>
2358             You should follow the directions in the <em>Debian Packaging
2359             Manual</em> for putting the shared library in its package,
2360             and you must include a <tt>shlibs</tt> control area
2361             file with details of the dependencies for packages which
2362             use the library.</p>
2363             
2364           <p>
2365             Shared libraries should not be installed
2366             executable, since <prgn>ld.so</prgn> does not require this
2367             and trying to execute a shared library results in a core
2368             dump.</p></sect>
2369             
2370             
2371         <sect id="scripts">
2372           <heading>Scripts</heading>
2373             
2374           <p>
2375             All command scripts, including the package maintainer
2376             scripts inside the package and used by <prgn>dpkg</prgn>,
2377             should have a <tt>#!</tt> line naming the shell to be used
2378             to interpret them.</p>
2379             
2380           <p>
2381             In the case of Perl scripts this should be
2382             <tt>#!/usr/bin/perl</tt>.</p>
2383             
2384           <p>
2385             Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
2386             should almost certainly start with <tt>set -e</tt> so that
2387             errors are detected.  Every script should use
2388             <tt>set -e</tt> or check the exit status of <em>every</em>
2389             command.</p>
2390             
2391           <p>
2392             The standard shell interpreter `<tt>/bin/sh</tt>' can be a
2393             symbolic link to any POSIX compatible shell. Thus, shell
2394             scripts specifying `<tt>/bin/sh</tt>' as interpreter should
2395             only use POSIX features. If a script requires non-POSIX
2396             features from the shell interpreter, the appropriate shell
2397             must be specified in the first line of the script (e.g.,
2398             `<tt>#!/bin/bash</tt>') and the package must depend on
2399             the package providing the shell (unless the shell package
2400             is marked `Essential', e.g., in the case of
2401             <prgn>bash</prgn>).</p>
2402             
2403           <p>
2404             You may wish to restrict your script to POSIX features when possible so
2405             that it may use <tt>/bin/sh</tt> as its interpreter. If
2406             your script works with <prgn>ash</prgn>, it's probably
2407             POSIX compliant, but if you are in doubt, use
2408             <tt>/bin/bash</tt>.</p>
2409             
2410           <p>
2411             Perl scripts should check for errors when making any
2412             system calls, including <tt>open</tt>, <tt>print</tt>,
2413             <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.</p>
2414             
2415           <p>
2416             <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided
2417             as scripting languages.  See <em>Csh Programming
2418             Considered Harmful</em>, one of the <tt>comp.unix.*</tt>
2419           FAQs.  It can be found on 
2420           <url id="http://language.perl.com/versus/csh.whynot">, or
2421           <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
2422           or even on <ftpsite>ftp.cpan.org</ftpsite> 
2423           <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
2424           If an upstream package comes with <prgn>csh</prgn> scripts
2425           then you must make sure that they start with
2426           <tt>#!/bin/csh</tt> and make your package depend on the
2427           <prgn>c-shell</prgn> virtual package.</p>
2428             
2429           <p>
2430             Any scripts which create files in world-writeable
2431             directories (e.g., in <tt>/tmp</tt>) must use a
2432             mechanism which will fail if a file with the same name
2433             already exists.</p>
2434             
2435           <p>
2436             The Debian base distribution provides the
2437             <prgn>tempfile</prgn> and <prgn>mktemp</prgn> utilities
2438             for use by scripts for this purpose.</p></sect>
2439             
2440             
2441         <sect>
2442           <heading>Symbolic links</heading>
2443             
2444           <p>
2445             In general, symbolic links within a top-level directory
2446             should be relative, and symbolic links pointing from one
2447             top-level directory into another should be absolute. (A
2448             top-level directory is a sub-directory of the root
2449             directory `/'.)</p>
2450             
2451           <p>
2452             In addition, symbolic links should be specified as short
2453             as possible, i.e., link targets like `foo/../bar' are
2454             deprecated.</p>
2455             
2456           <p>
2457             Note that when creating a relative link using
2458             <prgn>ln</prgn> it is not necessary for the target of the
2459             link to exist relative to the working directory you're
2460             running <prgn>ln</prgn> from; nor is it necessary to
2461             change directory to the directory where the link is to be
2462             made.  Simply include the string that should appear as the
2463             target of the link (this will be a pathname relative to
2464             the directory in which the link resides) as the first
2465             argument to <prgn>ln</prgn>.</p>
2466             
2467           <p>
2468             For example, in your <prgn>Makefile</prgn> or
2469             <tt>debian/rules</tt>, do things like:
2470             <example>
2471               ln -fs gcc $(prefix)/bin/cc 
2472               ln -fs gcc debian/tmp/usr/bin/cc 
2473               ln -fs ../sbin/sendmail $(prefix)/bin/runq 
2474               ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
2475             </example></p>
2476             
2477           <p>
2478             A symbolic link pointing to a compressed file should
2479             always have the same file extension as the referenced
2480             file. (For example, if a file `<tt>foo.gz</tt>' is
2481             referenced by a symbolic link, the filename of the link
2482             has to end with `<tt>.gz</tt>' too, as in
2483             `bar.gz.')</p></sect>
2484             
2485             
2486         <sect>
2487           <heading>Device files</heading>
2488             
2489           <p>
2490             Packages must not include device files in the package file
2491             tree.</p>
2492             
2493           <p>
2494             If a package needs any special device files that are not
2495             included in the base system, it must call
2496             <prgn>makedev</prgn> in the <tt>postinst</tt> script,
2497             after asking the user for permission to do so.</p>
2498             
2499           <p>
2500             Packages must not remove any device files in the
2501             <tt>postrm</tt> or any other script. This is left to the
2502             system administrator.</p>
2503             
2504           <p>
2505             Debian uses the serial devices
2506             <tt>/dev/tty*</tt>. Programs using the old
2507             <tt>/dev/cu*</tt> devices should be changed to use
2508             <tt>/dev/tty*</tt>.</p>
2509       </sect>
2510             
2511       <sect id="config files">
2512           <heading>Configuration files</heading>
2513         <sect1>
2514           <heading>Definitions</heading>
2515           <p>
2516             <taglist>
2517               <tag>configuration file</tag>
2518               <item><p>
2519                   A file that affects the operation of program, or
2520                   provides site- or host-specific information, or
2521                   otherwise customizes the behavior of program.
2522                   Typically, configuration files are intended to be
2523                   modified by the system administrator (if needed or
2524                   desired) to conform to local policy or provide more
2525                   useful site-specific behavior.</p>
2526               </item>
2527
2528               <tag><tt>conffile</tt></tag>
2529               <item><p>
2530                   A file listed in a package's <tt>conffiles</tt>
2531                   file, and is treated specially by <prgn>dpkg</prgn>
2532                   (see the <em>Debian Packaging Manual</em>).</p>
2533               </item>
2534             </taglist>
2535           </p>
2536
2537           <p>
2538             The distinction between these two is important; they are
2539             not interchangeable concepts. Almost all
2540             <tt>conffiles</tt> are configuration files, but many
2541             configuration files are not <tt>conffiles</tt>.</p>
2542
2543           <p>
2544             Note that a script that embeds configuration information
2545             (such as most of the files in <tt>/etc/init.d</tt> and
2546             <tt>/etc/cron.{daily,weekly,monthly}</tt>) is de-facto a
2547             configuration file and should be treated as such.</p>
2548         </sect1>
2549
2550         <sect1>
2551           <heading>Location</heading>
2552           <p>
2553             Any configuration files created or used by your package
2554             must reside in <tt>/etc</tt>. If there are several you
2555             should consider creating a subdirectory of <tt>/etc</tt>
2556             named after your package.</p>
2557
2558           <p>
2559             If your package creates or uses configuration files
2560             outside of <tt>/etc</tt>, and it is not feasible to modify
2561             the package to use the <tt>/etc</tt>, you should still put
2562             the files in <tt>/etc</tt> and create symbolic links to
2563             those files from the location that the package
2564             requires.</p>
2565         </sect1>
2566
2567         <sect1>
2568           <heading>Behavior</heading>
2569           <p>
2570             Configuration file handling must conform to the following
2571             behavior:
2572             <list>
2573               <item>
2574                 <p>local changes must be preserved during a package
2575                   upgrade</p>
2576               </item>
2577               <item>
2578                 <p>configuration files must be preserved when the
2579                   package is removed, and only deleted when the
2580                   package is purged.</p>
2581               </item>
2582             </list></p>
2583
2584           <p>
2585             The easy way to achieve this behavior is to make the
2586             configuration file a <tt>conffile</tt>. This is
2587             appropriate if it is possible to distribute a default
2588             version that will work for most installations, although
2589             some system administrators may choose to modify it. This
2590             implies that the default version will be part of the
2591             package distribution, and must not be modified by the
2592             maintainer scripts during installation (or at any other
2593             time).</p>
2594
2595           <p>
2596             In order to ensure that local changes are preserved
2597             correctly, no package may contain or make hard links to
2598             conffiles.
2599             <footnote>
2600               <p>
2601                 Rationale: There are two problems with hard links.
2602                 The first is that some editors break the link while
2603                 editing one of the files, so that the two files may
2604                 unwittingly become different.  The second is that
2605                 <prgn>dpkg</prgn> might break the hard link while
2606                 upgrading <tt>conffile</tt>s.
2607               </p>
2608             </footnote>
2609
2610           <p>
2611             The other way to do it is to via the maintainer scripts.
2612             In this case, the configuration file must not be listed as
2613             a <tt>conffile</tt> and must not be part of the package
2614             distribution. If the existence of a file is required for
2615             the package to be sensibly configured it is the
2616             responsibility of the package maintainer to write scripts
2617             which correctly create, update, maintain and
2618             remove-on-purge the file. These scripts must be idempotent
2619             (i.e. must work correctly if <prgn>dpkg</prgn> needs to
2620             re-run them due to errors during installation or removal),
2621             must cope with all the variety of ways <prgn>dpkg</prgn>
2622             can call maintainer scripts, must not overwrite or
2623             otherwise mangle the user's configuration without asking,
2624             must not ask unnecessary questions (particularly during
2625             upgrades), and otherwise be good citizens.</p>
2626
2627           <p>
2628             The scripts are not required to configure every possible option for
2629             the package, but only those necessary to get the package
2630             running on a given system. Ideally the sysadmin should not
2631             have to do any configuration other than that done
2632             (semi-)automatically by the <tt>postinst</tt> script.</p>
2633
2634           <p>
2635             A common practice is to create a script called
2636             <tt><var>package</var>-configure</tt> and have the
2637             package's <tt>postinst</tt> call it if and only if the
2638             configuration file does not already exist. In certain
2639             cases it is useful for there to be an example or template
2640             file which the maintainer scripts use. Such files should
2641             be in <tt>/usr/share/doc</tt> if they are examples or
2642             <tt>/usr/lib</tt> if they are templates, and should be
2643             perfectly ordinary <prgn>dpkg</prgn>-handled files
2644             (<em>not</em> <tt>conffiles</tt>).</p>
2645
2646           <p>
2647             These two styles of configuration file handling must
2648             not be mixed, for that way lies madness:
2649             <prgn>dpkg</prgn> will ask about overwriting the file
2650             every time the package is upgraded.</p>
2651
2652         </sect1>
2653
2654         <sect1>
2655           <heading>Sharing configuration files</heading>
2656           <p>
2657             Packages that are not tagged as <em>conflicting</em> with
2658             each other must not specify the same file as
2659             <tt>conffile</tt>.</p>
2660
2661           <p>
2662             The maintainer scripts must not alter the conffile of
2663             <em>any</em> package, including the one the scripts belong
2664             to.</p>
2665
2666           <p>
2667             If two or more packages use the same configuration file
2668             and it is reasonable for both to be installed at the same
2669             time, one of these packages must be defined as
2670             <em>owner</em> of the configuration file, i.e. it will be
2671             the package to list that distributes the file and lists it
2672             as a <tt>conffile</tt>. Other packages that use the
2673             configuration file must depend on the owning package if
2674             they require the configuration file to operate. If the
2675             other package will use the configuration file if present,
2676             but is capable of operating without it, no dependency need
2677             be declared.</p>
2678
2679           <p>
2680             If it is desirable for two or more related packages to
2681             share a configuration file <em>and</em> for all of the
2682             related packages to be able to modify that configuration
2683             file, then the following should be done:
2684             <enumlist>
2685               <item>
2686                 <p>
2687                   have one of the related packages (the "core"
2688                   package) manage the configuration file with
2689                   maintainer scripts as described in the previous
2690                   section.</p>
2691               </item>
2692               <item><p>
2693                   the core package should also provide a program that
2694                   the other packages may use to modify the
2695                   configuration file.</p>
2696               </item>
2697               <item>
2698                 <p>
2699                   the related packages must use the provided program
2700                   to make any modifications to the configuration file.
2701                   They should either depend on the core package to
2702                   guarantee that the configuration modifier program is
2703                   available or accept gracefully that they cannot
2704                   modify the configuration file if it is not.</p>
2705               </item>
2706             </enumlist></p>
2707
2708           <p>
2709             Sometimes it's appropriate to create a new package which
2710             provides the basic infrastructure for the other packages
2711             and which manages the shared configuration files. (Check
2712             out the <tt>sgml-base</tt> package as an example.)</p>
2713         </sect1>
2714
2715         <sect1>
2716           <heading>User configuration files ("dotfiles")</heading>
2717
2718           <p>
2719             Files in <tt>/etc/skel</tt> will automatically be copied
2720             into new user accounts by <prgn>adduser</prgn>. They
2721             should not be referenced there by any program.</p>
2722
2723           <p>
2724             Therefore, if a program needs a dotfile to exist in
2725             advance in <tt>$HOME</tt> to work sensibly that dotfile
2726             should be installed in <tt>/etc/skel</tt> (and listed in
2727             conffiles, if it is not generated and modified dynamically
2728             by the package's installation scripts).</p>
2729
2730           <p>
2731             However, programs that require dotfiles in order to
2732             operate sensibly (dotfiles that they do not create
2733             themselves automatically, that is) are a bad thing, and
2734             programs should be configured by the Debian default
2735             installation as close to normal as possible.</p>
2736
2737           <p>
2738             Therefore, if a program in a Debian package needs to be
2739             configured in some way in order to operate sensibly that
2740             configuration should be done in a site-wide global
2741             configuration file elsewhere in <tt>/etc</tt>. Only if the
2742             program doesn't support a site-wide default configuration
2743             and the package maintainer doesn't have time to add it
2744             may a default per-user file be placed in
2745             <tt>/etc/skel</tt>.</p>
2746
2747           <p>
2748             <tt>/etc/skel</tt> should be as empty as we can make it.
2749             This is particularly true because there is no easy
2750             mechanism for ensuring that the appropriate dotfiles are
2751             copied into the accounts of existing users when a package
2752             is installed.</p>
2753         </sect1>
2754       </sect>
2755       
2756       <sect>
2757         <heading>Log files</heading>
2758         <p>
2759           The traditional approach to log files has been to set up ad
2760           hoc log rotation schemes using simple shell scripts and
2761           cron. While this approach is highly customizable, it
2762           requires quite a lot of sysadmin work. Even though the
2763           original Debian system helped a little by automatically
2764           installing a system which can be used as a template, this
2765           was deemed not enough. 
2766         </p>
2767
2768         <p>
2769           A better scheme is to use logrotate, a GPL'd program
2770           developed by Red Hat, which centralizes log management. It
2771           has both a configuration file (<tt>/etc/logrotate.conf</tt>)
2772           and a directory where packages can drop logrotation info
2773           (<tt>/etc/logrotate.d</tt>). 
2774         </p>
2775
2776         <p>
2777           Log files should usually be named
2778           <tt>/var/log/<var>package</var>.log</tt>.  If you have many
2779           log files, or need a separate directory for permissions
2780           reasons (<tt>/var/log</tt> is writable only by
2781           <tt>root</tt>), you should usually create a directory named
2782           <tt>/var/log/<var>package</var></tt>.</p>
2783         
2784         <p>
2785           Log files must be rotated occasionally so
2786           that they don't grow indefinitely; the best way to do this
2787           is to drop a script into the directory
2788           <tt>/etc/logrotate.d</tt> and use the facilities provided by
2789           logrotate. Here is a good example for a logrotate config
2790           file (for more information see <manref name="logrotate"
2791                                                  section="8">):
2792           <example>
2793         /var/log/foo/* {
2794                 rotate 12
2795                 weekly
2796                 compress
2797                 postrotate
2798                         /etc/init.d/foo force-reload
2799                 endscript
2800         }
2801           </example>      
2802           Which rotates all files under `/var/log/foo', saves 12
2803           compressed generations, and sends a HUP signal at the end of
2804           rotation.
2805
2806         </p>
2807         
2808         <p>
2809           Log files should be removed when the package is
2810           purged (but not when it is only removed), by checking the
2811           argument to the <tt>postrm</tt> script (see the <em>Debian
2812           Packaging Manual</em> for details).</p>
2813       </sect>
2814             
2815             
2816         <sect>
2817           <heading>Permissions and owners</heading>
2818             
2819           <p>
2820             The rules in this section are guidelines for general use.
2821             If necessary you may deviate from the details below.
2822             However, if you do so you must make sure that what is done
2823             is secure and you should try to be as consistent as possible
2824             with the rest of the system.  You should probably also
2825             discuss it on <prgn>debian-devel</prgn> first.</p>
2826             
2827           <p>
2828             Files should be owned by <tt>root.root</tt>, and made
2829             writable only by the owner and universally readable (and
2830             executable, if appropriate).</p>
2831             
2832           <p>
2833             Directories should be mode 755 or (for group-writability)
2834             mode 2775.  The ownership of the directory should be
2835             consistent with its mode--if a directory is mode 2775, it
2836             should be owned by the group that needs write access to
2837             it.</p>
2838             
2839           <p>
2840             Setuid and setgid executables should be mode 4755 or 2755
2841             respectively, and owned by the appropriate user or group.
2842             They should not be made unreadable (modes like 4711 or
2843             2711 or even 4111); doing so achieves no extra security,
2844             because anyone can find the binary in the freely available
2845             Debian package--it is merely inconvenient.  For the same
2846             reason you should not restrict read or execute permissions
2847             on non-set-id executables.</p>
2848             
2849           <p>
2850             Some setuid programs need to be restricted to particular
2851             sets of users, using file permissions.  In this case they
2852             should be owned by the uid to which they are set-id, and
2853             by the group which should be allowed to execute them.
2854             They should have mode 4754; there is no point in making
2855             them unreadable to those users who must not be allowed to
2856             execute them.</p>
2857             
2858           <p>
2859             You must not arrange that the system administrator can only
2860             reconfigure the package to correspond to their local
2861             security policy by changing the permissions on a binary.
2862             Ordinary files installed by <prgn>dpkg</prgn> (as opposed
2863             to conffiles and other similar objects) have their
2864             permissions reset to the distributed permissions when the
2865             package is reinstalled.  Instead you should consider (for
2866             example) creating a group for people allowed to use the
2867             program(s) and making any setuid executables executable
2868             only by that group.</p>
2869             
2870           <p>
2871             If you need to create a new user or group for your package
2872             there are two possibilities.  Firstly, you may need to
2873             make some files in the binary package be owned by this
2874             user or group, or you may need to compile the user or
2875             group id (rather than just the name) into the binary
2876             (though this latter should be avoided if possible, as in
2877             this case you need a statically allocated id).</p>
2878             
2879           <p>
2880             If you need a statically allocated id, you must ask for a
2881             user or group id from the base system
2882             maintainer, and must not release the package until you
2883             have been allocated one.  Once you have been allocated one
2884             you must make the package depend on a version of the base
2885             system with the id present in <tt>/etc/passwd</tt> or
2886             <tt>/etc/group</tt>, or alternatively arrange for your
2887             package to create the user or group itself with the
2888             correct id (using <tt>adduser</tt>) in its pre- or
2889             post-installation script (the latter is to be preferred if
2890             it is possible).</p>
2891             
2892           <p>
2893             On the other hand, the program might be able to determine the
2894             uid or gid from the group name at runtime, so that a
2895             dynamic id can be used.  In this case you should choose an
2896             appropriate user or group name, discussing this on
2897             <prgn>debian-devel</prgn> and checking with the base
2898             system maintainer that it is unique and that they do not
2899             wish you to use a statically allocated id instead.  When
2900             this has been checked you must arrange for your package to
2901             create the user or group if necessary using
2902             <prgn>adduser</prgn> in the pre- or post-installation
2903             script (again, the latter is to be preferred if it is
2904             possible).</p>
2905             
2906           <p>
2907             Note that changing the numeric value of an id associated with a name
2908             is very difficult, and involves searching the file system for all
2909             appropriate files.  You need to think carefully whether a static or
2910             dynamic id is required, since changing your mind later will cause
2911             problems.</p>
2912         </sect>
2913     </chapt>
2914
2915     <chapt>
2916       <heading>Customized programs</heading>
2917         
2918       <sect id="arch-spec">
2919         <heading>Architecture specification strings</heading>
2920           
2921         <p>
2922           If a program needs to specify an <em>architecture specification
2923           string</em> in some place, the following format should be used:
2924           <example>
2925             &lt;arch&gt;-&lt;os&gt;
2926           </example>
2927           where `&lt;arch&gt;' is one of the following: i386, alpha, arm, m68k,
2928           powerpc, sparc and `&lt;os&gt;' is one of: linux, gnu.  Use
2929           of <em>gnu</em> in this string is reserved for the GNU/Hurd
2930           operating system.</p> 
2931         <p>
2932           Note, that we don't want to use `&lt;arch&gt;-debian-linux'
2933           to apply to the rule `architecture-vendor-os' since this
2934           would make our programs incompatible to other Linux
2935           distributions. Also note, that we don't use
2936           `&lt;arch&gt;-unknown-linux', since the `unknown' does not
2937           look very good.</p></sect>
2938           
2939           
2940       <sect>
2941         <heading>Daemons</heading>
2942           
2943         <p>
2944           The configuration files <tt>/etc/services</tt>,
2945           <tt>/etc/protocols</tt>, and <tt>/etc/rpc</tt> are managed
2946           by the <prgn>netbase</prgn> package and may not be modified
2947           by other packages.</p>
2948           
2949         <p>
2950           If a package requires a new entry in one of these files, the
2951           maintainer should get in contact with the
2952           <prgn>netbase</prgn> maintainer, who will add the entries
2953           and release a new version of the <prgn>netbase</prgn>
2954           package.</p>
2955           
2956         <p>
2957           The configuration file <tt>/etc/inetd.conf</tt> must not be
2958           modified by the package's scripts except via the
2959           <prgn>update-inetd</prgn> script or the
2960           <prgn>DebianNet.pm</prgn> Perl module.</p>
2961           
2962         <p>
2963           If a package wants to install an example entry into
2964           <tt>/etc/inetd.conf</tt>, the entry must be preceded with
2965           exactly one hash character (<tt>#</tt>). Such lines are
2966           treated as `commented out by user' by the
2967           <prgn>update-inetd</prgn> script and are not changed or
2968           activated during a package updates.</p></sect>
2969           
2970           
2971       <sect>
2972         <heading>Using pseudo-ttys and modifying wtmp, utmp and lastlog</heading>
2973           
2974         <p>
2975           Some programs need to create pseudo-ttys. This should be done
2976           using Unix98 ptys if the C library supports it. The resulting
2977           program must not be installed setuid root, unless that
2978           is required for other functionality.
2979         </p>
2980         
2981         <p>
2982           The files <tt>/var/run/utmp</tt>, <tt>/var/log/wtmp</tt> and
2983           <tt>/var/log/lastlog</tt> must be installed writeable by
2984           group utmp.  Programs who need to modify those files must
2985           be installed setgid utmp.
2986         </p>
2987       </sect>
2988
2989       <sect>
2990         <heading>Editors and pagers</heading>
2991           
2992         <p>
2993           Some programs have the ability to launch an editor or pager
2994           program to edit or display a text document. Since there are
2995           lots of different editors and pagers available in the Debian
2996           distribution, the system administrator and each user should
2997           have the possibility to choose his/her preferred editor and
2998           pager.</p>
2999           
3000         <p>
3001           In addition, every program should choose a good default
3002           editor/pager if none is selected by the user or system
3003           administrator.</p>
3004           
3005         <p>
3006           Thus, every program that launches an editor or pager must
3007           use the EDITOR or PAGER environment variables to determine
3008           the editor/pager the user wants to get started. If these
3009           variables are not set, the programs <tt>/usr/bin/editor</tt>
3010           and <tt>/usr/bin/pager</tt> should be used, respectively.</p>
3011           
3012         <p>
3013           These two files are managed through `alternatives.' That is,
3014           every package providing an editor or pager must call the
3015           <prgn>update-alternatives</prgn> script to register these
3016           programs.</p>
3017           
3018         <p>
3019           If it is very hard to adapt a program to make us of the
3020           EDITOR and PAGER variable, that program may be configured
3021           to use <tt>/usr/bin/sensible-editor</tt> and
3022           <tt>/usr/bin/sensible-pager</tt> as editor or pager program,
3023           respectively. These are two scripts provided in the Debian
3024           base system that check the EDITOR and PAGER variables and
3025           launch the appropriate program or fall back to
3026           <tt>/usr/bin/editor</tt> and <tt>/usr/bin/pager</tt>,
3027           automatically.</p>
3028           
3029         <p>
3030           A program may also use the VISUAL environment variable to
3031           determine the user's choice of editor. If it exists, it
3032           should take precedence over EDITOR. This is in fact what
3033           <tt>/usr/bin/sensible-editor</tt> does.</p>
3034
3035         <p>
3036           Since the Debian base system already provides an editor and
3037           a pager program, it is not required for a package to depend on
3038           `editor' and `pager', nor is it required for a package to
3039           provide such virtual packages.</p></sect>
3040           
3041           
3042       <sect id="web-appl">
3043         <heading>Web servers and applications</heading>
3044           
3045         <p>
3046           This section describes the locations and URLs that should
3047           be used by all web servers and web application in the Debian
3048           system.</p>
3049           
3050         <p>
3051           <enumlist>
3052             <item>
3053               <p>Cgi-bin executable files are installed in the
3054                 directory
3055                 <example>
3056                   /usr/lib/cgi-bin/&lt;cgi-bin-name&gt;
3057                 </example>
3058                 and should be referred to as
3059                 <example>
3060                   http://localhost/cgi-bin/&lt;cgi-bin-name&gt;
3061                 </example></p></item>
3062                 
3063                 
3064             <item><p>Access to html documents</p>
3065                 
3066               <p>
3067                 Html documents for a package are stored in
3068                 <tt>/usr/share/doc/<var>package</var></tt> but should
3069                 be accessed via symlinks as
3070                 <tt>/usr/doc/<var>package</var></tt><footnote> for
3071                 backward compatibility, see <ref id="usrdoc"></footnote>
3072                 and can be referred to as
3073                 <example>
3074                   http://localhost/doc/&lt;package&gt;/&lt;filename&gt;
3075                 </example></p></item>
3076                 
3077                 
3078             <item><p>Web Document Root</p>
3079                 
3080               <p>
3081                 Web Applications should try to avoid storing files in
3082                 the Web Document Root.  Instead they should use the
3083                 /usr/share/doc/&lt;package&gt; directory for documents and
3084                 register the Web Application via the menu package. If
3085                 access to the web-root is unavoidable then use
3086                 <example>
3087                   /var/www
3088                 </example> 
3089                 as the Document Root. This might be just a
3090                 symbolic link to the location where the sysadmin has
3091                 put the real document root.</p>
3092             </item>
3093             
3094           </enumlist></p></sect>
3095           
3096           
3097       <sect>
3098         <heading>Mail transport agents</heading>
3099           
3100         <p>
3101           Debian packages which process electronic mail, whether
3102           mail-user-agents (MUAs) or mail-transport-agents (MTAs),
3103           must make sure that they are compatible with the
3104           configuration decisions below.  Failure to do this may
3105           result in lost mail, broken <tt>From:</tt> lines, and other
3106           serious brain damage!</p>
3107           
3108         <p>
3109           The mail spool is <tt>/var/spool/mail</tt> and the interface
3110           to send a mail message is <tt>/usr/sbin/sendmail</tt> (as
3111           per the FHS).  The mail spool is part of the base system
3112           and not part of the MTA package.</p>
3113           
3114         <p>
3115           All Debian MUAs, MTAs, MDAs and other mailbox accessing
3116           programs (like IMAP daemons) must lock the mailbox in an
3117           NFS-safe way. This means that <tt>fcntl()</tt> locking must
3118           to be combined with dot locking.  To avoid dead locks, a
3119           program should use <tt>fcntl()</tt> first and dot locking
3120           after this or alternatively implement the two locking
3121           methods in a non blocking way<footnote>
3122             <p>
3123               If it is not possible to establish both locks, the
3124               system shouldn't wait for the second lock to be
3125               established, but remove the first lock, wait a (random)
3126               time, and start over locking again.</p>
3127           </footnote>. Using the functions <tt>maillock</tt> and
3128           <tt>mailunlock</tt> provided by the
3129           <tt>liblockfile*</tt><footnote>
3130             <p>
3131               <tt>liblockfile</tt> version &gt;&gt;1.01</p>
3132           </footnote> packages is the recommended way to realize this.
3133         </p>
3134   
3135         <p>
3136           Mailboxes are generally 660 <tt><var>user</var>.mail</tt>
3137           unless the user has chosen otherwise.  A MUA may remove a
3138           mailbox (unless it has nonstandard permissions) in which
3139           case the MTA or another MUA must recreate it if needed.
3140           Mailboxes must be writable by group mail.</p>
3141           
3142         <p>
3143           The mail spool is 2775 <tt>mail.mail</tt>, and MUAs should
3144           be setgid mail to do the locking mentioned above (and
3145           must obviously avoid accessing other users' mailboxes
3146           using this privilege).</p>
3147           
3148         <p>
3149           <tt>/etc/aliases</tt> is the source file for the system mail
3150           aliases (e.g., postmaster, usenet, etc.)--it is the one
3151           which the sysadmin and <tt>postinst</tt> scripts may edit.
3152           After <tt>/etc/aliases</tt> is edited the program or human
3153           editing it must call <prgn>newaliases</prgn>.  All MTA
3154           packages must come with a <prgn>newaliases</prgn> program,
3155           even if it does nothing, but older MTA packages do not do
3156           this so programs should not fail if <prgn>newaliases</prgn>
3157           cannot be found.</p>
3158           
3159         <p>
3160           The convention of writing <tt>forward to
3161           <var>address</var></tt> in the mailbox itself is not
3162           supported.  Use a <tt>.forward</tt> file instead.</p>
3163           
3164         <p>
3165           The <prgn>rmail</prgn> program used by UUCP
3166           for incoming mail should be  <tt>/usr/sbin/rmail</tt>, as per the
3167           FHS.  Likewise, <prgn>rsmtp</prgn>, for receiving
3168           batch-SMTP-over-UUCP, should be <tt>/usr/sbin/rsmtp</tt> if it
3169           is supported.</p>
3170           
3171         <p>
3172           If you need to know what name to use (for example) on
3173           outgoing news and mail messages which are generated locally,
3174           you should use the file <tt>/etc/mailname</tt>.  It will
3175           contain the portion after the username and <tt>@</tt> (at)
3176           sign for email addresses of users on the machine (followed
3177           by a newline).</p>
3178           
3179         <p>
3180           A package should check for the existence of this file.  If
3181           it exists it should use it without comment. (An MTA's
3182           prompting configuration script may wish to prompt the user
3183           even if it finds this file exists.) If it does not exist it
3184           should prompt the user for the value and store it in
3185           <tt>/etc/mailname</tt> as well as using it in the package's
3186           configuration.  The prompt should make it clear that the
3187           name will not just be used by that package.  For example, in
3188           this situation the INN package says:
3189           <example>
3190             Please enter the `mail name' of your system.  This is the
3191             hostname portion of the address to be shown on outgoing
3192             news and mail messages.  The default is
3193             <var>syshostname</var>, your system's host name.  Mail
3194             name [`<var>syshostname</var>']:
3195           </example>
3196           where <var>syshostname</var> is the output of <tt>hostname
3197             --fqdn</tt>.</p></sect> 
3198           
3199           
3200       <sect>
3201         <heading>News system configuration</heading>
3202           
3203         <p>
3204           All the configuration files related to the NNTP (news)
3205           servers and clients should be located under
3206           <tt>/etc/news</tt>.</p>
3207           
3208         <p>
3209           There are some configuration issues that apply to a number
3210           of news clients and server packages on the machine. These
3211           are:
3212           
3213           <taglist>
3214             <tag>/etc/news/organization</tag>
3215             <item><p>A string which should appear as the
3216                 organization header for all messages posted
3217                 by NNTP clients on the machine</p></item>
3218                 
3219             <tag>/etc/news/server</tag>
3220             <item><p>Contains the FQDN of the upstream NNTP
3221                 server, or localhost if the local machine is
3222                 an NNTP server.</p></item>
3223           </taglist>
3224           
3225           Other global files may be added as required for cross-package news 
3226           configuration.</p></sect>
3227           
3228           
3229       <sect>
3230         <heading>Programs for the X Window System</heading>
3231           
3232         <p>
3233           Some programs can be configured with or without support for the X
3234           Window System.  Typically, binaries produced with support for X
3235           will need the X shared libraries to run.<footnote>
3236             <p>
3237               <strong>NOTE</strong> The forthcoming major X Window
3238               System release shall probably change this
3239               drastically.
3240             </p>
3241           </footnote>
3242         </p>
3243   
3244         <p>
3245           Such programs should be configured <em>with</em> X support,
3246           and should declare a dependency on <tt>xlib6g</tt> (which
3247           contains X shared libraries).  Users who wish to use the
3248           program can install just the relatively small
3249           <tt>xfree86-common</tt> and <tt>xlib6g</tt> packages, and do
3250           not need to install the whole of X.
3251           <footnote>
3252             <p>Note: With the release of the new X window System
3253             version (4.X), there probably shall be a sweeping change
3254             in the X Window System Policy in the future.</p>
3255           </footnote>
3256         </p>
3257   
3258         <p>
3259           You should not create two versions (one with X support and one
3260           without) of your package.</p>
3261           
3262         <p>
3263          <em>Packages which provide an X server</em> that, directly or
3264          indirectly, communicates with real input and display hardware
3265          should declare in their control data that they provide the
3266           virtual package <tt>xserver</tt>.
3267           <footnote>
3268             <p>
3269               Rationale: implement current practice, and provide an
3270               actual policy for usage of the "xserver" virtual package
3271               which appears in the virtual packages list.
3272               In a nutshell, X servers that interface directly with
3273               the display and input hardware or via another subsystem
3274               (e.g., GGI) should provide xserver.  Things like Xvfb,
3275               Xnest, and Xprt should not. <strong>NOTE</strong> The
3276               forthcoming major X Window System release shall probably
3277               change this drastically.
3278             </p>
3279           </footnote>
3280        </p>
3281
3282         <p>
3283           <em>Packages that provide a terminal emulator</em> for the X
3284           Window System which support a terminal type with a terminfo
3285           description provided in the <tt>ncurses-base</tt> package
3286           should declare in their control data that they provide the
3287           virtual package <tt>x-terminal-emulator</tt>.  They should
3288           also register themselves as an alternative for
3289           <tt>/usr/bin/x-terminal-emulator</tt>, with a priority of
3290           20.
3291         </p>
3292
3293         <p>
3294           <em>Packages that provide window managers</em> should declare in
3295           their control data that they provide the virtual package
3296           <tt>x-window-manager</tt>.  They should also register themselves as an
3297           alternative for <tt>/usr/bin/x-window-manager</tt>, with a priority
3298           calculated as follows:
3299           <list>
3300             <item>Start with a priority of 20.</item>
3301             <item>If the window manager supports the Debian menu system,
3302                 add 20 points if this support is available in the
3303                 package's default configuration (i.e., no
3304                 configuration files belonging to the system or user
3305                 have to be edited to activate the feature); if
3306                 configuration files must be modified, add only 10
3307                 points.</item>
3308             <item>If the window manager permits the X session to be
3309                 restarted using a <em>different</em> window manager
3310                 (without killing the X server) in its default
3311                 configuration, add 10 points; otherwise add
3312                 none.</item>
3313          </list>
3314        </p>
3315
3316         <p>
3317          <em>Packages that provide fonts for the X Window System</em>
3318          must do a number of things to ensure that they are both
3319          available without modification of the X or font server
3320          configuration, and that they do not corrupt files used by
3321          other font packages to register information about themselves.
3322          <enumlist>
3323            <item>
3324                 Fonts of any type supported by the X Window System
3325                 should be be in a separate binary package from any
3326                 executables, libraries, or documentation (except that
3327                 specific to the fonts shipped); if a program or
3328                 library is <em>unusable</em> without one or more
3329                 specific fonts, the package containing the program or
3330                 library should declare a dependency on the package(s)
3331                 containing the font(s) it requires.
3332             </item>
3333            <item>
3334                 BDF fonts should be converted to PCF fonts with the
3335                 <tt>bdftopcf</tt> utility (available in the
3336                 <tt>xbase-clients</tt> package, <tt>gzip</tt>ped, and
3337                 placed in a directory that corresponds to their
3338                 resolution:
3339                 <list>
3340                   <item>
3341                       100 dpi fonts should be placed in
3342                       <tt>/usr/X11R6/lib/X11/fonts/100dpi/</tt>.
3343                   </item>
3344                   <item>
3345                       75 dpi fonts should be placed in
3346                       <tt>/usr/X11R6/lib/X11/fonts/75dpi/</tt>.
3347                   </item>
3348                   <item>
3349                       Character-cell fonts, cursor fonts, and other
3350                       low-resolution fonts should be placed in
3351                       <tt>/usr/X11R6/lib/X11/fonts/misc/</tt>.
3352                   </item>
3353                 </list>
3354             </item>
3355             <item>
3356                 Speedo fonts should be placed in
3357                 <tt>/usr/X11R6/lib/X11/fonts/Speedo/</tt>.
3358             </item>
3359             <item>
3360                 Type 1 fonts should be placed in
3361                 <tt>/usr/X11R6/lib/X11/fonts/Type1/</tt>.  If font
3362                 metric files are available, they may be placed here as
3363                 well.
3364             </item>
3365             <item>
3366                 Subdirectories of <tt>/usr/X11R6/lib/X11/fonts/</tt>
3367                 other than those listed above should be neither created nor
3368                 used.  (The <tt>PEX</tt> and <tt>cyrillic</tt> directories are
3369                 excepted for historical reasons, but installation of files into
3370                 these directories remains discouraged.)
3371             </item>
3372             <item>
3373                 Font packages may, instead of placing files directly in
3374                 the X font directories listed above, provide symbolic links in
3375                 the font directory which point to the files' actual location
3376                 in the filesystem.  Such a location should comply with the
3377                 FHS.
3378             </item>
3379             <item>
3380                 Font packages should not contain both 75dpi and 100dpi
3381                 versions of a font.  If both are available, they should be
3382                 provided in separate binary packages with "-75dpi" or "-100dpi"
3383                 appended to the names of the packages containing the
3384                 corresponding fonts.
3385             </item>
3386             <item>
3387                 Fonts destined for the <tt>misc</tt> subdirectory should
3388                 not be included in the same package as 75dpi or 100dpi fonts;
3389                 instead, they should be provided in a separate package with
3390                 "-misc" appended to its name.
3391             </item>
3392             <item>
3393                 Font packages <em>must not</em> provide the files
3394                 <tt>fonts.dir</tt>, <tt>fonts.alias</tt>, or
3395                 <tt>fonts.scale</tt> in a font directory.
3396                 <list>
3397                   <item>
3398                       <tt>fonts.dir</tt> files must not be provided at
3399                       all.
3400                   </item>
3401                   <item>
3402                       <tt>fonts.alias</tt> and <tt>fonts.scale</tt>
3403                       files, if needed, should be provided in the
3404                       directory
3405                       <tt>/etc/X11/fonts/<em>fontdir</em>/<em>package</em>.<em>extension</em></tt>,
3406                       where <em>fontdir</em> is the name of the
3407                       subdirectory of
3408                       <tt>/usr/X11R6/lib/X11/fonts/</tt> where the
3409                       package's corresponding fonts are stored (e.g.,
3410                       <tt>75dpi</tt> or <tt>misc</tt>),
3411                       <em>package</em> is the name of the package that
3412                       provides these fonts, and <em>extension</em> is
3413                       either <tt>scale</tt> or <tt>alias</tt>,
3414                       whichever corresponds to the file
3415                       contents.
3416                   </item>
3417                 </list>
3418             </item>
3419             <item>
3420                 Font packages must declare a dependency on
3421                 <tt>xbase-clients</tt> and, in the package
3422                 post-installation and post-removal scripts, invoke the
3423                 <tt>mkfontdir</tt> command on each directory into
3424                 which they installed fonts.
3425             </item>
3426             <item>
3427                 Font packages that provide one or more
3428                 <tt>fonts.scale</tt> files as described above must declare a
3429                 versioned dependency on <tt>xbase-clients (&gt;=
3430                   3.3.3.1-5)</tt> and invoke <tt>update-fonts-scale</tt> on each
3431                 directory into which they installed fonts
3432                 <em>before</em> invoking <tt>mkfontdir</tt> on that
3433                 directory.  This invocation must occur in both the
3434                 post-installation and post-removal scripts.
3435             </item>
3436             <item>
3437                 Font packages that provide one or more
3438                 <tt>fonts.alias</tt> files as described above must
3439                 declare a versioned dependency on <tt>xbase-clients
3440                 (&gt;= 3.3.3.1-5)</tt> and, in the package
3441                 post-installation and post-removal scripts, invoke
3442                 <tt>update-fonts-alias</tt> on each directory into
3443                 which they installed fonts.
3444             </item>
3445             <item>
3446                 Font packages must not provide alias names for the
3447                 fonts they include which collide with alias names already in
3448                 use by fonts already packaged.
3449             </item>
3450             <item>
3451                 Font packages must not provide fonts with the same XLFD
3452                 registry name as another font already packaged.
3453             </item>
3454           </enumlist>
3455         </p>
3456         
3457         <p>
3458           <em>Application defaults</em> files must be installed in the
3459           directory <tt>/usr/X11R6/lib/X11/app-defaults/</tt>.
3460           <footnote>
3461             <p>Note: This shall change very shortly.</p>
3462           </footnote>
3463           They should not be registered as <em>conffile</em>s or
3464           otherwise treated as configuration files.  Customization of
3465           programs' X resources may be supported with the provision of
3466           a file with the same name as that of the package placed in
3467           the <tt>/etc/X11/Xresources/</tt> directory, which must
3468           registered as a <em>conffile</em>.  <em>Important:</em>
3469           packages that install files into the
3470           <tt>/etc/X11/Xresources/</tt> directory <em>must</em>
3471           declare a conflict with <tt>xbase (&lt;&lt;
3472             3.3.2.3a-2)</tt>; if this is not done it is possible for the
3473           installing package to destroy a previously-existing
3474           <tt>/etc/X11/Xresources</tt> <em>file</em> which had been
3475           customized by the system administrator.
3476           <footnote>
3477             <p>Rationale: clarifies the language to properly
3478               address the package maintainer, not the system
3479               administrator, as to how to manage
3480               /etc/X11/Xresources.</p>
3481           </footnote>
3482        </p>
3483
3484           
3485         <p>
3486           <em>Packages using the X Window System should abide by the FHS
3487             standard whenever possible</em>; they should install binaries,
3488           libraries, manual pages, and other files in FHS-mandated
3489           locations wherever possible.  This means that files must
3490           not be installed into <tt>/usr/X11R6/bin/</tt>,
3491           <tt>/usr/X11R6/lib/</tt>, or <tt>/usr/X11R6/man/</tt> unless
3492           this is necessary for the package to operate properly.
3493           Configuration files for window managers and display managers
3494           should be placed in a subdirectory of <tt>/etc/X11/</tt>
3495           corresponding to the package name due to these programs'
3496           tight integration with the mechanisms of the X Window
3497           System.  Application-level programs should use the
3498           <tt>/etc/</tt> directory unless otherwise mandated by
3499           policy.  The installation of files into subdirectories of
3500           <tt>/usr/X11R6/include/X11/</tt> and
3501           <tt>/usr/X11R6/lib/X11/</tt> is permitted but discouraged;
3502           package maintainers should determine if subdirectories of
3503           <tt>/usr/lib/</tt> and <tt>/usr/share/</tt> can be used
3504           instead (symlinks from the X11R6 directories to
3505           FHS-compliant locations is encouraged if the program is not
3506           easily configured to look elsewhere for its files).
3507           Packages must not provide -- or install files into -- the
3508           directories <tt>/usr/bin/X11/</tt>,
3509           <tt>/usr/include/X11/</tt>, or <tt>/usr/lib/X11/</tt>.
3510           Files within a package should, however, make reference to
3511           these directories, rather than their X11R6-named
3512           counterparts <tt>/usr/X11R6/bin/</tt>,
3513           <tt>/usr/X11R6/include/X11/</tt>, and
3514           <tt>/usr/X11R6/lib/X11/</tt>, if the resources being
3515           referred to have not been moved to FHS-compliant locations.
3516        </p>
3517
3518         <p>
3519           <em>Programs that require the non-DFSG-compliant OSF/Motif
3520             library</em> should be compiled against and tested with
3521           LessTif (a free re-implementation of Motif) instead.  If the
3522           maintainer judges that the program or programs do not work
3523           sufficiently well with LessTif to be distributed and
3524           supported, but do so when compiled against Motif, then two
3525           versions of the package should be created; one linked
3526           statically against Motif and with <tt>-smotif</tt> appended
3527           to the package name, and one linked dynamically against
3528           Motif and with <tt>-dmotif</tt> appended to the package
3529           name.  Both Motif-linked versions are dependent upon
3530           non-DFSG-compliant software and thus cannot be uploaded to
3531           the main distribution; if the software is itself
3532           DFSG-compliant it may be uploaded to the contrib
3533           distribution.  While known existing versions of OSF/Motif
3534           permit unlimited redistribution of binaries linked against
3535           the library (whether statically or dynamically), it is the
3536           package maintainer's responsibility to determine whether
3537           this is permitted by the license of the copy of OSF/Motif in
3538           his or her possession.
3539         </p>
3540       </sect>
3541           
3542           
3543       <sect>
3544         <heading>Emacs lisp programs</heading>
3545           
3546         <p>
3547           Please refer to the `Debian Emacs Policy' (documented in
3548           <tt>debian-emacs-policy.gz</tt> of the
3549           <prgn>emacsen-common</prgn> package) for details of how to
3550           package emacs lisp programs.</p></sect>
3551           
3552           
3553       <sect>
3554         <heading>Games</heading>
3555           
3556         <p>
3557           The permissions on /var/games are 755
3558           <tt>root.root</tt>.</p>
3559           
3560         <p>
3561           Each game decides on its own security policy.</p>
3562           
3563         <p>
3564           Games which require protected, privileged access to
3565           high-score files, savegames, etc., may be made
3566           set-<em>group</em>-id (mode 2755) and owned by
3567           <tt>root.games</tt>, and use files and directories with
3568           appropriate permissions (770 <tt>root.games</tt>, for
3569           example).  They must not be made
3570           set-<em>user</em>-id, as this causes security problems. (If
3571           an attacker can subvert any set-user-id game they can
3572           overwrite the executable of any other, causing other players
3573           of these games to run a Trojan horse program.  With a
3574           set-group-id game the attacker only gets access to less
3575           important game data, and if they can get at the other
3576           players' accounts at all it will take considerably more
3577           effort.)</p>
3578           
3579         <p>
3580           Some packages, for example some fortune cookie programs, are
3581           configured by the upstream authors to install with their
3582           data files or other static information made unreadable so
3583           that they can only be accessed through set-id programs
3584           provided.  You should not do this in a Debian package: anyone can
3585           download the <tt>.deb</tt> file and read the data from it,
3586           so there is no point making the files unreadable.  Not
3587           making the files unreadable also means that you don't have
3588           to make so many programs set-id, which reduces the risk of a
3589           security hole.</p>
3590           
3591         <p>
3592           As described in the FHS, binaries of games should be
3593           installed in the directory <tt>/usr/games</tt>. This also
3594           applies to games that use the X Window System. Manual pages
3595           for games (X and non-X games) should be installed in
3596           <tt>/usr/share/man/man6</tt>.</p>
3597       </sect>
3598     </chapt>
3599       
3600     <chapt><heading>Documentation</heading>
3601         
3602       
3603       <sect>
3604         <heading>Manual pages</heading>
3605           
3606         <p>
3607           You should install manual pages in <prgn>nroff</prgn> source
3608           form, in appropriate places under <tt>/usr/share/man</tt>.  You
3609           should only use sections 1 to 9 (see the FHS for more
3610           details).  You must not install a preformatted `cat
3611           page'.</p>
3612           
3613         <p>
3614           Each program, utiltiy, and function should have an
3615           associated manpage included in the same package. It is
3616           suggested that all configuration files also have a manual
3617           page included as well.
3618         </p>
3619           
3620         <p>
3621           If no manual page is available for a particular program,
3622           utility, function or configuration file and this is reported as a bug on
3623           debian-bugs, a symbolic link from the requested manual page
3624           to the <manref name="undocumented" section="7"> manual page
3625           may be provided.  This symbolic link can be created from
3626           <tt>debian/rules</tt> like this:
3627           <example>
3628             ln -s ../man7/undocumented.7.gz \
3629             debian/tmp/usr/share/man/man[1-9]/the_requested_manpage.[1-9].gz
3630           </example> 
3631           This manpage claims that the lack of a manpage has been
3632           reported as a bug, so you may only do this if it really has
3633           (you can report it yourself, if you like).  Do not close the
3634           bug report until a proper manpage is available.</p>
3635           
3636         <p>
3637           You may forward a complaint about a missing manpage to the
3638           upstream authors, and mark the bug as forwarded in the
3639           Debian bug tracking system.  Even though the GNU Project do
3640           not in general consider the lack of a manpage to be a bug,
3641           we do--if they tell you that they don't consider it a bug
3642           you should leave the bug in our bug tracking system open
3643           anyway.</p>
3644           
3645         <p>
3646           Manual pages should be installed compressed using <tt>gzip
3647           -9</tt>.</p>
3648           
3649         <p>
3650           If one manpage needs to be accessible via several names it
3651           is better to use a symbolic link than the <tt>.so</tt>
3652           feature, but there is no need to fiddle with the relevant
3653           parts of the upstream source to change from <tt>.so</tt> to
3654           symlinks--don't do it unless it's easy.  You should not create hard
3655           links in the manual page directories, nor put
3656           absolute filenames in <tt>.so</tt> directives.  The filename
3657           in a <tt>.so</tt> in a manpage should be relative to the
3658           base of the manpage tree (usually
3659           <tt>/usr/share/man</tt>).</p></sect>
3660           
3661           
3662       <sect>
3663         <heading>Info documents</heading>
3664           
3665         <p>
3666           Info documents should be installed in <tt>/usr/share/info</tt>.
3667           They should be compressed with <tt>gzip -9</tt>.</p>
3668           
3669         <p>
3670           Your package should call <prgn>install-info</prgn> to update the Info
3671           <tt>dir</tt>
3672           file, in its post-installation script:
3673           <example>
3674             install-info --quiet --section Development Development \
3675             /usr/share/info/foobar.info
3676           </example></p>
3677           
3678         <p>
3679           It is a good idea to specify a section for the location of
3680           your program; this is done with the <tt>--section</tt>
3681           switch.  To determine which section to use, you should look
3682           at <tt>/usr/share/info/dir</tt> on your system and choose the most
3683           relevant (or create a new section if none of the current
3684           sections are relevant).  Note that the <tt>--section</tt>
3685           flag takes two arguments; the first is a regular expression
3686           to match (case-insensitively) against an existing section,
3687           the second is used when creating a new one.</p>
3688           
3689         <p>
3690           You should remove the entries in the pre-removal script:
3691           <example>
3692             install-info --quiet --remove /usr/share/info/foobar.info
3693           </example></p>
3694           
3695         <p>
3696           If <prgn>install-info</prgn> cannot find a description entry
3697           in the Info file you must supply one.  See <manref
3698           name="install-info" section="8"> for details.</p>
3699       </sect>
3700       
3701       <sect>
3702         <heading>Additional documentation</heading>
3703         
3704         <p>
3705           Any additional documentation that comes with the package may
3706           be installed at the discretion of the package maintainer.
3707           Text documentation should be installed in a directory
3708           <tt>/usr/share/doc/<var>package</var></tt>, where
3709           <var>package</var> is the name of the package, and
3710           compressed with <tt>gzip -9</tt> unless it is small.</p>
3711         
3712         <p>
3713           If a package comes with large amounts of documentation which
3714           many users of the package will not require you should create
3715           a separate binary package to contain it, so that it does not
3716           take up disk space on the machines of users who do not need
3717           or want it installed.</p>
3718         
3719         <p>
3720           It is often a good idea to put text information files
3721           (<tt>README</tt>s, changelogs, and so forth) that come with
3722           the source package in <tt>/usr/share/doc/<var>package</var></tt>
3723           in the binary package.  However, you don't need to install
3724           the instructions for building and installing the package, of
3725           course!</p>
3726       </sect>
3727  
3728       <sect id="usrdoc">
3729       <heading>Accessing the documentation</heading>
3730
3731        <p>
3732          Former Debian releases placed all additional documentation
3733          in <tt>/usr/doc/<var>package</var></tt>.  To realize a
3734          smooth migration to
3735          <tt>/usr/share/doc/<var>package</var></tt>, each package
3736          must maintain a symlink <tt>/usr/doc/<var>package</var></tt>
3737          that points to the new location of its documentation in
3738          <tt>/usr/share/doc/<var>package</var></tt><footnote>These
3739          symlinks will be removed in the future, but they have to be
3740          there for compatibility reasons until all packages have
3741          moved and the policy is changed accordingly.</footnote>.
3742          The symlink must be created when the package is installed;
3743          it cannot be contained in the package itself due to problems
3744          with <prgn>dpkg</prgn>. One reasonable way to accomplish
3745          this is to put the following in the package's
3746          <prgn>postinst</prgn>:
3747           <example>
3748   if [ "$1" = "configure" ]; then
3749         if [ -d /usr/doc -a ! -e /usr/doc/#PACKAGE# \
3750             -a -d /usr/share/doc/#PACKAGE# ]; then
3751                 ln -sf ../share/doc/#PACKAGE# /usr/doc/#PACKAGE#
3752         fi
3753   fi
3754           </example>
3755           And the following in the package's <prgn>prerm</prgn>:
3756           <example>
3757   if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \
3758        -a -L /usr/doc/#PACKAGE# ]; then
3759         rm -f /usr/doc/#PACKAGE#
3760   fi
3761           </example>
3762         </p>
3763       </sect>
3764      
3765       <sect>
3766         <heading>Preferred documentation formats</heading>
3767         
3768         <p>
3769           The unification of Debian documentation is being carried out
3770           via HTML.</p>
3771         
3772         <p>
3773           If your package comes with extensive documentation in a
3774           mark up format that can be converted to various other formats
3775           you should if possible ship HTML versions in a binary
3776           package, in the directory
3777           <tt>/usr/share/doc/<var>appropriate package</var></tt> or its
3778           subdirectories.
3779           <footnote>
3780             <p>The rationale: The important thing here is that HTML
3781               docs should be available in <em>some</em> package, not
3782               necessarily in the main binary package, though. </p>
3783           </footnote>
3784         </p>
3785         
3786         <p>
3787           Other formats such as PostScript may be provided at your
3788           option.</p>
3789       </sect>
3790       
3791       <sect id="copyrightfile">
3792         <heading>Copyright information</heading>
3793         
3794         <p>
3795           Every package must be accompanied by a verbatim copy of its
3796           copyright and distribution license in the file
3797           /usr/share/doc/&lt;package-name&gt;/copyright. This file must
3798           neither be compressed nor be a symbolic link.</p>
3799         
3800         <p>
3801           In addition, the copyright file must say where the upstream
3802           sources (if any) were obtained, and should explain briefly what
3803           modifications were made in the Debian version of the package
3804           compared to the upstream one.  It should name the original
3805           authors of the package and the Debian maintainer(s) who were
3806           involved with its creation.</p>
3807         
3808         <p>
3809           /usr/share/doc/&lt;package-name&gt; may be a symbolic link to a
3810           directory in /usr/share/doc only if two packages both come from
3811           the same source and the first package has a "Depends"
3812           relationship on the second.  These rules are important
3813           because copyrights must be extractable by mechanical
3814           means.</p>
3815         
3816         <p>
3817           Packages distributed under the UCB BSD license, the Artistic
3818           license, the GNU GPL, and the GNU LGPL should refer to the
3819           files /usr/share/common-licenses/BSD,
3820           /usr/share/common-licenses/Artistic,
3821           /usr/share/common-licenses/GPL, and
3822           /usr/share/common-licenses/LGPL.
3823           <footnote>
3824             <p>
3825               Why "licenses" and not "copyright"? Because
3826               <tt>/usr/doc/copyright</tt> used to contain all the
3827               copyright files, plus the four common licenses GPL,
3828               LGPL, Artistic and BSD. Now individual copyright files
3829               for packages are no longer in a common directory. Once
3830               <tt>/usr/doc/copyright</tt> is almost empty it makes
3831               sense to rename "copyright" to "licenses"
3832             </p> 
3833             <p>
3834               Why "common-licenses" and not "licenses"? Because if I
3835               put just "licenses" I'm sure I will receive a bug report
3836               saying "license foo is not included in the licenses
3837               directory. They are not all the licenses, just a few
3838               common ones. I could use /usr/share/doc/common-licenses
3839               but I think this is too long, and, after all, the GPL
3840               does not "document" anything, it is merely a license.
3841             </p>
3842           </footnote>
3843         </p>
3844         
3845         <p>
3846           You should not use the copyright file as a general <tt>README</tt>
3847           file.  If your package has such a file it should be
3848           installed in <tt>/usr/share/doc/<var>package</var>/README</tt> or
3849           <tt>README.Debian</tt> or some other appropriate place.</p>
3850       </sect>
3851       
3852       <sect>
3853         <heading>Examples</heading>
3854         
3855         <p>
3856           Any examples (configurations, source files, whatever),
3857           should be installed in a directory
3858           <tt>/usr/share/doc/<var>package</var>/examples</tt>.  These
3859           files should not be referenced by any program--they're there
3860           for the benefit of the system administrator and users, as
3861           documentation only. Architecture-specific example files
3862           should be installed in a directory
3863           <tt>/usr/lib/<var>package</var>/examples</tt>, and files in
3864           <tt>/usr/share/doc/<var>package</var>/examples</tt> symlink
3865           to files in it. Or the latter directory may be a symlink to
3866           the former.</p>
3867       </sect>
3868       
3869       <sect id="instchangelog">
3870         <heading>Changelog files</heading>
3871         
3872         <p>
3873           Packages that are not Debian-native must contain a copy
3874           of <tt>debian/changelog</tt> file from the Debian source
3875           tree in <tt>/usr/share/doc/<var>package</var></tt>
3876           as <tt>changelog.Debian.gz</tt>. If an upstream
3877           changelog is available, it should be accessible as
3878           <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>
3879           in plain text. If the upstream changelog is distributed
3880           in HTML, it should be made available in that form as
3881           <tt>/usr/share/doc/<var>package</var>/changelog.html.gz</tt>
3882           and the <tt>changelog.gz</tt> should be generated using, eg,
3883           lynx -dump -nolist</tt>. If the upstream changelog files do
3884           not already conform to this naming convention, then this may
3885           be achieved either by renaming the files, or adding a symbolic
3886           link, at the maintainer's discretion.</p>
3887           <footnote>
3888             <p>
3889               Rationale: People should not have to look into two
3890               places for upstream changelogs merely because they are
3891               in HTML format.
3892             </p>
3893           </footnote>
3894         </p>
3895         
3896  
3897        <p>
3898          All these files should be installed compressed using <tt>gzip -9</tt>,
3899          as they will become large with time even if they start out
3900          small.
3901         </p>
3902         
3903         <p>
3904           If the package has only one changelog which is used both as
3905           the Debian changelog and the upstream one because there is
3906           no separate upstream maintainer then that changelog should
3907           usually be installed as
3908           <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>; if
3909           there is a separate upstream maintainer, but no upstream
3910           changelog, then the Debian changelog should still be called
3911           <tt>changelog.Debian.gz</tt>.</p>
3912       </sect>
3913     </chapt>    
3914   </book>
3915 </debiandoc>
3916
3917
3918
3919
3920
3921