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