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