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