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