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