]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
updated all the references to sub-policy documents to properly reference external...
[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   <book>
9     <titlepag>
10       <title>Debian Policy Manual</title>
11       <author><ref id="authors"></author>
12       <version>version &version;, &date;</version>
13
14       <abstract>
15         This manual describes the policy requirements for the Debian
16         GNU/Linux distribution.  This includes the structure and
17         contents of the Debian archive and several design issues of
18         the operating system, as well as technical requirements that
19         each package must satisfy to be included in the distribution.
20       </abstract>
21
22       <copyright>
23         <copyrightsummary>
24           Copyright &copy; 1996,1997,1998 Ian Jackson
25           and Christian Schwarz.
26         </copyrightsummary>
27         <p>
28           This manual is free software; you may redistribute it and/or
29           modify it under the terms of the GNU General Public License
30           as published by the Free Software Foundation; either version
31           2, or (at your option) any later version.
32         </p>
33
34         <p>
35           This is distributed in the hope that it will be useful, but
36           <em>without any warranty</em>; without even the implied
37           warranty of merchantability or fitness for a particular
38           purpose.  See the GNU General Public License for more
39           details.
40         </p>
41
42         <p>
43           A copy of the GNU General Public License is available as
44           <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
45           distribution or on the World Wide Web at
46           <url id="http://www.gnu.org/copyleft/gpl.html"
47                name="the GNU General Public Licence">. You can also
48           obtain it by writing to the Free Software Foundation, Inc.,
49           59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
50         </p>
51       </copyright>
52     </titlepag>
53
54     <toc detail="sect1">
55
56     <chapt id="scope">
57       <heading>About this manual</heading>
58       <sect>
59         <heading>Scope</heading>
60         <p>
61           This manual describes the policy requirements for the Debian
62           GNU/Linux distribution. This includes the structure and
63           contents of the Debian archive and several design issues of the
64           operating system, as well as technical requirements that
65           each package must satisfy to be included in the
66           distribution.
67         </p>
68
69         <p>
70           This manual also describes Debian policy as it relates to
71           creating Debian packages. It is not a tutorial on how to build
72           packages, nor is it exhaustive where it comes to describing
73           the behavior of the packaging system. Instead, this manual
74           attempts to define the interface to the package management
75           system that the developers have to be conversant with.<footnote>
76             <p>
77               Informally, the criteria used for inclusion is that the
78               material meet one of the following requirements:
79               <taglist compact="compact">
80                 <tag>Standard interfaces</tag>
81                 <item>
82                   <p>
83                     The material presented represents an interface to
84                     the packaging system that is mandated for use, and
85                     is used by, a significant number of packages, and
86                     therefore should not be changed without peer
87                     review. Package maintainers can then rely on this
88                     interfaces not changing, and the package
89                     management software authors need to ensure
90                     compatibility with these interface
91                     definitions. (Control file and changelog file
92                     formats are examples.)
93                   </p>
94                 </item>
95                 <tag>Chosen Convention</tag>
96                 <item>
97                   <p>
98                     If there are a number of technically viable choices
99                     that can be made, but one needs to select one of
100                     these options for inter-operability. The version
101                     number format is one example.
102                   </p>
103                 </item>
104               </taglist>
105               Please note that these are not mutually exclusive;
106               selected conventions often become parts of standard
107               interfaces.
108             </p>
109           </footnote>
110         </p>
111
112         <p>
113           The footnotes present in this manual are
114           merely informative, and are not part of Debian policy itself.
115         </p>
116
117         <p>
118           The appendices to this manual are not necessarily normative,
119           either. Please see <ref id="pkg-scope"> for more information.
120         </p>
121
122         <p>
123           In the normative part of this manual,
124           the words <em>must</em>, <em>should</em> and
125           <em>may</em>, and the adjectives <em>required</em>,
126           <em>recommended</em> and <em>optional</em>, are used to
127           distinguish the significance of the various guidelines in
128           this policy document. Packages that do not conform to the
129           guidelines denoted by <em>must</em> (or <em>required</em>)
130           will generally not be considered acceptable for the Debian
131           distribution. Non-conformance with guidelines denoted by
132           <em>should</em> (or <em>recommended</em>) will generally be
133           considered a bug, but will not necessarily render a package
134           unsuitable for distribution. Guidelines denoted by
135           <em>may</em> (or <em>optional</em>) are truly optional and
136           adherence is left to the maintainer's discretion.
137         </p>
138         <p>
139           These classifications are roughly equivalent to the bug
140           severities <em>serious</em> (for <em>must</em> or
141           <em>required</em> directive violations), <em>minor</em>,
142           <em>normal</em> or <em>important</em>
143           (for <em>should</em> or <em>recommended</em> directive
144           violations) and <em>wishlist</em> (for <em>optional</em>
145           items).<footnote>
146             <p>Compare RFC 2119.  Note, however, that these words are
147           used in a different way in this document.</p>
148           </footnote>
149         </p>
150         <p>
151           Much of the information presented in this manual will be
152           useful even when building a package which is to be
153           distributed in some other way or is intended for local use
154           only.
155         </p>
156       </sect>
157
158       <sect>
159         <heading>New versions of this document</heading>
160         <p>
161           The current version of this document is always accessible
162           from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
163           as
164           <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
165           (also available from the same directory are several other
166           formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
167           and <file>policy.ps.gz</file>) or from the <url
168           id="http://www.debian.org/doc/debian-policy/" name="Debian
169           Policy Manual"> webpage.</p>
170
171         <p>
172           In addition, this manual is distributed via the Debian package
173           <file>debian-policy</file>.
174         </p>
175
176         <p>
177           The <tt>debian-policy</tt> package also includes the file
178           <file>upgrading-checklist.txt</file> which indicates policy
179           changes between versions of this document.
180         </p>
181       </sect>
182
183       <sect id="authors">
184         <heading>Authors and Maintainers</heading>
185
186         <p>
187           Originally called "Debian GNU/Linux Policy Manual", this
188           manual was initially written in 1996 by Ian Jackson.
189           It was revised on November 27th, 1996 by David A. Morris.
190           Christian Schwarz added new sections on March 15th, 1997,
191           and reworked/restructured it in April-July 1997.
192           Christoph Lameter contributed the "Web Standard".
193           Julian Gilbey largely restructured it in 2001.
194         </p>
195
196         <p>
197           Since September 1998, the responsibility for the contents of
198           this document lies on the debian-policy mailing list. Proposals
199           are discussed there and inserted into policy after a certain
200           consensus is established.
201           <!-- insert shameless policy-process plug here eventually -->
202           The actual editing is done by a group of maintainers that have
203           no editorial powers. These are the current maintainers:
204
205           <enumlist>
206             <item>Julian Gilbey</item>
207             <item>Branden Robinson</item>
208             <item>Josip Rodin</item>
209             <item>Manoj Srivastava</item>
210           </enumlist>
211         </p>
212
213         <p>
214           While the authors of this document have tried hard to avoid
215           typos and other errors, these do still occur. If you discover
216           an error in this manual or if you want to give any
217           comments, suggestions, or criticisms please send an email to
218           the Debian Policy List,
219           <email>debian-policy@lists.debian.org</email>, or submit a
220           bug report against the <tt>debian-policy</tt> package.
221         </p>
222
223         <p>
224           Please do not try to reach the individual authors or maintainers
225           of the Policy Manual regarding changes to the Policy.
226         </p>
227       </sect>
228     </chapt>
229
230     <chapt id="archive">
231       <heading>The Debian Archive</heading>
232       <p>
233         The Debian GNU/Linux system is maintained and distributed as a
234         collection of <em>packages</em>. Since there are so many of
235         them (currently well over 6000), they are split into
236         <em>sections</em> and given <em>priorities</em> to simplify
237         the handling of them.
238       </p>
239       <p>
240         The effort of the Debian project is to build a free operating
241         system, but not every package we want to make accessible is
242         <em>free</em> in our sense (see the Debian Free Software
243         Guidelines, below), or may be imported/exported without
244         restrictions. Thus, the archive is split into the sections
245         <em>main</em>, <em>non-free</em>, <em>contrib</em>,
246         <em>non-US/main</em>, <em>non-US/non-free</em>, and
247         <em>non-US/contrib</em>.  The sections are explained in detail
248         below.
249       </p>
250
251       <p>
252         The <em>main</em> and the <em>non-US/main</em> sections
253         together form the <em>Debian GNU/Linux distribution</em>.
254       </p>
255
256       <p>
257         Packages in the other sections are not considered to be part
258         of the Debian distribution, although we support their use and
259         provide infrastructure for them (such as our bug-tracking
260         system and mailing lists). This Debian Policy Manual applies
261         to these packages as well.</p>
262
263       <sect id="pkgcopyright">
264         <heading>Package copyright and sections</heading>
265         <p>
266           The aims of this section are:
267
268           <list compact="compact">
269             <item>
270               <p>to allow us to make as much software available as we
271                 can,</p>
272             </item>
273             <item>
274               <p>to allow us to encourage everyone to write free
275               software, and</p>
276             </item>
277             <item>
278               <p>to allow us to make it easy for people to produce
279                 CD-ROMs of our system without violating any licenses,
280                 import/export restrictions, or any other laws.</p>
281             </item>
282           </list>
283         </p>
284         <sect1>
285           <heading>The Debian Free Software Guidelines</heading>
286           <p>
287             The Debian Free Software Guidelines (DFSG) form our
288             definition of "free software".  These are:
289             <taglist>
290               <tag>Free Redistribution
291               </tag>
292               <item>
293                 <p>
294                   The license of a Debian component may not restrict any
295                   party from selling or giving away the software as a
296                   component of an aggregate software distribution
297                   containing programs from several different
298                   sources. The license may not require a royalty or
299                   other fee for such sale.
300                 </p>
301               </item>
302               <tag>Source Code
303               </tag>
304               <item>
305                 <p>
306                   The program must include source code, and must allow
307                   distribution in source code as well as compiled form.
308                 </p>
309               </item>
310               <tag>Derived Works
311               </tag>
312               <item>
313                 <p>
314                   The license must allow modifications and derived
315                   works, and must allow them to be distributed under the
316                   same terms as the license of the original software.
317                 </p>
318               </item>
319               <tag>Integrity of The Author's Source Code
320               </tag>
321               <item>
322                 <p>
323                   The license may restrict source-code from being
324                   distributed in modified form <em>only</em> if the
325                   license allows the distribution of "patch files"
326                   with the source code for the purpose of modifying the
327                   program at build time. The license must explicitly
328                   permit distribution of software built from modified
329                   source code. The license may require derived works to
330                   carry a different name or version number from the
331                   original software.  (This is a compromise. The Debian
332                   Project encourages all authors to not restrict any
333                   files, source or binary, from being modified.)
334                 </p>
335               </item>
336               <tag>No Discrimination Against Persons or Groups
337               </tag>
338               <item>
339                 <p>
340                   The license must not discriminate against any person
341                   or group of persons.
342                 </p>
343               </item>
344               <tag>No Discrimination Against Fields of Endeavor
345               </tag>
346               <item>
347                 <p>
348                   The license must not restrict anyone from making use
349                   of the program in a specific field of endeavor. For
350                   example, it may not restrict the program from being
351                   used in a business, or from being used for genetic
352                   research.
353                 </p>
354               </item>
355               <tag>Distribution of License
356               </tag>
357               <item>
358                 <p>
359                   The rights attached to the program must apply to all
360                   to whom the program is redistributed without the need
361                   for execution of an additional license by those
362                   parties.
363                 </p>
364               </item>
365               <tag>License Must Not Be Specific to Debian
366               </tag>
367               <item>
368                 <p>
369                   The rights attached to the program must not depend on
370                   the program's being part of a Debian system. If the
371                   program is extracted from Debian and used or
372                   distributed without Debian but otherwise within the
373                   terms of the program's license, all parties to whom
374                   the program is redistributed must have the same
375                   rights as those that are granted in conjunction with
376                   the Debian system.
377                 </p>
378               </item>
379               <tag>License Must Not Contaminate Other Software
380               </tag>
381               <item>
382                 <p>
383                   The license must not place restrictions on other
384                   software that is distributed along with the licensed
385                   software. For example, the license must not insist
386                   that all other programs distributed on the same medium
387                   must be free software.
388                 </p>
389               </item>
390               <tag>Example Licenses
391               </tag>
392               <item>
393                 <p>
394                   The "GPL," "BSD," and "Artistic" licenses are examples of
395                   licenses that we consider <em>free</em>.
396                 </p>
397               </item>
398             </taglist>
399           </p>
400         </sect1>
401         <sect1>
402           <heading>The main section</heading>
403           <p>
404             Every package in <em>main</em> and <em>non-US/main</em>
405             must comply with the DFSG (Debian Free Software
406             Guidelines).</p>
407
408           <p>
409             In addition, the packages in <em>main</em>
410             <list compact="compact">
411               <item>
412                 <p>
413                   must not require a package outside of <em>main</em>
414                   for compilation or execution (thus, the package must
415                   not declare a "Depends", "Recommends", or
416                   "Build-Depends" relationship on a non-<em>main</em>
417                   package),
418                 </p>
419               </item>
420               <item>
421                 <p>
422                   must not be so buggy that we refuse to support them,
423                   and
424                 </p>
425               </item>
426               <item>
427                 <p>
428                   must meet all policy requirements presented in this
429                   manual.
430                 </p>
431               </item>
432             </list>
433           </p>
434           <p>
435             Similarly, the packages in <em>non-US/main</em>
436             <list compact="compact">
437               <item>
438                 <p>
439                    must not require a package outside of <em>main</em>
440                    or <em>non-US/main</em> for compilation or
441                    execution,
442                 </p>
443               </item>
444               <item>
445                 <p>
446                   must not be so buggy that we refuse to support them,
447                 </p>
448               </item>
449               <item>
450                 <p>
451                   must meet all policy requirements presented in this
452                   manual.
453                 </p>
454               </item>
455             </list>
456           </p>
457         </sect1>
458         <sect1>
459           <heading>The contrib section</heading>
460           <p>
461             Every package in <em>contrib</em> and
462             <em>non-US/contrib</em> must comply with the DFSG.
463           </p>
464
465           <p>
466             In addition, the packages in <em>contrib</em> and
467             <em>non-US/contrib</em>
468             <list compact="compact">
469               <item>
470                 <p>
471                   must not be so buggy that we refuse to support them,
472                   and
473                 </p>
474               </item>
475               <item>
476                 <p>
477                   must meet all policy requirements presented in this
478                   manual.
479                 </p>
480               </item>
481             </list>
482           </p>
483
484           <p>
485             Furthermore, packages in <em>contrib</em> must not require
486             a package in a <em>non-US</em> section for compilation or
487             execution.
488           </p>
489
490           <p>
491             Examples of packages which would be included in
492             <em>contrib</em> or <em>non-US/contrib</em> are:
493             <list compact="compact">
494               <item>
495                 <p>
496                   free packages which require <em>contrib</em>,
497                   <em>non-free</em> packages or packages which are not
498                   in our archive at all for compilation or execution,
499                   and
500                 </p>
501               </item>
502               <item>
503                 <p>
504                   wrapper packages or other sorts of free accessories for
505                   non-free programs.
506                 </p>
507               </item>
508             </list>
509           </p>
510         </sect1>
511         <sect1>
512           <heading>The non-free section</heading>
513           <p>
514             Packages must be placed in <em>non-free</em> or
515             <em>non-US/non-free</em> if they are not compliant with
516             the DFSG or are encumbered by patents or other legal
517             issues that make their distribution problematic.
518           </p>
519           <p>
520             In addition, the packages in <em>non-free</em> and
521             <em>non-US/non-free</em>
522             <list compact="compact">
523               <item>
524                 <p>
525                   must not be so buggy that we refuse to support them,
526                   and
527                 </p>
528               </item>
529               <item>
530                 <p>
531                   must meet all policy requirements presented in this
532                   manual that it is possible for them to meet.<footnote>
533                     <p>
534                       It is possible that there are policy
535                       requirements which the package is unable to
536                       meet, for example, if the source is
537                       unavailable.  These situations will need to be
538                       handled on a case-by-case basis.
539                     </p>
540                   </footnote>
541                 </p>
542               </item>
543             </list>
544           </p>
545         </sect1>
546
547         <sect1>
548           <heading>The non-US sections</heading>
549           <p>
550             Non-free programs with cryptographic program code need to
551             be stored on the <em>non-us</em> server because of export
552             restrictions of the U.S.
553           </p>
554           <p>
555             Programs which use patented algorithms that have a
556             restrictied license also need to be stored on "non-us",
557             since that is located in a country where it is not allowed
558             to patent algorithms.
559           </p>
560           <p>
561             A package depends on another package which is distributed
562             via the non-us server has to be stored on the non-us
563             server as well.
564           </p>
565         </sect1>
566         <sect1>
567           <heading>Further copyright considerations</heading>
568           <p>
569             Every package must be accompanied by a verbatim copy of
570             its copyright and distribution license in the file
571             <file>/usr/share/doc/<var>package</var>/copyright</file>
572             (see <ref id="copyrightfile"> for further details).
573           </p>
574           <p>
575             We reserve the right to restrict files from being included
576             anywhere in our archives if
577             <list compact="compact">
578               <item>
579                 <p>
580                   their use or distribution would break a law,
581                 </p>
582               </item>
583               <item>
584                 <p>
585                   there is an ethical conflict in their distribution or
586                   use,
587                 </p>
588               </item>
589               <item>
590                 <p>
591                   we would have to sign a license for them, or
592                 </p>
593               </item>
594               <item>
595                 <p>
596                   their distribution would conflict with other project
597                   policies.
598                 </p>
599               </item>
600             </list>
601           </p>
602
603           <p>
604             Programs whose authors encourage the user to make
605             donations are fine for the main distribution, provided
606             that the authors do not claim that not donating is
607             immoral, unethical, illegal or something similar; in such
608             a case they must go in <em>non-free</em>.</p>
609
610           <p>
611             Packages whose copyright permission notices (or patent
612             problems) do not even allow redistribution of binaries
613             only, and where no special permission has been obtained,
614             must not be placed on the Debian FTP site and its mirrors
615             at all.</p>
616
617           <p>
618             Note that under international copyright law (this applies
619             in the United States, too), <em>no</em> distribution or
620             modification of a work is allowed without an explicit
621             notice saying so.  Therefore a program without a copyright
622             notice <em>is</em> copyrighted and you may not do anything
623             to it without risking being sued! Likewise if a program
624             has a copyright notice but no statement saying what is
625             permitted then nothing is permitted.</p>
626
627           <p>
628             Many authors are unaware of the problems that restrictive
629             copyrights (or lack of copyright notices) can cause for
630             the users of their supposedly-free software.  It is often
631             worthwhile contacting such authors diplomatically to ask
632             them to modify their license terms. However, this can be a
633             politically difficult thing to do and you should ask for
634             advice on the <tt>debian-legal</tt> mailing list first, as
635             explained below.
636           </p>
637
638           <p>
639             When in doubt about a copyright, send mail to
640             <email>debian-legal@lists.debian.org</email>.  Be prepared
641             to provide us with the copyright statement.  Software
642             covered by the GPL, public domain software and BSD-like
643             copyrights are safe; be wary of the phrases "commercial
644             use prohibited" and "distribution restricted".
645           </p>
646         </sect1>
647         <sect1>
648           <heading>Subsections</heading>
649
650           <p>
651             The packages in the sections <em>main</em>,
652             <em>contrib</em> and <em>non-free</em> are grouped further
653             into <em>subsections</em> to simplify handling.
654           </p>
655
656           <p>
657             The section and subsection for each package should be
658             specified in the package's <tt>Section</tt> control
659             record.  However, the maintainer of the Debian archive
660             may override this selection to ensure the consistency of
661             the Debian distribution.  The <tt>Section</tt> field
662             should be of the form:
663             <list compact="compact">
664               <item>
665                 <p>
666                   <em>subsection</em> if the package is in the
667                   <em>main</em> section,
668                 </p>
669               </item>
670               <item>
671                 <p>
672                   <em>section/subsection</em> if the package is in
673                   the <em>contrib</em> or <em>non-free</em> section,
674                   and
675                 </p>
676               </item>
677               <item>
678                 <p>
679                   <tt>non-US</tt>, <tt>non-US/contrib</tt> or
680                   <tt>non-US/non-free</tt> if the package is in
681                   <em>non-US/main</em>, <em>non-US/contrib</em> or
682                   <em>non-US/non-free</em> respectively.
683                 </p>
684               </item>
685             </list>
686           </p>
687
688           <p>
689             The Debian archive maintainers provide the authoritative
690             list of subsections.  At present, they are:
691             <em>admin</em>, <em>base</em>, <em>comm</em>,
692             <em>contrib</em>, <em>devel</em>, <em>doc</em>,
693             <em>editors</em>, <em>electronics</em>, <em>games</em>,
694             <em>graphics</em>, <em>hamradio</em>,
695             <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
696             <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
697             <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
698             <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
699             <em>sound</em>, <em>tex</em>, <em>text</em>,
700             <em>utils</em>, <em>web</em>, <em>x11</em>.
701           </p>
702         </sect1>
703       <sect>
704         <heading>Priorities</heading>
705
706         <p>
707           Each package should have a <em>priority</em> value, which is
708           included in the package's <em>control record</em>. This
709           information is used by the Debian package management tools
710           to separate high-priority packages from less-important
711           packages.</p>
712
713         <p>
714           The following <em>priority levels</em> are recognised by the
715           Debian package management tools.
716           <taglist>
717             <tag><tt>required</tt></tag>
718             <item>
719               <p>
720                 Packages which are necessary for the proper
721                 functioning of the system.  You must not remove these
722                 packages or your system may become totally broken and
723                 you may not even be able to use <prgn>dpkg</prgn> to
724                 put things back.  Systems with only the
725                 <tt>required</tt> packages are probably unusable, but
726                 they do have enough functionality to allow the
727                 sysadmin to boot and install more software.</p>
728             </item>
729             <tag><tt>important</tt></tag>
730             <item>
731               <p>
732                 Important programs, including those which one would
733                 expect to find on any Unix-like system.  If the
734                 expectation is that an experienced Unix person who
735                 found it missing would say "What on earth is going on,
736                 where is <prgn>foo</prgn>?", it must be an
737                 <tt>important</tt> package.<footnote>
738                   <p>
739                     This is an important criterion because we are
740                     trying to produce, amongst other things, a free
741                     Unix.
742                   </p>
743                 </footnote>
744                 Other packages without which the system will not run
745                 well or be usable must also have priority
746                 <tt>important</tt>.  This does
747                 <em>not</em> include Emacs, the X Window System, TeX
748                 or any other large applications.  The
749                 <tt>important</tt> packages are just a bare minimum of
750                 commonly-expected and necessary tools.</p>
751             </item>
752             <tag><tt>standard</tt></tag>
753             <item>
754               <p>
755                 These packages provide a reasonably small but not too
756                 limited character-mode system.  This is what will be
757                 installed by default if the user doesn't select anything
758                 else.  It doesn't include many large applications.</p>
759             </item>
760             <tag><tt>optional</tt></tag>
761             <item>
762               <p>
763                 (In a sense everything that isn't required is
764                 optional, but that's not what is meant here.) This is
765                 all the software that you might reasonably want to
766                 install if you didn't know what it was and don't have
767                 specialized requirements. This is a much larger system
768                 and includes the X Window System, a full TeX
769                 distribution, and many applications. Note that
770                 optional packages should not conflict with each other.
771               </p>
772             </item>
773             <tag><tt>extra</tt></tag>
774             <item>
775               <p>
776                 This contains all packages that conflict with others
777                 with required, important, standard or optional
778                 priorities, or are only likely to be useful if you
779                 already know what they are or have specialised
780                 requirements.
781               </p>
782             </item>
783           </taglist></p>
784
785         <p>
786           Packages must not depend on packages with lower priority
787           values (excluding build-time dependencies).  In order to
788           ensure this, the priorities of one or more packages may need
789           to be adjusted.
790         </p>
791       </sect>
792
793       <sect>
794         <heading>Binary packages</heading>
795
796         <p>
797           The Debian GNU/Linux distribution is based on the Debian
798           package management system, called <prgn>dpkg</prgn>. Thus,
799           all packages in the Debian distribution must be provided
800           in the <tt>.deb</tt> file format.</p>
801
802
803         <sect1>
804           <heading>The package name</heading>
805
806           <p>
807             Every package must have a name that's unique within the Debian
808             archive.</p>
809
810           <p>
811             Package names must consist of lower case letters
812             (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
813             and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
814             They must be at least two characters long and must start
815             with an alphanumeric character.
816           </p>
817
818           <p>
819             The package name is part of the file name of the
820             <tt>.deb</tt> file and is included in the control field
821             information.
822           </p>
823         </sect1>
824
825         <sect1>
826           <heading>The maintainer of a package</heading>
827          <p>
828             Every package must have a Debian maintainer (the
829             maintainer may be one person or a group of people
830             reachable from a common email address, such as a mailing
831             list).  The maintainer is responsible for ensuring that
832             the package is placed in the appropriate distributions.
833           </p>
834
835           <p>
836             The maintainer must be specified in the
837             <tt>Maintainer</tt> control field with their correct name
838             and a working email address.  If one person maintains
839             several packages, he/she should try to avoid having
840             different forms of their name and email address in
841             the <tt>Maintainer</tt> fields of those packages.
842           </p>
843
844           <p>
845             If the maintainer of a package quits from the Debian
846             project, "Debian QA Group"
847             <email>packages@qa.debian.org</email> takes over the
848             maintainership of the package until someone else
849             volunteers for that task. These packages are called
850             <em>orphaned packages</em>.<footnote>
851               <p>
852                 The detailed procedure for doing this gracefully can
853                 be found in the Debian Developer's Reference, either
854                 in the <tt>developers-reference</tt> package, or on
855                 the Debian FTP server
856                 <ftpsite>ftp.debian.org</ftpsite> as
857                 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
858                 or from the <url
859                 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
860                 name="Debian Developer's Reference"> webpage.
861               </p>
862             </footnote>
863           </p>
864         </sect1>
865
866
867         <sect1>
868           <heading>The description of a package</heading>
869
870           <p>
871             Every Debian package must have an extended description
872             stored in the appropriate field of the control record.</p>
873
874           <p>
875             The description should be written so that it gives the
876             system administrator enough information to decide whether
877             to install the package. This description should not just
878             be copied verbatim from the program's documentation.
879             Instructions for configuring or using the package should
880             not be included (that is what installation scripts,
881             manual pages, info files, etc., are for).  Copyright
882             statements and other administrivia should not be included
883             either (that is what the copyright file is for).
884           </p>
885
886           <p>
887             Please refer to <ref id="descriptions"> for more information.
888           </p>
889
890         </sect1>
891
892
893         <sect1>
894           <heading>Dependencies</heading>
895
896           <p>
897             Every package must specify the dependency information
898             about other packages that are required for the first to
899             work correctly.</p>
900
901           <p>
902             For example, a dependency entry must be provided for any
903             shared libraries required by a dynamically-linked executable
904             binary in a package.</p>
905
906           <p>
907             Packages are not required to declare any dependencies they
908             have on other packages which are marked <tt>Essential</tt>
909             (see below), and should not do so unless they depend on a
910             particular version of that package.</p>
911
912           <p>
913             Sometimes, a package requires another package to be installed
914             <em>and</em> configured before it can be installed. In this
915             case, you must specify a <tt>Pre-Depends</tt> entry for
916             the package.</p>
917
918           <p>
919             You should not specify a <tt>Pre-Depends</tt> entry for a
920             package before this has been discussed on the
921             <tt>debian-devel</tt> mailing list and a consensus about
922             doing that has been reached.</p></sect1>
923
924
925         <sect1 id="virtual_pkg">
926           <heading>Virtual packages</heading>
927
928           <p>
929             Sometimes, there are several packages which offer
930             more-or-less the same functionality. In this case, it's
931             useful to define a <em>virtual package</em> whose name
932             describes that common functionality.  (The virtual
933             packages only exist logically, not physically; that's why
934             they are called <em>virtual</em>.) The packages with this
935             particular function will then <em>provide</em> the virtual
936             package. Thus, any other package requiring that function
937             can simply depend on the virtual package without having to
938             specify all possible packages individually.</p>
939
940           <p>
941             All packages should use virtual package names where
942             appropriate, and arrange to create new ones if necessary.
943             They should not use virtual package names (except privately,
944             amongst a cooperating group of packages) unless they have
945             been agreed upon and appear in the list of virtual package
946             names. (See also <ref id="virtual">)</p>
947
948           <p>
949             The latest version of the authoritative list of virtual
950             package names can be found in the <tt>debian-policy</tt> package.
951             It's also available from the Debian web mirrors at
952             <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
953                 id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>
954             and from the Debian archive mirrors at
955             <tt><url name="/doc/package-developer/virtual-package-names-list.txt"
956                 id="http://ftp.debian.org/debian/doc/package-developer/virtual-package-names-list.txt"></tt>.
957           </p>
958
959           <p>
960             The procedure for updating the list is described in the preface
961             to the list.
962           </p>
963
964         </sect1>
965
966         <sect1>
967           <heading>Base system</heading>
968
969           <p>
970             The  <tt>base system</tt> is a minimum subset of the Debian
971             GNU/Linux system that is installed before everything else
972             on a new system. Thus, only very few packages are allowed
973             to go into the <tt>base</tt> section to keep the required
974             disk usage very small.</p>
975
976           <p>
977             Most of these packages will have the priority value
978             <tt>required</tt> or at least <tt>important</tt>, and many
979             of them will be tagged <tt>essential</tt> (see below).</p>
980
981
982         </sect1>
983
984
985         <sect1>
986           <heading>Essential packages</heading>
987
988           <p>
989             Some packages are tagged <tt>essential</tt>. (They have
990             <tt>Essential: yes</tt> in their package control record.)
991             This flag is used for packages that are <em>essential</em>
992             for a system.</p>
993
994           <p>
995             Since these packages cannot be easily removed (one has to
996             specify an extra <em>force option</em> to
997             <prgn>dpkg</prgn> to do so), this flag must not be used
998             unless absolutely necessary.  A shared library package
999             must not be tagged <tt>essential</tt>; dependencies will
1000             prevent its premature removal, and we need to be able to
1001             remove it when it has been superseded.
1002           </p>
1003
1004           <p>
1005             Since dpkg will not prevent upgrading of other packages
1006             while an <tt>essential</tt> package is in an unconfigured
1007             state, all <tt>essential</tt> packages must supply all of
1008             their core functionality even when unconfigured. If the
1009             package cannot satisfy this requirement it must not be
1010             tagged as essential, and any packages depending on this
1011             package must instead have explicit dependency fields as
1012             appropriate.
1013           </p>
1014
1015           <p>
1016             You must not tag any packages <tt>essential</tt> before
1017             this has been discussed on the <tt>debian-devel</tt>
1018             mailing list and a consensus about doing that has been
1019             reached.
1020           </p>
1021         </sect1>
1022          <sect1>
1023           <heading>Tasks</heading>
1024
1025           <p>
1026             The Debian install process allows the user to choose from
1027             a number of common tasks which a Debian system can be used to
1028             perform. Selecting a task with <prgn>tasksel</prgn> causes
1029             a set of packages that are useful in performing that task to be
1030             installed.
1031           </p>
1032
1033           <p>
1034             This set of packages is all available packages which have the
1035             name of the selected task in the <tt>Task</tt> field of their
1036             control file. The format of this field is a list of tasks,
1037             separated by commas.
1038           </p>
1039
1040           <p>
1041             You should not tag any packages as belonging to a task
1042             before this has been discussed on the
1043             <em>debian-devel</em> mailing list and a consensus about
1044             doing that has been reached.
1045           </p>
1046
1047           <p>
1048             For third parties (and historical reasons), tasksel also
1049             supports constructing tasks based on <em>task
1050             packages</em>. These are packages whose names begin with
1051             <em>task-</em>. Task packages should not be included in the
1052             Debian archive.
1053           </p>
1054         </sect1>
1055
1056         <sect1 id="maintscripts">
1057           <heading>Maintainer Scripts</heading>
1058
1059           <p>
1060             The package installation scripts should avoid producing
1061             output which it is unnecessary for the user to see and
1062             should rely on <prgn>dpkg</prgn> to stave off boredom on
1063             the part of a user installing many packages.  This means,
1064             amongst other things, using the <tt>--quiet</tt> option on
1065             <prgn>install-info</prgn>.</p>
1066
1067           <p>
1068             Errors which occur during the execution of an installation
1069             script must be checked and the installation must not
1070             continue after an error.
1071           </p>
1072
1073           <p>
1074             Note that in general <ref id="scripts"> applies to package
1075             maintainer scripts, too.
1076           </p>
1077
1078           <p>
1079             You should not use <prgn>dpkg-divert</prgn> on a file
1080             belonging to another package without consulting the
1081             maintainer of that package first.
1082           </p>
1083
1084           <p>
1085             All packages which supply an instance of a common command
1086             name (or, in general, filename) should generally use
1087             <prgn>update-alternatives</prgn>, so that they may be
1088             installed together.  If <prgn>update-alternatives</prgn>
1089             is not used, then each package must use
1090             <tt>Conflicts</tt> to ensure that other packages are
1091             de-installed.  (In this case, it may be appropriate to
1092             specify a conflict against earlier versions of something
1093             that previously did not use
1094             <prgn>update-alternatives</prgn>; this is an exception to
1095             the usual rule that versioned conflicts should be
1096             avoided.)
1097           </p>
1098
1099
1100           <sect2>
1101             <heading>Prompting in maintainer scripts</heading>
1102             <p>
1103               Package maintainer scripts may prompt the user if
1104               necessary. Prompting may be accomplished by hand, or by
1105               communicating with a program, such as
1106               <prgn>debconf</prgn>, which conforms to the Debian
1107               Configuration management specification, version 2 or
1108               higher.  These are included in the
1109               <file>debconf_specification</file> files in the
1110               <package>debian-policy</package> package.
1111               You may also find this file on the FTP site
1112               <ftpsite>ftp.debian.org</ftpsite> in
1113               <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1114               or on your local mirror.<footnote>
1115                 <p>
1116                   4% of Debian packages [see <url
1117                   id="http://kitenet.net/programs/debconf/stats/"
1118                   name="Debconf stats">] currently use
1119                   <package>debconf</package> to prompt the user at
1120                   install time, and this number is growing daily. The
1121                   benefits of using debconf are briefly explained at
1122                   <url
1123                   id="http://kitenet.net/doc/debconf-doc/introduction.html"
1124                   name="Debconf introduction">; they include
1125                   preconfiguration, (mostly) noninteractive
1126                   installation, elimination of redundant prompting,
1127                   consistency of user interface, etc.
1128                 </p>
1129                 <p>
1130                   With this increasing number of packages using
1131                   <package>debconf</package>, plus the existance of a
1132                   nascent second implementation of the Debian
1133                   configuration management system
1134                   (<package>cdebconf</package>), and the stabilization
1135                   of the protocol these things use, the time has
1136                   finally come to reflect the use of these things in
1137                   policy.
1138
1139                 </p>
1140               </footnote>
1141             </p>
1142             <p>
1143               Packages which use the Debian Configuration management
1144               specification may contain an additional
1145               <prgn>config</prgn> script and a <tt>templates</tt>
1146               file in their control archive. The <prgn>config</prgn>
1147               script might be run before the <prgn>preinst</prgn>
1148               script, and before the package is unpacked or any of its
1149               dependencies or pre-dependancies are satisfied.
1150               Therefore it must work using only the tools present in
1151               <em>essential</em> packages.<footnote>
1152                 <p>
1153                   <package>Debconf</package> or another tool that
1154                   implements the Debian Configuration management
1155                   specification will also be installed, and any
1156                   versioned dependencies on it will be satisfied
1157                   before preconfiguration begins.
1158                 </p>
1159               </footnote>
1160             </p>
1161
1162             <p>
1163               Packages should try to minimize the amount of prompting
1164               they need to do, and they should ensure that the user
1165               will only ever be asked each question once.  This means
1166               that packages should try to use appropriate shared
1167               configuration files (such as <file>/etc/papersize</file> and
1168               <file>/etc/news/server</file>), and shared
1169               <package>debconf</package> variables rather than each
1170               prompting for their own list of required pieces of
1171               information.
1172             </p>
1173
1174             <p>
1175               It also means that an upgrade should not ask the same
1176               questions again, unless the user has used <tt>dpkg
1177                 --purge</tt> to remove the package's configuration.  The
1178               answers to configuration questions should be stored in an
1179               appropriate place in <file>/etc</file> so that the user can
1180               modify them, and how this has been done should be
1181               documented.</p>
1182
1183             <p>
1184               If a package has a vitally important piece of
1185               information to pass to the user (such as "don't run me
1186               as I am, you must edit the following configuration files
1187               first or you risk your system emitting badly-formatted
1188               messages"), it should display this in the
1189               <prgn>config</prgn> or <prgn>postinst</prgn> script and
1190               prompt the user to hit return to acknowledge the
1191               message.  Copyright messages do not count as vitally
1192               important (they belong in
1193               <file>/usr/share/doc/<var>package</var>/copyright</file>);
1194               neither do instructions on how to use a program (these
1195               should be in on-line documentation, where all the users
1196               can see them).</p>
1197
1198             <p>
1199               Any necessary prompting should almost always be confined
1200               to the <prgn>config</prgn> or <prgn>postinst</prgn>
1201               script. If it is done in the <prgn>postinst</prgn>, it
1202               should be protected with a conditional so that
1203               unnecessary prompting doesn't happen if a package's
1204               installation fails and the <prgn>postinst</prgn> is
1205               called with <tt>abort-upgrade</tt>,
1206               <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1207         </sect1>
1208       </sect>
1209
1210       <sect>
1211         <heading>Source packages</heading>
1212
1213         <sect1 id="standardsversion">
1214           <heading>Standards conformance</heading>
1215
1216           <p>
1217             In the source package's <tt>Standards-Version</tt> control
1218             field, you should specify the most recent version number
1219             of this policy document with which your package complied
1220             when it was last updated.  The current version number is
1221             &version;.
1222           </p>
1223
1224           <p>
1225             This information may be used to file bug reports
1226             automatically if your package becomes too much out of
1227             date.
1228           </p>
1229
1230           <p>
1231             The version number has four components: major and minor
1232             version number and major and minor patch level.  When the
1233             standards change in a way that requires every package to
1234             change the major number will be changed.  Significant
1235             changes that will require work in many packages will be
1236             signaled by a change to the minor number.  The major patch
1237             level will be changed for any change to the meaning of the
1238             standards, however small; the minor patch level will be
1239             changed when only cosmetic, typographical or other edits
1240             are made which neither change the meaning of the document
1241             nor affect the contents of packages.</p>
1242
1243           <p>
1244             Thus only the first three components of the policy version
1245             are significant in the <em>Standards-Version</em> control
1246             field, and so either these three components or the all
1247             four components may be specified.<footnote>
1248               <p>
1249                 In the past, people specified the full version number
1250                 in the Standards-Version field, for example "2.3.0.0".
1251                 Since minor patch-level changes don"t introduce new
1252                 policy, it was thought it would be better to relax
1253                 policy and only require the first 3 components to be
1254                 specified, in this example "2.3.0".  All four
1255                 components may still be used if someone wishes to do
1256                 so.
1257               </p>
1258             </footnote>
1259           </p>
1260
1261           <p>
1262             You should regularly, and especially if your package has
1263             become out of date, check for the newest Policy Manual
1264             available and update your package, if necessary. When your
1265             package complies with the new standards you should update the
1266             <tt>Standards-Version</tt> source package field and
1267             release it.<footnote>
1268               <p>
1269                 See the file <file>upgrading-checklist</file> for
1270                 information about policy which has changed between
1271                 different versions of this document.
1272               </p>
1273             </footnote>
1274           </p>
1275         </sect1>
1276
1277
1278         <sect1 id="pkg-relations">
1279           <heading>Package relationships</heading>
1280
1281           <p>
1282             Source packages should specify which binary packages they
1283             require to be installed or not to be installed in order to
1284             build correctly.  For example, if building a package
1285             requires a certain compiler, then the compiler should be
1286             specified as a build-time dependency.
1287           </p>
1288
1289           <p>
1290             It is not necessary to explicitly specify build-time
1291             relationships on a minimal set of packages that are always
1292             needed to compile, link and put in a Debian package a
1293             standard "Hello World!" program written in C or C++.  The
1294             required packages are called <em>build-essential</em>, and
1295             an informational list can be found in
1296             <file>/usr/share/doc/build-essential/list</file> (which is
1297             contained in the <tt>build-essential</tt>
1298             package).<footnote>
1299               <p>Rationale:
1300                 <list compact="compact">
1301                   <item>
1302                     <p>This allows maintaining the list separately
1303                       from the policy documents (the list does not
1304                       need the kind of control that the policy
1305                       documents do).
1306                     </p>
1307                   </item>
1308                   <item>
1309                     <p>
1310                       Having a separate package allows one to install
1311                       the build-essential packages on a machine, as
1312                       well as allowing other packages such as tasks to
1313                       require installation of the build-essential
1314                       packages using the depends relation.
1315                     </p>
1316                   </item>
1317                   <item>
1318                     <p>
1319                       The separate package allows bug reports against
1320                       the list to be categorized separately from
1321                       the policy management process in the BTS.
1322                     </p>
1323                   </item>
1324                 </list>
1325               </p>
1326
1327             </footnote>
1328           </p>
1329
1330           <p>
1331             When specifying the set of build-time dependencies, one
1332             should list only those packages explicitly required by the
1333             build.  It is not necessary to list packages which are
1334             required merely because some other package in the list of
1335             build-time dependencies depends on them.<footnote>
1336               <p>
1337                 The reason for this is that dependencies change, and
1338                 you should list all those packages, and <em>only</em>
1339                 those packages that <em>you</em> need directly.  What
1340                 others need is their business.  For example, if you
1341                 only link against <file>libimlib</file>, you will need to
1342                 build-depend on <package>libimlib2-dev</package> but
1343                 not against any <tt>libjpeg*</tt> packages, even
1344                 though <tt>libimlib2-dev</tt> currently depends on
1345                 them: installation of <package>libimlib2-dev</package>
1346                 will automatically ensure that all of its run-time
1347                 dependencies are satisfied.
1348               </p>
1349             </footnote>
1350           </p>
1351
1352           <p>
1353             If build-time dependencies are specified, it must be
1354             possible to build the package and produce working binaries
1355             on a system with only essential and build-essential
1356             packages installed and also those required to satisfy the
1357             build-time relationships (including any implied
1358             relationships).  In particular, this means that version
1359             clauses should be used rigorously in build-time
1360             relationships so that one cannot produce bad or
1361             inconsistently configured packages when the relationships
1362             are properly satisfied.
1363           </p>
1364
1365           <p>
1366             <ref id="relationships"> explains the technical details.
1367           </p>
1368
1369         <sect1>
1370           <heading>Changes to the upstream sources</heading>
1371
1372           <p>
1373             If changes to the source code are made that are not
1374             specific to the needs of the Debian system, they should be
1375             sent to the upstream authors in whatever form they prefer
1376             so as to be included in the upstream version of the
1377             package.</p>
1378
1379           <p>
1380             If you need to configure the package differently for
1381             Debian or for Linux, and the upstream source doesn't
1382             provide a way to do so, you should add such configuration
1383             facilities (for example, a new <prgn>autoconf</prgn> test
1384             or <tt>#define</tt>) and send the patch to the upstream
1385             authors, with the default set to the way they originally
1386             had it.  You can then easily override the default in your
1387             <file>debian/rules</file> or wherever is appropriate.</p>
1388
1389           <p>
1390             You should make sure that the <prgn>configure</prgn> utility
1391             detects the correct architecture specification string
1392             (refer to <ref id="arch-spec"> for details).</p>
1393
1394           <p>
1395             If you need to edit a <prgn>Makefile</prgn> where
1396             GNU-style <prgn>configure</prgn> scripts are used, you
1397             should edit the <file>.in</file> files rather than editing the
1398             <prgn>Makefile</prgn> directly.  This allows the user to
1399             reconfigure the package if necessary.  You should
1400             <em>not</em> configure the package and edit the generated
1401             <prgn>Makefile</prgn>!  This makes it impossible for
1402             someone else to later reconfigure the package.</p>
1403
1404           <p>
1405             You should document your changes and updates to the source
1406             package properly in the <file>debian/changelog</file> file.
1407             For more information, please see <ref id="changelogs">.
1408           </p>
1409         </sect1>
1410
1411
1412         <sect1>
1413           <heading>Error trapping in makefiles</heading>
1414
1415           <p>
1416             When <prgn>make</prgn> invokes a command in a makefile
1417             (including your package's upstream makefiles and
1418             <file>debian/rules</file>), it does so using <prgn>sh</prgn>.  This
1419             means that <prgn>sh</prgn>'s usual bad error handling
1420             properties apply: if you include a miniature script as one
1421             of the commands in your makefile you'll find that if you
1422             don't do anything about it then errors are not detected
1423             and <prgn>make</prgn> will blithely continue after
1424             problems.</p>
1425
1426           <p>
1427             Every time you put more than one shell command (this
1428             includes using a loop) in a makefile command you
1429             must make sure that errors are trapped.  For
1430             simple compound commands, such as changing directory and
1431             then running a program, using <tt>&amp;&amp;</tt> rather
1432             than semicolon as a command separator is sufficient.  For
1433             more complex commands including most loops and
1434             conditionals you should include a separate <tt>set -e</tt>
1435             command at the start of every makefile command that's
1436             actually one of these miniature shell scripts.</p></sect1>
1437
1438
1439         <sect1>
1440           <heading>Obsolete constructs and libraries</heading>
1441
1442           <p>
1443             The include file <tt>&lt;varargs.h&gt;</tt> is
1444             provided to support end-users compiling very old software;
1445             the library <tt>libtermcap</tt> is provided to support the
1446             execution of software which has been linked against it
1447             (either old programs or those such as Netscape which are
1448             only available in binary form).</p>
1449
1450           <p>
1451             Debian packages should be patched to use
1452             <tt>&lt;stdarg.h&gt;</tt> and <tt>ncurses</tt>
1453             instead.
1454           </p>
1455         </sect1>
1456       </sect>
1457     </chapt>
1458
1459     <chapt id="controlfields"><heading>Control files and their fields</heading>
1460
1461       <p>
1462         Many of the tools in the package management suite manipulate
1463         data represented in a common format, known as <em>control
1464         data</em>.  The data is often stored in <em>control
1465         files</em>.  Binary and source packages have control files,
1466         and the <file>.changes</file> files which control the installation
1467         of uploaded files are also in control file format.
1468         <prgn>dpkg</prgn>'s internal databases are in a similar
1469         format.
1470       </p>
1471
1472       <sect id="controlsyntax"><heading>Syntax of control files</heading>
1473
1474         <p>
1475           A control file consists of one or more paragraphs of fields.
1476           The paragraphs are separated by blank lines.  Some control
1477           files allow only one paragraph; others allow several, in
1478           which case each paragraph usually refers to a different
1479           package.  (For example, in source packages, the first
1480           paragraph refers to the source package, and later paragraphs
1481           refer to binary packages generated from the source.)
1482         </p>
1483
1484         <p>
1485           Each paragraph consists of a series of data fields; each
1486           field consists of the field name, followed by a colon and
1487           then the data/value associated with that field.  It ends at
1488           the end of the line.  Horizontal whitespace (spaces and
1489           tabs) may occur immediately before or after the value and is
1490           ignored there; it is conventional to put a single space
1491           after the colon.  For example, a field might be:
1492           <example compact="compact">
1493 Package: libc6
1494           </example>
1495           the field name is <tt>Package</tt> and the field value
1496           <tt>libc6</tt>.
1497         </p>
1498
1499         <p>
1500           Some fields' values may span several lines; in this case
1501           each continuation line <em>must</em> start with a space or
1502           tab.  Any trailing spaces or tabs at the end of individual
1503           lines of a field value are ignored.
1504         </p>
1505
1506         <p>
1507           Except where otherwise stated only a single line of data is
1508           allowed and whitespace is not significant in a field body.
1509           Whitespace must not appear inside names (of packages,
1510           architectures, files or anything else) or version numbers,
1511           or between the characters of multi-character version
1512           relationships.
1513         </p>
1514
1515         <p>
1516           Field names are not case-sensitive, but it is usual to
1517           capitalize the field names using mixed case as shown below.
1518         </p>
1519
1520         <p>
1521           Blank lines, or lines consisting only of spaces and tabs,
1522           are not allowed within field values or between fields - that
1523           would mean a new paragraph.
1524         </p>
1525
1526       </sect>
1527
1528       <sect><heading>List of fields</heading>
1529         <p>
1530           This list here is not supposed to be exhaustive. Most fields
1531           are dealt with elsewhere in this document.
1532         </p>
1533         <sect1 id="f-Package"><heading><tt>Package</tt>
1534           </heading>
1535
1536           <p>
1537             The name of the binary package.  Package names consist of
1538             lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1539             plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1540             periods (<tt>.</tt>).
1541           </p>
1542
1543           <p>
1544             They must be at least two characters long and must start
1545             with an alphanumeric character.  The use of lowercase
1546             package names is required unless the package you're
1547             building (or referring to, in other fields) is already
1548             using uppercase characters.</p>
1549         </sect1>
1550
1551         <sect1 id="f-Version"><heading><tt>Version</tt>
1552           </heading>
1553
1554           <p>
1555             This lists the source or binary package's version number -
1556             see <ref id="versions">.
1557           </p>
1558
1559         </sect1>
1560
1561         <sect1
1562                id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1563           </heading>
1564
1565           <p>
1566             The most recent version of the standards (the policy
1567             manual and associated texts) with which the package
1568             complies.  This is updated manually when editing the
1569             source package to conform to newer standards; it can
1570             sometimes be used to tell when a package needs attention.
1571             Its format is described above; see
1572             <ref id="standardsversion">.
1573           </p>
1574         </sect1>
1575
1576
1577         <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1578           </heading>
1579
1580           <p>
1581             In a <file>.changes</file> file or parsed changelog output
1582             this contains the (space-separated) name(s) of the
1583             distribution(s) where this version of the package should
1584             be installed.  Valid distributions are determined by the
1585             archive maintainers.<footnote>
1586                 Current distribution names are:
1587                 <taglist compact="compact">
1588                   <tag><em>stable</em></tag>
1589                   <item>
1590                     <p>
1591                       This is the current "released" version of Debian
1592                       GNU/Linux.  Once the distribution is
1593                       <em>stable</em> only security fixes and other
1594                       major bug fixes are allowed. When changes are
1595                       made to this distribution, the release number is
1596                       increased (for example: 2.2r1 becomes 2.2r2 then
1597                       2.2r3, etc).
1598                     </p>
1599                   </item>
1600
1601                   <tag><em>unstable</em></tag>
1602                   <item>
1603                     <p>
1604                       This distribution value refers to the
1605                       <em>developmental</em> part of the Debian
1606                       distribution tree. New packages, new upstream
1607                       versions of packages and bug fixes go into the
1608                       <em>unstable</em> directory tree. Download from
1609                       this distribution at your own risk.
1610                     </p>
1611                   </item>
1612
1613                   <tag><em>testing</em></tag>
1614                   <item>
1615                     <p>
1616                       This distribution value refers to the
1617                       <em>testing</em> part of the Debian distribution
1618                       tree.  It receives its packages from the
1619                       unstable distribution after a short time lag to
1620                       ensure that there are no major issues with the
1621                       unstable packages.  It is less prone to breakage
1622                       than unstable, but still risky.  It is not
1623                       possible to upload packages directly to
1624                       <em>testing</em>.
1625                     </p>
1626                   </item>
1627
1628                   <tag><em>frozen</em></tag>
1629                   <item>
1630                     <p>
1631                       From time to time, the <em>testing</em>
1632                       distribution enters a state of "code-freeze" in
1633                       anticipation of release as a <em>stable</em>
1634                       version. During this period of testing only
1635                       fixes for existing or newly-discovered bugs will
1636                       be allowed.  The exact details of this stage are
1637                       determined by the Release Manager.
1638                     </p>
1639                   </item>
1640
1641                   <tag><em>experimental</em></tag>
1642                   <item>
1643                     <p>
1644                       The packages with this distribution value are
1645                       deemed by their maintainers to be high
1646                       risk. Oftentimes they represent early beta or
1647                       developmental packages from various sources that
1648                       the maintainers want people to try, but are not
1649                       ready to be a part of the other parts of the
1650                       Debian distribution tree. Download at your own
1651                       risk.
1652                     </p>
1653                   </item>
1654                 </taglist>
1655
1656                 You should list <em>all</em> distributions that the
1657                 package should be installed into.
1658             </footnote>
1659           </p>
1660         </sect1>
1661
1662
1663       </sect>
1664     </chapt>
1665
1666     <chapt id="versions"><heading>Version numbering</heading>
1667
1668       <p>
1669         Every package has a version number recorded in its
1670         <tt>Version</tt> control file field.
1671       </p>
1672
1673       <p>
1674         The package management system imposes an ordering on version
1675         numbers, so that it can tell whether packages are being up- or
1676         downgraded and so that package system front end applications
1677         can tell whether a package it finds available is newer than
1678         the one installed on the system.  The version number format
1679         has the most significant parts (as far as comparison is
1680         concerned) at the beginning.
1681       </p>
1682
1683       <p>
1684         The version number format is:
1685         &lsqb;<var>epoch</var><tt>:</tt>&rsqb;<var>upstream_version</var>&lsqb;<tt>-</tt><var>debian_revision</var>&rsqb;
1686       </p>
1687
1688       <p>
1689         The three components here are:
1690         <taglist>
1691           <tag><var>epoch</var></tag>
1692           <item>
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           </item>
1706
1707           <tag><var>upstream_version</var></tag>
1708           <item>
1709             <p>
1710               This is the main part of the version number.  It is
1711               usually the version number of the original ("upstream")
1712               package from which the <file>.deb</file> file has been made,
1713               if this is applicable.  Usually this will be in the same
1714               format as that specified by the upstream author(s);
1715               however, it may need to be reformatted to fit into the
1716               package management system's format and comparison
1717               scheme.
1718             </p>
1719
1720             <p>
1721               The comparison behavior of the package management system
1722               with respect to the <var>upstream_version</var> is
1723               described below.  The <var>upstream_version</var>
1724               portion of the version number is mandatory.
1725             </p>
1726
1727             <p>
1728               The <var>upstream_version</var> may contain only
1729               alphanumerics<footnote>
1730                 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1731               </footnote>
1732               and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1733               <tt>:</tt> (full stop, plus, hyphen, colon) and should
1734               start with a digit.  If there is no
1735               <var>debian_revision</var> then hyphens are not allowed;
1736               if there is no <var>epoch</var> then colons are not
1737               allowed.</p>
1738           </item>
1739
1740           <tag><var>debian_revision</var></tag>
1741           <item>
1742             <p>
1743               This part of the version number specifies the version of
1744               the Debian package based on the upstream version.  It
1745               may contain only alphanumerics and the characters
1746               <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1747               compared in the same way as the
1748               <var>upstream_version</var> is.
1749             </p>
1750
1751             <p>
1752               It is optional; if it isn't present then the
1753               <var>upstream_version</var> may not contain a hyphen.
1754               This format represents the case where a piece of
1755               software was written specifically to be turned into a
1756               Debian package, and so there is only one "debianization"
1757               of it and therefore no revision indication is required.
1758             </p>
1759
1760             <p>
1761               It is conventional to restart the
1762               <var>debian_revision</var> at <tt>1</tt> each time the
1763               <var>upstream_version</var> is increased.
1764             </p>
1765
1766             <p>
1767               The package management system will break the version
1768               number apart at the last hyphen in the string (if there
1769               is one) to determine the <var>upstream_version</var> and
1770               <var>debian_revision</var>.  The absence of a
1771               <var>debian_revision</var> compares earlier than the
1772               presence of one (but note that the
1773               <var>debian_revision</var> is the least significant part
1774               of the version number).
1775             </p>
1776           </item>
1777         </taglist>
1778       </p>
1779
1780       <p>
1781         The <var>upstream_version</var> and <var>debian_revision</var>
1782         parts are compared by the package management system using the
1783         same algorithm:
1784       </p>
1785
1786       <p>
1787         The strings are compared from left to right.
1788       </p>
1789
1790       <p>
1791         First the initial part of each string consisting entirely of
1792         non-digit characters is determined.  These two parts (one of
1793         which may be empty) are compared lexically.  If a difference
1794         is found it is returned.  The lexical comparison is a
1795         comparison of ASCII values modified so that all the letters
1796         sort earlier than all the non-letters.
1797       </p>
1798
1799       <p>
1800         Then the initial part of the remainder of each string which
1801         consists entirely of digit characters is determined.  The
1802         numerical values of these two parts are compared, and any
1803         difference found is returned as the result of the comparison.
1804         For these purposes an empty string (which can only occur at
1805         the end of one or both version strings being compared) counts
1806         as zero.
1807       </p>
1808
1809       <p>
1810         These two steps (comparing and removing initial non-digit
1811         strings and initial digit strings) are repeated until a
1812         difference is found or both strings are exhausted.
1813       </p>
1814
1815       <p>
1816         Note that the purpose of epochs is to allow us to leave behind
1817         mistakes in version numbering, and to cope with situations
1818         where the version numbering scheme changes.  It is
1819         <em>not</em> intended to cope with version numbers containing
1820         strings of letters which the package management system cannot
1821         interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1822         silly orderings (the author of this manual has heard of a
1823         package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1824         <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1825         <tt>2</tt> and so forth).
1826       </p>
1827
1828       <p>
1829         If an upstream package has problematic version numbers they
1830         should be converted to a sane form for use in the
1831         <tt>Version</tt> field.
1832       </p>
1833
1834       <sect>
1835         <heading>Version numbers based on dates</heading>
1836         <p>
1837           In general, Debian packages should use the same version
1838           numbers as the upstream sources.</p>
1839
1840         <p>
1841           However, in some cases where the upstream version number is
1842           based on a date (e.g., a development "snapshot" release) the
1843           package management system cannot handle these version
1844           numbers without epochs. For example, dpkg will consider
1845           "96May01" to be greater than "96Dec24".</p>
1846
1847         <p>
1848           To prevent having to use epochs for every new upstream
1849           version, the version number should be changed to the
1850           following format in such cases: "19960501", "19961224". It
1851           is up to the maintainer whether he/she wants to bother the
1852           upstream maintainer to change the version numbers upstream,
1853           too.</p>
1854
1855         <p>
1856           Note that other version formats based on dates which are
1857           parsed correctly by the package management system should
1858           <em>not</em> be changed.</p>
1859
1860         <p>
1861           Native Debian packages (i.e., packages which have been
1862           written especially for Debian) whose version numbers include
1863           dates should always use the "YYYYMMDD" format.</p>
1864       </sect>
1865     </chapt>
1866
1867     <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1868
1869       <sect id="timestamps"><heading>Time Stamps</heading>
1870         <p>
1871           Maintainers should preserve the modification times of the
1872           upstream source files in a package, as far as is reasonably
1873           possible.<footnote>
1874             <p>
1875               The rationale is that there is some information conveyed
1876               by knowing the age of the file, for example, you could
1877               recognize that some documentation is very old by looking
1878               at the modification time, so it would be nice if the
1879               modification time of the upstream source would be
1880               preserved.
1881             </p>
1882           </footnote>
1883         </p>
1884       </sect>
1885
1886       <sect id="debianrules"><heading><file>debian/rules</file> - the
1887           main building script</heading>
1888
1889         <p>
1890           This file must be an executable makefile, and contains the
1891           package-specific recipes for compiling the package and
1892           building binary package(s) from the source.
1893         </p>
1894
1895         <p>
1896           It must start with the line <tt>#!/usr/bin/make -f</tt>,
1897           so that it can be invoked by saying its name rather than
1898           invoking <prgn>make</prgn> explicitly.
1899         </p>
1900
1901         <p>
1902           Since an interactive <file>debian/rules</file> script makes it
1903           impossible to auto-compile that package and also makes it
1904           hard for other people to reproduce the same binary
1905           package, all <em>required targets</em> MUST be
1906           non-interactive. At a minimum, required targets are the
1907           ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1908           <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1909           <em>binary-indep</em>, and <em>build</em>. It also follows
1910           that any target that these targets depend on must also be
1911           non-interactive.
1912         </p>
1913
1914         <p>
1915           The required and optional targets are as follows:
1916           <taglist>
1917             <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1918               <tt>build-indep</tt> (optional)</tag>
1919             <item>
1920               <p>
1921                 The <tt>build</tt> target should perform all
1922                 non-interactive configuration and compilation of the
1923                 package.  If a package has an interactive pre-build
1924                 configuration routine, the Debianized source package
1925                 must either be built after this has taken place (so
1926                 that the binary package can be built without rerunning
1927                 the configuration) or the configuration routine
1928                 modified to become non-interactive.  (The latter is
1929                 preferable if there are architecture-specific features
1930                 detected by the configuration routine.)
1931               </p>
1932
1933               <p>
1934                 For some packages, notably ones where the same
1935                 source tree is compiled in different ways to produce
1936                 two binary packages, the <tt>build</tt> target
1937                 does not make much sense.  For these packages it is
1938                 good enough to provide two (or more) targets
1939                 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1940                 for each of the ways of building the package, and a
1941                 <tt>build</tt> target that does nothing.  The
1942                 <tt>binary</tt> target will have to build the
1943                 package in each of the possible ways and make the
1944                 binary package out of each.
1945               </p>
1946
1947               <p>
1948                 The <tt>build</tt> target must not do anything
1949                 that might require root privilege.
1950               </p>
1951
1952               <p>
1953                 The <tt>build</tt> target may need to run the
1954                 <tt>clean</tt> target first - see below.
1955               </p>
1956
1957               <p>
1958                 When a package has a configuration and build routine
1959                 which takes a long time, or when the makefiles are
1960                 poorly designed, or when <tt>build</tt> needs to
1961                 run <tt>clean</tt> first, it is a good idea to
1962                 <tt>touch build</tt> when the build process is
1963                 complete.  This will ensure that if <tt>debian/rules
1964                 build</tt> is run again it will not rebuild the whole
1965                 program.<footnote>
1966                   <p>
1967                     Another common way to do this is for <tt>build</tt>
1968                     to depend on <prgn>build-stamp</prgn> and to do
1969                     nothing else, and for the <prgn>build-stamp</prgn>
1970                     target to do the building and to <tt>touch
1971                     build-stamp</tt> on completion.  This is
1972                     especially useful if the build routine creates a
1973                     file or directory called <tt>build</tt>; in such a
1974                     case, <tt>build</tt> will need to be listed as
1975                     a phony target (i.e., as a dependency of the
1976                     <tt>.PHONY</tt> target).  See the documentation of
1977                     <prgn>make</prgn> for more information on phony
1978                     targets.
1979                   </p>
1980                 </footnote>
1981               </p>
1982             </item>
1983
1984             <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1985               <tt>binary-indep</tt>
1986             </tag>
1987             <item>
1988               <p>
1989                 The <tt>binary</tt> target must be all that is
1990                 necessary for the user to build the binary package(s)
1991                 produced from this source package.  All of these
1992                 targets are required to be non-interactive.  It is
1993                 split into two parts: <prgn>binary-arch</prgn> builds
1994                 the binary packages which are specific to a particular
1995                 architecture, and <tt>binary-indep</tt> builds
1996                 those which are not.
1997               </p>
1998               <p>
1999                 <tt>binary</tt> may be (and commonly is) a target with
2000                 no commands which simply depends on
2001                 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
2002               </p>
2003               <p>
2004                 Both <tt>binary-*</tt> targets should depend on the
2005                 <tt>build</tt> target, or on the appropriate
2006                 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
2007                 provided, so that the package is built if it has not
2008                 been already.  It should then create the relevant
2009                 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
2010                 make their control files and <prgn>dpkg-deb</prgn> to
2011                 build them and place them in the parent of the top
2012                 level directory.
2013               </p>
2014
2015               <p>
2016                 Both the <tt>binary-arch</tt> and
2017                 <tt>binary-indep</tt> targets <em>must</em> exist.
2018                 If one of them has nothing to do (which will always be
2019                 the case if the source generates only a single binary
2020                 package, whether architecture-dependent or not), it
2021                 must still exist and must always succeed.
2022               </p>
2023
2024               <p>
2025                 The <tt>binary</tt> targets must be invoked as
2026                 root.<footnote>
2027                   <p>
2028                     The <prgn>fakeroot</prgn> package often allows one
2029                     to build a package correctly even without being
2030                     root.
2031                   </p>
2032                 </footnote>
2033               </p>
2034             </item>
2035
2036             <tag><tt>clean</tt></tag>
2037             <item>
2038               <p>
2039                 This must undo any effects that the <tt>build</tt>
2040                 and <tt>binary</tt> targets may have had, except
2041                 that it should leave alone any output files created in
2042                 the parent directory by a run of a <tt>binary</tt>
2043                 target. This target must be non-interactive.
2044               </p>
2045
2046               <p>
2047                 If a <tt>build</tt> file is touched at the end of
2048                 the <tt>build</tt> target, as suggested above, it
2049                 should be removed as the first action that
2050                 <tt>clean</tt> performs, so that running
2051                 <tt>build</tt> again after an interrupted
2052                 <tt>clean</tt> doesn't think that everything is
2053                 already done.
2054               </p>
2055
2056               <p>
2057                 The <tt>clean</tt> target may need to be
2058                 invoked as root if <tt>binary</tt> has been
2059                 invoked since the last <tt>clean</tt>, or if
2060                 <tt>build</tt> has been invoked as root (since
2061                 <tt>build</tt> may create directories, for
2062                 example).
2063               </p>
2064             </item>
2065
2066             <tag><tt>get-orig-source</tt> (optional)</tag>
2067             <item>
2068               <p>
2069                 This target fetches the most recent version of the
2070                 original source package from a canonical archive site
2071                 (via FTP or WWW, for example), does any necessary
2072                 rearrangement to turn it into the original source
2073                 tar file format described below, and leaves it in the
2074                 current directory.
2075               </p>
2076
2077               <p>
2078                 This target may be invoked in any directory, and
2079                 should take care to clean up any temporary files it
2080                 may have left.
2081               </p>
2082
2083               <p>
2084                 This target is optional, but providing it if
2085                 possible is a good idea.
2086               </p>
2087             </item>
2088           </taglist>
2089
2090         <p>
2091           The <tt>build</tt>, <tt>binary</tt> and
2092           <tt>clean</tt> targets must be invoked with the current
2093           directory being the package's top-level directory.
2094         </p>
2095
2096
2097         <p>
2098           Additional targets may exist in <file>debian/rules</file>,
2099           either as published or undocumented interfaces or for the
2100           package's internal use.
2101         </p>
2102
2103         <p>
2104           The architectures we build on and build for are determined
2105           by <prgn>make</prgn> variables using the utility
2106           <prgn>dpkg-architecture</prgn>.  You can determine the
2107           Debian architecture and the GNU style architecture
2108           specification string for the build machine (the machine type
2109           we are building on) as well as for the host machine (the
2110           machine type we are building for).  Here is a list of
2111           supported <prgn>make</prgn> variables:
2112           <list compact="compact">
2113             <item>
2114               <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2115             </item>
2116             <item>
2117               <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2118                 specification string)</p>
2119             </item>
2120             <item>
2121               <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2122               <tt>DEB_*_GNU_TYPE</tt>)</p>
2123             </item>
2124             <item>
2125               <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2126                 <tt>DEB_*_GNU_TYPE</tt>)</p>
2127           </list>
2128           where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2129           the build machine or <tt>HOST</tt> for specification of the
2130           host machine.
2131         </p>
2132
2133         <p>
2134           Backward compatibility can be provided in the rules file
2135           by setting the needed variables to suitable default
2136           values; please refer to the documentation of
2137           <prgn>dpkg-architecture</prgn> for details.
2138         </p>
2139
2140         <p>
2141           It is important to understand that the <tt>DEB_*_ARCH</tt>
2142           string only determines which Debian architecture we are
2143           building on or for. It should not be used to get the CPU
2144           or system information; the GNU style variables should be
2145           used for that.
2146         </p>
2147       </sect>
2148
2149       <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2150         </heading>
2151
2152         <p>
2153           This file records the changes to the Debian-specific parts of the
2154           package<footnote>
2155             <p>
2156               Though there is nothing stopping an author who is also
2157               the Debian maintainer from using it for all their
2158               changes, it will have to be renamed if the Debian and
2159               upstream maintainers become different people.  In such a
2160               case, however, it might be better to maintain the
2161               package as a non-native package.
2162             </p>
2163           </footnote>.
2164         </p>
2165
2166         <p>
2167           It has a special format which allows the package building
2168           tools to discover which version of the package is being
2169           built and find out other release-specific information.
2170         </p>
2171
2172         <p>
2173           That format is a series of entries like this:
2174           <example compact="compact">
2175 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2176             <comment>
2177               <p>[optional blank line(s), stripped]</p>
2178             </comment>
2179   * <var>change details</var>
2180     <var>more change details</var>
2181             <comment>
2182               <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2183             </comment>
2184   * <var>even more change details</var>
2185             <comment>
2186               <p>[optional blank line(s), stripped]</p>
2187             </comment>
2188             -- <var>maintainer name</var> &lt;<var>email
2189               address</var>&gt;<var>[two spaces]</var>  <var>date</var>
2190           </example>
2191         </p>
2192
2193         <p>
2194           <var>package</var> and <var>version</var> are the source
2195           package name and version number.
2196         </p>
2197
2198         <p>
2199           <var>distribution(s)</var> lists the distributions where
2200           this version should be installed when it is uploaded - it
2201           is copied to the <tt>Distribution</tt> field in the
2202           <file>.changes</file> file.  See <ref id="f-Distribution">.
2203         </p>
2204
2205         <p>
2206           <var>urgency</var> is the value for the <tt>Urgency</tt>
2207           field in the <file>.changes</file> file for the upload. It is
2208           not possible to specify an urgency containing commas; commas
2209           are used to separate
2210           <tt><var>keyword</var>=<var>value</var></tt> settings in the
2211           <prgn>dpkg</prgn> changelog format (though there is
2212           currently only one useful <var>keyword</var>,
2213           <tt>urgency</tt>).<footnote>
2214             <p>
2215               Recognised urgency values are <tt>low</tt>,
2216               <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2217               They have an effect on how quickly a package will be
2218               considered for inclusion into the <tt>testing</tt>
2219               distribution, and give an indication of the importance
2220               of any fixes included in this upload.
2221             </p>
2222           </footnote>
2223         </p>
2224
2225         <p>
2226           The change details may in fact be any series of lines
2227           starting with at least two spaces, but conventionally each
2228           change starts with an asterisk and a separating space and
2229           continuation lines are indented so as to bring them in
2230           line with the start of the text above.  Blank lines may be
2231           used here to separate groups of changes, if desired.
2232         </p>
2233
2234         <p>
2235           If this upload resolves bugs recorded in the Bug Tracking
2236           System (BTS), they may be automatically closed on the
2237           inclusion of this package into the Debian archive by
2238           including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2239           in the change details.<footnote>
2240             <p>
2241               To be precise, the string should match the following
2242               Perl regular expression:
2243               <example>
2244 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2245               </example>
2246               Then all of the bug numbers listed will be closed by the
2247               archive maintenance script (<prgn>katie</prgn>), or in
2248               the case of an NMU, marked as fixed.
2249             </p>
2250           </footnote>
2251         </p>
2252
2253         <p>
2254           The maintainer name and email address used in the changelog
2255           should be the details of the person uploading <em>this</em>
2256           version.  They are <em>not</em> necessarily those of the
2257           usual package maintainer.  The information here will be
2258           copied to the <tt>Changed-By</tt> field in the
2259           <tt>.changes</tt> file, and then later used to send an
2260           acknowledgement when the upload has been installed.
2261         </p>
2262
2263         <p>
2264           The <var>date</var> should be in RFC822 format<footnote>
2265             <p>
2266               This is generated by the <prgn>822-date</prgn>
2267               program.
2268             </p>
2269           </footnote>; it should include the time zone specified
2270           numerically, with the time zone name or abbreviation
2271           optionally present as a comment in parentheses.
2272         </p>
2273
2274         <p>
2275           The first "title" line with the package name should start
2276           at the left hand margin; the "trailer" line with the
2277           maintainer and date details should be preceded by exactly
2278           one space.  The maintainer details and the date must be
2279           separated by exactly two spaces.
2280         </p>
2281
2282         <sect1><heading>Defining alternative changelog formats</heading>
2283
2284           <p>
2285             It is possible to use a different format to the standard
2286             one, by providing a parser for the format you wish to
2287             use.
2288           </p>
2289           <p>
2290             A changelog parser must not interact with the user at
2291             all.
2292           </p>
2293         </sect1>
2294       </sect>
2295
2296 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
2297
2298       <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2299           and variable substitutions      </heading>
2300
2301         <p>
2302           When <prgn>dpkg-gencontrol</prgn>,
2303           <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2304           generate control files they perform variable substitutions
2305           on their output just before writing it.  Variable
2306           substitutions have the form <tt>${<var>variable</var>}</tt>.
2307           The optional file <file>debian/substvars</file> contains
2308           variable substitutions to be used; variables can also be set
2309           directly from <file>debian/rules</file> using the <tt>-V</tt>
2310           option to the source packaging commands, and certain
2311           predefined variables are also available.
2312         </p>
2313
2314         <p>
2315           The <file>debian/substvars</file> file is usually generated and
2316           modified dynamically by <file>debian/rules</file> targets, in
2317           which case it must be removed by the <tt>clean</tt> target.
2318         </p>
2319
2320         <p>
2321           See <manref name="dpkg-source" section="1"> for full
2322           details about source variable substitutions, including the
2323           format of <file>debian/substvars</file>.</p>
2324       </sect>
2325
2326       <sect id="debianfiles"><heading><file>debian/files</file>
2327         </heading>
2328
2329         <p>
2330           This file is not a permanent part of the source tree; it
2331           is used while building packages to record which files are
2332           being generated.  <prgn>dpkg-genchanges</prgn> uses it
2333           when it generates a <file>.changes</file> file.
2334         </p>
2335
2336         <p>
2337           It should not exist in a shipped source package, and so it
2338           (and any backup files or temporary files such as
2339           <file>files.new</file><footnote>
2340             <p>
2341               <file>files.new</file> is used as a temporary file by
2342               <prgn>dpkg-gencontrol</prgn> and
2343               <prgn>dpkg-distaddfile</prgn> - they write a new
2344               version of <tt>files</tt> here before renaming it,
2345               to avoid leaving a corrupted copy if an error
2346               occurs
2347             </p>
2348           </footnote>) should be removed by the
2349           <tt>clean</tt> target.  It may also be wise to
2350           ensure a fresh start by emptying or removing it at the
2351           start of the <tt>binary</tt> target.
2352         </p>
2353
2354         <p>
2355           When <prgn>dpkg-gencontrol</prgn> is run for a binary
2356           package, it adds an entry to <file>debian/files</file> for the
2357           <file>.deb</file> file that will be created when <tt>dpkg-deb
2358           --build</tt> is run for that binary package.  So for most
2359           packages all that needs to be done with this file is to
2360           delete it in the <tt>clean</tt> target.
2361         </p>
2362
2363         <p>
2364           If a package upload includes files besides the source
2365           package and any binary packages whose control files were
2366           made with <prgn>dpkg-gencontrol</prgn> then they should be
2367           placed in the parent of the package's top-level directory
2368           and <prgn>dpkg-distaddfile</prgn> should be called to add
2369           the file to the list in <file>debian/files</file>.</p>
2370       </sect>
2371
2372       <sect id="restrictions"><heading>Restrictions on objects in source packages
2373         </heading>
2374
2375         <p>
2376           The source package may not contain any hard links<footnote>
2377             <p>
2378               This is not currently detected when building source
2379               packages, but only when extracting
2380               them.
2381             </p>
2382             <p>
2383               Hard links may be permitted at some point in the
2384               future, but would require a fair amount of
2385               work.
2386             </p>
2387           </footnote>, device special files, sockets or setuid or
2388           setgid files.<footnote>
2389             <p>
2390               Setgid directories are allowed.
2391             </p>
2392           </footnote>
2393         </p>
2394       </sect>
2395
2396       <sect id="descriptions"><heading>Descriptions of packages - the
2397           <tt>Description</tt> field</heading>
2398
2399         <p>
2400           The "Description" control file field consists of two parts,
2401           the synopsis or the short description, and the long description.
2402           The field's format is as follows:
2403         </p>
2404
2405         <p><example>
2406         Description: &lt;single line synopsis&gt;
2407          &lt;extended description over several lines&gt;
2408 </example></p>
2409
2410         <p>
2411           The description is intended to describe the program to a user
2412           who has never met it before so that they know whether they
2413           want to install it.  It should also give information about the
2414           significant dependencies and conflicts between this package
2415           and others, so that the user knows why these dependencies and
2416           conflicts have been declared.
2417         </p>
2418
2419         <p>
2420           Put important information first, both in the synopsis and
2421           extended description.  Sometimes only the first part of the
2422           synopsis or of the description will be displayed.  You can
2423           assume that there will usually be a way to see the whole
2424           extended description.
2425         </p>
2426
2427         <sect1 id="synopsis"><heading>The single line synopsis</heading>
2428
2429           <p>
2430             The single line synopsis should be kept brief - certainly
2431             under 80 characters.
2432           </p>
2433
2434           <p>
2435             Do not include the package name in the synopsis line.  The
2436             display software knows how to display this already, and you
2437             do not need to state it.  Remember that in many situations
2438             the user may only see the synopsis line - make it as
2439             informative as you can.
2440           </p>
2441
2442         </sect1>
2443
2444         <sect1 id="extendeddesc"><heading>The extended description</heading>
2445
2446           <p>
2447             Do not try to continue the single line synopsis into the
2448             extended description.  This will not work correctly when
2449             the full description is displayed, and makes no sense
2450             where only the summary (the single line synopsis) is
2451             available.
2452           </p>
2453
2454           <p>
2455             The extended description should describe what the package
2456             does and how it relates to the rest of the system (in terms
2457             of, for example, which subsystem it is which part of).
2458           </p>
2459
2460           <p>
2461             The description field needs to make sense to anyone, even
2462             people who have no idea about any of the things the
2463             package deals with.<footnote>
2464                 The blurb that comes with a program in its
2465                 announcements and/or <prgn>README</prgn> files is
2466                 rarely suitable for use in a description.  It is
2467                 usually aimed at people who are already in the
2468                 community where the package is used.
2469             </footnote>
2470           </p>
2471
2472           <p>
2473             The lines in the extended description can have these formats:
2474           </p>
2475
2476           <p><list>
2477
2478             <item>
2479               Those starting with a single space are part of a paragraph.
2480               Successive lines of this form will be word-wrapped when
2481               displayed. The leading space will usually be stripped off.
2482             </item>
2483
2484             <item>
2485               Those starting with two or more spaces. These will be
2486               displayed verbatim. If the display cannot be panned
2487               horizontally, the displaying program will linewrap them "hard"
2488               (i.e., without taking account of word breaks). If it can they
2489               will be allowed to trail off to the right. None, one or two
2490               initial spaces may be deleted, but the number of spaces
2491               deleted from each line will be the same (so that you can have
2492               indenting work correctly, for example).
2493             </item>
2494
2495             <item>
2496               Those containing a single space followed by a single full stop
2497               character. These are rendered as blank lines. This is the
2498               <em>only</em> way to get a blank line<footnote>
2499                 Completely empty lines will not be rendered as blank lines. 
2500                 Instead, they will cause the parser to think you're starting
2501                 a whole new record in the control file, and will therefore
2502                 likely abort with an error.
2503               </footnote>.
2504             </item>
2505
2506             <item>
2507               Those containing a space, a full stop and some more characters.
2508               These are for future expansion. Do not use them.
2509             </item>
2510
2511           </list></p>
2512
2513           <p>
2514             Do not use tab characters.  Their effect is not predictable.
2515           </p>
2516
2517         </sect1>
2518
2519       </sect>
2520
2521     </chapt>
2522
2523
2524     <chapt id="maintainerscripts"><heading>Package maintainer scripts
2525         and installation procedure
2526       </heading>
2527
2528       <sect><heading>Introduction to package maintainer scripts
2529         </heading>
2530
2531         <p>
2532           It is possible to supply scripts as part of a package which
2533           the package management system will run for you when your
2534           package is installed, upgraded or removed.
2535         </p>
2536
2537         <p>
2538           These scripts are the files <prgn>preinst</prgn>,
2539           <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2540           control area of the package.  They must be proper executable
2541           files; if they are scripts (which is recommended), they must
2542           start with the usual <tt>#!</tt> convention.  They should be
2543           readable and executable by anyone, and not world-writable.
2544         </p>
2545
2546         <p>
2547           The package management system looks at the exit status from
2548           these scripts.  It is important that they exit with a
2549           non-zero status if there is an error, so that the package
2550           management system can stop its processing.  For shell
2551           scripts this means that you <em>almost always</em> need to
2552           use <tt>set -e</tt> (this is usually true when writing shell
2553           scripts, in fact).  It is also important, of course, that
2554           they don't exit with a non-zero status if everything went
2555           well.
2556         </p>
2557
2558         <p>
2559           When a package is upgraded a combination of the scripts from
2560           the old and new packages is called during the upgrade
2561           procedure.  If your scripts are going to be at all
2562           complicated you need to be aware of this, and may need to
2563           check the arguments to your scripts.
2564         </p>
2565
2566         <p>
2567           Broadly speaking the <prgn>preinst</prgn> is called before
2568           (a particular version of) a package is installed, and the
2569           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2570           before (a version of) a package is removed and the
2571           <prgn>postrm</prgn> afterwards.
2572         </p>
2573
2574         <p>
2575           Programs called from maintainer scripts should not normally
2576           have a path prepended to them. Before installation is
2577           started, the package management system checks to see if the
2578           programs <prgn>ldconfig</prgn>,
2579           <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2580           and <prgn>update-rc.d</prgn> can be found via the
2581           <tt>PATH</tt> environment variable. Those programs, and any
2582           other program that one would expect to be on the
2583           <tt>PATH</tt>, should thus be invoked without an absolute
2584           pathname. Maintainer scripts should also not reset the
2585           <tt>PATH</tt>, though they might choose to modify it by
2586           prepending or appending package-specific directories. These
2587           considerations really apply to all shell scripts.</p>
2588       </sect>
2589
2590       <sect>
2591         <heading>Maintainer scripts Idempotency</heading>
2592
2593         <p>
2594           It is necessary for the error recovery procedures that the
2595           scripts be idempotent.  This means that if it is run
2596           successfully, and then it is called again, it doesn't bomb
2597           out or cause any harm, but just ensures that everything is
2598           the way it ought to be.  If the first call failed, or
2599           aborted half way through for some reason, the second call
2600           should merely do the things that were left undone the first
2601           time, if any, and exit with a success status if everything
2602           is OK.<footnote>
2603             <p>
2604               This is so that if an error occurs, the user interrupts
2605               <prgn>dpkg</prgn> or some other unforeseen circumstance
2606               happens you don't leave the user with a badly-broken
2607               package when <prgn>dpkg</prgn> attempts to repeat the
2608               action.
2609             </p>
2610           </footnote>
2611         </p>
2612       </sect>
2613
2614       <sect>
2615         <heading>Controlling terminal for maintainer scripts</heading>
2616
2617         <p>
2618           The maintainer scripts are guaranteed to run with a
2619           controlling terminal and can interact with the user.
2620           If they need to prompt for passwords, do full-screen
2621           interaction or something similar you should do these
2622           things to and from <file>/dev/tty</file>, since
2623           <prgn>dpkg</prgn> will at some point redirect scripts'
2624           standard input and output so that it can log the
2625           installation process.  Likewise, because these scripts
2626           may be executed with standard output redirected into a
2627           pipe for logging purposes, Perl scripts should set
2628           unbuffered output by setting <tt>$|=1</tt> so that the
2629           output is printed immediately rather than being
2630           buffered.
2631         </p>
2632
2633         <p>
2634           Each script should return a zero exit status for
2635           success, or a nonzero one for failure.
2636         </p>
2637       </sect>
2638
2639       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2640           scripts are called
2641         </heading>
2642
2643         <p>
2644           <list compact="compact">
2645             <item>
2646               <p><var>new-preinst</var> <tt>install</tt></p>
2647             </item>
2648             <item>
2649               <p><var>new-preinst</var> <tt>install</tt>
2650                 <var>old-version</var></p>
2651             </item>
2652             <item>
2653               <p><var>new-preinst</var> <tt>upgrade</tt>
2654                 <var>old-version</var></p>
2655             </item>
2656             <item>
2657               <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2658                 <var>new-version</var>
2659               </p>
2660             </item>
2661           </list>
2662
2663         <p>
2664           <list compact="compact">
2665             <item>
2666               <p><var>postinst</var> <tt>configure</tt>
2667                 <var>most-recently-configured-version</var></p>
2668             </item>
2669             <item>
2670               <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2671                 <var>new-version</var></p>
2672             </item>
2673             <item>
2674               <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2675                 <tt>in-favour</tt> <var>package</var>
2676                 <var>new-version</var></p>
2677             </item>
2678             <item>
2679               <p>
2680                 <var>deconfigured's-postinst</var>
2681                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2682                 <var>failed-install-package</var> <var>version</var>
2683                 <tt>removing</tt> <var>conflicting-package</var>
2684                 <var>version</var>
2685               </p>
2686             </item>
2687           </list>
2688
2689         <p>
2690           <list compact="compact">
2691             <item>
2692               <p><var>prerm</var> <tt>remove</tt></p>
2693             </item>
2694             <item>
2695               <p><var>old-prerm</var> <tt>upgrade</tt>
2696                 <var>new-version</var></p>
2697             </item>
2698             <item>
2699               <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2700                 <var>old-version</var></p>
2701             </item>
2702             <item>
2703               <p><var>conflictor's-prerm</var> <tt>remove</tt>
2704                 <tt>in-favour</tt> <var>package</var>
2705                 <var>new-version</var></p>
2706             </item>
2707             <item>
2708               <p>
2709                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2710                 <tt>in-favour</tt> <var>package-being-installed</var>
2711                 <var>version</var> <tt>removing</tt>
2712                 <var>conflicting-package</var>
2713                 <var>version</var>
2714               </p>
2715             </item>
2716           </list>
2717
2718         <p>
2719           <list compact="compact">
2720             <item>
2721               <p><var>postrm</var> <tt>remove</tt></p>
2722             </item>
2723             <item>
2724               <p><var>postrm</var> <tt>purge</tt></p>
2725             </item>
2726             <item>
2727               <p>
2728                 <var>old-postrm</var> <tt>upgrade</tt>
2729                 <var>new-version</var></p>
2730             </item>
2731             <item>
2732               <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2733                 <var>old-version</var></p>
2734             </item>
2735             <item>
2736               <p><var>new-postrm</var> <tt>abort-install</tt></p>
2737             </item>
2738             <item>
2739               <p><var>new-postrm</var> <tt>abort-install</tt>
2740                 <var>old-version</var></p>
2741             </item>
2742             <item>
2743               <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2744                 <var>old-version</var></p>
2745             </item>
2746             <item>
2747               <p>
2748                 <var>disappearer's-postrm</var> <tt>disappear</tt>
2749                 <var>overwriter</var>
2750                 <var>overwriter-version</var></p></item>
2751           </list>
2752         </p>
2753
2754
2755       <sect id="unpackphase"><heading>Details of unpack phase of
2756           installation or upgrade
2757         </heading>
2758
2759         <p>
2760           The procedure on installation/upgrade/overwrite/disappear
2761           (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2762           stage of <tt>dpkg --install</tt>) is as follows.  In each
2763           case, if a major error occurs (unless listed below) the
2764           actions are, in general, run backwards - this means that the
2765           maintainer scripts are run with different arguments in
2766           reverse order.  These are the "error unwind" calls listed
2767           below.
2768
2769           <enumlist>
2770             <item>
2771               <p>
2772                 <enumlist>
2773                   <item>
2774                     <p>If a version of the package is already
2775                       installed, call
2776                       <example compact="compact">
2777 <var>old-prerm</var> upgrade <var>new-version</var>
2778                       </example></p>
2779                   </item>
2780                   <item>
2781                     <p>
2782                       If the script runs but exits with a non-zero
2783                       exit status, <prgn>dpkg</prgn> will attempt:
2784                       <example compact="compact">
2785 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2786                       </example>
2787                       Error unwind, for both the above cases:
2788                       <example compact="compact">
2789 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2790                       </example>
2791                     </p>
2792                   </item>
2793                 </enumlist>
2794               </p>
2795             </item>
2796             <item>
2797               <p>If a "conflicting" package is being removed at the same time:
2798                 <enumlist>
2799                   <item>
2800                     <p>
2801                       If any packages depended on that conflicting
2802                       package and <tt>--auto-deconfigure</tt> is
2803                       specified, call, for each such package:
2804                       <example compact="compact">
2805 <var>deconfigured's-prerm</var> deconfigure \
2806   in-favour <var>package-being-installed</var> <var>version</var> \
2807     removing <var>conflicting-package</var> <var>version</var>
2808                       </example>
2809                       Error unwind:
2810                       <example compact="compact">
2811 <var>deconfigured's-postinst</var> abort-deconfigure \
2812   in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2813     removing <var>conflicting-package</var> <var>version</var>
2814                       </example>
2815                       The deconfigured packages are marked as
2816                       requiring configuration, so that if
2817                       <tt>--install</tt> is used they will be
2818                       configured again if possible.</p>
2819                   </item>
2820                   <item>
2821                     <p>To prepare for removal of the conflicting package, call:
2822                       <example compact="compact">
2823 <var>conflictor's-prerm</var> remove \
2824   in-favour <var>package</var> <var>new-version</var>
2825                       </example>
2826                       Error unwind:
2827                       <example compact="compact">
2828 <var>conflictor's-postinst</var> abort-remove \
2829   in-favour <var>package</var> <var>new-version</var>
2830                       </example>
2831                     </p>
2832                   </item>
2833                 </enumlist>
2834               </p>
2835             </item>
2836             <item>
2837               <p>
2838                 <enumlist>
2839                   <item>
2840                     <p>If the package is being upgraded, call:
2841                       <example compact="compact">
2842 <var>new-preinst</var> upgrade <var>old-version</var>
2843                       </example></p>
2844                   </item>
2845                   <item>
2846                     <p>
2847                       Otherwise, if the package had some configuration
2848                       files from a previous version installed (i.e., it
2849                       is in the "configuration files only" state):
2850                       <example compact="compact">
2851 <var>new-preinst</var> install <var>old-version</var>
2852                       </example></p>
2853
2854                   <item>
2855                     <p>Otherwise (i.e., the package was completely purged):
2856                       <example compact="compact">
2857 <var>new-preinst</var> install
2858                       </example>
2859                       Error unwind actions, respectively:
2860                       <example compact="compact">
2861 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2862 <var>new-postrm</var> abort-install <var>old-version</var>
2863 <var>new-postrm</var> abort-install
2864                       </example>
2865                     </p>
2866                   </item>
2867                 </enumlist>
2868               </p>
2869             </item>
2870             <item>
2871               <p>
2872                 The new package's files are unpacked, overwriting any
2873                 that may be on the system already, for example any
2874                 from the old version of the same package or from
2875                 another package.  Backups of the old files are kept
2876                 temporarily, and if anything goes wrong the package
2877                 management system will attempt to put them back as
2878                 part of the error unwind.
2879               </p>
2880
2881               <p>
2882                 It is an error for a package to contains files which
2883                 are on the system in another package, unless
2884                 <tt>Replaces</tt> is used (see <ref id="replaces">).
2885                 <!--
2886                 The following paragraph is not currently the case:
2887                 Currently the <tt>- - force-overwrite</tt> flag is
2888                 enabled, downgrading it to a warning, but this may not
2889                 always be the case.
2890                 -->
2891               </p>
2892
2893               <p>
2894                 It is a more serious error for a package to contain a
2895                 plain file or other kind of non-directory where another
2896                 package has a directory (again, unless
2897                 <tt>Replaces</tt> is used).  This error can be
2898                 overridden if desired using
2899                 <tt>--force-overwrite-dir</tt>, but this is not
2900                 advisable.
2901               </p>
2902
2903               <p>
2904                 Packages which overwrite each other's files produce
2905                 behavior which, though deterministic, is hard for the
2906                 system administrator to understand.  It can easily
2907                 lead to "missing" programs if, for example, a package
2908                 is installed which overwrites a file from another
2909                 package, and is then removed again.<footnote>
2910                   <p>
2911                     Part of the problem is due to what is arguably a
2912                     bug in <prgn>dpkg</prgn>.
2913                   </p>
2914                 </footnote>
2915               </p>
2916
2917               <p>
2918                 A directory will never be replaced by a symbolic link
2919                 to a directory or vice versa; instead, the existing
2920                 state (symlink or not) will be left alone and
2921                 <prgn>dpkg</prgn> will follow the symlink if there is
2922                 one.</p>
2923             </item>
2924
2925             <item>
2926               <p>
2927                 <enumlist>
2928                   <item>
2929                     <p>If the package is being upgraded, call
2930                       <example compact="compact">
2931 <var>old-postrm</var> upgrade <var>new-version</var>
2932                       </example>
2933                     </p>
2934                   </item>
2935                   <item>
2936                     <p>If this fails, <prgn>dpkg</prgn> will attempt:
2937                       <example compact="compact">
2938 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2939                       </example>
2940                       Error unwind, for both cases:
2941                       <example compact="compact">
2942 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2943                       </example>
2944                     </p>
2945                   </item>
2946                 </enumlist>
2947               </p>
2948               <p>
2949                 This is the point of no return - if
2950                 <prgn>dpkg</prgn> gets this far, it won't back off
2951                 past this point if an error occurs.  This will
2952                 leave the package in a fairly bad state, which
2953                 will require a successful re-installation to clear
2954                 up, but it's when <prgn>dpkg</prgn> starts doing
2955                 things that are irreversible.
2956               </p>
2957             </item>
2958             <item>
2959               <p>
2960                 Any files which were in the old version of the package
2961                 but not in the new are removed.</p>
2962             </item>
2963             <item>
2964               <p>The new file list replaces the old.</p>
2965             </item>
2966             <item>
2967               <p>The new maintainer scripts replace the old.</p>
2968             </item>
2969
2970             <item>
2971               <p>Any packages all of whose files have been overwritten during the
2972                 installation, and which aren't required for
2973                 dependencies, are considered to have been removed.
2974                 For each such package
2975                 <enumlist>
2976                   <item>
2977                     <p><prgn>dpkg</prgn> calls:
2978                       <example compact="compact">
2979 <var>disappearer's-postrm</var> disappear \
2980   <var>overwriter</var> <var>overwriter-version</var>
2981                       </example>
2982                     </p>
2983                   </item>
2984                   <item>
2985                     <p>The package's maintainer scripts are removed.
2986                     </p>
2987                   </item>
2988                   <item>
2989                     <p>
2990                       It is noted in the status database as being in a
2991                       sane state, namely not installed (any conffiles
2992                       it may have are ignored, rather than being
2993                       removed by <prgn>dpkg</prgn>).  Note that
2994                       disappearing packages do not have their prerm
2995                       called, because <prgn>dpkg</prgn> doesn't know
2996                       in advance that the package is going to
2997                       vanish.
2998                     </p>
2999                   </item>
3000                 </enumlist>
3001               </p>
3002             </item>
3003             <item>
3004               <p>
3005                 Any files in the package we're unpacking that are also
3006                 listed in the file lists of other packages are removed
3007                 from those lists.  (This will lobotomize the file list
3008                 of the "conflicting" package if there is one.)
3009               </p>
3010             </item>
3011             <item>
3012               <p>
3013                 The backup files made during installation, above, are
3014                 deleted.
3015               </p>
3016             </item>
3017
3018             <item>
3019               <p>
3020                 The new package's status is now sane, and recorded as
3021                 "unpacked".
3022               </p>
3023
3024               <p>
3025                 Here is another point of no return - if the
3026                 conflicting package's removal fails we do not unwind
3027                 the rest of the installation; the conflicting package
3028                 is left in a half-removed limbo.
3029               </p>
3030             </item>
3031
3032             <item>
3033               <p>
3034                 If there was a conflicting package we go and do the
3035                 removal actions (described below), starting with the
3036                 removal of the conflicting package's files (any that
3037                 are also in the package being installed have already
3038                 been removed from the conflicting package's file list,
3039                 and so do not get removed now).
3040               </p>
3041             </item>
3042           </enumlist>
3043         </p>
3044       </sect>
3045
3046       <sect id="configdetails"><heading>Details of configuration</heading>
3047
3048         <p>
3049           When we configure a package (this happens with <tt>dpkg
3050             --install</tt> and <tt>dpkg --configure</tt>), we first
3051           update any <tt>conffile</tt>s and then call:
3052           <example compact="compact">
3053 <var>postinst</var> configure <var>most-recently-configured-version</var>
3054           </example>
3055         </p>
3056
3057         <p>
3058           No attempt is made to unwind after errors during
3059           configuration.
3060         </p>
3061
3062         <p>
3063           If there is no most recently configured version
3064           <prgn>dpkg</prgn> will pass a null argument; older versions
3065           of dpkg may pass <tt>&lt;unknown&gt;</tt> (including the
3066           angle brackets) in this case.  Even older ones do not pass a
3067           second argument at all, under any circumstances.
3068         </p>
3069       </sect>
3070
3071       <sect id="removedetails"><heading>Details of removal and/or
3072       configuration purging</heading>
3073
3074         <p>
3075           <enumlist>
3076             <item>
3077               <p>
3078                 <example compact="compact">
3079 <var>prerm</var> remove
3080                 </example>
3081               </p>
3082             </item>
3083             <item>
3084               <p>
3085                 The package's files are removed (except <tt>conffile</tt>s).
3086               </p>
3087             </item>
3088             <item>
3089               <p>
3090                 <example compact="compact">
3091 <var>postrm</var> remove
3092                 </example>
3093               </p>
3094             </item>
3095             <item>
3096               <p>
3097                 All the maintainer scripts except the <prgn>postrm</prgn>
3098                 are removed.
3099               </p>
3100
3101               <p>
3102                 If we aren't purging the package we stop here.  Note
3103                 that packages which have no <prgn>postrm</prgn> and no
3104                 <tt>conffile</tt>s are automatically purged when
3105                 removed, as there is no difference except for the
3106                 <prgn>dpkg</prgn> status.</p>
3107             </item>
3108             <item>
3109               <p>
3110                 The <tt>conffile</tt>s and any backup files
3111                 (<tt>~</tt>-files, <tt>#*#</tt> files,
3112                 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3113                 are removed.</p>
3114             </item>
3115             <item>
3116               <p>
3117                 <example compact="compact">
3118 <var>postrm</var> purge
3119                 </example>
3120               </p>
3121             </item>
3122             <item>
3123               <p>The package's file list is removed.</p>
3124             </item>
3125           </enumlist>
3126           No attempt is made to unwind after errors during
3127           removal.
3128         </p>
3129       </sect>
3130     </chapt>
3131
3132
3133     <chapt id="relationships"><heading>Declaring relationships between
3134         packages</heading>
3135
3136       <sect id="depsyntax"><heading>Syntax of relationship fields
3137         </heading>
3138
3139         <p>
3140           These fields all have a uniform syntax.  They are a list of
3141           package names separated by commas.
3142         </p>
3143
3144         <p>
3145           In the <tt>Depends</tt>, <tt>Recommends</tt>,
3146           <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3147           <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3148           control file fields of the package, which declare
3149           dependencies on other packages, the package names listed may
3150           also include lists of alternative package names, separated
3151           by vertical bar (pipe) symbols <tt>|</tt>.  In such a case,
3152           if any one of the alternative packages is installed, that
3153           part of the dependency is considered to be satisfied.
3154         </p>
3155
3156         <p>
3157           All of the fields except for <tt>Provides</tt> may restrict
3158           their applicability to particular versions of each named
3159           package.  This is done in parentheses after each individual
3160           package name; the parentheses should contain a relation from
3161           the list below followed by a version number, in the format
3162           described in <ref id="versions">.
3163         </p>
3164
3165         <p>
3166           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
3167           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
3168           strictly earlier, earlier or equal, exactly equal, later or
3169           equal and strictly later, respectively.  The deprecated
3170           forms <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
3171           earlier/later or equal, rather than strictly earlier/later,
3172           so they should not appear in new packages (though
3173           <prgn>dpkg</prgn> still supports them).
3174         </p>
3175
3176         <p>
3177           Whitespace may appear at any point in the version
3178           specification subject to the rules in <ref
3179           id="controlsyntax">, and must appear where it's necessary to
3180           disambiguate; it is not otherwise significant.  For
3181           consistency and in case of future changes to
3182           <prgn>dpkg</prgn> it is recommended that a single space be
3183           used after a version relationship and before a version
3184           number; it is also conventional to put a single space after
3185           each comma, on either side of each vertical bar, and before
3186           each open parenthesis.
3187         </p>
3188
3189         <p>
3190           For example, a list of dependencies might appear as:
3191           <example compact="compact">
3192 Package: mutt
3193 Version: 1.3.17-1
3194 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3195           </example>
3196         </p>
3197
3198         <p>
3199           All fields that specify build-time relationships
3200           (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3201           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3202           may be restricted to a certain set of architectures.  This
3203           is indicated in brackets after each individual package name and
3204           the optional version specification.  The brackets enclose a
3205           list of Debian architecture names separated by whitespace.
3206           Exclamation marks may be prepended to each of the names.
3207           (It is not permitted for some names to be prepended with
3208           exclamation marks and others not.) If the current Debian
3209           host architecture is not in this list and there are no
3210           exclamation marks in the list, or it is in the list with a
3211           prepended exclamation mark, the package name and the
3212           associated version specification are ignored completely for
3213           the purposes of defining the relationships.
3214         </p>
3215
3216         <p>
3217           For example:
3218           <example compact="compact">
3219 Source: glibc
3220 Build-Depends-Indep: texinfo
3221 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3222   hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3223           </example>
3224         </p>
3225
3226         <p>
3227           Note that the binary package relationship fields such as
3228           <tt>Depends</tt> appear in one of the binary package
3229           sections of the control file, whereas the build-time
3230           relationships such as <tt>Build-Depends</tt> appear in the
3231           source package section of the control file (which is the
3232           first section).
3233         </p>
3234       </sect>
3235
3236       <sect>
3237         <heading>Binary Dependencies - <tt>Depends</tt>,
3238           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3239           <tt>Pre-Depends</tt>
3240         </heading>
3241
3242         <p>
3243           Packages can declare in their control file that they have
3244           certain relationships to other packages - for example, that
3245           they may not be installed at the same time as certain other
3246           packages, and/or that they depend on the presence of others.
3247         </p>
3248   
3249         <p>
3250           This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3251           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt> and
3252           <tt>Conflicts</tt> control file fields.
3253         </p>
3254
3255         <p>
3256           These six fields are used to declare a dependency
3257           relationship by one package on another.  Except for
3258           <tt>Enhances</tt>, they appear in the depending (binary)
3259           package's control file.  (<tt>Enhances</tt> appears in the
3260           recommending package's control file.)
3261         </p>
3262
3263         <p>
3264           A <tt>Depends</tt> field takes effect <em>only</em> when a
3265           package is to be configured.  It does not prevent a package
3266           being on the system in an unconfigured state while its
3267           dependencies are unsatisfied, and it is possible to replace
3268           a package whose dependencies are satisfied and which is
3269           properly installed with a different version whose
3270           dependencies are not and cannot be satisfied; when this is
3271           done the depending package will be left unconfigured (since
3272           attempts to configure it will give errors) and will not
3273           function properly.  If it is necessary, a
3274           <tt>Pre-Depends</tt> field can be used, which has a partial
3275           effect even when a package is being unpacked, as explained
3276           in detail below.  (The other three dependency fields,
3277           <tt>Recommends</tt>, <tt>Suggests</tt> and
3278           <tt>Enhances</tt>, are only used by the various front-ends
3279           to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3280         </p>
3281
3282         <p>
3283           For this reason packages in an installation run are usually
3284           all unpacked first and all configured later; this gives
3285           later versions of packages with dependencies on later
3286           versions of other packages the opportunity to have their
3287           dependencies satisfied.
3288         </p>
3289
3290         <p>
3291           The <tt>Depends</tt> field thus allows package maintainers
3292           to impose an order in which packages should be configured.
3293         </p>
3294
3295         <p>
3296           The meaning of the five dependency fields is as follows:
3297           <taglist>
3298             <tag><tt>Depends</tt></tag>
3299             <item>
3300               <p>
3301                 This declares an absolute dependency.  A package will
3302                 not be configured unless all of the packages listed in
3303                 its <tt>Depends</tt> field have been correctly
3304                 configured.
3305               </p>
3306
3307               <p>
3308                 The <tt>Depends</tt> field should be used if the
3309                 depended-on package is required for the depending
3310                 package to provide a significant amount of
3311                 functionality.
3312               </p>
3313               <p>
3314                 The <tt>Depends</tt> field should also be used if the
3315                 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3316                 <prgn>postrm</prgn> scripts require the package to be
3317                 present in order to run.  Note, however, that the
3318                 <prgn>postrm</prgn> cannot rely on any non-essential
3319                 packages to be present during the <tt>purge</tt>
3320                 phase.
3321             </item>
3322
3323             <tag><tt>Recommends</tt></tag>
3324             <item>
3325               <p>This declares a strong, but not absolute, dependency.
3326               </p>
3327
3328               <p>
3329                 The <tt>Recommends</tt> field should list packages
3330                 that would be found together with this one in all but
3331                 unusual installations.</p>
3332             </item>
3333
3334             <tag><tt>Suggests</tt></tag>
3335             <item>
3336               <p>
3337                 This is used to declare that one package may be more
3338                 useful with one or more others.  Using this field
3339                 tells the packaging system and the user that the
3340                 listed packages are related to this one and can
3341                 perhaps enhance its usefulness, but that installing
3342                 this one without them is perfectly reasonable.
3343               </p>
3344             </item>
3345
3346             <tag><tt>Enhances</tt></tag>
3347             <item>
3348               <p>
3349                 This field is similar to Suggests but works in the
3350                 opposite direction. It is used to declare that a
3351                 package can enhance the functionality of another
3352                 package.
3353               </p>
3354             </item>
3355
3356             <tag><tt>Pre-Depends</tt></tag>
3357             <item>
3358               <p>
3359                 This field is like <tt>Depends</tt>, except that it
3360                 also forces <prgn>dpkg</prgn> to complete installation
3361                 of the packages named before even starting the
3362                 installation of the package which declares the
3363                 pre-dependency, as follows:
3364               </p>
3365
3366               <p>
3367                 When a package declaring a pre-dependency is about to
3368                 be <em>unpacked</em> the pre-dependency can be
3369                 satisfied if the depended-on package is either fully
3370                 configured, <em>or even if</em> the depended-on
3371                 package(s) are only unpacked or half-configured,
3372                 provided that they have been configured correctly at
3373                 some point in the past (and not removed or partially
3374                 removed since).  In this case, both the
3375                 previously-configured and currently unpacked or
3376                 half-configured versions must satisfy any version
3377                 clause in the <tt>Pre-Depends</tt> field.
3378               </p>
3379
3380               <p>
3381                 When the package declaring a pre-dependency is about
3382                 to be <em>configured</em>, the pre-dependency will be
3383                 treated as a normal <tt>Depends</tt>, that is, it will
3384                 be considered satisfied only if the depended-on
3385                 package has been correctly configured.
3386               </p>
3387
3388               <p>
3389                 <tt>Pre-Depends</tt> should be used sparingly,
3390                 preferably only by packages whose premature upgrade or
3391                 installation would hamper the ability of the system to
3392                 continue with any upgrade that might be in progress.
3393               </p>
3394
3395               <p>
3396                 <tt>Pre-Depends</tt> are also required if the
3397                 <prgn>preinst</prgn> script depends on the named
3398                 package.  It is best to avoid this situation if
3399                 possible.
3400             </item>
3401           </taglist>
3402         </p>
3403         <p>
3404           When selecting which level of dependency to use you should
3405           consider how important the depended-on package is to the
3406           functionality of the one declaring the dependency.  Some
3407           packages are composed of components of varying degrees of
3408           importance.  Such a package should list using
3409           <tt>Depends</tt> the package(s) which are required by the
3410           more important components.  The other components'
3411           requirements may be mentioned as Suggestions or
3412           Recommendations, as appropriate to the components' relative
3413           importance.
3414         </p>
3415
3416
3417       <sect id="conflicts"><heading>Conflicting binary packages -
3418            <tt>Conflicts</tt></heading>
3419
3420         <p>
3421           When one binary package declares a conflict with another
3422           using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3423           refuse to allow them to be installed on the system at the
3424           same time.
3425         </p>
3426
3427         <p>
3428           If one package is to be installed, the other must be removed
3429           first - if the package being installed is marked as
3430           replacing (see <ref id="replaces">) the one on the system,
3431           or the one on the system is marked as deselected, or both
3432           packages are marked <tt>Essential</tt>, then
3433           <prgn>dpkg</prgn> will automatically remove the package
3434           which is causing the conflict, otherwise it will halt the
3435           installation of the new package with an error.  This
3436           mechanism is specifically designed to produce an error when
3437           the installed package is <tt>Essential</tt>, but the new
3438           package is not.
3439         </p>
3440
3441         <p>
3442           A package will not cause a conflict merely because its
3443           configuration files are still installed; it must be at least
3444           half-installed.
3445         </p>
3446
3447         <p>
3448           A special exception is made for packages which declare a
3449           conflict with their own package name, or with a virtual
3450           package which they provide (see below): this does not
3451           prevent their installation, and allows a package to conflict
3452           with others providing a replacement for it.  You use this
3453           feature when you want the package in question to be the only
3454           package providing some feature.
3455         </p>
3456
3457         <p>
3458           A <tt>Conflicts</tt> entry should almost never have an
3459           "earlier than" version clause.  This would prevent
3460           <prgn>dpkg</prgn> from upgrading or installing the package
3461           which declared such a conflict until the upgrade or removal
3462           of the conflicted-with package had been completed.
3463         </p>
3464       </sect>
3465
3466       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3467         </heading>
3468
3469         <p>
3470           As well as the names of actual ("concrete") packages, the
3471           package relationship fields <tt>Depends</tt>,
3472           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3473           <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3474           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3475           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3476           may mention "virtual packages".
3477         </p>
3478
3479         <p>
3480           A <em>virtual package</em> is one which appears in the
3481           <tt>Provides</tt> control file field of another package.
3482           The effect is as if the package(s) which provide a
3483           particular virtual package name had been listed by name
3484           everywhere the virtual package name appears. (See also <ref
3485             id="virtual_pkg">)
3486         </p>
3487
3488         <p>
3489           If there are both concrete and virtual packages of the same
3490           name, then the dependency may be satisfied (or the conflict
3491           caused) by either the concrete package with the name in
3492           question or any other concrete package which provides the
3493           virtual package with the name in question.  This is so that,
3494           for example, supposing we have
3495           <example compact="compact">
3496 Package: foo
3497 Depends: bar
3498           </example>
3499           and someone else releases an enhanced version of the
3500           <tt>bar</tt> package (for example, a non-US variant), they
3501           can say:
3502           <example compact="compact">
3503 Package: bar-plus
3504 Provides: bar
3505           </example>
3506           and the <tt>bar-plus</tt> package will now also satisfy the
3507           dependency for the <tt>foo</tt> package.
3508         </p>
3509
3510         <p>
3511           If a dependency or a conflict has a version number attached
3512           then only real packages will be considered to see whether
3513           the relationship is satisfied (or the prohibition violated,
3514           for a conflict) - it is assumed that a real package which
3515           provides the virtual package is not of the "right" version.
3516           So, a <tt>Provides</tt> field may not contain version
3517           numbers, and the version number of the concrete package
3518           which provides a particular virtual package will not be
3519           looked at when considering a dependency on or conflict with
3520           the virtual package name.
3521         </p>
3522
3523         <p>
3524           It is likely that the ability will be added in a future
3525           release of <prgn>dpkg</prgn> to specify a version number for
3526           each virtual package it provides.  This feature is not yet
3527           present, however, and is expected to be used only
3528           infrequently.
3529         </p>
3530
3531         <p>
3532           If you want to specify which of a set of real packages
3533           should be the default to satisfy a particular dependency on
3534           a virtual package, you should list the real package as an
3535           alternative before the virtual one.
3536         </p>
3537       </sect>
3538
3539
3540       <sect id="replaces"><heading>Overwriting files and replacing
3541           packages - <tt>Replaces</tt></heading>
3542
3543         <p>
3544           Packages can declare in their control file that they should
3545           overwrite files in certain other packages, or completely
3546           replace other packages. The <tt>Replaces</tt> control file
3547           field has these two distinct purposes.
3548         </p>
3549
3550         <sect1><heading>Overwriting files in other packages</heading>
3551
3552           <p>
3553             Firstly, as mentioned before, it is usually an error for a
3554             package to contain files which are on the system in
3555             another package.
3556           </p>
3557
3558           <p>
3559             However, if the overwriting package declares that it
3560             <tt>Replaces</tt> the one containing the file being
3561             overwritten, then <prgn>dpkg</prgn> will replace the file
3562             from the old package with that from the new.  The file
3563             will no longer be listed as "owned" by the old package.
3564           </p>
3565
3566           <p>
3567             If a package is completely replaced in this way, so that
3568             <prgn>dpkg</prgn> does not know of any files it still
3569             contains, it is considered to have "disappeared".  It will
3570             be marked as not wanted on the system (selected for
3571             removal) and not installed.  Any <tt>conffile</tt>s
3572             details noted for the package will be ignored, as they
3573             will have been taken over by the overwriting package.  The
3574             package's <prgn>postrm</prgn> script will be run with a
3575             special argument to allow the package to do any final
3576             cleanup required.  See <ref id="mscriptsinstact">.
3577           </p>
3578
3579           <p>
3580             If an installed package, <tt>foo</tt> say, declares that
3581             it replaces another, <tt>bar</tt>, and an attempt is made
3582             to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3583             files in the <tt>bar</tt> package which would overwrite
3584             those already present in <tt>foo</tt>.  This is so that
3585             you can install an older version of a package without
3586             problems.
3587           </p>
3588
3589           <p>
3590             For this usage of <tt>Replaces</tt>, virtual packages (see
3591             <ref id="virtual">) are not considered when looking at a
3592             <tt>Replaces</tt> field - the packages declared as being
3593             replaced must be mentioned by their real names.
3594           </p>
3595
3596           <p>
3597             Furthermore, this usage of <tt>Replaces</tt> only takes
3598             effect when both packages are at least partially on the
3599             system at once, so that it can only happen if they do not
3600             conflict or if the conflict has been overridden.
3601           </p>
3602
3603         </sect1>
3604
3605         <sect1><heading>Replacing whole packages, forcing their
3606             removal</heading>
3607
3608           <p>
3609             Secondly, <tt>Replaces</tt> allows the packaging system to
3610             resolve which package should be removed when there is a
3611             conflict - see <ref id="conflicts">.  This usage only
3612             takes effect when the two packages <em>do</em> conflict,
3613             so that the two usages of this field do not interfere with
3614             each other.
3615           </p>
3616
3617           <p>
3618             In this situation, the package declared as being replaced
3619             can be a virtual package, so for example, all mail
3620             transport agents (MTAs) would have the following fields in
3621             their control files:
3622             <example compact="compact">
3623 Provides: mail-transport-agent
3624 Conflicts: mail-transport-agent
3625 Replaces: mail-transport-agent
3626             </example>
3627             ensuring that only one MTA can be installed at any one
3628             time.
3629         </sect1>
3630       </sect>
3631
3632       <sect><heading>Relationships between source and binary packages -
3633           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3634           <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3635         </heading>
3636
3637         <p>
3638           Source packages that require certain binary packages to be
3639           installed or absent at the time of building the package
3640           can declare relationships to those binary packages.
3641         </p>
3642   
3643         <p>
3644           This is done using the <tt>Build-Depends</tt>,
3645           <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3646           <tt>Build-Conflicts-Indep</tt> control file fields.
3647         </p>
3648
3649         <p>
3650           Build-dependencies on "build-essential" binary packages can be
3651           omitted. Please see <ref id="pkg-relations"> for more information.
3652         </p>
3653
3654         <p>
3655           The dependencies and conflicts they define must be satisfied
3656           (as defined earlier for binary packages) in order to invoke
3657           the targets in <tt>debian/rules</tt>, as follows:<footnote>
3658             <p>
3659               If you make "build-arch" or "binary-arch", you need
3660               Build-Depends.  If you make "build-indep" or
3661               "binary-indep", you need Build-Depends and
3662               Build-Depends-Indep.  If you make "build" or "binary",
3663               you need both.
3664             </p>
3665             <p>
3666               There is no Build-Depends-Arch; the autobuilders will
3667               only need the Build-Depends if they know how to build
3668               only build-arch and binary-arch.  Anyone building the
3669               build-indep/binary-indep targets is basically assumed to
3670               be building the whole package and so installs all build
3671               dependencies.
3672             </p>
3673             <p>
3674               The purpose of the original split, I recall, was so that
3675               the autobuilders wouldn't need to install extra packages
3676               needed only for the binary-indep targets.  But without a
3677               build-arch/build-indep split, this didn't work, since
3678               most of the work is done in the build target, not in the
3679               binary target.
3680             </p>
3681           </footnote>
3682
3683           <taglist>
3684             <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3685             <item>
3686               <p>
3687                 The <tt>Build-Depends</tt> and
3688                 <tt>Build-Conflicts</tt> fields must be satisfied when
3689                 any of the following targets is invoked:
3690                 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
3691                 <tt>binary-arch</tt>, <tt>build-arch</tt>,
3692                 <tt>build-indep</tt> and <tt>binary-indep</tt>.
3693               </p>
3694             </item>
3695             <tag><tt>Build-Depends-Indep</tt>,
3696               <tt>Build-Conflicts-Indep</tt></tag>
3697             <item>
3698               <p>
3699                 The <tt>Build-Depends-Indep</tt> and
3700                 <tt>Build-Conflicts-Indep</tt> fields must be
3701                 satisfied when any of the following targets is
3702                 invoked: <tt>build</tt>, <tt>clean</tt>,
3703                 <tt>build-indep</tt>, <tt>binary</tt> and
3704                 <tt>binary-indep</tt>.
3705               </p>
3706             </item>
3707           </taglist>
3708
3709         </p>
3710
3711       </sect>
3712     </chapt>
3713
3714
3715     <chapt id="conffiles"><heading>Configuration file handling
3716       </heading>
3717
3718       <p>
3719         This chapter has been superseded by <ref id="config-files">.
3720       </p>
3721
3722
3723     <chapt id="sharedlibs"><heading>Shared libraries</heading>
3724
3725       <p>
3726         Packages containing shared libraries must be constructed with
3727         a little care to make sure that the shared library is always
3728         available.  This is especially important for packages whose
3729         shared libraries are vitally important, such as the C library
3730         (currently <tt>libc6</tt>).
3731       </p>
3732
3733       <p>
3734         Packages involving shared libraries should be split up into
3735         several binary packages. This section mostly deals with how
3736         this separation is to be accomplished; rules for files within
3737         the shared library packages are in <ref id="libraries"> instead.
3738       </p>
3739
3740       <sect id="sharedlibs-runtime">
3741         <heading>Run-time shared libraries</heading>
3742
3743       <p>
3744         The run-time shared library needs to be placed in a package called
3745         <package><var>libraryname</var><var>soversion</var></package>, where
3746         <file><var>soversion</var></file> is the version number in the
3747         soname of the shared library<footnote>
3748             <p>
3749               The soname is the shared object name: it's the thing
3750               that has to match exactly between building an executable
3751               and running it for the dynamic linker to be able run the
3752               program.  For example, if the soname of the library is
3753               <file>libfoo.so.6</file>, the library package would be
3754               called <file>libfoo6</file>.
3755             </p>
3756           </footnote>.
3757         Alternatively, if it would be confusing to directly append
3758         <var>soversion</var> to <var>libraryname</var> (e.g. because
3759         <var>libraryname</var> itself ends in a number), you may use
3760         <package><var>libraryname</var>-<var>soversion</var></package> and
3761         <package><var>libraryname</var>-<var>soversion</var>-dev</package>
3762         instead.
3763       </p>
3764
3765       <p>
3766         If you have several shared libraries built from the same
3767         source tree you may lump them all together into a single
3768         shared library package, provided that you change all of
3769         their sonames at once (so that you don't get filename
3770         clashes if you try to install different versions of the
3771         combined shared libraries package).
3772       </p>
3773
3774       <p>
3775         The package should install the shared libraries under
3776         their normal names.  For example, the <package>libgdbmg1</package>
3777         package should install <file>libgdbm.so.1.7.3</file> as
3778         <file>/usr/lib/libgdbm.so.1.7.3</file>.  The files should not be
3779         renamed or re-linked by any <prgn>prerm</prgn> or
3780         <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3781         of renaming things safely without affecting running programs,
3782         and attempts to interfere with this are likely to lead to
3783         problems.
3784       </p>
3785
3786       <p>
3787         Shared libraries should not be installed executable, since
3788         the dynamic linker does not require this and trying to
3789         execute a shared library usually results in a core dump.
3790       </p>
3791
3792       <p>
3793         The run-time library package should include the symbolic link that
3794         <prgn>ldconfig</prgn> would create for the shared libraries.
3795         For example, the <package>libgdbmg1</package> package should include
3796         a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3797         <file>libgdbm.so.1.7.3</file>.  This is needed so that the dynamic
3798         linker (for example <prgn>ld.so</prgn> or
3799         <prgn>ld-linux.so.*</prgn>) can find the library between the
3800         time that <prgn>dpkg</prgn> installs it and the time that
3801         <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3802         script.<footnote>
3803           <p>
3804             The package management system requires the library to be
3805             placed before the symbolic link pointing to it in the
3806             <file>.deb</file> file.  This is so that when
3807             <prgn>dpkg</prgn> comes to install the symlink
3808             (overwriting the previous symlink pointing at an older
3809             version of the library), the new shared library is already
3810             in place.  In the past, this was achieved by creating the
3811             library in the temporary packaging directory before
3812             creating the symlink.  Unfortunately, this was not always
3813             effective, since the building of the tar file in the
3814             <file>.deb</file> depended on the behavior of the underlying
3815             file system.  Some file systems (such as reiserfs) reorder
3816             the files so that the order of creation is forgotten.
3817             Since version 1.7.0, <prgn>dpkg</prgn>
3818             reorders the files itself as necessary when building a
3819             package.  Thus it is no longer important to concern
3820             oneself with the order of file creation.
3821           </p>
3822         </footnote>
3823       </p>
3824
3825       <sect1 id="ldconfig">
3826         <heading><tt>ldconfig</tt></heading>
3827
3828       <p>
3829         Any package installing shared libraries in one of the default
3830         library directories of the dynamic linker (which are currently
3831         <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3832         listed in <file>/etc/ld.so.conf</file><footnote>
3833           <p>
3834             These are currently
3835             <list compact="compact">
3836               <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3837               <item><p>/usr/local/lib</p></item>
3838               <item><p>/usr/lib/libc5-compat</p></item>
3839               <item><p>/lib/libc5-compat</p></item>
3840               <item><p>/usr/X11R6/lib</p></item>
3841             </list>
3842           </p>
3843         </footnote>
3844         must use <prgn>ldconfig</prgn> to update the shared library
3845         system.
3846       </p>
3847
3848       <p>
3849         The package must call <prgn>ldconfig</prgn> in the
3850         <prgn>postinst</prgn> script if the first argument is
3851         <tt>configure</tt>; the <prgn>postinst</prgn> script may
3852         optionally invoke <prgn>ldconfig</prgn> at other times.  The
3853         package should call <prgn>ldconfig</prgn> in the
3854         <prgn>postrm</prgn> script if the first argument is
3855         <tt>remove</tt>.  The maintainer scripts must not invoke
3856         <prgn>ldconfig</prgn> under any circumstances other than those
3857         described in this paragraph.<footnote>
3858           <p>During install or upgrade, the preinst is called before
3859             the new files are installed, so calling "ldconfig" is
3860             pointless.  The preinst of an existing package can also be
3861             called if an upgrade fails.  However, this happens during
3862             the critical time when a shared libs may exist on-disk
3863             under a temporary name.  Thus, it is dangerous and
3864             forbidden by current policy to call "ldconfig" at this
3865             time.
3866           </p>
3867           <p>When a package is installed or upgraded, "postinst
3868             configure" runs after the new files are safely on-disk.
3869             Since it is perfectly safe to invoke ldconfig
3870             unconditionally in a postinst, it is OK for a package to
3871             simply put ldconfig in its postinst without checking the
3872             argument.  The postinst can also be called to recover from
3873             a failed upgrade.  This happens before any new files are
3874             unpacked, so there is no reason to call "ldconfig" at this
3875             point.
3876           </p>
3877           <p>For a package that is being removed, prerm is
3878             called with all the files intact, so calling ldconfig is
3879             useless.  The other calls to "prerm" happen in the case of
3880             upgrade at a time when all the files of the old package
3881             are on-disk, so again calling "ldconfig" is pointless.
3882           </p>
3883           <p>postrm, on the other hand, is called with the "remove"
3884             argument just after the files are removed, so this is the
3885             proper time to call "ldconfig" to notify the system of the
3886             fact shared libraries from the package are removed.
3887             The postrm can be called at several other times.  At the
3888             time of "postrm purge", "postrm abort-install", or "postrm
3889             abort-upgrade", calling "ldconfig" is useless because the
3890             shared lib files are not on-disk.  However, when "postrm"
3891             is invoked with arguments "upgrade", "failed-upgrade", or
3892             "disappear", a shared lib may exist on-disk under a
3893             temporary filename.
3894           </p>
3895         </footnote>
3896       </p>
3897       </sect1>
3898
3899       </sect>
3900
3901       <sect id="sharedlibs-runtime-progs">
3902         <heading>Run-time support programs</heading>
3903
3904       <p>
3905         If your package has some run-time support programs which use
3906         the shared library you must not put them in the shared
3907         library package.  If you do that then you won't be able to
3908         install several versions of the shared library without
3909         getting filename clashes.
3910       </p>
3911
3912       <p>
3913         Instead, either create another package for the runtime binaries
3914         (this package might typically be named
3915         <package><var>libraryname</var>-runtime</package>; note the absence
3916         of the <var>soversion</var> in the package name), or if the
3917         development package is small, include them in there.
3918       </p>
3919       </sect>
3920
3921       <sect id="sharedlibs-static">
3922         <heading>Static libraries</heading>
3923
3924       <p>
3925         The static library (<file><var>libraryname.a</var></file>)
3926         is usually provided in addition to the shared version.
3927         It is placed into the development package (see below).
3928       </p>
3929
3930       <p>
3931         In some cases, it is acceptable for a library to be
3932         available in static form only; these cases include:
3933         <list>
3934           <item>libraries for languages whose shared library support
3935                 is immature or unstable</item>
3936           <item>libraries whose interfaces are in flux or under
3937                 development (commonly the case when the library's
3938                 major version number is zero, or where the ABI breaks
3939                 across patchlevels)</item>
3940           <item>libraries which are explicitly intended to be
3941                 available only in static form by their upstream
3942                 author(s)</item>
3943         </list>
3944       </p>
3945
3946       <sect id="sharedlibs-dev">
3947         <heading>Development files</heading>
3948
3949       <p>
3950         The development files associated to a shared library need to be
3951         placed in a package called
3952         <package><var>libraryname</var><var>soversion</var>-dev</package>,
3953         or if you prefer only to support one development version at a
3954         time, <package><var>libraryname</var>-dev</package>.
3955       </p>
3956
3957       <p>
3958         In case several development versions of a library exist, you may
3959         need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
3960         <ref id="conflicts">) to ensure that the user only installs one
3961         development version at a time (as different development versions are
3962         likely to have the same header files in them, which would cause a
3963         filename clash if both were installed).
3964       </p>
3965
3966       <p>
3967         The development package should contain a symlink for the associated
3968         shared library without a version number. For example, the
3969         <package>libgdbmg1-dev</package> package should include a symlink
3970         from <file>/usr/lib/libgdbm.so</file> to
3971         <file>libgdbm.so.1.7.3</file>.  This symlink is needed by the linker
3972         (<prgn>ld</prgn>) when compiling packages, as it will only look for
3973         <file>libgdbm.so</file> when compiling dynamically.
3974       </p>
3975       </sect>
3976
3977       <sect id="sharedlibs-intradeps">
3978         <heading>Dependencies between the packages of the same library</heading>
3979
3980         <p>
3981           Typically the development version should have an exact
3982           version dependency on the runtime library, to make sure that
3983           compilation and linking happens correctly.  The
3984           <tt>${Source-Version}</tt> substitution variable can be
3985           useful for this purpose.
3986         </p>
3987       </sect>
3988
3989       <sect id="sharedlibs-shlibdeps">
3990         <heading>Dependencies between the library and other packages -
3991         the <tt>shlibs</tt> system</heading>
3992
3993         <p>
3994           If a package contains a binary or library which links to a
3995           shared library, we must ensure that when the package is
3996           installed on the system, all of the libraries needed are
3997           also installed.  This requirement led to the creation of the
3998           <tt>shlibs</tt> system, which is very simple in its design:
3999           any package which <em>provides</em> a shared library also
4000           provides information on the package dependencies required to
4001           ensure the presence of this library, and any package which
4002           <em>uses</em> a shared library uses this information to
4003           determine the dependencies it requires.  The files which
4004           contain the mapping from shared libraries to the necessary
4005           dependency information are called <file>shlibs</file> files.
4006         </p>
4007
4008         <p>
4009           Thus, when a package is built which contains any shared
4010           libraries, it must provide a <file>shlibs</file> file for other
4011           packages to use, and when a package is built which contains
4012           any shared libraries or compiled binaries, it must run
4013           <prgn>dpkg-shlibdeps</prgn> on these to determine the
4014           libraries used and hence the dependencies needed by this
4015           package.<footnote>
4016             <p>
4017               In the past, the shared libraries linked to were
4018               determined by calling <prgn>ldd</prgn>, but now
4019               <prgn>objdump</prgn> is used to do this.  The only
4020               change this makes to package building is that
4021               <prgn>dpkg-shlibdeps</prgn> must also be run on shared
4022               libraries, whereas in the past this was unnecessary.
4023               The rest of this footnote explains the advantage that
4024               this method gives.
4025             </p>
4026
4027             <p>
4028               We say that a binary <tt>foo</tt> <em>directly</em> uses
4029               a library <tt>libbar</tt> if it is explicitly linked
4030               with that library (that is, it uses the flag
4031               <tt>-lbar</tt> during the linking stage).  Other
4032               libraries that are needed by <tt>libbar</tt> are linked
4033               <em>indirectly</em> to <tt>foo</tt>, and the dynamic
4034               linker will load them automatically when it loads
4035               <tt>libbar</tt>.  A package should depend on
4036               the libraries it directly uses, and the dependencies for
4037               those libraries should automatically pull in the other
4038               libraries.
4039             </p>
4040
4041             <p>
4042               Unfortunately, the <prgn>ldd</prgn> program shows both
4043               the directly and indirectly used libraries, meaning that
4044               the dependencies determined included both direct and
4045               indirect dependencies.  The use of <prgn>objdump</prgn>
4046               avoids this problem by determining only the directly
4047               used libraries.
4048             </p>
4049
4050             <p>
4051               A good example of where this helps is the following.  We
4052               could update <tt>libimlib</tt> with a new version that
4053               supports a new graphics format called dgf (but retaining
4054               the same major version number).  If we used the old
4055               <prgn>ldd</prgn> method, every package that uses
4056               <tt>libimlib</tt> would need to be recompiled so it
4057               would also depend on <tt>libdgf</tt> or it wouldn't run
4058               due to missing symbols.  However with the new system,
4059               packages using <tt>libimlib</tt> can rely on
4060               <tt>libimlib</tt> itself having the dependency on
4061               <tt>libdgf</tt> and so they would not need rebuilding.
4062             </p>
4063           </footnote>
4064         </p>
4065
4066         <p>
4067           In the following sections, we will first describe where the
4068           various <tt>shlibs</tt> files are to be found, then how to
4069           use <prgn>dpkg-shlibdeps</prgn>, and finally the
4070           <tt>shlibs</tt> file format and how to create them if your
4071           package contains a shared library.
4072         </p>
4073
4074       <sect1>
4075         <heading>The <tt>shlibs</tt> files present on the system</heading>
4076
4077         <p>
4078           There are several places where <tt>shlibs</tt> files are
4079           found.  The following list gives them in the order in which
4080           they are read by <prgn>dpkg-shlibdeps</prgn>.  (The first
4081           one which gives the required information is used.)
4082         </p>
4083
4084         <p>
4085           <list>
4086             <item>
4087               <p><file>debian/shlibs.local</file></p>
4088               <p>
4089                 This lists overrides for this package.  Its use is
4090                 described below (see <ref id="shlibslocal">).
4091               </p>
4092             </item>
4093
4094             <item>
4095               <p><file>/etc/dpkg/shlibs.override</file></p>
4096               <p>
4097                 This lists global overrides.  This list is normally
4098                 empty.  It is maintained by the local system
4099                 administrator.
4100               </p>
4101             </item>
4102
4103             <item>
4104               <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
4105               <p>
4106                 When packages are being built, any
4107                 <file>debian/shlibs</file> files are copied into the
4108                 control file area of the temporary build directory and
4109                 given the name <file>shlibs</file>.  These files give
4110                 details of any shared libraries included in the
4111                 package.<footnote>
4112                   <p>
4113                     An example may help here.  Let us say that the
4114                     source package <tt>foo</tt> generates two binary
4115                     packages, <tt>libfoo2</tt> and
4116                     <tt>foo-runtime</tt>.  When building the binary
4117                     packages, the two packages are created in the
4118                     directories <file>debian/libfoo2</file> and
4119                     <file>debian/foo-runtime</file> respectively.
4120                     (<file>debian/tmp</file> could be used instead of one
4121                     of these.)  Since <tt>libfoo2</tt> provides the
4122                     <tt>libfoo</tt> shared library, it will require a
4123                     <tt>shlibs</tt> file, which will be installed in
4124                     <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
4125                     to become
4126                     <file>/var/lib/dpkg/info/libfoo2.shlibs</file>.  Then
4127                     when <prgn>dpkg-shlibdeps</prgn> is run on the
4128                     executable
4129                     <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
4130                     will examine the
4131                     <file>debian/libfoo2/DEBIAN/shlibs</file> file to
4132                     determine whether <tt>foo-prog</tt>'s library
4133                     dependencies are satisfied by any of the libraries
4134                     provided by <tt>libfoo2</tt>.  For this reason,
4135                     <prgn>dpkg-shlibdeps</prgn> must only be run once
4136                     all of the individual binary packages'
4137                     <tt>shlibs</tt> files have been installed into the
4138                     build directory.
4139                   </p>
4140                 </footnote>
4141               </p>
4142             </item>
4143
4144             <item>
4145               <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
4146               <p>
4147                 These are the <file>shlibs</file> files corresponding to
4148                 all of the packages installed on the system, and are
4149                 maintained by the relevant package maintainers.
4150               </p>
4151             </item>
4152
4153             <item>
4154               <p><file>/etc/dpkg/shlibs.default</file></p>
4155               <p>
4156                 This file lists any shared libraries whose packages
4157                 have failed to provide correct <file>shlibs</file> files.
4158                 It was used when the <file>shlibs</file> setup was first
4159                 introduced, but it is now normally empty.  It is
4160                 maintained by the <tt>dpkg</tt> maintainer.
4161               </p>
4162             </item>
4163           </list>
4164         </p>
4165       </sect1>
4166
4167       <sect1>
4168         <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4169             <file>shlibs</file> files</heading>
4170
4171         <p>
4172           Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4173           <file>debian/rules</file> file.  If your package contains only
4174           compiled binaries and libraries (but no scripts), you can
4175           use a command such as:
4176           <example compact="compact">
4177 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4178   debian/tmp/usr/lib/*
4179           </example>
4180           Otherwise, you will need to explicitly list the compiled
4181           binaries and libraries.<footnote>
4182             <p>
4183               If you are using <tt>debhelper</tt>, the
4184               <prgn>dh_shlibdeps</prgn> program will do this work for
4185               you.  It will also correctly handle multi-binary
4186               packages.
4187             </p>
4188           </footnote>
4189         </p>
4190
4191         <p>
4192           This command puts the dependency information into the
4193           <file>debian/substvars</file> file, which is then used by
4194           <prgn>dpkg-gencontrol</prgn>.  You will need to place a
4195           <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4196           field in the control file for this to work.
4197         </p>
4198
4199         <p>
4200           If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4201           done.  If it does complain you might need to create your own
4202           <file>debian/shlibs.local</file> file, as explained below (see
4203           <ref id="shlibslocal">).
4204         </p>
4205
4206         <p>
4207           If you have multiple binary packages, you will need to call
4208           <prgn>dpkg-shlibdeps</prgn> on each one which contains
4209           compiled libraries or binaries.  In such a case, you will
4210           need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4211           utilities to specify a different <file>substvars</file> file.
4212           For more details on this and other options, see <manref
4213           name="dpkg-shlibdeps" section="1">.
4214         </p>
4215       </sect1>
4216
4217       <sect1 id="shlibs">
4218         <heading>The <file>shlibs</file> File Format</heading>
4219
4220         <p>
4221           Each <file>shlibs</file> file has the same format.  Lines
4222           beginning with <tt>#</tt> are considered to be comments and
4223           are ignored.  Each line is of the form:
4224           <example compact="compact">
4225 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4226           </example>
4227         </p>
4228
4229         <p>
4230           We will explain this by reference to the example of the
4231           <tt>zlib1g</tt> package, which (at the time of writing)
4232           installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4233         </p>
4234
4235         <p>
4236           <var>library-name</var> is the name of the shared library,
4237           in this case <tt>libz</tt>.  (This must match the name part
4238           of the soname, see below.)
4239         </p>
4240
4241         <p>
4242           <var>soname-version-number</var> is the version part of the
4243           soname of the library.  The soname is the thing that must
4244           exactly match for the library to be recognized by the
4245           dynamic linker, and is usually of the form
4246           <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4247           example, <tt>libz.so.1</tt>.<footnote>
4248             <p>
4249               This can be determined using the command
4250               <example compact="compact">
4251 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4252               </example>
4253             </p>
4254           </footnote>
4255           The version part is the part which comes after
4256           <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4257         </p>
4258
4259         <p>
4260           <var>dependencies</var> has the same syntax as a dependency
4261           field in a binary package control file.  It should give
4262           details of which packages are required to satisfy a binary
4263           built against the version of the library contained in the
4264           package.  See <ref id="depsyntax"> for details.
4265         </p>
4266
4267         <p>
4268           In our example, if the first version of the <tt>zlib1g</tt>
4269           package which contained a minor number of at least
4270           <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4271           <tt>shlibs</tt> entry for this library could say:
4272           <example compact="compact">
4273 libz 1 zlib1g (>= 1:1.1.3)
4274           </example>
4275           The version-specific dependency is to avoid warnings from
4276           the dynamic linker about using older shared libraries with
4277           newer binaries.
4278         </p>
4279       </sect1>
4280
4281       <sect1>
4282         <heading>Providing a <file>shlibs</file> file</heading>
4283
4284         <p>
4285           If your package provides a shared library, you should create
4286           a <file>shlibs</file> file following the format described above.
4287           It is usual to call this file <file>debian/shlibs</file> (but if
4288           you have multiple binary packages, you might want to call it
4289           <file>debian/shlibs.<var>package</var></file> instead).  Then
4290           let <file>debian/rules</file> install it in the control area:
4291           <example compact="compact">
4292 install -m644 debian/shlibs debian/tmp/DEBIAN
4293           </example>
4294           or, in the case of a multi-binary package:
4295           <example compact="compact">
4296 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4297           </example>
4298           An alternative way of doing this is to create the
4299           <file>shlibs</file> file in the control area directly from
4300           <file>debian/rules</file> without using a <file>debian/shlibs</file>
4301           file at all,<footnote>
4302             <p>
4303               This is what <prgn>dh_makeshlibs</prgn> in the
4304               <tt>debhelper</tt> suite does.
4305             </p>
4306           </footnote>
4307           since the <file>debian/shlibs</file> file itself is ignored by
4308           <prgn>dpkg-shlibdeps</prgn>.
4309         </p>
4310
4311         <p>
4312           As <prgn>dpkg-shlibdeps</prgn> reads the
4313           <file>DEBIAN/shlibs</file> files in all of the binary packages
4314           being built from this source package, all of the
4315           <file>DEBIAN/shlibs</file> files should be installed before
4316           <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4317           packages.
4318         </p>
4319       </sect1>
4320
4321       <sect1 id="shlibslocal">
4322         <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4323
4324         <p>
4325           This file is intended only as a <em>temporary</em> fix if
4326           your binaries or libraries depend on a library whose package
4327           does not yet provide a correct <file>shlibs</file> file.
4328         </p>
4329
4330         <p>
4331           We will assume that you are trying to package a binary
4332           <tt>foo</tt>.  When you try running
4333           <prgn>dpkg-shlibdeps</prgn> you get the following error
4334           message (<tt>-O</tt> displays the dependency information on
4335           <tt>stdout</tt> instead of writing it to
4336           <tt>debian/substvars</tt>, and the lines have been wrapped
4337           for ease of reading):
4338           <example compact="compact">
4339 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4340 dpkg-shlibdeps: warning: unable to find dependency
4341   information for shared library libbar (soname 1,
4342   path /usr/lib/libbar.so.1, dependency field Depends)
4343 shlibs:Depends=libc6 (>= 2.2.2-2)
4344           </example>
4345           You can then run <prgn>ldd</prgn> on the binary to find the
4346           full location of the library concerned:
4347           <example compact="compact">
4348 $ ldd foo
4349 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4350 libc.so.6 => /lib/libc.so.6 (0x40032000)
4351 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4352           </example>
4353           So the <prgn>foo</prgn> binary depends on the
4354           <prgn>libbar</prgn> shared library, but no package seems to
4355           provide a <file>*.shlibs</file> file handling
4356           <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>.  Let's
4357           determine the package responsible:
4358           <example compact="compact">
4359 $ dpkg -S /usr/lib/libbar.so.1
4360 bar1: /usr/lib/libbar.so.1
4361 $ dpkg -s bar1 | grep Version
4362 Version: 1.0-1
4363           </example>
4364           This tells us that the <tt>bar1</tt> package, version 1.0-1,
4365           is the one we are using.  Now we can file a bug against the
4366           <tt>bar1</tt> package and create our own
4367           <file>debian/shlibs.local</file> to locally fix the problem.
4368           Including the following line into your
4369           <file>debian/shlibs.local</file> file:
4370           <example compact="compact">
4371 libbar 1 bar1 (>= 1.0-1)
4372           </example>
4373           should allow the package build to work.
4374         </p>
4375
4376         <p>
4377           As soon as the maintainer of <tt>bar1</tt> provides a
4378           correct <file>shlibs</file> file, you should remove this line
4379           from your <file>debian/shlibs.local</file> file.  (You should
4380           probably also then have a versioned <tt>Build-Depends</tt>
4381           on <tt>bar1</tt> to help ensure that others do not have the
4382           same problem building your package.)
4383         </p>
4384       </sect1>
4385
4386       </sect>
4387
4388     </chapt>
4389
4390     <chapt id="opersys"><heading>The Operating System</heading>
4391
4392       <sect>
4393         <heading>Filesystem hierarchy</heading>
4394
4395
4396         <sect1>
4397           <heading>Filesystem Structure</heading>
4398
4399           <p>
4400             The location of all installed files and directories must
4401             comply with the Filesystem Hierarchy Standard (FHS),
4402             version 2.1, except where doing so would violate other
4403             terms of Debian Policy. The version of this document
4404             referred here can be found in the <tt>debian-policy</tt>
4405             package or on
4406             <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4407               name="FHS (Debian copy)"> alongside this manual (or, if
4408             you have the <package>debian-policy</package> installed,
4409             you can try <url
4410               id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4411               (local copy)">). The
4412             latest version, which may be a more recent version, may
4413             be found on
4414             <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4415             Specific questions about following the standard may be
4416             asked on the <tt>debian-devel</tt> mailing list, or
4417             referred to the FHS mailing list (see the
4418             <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4419             more information).
4420           </p>
4421         </sect1>
4422
4423         <sect1>
4424           <heading>Site-specific programs</heading>
4425
4426           <p>
4427             As mandated by the FHS, packages must not place any
4428             files in <file>/usr/local</file>, either by putting them in
4429             the file system archive to be unpacked by <prgn>dpkg</prgn>
4430             or by manipulating them in their maintainer scripts.
4431           </p>
4432
4433           <p>
4434             However, the package may create empty directories below
4435             <file>/usr/local</file> so that the system administrator knows
4436             where to place site-specific files.  These directories
4437             should be removed on package removal if they are
4438             empty.
4439           </p>
4440
4441           <p>
4442             Note, that this applies only to directories <em>below</em>
4443             <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4444             Packages must not create sub-directories in the directory
4445             <file>/usr/local</file> itself, except those listed in FHS,
4446             section 4.5.  However, you may create directories below
4447             them as you wish. You must not remove any of the
4448             directories listed in 4.5, even if you created them.
4449           </p>
4450
4451           <p>
4452             Since <file>/usr/local</file> can be mounted read-only from a
4453             remote server, these directories must be created and
4454             removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4455             maintainer scripts and not be included in the
4456             <file>.deb</file> archive.  These scripts must not fail if
4457             either of these operations fail.
4458           </p>
4459
4460           <p>
4461             For example, the <tt>emacsen-common</tt> package could
4462             contain something like
4463             <example compact="compact">
4464 if [ ! -e /usr/local/share/emacs ]
4465 then
4466   if mkdir /usr/local/share/emacs 2>/dev/null
4467   then
4468     chown root:staff /usr/local/share/emacs
4469     chmod 2775 /usr/local/share/emacs
4470   fi
4471 fi
4472             </example>
4473             in its <prgn>postinst</prgn> script, and
4474             <example compact="compact">
4475 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4476 rmdir /usr/local/share/emacs 2>/dev/null || true
4477             </example>
4478             in the <prgn>prerm</prgn> script.  (Note that this form is
4479             used to ensure that if the script is interrupted, the
4480             directory <file>/usr/local/share/emacs</file> will still be
4481             removed.)
4482           </p>
4483
4484           <p>
4485             If you do create a directory in <file>/usr/local</file> for
4486             local additions to a package, you should ensure that
4487             settings in <file>/usr/local</file> take precedence over the
4488             equivalents in <file>/usr</file>.
4489           </p>
4490
4491           <p>
4492             However, because <file>/usr/local</file> and its contents are
4493             for exclusive use of the local administrator, a package
4494             must not rely on the presence or absence of files or
4495             directories in <file>/usr/local</file> for normal operation.
4496           </p>
4497
4498           <p>
4499             The <file>/usr/local</file> directory itself and all the
4500             subdirectories created by the package should (by default) have
4501             permissions 2775 (group-writable and set-group-id) and be
4502             owned by <tt>root.staff</tt>.
4503           </p>
4504         </sect1>
4505
4506         <sect1>
4507           <heading>The system-wide mail directory</heading>
4508           <p>
4509             The system-wide mail directory is <file>/var/mail</file>. This
4510             directory is part of the base system and should not owned
4511             by any particular mail agents.  The use of the old
4512             location <file>/var/spool/mail</file> is deprecated, even
4513             though the spool may still be physically located there.
4514             To maintain partial upgrade compatibility for systems
4515             which have <file>/var/spool/mail</file> as their physical mail
4516             spool, packages using <file>/var/mail</file> must depend on
4517             either <package>libc6</package> (&gt;= 2.1.3-13), or on
4518             <package>base-files</package> (&gt;= 2.2.0), or on later
4519             versions of either one of these packages.
4520           </p>
4521         </sect1>
4522       </sect>
4523
4524       <sect>
4525         <heading>Users and groups</heading>
4526
4527         <sect1>
4528           <heading>Introduction</heading>
4529           <p>
4530             The Debian system can be configured to use either plain or
4531             shadow passwords.
4532           </p>
4533
4534           <p>
4535             Some user ids (UIDs) and group ids (GIDs) are reserved
4536             globally for use by certain packages.  Because some
4537             packages need to include files which are owned by these
4538             users or groups, or need the ids compiled into binaries,
4539             these ids must be used on any Debian system only for the
4540             purpose for which they are allocated. This is a serious
4541             restriction, and we should avoid getting in the way of
4542             local administration policies. In particular, many sites
4543             allocate users and/or local system groups starting at 100.
4544           </p>
4545
4546           <p>
4547             Apart from this we should have dynamically allocated ids,
4548             which should by default be arranged in some sensible
4549             order, but the behavior should be configurable.
4550           </p>
4551
4552           <p>
4553             Packages other than <tt>base-passwd</tt> must not modify
4554             <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4555             <file>/etc/group</file> or <file>/etc/gshadow</file>.
4556           </p>
4557         </sect1>
4558
4559         <sect1>
4560           <heading>UID and GID classes</heading>
4561           <p>
4562             The UID and GID numbers are divided into classes as
4563             follows:
4564             <taglist>
4565               <tag>0-99:</tag>
4566               <item>
4567                 <p>
4568                   Globally allocated by the Debian project, the same
4569                   on every Debian system.  These ids will appear in
4570                   the <file>passwd</file> and <file>group</file> files of all
4571                   Debian systems, new ids in this range being added
4572                   automatically as the <tt>base-passwd</tt> package is
4573                   updated.
4574                 </p>
4575
4576                 <p>
4577                   Packages which need a single statically allocated
4578                   uid or gid should use one of these; their
4579                   maintainers should ask the <tt>base-passwd</tt>
4580                   maintainer for ids.
4581                 </p>
4582               </item>
4583
4584               <tag>100-999:</tag>
4585               <item>
4586                 <p>
4587                   Dynamically allocated system users and groups.
4588                   Packages which need a user or group, but can have
4589                   this user or group allocated dynamically and
4590                   differently on each system, should use <tt>adduser
4591                   --system</tt> to create the group and/or user.
4592                   <prgn>adduser</prgn> will check for the existence of
4593                   the user or group, and if necessary choose an unused
4594                   id based on the ranges specified in
4595                   <file>adduser.conf</file>.
4596                 </p>
4597               </item>
4598
4599               <tag>1000-29999:</tag>
4600               <item>
4601                 <p>
4602                   Dynamically allocated user accounts.  By default
4603                   <prgn>adduser</prgn> will choose UIDs and GIDs for
4604                   user accounts in this range, though
4605                   <file>adduser.conf</file> may be used to modify this
4606                   behavior.
4607                 </p>
4608               </item>
4609
4610               <tag>30000-59999:</tag>
4611               <item>
4612                 <p>Reserved.</p>
4613               </item>
4614
4615               <tag>60000-64999:</tag>
4616               <item>
4617                 <p>
4618                   Globally allocated by the Debian project, but only
4619                   created on demand. The ids are allocated centrally
4620                   and statically, but the actual accounts are only
4621                   created on users' systems on demand.
4622                 </p>
4623
4624                 <p>
4625                   These ids are for packages which are obscure or
4626                   which require many statically-allocated ids.  These
4627                   packages should check for and create the accounts in
4628                   <file>/etc/passwd</file> or <file>/etc/group</file> (using
4629                   <prgn>adduser</prgn> if it has this facility) if
4630                   necessary.  Packages which are likely to require
4631                   further allocations should have a "hole" left after
4632                   them in the allocation, to give them room to
4633                   grow.
4634                 </p>
4635               </item>
4636
4637               <tag>65000-65533:</tag>
4638               <item>
4639                 <p>Reserved.</p>
4640               </item>
4641
4642               <tag>65534:</tag>
4643               <item>
4644                 <p>
4645                   User <tt>nobody</tt>. The corresponding gid refers
4646                   to the group <tt>nogroup</tt>.
4647                 </p>
4648               </item>
4649
4650               <tag>65535:</tag>
4651               <item>
4652                 <p>
4653                   <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4654                   not</em> be used, because it is the error return
4655                   sentinel value.
4656                 </p>
4657               </item>
4658             </taglist>
4659           </p>
4660         </sect1>
4661       </sect>
4662
4663       <sect id="sysvinit">
4664         <heading>System run levels and <file>init.d</file> scripts</heading>
4665
4666         <sect1 id="/etc/init.d">
4667           <heading>Introduction</heading>
4668
4669           <p>
4670             The <file>/etc/init.d</file> directory contains the scripts
4671             executed by <prgn>init</prgn> at boot time and when the
4672             init state (or "runlevel") is changed (see <manref
4673             name="init" section="8">).
4674           </p>
4675
4676           <p>
4677             There are at least two different, yet functionally
4678             equivalent, ways of handling these scripts.  For the sake
4679             of simplicity, this document describes only the symbolic
4680             link method. However, it must not be assumed by maintainer
4681             scripts that this method is being used, and any automated
4682             manipulation of the various runlevel behaviours by
4683             maintainer scripts must be performed using
4684             <prgn>update-rc.d</prgn> as described below and not by
4685             manually installing or removing symlinks.  For information
4686             on the implementation details of the other method,
4687             implemented in the <tt>file-rc</tt> package, please refer
4688             to the documentation of that package.
4689           </p>
4690
4691           <p>
4692             These scripts are referenced by symbolic links in the
4693             <file>/etc/rc<var>n</var>.d</file> directories.  When changing
4694             runlevels, <prgn>init</prgn> looks in the directory
4695             <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4696             execute, where <tt><var>n</var></tt> is the runlevel that
4697             is being changed to, or <tt>S</tt> for the boot-up
4698             scripts.
4699           </p>
4700
4701           <p>
4702             The names of the links all have the form
4703             <file>S<var>mm</var><var>script</var></file> or
4704             <file>K<var>mm</var><var>script</var></file> where
4705             <var>mm</var> is a two-digit number and <var>script</var>
4706             is the name of the script (this should be the same as the
4707             name of the actual script in <file>/etc/init.d</file>).
4708           </p>
4709
4710           <p>
4711             When <prgn>init</prgn> changes runlevel first the targets
4712             of the links whose names start with a <tt>K</tt> are
4713             executed, each with the single argument <tt>stop</tt>,
4714             followed by the scripts prefixed with an <tt>S</tt>, each
4715             with the single argument <tt>start</tt>.  (The links are
4716             those in the <file>/etc/rc<var>n</var>.d</file> directory
4717             corresponding to the new runlevel.)  The <tt>K</tt> links
4718             are responsible for killing services and the <tt>S</tt>
4719             link for starting services upon entering the runlevel.
4720           </p>
4721
4722           <p>
4723             For example, if we are changing from runlevel 2 to
4724             runlevel 3, init will first execute all of the <tt>K</tt>
4725             prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4726             all of the <tt>S</tt> prefixed scripts in that directory.
4727             The links starting with <tt>K</tt> will cause the
4728             referred-to file to be executed with an argument of
4729             <tt>stop</tt>, and the <tt>S</tt> links with an argument
4730             of <tt>start</tt>.
4731           </p>
4732
4733           <p>
4734             The two-digit number <var>mm</var> is used to determine
4735             the order in which to run the scripts: low-numbered links
4736             have their scripts run first.  For example, the
4737             <tt>K20</tt> scripts will be executed before the
4738             <tt>K30</tt> scripts.  This is used when a certain service
4739             must be started before another.  For example, the name
4740             server <prgn>bind</prgn> might need to be started before
4741             the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4742             can set up its access lists.  In this case, the script
4743             that starts <prgn>bind</prgn> would have a lower number
4744             than the script that starts <prgn>inn</prgn> so that it
4745             runs first:
4746             <example compact="compact">
4747 /etc/rc2.d/S17bind
4748 /etc/rc2.d/S70inn
4749             </example>
4750           </p>
4751
4752           <p>
4753             The two runlevels 0 (halt) and 6 (reboot) are slightly
4754             different.  In these runlevels, the links with an
4755             <tt>S</tt> prefix are still called after those with a
4756             <tt>K</tt> prefix, but they too are called with the single
4757             argument <tt>stop</tt>.
4758           </p>
4759
4760           <p>
4761             Also, if the script name ends <tt>.sh</tt>, the script
4762             will be sourced in runlevel <tt>S</tt> rather that being
4763             run in a forked subprocess, but will be explicitly run by
4764             <prgn>sh</prgn> in all other runlevels.
4765           </p>
4766         </sect1>
4767
4768         <sect1>
4769           <heading>Writing the scripts</heading>
4770
4771           <p>
4772             Packages that include daemons for system services should
4773             place scripts in <file>/etc/init.d</file> to start or stop
4774             services at boot time or during a change of runlevel.
4775             These scripts should be named
4776             <file>/etc/init.d/<var>package</var></file>, and they should
4777             accept one argument, saying what to do:
4778
4779             <taglist>
4780               <tag><tt>start</tt></tag>
4781               <item><p>start the service,</p></item>
4782
4783               <tag><tt>stop</tt></tag>
4784               <item><p>stop the service,</p></item>
4785
4786               <tag><tt>restart</tt></tag>
4787               <item><p>stop and restart the service if it's already
4788                   running, otherwise start the service</p></item>
4789
4790               <tag><tt>reload</tt></tag>
4791               <item><p>cause the configuration of the service to be
4792                   reloaded without actually stopping and restarting
4793                   the service,</p></item>
4794
4795               <tag><tt>force-reload</tt></tag>
4796               <item><p>cause the configuration to be reloaded if the
4797                   service supports this, otherwise restart the
4798                   service.</p></item>
4799             </taglist>
4800
4801             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4802             <tt>force-reload</tt> options should be supported by all
4803             scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4804             option is optional.</p>
4805
4806           <p>
4807             The <file>init.d</file> scripts should ensure that they will
4808             behave sensibly if invoked with <tt>start</tt> when the
4809             service is already running, or with <tt>stop</tt> when it
4810             isn't, and that they don't kill unfortunately-named user
4811             processes.  The best way to achieve this is usually to use
4812             <prgn>start-stop-daemon</prgn>.</p>
4813
4814           <p>
4815             If a service reloads its configuration automatically (as
4816             in the case of <prgn>cron</prgn>, for example), the
4817             <tt>reload</tt> option of the <file>init.d</file> script
4818             should behave as if the configuration has been reloaded
4819             successfully.</p>
4820
4821           <p>
4822             The <file>/etc/init.d</file> scripts must be treated as
4823             configuration files, either (if they are present in the
4824             package, that is, in the .deb file) by marking them as
4825             <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4826             by managing them correctly in the maintainer scripts (see
4827             <ref id="config-files">).  This is important since we want
4828             to give the local system administrator the chance to adapt
4829             the scripts to the local system, e.g., to disable a
4830             service without de-installing the package, or to specify
4831             some special command line options when starting a service,
4832             while making sure her changes aren't lost during the next
4833             package upgrade.
4834           </p>
4835
4836           <p>
4837             These scripts should not fail obscurely when the
4838             configuration files remain but the package has been
4839             removed, as configuration files remain on the system after
4840             the package has been removed.  Only when <prgn>dpkg</prgn>
4841             is executed with the <tt>--purge</tt> option will
4842             configuration files be removed.  In particular, as the
4843             <file>/etc/init.d/<var>package</var></file> script itself is
4844             usually a <tt>conffile</tt>, it will remain on the system
4845             if the package is removed but not purged.  Therefore, you
4846             should include a <tt>test</tt> statement at the top of the
4847             script, like this:
4848             <example compact="compact">
4849 test -f <var>program-executed-later-in-script</var> || exit 0
4850             </example>
4851           </p>
4852
4853           <p>
4854             Often there are some variables in the <file>init.d</file>
4855             scripts whose values control the behaviour of the scripts,
4856             and which a system administrator is likely to want to
4857             change.  As the scripts themselves are frequently
4858             <tt>conffile</tt>s, modifying them requires that the
4859             administrator merge in their changes each time the package
4860             is upgraded and the <tt>conffile</tt> changes.  To ease
4861             the burden on the system administrator, such configurable
4862             values should not be placed directly in the script.
4863             Instead, they should be placed in a file in
4864             <file>/etc/default</file>, which typically will have the same
4865             base name as the <file>init.d</file> script.  This extra file
4866             should be sourced by the script when the script runs.  It
4867             must contain only variable settings and comments in POSIX
4868             <prgn>sh</prgn> format.  It may either be a
4869             <tt>conffile</tt> or a configuration file maintained by
4870             the package maintainer scripts.  See <ref id="config-files">
4871             for more details.
4872           </p>
4873
4874           <p>
4875             To ensure that vital configurable values are always
4876             available, the <file>init.d</file> script should set default
4877             values for each of the shell variables it uses, either
4878             before sourcing the <file>/etc/default/</file> file or
4879             afterwards using something like the <tt>:
4880             ${VAR:=default}</tt> syntax.  Also, the <file>init.d</file>
4881             script must behave sensibly and not fail if the
4882             <file>/etc/default</file> file is deleted.
4883           </p>
4884         </sect1>
4885
4886         <sect1>
4887           <heading>Interfacing with the initscript system</heading>
4888
4889           <p>
4890             Maintainers should use the abstraction layer provided by
4891             the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4892             programs to deal with initscripts in their packages'
4893             scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4894             and <prgn>postrm</prgn>.
4895           </p>
4896           <p>
4897             Directly managing the /etc/rc?.d links and directly
4898             invoking the <file>/etc/init.d/</file> initscripts should
4899             be done only by packages providing the initscript
4900             subsystem (such as <prgn>sysvinit</prgn> and
4901             <prgn>file-rc</prgn>).
4902
4903           </p>
4904
4905           <sect2>
4906             <heading>Managing the links</heading>
4907
4908             <p>
4909               The program <prgn>update-rc.d</prgn> is provided for
4910               package maintainers to arrange for the proper creation and
4911               removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4912               or their functional equivalent if another method is being
4913               used.  This may be used by maintainers in their packages'
4914               <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4915
4916             <p>
4917               You must not include any <file>/etc/rc<var>n</var>.d</file>
4918               symbolic links in the actual archive or manually create or
4919               remove the symbolic links in maintainer scripts; you must
4920               use the <prgn>update-rc.d</prgn> program instead.  (The
4921               former will fail if an alternative method of maintaining
4922               runlevel information is being used.)  You must not include
4923               the <file>/etc/rc<var>n</var>.d</file> directories themselves
4924               in the archive either.  (Only the <tt>sysvinit</tt>
4925               package may do so.)
4926             </p>
4927
4928             <p>
4929               By default <prgn>update-rc.d</prgn> will start services in
4930               each of the multi-user state runlevels (2, 3, 4, and 5)
4931               and stop them in the halt runlevel (0), the single-user
4932               runlevel (1) and the reboot runlevel (6).  The system
4933               administrator will have the opportunity to customize
4934               runlevels by simply adding, moving, or removing the
4935               symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4936               symbolic links are being used, or by modifying
4937               <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4938               is being used.
4939             </p>
4940
4941             <p>
4942               To get the default behavior for your package, put in your
4943               <prgn>postinst</prgn> script
4944               <example compact="compact">
4945                 update-rc.d <var>package</var> defaults
4946               </example>
4947               and in your <prgn>postrm</prgn>
4948               <example compact="compact">
4949                 if [ "$1" = purge ]; then
4950                 update-rc.d <var>package</var> remove
4951                 fi
4952               </example>. Note that if your package changes runlevels
4953               or priority, you may have to remove and recreate the links,
4954               since otherwise the old links may persist. Refer to the
4955               documentation of <prgn>update-rc.d</prgn></p>
4956
4957             <p>
4958               This will use a default sequence number of 20.  If it does
4959               not matter when or in which order the <file>init.d</file>
4960               script is run, use this default.  If it does, then you
4961               should talk to the maintainer of the <prgn>sysvinit</prgn>
4962               package or post to <tt>debian-devel</tt>, and they will
4963               help you choose a number.
4964             </p>
4965
4966             <p>
4967               For more information about using <tt>update-rc.d</tt>,
4968               please consult its manpage <manref name="update-rc.d"
4969                 section="8">.
4970             </p>
4971           </sect2>
4972
4973           <sect2>
4974             <heading>Running initscripts</heading>
4975             <p>
4976               The program <prgn>invoke-rc.d</prgn> is provided to make
4977               it easier for package maintainers to properly invoke an
4978               initscript, obeying runlevel and other locally-defined
4979               constraints that might limit a package's right to start,
4980               stop and otherwise manage services. This program may be
4981               used by maintainers in their packages' scripts.
4982             </p>
4983             <p>
4984               The use of <prgn>invoke-rc.d</prgn> to invoke the
4985               <file>/etc/init.d/*</file> initscripts is strongly
4986               recommended<footnote>
4987                 <p>
4988                   In the future, the use of invoke-rc.d to invoke
4989                   initscripts shall be made mandatory. Maintainers are
4990                   advised to switch to invoke-rc.d as soon as
4991                   possible.</p>
4992               </footnote>, instead of calling them directly.
4993             </p>
4994
4995             <p>
4996               By default, <prgn>invoke-rc.d</prgn> will pass any
4997               action requests (start, stop, reload, restart...) to the
4998               <file>/etc/init.d</file> script, filtering out requests
4999               to start or restart a service out of its intended
5000               runlevels.
5001             </p>
5002             <p>
5003               Most packages will simply need to change:
5004               <example compact="compact">/etc/init.d/&lt;package&gt;
5005               &lt;action&gt;</example> in their <prgn>postinst</prgn>
5006               and <prgn>prerm</prgn> scripts to:
5007               <example compact="compact">
5008           if [ -x /usr/sbin/invoke-rc.d ] ; then
5009                 invoke-rc.d <var>package</var> &lt;action&gt;
5010           else
5011              /etc/init.d/<var>package</var> &lt;action&gt;
5012           fi
5013               </example></p>
5014             <p>
5015               A package should register its initscript services using
5016               <prgn>update-rc.d</prgn> before it tries to invoke them
5017               using <prgn>invoke-rc.d</prgn>. Invocation of
5018               unregistered services may fail.
5019             </p>
5020             <p>
5021               For more information about using
5022               <prgn>invoke-rc.d</prgn>, please consult its manpage
5023               <manref name="invoke-rc.d" section="8">.
5024             </p>
5025           </sect2>
5026         </sect1>
5027
5028
5029         <sect1>
5030           <heading>Boot-time initialization</heading>
5031
5032           <p>
5033             There used to be another directory, <file>/etc/rc.boot</file>,
5034             which contained scripts which were run once per machine
5035             boot. This has been deprecated in favour of links from
5036             <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
5037             described in <ref id="/etc/init.d">.  Packages must not
5038             place files in <file>/etc/rc.boot</file>.</p>
5039
5040         <sect1>
5041           <heading>Example</heading>
5042
5043           <p>
5044             The <prgn>bind</prgn> DNS (nameserver) package wants to
5045             make sure that the nameserver is running in multiuser
5046             runlevels, and is properly shut down with the system.  It
5047             puts a script in <file>/etc/init.d</file>, naming the script
5048             appropriately <tt>bind</tt>.  As you can see, the script
5049             interprets the argument <tt>reload</tt> to send the
5050             nameserver a <tt>HUP</tt> signal (causing it to reload its
5051             configuration); this way the system administrator can say
5052             <tt>/etc/init.d/bind reload</tt> to reload the name
5053             server.  The script has one configurable value, which can
5054             be used to pass parameters to the named program at
5055             startup; this value is read from
5056             <file>/etc/default/bind</file> (see below).
5057           </p>
5058
5059           <p>
5060             <example compact="compact">
5061 #!/bin/sh
5062 #
5063 # Original version by Robert Leslie
5064 # &lt;rob@mars.org&gt;, edited by iwj and cs
5065
5066 test -x /usr/sbin/named || exit 0
5067
5068 # Source defaults file.
5069 PARAMS=''
5070 if [ -f /etc/default/bind ]; then
5071   . /etc/default/bind
5072 fi
5073
5074
5075 case "$1" in
5076 start)
5077   echo -n "Starting domain name service: named"
5078   start-stop-daemon --start --quiet --exec /usr/sbin/named \
5079                     -- $PARAMS
5080   echo "."
5081   ;;
5082 stop)
5083   echo -n "Stopping domain name service: named"
5084   start-stop-daemon --stop --quiet  \
5085     --pidfile /var/run/named.pid --exec /usr/sbin/named
5086   echo "."
5087   ;;
5088 restart)
5089   echo -n "Restarting domain name service: named"
5090   start-stop-daemon --stop --quiet  \
5091     --pidfile /var/run/named.pid --exec /usr/sbin/named
5092   start-stop-daemon --start --verbose --exec /usr/sbin/named \
5093                     -- $PARAMS
5094   echo "."
5095   ;;
5096 force-reload|reload)
5097   echo -n "Reloading configuration of domain name service: named"
5098   start-stop-daemon --stop --signal 1 --quiet  \
5099     --pidfile /var/run/named.pid --exec /usr/sbin/named
5100   echo "."
5101   ;;
5102 *)
5103   echo "Usage: /etc/init.d/bind " \
5104          " {start|stop|restart|reload|force-reload}" >&2
5105   exit 1
5106   ;;
5107 esac
5108
5109 exit 0
5110             </example>
5111           </p>
5112
5113           <p>
5114             Complementing the above init script is a configuration
5115             file <file>/etc/default/bind</file>, which contains
5116             configurable parameters used by the script.  This would be
5117             created by the <prgn>postinst</prgn> script if it was not
5118             already present, and removed on purge by the
5119             <prgn>postrm</prgn> script.
5120             <example compact="compact">
5121 # Specified parameters to pass to named. See named(8).
5122 # You may uncomment the following line, and edit to taste.
5123 #PARAMS="-u nobody"
5124             </example>
5125           </p>
5126
5127           <p>
5128             Another example on which you can base your
5129             <file>/etc/init.d</file> scripts is found in
5130             <file>/etc/init.d/skeleton</file>.
5131           </p>
5132
5133           <p>
5134             If this package is happy with the default setup from
5135             <prgn>update-rc.d</prgn>, namely an ordering number of 20
5136             and having named running in all runlevels, it can say in
5137             its <prgn>postinst</prgn>:
5138             <example compact="compact">
5139 update-rc.d bind defaults >/dev/null
5140             </example>
5141             And in its <prgn>postrm</prgn>, to remove the links when the
5142             package is purged:
5143             <example compact="compact">
5144 if [ "$1" = purge ]; then
5145   update-rc.d bind remove >/dev/null
5146 fi
5147             </example>
5148           </p>
5149         </sect1>
5150       </sect>
5151
5152       <sect>
5153         <heading>Console messages from <file>init.d</file> scripts</heading>
5154
5155         <p>
5156           This section describes the formats to be used for messages
5157           written to standard output by the <file>/etc/init.d</file>
5158           scripts.  The intent is to improve the consistency of
5159           Debian's startup and shutdown look and feel.  For this
5160           reason, please look very carefully at the details.  We want
5161           the messages to have the same format in terms of wording,
5162           spaces, punctuation and case of letters.
5163         </p>
5164
5165         <p>
5166           Here is a list of overall rules that you should use when you
5167           create output messages.  They can be useful if you have a
5168           non-standard message that is not covered specifically in the
5169           sections below.
5170         </p>
5171
5172         <p>
5173           <list>
5174             <item>
5175               <p>
5176                 Every message should fit in one line (fewer than 80
5177                 characters), start with a capital letter and end with
5178                 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5179               </p>
5180             </item>
5181
5182             <item>
5183               <p>
5184                 If you want to express that the computer is working on
5185                 something (that is, performing a specific task, not
5186                 starting or stopping a program), we use an "ellipsis"
5187                 (three dots: <tt>...</tt>).  Note that we don't insert
5188                 spaces before or after the dots.  If the task has been
5189                 completed we write <tt>done.</tt> and a line feed.
5190               </p>
5191             </item>
5192
5193             <item>
5194               <p>
5195                 Design your messages as if the computer is telling you
5196                 what he is doing (let him be polite :-), but don't
5197                 mention "him" directly.  For example, if you think of
5198                 saying
5199                 <example compact="compact">
5200 I'm starting network daemons: nfsd mountd.
5201                 </example>
5202                 just say
5203                 <example compact="compact">
5204 Starting network daemons: nfsd mountd.
5205                 </example>
5206               </p>
5207             </item>
5208           </list>
5209         </p>
5210
5211         <p>
5212           There are standard message formats for the following
5213           situations.  They should be used by the <tt>init.d</tt>
5214           scripts.
5215         </p>
5216
5217         <p>
5218           <list>
5219             <item>
5220               <p>When daemons are started</p>
5221
5222               <p>
5223                 If your script starts one or more daemons, the output
5224                 should look like this (a single line, no leading
5225                 spaces):
5226                 <example compact="compact">
5227 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5228                 </example>
5229                 The <var>description</var> should describe the
5230                 subsystem the daemon or set of daemons are part of,
5231                 while <var>daemon-1</var> up to <var>daemon-n</var>
5232                 denote each daemon's name (typically the file name of
5233                 the program).
5234               </p>
5235
5236               <p>
5237                 For example, the output of <file>/etc/init.d/lpd</file>
5238                 would look like:
5239                 <example compact="compact">
5240 Starting printer spooler: lpd.
5241                 </example>
5242               </p>
5243
5244               <p>
5245                 This can be achieved by saying
5246                 <example compact="compact">
5247 echo -n "Starting printer spooler: lpd"
5248 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5249 echo "."
5250                 </example>
5251                 in the script. If you have more than one daemon to
5252                 start, you should do the following:
5253                 <example compact="compact">
5254 echo -n "Starting remote file system services:"
5255 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5256 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5257 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5258 echo "."
5259                 </example>
5260                 This makes it possible for the user to see what takes
5261                 so long and when the final daemon has been started.
5262                 You should be careful where to put spaces: in the
5263                 example above the system administrator can easily
5264                 comment out a line if he don't wants to start a
5265                 specific daemon, while the displayed message still
5266                 looks good.
5267               </p>
5268             </item>
5269
5270             <item>
5271               <p>When a system parameter is being set</p>
5272
5273               <p>
5274                 If you have to set up different system parameters
5275                 during the system boot, you should use this format:
5276                 <example compact="compact">
5277 Setting <var>parameter</var> to "<var>value</var>".
5278                 </example>
5279               </p>
5280
5281               <p>
5282                 You can use a statement such as the following to get
5283                 the quotes right:
5284                 <example compact="compact">
5285 echo "Setting DNS domainname to \"$domainname\"."
5286                 </example>
5287               </p>
5288
5289               <p>
5290                 Note that the same symbol (<tt>"</tt>) is used for the left
5291                 and right quotation marks.  A grave accent (<tt>`</tt>) is
5292                 not a quote character; neither is an apostrophe
5293                 (<tt>'</tt>).
5294               </p>
5295             </item>
5296
5297             <item>
5298               <p>When a daemon is stopped or restarted</p>
5299
5300               <p>
5301                 When you stop or restart a daemon, you should issue a
5302                 message identical to the startup message, except that
5303                 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5304                 or <tt>Restarting</tt> respectively.
5305               </p>
5306
5307               <p>
5308                 For example, stopping the printer daemon will like
5309                 like this:
5310                 <example compact="compact">
5311 Stopping printer spooler: lpd.
5312                 </example>
5313               </p>
5314             </item>
5315
5316             <item>
5317               <p>When something is executed</p>
5318
5319               <p>
5320                 There are several examples where you have to run a
5321                 program at system startup or shutdown to perform a
5322                 specific task, for example, setting the system's clock
5323                 using <prgn>netdate</prgn> or killing all processes
5324                 when the system shuts down.  Your message should look
5325                 like this:
5326                 <example compact="compact">
5327 Doing something very useful...done.
5328                 </example>
5329                 You should print the <tt>done.</tt> immediately after
5330                 the job has been completed, so that the user is
5331                 informed why she has to wait.  You can get this
5332                 behavior by saying
5333                 <example compact="compact">
5334 echo -n "Doing something very useful..."
5335 do_something
5336 echo "done."
5337                 </example>
5338                 in your script.
5339               </p>
5340             </item>
5341
5342             <item>
5343               <p>When the configuration is reloaded</p>
5344
5345               <p>
5346                 When a daemon is forced to reload its configuration
5347                 files you should use the following format:
5348                 <example compact="compact">
5349 Reloading <var>description</var> configuration...done.
5350                 </example>
5351                 where <var>description</var> is the same as in the
5352                 daemon starting message.
5353               </p>
5354             </item>
5355           </list>
5356         </p>
5357       </sect>
5358
5359       <sect>
5360         <heading>Cron jobs</heading>
5361
5362         <p>
5363           Packages must not modify the configuration file
5364           <file>/etc/crontab</file>, and they must not modify the files in
5365           <file>/var/spool/cron/crontabs</file>.</p>
5366
5367         <p>
5368           If a package wants to install a job that has to be executed
5369           via cron, it should place a file with the name of the
5370           package in one or more of the following directories:
5371           <example compact="compact">
5372 /etc/cron.daily
5373 /etc/cron.weekly
5374 /etc/cron.monthly
5375           </example>
5376           As these directory names imply, the files within them are
5377           executed on a daily, weekly, or monthly basis,
5378           respectively. The exact times are listed in
5379           <file>/etc/crontab</file>.</p>
5380
5381         <p>
5382           All files installed in any of these directories must be
5383           scripts (e.g., shell scripts or Perl scripts) so that they
5384           can easily be modified by the local system administrator.
5385           In addition, they should be treated as configuration
5386           files.
5387         </p>
5388
5389         <p>
5390           If a certain job has to be executed more frequently than
5391           daily, the package should install a file
5392           <file>/etc/cron.d/<var>package</var></file>. This file uses the
5393           same syntax as <file>/etc/crontab</file> and is processed by
5394           <prgn>cron</prgn> automatically. The file must also be
5395           treated as a configuration file. (Note that entries in the
5396           <file>/etc/cron.d</file> directory are not handled by
5397           <prgn>anacron</prgn>. Thus, you should only use this
5398           directory for jobs which may be skipped if the system is not
5399           running.)</p>
5400
5401         <p>
5402           The scripts or crontab entries in these directories should
5403           check if all necessary programs are installed before they
5404           try to execute them. Otherwise, problems will arise when a
5405           package was removed but not purged since configuration files
5406           are kept on the system in this situation.</p>
5407       </sect>
5408
5409       <sect>
5410         <heading>Menus</heading>
5411
5412         <p>
5413           The Debian <tt>menu</tt> package provides a standard
5414           interface between packages providing applications and
5415           documents, and <em>menu programs</em> (either X window
5416           managers or text-based menu programs such as
5417           <prgn>pdmenu</prgn>).
5418         </p>
5419
5420         <p>
5421           All packages that provide applications that need not be
5422           passed any special command line arguments for normal
5423           operation should register a menu entry for those
5424           applications, so that users of the <tt>menu</tt> package
5425           will automatically get menu entries in their window
5426           managers, as well in shells like <tt>pdmenu</tt>.
5427         </p>
5428
5429         <p>
5430           Menu entries should follow the current menu policy.
5431         </p>
5432
5433         <p>
5434           The menu policy can be found in the <tt>menu-policy</tt>
5435           files in the <tt>debian-policy</tt> package.
5436           They are also available from the Debian web mirrors at
5437           <tt><url name="/doc/packaging-manuals/menu-policy/"
5438                 id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>
5439           and from the Debian archive mirrors at
5440           <tt><url name="/doc/package-developer/menu-policy.txt.gz"
5441                 id="http://ftp.debian.org/debian/doc/package-developer/menu-policy.txt.gz"></tt>.
5442         </p>
5443
5444         <p>
5445           Please also refer to the <em>Debian Menu System</em>
5446           documentation that comes with the <tt>menu</tt> package for
5447           information about how to register your applications and web
5448           documents.
5449         </p>
5450       </sect>
5451
5452       <sect>
5453         <heading>Multimedia handlers</heading>
5454
5455         <p>
5456           MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5457           is a mechanism for encoding files and data streams and
5458           providing meta-information about them, in particular their
5459           type (e.g.  audio or video) and format (e.g. PNG, HTML,
5460           MP3).
5461         </p>
5462
5463         <p>
5464           Registration of MIME type handlers allows programs like mail
5465           user agents and web browsers to to invoke these handlers to
5466           view, edit or display MIME types they don't support
5467           directly.
5468         </p>
5469
5470         <p>
5471           Packages which provide the ability to view/show/play,
5472           compose, edit or print MIME types should register themselves
5473           as such following the current MIME support policy.
5474         </p>
5475
5476         <p>
5477           The MIME support policy can be found in the <tt>mime-policy</tt>
5478           files in the <tt>debian-policy</tt> package.
5479           They are also available from the Debian web mirrors at
5480           <tt><url name="/doc/packaging-manuals/mime-policy/"
5481                 id="http://www.debian.org/doc/packaging-manuals/mime-policy/"></tt>
5482           and from the Debian archive mirrors at
5483           <tt><url name="/doc/package-developer/mime-policy.txt.gz"
5484                 id="http://ftp.debian.org/debian/doc/package-developer/mime-policy.txt.gz"></tt>.
5485         </p>
5486
5487       </sect>
5488
5489       <sect>
5490         <heading>Keyboard configuration</heading>
5491
5492         <p>
5493           To achieve a consistent keyboard configuration so that all
5494           applications interpret a keyboard event the same way, all
5495           programs in the Debian distribution must be configured to
5496           comply with the following guidelines.
5497         </p>
5498
5499         <p>
5500           The following keys must have the specified interpretations:
5501
5502           <taglist>
5503             <tag><tt>&lt;--</tt></tag>
5504             <item><p>delete the character to the left of the cursor</p></item>
5505
5506             <tag><tt>Delete</tt></tag>
5507             <item><p>delete the character to the right of the cursor</p></item>
5508
5509             <tag><tt>Control+H</tt></tag>
5510             <item><p>emacs: the help prefix</p></item>
5511           </taglist>
5512
5513           The interpretation of any keyboard events should be
5514           independent of the terminal that is used, be it a virtual
5515           console, an X terminal emulator, an rlogin/telnet session,
5516           etc.
5517         </p>
5518
5519         <p>
5520           The following list explains how the different programs
5521           should be set up to achieve this:
5522         </p>
5523
5524         <p>
5525           <list>
5526             <item><p><tt>&lt;--</tt> generates <tt>KB_BackSpace</tt>
5527                 in X.</p></item>
5528
5529             <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5530                 X.</p></item>
5531
5532             <item>
5533               <p>
5534                 X translations are set up to make
5535                 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5536                 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5537                 is the vt220 escape code for the "delete character"
5538                 key).  This must be done by loading the X resources
5539                 using <prgn>xrdb</prgn> on all local X displays, not
5540                 using the application defaults, so that the
5541                 translation resources used correspond to the
5542                 <prgn>xmodmap</prgn> settings.</p></item>
5543
5544             <item>
5545               <p>
5546                 The Linux console is configured to make
5547                 <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
5548                 generate <tt>ESC [ 3 ~</tt>.</p></item>
5549
5550             <item>
5551               <p>
5552                 X applications are configured so that <tt>&lt;</tt>
5553                 deletes left, and <tt>Delete</tt> deletes right.  Motif
5554                 applications already work like this.</p></item>
5555
5556             <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5557
5558             <item>
5559               <p>
5560                 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5561                 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5562                 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5563
5564             <item>
5565               <p>
5566                 Emacs is programmed to map <tt>KB_Backspace</tt> or
5567                 the <tt>stty erase</tt> character to
5568                 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5569                 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5570                 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5571
5572             <item>
5573               <p>
5574                 Other applications use the <tt>stty erase</tt>
5575                 character and <tt>kdch1</tt> for the two delete keys,
5576                 with ASCII DEL being "delete previous character" and
5577                 <tt>kdch1</tt> being "delete character under
5578                 cursor".</p></item>
5579
5580           </list>
5581         </p>
5582
5583         <p>
5584           This will solve the problem except for the following
5585           cases:
5586         </p>
5587
5588         <p>
5589           <list>
5590             <item>
5591               <p>
5592                 Some terminals have a <tt>&lt;--</tt> key that cannot
5593                 be made to produce anything except <tt>^H</tt>.  On
5594                 these terminals Emacs help will be unavailable on
5595                 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5596                 character takes precedence in Emacs, and has been set
5597                 correctly).  <tt>M-x help</tt> or <tt>F1</tt> (if
5598                 available) can be used instead.</p></item>
5599
5600             <item>
5601               <p>
5602                 Some operating systems use <tt>^H</tt> for <tt>stty
5603                 erase</tt>.  However, modern telnet versions and all
5604                 rlogin versions propagate <tt>stty</tt> settings, and
5605                 almost all UNIX versions honour <tt>stty erase</tt>.
5606                 Where the <tt>stty</tt> settings are not propagated
5607                 correctly, things can be made to work by using
5608                 <tt>stty</tt> manually.</p></item>
5609
5610             <item>
5611               <p>
5612                 Some systems (including previous Debian versions) use
5613                 <prgn>xmodmap</prgn> to arrange for both
5614                 <tt>&lt;--</tt> and <tt>Delete</tt> to generate
5615                 <tt>KB_Delete</tt>.  We can change the behavior of
5616                 their X clients using the same X resources that we use
5617                 to do it for our own clients, or configure our clients
5618                 using their resources when things are the other way
5619                 around.  On displays configured like this
5620                 <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
5621                 will.</p></item>
5622
5623             <item>
5624               <p>
5625                 Some operating systems have different <tt>kdch1</tt>
5626                 settings in their <tt>terminfo</tt> database for
5627                 <tt>xterm</tt> and others.  On these systems the
5628                 <tt>Delete</tt> key will not work correctly when you
5629                 log in from a system conforming to our policy, but
5630                 <tt>&lt;--</tt> will.</p></item>
5631           </list>
5632         </p>
5633       </sect>
5634
5635       <sect>
5636         <heading>Environment variables</heading>
5637
5638         <p>
5639           A program must not depend on environment variables to get
5640           reasonable defaults.  (That's because these environment
5641           variables would have to be set in a system-wide
5642           configuration file like <file>/etc/profile</file>, which is not
5643           supported by all shells.)</p>
5644
5645         <p>
5646           If a program usually depends on environment variables for its
5647           configuration, the program should be changed to fall back to
5648           a reasonable default configuration if these environment
5649           variables are not present. If this cannot be done easily
5650           (e.g., if the source code of a non-free program is not
5651           available), the program must be replaced by a small
5652           "wrapper" shell script which sets the environment variables
5653           if they are not already defined, and calls the original program.</p>
5654
5655         <p>
5656           Here is an example of a wrapper script for this purpose:
5657
5658           <example compact="compact">
5659 #!/bin/sh
5660 BAR=${BAR:-/var/lib/fubar}
5661 export BAR
5662 exec /usr/lib/foo/foo "$@"
5663           </example>
5664         </p>
5665
5666         <p>
5667           Furthermore, as <file>/etc/profile</file> is a configuration
5668           file of the <prgn>base-files</prgn> package, other packages must not
5669           put any environment variables or other commands into that
5670           file.</p>
5671       </sect>
5672     </chapt>
5673
5674     <chapt id="files">
5675       <heading>Files</heading>
5676
5677       <sect>
5678         <heading>Binaries</heading>
5679
5680         <p>
5681           Two different packages must not install programs with
5682           different functionality but with the same filenames.  (The
5683           case of two programs having the same functionality but
5684           different implementations is handled via "alternatives" or
5685           the "Conflicts" mechanism.  See <ref id="maintscripts"> and
5686           <ref id="conflicts"> respectively.)  If this case happens,
5687           one of the programs must be renamed.  The maintainers should
5688           report this to the <tt>debian-devel</tt> mailing list and
5689           try to find a consensus about which program will have to be
5690           renamed.  If a consensus cannot be reached, <em>both</em>
5691           programs must be renamed.
5692         </p>
5693
5694         <p>
5695          By default, when a package is being built, any binaries
5696          created should include debugging information, as well as
5697          being compiled with optimization.  You should also turn on
5698          as many reasonable compilation warnings as possible; this
5699          makes life easier for porters, who can then look at build
5700          logs for possible problems.  For the C programming language,
5701          this means the following compilation parameters should be
5702          used:
5703           <example compact="compact">
5704 CC = gcc
5705 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5706 LDFLAGS = # none
5707 install -s # (or use strip on the files in debian/tmp)
5708           </example>
5709         </p>
5710
5711         <p>
5712           Note that by default all installed binaries should be stripped,
5713           either by using the <tt>-s</tt> flag to
5714           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5715           the binaries after they have been copied into
5716           <file>debian/tmp</file> but before the tree is made into a
5717           package.</p>
5718
5719         <p>
5720           Although binaries in the build tree should be compiled with
5721           debugging information by default, it can often be difficult
5722           to debug programs if they are also subjected to compiler
5723           optimization.  For this reason, it is recommended to support
5724           the standardized environment
5725           variable <tt>DEB_BUILD_OPTIONS</tt>.  This variable can
5726           contain several flags to change how a package is compiled
5727           and built.
5728         </p>
5729         <p>
5730           <taglist>
5731             <tag>noopt</tag>
5732             <item>
5733               <p>
5734                 The presence of this string means that the package
5735                 should be complied with a minimum of optimization.
5736                 For C programs, it is best to add <tt>-O0</tt>
5737                 to <tt>CFLAGS</tt> (although this is usually the
5738                 default).  Some programs might fail to build or run at
5739                 this level of optimization; it may be necessary to
5740                 use <tt>-O1</tt>, for example.
5741               </p>
5742             </item>
5743             <tag>nostrip</tag>
5744             <item>
5745               <p>
5746                 This string means that the debugging symbols should
5747                 not be stripped from the binary during installation,
5748                 so that debugging information may be included in the package.
5749               </p>
5750             </item>
5751           </taglist>
5752         </p>
5753         <p>
5754           The following makefile snippet is an example of how one may
5755           implement the build options; you will probably have to
5756           massage this example in order to make it work for your
5757           package.
5758           <example compact="compact">
5759 CFLAGS = -Wall -g
5760 INSTALL = install
5761 INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
5762 INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
5763 INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
5764 INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
5765
5766 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5767 CFLAGS += -O0
5768 else
5769 CFLAGS += -O2
5770 endif
5771 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5772 INSTALL_PROGRAM += -s
5773 endif
5774           </example>
5775         </p>
5776
5777         <p>
5778           It is up to the package maintainer to decide what
5779           compilation options are best for the package.  Certain
5780           binaries (such as computationally-intensive programs) will
5781           function better with certain flags (<tt>-O3</tt>, for
5782           example); feel free to use them.  Please use good judgment
5783           here.  Don't use flags for the sake of it; only use them
5784           if there is good reason to do so.  Feel free to override
5785           the upstream author's ideas about which compilation
5786           options are best: they are often inappropriate for our
5787           environment.
5788         </p>
5789       </sect>
5790
5791
5792       <sect id="libraries">
5793         <heading>Libraries</heading>
5794
5795         <p>
5796           The shared version of a library must be compiled with
5797           <tt>-fPIC</tt>, and the static version must not be. In other
5798           words, each source unit (<tt>*.c</tt>, for example, for C files)
5799           will need to be compiled twice.
5800         </p>
5801
5802
5803         <p>
5804           You must specify the gcc option <tt>-D_REENTRANT</tt>
5805           when building a library (either static or shared) to make
5806           the library compatible with LinuxThreads.
5807         </p>
5808
5809         <p>
5810           All installed shared libraries should be stripped with
5811           <example compact="compact">
5812 strip --strip-unneeded <var>your-lib</var>
5813           </example>
5814           (The option <tt>--strip-unneeded</tt> makes
5815           <prgn>strip</prgn> remove only the symbols which aren't
5816           needed for relocation processing.)  Shared libraries can
5817           function perfectly well when stripped, since the symbols for
5818           dynamic linking are in a separate part of the ELF object
5819           file.<footnote>
5820             <p>
5821               You might also want to use the options
5822               <tt>--remove-section=.comment</tt> and
5823               <tt>--remove-section=.note</tt> on both shared libraries
5824               and executables, and <tt>--strip-debug</tt> on static
5825               libraries.
5826             </p>
5827           </footnote>
5828         </p>
5829
5830         <p>
5831           Note that under some circumstances it may be useful to
5832           install a shared library unstripped, for example when
5833           building a separate package to support debugging.
5834         </p>
5835
5836         <p>
5837           Shared object files (often <file>.so</file> files) that are not
5838           public libraries, that is, they are not meant to be linked
5839           to by third party executables (binaries of other packages),
5840           should be installed in subdirectories of the
5841           <file>/usr/lib</file> directory.  Such files are exempt from the
5842           rules that govern ordinary shared libraries, except that
5843           they must not be installed executable and should be
5844           stripped.<footnote>
5845             <p>
5846               A common example are the so-called "plug-ins",
5847               internal shared objects that are dynamically loaded by
5848               programs using <manref name="dlopen" section="3">.
5849             </p>
5850           </footnote>
5851         </p>
5852
5853         <p>
5854           Packages containing shared libraries that may be linked to
5855           by other packages' binaries, but which for some
5856           <em>compelling</em> reason can not be installed in
5857           <file>/usr/lib</file> directory, may install the shared library
5858           files in subdirectories of the <file>/usr/lib</file> directory,
5859           in which case they should arrange to add that directory in
5860           <file>/etc/ld.so.conf</file> in the package's post-installation
5861           script, and remove it in the package's post-removal script.
5862         </p>
5863
5864         <p>
5865           An ever increasing number of packages are using
5866           <prgn>libtool</prgn> to do their linking.  The latest GNU
5867           libtools (>= 1.3a) can take advantage of the metadata in the
5868           installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5869           files).  The main advantage of <prgn>libtool</prgn>'s
5870           <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5871           store and subsequently access metadata with respect to the
5872           libraries it builds.  <prgn>libtool</prgn> will search for
5873           those files, which contain a lot of useful information about
5874           a library (such as library dependency information for static
5875           linking).  Also, they're <em>essential</em> for programs
5876           using <tt>libltdl</tt>.<footnote>
5877             <p>
5878               Although <prgn>libtool</prgn> is fully capable of
5879               linking against shared libraries which don't have
5880               <tt>.la</tt> files, as it is a mere shell script it can
5881               add considerably to the build time of a
5882               <prgn>libtool</prgn>-using package if that shell script
5883               has to derive all this information from first principles
5884               for each library every time it is linked.  With the
5885               advent of <prgn>libtool</prgn> version 1.4 (and to a
5886               lesser extent <prgn>libtool</prgn> version 1.3), the
5887               <file>.la</file> files also store information about
5888               inter-library dependencies which cannot necessarily be
5889               derived after the <file>.la</file> file is deleted.
5890             </p>
5891           </footnote>
5892         </p>
5893
5894         <p>
5895           Packages that use <prgn>libtool</prgn> to create shared
5896           libraries should include the <file>.la</file> files in the
5897           <tt>-dev</tt> package, unless the package relies on
5898           <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5899           the <tt>.la</tt> files must go in the run-time library
5900           package.
5901         </p>
5902
5903         <p>
5904           You must make sure that you use only released versions of
5905           shared libraries to build your packages; otherwise other
5906           users will not be able to run your binaries
5907           properly. Producing source packages that depend on
5908           unreleased compilers is also usually a bad
5909           idea.
5910         </p>
5911       </sect>
5912
5913
5914       <sect>
5915         <heading>Shared libraries</heading>
5916         <p>
5917           This section has moved to <ref id="sharedlibs">.
5918         </p>
5919       </sect>
5920
5921
5922       <sect id="scripts">
5923         <heading>Scripts</heading>
5924
5925         <p>
5926           All command scripts, including the package maintainer
5927           scripts inside the package and used by <prgn>dpkg</prgn>,
5928           should have a <tt>#!</tt> line naming the shell to be used
5929           to interpret them.</p>
5930
5931         <p>
5932           In the case of Perl scripts this should be
5933           <tt>#!/usr/bin/perl</tt>.</p>
5934
5935         <p>
5936           Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5937           should almost certainly start with <tt>set -e</tt> so that
5938           errors are detected.  Every script should use
5939           <tt>set -e</tt> or check the exit status of <em>every</em>
5940           command.</p>
5941
5942         <p>
5943           The standard shell interpreter <file>/bin/sh</file> can be a
5944           symbolic link to any POSIX compatible shell, if <tt>echo
5945           -n</tt> does not generate a newline.<footnote>
5946             <p>
5947               Debian policy specifies POSIX behavior for
5948               <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5949               use in the Linux community (in particular including this
5950               policy, the Linux kernel source, many Debian scripts,
5951               etc.).  This <tt>echo -n</tt> mechanism is valid but not
5952               required under POSIX, hence this explicit addition.
5953               Also, rumour has it that this shall be mandated under
5954               the LSB anyway.
5955             </p>
5956           </footnote>
5957           Thus, shell scripts specifying <file>/bin/sh</file> as
5958           interpreter should only use POSIX features. If a script
5959           requires non-POSIX features from the shell interpreter, the
5960           appropriate shell must be specified in the first line of the
5961           script (e.g., <tt>#!/bin/bash</tt>) and the package must
5962           depend on the package providing the shell (unless the shell
5963           package is marked "Essential", as in the case of
5964           <prgn>bash</prgn>).
5965         </p>
5966
5967         <p>
5968           You may wish to restrict your script to POSIX features when
5969           possible so that it may use <file>/bin/sh</file> as its
5970           interpreter. If your script works with <prgn>dash</prgn>
5971           (originally called <prgn>ash</prgn>), it's probably POSIX
5972           compliant, but if you are in doubt, use
5973           <file>/bin/bash</file>.
5974         </p>
5975
5976         <p>
5977           Perl scripts should check for errors when making any
5978           system calls, including <tt>open</tt>, <tt>print</tt>,
5979           <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5980         </p>
5981
5982         <p>
5983           <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5984           scripting languages.  See <em>Csh Programming Considered
5985           Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5986           can be found at <url
5987           id="http://language.perl.com/versus/csh.whynot">.<footnote>
5988             <p>
5989               It can also be found on
5990               <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5991               or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5992               <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5993               </p>
5994           </footnote>
5995           If an upstream package comes with <prgn>csh</prgn> scripts
5996           then you must make sure that they start with
5997           <tt>#!/bin/csh</tt> and make your package depend on the
5998           <prgn>c-shell</prgn> virtual package.
5999         </p>
6000
6001         <p>
6002           Any scripts which create files in world-writeable
6003           directories (e.g., in <file>/tmp</file>) must use a
6004           mechanism which will fail if a file with the same name
6005           already exists.</p>
6006
6007         <p>
6008           The Debian base system provides the <prgn>tempfile</prgn>
6009           and <prgn>mktemp</prgn> utilities for use by scripts for
6010           this purpose.</p></sect>
6011
6012
6013       <sect>
6014         <heading>Symbolic links</heading>
6015
6016         <p>
6017           In general, symbolic links within a top-level directory
6018           should be relative, and symbolic links pointing from one
6019           top-level directory into another should be absolute. (A
6020           top-level directory is a sub-directory of the root
6021           directory <file>/</file>.)</p>
6022
6023         <p>
6024           In addition, symbolic links should be specified as short as
6025           possible, i.e., link targets like <file>foo/../bar</file> are
6026           deprecated.</p>
6027
6028         <p>
6029           Note that when creating a relative link using
6030           <prgn>ln</prgn> it is not necessary for the target of the
6031           link to exist relative to the working directory you're
6032           running <prgn>ln</prgn> from, nor is it necessary to change
6033           directory to the directory where the link is to be made.
6034           Simply include the string that should appear as the target
6035           of the link (this will be a pathname relative to the
6036           directory in which the link resides) as the first argument
6037           to <prgn>ln</prgn>.</p>
6038
6039         <p>
6040           For example, in your <prgn>Makefile</prgn> or
6041           <file>debian/rules</file>, you can do things like:
6042           <example compact="compact">
6043 ln -fs gcc $(prefix)/bin/cc
6044 ln -fs gcc debian/tmp/usr/bin/cc
6045 ln -fs ../sbin/sendmail $(prefix)/bin/runq
6046 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
6047           </example></p>
6048
6049         <p>
6050           A symbolic link pointing to a compressed file should always
6051           have the same file extension as the referenced file. (For
6052           example, if a file <file>foo.gz</file> is referenced by a
6053           symbolic link, the filename of the link has to end with
6054           "<file>.gz</file>" too, as in <file>bar.gz</file>.)
6055         </p>
6056       </sect>
6057
6058       <sect>
6059         <heading>Device files</heading>
6060
6061         <p>
6062           Packages must not include device files in the package file
6063           tree.</p>
6064
6065         <p>
6066           If a package needs any special device files that are not
6067           included in the base system, it must call
6068           <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
6069           after notifying the user<footnote>
6070             <p>
6071               This notification could be done via a (low-priority)
6072               debconf message, or an echo (printf) statement.
6073             </p>
6074           </footnote>
6075           .</p>
6076
6077         <p>
6078           Packages must not remove any device files in the
6079           <prgn>postrm</prgn> or any other script. This is left to the
6080           system administrator.</p>
6081
6082         <p>
6083           Debian uses the serial devices
6084           <file>/dev/ttyS*</file>. Programs using the old
6085           <file>/dev/cu*</file> devices should be changed to use
6086           <file>/dev/ttyS*</file>.</p>
6087       </sect>
6088
6089       <sect id="config-files">
6090         <heading>Configuration files</heading>
6091         <sect1>
6092           <heading>Definitions</heading>
6093           <p>
6094             <taglist>
6095               <tag>configuration file</tag>
6096               <item>
6097                 <p>
6098                   A file that affects the operation of a program, or
6099                   provides site- or host-specific information, or
6100                   otherwise customizes the behavior of a program.
6101                   Typically, configuration files are intended to be
6102                   modified by the system administrator (if needed or
6103                   desired) to conform to local policy or to provide
6104                   more useful site-specific behavior.
6105                 </p>
6106               </item>
6107
6108               <tag><tt>conffile</tt></tag>
6109               <item>
6110                 <p>
6111                   A file listed in a package's <tt>conffiles</tt>
6112                   file, and is treated specially by <prgn>dpkg</prgn>
6113                   (see <ref id="configdetails">).
6114                 </p>
6115               </item>
6116             </taglist>
6117           </p>
6118
6119           <p>
6120             The distinction between these two is important; they are
6121             not interchangeable concepts. Almost all
6122             <tt>conffile</tt>s are configuration files, but many
6123             configuration files are not <tt>conffiles</tt>.
6124           </p>
6125
6126           <p>
6127             Note that a script that embeds configuration information
6128             (such as most of the files in <file>/etc/default</file> and
6129             <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6130             configuration file and should be treated as such.
6131           </p>
6132         </sect1>
6133
6134         <sect1>
6135           <heading>Location</heading>
6136           <p>
6137             Any configuration files created or used by your package
6138             must reside in <file>/etc</file>. If there are several,
6139             consider creating a subdirectory of <file>/etc</file>
6140             named after your package.</p>
6141
6142           <p>
6143             If your package creates or uses configuration files
6144             outside of <file>/etc</file>, and it is not feasible to modify
6145             the package to use <file>/etc</file> directly, put the files
6146             in <file>/etc</file> and create symbolic links to those files
6147             from the location that the package requires.</p>
6148         </sect1>
6149
6150         <sect1>
6151           <heading>Behavior</heading>
6152           <p>
6153             Configuration file handling must conform to the following
6154             behavior:
6155             <list compact="compact">
6156               <item>
6157                 <p>
6158                   local changes must be preserved during a package
6159                   upgrade, and
6160                 </p>
6161               </item>
6162               <item>
6163                 <p>
6164                   configuration files must be preserved when the
6165                   package is removed, and only deleted when the
6166                   package is purged.
6167                 </p>
6168               </item>
6169             </list>
6170           </p>
6171
6172           <p>
6173             The easy way to achieve this behavior is to make the
6174             configuration file a <tt>conffile</tt>. This is
6175             appropriate only if it is possible to distribute a default
6176             version that will work for most installations, although
6177             some system administrators may choose to modify it. This
6178             implies that the default version will be part of the
6179             package distribution, and must not be modified by the
6180             maintainer scripts during installation (or at any other
6181             time).
6182           </p>
6183
6184           <p>
6185             In order to ensure that local changes are preserved
6186             correctly, no package may contain or make hard links to
6187             conffiles.<footnote>
6188               <p>
6189                 Rationale: There are two problems with hard links.
6190                 The first is that some editors break the link while
6191                 editing one of the files, so that the two files may
6192                 unwittingly become unlinked and different.  The second
6193                 is that <prgn>dpkg</prgn> might break the hard link
6194                 while upgrading <tt>conffile</tt>s.
6195               </p>
6196             </footnote>
6197             </p>
6198
6199             <p>
6200             The other way to do it is via the maintainer scripts.  In
6201             this case, the configuration file must not be listed as a
6202             <tt>conffile</tt> and must not be part of the package
6203             distribution. If the existence of a file is required for
6204             the package to be sensibly configured it is the
6205             responsibility of the package maintainer to provide
6206             maintainer scripts which correctly create, update and
6207             maintain the file and remove it on purge.  (See <ref
6208             id="maintainerscripts"> for more information.)  These
6209             scripts must be idempotent (i.e., must work correctly if
6210             <prgn>dpkg</prgn> needs to re-run them due to errors
6211             during installation or removal), must cope with all the
6212             variety of ways <prgn>dpkg</prgn> can call maintainer
6213             scripts, must not overwrite or otherwise mangle the user's
6214             configuration without asking, must not ask unnecessary
6215             questions (particularly during upgrades), and otherwise be
6216             good citizens.
6217           </p>
6218
6219           <p>
6220             The scripts are not required to configure every possible
6221             option for the package, but only those necessary to get
6222             the package running on a given system. Ideally the
6223             sysadmin should not have to do any configuration other
6224             than that done (semi-)automatically by the
6225             <prgn>postinst</prgn> script.
6226           </p>
6227
6228           <p>
6229             A common practice is to create a script called
6230             <file><var>package</var>-configure</file> and have the
6231             package's <prgn>postinst</prgn> call it if and only if the
6232             configuration file does not already exist.  In certain
6233             cases it is useful for there to be an example or template
6234             file which the maintainer scripts use.  Such files should
6235             be in <file>/usr/share/<var>package</var></file> or
6236             <file>/usr/lib/<var>package</var></file> (depending on whether
6237             they are architecture-independent or not).  There should
6238             be symbolic links to them from
6239             <file>/usr/share/doc/<var>package</var>/examples</file> if
6240             they are examples, and should be perfectly ordinary
6241             <prgn>dpkg</prgn>-handled files (<em>not</em>
6242             configuration files).
6243           </p>
6244
6245           <p>
6246             These two styles of configuration file handling must
6247             not be mixed, for that way lies madness:
6248             <prgn>dpkg</prgn> will ask about overwriting the file
6249             every time the package is upgraded.
6250           </p>
6251         </sect1>
6252
6253         <sect1>
6254           <heading>Sharing configuration files</heading>
6255           <p>
6256             Packages which specify the same file as a
6257             <tt>conffile</tt> must be tagged as <em>conflicting</em>
6258             with each other.  (This is an instance of the general rule
6259             about not sharing files.  Note that neither alternatives
6260             nor diversions are likely to be appropriate in this case;
6261             in particular, <prgn>dpkg</prgn> does not handle diverted
6262             <tt>conffile</tt>s well.)
6263           </p>
6264
6265           <p>
6266             The maintainer scripts must not alter a <tt>conffile</tt>
6267             of <em>any</em> package, including the one the scripts
6268             belong to.
6269           </p>
6270
6271           <p>
6272             If two or more packages use the same configuration file
6273             and it is reasonable for both to be installed at the same
6274             time, one of these packages must be defined as
6275             <em>owner</em> of the configuration file, i.e., it will be
6276             the package which handles that file as a configuration
6277             file.  Other packages that use the configuration file must
6278             depend on the owning package if they require the
6279             configuration file to operate. If the other package will
6280             use the configuration file if present, but is capable of
6281             operating without it, no dependency need be declared.</p>
6282
6283           <p>
6284             If it is desirable for two or more related packages to
6285             share a configuration file <em>and</em> for all of the
6286             related packages to be able to modify that configuration
6287             file, then the following should be done:
6288             <enumlist compact="compact">
6289               <item>
6290                 <p>
6291                   One of the related packages (the "owning" package)
6292                   will manage the configuration file with maintainer
6293                   scripts as described in the previous section.
6294                 </p>
6295               </item>
6296               <item>
6297                 <p>
6298                   The owning package should also provide a program
6299                   that the other packages may use to modify the
6300                   configuration file.
6301                 </p>
6302               </item>
6303               <item>
6304                 <p>
6305                   The related packages must use the provided program
6306                   to make any desired modifications to the
6307                   configuration file.  They should either depend on
6308                   the core package to guarantee that the configuration
6309                   modifier program is available or accept gracefully
6310                   that they cannot modify the configuration file if it
6311                   is not.  (This is in addition to the fact that the
6312                   configuration file may not even be present in the
6313                   latter scenario.)
6314                 </p>
6315               </item>
6316             </enumlist>
6317           </p>
6318
6319           <p>
6320             Sometimes it's appropriate to create a new package which
6321             provides the basic infrastructure for the other packages
6322             and which manages the shared configuration files.  (The
6323             <tt>sgml-base</tt> package is a good example.)
6324           </p>
6325         </sect1>
6326
6327         <sect1>
6328           <heading>User configuration files ("dotfiles")</heading>
6329
6330           <p>
6331             The files in <file>/etc/skel</file> will automatically be
6332             copied into new user accounts by <prgn>adduser</prgn>.
6333             No other program should reference the files in
6334             <file>/etc/skel</file>.
6335           </p>
6336
6337           <p>
6338             Therefore, if a program needs a dotfile to exist in
6339             advance in <file>$HOME</file> to work sensibly, that dotfile
6340             should be installed in <file>/etc/skel</file> and treated as a
6341             configuration file.
6342           </p>
6343
6344           <p>
6345             However, programs that require dotfiles in order to
6346             operate sensibly are a bad thing, unless they do create
6347             the dotfiles themselves automatically.
6348           </p>
6349
6350           <p>
6351             Furthermore, programs should be configured by the Debian
6352             default installation to behave as closely to the upstream
6353             default behaviour as possible.
6354           </p>
6355
6356           <p>
6357             Therefore, if a program in a Debian package needs to be
6358             configured in some way in order to operate sensibly, that
6359             should be done using a site-wide configuration file placed
6360             in <file>/etc</file>.  Only if the program doesn't support a
6361             site-wide default configuration and the package maintainer
6362             doesn't have time to add it may a default per-user file be
6363             placed in <file>/etc/skel</file>.
6364           </p>
6365
6366           <p>
6367             <file>/etc/skel</file> should be as empty as we can make it.
6368             This is particularly true because there is no easy (or
6369             necessarily desirable) mechanism for ensuring that the
6370             appropriate dotfiles are copied into the accounts of
6371             existing users when a package is installed.
6372           </p>
6373         </sect1>
6374       </sect>
6375
6376       <sect>
6377         <heading>Log files</heading>
6378         <p>
6379           Log files should usually be named
6380           <file>/var/log/<var>package</var>.log</file>.  If you have many
6381           log files, or need a separate directory for permission
6382           reasons (<file>/var/log</file> is writable only by
6383           <file>root</file>), you should usually create a directory named
6384           <file>/var/log/<var>package</var></file> and place your log
6385           files there.
6386         </p>
6387
6388         <p>
6389           Log files must be rotated occasionally so that they don't
6390           grow indefinitely; the best way to do this is to drop a log
6391           rotation configuration file into the directory
6392           <file>/etc/logrotate.d</file> and use the facilities provided by
6393           logrotate.<footnote>
6394             <p>
6395               The traditional approach to log files has been to set up
6396               <em>ad hoc</em> log rotation schemes using simple shell
6397               scripts and cron.  While this approach is highly
6398               customizable, it requires quite a lot of sysadmin work.
6399               Even though the original Debian system helped a little
6400               by automatically installing a system which can be used
6401               as a template, this was deemed not enough.
6402             </p>
6403
6404             <p>
6405               The use of <prgn>logrotate</prgn>, a program developed
6406               by Red Hat, is better, as it centralizes log management.
6407               It has both a configuration file
6408               (<file>/etc/logrotate.conf</file>) and a directory where
6409               packages can drop their individual log rotation
6410               configurations (<file>/etc/logrotate.d</file>).
6411             </p>
6412           </footnote>
6413           Here is a good example for a logrotate config
6414           file (for more information see <manref name="logrotate"
6415             section="8">):
6416           <example compact="compact">
6417 /var/log/foo/* {
6418 rotate 12
6419 weekly
6420 compress
6421 postrotate
6422 /etc/init.d/foo force-reload
6423 endscript
6424 }
6425           </example>
6426           This rotates all files under <file>/var/log/foo</file>, saves 12
6427           compressed generations, and forces the daemon to reload its
6428           configuration information after the log rotation.
6429         </p>
6430
6431         <p>
6432           Log files should be removed when the package is
6433           purged (but not when it is only removed).  This should be
6434           done by the <prgn>postrm</prgn> script when it is called
6435           with the argument <tt>purge</tt> (see <ref
6436           id="removedetails">).
6437         </p>
6438       </sect>
6439
6440       <sect>
6441         <heading>Permissions and owners</heading>
6442
6443         <p>
6444           The rules in this section are guidelines for general use.
6445           If necessary you may deviate from the details below.
6446           However, if you do so you must make sure that what is done
6447           is secure and you should try to be as consistent as possible
6448           with the rest of the system.  You should probably also
6449           discuss it on <prgn>debian-devel</prgn> first.
6450         </p>
6451
6452         <p>
6453           Files should be owned by <tt>root.root</tt>, and made
6454           writable only by the owner and universally readable (and
6455           executable, if appropriate), that is mode 644 or 755.
6456         </p>
6457
6458         <p>
6459           Directories should be mode 755 or (for group-writability)
6460           mode 2775.  The ownership of the directory should be
6461           consistent with its mode: if a directory is mode 2775, it
6462           should be owned by the group that needs write access to
6463           it.
6464         </p>
6465
6466         <p>
6467           Setuid and setgid executables should be mode 4755 or 2755
6468           respectively, and owned by the appropriate user or group.
6469           They should not be made unreadable (modes like 4711 or
6470           2711 or even 4111); doing so achieves no extra security,
6471           because anyone can find the binary in the freely available
6472           Debian package; it is merely inconvenient.  For the same
6473           reason you should not restrict read or execute permissions
6474           on non-set-id executables.
6475         </p>
6476
6477         <p>
6478           Some setuid programs need to be restricted to particular
6479           sets of users, using file permissions.  In this case they
6480           should be owned by the uid to which they are set-id, and by
6481           the group which should be allowed to execute them.  They
6482           should have mode 4754; again there is no point in making
6483           them unreadable to those users who must not be allowed to
6484           execute them.
6485         </p>
6486
6487         <p>
6488           It is possible to arrange that the system administrator can
6489           reconfigure the package to correspond to their local
6490           security policy by changing the permissions on a binary:
6491           they can do this by using <prgn>dpkg-statoverride</prgn>, as
6492           described below.<footnote>
6493             <p>
6494               Ordinary files installed by <prgn>dpkg</prgn> (as
6495               opposed to <tt>conffile</tt>s and other similar objects)
6496               normally have their permissions reset to the distributed
6497               permissions when the package is reinstalled.  However,
6498               the use of <prgn>dpkg-statoverride</prgn> overrides this
6499               default behaviour.  If you use this method, you should
6500               remember to describe <prgn>dpkg-statoverride</prgn> in
6501               the package documentation; being a relatively new
6502               addition to Debian, it is probably not yet well-known.
6503             </p>
6504           </footnote>
6505           Another method you should consider is to create a group for
6506           people allowed to use the program(s) and make any setuid
6507           executables executable only by that group.
6508         </p>
6509
6510         <p>
6511           If you need to create a new user or group for your package
6512           there are two possibilities.  Firstly, you may need to
6513           make some files in the binary package be owned by this
6514           user or group, or you may need to compile the user or
6515           group id (rather than just the name) into the binary
6516           (though this latter should be avoided if possible, as in
6517           this case you need a statically allocated id).</p>
6518
6519         <p>
6520           If you need a statically allocated id, you must ask for a
6521           user or group id from the <tt>base-passwd</tt> maintainer,
6522           and must not release the package until you have been
6523           allocated one.  Once you have been allocated one you must
6524           either make the package depend on a version of the
6525           <tt>base-passwd</tt> package with the id present in
6526           <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6527           your package to create the user or group itself with the
6528           correct id (using <tt>adduser</tt>) in its
6529           <prgn>preinst</prgn> or <prgn>postinst</prgn>.  (Doing it in
6530           the <prgn>postinst</prgn> is to be preferred if it is
6531           possible, otherwise a pre-dependency will be needed on the
6532           <tt>adduser</tt> package.)
6533         </p>
6534
6535         <p>
6536           On the other hand, the program might be able to determine
6537           the uid or gid from the user or group name at runtime, so
6538           that a dynamically allocated id can be used.  In this case
6539           you should choose an appropriate user or group name,
6540           discussing this on <prgn>debian-devel</prgn> and checking
6541           with the <package/base-passwd/ maintainer that it is unique and that
6542           they do not wish you to use a statically allocated id
6543           instead.  When this has been checked you must arrange for
6544           your package to create the user or group if necessary using
6545           <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6546           <prgn>postinst</prgn> script (again, the latter is to be
6547           preferred if it is possible).
6548         </p>
6549
6550         <p>
6551           Note that changing the numeric value of an id associated
6552           with a name is very difficult, and involves searching the
6553           file system for all appropriate files.  You need to think
6554           carefully whether a static or dynamic id is required, since
6555           changing your mind later will cause problems.
6556         </p>
6557
6558         <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6559           <p>
6560             This section is not intended as policy, but as a
6561             description of the use of <prgn>dpkg-statoverride</prgn>.
6562           </p>
6563
6564           <p>
6565             <prgn>dpkg-statoverride</prgn> is a replacement for the
6566             deprecated <tt>suidmanager</tt> package.  Packages which
6567             previously used <tt>suidmanager</tt> should have a
6568             <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6569             <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6570             and <tt>suidunregister</tt> should now be simply removed
6571             from the maintainer scripts.
6572           </p>
6573
6574           <p>
6575             If a system administrator wishes to have a file (or
6576             directory or other such thing) installed with owner and
6577             permissions different from those in the distributed Debian
6578             package, he can use the <prgn>dpkg-statoverride</prgn>
6579             program to instruct <prgn>dpkg</prgn> to use the different
6580             settings every time the file is installed.  Thus the
6581             package maintainer should distribute the files with their
6582             normal permissions, and leave it for the system
6583             administrator to make any desired changes.  For example, a
6584             daemon which is normally required to be setuid root, but
6585             in certain situations could be used without being setuid,
6586             should be installed setuid in the <tt>.deb</tt>.  Then the
6587             local system administrator can change this if they wish.
6588             If there are two standard ways of doing it, the package
6589             maintainer can use <tt>debconf</tt> to find out the
6590             preference, and call <prgn>dpkg-statoverride</prgn> in the
6591             maintainer script if necessary to accommodate the system
6592             administrator's choice.
6593           </p>
6594
6595           <p>
6596             Given the above, <prgn>dpkg-statoverride</prgn> is
6597             essentially a tool for system administrators and would not
6598             normally be needed in the maintainer scripts.  There is
6599             one type of situation, though, where calls to
6600             <prgn>dpkg-statoverride</prgn> would be needed in the
6601             maintainer scripts, and that involves packages which use
6602             dynamically allocated user or group ids.  In such a
6603             situation, something like the following idiom can be very
6604             helpful in the package's <prgn>postinst</prgn>, where
6605             <tt>sysuser</tt> is a dynamically allocated id:
6606             <example>
6607 for i in /usr/bin/foo /usr/sbin/bar
6608 do
6609   if ! dpkg-statoverride --list $i >/dev/null
6610   then
6611     dpkg-statoverride --update --add sysuser root 4755 $i
6612   fi
6613 done
6614             </example>
6615             The corresponding <tt>dpkg-statoverride --remove</tt>
6616             calls can then be made unconditionally when the package is
6617             purged.
6618           </p>
6619         </sect1>
6620       </sect>
6621     </chapt>
6622
6623     <chapt id="customized-programs">
6624       <heading>Customized programs</heading>
6625
6626       <sect id="arch-spec">
6627         <heading>Architecture specification strings</heading>
6628
6629         <p>
6630           If a program needs to specify an <em>architecture specification
6631             string</em> in some place, the following format should be
6632             used: <var>arch</var>-<var>os</var><footnote>
6633             <p>
6634               The following architectures and operating systems are
6635               currently recognised by <prgn>dpkg-archictecture</prgn>.
6636               The architecture, <tt><var>arch</var></tt>, is one of
6637               the following: <tt>alpha</tt>, <tt>arm</tt>,
6638               <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6639               <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6640               <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6641               <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>.  The
6642               operating system, <tt><var>os</var></tt>, is one of:
6643               <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6644               <tt>openbsd</tt>.  Use of <tt>gnu</tt> in this string is
6645               reserved for the GNU/Hurd operating system.
6646             </p>
6647           </footnote>.
6648         </p>
6649
6650         <p>
6651           Note that we don't want to use
6652           <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6653           <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6654           since this would make our programs incompatible with other
6655           Linux distributions.  We also don't use something like
6656           <tt><var>arch</var>-unknown-linux</tt>, since the
6657           <tt>unknown</tt> does not look very good.
6658         </p>
6659       </sect>
6660
6661       <sect>
6662         <heading>Daemons</heading>
6663
6664         <p>
6665           The configuration files <file>/etc/services</file>,
6666           <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6667           by the <prgn>netbase</prgn> package and must not be modified
6668           by other packages.
6669         </p>
6670
6671         <p>
6672           If a package requires a new entry in one of these files, the
6673           maintainer should get in contact with the
6674           <prgn>netbase</prgn> maintainer, who will add the entries
6675           and release a new version of the <prgn>netbase</prgn>
6676           package.
6677         </p>
6678
6679         <p>
6680           The configuration file <file>/etc/inetd.conf</file> must not be
6681           modified by the package's scripts except via the
6682           <prgn>update-inetd</prgn> script or the
6683           <file>DebianNet.pm</file> Perl module.  See their documentation
6684           for details on how to add entries.
6685         </p>
6686
6687         <p>
6688           If a package wants to install an example entry into
6689           <file>/etc/inetd.conf</file>, the entry must be preceded with
6690           exactly one hash character (<tt>#</tt>). Such lines are
6691           treated as "commented out by user" by the
6692           <prgn>update-inetd</prgn> script and are not changed or
6693           activated during package updates.
6694         </p>
6695       </sect>
6696
6697       <sect>
6698         <heading>Using pseudo-ttys and modifying wtmp, utmp and
6699         lastlog</heading>
6700
6701         <p>
6702           Some programs need to create pseudo-ttys. This should be done
6703           using Unix98 ptys if the C library supports it. The resulting
6704           program must not be installed setuid root, unless that
6705           is required for other functionality.
6706         </p>
6707
6708         <p>
6709           The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6710           <file>/var/log/lastlog</file> must be installed writeable by
6711           group <tt>utmp</tt>.  Programs which need to modify those
6712           files must be installed setgid <tt>utmp</tt>.
6713         </p>
6714       </sect>
6715
6716       <sect>
6717         <heading>Editors and pagers</heading>
6718
6719         <p>
6720           Some programs have the ability to launch an editor or pager
6721           program to edit or display a text document.  Since there are
6722           lots of different editors and pagers available in the Debian
6723           distribution, the system administrator and each user should
6724           have the possibility to choose his/her preferred editor and
6725           pager.
6726         </p>
6727
6728         <p>
6729           In addition, every program should choose a good default
6730           editor/pager if none is selected by the user or system
6731           administrator.
6732         </p>
6733
6734         <p>
6735           Thus, every program that launches an editor or pager must
6736           use the EDITOR or PAGER environment variable to determine
6737           the editor or pager the user wishes to use.  If these
6738           variables are not set, the programs <file>/usr/bin/editor</file>
6739           and <file>/usr/bin/pager</file> should be used, respectively.
6740         </p>
6741
6742         <p>
6743           These two files are managed through the <prgn>dpkg</prgn>
6744           "alternatives" mechanism.  Thus every package providing an
6745           editor or pager must call the
6746           <prgn>update-alternatives</prgn> script to register these
6747           programs.
6748         </p>
6749
6750         <p>
6751           If it is very hard to adapt a program to make use of the
6752           EDITOR or PAGER variables, that program may be configured to
6753           use <file>/usr/bin/sensible-editor</file> and
6754           <file>/usr/bin/sensible-pager</file> as the editor or pager
6755           program respectively.  These are two scripts provided in the
6756           Debian base system that check the EDITOR and PAGER variables
6757           and launch the appropriate program, and fall back to
6758           <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6759           variable is not set.
6760         </p>
6761
6762         <p>
6763           A program may also use the VISUAL environment variable to
6764           determine the user's choice of editor.  If it exists, it
6765           should take precedence over EDITOR.  This is in fact what
6766           <file>/usr/bin/sensible-editor</file> does.
6767         </p>
6768
6769         <p>
6770           It is not required for a package to depend on
6771           <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6772           package to provide such virtual packages.<footnote>
6773             <p>
6774               The Debian base system already provides an editor and a
6775               pager program,
6776             </p>
6777           </footnote>
6778         </p>
6779       </sect>
6780
6781       <sect id="web-appl">
6782         <heading>Web servers and applications</heading>
6783
6784         <p>
6785           This section describes the locations and URLs that should
6786           be used by all web servers and web applications in the
6787           Debian system.
6788         </p>
6789
6790         <p>
6791           <enumlist>
6792             <item>
6793               <p>
6794                 Cgi-bin executable files are installed in the
6795                 directory
6796                 <example compact="compact">
6797 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6798                 </example>
6799                 and should be referred to as
6800                 <example compact="compact">
6801 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6802                 </example>
6803               </p>
6804             </item>
6805
6806             <item><p>Access to HTML documents</p>
6807
6808               <p>
6809                 HTML documents for a package are stored in
6810                 <file>/usr/share/doc/<var>package</var></file>
6811                 and can be referred to as
6812                 <example compact="compact">
6813 http://localhost/doc/<var>package</var>/<var>filename</var>
6814                 </example>
6815               </p>
6816              <p>
6817                 The web server should restrict access to the document
6818                 tree so that only clients on the same host can read
6819                 the documents. If the web server does not support such
6820                 access controls, then it should not provide access at
6821                 all, or ask about providing access during installation.
6822               </p>
6823             </item>
6824
6825             <item><p>Web Document Root</p>
6826
6827               <p>
6828                 Web Applications should try to avoid storing files in
6829                 the Web Document Root.  Instead they should use the
6830                 /usr/share/doc/<var>package</var> directory for
6831                 documents and register the Web Application via the
6832                 menu package.  If access to the web document root is
6833                 unavoidable then use
6834                 <example compact="compact">
6835 /var/www
6836                 </example>
6837                 as the Document Root.  This might be just a symbolic
6838                 link to the location where the system administrator
6839                 has put the real document root.
6840               </p>
6841             </item>
6842
6843           </enumlist></p></sect>
6844
6845
6846       <sect id="mail-transport-agents">
6847         <heading>Mail transport, delivery and user agents</heading>
6848
6849         <p>
6850           Debian packages which process electronic mail, whether mail
6851           user agents (MUAs) or mail transport agents (MTAs), must
6852           ensure that they are compatible with the configuration
6853           decisions below.  Failure to do this may result in lost
6854           mail, broken <tt>From:</tt> lines, and other serious brain
6855           damage!
6856         </p>
6857
6858         <p>
6859           The mail spool is <file>/var/mail</file> and the interface to
6860           send a mail message is <file>/usr/sbin/sendmail</file> (as per
6861           the FHS).  On older systems, the mail spool may be
6862           physically located in <file>/var/spool/mail</file>, but all
6863           access to the mail spool should be via the
6864           <file>/var/mail</file> symlink.  The mail spool is part of the
6865           base system and not part of the MTA package.
6866         </p>
6867
6868         <p>
6869           All Debian MUAs, MTAs, MDAs and other mailbox accessing
6870           programs (such as IMAP daemons) must lock the mailbox in an
6871           NFS-safe way. This means that <tt>fcntl()</tt> locking must
6872           be combined with dot locking.  To avoid deadlocks, a program
6873           should use <tt>fcntl()</tt> first and dot locking after
6874           this, or alternatively implement the two locking methods in
6875           a non blocking way<footnote>
6876             <p>
6877               If it is not possible to establish both locks, the
6878               system shouldn't wait for the second lock to be
6879               established, but remove the first lock, wait a (random)
6880               time, and start over locking again.
6881             </p>
6882           </footnote>. Using the functions <tt>maillock</tt> and
6883           <tt>mailunlock</tt> provided by the
6884           <tt>liblockfile*</tt><footnote>
6885             <p>
6886               You will need to depend on <tt>liblockfile1
6887                 (&gt;&gt;1.01)</tt> to use these functions.
6888             </p>
6889           </footnote> packages is the recommended way to realize this.
6890         </p>
6891
6892         <p>
6893           Mailboxes are generally mode 660
6894           <tt><var>user</var>.mail</tt> unless the system
6895           administrator has chosen otherwise.  A MUA may remove a
6896           mailbox (unless it has nonstandard permissions) in which
6897           case the MTA or another MUA must recreate it if needed.
6898           Mailboxes must be writable by group mail.
6899         </p>
6900
6901         <p>
6902           The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6903           be setgid mail to do the locking mentioned above (and
6904           must obviously avoid accessing other users' mailboxes
6905           using this privilege).</p>
6906
6907         <p>
6908           <file>/etc/aliases</file> is the source file for the system mail
6909           aliases (e.g., postmaster, usenet, etc.), it is the one
6910           which the sysadmin and <prgn>postinst</prgn> scripts may
6911           edit.  After <file>/etc/aliases</file> is edited the program or
6912           human editing it must call <prgn>newaliases</prgn>.  All MTA
6913           packages must come with a <prgn>newaliases</prgn> program,
6914           even if it does nothing, but older MTA packages did not do
6915           this so programs should not fail if <prgn>newaliases</prgn>
6916           cannot be found.  Note that because of this, all MTA
6917           packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6918           <tt>Replaces: mail-transport-agent</tt> control file
6919           fields.
6920         </p>
6921
6922         <p>
6923           The convention of writing <tt>forward to
6924             <var>address</var></tt> in the mailbox itself is not
6925           supported.  Use a <tt>.forward</tt> file instead.</p>
6926
6927         <p>
6928           The <prgn>rmail</prgn> program used by UUCP
6929           for incoming mail should be  <file>/usr/sbin/rmail</file>.
6930           Likewise, <prgn>rsmtp</prgn>, for receiving
6931           batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6932           is supported.</p>
6933
6934         <p>
6935           If your package needs to know what hostname to use on (for
6936           example) outgoing news and mail messages which are generated
6937           locally, you should use the file <file>/etc/mailname</file>.  It
6938           will contain the portion after the username and <tt>@</tt>
6939           (at) sign for email addresses of users on the machine
6940           (followed by a newline).
6941         </p>
6942
6943         <p>
6944           Such package should check for the existence of this file
6945           when it is being configured.  If it exists, it should be
6946           used without comment, although an MTA's configuration script
6947           may wish to prompt the user even if it finds that this file
6948           exists.  If the file does not exist, the package should
6949           prompt the user for the value (preferably using
6950           <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6951           as well as using it in the package's configuration.  The
6952           prompt should make it clear that the name will not just be
6953           used by that package.  For example, in this situation the
6954           <tt>inn</tt> package could say something like:
6955           <example compact="compact">
6956 Please enter the "mail name" of your system.  This is the
6957 hostname portion of the address to be shown on outgoing
6958 news and mail messages.  The default is
6959 <var>syshostname</var>, your system's host name.  Mail
6960 name ["<var>syshostname</var>"]:
6961           </example>
6962           where <var>syshostname</var> is the output of <tt>hostname
6963             --fqdn</tt>.
6964         </p>
6965       </sect>
6966
6967       <sect>
6968         <heading>News system configuration</heading>
6969
6970         <p>
6971           All the configuration files related to the NNTP (news)
6972           servers and clients should be located under
6973           <file>/etc/news</file>.</p>
6974
6975         <p>
6976           There are some configuration issues that apply to a number
6977           of news clients and server packages on the machine. These
6978           are:
6979
6980           <taglist>
6981             <tag><file>/etc/news/organization</file></tag>
6982             <item><p>A string which should appear as the
6983                 organization header for all messages posted
6984                 by NNTP clients on the machine</p></item>
6985
6986             <tag><file>/etc/news/server</file></tag>
6987             <item><p>Contains the FQDN of the upstream NNTP
6988                 server, or localhost if the local machine is
6989                 an NNTP server.</p></item>
6990           </taglist>
6991
6992           Other global files may be added as required for cross-package news
6993           configuration.</p></sect>
6994
6995
6996       <sect>
6997         <heading>Programs for the X Window System</heading>
6998
6999         <sect1>
7000           <heading>Providing X support and package priorities</heading>
7001
7002           <p>
7003             Programs that can be configured with support for the X
7004             Window System must be configured to do so and must declare
7005             any package dependencies necessary to satisfy their
7006             runtime requirements when using the X Window System.  If
7007             such a package is of higher priority than the X packages
7008             on which it depends, it is required that either the
7009             X-specific components be split into a separate package, or
7010             that an alternative version of the package, which includes
7011             X support, be provided, or that the package's priority be
7012             lowered.
7013           </p>
7014         </sect1>
7015
7016         <sect1>
7017           <heading>Packages providing an X server</heading>
7018
7019           <p>
7020             Packages that provide an X server that, directly or
7021             indirectly, communicates with real input and display
7022             hardware should declare in their control data that they
7023             provide the virtual package <tt>xserver</tt>.<footnote>
7024               <p>
7025                 This implements current practice, and provides an
7026                 actual policy for usage of the <tt>xserver</tt>
7027                 virtual package which appears in the virtual packages
7028                 list.  In a nutshell, X servers that interface
7029                 directly with the display and input hardware or via
7030                 another subsystem (e.g., GGI) should provide
7031                 <tt>xserver</tt>.  Things like <tt>Xvfb</tt>,
7032                 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
7033               </p>
7034             </footnote>
7035           </p>
7036         </sect1>
7037
7038         <sect1>
7039           <heading>Packages providing a terminal emulator</heading>
7040
7041           <p>
7042             Packages that provide a terminal emulator for the X Window
7043             System which meet the criteria listed below should declare
7044             in their control data that they provide the virtual
7045             package <tt>x-terminal-emulator</tt>.  They should also
7046             register themselves as an alternative for
7047             <file>/usr/bin/x-terminal-emulator</file>, with a priority of
7048             20.
7049           </p>
7050
7051           <p>
7052             To be an <tt>x-terminal-emulator</tt>, a program must:
7053             <list compact="compact">
7054               <item><p>
7055                   Be able to emulate a DEC VT100 terminal, or a
7056                   compatible terminal.
7057                 </p></item>
7058
7059               <item><p>
7060                   Support the command-line option <tt>-e
7061                     <var>command</var></tt>, which creates a new
7062                   terminal window<footnote>
7063                     <p>
7064                       "New terminal window" does not necessarily mean
7065                       a new top-level X window directly parented by
7066                       the window manager; it could, if the terminal
7067                       emulator application were so coded, be a new
7068                       "view" in a multiple-document interface (MDI).
7069                     </p>
7070                   </footnote>
7071                   and runs the specified <var>command</var>.
7072                 </p></item>
7073
7074               <item><p>
7075                   Support the command-line option <tt>-T
7076                     <var>title</var></tt>, which creates a new terminal
7077                   window with the window title <var>title</var>.
7078                 </p></item>
7079             </list>
7080           </p>
7081         </sect1>
7082
7083         <sect1>
7084           <heading>Packages providing a window manager</heading>
7085
7086           <p>
7087             Packages that provide a window manager should declare in
7088             their control data that they provide the virtual package
7089             <tt>x-window-manager</tt>.  They should also register
7090             themselves as an alternative for
7091             <file>/usr/bin/x-window-manager</file>, with a priority
7092             calculated as follows:
7093             <list compact="compact">
7094               <item><p>Start with a priority of 20.</p></item>
7095
7096               <item>
7097                 <p>
7098                   If the window manager supports the Debian menu
7099                   system, add 20 points if this support is available
7100                   in the package's default configuration (i.e., no
7101                   configuration files belonging to the system or user
7102                   have to be edited to activate the feature); if
7103                   configuration files must be modified, add only 10
7104                   points.
7105                 </p>
7106               </item>
7107               <item>
7108                 <p>
7109                   If the window manager complies with  <url
7110                     id="http://www.freedesktop.org/standards/wm-spec.html"
7111                     name="The Window Manager Specification Project">,
7112                   written by the <url id="http://www.freedesktop.org"
7113                     name="Free Desktop Group">, add 20 points.
7114                 </p>
7115               </item>
7116
7117               <item>
7118                 <p>
7119                   If the window manager permits the X session to be
7120                   restarted using a <em>different</em> window manager
7121                   (without killing the X server) in its default
7122                   configuration, add 10 points; otherwise add none.
7123                 </p>
7124               </item>
7125             </list>
7126           </p>
7127         </sect1>
7128
7129         <sect1>
7130           <heading>Packages providing fonts</heading>
7131
7132           <p>
7133             Packages that provide fonts for the X Window
7134             System<footnote>
7135               <p>
7136                 For the purposes of Debian Policy, a "font for the X
7137                 Window System" is one which is accessed via X protocol
7138                 requests.  Fonts for the Linux console, for PostScript
7139                 renderers, or any other purpose, do not fit this
7140                 definition.  Any tool which makes such fonts available
7141                 to the X Window System, however, must abide by this
7142                 font policy.
7143               </p>
7144             </footnote>
7145             must do a number of things to ensure that they are both
7146             available without modification of the X or font server
7147             configuration, and that they do not corrupt files used by
7148             other font packages to register information about
7149             themselves.
7150             <enumlist>
7151               <item>
7152                 <p>
7153                   Fonts of any type supported by the X Window System
7154                   must be in a separate binary package from any
7155                   executables, libraries, or documentation (except
7156                   that specific to the fonts shipped, such as their
7157                   license information).  If one or more of the fonts
7158                   so packaged are necessary for proper operation of
7159                   the package with which they are associated the font
7160                   package may be Recommended; if the fonts merely
7161                   provide an enhancement, a Suggests relationship may
7162                   be used.  Packages must not Depend on font
7163                   packages.<footnote>
7164                     <p>
7165                       This is because the X server may retrieve fonts
7166                       from the local filesystem or over the network
7167                       from an X font server; the Debian package system
7168                       is empowered to deal only with the local
7169                       filesystem.
7170                     </p>
7171                   </footnote>
7172                 </p>
7173               </item>
7174
7175               <item>
7176                 <p>
7177                   BDF fonts must be converted to PCF fonts with the
7178                   <prgn>bdftopcf</prgn> utility (available in the
7179                   <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7180                   placed in a directory that corresponds to their
7181                   resolution:
7182                   <list compact="compact">
7183                     <item><p>
7184                         100 dpi fonts must be placed in
7185                         <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7186                       </p></item>
7187
7188                     <item><p>
7189                         75 dpi fonts must be placed in
7190                         <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7191                       </p></item>
7192
7193                     <item><p>
7194                         Character-cell fonts, cursor fonts, and other
7195                         low-resolution fonts must be placed in
7196                         <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7197                       </p></item>
7198                   </list>
7199                 </p>
7200               </item>
7201
7202               <item><p>
7203                   Speedo fonts must be placed in
7204                   <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7205                 </p></item>
7206
7207               <item><p>
7208                   Type 1 fonts must be placed in
7209                   <file>/usr/X11R6/lib/X11/fonts/Type1/</file>.  If font
7210                   metric files are available, they must be placed here
7211                   as well.
7212                 </p></item>
7213
7214               <item>
7215                 <p>
7216                   Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7217                   other than those listed above must be neither
7218                   created nor used.  (The <file>PEX</file>, <file>CID</file>,
7219                   and <file>cyrillic</file> directories are excepted for
7220                   historical reasons, but installation of files into
7221                   these directories remains discouraged.)
7222                 </p>
7223               </item>
7224
7225               <item>
7226                 <p>
7227                   Font packages may, instead of placing files directly
7228                   in the X font directories listed above, provide
7229                   symbolic links in that font directory pointing to
7230                   the files' actual location in the filesystem.  Such
7231                   a location must comply with the FHS.
7232                 </p>
7233               </item>
7234
7235               <item>
7236                 <p>
7237                   Font packages should not contain both 75dpi and
7238                   100dpi versions of a font.  If both are available,
7239                   they should be provided in separate binary packages
7240                   with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7241                   the names of the packages containing the
7242                   corresponding fonts.
7243                 </p>
7244               </item>
7245
7246               <item>
7247                 <p>
7248                   Fonts destined for the <file>misc</file> subdirectory
7249                   should not be included in the same package as 75dpi
7250                   or 100dpi fonts; instead, they should be provided in
7251                   a separate package with <tt>-misc</tt> appended to
7252                   its name.
7253                 </p>
7254               </item>
7255
7256               <item>
7257                 <p>
7258                   Font packages must not provide the files
7259                   <file>fonts.dir</file>, <file>fonts.alias</file>, or
7260                   <file>fonts.scale</file> in a font directory:
7261                   <list>
7262                     <item><p>
7263                         <file>fonts.dir</file> files must not be provided at all.
7264                       </p></item>
7265
7266                     <item>
7267                       <p>
7268                         <file>fonts.alias</file> and <file>fonts.scale</file>
7269                         files, if needed, should be provided in the
7270                         directory
7271                         <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7272                         where <var>fontdir</var> is the name of the
7273                         subdirectory of
7274                         <file>/usr/X11R6/lib/X11/fonts/</file> where the
7275                         package's corresponding fonts are stored
7276                         (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7277                         <var>package</var> is the name of the package
7278                         that provides these fonts, and
7279                         <var>extension</var> is either <tt>scale</tt>
7280                         or <tt>alias</tt>, whichever corresponds to
7281                         the file contents.
7282                       </p>
7283                     </item>
7284                   </list>
7285                 </p>
7286               </item>
7287
7288               <item>
7289                 <p>
7290                   Font packages must declare a dependency on
7291                   <tt>xutils (&gt;&gt; 4.0.3)</tt> in their control
7292                   data.
7293                 </p>
7294               </item>
7295
7296               <item>
7297                 <p>
7298                   Font packages that provide one or more
7299                   <file>fonts.scale</file> files as described above must
7300                   invoke <prgn>update-fonts-scale</prgn> on each
7301                   directory into which they installed fonts
7302                   <em>before</em> invoking
7303                   <prgn>update-fonts-dir</prgn> on that directory.
7304                   This invocation must occur in both the
7305                   <prgn>postinst</prgn> (for all arguments) and
7306                   <prgn>postrm</prgn> (for all arguments except
7307                   <tt>upgrade</tt>) scripts.
7308                 </p>
7309               </item>
7310
7311               <item>
7312                 <p>
7313                   Font packages that provide one or more
7314                   <file>fonts.alias</file> files as described above must
7315                   invoke <prgn>update-fonts-alias</prgn> on each
7316                   directory into which they installed fonts.  This
7317                   invocation must occur in both the
7318                   <prgn>postinst</prgn> (for all arguments) and
7319                   <prgn>postrm</prgn> (for all arguments except
7320                   <tt>upgrade</tt>) scripts.
7321                 </p>
7322               </item>
7323
7324               <item>
7325                 <p>
7326                   Font packages must invoke
7327                   <prgn>update-fonts-dir</prgn> on each directory into
7328                   which they installed fonts.  This invocation must
7329                   occur in both the <prgn>postinst</prgn> (for all
7330                   arguments) and <prgn>postrm</prgn> (for all
7331                   arguments except <tt>upgrade</tt>) scripts.
7332                 </p>
7333               </item>
7334
7335               <item>
7336                 <p>
7337                   Font packages must not provide alias names for the
7338                   fonts they include which collide with alias names
7339                   already in use by fonts already packaged.
7340                 </p>
7341               </item>
7342
7343               <item>
7344                 <p>
7345                   Font packages must not provide fonts with the same
7346                   XLFD registry name as another font already packaged.
7347                 </p>
7348               </item>
7349             </enumlist>
7350           </p>
7351         </sect1>
7352
7353         <sect1>
7354           <heading>Application defaults files</heading>
7355
7356           <p>
7357             Application defaults files must be installed in the
7358             directory <file>/etc/X11/app-defaults/</file> (use of a
7359             localized subdirectory of <file>/etc/X11/</file> as described
7360             in the <em>X Toolkit Intrinsics - C Language
7361             Interface</em> manual is also permitted).  They must be
7362             registered as <tt>conffile</tt>s or handled as
7363             configuration files.  Packages must not provide the
7364             directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7365           </p>
7366
7367           <p>
7368             Customization of programs' X resources may also be
7369             supported with the provision of a file with the same name
7370             as that of the package placed in the
7371             <file>/etc/X11/Xresources/</file> directory, which must
7372             registered as a <tt>conffile</tt> or handled as a
7373             configuration file.<footnote>
7374               <p>
7375                 Note that this mechanism is not the same as using
7376                 app-defaults; app-defaults are tied to the client
7377                 binary on the local filesystem, whereas X resources
7378                 are stored in the X server and affect all connecting
7379                 clients.
7380               </p>
7381             </footnote>
7382             <em>Important:</em> packages that install files into the
7383             <file>/etc/X11/Xresources/</file> directory must conflict with
7384             <tt>xbase (&lt;&lt; 3.3.2.3a-2)</tt>; if this is not done
7385             it is possible for the installing package to destroy a
7386             previously-existing <file>/etc/X11/Xresources</file> file
7387             which had been customized by the system administrator.
7388           </p>
7389         </sect1>
7390
7391         <sect1>
7392           <heading>Installation directory issues</heading>
7393
7394           <p>
7395             Packages using the X Window System should not be
7396             configured to install files under the <file>/usr/X11R6/</file>
7397             directory unless they use <prgn>imake</prgn>. The
7398             <file>/usr/X11R6/</file> directory hierarchy should be
7399             regarded as deprecated for all packages except the X
7400             Window System itself, and those which use the
7401             <prgn>imake</prgn> program it provides, in which case the
7402             packages may transition out of the <file>/usr/X11R6/</file>
7403             directory at the maintainer's discretion.<footnote>
7404               <p>
7405                 <prgn>Imake</prgn>-using programs are exempt because,
7406                 as long as they are written correctly, the pathnames
7407                 they use to locate resources and install themselves
7408                 are derived wholly from the X Window System
7409                 configuration.  Thus, in the event that the X Window
7410                 System moves to <file>/usr/X11R7/</file>,
7411                 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7412                 that is required for these programs is a recompile
7413                 against the corresponding X Window System library
7414                 development packages.
7415               </p>
7416             </footnote>
7417             Programs that use GNU <prgn>autoconf</prgn> and
7418             <prgn>automake</prgn> are usually easily configured at
7419             compile time to use <file>/usr/</file> instead of
7420             <file>/usr/X11R6/</file>, and this should be done whenever
7421             possible.  Configuration files for window managers and
7422             display managers should be placed in a subdirectory of
7423             <file>/etc/X11/</file> corresponding to the package name due
7424             to these programs' tight integration with the mechanisms
7425             of the X Window System.  Application-level programs should
7426             use the <file>/etc/</file> directory unless otherwise mandated
7427             by policy.  The installation of files into subdirectories
7428             of <file>/usr/X11R6/include/X11/</file> and
7429             <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7430             package maintainers should determine if subdirectories of
7431             <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7432             instead.  (The use of symbolic links from the
7433             <file>X11R6</file> directories to other FHS-compliant
7434             locations is encouraged if the program is not easily
7435             configured to look elsewhere for its files.)  Packages
7436             must not provide or install files into the directories
7437             <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7438             <file>/usr/lib/X11/</file>.  Files within a package should,
7439             however, make reference to these directories, rather than
7440             their <tt>X11R6</tt>-named counterparts
7441             <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7442             and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7443             referred to have not been moved to other FHS-compliant
7444             locations.
7445           </p>
7446         </sect1>
7447
7448         <sect1>
7449           <heading>The OSF/Motif and OpenMotif libraries</heading>
7450
7451           <p>
7452             <em>Programs that require the non-DFSG-compliant OSF/Motif or
7453               OpenMotif libraries</em><footnote>
7454               <p>
7455                 OSF/Motif and OpenMotif are collectively referred to as
7456                 "Motif" in this policy document.
7457               </p>
7458             </footnote>
7459             should be compiled against and tested with LessTif (a free
7460             re-implementation of Motif) instead.  If the maintainer
7461             judges that the program or programs do not work
7462             sufficiently well with LessTif to be distributed and
7463             supported, but do so when compiled against Motif, then two
7464             versions of the package should be created; one linked
7465             statically against Motif and with <tt>-smotif</tt>
7466             appended to the package name, and one linked dynamically
7467             against Motif and with <tt>-dmotif</tt> appended to the
7468             package name.  Both Motif-linked versions are dependent
7469             upon non-DFSG-compliant software and thus cannot be
7470             uploaded to the <em>main</em> distribution; if the
7471             software is itself DFSG-compliant it may be uploaded to
7472             the <em>contrib</em> distribution.  While known existing
7473             versions of Motif permit unlimited redistribution of
7474             binaries linked against the library (whether statically or
7475             dynamically), it is the package maintainer's
7476             responsibility to determine whether this is permitted by
7477             the license of the copy of Motif in his or her possession.
7478           </p>
7479         </sect1>
7480       </sect>
7481
7482       <sect>
7483         <heading>Perl programs and modules</heading>
7484
7485         <p>
7486           Perl programs and modules should follow the current Perl policy.
7487         </p>
7488
7489         <p>
7490           The Perl policy can be found in the <tt>perl-policy</tt>
7491           files in the <tt>debian-policy</tt> package.
7492           They are also available from the Debian web mirrors at
7493           <tt><url name="/doc/packaging-manuals/perl-policy/"
7494                 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>
7495           and from the Debian archive mirrors at
7496           <tt><url name="/doc/package-developer/perl-policy.txt.gz"
7497                 id="http://ftp.debian.org/debian/doc/package-developer/perl-policy.txt.gz"></tt>.
7498         </p>
7499       </sect>
7500
7501       <sect>
7502         <heading>Emacs lisp programs</heading>
7503
7504         <p>
7505           Please refer to the "Debian Emacs Policy" for details of how to
7506           package emacs lisp programs.
7507         </p>
7508
7509         <p>
7510           The Emacs policy is available in
7511           <file>debian-emacs-policy.gz</file> of the
7512           <package>emacsen-common</package> package.
7513           It is also available from the Debian web mirrors at
7514           <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
7515                 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
7516         </p>
7517       </sect>
7518
7519       <sect>
7520         <heading>Games</heading>
7521
7522         <p>
7523           The permissions on <file>/var/games</file> are mode 755, owner
7524           <tt>root</tt> and group <tt>root</tt>.
7525         </p>
7526
7527         <p>
7528           Each game decides on its own security policy.</p>
7529
7530         <p>
7531           Games which require protected, privileged access to
7532           high-score files, savegames, etc., may be made
7533           set-<em>group</em>-id (mode 2755) and owned by
7534           <tt>root.games</tt>, and use files and directories with
7535           appropriate permissions (770 <tt>root.games</tt>, for
7536           example).  They must not be made
7537           set-<em>user</em>-id, as this causes security problems. (If
7538           an attacker can subvert any set-user-id game they can
7539           overwrite the executable of any other, causing other players
7540           of these games to run a Trojan horse program.  With a
7541           set-group-id game the attacker only gets access to less
7542           important game data, and if they can get at the other
7543           players' accounts at all it will take considerably more
7544           effort.)</p>
7545
7546         <p>
7547           Some packages, for example some fortune cookie programs, are
7548           configured by the upstream authors to install with their
7549           data files or other static information made unreadable so
7550           that they can only be accessed through set-id programs
7551           provided.  You should not do this in a Debian package: anyone can
7552           download the <file>.deb</file> file and read the data from it,
7553           so there is no point making the files unreadable.  Not
7554           making the files unreadable also means that you don't have
7555           to make so many programs set-id, which reduces the risk of a
7556           security hole.</p>
7557
7558         <p>
7559           As described in the FHS, binaries of games should be
7560           installed in the directory <file>/usr/games</file>. This also
7561           applies to games that use the X Window System. Manual pages
7562           for games (X and non-X games) should be installed in
7563           <file>/usr/share/man/man6</file>.</p>
7564       </sect>
7565     </chapt>
7566
7567     <chapt id="docs"><heading>Documentation</heading>
7568
7569
7570       <sect>
7571         <heading>Manual pages</heading>
7572
7573         <p>
7574           You should install manual pages in <prgn>nroff</prgn> source
7575           form, in appropriate places under <file>/usr/share/man</file>.
7576           You should only use sections 1 to 9 (see the FHS for more
7577           details).  You must not install a preformatted "cat page".
7578         </p>
7579
7580         <p>
7581           Each program, utility, and function should have an
7582           associated manual page included in the same package. It is
7583           suggested that all configuration files also have a manual
7584           page included as well. Manual pages for protocols and other
7585           auxiliary things are optional.
7586         </p>
7587
7588         <p>
7589           If no manual page is available, this is considered as a bug
7590           and should be reported to the Debian Bug Tracking System (the
7591           maintainer of the package is allowed to write this bug report
7592           themselves, if they so desire).  Do not close the bug report
7593           until a proper manpage is available.<footnote>
7594             <p>
7595               It is not very hard to write a man page. See the 
7596               <url id="http://www.schweikhardt.net/man_page_howto.html"
7597                 name="Man-Page-HOWTO">, 
7598               <manref name="man" section="7">, the examples
7599               created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7600               the helper programs <prgn>help2man</prgn>, or the
7601               directory <file>/usr/share/doc/man-db/examples</file>.
7602             </p>
7603           </footnote>
7604         </p>
7605
7606         <p>
7607           You may forward a complaint about a missing manpage to the
7608           upstream authors, and mark the bug as forwarded in the
7609           Debian bug tracking system.  Even though the GNU Project do
7610           not in general consider the lack of a manpage to be a bug,
7611           we do; if they tell you that they don't consider it a bug
7612           you should leave the bug in our bug tracking system open
7613           anyway.
7614         </p>
7615
7616         <p>
7617           Manual pages should be installed compressed using <tt>gzip -9</tt>.
7618         </p>
7619
7620         <p>
7621           If one manpage needs to be accessible via several names it
7622           is better to use a symbolic link than the <file>.so</file>
7623           feature, but there is no need to fiddle with the relevant
7624           parts of the upstream source to change from <file>.so</file> to
7625           symlinks: don't do it unless it's easy.  You should not
7626           create hard links in the manual page directories, nor put
7627           absolute filenames in <file>.so</file> directives.  The filename
7628           in a <file>.so</file> in a manpage should be relative to the
7629           base of the manpage tree (usually
7630           <file>/usr/share/man</file>). If you do not create any links
7631           (whether symlinks, hard links, or <tt>.so</tt> directives)
7632           in the filesystem to the alternate names of the manpage,
7633           then you should not rely on <prgn>man</prgn> finding your
7634           manpage under those names based solely on the information in
7635           the manpage's header.<footnote>
7636             <p>
7637               Supporting this in <prgn>man</prgn> often requires
7638               unreasonable processing time to find a manual page or to
7639               report that none exists, and moves knowledge into man's
7640               database that would be better left in the filesystem.
7641               This support is therefore deprecated and will cease to
7642               be present in the future.
7643             </p>
7644           </footnote>
7645         </p>
7646       </sect>
7647
7648       <sect>
7649         <heading>Info documents</heading>
7650
7651         <p>
7652           Info documents should be installed in <file>/usr/share/info</file>.
7653           They should be compressed with <tt>gzip -9</tt>.
7654         </p>
7655
7656         <p>
7657           Your package should call <prgn>install-info</prgn> to update
7658           the Info <file>dir</file> file in its <prgn>postinst</prgn>
7659           script when called with a <tt>configure</tt> argument, for
7660           example:
7661           <example compact="compact">
7662 install-info --quiet --section Development Development \
7663   /usr/share/info/foobar.info
7664           </example></p>
7665
7666         <p>
7667           It is a good idea to specify a section for the location of
7668           your program; this is done with the <tt>--section</tt>
7669           switch.  To determine which section to use, you should look
7670           at <file>/usr/share/info/dir</file> on your system and choose the most
7671           relevant (or create a new section if none of the current
7672           sections are relevant).  Note that the <tt>--section</tt>
7673           flag takes two arguments; the first is a regular expression
7674           to match (case-insensitively) against an existing section,
7675           the second is used when creating a new one.</p>
7676
7677         <p>
7678           You should remove the entries in the <prgn>prerm</prgn>
7679           script when called with a <tt>remove</tt> argument:
7680           <example compact="compact">
7681 install-info --quiet --remove /usr/share/info/foobar.info
7682           </example></p>
7683
7684         <p>
7685           If <prgn>install-info</prgn> cannot find a description entry
7686           in the Info file you must supply one.  See <manref
7687           name="install-info" section="8"> for details.</p>
7688       </sect>
7689
7690       <sect>
7691         <heading>Additional documentation</heading>
7692
7693         <p>
7694           Any additional documentation that comes with the package may
7695           be installed at the discretion of the package maintainer.
7696           Text documentation should be installed in the directory
7697           <file>/usr/share/doc/<var>package</var></file>, where
7698           <var>package</var> is the name of the package, and
7699           compressed with <tt>gzip -9</tt> unless it is small.
7700         </p>
7701
7702         <p>
7703           If a package comes with large amounts of documentation which
7704           many users of the package will not require you should create
7705           a separate binary package to contain it, so that it does not
7706           take up disk space on the machines of users who do not need
7707           or want it installed.</p>
7708
7709         <p>
7710           It is often a good idea to put text information files
7711           (<file>README</file>s, changelogs, and so forth) that come with
7712           the source package in <file>/usr/share/doc/<var>package</var></file>
7713           in the binary package.  However, you don't need to install
7714           the instructions for building and installing the package, of
7715           course!</p>
7716
7717         <p>
7718           Packages must not require the existance of any files in
7719           <file>/usr/share/doc/</file> in order to function
7720           <footnote>
7721             <p>
7722               The system administrator should be able to
7723               delete files in <file>/usr/share/doc/</file> without causing
7724               any programs to break.
7725             </p>
7726           </footnote>.
7727           Any files that are referenced by programs but are also
7728           useful as standalone documentation should be installed under
7729           <file>/usr/share/<var>package</var>/</file> with symbolic links from
7730           <file>/usr/share/doc/<var>package</var></file>.
7731         </p>
7732
7733         <p>
7734           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7735           link to another directory in <file>/usr/share/doc</file> only if
7736           the two packages both come from the same source and the
7737           first package Depends on the second.
7738         </p>
7739
7740         <p>
7741           Former Debian releases placed all additional documentation
7742           in <file>/usr/doc/<var>package</var></file>.  This has been
7743           changed to <file>/usr/share/doc/<var>package</var></file>,
7744           and packages must not put documentation in the directory
7745           <file>/usr/doc/<var>package</var></file>. <footnote>
7746             <p>At this phase of the transition, we no longer require a
7747             symbolic link in <file>/usr/doc/</file>. At a later point,
7748             policy shall change to make the symbolic links a bug.</p>
7749           </footnote>
7750         </p>
7751       </sect>
7752
7753       <sect>
7754         <heading>Preferred documentation formats</heading>
7755
7756         <p>
7757           The unification of Debian documentation is being carried out
7758           via HTML.</p>
7759
7760         <p>
7761           If your package comes with extensive documentation in a
7762           markup format that can be converted to various other formats
7763           you should if possible ship HTML versions in a binary
7764           package, in the directory
7765           <file>/usr/share/doc/<var>appropriate-package</var></file> or
7766           its subdirectories.<footnote>
7767             <p>
7768               The rationale: The important thing here is that HTML
7769               docs should be available in <em>some</em> package, not
7770               necessarily in the main binary package.
7771             </p>
7772           </footnote>
7773         </p>
7774
7775         <p>
7776           Other formats such as PostScript may be provided at the
7777           package maintainer's discretion.
7778         </p>
7779       </sect>
7780
7781       <sect id="copyrightfile">
7782         <heading>Copyright information</heading>
7783
7784         <p>
7785           Every package must be accompanied by a verbatim copy of its
7786           copyright and distribution license in the file
7787           <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7788           file must neither be compressed nor be a symbolic link.
7789         </p>
7790
7791         <p>
7792           In addition, the copyright file must say where the upstream
7793           sources (if any) were obtained.  It should name the original
7794           authors of the package and the Debian maintainer(s) who were
7795           involved with its creation.</p>
7796
7797         <p>
7798           A copy of the file which will be installed in
7799           <file>/usr/share/doc/<var>package</var>/copyright</file> should
7800           be in <file>debian/copyright</file> in the source package.
7801         </p>
7802
7803         <p>
7804           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7805           link to another directory in <file>/usr/share/doc</file> only if
7806           the two packages both come from the same source and the
7807           first package Depends on the second.  These rules are
7808           important because copyrights must be extractable by
7809           mechanical means.
7810         </p>
7811
7812         <p>
7813           Packages distributed under the UCB BSD license, the Artistic
7814           license, the GNU GPL, and the GNU LGPL should refer to the
7815           files <file>/usr/share/common-licenses/BSD</file>,
7816           <file>/usr/share/common-licenses/Artistic</file>,
7817           <file>/usr/share/common-licenses/GPL</file>, and
7818           <file>/usr/share/common-licenses/LGPL</file> respectively,
7819           rather than quoting them in the copyright file.
7820         </p>
7821
7822         <p>
7823           You should not use the copyright file as a general <file>README</file>
7824           file.  If your package has such a file it should be
7825           installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7826           <file>README.Debian</file> or some other appropriate place.</p>
7827       </sect>
7828
7829       <sect>
7830         <heading>Examples</heading>
7831
7832         <p>
7833           Any examples (configurations, source files, whatever),
7834           should be installed in a directory
7835           <file>/usr/share/doc/<var>package</var>/examples</file>.  These
7836           files should not be referenced by any program: they're there
7837           for the benefit of the system administrator and users as
7838           documentation only.  Architecture-specific example files
7839           should be installed in a directory
7840           <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7841           links to them from
7842           <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7843           latter directory itself may be a symbolic link to the
7844           former.
7845         </p>
7846
7847         <p>
7848           If the purpose of a package is to provide examples, then the
7849           example files may be installed into
7850           <file>/usr/share/doc/<var>package</var></file>.
7851         </p>
7852       </sect>
7853
7854       <sect id="changelogs">
7855         <heading>Changelog files</heading>
7856
7857         <p>
7858           The Debian changelog file (<file>debian/changelog</file>) should
7859           explain briefly what modifications were made in the Debian version
7860           of the package compared to the upstream one. Other changes and
7861           updates to the package should also be documented in this file.
7862         </p>
7863
7864         <p>
7865           Mistakes in changelogs are usually best rectified by
7866           making a new changelog entry rather than "rewriting history"
7867           by editing old changelog entries.
7868         </p>
7869
7870         <p>
7871           The format of the <file>debian/changelog</file> file is described
7872           in <ref id="dpkgchangelog">. In non-experimental packages you must
7873           use a format for <file>debian/changelog</file> which is supported
7874           by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7875             <p>
7876               If you wish to use an alternative format, you may do so as
7877               long as you include a parser for it in your source package.
7878               The parser must have an API compatible with that expected by
7879               <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7880               If there is general interest in the new format, you should
7881               contact the <package>dpkg</package> maintainer to have the
7882               parser script for it included in the <prgn>dpkg</prgn>
7883               package.  (You will need to agree that the parser and its
7884               manpage may be distributed under the GNU GPL, just as the rest
7885               of <prgn>dpkg</prgn> is.)
7886             </p>
7887           </footnote>
7888         </p>
7889
7890         <p>
7891           Packages that are not Debian-native must contain a
7892           compressed copy of the <file>debian/changelog</file> file from
7893           the Debian source tree in
7894           <file>/usr/share/doc/<var>package</var></file> with the name
7895           <file>changelog.Debian.gz</file>.
7896         </p>
7897
7898         <p>
7899           If an upstream changelog is available, it should be accessible as
7900           <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7901           plain text.  If the upstream changelog is distributed in
7902           HTML, it should be made available in that form as
7903           <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7904           and a plain text <file>changelog.gz</file> should be generated
7905           from it using, for example, <tt>lynx -dump -nolist</tt>.  If
7906           the upstream changelog files do not already conform to this
7907           naming convention, then this may be achieved either by
7908           renaming the files, or by adding a symbolic link, at the
7909           maintainer's discretion.<footnote>
7910             <p>
7911               Rationale: People should not have to look in places for
7912               upstream changelogs merely because they are given
7913               different names or are distributed in HTML format.
7914             </p>
7915           </footnote>
7916         </p>
7917
7918         <p>
7919           All of these files should be installed compressed using
7920           <tt>gzip -9</tt>, as they will become large with time even
7921           if they start out small.
7922         </p>
7923
7924         <p>
7925           If the package has only one changelog which is used both as
7926           the Debian changelog and the upstream one because there is
7927           no separate upstream maintainer then that changelog should
7928           usually be installed as
7929           <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7930           there is a separate upstream maintainer, but no upstream
7931           changelog, then the Debian changelog should still be called
7932           <file>changelog.Debian.gz</file>.</p>
7933
7934       </sect>
7935     </chapt>
7936
7937     <appendix id="pkg-scope">
7938       <heading>Introduction and scope of these appendices</heading>
7939
7940       <p>
7941         These appendices are taken essentially verbatim from the
7942         now-deprecated Packaging Manual, version 3.2.1.0.  They are
7943         the chapters which are likely to be of use to package
7944         maintainers and which have not already been included in the
7945         policy document itself. Most of these sections are very likely
7946         not relevant to policy; they should be treated as
7947         documentation for the packaging system. Please note that these
7948         appendices are included for convenience, and for historical
7949         reasons: they used to be part of policy package, and they have
7950         not yet been incorporated into dpkg documentation. However,
7951         they still have value, and hence they are presented here.
7952       </p>
7953       <p>
7954         They have not yet been checked to ensure that they are
7955         compatible with the contents of policy, and if there are any
7956         contradictions, the version in the main policy document takes
7957         precedence.  The remaining chapters of the old Packaging
7958         Manual have also not been read in detail to ensure that there
7959         are not parts which have been left out.  Both of these will be
7960         done in due course.
7961       </p>
7962
7963       <p>
7964         <prgn>dpkg</prgn> is a suite of programs for creating binary
7965         package files and installing and removing them on Unix
7966         systems.<footnote>
7967           <p>
7968             <prgn>dpkg</prgn> is targetted primarily at Debian
7969             GNU/Linux, but may work on or be ported to other
7970             systems.
7971           </p>
7972         </footnote>
7973       </p>
7974
7975       <p>
7976         The binary packages are designed for the management of
7977         installed executable programs (usually compiled binaries) and
7978         their associated data, though source code examples and
7979         documentation are provided as part of some packages.</p>
7980
7981       <p>
7982         This manual describes the technical aspects of creating Debian
7983         binary packages (<file>.deb</file> files).  It documents the
7984         behaviour of the package management programs
7985         <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7986         they interact with packages.</p>
7987
7988       <p>
7989         It also documents the interaction between
7990         <prgn>dselect</prgn>'s core and the access method scripts it
7991         uses to actually install the selected packages, and describes
7992         how to create a new access method.</p>
7993
7994       <p>
7995         This manual does not go into detail about the options and
7996         usage of the package building and installation tools.  It
7997         should therefore be read in conjuction with those programs'
7998         manpages.
7999       </p>
8000
8001       <p>
8002         The utility programs which are provided with <prgn>dpkg</prgn>
8003         for managing various system configuration and similar issues,
8004         such as <prgn>update-rc.d</prgn> and
8005         <prgn>install-info</prgn>, are not described in detail here -
8006         please see their manpages.
8007       </p>
8008
8009       <p>
8010         It is assumed that the reader is reasonably familiar with the
8011         <prgn>dpkg</prgn> System Administrators' manual.
8012         Unfortunately this manual does not yet exist.
8013       </p>
8014
8015       <p>
8016         The Debian version of the FSF's GNU hello program is provided
8017         as an example for people wishing to create Debian
8018         packages. The Debian <prgn>debmake</prgn> package is
8019         recommended as a very helpful tool in creating and maintaining
8020         Debian packages. However, while the tools and examples are
8021         helpful, they do not replace the need to read and follow the
8022         Policy and Programmer's Manual.</p>
8023     </appendix>
8024
8025     <appendix id="pkg-binarypkg"><heading>Binary packages (from old
8026     Packaging Manual)
8027       </heading>
8028
8029       <p>
8030         The binary package has two main sections.  The first part
8031         consists of various control information files and scripts used
8032         by <prgn>dpkg</prgn> when installing and removing.  See <ref
8033         id="pkg-controlarea">.
8034       </p>
8035
8036       <p>
8037         The second part is an archive containing the files and
8038         directories to be installed.
8039       </p>
8040
8041       <p>
8042         In the future binary packages may also contain other
8043         components, such as checksums and digital signatures. The
8044         format for the archive is described in full in the
8045         <file>deb(5)</file> manpage.
8046       </p>
8047
8048
8049       <sect id="pkg-bincreating"><heading>Creating package files -
8050       <prgn>dpkg-deb</prgn>
8051         </heading>
8052
8053         <p>
8054           All manipulation of binary package files is done by
8055           <prgn>dpkg-deb</prgn>; it's the only program that has
8056           knowledge of the format.  (<prgn>dpkg-deb</prgn> may be
8057           invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
8058           will spot that the options requested are appropriate to
8059           <prgn>dpkg-deb</prgn> and invoke that instead with the same
8060           arguments.)
8061         </p>
8062
8063         <p>
8064           In order to create a binary package you must make a
8065           directory tree which contains all the files and directories
8066           you want to have in the filesystem data part of the package.
8067           In Debian-format source packages this directory is usually
8068           <file>debian/tmp</file>, relative to the top of the package's
8069           source tree.
8070         </p>
8071
8072         <p>
8073           They should have the locations (relative to the root of the
8074           directory tree you're constructing) ownerships and
8075           permissions which you want them to have on the system when
8076           they are installed.
8077         </p>
8078
8079         <p>
8080           With current versions of <prgn>dpkg</prgn> the uid/username
8081           and gid/groupname mappings for the users and groups being
8082           used should be the same on the system where the package is
8083           built and the one where it is installed.
8084         </p>
8085
8086         <p>
8087           You need to add one special directory to the root of the
8088           miniature filesystem tree you're creating:
8089           <prgn>DEBIAN</prgn>.  It should contain the control
8090           information files, notably the binary package control file
8091           (see <ref id="pkg-controlfile">).
8092         </p>
8093
8094         <p>
8095           The <prgn>DEBIAN</prgn> directory will not appear in the
8096           filesystem archive of the package, and so won't be installed
8097           by <prgn>dpkg</prgn> when the package is installed.
8098         </p>
8099
8100         <p>
8101           When you've prepared the package, you should invoke:
8102           <example>
8103   dpkg --build <var>directory</var>
8104           </example>
8105         </p>
8106
8107         <p>
8108           This will build the package in
8109           <file><var>directory</var>.deb</file>.  (<prgn>dpkg</prgn> knows
8110           that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8111           it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8112           build the package.)
8113         </p>
8114
8115         <p>
8116           See the manpage <manref name="dpkg-deb" section="8"> for details of how
8117           to examine the contents of this newly-created file.  You may find the
8118           output of following commands enlightening:
8119           <example>
8120   dpkg-deb --info <var>filename</var>.deb
8121   dpkg-deb --contents <var>filename</var>.deb
8122   dpkg --contents <var>filename</var>.deb
8123           </example>
8124           To view the copyright file for a package you could use this command:
8125           <example>
8126   dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8127           </example>
8128         </p>
8129       </sect>
8130
8131       <sect id="pkg-controlarea">
8132         <heading>
8133           Package control information files
8134         </heading>
8135
8136         <p>
8137           The control information portion of a binary package is a
8138           collection of files with names known to <prgn>dpkg</prgn>.
8139           It will treat the contents of these files specially - some
8140           of them contain information used by <prgn>dpkg</prgn> when
8141           installing or removing the package; others are scripts which
8142           the package maintainer wants <prgn>dpkg</prgn> to run.
8143         </p>
8144
8145         <p>
8146           It is possible to put other files in the package control
8147           area, but this is not generally a good idea (though they
8148           will largely be ignored).
8149         </p>
8150
8151         <p>
8152           Here is a brief list of the control info files supported by
8153           <prgn>dpkg</prgn> and a summary of what they're used for.
8154         </p>
8155
8156         <p>
8157           <taglist>
8158             <tag><tt>control</tt>
8159             <item>
8160
8161               <p>
8162                 This is the key description file used by
8163                 <prgn>dpkg</prgn>.  It specifies the package's name
8164                 and version, gives its description for the user,
8165                 states its relationships with other packages, and so
8166                 forth.  See <ref id="pkg-controlfile">.
8167               </p>
8168
8169               <p>
8170                 It is usually generated automatically from information
8171                 in the source package by the
8172                 <prgn>dpkg-gencontrol</prgn> program, and with
8173                 assistance from <prgn>dpkg-shlibdeps</prgn>.  See <ref
8174                 id="pkg-sourcetools">.</p>
8175             </item>
8176
8177             <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8178             <tt>prerm</tt>
8179             </tag>
8180             <item>
8181
8182               <p>
8183                 These are exectuable files (usually scripts) which
8184                 <prgn>dpkg</prgn> runs during installation, upgrade
8185                 and removal of packages.  They allow the package to
8186                 deal with matters which are particular to that package
8187                 or require more complicated processing than that
8188                 provided by <prgn>dpkg</prgn>.  Details of when and
8189                 how they are called are in <ref
8190                 id="maintainerscripts">.
8191               </p>
8192
8193               <p>
8194                 It is very important to make these scripts
8195                 idempotent.
8196                 <footnote>
8197                   <p>
8198                     That means that if it runs successfully or fails
8199                     and then you call it again it doesn't bomb out,
8200                     but just ensures that everything is the way it
8201                     ought to be.
8202                   </p>
8203                 </footnote> This is so that if an error occurs, the
8204                 user interrupts <prgn>dpkg</prgn> or some other
8205                 unforeseen circumstance happens you don't leave the
8206                 user with a badly-broken package.
8207               </p>
8208
8209               <p>
8210                 The maintainer scripts are guaranteed to run with a
8211                 controlling terminal and can interact with the user.
8212                 If they need to prompt for passwords, do full-screen
8213                 interaction or something similar you should do these
8214                 things to and from <file>/dev/tty</file>, since
8215                 <prgn>dpkg</prgn> will at some point redirect scripts'
8216                 standard input and output so that it can log the
8217                 installation process.  Likewise, because these scripts
8218                 may be executed with standard output redirected into a
8219                 pipe for logging purposes, Perl scripts should set
8220                 unbuffered output by setting <tt>$|=1</tt> so that the
8221                 output is printed immediately rather than being
8222                 buffered.
8223               </p>
8224
8225               <p>
8226                 Each script should return a zero exit status for
8227                 success, or a nonzero one for failure.</p>
8228             </item>
8229
8230             <tag><tt>conffiles</tt>
8231             </tag>
8232             <item>
8233
8234               <p>
8235                 This file contains a list of configuration files which
8236                 are to be handled automatically by <prgn>dpkg</prgn>
8237                 (see <ref id="pkg-conffiles">).  Note that not necessarily
8238                 every configuration file should be listed here.</p>
8239             </item>
8240
8241             <tag><tt>shlibs</tt>
8242             </tag>
8243             <item>
8244
8245               <p>
8246                 This file contains a list of the shared libraries
8247                 supplied by the package, with dependency details for
8248                 each.  This is used by <prgn>dpkg-shlibdeps</prgn>
8249                 when it determines what dependencies are required in a
8250                 package control file. The <tt>shlibs</tt> file format
8251                 is described on <ref id="shlibs">.
8252               </p>
8253             </item>
8254           </taglist>
8255         </p>
8256
8257       <sect id="pkg-controlfile">
8258         <heading>
8259           The main control information file: <tt>control</tt>
8260         </heading>
8261         <p>
8262           The most important control information file used by
8263           <prgn>dpkg</prgn> when it installs a package is
8264           <tt>control</tt>.  It contains all the package"s "vital
8265           statistics".
8266         </p>
8267
8268         <p>
8269           The binary package control files of packages built from
8270           Debian sources are made by a special tool,
8271           <prgn>dpkg-gencontrol</prgn>, which reads
8272           <file>debian/control</file> and <file>debian/changelog</file> to
8273           find the information it needs.  See <ref id="pkg-sourcepkg"> for
8274           more details.
8275         </p>
8276
8277         <p>
8278           The fields in binary package control files are:
8279           <list compact="compact">
8280             <item>
8281               <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8282             </item>
8283             <item>
8284               <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8285             </item>
8286             <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8287                 (mandatory)
8288                 <footnote>
8289                   <p>
8290                     This field should appear in all packages, though
8291                     <prgn>dpkg</prgn> doesn't require it yet so that
8292                     old packages can still be installed.
8293                   </p>
8294                 </footnote>
8295               </p>
8296             </item>
8297             <item>
8298               <p><qref id="relationships"><tt>Depends</tt>,
8299                   <tt>Provides</tt> et al.</qref></p>
8300             </item>
8301             <item>
8302               <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8303             </item>
8304             <item>
8305               <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8306             </item>
8307             <item>
8308               <p><qref id="pkg-f-classification"><tt>Section</tt>,
8309                   <tt>Priority</tt></qref></p>
8310             </item>
8311             <item>
8312               <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8313             </item>
8314             <item>
8315               <p><qref id="descriptions"><tt>Description</tt></qref></p>
8316             </item>
8317             <item>
8318               <p>
8319                 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8320               </p>
8321             </item>
8322           </list>
8323
8324         <p>
8325           A description of the syntax of control files and the purpose
8326           of these fields is available in <ref id="pkg-controlfields">.
8327         </p>
8328       </sect>
8329
8330       <sect>
8331         <heading>Time Stamps</heading>
8332         <p>
8333           Maintainers are encouraged to preserve the modification
8334           times of the upstream source files in a package, as far as
8335           is reasonably possible.
8336           <footnote>
8337             <p>
8338               The rationale is that there is some information conveyed
8339               by knowing the age of the file, for example, you could
8340               recognize that some documentation is very old by looking
8341               at the modification time, so it would be nice if the
8342               modification time of the upstream source would be
8343               preserved.
8344             </p>
8345           </footnote>
8346         </p>
8347       </sect>
8348     </appendix>
8349
8350     <appendix id="pkg-sourcepkg">
8351       <heading>Source packages (from old Packaging Manual) </heading>
8352
8353       <p>
8354         The Debian binary packages in the distribution are generated
8355         from Debian sources, which are in a special format to assist
8356         the easy and automatic building of binaries.
8357       </p>
8358
8359       <sect id="pkg-sourcetools">
8360         <heading>Tools for processing source packages</heading>
8361
8362         <p>
8363           Various tools are provided for manipulating source packages;
8364           they pack and unpack sources and help build of binary
8365           packages and help manage the distribution of new versions.
8366         </p>
8367
8368         <p>
8369           They are introduced and typical uses described here; see
8370           <manref name="dpkg-source" section="1"> for full
8371           documentation about their arguments and operation.
8372         </p>
8373
8374         <p>
8375           For examples of how to construct a Debian source package,
8376           and how to use those utilities that are used by Debian
8377           source packages, please see the <prgn>hello</prgn> example
8378           package.
8379         </p>
8380
8381         <sect1>
8382           <heading>
8383             <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8384             packages
8385           </heading>
8386
8387           <p>
8388             This program is frequently used by hand, and is also
8389             called from package-independent automated building scripts
8390             such as <prgn>dpkg-buildpackage</prgn>.
8391           </p>
8392
8393           <p>
8394             To unpack a package it is typically invoked with
8395             <example>
8396   dpkg-source -x <var>.../path/to/filename</var>.dsc
8397             </example>
8398           </p>
8399
8400            <p>
8401             with the <file><var>filename</var>.tar.gz</file> and
8402             <file><var>filename</var>.diff.gz</file> (if applicable) in
8403             the same directory.  It unpacks into
8404             <file><var>package</var>-<var>version</var></file>, and if
8405             applicable
8406             <file><var>package</var>-<var>version</var>.orig</file>, in
8407             the current directory.
8408           </p>
8409
8410           <p>
8411             To create a packed source archive it is typically invoked:
8412             <example>
8413   dpkg-source -b <var>package</var>-<var>version</var>
8414           </example>
8415           </p>
8416
8417           <p>
8418             This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8419             <file>.diff.gz</file> (if appropriate) in the current
8420             directory.  <prgn>dpkg-source</prgn> does not clean the
8421             source tree first - this must be done separately if it is
8422             required.
8423           </p>
8424
8425           <p>
8426             See also <ref id="pkg-sourcearchives">.</p>
8427         </sect1>
8428
8429
8430         <sect1>
8431           <heading>
8432             <prgn>dpkg-buildpackage</prgn> - overall package-building
8433             control script
8434           </heading>
8435
8436           <p>
8437             <prgn>dpkg-buildpackage</prgn> is a script which invokes
8438             <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8439             targets <tt>clean</tt>, <tt>build</tt> and
8440             <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8441             <prgn>pgp</prgn> to build a signed source and binary
8442             package upload.
8443           </p>
8444
8445           <p>
8446             It is usually invoked by hand from the top level of the
8447             built or unbuilt source directory.  It may be invoked with
8448             no arguments; useful arguments include:
8449             <taglist compact="compact">
8450               <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8451               <item>
8452                 <p>
8453                   Do not PGP-sign the <tt>.changes</tt> file or the
8454                   source package <tt>.dsc</tt> file, respectively.</p>
8455               </item>
8456               <tag><tt>-p<var>pgp-command</var></tt></tag>
8457               <item>
8458                 <p>
8459                   Invoke <var>pgp-command</var> instead of finding
8460                   <tt>pgp</tt> on the <prgn>PATH</prgn>.
8461                   <var>pgp-command</var> must behave just like
8462                   <prgn>pgp</prgn>.</p>
8463               </item>
8464               <tag><tt>-r<var>root-command</var></tt></tag>
8465               <item>
8466                 <p>
8467                   When root privilege is required, invoke the command
8468                   <var>root-command</var>.  <var>root-command</var>
8469                   should invoke its first argument as a command, from
8470                   the <prgn>PATH</prgn> if necessary, and pass its
8471                   second and subsequent arguments to the command it
8472                   calls.  If no <var>root-command</var> is supplied
8473                   then <var>dpkg-buildpackage</var> will take no
8474                   special action to gain root privilege, so that for
8475                   most packages it will have to be invoked as root to
8476                   start with.</p>
8477               </item>
8478               <tag><tt>-b</tt>, <tt>-B</tt></tag>
8479               <item>
8480                 <p>
8481                   Two types of binary-only build and upload - see
8482                   <manref name="dpkg-source" section="1">.
8483                 </p>
8484               </item>
8485             </taglist>
8486           </p>
8487         </sect1>
8488
8489         <sect1>
8490           <heading>
8491             <prgn>dpkg-gencontrol</prgn> - generates binary package
8492             control files
8493           </heading>
8494
8495           <p>
8496             This program is usually called from <file>debian/rules</file>
8497             (see <ref id="pkg-sourcetree">) in the top level of the source
8498             tree.
8499           </p>
8500
8501           <p>
8502             This is usually done just before the files and directories in the
8503             temporary directory tree where the package is being built have their
8504             permissions and ownerships set and the package is constructed using
8505             <prgn>dpkg-deb/</prgn>
8506               <footnote>
8507               <p>
8508                 This is so that the control file which is produced has
8509                 the right permissions
8510               </p>
8511             </footnote>.
8512           </p>
8513
8514           <p>
8515             <prgn>dpkg-gencontrol</prgn> must be called after all the
8516             files which are to go into the package have been placed in
8517             the temporary build directory, so that its calculation of
8518             the installed size of a package is correct.
8519           </p>
8520
8521           <p>
8522             It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8523             be run after <prgn>dpkg-shlibdeps</prgn> so that the
8524             variable substitutions created by
8525             <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8526             are available.
8527           </p>
8528
8529           <p>
8530             For a package which generates only one binary package, and
8531             which builds it in <file>debian/tmp</file> relative to the top
8532             of the source package, it is usually sufficient to call
8533             <prgn>dpkg-gencontrol</prgn>.
8534           </p>
8535
8536           <p>
8537             Sources which build several binaries will typically need
8538             something like:
8539             <example>
8540   dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8541             </example> The <tt>-P</tt> tells
8542             <prgn>dpkg-gencontrol</prgn> that the package is being
8543             built in a non-default directory, and the <tt>-p</tt>
8544             tells it which package's control file should be generated.
8545           </p>
8546
8547           <p>
8548             <prgn>dpkg-gencontrol</prgn> also adds information to the
8549             list of files in <file>debian/files</file>, for the benefit of
8550             (for example) a future invocation of
8551             <prgn>dpkg-genchanges</prgn>.</p>
8552         </sect1>
8553
8554         <sect1>
8555           <heading>
8556             <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8557             dependencies
8558           </heading>
8559
8560           <p>
8561             This program is usually called from <file>debian/rules</file>
8562             just before <prgn>dpkg-gencontrol</prgn> (see <ref
8563             id="pkg-sourcetree">), in the top level of the source tree.
8564           </p>
8565
8566           <p>
8567             Its arguments are executables.
8568             <footnote>
8569               <p>
8570                 In a forthcoming dpkg version,
8571                 <prgn>dpkg-shlibdeps</prgn> would be required to be
8572                 called on shared libraries as well.
8573               </p>
8574               <p>
8575                 They may be specified either in the locations in the
8576                 source tree where they are created or in the locations
8577                 in the temporary build tree where they are installed
8578                 prior to binary package creation.
8579               </p>
8580             </footnote> for which shared library dependencies should
8581             be included in the binary package's control file.
8582           </p>
8583
8584           <p>
8585             If some of the found shared libraries should only
8586             warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8587             some warrant a <tt>Pre-Depends</tt>, this can be achieved
8588             by using the <tt>-d<var>dependency-field</var></tt> option
8589             before those executable(s).  (Each <tt>-d</tt> option
8590             takes effect until the next <tt>-d</tt>.)
8591           </p>
8592
8593           <p>
8594             <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8595             output control file to be modified.  Instead by default it
8596             adds to the <file>debian/substvars</file> file variable
8597             settings like <tt>shlibs:Depends</tt>.  These variable
8598             settings must be referenced in dependency fields in the
8599             appropriate per-binary-package sections of the source
8600             control file.
8601           </p>
8602
8603           <p>
8604             For example, the <prgn>procps</prgn> package generates two
8605             kinds of binaries, simple C binaries like <prgn>ps</prgn>
8606             which require a predependency and full-screen ncurses
8607             binaries like <prgn>top</prgn> which require only a
8608             recommendation.  It can say in its <file>debian/rules</file>:
8609             <example>
8610   dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8611             </example>
8612             and then in its main control file <file>debian/control</file>:
8613             <example>
8614   <var>...</var>
8615   Package: procps
8616   Pre-Depends: ${shlibs:Pre-Depends}
8617   Recommends: ${shlibs:Recommends}
8618   <var>...</var>
8619             </example>
8620           </p>
8621
8622           <p>
8623             Sources which produce several binary packages with
8624             different shared library dependency requirements can use
8625             the <tt>-p<var>varnameprefix</var></tt> option to override
8626             the default <tt>shlibs:</tt> prefix (one invocation of
8627             <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8628             They can thus produce several sets of dependency
8629             variables, each of the form
8630             <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8631             which can be referred to in the appropriate parts of the
8632             binary package control files.
8633           </p>
8634         </sect1>
8635
8636
8637         <sect1>
8638           <heading>
8639             <prgn>dpkg-distaddfile</prgn> - adds a file to
8640             <file>debian/files</file>
8641           </heading>
8642
8643           <p>
8644             Some packages' uploads need to include files other than
8645             the source and binary package files.
8646           </p>
8647
8648           <p>
8649             <prgn>dpkg-distaddfile</prgn> adds a file to the
8650             <file>debian/files</file> file so that it will be included in
8651             the <file>.changes</file> file when
8652             <prgn>dpkg-genchanges</prgn> is run.
8653           </p>
8654
8655           <p>
8656             It is usually invoked from the <tt>binary</tt> target of
8657             <file>debian/rules</file>:
8658             <example>
8659   dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8660             </example>
8661             The <var>filename</var> is relative to the directory where
8662             <prgn>dpkg-genchanges</prgn> will expect to find it - this
8663             is usually the directory above the top level of the source
8664             tree.  The <file>debian/rules</file> target should put the
8665             file there just before or just after calling
8666             <prgn>dpkg-distaddfile</prgn>.
8667           </p>
8668
8669           <p>
8670             The <var>section</var> and <var>priority</var> are passed
8671             unchanged into the resulting <file>.changes</file> file.  See
8672             <ref id="pkg-f-classification">.
8673           </p>
8674         </sect1>
8675
8676
8677         <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8678             control file
8679           </heading>
8680
8681           <p>
8682             This program is usually called by package-independent
8683             automatic building scripts such as
8684             <prgn>dpkg-buildpackage</prgn>, but it may also be called
8685             by hand.
8686           </p>
8687
8688           <p>
8689             It is usually called in the top level of a built source
8690             tree, and when invoked with no arguments will print out a
8691             straightforward <file>.changes</file> file based on the
8692             information in the source package's changelog and control
8693             file and the binary and source packages which should have
8694             been built.
8695           </p>
8696         </sect1>
8697
8698
8699         <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8700             a changelog
8701           </heading>
8702
8703           <p>
8704             This program is used internally by
8705             <prgn>dpkg-source</prgn> et al.  It may also occasionally
8706             be useful in <file>debian/rules</file> and elsewhere.  It
8707             parses a changelog, <file>debian/changelog</file> by default,
8708             and prints a control-file format representation of the
8709             information in it to standard output.
8710           </p>
8711         </sect1>
8712
8713         <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8714             information about the build and host system
8715           </heading>
8716
8717           <p>
8718             This program can be used manually, but is also invoked by
8719             <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8720             to set environment or make variables which specify the build and
8721             host architecture for the package building process.
8722           </p>
8723         </sect1>
8724       </sect>
8725
8726       <sect id="pkg-sourcetree"><heading>The Debianised source tree
8727         </heading>
8728
8729         <p>
8730           The source archive scheme described later is intended to
8731           allow a Debianised source tree with some associated control
8732           information to be reproduced and transported easily.  The
8733           Debianised source tree is a version of the original program
8734           with certain files added for the benefit of the
8735           Debianisation process, and with any other changes required
8736           made to the rest of the source code and installation
8737           scripts.
8738         </p>
8739
8740         <p>
8741           The extra files created for Debian are in the subdirectory
8742           <file>debian</file> of the top level of the Debianised source
8743           tree.  They are described below.
8744         </p>
8745
8746         <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8747         script
8748           </heading>
8749
8750           <p>
8751             This file is an executable makefile, and contains the
8752             package-specific recipies for compiling the package and
8753             building binary package(s) out of the source.
8754           </p>
8755
8756           <p>
8757             It must start with the line <tt>#!/usr/bin/make -f</tt>,
8758             so that it can be invoked by saying its name rather than
8759             invoking <prgn>make</prgn> explicitly.
8760           </p>
8761
8762           <p>
8763             Since an interactive <file>debian/rules</file> script makes it
8764             impossible to autocompile that package and also makes it
8765             hard for other people to reproduce the same binary
8766             package, all <strong>required targets</strong> have to be
8767             non-interactive. At a minimul, required targets are the
8768             ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8769             <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8770             <em>build</em>. It also follows that any target that these
8771             targets depend on must also be non-interactive.
8772           </p>
8773
8774           <p>
8775             The targets which are required to be present are:
8776             <taglist>
8777               <tag><tt>build</tt></tag>
8778               <item>
8779                 <p>
8780                   This should perform all non-interactive
8781                   configuration and compilation of the package.  If a
8782                   package has an interactive pre-build configuration
8783                   routine, the Debianised source package should be
8784                   built after this has taken place, so that it can be
8785                   built without rerunning the configuration.
8786                 </p>
8787
8788                 <p>
8789                   A package may also provide both of the targets
8790                   <tt>build-arch</tt> and <tt>build-indep</tt>.  The
8791                   <tt>build-arch</tt> target, if provided, should
8792                   perform all non-interactive configuration and
8793                   compilation required for producing all
8794                   architecture-dependant binary packages (those packages
8795                   for which the body of the <tt>Architecture</tt> field
8796                   in <tt>debian/control</tt> is not <tt>all</tt>).
8797                   Similarly, the <tt>build-indep</tt> target, if
8798                   provided, should perform all non-interactive
8799                   configuration and compilation required for producing
8800                   all architecture-independent binary packages (those
8801                   packages for which the body of the
8802                   <tt>Architecture</tt> field in <tt>debian/control</tt>
8803                   is <tt>all</tt>).  The <tt>build</tt> target should
8804                   depend on those of the targets <tt>build-arch</tt> and
8805                   <tt>build-indep</tt> that are provided in the rules
8806                   file.
8807                 </p>
8808
8809                 <p>
8810                   If one or both of the targets <tt>build-arch</tt> and
8811                   <tt>build-indep</tt> are not provided, then invoking
8812                   <file>debian/rules</file> with one of the not-provided
8813                   targets as arguments should produce a exit status code
8814                   of 2.  Usually this is provided automatically by make
8815                   if the target is missing.
8816                 </p>
8817
8818                 <p>
8819                   For some packages, notably ones where the same
8820                   source tree is compiled in different ways to produce
8821                   two binary packages, the <tt>build</tt> target does
8822                   not make much sense.  For these packages it is good
8823                   enough to provide two (or more) targets
8824                   (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8825                   for each of the ways of building the package, and a
8826                   <tt>build</tt> target that does nothing.  The
8827                   <tt>binary</tt> target will have to build the
8828                   package in each of the possible ways and make the
8829                   binary package out of each.
8830                 </p>
8831
8832                 <p>
8833                   The targets <tt>build</tt>, <tt>build-arch</tt>
8834                   and <tt>build-indep</tt> target must not do
8835                   anything that might require root privilege.
8836                 </p>
8837
8838                 <p>
8839                   The <tt>build</tt> target may need to run
8840                   <tt>clean</tt> first - see below.
8841                 </p>
8842
8843                 <p>
8844                   When a package has a configuration routine that takes
8845                   a long time, or when the makefiles are poorly
8846                   designed, or when <tt>build</tt> needs to run
8847                   <tt>clean</tt> first, it is a good idea to <tt>touch
8848                     build</tt> when the build process is complete.  This
8849                   will ensure that if <tt>debian/rules build</tt> is run
8850                   again it will not rebuild the whole program.
8851                 </p>
8852               </item>
8853
8854               <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8855                 <tt>binary-indep</tt>
8856               </tag>
8857               <item>
8858                 <p>
8859                   The <tt>binary</tt> target should be all that is
8860                   necessary for the user to build the binary
8861                   package. All these targets are required to be
8862                   non-interactive.  It is split into two parts:
8863                   <tt>binary-arch</tt> builds the packages' output
8864                   files which are specific to a particular
8865                   architecture, and <tt>binary-indep</tt> builds
8866                   those which are not.
8867                 </p>
8868
8869                 <p>
8870                   <tt>binary</tt> should usually be a target with
8871                   no commands which simply depends on
8872                   <prgn>binary-arch</prgn> and
8873                   <prgn>binary-indep</prgn>.
8874                 </p>
8875
8876                 <p>
8877                   Both <prgn>binary-*</prgn> targets should depend on
8878                   the <tt>build</tt> target, above, so that the
8879                   package is built if it has not been already.  It
8880                   should then create the relevant binary package(s),
8881                   using <prgn>dpkg-gencontrol</prgn> to make their
8882                   control files and <prgn>dpkg-deb</prgn> to build
8883                   them and place them in the parent of the top level
8884                   directory.
8885                 </p>
8886
8887                 <p>
8888                   If one of the <prgn>binary-*</prgn> targets has
8889                   nothing to do (this will be always be the case if
8890                   the source generates only a single binary package,
8891                   whether architecture-dependent or not) it
8892                   <em>must</em> still exist, but should always
8893                   succeed.
8894                 </p>
8895
8896                 <p>
8897                   <ref id="pkg-binarypkg"> describes how to construct
8898                   binary packages.
8899                 </p>
8900
8901                 <p>
8902                   The <tt>binary</tt> targets must be invoked as
8903                   root.
8904                 </p>
8905               </item>
8906
8907               <tag><tt>clean</tt></tag>
8908               <item>
8909
8910                 <p>
8911                   This should undo any effects that the
8912                   <tt>build</tt> and <tt>binary</tt> targets
8913                   may have had, except that it should leave alone any
8914                   output files created in the parent directory by a
8915                   run of <tt>binary</tt>. This target is required
8916                   to be non-interactive.
8917                 </p>
8918
8919                 <p>
8920                   If a <tt>build</tt> file is touched at the end
8921                   of the <tt>build</tt> target, as suggested
8922                   above, it must be removed as the first thing that
8923                   <tt>clean</tt> does, so that running
8924                   <tt>build</tt> again after an interrupted
8925                   <tt>clean</tt> doesn't think that everything is
8926                   already done.
8927                 </p>
8928
8929                 <p>
8930                   The <tt>clean</tt> target must be invoked as
8931                   root if <tt>binary</tt> has been invoked since
8932                   the last <tt>clean</tt>, or if
8933                   <tt>build</tt> has been invoked as root (since
8934                   <tt>build</tt> may create directories, for
8935                   example).
8936                 </p>
8937               </item>
8938
8939               <tag><tt>get-orig-source</tt> (optional)</tag>
8940               <item>
8941
8942                 <p>
8943                   This target fetches the most recent version of the
8944                   original source package from a canonical archive
8945                   site (via FTP or WWW, for example), does any
8946                   necessary rearrangement to turn it into the original
8947                   source tarfile format described below, and leaves it
8948                   in the current directory.
8949                 </p>
8950
8951                 <p>
8952                   This target may be invoked in any directory, and
8953                   should take care to clean up any temporary files it
8954                   may have left.
8955                 </p>
8956
8957                 <p>
8958                   This target is optional, but providing it if
8959                   possible is a good idea.
8960                 </p>
8961               </item>
8962             </taglist>
8963
8964           <p>
8965             The <tt>build</tt>, <tt>binary</tt> and
8966             <tt>clean</tt> targets must be invoked with a current
8967             directory of the package's top-level directory.
8968           </p>
8969
8970
8971           <p>
8972             Additional targets may exist in <file>debian/rules</file>,
8973             either as published or undocumented interfaces or for the
8974             package's internal use.
8975           </p>
8976
8977           <p>
8978             The architecture we build on and build for is determined by make
8979             variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8980             get the Debian architecture and the GNU style architecture
8981             specification string for the build machine as well as the host
8982             machine. Here is a list of supported make variables:
8983             <list compact="compact">
8984               <item>
8985                 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8986               </item>
8987               <item>
8988                 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8989                   specification string)</p>
8990               </item>
8991               <item>
8992                 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8993               </item>
8994               <item>
8995                 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8996                   DEB_*_GNU_TYPE)</p>
8997             </list>
8998           </p>
8999
9000           <p>
9001             where <tt>*</tt> is either <tt>BUILD</tt> for specification of
9002             the build machine or <tt>HOST</tt> for specification of the machine
9003             we build for.
9004           </p>
9005
9006           <p>
9007             Backward compatibility can be provided in the rules file
9008             by setting the needed variables to suitable default
9009             values, please refer to the documentation of
9010             dpkg-architecture for details.
9011           </p>
9012
9013           <p>
9014             It is important to understand that the <tt>DEB_*_ARCH</tt>
9015             string does only determine which Debian architecture we
9016             build on resp. for. It should not be used to get the CPU
9017             or System information, the GNU style variables should be
9018             used for that.
9019           </p>
9020         </sect1>
9021
9022
9023         <sect1><heading><file>debian/control</file>
9024           </heading>
9025
9026           <p>
9027             This file contains version-independent details about the
9028             source package and about the binary packages it creates.
9029           </p>
9030
9031           <p>
9032             It is a series of sets of control fields, each
9033             syntactically similar to a binary package control file.
9034             The sets are separated by one or more blank lines.  The
9035             first set is information about the source package in
9036             general; each subsequent set describes one binary package
9037             that the source tree builds.
9038           </p>
9039
9040           <p>
9041             The syntax and semantics of the fields are described below
9042             in <ref id="pkg-controlfields">.
9043           </p>
9044
9045           <p>
9046             The general (binary-package-independent) fields are:
9047             <list compact="compact">
9048               <item>
9049                 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
9050               </item>
9051               <item>
9052                 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9053               </item>
9054               <item>
9055                 <p>
9056                   <qref id="pkg-f-classification"><tt>Section</tt> and
9057                     <tt>Priority</tt></qref>
9058                   (classification, mandatory)
9059                 </p>
9060               </item>
9061                <item>
9062                  <p>
9063                    <qref id="relationships"><tt>Build-Depends</tt> et
9064                      al.</qref> (source package interrelationships)
9065                  </p>
9066                </item>
9067               <item>
9068                 <p>
9069                   <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
9070                 </p>
9071               </item>
9072             </list>
9073
9074           <p>
9075             The per-binary-package fields are:
9076             <list compact="compact">
9077               <item>
9078                 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
9079               </item>
9080               <item>
9081                 <p>
9082                   <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
9083                   (mandatory)</p>
9084               </item>
9085               <item>
9086                 <p><qref id="descriptions"><tt>Description</tt></qref></p>
9087               </item>
9088               <item>
9089                 <p>
9090                   <qref id="pkg-f-classification"><tt>Section</tt> and
9091                     <tt>Priority</tt></qref> (classification)</p>
9092               </item>
9093               <item>
9094                 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
9095               </item>
9096               <item>
9097                 <p>
9098                   <qref id="relationships"><tt>Depends</tt> et
9099                   al.</qref> (binary package interrelationships)
9100                 </p>
9101               </item>
9102             </list>
9103
9104           <p>
9105             These fields are used by <prgn>dpkg-gencontrol</prgn> to
9106             generate control files for binary packages (see below), by
9107             <prgn>dpkg-genchanges</prgn> to generate the
9108             <tt>.changes</tt> file to accompany the upload, and by
9109             <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9110             source control file as part of a source archive.
9111           </p>
9112
9113           <p>
9114             The fields here may contain variable references - their
9115             values will be substituted by
9116             <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9117             or <prgn>dpkg-source</prgn> when they generate output
9118             control files.  See <ref id="pkg-srcsubstvars"> for details.
9119           </p>
9120
9121           <p> <sect2><heading>User-defined fields
9122             </heading>
9123
9124             <p>
9125               Additional user-defined fields may be added to the
9126               source package control file.  Such fields will be
9127               ignored, and not copied to (for example) binary or
9128               source package control files or upload control files.
9129             </p>
9130
9131             <p>
9132               If you wish to add additional unsupported fields to
9133               these output files you should use the mechanism
9134               described here.
9135             </p>
9136
9137             <p>
9138               Fields in the main source control information file with
9139               names starting <tt>X</tt>, followed by one or more of
9140               the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9141               be copied to the output files.  Only the part of the
9142               field name after the hyphen will be used in the output
9143               file.  Where the letter <tt>B</tt> is used the field
9144               will appear in binary package control files, where the
9145               letter <tt>S</tt> is used in source package control
9146               files and where <tt>C</tt> is used in upload control
9147               (<tt>.changes</tt>) files.
9148             </p>
9149
9150             <p>
9151               For example, if the main source information control file
9152               contains the field
9153               <example>
9154   XBS-Comment: I stand between the candle and the star.
9155               </example>
9156               then the binary and source package control files will contain the
9157               field
9158               <example>
9159   Comment: I stand between the candle and the star.
9160               </example>
9161             </p>
9162           </sect2>
9163
9164         </sect1>
9165
9166         <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9167           </heading>
9168
9169           <p>
9170             This file records the changes to the Debian-specific parts of the
9171             package
9172             <footnote>
9173               <p>
9174                 Though there is nothing stopping an author who is also
9175                 the Debian maintainer from using it for all their
9176                 changes, it will have to be renamed if the Debian and
9177                 upstream maintainers become different
9178                 people.
9179               </p>
9180             </footnote>.
9181           </p>
9182
9183           <p>
9184             It has a special format which allows the package building
9185             tools to discover which version of the package is being
9186             built and find out other release-specific information.
9187           </p>
9188
9189           <p>
9190             That format is a series of entries like this:
9191             <example>
9192   <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9193
9194    * <var>change details</var>
9195    <var>more change details</var>
9196    * <var>even more change details</var>
9197
9198   -- <var>maintainer name and email address</var>  <var>date</var>
9199             </example>
9200           </p>
9201
9202           <p>
9203             <var>package</var> and <var>version</var> are the source
9204             package name and version number.
9205           </p>
9206
9207           <p>
9208             <var>distribution(s)</var> lists the distributions where
9209             this version should be installed when it is uploaded - it
9210             is copied to the <tt>Distribution</tt> field in the
9211             <tt>.changes</tt> file.  See <ref id="pkg-f-Distribution">.
9212           </p>
9213
9214           <p>
9215             <var>urgency</var> is the value for the <tt>Urgency</tt>
9216             field in the <file>.changes</file> file for the upload.  See
9217             <ref id="pkg-f-Urgency">.  It is not possible to specify an
9218             urgency containing commas; commas are used to separate
9219             <tt><var>keyword</var>=<var>value</var></tt> settings in
9220             the <prgn>dpkg</prgn> changelog format (though there is
9221             currently only one useful <var>keyword</var>,
9222             <tt>urgency</tt>).
9223           </p>
9224
9225           <p>
9226             The change details may in fact be any series of lines
9227             starting with at least two spaces, but conventionally each
9228             change starts with an asterisk and a separating space and
9229             continuation lines are indented so as to bring them in
9230             line with the start of the text above.  Blank lines may be
9231             used here to separate groups of changes, if desired.
9232           </p>
9233
9234           <p>
9235             The maintainer name and email address should <em>not</em>
9236             necessarily be those of the usual package maintainer.
9237             They should be the details of the person doing
9238             <em>this</em> version.  The information here will be
9239             copied to the <file>.changes</file> file, and then later used
9240             to send an acknowledgement when the upload has been
9241             installed.
9242           </p>
9243
9244           <p>
9245             The <var>date</var> should be in RFC822 format
9246             <footnote>
9247               <p>
9248                 This is generated by the <prgn>822-date</prgn>
9249                 program.
9250               </p>
9251             </footnote>; it should include the timezone specified
9252             numerically, with the timezone name or abbreviation
9253             optionally present as a comment.
9254           </p>
9255
9256           <p>
9257             The first "title" line with the package name should start
9258             at the left hand margin; the "trailer" line with the
9259             maintainer and date details should be preceded by exactly
9260             one space.  The maintainer details and the date must be
9261             separated by exactly two spaces.
9262           </p>
9263
9264           <p>
9265             An Emacs mode for editing this format is available: it is
9266             called <tt>debian-changelog-mode</tt>.  You can have this
9267             mode selected automatically when you edit a Debian
9268             changelog by adding a local variables clause to the end of
9269             the changelog.
9270           </p>
9271
9272           <sect2><heading>Defining alternative changelog formats
9273             </heading>
9274
9275             <p>
9276               It is possible to use a different format to the standard
9277               one, by providing a parser for the format you wish to
9278               use.
9279             </p>
9280
9281             <p>
9282               In order to have <tt>dpkg-parsechangelog</tt> run your
9283               parser, you must include a line within the last 40 lines
9284               of your file matching the Perl regular expression:
9285               <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9286               parentheses should be the name of the format.  For
9287               example, you might say:
9288               <example>
9289   @@@ changelog-format: joebloggs @@@
9290               </example>
9291               Changelog format names are non-empty strings of alphanumerics.
9292             </p>
9293
9294             <p>
9295               If such a line exists then <tt>dpkg-parsechangelog</tt>
9296               will look for the parser as
9297               <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9298               or
9299               <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9300               it is an error for it not to find it, or for it not to
9301               be an executable program.  The default changelog format
9302               is <tt>dpkg</tt>, and a parser for it is provided with
9303               the <tt>dpkg</tt> package.
9304             </p>
9305
9306             <p>
9307               The parser will be invoked with the changelog open on
9308               standard input at the start of the file.  It should read
9309               the file (it may seek if it wishes) to determine the
9310               information required and return the parsed information
9311               to standard output in the form of a series of control
9312               fields in the standard format.  By default it should
9313               return information about only the most recent version in
9314               the changelog; it should accept a
9315               <tt>-v<var>version</var></tt> option to return changes
9316               information from all versions present <em>strictly
9317               after</em> <var>version</var>, and it should then be an
9318               error for <var>version</var> not to be present in the
9319               changelog.
9320             </p>
9321
9322             <p>
9323               The fields are:
9324               <list compact="compact">
9325                 <item>
9326                   <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9327                 </item>
9328                 <item>
9329                   <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9330                 </item>
9331                 <item>
9332                   <p>
9333                     <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9334                     (mandatory)
9335                   </p>
9336                 </item>
9337                 <item>
9338                   <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9339                 </item>
9340                 <item>
9341                   <p>
9342                     <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9343                     (mandatory)
9344                   </p>
9345                 </item>
9346                 <item>
9347                   <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9348                 </item>
9349                 <item>
9350                   <p>
9351                     <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9352                     (mandatory)
9353                   </p>
9354                 </item>
9355               </list>
9356
9357             <p>
9358               If several versions are being returned (due to the use
9359               of <tt>-v</tt>), the urgency value should be of the
9360               highest urgency code listed at the start of any of the
9361               versions requested followed by the concatenated
9362               (space-separated) comments from all the versions
9363               requested; the maintainer, version, distribution and
9364               date should always be from the most recent version.
9365             </p>
9366
9367             <p>
9368               For the format of the <tt>Changes</tt> field see <ref
9369               id="pkg-f-Changes">.
9370             </p>
9371
9372             <p>
9373               If the changelog format which is being parsed always or
9374               almost always leaves a blank line between individual
9375               change notes these blank lines should be stripped out,
9376               so as to make the resulting output compact.
9377             </p>
9378
9379             <p>
9380               If the changelog format does not contain date or package
9381               name information this information should be omitted from
9382               the output.  The parser should not attempt to synthesise
9383               it or find it from other sources.
9384             </p>
9385
9386             <p>
9387               If the changelog does not have the expected format the
9388               parser should exit with a nonzero exit status, rather
9389               than trying to muddle through and possibly generating
9390               incorrect output.
9391             </p>
9392
9393             <p>
9394               A changelog parser may not interact with the user at
9395               all.</p></sect2>
9396         </sect1>
9397
9398 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
9399
9400         <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9401         and variable substitutions
9402           </heading>
9403
9404           <p>
9405             When <prgn>dpkg-gencontrol</prgn>,
9406             <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9407             generate control files they do variable substitutions on
9408             their output just before writing it.  Variable
9409             substitutions have the form
9410             <tt>${<var>variable-name</var>}</tt>.  The optional file
9411             <file>debian/substvars</file> contains variable substitutions
9412             to be used; variables can also be set directly from
9413             <file>debian/rules</file> using the <tt>-V</tt> option to the
9414             source packaging commands, and certain predefined
9415             variables are available.
9416           </p>
9417
9418           <p>
9419             This file is usually generated and modified dynamically by
9420             <file>debian/rules</file> targets, in which case it must be
9421             removed by the <tt>clean</tt> target.
9422           </p>
9423
9424           <p>
9425             See <manref name="dpkg-source" section="1"> for full
9426             details about source variable substitutions, including the
9427             format of <file>debian/substvars</file>.</p>
9428         </sect1>
9429
9430         <sect1><heading><file>debian/files</file>
9431           </heading>
9432
9433           <p>
9434             This file is not a permanent part of the source tree; it
9435             is used while building packages to record which files are
9436             being generated.  <prgn>dpkg-genchanges</prgn> uses it
9437             when it generates a <file>.changes</file> file.
9438           </p>
9439
9440           <p>
9441             It should not exist in a shipped source package, and so it
9442             (and any backup files or temporary files such as
9443             <file>files.new</file>
9444               <footnote>
9445                 <p>
9446                   <file>files.new</file> is used as a temporary file by
9447                   <prgn>dpkg-gencontrol</prgn> and
9448                   <prgn>dpkg-distaddfile</prgn> - they write a new
9449                   version of <file>files</file> here before renaming it,
9450                   to avoid leaving a corrupted copy if an error
9451                   occurs
9452                 </p>
9453               </footnote>) should be removed by the
9454               <tt>clean</tt> target.  It may also be wise to
9455               ensure a fresh start by emptying or removing it at the
9456               start of the <tt>binary</tt> target.
9457           </p>
9458
9459           <p>
9460             <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9461             for the <file>.deb</file> file that will be created by
9462             <prgn>dpkg-deb</prgn> from the control file that it
9463             generates, so for most packages all that needs to be done
9464             with this file is to delete it in <tt>clean</tt>.
9465           </p>
9466
9467           <p>
9468             If a package upload includes files besides the source
9469             package and any binary packages whose control files were
9470             made with <prgn>dpkg-gencontrol</prgn> then they should be
9471             placed in the parent of the package's top-level directory
9472             and <prgn>dpkg-distaddfile</prgn> should be called to add
9473             the file to the list in <file>debian/files</file>.</p>
9474         </sect1>
9475
9476         <sect1><heading><file>debian/tmp</file>
9477           </heading>
9478
9479           <p>
9480             This is the canonical temporary location for the
9481             construction of binary packages by the <tt>binary</tt>
9482             target.  The directory <file>tmp</file> serves as the root of
9483             the filesystem tree as it is being constructed (for
9484             example, by using the package's upstream makefiles install
9485             targets and redirecting the output there), and it also
9486             contains the <tt>DEBIAN</tt> subdirectory.  See <ref
9487             id="pkg-bincreating">.
9488           </p>
9489
9490           <p>
9491             If several binary packages are generated from the same
9492             source tree it is usual to use several
9493             <file>debian/tmp<var>something</var></file> directories, for
9494             example <file>tmp-a</file> or <file>tmp-doc</file>.
9495           </p>
9496
9497           <p>
9498             Whatever <file>tmp</file> directories are created and used by
9499             <tt>binary</tt> must of course be removed by the
9500             <tt>clean</tt> target.</p></sect1>
9501       </sect>
9502
9503
9504       <sect id="pkg-sourcearchives"><heading>Source packages as archives
9505         </heading>
9506
9507         <p>
9508           As it exists on the FTP site, a Debian source package
9509           consists of three related files.  You must have the right
9510           versions of all three to be able to use them.
9511         </p>
9512
9513         <p>
9514           <taglist>
9515             <tag>Debian source control file - <tt>.dsc</tt></tag>
9516             <item>
9517
9518               <p>
9519                 This file contains a series of fields, identified and
9520                 separated just like the fields in the control file of
9521                 a binary package.  The fields are listed below; their
9522                 syntax is described above, in <ref id="pkg-controlfields">.
9523                 <list compact="compact">
9524                   <item>
9525                     <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9526                   </item>
9527                   <item>
9528                     <p><qref id="versions"><tt>Version</tt></qref></p>
9529                   </item>
9530                   <item>
9531                     <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9532                   </item>
9533                   <item>
9534                     <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9535                   </item>
9536                   <item>
9537                     <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9538                   </item>
9539                   <item>
9540                      <p>
9541                        <qref id="relationships"><tt>Build-Depends</tt> et
9542                          al.</qref> (source package interrelationships)
9543                      </p>
9544                   </item>
9545                   <item>
9546                     <p>
9547                       <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9548                   </item>
9549                   <item>
9550                     <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9551                   </item>
9552                 </list>
9553
9554               <p>
9555                 The source package control file is generated by
9556                 <prgn>dpkg-source</prgn> when it builds the source
9557                 archive, from other files in the source package,
9558                 described above.  When unpacking it is checked against
9559                 the files and directories in the other parts of the
9560                 source package, as described below.</p>
9561             </item>
9562
9563             <tag>
9564               Original source archive -
9565               <file>
9566                 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9567               </file>
9568             </tag>
9569
9570             <item>
9571
9572               <p>
9573                 This is a compressed (with <tt>gzip -9</tt>)
9574                 <prgn>tar</prgn> file containing the source code from
9575                 the upstream authors of the program.  The tarfile
9576                 unpacks into a directory
9577                 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9578                 and does not contain files anywhere other than in
9579                 there or in its subdirectories.</p>
9580             </item>
9581
9582             <tag>
9583               Debianisation diff -
9584               <file>
9585                 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9586               </file>
9587             </tag>
9588             <item>
9589
9590               <p>
9591                 This is a unified context diff (<tt>diff -u</tt>)
9592                 giving the changes which are required to turn the
9593                 original source into the Debian source.  These changes
9594                 may only include editing and creating plain files.
9595                 The permissions of files, the targets of symbolic
9596                 links and the characteristics of special files or
9597                 pipes may not be changed and no files may be removed
9598                 or renamed.
9599               </p>
9600
9601               <p>
9602                 All the directories in the diff must exist, except the
9603                 <file>debian</file> subdirectory of the top of the source
9604                 tree, which will be created by
9605                 <prgn>dpkg-source</prgn> if necessary when unpacking.
9606               </p>
9607
9608               <p>
9609                 The <prgn>dpkg-source</prgn> program will
9610                 automatically make the <file>debian/rules</file> file
9611                 executable (see below).</p></item>
9612           </taglist>
9613
9614
9615         <p>
9616           If there is no original source code - for example, if the
9617           package is specially prepared for Debian or the Debian
9618           maintainer is the same as the upstream maintainer - the
9619           format is slightly different: then there is no diff, and the
9620           tarfile is named
9621           <file><var>package</var>_<var>version</var>.tar.gz</file> and
9622           contains a directory
9623           <file><var>package</var>-<var>version</var></file>.
9624         </p>
9625       </sect>
9626
9627       <sect><heading>Unpacking a Debian source package without
9628       <prgn>dpkg-source</prgn>
9629         </heading>
9630
9631         <p>
9632           <tt>dpkg-source -x</tt> is the recommended way to unpack a
9633           Debian source package.  However, if it is not available it
9634           is possible to unpack a Debian source archive as follows:
9635         <enumlist compact="compact">
9636           <item>
9637             <p>
9638               Untar the tarfile, which will create a <file>.orig</file>
9639               directory.</p>
9640           </item>
9641           <item>
9642             <p>Rename the <file>.orig</file> directory to
9643               <file><var>package</var>-<var>version</var></file>.</p>
9644           </item>
9645             <item>
9646             <p>
9647               Create the subdirectory <file>debian</file> at the top of
9648               the source tree.</p>
9649           </item>
9650           <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9651           </item>
9652           <item><p>Untar the tarfile again if you want a copy of the original
9653               source code alongside the Debianised version.</p>
9654           </item>
9655         </enumlist>
9656
9657         <p>
9658           It is not possible to generate a valid Debian source archive
9659           without using <prgn>dpkg-source</prgn>.  In particular,
9660           attempting to use <prgn>diff</prgn> directly to generate the
9661           <file>.diff.gz</file> file will not work.
9662         </p>
9663
9664         <sect1><heading>Restrictions on objects in source packages
9665           </heading>
9666
9667           <p>
9668             The source package may not contain any hard links
9669             <footnote>
9670               <p>
9671                 This is not currently detected when building source
9672                 packages, but only when extracting
9673                 them.
9674               </p>
9675             </footnote>
9676             <footnote>
9677               <p>
9678                 Hard links may be permitted at some point in the
9679                 future, but would require a fair amount of
9680                 work.
9681               </p>
9682             </footnote>, device special files, sockets or setuid or
9683             setgid files.
9684             <footnote>
9685               <p>
9686                 Setgid directories are allowed.
9687               </p>
9688             </footnote>
9689           </p>
9690
9691           <p>
9692             The source packaging tools manage the changes between the
9693             original and Debianised source using <prgn>diff</prgn> and
9694             <prgn>patch</prgn>.  Turning the original source tree as
9695             included in the <file>.orig.tar.gz</file> into the debianised
9696             source must not involve any changes which cannot be
9697             handled by these tools.  Problematic changes which cause
9698             <prgn>dpkg-source</prgn> to halt with an error when
9699             building the source package are:
9700             <list compact="compact">
9701               <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9702               </item>
9703               <item><p>Changing the targets of symbolic links.</p>
9704               </item>
9705               <item><p>Creating directories, other than <file>debian</file>.</p>
9706               </item>
9707               <item><p>Changes to the contents of binary files.</p></item>
9708             </list> Changes which cause <prgn>dpkg-source</prgn> to
9709             print a warning but continue anyway are:
9710             <list compact="compact">
9711               <item>
9712                 <p>
9713                   Removing files, directories or symlinks.
9714                   <footnote>
9715                     <p>
9716                       Renaming a file is not treated specially - it is
9717                       seen as the removal of the old file (which
9718                       generates a warning, but is otherwise ignored),
9719                       and the creation of the new
9720                       one.</p>
9721                   </footnote>
9722                 </p>
9723               </item>
9724               <item>
9725                 <p>
9726                   Changed text files which are missing the usual final
9727                   newline (either in the original or the modified
9728                   source tree).
9729                 </p>
9730               </item>
9731             </list>
9732             Changes which are not represented, but which are not detected by
9733             <prgn>dpkg-source</prgn>, are:
9734             <list compact="compact">
9735               <item><p>Changing the permissions of files (other than
9736                   <file>debian/rules</file>) and directories.</p></item>
9737             </list>
9738           </p>
9739
9740           <p>
9741             The <file>debian</file> directory and <file>debian/rules</file>
9742             are handled specially by <prgn>dpkg-source</prgn> - before
9743             applying the changes it will create the <file>debian</file>
9744             directory, and afterwards it will make
9745             <file>debian/rules</file> world-exectuable.
9746           </p>
9747         </sect1>
9748       </sect>
9749     </appendix>
9750
9751     <appendix id="pkg-controlfields"><heading>Control files and their
9752         fields (from old Packaging Manual)
9753       </heading>
9754
9755       <p>
9756         Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9757         data in a common format, known as control files.  Binary and
9758         source packages have control data as do the <file>.changes</file>
9759         files which control the installation of uploaded files, and
9760         <prgn>dpkg</prgn>'s internal databases are in a similar
9761         format.
9762       </p>
9763
9764       <sect><heading>Syntax of control files
9765         </heading>
9766
9767         <p>
9768           A file consists of one or more paragraphs of fields.  The
9769           paragraphs are separated by blank lines.  Some control files
9770           only allow one paragraph; others allow several, in which
9771           case each paragraph often refers to a different package.
9772         </p>
9773
9774         <p>
9775           Each paragraph is a series of fields and values; each field
9776           consists of a name, followed by a colon and the value.  It
9777           ends at the end of the line.  Horizontal whitespace (spaces
9778           and tabs) may occur before or after the value and is ignored
9779           there; it is conventional to put a single space after the
9780           colon.
9781         </p>
9782
9783         <p>
9784           Some fields' values may span several lines; in this case
9785           each continuation line <em>must</em> start with a space or
9786           tab.  Any trailing spaces or tabs at the end of individual
9787           lines of a field value are ignored.
9788         </p>
9789
9790         <p>
9791           Except where otherwise stated only a single line of data is
9792           allowed and whitespace is not significant in a field body.
9793           Whitespace may never appear inside names (of packages,
9794           architectures, files or anything else), version numbers or
9795           in between the characters of multi-character version
9796           relationships.
9797         </p>
9798
9799         <p>
9800           Field names are not case-sensitive, but it is usual to
9801           capitalise the field names using mixed case as shown below.
9802         </p>
9803
9804         <p>
9805           Blank lines, or lines consisting only of spaces and tabs,
9806           are not allowed within field values or between fields - that
9807           would mean a new paragraph.
9808         </p>
9809
9810         <p>
9811           It is important to note that there are several fields which
9812           are optional as far as <prgn>dpkg</prgn> and the related
9813           tools are concerned, but which must appear in every Debian
9814           package, or whose omission may cause problems.
9815         </p>
9816       </sect>
9817
9818       <sect><heading>List of fields
9819         </heading>
9820
9821         <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9822           </heading>
9823
9824           <p>
9825             The name of the binary package.  Package names consist of
9826             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9827             (plus, minus and full stop).
9828             <footnote>
9829               <p>
9830                 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9831                 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9832                 and underscore) used to be legal and are still
9833                 accepted when found in a package file, but may not be
9834                 used in new packages
9835               </p>
9836             </footnote>
9837           </p>
9838
9839           <p>
9840             They must be at least two characters and must start with
9841             an alphanumeric.  In current versions of dpkg they are
9842             sort of case-sensitive<footnote><p>This is a
9843             bug.</p></footnote>; use lowercase package names unless
9844             the package you're building (or referring to, in other
9845             fields) is already using uppercase.</p>
9846         </sect1>
9847
9848         <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9849           </heading>
9850
9851           <p>
9852             This lists the source or binary package's version number -
9853             see <ref id="versions">.
9854           </p>
9855
9856         </sect1>
9857
9858         <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9859           </heading>
9860
9861           <p>
9862             This is the architecture string; it is a single word for
9863             the Debian architecture.
9864           </p>
9865
9866           <p>
9867             <prgn>dpkg</prgn> will check the declared architecture of
9868             a binary package against its own compiled-in value before
9869             it installs it.
9870           </p>
9871
9872           <p>
9873             The special value <tt>all</tt> indicates that the package
9874             is architecture-independent.
9875           </p>
9876
9877           <p>
9878             In the main <file>debian/control</file> file in the source
9879             package, or in the source package control file
9880             <file>.dsc</file>, a list of architectures (separated by
9881             spaces) is also allowed, as is the special value
9882             <tt>any</tt>.  A list indicates that the source will build
9883             an architecture-dependent package, and will only work
9884             correctly on the listed architectures.  <tt>any</tt>
9885             indicates that though the source package isn't dependent
9886             on any particular architecture and should compile fine on
9887             any one, the binary package(s) produced are not
9888             architecture-independent but will instead be specific to
9889             whatever the current build architecture is.
9890           </p>
9891
9892           <p>
9893             In a <file>.changes</file> file the <tt>Architecture</tt>
9894             field lists the architecture(s) of the package(s)
9895             currently being uploaded.  This will be a list; if the
9896             source for the package is being uploaded too the special
9897             entry <tt>source</tt> is also present.
9898           </p>
9899
9900           <p>
9901             See <ref id="pkg-debianrules"> for information how to get the
9902             architecture for the build process.
9903           </p>
9904         </sect1>
9905
9906         <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9907           </heading>
9908
9909           <p>
9910             The package maintainer's name and email address.  The name
9911             should come first, then the email address inside angle
9912             brackets <tt>&lt;&gt</tt> (in RFC822 format).
9913           </p>
9914
9915           <p>
9916             If the maintainer's name contains a full stop then the
9917             whole field will not work directly as an email address due
9918             to a misfeature in the syntax specified in RFC822; a
9919             program using this field as an address must check for this
9920             and correct the problem if necessary (for example by
9921             putting the name in round brackets and moving it to the
9922             end, and bringing the email address forward).
9923           </p>
9924
9925           <p>
9926             In a <file>.changes</file> file or parsed changelog data this
9927             contains the name and email address of the person
9928             responsible for the particular version in question - this
9929             may not be the package's usual maintainer.
9930           </p>
9931
9932           <p>
9933             This field is usually optional in as far as the
9934             <prgn>dpkg</prgn> are concerned, but its absence when
9935             building packages usually generates a warning.</p>
9936         </sect1>
9937
9938         <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9939           </heading>
9940
9941           <p>
9942             This field identifies the source package name.
9943           </p>
9944
9945           <p>
9946             In a main source control information or a
9947             <file>.changes</file> or <file>.dsc</file> file or parsed
9948             changelog data this may contain only the name of the
9949             source package.
9950           </p>
9951
9952           <p>
9953             In the control file of a binary package (or in a
9954             <file>Packages</file> file) it may be followed by a version
9955             number in parentheses.
9956             <footnote>
9957               <p>
9958                 It is usual to leave a space after the package name if
9959                 a version number is specified.
9960               </p>
9961             </footnote> This version number may be omitted (and is, by
9962             <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9963             the <tt>Version</tt> field of the binary package in
9964             question.  The field itself may be omitted from a binary
9965             package control file when the source package has the same
9966             name and version as the binary package.
9967           </p>
9968         </sect1>
9969
9970         <sect1><heading>Package interrelationship fields:
9971             <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9972             <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9973             <tt>Provides</tt>, <tt>Replaces</tt>
9974           </heading>
9975
9976           <p>
9977             These fields describe the package's relationships with
9978             other packages.  Their syntax and semantics are described
9979             in <ref id="relationships">.</p>
9980         </sect1>
9981
9982         <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9983           </heading>
9984
9985           <p>
9986             In a binary package <tt>Packages</tt> file or main source
9987             control file this field contains a description of the
9988             binary package, in a special format.  See <ref
9989             id="descriptions"> for details.
9990           </p>
9991
9992           <p>
9993             In a <file>.changes</file> file it contains a summary of the
9994             descriptions for the packages being uploaded.  The part of
9995             the field before the first newline is empty; thereafter
9996             each line has the name of a binary package and the summary
9997             description line from that binary package.  Each line is
9998             indented by one space.</p>
9999         </sect1>
10000
10001         <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
10002           </heading>
10003
10004           <p>
10005             This is a boolean field which may occur only in the
10006             control file of a binary package (or in the
10007             <file>Packages</file> file) or in a per-package fields
10008             paragraph of a main source control data file.
10009           </p>
10010
10011           <p>
10012             If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
10013             <prgn>dselect</prgn> will refuse to remove the package
10014             (though it can be upgraded and/or replaced).  The other
10015             possible value is <tt>no</tt>, which is the same as not
10016             having the field at all.</p>
10017         </sect1>
10018
10019         <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
10020         <tt>Priority</tt>
10021           </heading>
10022
10023           <p>
10024             These two fields classify the package.  The
10025             <tt>Priority</tt> represents how important that it is that
10026             the user have it installed; the <tt>Section</tt>
10027             represents an application area into which the package has
10028             been classified.
10029           </p>
10030
10031           <p>
10032             When they appear in the <file>debian/control</file> file these
10033             fields give values for the section and priority subfields
10034             of the <tt>Files</tt> field of the <file>.changes</file> file,
10035             and give defaults for the section and priority of the
10036             binary packages.
10037           </p>
10038
10039           <p>
10040             The section and priority are represented, though not as
10041             separate fields, in the information for each file in the
10042             <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
10043             <file>.changes</file> file.  The section value in a
10044             <file>.changes</file> file is used to decide where to install
10045             a package in the FTP archive.
10046           </p>
10047
10048           <p>
10049             These fields are not used by by <prgn>dpkg</prgn> proper,
10050             but by <prgn>dselect</prgn> when it sorts packages and
10051             selects defaults.
10052           </p>
10053
10054           <p>
10055             These fields can appear in binary package control files,
10056             in which case they provide a default value in case the
10057             <file>Packages</file> files are missing the information.
10058             <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
10059             the value from a <file>.deb</file> file if they have no other
10060             information; a value listed in a <file>Packages</file> file
10061             will always take precedence.  By default
10062             <prgn>dpkg-gencontrol</prgn> does not include the section
10063             and priority in the control file of a binary package - use
10064             the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
10065             achieve this effect.</p>
10066         </sect1>
10067
10068         <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
10069           </heading>
10070
10071           <p>
10072             This field is a list of binary packages.
10073           </p>
10074
10075           <p>
10076             When it appears in the <file>.dsc</file> file it is the list
10077             of binary packages which a source package can produce.  It
10078             does not necessarily produce all of these binary packages
10079             for every architecture.  The source control file doesn't
10080             contain details of which architectures are appropriate for
10081             which of the binary packages.
10082           </p>
10083
10084           <p>
10085             When it appears in a <file>.changes</file> file it lists the
10086             names of the binary packages actually being uploaded.
10087           </p>
10088
10089           <p>
10090             The syntax is a list of binary packages separated by
10091             commas.
10092             <footnote>
10093               <p>
10094                 A space after each comma is conventional.
10095               </p>
10096             </footnote> Currently the packages must be separated using
10097             only spaces in the <file>.changes</file> file.</p>
10098         </sect1>
10099
10100         <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10101           </heading>
10102
10103           <p>
10104             This field appears in the control files of binary
10105             packages, and in the <file>Packages</file> files.  It gives
10106             the total amount of disk space required to install the
10107             named package.
10108           </p>
10109
10110           <p>
10111             The disk space is represented in kilobytes as a simple
10112             decimal number.</p>
10113         </sect1>
10114
10115         <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10116           </heading>
10117
10118           <p>
10119             This field contains a list of files with information about
10120             each one.  The exact information and syntax varies with
10121             the context.  In all cases the part of the field
10122             contents on the same line as the field name is empty.  The
10123             remainder of the field is one line per file, each line
10124             being indented by one space and containing a number of
10125             sub-fields separated by spaces.
10126           </p>
10127
10128           <p>
10129             In the <file>.dsc</file> (Debian source control) file each
10130             line contains the MD5 checksum, size and filename of the
10131             tarfile and (if applicable) diff file which make up the
10132             remainder of the source package.
10133             <footnote>
10134               <p>
10135                 That is, the parts which are not the
10136                 <tt>.dsc</tt>.
10137               </p>
10138             </footnote> The exact forms of the filenames are described
10139             in <ref id="pkg-sourcearchives">.
10140           </p>
10141
10142           <p>
10143             In the <file>.changes</file> file this contains one line per
10144             file being uploaded.  Each line contains the MD5 checksum,
10145             size, section and priority and the filename.  The section
10146             and priority are the values of the corresponding fields in
10147             the main source control file - see <ref
10148             id="pkg-f-classification">.  If no section or priority is
10149             specified then <tt>-</tt> should be used, though section
10150             and priority values must be specified for new packages to
10151             be installed properly.
10152           </p>
10153
10154           <p>
10155             The special value <tt>byhand</tt> for the section in a
10156             <tt>.changes</tt> file indicates that the file in question
10157             is not an ordinary package file and must by installed by
10158             hand by the distribution maintainers.  If the section is
10159             <tt>byhand</tt> the priority should be <tt>-</tt>.
10160           </p>
10161
10162           <p>
10163             If a new Debian revision of a package is being shipped and
10164             no new original source archive is being distributed the
10165             <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10166             entry for the original source archive
10167             <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10168             but the <file>.changes</file> file should leave it out.  In
10169             this case the original source archive on the distribution
10170             site must match exactly, byte-for-byte, the original
10171             source archive which was used to generate the
10172             <file>.dsc</file> file and diff which are being uploaded.</p>
10173         </sect1>
10174
10175
10176         <sect1
10177         id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10178           </heading>
10179
10180           <p>
10181             The most recent version of the standards (the Debian Policy
10182             and associated texts) with which the package complies. This
10183             is updated manually when editing the source package to
10184             conform to newer standards; it can sometimes be used to
10185             tell when a package needs attention.
10186           </p>
10187
10188           <p>
10189             Its format is the same as that of a version number except
10190             that no epoch or Debian revision is allowed - see <ref
10191             id="versions">.</p>
10192         </sect1>
10193
10194
10195         <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10196           </heading>
10197
10198           <p>
10199             In a <file>.changes</file> file or parsed changelog output
10200             this contains the (space-separated) name(s) of the
10201             distribution(s) where this version of the package should
10202             be or was installed.  Distribution names follow the rules
10203             for package names.  (See <ref id="pkg-f-Package">).
10204           </p>
10205
10206           <p>
10207             Current distribution values are:
10208           <taglist>
10209             <tag><em>stable</em></tag>
10210             <item>
10211               <p>
10212                 This is the current "released" version of Debian
10213                 GNU/Linux.  A new version is released approximately
10214                 every 3 months after the <em>development</em> code has
10215                 been <em>frozen</em> for a month of testing.  Once the
10216                 distribution is <em>stable</em> only major bug fixes
10217                 are allowed. When changes are made to this
10218                 distribution, the release number is increased
10219                 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10220               </p>
10221             </item>
10222
10223             <tag><em>unstable</em></tag>
10224             <item>
10225               <p>
10226                 This distribution value refers to the
10227                 <em>developmental</em> part of the Debian distribution
10228                 tree. New packages, new upstream versions of packages
10229                 and bug fixes go into the <em>unstable</em> directory
10230                 tree. Download from this distribution at your own
10231                 risk.</p>
10232             </item>
10233
10234             <tag><em>contrib</em></tag>
10235             <item>
10236               <p>
10237                 The packages with this distribution value do not meet
10238                 the criteria for inclusion in the main Debian
10239                 distribution as defined by the Policy Manual, but meet
10240                 the criteria for the <em>contrib</em>
10241                 Distribution. There is currently no distinction
10242                 between stable and unstable packages in the
10243                 <em>contrib</em> or <em>non-free</em>
10244                 distributions. Use your best judgement in downloading
10245                 from this Distribution.</p>
10246             </item>
10247
10248             <tag><em>non-free</em></tag>
10249             <item>
10250               <p>
10251                 Like the packages in the <em>contrib</em> seciton,
10252                 the packages in <em>non-free</em> do not meet the
10253                 criteria for inclusion in the main Debian distribution
10254                 as defined by the Policy Manual. Again, use your best
10255                 judgement in downloading from this Distribution.</p>
10256
10257             <tag><em>experimental</em></tag>
10258             <item>
10259               <p>
10260                 The packages with this distribution value are deemed
10261                 by their maintainers to be high risk. Oftentimes they
10262                 represent early beta or developmental packages from
10263                 various sources that the maintainers want people to
10264                 try, but are not ready to be a part of the other parts
10265                 of the Debian distribution tree. Download at your own
10266                 risk.</p>
10267             </item>
10268
10269             <tag><em>frozen</em></tag>
10270             <item>
10271               <p>
10272                 From time to time, (currently, every 3 months) the
10273                 <em>unstable</em> distribution enters a state of
10274                 "code-freeze" in anticipation of release as a
10275                 <em>stable</em> version. During this period of testing
10276                 (usually 4 weeks) only fixes for existing or
10277                 newly-discovered bugs will be allowed.
10278               </p>
10279             </item>
10280           </taglist> You should list <em>all</em> distributions that
10281           the package should be installed into. Except in unusual
10282           circumstances, installations to <em>stable</em> should also
10283           go into <em>frozen</em> (if it exists) and
10284           <em>unstable</em>. Likewise, installations into
10285           <em>frozen</em> should also go into <em>unstable</em>.</p>
10286         </sect1>
10287
10288         <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10289           </heading>
10290
10291           <p>
10292             This is a description of how important it is to upgrade to
10293             this version from previous ones.  It consists of a single
10294             keyword usually taking one of the values <tt>LOW</tt>,
10295             <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10296             commentary (separated by a space) which is usually in
10297             parentheses.  For example:
10298             <example>
10299   Urgency: LOW (HIGH for diversions users)
10300             </example>
10301           </p>
10302
10303           <p>
10304             This field appears in the <file>.changes</file> file and in
10305             parsed changelogs; its value appears as the value of the
10306             <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10307             changelog (see <ref id="pkg-dpkgchangelog">).
10308           </p>
10309
10310           <p>
10311             Urgency keywords are not case-sensitive.</p>
10312         </sect1>
10313
10314         <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10315           </heading>
10316
10317           <p>
10318             In <tt>.changes</tt> files and parsed changelogs, this
10319             gives the date the package was built or last edited.</p>
10320         </sect1>
10321
10322         <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10323           </heading>
10324
10325           <p>
10326             This field occurs in <file>.changes</file> files, and
10327             specifies a format revision for the file.  The format
10328             described here is version <tt>1.5</tt>.  The syntax of the
10329             format value is the same as that of a package version
10330             number except that no epoch or Debian revision is allowed
10331             - see <ref id="versions">.</p>
10332         </sect1>
10333
10334         <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10335           </heading>
10336
10337           <p>
10338             In a <file>.changes</file> file or parsed changelog this field
10339             contains the human-readable changes data, describing the
10340             differences between the last version and the current one.
10341           </p>
10342
10343           <p>
10344             There should be nothing in this field before the first
10345             newline; all the subsequent lines must be indented by at
10346             least one space; blank lines must be represented by a line
10347             consiting only of a space and a full stop.
10348           </p>
10349
10350           <p>
10351             Each version's change information should be preceded by a
10352             "title" line giving at least the version, distribution(s)
10353             and urgency, in a human-readable way.
10354           </p>
10355
10356           <p>
10357             If data from several versions is being returned the entry
10358             for the most recent version should be returned first, and
10359             entries should be separated by the representation of a
10360             blank line (the "title" line may also be followed by the
10361             representation of blank line).</p>
10362         </sect1>
10363
10364         <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10365         <tt>MSDOS-Filename</tt>
10366           </heading>
10367
10368           <p>
10369             These fields in <tt>Packages</tt> files give the
10370             filename(s) of (the parts of) a package in the
10371             distribution directories, relative to the root of the
10372             Debian hierarchy.  If the package has been split into
10373             several parts the parts are all listed in order, separated
10374             by spaces.</p>
10375         </sect1>
10376
10377         <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10378           </heading>
10379
10380           <p>
10381             These fields in <file>Packages</file> files give the size (in
10382             bytes, expressed in decimal) and MD5 checksum of the
10383             file(s) which make(s) up a binary package in the
10384             distribution.  If the package is split into several parts
10385             the values for the parts are listed in order, separated by
10386             spaces.</p>
10387         </sect1>
10388
10389         <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10390           </heading>
10391
10392           <p>
10393             This field in <prgn>dpkg</prgn>'s status file records
10394             whether the user wants a package installed, removed or
10395             left alone, whether it is broken (requiring
10396             reinstallation) or not and what its current state on the
10397             system is.  Each of these pieces of information is a
10398             single word.</p>
10399         </sect1>
10400
10401         <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10402           </heading>
10403
10404           <p>
10405             If a package is not installed or not configured, this
10406             field in <prgn>dpkg</prgn>'s status file records the last
10407             version of the package which was successfully
10408             configured.</p>
10409         </sect1>
10410
10411         <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10412           </heading>
10413
10414           <p>
10415             This field in <prgn>dpkg</prgn>'s status file contains
10416             information about the automatically-managed configuration
10417             files held by a package.  This field should <em>not</em>
10418             appear anywhere in a package!</p>
10419         </sect1>
10420
10421         <sect1><heading>Obsolete fields
10422           </heading>
10423
10424           <p>
10425             These are still recognised by <prgn>dpkg</prgn> but should
10426             not appear anywhere any more.
10427             <taglist compact="compact">
10428
10429               <tag><tt>Revision</tt></tag>
10430               <tag><tt>Package-Revision</tt></tag>
10431               <tag><tt>Package_Revision</tt></tag>
10432               <item>
10433                 <p>
10434                   The Debian revision part of the package version was
10435                   at one point in a separate control file field.  This
10436                   field went through several names.</p>
10437               </item>
10438
10439               <tag><tt>Recommended</tt></tag>
10440               <item><p>Old name for <tt>Recommends</tt></p>
10441               </item>
10442
10443               <tag><tt>Optional</tt></tag>
10444               <item><p>Old name for <tt>Suggests</tt>.</p>
10445               </item>
10446               <tag><tt>Class</tt></tag>
10447               <item><p>Old name for <tt>Priority</tt>.</p>
10448               </item>
10449             </taglist>
10450           </p>
10451         </sect1>
10452       </sect>
10453     </appendix>
10454
10455     <appendix id="pkg-conffiles"><heading>Configuration file handling
10456     (from old Packaging Manual)
10457       </heading>
10458
10459       <p>
10460         <prgn>dpkg</prgn> can do a certain amount of automatic
10461         handling of package configuration files.
10462       </p>
10463
10464       <p>
10465         Whether this mechanism is appropriate depends on a number of
10466         factors, but basically there are two approaches to any
10467         particular configuration file.
10468       </p>
10469
10470       <p>
10471         The easy method is to ship a best-effort configuration in the
10472         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10473         handle updates.  If the user is unlikely to want to edit the
10474         file, but you need them to be able to without losing their
10475         changes, and a new package with a changed version of the file
10476         is only released infrequently, this is a good approach.
10477       </p>
10478
10479       <p>
10480         The hard method is to build the configuration file from
10481         scratch in the <prgn>postinst</prgn> script, and to take the
10482         responsibility for fixing any mistakes made in earlier
10483         versions of the package automatically.  This will be
10484         appropriate if the file is likely to need to be different on
10485         each system.
10486       </p>
10487
10488       <sect><heading>Automatic handling of configuration files by
10489       <prgn>dpkg</prgn>
10490         </heading>
10491
10492         <p>
10493           A package may contain a control area file called
10494           <tt>conffiles</tt>.  This file should be a list of filenames
10495           of configuration files needing automatic handling, separated
10496           by newlines.  The filenames should be absolute pathnames,
10497           and the files referred to should actually exist in the
10498           package.
10499         </p>
10500
10501         <p>
10502           When a package is upgraded <prgn>dpkg</prgn> will process
10503           the configuration files during the configuration stage,
10504           shortly before it runs the package's <prgn>postinst</prgn>
10505           script,
10506         </p>
10507
10508         <p>
10509           For each file it checks to see whether the version of the
10510           file included in the package is the same as the one that was
10511           included in the last version of the package (the one that is
10512           being upgraded from); it also compares the version currently
10513           installed on the system with the one shipped with the last
10514           version.
10515         </p>
10516
10517         <p>
10518           If neither the user nor the package maintainer has changed
10519           the file, it is left alone.  If one or the other has changed
10520           their version, then the changed version is preferred - i.e.,
10521           if the user edits their file, but the package maintainer
10522           doesn't ship a different version, the user's changes will
10523           stay, silently, but if the maintainer ships a new version
10524           and the user hasn't edited it the new version will be
10525           installed (with an informative message).  If both have
10526           changed their version the user is prompted about the problem
10527           and must resolve the differences themselves.
10528         </p>
10529
10530         <p>
10531           The comparisons are done by calculating the MD5 message
10532           digests of the files, and storing the MD5 of the file as it
10533           was included in the most recent version of the package.
10534         </p>
10535
10536         <p>
10537           When a package is installed for the first time
10538           <prgn>dpkg</prgn> will install the file that comes with it,
10539           unless that would mean overwriting a file already on the
10540           filesystem.
10541         </p>
10542
10543         <p>
10544           However, note that <prgn>dpkg</prgn> will <em>not</em>
10545           replace a conffile that was removed by the user (or by a
10546           script).  This is necessary because with some programs a
10547           missing file produces an effect hard or impossible to
10548           achieve in another way, so that a missing file needs to be
10549           kept that way if the user did it.
10550         </p>
10551
10552         <p>
10553           Note that a package should <em>not</em> modify a
10554           <prgn>dpkg</prgn>-handled conffile in its maintainer
10555           scripts.  Doing this will lead to <prgn>dpkg</prgn> giving
10556           the user confusing and possibly dangerous options for
10557           conffile update when the package is upgraded.</p>
10558       </sect>
10559
10560       <sect><heading>Fully-featured maintainer script configuration
10561       handling
10562         </heading>
10563
10564         <p>
10565           For files which contain site-specific information such as
10566           the hostname and networking details and so forth, it is
10567           better to create the file in the package's
10568           <prgn>postinst</prgn> script.
10569         </p>
10570
10571         <p>
10572           This will typically involve examining the state of the rest
10573           of the system to determine values and other information, and
10574           may involve prompting the user for some information which
10575           can't be obtained some other way.
10576         </p>
10577
10578         <p>
10579           When using this method there are a couple of important
10580           issues which should be considered:
10581         </p>
10582
10583         <p>
10584           If you discover a bug in the program which generates the
10585           configuration file, or if the format of the file changes
10586           from one version to the next, you will have to arrange for
10587           the postinst script to do something sensible - usually this
10588           will mean editing the installed configuration file to remove
10589           the problem or change the syntax.  You will have to do this
10590           very carefully, since the user may have changed the file,
10591           perhaps to fix the very problem that your script is trying
10592           to deal with - you will have to detect these situations and
10593           deal with them correctly.
10594         </p>
10595
10596         <p>
10597           If you do go down this route it's probably a good idea to
10598           make the program that generates the configuration file(s) a
10599           separate program in <file>/usr/sbin</file>, by convention called
10600           <file><var>package</var>config</file> and then run that if
10601           appropriate from the post-installation script.  The
10602           <tt><var>package</var>config</tt> program should not
10603           unquestioningly overwrite an existing configuration - if its
10604           mode of operation is geared towards setting up a package for
10605           the first time (rather than any arbitrary reconfiguration
10606           later) you should have it check whether the configuration
10607           already exists, and require a <tt>--force</tt> flag to
10608           overwrite it.</p></sect>
10609     </appendix>
10610
10611     <appendix id="pkg-alternatives"><heading>Alternative versions of
10612         an interface - <prgn>update-alternatives</prgn> (from old
10613     Packaging Manual)
10614       </heading>
10615
10616       <p>
10617         When several packages all provide different versions of the
10618         same program or file it is useful to have the system select a
10619         default, but to allow the system administrator to change it
10620         and have their decisions respected.
10621       </p>
10622
10623       <p>
10624         For example, there are several versions of the <prgn>vi</prgn>
10625         editor, and there is no reason to prevent all of them from
10626         being installed at once, each under their own name
10627         (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10628         Nevertheless it is desirable to have the name <tt>vi</tt>
10629         refer to something, at least by default.
10630       </p>
10631
10632       <p>
10633         If all the packages involved cooperate, this can be done with
10634         <prgn>update-alternatives</prgn>.
10635       </p>
10636
10637       <p>
10638         Each package provides its own version under its own name, and
10639         calls <prgn>update-alternatives</prgn> in its postinst to
10640         register its version (and again in its prerm to deregister
10641         it).
10642       </p>
10643
10644       <p>
10645         See the manpage <manref name="update-alternatives"
10646         section="8"> for details.
10647       </p>
10648
10649       <p>
10650         If <prgn>update-alternatives</prgn> does not seem appropriate
10651         you may wish to consider using diversions instead.</p>
10652     </appendix>
10653
10654     <appendix id="pkg-diversions"><heading>Diversions - overriding a
10655     package's version of a file (from old Packaging Manual)
10656       </heading>
10657
10658       <p>
10659         It is possible to have <prgn>dpkg</prgn> not overwrite a file
10660         when it reinstalls the package it belongs to, and to have it
10661         put the file from the package somewhere else instead.
10662       </p>
10663
10664       <p>
10665         This can be used locally to override a package's version of a
10666         file, or by one package to override another's version (or
10667         provide a wrapper for it).
10668       </p>
10669
10670       <p>
10671         Before deciding to use a diversion, read <ref
10672         id="pkg-alternatives"> to see if you really want a diversion
10673         rather than several alternative versions of a program.
10674       </p>
10675
10676       <p>
10677         There is a diversion list, which is read by <prgn>dpkg</prgn>,
10678         and updated by a special program <prgn>dpkg-divert</prgn>.
10679         Please see <manref name="dpkg-divert" section="8"> for full
10680         details of its operation.
10681       </p>
10682
10683       <p>
10684         When a package wishes to divert a file from another, it should
10685         call <prgn>dpkg-divert</prgn> in its preinst to add the
10686         diversion and rename the existing file.  For example,
10687         supposing that a <prgn>smailwrapper</prgn> package wishes to
10688         install a wrapper around <file>/usr/sbin/smail</file>:
10689         <example>
10690   if [ install = "$1"  ]; then
10691      dpkg-divert --package smailwrapper --add --rename \
10692         --divert /usr/sbin/smail.real /usr/sbin/smail
10693   fi
10694         </example> Testing <tt>$1</tt> is necessary so that the script
10695         doesn't try to add the diversion again when
10696         <prgn>smailwrapper</prgn> is upgraded.  The <tt>--package
10697         smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10698         copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10699         get installed as the true version.
10700       </p>
10701
10702       <p>
10703         The postrm has to do the reverse:
10704         <example>
10705   if [ remove = "$1" ]; then
10706      dpkg-divert --package smailwrapper --remove --rename \
10707         --divert /usr/sbin/smail.real /usr/sbin/smail
10708   fi
10709         </example>
10710       </p>
10711
10712       <p>
10713         Do not attempt to divert a file which is vitally important for
10714         the system's operation - when using <prgn>dpkg-divert</prgn>
10715         there is a time, after it has been diverted but before
10716         <prgn>dpkg</prgn> has installed the new version, when the file
10717         does not exist.</p>
10718     </appendix>
10719
10720   </book>
10721 </debiandoc>
10722 <!-- vim:set ai et sts=2 sw=2 tw=76: -->