]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
Josip
[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
161         <p>
162           This manual is distributed via the Debian package
163           <package>debian-policy</package>.
164         </p>
165
166         <p>
167           The current version of this document is also available from
168           the Debian web mirrors at
169           <tt><url name="/doc/debian-policy/"
170                 id="http://www.debian.org/doc/debian-policy/"></tt>
171           and from the Debian archive mirrors at
172           <tt><url name="/doc/package-developer/policy.txt.gz"
173                 id="http://ftp.debian.org/debian/doc/package-developer/policy.txt.gz"></tt>.
174           Also available from the same directory are several other
175           formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
176           and <file>policy.ps.gz</file>.
177         </p>
178
179         <p>
180           The <package>debian-policy</package> package also includes the file
181           <file>upgrading-checklist.txt</file> which indicates policy
182           changes between versions of this document.
183         </p>
184       </sect>
185
186       <sect id="authors">
187         <heading>Authors and Maintainers</heading>
188
189         <p>
190           Originally called "Debian GNU/Linux Policy Manual", this
191           manual was initially written in 1996 by Ian Jackson.
192           It was revised on November 27th, 1996 by David A. Morris.
193           Christian Schwarz added new sections on March 15th, 1997,
194           and reworked/restructured it in April-July 1997.
195           Christoph Lameter contributed the "Web Standard".
196           Julian Gilbey largely restructured it in 2001.
197         </p>
198
199         <p>
200           Since September 1998, the responsibility for the contents of
201           this document lies on the debian-policy mailing list. Proposals
202           are discussed there and inserted into policy after a certain
203           consensus is established.
204           <!-- insert shameless policy-process plug here eventually -->
205           The actual editing is done by a group of maintainers that have
206           no editorial powers. These are the current maintainers:
207
208           <enumlist>
209             <item>Julian Gilbey</item>
210             <item>Branden Robinson</item>
211             <item>Josip Rodin</item>
212             <item>Manoj Srivastava</item>
213           </enumlist>
214         </p>
215
216         <p>
217           While the authors of this document have tried hard to avoid
218           typos and other errors, these do still occur. If you discover
219           an error in this manual or if you want to give any
220           comments, suggestions, or criticisms please send an email to
221           the Debian Policy List,
222           <email>debian-policy@lists.debian.org</email>, or submit a
223           bug report against the <tt>debian-policy</tt> package.
224         </p>
225
226         <p>
227           Please do not try to reach the individual authors or maintainers
228           of the Policy Manual regarding changes to the Policy.
229         </p>
230       </sect>
231     </chapt>
232
233     <chapt id="archive">
234       <heading>The Debian Archive</heading>
235       <p>
236         The Debian GNU/Linux system is maintained and distributed as a
237         collection of <em>packages</em>. Since there are so many of
238         them (currently well over 6000), they are split into
239         <em>sections</em> and given <em>priorities</em> to simplify
240         the handling of them.
241       </p>
242       <p>
243         The effort of the Debian project is to build a free operating
244         system, but not every package we want to make accessible is
245         <em>free</em> in our sense (see the Debian Free Software
246         Guidelines, below), or may be imported/exported without
247         restrictions. Thus, the archive is split into the sections
248         <em>main</em>, <em>non-free</em>, <em>contrib</em>,
249         <em>non-US/main</em>, <em>non-US/non-free</em>, and
250         <em>non-US/contrib</em>.  The sections are explained in detail
251         below.
252       </p>
253
254       <p>
255         The <em>main</em> and the <em>non-US/main</em> sections
256         together form the <em>Debian GNU/Linux distribution</em>.
257       </p>
258
259       <p>
260         Packages in the other sections are not considered to be part
261         of the Debian distribution, although we support their use and
262         provide infrastructure for them (such as our bug-tracking
263         system and mailing lists). This Debian Policy Manual applies
264         to these packages as well.</p>
265
266       <sect id="pkgcopyright">
267         <heading>Package copyright and sections</heading>
268         <p>
269           The aims of this section are:
270
271           <list compact="compact">
272             <item>
273               <p>to allow us to make as much software available as we
274                 can,</p>
275             </item>
276             <item>
277               <p>to allow us to encourage everyone to write free
278               software, and</p>
279             </item>
280             <item>
281               <p>to allow us to make it easy for people to produce
282                 CD-ROMs of our system without violating any licenses,
283                 import/export restrictions, or any other laws.</p>
284             </item>
285           </list>
286         </p>
287         <sect1>
288           <heading>The Debian Free Software Guidelines</heading>
289           <p>
290             The Debian Free Software Guidelines (DFSG) form our
291             definition of "free software".  These are:
292             <taglist>
293               <tag>Free Redistribution
294               </tag>
295               <item>
296                 <p>
297                   The license of a Debian component may not restrict any
298                   party from selling or giving away the software as a
299                   component of an aggregate software distribution
300                   containing programs from several different
301                   sources. The license may not require a royalty or
302                   other fee for such sale.
303                 </p>
304               </item>
305               <tag>Source Code
306               </tag>
307               <item>
308                 <p>
309                   The program must include source code, and must allow
310                   distribution in source code as well as compiled form.
311                 </p>
312               </item>
313               <tag>Derived Works
314               </tag>
315               <item>
316                 <p>
317                   The license must allow modifications and derived
318                   works, and must allow them to be distributed under the
319                   same terms as the license of the original software.
320                 </p>
321               </item>
322               <tag>Integrity of The Author's Source Code
323               </tag>
324               <item>
325                 <p>
326                   The license may restrict source-code from being
327                   distributed in modified form <em>only</em> if the
328                   license allows the distribution of "patch files"
329                   with the source code for the purpose of modifying the
330                   program at build time. The license must explicitly
331                   permit distribution of software built from modified
332                   source code. The license may require derived works to
333                   carry a different name or version number from the
334                   original software.  (This is a compromise. The Debian
335                   Project encourages all authors to not restrict any
336                   files, source or binary, from being modified.)
337                 </p>
338               </item>
339               <tag>No Discrimination Against Persons or Groups
340               </tag>
341               <item>
342                 <p>
343                   The license must not discriminate against any person
344                   or group of persons.
345                 </p>
346               </item>
347               <tag>No Discrimination Against Fields of Endeavor
348               </tag>
349               <item>
350                 <p>
351                   The license must not restrict anyone from making use
352                   of the program in a specific field of endeavor. For
353                   example, it may not restrict the program from being
354                   used in a business, or from being used for genetic
355                   research.
356                 </p>
357               </item>
358               <tag>Distribution of License
359               </tag>
360               <item>
361                 <p>
362                   The rights attached to the program must apply to all
363                   to whom the program is redistributed without the need
364                   for execution of an additional license by those
365                   parties.
366                 </p>
367               </item>
368               <tag>License Must Not Be Specific to Debian
369               </tag>
370               <item>
371                 <p>
372                   The rights attached to the program must not depend on
373                   the program's being part of a Debian system. If the
374                   program is extracted from Debian and used or
375                   distributed without Debian but otherwise within the
376                   terms of the program's license, all parties to whom
377                   the program is redistributed must have the same
378                   rights as those that are granted in conjunction with
379                   the Debian system.
380                 </p>
381               </item>
382               <tag>License Must Not Contaminate Other Software
383               </tag>
384               <item>
385                 <p>
386                   The license must not place restrictions on other
387                   software that is distributed along with the licensed
388                   software. For example, the license must not insist
389                   that all other programs distributed on the same medium
390                   must be free software.
391                 </p>
392               </item>
393               <tag>Example Licenses
394               </tag>
395               <item>
396                 <p>
397                   The "GPL," "BSD," and "Artistic" licenses are examples of
398                   licenses that we consider <em>free</em>.
399                 </p>
400               </item>
401             </taglist>
402           </p>
403         </sect1>
404         <sect1>
405           <heading>The main section</heading>
406           <p>
407             Every package in <em>main</em> and <em>non-US/main</em>
408             must comply with the DFSG (Debian Free Software
409             Guidelines).</p>
410
411           <p>
412             In addition, the packages in <em>main</em>
413             <list compact="compact">
414               <item>
415                 <p>
416                   must not require a package outside of <em>main</em>
417                   for compilation or execution (thus, the package must
418                   not declare a "Depends", "Recommends", or
419                   "Build-Depends" relationship on a non-<em>main</em>
420                   package),
421                 </p>
422               </item>
423               <item>
424                 <p>
425                   must not be so buggy that we refuse to support them,
426                   and
427                 </p>
428               </item>
429               <item>
430                 <p>
431                   must meet all policy requirements presented in this
432                   manual.
433                 </p>
434               </item>
435             </list>
436           </p>
437           <p>
438             Similarly, the packages in <em>non-US/main</em>
439             <list compact="compact">
440               <item>
441                 <p>
442                    must not require a package outside of <em>main</em>
443                    or <em>non-US/main</em> for compilation or
444                    execution,
445                 </p>
446               </item>
447               <item>
448                 <p>
449                   must not be so buggy that we refuse to support them,
450                 </p>
451               </item>
452               <item>
453                 <p>
454                   must meet all policy requirements presented in this
455                   manual.
456                 </p>
457               </item>
458             </list>
459           </p>
460         </sect1>
461         <sect1>
462           <heading>The contrib section</heading>
463           <p>
464             Every package in <em>contrib</em> and
465             <em>non-US/contrib</em> must comply with the DFSG.
466           </p>
467
468           <p>
469             In addition, the packages in <em>contrib</em> and
470             <em>non-US/contrib</em>
471             <list compact="compact">
472               <item>
473                 <p>
474                   must not be so buggy that we refuse to support them,
475                   and
476                 </p>
477               </item>
478               <item>
479                 <p>
480                   must meet all policy requirements presented in this
481                   manual.
482                 </p>
483               </item>
484             </list>
485           </p>
486
487           <p>
488             Furthermore, packages in <em>contrib</em> must not require
489             a package in a <em>non-US</em> section for compilation or
490             execution.
491           </p>
492
493           <p>
494             Examples of packages which would be included in
495             <em>contrib</em> or <em>non-US/contrib</em> are:
496             <list compact="compact">
497               <item>
498                 <p>
499                   free packages which require <em>contrib</em>,
500                   <em>non-free</em> packages or packages which are not
501                   in our archive at all for compilation or execution,
502                   and
503                 </p>
504               </item>
505               <item>
506                 <p>
507                   wrapper packages or other sorts of free accessories for
508                   non-free programs.
509                 </p>
510               </item>
511             </list>
512           </p>
513         </sect1>
514         <sect1>
515           <heading>The non-free section</heading>
516           <p>
517             Packages must be placed in <em>non-free</em> or
518             <em>non-US/non-free</em> if they are not compliant with
519             the DFSG or are encumbered by patents or other legal
520             issues that make their distribution problematic.
521           </p>
522           <p>
523             In addition, the packages in <em>non-free</em> and
524             <em>non-US/non-free</em>
525             <list compact="compact">
526               <item>
527                 <p>
528                   must not be so buggy that we refuse to support them,
529                   and
530                 </p>
531               </item>
532               <item>
533                 <p>
534                   must meet all policy requirements presented in this
535                   manual that it is possible for them to meet.<footnote>
536                     <p>
537                       It is possible that there are policy
538                       requirements which the package is unable to
539                       meet, for example, if the source is
540                       unavailable.  These situations will need to be
541                       handled on a case-by-case basis.
542                     </p>
543                   </footnote>
544                 </p>
545               </item>
546             </list>
547           </p>
548         </sect1>
549
550         <sect1>
551           <heading>The non-US sections</heading>
552           <p>
553             Non-free programs with cryptographic program code need to
554             be stored on the <em>non-us</em> server because of export
555             restrictions of the U.S.
556           </p>
557           <p>
558             Programs which use patented algorithms that have a
559             restrictied license also need to be stored on "non-us",
560             since that is located in a country where it is not allowed
561             to patent algorithms.
562           </p>
563           <p>
564             A package depends on another package which is distributed
565             via the non-us server has to be stored on the non-us
566             server as well.
567           </p>
568         </sect1>
569         <sect1>
570           <heading>Further copyright considerations</heading>
571           <p>
572             Every package must be accompanied by a verbatim copy of
573             its copyright and distribution license in the file
574             <file>/usr/share/doc/<var>package</var>/copyright</file>
575             (see <ref id="copyrightfile"> for further details).
576           </p>
577           <p>
578             We reserve the right to restrict files from being included
579             anywhere in our archives if
580             <list compact="compact">
581               <item>
582                 <p>
583                   their use or distribution would break a law,
584                 </p>
585               </item>
586               <item>
587                 <p>
588                   there is an ethical conflict in their distribution or
589                   use,
590                 </p>
591               </item>
592               <item>
593                 <p>
594                   we would have to sign a license for them, or
595                 </p>
596               </item>
597               <item>
598                 <p>
599                   their distribution would conflict with other project
600                   policies.
601                 </p>
602               </item>
603             </list>
604           </p>
605
606           <p>
607             Programs whose authors encourage the user to make
608             donations are fine for the main distribution, provided
609             that the authors do not claim that not donating is
610             immoral, unethical, illegal or something similar; in such
611             a case they must go in <em>non-free</em>.</p>
612
613           <p>
614             Packages whose copyright permission notices (or patent
615             problems) do not even allow redistribution of binaries
616             only, and where no special permission has been obtained,
617             must not be placed on the Debian FTP site and its mirrors
618             at all.</p>
619
620           <p>
621             Note that under international copyright law (this applies
622             in the United States, too), <em>no</em> distribution or
623             modification of a work is allowed without an explicit
624             notice saying so.  Therefore a program without a copyright
625             notice <em>is</em> copyrighted and you may not do anything
626             to it without risking being sued! Likewise if a program
627             has a copyright notice but no statement saying what is
628             permitted then nothing is permitted.</p>
629
630           <p>
631             Many authors are unaware of the problems that restrictive
632             copyrights (or lack of copyright notices) can cause for
633             the users of their supposedly-free software.  It is often
634             worthwhile contacting such authors diplomatically to ask
635             them to modify their license terms. However, this can be a
636             politically difficult thing to do and you should ask for
637             advice on the <tt>debian-legal</tt> mailing list first, as
638             explained below.
639           </p>
640
641           <p>
642             When in doubt about a copyright, send mail to
643             <email>debian-legal@lists.debian.org</email>.  Be prepared
644             to provide us with the copyright statement.  Software
645             covered by the GPL, public domain software and BSD-like
646             copyrights are safe; be wary of the phrases "commercial
647             use prohibited" and "distribution restricted".
648           </p>
649         </sect1>
650         <sect1>
651           <heading>Subsections</heading>
652
653           <p>
654             The packages in the sections <em>main</em>,
655             <em>contrib</em> and <em>non-free</em> are grouped further
656             into <em>subsections</em> to simplify handling.
657           </p>
658
659           <p>
660             The section and subsection for each package should be
661             specified in the package's <tt>Section</tt> control
662             record.  However, the maintainer of the Debian archive
663             may override this selection to ensure the consistency of
664             the Debian distribution.  The <tt>Section</tt> field
665             should be of the form:
666             <list compact="compact">
667               <item>
668                 <p>
669                   <em>subsection</em> if the package is in the
670                   <em>main</em> section,
671                 </p>
672               </item>
673               <item>
674                 <p>
675                   <em>section/subsection</em> if the package is in
676                   the <em>contrib</em> or <em>non-free</em> section,
677                   and
678                 </p>
679               </item>
680               <item>
681                 <p>
682                   <tt>non-US</tt>, <tt>non-US/contrib</tt> or
683                   <tt>non-US/non-free</tt> if the package is in
684                   <em>non-US/main</em>, <em>non-US/contrib</em> or
685                   <em>non-US/non-free</em> respectively.
686                 </p>
687               </item>
688             </list>
689           </p>
690
691           <p>
692             The Debian archive maintainers provide the authoritative
693             list of subsections.  At present, they are:
694             <em>admin</em>, <em>base</em>, <em>comm</em>,
695             <em>contrib</em>, <em>devel</em>, <em>doc</em>,
696             <em>editors</em>, <em>electronics</em>, <em>games</em>,
697             <em>graphics</em>, <em>hamradio</em>,
698             <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
699             <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
700             <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
701             <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
702             <em>sound</em>, <em>tex</em>, <em>text</em>,
703             <em>utils</em>, <em>web</em>, <em>x11</em>.
704           </p>
705         </sect1>
706       <sect>
707         <heading>Priorities</heading>
708
709         <p>
710           Each package should have a <em>priority</em> value, which is
711           included in the package's <em>control record</em>. This
712           information is used by the Debian package management tools
713           to separate high-priority packages from less-important
714           packages.</p>
715
716         <p>
717           The following <em>priority levels</em> are recognised by the
718           Debian package management tools.
719           <taglist>
720             <tag><tt>required</tt></tag>
721             <item>
722               <p>
723                 Packages which are necessary for the proper
724                 functioning of the system.  You must not remove these
725                 packages or your system may become totally broken and
726                 you may not even be able to use <prgn>dpkg</prgn> to
727                 put things back.  Systems with only the
728                 <tt>required</tt> packages are probably unusable, but
729                 they do have enough functionality to allow the
730                 sysadmin to boot and install more software.</p>
731             </item>
732             <tag><tt>important</tt></tag>
733             <item>
734               <p>
735                 Important programs, including those which one would
736                 expect to find on any Unix-like system.  If the
737                 expectation is that an experienced Unix person who
738                 found it missing would say "What on earth is going on,
739                 where is <prgn>foo</prgn>?", it must be an
740                 <tt>important</tt> package.<footnote>
741                   <p>
742                     This is an important criterion because we are
743                     trying to produce, amongst other things, a free
744                     Unix.
745                   </p>
746                 </footnote>
747                 Other packages without which the system will not run
748                 well or be usable must also have priority
749                 <tt>important</tt>.  This does
750                 <em>not</em> include Emacs, the X Window System, TeX
751                 or any other large applications.  The
752                 <tt>important</tt> packages are just a bare minimum of
753                 commonly-expected and necessary tools.</p>
754             </item>
755             <tag><tt>standard</tt></tag>
756             <item>
757               <p>
758                 These packages provide a reasonably small but not too
759                 limited character-mode system.  This is what will be
760                 installed by default if the user doesn't select anything
761                 else.  It doesn't include many large applications.</p>
762             </item>
763             <tag><tt>optional</tt></tag>
764             <item>
765               <p>
766                 (In a sense everything that isn't required is
767                 optional, but that's not what is meant here.) This is
768                 all the software that you might reasonably want to
769                 install if you didn't know what it was and don't have
770                 specialized requirements. This is a much larger system
771                 and includes the X Window System, a full TeX
772                 distribution, and many applications. Note that
773                 optional packages should not conflict with each other.
774               </p>
775             </item>
776             <tag><tt>extra</tt></tag>
777             <item>
778               <p>
779                 This contains all packages that conflict with others
780                 with required, important, standard or optional
781                 priorities, or are only likely to be useful if you
782                 already know what they are or have specialised
783                 requirements.
784               </p>
785             </item>
786           </taglist></p>
787
788         <p>
789           Packages must not depend on packages with lower priority
790           values (excluding build-time dependencies).  In order to
791           ensure this, the priorities of one or more packages may need
792           to be adjusted.
793         </p>
794       </sect>
795
796       <sect>
797         <heading>Binary packages</heading>
798
799         <p>
800           The Debian GNU/Linux distribution is based on the Debian
801           package management system, called <prgn>dpkg</prgn>. Thus,
802           all packages in the Debian distribution must be provided
803           in the <tt>.deb</tt> file format.</p>
804
805
806         <sect1>
807           <heading>The package name</heading>
808
809           <p>
810             Every package must have a name that's unique within the Debian
811             archive.</p>
812
813           <p>
814             Package names must consist of lower case letters
815             (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
816             and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
817             They must be at least two characters long and must start
818             with an alphanumeric character.
819           </p>
820
821           <p>
822             The package name is part of the file name of the
823             <tt>.deb</tt> file and is included in the control field
824             information.
825           </p>
826         </sect1>
827
828         <sect1>
829           <heading>The maintainer of a package</heading>
830          <p>
831             Every package must have a Debian maintainer (the
832             maintainer may be one person or a group of people
833             reachable from a common email address, such as a mailing
834             list).  The maintainer is responsible for ensuring that
835             the package is placed in the appropriate distributions.
836           </p>
837
838           <p>
839             The maintainer must be specified in the
840             <tt>Maintainer</tt> control field with their correct name
841             and a working email address.  If one person maintains
842             several packages, he/she should try to avoid having
843             different forms of their name and email address in
844             the <tt>Maintainer</tt> fields of those packages.
845           </p>
846
847           <p>
848             If the maintainer of a package quits from the Debian
849             project, "Debian QA Group"
850             <email>packages@qa.debian.org</email> takes over the
851             maintainership of the package until someone else
852             volunteers for that task. These packages are called
853             <em>orphaned packages</em>.<footnote>
854               <p>
855                 The detailed procedure for doing this gracefully can
856                 be found in the Debian Developer's Reference, either
857                 in the <tt>developers-reference</tt> package, or on
858                 the Debian FTP server
859                 <ftpsite>ftp.debian.org</ftpsite> as
860                 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
861                 or from the <url
862                 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
863                 name="Debian Developer's Reference"> webpage.
864               </p>
865             </footnote>
866           </p>
867         </sect1>
868
869
870         <sect1>
871           <heading>The description of a package</heading>
872
873           <p>
874             Every Debian package must have an extended description
875             stored in the appropriate field of the control record.</p>
876
877           <p>
878             The description should be written so that it gives the
879             system administrator enough information to decide whether
880             to install the package. This description should not just
881             be copied verbatim from the program's documentation.
882             Instructions for configuring or using the package should
883             not be included (that is what installation scripts,
884             manual pages, info files, etc., are for).  Copyright
885             statements and other administrivia should not be included
886             either (that is what the copyright file is for).
887           </p>
888
889           <p>
890             Please refer to <ref id="descriptions"> for more information.
891           </p>
892
893         </sect1>
894
895
896         <sect1>
897           <heading>Dependencies</heading>
898
899           <p>
900             Every package must specify the dependency information
901             about other packages that are required for the first to
902             work correctly.</p>
903
904           <p>
905             For example, a dependency entry must be provided for any
906             shared libraries required by a dynamically-linked executable
907             binary in a package.</p>
908
909           <p>
910             Packages are not required to declare any dependencies they
911             have on other packages which are marked <tt>Essential</tt>
912             (see below), and should not do so unless they depend on a
913             particular version of that package.</p>
914
915           <p>
916             Sometimes, a package requires another package to be installed
917             <em>and</em> configured before it can be installed. In this
918             case, you must specify a <tt>Pre-Depends</tt> entry for
919             the package.</p>
920
921           <p>
922             You should not specify a <tt>Pre-Depends</tt> entry for a
923             package before this has been discussed on the
924             <tt>debian-devel</tt> mailing list and a consensus about
925             doing that has been reached.</p></sect1>
926
927
928         <sect1 id="virtual_pkg">
929           <heading>Virtual packages</heading>
930
931           <p>
932             Sometimes, there are several packages which offer
933             more-or-less the same functionality. In this case, it's
934             useful to define a <em>virtual package</em> whose name
935             describes that common functionality.  (The virtual
936             packages only exist logically, not physically; that's why
937             they are called <em>virtual</em>.) The packages with this
938             particular function will then <em>provide</em> the virtual
939             package. Thus, any other package requiring that function
940             can simply depend on the virtual package without having to
941             specify all possible packages individually.</p>
942
943           <p>
944             All packages should use virtual package names where
945             appropriate, and arrange to create new ones if necessary.
946             They should not use virtual package names (except privately,
947             amongst a cooperating group of packages) unless they have
948             been agreed upon and appear in the list of virtual package
949             names. (See also <ref id="virtual">)</p>
950
951           <p>
952             The latest version of the authoritative list of virtual
953             package names can be found in the <tt>debian-policy</tt> package.
954             It's also available from the Debian web mirrors at
955             <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
956                 id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>
957             and from the Debian archive mirrors at
958             <tt><url name="/doc/package-developer/virtual-package-names-list.txt"
959                 id="http://ftp.debian.org/debian/doc/package-developer/virtual-package-names-list.txt"></tt>.
960           </p>
961
962           <p>
963             The procedure for updating the list is described in the preface
964             to the list.
965           </p>
966
967         </sect1>
968
969         <sect1>
970           <heading>Base system</heading>
971
972           <p>
973             The  <tt>base system</tt> is a minimum subset of the Debian
974             GNU/Linux system that is installed before everything else
975             on a new system. Thus, only very few packages are allowed
976             to go into the <tt>base</tt> section to keep the required
977             disk usage very small.</p>
978
979           <p>
980             Most of these packages will have the priority value
981             <tt>required</tt> or at least <tt>important</tt>, and many
982             of them will be tagged <tt>essential</tt> (see below).</p>
983
984
985         </sect1>
986
987
988         <sect1>
989           <heading>Essential packages</heading>
990
991           <p>
992             Some packages are tagged <tt>essential</tt>. (They have
993             <tt>Essential: yes</tt> in their package control record.)
994             This flag is used for packages that are <em>essential</em>
995             for a system.</p>
996
997           <p>
998             Since these packages cannot be easily removed (one has to
999             specify an extra <em>force option</em> to
1000             <prgn>dpkg</prgn> to do so), this flag must not be used
1001             unless absolutely necessary.  A shared library package
1002             must not be tagged <tt>essential</tt>; dependencies will
1003             prevent its premature removal, and we need to be able to
1004             remove it when it has been superseded.
1005           </p>
1006
1007           <p>
1008             Since dpkg will not prevent upgrading of other packages
1009             while an <tt>essential</tt> package is in an unconfigured
1010             state, all <tt>essential</tt> packages must supply all of
1011             their core functionality even when unconfigured. If the
1012             package cannot satisfy this requirement it must not be
1013             tagged as essential, and any packages depending on this
1014             package must instead have explicit dependency fields as
1015             appropriate.
1016           </p>
1017
1018           <p>
1019             You must not tag any packages <tt>essential</tt> before
1020             this has been discussed on the <tt>debian-devel</tt>
1021             mailing list and a consensus about doing that has been
1022             reached.
1023           </p>
1024         </sect1>
1025          <sect1>
1026           <heading>Tasks</heading>
1027
1028           <p>
1029             The Debian install process allows the user to choose from
1030             a number of common tasks which a Debian system can be used to
1031             perform. Selecting a task with <prgn>tasksel</prgn> causes
1032             a set of packages that are useful in performing that task to be
1033             installed.
1034           </p>
1035
1036           <p>
1037             This set of packages is all available packages which have the
1038             name of the selected task in the <tt>Task</tt> field of their
1039             control file. The format of this field is a list of tasks,
1040             separated by commas.
1041           </p>
1042
1043           <p>
1044             You should not tag any packages as belonging to a task
1045             before this has been discussed on the
1046             <em>debian-devel</em> mailing list and a consensus about
1047             doing that has been reached.
1048           </p>
1049
1050           <p>
1051             For third parties (and historical reasons), tasksel also
1052             supports constructing tasks based on <em>task
1053             packages</em>. These are packages whose names begin with
1054             <em>task-</em>. Task packages should not be included in the
1055             Debian archive.
1056           </p>
1057         </sect1>
1058
1059         <sect1 id="maintscripts">
1060           <heading>Maintainer Scripts</heading>
1061
1062           <p>
1063             The package installation scripts should avoid producing
1064             output which it is unnecessary for the user to see and
1065             should rely on <prgn>dpkg</prgn> to stave off boredom on
1066             the part of a user installing many packages.  This means,
1067             amongst other things, using the <tt>--quiet</tt> option on
1068             <prgn>install-info</prgn>.</p>
1069
1070           <p>
1071             Errors which occur during the execution of an installation
1072             script must be checked and the installation must not
1073             continue after an error.
1074           </p>
1075
1076           <p>
1077             Note that in general <ref id="scripts"> applies to package
1078             maintainer scripts, too.
1079           </p>
1080
1081           <p>
1082             You should not use <prgn>dpkg-divert</prgn> on a file
1083             belonging to another package without consulting the
1084             maintainer of that package first.
1085           </p>
1086
1087           <p>
1088             All packages which supply an instance of a common command
1089             name (or, in general, filename) should generally use
1090             <prgn>update-alternatives</prgn>, so that they may be
1091             installed together.  If <prgn>update-alternatives</prgn>
1092             is not used, then each package must use
1093             <tt>Conflicts</tt> to ensure that other packages are
1094             de-installed.  (In this case, it may be appropriate to
1095             specify a conflict against earlier versions of something
1096             that previously did not use
1097             <prgn>update-alternatives</prgn>; this is an exception to
1098             the usual rule that versioned conflicts should be
1099             avoided.)
1100           </p>
1101
1102
1103           <sect2>
1104             <heading>Prompting in maintainer scripts</heading>
1105             <p>
1106               Package maintainer scripts may prompt the user if
1107               necessary. Prompting may be accomplished by hand, or by
1108               communicating with a program, such as
1109               <prgn>debconf</prgn>, which conforms to the Debian
1110               Configuration management specification, version 2 or
1111               higher.  These are included in the
1112               <file>debconf_specification</file> files in the
1113               <package>debian-policy</package> package.
1114               You may also find this file on the FTP site
1115               <ftpsite>ftp.debian.org</ftpsite> in
1116               <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1117               or on your local mirror.<footnote>
1118                 <p>
1119                   4% of Debian packages [see <url
1120                   id="http://kitenet.net/programs/debconf/stats/"
1121                   name="Debconf stats">] currently use
1122                   <package>debconf</package> to prompt the user at
1123                   install time, and this number is growing daily. The
1124                   benefits of using debconf are briefly explained at
1125                   <url
1126                   id="http://kitenet.net/doc/debconf-doc/introduction.html"
1127                   name="Debconf introduction">; they include
1128                   preconfiguration, (mostly) noninteractive
1129                   installation, elimination of redundant prompting,
1130                   consistency of user interface, etc.
1131                 </p>
1132                 <p>
1133                   With this increasing number of packages using
1134                   <package>debconf</package>, plus the existance of a
1135                   nascent second implementation of the Debian
1136                   configuration management system
1137                   (<package>cdebconf</package>), and the stabilization
1138                   of the protocol these things use, the time has
1139                   finally come to reflect the use of these things in
1140                   policy.
1141
1142                 </p>
1143               </footnote>
1144             </p>
1145             <p>
1146               Packages which use the Debian Configuration management
1147               specification may contain an additional
1148               <prgn>config</prgn> script and a <tt>templates</tt>
1149               file in their control archive. The <prgn>config</prgn>
1150               script might be run before the <prgn>preinst</prgn>
1151               script, and before the package is unpacked or any of its
1152               dependencies or pre-dependancies are satisfied.
1153               Therefore it must work using only the tools present in
1154               <em>essential</em> packages.<footnote>
1155                 <p>
1156                   <package>Debconf</package> or another tool that
1157                   implements the Debian Configuration management
1158                   specification will also be installed, and any
1159                   versioned dependencies on it will be satisfied
1160                   before preconfiguration begins.
1161                 </p>
1162               </footnote>
1163             </p>
1164
1165             <p>
1166               Packages should try to minimize the amount of prompting
1167               they need to do, and they should ensure that the user
1168               will only ever be asked each question once.  This means
1169               that packages should try to use appropriate shared
1170               configuration files (such as <file>/etc/papersize</file> and
1171               <file>/etc/news/server</file>), and shared
1172               <package>debconf</package> variables rather than each
1173               prompting for their own list of required pieces of
1174               information.
1175             </p>
1176
1177             <p>
1178               It also means that an upgrade should not ask the same
1179               questions again, unless the user has used <tt>dpkg
1180                 --purge</tt> to remove the package's configuration.  The
1181               answers to configuration questions should be stored in an
1182               appropriate place in <file>/etc</file> so that the user can
1183               modify them, and how this has been done should be
1184               documented.</p>
1185
1186             <p>
1187               If a package has a vitally important piece of
1188               information to pass to the user (such as "don't run me
1189               as I am, you must edit the following configuration files
1190               first or you risk your system emitting badly-formatted
1191               messages"), it should display this in the
1192               <prgn>config</prgn> or <prgn>postinst</prgn> script and
1193               prompt the user to hit return to acknowledge the
1194               message.  Copyright messages do not count as vitally
1195               important (they belong in
1196               <file>/usr/share/doc/<var>package</var>/copyright</file>);
1197               neither do instructions on how to use a program (these
1198               should be in on-line documentation, where all the users
1199               can see them).</p>
1200
1201             <p>
1202               Any necessary prompting should almost always be confined
1203               to the <prgn>config</prgn> or <prgn>postinst</prgn>
1204               script. If it is done in the <prgn>postinst</prgn>, it
1205               should be protected with a conditional so that
1206               unnecessary prompting doesn't happen if a package's
1207               installation fails and the <prgn>postinst</prgn> is
1208               called with <tt>abort-upgrade</tt>,
1209               <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1210         </sect1>
1211       </sect>
1212
1213       <sect>
1214         <heading>Source packages</heading>
1215
1216         <sect1 id="standardsversion">
1217           <heading>Standards conformance</heading>
1218
1219           <p>
1220             In the source package's <tt>Standards-Version</tt> control
1221             field, you should specify the most recent version number
1222             of this policy document with which your package complied
1223             when it was last updated.  The current version number is
1224             &version;.
1225           </p>
1226
1227           <p>
1228             This information may be used to file bug reports
1229             automatically if your package becomes too much out of
1230             date.
1231           </p>
1232
1233           <p>
1234             The version number has four components: major and minor
1235             version number and major and minor patch level.  When the
1236             standards change in a way that requires every package to
1237             change the major number will be changed.  Significant
1238             changes that will require work in many packages will be
1239             signaled by a change to the minor number.  The major patch
1240             level will be changed for any change to the meaning of the
1241             standards, however small; the minor patch level will be
1242             changed when only cosmetic, typographical or other edits
1243             are made which neither change the meaning of the document
1244             nor affect the contents of packages.</p>
1245
1246           <p>
1247             Thus only the first three components of the policy version
1248             are significant in the <em>Standards-Version</em> control
1249             field, and so either these three components or the all
1250             four components may be specified.<footnote>
1251               <p>
1252                 In the past, people specified the full version number
1253                 in the Standards-Version field, for example "2.3.0.0".
1254                 Since minor patch-level changes don"t introduce new
1255                 policy, it was thought it would be better to relax
1256                 policy and only require the first 3 components to be
1257                 specified, in this example "2.3.0".  All four
1258                 components may still be used if someone wishes to do
1259                 so.
1260               </p>
1261             </footnote>
1262           </p>
1263
1264           <p>
1265             You should regularly, and especially if your package has
1266             become out of date, check for the newest Policy Manual
1267             available and update your package, if necessary. When your
1268             package complies with the new standards you should update the
1269             <tt>Standards-Version</tt> source package field and
1270             release it.<footnote>
1271               <p>
1272                 See the file <file>upgrading-checklist</file> for
1273                 information about policy which has changed between
1274                 different versions of this document.
1275               </p>
1276             </footnote>
1277           </p>
1278         </sect1>
1279
1280
1281         <sect1 id="pkg-relations">
1282           <heading>Package relationships</heading>
1283
1284           <p>
1285             Source packages should specify which binary packages they
1286             require to be installed or not to be installed in order to
1287             build correctly.  For example, if building a package
1288             requires a certain compiler, then the compiler should be
1289             specified as a build-time dependency.
1290           </p>
1291
1292           <p>
1293             It is not necessary to explicitly specify build-time
1294             relationships on a minimal set of packages that are always
1295             needed to compile, link and put in a Debian package a
1296             standard "Hello World!" program written in C or C++.  The
1297             required packages are called <em>build-essential</em>, and
1298             an informational list can be found in
1299             <file>/usr/share/doc/build-essential/list</file> (which is
1300             contained in the <tt>build-essential</tt>
1301             package).<footnote>
1302               <p>Rationale:
1303                 <list compact="compact">
1304                   <item>
1305                     <p>This allows maintaining the list separately
1306                       from the policy documents (the list does not
1307                       need the kind of control that the policy
1308                       documents do).
1309                     </p>
1310                   </item>
1311                   <item>
1312                     <p>
1313                       Having a separate package allows one to install
1314                       the build-essential packages on a machine, as
1315                       well as allowing other packages such as tasks to
1316                       require installation of the build-essential
1317                       packages using the depends relation.
1318                     </p>
1319                   </item>
1320                   <item>
1321                     <p>
1322                       The separate package allows bug reports against
1323                       the list to be categorized separately from
1324                       the policy management process in the BTS.
1325                     </p>
1326                   </item>
1327                 </list>
1328               </p>
1329
1330             </footnote>
1331           </p>
1332
1333           <p>
1334             When specifying the set of build-time dependencies, one
1335             should list only those packages explicitly required by the
1336             build.  It is not necessary to list packages which are
1337             required merely because some other package in the list of
1338             build-time dependencies depends on them.<footnote>
1339               <p>
1340                 The reason for this is that dependencies change, and
1341                 you should list all those packages, and <em>only</em>
1342                 those packages that <em>you</em> need directly.  What
1343                 others need is their business.  For example, if you
1344                 only link against <file>libimlib</file>, you will need to
1345                 build-depend on <package>libimlib2-dev</package> but
1346                 not against any <tt>libjpeg*</tt> packages, even
1347                 though <tt>libimlib2-dev</tt> currently depends on
1348                 them: installation of <package>libimlib2-dev</package>
1349                 will automatically ensure that all of its run-time
1350                 dependencies are satisfied.
1351               </p>
1352             </footnote>
1353           </p>
1354
1355           <p>
1356             If build-time dependencies are specified, it must be
1357             possible to build the package and produce working binaries
1358             on a system with only essential and build-essential
1359             packages installed and also those required to satisfy the
1360             build-time relationships (including any implied
1361             relationships).  In particular, this means that version
1362             clauses should be used rigorously in build-time
1363             relationships so that one cannot produce bad or
1364             inconsistently configured packages when the relationships
1365             are properly satisfied.
1366           </p>
1367
1368           <p>
1369             <ref id="relationships"> explains the technical details.
1370           </p>
1371
1372         <sect1>
1373           <heading>Changes to the upstream sources</heading>
1374
1375           <p>
1376             If changes to the source code are made that are not
1377             specific to the needs of the Debian system, they should be
1378             sent to the upstream authors in whatever form they prefer
1379             so as to be included in the upstream version of the
1380             package.</p>
1381
1382           <p>
1383             If you need to configure the package differently for
1384             Debian or for Linux, and the upstream source doesn't
1385             provide a way to do so, you should add such configuration
1386             facilities (for example, a new <prgn>autoconf</prgn> test
1387             or <tt>#define</tt>) and send the patch to the upstream
1388             authors, with the default set to the way they originally
1389             had it.  You can then easily override the default in your
1390             <file>debian/rules</file> or wherever is appropriate.</p>
1391
1392           <p>
1393             You should make sure that the <prgn>configure</prgn> utility
1394             detects the correct architecture specification string
1395             (refer to <ref id="arch-spec"> for details).</p>
1396
1397           <p>
1398             If you need to edit a <prgn>Makefile</prgn> where
1399             GNU-style <prgn>configure</prgn> scripts are used, you
1400             should edit the <file>.in</file> files rather than editing the
1401             <prgn>Makefile</prgn> directly.  This allows the user to
1402             reconfigure the package if necessary.  You should
1403             <em>not</em> configure the package and edit the generated
1404             <prgn>Makefile</prgn>!  This makes it impossible for
1405             someone else to later reconfigure the package.</p>
1406
1407           <p>
1408             You should document your changes and updates to the source
1409             package properly in the <file>debian/changelog</file> file.
1410             For more information, please see <ref id="changelogs">.
1411           </p>
1412         </sect1>
1413
1414
1415         <sect1>
1416           <heading>Error trapping in makefiles</heading>
1417
1418           <p>
1419             When <prgn>make</prgn> invokes a command in a makefile
1420             (including your package's upstream makefiles and
1421             <file>debian/rules</file>), it does so using <prgn>sh</prgn>.  This
1422             means that <prgn>sh</prgn>'s usual bad error handling
1423             properties apply: if you include a miniature script as one
1424             of the commands in your makefile you'll find that if you
1425             don't do anything about it then errors are not detected
1426             and <prgn>make</prgn> will blithely continue after
1427             problems.</p>
1428
1429           <p>
1430             Every time you put more than one shell command (this
1431             includes using a loop) in a makefile command you
1432             must make sure that errors are trapped.  For
1433             simple compound commands, such as changing directory and
1434             then running a program, using <tt>&amp;&amp;</tt> rather
1435             than semicolon as a command separator is sufficient.  For
1436             more complex commands including most loops and
1437             conditionals you should include a separate <tt>set -e</tt>
1438             command at the start of every makefile command that's
1439             actually one of these miniature shell scripts.</p></sect1>
1440
1441
1442         <sect1>
1443           <heading>Obsolete constructs and libraries</heading>
1444
1445           <p>
1446             The include file <tt>&lt;varargs.h&gt;</tt> is
1447             provided to support end-users compiling very old software;
1448             the library <tt>libtermcap</tt> is provided to support the
1449             execution of software which has been linked against it
1450             (either old programs or those such as Netscape which are
1451             only available in binary form).</p>
1452
1453           <p>
1454             Debian packages should be patched to use
1455             <tt>&lt;stdarg.h&gt;</tt> and <tt>ncurses</tt>
1456             instead.
1457           </p>
1458         </sect1>
1459       </sect>
1460     </chapt>
1461
1462     <chapt id="controlfields"><heading>Control files and their fields</heading>
1463
1464       <p>
1465         Many of the tools in the package management suite manipulate
1466         data represented in a common format, known as <em>control
1467         data</em>.  The data is often stored in <em>control
1468         files</em>.  Binary and source packages have control files,
1469         and the <file>.changes</file> files which control the installation
1470         of uploaded files are also in control file format.
1471         <prgn>dpkg</prgn>'s internal databases are in a similar
1472         format.
1473       </p>
1474
1475       <sect id="controlsyntax"><heading>Syntax of control files</heading>
1476
1477         <p>
1478           A control file consists of one or more paragraphs of fields.
1479           The paragraphs are separated by blank lines.  Some control
1480           files allow only one paragraph; others allow several, in
1481           which case each paragraph usually refers to a different
1482           package.  (For example, in source packages, the first
1483           paragraph refers to the source package, and later paragraphs
1484           refer to binary packages generated from the source.)
1485         </p>
1486
1487         <p>
1488           Each paragraph consists of a series of data fields; each
1489           field consists of the field name, followed by a colon and
1490           then the data/value associated with that field.  It ends at
1491           the end of the line.  Horizontal whitespace (spaces and
1492           tabs) may occur immediately before or after the value and is
1493           ignored there; it is conventional to put a single space
1494           after the colon.  For example, a field might be:
1495           <example compact="compact">
1496 Package: libc6
1497           </example>
1498           the field name is <tt>Package</tt> and the field value
1499           <tt>libc6</tt>.
1500         </p>
1501
1502         <p>
1503           Some fields' values may span several lines; in this case
1504           each continuation line <em>must</em> start with a space or
1505           tab.  Any trailing spaces or tabs at the end of individual
1506           lines of a field value are ignored.
1507         </p>
1508
1509         <p>
1510           Except where otherwise stated only a single line of data is
1511           allowed and whitespace is not significant in a field body.
1512           Whitespace must not appear inside names (of packages,
1513           architectures, files or anything else) or version numbers,
1514           or between the characters of multi-character version
1515           relationships.
1516         </p>
1517
1518         <p>
1519           Field names are not case-sensitive, but it is usual to
1520           capitalize the field names using mixed case as shown below.
1521         </p>
1522
1523         <p>
1524           Blank lines, or lines consisting only of spaces and tabs,
1525           are not allowed within field values or between fields - that
1526           would mean a new paragraph.
1527         </p>
1528
1529       </sect>
1530
1531       <sect><heading>List of fields</heading>
1532         <p>
1533           This list here is not supposed to be exhaustive. Most fields
1534           are dealt with elsewhere in this document.
1535         </p>
1536         <sect1 id="f-Package"><heading><tt>Package</tt>
1537           </heading>
1538
1539           <p>
1540             The name of the binary package.  Package names consist of
1541             lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1542             plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1543             periods (<tt>.</tt>).
1544           </p>
1545
1546           <p>
1547             They must be at least two characters long and must start
1548             with an alphanumeric character.  The use of lowercase
1549             package names is required unless the package you're
1550             building (or referring to, in other fields) is already
1551             using uppercase characters.</p>
1552         </sect1>
1553
1554         <sect1 id="f-Version"><heading><tt>Version</tt>
1555           </heading>
1556
1557           <p>
1558             This lists the source or binary package's version number -
1559             see <ref id="versions">.
1560           </p>
1561
1562         </sect1>
1563
1564         <sect1
1565                id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1566           </heading>
1567
1568           <p>
1569             The most recent version of the standards (the policy
1570             manual and associated texts) with which the package
1571             complies.  This is updated manually when editing the
1572             source package to conform to newer standards; it can
1573             sometimes be used to tell when a package needs attention.
1574             Its format is described above; see
1575             <ref id="standardsversion">.
1576           </p>
1577         </sect1>
1578
1579
1580         <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1581           </heading>
1582
1583           <p>
1584             In a <file>.changes</file> file or parsed changelog output
1585             this contains the (space-separated) name(s) of the
1586             distribution(s) where this version of the package should
1587             be installed.  Valid distributions are determined by the
1588             archive maintainers.<footnote>
1589                 Current distribution names are:
1590                 <taglist compact="compact">
1591                   <tag><em>stable</em></tag>
1592                   <item>
1593                     <p>
1594                       This is the current "released" version of Debian
1595                       GNU/Linux.  Once the distribution is
1596                       <em>stable</em> only security fixes and other
1597                       major bug fixes are allowed. When changes are
1598                       made to this distribution, the release number is
1599                       increased (for example: 2.2r1 becomes 2.2r2 then
1600                       2.2r3, etc).
1601                     </p>
1602                   </item>
1603
1604                   <tag><em>unstable</em></tag>
1605                   <item>
1606                     <p>
1607                       This distribution value refers to the
1608                       <em>developmental</em> part of the Debian
1609                       distribution tree. New packages, new upstream
1610                       versions of packages and bug fixes go into the
1611                       <em>unstable</em> directory tree. Download from
1612                       this distribution at your own risk.
1613                     </p>
1614                   </item>
1615
1616                   <tag><em>testing</em></tag>
1617                   <item>
1618                     <p>
1619                       This distribution value refers to the
1620                       <em>testing</em> part of the Debian distribution
1621                       tree.  It receives its packages from the
1622                       unstable distribution after a short time lag to
1623                       ensure that there are no major issues with the
1624                       unstable packages.  It is less prone to breakage
1625                       than unstable, but still risky.  It is not
1626                       possible to upload packages directly to
1627                       <em>testing</em>.
1628                     </p>
1629                   </item>
1630
1631                   <tag><em>frozen</em></tag>
1632                   <item>
1633                     <p>
1634                       From time to time, the <em>testing</em>
1635                       distribution enters a state of "code-freeze" in
1636                       anticipation of release as a <em>stable</em>
1637                       version. During this period of testing only
1638                       fixes for existing or newly-discovered bugs will
1639                       be allowed.  The exact details of this stage are
1640                       determined by the Release Manager.
1641                     </p>
1642                   </item>
1643
1644                   <tag><em>experimental</em></tag>
1645                   <item>
1646                     <p>
1647                       The packages with this distribution value are
1648                       deemed by their maintainers to be high
1649                       risk. Oftentimes they represent early beta or
1650                       developmental packages from various sources that
1651                       the maintainers want people to try, but are not
1652                       ready to be a part of the other parts of the
1653                       Debian distribution tree. Download at your own
1654                       risk.
1655                     </p>
1656                   </item>
1657                 </taglist>
1658
1659                 You should list <em>all</em> distributions that the
1660                 package should be installed into.
1661             </footnote>
1662           </p>
1663         </sect1>
1664
1665
1666       </sect>
1667     </chapt>
1668
1669     <chapt id="versions"><heading>Version numbering</heading>
1670
1671       <p>
1672         Every package has a version number recorded in its
1673         <tt>Version</tt> control file field.
1674       </p>
1675
1676       <p>
1677         The package management system imposes an ordering on version
1678         numbers, so that it can tell whether packages are being up- or
1679         downgraded and so that package system front end applications
1680         can tell whether a package it finds available is newer than
1681         the one installed on the system.  The version number format
1682         has the most significant parts (as far as comparison is
1683         concerned) at the beginning.
1684       </p>
1685
1686       <p>
1687         The version number format is:
1688         [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1689       </p>
1690
1691       <p>
1692         The three components here are:
1693         <taglist>
1694           <tag><var>epoch</var></tag>
1695           <item>
1696             <p>
1697               This is a single (generally small) unsigned integer.  It
1698               may be omitted, in which case zero is assumed.  If it is
1699               omitted then the <var>upstream_version</var> may not
1700               contain any colons.
1701             </p>
1702
1703             <p>
1704               It is provided to allow mistakes in the version numbers
1705               of older versions of a package, and also a package's
1706               previous version numbering schemes, to be left behind.
1707             </p>
1708           </item>
1709
1710           <tag><var>upstream_version</var></tag>
1711           <item>
1712             <p>
1713               This is the main part of the version number.  It is
1714               usually the version number of the original ("upstream")
1715               package from which the <file>.deb</file> file has been made,
1716               if this is applicable.  Usually this will be in the same
1717               format as that specified by the upstream author(s);
1718               however, it may need to be reformatted to fit into the
1719               package management system's format and comparison
1720               scheme.
1721             </p>
1722
1723             <p>
1724               The comparison behavior of the package management system
1725               with respect to the <var>upstream_version</var> is
1726               described below.  The <var>upstream_version</var>
1727               portion of the version number is mandatory.
1728             </p>
1729
1730             <p>
1731               The <var>upstream_version</var> may contain only
1732               alphanumerics<footnote>
1733                 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1734               </footnote>
1735               and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1736               <tt>:</tt> (full stop, plus, hyphen, colon) and should
1737               start with a digit.  If there is no
1738               <var>debian_revision</var> then hyphens are not allowed;
1739               if there is no <var>epoch</var> then colons are not
1740               allowed.</p>
1741           </item>
1742
1743           <tag><var>debian_revision</var></tag>
1744           <item>
1745             <p>
1746               This part of the version number specifies the version of
1747               the Debian package based on the upstream version.  It
1748               may contain only alphanumerics and the characters
1749               <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1750               compared in the same way as the
1751               <var>upstream_version</var> is.
1752             </p>
1753
1754             <p>
1755               It is optional; if it isn't present then the
1756               <var>upstream_version</var> may not contain a hyphen.
1757               This format represents the case where a piece of
1758               software was written specifically to be turned into a
1759               Debian package, and so there is only one "debianization"
1760               of it and therefore no revision indication is required.
1761             </p>
1762
1763             <p>
1764               It is conventional to restart the
1765               <var>debian_revision</var> at <tt>1</tt> each time the
1766               <var>upstream_version</var> is increased.
1767             </p>
1768
1769             <p>
1770               The package management system will break the version
1771               number apart at the last hyphen in the string (if there
1772               is one) to determine the <var>upstream_version</var> and
1773               <var>debian_revision</var>.  The absence of a
1774               <var>debian_revision</var> compares earlier than the
1775               presence of one (but note that the
1776               <var>debian_revision</var> is the least significant part
1777               of the version number).
1778             </p>
1779           </item>
1780         </taglist>
1781       </p>
1782
1783       <p>
1784         The <var>upstream_version</var> and <var>debian_revision</var>
1785         parts are compared by the package management system using the
1786         same algorithm:
1787       </p>
1788
1789       <p>
1790         The strings are compared from left to right.
1791       </p>
1792
1793       <p>
1794         First the initial part of each string consisting entirely of
1795         non-digit characters is determined.  These two parts (one of
1796         which may be empty) are compared lexically.  If a difference
1797         is found it is returned.  The lexical comparison is a
1798         comparison of ASCII values modified so that all the letters
1799         sort earlier than all the non-letters.
1800       </p>
1801
1802       <p>
1803         Then the initial part of the remainder of each string which
1804         consists entirely of digit characters is determined.  The
1805         numerical values of these two parts are compared, and any
1806         difference found is returned as the result of the comparison.
1807         For these purposes an empty string (which can only occur at
1808         the end of one or both version strings being compared) counts
1809         as zero.
1810       </p>
1811
1812       <p>
1813         These two steps (comparing and removing initial non-digit
1814         strings and initial digit strings) are repeated until a
1815         difference is found or both strings are exhausted.
1816       </p>
1817
1818       <p>
1819         Note that the purpose of epochs is to allow us to leave behind
1820         mistakes in version numbering, and to cope with situations
1821         where the version numbering scheme changes.  It is
1822         <em>not</em> intended to cope with version numbers containing
1823         strings of letters which the package management system cannot
1824         interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1825         silly orderings (the author of this manual has heard of a
1826         package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1827         <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1828         <tt>2</tt> and so forth).
1829       </p>
1830
1831       <p>
1832         If an upstream package has problematic version numbers they
1833         should be converted to a sane form for use in the
1834         <tt>Version</tt> field.
1835       </p>
1836
1837       <sect>
1838         <heading>Version numbers based on dates</heading>
1839         <p>
1840           In general, Debian packages should use the same version
1841           numbers as the upstream sources.</p>
1842
1843         <p>
1844           However, in some cases where the upstream version number is
1845           based on a date (e.g., a development "snapshot" release) the
1846           package management system cannot handle these version
1847           numbers without epochs. For example, dpkg will consider
1848           "96May01" to be greater than "96Dec24".</p>
1849
1850         <p>
1851           To prevent having to use epochs for every new upstream
1852           version, the version number should be changed to the
1853           following format in such cases: "19960501", "19961224". It
1854           is up to the maintainer whether he/she wants to bother the
1855           upstream maintainer to change the version numbers upstream,
1856           too.</p>
1857
1858         <p>
1859           Note that other version formats based on dates which are
1860           parsed correctly by the package management system should
1861           <em>not</em> be changed.</p>
1862
1863         <p>
1864           Native Debian packages (i.e., packages which have been
1865           written especially for Debian) whose version numbers include
1866           dates should always use the "YYYYMMDD" format.</p>
1867       </sect>
1868     </chapt>
1869
1870     <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1871
1872       <sect id="timestamps"><heading>Time Stamps</heading>
1873         <p>
1874           Maintainers should preserve the modification times of the
1875           upstream source files in a package, as far as is reasonably
1876           possible.<footnote>
1877             <p>
1878               The rationale is that there is some information conveyed
1879               by knowing the age of the file, for example, you could
1880               recognize that some documentation is very old by looking
1881               at the modification time, so it would be nice if the
1882               modification time of the upstream source would be
1883               preserved.
1884             </p>
1885           </footnote>
1886         </p>
1887       </sect>
1888
1889       <sect id="debianrules"><heading><file>debian/rules</file> - the
1890           main building script</heading>
1891
1892         <p>
1893           This file must be an executable makefile, and contains the
1894           package-specific recipes for compiling the package and
1895           building binary package(s) from the source.
1896         </p>
1897
1898         <p>
1899           It must start with the line <tt>#!/usr/bin/make -f</tt>,
1900           so that it can be invoked by saying its name rather than
1901           invoking <prgn>make</prgn> explicitly.
1902         </p>
1903
1904         <p>
1905           Since an interactive <file>debian/rules</file> script makes it
1906           impossible to auto-compile that package and also makes it
1907           hard for other people to reproduce the same binary
1908           package, all <em>required targets</em> MUST be
1909           non-interactive. At a minimum, required targets are the
1910           ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1911           <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1912           <em>binary-indep</em>, and <em>build</em>. It also follows
1913           that any target that these targets depend on must also be
1914           non-interactive.
1915         </p>
1916
1917         <p>
1918           The required and optional targets are as follows:
1919           <taglist>
1920             <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1921               <tt>build-indep</tt> (optional)</tag>
1922             <item>
1923               <p>
1924                 The <tt>build</tt> target should perform all
1925                 non-interactive configuration and compilation of the
1926                 package.  If a package has an interactive pre-build
1927                 configuration routine, the Debianized source package
1928                 must either be built after this has taken place (so
1929                 that the binary package can be built without rerunning
1930                 the configuration) or the configuration routine
1931                 modified to become non-interactive.  (The latter is
1932                 preferable if there are architecture-specific features
1933                 detected by the configuration routine.)
1934               </p>
1935
1936               <p>
1937                 For some packages, notably ones where the same
1938                 source tree is compiled in different ways to produce
1939                 two binary packages, the <tt>build</tt> target
1940                 does not make much sense.  For these packages it is
1941                 good enough to provide two (or more) targets
1942                 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1943                 for each of the ways of building the package, and a
1944                 <tt>build</tt> target that does nothing.  The
1945                 <tt>binary</tt> target will have to build the
1946                 package in each of the possible ways and make the
1947                 binary package out of each.
1948               </p>
1949
1950               <p>
1951                 The <tt>build</tt> target must not do anything
1952                 that might require root privilege.
1953               </p>
1954
1955               <p>
1956                 The <tt>build</tt> target may need to run the
1957                 <tt>clean</tt> target first - see below.
1958               </p>
1959
1960               <p>
1961                 When a package has a configuration and build routine
1962                 which takes a long time, or when the makefiles are
1963                 poorly designed, or when <tt>build</tt> needs to
1964                 run <tt>clean</tt> first, it is a good idea to
1965                 <tt>touch build</tt> when the build process is
1966                 complete.  This will ensure that if <tt>debian/rules
1967                 build</tt> is run again it will not rebuild the whole
1968                 program.<footnote>
1969                   <p>
1970                     Another common way to do this is for <tt>build</tt>
1971                     to depend on <prgn>build-stamp</prgn> and to do
1972                     nothing else, and for the <prgn>build-stamp</prgn>
1973                     target to do the building and to <tt>touch
1974                     build-stamp</tt> on completion.  This is
1975                     especially useful if the build routine creates a
1976                     file or directory called <tt>build</tt>; in such a
1977                     case, <tt>build</tt> will need to be listed as
1978                     a phony target (i.e., as a dependency of the
1979                     <tt>.PHONY</tt> target).  See the documentation of
1980                     <prgn>make</prgn> for more information on phony
1981                     targets.
1982                   </p>
1983                 </footnote>
1984               </p>
1985             </item>
1986
1987             <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1988               <tt>binary-indep</tt>
1989             </tag>
1990             <item>
1991               <p>
1992                 The <tt>binary</tt> target must be all that is
1993                 necessary for the user to build the binary package(s)
1994                 produced from this source package.  All of these
1995                 targets are required to be non-interactive.  It is
1996                 split into two parts: <prgn>binary-arch</prgn> builds
1997                 the binary packages which are specific to a particular
1998                 architecture, and <tt>binary-indep</tt> builds
1999                 those which are not.
2000               </p>
2001               <p>
2002                 <tt>binary</tt> may be (and commonly is) a target with
2003                 no commands which simply depends on
2004                 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
2005               </p>
2006               <p>
2007                 Both <tt>binary-*</tt> targets should depend on the
2008                 <tt>build</tt> target, or on the appropriate
2009                 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
2010                 provided, so that the package is built if it has not
2011                 been already.  It should then create the relevant
2012                 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
2013                 make their control files and <prgn>dpkg-deb</prgn> to
2014                 build them and place them in the parent of the top
2015                 level directory.
2016               </p>
2017
2018               <p>
2019                 Both the <tt>binary-arch</tt> and
2020                 <tt>binary-indep</tt> targets <em>must</em> exist.
2021                 If one of them has nothing to do (which will always be
2022                 the case if the source generates only a single binary
2023                 package, whether architecture-dependent or not), it
2024                 must still exist and must always succeed.
2025               </p>
2026
2027               <p>
2028                 The <tt>binary</tt> targets must be invoked as
2029                 root.<footnote>
2030                   <p>
2031                     The <prgn>fakeroot</prgn> package often allows one
2032                     to build a package correctly even without being
2033                     root.
2034                   </p>
2035                 </footnote>
2036               </p>
2037             </item>
2038
2039             <tag><tt>clean</tt></tag>
2040             <item>
2041               <p>
2042                 This must undo any effects that the <tt>build</tt>
2043                 and <tt>binary</tt> targets may have had, except
2044                 that it should leave alone any output files created in
2045                 the parent directory by a run of a <tt>binary</tt>
2046                 target. This target must be non-interactive.
2047               </p>
2048
2049               <p>
2050                 If a <tt>build</tt> file is touched at the end of
2051                 the <tt>build</tt> target, as suggested above, it
2052                 should be removed as the first action that
2053                 <tt>clean</tt> performs, so that running
2054                 <tt>build</tt> again after an interrupted
2055                 <tt>clean</tt> doesn't think that everything is
2056                 already done.
2057               </p>
2058
2059               <p>
2060                 The <tt>clean</tt> target may need to be
2061                 invoked as root if <tt>binary</tt> has been
2062                 invoked since the last <tt>clean</tt>, or if
2063                 <tt>build</tt> has been invoked as root (since
2064                 <tt>build</tt> may create directories, for
2065                 example).
2066               </p>
2067             </item>
2068
2069             <tag><tt>get-orig-source</tt> (optional)</tag>
2070             <item>
2071               <p>
2072                 This target fetches the most recent version of the
2073                 original source package from a canonical archive site
2074                 (via FTP or WWW, for example), does any necessary
2075                 rearrangement to turn it into the original source
2076                 tar file format described below, and leaves it in the
2077                 current directory.
2078               </p>
2079
2080               <p>
2081                 This target may be invoked in any directory, and
2082                 should take care to clean up any temporary files it
2083                 may have left.
2084               </p>
2085
2086               <p>
2087                 This target is optional, but providing it if
2088                 possible is a good idea.
2089               </p>
2090             </item>
2091           </taglist>
2092
2093         <p>
2094           The <tt>build</tt>, <tt>binary</tt> and
2095           <tt>clean</tt> targets must be invoked with the current
2096           directory being the package's top-level directory.
2097         </p>
2098
2099
2100         <p>
2101           Additional targets may exist in <file>debian/rules</file>,
2102           either as published or undocumented interfaces or for the
2103           package's internal use.
2104         </p>
2105
2106         <p>
2107           The architectures we build on and build for are determined
2108           by <prgn>make</prgn> variables using the utility
2109           <prgn>dpkg-architecture</prgn>.  You can determine the
2110           Debian architecture and the GNU style architecture
2111           specification string for the build machine (the machine type
2112           we are building on) as well as for the host machine (the
2113           machine type we are building for).  Here is a list of
2114           supported <prgn>make</prgn> variables:
2115           <list compact="compact">
2116             <item>
2117               <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2118             </item>
2119             <item>
2120               <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2121                 specification string)</p>
2122             </item>
2123             <item>
2124               <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2125               <tt>DEB_*_GNU_TYPE</tt>)</p>
2126             </item>
2127             <item>
2128               <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2129                 <tt>DEB_*_GNU_TYPE</tt>)</p>
2130           </list>
2131           where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2132           the build machine or <tt>HOST</tt> for specification of the
2133           host machine.
2134         </p>
2135
2136         <p>
2137           Backward compatibility can be provided in the rules file
2138           by setting the needed variables to suitable default
2139           values; please refer to the documentation of
2140           <prgn>dpkg-architecture</prgn> for details.
2141         </p>
2142
2143         <p>
2144           It is important to understand that the <tt>DEB_*_ARCH</tt>
2145           string only determines which Debian architecture we are
2146           building on or for. It should not be used to get the CPU
2147           or system information; the GNU style variables should be
2148           used for that.
2149         </p>
2150       </sect>
2151
2152       <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2153         </heading>
2154
2155         <p>
2156           This file records the changes to the Debian-specific parts of the
2157           package<footnote>
2158             <p>
2159               Though there is nothing stopping an author who is also
2160               the Debian maintainer from using it for all their
2161               changes, it will have to be renamed if the Debian and
2162               upstream maintainers become different people.  In such a
2163               case, however, it might be better to maintain the
2164               package as a non-native package.
2165             </p>
2166           </footnote>.
2167         </p>
2168
2169         <p>
2170           It has a special format which allows the package building
2171           tools to discover which version of the package is being
2172           built and find out other release-specific information.
2173         </p>
2174
2175         <p>
2176           That format is a series of entries like this:
2177           <example compact="compact">
2178 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2179             <comment>
2180               <p>[optional blank line(s), stripped]</p>
2181             </comment>
2182   * <var>change details</var>
2183     <var>more change details</var>
2184             <comment>
2185               <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2186             </comment>
2187   * <var>even more change details</var>
2188             <comment>
2189               <p>[optional blank line(s), stripped]</p>
2190             </comment>
2191             -- <var>maintainer name</var> &lt;<var>email
2192               address</var>&gt;<var>[two spaces]</var>  <var>date</var>
2193           </example>
2194         </p>
2195
2196         <p>
2197           <var>package</var> and <var>version</var> are the source
2198           package name and version number.
2199         </p>
2200
2201         <p>
2202           <var>distribution(s)</var> lists the distributions where
2203           this version should be installed when it is uploaded - it
2204           is copied to the <tt>Distribution</tt> field in the
2205           <file>.changes</file> file.  See <ref id="f-Distribution">.
2206         </p>
2207
2208         <p>
2209           <var>urgency</var> is the value for the <tt>Urgency</tt>
2210           field in the <file>.changes</file> file for the upload. It is
2211           not possible to specify an urgency containing commas; commas
2212           are used to separate
2213           <tt><var>keyword</var>=<var>value</var></tt> settings in the
2214           <prgn>dpkg</prgn> changelog format (though there is
2215           currently only one useful <var>keyword</var>,
2216           <tt>urgency</tt>).<footnote>
2217             <p>
2218               Recognised urgency values are <tt>low</tt>,
2219               <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2220               They have an effect on how quickly a package will be
2221               considered for inclusion into the <tt>testing</tt>
2222               distribution, and give an indication of the importance
2223               of any fixes included in this upload.
2224             </p>
2225           </footnote>
2226         </p>
2227
2228         <p>
2229           The change details may in fact be any series of lines
2230           starting with at least two spaces, but conventionally each
2231           change starts with an asterisk and a separating space and
2232           continuation lines are indented so as to bring them in
2233           line with the start of the text above.  Blank lines may be
2234           used here to separate groups of changes, if desired.
2235         </p>
2236
2237         <p>
2238           If this upload resolves bugs recorded in the Bug Tracking
2239           System (BTS), they may be automatically closed on the
2240           inclusion of this package into the Debian archive by
2241           including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2242           in the change details.<footnote>
2243             <p>
2244               To be precise, the string should match the following
2245               Perl regular expression:
2246               <example>
2247 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2248               </example>
2249               Then all of the bug numbers listed will be closed by the
2250               archive maintenance script (<prgn>katie</prgn>), or in
2251               the case of an NMU, marked as fixed.
2252             </p>
2253           </footnote>
2254         </p>
2255
2256         <p>
2257           The maintainer name and email address used in the changelog
2258           should be the details of the person uploading <em>this</em>
2259           version.  They are <em>not</em> necessarily those of the
2260           usual package maintainer.  The information here will be
2261           copied to the <tt>Changed-By</tt> field in the
2262           <tt>.changes</tt> file, and then later used to send an
2263           acknowledgement when the upload has been installed.
2264         </p>
2265
2266         <p>
2267           The <var>date</var> should be in RFC822 format<footnote>
2268             <p>
2269               This is generated by the <prgn>822-date</prgn>
2270               program.
2271             </p>
2272           </footnote>; it should include the time zone specified
2273           numerically, with the time zone name or abbreviation
2274           optionally present as a comment in parentheses.
2275         </p>
2276
2277         <p>
2278           The first "title" line with the package name should start
2279           at the left hand margin; the "trailer" line with the
2280           maintainer and date details should be preceded by exactly
2281           one space.  The maintainer details and the date must be
2282           separated by exactly two spaces.
2283         </p>
2284
2285         <sect1><heading>Defining alternative changelog formats</heading>
2286
2287           <p>
2288             It is possible to use a different format to the standard
2289             one, by providing a parser for the format you wish to
2290             use.
2291           </p>
2292           <p>
2293             A changelog parser must not interact with the user at
2294             all.
2295           </p>
2296         </sect1>
2297       </sect>
2298
2299 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
2300
2301       <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2302           and variable substitutions      </heading>
2303
2304         <p>
2305           When <prgn>dpkg-gencontrol</prgn>,
2306           <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2307           generate control files they perform variable substitutions
2308           on their output just before writing it.  Variable
2309           substitutions have the form <tt>${<var>variable</var>}</tt>.
2310           The optional file <file>debian/substvars</file> contains
2311           variable substitutions to be used; variables can also be set
2312           directly from <file>debian/rules</file> using the <tt>-V</tt>
2313           option to the source packaging commands, and certain
2314           predefined variables are also available.
2315         </p>
2316
2317         <p>
2318           The <file>debian/substvars</file> file is usually generated and
2319           modified dynamically by <file>debian/rules</file> targets, in
2320           which case it must be removed by the <tt>clean</tt> target.
2321         </p>
2322
2323         <p>
2324           See <manref name="dpkg-source" section="1"> for full
2325           details about source variable substitutions, including the
2326           format of <file>debian/substvars</file>.</p>
2327       </sect>
2328
2329       <sect id="debianfiles"><heading><file>debian/files</file>
2330         </heading>
2331
2332         <p>
2333           This file is not a permanent part of the source tree; it
2334           is used while building packages to record which files are
2335           being generated.  <prgn>dpkg-genchanges</prgn> uses it
2336           when it generates a <file>.changes</file> file.
2337         </p>
2338
2339         <p>
2340           It should not exist in a shipped source package, and so it
2341           (and any backup files or temporary files such as
2342           <file>files.new</file><footnote>
2343             <p>
2344               <file>files.new</file> is used as a temporary file by
2345               <prgn>dpkg-gencontrol</prgn> and
2346               <prgn>dpkg-distaddfile</prgn> - they write a new
2347               version of <tt>files</tt> here before renaming it,
2348               to avoid leaving a corrupted copy if an error
2349               occurs
2350             </p>
2351           </footnote>) should be removed by the
2352           <tt>clean</tt> target.  It may also be wise to
2353           ensure a fresh start by emptying or removing it at the
2354           start of the <tt>binary</tt> target.
2355         </p>
2356
2357         <p>
2358           When <prgn>dpkg-gencontrol</prgn> is run for a binary
2359           package, it adds an entry to <file>debian/files</file> for the
2360           <file>.deb</file> file that will be created when <tt>dpkg-deb
2361           --build</tt> is run for that binary package.  So for most
2362           packages all that needs to be done with this file is to
2363           delete it in the <tt>clean</tt> target.
2364         </p>
2365
2366         <p>
2367           If a package upload includes files besides the source
2368           package and any binary packages whose control files were
2369           made with <prgn>dpkg-gencontrol</prgn> then they should be
2370           placed in the parent of the package's top-level directory
2371           and <prgn>dpkg-distaddfile</prgn> should be called to add
2372           the file to the list in <file>debian/files</file>.</p>
2373       </sect>
2374
2375       <sect id="restrictions"><heading>Restrictions on objects in source packages
2376         </heading>
2377
2378         <p>
2379           The source package may not contain any hard links<footnote>
2380             <p>
2381               This is not currently detected when building source
2382               packages, but only when extracting
2383               them.
2384             </p>
2385             <p>
2386               Hard links may be permitted at some point in the
2387               future, but would require a fair amount of
2388               work.
2389             </p>
2390           </footnote>, device special files, sockets or setuid or
2391           setgid files.<footnote>
2392             <p>
2393               Setgid directories are allowed.
2394             </p>
2395           </footnote>
2396         </p>
2397       </sect>
2398
2399       <sect id="descriptions"><heading>Descriptions of packages - the
2400           <tt>Description</tt> field</heading>
2401
2402         <p>
2403           The "Description" control file field consists of two parts,
2404           the synopsis or the short description, and the long description.
2405           The field's format is as follows:
2406         </p>
2407
2408         <p><example>
2409         Description: &lt;single line synopsis&gt;
2410          &lt;extended description over several lines&gt;
2411 </example></p>
2412
2413         <p>
2414           The description is intended to describe the program to a user
2415           who has never met it before so that they know whether they
2416           want to install it.  It should also give information about the
2417           significant dependencies and conflicts between this package
2418           and others, so that the user knows why these dependencies and
2419           conflicts have been declared.
2420         </p>
2421
2422         <p>
2423           Put important information first, both in the synopsis and
2424           extended description.  Sometimes only the first part of the
2425           synopsis or of the description will be displayed.  You can
2426           assume that there will usually be a way to see the whole
2427           extended description.
2428         </p>
2429
2430         <sect1 id="synopsis"><heading>The single line synopsis</heading>
2431
2432           <p>
2433             The single line synopsis should be kept brief - certainly
2434             under 80 characters.
2435           </p>
2436
2437           <p>
2438             Do not include the package name in the synopsis line.  The
2439             display software knows how to display this already, and you
2440             do not need to state it.  Remember that in many situations
2441             the user may only see the synopsis line - make it as
2442             informative as you can.
2443           </p>
2444
2445         </sect1>
2446
2447         <sect1 id="extendeddesc"><heading>The extended description</heading>
2448
2449           <p>
2450             Do not try to continue the single line synopsis into the
2451             extended description.  This will not work correctly when
2452             the full description is displayed, and makes no sense
2453             where only the summary (the single line synopsis) is
2454             available.
2455           </p>
2456
2457           <p>
2458             The extended description should describe what the package
2459             does and how it relates to the rest of the system (in terms
2460             of, for example, which subsystem it is which part of).
2461           </p>
2462
2463           <p>
2464             The description field needs to make sense to anyone, even
2465             people who have no idea about any of the things the
2466             package deals with.<footnote>
2467                 The blurb that comes with a program in its
2468                 announcements and/or <prgn>README</prgn> files is
2469                 rarely suitable for use in a description.  It is
2470                 usually aimed at people who are already in the
2471                 community where the package is used.
2472             </footnote>
2473           </p>
2474
2475           <p>
2476             The lines in the extended description can have these formats:
2477           </p>
2478
2479           <p><list>
2480
2481             <item>
2482               Those starting with a single space are part of a paragraph.
2483               Successive lines of this form will be word-wrapped when
2484               displayed. The leading space will usually be stripped off.
2485             </item>
2486
2487             <item>
2488               Those starting with two or more spaces. These will be
2489               displayed verbatim. If the display cannot be panned
2490               horizontally, the displaying program will linewrap them "hard"
2491               (i.e., without taking account of word breaks). If it can they
2492               will be allowed to trail off to the right. None, one or two
2493               initial spaces may be deleted, but the number of spaces
2494               deleted from each line will be the same (so that you can have
2495               indenting work correctly, for example).
2496             </item>
2497
2498             <item>
2499               Those containing a single space followed by a single full stop
2500               character. These are rendered as blank lines. This is the
2501               <em>only</em> way to get a blank line<footnote>
2502                 Completely empty lines will not be rendered as blank lines. 
2503                 Instead, they will cause the parser to think you're starting
2504                 a whole new record in the control file, and will therefore
2505                 likely abort with an error.
2506               </footnote>.
2507             </item>
2508
2509             <item>
2510               Those containing a space, a full stop and some more characters.
2511               These are for future expansion. Do not use them.
2512             </item>
2513
2514           </list></p>
2515
2516           <p>
2517             Do not use tab characters.  Their effect is not predictable.
2518           </p>
2519
2520         </sect1>
2521
2522       </sect>
2523
2524     </chapt>
2525
2526
2527     <chapt id="maintainerscripts"><heading>Package maintainer scripts
2528         and installation procedure
2529       </heading>
2530
2531       <sect><heading>Introduction to package maintainer scripts
2532         </heading>
2533
2534         <p>
2535           It is possible to supply scripts as part of a package which
2536           the package management system will run for you when your
2537           package is installed, upgraded or removed.
2538         </p>
2539
2540         <p>
2541           These scripts are the files <prgn>preinst</prgn>,
2542           <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2543           control area of the package.  They must be proper executable
2544           files; if they are scripts (which is recommended), they must
2545           start with the usual <tt>#!</tt> convention.  They should be
2546           readable and executable by anyone, and not world-writable.
2547         </p>
2548
2549         <p>
2550           The package management system looks at the exit status from
2551           these scripts.  It is important that they exit with a
2552           non-zero status if there is an error, so that the package
2553           management system can stop its processing.  For shell
2554           scripts this means that you <em>almost always</em> need to
2555           use <tt>set -e</tt> (this is usually true when writing shell
2556           scripts, in fact).  It is also important, of course, that
2557           they don't exit with a non-zero status if everything went
2558           well.
2559         </p>
2560
2561         <p>
2562           When a package is upgraded a combination of the scripts from
2563           the old and new packages is called during the upgrade
2564           procedure.  If your scripts are going to be at all
2565           complicated you need to be aware of this, and may need to
2566           check the arguments to your scripts.
2567         </p>
2568
2569         <p>
2570           Broadly speaking the <prgn>preinst</prgn> is called before
2571           (a particular version of) a package is installed, and the
2572           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2573           before (a version of) a package is removed and the
2574           <prgn>postrm</prgn> afterwards.
2575         </p>
2576
2577         <p>
2578           Programs called from maintainer scripts should not normally
2579           have a path prepended to them. Before installation is
2580           started, the package management system checks to see if the
2581           programs <prgn>ldconfig</prgn>,
2582           <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2583           and <prgn>update-rc.d</prgn> can be found via the
2584           <tt>PATH</tt> environment variable. Those programs, and any
2585           other program that one would expect to be on the
2586           <tt>PATH</tt>, should thus be invoked without an absolute
2587           pathname. Maintainer scripts should also not reset the
2588           <tt>PATH</tt>, though they might choose to modify it by
2589           prepending or appending package-specific directories. These
2590           considerations really apply to all shell scripts.</p>
2591       </sect>
2592
2593       <sect>
2594         <heading>Maintainer scripts Idempotency</heading>
2595
2596         <p>
2597           It is necessary for the error recovery procedures that the
2598           scripts be idempotent.  This means that if it is run
2599           successfully, and then it is called again, it doesn't bomb
2600           out or cause any harm, but just ensures that everything is
2601           the way it ought to be.  If the first call failed, or
2602           aborted half way through for some reason, the second call
2603           should merely do the things that were left undone the first
2604           time, if any, and exit with a success status if everything
2605           is OK.<footnote>
2606             <p>
2607               This is so that if an error occurs, the user interrupts
2608               <prgn>dpkg</prgn> or some other unforeseen circumstance
2609               happens you don't leave the user with a badly-broken
2610               package when <prgn>dpkg</prgn> attempts to repeat the
2611               action.
2612             </p>
2613           </footnote>
2614         </p>
2615       </sect>
2616
2617       <sect>
2618         <heading>Controlling terminal for maintainer scripts</heading>
2619
2620         <p>
2621           The maintainer scripts are guaranteed to run with a
2622           controlling terminal and can interact with the user.
2623           If they need to prompt for passwords, do full-screen
2624           interaction or something similar you should do these
2625           things to and from <file>/dev/tty</file>, since
2626           <prgn>dpkg</prgn> will at some point redirect scripts'
2627           standard input and output so that it can log the
2628           installation process.  Likewise, because these scripts
2629           may be executed with standard output redirected into a
2630           pipe for logging purposes, Perl scripts should set
2631           unbuffered output by setting <tt>$|=1</tt> so that the
2632           output is printed immediately rather than being
2633           buffered.
2634         </p>
2635
2636         <p>
2637           Each script should return a zero exit status for
2638           success, or a nonzero one for failure.
2639         </p>
2640       </sect>
2641
2642       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2643           scripts are called
2644         </heading>
2645
2646         <p>
2647           <list compact="compact">
2648             <item>
2649               <p><var>new-preinst</var> <tt>install</tt></p>
2650             </item>
2651             <item>
2652               <p><var>new-preinst</var> <tt>install</tt>
2653                 <var>old-version</var></p>
2654             </item>
2655             <item>
2656               <p><var>new-preinst</var> <tt>upgrade</tt>
2657                 <var>old-version</var></p>
2658             </item>
2659             <item>
2660               <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2661                 <var>new-version</var>
2662               </p>
2663             </item>
2664           </list>
2665
2666         <p>
2667           <list compact="compact">
2668             <item>
2669               <p><var>postinst</var> <tt>configure</tt>
2670                 <var>most-recently-configured-version</var></p>
2671             </item>
2672             <item>
2673               <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2674                 <var>new-version</var></p>
2675             </item>
2676             <item>
2677               <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2678                 <tt>in-favour</tt> <var>package</var>
2679                 <var>new-version</var></p>
2680             </item>
2681             <item>
2682               <p>
2683                 <var>deconfigured's-postinst</var>
2684                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2685                 <var>failed-install-package</var> <var>version</var>
2686                 <tt>removing</tt> <var>conflicting-package</var>
2687                 <var>version</var>
2688               </p>
2689             </item>
2690           </list>
2691
2692         <p>
2693           <list compact="compact">
2694             <item>
2695               <p><var>prerm</var> <tt>remove</tt></p>
2696             </item>
2697             <item>
2698               <p><var>old-prerm</var> <tt>upgrade</tt>
2699                 <var>new-version</var></p>
2700             </item>
2701             <item>
2702               <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2703                 <var>old-version</var></p>
2704             </item>
2705             <item>
2706               <p><var>conflictor's-prerm</var> <tt>remove</tt>
2707                 <tt>in-favour</tt> <var>package</var>
2708                 <var>new-version</var></p>
2709             </item>
2710             <item>
2711               <p>
2712                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2713                 <tt>in-favour</tt> <var>package-being-installed</var>
2714                 <var>version</var> <tt>removing</tt>
2715                 <var>conflicting-package</var>
2716                 <var>version</var>
2717               </p>
2718             </item>
2719           </list>
2720
2721         <p>
2722           <list compact="compact">
2723             <item>
2724               <p><var>postrm</var> <tt>remove</tt></p>
2725             </item>
2726             <item>
2727               <p><var>postrm</var> <tt>purge</tt></p>
2728             </item>
2729             <item>
2730               <p>
2731                 <var>old-postrm</var> <tt>upgrade</tt>
2732                 <var>new-version</var></p>
2733             </item>
2734             <item>
2735               <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2736                 <var>old-version</var></p>
2737             </item>
2738             <item>
2739               <p><var>new-postrm</var> <tt>abort-install</tt></p>
2740             </item>
2741             <item>
2742               <p><var>new-postrm</var> <tt>abort-install</tt>
2743                 <var>old-version</var></p>
2744             </item>
2745             <item>
2746               <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2747                 <var>old-version</var></p>
2748             </item>
2749             <item>
2750               <p>
2751                 <var>disappearer's-postrm</var> <tt>disappear</tt>
2752                 <var>overwriter</var>
2753                 <var>overwriter-version</var></p></item>
2754           </list>
2755         </p>
2756
2757
2758       <sect id="unpackphase"><heading>Details of unpack phase of
2759           installation or upgrade
2760         </heading>
2761
2762         <p>
2763           The procedure on installation/upgrade/overwrite/disappear
2764           (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2765           stage of <tt>dpkg --install</tt>) is as follows.  In each
2766           case, if a major error occurs (unless listed below) the
2767           actions are, in general, run backwards - this means that the
2768           maintainer scripts are run with different arguments in
2769           reverse order.  These are the "error unwind" calls listed
2770           below.
2771
2772           <enumlist>
2773             <item>
2774               <p>
2775                 <enumlist>
2776                   <item>
2777                     <p>If a version of the package is already
2778                       installed, call
2779                       <example compact="compact">
2780 <var>old-prerm</var> upgrade <var>new-version</var>
2781                       </example></p>
2782                   </item>
2783                   <item>
2784                     <p>
2785                       If the script runs but exits with a non-zero
2786                       exit status, <prgn>dpkg</prgn> will attempt:
2787                       <example compact="compact">
2788 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2789                       </example>
2790                       Error unwind, for both the above cases:
2791                       <example compact="compact">
2792 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2793                       </example>
2794                     </p>
2795                   </item>
2796                 </enumlist>
2797               </p>
2798             </item>
2799             <item>
2800               <p>If a "conflicting" package is being removed at the same time:
2801                 <enumlist>
2802                   <item>
2803                     <p>
2804                       If any packages depended on that conflicting
2805                       package and <tt>--auto-deconfigure</tt> is
2806                       specified, call, for each such package:
2807                       <example compact="compact">
2808 <var>deconfigured's-prerm</var> deconfigure \
2809   in-favour <var>package-being-installed</var> <var>version</var> \
2810     removing <var>conflicting-package</var> <var>version</var>
2811                       </example>
2812                       Error unwind:
2813                       <example compact="compact">
2814 <var>deconfigured's-postinst</var> abort-deconfigure \
2815   in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2816     removing <var>conflicting-package</var> <var>version</var>
2817                       </example>
2818                       The deconfigured packages are marked as
2819                       requiring configuration, so that if
2820                       <tt>--install</tt> is used they will be
2821                       configured again if possible.</p>
2822                   </item>
2823                   <item>
2824                     <p>To prepare for removal of the conflicting package, call:
2825                       <example compact="compact">
2826 <var>conflictor's-prerm</var> remove \
2827   in-favour <var>package</var> <var>new-version</var>
2828                       </example>
2829                       Error unwind:
2830                       <example compact="compact">
2831 <var>conflictor's-postinst</var> abort-remove \
2832   in-favour <var>package</var> <var>new-version</var>
2833                       </example>
2834                     </p>
2835                   </item>
2836                 </enumlist>
2837               </p>
2838             </item>
2839             <item>
2840               <p>
2841                 <enumlist>
2842                   <item>
2843                     <p>If the package is being upgraded, call:
2844                       <example compact="compact">
2845 <var>new-preinst</var> upgrade <var>old-version</var>
2846                       </example></p>
2847                   </item>
2848                   <item>
2849                     <p>
2850                       Otherwise, if the package had some configuration
2851                       files from a previous version installed (i.e., it
2852                       is in the "configuration files only" state):
2853                       <example compact="compact">
2854 <var>new-preinst</var> install <var>old-version</var>
2855                       </example></p>
2856
2857                   <item>
2858                     <p>Otherwise (i.e., the package was completely purged):
2859                       <example compact="compact">
2860 <var>new-preinst</var> install
2861                       </example>
2862                       Error unwind actions, respectively:
2863                       <example compact="compact">
2864 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2865 <var>new-postrm</var> abort-install <var>old-version</var>
2866 <var>new-postrm</var> abort-install
2867                       </example>
2868                     </p>
2869                   </item>
2870                 </enumlist>
2871               </p>
2872             </item>
2873             <item>
2874               <p>
2875                 The new package's files are unpacked, overwriting any
2876                 that may be on the system already, for example any
2877                 from the old version of the same package or from
2878                 another package.  Backups of the old files are kept
2879                 temporarily, and if anything goes wrong the package
2880                 management system will attempt to put them back as
2881                 part of the error unwind.
2882               </p>
2883
2884               <p>
2885                 It is an error for a package to contains files which
2886                 are on the system in another package, unless
2887                 <tt>Replaces</tt> is used (see <ref id="replaces">).
2888                 <!--
2889                 The following paragraph is not currently the case:
2890                 Currently the <tt>- - force-overwrite</tt> flag is
2891                 enabled, downgrading it to a warning, but this may not
2892                 always be the case.
2893                 -->
2894               </p>
2895
2896               <p>
2897                 It is a more serious error for a package to contain a
2898                 plain file or other kind of non-directory where another
2899                 package has a directory (again, unless
2900                 <tt>Replaces</tt> is used).  This error can be
2901                 overridden if desired using
2902                 <tt>--force-overwrite-dir</tt>, but this is not
2903                 advisable.
2904               </p>
2905
2906               <p>
2907                 Packages which overwrite each other's files produce
2908                 behavior which, though deterministic, is hard for the
2909                 system administrator to understand.  It can easily
2910                 lead to "missing" programs if, for example, a package
2911                 is installed which overwrites a file from another
2912                 package, and is then removed again.<footnote>
2913                   <p>
2914                     Part of the problem is due to what is arguably a
2915                     bug in <prgn>dpkg</prgn>.
2916                   </p>
2917                 </footnote>
2918               </p>
2919
2920               <p>
2921                 A directory will never be replaced by a symbolic link
2922                 to a directory or vice versa; instead, the existing
2923                 state (symlink or not) will be left alone and
2924                 <prgn>dpkg</prgn> will follow the symlink if there is
2925                 one.</p>
2926             </item>
2927
2928             <item>
2929               <p>
2930                 <enumlist>
2931                   <item>
2932                     <p>If the package is being upgraded, call
2933                       <example compact="compact">
2934 <var>old-postrm</var> upgrade <var>new-version</var>
2935                       </example>
2936                     </p>
2937                   </item>
2938                   <item>
2939                     <p>If this fails, <prgn>dpkg</prgn> will attempt:
2940                       <example compact="compact">
2941 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2942                       </example>
2943                       Error unwind, for both cases:
2944                       <example compact="compact">
2945 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2946                       </example>
2947                     </p>
2948                   </item>
2949                 </enumlist>
2950               </p>
2951               <p>
2952                 This is the point of no return - if
2953                 <prgn>dpkg</prgn> gets this far, it won't back off
2954                 past this point if an error occurs.  This will
2955                 leave the package in a fairly bad state, which
2956                 will require a successful re-installation to clear
2957                 up, but it's when <prgn>dpkg</prgn> starts doing
2958                 things that are irreversible.
2959               </p>
2960             </item>
2961             <item>
2962               <p>
2963                 Any files which were in the old version of the package
2964                 but not in the new are removed.</p>
2965             </item>
2966             <item>
2967               <p>The new file list replaces the old.</p>
2968             </item>
2969             <item>
2970               <p>The new maintainer scripts replace the old.</p>
2971             </item>
2972
2973             <item>
2974               <p>Any packages all of whose files have been overwritten during the
2975                 installation, and which aren't required for
2976                 dependencies, are considered to have been removed.
2977                 For each such package
2978                 <enumlist>
2979                   <item>
2980                     <p><prgn>dpkg</prgn> calls:
2981                       <example compact="compact">
2982 <var>disappearer's-postrm</var> disappear \
2983   <var>overwriter</var> <var>overwriter-version</var>
2984                       </example>
2985                     </p>
2986                   </item>
2987                   <item>
2988                     <p>The package's maintainer scripts are removed.
2989                     </p>
2990                   </item>
2991                   <item>
2992                     <p>
2993                       It is noted in the status database as being in a
2994                       sane state, namely not installed (any conffiles
2995                       it may have are ignored, rather than being
2996                       removed by <prgn>dpkg</prgn>).  Note that
2997                       disappearing packages do not have their prerm
2998                       called, because <prgn>dpkg</prgn> doesn't know
2999                       in advance that the package is going to
3000                       vanish.
3001                     </p>
3002                   </item>
3003                 </enumlist>
3004               </p>
3005             </item>
3006             <item>
3007               <p>
3008                 Any files in the package we're unpacking that are also
3009                 listed in the file lists of other packages are removed
3010                 from those lists.  (This will lobotomize the file list
3011                 of the "conflicting" package if there is one.)
3012               </p>
3013             </item>
3014             <item>
3015               <p>
3016                 The backup files made during installation, above, are
3017                 deleted.
3018               </p>
3019             </item>
3020
3021             <item>
3022               <p>
3023                 The new package's status is now sane, and recorded as
3024                 "unpacked".
3025               </p>
3026
3027               <p>
3028                 Here is another point of no return - if the
3029                 conflicting package's removal fails we do not unwind
3030                 the rest of the installation; the conflicting package
3031                 is left in a half-removed limbo.
3032               </p>
3033             </item>
3034
3035             <item>
3036               <p>
3037                 If there was a conflicting package we go and do the
3038                 removal actions (described below), starting with the
3039                 removal of the conflicting package's files (any that
3040                 are also in the package being installed have already
3041                 been removed from the conflicting package's file list,
3042                 and so do not get removed now).
3043               </p>
3044             </item>
3045           </enumlist>
3046         </p>
3047       </sect>
3048
3049       <sect id="configdetails"><heading>Details of configuration</heading>
3050
3051         <p>
3052           When we configure a package (this happens with <tt>dpkg
3053             --install</tt> and <tt>dpkg --configure</tt>), we first
3054           update any <tt>conffile</tt>s and then call:
3055           <example compact="compact">
3056 <var>postinst</var> configure <var>most-recently-configured-version</var>
3057           </example>
3058         </p>
3059
3060         <p>
3061           No attempt is made to unwind after errors during
3062           configuration.
3063         </p>
3064
3065         <p>
3066           If there is no most recently configured version
3067           <prgn>dpkg</prgn> will pass a null argument; older versions
3068           of dpkg may pass <tt>&lt;unknown&gt;</tt> (including the
3069           angle brackets) in this case.  Even older ones do not pass a
3070           second argument at all, under any circumstances.
3071         </p>
3072       </sect>
3073
3074       <sect id="removedetails"><heading>Details of removal and/or
3075       configuration purging</heading>
3076
3077         <p>
3078           <enumlist>
3079             <item>
3080               <p>
3081                 <example compact="compact">
3082 <var>prerm</var> remove
3083                 </example>
3084               </p>
3085             </item>
3086             <item>
3087               <p>
3088                 The package's files are removed (except <tt>conffile</tt>s).
3089               </p>
3090             </item>
3091             <item>
3092               <p>
3093                 <example compact="compact">
3094 <var>postrm</var> remove
3095                 </example>
3096               </p>
3097             </item>
3098             <item>
3099               <p>
3100                 All the maintainer scripts except the <prgn>postrm</prgn>
3101                 are removed.
3102               </p>
3103
3104               <p>
3105                 If we aren't purging the package we stop here.  Note
3106                 that packages which have no <prgn>postrm</prgn> and no
3107                 <tt>conffile</tt>s are automatically purged when
3108                 removed, as there is no difference except for the
3109                 <prgn>dpkg</prgn> status.</p>
3110             </item>
3111             <item>
3112               <p>
3113                 The <tt>conffile</tt>s and any backup files
3114                 (<tt>~</tt>-files, <tt>#*#</tt> files,
3115                 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3116                 are removed.</p>
3117             </item>
3118             <item>
3119               <p>
3120                 <example compact="compact">
3121 <var>postrm</var> purge
3122                 </example>
3123               </p>
3124             </item>
3125             <item>
3126               <p>The package's file list is removed.</p>
3127             </item>
3128           </enumlist>
3129           No attempt is made to unwind after errors during
3130           removal.
3131         </p>
3132       </sect>
3133     </chapt>
3134
3135
3136     <chapt id="relationships"><heading>Declaring relationships between
3137         packages</heading>
3138
3139       <sect id="depsyntax"><heading>Syntax of relationship fields
3140         </heading>
3141
3142         <p>
3143           These fields all have a uniform syntax.  They are a list of
3144           package names separated by commas.
3145         </p>
3146
3147         <p>
3148           In the <tt>Depends</tt>, <tt>Recommends</tt>,
3149           <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3150           <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3151           control file fields of the package, which declare
3152           dependencies on other packages, the package names listed may
3153           also include lists of alternative package names, separated
3154           by vertical bar (pipe) symbols <tt>|</tt>.  In such a case,
3155           if any one of the alternative packages is installed, that
3156           part of the dependency is considered to be satisfied.
3157         </p>
3158
3159         <p>
3160           All of the fields except for <tt>Provides</tt> may restrict
3161           their applicability to particular versions of each named
3162           package.  This is done in parentheses after each individual
3163           package name; the parentheses should contain a relation from
3164           the list below followed by a version number, in the format
3165           described in <ref id="versions">.
3166         </p>
3167
3168         <p>
3169           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
3170           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
3171           strictly earlier, earlier or equal, exactly equal, later or
3172           equal and strictly later, respectively.  The deprecated
3173           forms <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
3174           earlier/later or equal, rather than strictly earlier/later,
3175           so they should not appear in new packages (though
3176           <prgn>dpkg</prgn> still supports them).
3177         </p>
3178
3179         <p>
3180           Whitespace may appear at any point in the version
3181           specification subject to the rules in <ref
3182           id="controlsyntax">, and must appear where it's necessary to
3183           disambiguate; it is not otherwise significant.  For
3184           consistency and in case of future changes to
3185           <prgn>dpkg</prgn> it is recommended that a single space be
3186           used after a version relationship and before a version
3187           number; it is also conventional to put a single space after
3188           each comma, on either side of each vertical bar, and before
3189           each open parenthesis.
3190         </p>
3191
3192         <p>
3193           For example, a list of dependencies might appear as:
3194           <example compact="compact">
3195 Package: mutt
3196 Version: 1.3.17-1
3197 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3198           </example>
3199         </p>
3200
3201         <p>
3202           All fields that specify build-time relationships
3203           (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3204           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3205           may be restricted to a certain set of architectures.  This
3206           is indicated in brackets after each individual package name and
3207           the optional version specification.  The brackets enclose a
3208           list of Debian architecture names separated by whitespace.
3209           Exclamation marks may be prepended to each of the names.
3210           (It is not permitted for some names to be prepended with
3211           exclamation marks and others not.) If the current Debian
3212           host architecture is not in this list and there are no
3213           exclamation marks in the list, or it is in the list with a
3214           prepended exclamation mark, the package name and the
3215           associated version specification are ignored completely for
3216           the purposes of defining the relationships.
3217         </p>
3218
3219         <p>
3220           For example:
3221           <example compact="compact">
3222 Source: glibc
3223 Build-Depends-Indep: texinfo
3224 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3225   hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3226           </example>
3227         </p>
3228
3229         <p>
3230           Note that the binary package relationship fields such as
3231           <tt>Depends</tt> appear in one of the binary package
3232           sections of the control file, whereas the build-time
3233           relationships such as <tt>Build-Depends</tt> appear in the
3234           source package section of the control file (which is the
3235           first section).
3236         </p>
3237       </sect>
3238
3239       <sect>
3240         <heading>Binary Dependencies - <tt>Depends</tt>,
3241           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3242           <tt>Pre-Depends</tt>
3243         </heading>
3244
3245         <p>
3246           Packages can declare in their control file that they have
3247           certain relationships to other packages - for example, that
3248           they may not be installed at the same time as certain other
3249           packages, and/or that they depend on the presence of others.
3250         </p>
3251   
3252         <p>
3253           This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3254           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt> and
3255           <tt>Conflicts</tt> control file fields.
3256         </p>
3257
3258         <p>
3259           These six fields are used to declare a dependency
3260           relationship by one package on another.  Except for
3261           <tt>Enhances</tt>, they appear in the depending (binary)
3262           package's control file.  (<tt>Enhances</tt> appears in the
3263           recommending package's control file.)
3264         </p>
3265
3266         <p>
3267           A <tt>Depends</tt> field takes effect <em>only</em> when a
3268           package is to be configured.  It does not prevent a package
3269           being on the system in an unconfigured state while its
3270           dependencies are unsatisfied, and it is possible to replace
3271           a package whose dependencies are satisfied and which is
3272           properly installed with a different version whose
3273           dependencies are not and cannot be satisfied; when this is
3274           done the depending package will be left unconfigured (since
3275           attempts to configure it will give errors) and will not
3276           function properly.  If it is necessary, a
3277           <tt>Pre-Depends</tt> field can be used, which has a partial
3278           effect even when a package is being unpacked, as explained
3279           in detail below.  (The other three dependency fields,
3280           <tt>Recommends</tt>, <tt>Suggests</tt> and
3281           <tt>Enhances</tt>, are only used by the various front-ends
3282           to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3283         </p>
3284
3285         <p>
3286           For this reason packages in an installation run are usually
3287           all unpacked first and all configured later; this gives
3288           later versions of packages with dependencies on later
3289           versions of other packages the opportunity to have their
3290           dependencies satisfied.
3291         </p>
3292
3293         <p>
3294           The <tt>Depends</tt> field thus allows package maintainers
3295           to impose an order in which packages should be configured.
3296         </p>
3297
3298         <p>
3299           The meaning of the five dependency fields is as follows:
3300           <taglist>
3301             <tag><tt>Depends</tt></tag>
3302             <item>
3303               <p>
3304                 This declares an absolute dependency.  A package will
3305                 not be configured unless all of the packages listed in
3306                 its <tt>Depends</tt> field have been correctly
3307                 configured.
3308               </p>
3309
3310               <p>
3311                 The <tt>Depends</tt> field should be used if the
3312                 depended-on package is required for the depending
3313                 package to provide a significant amount of
3314                 functionality.
3315               </p>
3316               <p>
3317                 The <tt>Depends</tt> field should also be used if the
3318                 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3319                 <prgn>postrm</prgn> scripts require the package to be
3320                 present in order to run.  Note, however, that the
3321                 <prgn>postrm</prgn> cannot rely on any non-essential
3322                 packages to be present during the <tt>purge</tt>
3323                 phase.
3324             </item>
3325
3326             <tag><tt>Recommends</tt></tag>
3327             <item>
3328               <p>This declares a strong, but not absolute, dependency.
3329               </p>
3330
3331               <p>
3332                 The <tt>Recommends</tt> field should list packages
3333                 that would be found together with this one in all but
3334                 unusual installations.</p>
3335             </item>
3336
3337             <tag><tt>Suggests</tt></tag>
3338             <item>
3339               <p>
3340                 This is used to declare that one package may be more
3341                 useful with one or more others.  Using this field
3342                 tells the packaging system and the user that the
3343                 listed packages are related to this one and can
3344                 perhaps enhance its usefulness, but that installing
3345                 this one without them is perfectly reasonable.
3346               </p>
3347             </item>
3348
3349             <tag><tt>Enhances</tt></tag>
3350             <item>
3351               <p>
3352                 This field is similar to Suggests but works in the
3353                 opposite direction. It is used to declare that a
3354                 package can enhance the functionality of another
3355                 package.
3356               </p>
3357             </item>
3358
3359             <tag><tt>Pre-Depends</tt></tag>
3360             <item>
3361               <p>
3362                 This field is like <tt>Depends</tt>, except that it
3363                 also forces <prgn>dpkg</prgn> to complete installation
3364                 of the packages named before even starting the
3365                 installation of the package which declares the
3366                 pre-dependency, as follows:
3367               </p>
3368
3369               <p>
3370                 When a package declaring a pre-dependency is about to
3371                 be <em>unpacked</em> the pre-dependency can be
3372                 satisfied if the depended-on package is either fully
3373                 configured, <em>or even if</em> the depended-on
3374                 package(s) are only unpacked or half-configured,
3375                 provided that they have been configured correctly at
3376                 some point in the past (and not removed or partially
3377                 removed since).  In this case, both the
3378                 previously-configured and currently unpacked or
3379                 half-configured versions must satisfy any version
3380                 clause in the <tt>Pre-Depends</tt> field.
3381               </p>
3382
3383               <p>
3384                 When the package declaring a pre-dependency is about
3385                 to be <em>configured</em>, the pre-dependency will be
3386                 treated as a normal <tt>Depends</tt>, that is, it will
3387                 be considered satisfied only if the depended-on
3388                 package has been correctly configured.
3389               </p>
3390
3391               <p>
3392                 <tt>Pre-Depends</tt> should be used sparingly,
3393                 preferably only by packages whose premature upgrade or
3394                 installation would hamper the ability of the system to
3395                 continue with any upgrade that might be in progress.
3396               </p>
3397
3398               <p>
3399                 <tt>Pre-Depends</tt> are also required if the
3400                 <prgn>preinst</prgn> script depends on the named
3401                 package.  It is best to avoid this situation if
3402                 possible.
3403             </item>
3404           </taglist>
3405         </p>
3406         <p>
3407           When selecting which level of dependency to use you should
3408           consider how important the depended-on package is to the
3409           functionality of the one declaring the dependency.  Some
3410           packages are composed of components of varying degrees of
3411           importance.  Such a package should list using
3412           <tt>Depends</tt> the package(s) which are required by the
3413           more important components.  The other components'
3414           requirements may be mentioned as Suggestions or
3415           Recommendations, as appropriate to the components' relative
3416           importance.
3417         </p>
3418
3419
3420       <sect id="conflicts"><heading>Conflicting binary packages -
3421            <tt>Conflicts</tt></heading>
3422
3423         <p>
3424           When one binary package declares a conflict with another
3425           using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3426           refuse to allow them to be installed on the system at the
3427           same time.
3428         </p>
3429
3430         <p>
3431           If one package is to be installed, the other must be removed
3432           first - if the package being installed is marked as
3433           replacing (see <ref id="replaces">) the one on the system,
3434           or the one on the system is marked as deselected, or both
3435           packages are marked <tt>Essential</tt>, then
3436           <prgn>dpkg</prgn> will automatically remove the package
3437           which is causing the conflict, otherwise it will halt the
3438           installation of the new package with an error.  This
3439           mechanism is specifically designed to produce an error when
3440           the installed package is <tt>Essential</tt>, but the new
3441           package is not.
3442         </p>
3443
3444         <p>
3445           A package will not cause a conflict merely because its
3446           configuration files are still installed; it must be at least
3447           half-installed.
3448         </p>
3449
3450         <p>
3451           A special exception is made for packages which declare a
3452           conflict with their own package name, or with a virtual
3453           package which they provide (see below): this does not
3454           prevent their installation, and allows a package to conflict
3455           with others providing a replacement for it.  You use this
3456           feature when you want the package in question to be the only
3457           package providing some feature.
3458         </p>
3459
3460         <p>
3461           A <tt>Conflicts</tt> entry should almost never have an
3462           "earlier than" version clause.  This would prevent
3463           <prgn>dpkg</prgn> from upgrading or installing the package
3464           which declared such a conflict until the upgrade or removal
3465           of the conflicted-with package had been completed.
3466         </p>
3467       </sect>
3468
3469       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3470         </heading>
3471
3472         <p>
3473           As well as the names of actual ("concrete") packages, the
3474           package relationship fields <tt>Depends</tt>,
3475           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3476           <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3477           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3478           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3479           may mention "virtual packages".
3480         </p>
3481
3482         <p>
3483           A <em>virtual package</em> is one which appears in the
3484           <tt>Provides</tt> control file field of another package.
3485           The effect is as if the package(s) which provide a
3486           particular virtual package name had been listed by name
3487           everywhere the virtual package name appears. (See also <ref
3488             id="virtual_pkg">)
3489         </p>
3490
3491         <p>
3492           If there are both concrete and virtual packages of the same
3493           name, then the dependency may be satisfied (or the conflict
3494           caused) by either the concrete package with the name in
3495           question or any other concrete package which provides the
3496           virtual package with the name in question.  This is so that,
3497           for example, supposing we have
3498           <example compact="compact">
3499 Package: foo
3500 Depends: bar
3501           </example>
3502           and someone else releases an enhanced version of the
3503           <tt>bar</tt> package (for example, a non-US variant), they
3504           can say:
3505           <example compact="compact">
3506 Package: bar-plus
3507 Provides: bar
3508           </example>
3509           and the <tt>bar-plus</tt> package will now also satisfy the
3510           dependency for the <tt>foo</tt> package.
3511         </p>
3512
3513         <p>
3514           If a dependency or a conflict has a version number attached
3515           then only real packages will be considered to see whether
3516           the relationship is satisfied (or the prohibition violated,
3517           for a conflict) - it is assumed that a real package which
3518           provides the virtual package is not of the "right" version.
3519           So, a <tt>Provides</tt> field may not contain version
3520           numbers, and the version number of the concrete package
3521           which provides a particular virtual package will not be
3522           looked at when considering a dependency on or conflict with
3523           the virtual package name.
3524         </p>
3525
3526         <p>
3527           It is likely that the ability will be added in a future
3528           release of <prgn>dpkg</prgn> to specify a version number for
3529           each virtual package it provides.  This feature is not yet
3530           present, however, and is expected to be used only
3531           infrequently.
3532         </p>
3533
3534         <p>
3535           If you want to specify which of a set of real packages
3536           should be the default to satisfy a particular dependency on
3537           a virtual package, you should list the real package as an
3538           alternative before the virtual one.
3539         </p>
3540       </sect>
3541
3542
3543       <sect id="replaces"><heading>Overwriting files and replacing
3544           packages - <tt>Replaces</tt></heading>
3545
3546         <p>
3547           Packages can declare in their control file that they should
3548           overwrite files in certain other packages, or completely
3549           replace other packages. The <tt>Replaces</tt> control file
3550           field has these two distinct purposes.
3551         </p>
3552
3553         <sect1><heading>Overwriting files in other packages</heading>
3554
3555           <p>
3556             Firstly, as mentioned before, it is usually an error for a
3557             package to contain files which are on the system in
3558             another package.
3559           </p>
3560
3561           <p>
3562             However, if the overwriting package declares that it
3563             <tt>Replaces</tt> the one containing the file being
3564             overwritten, then <prgn>dpkg</prgn> will replace the file
3565             from the old package with that from the new.  The file
3566             will no longer be listed as "owned" by the old package.
3567           </p>
3568
3569           <p>
3570             If a package is completely replaced in this way, so that
3571             <prgn>dpkg</prgn> does not know of any files it still
3572             contains, it is considered to have "disappeared".  It will
3573             be marked as not wanted on the system (selected for
3574             removal) and not installed.  Any <tt>conffile</tt>s
3575             details noted for the package will be ignored, as they
3576             will have been taken over by the overwriting package.  The
3577             package's <prgn>postrm</prgn> script will be run with a
3578             special argument to allow the package to do any final
3579             cleanup required.  See <ref id="mscriptsinstact">.
3580           </p>
3581
3582           <p>
3583             If an installed package, <tt>foo</tt> say, declares that
3584             it replaces another, <tt>bar</tt>, and an attempt is made
3585             to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3586             files in the <tt>bar</tt> package which would overwrite
3587             those already present in <tt>foo</tt>.  This is so that
3588             you can install an older version of a package without
3589             problems.
3590           </p>
3591
3592           <p>
3593             For this usage of <tt>Replaces</tt>, virtual packages (see
3594             <ref id="virtual">) are not considered when looking at a
3595             <tt>Replaces</tt> field - the packages declared as being
3596             replaced must be mentioned by their real names.
3597           </p>
3598
3599           <p>
3600             Furthermore, this usage of <tt>Replaces</tt> only takes
3601             effect when both packages are at least partially on the
3602             system at once, so that it can only happen if they do not
3603             conflict or if the conflict has been overridden.
3604           </p>
3605
3606         </sect1>
3607
3608         <sect1><heading>Replacing whole packages, forcing their
3609             removal</heading>
3610
3611           <p>
3612             Secondly, <tt>Replaces</tt> allows the packaging system to
3613             resolve which package should be removed when there is a
3614             conflict - see <ref id="conflicts">.  This usage only
3615             takes effect when the two packages <em>do</em> conflict,
3616             so that the two usages of this field do not interfere with
3617             each other.
3618           </p>
3619
3620           <p>
3621             In this situation, the package declared as being replaced
3622             can be a virtual package, so for example, all mail
3623             transport agents (MTAs) would have the following fields in
3624             their control files:
3625             <example compact="compact">
3626 Provides: mail-transport-agent
3627 Conflicts: mail-transport-agent
3628 Replaces: mail-transport-agent
3629             </example>
3630             ensuring that only one MTA can be installed at any one
3631             time.
3632         </sect1>
3633       </sect>
3634
3635       <sect><heading>Relationships between source and binary packages -
3636           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3637           <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3638         </heading>
3639
3640         <p>
3641           Source packages that require certain binary packages to be
3642           installed or absent at the time of building the package
3643           can declare relationships to those binary packages.
3644         </p>
3645   
3646         <p>
3647           This is done using the <tt>Build-Depends</tt>,
3648           <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3649           <tt>Build-Conflicts-Indep</tt> control file fields.
3650         </p>
3651
3652         <p>
3653           Build-dependencies on "build-essential" binary packages can be
3654           omitted. Please see <ref id="pkg-relations"> for more information.
3655         </p>
3656
3657         <p>
3658           The dependencies and conflicts they define must be satisfied
3659           (as defined earlier for binary packages) in order to invoke
3660           the targets in <tt>debian/rules</tt>, as follows:<footnote>
3661             <p>
3662               If you make "build-arch" or "binary-arch", you need
3663               Build-Depends.  If you make "build-indep" or
3664               "binary-indep", you need Build-Depends and
3665               Build-Depends-Indep.  If you make "build" or "binary",
3666               you need both.
3667             </p>
3668             <p>
3669               There is no Build-Depends-Arch; the autobuilders will
3670               only need the Build-Depends if they know how to build
3671               only build-arch and binary-arch.  Anyone building the
3672               build-indep/binary-indep targets is basically assumed to
3673               be building the whole package and so installs all build
3674               dependencies.
3675             </p>
3676             <p>
3677               The purpose of the original split, I recall, was so that
3678               the autobuilders wouldn't need to install extra packages
3679               needed only for the binary-indep targets.  But without a
3680               build-arch/build-indep split, this didn't work, since
3681               most of the work is done in the build target, not in the
3682               binary target.
3683             </p>
3684           </footnote>
3685
3686           <taglist>
3687             <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3688             <item>
3689               <p>
3690                 The <tt>Build-Depends</tt> and
3691                 <tt>Build-Conflicts</tt> fields must be satisfied when
3692                 any of the following targets is invoked:
3693                 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
3694                 <tt>binary-arch</tt>, <tt>build-arch</tt>,
3695                 <tt>build-indep</tt> and <tt>binary-indep</tt>.
3696               </p>
3697             </item>
3698             <tag><tt>Build-Depends-Indep</tt>,
3699               <tt>Build-Conflicts-Indep</tt></tag>
3700             <item>
3701               <p>
3702                 The <tt>Build-Depends-Indep</tt> and
3703                 <tt>Build-Conflicts-Indep</tt> fields must be
3704                 satisfied when any of the following targets is
3705                 invoked: <tt>build</tt>, <tt>clean</tt>,
3706                 <tt>build-indep</tt>, <tt>binary</tt> and
3707                 <tt>binary-indep</tt>.
3708               </p>
3709             </item>
3710           </taglist>
3711
3712         </p>
3713
3714       </sect>
3715     </chapt>
3716
3717
3718     <chapt id="conffiles"><heading>Configuration file handling
3719       </heading>
3720
3721       <p>
3722         This chapter has been superseded by <ref id="config-files">.
3723       </p>
3724
3725
3726     <chapt id="sharedlibs"><heading>Shared libraries</heading>
3727
3728       <p>
3729         Packages containing shared libraries must be constructed with
3730         a little care to make sure that the shared library is always
3731         available.  This is especially important for packages whose
3732         shared libraries are vitally important, such as the C library
3733         (currently <tt>libc6</tt>).
3734       </p>
3735
3736       <p>
3737         Packages involving shared libraries should be split up into
3738         several binary packages. This section mostly deals with how
3739         this separation is to be accomplished; rules for files within
3740         the shared library packages are in <ref id="libraries"> instead.
3741       </p>
3742
3743       <sect id="sharedlibs-runtime">
3744         <heading>Run-time shared libraries</heading>
3745
3746       <p>
3747         The run-time shared library needs to be placed in a package called
3748         <package><var>libraryname</var><var>soversion</var></package>, where
3749         <file><var>soversion</var></file> is the version number in the
3750         soname of the shared library<footnote>
3751             <p>
3752               The soname is the shared object name: it's the thing
3753               that has to match exactly between building an executable
3754               and running it for the dynamic linker to be able run the
3755               program.  For example, if the soname of the library is
3756               <file>libfoo.so.6</file>, the library package would be
3757               called <file>libfoo6</file>.
3758             </p>
3759           </footnote>.
3760         Alternatively, if it would be confusing to directly append
3761         <var>soversion</var> to <var>libraryname</var> (e.g. because
3762         <var>libraryname</var> itself ends in a number), you may use
3763         <package><var>libraryname</var>-<var>soversion</var></package> and
3764         <package><var>libraryname</var>-<var>soversion</var>-dev</package>
3765         instead.
3766       </p>
3767
3768       <p>
3769         If you have several shared libraries built from the same
3770         source tree you may lump them all together into a single
3771         shared library package, provided that you change all of
3772         their sonames at once (so that you don't get filename
3773         clashes if you try to install different versions of the
3774         combined shared libraries package).
3775       </p>
3776
3777       <p>
3778         The package should install the shared libraries under
3779         their normal names.  For example, the <package>libgdbmg1</package>
3780         package should install <file>libgdbm.so.1.7.3</file> as
3781         <file>/usr/lib/libgdbm.so.1.7.3</file>.  The files should not be
3782         renamed or re-linked by any <prgn>prerm</prgn> or
3783         <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3784         of renaming things safely without affecting running programs,
3785         and attempts to interfere with this are likely to lead to
3786         problems.
3787       </p>
3788
3789       <p>
3790         Shared libraries should not be installed executable, since
3791         the dynamic linker does not require this and trying to
3792         execute a shared library usually results in a core dump.
3793       </p>
3794
3795       <p>
3796         The run-time library package should include the symbolic link that
3797         <prgn>ldconfig</prgn> would create for the shared libraries.
3798         For example, the <package>libgdbmg1</package> package should include
3799         a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3800         <file>libgdbm.so.1.7.3</file>.  This is needed so that the dynamic
3801         linker (for example <prgn>ld.so</prgn> or
3802         <prgn>ld-linux.so.*</prgn>) can find the library between the
3803         time that <prgn>dpkg</prgn> installs it and the time that
3804         <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3805         script.<footnote>
3806           <p>
3807             The package management system requires the library to be
3808             placed before the symbolic link pointing to it in the
3809             <file>.deb</file> file.  This is so that when
3810             <prgn>dpkg</prgn> comes to install the symlink
3811             (overwriting the previous symlink pointing at an older
3812             version of the library), the new shared library is already
3813             in place.  In the past, this was achieved by creating the
3814             library in the temporary packaging directory before
3815             creating the symlink.  Unfortunately, this was not always
3816             effective, since the building of the tar file in the
3817             <file>.deb</file> depended on the behavior of the underlying
3818             file system.  Some file systems (such as reiserfs) reorder
3819             the files so that the order of creation is forgotten.
3820             Since version 1.7.0, <prgn>dpkg</prgn>
3821             reorders the files itself as necessary when building a
3822             package.  Thus it is no longer important to concern
3823             oneself with the order of file creation.
3824           </p>
3825         </footnote>
3826       </p>
3827
3828       <sect1 id="ldconfig">
3829         <heading><tt>ldconfig</tt></heading>
3830
3831       <p>
3832         Any package installing shared libraries in one of the default
3833         library directories of the dynamic linker (which are currently
3834         <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3835         listed in <file>/etc/ld.so.conf</file><footnote>
3836           <p>
3837             These are currently
3838             <list compact="compact">
3839               <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3840               <item><p>/usr/local/lib</p></item>
3841               <item><p>/usr/lib/libc5-compat</p></item>
3842               <item><p>/lib/libc5-compat</p></item>
3843               <item><p>/usr/X11R6/lib</p></item>
3844             </list>
3845           </p>
3846         </footnote>
3847         must use <prgn>ldconfig</prgn> to update the shared library
3848         system.
3849       </p>
3850
3851       <p>
3852         The package must call <prgn>ldconfig</prgn> in the
3853         <prgn>postinst</prgn> script if the first argument is
3854         <tt>configure</tt>; the <prgn>postinst</prgn> script may
3855         optionally invoke <prgn>ldconfig</prgn> at other times.  The
3856         package should call <prgn>ldconfig</prgn> in the
3857         <prgn>postrm</prgn> script if the first argument is
3858         <tt>remove</tt>.  The maintainer scripts must not invoke
3859         <prgn>ldconfig</prgn> under any circumstances other than those
3860         described in this paragraph.<footnote>
3861           <p>During install or upgrade, the preinst is called before
3862             the new files are installed, so calling "ldconfig" is
3863             pointless.  The preinst of an existing package can also be
3864             called if an upgrade fails.  However, this happens during
3865             the critical time when a shared libs may exist on-disk
3866             under a temporary name.  Thus, it is dangerous and
3867             forbidden by current policy to call "ldconfig" at this
3868             time.
3869           </p>
3870           <p>When a package is installed or upgraded, "postinst
3871             configure" runs after the new files are safely on-disk.
3872             Since it is perfectly safe to invoke ldconfig
3873             unconditionally in a postinst, it is OK for a package to
3874             simply put ldconfig in its postinst without checking the
3875             argument.  The postinst can also be called to recover from
3876             a failed upgrade.  This happens before any new files are
3877             unpacked, so there is no reason to call "ldconfig" at this
3878             point.
3879           </p>
3880           <p>For a package that is being removed, prerm is
3881             called with all the files intact, so calling ldconfig is
3882             useless.  The other calls to "prerm" happen in the case of
3883             upgrade at a time when all the files of the old package
3884             are on-disk, so again calling "ldconfig" is pointless.
3885           </p>
3886           <p>postrm, on the other hand, is called with the "remove"
3887             argument just after the files are removed, so this is the
3888             proper time to call "ldconfig" to notify the system of the
3889             fact shared libraries from the package are removed.
3890             The postrm can be called at several other times.  At the
3891             time of "postrm purge", "postrm abort-install", or "postrm
3892             abort-upgrade", calling "ldconfig" is useless because the
3893             shared lib files are not on-disk.  However, when "postrm"
3894             is invoked with arguments "upgrade", "failed-upgrade", or
3895             "disappear", a shared lib may exist on-disk under a
3896             temporary filename.
3897           </p>
3898         </footnote>
3899       </p>
3900       </sect1>
3901
3902       </sect>
3903
3904       <sect id="sharedlibs-runtime-progs">
3905         <heading>Run-time support programs</heading>
3906
3907       <p>
3908         If your package has some run-time support programs which use
3909         the shared library you must not put them in the shared
3910         library package.  If you do that then you won't be able to
3911         install several versions of the shared library without
3912         getting filename clashes.
3913       </p>
3914
3915       <p>
3916         Instead, either create another package for the runtime binaries
3917         (this package might typically be named
3918         <package><var>libraryname</var>-runtime</package>; note the absence
3919         of the <var>soversion</var> in the package name), or if the
3920         development package is small, include them in there.
3921       </p>
3922       </sect>
3923
3924       <sect id="sharedlibs-static">
3925         <heading>Static libraries</heading>
3926
3927       <p>
3928         The static library (<file><var>libraryname.a</var></file>)
3929         is usually provided in addition to the shared version.
3930         It is placed into the development package (see below).
3931       </p>
3932
3933       <p>
3934         In some cases, it is acceptable for a library to be
3935         available in static form only; these cases include:
3936         <list>
3937           <item>libraries for languages whose shared library support
3938                 is immature or unstable</item>
3939           <item>libraries whose interfaces are in flux or under
3940                 development (commonly the case when the library's
3941                 major version number is zero, or where the ABI breaks
3942                 across patchlevels)</item>
3943           <item>libraries which are explicitly intended to be
3944                 available only in static form by their upstream
3945                 author(s)</item>
3946         </list>
3947       </p>
3948
3949       <sect id="sharedlibs-dev">
3950         <heading>Development files</heading>
3951
3952       <p>
3953         The development files associated to a shared library need to be
3954         placed in a package called
3955         <package><var>libraryname</var><var>soversion</var>-dev</package>,
3956         or if you prefer only to support one development version at a
3957         time, <package><var>libraryname</var>-dev</package>.
3958       </p>
3959
3960       <p>
3961         In case several development versions of a library exist, you may
3962         need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
3963         <ref id="conflicts">) to ensure that the user only installs one
3964         development version at a time (as different development versions are
3965         likely to have the same header files in them, which would cause a
3966         filename clash if both were installed).
3967       </p>
3968
3969       <p>
3970         The development package should contain a symlink for the associated
3971         shared library without a version number. For example, the
3972         <package>libgdbmg1-dev</package> package should include a symlink
3973         from <file>/usr/lib/libgdbm.so</file> to
3974         <file>libgdbm.so.1.7.3</file>.  This symlink is needed by the linker
3975         (<prgn>ld</prgn>) when compiling packages, as it will only look for
3976         <file>libgdbm.so</file> when compiling dynamically.
3977       </p>
3978       </sect>
3979
3980       <sect id="sharedlibs-intradeps">
3981         <heading>Dependencies between the packages of the same library</heading>
3982
3983         <p>
3984           Typically the development version should have an exact
3985           version dependency on the runtime library, to make sure that
3986           compilation and linking happens correctly.  The
3987           <tt>${Source-Version}</tt> substitution variable can be
3988           useful for this purpose.
3989         </p>
3990       </sect>
3991
3992       <sect id="sharedlibs-shlibdeps">
3993         <heading>Dependencies between the library and other packages -
3994         the <tt>shlibs</tt> system</heading>
3995
3996         <p>
3997           If a package contains a binary or library which links to a
3998           shared library, we must ensure that when the package is
3999           installed on the system, all of the libraries needed are
4000           also installed.  This requirement led to the creation of the
4001           <tt>shlibs</tt> system, which is very simple in its design:
4002           any package which <em>provides</em> a shared library also
4003           provides information on the package dependencies required to
4004           ensure the presence of this library, and any package which
4005           <em>uses</em> a shared library uses this information to
4006           determine the dependencies it requires.  The files which
4007           contain the mapping from shared libraries to the necessary
4008           dependency information are called <file>shlibs</file> files.
4009         </p>
4010
4011         <p>
4012           Thus, when a package is built which contains any shared
4013           libraries, it must provide a <file>shlibs</file> file for other
4014           packages to use, and when a package is built which contains
4015           any shared libraries or compiled binaries, it must run
4016           <prgn>dpkg-shlibdeps</prgn> on these to determine the
4017           libraries used and hence the dependencies needed by this
4018           package.<footnote>
4019             <p>
4020               In the past, the shared libraries linked to were
4021               determined by calling <prgn>ldd</prgn>, but now
4022               <prgn>objdump</prgn> is used to do this.  The only
4023               change this makes to package building is that
4024               <prgn>dpkg-shlibdeps</prgn> must also be run on shared
4025               libraries, whereas in the past this was unnecessary.
4026               The rest of this footnote explains the advantage that
4027               this method gives.
4028             </p>
4029
4030             <p>
4031               We say that a binary <tt>foo</tt> <em>directly</em> uses
4032               a library <tt>libbar</tt> if it is explicitly linked
4033               with that library (that is, it uses the flag
4034               <tt>-lbar</tt> during the linking stage).  Other
4035               libraries that are needed by <tt>libbar</tt> are linked
4036               <em>indirectly</em> to <tt>foo</tt>, and the dynamic
4037               linker will load them automatically when it loads
4038               <tt>libbar</tt>.  A package should depend on
4039               the libraries it directly uses, and the dependencies for
4040               those libraries should automatically pull in the other
4041               libraries.
4042             </p>
4043
4044             <p>
4045               Unfortunately, the <prgn>ldd</prgn> program shows both
4046               the directly and indirectly used libraries, meaning that
4047               the dependencies determined included both direct and
4048               indirect dependencies.  The use of <prgn>objdump</prgn>
4049               avoids this problem by determining only the directly
4050               used libraries.
4051             </p>
4052
4053             <p>
4054               A good example of where this helps is the following.  We
4055               could update <tt>libimlib</tt> with a new version that
4056               supports a new graphics format called dgf (but retaining
4057               the same major version number).  If we used the old
4058               <prgn>ldd</prgn> method, every package that uses
4059               <tt>libimlib</tt> would need to be recompiled so it
4060               would also depend on <tt>libdgf</tt> or it wouldn't run
4061               due to missing symbols.  However with the new system,
4062               packages using <tt>libimlib</tt> can rely on
4063               <tt>libimlib</tt> itself having the dependency on
4064               <tt>libdgf</tt> and so they would not need rebuilding.
4065             </p>
4066           </footnote>
4067         </p>
4068
4069         <p>
4070           In the following sections, we will first describe where the
4071           various <tt>shlibs</tt> files are to be found, then how to
4072           use <prgn>dpkg-shlibdeps</prgn>, and finally the
4073           <tt>shlibs</tt> file format and how to create them if your
4074           package contains a shared library.
4075         </p>
4076
4077       <sect1>
4078         <heading>The <tt>shlibs</tt> files present on the system</heading>
4079
4080         <p>
4081           There are several places where <tt>shlibs</tt> files are
4082           found.  The following list gives them in the order in which
4083           they are read by <prgn>dpkg-shlibdeps</prgn>.  (The first
4084           one which gives the required information is used.)
4085         </p>
4086
4087         <p>
4088           <list>
4089             <item>
4090               <p><file>debian/shlibs.local</file></p>
4091               <p>
4092                 This lists overrides for this package.  Its use is
4093                 described below (see <ref id="shlibslocal">).
4094               </p>
4095             </item>
4096
4097             <item>
4098               <p><file>/etc/dpkg/shlibs.override</file></p>
4099               <p>
4100                 This lists global overrides.  This list is normally
4101                 empty.  It is maintained by the local system
4102                 administrator.
4103               </p>
4104             </item>
4105
4106             <item>
4107               <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
4108               <p>
4109                 When packages are being built, any
4110                 <file>debian/shlibs</file> files are copied into the
4111                 control file area of the temporary build directory and
4112                 given the name <file>shlibs</file>.  These files give
4113                 details of any shared libraries included in the
4114                 package.<footnote>
4115                   <p>
4116                     An example may help here.  Let us say that the
4117                     source package <tt>foo</tt> generates two binary
4118                     packages, <tt>libfoo2</tt> and
4119                     <tt>foo-runtime</tt>.  When building the binary
4120                     packages, the two packages are created in the
4121                     directories <file>debian/libfoo2</file> and
4122                     <file>debian/foo-runtime</file> respectively.
4123                     (<file>debian/tmp</file> could be used instead of one
4124                     of these.)  Since <tt>libfoo2</tt> provides the
4125                     <tt>libfoo</tt> shared library, it will require a
4126                     <tt>shlibs</tt> file, which will be installed in
4127                     <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
4128                     to become
4129                     <file>/var/lib/dpkg/info/libfoo2.shlibs</file>.  Then
4130                     when <prgn>dpkg-shlibdeps</prgn> is run on the
4131                     executable
4132                     <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
4133                     will examine the
4134                     <file>debian/libfoo2/DEBIAN/shlibs</file> file to
4135                     determine whether <tt>foo-prog</tt>'s library
4136                     dependencies are satisfied by any of the libraries
4137                     provided by <tt>libfoo2</tt>.  For this reason,
4138                     <prgn>dpkg-shlibdeps</prgn> must only be run once
4139                     all of the individual binary packages'
4140                     <tt>shlibs</tt> files have been installed into the
4141                     build directory.
4142                   </p>
4143                 </footnote>
4144               </p>
4145             </item>
4146
4147             <item>
4148               <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
4149               <p>
4150                 These are the <file>shlibs</file> files corresponding to
4151                 all of the packages installed on the system, and are
4152                 maintained by the relevant package maintainers.
4153               </p>
4154             </item>
4155
4156             <item>
4157               <p><file>/etc/dpkg/shlibs.default</file></p>
4158               <p>
4159                 This file lists any shared libraries whose packages
4160                 have failed to provide correct <file>shlibs</file> files.
4161                 It was used when the <file>shlibs</file> setup was first
4162                 introduced, but it is now normally empty.  It is
4163                 maintained by the <tt>dpkg</tt> maintainer.
4164               </p>
4165             </item>
4166           </list>
4167         </p>
4168       </sect1>
4169
4170       <sect1>
4171         <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4172             <file>shlibs</file> files</heading>
4173
4174         <p>
4175           Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4176           <file>debian/rules</file> file.  If your package contains only
4177           compiled binaries and libraries (but no scripts), you can
4178           use a command such as:
4179           <example compact="compact">
4180 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4181   debian/tmp/usr/lib/*
4182           </example>
4183           Otherwise, you will need to explicitly list the compiled
4184           binaries and libraries.<footnote>
4185             <p>
4186               If you are using <tt>debhelper</tt>, the
4187               <prgn>dh_shlibdeps</prgn> program will do this work for
4188               you.  It will also correctly handle multi-binary
4189               packages.
4190             </p>
4191           </footnote>
4192         </p>
4193
4194         <p>
4195           This command puts the dependency information into the
4196           <file>debian/substvars</file> file, which is then used by
4197           <prgn>dpkg-gencontrol</prgn>.  You will need to place a
4198           <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4199           field in the control file for this to work.
4200         </p>
4201
4202         <p>
4203           If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4204           done.  If it does complain you might need to create your own
4205           <file>debian/shlibs.local</file> file, as explained below (see
4206           <ref id="shlibslocal">).
4207         </p>
4208
4209         <p>
4210           If you have multiple binary packages, you will need to call
4211           <prgn>dpkg-shlibdeps</prgn> on each one which contains
4212           compiled libraries or binaries.  In such a case, you will
4213           need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4214           utilities to specify a different <file>substvars</file> file.
4215           For more details on this and other options, see <manref
4216           name="dpkg-shlibdeps" section="1">.
4217         </p>
4218       </sect1>
4219
4220       <sect1 id="shlibs">
4221         <heading>The <file>shlibs</file> File Format</heading>
4222
4223         <p>
4224           Each <file>shlibs</file> file has the same format.  Lines
4225           beginning with <tt>#</tt> are considered to be comments and
4226           are ignored.  Each line is of the form:
4227           <example compact="compact">
4228 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4229           </example>
4230         </p>
4231
4232         <p>
4233           We will explain this by reference to the example of the
4234           <tt>zlib1g</tt> package, which (at the time of writing)
4235           installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4236         </p>
4237
4238         <p>
4239           <var>library-name</var> is the name of the shared library,
4240           in this case <tt>libz</tt>.  (This must match the name part
4241           of the soname, see below.)
4242         </p>
4243
4244         <p>
4245           <var>soname-version-number</var> is the version part of the
4246           soname of the library.  The soname is the thing that must
4247           exactly match for the library to be recognized by the
4248           dynamic linker, and is usually of the form
4249           <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4250           example, <tt>libz.so.1</tt>.<footnote>
4251             <p>
4252               This can be determined using the command
4253               <example compact="compact">
4254 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4255               </example>
4256             </p>
4257           </footnote>
4258           The version part is the part which comes after
4259           <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4260         </p>
4261
4262         <p>
4263           <var>dependencies</var> has the same syntax as a dependency
4264           field in a binary package control file.  It should give
4265           details of which packages are required to satisfy a binary
4266           built against the version of the library contained in the
4267           package.  See <ref id="depsyntax"> for details.
4268         </p>
4269
4270         <p>
4271           In our example, if the first version of the <tt>zlib1g</tt>
4272           package which contained a minor number of at least
4273           <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4274           <tt>shlibs</tt> entry for this library could say:
4275           <example compact="compact">
4276 libz 1 zlib1g (>= 1:1.1.3)
4277           </example>
4278           The version-specific dependency is to avoid warnings from
4279           the dynamic linker about using older shared libraries with
4280           newer binaries.
4281         </p>
4282       </sect1>
4283
4284       <sect1>
4285         <heading>Providing a <file>shlibs</file> file</heading>
4286
4287         <p>
4288           If your package provides a shared library, you should create
4289           a <file>shlibs</file> file following the format described above.
4290           It is usual to call this file <file>debian/shlibs</file> (but if
4291           you have multiple binary packages, you might want to call it
4292           <file>debian/shlibs.<var>package</var></file> instead).  Then
4293           let <file>debian/rules</file> install it in the control area:
4294           <example compact="compact">
4295 install -m644 debian/shlibs debian/tmp/DEBIAN
4296           </example>
4297           or, in the case of a multi-binary package:
4298           <example compact="compact">
4299 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4300           </example>
4301           An alternative way of doing this is to create the
4302           <file>shlibs</file> file in the control area directly from
4303           <file>debian/rules</file> without using a <file>debian/shlibs</file>
4304           file at all,<footnote>
4305             <p>
4306               This is what <prgn>dh_makeshlibs</prgn> in the
4307               <tt>debhelper</tt> suite does.
4308             </p>
4309           </footnote>
4310           since the <file>debian/shlibs</file> file itself is ignored by
4311           <prgn>dpkg-shlibdeps</prgn>.
4312         </p>
4313
4314         <p>
4315           As <prgn>dpkg-shlibdeps</prgn> reads the
4316           <file>DEBIAN/shlibs</file> files in all of the binary packages
4317           being built from this source package, all of the
4318           <file>DEBIAN/shlibs</file> files should be installed before
4319           <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4320           packages.
4321         </p>
4322       </sect1>
4323
4324       <sect1 id="shlibslocal">
4325         <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4326
4327         <p>
4328           This file is intended only as a <em>temporary</em> fix if
4329           your binaries or libraries depend on a library whose package
4330           does not yet provide a correct <file>shlibs</file> file.
4331         </p>
4332
4333         <p>
4334           We will assume that you are trying to package a binary
4335           <tt>foo</tt>.  When you try running
4336           <prgn>dpkg-shlibdeps</prgn> you get the following error
4337           message (<tt>-O</tt> displays the dependency information on
4338           <tt>stdout</tt> instead of writing it to
4339           <tt>debian/substvars</tt>, and the lines have been wrapped
4340           for ease of reading):
4341           <example compact="compact">
4342 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4343 dpkg-shlibdeps: warning: unable to find dependency
4344   information for shared library libbar (soname 1,
4345   path /usr/lib/libbar.so.1, dependency field Depends)
4346 shlibs:Depends=libc6 (>= 2.2.2-2)
4347           </example>
4348           You can then run <prgn>ldd</prgn> on the binary to find the
4349           full location of the library concerned:
4350           <example compact="compact">
4351 $ ldd foo
4352 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4353 libc.so.6 => /lib/libc.so.6 (0x40032000)
4354 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4355           </example>
4356           So the <prgn>foo</prgn> binary depends on the
4357           <prgn>libbar</prgn> shared library, but no package seems to
4358           provide a <file>*.shlibs</file> file handling
4359           <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>.  Let's
4360           determine the package responsible:
4361           <example compact="compact">
4362 $ dpkg -S /usr/lib/libbar.so.1
4363 bar1: /usr/lib/libbar.so.1
4364 $ dpkg -s bar1 | grep Version
4365 Version: 1.0-1
4366           </example>
4367           This tells us that the <tt>bar1</tt> package, version 1.0-1,
4368           is the one we are using.  Now we can file a bug against the
4369           <tt>bar1</tt> package and create our own
4370           <file>debian/shlibs.local</file> to locally fix the problem.
4371           Including the following line into your
4372           <file>debian/shlibs.local</file> file:
4373           <example compact="compact">
4374 libbar 1 bar1 (>= 1.0-1)
4375           </example>
4376           should allow the package build to work.
4377         </p>
4378
4379         <p>
4380           As soon as the maintainer of <tt>bar1</tt> provides a
4381           correct <file>shlibs</file> file, you should remove this line
4382           from your <file>debian/shlibs.local</file> file.  (You should
4383           probably also then have a versioned <tt>Build-Depends</tt>
4384           on <tt>bar1</tt> to help ensure that others do not have the
4385           same problem building your package.)
4386         </p>
4387       </sect1>
4388
4389       </sect>
4390
4391     </chapt>
4392
4393     <chapt id="opersys"><heading>The Operating System</heading>
4394
4395       <sect>
4396         <heading>Filesystem hierarchy</heading>
4397
4398
4399         <sect1>
4400           <heading>Filesystem Structure</heading>
4401
4402           <p>
4403             The location of all installed files and directories must
4404             comply with the Filesystem Hierarchy Standard (FHS),
4405             version 2.1, except where doing so would violate other
4406             terms of Debian Policy. The version of this document
4407             referred here can be found in the <tt>debian-policy</tt>
4408             package or on
4409             <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4410               name="FHS (Debian copy)"> alongside this manual (or, if
4411             you have the <package>debian-policy</package> installed,
4412             you can try <url
4413               id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4414               (local copy)">). The
4415             latest version, which may be a more recent version, may
4416             be found on
4417             <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4418             Specific questions about following the standard may be
4419             asked on the <tt>debian-devel</tt> mailing list, or
4420             referred to the FHS mailing list (see the
4421             <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4422             more information).
4423           </p>
4424         </sect1>
4425
4426         <sect1>
4427           <heading>Site-specific programs</heading>
4428
4429           <p>
4430             As mandated by the FHS, packages must not place any
4431             files in <file>/usr/local</file>, either by putting them in
4432             the file system archive to be unpacked by <prgn>dpkg</prgn>
4433             or by manipulating them in their maintainer scripts.
4434           </p>
4435
4436           <p>
4437             However, the package may create empty directories below
4438             <file>/usr/local</file> so that the system administrator knows
4439             where to place site-specific files.  These directories
4440             should be removed on package removal if they are
4441             empty.
4442           </p>
4443
4444           <p>
4445             Note, that this applies only to directories <em>below</em>
4446             <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4447             Packages must not create sub-directories in the directory
4448             <file>/usr/local</file> itself, except those listed in FHS,
4449             section 4.5.  However, you may create directories below
4450             them as you wish. You must not remove any of the
4451             directories listed in 4.5, even if you created them.
4452           </p>
4453
4454           <p>
4455             Since <file>/usr/local</file> can be mounted read-only from a
4456             remote server, these directories must be created and
4457             removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4458             maintainer scripts and not be included in the
4459             <file>.deb</file> archive.  These scripts must not fail if
4460             either of these operations fail.
4461           </p>
4462
4463           <p>
4464             For example, the <tt>emacsen-common</tt> package could
4465             contain something like
4466             <example compact="compact">
4467 if [ ! -e /usr/local/share/emacs ]
4468 then
4469   if mkdir /usr/local/share/emacs 2>/dev/null
4470   then
4471     chown root:staff /usr/local/share/emacs
4472     chmod 2775 /usr/local/share/emacs
4473   fi
4474 fi
4475             </example>
4476             in its <prgn>postinst</prgn> script, and
4477             <example compact="compact">
4478 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4479 rmdir /usr/local/share/emacs 2>/dev/null || true
4480             </example>
4481             in the <prgn>prerm</prgn> script.  (Note that this form is
4482             used to ensure that if the script is interrupted, the
4483             directory <file>/usr/local/share/emacs</file> will still be
4484             removed.)
4485           </p>
4486
4487           <p>
4488             If you do create a directory in <file>/usr/local</file> for
4489             local additions to a package, you should ensure that
4490             settings in <file>/usr/local</file> take precedence over the
4491             equivalents in <file>/usr</file>.
4492           </p>
4493
4494           <p>
4495             However, because <file>/usr/local</file> and its contents are
4496             for exclusive use of the local administrator, a package
4497             must not rely on the presence or absence of files or
4498             directories in <file>/usr/local</file> for normal operation.
4499           </p>
4500
4501           <p>
4502             The <file>/usr/local</file> directory itself and all the
4503             subdirectories created by the package should (by default) have
4504             permissions 2775 (group-writable and set-group-id) and be
4505             owned by <tt>root.staff</tt>.
4506           </p>
4507         </sect1>
4508
4509         <sect1>
4510           <heading>The system-wide mail directory</heading>
4511           <p>
4512             The system-wide mail directory is <file>/var/mail</file>. This
4513             directory is part of the base system and should not owned
4514             by any particular mail agents.  The use of the old
4515             location <file>/var/spool/mail</file> is deprecated, even
4516             though the spool may still be physically located there.
4517             To maintain partial upgrade compatibility for systems
4518             which have <file>/var/spool/mail</file> as their physical mail
4519             spool, packages using <file>/var/mail</file> must depend on
4520             either <package>libc6</package> (&gt;= 2.1.3-13), or on
4521             <package>base-files</package> (&gt;= 2.2.0), or on later
4522             versions of either one of these packages.
4523           </p>
4524         </sect1>
4525       </sect>
4526
4527       <sect>
4528         <heading>Users and groups</heading>
4529
4530         <sect1>
4531           <heading>Introduction</heading>
4532           <p>
4533             The Debian system can be configured to use either plain or
4534             shadow passwords.
4535           </p>
4536
4537           <p>
4538             Some user ids (UIDs) and group ids (GIDs) are reserved
4539             globally for use by certain packages.  Because some
4540             packages need to include files which are owned by these
4541             users or groups, or need the ids compiled into binaries,
4542             these ids must be used on any Debian system only for the
4543             purpose for which they are allocated. This is a serious
4544             restriction, and we should avoid getting in the way of
4545             local administration policies. In particular, many sites
4546             allocate users and/or local system groups starting at 100.
4547           </p>
4548
4549           <p>
4550             Apart from this we should have dynamically allocated ids,
4551             which should by default be arranged in some sensible
4552             order, but the behavior should be configurable.
4553           </p>
4554
4555           <p>
4556             Packages other than <tt>base-passwd</tt> must not modify
4557             <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4558             <file>/etc/group</file> or <file>/etc/gshadow</file>.
4559           </p>
4560         </sect1>
4561
4562         <sect1>
4563           <heading>UID and GID classes</heading>
4564           <p>
4565             The UID and GID numbers are divided into classes as
4566             follows:
4567             <taglist>
4568               <tag>0-99:</tag>
4569               <item>
4570                 <p>
4571                   Globally allocated by the Debian project, the same
4572                   on every Debian system.  These ids will appear in
4573                   the <file>passwd</file> and <file>group</file> files of all
4574                   Debian systems, new ids in this range being added
4575                   automatically as the <tt>base-passwd</tt> package is
4576                   updated.
4577                 </p>
4578
4579                 <p>
4580                   Packages which need a single statically allocated
4581                   uid or gid should use one of these; their
4582                   maintainers should ask the <tt>base-passwd</tt>
4583                   maintainer for ids.
4584                 </p>
4585               </item>
4586
4587               <tag>100-999:</tag>
4588               <item>
4589                 <p>
4590                   Dynamically allocated system users and groups.
4591                   Packages which need a user or group, but can have
4592                   this user or group allocated dynamically and
4593                   differently on each system, should use <tt>adduser
4594                   --system</tt> to create the group and/or user.
4595                   <prgn>adduser</prgn> will check for the existence of
4596                   the user or group, and if necessary choose an unused
4597                   id based on the ranges specified in
4598                   <file>adduser.conf</file>.
4599                 </p>
4600               </item>
4601
4602               <tag>1000-29999:</tag>
4603               <item>
4604                 <p>
4605                   Dynamically allocated user accounts.  By default
4606                   <prgn>adduser</prgn> will choose UIDs and GIDs for
4607                   user accounts in this range, though
4608                   <file>adduser.conf</file> may be used to modify this
4609                   behavior.
4610                 </p>
4611               </item>
4612
4613               <tag>30000-59999:</tag>
4614               <item>
4615                 <p>Reserved.</p>
4616               </item>
4617
4618               <tag>60000-64999:</tag>
4619               <item>
4620                 <p>
4621                   Globally allocated by the Debian project, but only
4622                   created on demand. The ids are allocated centrally
4623                   and statically, but the actual accounts are only
4624                   created on users' systems on demand.
4625                 </p>
4626
4627                 <p>
4628                   These ids are for packages which are obscure or
4629                   which require many statically-allocated ids.  These
4630                   packages should check for and create the accounts in
4631                   <file>/etc/passwd</file> or <file>/etc/group</file> (using
4632                   <prgn>adduser</prgn> if it has this facility) if
4633                   necessary.  Packages which are likely to require
4634                   further allocations should have a "hole" left after
4635                   them in the allocation, to give them room to
4636                   grow.
4637                 </p>
4638               </item>
4639
4640               <tag>65000-65533:</tag>
4641               <item>
4642                 <p>Reserved.</p>
4643               </item>
4644
4645               <tag>65534:</tag>
4646               <item>
4647                 <p>
4648                   User <tt>nobody</tt>. The corresponding gid refers
4649                   to the group <tt>nogroup</tt>.
4650                 </p>
4651               </item>
4652
4653               <tag>65535:</tag>
4654               <item>
4655                 <p>
4656                   <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4657                   not</em> be used, because it is the error return
4658                   sentinel value.
4659                 </p>
4660               </item>
4661             </taglist>
4662           </p>
4663         </sect1>
4664       </sect>
4665
4666       <sect id="sysvinit">
4667         <heading>System run levels and <file>init.d</file> scripts</heading>
4668
4669         <sect1 id="/etc/init.d">
4670           <heading>Introduction</heading>
4671
4672           <p>
4673             The <file>/etc/init.d</file> directory contains the scripts
4674             executed by <prgn>init</prgn> at boot time and when the
4675             init state (or "runlevel") is changed (see <manref
4676             name="init" section="8">).
4677           </p>
4678
4679           <p>
4680             There are at least two different, yet functionally
4681             equivalent, ways of handling these scripts.  For the sake
4682             of simplicity, this document describes only the symbolic
4683             link method. However, it must not be assumed by maintainer
4684             scripts that this method is being used, and any automated
4685             manipulation of the various runlevel behaviours by
4686             maintainer scripts must be performed using
4687             <prgn>update-rc.d</prgn> as described below and not by
4688             manually installing or removing symlinks.  For information
4689             on the implementation details of the other method,
4690             implemented in the <tt>file-rc</tt> package, please refer
4691             to the documentation of that package.
4692           </p>
4693
4694           <p>
4695             These scripts are referenced by symbolic links in the
4696             <file>/etc/rc<var>n</var>.d</file> directories.  When changing
4697             runlevels, <prgn>init</prgn> looks in the directory
4698             <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4699             execute, where <tt><var>n</var></tt> is the runlevel that
4700             is being changed to, or <tt>S</tt> for the boot-up
4701             scripts.
4702           </p>
4703
4704           <p>
4705             The names of the links all have the form
4706             <file>S<var>mm</var><var>script</var></file> or
4707             <file>K<var>mm</var><var>script</var></file> where
4708             <var>mm</var> is a two-digit number and <var>script</var>
4709             is the name of the script (this should be the same as the
4710             name of the actual script in <file>/etc/init.d</file>).
4711           </p>
4712
4713           <p>
4714             When <prgn>init</prgn> changes runlevel first the targets
4715             of the links whose names start with a <tt>K</tt> are
4716             executed, each with the single argument <tt>stop</tt>,
4717             followed by the scripts prefixed with an <tt>S</tt>, each
4718             with the single argument <tt>start</tt>.  (The links are
4719             those in the <file>/etc/rc<var>n</var>.d</file> directory
4720             corresponding to the new runlevel.)  The <tt>K</tt> links
4721             are responsible for killing services and the <tt>S</tt>
4722             link for starting services upon entering the runlevel.
4723           </p>
4724
4725           <p>
4726             For example, if we are changing from runlevel 2 to
4727             runlevel 3, init will first execute all of the <tt>K</tt>
4728             prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4729             all of the <tt>S</tt> prefixed scripts in that directory.
4730             The links starting with <tt>K</tt> will cause the
4731             referred-to file to be executed with an argument of
4732             <tt>stop</tt>, and the <tt>S</tt> links with an argument
4733             of <tt>start</tt>.
4734           </p>
4735
4736           <p>
4737             The two-digit number <var>mm</var> is used to determine
4738             the order in which to run the scripts: low-numbered links
4739             have their scripts run first.  For example, the
4740             <tt>K20</tt> scripts will be executed before the
4741             <tt>K30</tt> scripts.  This is used when a certain service
4742             must be started before another.  For example, the name
4743             server <prgn>bind</prgn> might need to be started before
4744             the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4745             can set up its access lists.  In this case, the script
4746             that starts <prgn>bind</prgn> would have a lower number
4747             than the script that starts <prgn>inn</prgn> so that it
4748             runs first:
4749             <example compact="compact">
4750 /etc/rc2.d/S17bind
4751 /etc/rc2.d/S70inn
4752             </example>
4753           </p>
4754
4755           <p>
4756             The two runlevels 0 (halt) and 6 (reboot) are slightly
4757             different.  In these runlevels, the links with an
4758             <tt>S</tt> prefix are still called after those with a
4759             <tt>K</tt> prefix, but they too are called with the single
4760             argument <tt>stop</tt>.
4761           </p>
4762
4763           <p>
4764             Also, if the script name ends <tt>.sh</tt>, the script
4765             will be sourced in runlevel <tt>S</tt> rather that being
4766             run in a forked subprocess, but will be explicitly run by
4767             <prgn>sh</prgn> in all other runlevels.
4768           </p>
4769         </sect1>
4770
4771         <sect1>
4772           <heading>Writing the scripts</heading>
4773
4774           <p>
4775             Packages that include daemons for system services should
4776             place scripts in <file>/etc/init.d</file> to start or stop
4777             services at boot time or during a change of runlevel.
4778             These scripts should be named
4779             <file>/etc/init.d/<var>package</var></file>, and they should
4780             accept one argument, saying what to do:
4781
4782             <taglist>
4783               <tag><tt>start</tt></tag>
4784               <item><p>start the service,</p></item>
4785
4786               <tag><tt>stop</tt></tag>
4787               <item><p>stop the service,</p></item>
4788
4789               <tag><tt>restart</tt></tag>
4790               <item><p>stop and restart the service if it's already
4791                   running, otherwise start the service</p></item>
4792
4793               <tag><tt>reload</tt></tag>
4794               <item><p>cause the configuration of the service to be
4795                   reloaded without actually stopping and restarting
4796                   the service,</p></item>
4797
4798               <tag><tt>force-reload</tt></tag>
4799               <item><p>cause the configuration to be reloaded if the
4800                   service supports this, otherwise restart the
4801                   service.</p></item>
4802             </taglist>
4803
4804             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4805             <tt>force-reload</tt> options should be supported by all
4806             scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4807             option is optional.</p>
4808
4809           <p>
4810             The <file>init.d</file> scripts should ensure that they will
4811             behave sensibly if invoked with <tt>start</tt> when the
4812             service is already running, or with <tt>stop</tt> when it
4813             isn't, and that they don't kill unfortunately-named user
4814             processes.  The best way to achieve this is usually to use
4815             <prgn>start-stop-daemon</prgn>.</p>
4816
4817           <p>
4818             If a service reloads its configuration automatically (as
4819             in the case of <prgn>cron</prgn>, for example), the
4820             <tt>reload</tt> option of the <file>init.d</file> script
4821             should behave as if the configuration has been reloaded
4822             successfully.</p>
4823
4824           <p>
4825             The <file>/etc/init.d</file> scripts must be treated as
4826             configuration files, either (if they are present in the
4827             package, that is, in the .deb file) by marking them as
4828             <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4829             by managing them correctly in the maintainer scripts (see
4830             <ref id="config-files">).  This is important since we want
4831             to give the local system administrator the chance to adapt
4832             the scripts to the local system, e.g., to disable a
4833             service without de-installing the package, or to specify
4834             some special command line options when starting a service,
4835             while making sure her changes aren't lost during the next
4836             package upgrade.
4837           </p>
4838
4839           <p>
4840             These scripts should not fail obscurely when the
4841             configuration files remain but the package has been
4842             removed, as configuration files remain on the system after
4843             the package has been removed.  Only when <prgn>dpkg</prgn>
4844             is executed with the <tt>--purge</tt> option will
4845             configuration files be removed.  In particular, as the
4846             <file>/etc/init.d/<var>package</var></file> script itself is
4847             usually a <tt>conffile</tt>, it will remain on the system
4848             if the package is removed but not purged.  Therefore, you
4849             should include a <tt>test</tt> statement at the top of the
4850             script, like this:
4851             <example compact="compact">
4852 test -f <var>program-executed-later-in-script</var> || exit 0
4853             </example>
4854           </p>
4855
4856           <p>
4857             Often there are some variables in the <file>init.d</file>
4858             scripts whose values control the behaviour of the scripts,
4859             and which a system administrator is likely to want to
4860             change.  As the scripts themselves are frequently
4861             <tt>conffile</tt>s, modifying them requires that the
4862             administrator merge in their changes each time the package
4863             is upgraded and the <tt>conffile</tt> changes.  To ease
4864             the burden on the system administrator, such configurable
4865             values should not be placed directly in the script.
4866             Instead, they should be placed in a file in
4867             <file>/etc/default</file>, which typically will have the same
4868             base name as the <file>init.d</file> script.  This extra file
4869             should be sourced by the script when the script runs.  It
4870             must contain only variable settings and comments in POSIX
4871             <prgn>sh</prgn> format.  It may either be a
4872             <tt>conffile</tt> or a configuration file maintained by
4873             the package maintainer scripts.  See <ref id="config-files">
4874             for more details.
4875           </p>
4876
4877           <p>
4878             To ensure that vital configurable values are always
4879             available, the <file>init.d</file> script should set default
4880             values for each of the shell variables it uses, either
4881             before sourcing the <file>/etc/default/</file> file or
4882             afterwards using something like the <tt>:
4883             ${VAR:=default}</tt> syntax.  Also, the <file>init.d</file>
4884             script must behave sensibly and not fail if the
4885             <file>/etc/default</file> file is deleted.
4886           </p>
4887         </sect1>
4888
4889         <sect1>
4890           <heading>Interfacing with the initscript system</heading>
4891
4892           <p>
4893             Maintainers should use the abstraction layer provided by
4894             the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4895             programs to deal with initscripts in their packages'
4896             scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4897             and <prgn>postrm</prgn>.
4898           </p>
4899           <p>
4900             Directly managing the /etc/rc?.d links and directly
4901             invoking the <file>/etc/init.d/</file> initscripts should
4902             be done only by packages providing the initscript
4903             subsystem (such as <prgn>sysvinit</prgn> and
4904             <prgn>file-rc</prgn>).
4905
4906           </p>
4907
4908           <sect2>
4909             <heading>Managing the links</heading>
4910
4911             <p>
4912               The program <prgn>update-rc.d</prgn> is provided for
4913               package maintainers to arrange for the proper creation and
4914               removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4915               or their functional equivalent if another method is being
4916               used.  This may be used by maintainers in their packages'
4917               <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4918
4919             <p>
4920               You must not include any <file>/etc/rc<var>n</var>.d</file>
4921               symbolic links in the actual archive or manually create or
4922               remove the symbolic links in maintainer scripts; you must
4923               use the <prgn>update-rc.d</prgn> program instead.  (The
4924               former will fail if an alternative method of maintaining
4925               runlevel information is being used.)  You must not include
4926               the <file>/etc/rc<var>n</var>.d</file> directories themselves
4927               in the archive either.  (Only the <tt>sysvinit</tt>
4928               package may do so.)
4929             </p>
4930
4931             <p>
4932               By default <prgn>update-rc.d</prgn> will start services in
4933               each of the multi-user state runlevels (2, 3, 4, and 5)
4934               and stop them in the halt runlevel (0), the single-user
4935               runlevel (1) and the reboot runlevel (6).  The system
4936               administrator will have the opportunity to customize
4937               runlevels by simply adding, moving, or removing the
4938               symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4939               symbolic links are being used, or by modifying
4940               <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4941               is being used.
4942             </p>
4943
4944             <p>
4945               To get the default behavior for your package, put in your
4946               <prgn>postinst</prgn> script
4947               <example compact="compact">
4948                 update-rc.d <var>package</var> defaults
4949               </example>
4950               and in your <prgn>postrm</prgn>
4951               <example compact="compact">
4952                 if [ "$1" = purge ]; then
4953                 update-rc.d <var>package</var> remove
4954                 fi
4955               </example>. Note that if your package changes runlevels
4956               or priority, you may have to remove and recreate the links,
4957               since otherwise the old links may persist. Refer to the
4958               documentation of <prgn>update-rc.d</prgn></p>
4959
4960             <p>
4961               This will use a default sequence number of 20.  If it does
4962               not matter when or in which order the <file>init.d</file>
4963               script is run, use this default.  If it does, then you
4964               should talk to the maintainer of the <prgn>sysvinit</prgn>
4965               package or post to <tt>debian-devel</tt>, and they will
4966               help you choose a number.
4967             </p>
4968
4969             <p>
4970               For more information about using <tt>update-rc.d</tt>,
4971               please consult its manpage <manref name="update-rc.d"
4972                 section="8">.
4973             </p>
4974           </sect2>
4975
4976           <sect2>
4977             <heading>Running initscripts</heading>
4978             <p>
4979               The program <prgn>invoke-rc.d</prgn> is provided to make
4980               it easier for package maintainers to properly invoke an
4981               initscript, obeying runlevel and other locally-defined
4982               constraints that might limit a package's right to start,
4983               stop and otherwise manage services. This program may be
4984               used by maintainers in their packages' scripts.
4985             </p>
4986             <p>
4987               The use of <prgn>invoke-rc.d</prgn> to invoke the
4988               <file>/etc/init.d/*</file> initscripts is strongly
4989               recommended<footnote>
4990                 <p>
4991                   In the future, the use of invoke-rc.d to invoke
4992                   initscripts shall be made mandatory. Maintainers are
4993                   advised to switch to invoke-rc.d as soon as
4994                   possible.</p>
4995               </footnote>, instead of calling them directly.
4996             </p>
4997
4998             <p>
4999               By default, <prgn>invoke-rc.d</prgn> will pass any
5000               action requests (start, stop, reload, restart...) to the
5001               <file>/etc/init.d</file> script, filtering out requests
5002               to start or restart a service out of its intended
5003               runlevels.
5004             </p>
5005             <p>
5006               Most packages will simply need to change:
5007               <example compact="compact">/etc/init.d/&lt;package&gt;
5008               &lt;action&gt;</example> in their <prgn>postinst</prgn>
5009               and <prgn>prerm</prgn> scripts to:
5010               <example compact="compact">
5011           if [ -x /usr/sbin/invoke-rc.d ] ; then
5012                 invoke-rc.d <var>package</var> &lt;action&gt;
5013           else
5014              /etc/init.d/<var>package</var> &lt;action&gt;
5015           fi
5016               </example></p>
5017             <p>
5018               A package should register its initscript services using
5019               <prgn>update-rc.d</prgn> before it tries to invoke them
5020               using <prgn>invoke-rc.d</prgn>. Invocation of
5021               unregistered services may fail.
5022             </p>
5023             <p>
5024               For more information about using
5025               <prgn>invoke-rc.d</prgn>, please consult its manpage
5026               <manref name="invoke-rc.d" section="8">.
5027             </p>
5028           </sect2>
5029         </sect1>
5030
5031
5032         <sect1>
5033           <heading>Boot-time initialization</heading>
5034
5035           <p>
5036             There used to be another directory, <file>/etc/rc.boot</file>,
5037             which contained scripts which were run once per machine
5038             boot. This has been deprecated in favour of links from
5039             <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
5040             described in <ref id="/etc/init.d">.  Packages must not
5041             place files in <file>/etc/rc.boot</file>.</p>
5042
5043         <sect1>
5044           <heading>Example</heading>
5045
5046           <p>
5047             The <prgn>bind</prgn> DNS (nameserver) package wants to
5048             make sure that the nameserver is running in multiuser
5049             runlevels, and is properly shut down with the system.  It
5050             puts a script in <file>/etc/init.d</file>, naming the script
5051             appropriately <tt>bind</tt>.  As you can see, the script
5052             interprets the argument <tt>reload</tt> to send the
5053             nameserver a <tt>HUP</tt> signal (causing it to reload its
5054             configuration); this way the system administrator can say
5055             <tt>/etc/init.d/bind reload</tt> to reload the name
5056             server.  The script has one configurable value, which can
5057             be used to pass parameters to the named program at
5058             startup; this value is read from
5059             <file>/etc/default/bind</file> (see below).
5060           </p>
5061
5062           <p>
5063             <example compact="compact">
5064 #!/bin/sh
5065 #
5066 # Original version by Robert Leslie
5067 # &lt;rob@mars.org&gt;, edited by iwj and cs
5068
5069 test -x /usr/sbin/named || exit 0
5070
5071 # Source defaults file.
5072 PARAMS=''
5073 if [ -f /etc/default/bind ]; then
5074   . /etc/default/bind
5075 fi
5076
5077
5078 case "$1" in
5079 start)
5080   echo -n "Starting domain name service: named"
5081   start-stop-daemon --start --quiet --exec /usr/sbin/named \
5082                     -- $PARAMS
5083   echo "."
5084   ;;
5085 stop)
5086   echo -n "Stopping domain name service: named"
5087   start-stop-daemon --stop --quiet  \
5088     --pidfile /var/run/named.pid --exec /usr/sbin/named
5089   echo "."
5090   ;;
5091 restart)
5092   echo -n "Restarting domain name service: named"
5093   start-stop-daemon --stop --quiet  \
5094     --pidfile /var/run/named.pid --exec /usr/sbin/named
5095   start-stop-daemon --start --verbose --exec /usr/sbin/named \
5096                     -- $PARAMS
5097   echo "."
5098   ;;
5099 force-reload|reload)
5100   echo -n "Reloading configuration of domain name service: named"
5101   start-stop-daemon --stop --signal 1 --quiet  \
5102     --pidfile /var/run/named.pid --exec /usr/sbin/named
5103   echo "."
5104   ;;
5105 *)
5106   echo "Usage: /etc/init.d/bind " \
5107          " {start|stop|restart|reload|force-reload}" >&2
5108   exit 1
5109   ;;
5110 esac
5111
5112 exit 0
5113             </example>
5114           </p>
5115
5116           <p>
5117             Complementing the above init script is a configuration
5118             file <file>/etc/default/bind</file>, which contains
5119             configurable parameters used by the script.  This would be
5120             created by the <prgn>postinst</prgn> script if it was not
5121             already present, and removed on purge by the
5122             <prgn>postrm</prgn> script.
5123             <example compact="compact">
5124 # Specified parameters to pass to named. See named(8).
5125 # You may uncomment the following line, and edit to taste.
5126 #PARAMS="-u nobody"
5127             </example>
5128           </p>
5129
5130           <p>
5131             Another example on which you can base your
5132             <file>/etc/init.d</file> scripts is found in
5133             <file>/etc/init.d/skeleton</file>.
5134           </p>
5135
5136           <p>
5137             If this package is happy with the default setup from
5138             <prgn>update-rc.d</prgn>, namely an ordering number of 20
5139             and having named running in all runlevels, it can say in
5140             its <prgn>postinst</prgn>:
5141             <example compact="compact">
5142 update-rc.d bind defaults >/dev/null
5143             </example>
5144             And in its <prgn>postrm</prgn>, to remove the links when the
5145             package is purged:
5146             <example compact="compact">
5147 if [ "$1" = purge ]; then
5148   update-rc.d bind remove >/dev/null
5149 fi
5150             </example>
5151           </p>
5152         </sect1>
5153       </sect>
5154
5155       <sect>
5156         <heading>Console messages from <file>init.d</file> scripts</heading>
5157
5158         <p>
5159           This section describes the formats to be used for messages
5160           written to standard output by the <file>/etc/init.d</file>
5161           scripts.  The intent is to improve the consistency of
5162           Debian's startup and shutdown look and feel.  For this
5163           reason, please look very carefully at the details.  We want
5164           the messages to have the same format in terms of wording,
5165           spaces, punctuation and case of letters.
5166         </p>
5167
5168         <p>
5169           Here is a list of overall rules that you should use when you
5170           create output messages.  They can be useful if you have a
5171           non-standard message that is not covered specifically in the
5172           sections below.
5173         </p>
5174
5175         <p>
5176           <list>
5177             <item>
5178               <p>
5179                 Every message should fit in one line (fewer than 80
5180                 characters), start with a capital letter and end with
5181                 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5182               </p>
5183             </item>
5184
5185             <item>
5186               <p>
5187                 If you want to express that the computer is working on
5188                 something (that is, performing a specific task, not
5189                 starting or stopping a program), we use an "ellipsis"
5190                 (three dots: <tt>...</tt>).  Note that we don't insert
5191                 spaces before or after the dots.  If the task has been
5192                 completed we write <tt>done.</tt> and a line feed.
5193               </p>
5194             </item>
5195
5196             <item>
5197               <p>
5198                 Design your messages as if the computer is telling you
5199                 what he is doing (let him be polite :-), but don't
5200                 mention "him" directly.  For example, if you think of
5201                 saying
5202                 <example compact="compact">
5203 I'm starting network daemons: nfsd mountd.
5204                 </example>
5205                 just say
5206                 <example compact="compact">
5207 Starting network daemons: nfsd mountd.
5208                 </example>
5209               </p>
5210             </item>
5211           </list>
5212         </p>
5213
5214         <p>
5215           There are standard message formats for the following
5216           situations.  They should be used by the <tt>init.d</tt>
5217           scripts.
5218         </p>
5219
5220         <p>
5221           <list>
5222             <item>
5223               <p>When daemons are started</p>
5224
5225               <p>
5226                 If your script starts one or more daemons, the output
5227                 should look like this (a single line, no leading
5228                 spaces):
5229                 <example compact="compact">
5230 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5231                 </example>
5232                 The <var>description</var> should describe the
5233                 subsystem the daemon or set of daemons are part of,
5234                 while <var>daemon-1</var> up to <var>daemon-n</var>
5235                 denote each daemon's name (typically the file name of
5236                 the program).
5237               </p>
5238
5239               <p>
5240                 For example, the output of <file>/etc/init.d/lpd</file>
5241                 would look like:
5242                 <example compact="compact">
5243 Starting printer spooler: lpd.
5244                 </example>
5245               </p>
5246
5247               <p>
5248                 This can be achieved by saying
5249                 <example compact="compact">
5250 echo -n "Starting printer spooler: lpd"
5251 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5252 echo "."
5253                 </example>
5254                 in the script. If you have more than one daemon to
5255                 start, you should do the following:
5256                 <example compact="compact">
5257 echo -n "Starting remote file system services:"
5258 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5259 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5260 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5261 echo "."
5262                 </example>
5263                 This makes it possible for the user to see what takes
5264                 so long and when the final daemon has been started.
5265                 You should be careful where to put spaces: in the
5266                 example above the system administrator can easily
5267                 comment out a line if he don't wants to start a
5268                 specific daemon, while the displayed message still
5269                 looks good.
5270               </p>
5271             </item>
5272
5273             <item>
5274               <p>When a system parameter is being set</p>
5275
5276               <p>
5277                 If you have to set up different system parameters
5278                 during the system boot, you should use this format:
5279                 <example compact="compact">
5280 Setting <var>parameter</var> to "<var>value</var>".
5281                 </example>
5282               </p>
5283
5284               <p>
5285                 You can use a statement such as the following to get
5286                 the quotes right:
5287                 <example compact="compact">
5288 echo "Setting DNS domainname to \"$domainname\"."
5289                 </example>
5290               </p>
5291
5292               <p>
5293                 Note that the same symbol (<tt>"</tt>) is used for the left
5294                 and right quotation marks.  A grave accent (<tt>`</tt>) is
5295                 not a quote character; neither is an apostrophe
5296                 (<tt>'</tt>).
5297               </p>
5298             </item>
5299
5300             <item>
5301               <p>When a daemon is stopped or restarted</p>
5302
5303               <p>
5304                 When you stop or restart a daemon, you should issue a
5305                 message identical to the startup message, except that
5306                 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5307                 or <tt>Restarting</tt> respectively.
5308               </p>
5309
5310               <p>
5311                 For example, stopping the printer daemon will like
5312                 like this:
5313                 <example compact="compact">
5314 Stopping printer spooler: lpd.
5315                 </example>
5316               </p>
5317             </item>
5318
5319             <item>
5320               <p>When something is executed</p>
5321
5322               <p>
5323                 There are several examples where you have to run a
5324                 program at system startup or shutdown to perform a
5325                 specific task, for example, setting the system's clock
5326                 using <prgn>netdate</prgn> or killing all processes
5327                 when the system shuts down.  Your message should look
5328                 like this:
5329                 <example compact="compact">
5330 Doing something very useful...done.
5331                 </example>
5332                 You should print the <tt>done.</tt> immediately after
5333                 the job has been completed, so that the user is
5334                 informed why she has to wait.  You can get this
5335                 behavior by saying
5336                 <example compact="compact">
5337 echo -n "Doing something very useful..."
5338 do_something
5339 echo "done."
5340                 </example>
5341                 in your script.
5342               </p>
5343             </item>
5344
5345             <item>
5346               <p>When the configuration is reloaded</p>
5347
5348               <p>
5349                 When a daemon is forced to reload its configuration
5350                 files you should use the following format:
5351                 <example compact="compact">
5352 Reloading <var>description</var> configuration...done.
5353                 </example>
5354                 where <var>description</var> is the same as in the
5355                 daemon starting message.
5356               </p>
5357             </item>
5358           </list>
5359         </p>
5360       </sect>
5361
5362       <sect>
5363         <heading>Cron jobs</heading>
5364
5365         <p>
5366           Packages must not modify the configuration file
5367           <file>/etc/crontab</file>, and they must not modify the files in
5368           <file>/var/spool/cron/crontabs</file>.</p>
5369
5370         <p>
5371           If a package wants to install a job that has to be executed
5372           via cron, it should place a file with the name of the
5373           package in one or more of the following directories:
5374           <example compact="compact">
5375 /etc/cron.daily
5376 /etc/cron.weekly
5377 /etc/cron.monthly
5378           </example>
5379           As these directory names imply, the files within them are
5380           executed on a daily, weekly, or monthly basis,
5381           respectively. The exact times are listed in
5382           <file>/etc/crontab</file>.</p>
5383
5384         <p>
5385           All files installed in any of these directories must be
5386           scripts (e.g., shell scripts or Perl scripts) so that they
5387           can easily be modified by the local system administrator.
5388           In addition, they should be treated as configuration
5389           files.
5390         </p>
5391
5392         <p>
5393           If a certain job has to be executed more frequently than
5394           daily, the package should install a file
5395           <file>/etc/cron.d/<var>package</var></file>. This file uses the
5396           same syntax as <file>/etc/crontab</file> and is processed by
5397           <prgn>cron</prgn> automatically. The file must also be
5398           treated as a configuration file. (Note that entries in the
5399           <file>/etc/cron.d</file> directory are not handled by
5400           <prgn>anacron</prgn>. Thus, you should only use this
5401           directory for jobs which may be skipped if the system is not
5402           running.)</p>
5403
5404         <p>
5405           The scripts or crontab entries in these directories should
5406           check if all necessary programs are installed before they
5407           try to execute them. Otherwise, problems will arise when a
5408           package was removed but not purged since configuration files
5409           are kept on the system in this situation.</p>
5410       </sect>
5411
5412       <sect>
5413         <heading>Menus</heading>
5414
5415         <p>
5416           The Debian <tt>menu</tt> package provides a standard
5417           interface between packages providing applications and
5418           documents, and <em>menu programs</em> (either X window
5419           managers or text-based menu programs such as
5420           <prgn>pdmenu</prgn>).
5421         </p>
5422
5423         <p>
5424           All packages that provide applications that need not be
5425           passed any special command line arguments for normal
5426           operation should register a menu entry for those
5427           applications, so that users of the <tt>menu</tt> package
5428           will automatically get menu entries in their window
5429           managers, as well in shells like <tt>pdmenu</tt>.
5430         </p>
5431
5432         <p>
5433           Menu entries should follow the current menu policy.
5434         </p>
5435
5436         <p>
5437           The menu policy can be found in the <tt>menu-policy</tt>
5438           files in the <tt>debian-policy</tt> package.
5439           They are also available from the Debian web mirrors at
5440           <tt><url name="/doc/packaging-manuals/menu-policy/"
5441                 id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>
5442           and from the Debian archive mirrors at
5443           <tt><url name="/doc/package-developer/menu-policy.txt.gz"
5444                 id="http://ftp.debian.org/debian/doc/package-developer/menu-policy.txt.gz"></tt>.
5445         </p>
5446
5447         <p>
5448           Please also refer to the <em>Debian Menu System</em>
5449           documentation that comes with the <tt>menu</tt> package for
5450           information about how to register your applications and web
5451           documents.
5452         </p>
5453       </sect>
5454
5455       <sect>
5456         <heading>Multimedia handlers</heading>
5457
5458         <p>
5459           MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5460           is a mechanism for encoding files and data streams and
5461           providing meta-information about them, in particular their
5462           type (e.g.  audio or video) and format (e.g. PNG, HTML,
5463           MP3).
5464         </p>
5465
5466         <p>
5467           Registration of MIME type handlers allows programs like mail
5468           user agents and web browsers to to invoke these handlers to
5469           view, edit or display MIME types they don't support
5470           directly.
5471         </p>
5472
5473         <p>
5474           Packages which provide the ability to view/show/play,
5475           compose, edit or print MIME types should register themselves
5476           as such following the current MIME support policy.
5477         </p>
5478
5479         <p>
5480           The MIME support policy can be found in the <tt>mime-policy</tt>
5481           files in the <tt>debian-policy</tt> package.
5482           They are also available from the Debian web mirrors at
5483           <tt><url name="/doc/packaging-manuals/mime-policy/"
5484                 id="http://www.debian.org/doc/packaging-manuals/mime-policy/"></tt>
5485           and from the Debian archive mirrors at
5486           <tt><url name="/doc/package-developer/mime-policy.txt.gz"
5487                 id="http://ftp.debian.org/debian/doc/package-developer/mime-policy.txt.gz"></tt>.
5488         </p>
5489
5490       </sect>
5491
5492       <sect>
5493         <heading>Keyboard configuration</heading>
5494
5495         <p>
5496           To achieve a consistent keyboard configuration so that all
5497           applications interpret a keyboard event the same way, all
5498           programs in the Debian distribution must be configured to
5499           comply with the following guidelines.
5500         </p>
5501
5502         <p>
5503           The following keys must have the specified interpretations:
5504
5505           <taglist>
5506             <tag><tt>&lt;--</tt></tag>
5507             <item><p>delete the character to the left of the cursor</p></item>
5508
5509             <tag><tt>Delete</tt></tag>
5510             <item><p>delete the character to the right of the cursor</p></item>
5511
5512             <tag><tt>Control+H</tt></tag>
5513             <item><p>emacs: the help prefix</p></item>
5514           </taglist>
5515
5516           The interpretation of any keyboard events should be
5517           independent of the terminal that is used, be it a virtual
5518           console, an X terminal emulator, an rlogin/telnet session,
5519           etc.
5520         </p>
5521
5522         <p>
5523           The following list explains how the different programs
5524           should be set up to achieve this:
5525         </p>
5526
5527         <p>
5528           <list>
5529             <item><p><tt>&lt;--</tt> generates <tt>KB_BackSpace</tt>
5530                 in X.</p></item>
5531
5532             <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5533                 X.</p></item>
5534
5535             <item>
5536               <p>
5537                 X translations are set up to make
5538                 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5539                 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5540                 is the vt220 escape code for the "delete character"
5541                 key).  This must be done by loading the X resources
5542                 using <prgn>xrdb</prgn> on all local X displays, not
5543                 using the application defaults, so that the
5544                 translation resources used correspond to the
5545                 <prgn>xmodmap</prgn> settings.</p></item>
5546
5547             <item>
5548               <p>
5549                 The Linux console is configured to make
5550                 <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
5551                 generate <tt>ESC [ 3 ~</tt>.</p></item>
5552
5553             <item>
5554               <p>
5555                 X applications are configured so that <tt>&lt;</tt>
5556                 deletes left, and <tt>Delete</tt> deletes right.  Motif
5557                 applications already work like this.</p></item>
5558
5559             <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5560
5561             <item>
5562               <p>
5563                 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5564                 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5565                 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5566
5567             <item>
5568               <p>
5569                 Emacs is programmed to map <tt>KB_Backspace</tt> or
5570                 the <tt>stty erase</tt> character to
5571                 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5572                 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5573                 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5574
5575             <item>
5576               <p>
5577                 Other applications use the <tt>stty erase</tt>
5578                 character and <tt>kdch1</tt> for the two delete keys,
5579                 with ASCII DEL being "delete previous character" and
5580                 <tt>kdch1</tt> being "delete character under
5581                 cursor".</p></item>
5582
5583           </list>
5584         </p>
5585
5586         <p>
5587           This will solve the problem except for the following
5588           cases:
5589         </p>
5590
5591         <p>
5592           <list>
5593             <item>
5594               <p>
5595                 Some terminals have a <tt>&lt;--</tt> key that cannot
5596                 be made to produce anything except <tt>^H</tt>.  On
5597                 these terminals Emacs help will be unavailable on
5598                 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5599                 character takes precedence in Emacs, and has been set
5600                 correctly).  <tt>M-x help</tt> or <tt>F1</tt> (if
5601                 available) can be used instead.</p></item>
5602
5603             <item>
5604               <p>
5605                 Some operating systems use <tt>^H</tt> for <tt>stty
5606                 erase</tt>.  However, modern telnet versions and all
5607                 rlogin versions propagate <tt>stty</tt> settings, and
5608                 almost all UNIX versions honour <tt>stty erase</tt>.
5609                 Where the <tt>stty</tt> settings are not propagated
5610                 correctly, things can be made to work by using
5611                 <tt>stty</tt> manually.</p></item>
5612
5613             <item>
5614               <p>
5615                 Some systems (including previous Debian versions) use
5616                 <prgn>xmodmap</prgn> to arrange for both
5617                 <tt>&lt;--</tt> and <tt>Delete</tt> to generate
5618                 <tt>KB_Delete</tt>.  We can change the behavior of
5619                 their X clients using the same X resources that we use
5620                 to do it for our own clients, or configure our clients
5621                 using their resources when things are the other way
5622                 around.  On displays configured like this
5623                 <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
5624                 will.</p></item>
5625
5626             <item>
5627               <p>
5628                 Some operating systems have different <tt>kdch1</tt>
5629                 settings in their <tt>terminfo</tt> database for
5630                 <tt>xterm</tt> and others.  On these systems the
5631                 <tt>Delete</tt> key will not work correctly when you
5632                 log in from a system conforming to our policy, but
5633                 <tt>&lt;--</tt> will.</p></item>
5634           </list>
5635         </p>
5636       </sect>
5637
5638       <sect>
5639         <heading>Environment variables</heading>
5640
5641         <p>
5642           A program must not depend on environment variables to get
5643           reasonable defaults.  (That's because these environment
5644           variables would have to be set in a system-wide
5645           configuration file like <file>/etc/profile</file>, which is not
5646           supported by all shells.)</p>
5647
5648         <p>
5649           If a program usually depends on environment variables for its
5650           configuration, the program should be changed to fall back to
5651           a reasonable default configuration if these environment
5652           variables are not present. If this cannot be done easily
5653           (e.g., if the source code of a non-free program is not
5654           available), the program must be replaced by a small
5655           "wrapper" shell script which sets the environment variables
5656           if they are not already defined, and calls the original program.</p>
5657
5658         <p>
5659           Here is an example of a wrapper script for this purpose:
5660
5661           <example compact="compact">
5662 #!/bin/sh
5663 BAR=${BAR:-/var/lib/fubar}
5664 export BAR
5665 exec /usr/lib/foo/foo "$@"
5666           </example>
5667         </p>
5668
5669         <p>
5670           Furthermore, as <file>/etc/profile</file> is a configuration
5671           file of the <prgn>base-files</prgn> package, other packages must not
5672           put any environment variables or other commands into that
5673           file.</p>
5674       </sect>
5675     </chapt>
5676
5677     <chapt id="files">
5678       <heading>Files</heading>
5679
5680       <sect>
5681         <heading>Binaries</heading>
5682
5683         <p>
5684           Two different packages must not install programs with
5685           different functionality but with the same filenames.  (The
5686           case of two programs having the same functionality but
5687           different implementations is handled via "alternatives" or
5688           the "Conflicts" mechanism.  See <ref id="maintscripts"> and
5689           <ref id="conflicts"> respectively.)  If this case happens,
5690           one of the programs must be renamed.  The maintainers should
5691           report this to the <tt>debian-devel</tt> mailing list and
5692           try to find a consensus about which program will have to be
5693           renamed.  If a consensus cannot be reached, <em>both</em>
5694           programs must be renamed.
5695         </p>
5696
5697         <p>
5698          By default, when a package is being built, any binaries
5699          created should include debugging information, as well as
5700          being compiled with optimization.  You should also turn on
5701          as many reasonable compilation warnings as possible; this
5702          makes life easier for porters, who can then look at build
5703          logs for possible problems.  For the C programming language,
5704          this means the following compilation parameters should be
5705          used:
5706           <example compact="compact">
5707 CC = gcc
5708 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5709 LDFLAGS = # none
5710 install -s # (or use strip on the files in debian/tmp)
5711           </example>
5712         </p>
5713
5714         <p>
5715           Note that by default all installed binaries should be stripped,
5716           either by using the <tt>-s</tt> flag to
5717           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5718           the binaries after they have been copied into
5719           <file>debian/tmp</file> but before the tree is made into a
5720           package.</p>
5721
5722         <p>
5723           Although binaries in the build tree should be compiled with
5724           debugging information by default, it can often be difficult
5725           to debug programs if they are also subjected to compiler
5726           optimization.  For this reason, it is recommended to support
5727           the standardized environment
5728           variable <tt>DEB_BUILD_OPTIONS</tt>.  This variable can
5729           contain several flags to change how a package is compiled
5730           and built.
5731         </p>
5732         <p>
5733           <taglist>
5734             <tag>noopt</tag>
5735             <item>
5736               <p>
5737                 The presence of this string means that the package
5738                 should be complied with a minimum of optimization.
5739                 For C programs, it is best to add <tt>-O0</tt>
5740                 to <tt>CFLAGS</tt> (although this is usually the
5741                 default).  Some programs might fail to build or run at
5742                 this level of optimization; it may be necessary to
5743                 use <tt>-O1</tt>, for example.
5744               </p>
5745             </item>
5746             <tag>nostrip</tag>
5747             <item>
5748               <p>
5749                 This string means that the debugging symbols should
5750                 not be stripped from the binary during installation,
5751                 so that debugging information may be included in the package.
5752               </p>
5753             </item>
5754           </taglist>
5755         </p>
5756         <p>
5757           The following makefile snippet is an example of how one may
5758           implement the build options; you will probably have to
5759           massage this example in order to make it work for your
5760           package.
5761           <example compact="compact">
5762 CFLAGS = -Wall -g
5763 INSTALL = install
5764 INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
5765 INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
5766 INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
5767 INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
5768
5769 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5770 CFLAGS += -O0
5771 else
5772 CFLAGS += -O2
5773 endif
5774 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5775 INSTALL_PROGRAM += -s
5776 endif
5777           </example>
5778         </p>
5779
5780         <p>
5781           It is up to the package maintainer to decide what
5782           compilation options are best for the package.  Certain
5783           binaries (such as computationally-intensive programs) will
5784           function better with certain flags (<tt>-O3</tt>, for
5785           example); feel free to use them.  Please use good judgment
5786           here.  Don't use flags for the sake of it; only use them
5787           if there is good reason to do so.  Feel free to override
5788           the upstream author's ideas about which compilation
5789           options are best: they are often inappropriate for our
5790           environment.
5791         </p>
5792       </sect>
5793
5794
5795       <sect id="libraries">
5796         <heading>Libraries</heading>
5797
5798         <p>
5799           The shared version of a library must be compiled with
5800           <tt>-fPIC</tt>, and the static version must not be. In other
5801           words, each source unit (<tt>*.c</tt>, for example, for C files)
5802           will need to be compiled twice.
5803         </p>
5804
5805
5806         <p>
5807           You must specify the gcc option <tt>-D_REENTRANT</tt>
5808           when building a library (either static or shared) to make
5809           the library compatible with LinuxThreads.
5810         </p>
5811
5812         <p>
5813           All installed shared libraries should be stripped with
5814           <example compact="compact">
5815 strip --strip-unneeded <var>your-lib</var>
5816           </example>
5817           (The option <tt>--strip-unneeded</tt> makes
5818           <prgn>strip</prgn> remove only the symbols which aren't
5819           needed for relocation processing.)  Shared libraries can
5820           function perfectly well when stripped, since the symbols for
5821           dynamic linking are in a separate part of the ELF object
5822           file.<footnote>
5823             <p>
5824               You might also want to use the options
5825               <tt>--remove-section=.comment</tt> and
5826               <tt>--remove-section=.note</tt> on both shared libraries
5827               and executables, and <tt>--strip-debug</tt> on static
5828               libraries.
5829             </p>
5830           </footnote>
5831         </p>
5832
5833         <p>
5834           Note that under some circumstances it may be useful to
5835           install a shared library unstripped, for example when
5836           building a separate package to support debugging.
5837         </p>
5838
5839         <p>
5840           Shared object files (often <file>.so</file> files) that are not
5841           public libraries, that is, they are not meant to be linked
5842           to by third party executables (binaries of other packages),
5843           should be installed in subdirectories of the
5844           <file>/usr/lib</file> directory.  Such files are exempt from the
5845           rules that govern ordinary shared libraries, except that
5846           they must not be installed executable and should be
5847           stripped.<footnote>
5848             <p>
5849               A common example are the so-called "plug-ins",
5850               internal shared objects that are dynamically loaded by
5851               programs using <manref name="dlopen" section="3">.
5852             </p>
5853           </footnote>
5854         </p>
5855
5856         <p>
5857           Packages containing shared libraries that may be linked to
5858           by other packages' binaries, but which for some
5859           <em>compelling</em> reason can not be installed in
5860           <file>/usr/lib</file> directory, may install the shared library
5861           files in subdirectories of the <file>/usr/lib</file> directory,
5862           in which case they should arrange to add that directory in
5863           <file>/etc/ld.so.conf</file> in the package's post-installation
5864           script, and remove it in the package's post-removal script.
5865         </p>
5866
5867         <p>
5868           An ever increasing number of packages are using
5869           <prgn>libtool</prgn> to do their linking.  The latest GNU
5870           libtools (>= 1.3a) can take advantage of the metadata in the
5871           installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5872           files).  The main advantage of <prgn>libtool</prgn>'s
5873           <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5874           store and subsequently access metadata with respect to the
5875           libraries it builds.  <prgn>libtool</prgn> will search for
5876           those files, which contain a lot of useful information about
5877           a library (such as library dependency information for static
5878           linking).  Also, they're <em>essential</em> for programs
5879           using <tt>libltdl</tt>.<footnote>
5880             <p>
5881               Although <prgn>libtool</prgn> is fully capable of
5882               linking against shared libraries which don't have
5883               <tt>.la</tt> files, as it is a mere shell script it can
5884               add considerably to the build time of a
5885               <prgn>libtool</prgn>-using package if that shell script
5886               has to derive all this information from first principles
5887               for each library every time it is linked.  With the
5888               advent of <prgn>libtool</prgn> version 1.4 (and to a
5889               lesser extent <prgn>libtool</prgn> version 1.3), the
5890               <file>.la</file> files also store information about
5891               inter-library dependencies which cannot necessarily be
5892               derived after the <file>.la</file> file is deleted.
5893             </p>
5894           </footnote>
5895         </p>
5896
5897         <p>
5898           Packages that use <prgn>libtool</prgn> to create shared
5899           libraries should include the <file>.la</file> files in the
5900           <tt>-dev</tt> package, unless the package relies on
5901           <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5902           the <tt>.la</tt> files must go in the run-time library
5903           package.
5904         </p>
5905
5906         <p>
5907           You must make sure that you use only released versions of
5908           shared libraries to build your packages; otherwise other
5909           users will not be able to run your binaries
5910           properly. Producing source packages that depend on
5911           unreleased compilers is also usually a bad
5912           idea.
5913         </p>
5914       </sect>
5915
5916
5917       <sect>
5918         <heading>Shared libraries</heading>
5919         <p>
5920           This section has moved to <ref id="sharedlibs">.
5921         </p>
5922       </sect>
5923
5924
5925       <sect id="scripts">
5926         <heading>Scripts</heading>
5927
5928         <p>
5929           All command scripts, including the package maintainer
5930           scripts inside the package and used by <prgn>dpkg</prgn>,
5931           should have a <tt>#!</tt> line naming the shell to be used
5932           to interpret them.</p>
5933
5934         <p>
5935           In the case of Perl scripts this should be
5936           <tt>#!/usr/bin/perl</tt>.</p>
5937
5938         <p>
5939           Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5940           should almost certainly start with <tt>set -e</tt> so that
5941           errors are detected.  Every script should use
5942           <tt>set -e</tt> or check the exit status of <em>every</em>
5943           command.</p>
5944
5945         <p>
5946           The standard shell interpreter <file>/bin/sh</file> can be a
5947           symbolic link to any POSIX compatible shell, if <tt>echo
5948           -n</tt> does not generate a newline.<footnote>
5949             <p>
5950               Debian policy specifies POSIX behavior for
5951               <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5952               use in the Linux community (in particular including this
5953               policy, the Linux kernel source, many Debian scripts,
5954               etc.).  This <tt>echo -n</tt> mechanism is valid but not
5955               required under POSIX, hence this explicit addition.
5956               Also, rumour has it that this shall be mandated under
5957               the LSB anyway.
5958             </p>
5959           </footnote>
5960           Thus, shell scripts specifying <file>/bin/sh</file> as
5961           interpreter should only use POSIX features. If a script
5962           requires non-POSIX features from the shell interpreter, the
5963           appropriate shell must be specified in the first line of the
5964           script (e.g., <tt>#!/bin/bash</tt>) and the package must
5965           depend on the package providing the shell (unless the shell
5966           package is marked "Essential", as in the case of
5967           <prgn>bash</prgn>).
5968         </p>
5969
5970         <p>
5971           You may wish to restrict your script to POSIX features when
5972           possible so that it may use <file>/bin/sh</file> as its
5973           interpreter. If your script works with <prgn>dash</prgn>
5974           (originally called <prgn>ash</prgn>), it's probably POSIX
5975           compliant, but if you are in doubt, use
5976           <file>/bin/bash</file>.
5977         </p>
5978
5979         <p>
5980           Perl scripts should check for errors when making any
5981           system calls, including <tt>open</tt>, <tt>print</tt>,
5982           <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5983         </p>
5984
5985         <p>
5986           <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5987           scripting languages.  See <em>Csh Programming Considered
5988           Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5989           can be found at <url
5990           id="http://language.perl.com/versus/csh.whynot">.<footnote>
5991             <p>
5992               It can also be found on
5993               <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5994               or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5995               <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5996               </p>
5997           </footnote>
5998           If an upstream package comes with <prgn>csh</prgn> scripts
5999           then you must make sure that they start with
6000           <tt>#!/bin/csh</tt> and make your package depend on the
6001           <prgn>c-shell</prgn> virtual package.
6002         </p>
6003
6004         <p>
6005           Any scripts which create files in world-writeable
6006           directories (e.g., in <file>/tmp</file>) must use a
6007           mechanism which will fail if a file with the same name
6008           already exists.</p>
6009
6010         <p>
6011           The Debian base system provides the <prgn>tempfile</prgn>
6012           and <prgn>mktemp</prgn> utilities for use by scripts for
6013           this purpose.</p></sect>
6014
6015
6016       <sect>
6017         <heading>Symbolic links</heading>
6018
6019         <p>
6020           In general, symbolic links within a top-level directory
6021           should be relative, and symbolic links pointing from one
6022           top-level directory into another should be absolute. (A
6023           top-level directory is a sub-directory of the root
6024           directory <file>/</file>.)</p>
6025
6026         <p>
6027           In addition, symbolic links should be specified as short as
6028           possible, i.e., link targets like <file>foo/../bar</file> are
6029           deprecated.</p>
6030
6031         <p>
6032           Note that when creating a relative link using
6033           <prgn>ln</prgn> it is not necessary for the target of the
6034           link to exist relative to the working directory you're
6035           running <prgn>ln</prgn> from, nor is it necessary to change
6036           directory to the directory where the link is to be made.
6037           Simply include the string that should appear as the target
6038           of the link (this will be a pathname relative to the
6039           directory in which the link resides) as the first argument
6040           to <prgn>ln</prgn>.</p>
6041
6042         <p>
6043           For example, in your <prgn>Makefile</prgn> or
6044           <file>debian/rules</file>, you can do things like:
6045           <example compact="compact">
6046 ln -fs gcc $(prefix)/bin/cc
6047 ln -fs gcc debian/tmp/usr/bin/cc
6048 ln -fs ../sbin/sendmail $(prefix)/bin/runq
6049 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
6050           </example></p>
6051
6052         <p>
6053           A symbolic link pointing to a compressed file should always
6054           have the same file extension as the referenced file. (For
6055           example, if a file <file>foo.gz</file> is referenced by a
6056           symbolic link, the filename of the link has to end with
6057           "<file>.gz</file>" too, as in <file>bar.gz</file>.)
6058         </p>
6059       </sect>
6060
6061       <sect>
6062         <heading>Device files</heading>
6063
6064         <p>
6065           Packages must not include device files in the package file
6066           tree.</p>
6067
6068         <p>
6069           If a package needs any special device files that are not
6070           included in the base system, it must call
6071           <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
6072           after notifying the user<footnote>
6073             <p>
6074               This notification could be done via a (low-priority)
6075               debconf message, or an echo (printf) statement.
6076             </p>
6077           </footnote>
6078           .</p>
6079
6080         <p>
6081           Packages must not remove any device files in the
6082           <prgn>postrm</prgn> or any other script. This is left to the
6083           system administrator.</p>
6084
6085         <p>
6086           Debian uses the serial devices
6087           <file>/dev/ttyS*</file>. Programs using the old
6088           <file>/dev/cu*</file> devices should be changed to use
6089           <file>/dev/ttyS*</file>.</p>
6090       </sect>
6091
6092       <sect id="config-files">
6093         <heading>Configuration files</heading>
6094         <sect1>
6095           <heading>Definitions</heading>
6096           <p>
6097             <taglist>
6098               <tag>configuration file</tag>
6099               <item>
6100                 <p>
6101                   A file that affects the operation of a program, or
6102                   provides site- or host-specific information, or
6103                   otherwise customizes the behavior of a program.
6104                   Typically, configuration files are intended to be
6105                   modified by the system administrator (if needed or
6106                   desired) to conform to local policy or to provide
6107                   more useful site-specific behavior.
6108                 </p>
6109               </item>
6110
6111               <tag><tt>conffile</tt></tag>
6112               <item>
6113                 <p>
6114                   A file listed in a package's <tt>conffiles</tt>
6115                   file, and is treated specially by <prgn>dpkg</prgn>
6116                   (see <ref id="configdetails">).
6117                 </p>
6118               </item>
6119             </taglist>
6120           </p>
6121
6122           <p>
6123             The distinction between these two is important; they are
6124             not interchangeable concepts. Almost all
6125             <tt>conffile</tt>s are configuration files, but many
6126             configuration files are not <tt>conffiles</tt>.
6127           </p>
6128
6129           <p>
6130             Note that a script that embeds configuration information
6131             (such as most of the files in <file>/etc/default</file> and
6132             <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6133             configuration file and should be treated as such.
6134           </p>
6135         </sect1>
6136
6137         <sect1>
6138           <heading>Location</heading>
6139           <p>
6140             Any configuration files created or used by your package
6141             must reside in <file>/etc</file>. If there are several,
6142             consider creating a subdirectory of <file>/etc</file>
6143             named after your package.</p>
6144
6145           <p>
6146             If your package creates or uses configuration files
6147             outside of <file>/etc</file>, and it is not feasible to modify
6148             the package to use <file>/etc</file> directly, put the files
6149             in <file>/etc</file> and create symbolic links to those files
6150             from the location that the package requires.</p>
6151         </sect1>
6152
6153         <sect1>
6154           <heading>Behavior</heading>
6155           <p>
6156             Configuration file handling must conform to the following
6157             behavior:
6158             <list compact="compact">
6159               <item>
6160                 <p>
6161                   local changes must be preserved during a package
6162                   upgrade, and
6163                 </p>
6164               </item>
6165               <item>
6166                 <p>
6167                   configuration files must be preserved when the
6168                   package is removed, and only deleted when the
6169                   package is purged.
6170                 </p>
6171               </item>
6172             </list>
6173           </p>
6174
6175           <p>
6176             The easy way to achieve this behavior is to make the
6177             configuration file a <tt>conffile</tt>. This is
6178             appropriate only if it is possible to distribute a default
6179             version that will work for most installations, although
6180             some system administrators may choose to modify it. This
6181             implies that the default version will be part of the
6182             package distribution, and must not be modified by the
6183             maintainer scripts during installation (or at any other
6184             time).
6185           </p>
6186
6187           <p>
6188             In order to ensure that local changes are preserved
6189             correctly, no package may contain or make hard links to
6190             conffiles.<footnote>
6191               <p>
6192                 Rationale: There are two problems with hard links.
6193                 The first is that some editors break the link while
6194                 editing one of the files, so that the two files may
6195                 unwittingly become unlinked and different.  The second
6196                 is that <prgn>dpkg</prgn> might break the hard link
6197                 while upgrading <tt>conffile</tt>s.
6198               </p>
6199             </footnote>
6200             </p>
6201
6202             <p>
6203             The other way to do it is via the maintainer scripts.  In
6204             this case, the configuration file must not be listed as a
6205             <tt>conffile</tt> and must not be part of the package
6206             distribution. If the existence of a file is required for
6207             the package to be sensibly configured it is the
6208             responsibility of the package maintainer to provide
6209             maintainer scripts which correctly create, update and
6210             maintain the file and remove it on purge.  (See <ref
6211             id="maintainerscripts"> for more information.)  These
6212             scripts must be idempotent (i.e., must work correctly if
6213             <prgn>dpkg</prgn> needs to re-run them due to errors
6214             during installation or removal), must cope with all the
6215             variety of ways <prgn>dpkg</prgn> can call maintainer
6216             scripts, must not overwrite or otherwise mangle the user's
6217             configuration without asking, must not ask unnecessary
6218             questions (particularly during upgrades), and otherwise be
6219             good citizens.
6220           </p>
6221
6222           <p>
6223             The scripts are not required to configure every possible
6224             option for the package, but only those necessary to get
6225             the package running on a given system. Ideally the
6226             sysadmin should not have to do any configuration other
6227             than that done (semi-)automatically by the
6228             <prgn>postinst</prgn> script.
6229           </p>
6230
6231           <p>
6232             A common practice is to create a script called
6233             <file><var>package</var>-configure</file> and have the
6234             package's <prgn>postinst</prgn> call it if and only if the
6235             configuration file does not already exist.  In certain
6236             cases it is useful for there to be an example or template
6237             file which the maintainer scripts use.  Such files should
6238             be in <file>/usr/share/<var>package</var></file> or
6239             <file>/usr/lib/<var>package</var></file> (depending on whether
6240             they are architecture-independent or not).  There should
6241             be symbolic links to them from
6242             <file>/usr/share/doc/<var>package</var>/examples</file> if
6243             they are examples, and should be perfectly ordinary
6244             <prgn>dpkg</prgn>-handled files (<em>not</em>
6245             configuration files).
6246           </p>
6247
6248           <p>
6249             These two styles of configuration file handling must
6250             not be mixed, for that way lies madness:
6251             <prgn>dpkg</prgn> will ask about overwriting the file
6252             every time the package is upgraded.
6253           </p>
6254         </sect1>
6255
6256         <sect1>
6257           <heading>Sharing configuration files</heading>
6258           <p>
6259             Packages which specify the same file as a
6260             <tt>conffile</tt> must be tagged as <em>conflicting</em>
6261             with each other.  (This is an instance of the general rule
6262             about not sharing files.  Note that neither alternatives
6263             nor diversions are likely to be appropriate in this case;
6264             in particular, <prgn>dpkg</prgn> does not handle diverted
6265             <tt>conffile</tt>s well.)
6266           </p>
6267
6268           <p>
6269             The maintainer scripts must not alter a <tt>conffile</tt>
6270             of <em>any</em> package, including the one the scripts
6271             belong to.
6272           </p>
6273
6274           <p>
6275             If two or more packages use the same configuration file
6276             and it is reasonable for both to be installed at the same
6277             time, one of these packages must be defined as
6278             <em>owner</em> of the configuration file, i.e., it will be
6279             the package which handles that file as a configuration
6280             file.  Other packages that use the configuration file must
6281             depend on the owning package if they require the
6282             configuration file to operate. If the other package will
6283             use the configuration file if present, but is capable of
6284             operating without it, no dependency need be declared.</p>
6285
6286           <p>
6287             If it is desirable for two or more related packages to
6288             share a configuration file <em>and</em> for all of the
6289             related packages to be able to modify that configuration
6290             file, then the following should be done:
6291             <enumlist compact="compact">
6292               <item>
6293                 <p>
6294                   One of the related packages (the "owning" package)
6295                   will manage the configuration file with maintainer
6296                   scripts as described in the previous section.
6297                 </p>
6298               </item>
6299               <item>
6300                 <p>
6301                   The owning package should also provide a program
6302                   that the other packages may use to modify the
6303                   configuration file.
6304                 </p>
6305               </item>
6306               <item>
6307                 <p>
6308                   The related packages must use the provided program
6309                   to make any desired modifications to the
6310                   configuration file.  They should either depend on
6311                   the core package to guarantee that the configuration
6312                   modifier program is available or accept gracefully
6313                   that they cannot modify the configuration file if it
6314                   is not.  (This is in addition to the fact that the
6315                   configuration file may not even be present in the
6316                   latter scenario.)
6317                 </p>
6318               </item>
6319             </enumlist>
6320           </p>
6321
6322           <p>
6323             Sometimes it's appropriate to create a new package which
6324             provides the basic infrastructure for the other packages
6325             and which manages the shared configuration files.  (The
6326             <tt>sgml-base</tt> package is a good example.)
6327           </p>
6328         </sect1>
6329
6330         <sect1>
6331           <heading>User configuration files ("dotfiles")</heading>
6332
6333           <p>
6334             The files in <file>/etc/skel</file> will automatically be
6335             copied into new user accounts by <prgn>adduser</prgn>.
6336             No other program should reference the files in
6337             <file>/etc/skel</file>.
6338           </p>
6339
6340           <p>
6341             Therefore, if a program needs a dotfile to exist in
6342             advance in <file>$HOME</file> to work sensibly, that dotfile
6343             should be installed in <file>/etc/skel</file> and treated as a
6344             configuration file.
6345           </p>
6346
6347           <p>
6348             However, programs that require dotfiles in order to
6349             operate sensibly are a bad thing, unless they do create
6350             the dotfiles themselves automatically.
6351           </p>
6352
6353           <p>
6354             Furthermore, programs should be configured by the Debian
6355             default installation to behave as closely to the upstream
6356             default behaviour as possible.
6357           </p>
6358
6359           <p>
6360             Therefore, if a program in a Debian package needs to be
6361             configured in some way in order to operate sensibly, that
6362             should be done using a site-wide configuration file placed
6363             in <file>/etc</file>.  Only if the program doesn't support a
6364             site-wide default configuration and the package maintainer
6365             doesn't have time to add it may a default per-user file be
6366             placed in <file>/etc/skel</file>.
6367           </p>
6368
6369           <p>
6370             <file>/etc/skel</file> should be as empty as we can make it.
6371             This is particularly true because there is no easy (or
6372             necessarily desirable) mechanism for ensuring that the
6373             appropriate dotfiles are copied into the accounts of
6374             existing users when a package is installed.
6375           </p>
6376         </sect1>
6377       </sect>
6378
6379       <sect>
6380         <heading>Log files</heading>
6381         <p>
6382           Log files should usually be named
6383           <file>/var/log/<var>package</var>.log</file>.  If you have many
6384           log files, or need a separate directory for permission
6385           reasons (<file>/var/log</file> is writable only by
6386           <file>root</file>), you should usually create a directory named
6387           <file>/var/log/<var>package</var></file> and place your log
6388           files there.
6389         </p>
6390
6391         <p>
6392           Log files must be rotated occasionally so that they don't
6393           grow indefinitely; the best way to do this is to drop a log
6394           rotation configuration file into the directory
6395           <file>/etc/logrotate.d</file> and use the facilities provided by
6396           logrotate.<footnote>
6397             <p>
6398               The traditional approach to log files has been to set up
6399               <em>ad hoc</em> log rotation schemes using simple shell
6400               scripts and cron.  While this approach is highly
6401               customizable, it requires quite a lot of sysadmin work.
6402               Even though the original Debian system helped a little
6403               by automatically installing a system which can be used
6404               as a template, this was deemed not enough.
6405             </p>
6406
6407             <p>
6408               The use of <prgn>logrotate</prgn>, a program developed
6409               by Red Hat, is better, as it centralizes log management.
6410               It has both a configuration file
6411               (<file>/etc/logrotate.conf</file>) and a directory where
6412               packages can drop their individual log rotation
6413               configurations (<file>/etc/logrotate.d</file>).
6414             </p>
6415           </footnote>
6416           Here is a good example for a logrotate config
6417           file (for more information see <manref name="logrotate"
6418             section="8">):
6419           <example compact="compact">
6420 /var/log/foo/*.log {
6421 rotate 12
6422 weekly
6423 compress
6424 postrotate
6425 /etc/init.d/foo force-reload
6426 endscript
6427 }
6428           </example>
6429           This rotates all files under <file>/var/log/foo</file>, saves 12
6430           compressed generations, and forces the daemon to reload its
6431           configuration information after the log rotation.
6432         </p>
6433
6434         <p>
6435           Log files should be removed when the package is
6436           purged (but not when it is only removed).  This should be
6437           done by the <prgn>postrm</prgn> script when it is called
6438           with the argument <tt>purge</tt> (see <ref
6439           id="removedetails">).
6440         </p>
6441       </sect>
6442
6443       <sect>
6444         <heading>Permissions and owners</heading>
6445
6446         <p>
6447           The rules in this section are guidelines for general use.
6448           If necessary you may deviate from the details below.
6449           However, if you do so you must make sure that what is done
6450           is secure and you should try to be as consistent as possible
6451           with the rest of the system.  You should probably also
6452           discuss it on <prgn>debian-devel</prgn> first.
6453         </p>
6454
6455         <p>
6456           Files should be owned by <tt>root.root</tt>, and made
6457           writable only by the owner and universally readable (and
6458           executable, if appropriate), that is mode 644 or 755.
6459         </p>
6460
6461         <p>
6462           Directories should be mode 755 or (for group-writability)
6463           mode 2775.  The ownership of the directory should be
6464           consistent with its mode: if a directory is mode 2775, it
6465           should be owned by the group that needs write access to
6466           it.
6467         </p>
6468
6469         <p>
6470           Setuid and setgid executables should be mode 4755 or 2755
6471           respectively, and owned by the appropriate user or group.
6472           They should not be made unreadable (modes like 4711 or
6473           2711 or even 4111); doing so achieves no extra security,
6474           because anyone can find the binary in the freely available
6475           Debian package; it is merely inconvenient.  For the same
6476           reason you should not restrict read or execute permissions
6477           on non-set-id executables.
6478         </p>
6479
6480         <p>
6481           Some setuid programs need to be restricted to particular
6482           sets of users, using file permissions.  In this case they
6483           should be owned by the uid to which they are set-id, and by
6484           the group which should be allowed to execute them.  They
6485           should have mode 4754; again there is no point in making
6486           them unreadable to those users who must not be allowed to
6487           execute them.
6488         </p>
6489
6490         <p>
6491           It is possible to arrange that the system administrator can
6492           reconfigure the package to correspond to their local
6493           security policy by changing the permissions on a binary:
6494           they can do this by using <prgn>dpkg-statoverride</prgn>, as
6495           described below.<footnote>
6496             <p>
6497               Ordinary files installed by <prgn>dpkg</prgn> (as
6498               opposed to <tt>conffile</tt>s and other similar objects)
6499               normally have their permissions reset to the distributed
6500               permissions when the package is reinstalled.  However,
6501               the use of <prgn>dpkg-statoverride</prgn> overrides this
6502               default behaviour.  If you use this method, you should
6503               remember to describe <prgn>dpkg-statoverride</prgn> in
6504               the package documentation; being a relatively new
6505               addition to Debian, it is probably not yet well-known.
6506             </p>
6507           </footnote>
6508           Another method you should consider is to create a group for
6509           people allowed to use the program(s) and make any setuid
6510           executables executable only by that group.
6511         </p>
6512
6513         <p>
6514           If you need to create a new user or group for your package
6515           there are two possibilities.  Firstly, you may need to
6516           make some files in the binary package be owned by this
6517           user or group, or you may need to compile the user or
6518           group id (rather than just the name) into the binary
6519           (though this latter should be avoided if possible, as in
6520           this case you need a statically allocated id).</p>
6521
6522         <p>
6523           If you need a statically allocated id, you must ask for a
6524           user or group id from the <tt>base-passwd</tt> maintainer,
6525           and must not release the package until you have been
6526           allocated one.  Once you have been allocated one you must
6527           either make the package depend on a version of the
6528           <tt>base-passwd</tt> package with the id present in
6529           <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6530           your package to create the user or group itself with the
6531           correct id (using <tt>adduser</tt>) in its
6532           <prgn>preinst</prgn> or <prgn>postinst</prgn>.  (Doing it in
6533           the <prgn>postinst</prgn> is to be preferred if it is
6534           possible, otherwise a pre-dependency will be needed on the
6535           <tt>adduser</tt> package.)
6536         </p>
6537
6538         <p>
6539           On the other hand, the program might be able to determine
6540           the uid or gid from the user or group name at runtime, so
6541           that a dynamically allocated id can be used.  In this case
6542           you should choose an appropriate user or group name,
6543           discussing this on <prgn>debian-devel</prgn> and checking
6544           with the <package/base-passwd/ maintainer that it is unique and that
6545           they do not wish you to use a statically allocated id
6546           instead.  When this has been checked you must arrange for
6547           your package to create the user or group if necessary using
6548           <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6549           <prgn>postinst</prgn> script (again, the latter is to be
6550           preferred if it is possible).
6551         </p>
6552
6553         <p>
6554           Note that changing the numeric value of an id associated
6555           with a name is very difficult, and involves searching the
6556           file system for all appropriate files.  You need to think
6557           carefully whether a static or dynamic id is required, since
6558           changing your mind later will cause problems.
6559         </p>
6560
6561         <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6562           <p>
6563             This section is not intended as policy, but as a
6564             description of the use of <prgn>dpkg-statoverride</prgn>.
6565           </p>
6566
6567           <p>
6568             <prgn>dpkg-statoverride</prgn> is a replacement for the
6569             deprecated <tt>suidmanager</tt> package.  Packages which
6570             previously used <tt>suidmanager</tt> should have a
6571             <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6572             <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6573             and <tt>suidunregister</tt> should now be simply removed
6574             from the maintainer scripts.
6575           </p>
6576
6577           <p>
6578             If a system administrator wishes to have a file (or
6579             directory or other such thing) installed with owner and
6580             permissions different from those in the distributed Debian
6581             package, he can use the <prgn>dpkg-statoverride</prgn>
6582             program to instruct <prgn>dpkg</prgn> to use the different
6583             settings every time the file is installed.  Thus the
6584             package maintainer should distribute the files with their
6585             normal permissions, and leave it for the system
6586             administrator to make any desired changes.  For example, a
6587             daemon which is normally required to be setuid root, but
6588             in certain situations could be used without being setuid,
6589             should be installed setuid in the <tt>.deb</tt>.  Then the
6590             local system administrator can change this if they wish.
6591             If there are two standard ways of doing it, the package
6592             maintainer can use <tt>debconf</tt> to find out the
6593             preference, and call <prgn>dpkg-statoverride</prgn> in the
6594             maintainer script if necessary to accommodate the system
6595             administrator's choice.
6596           </p>
6597
6598           <p>
6599             Given the above, <prgn>dpkg-statoverride</prgn> is
6600             essentially a tool for system administrators and would not
6601             normally be needed in the maintainer scripts.  There is
6602             one type of situation, though, where calls to
6603             <prgn>dpkg-statoverride</prgn> would be needed in the
6604             maintainer scripts, and that involves packages which use
6605             dynamically allocated user or group ids.  In such a
6606             situation, something like the following idiom can be very
6607             helpful in the package's <prgn>postinst</prgn>, where
6608             <tt>sysuser</tt> is a dynamically allocated id:
6609             <example>
6610 for i in /usr/bin/foo /usr/sbin/bar
6611 do
6612   if ! dpkg-statoverride --list $i >/dev/null
6613   then
6614     dpkg-statoverride --update --add sysuser root 4755 $i
6615   fi
6616 done
6617             </example>
6618             The corresponding <tt>dpkg-statoverride --remove</tt>
6619             calls can then be made unconditionally when the package is
6620             purged.
6621           </p>
6622         </sect1>
6623       </sect>
6624     </chapt>
6625
6626     <chapt id="customized-programs">
6627       <heading>Customized programs</heading>
6628
6629       <sect id="arch-spec">
6630         <heading>Architecture specification strings</heading>
6631
6632         <p>
6633           If a program needs to specify an <em>architecture specification
6634             string</em> in some place, the following format should be
6635             used: <var>arch</var>-<var>os</var><footnote>
6636             <p>
6637               The following architectures and operating systems are
6638               currently recognised by <prgn>dpkg-archictecture</prgn>.
6639               The architecture, <tt><var>arch</var></tt>, is one of
6640               the following: <tt>alpha</tt>, <tt>arm</tt>,
6641               <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6642               <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6643               <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6644               <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>.  The
6645               operating system, <tt><var>os</var></tt>, is one of:
6646               <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6647               <tt>openbsd</tt>.  Use of <tt>gnu</tt> in this string is
6648               reserved for the GNU/Hurd operating system.
6649             </p>
6650           </footnote>.
6651         </p>
6652
6653         <p>
6654           Note that we don't want to use
6655           <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6656           <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6657           since this would make our programs incompatible with other
6658           Linux distributions.  We also don't use something like
6659           <tt><var>arch</var>-unknown-linux</tt>, since the
6660           <tt>unknown</tt> does not look very good.
6661         </p>
6662       </sect>
6663
6664       <sect>
6665         <heading>Daemons</heading>
6666
6667         <p>
6668           The configuration files <file>/etc/services</file>,
6669           <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6670           by the <prgn>netbase</prgn> package and must not be modified
6671           by other packages.
6672         </p>
6673
6674         <p>
6675           If a package requires a new entry in one of these files, the
6676           maintainer should get in contact with the
6677           <prgn>netbase</prgn> maintainer, who will add the entries
6678           and release a new version of the <prgn>netbase</prgn>
6679           package.
6680         </p>
6681
6682         <p>
6683           The configuration file <file>/etc/inetd.conf</file> must not be
6684           modified by the package's scripts except via the
6685           <prgn>update-inetd</prgn> script or the
6686           <file>DebianNet.pm</file> Perl module.  See their documentation
6687           for details on how to add entries.
6688         </p>
6689
6690         <p>
6691           If a package wants to install an example entry into
6692           <file>/etc/inetd.conf</file>, the entry must be preceded with
6693           exactly one hash character (<tt>#</tt>). Such lines are
6694           treated as "commented out by user" by the
6695           <prgn>update-inetd</prgn> script and are not changed or
6696           activated during package updates.
6697         </p>
6698       </sect>
6699
6700       <sect>
6701         <heading>Using pseudo-ttys and modifying wtmp, utmp and
6702         lastlog</heading>
6703
6704         <p>
6705           Some programs need to create pseudo-ttys. This should be done
6706           using Unix98 ptys if the C library supports it. The resulting
6707           program must not be installed setuid root, unless that
6708           is required for other functionality.
6709         </p>
6710
6711         <p>
6712           The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6713           <file>/var/log/lastlog</file> must be installed writeable by
6714           group <tt>utmp</tt>.  Programs which need to modify those
6715           files must be installed setgid <tt>utmp</tt>.
6716         </p>
6717       </sect>
6718
6719       <sect>
6720         <heading>Editors and pagers</heading>
6721
6722         <p>
6723           Some programs have the ability to launch an editor or pager
6724           program to edit or display a text document.  Since there are
6725           lots of different editors and pagers available in the Debian
6726           distribution, the system administrator and each user should
6727           have the possibility to choose his/her preferred editor and
6728           pager.
6729         </p>
6730
6731         <p>
6732           In addition, every program should choose a good default
6733           editor/pager if none is selected by the user or system
6734           administrator.
6735         </p>
6736
6737         <p>
6738           Thus, every program that launches an editor or pager must
6739           use the EDITOR or PAGER environment variable to determine
6740           the editor or pager the user wishes to use.  If these
6741           variables are not set, the programs <file>/usr/bin/editor</file>
6742           and <file>/usr/bin/pager</file> should be used, respectively.
6743         </p>
6744
6745         <p>
6746           These two files are managed through the <prgn>dpkg</prgn>
6747           "alternatives" mechanism.  Thus every package providing an
6748           editor or pager must call the
6749           <prgn>update-alternatives</prgn> script to register these
6750           programs.
6751         </p>
6752
6753         <p>
6754           If it is very hard to adapt a program to make use of the
6755           EDITOR or PAGER variables, that program may be configured to
6756           use <file>/usr/bin/sensible-editor</file> and
6757           <file>/usr/bin/sensible-pager</file> as the editor or pager
6758           program respectively.  These are two scripts provided in the
6759           Debian base system that check the EDITOR and PAGER variables
6760           and launch the appropriate program, and fall back to
6761           <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6762           variable is not set.
6763         </p>
6764
6765         <p>
6766           A program may also use the VISUAL environment variable to
6767           determine the user's choice of editor.  If it exists, it
6768           should take precedence over EDITOR.  This is in fact what
6769           <file>/usr/bin/sensible-editor</file> does.
6770         </p>
6771
6772         <p>
6773           It is not required for a package to depend on
6774           <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6775           package to provide such virtual packages.<footnote>
6776             <p>
6777               The Debian base system already provides an editor and a
6778               pager program,
6779             </p>
6780           </footnote>
6781         </p>
6782       </sect>
6783
6784       <sect id="web-appl">
6785         <heading>Web servers and applications</heading>
6786
6787         <p>
6788           This section describes the locations and URLs that should
6789           be used by all web servers and web applications in the
6790           Debian system.
6791         </p>
6792
6793         <p>
6794           <enumlist>
6795             <item>
6796               <p>
6797                 Cgi-bin executable files are installed in the
6798                 directory
6799                 <example compact="compact">
6800 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6801                 </example>
6802                 and should be referred to as
6803                 <example compact="compact">
6804 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6805                 </example>
6806               </p>
6807             </item>
6808
6809             <item><p>Access to HTML documents</p>
6810
6811               <p>
6812                 HTML documents for a package are stored in
6813                 <file>/usr/share/doc/<var>package</var></file>
6814                 and can be referred to as
6815                 <example compact="compact">
6816 http://localhost/doc/<var>package</var>/<var>filename</var>
6817                 </example>
6818               </p>
6819              <p>
6820                 The web server should restrict access to the document
6821                 tree so that only clients on the same host can read
6822                 the documents. If the web server does not support such
6823                 access controls, then it should not provide access at
6824                 all, or ask about providing access during installation.
6825               </p>
6826             </item>
6827
6828             <item><p>Web Document Root</p>
6829
6830               <p>
6831                 Web Applications should try to avoid storing files in
6832                 the Web Document Root.  Instead they should use the
6833                 /usr/share/doc/<var>package</var> directory for
6834                 documents and register the Web Application via the
6835                 menu package.  If access to the web document root is
6836                 unavoidable then use
6837                 <example compact="compact">
6838 /var/www
6839                 </example>
6840                 as the Document Root.  This might be just a symbolic
6841                 link to the location where the system administrator
6842                 has put the real document root.
6843               </p>
6844             </item>
6845
6846           </enumlist></p></sect>
6847
6848
6849       <sect id="mail-transport-agents">
6850         <heading>Mail transport, delivery and user agents</heading>
6851
6852         <p>
6853           Debian packages which process electronic mail, whether mail
6854           user agents (MUAs) or mail transport agents (MTAs), must
6855           ensure that they are compatible with the configuration
6856           decisions below.  Failure to do this may result in lost
6857           mail, broken <tt>From:</tt> lines, and other serious brain
6858           damage!
6859         </p>
6860
6861         <p>
6862           The mail spool is <file>/var/mail</file> and the interface to
6863           send a mail message is <file>/usr/sbin/sendmail</file> (as per
6864           the FHS).  On older systems, the mail spool may be
6865           physically located in <file>/var/spool/mail</file>, but all
6866           access to the mail spool should be via the
6867           <file>/var/mail</file> symlink.  The mail spool is part of the
6868           base system and not part of the MTA package.
6869         </p>
6870
6871         <p>
6872           All Debian MUAs, MTAs, MDAs and other mailbox accessing
6873           programs (such as IMAP daemons) must lock the mailbox in an
6874           NFS-safe way. This means that <tt>fcntl()</tt> locking must
6875           be combined with dot locking.  To avoid deadlocks, a program
6876           should use <tt>fcntl()</tt> first and dot locking after
6877           this, or alternatively implement the two locking methods in
6878           a non blocking way<footnote>
6879             <p>
6880               If it is not possible to establish both locks, the
6881               system shouldn't wait for the second lock to be
6882               established, but remove the first lock, wait a (random)
6883               time, and start over locking again.
6884             </p>
6885           </footnote>. Using the functions <tt>maillock</tt> and
6886           <tt>mailunlock</tt> provided by the
6887           <tt>liblockfile*</tt><footnote>
6888             <p>
6889               You will need to depend on <tt>liblockfile1
6890                 (&gt;&gt;1.01)</tt> to use these functions.
6891             </p>
6892           </footnote> packages is the recommended way to realize this.
6893         </p>
6894
6895         <p>
6896           Mailboxes are generally mode 660
6897           <tt><var>user</var>.mail</tt> unless the system
6898           administrator has chosen otherwise.  A MUA may remove a
6899           mailbox (unless it has nonstandard permissions) in which
6900           case the MTA or another MUA must recreate it if needed.
6901           Mailboxes must be writable by group mail.
6902         </p>
6903
6904         <p>
6905           The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6906           be setgid mail to do the locking mentioned above (and
6907           must obviously avoid accessing other users' mailboxes
6908           using this privilege).</p>
6909
6910         <p>
6911           <file>/etc/aliases</file> is the source file for the system mail
6912           aliases (e.g., postmaster, usenet, etc.), it is the one
6913           which the sysadmin and <prgn>postinst</prgn> scripts may
6914           edit.  After <file>/etc/aliases</file> is edited the program or
6915           human editing it must call <prgn>newaliases</prgn>.  All MTA
6916           packages must come with a <prgn>newaliases</prgn> program,
6917           even if it does nothing, but older MTA packages did not do
6918           this so programs should not fail if <prgn>newaliases</prgn>
6919           cannot be found.  Note that because of this, all MTA
6920           packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6921           <tt>Replaces: mail-transport-agent</tt> control file
6922           fields.
6923         </p>
6924
6925         <p>
6926           The convention of writing <tt>forward to
6927             <var>address</var></tt> in the mailbox itself is not
6928           supported.  Use a <tt>.forward</tt> file instead.</p>
6929
6930         <p>
6931           The <prgn>rmail</prgn> program used by UUCP
6932           for incoming mail should be  <file>/usr/sbin/rmail</file>.
6933           Likewise, <prgn>rsmtp</prgn>, for receiving
6934           batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6935           is supported.</p>
6936
6937         <p>
6938           If your package needs to know what hostname to use on (for
6939           example) outgoing news and mail messages which are generated
6940           locally, you should use the file <file>/etc/mailname</file>.  It
6941           will contain the portion after the username and <tt>@</tt>
6942           (at) sign for email addresses of users on the machine
6943           (followed by a newline).
6944         </p>
6945
6946         <p>
6947           Such package should check for the existence of this file
6948           when it is being configured.  If it exists, it should be
6949           used without comment, although an MTA's configuration script
6950           may wish to prompt the user even if it finds that this file
6951           exists.  If the file does not exist, the package should
6952           prompt the user for the value (preferably using
6953           <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6954           as well as using it in the package's configuration.  The
6955           prompt should make it clear that the name will not just be
6956           used by that package.  For example, in this situation the
6957           <tt>inn</tt> package could say something like:
6958           <example compact="compact">
6959 Please enter the "mail name" of your system.  This is the
6960 hostname portion of the address to be shown on outgoing
6961 news and mail messages.  The default is
6962 <var>syshostname</var>, your system's host name.  Mail
6963 name ["<var>syshostname</var>"]:
6964           </example>
6965           where <var>syshostname</var> is the output of <tt>hostname
6966             --fqdn</tt>.
6967         </p>
6968       </sect>
6969
6970       <sect>
6971         <heading>News system configuration</heading>
6972
6973         <p>
6974           All the configuration files related to the NNTP (news)
6975           servers and clients should be located under
6976           <file>/etc/news</file>.</p>
6977
6978         <p>
6979           There are some configuration issues that apply to a number
6980           of news clients and server packages on the machine. These
6981           are:
6982
6983           <taglist>
6984             <tag><file>/etc/news/organization</file></tag>
6985             <item><p>A string which should appear as the
6986                 organization header for all messages posted
6987                 by NNTP clients on the machine</p></item>
6988
6989             <tag><file>/etc/news/server</file></tag>
6990             <item><p>Contains the FQDN of the upstream NNTP
6991                 server, or localhost if the local machine is
6992                 an NNTP server.</p></item>
6993           </taglist>
6994
6995           Other global files may be added as required for cross-package news
6996           configuration.</p></sect>
6997
6998
6999       <sect>
7000         <heading>Programs for the X Window System</heading>
7001
7002         <sect1>
7003           <heading>Providing X support and package priorities</heading>
7004
7005           <p>
7006             Programs that can be configured with support for the X
7007             Window System must be configured to do so and must declare
7008             any package dependencies necessary to satisfy their
7009             runtime requirements when using the X Window System.  If
7010             such a package is of higher priority than the X packages
7011             on which it depends, it is required that either the
7012             X-specific components be split into a separate package, or
7013             that an alternative version of the package, which includes
7014             X support, be provided, or that the package's priority be
7015             lowered.
7016           </p>
7017         </sect1>
7018
7019         <sect1>
7020           <heading>Packages providing an X server</heading>
7021
7022           <p>
7023             Packages that provide an X server that, directly or
7024             indirectly, communicates with real input and display
7025             hardware should declare in their control data that they
7026             provide the virtual package <tt>xserver</tt>.<footnote>
7027               <p>
7028                 This implements current practice, and provides an
7029                 actual policy for usage of the <tt>xserver</tt>
7030                 virtual package which appears in the virtual packages
7031                 list.  In a nutshell, X servers that interface
7032                 directly with the display and input hardware or via
7033                 another subsystem (e.g., GGI) should provide
7034                 <tt>xserver</tt>.  Things like <tt>Xvfb</tt>,
7035                 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
7036               </p>
7037             </footnote>
7038           </p>
7039         </sect1>
7040
7041         <sect1>
7042           <heading>Packages providing a terminal emulator</heading>
7043
7044           <p>
7045             Packages that provide a terminal emulator for the X Window
7046             System which meet the criteria listed below should declare
7047             in their control data that they provide the virtual
7048             package <tt>x-terminal-emulator</tt>.  They should also
7049             register themselves as an alternative for
7050             <file>/usr/bin/x-terminal-emulator</file>, with a priority of
7051             20.
7052           </p>
7053
7054           <p>
7055             To be an <tt>x-terminal-emulator</tt>, a program must:
7056             <list compact="compact">
7057               <item><p>
7058                   Be able to emulate a DEC VT100 terminal, or a
7059                   compatible terminal.
7060                 </p></item>
7061
7062               <item><p>
7063                   Support the command-line option <tt>-e
7064                     <var>command</var></tt>, which creates a new
7065                   terminal window<footnote>
7066                     <p>
7067                       "New terminal window" does not necessarily mean
7068                       a new top-level X window directly parented by
7069                       the window manager; it could, if the terminal
7070                       emulator application were so coded, be a new
7071                       "view" in a multiple-document interface (MDI).
7072                     </p>
7073                   </footnote>
7074                   and runs the specified <var>command</var>.
7075                 </p></item>
7076
7077               <item><p>
7078                   Support the command-line option <tt>-T
7079                     <var>title</var></tt>, which creates a new terminal
7080                   window with the window title <var>title</var>.
7081                 </p></item>
7082             </list>
7083           </p>
7084         </sect1>
7085
7086         <sect1>
7087           <heading>Packages providing a window manager</heading>
7088
7089           <p>
7090             Packages that provide a window manager should declare in
7091             their control data that they provide the virtual package
7092             <tt>x-window-manager</tt>.  They should also register
7093             themselves as an alternative for
7094             <file>/usr/bin/x-window-manager</file>, with a priority
7095             calculated as follows:
7096             <list compact="compact">
7097               <item><p>Start with a priority of 20.</p></item>
7098
7099               <item>
7100                 <p>
7101                   If the window manager supports the Debian menu
7102                   system, add 20 points if this support is available
7103                   in the package's default configuration (i.e., no
7104                   configuration files belonging to the system or user
7105                   have to be edited to activate the feature); if
7106                   configuration files must be modified, add only 10
7107                   points.
7108                 </p>
7109               </item>
7110               <item>
7111                 <p>
7112                   If the window manager complies with  <url
7113                     id="http://www.freedesktop.org/standards/wm-spec.html"
7114                     name="The Window Manager Specification Project">,
7115                   written by the <url id="http://www.freedesktop.org"
7116                     name="Free Desktop Group">, add 20 points.
7117                 </p>
7118               </item>
7119
7120               <item>
7121                 <p>
7122                   If the window manager permits the X session to be
7123                   restarted using a <em>different</em> window manager
7124                   (without killing the X server) in its default
7125                   configuration, add 10 points; otherwise add none.
7126                 </p>
7127               </item>
7128             </list>
7129           </p>
7130         </sect1>
7131
7132         <sect1>
7133           <heading>Packages providing fonts</heading>
7134
7135           <p>
7136             Packages that provide fonts for the X Window
7137             System<footnote>
7138               <p>
7139                 For the purposes of Debian Policy, a "font for the X
7140                 Window System" is one which is accessed via X protocol
7141                 requests.  Fonts for the Linux console, for PostScript
7142                 renderers, or any other purpose, do not fit this
7143                 definition.  Any tool which makes such fonts available
7144                 to the X Window System, however, must abide by this
7145                 font policy.
7146               </p>
7147             </footnote>
7148             must do a number of things to ensure that they are both
7149             available without modification of the X or font server
7150             configuration, and that they do not corrupt files used by
7151             other font packages to register information about
7152             themselves.
7153             <enumlist>
7154               <item>
7155                 <p>
7156                   Fonts of any type supported by the X Window System
7157                   must be in a separate binary package from any
7158                   executables, libraries, or documentation (except
7159                   that specific to the fonts shipped, such as their
7160                   license information).  If one or more of the fonts
7161                   so packaged are necessary for proper operation of
7162                   the package with which they are associated the font
7163                   package may be Recommended; if the fonts merely
7164                   provide an enhancement, a Suggests relationship may
7165                   be used.  Packages must not Depend on font
7166                   packages.<footnote>
7167                     <p>
7168                       This is because the X server may retrieve fonts
7169                       from the local filesystem or over the network
7170                       from an X font server; the Debian package system
7171                       is empowered to deal only with the local
7172                       filesystem.
7173                     </p>
7174                   </footnote>
7175                 </p>
7176               </item>
7177
7178               <item>
7179                 <p>
7180                   BDF fonts must be converted to PCF fonts with the
7181                   <prgn>bdftopcf</prgn> utility (available in the
7182                   <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7183                   placed in a directory that corresponds to their
7184                   resolution:
7185                   <list compact="compact">
7186                     <item><p>
7187                         100 dpi fonts must be placed in
7188                         <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7189                       </p></item>
7190
7191                     <item><p>
7192                         75 dpi fonts must be placed in
7193                         <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7194                       </p></item>
7195
7196                     <item><p>
7197                         Character-cell fonts, cursor fonts, and other
7198                         low-resolution fonts must be placed in
7199                         <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7200                       </p></item>
7201                   </list>
7202                 </p>
7203               </item>
7204
7205               <item><p>
7206                   Speedo fonts must be placed in
7207                   <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7208                 </p></item>
7209
7210               <item><p>
7211                   Type 1 fonts must be placed in
7212                   <file>/usr/X11R6/lib/X11/fonts/Type1/</file>.  If font
7213                   metric files are available, they must be placed here
7214                   as well.
7215                 </p></item>
7216
7217               <item>
7218                 <p>
7219                   Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7220                   other than those listed above must be neither
7221                   created nor used.  (The <file>PEX</file>, <file>CID</file>,
7222                   and <file>cyrillic</file> directories are excepted for
7223                   historical reasons, but installation of files into
7224                   these directories remains discouraged.)
7225                 </p>
7226               </item>
7227
7228               <item>
7229                 <p>
7230                   Font packages may, instead of placing files directly
7231                   in the X font directories listed above, provide
7232                   symbolic links in that font directory pointing to
7233                   the files' actual location in the filesystem.  Such
7234                   a location must comply with the FHS.
7235                 </p>
7236               </item>
7237
7238               <item>
7239                 <p>
7240                   Font packages should not contain both 75dpi and
7241                   100dpi versions of a font.  If both are available,
7242                   they should be provided in separate binary packages
7243                   with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7244                   the names of the packages containing the
7245                   corresponding fonts.
7246                 </p>
7247               </item>
7248
7249               <item>
7250                 <p>
7251                   Fonts destined for the <file>misc</file> subdirectory
7252                   should not be included in the same package as 75dpi
7253                   or 100dpi fonts; instead, they should be provided in
7254                   a separate package with <tt>-misc</tt> appended to
7255                   its name.
7256                 </p>
7257               </item>
7258
7259               <item>
7260                 <p>
7261                   Font packages must not provide the files
7262                   <file>fonts.dir</file>, <file>fonts.alias</file>, or
7263                   <file>fonts.scale</file> in a font directory:
7264                   <list>
7265                     <item><p>
7266                         <file>fonts.dir</file> files must not be provided at all.
7267                       </p></item>
7268
7269                     <item>
7270                       <p>
7271                         <file>fonts.alias</file> and <file>fonts.scale</file>
7272                         files, if needed, should be provided in the
7273                         directory
7274                         <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7275                         where <var>fontdir</var> is the name of the
7276                         subdirectory of
7277                         <file>/usr/X11R6/lib/X11/fonts/</file> where the
7278                         package's corresponding fonts are stored
7279                         (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7280                         <var>package</var> is the name of the package
7281                         that provides these fonts, and
7282                         <var>extension</var> is either <tt>scale</tt>
7283                         or <tt>alias</tt>, whichever corresponds to
7284                         the file contents.
7285                       </p>
7286                     </item>
7287                   </list>
7288                 </p>
7289               </item>
7290
7291               <item>
7292                 <p>
7293                   Font packages must declare a dependency on
7294                   <tt>xutils (&gt;&gt; 4.0.3)</tt> in their control
7295                   data.
7296                 </p>
7297               </item>
7298
7299               <item>
7300                 <p>
7301                   Font packages that provide one or more
7302                   <file>fonts.scale</file> files as described above must
7303                   invoke <prgn>update-fonts-scale</prgn> on each
7304                   directory into which they installed fonts
7305                   <em>before</em> invoking
7306                   <prgn>update-fonts-dir</prgn> on that directory.
7307                   This invocation must occur in both the
7308                   <prgn>postinst</prgn> (for all arguments) and
7309                   <prgn>postrm</prgn> (for all arguments except
7310                   <tt>upgrade</tt>) scripts.
7311                 </p>
7312               </item>
7313
7314               <item>
7315                 <p>
7316                   Font packages that provide one or more
7317                   <file>fonts.alias</file> files as described above must
7318                   invoke <prgn>update-fonts-alias</prgn> on each
7319                   directory into which they installed fonts.  This
7320                   invocation must occur in both the
7321                   <prgn>postinst</prgn> (for all arguments) and
7322                   <prgn>postrm</prgn> (for all arguments except
7323                   <tt>upgrade</tt>) scripts.
7324                 </p>
7325               </item>
7326
7327               <item>
7328                 <p>
7329                   Font packages must invoke
7330                   <prgn>update-fonts-dir</prgn> on each directory into
7331                   which they installed fonts.  This invocation must
7332                   occur in both the <prgn>postinst</prgn> (for all
7333                   arguments) and <prgn>postrm</prgn> (for all
7334                   arguments except <tt>upgrade</tt>) scripts.
7335                 </p>
7336               </item>
7337
7338               <item>
7339                 <p>
7340                   Font packages must not provide alias names for the
7341                   fonts they include which collide with alias names
7342                   already in use by fonts already packaged.
7343                 </p>
7344               </item>
7345
7346               <item>
7347                 <p>
7348                   Font packages must not provide fonts with the same
7349                   XLFD registry name as another font already packaged.
7350                 </p>
7351               </item>
7352             </enumlist>
7353           </p>
7354         </sect1>
7355
7356         <sect1>
7357           <heading>Application defaults files</heading>
7358
7359           <p>
7360             Application defaults files must be installed in the
7361             directory <file>/etc/X11/app-defaults/</file> (use of a
7362             localized subdirectory of <file>/etc/X11/</file> as described
7363             in the <em>X Toolkit Intrinsics - C Language
7364             Interface</em> manual is also permitted).  They must be
7365             registered as <tt>conffile</tt>s or handled as
7366             configuration files.  Packages must not provide the
7367             directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7368           </p>
7369
7370           <p>
7371             Customization of programs' X resources may also be
7372             supported with the provision of a file with the same name
7373             as that of the package placed in the
7374             <file>/etc/X11/Xresources/</file> directory, which must
7375             registered as a <tt>conffile</tt> or handled as a
7376             configuration file.<footnote>
7377               <p>
7378                 Note that this mechanism is not the same as using
7379                 app-defaults; app-defaults are tied to the client
7380                 binary on the local filesystem, whereas X resources
7381                 are stored in the X server and affect all connecting
7382                 clients.
7383               </p>
7384             </footnote>
7385             <em>Important:</em> packages that install files into the
7386             <file>/etc/X11/Xresources/</file> directory must conflict with
7387             <tt>xbase (&lt;&lt; 3.3.2.3a-2)</tt>; if this is not done
7388             it is possible for the installing package to destroy a
7389             previously-existing <file>/etc/X11/Xresources</file> file
7390             which had been customized by the system administrator.
7391           </p>
7392         </sect1>
7393
7394         <sect1>
7395           <heading>Installation directory issues</heading>
7396
7397           <p>
7398             Packages using the X Window System should not be
7399             configured to install files under the <file>/usr/X11R6/</file>
7400             directory unless they use <prgn>imake</prgn>. The
7401             <file>/usr/X11R6/</file> directory hierarchy should be
7402             regarded as deprecated for all packages except the X
7403             Window System itself, and those which use the
7404             <prgn>imake</prgn> program it provides, in which case the
7405             packages may transition out of the <file>/usr/X11R6/</file>
7406             directory at the maintainer's discretion.<footnote>
7407               <p>
7408                 <prgn>Imake</prgn>-using programs are exempt because,
7409                 as long as they are written correctly, the pathnames
7410                 they use to locate resources and install themselves
7411                 are derived wholly from the X Window System
7412                 configuration.  Thus, in the event that the X Window
7413                 System moves to <file>/usr/X11R7/</file>,
7414                 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7415                 that is required for these programs is a recompile
7416                 against the corresponding X Window System library
7417                 development packages.
7418               </p>
7419             </footnote>
7420             Programs that use GNU <prgn>autoconf</prgn> and
7421             <prgn>automake</prgn> are usually easily configured at
7422             compile time to use <file>/usr/</file> instead of
7423             <file>/usr/X11R6/</file>, and this should be done whenever
7424             possible.  Configuration files for window managers and
7425             display managers should be placed in a subdirectory of
7426             <file>/etc/X11/</file> corresponding to the package name due
7427             to these programs' tight integration with the mechanisms
7428             of the X Window System.  Application-level programs should
7429             use the <file>/etc/</file> directory unless otherwise mandated
7430             by policy.  The installation of files into subdirectories
7431             of <file>/usr/X11R6/include/X11/</file> and
7432             <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7433             package maintainers should determine if subdirectories of
7434             <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7435             instead.  (The use of symbolic links from the
7436             <file>X11R6</file> directories to other FHS-compliant
7437             locations is encouraged if the program is not easily
7438             configured to look elsewhere for its files.)  Packages
7439             must not provide or install files into the directories
7440             <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7441             <file>/usr/lib/X11/</file>.  Files within a package should,
7442             however, make reference to these directories, rather than
7443             their <tt>X11R6</tt>-named counterparts
7444             <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7445             and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7446             referred to have not been moved to other FHS-compliant
7447             locations.
7448           </p>
7449         </sect1>
7450
7451         <sect1>
7452           <heading>The OSF/Motif and OpenMotif libraries</heading>
7453
7454           <p>
7455             <em>Programs that require the non-DFSG-compliant OSF/Motif or
7456               OpenMotif libraries</em><footnote>
7457               <p>
7458                 OSF/Motif and OpenMotif are collectively referred to as
7459                 "Motif" in this policy document.
7460               </p>
7461             </footnote>
7462             should be compiled against and tested with LessTif (a free
7463             re-implementation of Motif) instead.  If the maintainer
7464             judges that the program or programs do not work
7465             sufficiently well with LessTif to be distributed and
7466             supported, but do so when compiled against Motif, then two
7467             versions of the package should be created; one linked
7468             statically against Motif and with <tt>-smotif</tt>
7469             appended to the package name, and one linked dynamically
7470             against Motif and with <tt>-dmotif</tt> appended to the
7471             package name.  Both Motif-linked versions are dependent
7472             upon non-DFSG-compliant software and thus cannot be
7473             uploaded to the <em>main</em> distribution; if the
7474             software is itself DFSG-compliant it may be uploaded to
7475             the <em>contrib</em> distribution.  While known existing
7476             versions of Motif permit unlimited redistribution of
7477             binaries linked against the library (whether statically or
7478             dynamically), it is the package maintainer's
7479             responsibility to determine whether this is permitted by
7480             the license of the copy of Motif in his or her possession.
7481           </p>
7482         </sect1>
7483       </sect>
7484
7485       <sect>
7486         <heading>Perl programs and modules</heading>
7487
7488         <p>
7489           Perl programs and modules should follow the current Perl policy.
7490         </p>
7491
7492         <p>
7493           The Perl policy can be found in the <tt>perl-policy</tt>
7494           files in the <tt>debian-policy</tt> package.
7495           They are also available from the Debian web mirrors at
7496           <tt><url name="/doc/packaging-manuals/perl-policy/"
7497                 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>
7498           and from the Debian archive mirrors at
7499           <tt><url name="/doc/package-developer/perl-policy.txt.gz"
7500                 id="http://ftp.debian.org/debian/doc/package-developer/perl-policy.txt.gz"></tt>.
7501         </p>
7502       </sect>
7503
7504       <sect>
7505         <heading>Emacs lisp programs</heading>
7506
7507         <p>
7508           Please refer to the "Debian Emacs Policy" for details of how to
7509           package emacs lisp programs.
7510         </p>
7511
7512         <p>
7513           The Emacs policy is available in
7514           <file>debian-emacs-policy.gz</file> of the
7515           <package>emacsen-common</package> package.
7516           It is also available from the Debian web mirrors at
7517           <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
7518                 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
7519         </p>
7520       </sect>
7521
7522       <sect>
7523         <heading>Games</heading>
7524
7525         <p>
7526           The permissions on <file>/var/games</file> are mode 755, owner
7527           <tt>root</tt> and group <tt>root</tt>.
7528         </p>
7529
7530         <p>
7531           Each game decides on its own security policy.</p>
7532
7533         <p>
7534           Games which require protected, privileged access to
7535           high-score files, savegames, etc., may be made
7536           set-<em>group</em>-id (mode 2755) and owned by
7537           <tt>root.games</tt>, and use files and directories with
7538           appropriate permissions (770 <tt>root.games</tt>, for
7539           example).  They must not be made
7540           set-<em>user</em>-id, as this causes security problems. (If
7541           an attacker can subvert any set-user-id game they can
7542           overwrite the executable of any other, causing other players
7543           of these games to run a Trojan horse program.  With a
7544           set-group-id game the attacker only gets access to less
7545           important game data, and if they can get at the other
7546           players' accounts at all it will take considerably more
7547           effort.)</p>
7548
7549         <p>
7550           Some packages, for example some fortune cookie programs, are
7551           configured by the upstream authors to install with their
7552           data files or other static information made unreadable so
7553           that they can only be accessed through set-id programs
7554           provided.  You should not do this in a Debian package: anyone can
7555           download the <file>.deb</file> file and read the data from it,
7556           so there is no point making the files unreadable.  Not
7557           making the files unreadable also means that you don't have
7558           to make so many programs set-id, which reduces the risk of a
7559           security hole.</p>
7560
7561         <p>
7562           As described in the FHS, binaries of games should be
7563           installed in the directory <file>/usr/games</file>. This also
7564           applies to games that use the X Window System. Manual pages
7565           for games (X and non-X games) should be installed in
7566           <file>/usr/share/man/man6</file>.</p>
7567       </sect>
7568     </chapt>
7569
7570     <chapt id="docs"><heading>Documentation</heading>
7571
7572
7573       <sect>
7574         <heading>Manual pages</heading>
7575
7576         <p>
7577           You should install manual pages in <prgn>nroff</prgn> source
7578           form, in appropriate places under <file>/usr/share/man</file>.
7579           You should only use sections 1 to 9 (see the FHS for more
7580           details).  You must not install a preformatted "cat page".
7581         </p>
7582
7583         <p>
7584           Each program, utility, and function should have an
7585           associated manual page included in the same package. It is
7586           suggested that all configuration files also have a manual
7587           page included as well. Manual pages for protocols and other
7588           auxiliary things are optional.
7589         </p>
7590
7591         <p>
7592           If no manual page is available, this is considered as a bug
7593           and should be reported to the Debian Bug Tracking System (the
7594           maintainer of the package is allowed to write this bug report
7595           themselves, if they so desire).  Do not close the bug report
7596           until a proper manpage is available.<footnote>
7597             <p>
7598               It is not very hard to write a man page. See the 
7599               <url id="http://www.schweikhardt.net/man_page_howto.html"
7600                 name="Man-Page-HOWTO">, 
7601               <manref name="man" section="7">, the examples
7602               created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7603               the helper programs <prgn>help2man</prgn>, or the
7604               directory <file>/usr/share/doc/man-db/examples</file>.
7605             </p>
7606           </footnote>
7607         </p>
7608
7609         <p>
7610           You may forward a complaint about a missing manpage to the
7611           upstream authors, and mark the bug as forwarded in the
7612           Debian bug tracking system.  Even though the GNU Project do
7613           not in general consider the lack of a manpage to be a bug,
7614           we do; if they tell you that they don't consider it a bug
7615           you should leave the bug in our bug tracking system open
7616           anyway.
7617         </p>
7618
7619         <p>
7620           Manual pages should be installed compressed using <tt>gzip -9</tt>.
7621         </p>
7622
7623         <p>
7624           If one manpage needs to be accessible via several names it
7625           is better to use a symbolic link than the <file>.so</file>
7626           feature, but there is no need to fiddle with the relevant
7627           parts of the upstream source to change from <file>.so</file> to
7628           symlinks: don't do it unless it's easy.  You should not
7629           create hard links in the manual page directories, nor put
7630           absolute filenames in <file>.so</file> directives.  The filename
7631           in a <file>.so</file> in a manpage should be relative to the
7632           base of the manpage tree (usually
7633           <file>/usr/share/man</file>). If you do not create any links
7634           (whether symlinks, hard links, or <tt>.so</tt> directives)
7635           in the filesystem to the alternate names of the manpage,
7636           then you should not rely on <prgn>man</prgn> finding your
7637           manpage under those names based solely on the information in
7638           the manpage's header.<footnote>
7639             <p>
7640               Supporting this in <prgn>man</prgn> often requires
7641               unreasonable processing time to find a manual page or to
7642               report that none exists, and moves knowledge into man's
7643               database that would be better left in the filesystem.
7644               This support is therefore deprecated and will cease to
7645               be present in the future.
7646             </p>
7647           </footnote>
7648         </p>
7649       </sect>
7650
7651       <sect>
7652         <heading>Info documents</heading>
7653
7654         <p>
7655           Info documents should be installed in <file>/usr/share/info</file>.
7656           They should be compressed with <tt>gzip -9</tt>.
7657         </p>
7658
7659         <p>
7660           Your package should call <prgn>install-info</prgn> to update
7661           the Info <file>dir</file> file in its <prgn>postinst</prgn>
7662           script when called with a <tt>configure</tt> argument, for
7663           example:
7664           <example compact="compact">
7665 install-info --quiet --section Development Development \
7666   /usr/share/info/foobar.info
7667           </example></p>
7668
7669         <p>
7670           It is a good idea to specify a section for the location of
7671           your program; this is done with the <tt>--section</tt>
7672           switch.  To determine which section to use, you should look
7673           at <file>/usr/share/info/dir</file> on your system and choose the most
7674           relevant (or create a new section if none of the current
7675           sections are relevant).  Note that the <tt>--section</tt>
7676           flag takes two arguments; the first is a regular expression
7677           to match (case-insensitively) against an existing section,
7678           the second is used when creating a new one.</p>
7679
7680         <p>
7681           You should remove the entries in the <prgn>prerm</prgn>
7682           script when called with a <tt>remove</tt> argument:
7683           <example compact="compact">
7684 install-info --quiet --remove /usr/share/info/foobar.info
7685           </example></p>
7686
7687         <p>
7688           If <prgn>install-info</prgn> cannot find a description entry
7689           in the Info file you must supply one.  See <manref
7690           name="install-info" section="8"> for details.</p>
7691       </sect>
7692
7693       <sect>
7694         <heading>Additional documentation</heading>
7695
7696         <p>
7697           Any additional documentation that comes with the package may
7698           be installed at the discretion of the package maintainer.
7699           Text documentation should be installed in the directory
7700           <file>/usr/share/doc/<var>package</var></file>, where
7701           <var>package</var> is the name of the package, and
7702           compressed with <tt>gzip -9</tt> unless it is small.
7703         </p>
7704
7705         <p>
7706           If a package comes with large amounts of documentation which
7707           many users of the package will not require you should create
7708           a separate binary package to contain it, so that it does not
7709           take up disk space on the machines of users who do not need
7710           or want it installed.</p>
7711
7712         <p>
7713           It is often a good idea to put text information files
7714           (<file>README</file>s, changelogs, and so forth) that come with
7715           the source package in <file>/usr/share/doc/<var>package</var></file>
7716           in the binary package.  However, you don't need to install
7717           the instructions for building and installing the package, of
7718           course!</p>
7719
7720         <p>
7721           Packages must not require the existance of any files in
7722           <file>/usr/share/doc/</file> in order to function
7723           <footnote>
7724             <p>
7725               The system administrator should be able to
7726               delete files in <file>/usr/share/doc/</file> without causing
7727               any programs to break.
7728             </p>
7729           </footnote>.
7730           Any files that are referenced by programs but are also
7731           useful as standalone documentation should be installed under
7732           <file>/usr/share/<var>package</var>/</file> with symbolic links from
7733           <file>/usr/share/doc/<var>package</var></file>.
7734         </p>
7735
7736         <p>
7737           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7738           link to another directory in <file>/usr/share/doc</file> only if
7739           the two packages both come from the same source and the
7740           first package Depends on the second.
7741         </p>
7742
7743         <p>
7744           Former Debian releases placed all additional documentation
7745           in <file>/usr/doc/<var>package</var></file>.  This has been
7746           changed to <file>/usr/share/doc/<var>package</var></file>,
7747           and packages must not put documentation in the directory
7748           <file>/usr/doc/<var>package</var></file>. <footnote>
7749             <p>At this phase of the transition, we no longer require a
7750             symbolic link in <file>/usr/doc/</file>. At a later point,
7751             policy shall change to make the symbolic links a bug.</p>
7752           </footnote>
7753         </p>
7754       </sect>
7755
7756       <sect>
7757         <heading>Preferred documentation formats</heading>
7758
7759         <p>
7760           The unification of Debian documentation is being carried out
7761           via HTML.</p>
7762
7763         <p>
7764           If your package comes with extensive documentation in a
7765           markup format that can be converted to various other formats
7766           you should if possible ship HTML versions in a binary
7767           package, in the directory
7768           <file>/usr/share/doc/<var>appropriate-package</var></file> or
7769           its subdirectories.<footnote>
7770             <p>
7771               The rationale: The important thing here is that HTML
7772               docs should be available in <em>some</em> package, not
7773               necessarily in the main binary package.
7774             </p>
7775           </footnote>
7776         </p>
7777
7778         <p>
7779           Other formats such as PostScript may be provided at the
7780           package maintainer's discretion.
7781         </p>
7782       </sect>
7783
7784       <sect id="copyrightfile">
7785         <heading>Copyright information</heading>
7786
7787         <p>
7788           Every package must be accompanied by a verbatim copy of its
7789           copyright and distribution license in the file
7790           <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7791           file must neither be compressed nor be a symbolic link.
7792         </p>
7793
7794         <p>
7795           In addition, the copyright file must say where the upstream
7796           sources (if any) were obtained.  It should name the original
7797           authors of the package and the Debian maintainer(s) who were
7798           involved with its creation.</p>
7799
7800         <p>
7801           A copy of the file which will be installed in
7802           <file>/usr/share/doc/<var>package</var>/copyright</file> should
7803           be in <file>debian/copyright</file> in the source package.
7804         </p>
7805
7806         <p>
7807           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7808           link to another directory in <file>/usr/share/doc</file> only if
7809           the two packages both come from the same source and the
7810           first package Depends on the second.  These rules are
7811           important because copyrights must be extractable by
7812           mechanical means.
7813         </p>
7814
7815         <p>
7816           Packages distributed under the UCB BSD license, the Artistic
7817           license, the GNU GPL, and the GNU LGPL should refer to the
7818           files <file>/usr/share/common-licenses/BSD</file>,
7819           <file>/usr/share/common-licenses/Artistic</file>,
7820           <file>/usr/share/common-licenses/GPL</file>, and
7821           <file>/usr/share/common-licenses/LGPL</file> respectively,
7822           rather than quoting them in the copyright file.
7823         </p>
7824
7825         <p>
7826           You should not use the copyright file as a general <file>README</file>
7827           file.  If your package has such a file it should be
7828           installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7829           <file>README.Debian</file> or some other appropriate place.</p>
7830       </sect>
7831
7832       <sect>
7833         <heading>Examples</heading>
7834
7835         <p>
7836           Any examples (configurations, source files, whatever),
7837           should be installed in a directory
7838           <file>/usr/share/doc/<var>package</var>/examples</file>.  These
7839           files should not be referenced by any program: they're there
7840           for the benefit of the system administrator and users as
7841           documentation only.  Architecture-specific example files
7842           should be installed in a directory
7843           <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7844           links to them from
7845           <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7846           latter directory itself may be a symbolic link to the
7847           former.
7848         </p>
7849
7850         <p>
7851           If the purpose of a package is to provide examples, then the
7852           example files may be installed into
7853           <file>/usr/share/doc/<var>package</var></file>.
7854         </p>
7855       </sect>
7856
7857       <sect id="changelogs">
7858         <heading>Changelog files</heading>
7859
7860         <p>
7861           The Debian changelog file (<file>debian/changelog</file>) should
7862           explain briefly what modifications were made in the Debian version
7863           of the package compared to the upstream one. Other changes and
7864           updates to the package should also be documented in this file.
7865         </p>
7866
7867         <p>
7868           Mistakes in changelogs are usually best rectified by
7869           making a new changelog entry rather than "rewriting history"
7870           by editing old changelog entries.
7871         </p>
7872
7873         <p>
7874           The format of the <file>debian/changelog</file> file is described
7875           in <ref id="dpkgchangelog">. In non-experimental packages you must
7876           use a format for <file>debian/changelog</file> which is supported
7877           by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7878             <p>
7879               If you wish to use an alternative format, you may do so as
7880               long as you include a parser for it in your source package.
7881               The parser must have an API compatible with that expected by
7882               <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7883               If there is general interest in the new format, you should
7884               contact the <package>dpkg</package> maintainer to have the
7885               parser script for it included in the <prgn>dpkg</prgn>
7886               package.  (You will need to agree that the parser and its
7887               manpage may be distributed under the GNU GPL, just as the rest
7888               of <prgn>dpkg</prgn> is.)
7889             </p>
7890           </footnote>
7891         </p>
7892
7893         <p>
7894           Packages that are not Debian-native must contain a
7895           compressed copy of the <file>debian/changelog</file> file from
7896           the Debian source tree in
7897           <file>/usr/share/doc/<var>package</var></file> with the name
7898           <file>changelog.Debian.gz</file>.
7899         </p>
7900
7901         <p>
7902           If an upstream changelog is available, it should be accessible as
7903           <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7904           plain text.  If the upstream changelog is distributed in
7905           HTML, it should be made available in that form as
7906           <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7907           and a plain text <file>changelog.gz</file> should be generated
7908           from it using, for example, <tt>lynx -dump -nolist</tt>.  If
7909           the upstream changelog files do not already conform to this
7910           naming convention, then this may be achieved either by
7911           renaming the files, or by adding a symbolic link, at the
7912           maintainer's discretion.<footnote>
7913             <p>
7914               Rationale: People should not have to look in places for
7915               upstream changelogs merely because they are given
7916               different names or are distributed in HTML format.
7917             </p>
7918           </footnote>
7919         </p>
7920
7921         <p>
7922           All of these files should be installed compressed using
7923           <tt>gzip -9</tt>, as they will become large with time even
7924           if they start out small.
7925         </p>
7926
7927         <p>
7928           If the package has only one changelog which is used both as
7929           the Debian changelog and the upstream one because there is
7930           no separate upstream maintainer then that changelog should
7931           usually be installed as
7932           <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7933           there is a separate upstream maintainer, but no upstream
7934           changelog, then the Debian changelog should still be called
7935           <file>changelog.Debian.gz</file>.</p>
7936
7937       </sect>
7938     </chapt>
7939
7940     <appendix id="pkg-scope">
7941       <heading>Introduction and scope of these appendices</heading>
7942
7943       <p>
7944         These appendices are taken essentially verbatim from the
7945         now-deprecated Packaging Manual, version 3.2.1.0.  They are
7946         the chapters which are likely to be of use to package
7947         maintainers and which have not already been included in the
7948         policy document itself. Most of these sections are very likely
7949         not relevant to policy; they should be treated as
7950         documentation for the packaging system. Please note that these
7951         appendices are included for convenience, and for historical
7952         reasons: they used to be part of policy package, and they have
7953         not yet been incorporated into dpkg documentation. However,
7954         they still have value, and hence they are presented here.
7955       </p>
7956       <p>
7957         They have not yet been checked to ensure that they are
7958         compatible with the contents of policy, and if there are any
7959         contradictions, the version in the main policy document takes
7960         precedence.  The remaining chapters of the old Packaging
7961         Manual have also not been read in detail to ensure that there
7962         are not parts which have been left out.  Both of these will be
7963         done in due course.
7964       </p>
7965
7966       <p>
7967         <prgn>dpkg</prgn> is a suite of programs for creating binary
7968         package files and installing and removing them on Unix
7969         systems.<footnote>
7970           <p>
7971             <prgn>dpkg</prgn> is targetted primarily at Debian
7972             GNU/Linux, but may work on or be ported to other
7973             systems.
7974           </p>
7975         </footnote>
7976       </p>
7977
7978       <p>
7979         The binary packages are designed for the management of
7980         installed executable programs (usually compiled binaries) and
7981         their associated data, though source code examples and
7982         documentation are provided as part of some packages.</p>
7983
7984       <p>
7985         This manual describes the technical aspects of creating Debian
7986         binary packages (<file>.deb</file> files).  It documents the
7987         behaviour of the package management programs
7988         <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7989         they interact with packages.</p>
7990
7991       <p>
7992         It also documents the interaction between
7993         <prgn>dselect</prgn>'s core and the access method scripts it
7994         uses to actually install the selected packages, and describes
7995         how to create a new access method.</p>
7996
7997       <p>
7998         This manual does not go into detail about the options and
7999         usage of the package building and installation tools.  It
8000         should therefore be read in conjuction with those programs'
8001         manpages.
8002       </p>
8003
8004       <p>
8005         The utility programs which are provided with <prgn>dpkg</prgn>
8006         for managing various system configuration and similar issues,
8007         such as <prgn>update-rc.d</prgn> and
8008         <prgn>install-info</prgn>, are not described in detail here -
8009         please see their manpages.
8010       </p>
8011
8012       <p>
8013         It is assumed that the reader is reasonably familiar with the
8014         <prgn>dpkg</prgn> System Administrators' manual.
8015         Unfortunately this manual does not yet exist.
8016       </p>
8017
8018       <p>
8019         The Debian version of the FSF's GNU hello program is provided
8020         as an example for people wishing to create Debian
8021         packages. The Debian <prgn>debmake</prgn> package is
8022         recommended as a very helpful tool in creating and maintaining
8023         Debian packages. However, while the tools and examples are
8024         helpful, they do not replace the need to read and follow the
8025         Policy and Programmer's Manual.</p>
8026     </appendix>
8027
8028     <appendix id="pkg-binarypkg"><heading>Binary packages (from old
8029     Packaging Manual)
8030       </heading>
8031
8032       <p>
8033         The binary package has two main sections.  The first part
8034         consists of various control information files and scripts used
8035         by <prgn>dpkg</prgn> when installing and removing.  See <ref
8036         id="pkg-controlarea">.
8037       </p>
8038
8039       <p>
8040         The second part is an archive containing the files and
8041         directories to be installed.
8042       </p>
8043
8044       <p>
8045         In the future binary packages may also contain other
8046         components, such as checksums and digital signatures. The
8047         format for the archive is described in full in the
8048         <file>deb(5)</file> manpage.
8049       </p>
8050
8051
8052       <sect id="pkg-bincreating"><heading>Creating package files -
8053       <prgn>dpkg-deb</prgn>
8054         </heading>
8055
8056         <p>
8057           All manipulation of binary package files is done by
8058           <prgn>dpkg-deb</prgn>; it's the only program that has
8059           knowledge of the format.  (<prgn>dpkg-deb</prgn> may be
8060           invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
8061           will spot that the options requested are appropriate to
8062           <prgn>dpkg-deb</prgn> and invoke that instead with the same
8063           arguments.)
8064         </p>
8065
8066         <p>
8067           In order to create a binary package you must make a
8068           directory tree which contains all the files and directories
8069           you want to have in the filesystem data part of the package.
8070           In Debian-format source packages this directory is usually
8071           <file>debian/tmp</file>, relative to the top of the package's
8072           source tree.
8073         </p>
8074
8075         <p>
8076           They should have the locations (relative to the root of the
8077           directory tree you're constructing) ownerships and
8078           permissions which you want them to have on the system when
8079           they are installed.
8080         </p>
8081
8082         <p>
8083           With current versions of <prgn>dpkg</prgn> the uid/username
8084           and gid/groupname mappings for the users and groups being
8085           used should be the same on the system where the package is
8086           built and the one where it is installed.
8087         </p>
8088
8089         <p>
8090           You need to add one special directory to the root of the
8091           miniature filesystem tree you're creating:
8092           <prgn>DEBIAN</prgn>.  It should contain the control
8093           information files, notably the binary package control file
8094           (see <ref id="pkg-controlfile">).
8095         </p>
8096
8097         <p>
8098           The <prgn>DEBIAN</prgn> directory will not appear in the
8099           filesystem archive of the package, and so won't be installed
8100           by <prgn>dpkg</prgn> when the package is installed.
8101         </p>
8102
8103         <p>
8104           When you've prepared the package, you should invoke:
8105           <example>
8106   dpkg --build <var>directory</var>
8107           </example>
8108         </p>
8109
8110         <p>
8111           This will build the package in
8112           <file><var>directory</var>.deb</file>.  (<prgn>dpkg</prgn> knows
8113           that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8114           it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8115           build the package.)
8116         </p>
8117
8118         <p>
8119           See the manpage <manref name="dpkg-deb" section="8"> for details of how
8120           to examine the contents of this newly-created file.  You may find the
8121           output of following commands enlightening:
8122           <example>
8123   dpkg-deb --info <var>filename</var>.deb
8124   dpkg-deb --contents <var>filename</var>.deb
8125   dpkg --contents <var>filename</var>.deb
8126           </example>
8127           To view the copyright file for a package you could use this command:
8128           <example>
8129   dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8130           </example>
8131         </p>
8132       </sect>
8133
8134       <sect id="pkg-controlarea">
8135         <heading>
8136           Package control information files
8137         </heading>
8138
8139         <p>
8140           The control information portion of a binary package is a
8141           collection of files with names known to <prgn>dpkg</prgn>.
8142           It will treat the contents of these files specially - some
8143           of them contain information used by <prgn>dpkg</prgn> when
8144           installing or removing the package; others are scripts which
8145           the package maintainer wants <prgn>dpkg</prgn> to run.
8146         </p>
8147
8148         <p>
8149           It is possible to put other files in the package control
8150           area, but this is not generally a good idea (though they
8151           will largely be ignored).
8152         </p>
8153
8154         <p>
8155           Here is a brief list of the control info files supported by
8156           <prgn>dpkg</prgn> and a summary of what they're used for.
8157         </p>
8158
8159         <p>
8160           <taglist>
8161             <tag><tt>control</tt>
8162             <item>
8163
8164               <p>
8165                 This is the key description file used by
8166                 <prgn>dpkg</prgn>.  It specifies the package's name
8167                 and version, gives its description for the user,
8168                 states its relationships with other packages, and so
8169                 forth.  See <ref id="pkg-controlfile">.
8170               </p>
8171
8172               <p>
8173                 It is usually generated automatically from information
8174                 in the source package by the
8175                 <prgn>dpkg-gencontrol</prgn> program, and with
8176                 assistance from <prgn>dpkg-shlibdeps</prgn>.  See <ref
8177                 id="pkg-sourcetools">.</p>
8178             </item>
8179
8180             <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8181             <tt>prerm</tt>
8182             </tag>
8183             <item>
8184
8185               <p>
8186                 These are exectuable files (usually scripts) which
8187                 <prgn>dpkg</prgn> runs during installation, upgrade
8188                 and removal of packages.  They allow the package to
8189                 deal with matters which are particular to that package
8190                 or require more complicated processing than that
8191                 provided by <prgn>dpkg</prgn>.  Details of when and
8192                 how they are called are in <ref
8193                 id="maintainerscripts">.
8194               </p>
8195
8196               <p>
8197                 It is very important to make these scripts
8198                 idempotent.
8199                 <footnote>
8200                   <p>
8201                     That means that if it runs successfully or fails
8202                     and then you call it again it doesn't bomb out,
8203                     but just ensures that everything is the way it
8204                     ought to be.
8205                   </p>
8206                 </footnote> This is so that if an error occurs, the
8207                 user interrupts <prgn>dpkg</prgn> or some other
8208                 unforeseen circumstance happens you don't leave the
8209                 user with a badly-broken package.
8210               </p>
8211
8212               <p>
8213                 The maintainer scripts are guaranteed to run with a
8214                 controlling terminal and can interact with the user.
8215                 If they need to prompt for passwords, do full-screen
8216                 interaction or something similar you should do these
8217                 things to and from <file>/dev/tty</file>, since
8218                 <prgn>dpkg</prgn> will at some point redirect scripts'
8219                 standard input and output so that it can log the
8220                 installation process.  Likewise, because these scripts
8221                 may be executed with standard output redirected into a
8222                 pipe for logging purposes, Perl scripts should set
8223                 unbuffered output by setting <tt>$|=1</tt> so that the
8224                 output is printed immediately rather than being
8225                 buffered.
8226               </p>
8227
8228               <p>
8229                 Each script should return a zero exit status for
8230                 success, or a nonzero one for failure.</p>
8231             </item>
8232
8233             <tag><tt>conffiles</tt>
8234             </tag>
8235             <item>
8236
8237               <p>
8238                 This file contains a list of configuration files which
8239                 are to be handled automatically by <prgn>dpkg</prgn>
8240                 (see <ref id="pkg-conffiles">).  Note that not necessarily
8241                 every configuration file should be listed here.</p>
8242             </item>
8243
8244             <tag><tt>shlibs</tt>
8245             </tag>
8246             <item>
8247
8248               <p>
8249                 This file contains a list of the shared libraries
8250                 supplied by the package, with dependency details for
8251                 each.  This is used by <prgn>dpkg-shlibdeps</prgn>
8252                 when it determines what dependencies are required in a
8253                 package control file. The <tt>shlibs</tt> file format
8254                 is described on <ref id="shlibs">.
8255               </p>
8256             </item>
8257           </taglist>
8258         </p>
8259
8260       <sect id="pkg-controlfile">
8261         <heading>
8262           The main control information file: <tt>control</tt>
8263         </heading>
8264         <p>
8265           The most important control information file used by
8266           <prgn>dpkg</prgn> when it installs a package is
8267           <tt>control</tt>.  It contains all the package"s "vital
8268           statistics".
8269         </p>
8270
8271         <p>
8272           The binary package control files of packages built from
8273           Debian sources are made by a special tool,
8274           <prgn>dpkg-gencontrol</prgn>, which reads
8275           <file>debian/control</file> and <file>debian/changelog</file> to
8276           find the information it needs.  See <ref id="pkg-sourcepkg"> for
8277           more details.
8278         </p>
8279
8280         <p>
8281           The fields in binary package control files are:
8282           <list compact="compact">
8283             <item>
8284               <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8285             </item>
8286             <item>
8287               <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8288             </item>
8289             <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8290                 (mandatory)
8291                 <footnote>
8292                   <p>
8293                     This field should appear in all packages, though
8294                     <prgn>dpkg</prgn> doesn't require it yet so that
8295                     old packages can still be installed.
8296                   </p>
8297                 </footnote>
8298               </p>
8299             </item>
8300             <item>
8301               <p><qref id="relationships"><tt>Depends</tt>,
8302                   <tt>Provides</tt> et al.</qref></p>
8303             </item>
8304             <item>
8305               <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8306             </item>
8307             <item>
8308               <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8309             </item>
8310             <item>
8311               <p><qref id="pkg-f-classification"><tt>Section</tt>,
8312                   <tt>Priority</tt></qref></p>
8313             </item>
8314             <item>
8315               <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8316             </item>
8317             <item>
8318               <p><qref id="descriptions"><tt>Description</tt></qref></p>
8319             </item>
8320             <item>
8321               <p>
8322                 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8323               </p>
8324             </item>
8325           </list>
8326
8327         <p>
8328           A description of the syntax of control files and the purpose
8329           of these fields is available in <ref id="pkg-controlfields">.
8330         </p>
8331       </sect>
8332
8333       <sect>
8334         <heading>Time Stamps</heading>
8335         <p>
8336           Maintainers are encouraged to preserve the modification
8337           times of the upstream source files in a package, as far as
8338           is reasonably possible.
8339           <footnote>
8340             <p>
8341               The rationale is that there is some information conveyed
8342               by knowing the age of the file, for example, you could
8343               recognize that some documentation is very old by looking
8344               at the modification time, so it would be nice if the
8345               modification time of the upstream source would be
8346               preserved.
8347             </p>
8348           </footnote>
8349         </p>
8350       </sect>
8351     </appendix>
8352
8353     <appendix id="pkg-sourcepkg">
8354       <heading>Source packages (from old Packaging Manual) </heading>
8355
8356       <p>
8357         The Debian binary packages in the distribution are generated
8358         from Debian sources, which are in a special format to assist
8359         the easy and automatic building of binaries.
8360       </p>
8361
8362       <sect id="pkg-sourcetools">
8363         <heading>Tools for processing source packages</heading>
8364
8365         <p>
8366           Various tools are provided for manipulating source packages;
8367           they pack and unpack sources and help build of binary
8368           packages and help manage the distribution of new versions.
8369         </p>
8370
8371         <p>
8372           They are introduced and typical uses described here; see
8373           <manref name="dpkg-source" section="1"> for full
8374           documentation about their arguments and operation.
8375         </p>
8376
8377         <p>
8378           For examples of how to construct a Debian source package,
8379           and how to use those utilities that are used by Debian
8380           source packages, please see the <prgn>hello</prgn> example
8381           package.
8382         </p>
8383
8384         <sect1>
8385           <heading>
8386             <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8387             packages
8388           </heading>
8389
8390           <p>
8391             This program is frequently used by hand, and is also
8392             called from package-independent automated building scripts
8393             such as <prgn>dpkg-buildpackage</prgn>.
8394           </p>
8395
8396           <p>
8397             To unpack a package it is typically invoked with
8398             <example>
8399   dpkg-source -x <var>.../path/to/filename</var>.dsc
8400             </example>
8401           </p>
8402
8403            <p>
8404             with the <file><var>filename</var>.tar.gz</file> and
8405             <file><var>filename</var>.diff.gz</file> (if applicable) in
8406             the same directory.  It unpacks into
8407             <file><var>package</var>-<var>version</var></file>, and if
8408             applicable
8409             <file><var>package</var>-<var>version</var>.orig</file>, in
8410             the current directory.
8411           </p>
8412
8413           <p>
8414             To create a packed source archive it is typically invoked:
8415             <example>
8416   dpkg-source -b <var>package</var>-<var>version</var>
8417           </example>
8418           </p>
8419
8420           <p>
8421             This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8422             <file>.diff.gz</file> (if appropriate) in the current
8423             directory.  <prgn>dpkg-source</prgn> does not clean the
8424             source tree first - this must be done separately if it is
8425             required.
8426           </p>
8427
8428           <p>
8429             See also <ref id="pkg-sourcearchives">.</p>
8430         </sect1>
8431
8432
8433         <sect1>
8434           <heading>
8435             <prgn>dpkg-buildpackage</prgn> - overall package-building
8436             control script
8437           </heading>
8438
8439           <p>
8440             <prgn>dpkg-buildpackage</prgn> is a script which invokes
8441             <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8442             targets <tt>clean</tt>, <tt>build</tt> and
8443             <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8444             <prgn>pgp</prgn> to build a signed source and binary
8445             package upload.
8446           </p>
8447
8448           <p>
8449             It is usually invoked by hand from the top level of the
8450             built or unbuilt source directory.  It may be invoked with
8451             no arguments; useful arguments include:
8452             <taglist compact="compact">
8453               <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8454               <item>
8455                 <p>
8456                   Do not PGP-sign the <tt>.changes</tt> file or the
8457                   source package <tt>.dsc</tt> file, respectively.</p>
8458               </item>
8459               <tag><tt>-p<var>pgp-command</var></tt></tag>
8460               <item>
8461                 <p>
8462                   Invoke <var>pgp-command</var> instead of finding
8463                   <tt>pgp</tt> on the <prgn>PATH</prgn>.
8464                   <var>pgp-command</var> must behave just like
8465                   <prgn>pgp</prgn>.</p>
8466               </item>
8467               <tag><tt>-r<var>root-command</var></tt></tag>
8468               <item>
8469                 <p>
8470                   When root privilege is required, invoke the command
8471                   <var>root-command</var>.  <var>root-command</var>
8472                   should invoke its first argument as a command, from
8473                   the <prgn>PATH</prgn> if necessary, and pass its
8474                   second and subsequent arguments to the command it
8475                   calls.  If no <var>root-command</var> is supplied
8476                   then <var>dpkg-buildpackage</var> will take no
8477                   special action to gain root privilege, so that for
8478                   most packages it will have to be invoked as root to
8479                   start with.</p>
8480               </item>
8481               <tag><tt>-b</tt>, <tt>-B</tt></tag>
8482               <item>
8483                 <p>
8484                   Two types of binary-only build and upload - see
8485                   <manref name="dpkg-source" section="1">.
8486                 </p>
8487               </item>
8488             </taglist>
8489           </p>
8490         </sect1>
8491
8492         <sect1>
8493           <heading>
8494             <prgn>dpkg-gencontrol</prgn> - generates binary package
8495             control files
8496           </heading>
8497
8498           <p>
8499             This program is usually called from <file>debian/rules</file>
8500             (see <ref id="pkg-sourcetree">) in the top level of the source
8501             tree.
8502           </p>
8503
8504           <p>
8505             This is usually done just before the files and directories in the
8506             temporary directory tree where the package is being built have their
8507             permissions and ownerships set and the package is constructed using
8508             <prgn>dpkg-deb/</prgn>
8509               <footnote>
8510               <p>
8511                 This is so that the control file which is produced has
8512                 the right permissions
8513               </p>
8514             </footnote>.
8515           </p>
8516
8517           <p>
8518             <prgn>dpkg-gencontrol</prgn> must be called after all the
8519             files which are to go into the package have been placed in
8520             the temporary build directory, so that its calculation of
8521             the installed size of a package is correct.
8522           </p>
8523
8524           <p>
8525             It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8526             be run after <prgn>dpkg-shlibdeps</prgn> so that the
8527             variable substitutions created by
8528             <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8529             are available.
8530           </p>
8531
8532           <p>
8533             For a package which generates only one binary package, and
8534             which builds it in <file>debian/tmp</file> relative to the top
8535             of the source package, it is usually sufficient to call
8536             <prgn>dpkg-gencontrol</prgn>.
8537           </p>
8538
8539           <p>
8540             Sources which build several binaries will typically need
8541             something like:
8542             <example>
8543   dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8544             </example> The <tt>-P</tt> tells
8545             <prgn>dpkg-gencontrol</prgn> that the package is being
8546             built in a non-default directory, and the <tt>-p</tt>
8547             tells it which package's control file should be generated.
8548           </p>
8549
8550           <p>
8551             <prgn>dpkg-gencontrol</prgn> also adds information to the
8552             list of files in <file>debian/files</file>, for the benefit of
8553             (for example) a future invocation of
8554             <prgn>dpkg-genchanges</prgn>.</p>
8555         </sect1>
8556
8557         <sect1>
8558           <heading>
8559             <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8560             dependencies
8561           </heading>
8562
8563           <p>
8564             This program is usually called from <file>debian/rules</file>
8565             just before <prgn>dpkg-gencontrol</prgn> (see <ref
8566             id="pkg-sourcetree">), in the top level of the source tree.
8567           </p>
8568
8569           <p>
8570             Its arguments are executables.
8571             <footnote>
8572               <p>
8573                 In a forthcoming dpkg version,
8574                 <prgn>dpkg-shlibdeps</prgn> would be required to be
8575                 called on shared libraries as well.
8576               </p>
8577               <p>
8578                 They may be specified either in the locations in the
8579                 source tree where they are created or in the locations
8580                 in the temporary build tree where they are installed
8581                 prior to binary package creation.
8582               </p>
8583             </footnote> for which shared library dependencies should
8584             be included in the binary package's control file.
8585           </p>
8586
8587           <p>
8588             If some of the found shared libraries should only
8589             warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8590             some warrant a <tt>Pre-Depends</tt>, this can be achieved
8591             by using the <tt>-d<var>dependency-field</var></tt> option
8592             before those executable(s).  (Each <tt>-d</tt> option
8593             takes effect until the next <tt>-d</tt>.)
8594           </p>
8595
8596           <p>
8597             <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8598             output control file to be modified.  Instead by default it
8599             adds to the <file>debian/substvars</file> file variable
8600             settings like <tt>shlibs:Depends</tt>.  These variable
8601             settings must be referenced in dependency fields in the
8602             appropriate per-binary-package sections of the source
8603             control file.
8604           </p>
8605
8606           <p>
8607             For example, the <prgn>procps</prgn> package generates two
8608             kinds of binaries, simple C binaries like <prgn>ps</prgn>
8609             which require a predependency and full-screen ncurses
8610             binaries like <prgn>top</prgn> which require only a
8611             recommendation.  It can say in its <file>debian/rules</file>:
8612             <example>
8613   dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8614             </example>
8615             and then in its main control file <file>debian/control</file>:
8616             <example>
8617   <var>...</var>
8618   Package: procps
8619   Pre-Depends: ${shlibs:Pre-Depends}
8620   Recommends: ${shlibs:Recommends}
8621   <var>...</var>
8622             </example>
8623           </p>
8624
8625           <p>
8626             Sources which produce several binary packages with
8627             different shared library dependency requirements can use
8628             the <tt>-p<var>varnameprefix</var></tt> option to override
8629             the default <tt>shlibs:</tt> prefix (one invocation of
8630             <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8631             They can thus produce several sets of dependency
8632             variables, each of the form
8633             <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8634             which can be referred to in the appropriate parts of the
8635             binary package control files.
8636           </p>
8637         </sect1>
8638
8639
8640         <sect1>
8641           <heading>
8642             <prgn>dpkg-distaddfile</prgn> - adds a file to
8643             <file>debian/files</file>
8644           </heading>
8645
8646           <p>
8647             Some packages' uploads need to include files other than
8648             the source and binary package files.
8649           </p>
8650
8651           <p>
8652             <prgn>dpkg-distaddfile</prgn> adds a file to the
8653             <file>debian/files</file> file so that it will be included in
8654             the <file>.changes</file> file when
8655             <prgn>dpkg-genchanges</prgn> is run.
8656           </p>
8657
8658           <p>
8659             It is usually invoked from the <tt>binary</tt> target of
8660             <file>debian/rules</file>:
8661             <example>
8662   dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8663             </example>
8664             The <var>filename</var> is relative to the directory where
8665             <prgn>dpkg-genchanges</prgn> will expect to find it - this
8666             is usually the directory above the top level of the source
8667             tree.  The <file>debian/rules</file> target should put the
8668             file there just before or just after calling
8669             <prgn>dpkg-distaddfile</prgn>.
8670           </p>
8671
8672           <p>
8673             The <var>section</var> and <var>priority</var> are passed
8674             unchanged into the resulting <file>.changes</file> file.  See
8675             <ref id="pkg-f-classification">.
8676           </p>
8677         </sect1>
8678
8679
8680         <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8681             control file
8682           </heading>
8683
8684           <p>
8685             This program is usually called by package-independent
8686             automatic building scripts such as
8687             <prgn>dpkg-buildpackage</prgn>, but it may also be called
8688             by hand.
8689           </p>
8690
8691           <p>
8692             It is usually called in the top level of a built source
8693             tree, and when invoked with no arguments will print out a
8694             straightforward <file>.changes</file> file based on the
8695             information in the source package's changelog and control
8696             file and the binary and source packages which should have
8697             been built.
8698           </p>
8699         </sect1>
8700
8701
8702         <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8703             a changelog
8704           </heading>
8705
8706           <p>
8707             This program is used internally by
8708             <prgn>dpkg-source</prgn> et al.  It may also occasionally
8709             be useful in <file>debian/rules</file> and elsewhere.  It
8710             parses a changelog, <file>debian/changelog</file> by default,
8711             and prints a control-file format representation of the
8712             information in it to standard output.
8713           </p>
8714         </sect1>
8715
8716         <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8717             information about the build and host system
8718           </heading>
8719
8720           <p>
8721             This program can be used manually, but is also invoked by
8722             <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8723             to set environment or make variables which specify the build and
8724             host architecture for the package building process.
8725           </p>
8726         </sect1>
8727       </sect>
8728
8729       <sect id="pkg-sourcetree"><heading>The Debianised source tree
8730         </heading>
8731
8732         <p>
8733           The source archive scheme described later is intended to
8734           allow a Debianised source tree with some associated control
8735           information to be reproduced and transported easily.  The
8736           Debianised source tree is a version of the original program
8737           with certain files added for the benefit of the
8738           Debianisation process, and with any other changes required
8739           made to the rest of the source code and installation
8740           scripts.
8741         </p>
8742
8743         <p>
8744           The extra files created for Debian are in the subdirectory
8745           <file>debian</file> of the top level of the Debianised source
8746           tree.  They are described below.
8747         </p>
8748
8749         <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8750         script
8751           </heading>
8752
8753           <p>
8754             This file is an executable makefile, and contains the
8755             package-specific recipies for compiling the package and
8756             building binary package(s) out of the source.
8757           </p>
8758
8759           <p>
8760             It must start with the line <tt>#!/usr/bin/make -f</tt>,
8761             so that it can be invoked by saying its name rather than
8762             invoking <prgn>make</prgn> explicitly.
8763           </p>
8764
8765           <p>
8766             Since an interactive <file>debian/rules</file> script makes it
8767             impossible to autocompile that package and also makes it
8768             hard for other people to reproduce the same binary
8769             package, all <strong>required targets</strong> have to be
8770             non-interactive. At a minimul, required targets are the
8771             ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8772             <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8773             <em>build</em>. It also follows that any target that these
8774             targets depend on must also be non-interactive.
8775           </p>
8776
8777           <p>
8778             The targets which are required to be present are:
8779             <taglist>
8780               <tag><tt>build</tt></tag>
8781               <item>
8782                 <p>
8783                   This should perform all non-interactive
8784                   configuration and compilation of the package.  If a
8785                   package has an interactive pre-build configuration
8786                   routine, the Debianised source package should be
8787                   built after this has taken place, so that it can be
8788                   built without rerunning the configuration.
8789                 </p>
8790
8791                 <p>
8792                   A package may also provide both of the targets
8793                   <tt>build-arch</tt> and <tt>build-indep</tt>.  The
8794                   <tt>build-arch</tt> target, if provided, should
8795                   perform all non-interactive configuration and
8796                   compilation required for producing all
8797                   architecture-dependant binary packages (those packages
8798                   for which the body of the <tt>Architecture</tt> field
8799                   in <tt>debian/control</tt> is not <tt>all</tt>).
8800                   Similarly, the <tt>build-indep</tt> target, if
8801                   provided, should perform all non-interactive
8802                   configuration and compilation required for producing
8803                   all architecture-independent binary packages (those
8804                   packages for which the body of the
8805                   <tt>Architecture</tt> field in <tt>debian/control</tt>
8806                   is <tt>all</tt>).  The <tt>build</tt> target should
8807                   depend on those of the targets <tt>build-arch</tt> and
8808                   <tt>build-indep</tt> that are provided in the rules
8809                   file.
8810                 </p>
8811
8812                 <p>
8813                   If one or both of the targets <tt>build-arch</tt> and
8814                   <tt>build-indep</tt> are not provided, then invoking
8815                   <file>debian/rules</file> with one of the not-provided
8816                   targets as arguments should produce a exit status code
8817                   of 2.  Usually this is provided automatically by make
8818                   if the target is missing.
8819                 </p>
8820
8821                 <p>
8822                   For some packages, notably ones where the same
8823                   source tree is compiled in different ways to produce
8824                   two binary packages, the <tt>build</tt> target does
8825                   not make much sense.  For these packages it is good
8826                   enough to provide two (or more) targets
8827                   (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8828                   for each of the ways of building the package, and a
8829                   <tt>build</tt> target that does nothing.  The
8830                   <tt>binary</tt> target will have to build the
8831                   package in each of the possible ways and make the
8832                   binary package out of each.
8833                 </p>
8834
8835                 <p>
8836                   The targets <tt>build</tt>, <tt>build-arch</tt>
8837                   and <tt>build-indep</tt> target must not do
8838                   anything that might require root privilege.
8839                 </p>
8840
8841                 <p>
8842                   The <tt>build</tt> target may need to run
8843                   <tt>clean</tt> first - see below.
8844                 </p>
8845
8846                 <p>
8847                   When a package has a configuration routine that takes
8848                   a long time, or when the makefiles are poorly
8849                   designed, or when <tt>build</tt> needs to run
8850                   <tt>clean</tt> first, it is a good idea to <tt>touch
8851                     build</tt> when the build process is complete.  This
8852                   will ensure that if <tt>debian/rules build</tt> is run
8853                   again it will not rebuild the whole program.
8854                 </p>
8855               </item>
8856
8857               <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8858                 <tt>binary-indep</tt>
8859               </tag>
8860               <item>
8861                 <p>
8862                   The <tt>binary</tt> target should be all that is
8863                   necessary for the user to build the binary
8864                   package. All these targets are required to be
8865                   non-interactive.  It is split into two parts:
8866                   <tt>binary-arch</tt> builds the packages' output
8867                   files which are specific to a particular
8868                   architecture, and <tt>binary-indep</tt> builds
8869                   those which are not.
8870                 </p>
8871
8872                 <p>
8873                   <tt>binary</tt> should usually be a target with
8874                   no commands which simply depends on
8875                   <prgn>binary-arch</prgn> and
8876                   <prgn>binary-indep</prgn>.
8877                 </p>
8878
8879                 <p>
8880                   Both <prgn>binary-*</prgn> targets should depend on
8881                   the <tt>build</tt> target, above, so that the
8882                   package is built if it has not been already.  It
8883                   should then create the relevant binary package(s),
8884                   using <prgn>dpkg-gencontrol</prgn> to make their
8885                   control files and <prgn>dpkg-deb</prgn> to build
8886                   them and place them in the parent of the top level
8887                   directory.
8888                 </p>
8889
8890                 <p>
8891                   If one of the <prgn>binary-*</prgn> targets has
8892                   nothing to do (this will be always be the case if
8893                   the source generates only a single binary package,
8894                   whether architecture-dependent or not) it
8895                   <em>must</em> still exist, but should always
8896                   succeed.
8897                 </p>
8898
8899                 <p>
8900                   <ref id="pkg-binarypkg"> describes how to construct
8901                   binary packages.
8902                 </p>
8903
8904                 <p>
8905                   The <tt>binary</tt> targets must be invoked as
8906                   root.
8907                 </p>
8908               </item>
8909
8910               <tag><tt>clean</tt></tag>
8911               <item>
8912
8913                 <p>
8914                   This should undo any effects that the
8915                   <tt>build</tt> and <tt>binary</tt> targets
8916                   may have had, except that it should leave alone any
8917                   output files created in the parent directory by a
8918                   run of <tt>binary</tt>. This target is required
8919                   to be non-interactive.
8920                 </p>
8921
8922                 <p>
8923                   If a <tt>build</tt> file is touched at the end
8924                   of the <tt>build</tt> target, as suggested
8925                   above, it must be removed as the first thing that
8926                   <tt>clean</tt> does, so that running
8927                   <tt>build</tt> again after an interrupted
8928                   <tt>clean</tt> doesn't think that everything is
8929                   already done.
8930                 </p>
8931
8932                 <p>
8933                   The <tt>clean</tt> target must be invoked as
8934                   root if <tt>binary</tt> has been invoked since
8935                   the last <tt>clean</tt>, or if
8936                   <tt>build</tt> has been invoked as root (since
8937                   <tt>build</tt> may create directories, for
8938                   example).
8939                 </p>
8940               </item>
8941
8942               <tag><tt>get-orig-source</tt> (optional)</tag>
8943               <item>
8944
8945                 <p>
8946                   This target fetches the most recent version of the
8947                   original source package from a canonical archive
8948                   site (via FTP or WWW, for example), does any
8949                   necessary rearrangement to turn it into the original
8950                   source tarfile format described below, and leaves it
8951                   in the current directory.
8952                 </p>
8953
8954                 <p>
8955                   This target may be invoked in any directory, and
8956                   should take care to clean up any temporary files it
8957                   may have left.
8958                 </p>
8959
8960                 <p>
8961                   This target is optional, but providing it if
8962                   possible is a good idea.
8963                 </p>
8964               </item>
8965             </taglist>
8966
8967           <p>
8968             The <tt>build</tt>, <tt>binary</tt> and
8969             <tt>clean</tt> targets must be invoked with a current
8970             directory of the package's top-level directory.
8971           </p>
8972
8973
8974           <p>
8975             Additional targets may exist in <file>debian/rules</file>,
8976             either as published or undocumented interfaces or for the
8977             package's internal use.
8978           </p>
8979
8980           <p>
8981             The architecture we build on and build for is determined by make
8982             variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8983             get the Debian architecture and the GNU style architecture
8984             specification string for the build machine as well as the host
8985             machine. Here is a list of supported make variables:
8986             <list compact="compact">
8987               <item>
8988                 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8989               </item>
8990               <item>
8991                 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8992                   specification string)</p>
8993               </item>
8994               <item>
8995                 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8996               </item>
8997               <item>
8998                 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8999                   DEB_*_GNU_TYPE)</p>
9000             </list>
9001           </p>
9002
9003           <p>
9004             where <tt>*</tt> is either <tt>BUILD</tt> for specification of
9005             the build machine or <tt>HOST</tt> for specification of the machine
9006             we build for.
9007           </p>
9008
9009           <p>
9010             Backward compatibility can be provided in the rules file
9011             by setting the needed variables to suitable default
9012             values, please refer to the documentation of
9013             dpkg-architecture for details.
9014           </p>
9015
9016           <p>
9017             It is important to understand that the <tt>DEB_*_ARCH</tt>
9018             string does only determine which Debian architecture we
9019             build on resp. for. It should not be used to get the CPU
9020             or System information, the GNU style variables should be
9021             used for that.
9022           </p>
9023         </sect1>
9024
9025
9026         <sect1><heading><file>debian/control</file>
9027           </heading>
9028
9029           <p>
9030             This file contains version-independent details about the
9031             source package and about the binary packages it creates.
9032           </p>
9033
9034           <p>
9035             It is a series of sets of control fields, each
9036             syntactically similar to a binary package control file.
9037             The sets are separated by one or more blank lines.  The
9038             first set is information about the source package in
9039             general; each subsequent set describes one binary package
9040             that the source tree builds.
9041           </p>
9042
9043           <p>
9044             The syntax and semantics of the fields are described below
9045             in <ref id="pkg-controlfields">.
9046           </p>
9047
9048           <p>
9049             The general (binary-package-independent) fields are:
9050             <list compact="compact">
9051               <item>
9052                 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
9053               </item>
9054               <item>
9055                 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9056               </item>
9057               <item>
9058                 <p>
9059                   <qref id="pkg-f-classification"><tt>Section</tt> and
9060                     <tt>Priority</tt></qref>
9061                   (classification, mandatory)
9062                 </p>
9063               </item>
9064                <item>
9065                  <p>
9066                    <qref id="relationships"><tt>Build-Depends</tt> et
9067                      al.</qref> (source package interrelationships)
9068                  </p>
9069                </item>
9070               <item>
9071                 <p>
9072                   <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
9073                 </p>
9074               </item>
9075             </list>
9076
9077           <p>
9078             The per-binary-package fields are:
9079             <list compact="compact">
9080               <item>
9081                 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
9082               </item>
9083               <item>
9084                 <p>
9085                   <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
9086                   (mandatory)</p>
9087               </item>
9088               <item>
9089                 <p><qref id="descriptions"><tt>Description</tt></qref></p>
9090               </item>
9091               <item>
9092                 <p>
9093                   <qref id="pkg-f-classification"><tt>Section</tt> and
9094                     <tt>Priority</tt></qref> (classification)</p>
9095               </item>
9096               <item>
9097                 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
9098               </item>
9099               <item>
9100                 <p>
9101                   <qref id="relationships"><tt>Depends</tt> et
9102                   al.</qref> (binary package interrelationships)
9103                 </p>
9104               </item>
9105             </list>
9106
9107           <p>
9108             These fields are used by <prgn>dpkg-gencontrol</prgn> to
9109             generate control files for binary packages (see below), by
9110             <prgn>dpkg-genchanges</prgn> to generate the
9111             <tt>.changes</tt> file to accompany the upload, and by
9112             <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9113             source control file as part of a source archive.
9114           </p>
9115
9116           <p>
9117             The fields here may contain variable references - their
9118             values will be substituted by
9119             <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9120             or <prgn>dpkg-source</prgn> when they generate output
9121             control files.  See <ref id="pkg-srcsubstvars"> for details.
9122           </p>
9123
9124           <p> <sect2><heading>User-defined fields
9125             </heading>
9126
9127             <p>
9128               Additional user-defined fields may be added to the
9129               source package control file.  Such fields will be
9130               ignored, and not copied to (for example) binary or
9131               source package control files or upload control files.
9132             </p>
9133
9134             <p>
9135               If you wish to add additional unsupported fields to
9136               these output files you should use the mechanism
9137               described here.
9138             </p>
9139
9140             <p>
9141               Fields in the main source control information file with
9142               names starting <tt>X</tt>, followed by one or more of
9143               the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9144               be copied to the output files.  Only the part of the
9145               field name after the hyphen will be used in the output
9146               file.  Where the letter <tt>B</tt> is used the field
9147               will appear in binary package control files, where the
9148               letter <tt>S</tt> is used in source package control
9149               files and where <tt>C</tt> is used in upload control
9150               (<tt>.changes</tt>) files.
9151             </p>
9152
9153             <p>
9154               For example, if the main source information control file
9155               contains the field
9156               <example>
9157   XBS-Comment: I stand between the candle and the star.
9158               </example>
9159               then the binary and source package control files will contain the
9160               field
9161               <example>
9162   Comment: I stand between the candle and the star.
9163               </example>
9164             </p>
9165           </sect2>
9166
9167         </sect1>
9168
9169         <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9170           </heading>
9171
9172           <p>
9173             This file records the changes to the Debian-specific parts of the
9174             package
9175             <footnote>
9176               <p>
9177                 Though there is nothing stopping an author who is also
9178                 the Debian maintainer from using it for all their
9179                 changes, it will have to be renamed if the Debian and
9180                 upstream maintainers become different
9181                 people.
9182               </p>
9183             </footnote>.
9184           </p>
9185
9186           <p>
9187             It has a special format which allows the package building
9188             tools to discover which version of the package is being
9189             built and find out other release-specific information.
9190           </p>
9191
9192           <p>
9193             That format is a series of entries like this:
9194             <example>
9195   <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9196
9197    * <var>change details</var>
9198    <var>more change details</var>
9199    * <var>even more change details</var>
9200
9201   -- <var>maintainer name and email address</var>  <var>date</var>
9202             </example>
9203           </p>
9204
9205           <p>
9206             <var>package</var> and <var>version</var> are the source
9207             package name and version number.
9208           </p>
9209
9210           <p>
9211             <var>distribution(s)</var> lists the distributions where
9212             this version should be installed when it is uploaded - it
9213             is copied to the <tt>Distribution</tt> field in the
9214             <tt>.changes</tt> file.  See <ref id="pkg-f-Distribution">.
9215           </p>
9216
9217           <p>
9218             <var>urgency</var> is the value for the <tt>Urgency</tt>
9219             field in the <file>.changes</file> file for the upload.  See
9220             <ref id="pkg-f-Urgency">.  It is not possible to specify an
9221             urgency containing commas; commas are used to separate
9222             <tt><var>keyword</var>=<var>value</var></tt> settings in
9223             the <prgn>dpkg</prgn> changelog format (though there is
9224             currently only one useful <var>keyword</var>,
9225             <tt>urgency</tt>).
9226           </p>
9227
9228           <p>
9229             The change details may in fact be any series of lines
9230             starting with at least two spaces, but conventionally each
9231             change starts with an asterisk and a separating space and
9232             continuation lines are indented so as to bring them in
9233             line with the start of the text above.  Blank lines may be
9234             used here to separate groups of changes, if desired.
9235           </p>
9236
9237           <p>
9238             The maintainer name and email address should <em>not</em>
9239             necessarily be those of the usual package maintainer.
9240             They should be the details of the person doing
9241             <em>this</em> version.  The information here will be
9242             copied to the <file>.changes</file> file, and then later used
9243             to send an acknowledgement when the upload has been
9244             installed.
9245           </p>
9246
9247           <p>
9248             The <var>date</var> should be in RFC822 format
9249             <footnote>
9250               <p>
9251                 This is generated by the <prgn>822-date</prgn>
9252                 program.
9253               </p>
9254             </footnote>; it should include the timezone specified
9255             numerically, with the timezone name or abbreviation
9256             optionally present as a comment.
9257           </p>
9258
9259           <p>
9260             The first "title" line with the package name should start
9261             at the left hand margin; the "trailer" line with the
9262             maintainer and date details should be preceded by exactly
9263             one space.  The maintainer details and the date must be
9264             separated by exactly two spaces.
9265           </p>
9266
9267           <p>
9268             An Emacs mode for editing this format is available: it is
9269             called <tt>debian-changelog-mode</tt>.  You can have this
9270             mode selected automatically when you edit a Debian
9271             changelog by adding a local variables clause to the end of
9272             the changelog.
9273           </p>
9274
9275           <sect2><heading>Defining alternative changelog formats
9276             </heading>
9277
9278             <p>
9279               It is possible to use a different format to the standard
9280               one, by providing a parser for the format you wish to
9281               use.
9282             </p>
9283
9284             <p>
9285               In order to have <tt>dpkg-parsechangelog</tt> run your
9286               parser, you must include a line within the last 40 lines
9287               of your file matching the Perl regular expression:
9288               <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9289               parentheses should be the name of the format.  For
9290               example, you might say:
9291               <example>
9292   @@@ changelog-format: joebloggs @@@
9293               </example>
9294               Changelog format names are non-empty strings of alphanumerics.
9295             </p>
9296
9297             <p>
9298               If such a line exists then <tt>dpkg-parsechangelog</tt>
9299               will look for the parser as
9300               <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9301               or
9302               <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9303               it is an error for it not to find it, or for it not to
9304               be an executable program.  The default changelog format
9305               is <tt>dpkg</tt>, and a parser for it is provided with
9306               the <tt>dpkg</tt> package.
9307             </p>
9308
9309             <p>
9310               The parser will be invoked with the changelog open on
9311               standard input at the start of the file.  It should read
9312               the file (it may seek if it wishes) to determine the
9313               information required and return the parsed information
9314               to standard output in the form of a series of control
9315               fields in the standard format.  By default it should
9316               return information about only the most recent version in
9317               the changelog; it should accept a
9318               <tt>-v<var>version</var></tt> option to return changes
9319               information from all versions present <em>strictly
9320               after</em> <var>version</var>, and it should then be an
9321               error for <var>version</var> not to be present in the
9322               changelog.
9323             </p>
9324
9325             <p>
9326               The fields are:
9327               <list compact="compact">
9328                 <item>
9329                   <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9330                 </item>
9331                 <item>
9332                   <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9333                 </item>
9334                 <item>
9335                   <p>
9336                     <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9337                     (mandatory)
9338                   </p>
9339                 </item>
9340                 <item>
9341                   <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9342                 </item>
9343                 <item>
9344                   <p>
9345                     <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9346                     (mandatory)
9347                   </p>
9348                 </item>
9349                 <item>
9350                   <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9351                 </item>
9352                 <item>
9353                   <p>
9354                     <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9355                     (mandatory)
9356                   </p>
9357                 </item>
9358               </list>
9359
9360             <p>
9361               If several versions are being returned (due to the use
9362               of <tt>-v</tt>), the urgency value should be of the
9363               highest urgency code listed at the start of any of the
9364               versions requested followed by the concatenated
9365               (space-separated) comments from all the versions
9366               requested; the maintainer, version, distribution and
9367               date should always be from the most recent version.
9368             </p>
9369
9370             <p>
9371               For the format of the <tt>Changes</tt> field see <ref
9372               id="pkg-f-Changes">.
9373             </p>
9374
9375             <p>
9376               If the changelog format which is being parsed always or
9377               almost always leaves a blank line between individual
9378               change notes these blank lines should be stripped out,
9379               so as to make the resulting output compact.
9380             </p>
9381
9382             <p>
9383               If the changelog format does not contain date or package
9384               name information this information should be omitted from
9385               the output.  The parser should not attempt to synthesise
9386               it or find it from other sources.
9387             </p>
9388
9389             <p>
9390               If the changelog does not have the expected format the
9391               parser should exit with a nonzero exit status, rather
9392               than trying to muddle through and possibly generating
9393               incorrect output.
9394             </p>
9395
9396             <p>
9397               A changelog parser may not interact with the user at
9398               all.</p></sect2>
9399         </sect1>
9400
9401 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
9402
9403         <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9404         and variable substitutions
9405           </heading>
9406
9407           <p>
9408             When <prgn>dpkg-gencontrol</prgn>,
9409             <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9410             generate control files they do variable substitutions on
9411             their output just before writing it.  Variable
9412             substitutions have the form
9413             <tt>${<var>variable-name</var>}</tt>.  The optional file
9414             <file>debian/substvars</file> contains variable substitutions
9415             to be used; variables can also be set directly from
9416             <file>debian/rules</file> using the <tt>-V</tt> option to the
9417             source packaging commands, and certain predefined
9418             variables are available.
9419           </p>
9420
9421           <p>
9422             This file is usually generated and modified dynamically by
9423             <file>debian/rules</file> targets, in which case it must be
9424             removed by the <tt>clean</tt> target.
9425           </p>
9426
9427           <p>
9428             See <manref name="dpkg-source" section="1"> for full
9429             details about source variable substitutions, including the
9430             format of <file>debian/substvars</file>.</p>
9431         </sect1>
9432
9433         <sect1><heading><file>debian/files</file>
9434           </heading>
9435
9436           <p>
9437             This file is not a permanent part of the source tree; it
9438             is used while building packages to record which files are
9439             being generated.  <prgn>dpkg-genchanges</prgn> uses it
9440             when it generates a <file>.changes</file> file.
9441           </p>
9442
9443           <p>
9444             It should not exist in a shipped source package, and so it
9445             (and any backup files or temporary files such as
9446             <file>files.new</file>
9447               <footnote>
9448                 <p>
9449                   <file>files.new</file> is used as a temporary file by
9450                   <prgn>dpkg-gencontrol</prgn> and
9451                   <prgn>dpkg-distaddfile</prgn> - they write a new
9452                   version of <file>files</file> here before renaming it,
9453                   to avoid leaving a corrupted copy if an error
9454                   occurs
9455                 </p>
9456               </footnote>) should be removed by the
9457               <tt>clean</tt> target.  It may also be wise to
9458               ensure a fresh start by emptying or removing it at the
9459               start of the <tt>binary</tt> target.
9460           </p>
9461
9462           <p>
9463             <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9464             for the <file>.deb</file> file that will be created by
9465             <prgn>dpkg-deb</prgn> from the control file that it
9466             generates, so for most packages all that needs to be done
9467             with this file is to delete it in <tt>clean</tt>.
9468           </p>
9469
9470           <p>
9471             If a package upload includes files besides the source
9472             package and any binary packages whose control files were
9473             made with <prgn>dpkg-gencontrol</prgn> then they should be
9474             placed in the parent of the package's top-level directory
9475             and <prgn>dpkg-distaddfile</prgn> should be called to add
9476             the file to the list in <file>debian/files</file>.</p>
9477         </sect1>
9478
9479         <sect1><heading><file>debian/tmp</file>
9480           </heading>
9481
9482           <p>
9483             This is the canonical temporary location for the
9484             construction of binary packages by the <tt>binary</tt>
9485             target.  The directory <file>tmp</file> serves as the root of
9486             the filesystem tree as it is being constructed (for
9487             example, by using the package's upstream makefiles install
9488             targets and redirecting the output there), and it also
9489             contains the <tt>DEBIAN</tt> subdirectory.  See <ref
9490             id="pkg-bincreating">.
9491           </p>
9492
9493           <p>
9494             If several binary packages are generated from the same
9495             source tree it is usual to use several
9496             <file>debian/tmp<var>something</var></file> directories, for
9497             example <file>tmp-a</file> or <file>tmp-doc</file>.
9498           </p>
9499
9500           <p>
9501             Whatever <file>tmp</file> directories are created and used by
9502             <tt>binary</tt> must of course be removed by the
9503             <tt>clean</tt> target.</p></sect1>
9504       </sect>
9505
9506
9507       <sect id="pkg-sourcearchives"><heading>Source packages as archives
9508         </heading>
9509
9510         <p>
9511           As it exists on the FTP site, a Debian source package
9512           consists of three related files.  You must have the right
9513           versions of all three to be able to use them.
9514         </p>
9515
9516         <p>
9517           <taglist>
9518             <tag>Debian source control file - <tt>.dsc</tt></tag>
9519             <item>
9520
9521               <p>
9522                 This file contains a series of fields, identified and
9523                 separated just like the fields in the control file of
9524                 a binary package.  The fields are listed below; their
9525                 syntax is described above, in <ref id="pkg-controlfields">.
9526                 <list compact="compact">
9527                   <item>
9528                     <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9529                   </item>
9530                   <item>
9531                     <p><qref id="versions"><tt>Version</tt></qref></p>
9532                   </item>
9533                   <item>
9534                     <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9535                   </item>
9536                   <item>
9537                     <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9538                   </item>
9539                   <item>
9540                     <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9541                   </item>
9542                   <item>
9543                      <p>
9544                        <qref id="relationships"><tt>Build-Depends</tt> et
9545                          al.</qref> (source package interrelationships)
9546                      </p>
9547                   </item>
9548                   <item>
9549                     <p>
9550                       <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9551                   </item>
9552                   <item>
9553                     <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9554                   </item>
9555                 </list>
9556
9557               <p>
9558                 The source package control file is generated by
9559                 <prgn>dpkg-source</prgn> when it builds the source
9560                 archive, from other files in the source package,
9561                 described above.  When unpacking it is checked against
9562                 the files and directories in the other parts of the
9563                 source package, as described below.</p>
9564             </item>
9565
9566             <tag>
9567               Original source archive -
9568               <file>
9569                 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9570               </file>
9571             </tag>
9572
9573             <item>
9574
9575               <p>
9576                 This is a compressed (with <tt>gzip -9</tt>)
9577                 <prgn>tar</prgn> file containing the source code from
9578                 the upstream authors of the program.  The tarfile
9579                 unpacks into a directory
9580                 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9581                 and does not contain files anywhere other than in
9582                 there or in its subdirectories.</p>
9583             </item>
9584
9585             <tag>
9586               Debianisation diff -
9587               <file>
9588                 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9589               </file>
9590             </tag>
9591             <item>
9592
9593               <p>
9594                 This is a unified context diff (<tt>diff -u</tt>)
9595                 giving the changes which are required to turn the
9596                 original source into the Debian source.  These changes
9597                 may only include editing and creating plain files.
9598                 The permissions of files, the targets of symbolic
9599                 links and the characteristics of special files or
9600                 pipes may not be changed and no files may be removed
9601                 or renamed.
9602               </p>
9603
9604               <p>
9605                 All the directories in the diff must exist, except the
9606                 <file>debian</file> subdirectory of the top of the source
9607                 tree, which will be created by
9608                 <prgn>dpkg-source</prgn> if necessary when unpacking.
9609               </p>
9610
9611               <p>
9612                 The <prgn>dpkg-source</prgn> program will
9613                 automatically make the <file>debian/rules</file> file
9614                 executable (see below).</p></item>
9615           </taglist>
9616
9617
9618         <p>
9619           If there is no original source code - for example, if the
9620           package is specially prepared for Debian or the Debian
9621           maintainer is the same as the upstream maintainer - the
9622           format is slightly different: then there is no diff, and the
9623           tarfile is named
9624           <file><var>package</var>_<var>version</var>.tar.gz</file> and
9625           contains a directory
9626           <file><var>package</var>-<var>version</var></file>.
9627         </p>
9628       </sect>
9629
9630       <sect><heading>Unpacking a Debian source package without
9631       <prgn>dpkg-source</prgn>
9632         </heading>
9633
9634         <p>
9635           <tt>dpkg-source -x</tt> is the recommended way to unpack a
9636           Debian source package.  However, if it is not available it
9637           is possible to unpack a Debian source archive as follows:
9638         <enumlist compact="compact">
9639           <item>
9640             <p>
9641               Untar the tarfile, which will create a <file>.orig</file>
9642               directory.</p>
9643           </item>
9644           <item>
9645             <p>Rename the <file>.orig</file> directory to
9646               <file><var>package</var>-<var>version</var></file>.</p>
9647           </item>
9648             <item>
9649             <p>
9650               Create the subdirectory <file>debian</file> at the top of
9651               the source tree.</p>
9652           </item>
9653           <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9654           </item>
9655           <item><p>Untar the tarfile again if you want a copy of the original
9656               source code alongside the Debianised version.</p>
9657           </item>
9658         </enumlist>
9659
9660         <p>
9661           It is not possible to generate a valid Debian source archive
9662           without using <prgn>dpkg-source</prgn>.  In particular,
9663           attempting to use <prgn>diff</prgn> directly to generate the
9664           <file>.diff.gz</file> file will not work.
9665         </p>
9666
9667         <sect1><heading>Restrictions on objects in source packages
9668           </heading>
9669
9670           <p>
9671             The source package may not contain any hard links
9672             <footnote>
9673               <p>
9674                 This is not currently detected when building source
9675                 packages, but only when extracting
9676                 them.
9677               </p>
9678             </footnote>
9679             <footnote>
9680               <p>
9681                 Hard links may be permitted at some point in the
9682                 future, but would require a fair amount of
9683                 work.
9684               </p>
9685             </footnote>, device special files, sockets or setuid or
9686             setgid files.
9687             <footnote>
9688               <p>
9689                 Setgid directories are allowed.
9690               </p>
9691             </footnote>
9692           </p>
9693
9694           <p>
9695             The source packaging tools manage the changes between the
9696             original and Debianised source using <prgn>diff</prgn> and
9697             <prgn>patch</prgn>.  Turning the original source tree as
9698             included in the <file>.orig.tar.gz</file> into the debianised
9699             source must not involve any changes which cannot be
9700             handled by these tools.  Problematic changes which cause
9701             <prgn>dpkg-source</prgn> to halt with an error when
9702             building the source package are:
9703             <list compact="compact">
9704               <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9705               </item>
9706               <item><p>Changing the targets of symbolic links.</p>
9707               </item>
9708               <item><p>Creating directories, other than <file>debian</file>.</p>
9709               </item>
9710               <item><p>Changes to the contents of binary files.</p></item>
9711             </list> Changes which cause <prgn>dpkg-source</prgn> to
9712             print a warning but continue anyway are:
9713             <list compact="compact">
9714               <item>
9715                 <p>
9716                   Removing files, directories or symlinks.
9717                   <footnote>
9718                     <p>
9719                       Renaming a file is not treated specially - it is
9720                       seen as the removal of the old file (which
9721                       generates a warning, but is otherwise ignored),
9722                       and the creation of the new
9723                       one.</p>
9724                   </footnote>
9725                 </p>
9726               </item>
9727               <item>
9728                 <p>
9729                   Changed text files which are missing the usual final
9730                   newline (either in the original or the modified
9731                   source tree).
9732                 </p>
9733               </item>
9734             </list>
9735             Changes which are not represented, but which are not detected by
9736             <prgn>dpkg-source</prgn>, are:
9737             <list compact="compact">
9738               <item><p>Changing the permissions of files (other than
9739                   <file>debian/rules</file>) and directories.</p></item>
9740             </list>
9741           </p>
9742
9743           <p>
9744             The <file>debian</file> directory and <file>debian/rules</file>
9745             are handled specially by <prgn>dpkg-source</prgn> - before
9746             applying the changes it will create the <file>debian</file>
9747             directory, and afterwards it will make
9748             <file>debian/rules</file> world-exectuable.
9749           </p>
9750         </sect1>
9751       </sect>
9752     </appendix>
9753
9754     <appendix id="pkg-controlfields"><heading>Control files and their
9755         fields (from old Packaging Manual)
9756       </heading>
9757
9758       <p>
9759         Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9760         data in a common format, known as control files.  Binary and
9761         source packages have control data as do the <file>.changes</file>
9762         files which control the installation of uploaded files, and
9763         <prgn>dpkg</prgn>'s internal databases are in a similar
9764         format.
9765       </p>
9766
9767       <sect><heading>Syntax of control files
9768         </heading>
9769
9770         <p>
9771           A file consists of one or more paragraphs of fields.  The
9772           paragraphs are separated by blank lines.  Some control files
9773           only allow one paragraph; others allow several, in which
9774           case each paragraph often refers to a different package.
9775         </p>
9776
9777         <p>
9778           Each paragraph is a series of fields and values; each field
9779           consists of a name, followed by a colon and the value.  It
9780           ends at the end of the line.  Horizontal whitespace (spaces
9781           and tabs) may occur before or after the value and is ignored
9782           there; it is conventional to put a single space after the
9783           colon.
9784         </p>
9785
9786         <p>
9787           Some fields' values may span several lines; in this case
9788           each continuation line <em>must</em> start with a space or
9789           tab.  Any trailing spaces or tabs at the end of individual
9790           lines of a field value are ignored.
9791         </p>
9792
9793         <p>
9794           Except where otherwise stated only a single line of data is
9795           allowed and whitespace is not significant in a field body.
9796           Whitespace may never appear inside names (of packages,
9797           architectures, files or anything else), version numbers or
9798           in between the characters of multi-character version
9799           relationships.
9800         </p>
9801
9802         <p>
9803           Field names are not case-sensitive, but it is usual to
9804           capitalise the field names using mixed case as shown below.
9805         </p>
9806
9807         <p>
9808           Blank lines, or lines consisting only of spaces and tabs,
9809           are not allowed within field values or between fields - that
9810           would mean a new paragraph.
9811         </p>
9812
9813         <p>
9814           It is important to note that there are several fields which
9815           are optional as far as <prgn>dpkg</prgn> and the related
9816           tools are concerned, but which must appear in every Debian
9817           package, or whose omission may cause problems.
9818         </p>
9819       </sect>
9820
9821       <sect><heading>List of fields
9822         </heading>
9823
9824         <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9825           </heading>
9826
9827           <p>
9828             The name of the binary package.  Package names consist of
9829             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9830             (plus, minus and full stop).
9831             <footnote>
9832               <p>
9833                 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9834                 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9835                 and underscore) used to be legal and are still
9836                 accepted when found in a package file, but may not be
9837                 used in new packages
9838               </p>
9839             </footnote>
9840           </p>
9841
9842           <p>
9843             They must be at least two characters and must start with
9844             an alphanumeric.  In current versions of dpkg they are
9845             sort of case-sensitive<footnote><p>This is a
9846             bug.</p></footnote>; use lowercase package names unless
9847             the package you're building (or referring to, in other
9848             fields) is already using uppercase.</p>
9849         </sect1>
9850
9851         <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9852           </heading>
9853
9854           <p>
9855             This lists the source or binary package's version number -
9856             see <ref id="versions">.
9857           </p>
9858
9859         </sect1>
9860
9861         <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9862           </heading>
9863
9864           <p>
9865             This is the architecture string; it is a single word for
9866             the Debian architecture.
9867           </p>
9868
9869           <p>
9870             <prgn>dpkg</prgn> will check the declared architecture of
9871             a binary package against its own compiled-in value before
9872             it installs it.
9873           </p>
9874
9875           <p>
9876             The special value <tt>all</tt> indicates that the package
9877             is architecture-independent.
9878           </p>
9879
9880           <p>
9881             In the main <file>debian/control</file> file in the source
9882             package, or in the source package control file
9883             <file>.dsc</file>, a list of architectures (separated by
9884             spaces) is also allowed, as is the special value
9885             <tt>any</tt>.  A list indicates that the source will build
9886             an architecture-dependent package, and will only work
9887             correctly on the listed architectures.  <tt>any</tt>
9888             indicates that though the source package isn't dependent
9889             on any particular architecture and should compile fine on
9890             any one, the binary package(s) produced are not
9891             architecture-independent but will instead be specific to
9892             whatever the current build architecture is.
9893           </p>
9894
9895           <p>
9896             In a <file>.changes</file> file the <tt>Architecture</tt>
9897             field lists the architecture(s) of the package(s)
9898             currently being uploaded.  This will be a list; if the
9899             source for the package is being uploaded too the special
9900             entry <tt>source</tt> is also present.
9901           </p>
9902
9903           <p>
9904             See <ref id="pkg-debianrules"> for information how to get the
9905             architecture for the build process.
9906           </p>
9907         </sect1>
9908
9909         <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9910           </heading>
9911
9912           <p>
9913             The package maintainer's name and email address.  The name
9914             should come first, then the email address inside angle
9915             brackets <tt>&lt;&gt</tt> (in RFC822 format).
9916           </p>
9917
9918           <p>
9919             If the maintainer's name contains a full stop then the
9920             whole field will not work directly as an email address due
9921             to a misfeature in the syntax specified in RFC822; a
9922             program using this field as an address must check for this
9923             and correct the problem if necessary (for example by
9924             putting the name in round brackets and moving it to the
9925             end, and bringing the email address forward).
9926           </p>
9927
9928           <p>
9929             In a <file>.changes</file> file or parsed changelog data this
9930             contains the name and email address of the person
9931             responsible for the particular version in question - this
9932             may not be the package's usual maintainer.
9933           </p>
9934
9935           <p>
9936             This field is usually optional in as far as the
9937             <prgn>dpkg</prgn> are concerned, but its absence when
9938             building packages usually generates a warning.</p>
9939         </sect1>
9940
9941         <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9942           </heading>
9943
9944           <p>
9945             This field identifies the source package name.
9946           </p>
9947
9948           <p>
9949             In a main source control information or a
9950             <file>.changes</file> or <file>.dsc</file> file or parsed
9951             changelog data this may contain only the name of the
9952             source package.
9953           </p>
9954
9955           <p>
9956             In the control file of a binary package (or in a
9957             <file>Packages</file> file) it may be followed by a version
9958             number in parentheses.
9959             <footnote>
9960               <p>
9961                 It is usual to leave a space after the package name if
9962                 a version number is specified.
9963               </p>
9964             </footnote> This version number may be omitted (and is, by
9965             <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9966             the <tt>Version</tt> field of the binary package in
9967             question.  The field itself may be omitted from a binary
9968             package control file when the source package has the same
9969             name and version as the binary package.
9970           </p>
9971         </sect1>
9972
9973         <sect1><heading>Package interrelationship fields:
9974             <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9975             <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9976             <tt>Provides</tt>, <tt>Replaces</tt>
9977           </heading>
9978
9979           <p>
9980             These fields describe the package's relationships with
9981             other packages.  Their syntax and semantics are described
9982             in <ref id="relationships">.</p>
9983         </sect1>
9984
9985         <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9986           </heading>
9987
9988           <p>
9989             In a binary package <tt>Packages</tt> file or main source
9990             control file this field contains a description of the
9991             binary package, in a special format.  See <ref
9992             id="descriptions"> for details.
9993           </p>
9994
9995           <p>
9996             In a <file>.changes</file> file it contains a summary of the
9997             descriptions for the packages being uploaded.  The part of
9998             the field before the first newline is empty; thereafter
9999             each line has the name of a binary package and the summary
10000             description line from that binary package.  Each line is
10001             indented by one space.</p>
10002         </sect1>
10003
10004         <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
10005           </heading>
10006
10007           <p>
10008             This is a boolean field which may occur only in the
10009             control file of a binary package (or in the
10010             <file>Packages</file> file) or in a per-package fields
10011             paragraph of a main source control data file.
10012           </p>
10013
10014           <p>
10015             If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
10016             <prgn>dselect</prgn> will refuse to remove the package
10017             (though it can be upgraded and/or replaced).  The other
10018             possible value is <tt>no</tt>, which is the same as not
10019             having the field at all.</p>
10020         </sect1>
10021
10022         <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
10023         <tt>Priority</tt>
10024           </heading>
10025
10026           <p>
10027             These two fields classify the package.  The
10028             <tt>Priority</tt> represents how important that it is that
10029             the user have it installed; the <tt>Section</tt>
10030             represents an application area into which the package has
10031             been classified.
10032           </p>
10033
10034           <p>
10035             When they appear in the <file>debian/control</file> file these
10036             fields give values for the section and priority subfields
10037             of the <tt>Files</tt> field of the <file>.changes</file> file,
10038             and give defaults for the section and priority of the
10039             binary packages.
10040           </p>
10041
10042           <p>
10043             The section and priority are represented, though not as
10044             separate fields, in the information for each file in the
10045             <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
10046             <file>.changes</file> file.  The section value in a
10047             <file>.changes</file> file is used to decide where to install
10048             a package in the FTP archive.
10049           </p>
10050
10051           <p>
10052             These fields are not used by by <prgn>dpkg</prgn> proper,
10053             but by <prgn>dselect</prgn> when it sorts packages and
10054             selects defaults.
10055           </p>
10056
10057           <p>
10058             These fields can appear in binary package control files,
10059             in which case they provide a default value in case the
10060             <file>Packages</file> files are missing the information.
10061             <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
10062             the value from a <file>.deb</file> file if they have no other
10063             information; a value listed in a <file>Packages</file> file
10064             will always take precedence.  By default
10065             <prgn>dpkg-gencontrol</prgn> does not include the section
10066             and priority in the control file of a binary package - use
10067             the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
10068             achieve this effect.</p>
10069         </sect1>
10070
10071         <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
10072           </heading>
10073
10074           <p>
10075             This field is a list of binary packages.
10076           </p>
10077
10078           <p>
10079             When it appears in the <file>.dsc</file> file it is the list
10080             of binary packages which a source package can produce.  It
10081             does not necessarily produce all of these binary packages
10082             for every architecture.  The source control file doesn't
10083             contain details of which architectures are appropriate for
10084             which of the binary packages.
10085           </p>
10086
10087           <p>
10088             When it appears in a <file>.changes</file> file it lists the
10089             names of the binary packages actually being uploaded.
10090           </p>
10091
10092           <p>
10093             The syntax is a list of binary packages separated by
10094             commas.
10095             <footnote>
10096               <p>
10097                 A space after each comma is conventional.
10098               </p>
10099             </footnote> Currently the packages must be separated using
10100             only spaces in the <file>.changes</file> file.</p>
10101         </sect1>
10102
10103         <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10104           </heading>
10105
10106           <p>
10107             This field appears in the control files of binary
10108             packages, and in the <file>Packages</file> files.  It gives
10109             the total amount of disk space required to install the
10110             named package.
10111           </p>
10112
10113           <p>
10114             The disk space is represented in kilobytes as a simple
10115             decimal number.</p>
10116         </sect1>
10117
10118         <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10119           </heading>
10120
10121           <p>
10122             This field contains a list of files with information about
10123             each one.  The exact information and syntax varies with
10124             the context.  In all cases the part of the field
10125             contents on the same line as the field name is empty.  The
10126             remainder of the field is one line per file, each line
10127             being indented by one space and containing a number of
10128             sub-fields separated by spaces.
10129           </p>
10130
10131           <p>
10132             In the <file>.dsc</file> (Debian source control) file each
10133             line contains the MD5 checksum, size and filename of the
10134             tarfile and (if applicable) diff file which make up the
10135             remainder of the source package.
10136             <footnote>
10137               <p>
10138                 That is, the parts which are not the
10139                 <tt>.dsc</tt>.
10140               </p>
10141             </footnote> The exact forms of the filenames are described
10142             in <ref id="pkg-sourcearchives">.
10143           </p>
10144
10145           <p>
10146             In the <file>.changes</file> file this contains one line per
10147             file being uploaded.  Each line contains the MD5 checksum,
10148             size, section and priority and the filename.  The section
10149             and priority are the values of the corresponding fields in
10150             the main source control file - see <ref
10151             id="pkg-f-classification">.  If no section or priority is
10152             specified then <tt>-</tt> should be used, though section
10153             and priority values must be specified for new packages to
10154             be installed properly.
10155           </p>
10156
10157           <p>
10158             The special value <tt>byhand</tt> for the section in a
10159             <tt>.changes</tt> file indicates that the file in question
10160             is not an ordinary package file and must by installed by
10161             hand by the distribution maintainers.  If the section is
10162             <tt>byhand</tt> the priority should be <tt>-</tt>.
10163           </p>
10164
10165           <p>
10166             If a new Debian revision of a package is being shipped and
10167             no new original source archive is being distributed the
10168             <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10169             entry for the original source archive
10170             <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10171             but the <file>.changes</file> file should leave it out.  In
10172             this case the original source archive on the distribution
10173             site must match exactly, byte-for-byte, the original
10174             source archive which was used to generate the
10175             <file>.dsc</file> file and diff which are being uploaded.</p>
10176         </sect1>
10177
10178
10179         <sect1
10180         id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10181           </heading>
10182
10183           <p>
10184             The most recent version of the standards (the Debian Policy
10185             and associated texts) with which the package complies. This
10186             is updated manually when editing the source package to
10187             conform to newer standards; it can sometimes be used to
10188             tell when a package needs attention.
10189           </p>
10190
10191           <p>
10192             Its format is the same as that of a version number except
10193             that no epoch or Debian revision is allowed - see <ref
10194             id="versions">.</p>
10195         </sect1>
10196
10197
10198         <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10199           </heading>
10200
10201           <p>
10202             In a <file>.changes</file> file or parsed changelog output
10203             this contains the (space-separated) name(s) of the
10204             distribution(s) where this version of the package should
10205             be or was installed.  Distribution names follow the rules
10206             for package names.  (See <ref id="pkg-f-Package">).
10207           </p>
10208
10209           <p>
10210             Current distribution values are:
10211           <taglist>
10212             <tag><em>stable</em></tag>
10213             <item>
10214               <p>
10215                 This is the current "released" version of Debian
10216                 GNU/Linux.  A new version is released approximately
10217                 every 3 months after the <em>development</em> code has
10218                 been <em>frozen</em> for a month of testing.  Once the
10219                 distribution is <em>stable</em> only major bug fixes
10220                 are allowed. When changes are made to this
10221                 distribution, the release number is increased
10222                 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10223               </p>
10224             </item>
10225
10226             <tag><em>unstable</em></tag>
10227             <item>
10228               <p>
10229                 This distribution value refers to the
10230                 <em>developmental</em> part of the Debian distribution
10231                 tree. New packages, new upstream versions of packages
10232                 and bug fixes go into the <em>unstable</em> directory
10233                 tree. Download from this distribution at your own
10234                 risk.</p>
10235             </item>
10236
10237             <tag><em>contrib</em></tag>
10238             <item>
10239               <p>
10240                 The packages with this distribution value do not meet
10241                 the criteria for inclusion in the main Debian
10242                 distribution as defined by the Policy Manual, but meet
10243                 the criteria for the <em>contrib</em>
10244                 Distribution. There is currently no distinction
10245                 between stable and unstable packages in the
10246                 <em>contrib</em> or <em>non-free</em>
10247                 distributions. Use your best judgement in downloading
10248                 from this Distribution.</p>
10249             </item>
10250
10251             <tag><em>non-free</em></tag>
10252             <item>
10253               <p>
10254                 Like the packages in the <em>contrib</em> seciton,
10255                 the packages in <em>non-free</em> do not meet the
10256                 criteria for inclusion in the main Debian distribution
10257                 as defined by the Policy Manual. Again, use your best
10258                 judgement in downloading from this Distribution.</p>
10259
10260             <tag><em>experimental</em></tag>
10261             <item>
10262               <p>
10263                 The packages with this distribution value are deemed
10264                 by their maintainers to be high risk. Oftentimes they
10265                 represent early beta or developmental packages from
10266                 various sources that the maintainers want people to
10267                 try, but are not ready to be a part of the other parts
10268                 of the Debian distribution tree. Download at your own
10269                 risk.</p>
10270             </item>
10271
10272             <tag><em>frozen</em></tag>
10273             <item>
10274               <p>
10275                 From time to time, (currently, every 3 months) the
10276                 <em>unstable</em> distribution enters a state of
10277                 "code-freeze" in anticipation of release as a
10278                 <em>stable</em> version. During this period of testing
10279                 (usually 4 weeks) only fixes for existing or
10280                 newly-discovered bugs will be allowed.
10281               </p>
10282             </item>
10283           </taglist> You should list <em>all</em> distributions that
10284           the package should be installed into. Except in unusual
10285           circumstances, installations to <em>stable</em> should also
10286           go into <em>frozen</em> (if it exists) and
10287           <em>unstable</em>. Likewise, installations into
10288           <em>frozen</em> should also go into <em>unstable</em>.</p>
10289         </sect1>
10290
10291         <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10292           </heading>
10293
10294           <p>
10295             This is a description of how important it is to upgrade to
10296             this version from previous ones.  It consists of a single
10297             keyword usually taking one of the values <tt>LOW</tt>,
10298             <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10299             commentary (separated by a space) which is usually in
10300             parentheses.  For example:
10301             <example>
10302   Urgency: LOW (HIGH for diversions users)
10303             </example>
10304           </p>
10305
10306           <p>
10307             This field appears in the <file>.changes</file> file and in
10308             parsed changelogs; its value appears as the value of the
10309             <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10310             changelog (see <ref id="pkg-dpkgchangelog">).
10311           </p>
10312
10313           <p>
10314             Urgency keywords are not case-sensitive.</p>
10315         </sect1>
10316
10317         <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10318           </heading>
10319
10320           <p>
10321             In <tt>.changes</tt> files and parsed changelogs, this
10322             gives the date the package was built or last edited.</p>
10323         </sect1>
10324
10325         <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10326           </heading>
10327
10328           <p>
10329             This field occurs in <file>.changes</file> files, and
10330             specifies a format revision for the file.  The format
10331             described here is version <tt>1.5</tt>.  The syntax of the
10332             format value is the same as that of a package version
10333             number except that no epoch or Debian revision is allowed
10334             - see <ref id="versions">.</p>
10335         </sect1>
10336
10337         <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10338           </heading>
10339
10340           <p>
10341             In a <file>.changes</file> file or parsed changelog this field
10342             contains the human-readable changes data, describing the
10343             differences between the last version and the current one.
10344           </p>
10345
10346           <p>
10347             There should be nothing in this field before the first
10348             newline; all the subsequent lines must be indented by at
10349             least one space; blank lines must be represented by a line
10350             consiting only of a space and a full stop.
10351           </p>
10352
10353           <p>
10354             Each version's change information should be preceded by a
10355             "title" line giving at least the version, distribution(s)
10356             and urgency, in a human-readable way.
10357           </p>
10358
10359           <p>
10360             If data from several versions is being returned the entry
10361             for the most recent version should be returned first, and
10362             entries should be separated by the representation of a
10363             blank line (the "title" line may also be followed by the
10364             representation of blank line).</p>
10365         </sect1>
10366
10367         <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10368         <tt>MSDOS-Filename</tt>
10369           </heading>
10370
10371           <p>
10372             These fields in <tt>Packages</tt> files give the
10373             filename(s) of (the parts of) a package in the
10374             distribution directories, relative to the root of the
10375             Debian hierarchy.  If the package has been split into
10376             several parts the parts are all listed in order, separated
10377             by spaces.</p>
10378         </sect1>
10379
10380         <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10381           </heading>
10382
10383           <p>
10384             These fields in <file>Packages</file> files give the size (in
10385             bytes, expressed in decimal) and MD5 checksum of the
10386             file(s) which make(s) up a binary package in the
10387             distribution.  If the package is split into several parts
10388             the values for the parts are listed in order, separated by
10389             spaces.</p>
10390         </sect1>
10391
10392         <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10393           </heading>
10394
10395           <p>
10396             This field in <prgn>dpkg</prgn>'s status file records
10397             whether the user wants a package installed, removed or
10398             left alone, whether it is broken (requiring
10399             reinstallation) or not and what its current state on the
10400             system is.  Each of these pieces of information is a
10401             single word.</p>
10402         </sect1>
10403
10404         <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10405           </heading>
10406
10407           <p>
10408             If a package is not installed or not configured, this
10409             field in <prgn>dpkg</prgn>'s status file records the last
10410             version of the package which was successfully
10411             configured.</p>
10412         </sect1>
10413
10414         <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10415           </heading>
10416
10417           <p>
10418             This field in <prgn>dpkg</prgn>'s status file contains
10419             information about the automatically-managed configuration
10420             files held by a package.  This field should <em>not</em>
10421             appear anywhere in a package!</p>
10422         </sect1>
10423
10424         <sect1><heading>Obsolete fields
10425           </heading>
10426
10427           <p>
10428             These are still recognised by <prgn>dpkg</prgn> but should
10429             not appear anywhere any more.
10430             <taglist compact="compact">
10431
10432               <tag><tt>Revision</tt></tag>
10433               <tag><tt>Package-Revision</tt></tag>
10434               <tag><tt>Package_Revision</tt></tag>
10435               <item>
10436                 <p>
10437                   The Debian revision part of the package version was
10438                   at one point in a separate control file field.  This
10439                   field went through several names.</p>
10440               </item>
10441
10442               <tag><tt>Recommended</tt></tag>
10443               <item><p>Old name for <tt>Recommends</tt></p>
10444               </item>
10445
10446               <tag><tt>Optional</tt></tag>
10447               <item><p>Old name for <tt>Suggests</tt>.</p>
10448               </item>
10449               <tag><tt>Class</tt></tag>
10450               <item><p>Old name for <tt>Priority</tt>.</p>
10451               </item>
10452             </taglist>
10453           </p>
10454         </sect1>
10455       </sect>
10456     </appendix>
10457
10458     <appendix id="pkg-conffiles"><heading>Configuration file handling
10459     (from old Packaging Manual)
10460       </heading>
10461
10462       <p>
10463         <prgn>dpkg</prgn> can do a certain amount of automatic
10464         handling of package configuration files.
10465       </p>
10466
10467       <p>
10468         Whether this mechanism is appropriate depends on a number of
10469         factors, but basically there are two approaches to any
10470         particular configuration file.
10471       </p>
10472
10473       <p>
10474         The easy method is to ship a best-effort configuration in the
10475         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10476         handle updates.  If the user is unlikely to want to edit the
10477         file, but you need them to be able to without losing their
10478         changes, and a new package with a changed version of the file
10479         is only released infrequently, this is a good approach.
10480       </p>
10481
10482       <p>
10483         The hard method is to build the configuration file from
10484         scratch in the <prgn>postinst</prgn> script, and to take the
10485         responsibility for fixing any mistakes made in earlier
10486         versions of the package automatically.  This will be
10487         appropriate if the file is likely to need to be different on
10488         each system.
10489       </p>
10490
10491       <sect><heading>Automatic handling of configuration files by
10492       <prgn>dpkg</prgn>
10493         </heading>
10494
10495         <p>
10496           A package may contain a control area file called
10497           <tt>conffiles</tt>.  This file should be a list of filenames
10498           of configuration files needing automatic handling, separated
10499           by newlines.  The filenames should be absolute pathnames,
10500           and the files referred to should actually exist in the
10501           package.
10502         </p>
10503
10504         <p>
10505           When a package is upgraded <prgn>dpkg</prgn> will process
10506           the configuration files during the configuration stage,
10507           shortly before it runs the package's <prgn>postinst</prgn>
10508           script,
10509         </p>
10510
10511         <p>
10512           For each file it checks to see whether the version of the
10513           file included in the package is the same as the one that was
10514           included in the last version of the package (the one that is
10515           being upgraded from); it also compares the version currently
10516           installed on the system with the one shipped with the last
10517           version.
10518         </p>
10519
10520         <p>
10521           If neither the user nor the package maintainer has changed
10522           the file, it is left alone.  If one or the other has changed
10523           their version, then the changed version is preferred - i.e.,
10524           if the user edits their file, but the package maintainer
10525           doesn't ship a different version, the user's changes will
10526           stay, silently, but if the maintainer ships a new version
10527           and the user hasn't edited it the new version will be
10528           installed (with an informative message).  If both have
10529           changed their version the user is prompted about the problem
10530           and must resolve the differences themselves.
10531         </p>
10532
10533         <p>
10534           The comparisons are done by calculating the MD5 message
10535           digests of the files, and storing the MD5 of the file as it
10536           was included in the most recent version of the package.
10537         </p>
10538
10539         <p>
10540           When a package is installed for the first time
10541           <prgn>dpkg</prgn> will install the file that comes with it,
10542           unless that would mean overwriting a file already on the
10543           filesystem.
10544         </p>
10545
10546         <p>
10547           However, note that <prgn>dpkg</prgn> will <em>not</em>
10548           replace a conffile that was removed by the user (or by a
10549           script).  This is necessary because with some programs a
10550           missing file produces an effect hard or impossible to
10551           achieve in another way, so that a missing file needs to be
10552           kept that way if the user did it.
10553         </p>
10554
10555         <p>
10556           Note that a package should <em>not</em> modify a
10557           <prgn>dpkg</prgn>-handled conffile in its maintainer
10558           scripts.  Doing this will lead to <prgn>dpkg</prgn> giving
10559           the user confusing and possibly dangerous options for
10560           conffile update when the package is upgraded.</p>
10561       </sect>
10562
10563       <sect><heading>Fully-featured maintainer script configuration
10564       handling
10565         </heading>
10566
10567         <p>
10568           For files which contain site-specific information such as
10569           the hostname and networking details and so forth, it is
10570           better to create the file in the package's
10571           <prgn>postinst</prgn> script.
10572         </p>
10573
10574         <p>
10575           This will typically involve examining the state of the rest
10576           of the system to determine values and other information, and
10577           may involve prompting the user for some information which
10578           can't be obtained some other way.
10579         </p>
10580
10581         <p>
10582           When using this method there are a couple of important
10583           issues which should be considered:
10584         </p>
10585
10586         <p>
10587           If you discover a bug in the program which generates the
10588           configuration file, or if the format of the file changes
10589           from one version to the next, you will have to arrange for
10590           the postinst script to do something sensible - usually this
10591           will mean editing the installed configuration file to remove
10592           the problem or change the syntax.  You will have to do this
10593           very carefully, since the user may have changed the file,
10594           perhaps to fix the very problem that your script is trying
10595           to deal with - you will have to detect these situations and
10596           deal with them correctly.
10597         </p>
10598
10599         <p>
10600           If you do go down this route it's probably a good idea to
10601           make the program that generates the configuration file(s) a
10602           separate program in <file>/usr/sbin</file>, by convention called
10603           <file><var>package</var>config</file> and then run that if
10604           appropriate from the post-installation script.  The
10605           <tt><var>package</var>config</tt> program should not
10606           unquestioningly overwrite an existing configuration - if its
10607           mode of operation is geared towards setting up a package for
10608           the first time (rather than any arbitrary reconfiguration
10609           later) you should have it check whether the configuration
10610           already exists, and require a <tt>--force</tt> flag to
10611           overwrite it.</p></sect>
10612     </appendix>
10613
10614     <appendix id="pkg-alternatives"><heading>Alternative versions of
10615         an interface - <prgn>update-alternatives</prgn> (from old
10616     Packaging Manual)
10617       </heading>
10618
10619       <p>
10620         When several packages all provide different versions of the
10621         same program or file it is useful to have the system select a
10622         default, but to allow the system administrator to change it
10623         and have their decisions respected.
10624       </p>
10625
10626       <p>
10627         For example, there are several versions of the <prgn>vi</prgn>
10628         editor, and there is no reason to prevent all of them from
10629         being installed at once, each under their own name
10630         (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10631         Nevertheless it is desirable to have the name <tt>vi</tt>
10632         refer to something, at least by default.
10633       </p>
10634
10635       <p>
10636         If all the packages involved cooperate, this can be done with
10637         <prgn>update-alternatives</prgn>.
10638       </p>
10639
10640       <p>
10641         Each package provides its own version under its own name, and
10642         calls <prgn>update-alternatives</prgn> in its postinst to
10643         register its version (and again in its prerm to deregister
10644         it).
10645       </p>
10646
10647       <p>
10648         See the manpage <manref name="update-alternatives"
10649         section="8"> for details.
10650       </p>
10651
10652       <p>
10653         If <prgn>update-alternatives</prgn> does not seem appropriate
10654         you may wish to consider using diversions instead.</p>
10655     </appendix>
10656
10657     <appendix id="pkg-diversions"><heading>Diversions - overriding a
10658     package's version of a file (from old Packaging Manual)
10659       </heading>
10660
10661       <p>
10662         It is possible to have <prgn>dpkg</prgn> not overwrite a file
10663         when it reinstalls the package it belongs to, and to have it
10664         put the file from the package somewhere else instead.
10665       </p>
10666
10667       <p>
10668         This can be used locally to override a package's version of a
10669         file, or by one package to override another's version (or
10670         provide a wrapper for it).
10671       </p>
10672
10673       <p>
10674         Before deciding to use a diversion, read <ref
10675         id="pkg-alternatives"> to see if you really want a diversion
10676         rather than several alternative versions of a program.
10677       </p>
10678
10679       <p>
10680         There is a diversion list, which is read by <prgn>dpkg</prgn>,
10681         and updated by a special program <prgn>dpkg-divert</prgn>.
10682         Please see <manref name="dpkg-divert" section="8"> for full
10683         details of its operation.
10684       </p>
10685
10686       <p>
10687         When a package wishes to divert a file from another, it should
10688         call <prgn>dpkg-divert</prgn> in its preinst to add the
10689         diversion and rename the existing file.  For example,
10690         supposing that a <prgn>smailwrapper</prgn> package wishes to
10691         install a wrapper around <file>/usr/sbin/smail</file>:
10692         <example>
10693   if [ install = "$1"  ]; then
10694      dpkg-divert --package smailwrapper --add --rename \
10695         --divert /usr/sbin/smail.real /usr/sbin/smail
10696   fi
10697         </example> Testing <tt>$1</tt> is necessary so that the script
10698         doesn't try to add the diversion again when
10699         <prgn>smailwrapper</prgn> is upgraded.  The <tt>--package
10700         smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10701         copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10702         get installed as the true version.
10703       </p>
10704
10705       <p>
10706         The postrm has to do the reverse:
10707         <example>
10708   if [ remove = "$1" ]; then
10709      dpkg-divert --package smailwrapper --remove --rename \
10710         --divert /usr/sbin/smail.real /usr/sbin/smail
10711   fi
10712         </example>
10713       </p>
10714
10715       <p>
10716         Do not attempt to divert a file which is vitally important for
10717         the system's operation - when using <prgn>dpkg-divert</prgn>
10718         there is a time, after it has been diverted but before
10719         <prgn>dpkg</prgn> has installed the new version, when the file
10720         does not exist.</p>
10721     </appendix>
10722
10723   </book>
10724 </debiandoc>
10725 <!-- vim:set ai et sts=2 sw=2 tw=76: -->