]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
Add 40 points, not 20, when the window manager is compliant with "The
[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                   interpreting the entirity of the rest of the command
7076                   line as a command to pass straight to exec, in the 
7077                   manner that <tt>xterm</tt> does.
7078                 </p></item>
7079
7080               <item><p>
7081                   Support the command-line option <tt>-T
7082                     <var>title</var></tt>, which creates a new terminal
7083                   window with the window title <var>title</var>.
7084                 </p></item>
7085             </list>
7086           </p>
7087         </sect1>
7088
7089         <sect1>
7090           <heading>Packages providing a window manager</heading>
7091
7092           <p>
7093             Packages that provide a window manager should declare in
7094             their control data that they provide the virtual package
7095             <tt>x-window-manager</tt>.  They should also register
7096             themselves as an alternative for
7097             <file>/usr/bin/x-window-manager</file>, with a priority
7098             calculated as follows:
7099             <list compact="compact">
7100               <item><p>Start with a priority of 20.</p></item>
7101
7102               <item>
7103                 <p>
7104                   If the window manager supports the Debian menu
7105                   system, add 20 points if this support is available
7106                   in the package's default configuration (i.e., no
7107                   configuration files belonging to the system or user
7108                   have to be edited to activate the feature); if
7109                   configuration files must be modified, add only 10
7110                   points.
7111                 </p>
7112               </item>
7113               <item>
7114                 <p>
7115                   If the window manager complies with  <url
7116                     id="http://www.freedesktop.org/standards/wm-spec.html"
7117                     name="The Window Manager Specification Project">,
7118                   written by the <url id="http://www.freedesktop.org"
7119                     name="Free Desktop Group">, add 40 points.
7120                 </p>
7121               </item>
7122
7123               <item>
7124                 <p>
7125                   If the window manager permits the X session to be
7126                   restarted using a <em>different</em> window manager
7127                   (without killing the X server) in its default
7128                   configuration, add 10 points; otherwise add none.
7129                 </p>
7130               </item>
7131             </list>
7132           </p>
7133         </sect1>
7134
7135         <sect1>
7136           <heading>Packages providing fonts</heading>
7137
7138           <p>
7139             Packages that provide fonts for the X Window
7140             System<footnote>
7141               <p>
7142                 For the purposes of Debian Policy, a "font for the X
7143                 Window System" is one which is accessed via X protocol
7144                 requests.  Fonts for the Linux console, for PostScript
7145                 renderers, or any other purpose, do not fit this
7146                 definition.  Any tool which makes such fonts available
7147                 to the X Window System, however, must abide by this
7148                 font policy.
7149               </p>
7150             </footnote>
7151             must do a number of things to ensure that they are both
7152             available without modification of the X or font server
7153             configuration, and that they do not corrupt files used by
7154             other font packages to register information about
7155             themselves.
7156             <enumlist>
7157               <item>
7158                 <p>
7159                   Fonts of any type supported by the X Window System
7160                   must be in a separate binary package from any
7161                   executables, libraries, or documentation (except
7162                   that specific to the fonts shipped, such as their
7163                   license information).  If one or more of the fonts
7164                   so packaged are necessary for proper operation of
7165                   the package with which they are associated the font
7166                   package may be Recommended; if the fonts merely
7167                   provide an enhancement, a Suggests relationship may
7168                   be used.  Packages must not Depend on font
7169                   packages.<footnote>
7170                     <p>
7171                       This is because the X server may retrieve fonts
7172                       from the local filesystem or over the network
7173                       from an X font server; the Debian package system
7174                       is empowered to deal only with the local
7175                       filesystem.
7176                     </p>
7177                   </footnote>
7178                 </p>
7179               </item>
7180
7181               <item>
7182                 <p>
7183                   BDF fonts must be converted to PCF fonts with the
7184                   <prgn>bdftopcf</prgn> utility (available in the
7185                   <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7186                   placed in a directory that corresponds to their
7187                   resolution:
7188                   <list compact="compact">
7189                     <item><p>
7190                         100 dpi fonts must be placed in
7191                         <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7192                       </p></item>
7193
7194                     <item><p>
7195                         75 dpi fonts must be placed in
7196                         <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7197                       </p></item>
7198
7199                     <item><p>
7200                         Character-cell fonts, cursor fonts, and other
7201                         low-resolution fonts must be placed in
7202                         <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7203                       </p></item>
7204                   </list>
7205                 </p>
7206               </item>
7207
7208               <item><p>
7209                   Speedo fonts must be placed in
7210                   <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7211                 </p></item>
7212
7213               <item><p>
7214                   Type 1 fonts must be placed in
7215                   <file>/usr/X11R6/lib/X11/fonts/Type1/</file>.  If font
7216                   metric files are available, they must be placed here
7217                   as well.
7218                 </p></item>
7219
7220               <item>
7221                 <p>
7222                   Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7223                   other than those listed above must be neither
7224                   created nor used.  (The <file>PEX</file>, <file>CID</file>,
7225                   and <file>cyrillic</file> directories are excepted for
7226                   historical reasons, but installation of files into
7227                   these directories remains discouraged.)
7228                 </p>
7229               </item>
7230
7231               <item>
7232                 <p>
7233                   Font packages may, instead of placing files directly
7234                   in the X font directories listed above, provide
7235                   symbolic links in that font directory pointing to
7236                   the files' actual location in the filesystem.  Such
7237                   a location must comply with the FHS.
7238                 </p>
7239               </item>
7240
7241               <item>
7242                 <p>
7243                   Font packages should not contain both 75dpi and
7244                   100dpi versions of a font.  If both are available,
7245                   they should be provided in separate binary packages
7246                   with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7247                   the names of the packages containing the
7248                   corresponding fonts.
7249                 </p>
7250               </item>
7251
7252               <item>
7253                 <p>
7254                   Fonts destined for the <file>misc</file> subdirectory
7255                   should not be included in the same package as 75dpi
7256                   or 100dpi fonts; instead, they should be provided in
7257                   a separate package with <tt>-misc</tt> appended to
7258                   its name.
7259                 </p>
7260               </item>
7261
7262               <item>
7263                 <p>
7264                   Font packages must not provide the files
7265                   <file>fonts.dir</file>, <file>fonts.alias</file>, or
7266                   <file>fonts.scale</file> in a font directory:
7267                   <list>
7268                     <item><p>
7269                         <file>fonts.dir</file> files must not be provided at all.
7270                       </p></item>
7271
7272                     <item>
7273                       <p>
7274                         <file>fonts.alias</file> and <file>fonts.scale</file>
7275                         files, if needed, should be provided in the
7276                         directory
7277                         <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7278                         where <var>fontdir</var> is the name of the
7279                         subdirectory of
7280                         <file>/usr/X11R6/lib/X11/fonts/</file> where the
7281                         package's corresponding fonts are stored
7282                         (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7283                         <var>package</var> is the name of the package
7284                         that provides these fonts, and
7285                         <var>extension</var> is either <tt>scale</tt>
7286                         or <tt>alias</tt>, whichever corresponds to
7287                         the file contents.
7288                       </p>
7289                     </item>
7290                   </list>
7291                 </p>
7292               </item>
7293
7294               <item>
7295                 <p>
7296                   Font packages must declare a dependency on
7297                   <tt>xutils (&gt;&gt; 4.0.3)</tt> in their control
7298                   data.
7299                 </p>
7300               </item>
7301
7302               <item>
7303                 <p>
7304                   Font packages that provide one or more
7305                   <file>fonts.scale</file> files as described above must
7306                   invoke <prgn>update-fonts-scale</prgn> on each
7307                   directory into which they installed fonts
7308                   <em>before</em> invoking
7309                   <prgn>update-fonts-dir</prgn> on that directory.
7310                   This invocation must occur in both the
7311                   <prgn>postinst</prgn> (for all arguments) and
7312                   <prgn>postrm</prgn> (for all arguments except
7313                   <tt>upgrade</tt>) scripts.
7314                 </p>
7315               </item>
7316
7317               <item>
7318                 <p>
7319                   Font packages that provide one or more
7320                   <file>fonts.alias</file> files as described above must
7321                   invoke <prgn>update-fonts-alias</prgn> on each
7322                   directory into which they installed fonts.  This
7323                   invocation must occur in both the
7324                   <prgn>postinst</prgn> (for all arguments) and
7325                   <prgn>postrm</prgn> (for all arguments except
7326                   <tt>upgrade</tt>) scripts.
7327                 </p>
7328               </item>
7329
7330               <item>
7331                 <p>
7332                   Font packages must invoke
7333                   <prgn>update-fonts-dir</prgn> on each directory into
7334                   which they installed fonts.  This invocation must
7335                   occur in both the <prgn>postinst</prgn> (for all
7336                   arguments) and <prgn>postrm</prgn> (for all
7337                   arguments except <tt>upgrade</tt>) scripts.
7338                 </p>
7339               </item>
7340
7341               <item>
7342                 <p>
7343                   Font packages must not provide alias names for the
7344                   fonts they include which collide with alias names
7345                   already in use by fonts already packaged.
7346                 </p>
7347               </item>
7348
7349               <item>
7350                 <p>
7351                   Font packages must not provide fonts with the same
7352                   XLFD registry name as another font already packaged.
7353                 </p>
7354               </item>
7355             </enumlist>
7356           </p>
7357         </sect1>
7358
7359         <sect1>
7360           <heading>Application defaults files</heading>
7361
7362           <p>
7363             Application defaults files must be installed in the
7364             directory <file>/etc/X11/app-defaults/</file> (use of a
7365             localized subdirectory of <file>/etc/X11/</file> as described
7366             in the <em>X Toolkit Intrinsics - C Language
7367             Interface</em> manual is also permitted).  They must be
7368             registered as <tt>conffile</tt>s or handled as
7369             configuration files.  Packages must not provide the
7370             directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7371           </p>
7372
7373           <p>
7374             Customization of programs' X resources may also be
7375             supported with the provision of a file with the same name
7376             as that of the package placed in the
7377             <file>/etc/X11/Xresources/</file> directory, which must
7378             registered as a <tt>conffile</tt> or handled as a
7379             configuration file.<footnote>
7380               <p>
7381                 Note that this mechanism is not the same as using
7382                 app-defaults; app-defaults are tied to the client
7383                 binary on the local filesystem, whereas X resources
7384                 are stored in the X server and affect all connecting
7385                 clients.
7386               </p>
7387             </footnote>
7388             <em>Important:</em> packages that install files into the
7389             <file>/etc/X11/Xresources/</file> directory must conflict with
7390             <tt>xbase (&lt;&lt; 3.3.2.3a-2)</tt>; if this is not done
7391             it is possible for the installing package to destroy a
7392             previously-existing <file>/etc/X11/Xresources</file> file
7393             which had been customized by the system administrator.
7394           </p>
7395         </sect1>
7396
7397         <sect1>
7398           <heading>Installation directory issues</heading>
7399
7400           <p>
7401             Packages using the X Window System should not be
7402             configured to install files under the <file>/usr/X11R6/</file>
7403             directory unless they use <prgn>imake</prgn>. The
7404             <file>/usr/X11R6/</file> directory hierarchy should be
7405             regarded as deprecated for all packages except the X
7406             Window System itself, and those which use the
7407             <prgn>imake</prgn> program it provides, in which case the
7408             packages may transition out of the <file>/usr/X11R6/</file>
7409             directory at the maintainer's discretion.<footnote>
7410               <p>
7411                 <prgn>Imake</prgn>-using programs are exempt because,
7412                 as long as they are written correctly, the pathnames
7413                 they use to locate resources and install themselves
7414                 are derived wholly from the X Window System
7415                 configuration.  Thus, in the event that the X Window
7416                 System moves to <file>/usr/X11R7/</file>,
7417                 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7418                 that is required for these programs is a recompile
7419                 against the corresponding X Window System library
7420                 development packages.
7421               </p>
7422             </footnote>
7423             Programs that use GNU <prgn>autoconf</prgn> and
7424             <prgn>automake</prgn> are usually easily configured at
7425             compile time to use <file>/usr/</file> instead of
7426             <file>/usr/X11R6/</file>, and this should be done whenever
7427             possible.  Configuration files for window managers and
7428             display managers should be placed in a subdirectory of
7429             <file>/etc/X11/</file> corresponding to the package name due
7430             to these programs' tight integration with the mechanisms
7431             of the X Window System.  Application-level programs should
7432             use the <file>/etc/</file> directory unless otherwise mandated
7433             by policy.  The installation of files into subdirectories
7434             of <file>/usr/X11R6/include/X11/</file> and
7435             <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7436             package maintainers should determine if subdirectories of
7437             <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7438             instead.  (The use of symbolic links from the
7439             <file>X11R6</file> directories to other FHS-compliant
7440             locations is encouraged if the program is not easily
7441             configured to look elsewhere for its files.)  Packages
7442             must not provide or install files into the directories
7443             <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7444             <file>/usr/lib/X11/</file>.  Files within a package should,
7445             however, make reference to these directories, rather than
7446             their <tt>X11R6</tt>-named counterparts
7447             <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7448             and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7449             referred to have not been moved to other FHS-compliant
7450             locations.
7451           </p>
7452         </sect1>
7453
7454         <sect1>
7455           <heading>The OSF/Motif and OpenMotif libraries</heading>
7456
7457           <p>
7458             <em>Programs that require the non-DFSG-compliant OSF/Motif or
7459               OpenMotif libraries</em><footnote>
7460               <p>
7461                 OSF/Motif and OpenMotif are collectively referred to as
7462                 "Motif" in this policy document.
7463               </p>
7464             </footnote>
7465             should be compiled against and tested with LessTif (a free
7466             re-implementation of Motif) instead.  If the maintainer
7467             judges that the program or programs do not work
7468             sufficiently well with LessTif to be distributed and
7469             supported, but do so when compiled against Motif, then two
7470             versions of the package should be created; one linked
7471             statically against Motif and with <tt>-smotif</tt>
7472             appended to the package name, and one linked dynamically
7473             against Motif and with <tt>-dmotif</tt> appended to the
7474             package name.  Both Motif-linked versions are dependent
7475             upon non-DFSG-compliant software and thus cannot be
7476             uploaded to the <em>main</em> distribution; if the
7477             software is itself DFSG-compliant it may be uploaded to
7478             the <em>contrib</em> distribution.  While known existing
7479             versions of Motif permit unlimited redistribution of
7480             binaries linked against the library (whether statically or
7481             dynamically), it is the package maintainer's
7482             responsibility to determine whether this is permitted by
7483             the license of the copy of Motif in his or her possession.
7484           </p>
7485         </sect1>
7486       </sect>
7487
7488       <sect>
7489         <heading>Perl programs and modules</heading>
7490
7491         <p>
7492           Perl programs and modules should follow the current Perl policy.
7493         </p>
7494
7495         <p>
7496           The Perl policy can be found in the <tt>perl-policy</tt>
7497           files in the <tt>debian-policy</tt> package.
7498           They are also available from the Debian web mirrors at
7499           <tt><url name="/doc/packaging-manuals/perl-policy/"
7500                 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>
7501           and from the Debian archive mirrors at
7502           <tt><url name="/doc/package-developer/perl-policy.txt.gz"
7503                 id="http://ftp.debian.org/debian/doc/package-developer/perl-policy.txt.gz"></tt>.
7504         </p>
7505       </sect>
7506
7507       <sect>
7508         <heading>Emacs lisp programs</heading>
7509
7510         <p>
7511           Please refer to the "Debian Emacs Policy" for details of how to
7512           package emacs lisp programs.
7513         </p>
7514
7515         <p>
7516           The Emacs policy is available in
7517           <file>debian-emacs-policy.gz</file> of the
7518           <package>emacsen-common</package> package.
7519           It is also available from the Debian web mirrors at
7520           <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
7521                 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
7522         </p>
7523       </sect>
7524
7525       <sect>
7526         <heading>Games</heading>
7527
7528         <p>
7529           The permissions on <file>/var/games</file> are mode 755, owner
7530           <tt>root</tt> and group <tt>root</tt>.
7531         </p>
7532
7533         <p>
7534           Each game decides on its own security policy.</p>
7535
7536         <p>
7537           Games which require protected, privileged access to
7538           high-score files, savegames, etc., may be made
7539           set-<em>group</em>-id (mode 2755) and owned by
7540           <tt>root.games</tt>, and use files and directories with
7541           appropriate permissions (770 <tt>root.games</tt>, for
7542           example).  They must not be made
7543           set-<em>user</em>-id, as this causes security problems. (If
7544           an attacker can subvert any set-user-id game they can
7545           overwrite the executable of any other, causing other players
7546           of these games to run a Trojan horse program.  With a
7547           set-group-id game the attacker only gets access to less
7548           important game data, and if they can get at the other
7549           players' accounts at all it will take considerably more
7550           effort.)</p>
7551
7552         <p>
7553           Some packages, for example some fortune cookie programs, are
7554           configured by the upstream authors to install with their
7555           data files or other static information made unreadable so
7556           that they can only be accessed through set-id programs
7557           provided.  You should not do this in a Debian package: anyone can
7558           download the <file>.deb</file> file and read the data from it,
7559           so there is no point making the files unreadable.  Not
7560           making the files unreadable also means that you don't have
7561           to make so many programs set-id, which reduces the risk of a
7562           security hole.</p>
7563
7564         <p>
7565           As described in the FHS, binaries of games should be
7566           installed in the directory <file>/usr/games</file>. This also
7567           applies to games that use the X Window System. Manual pages
7568           for games (X and non-X games) should be installed in
7569           <file>/usr/share/man/man6</file>.</p>
7570       </sect>
7571     </chapt>
7572
7573     <chapt id="docs"><heading>Documentation</heading>
7574
7575
7576       <sect>
7577         <heading>Manual pages</heading>
7578
7579         <p>
7580           You should install manual pages in <prgn>nroff</prgn> source
7581           form, in appropriate places under <file>/usr/share/man</file>.
7582           You should only use sections 1 to 9 (see the FHS for more
7583           details).  You must not install a preformatted "cat page".
7584         </p>
7585
7586         <p>
7587           Each program, utility, and function should have an
7588           associated manual page included in the same package. It is
7589           suggested that all configuration files also have a manual
7590           page included as well. Manual pages for protocols and other
7591           auxiliary things are optional.
7592         </p>
7593
7594         <p>
7595           If no manual page is available, this is considered as a bug
7596           and should be reported to the Debian Bug Tracking System (the
7597           maintainer of the package is allowed to write this bug report
7598           themselves, if they so desire).  Do not close the bug report
7599           until a proper manpage is available.<footnote>
7600             <p>
7601               It is not very hard to write a man page. See the 
7602               <url id="http://www.schweikhardt.net/man_page_howto.html"
7603                 name="Man-Page-HOWTO">, 
7604               <manref name="man" section="7">, the examples
7605               created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7606               the helper programs <prgn>help2man</prgn>, or the
7607               directory <file>/usr/share/doc/man-db/examples</file>.
7608             </p>
7609           </footnote>
7610         </p>
7611
7612         <p>
7613           You may forward a complaint about a missing manpage to the
7614           upstream authors, and mark the bug as forwarded in the
7615           Debian bug tracking system.  Even though the GNU Project do
7616           not in general consider the lack of a manpage to be a bug,
7617           we do; if they tell you that they don't consider it a bug
7618           you should leave the bug in our bug tracking system open
7619           anyway.
7620         </p>
7621
7622         <p>
7623           Manual pages should be installed compressed using <tt>gzip -9</tt>.
7624         </p>
7625
7626         <p>
7627           If one manpage needs to be accessible via several names it
7628           is better to use a symbolic link than the <file>.so</file>
7629           feature, but there is no need to fiddle with the relevant
7630           parts of the upstream source to change from <file>.so</file> to
7631           symlinks: don't do it unless it's easy.  You should not
7632           create hard links in the manual page directories, nor put
7633           absolute filenames in <file>.so</file> directives.  The filename
7634           in a <file>.so</file> in a manpage should be relative to the
7635           base of the manpage tree (usually
7636           <file>/usr/share/man</file>). If you do not create any links
7637           (whether symlinks, hard links, or <tt>.so</tt> directives)
7638           in the filesystem to the alternate names of the manpage,
7639           then you should not rely on <prgn>man</prgn> finding your
7640           manpage under those names based solely on the information in
7641           the manpage's header.<footnote>
7642             <p>
7643               Supporting this in <prgn>man</prgn> often requires
7644               unreasonable processing time to find a manual page or to
7645               report that none exists, and moves knowledge into man's
7646               database that would be better left in the filesystem.
7647               This support is therefore deprecated and will cease to
7648               be present in the future.
7649             </p>
7650           </footnote>
7651         </p>
7652       </sect>
7653
7654       <sect>
7655         <heading>Info documents</heading>
7656
7657         <p>
7658           Info documents should be installed in <file>/usr/share/info</file>.
7659           They should be compressed with <tt>gzip -9</tt>.
7660         </p>
7661
7662         <p>
7663           Your package should call <prgn>install-info</prgn> to update
7664           the Info <file>dir</file> file in its <prgn>postinst</prgn>
7665           script when called with a <tt>configure</tt> argument, for
7666           example:
7667           <example compact="compact">
7668 install-info --quiet --section Development Development \
7669   /usr/share/info/foobar.info
7670           </example></p>
7671
7672         <p>
7673           It is a good idea to specify a section for the location of
7674           your program; this is done with the <tt>--section</tt>
7675           switch.  To determine which section to use, you should look
7676           at <file>/usr/share/info/dir</file> on your system and choose the most
7677           relevant (or create a new section if none of the current
7678           sections are relevant).  Note that the <tt>--section</tt>
7679           flag takes two arguments; the first is a regular expression
7680           to match (case-insensitively) against an existing section,
7681           the second is used when creating a new one.</p>
7682
7683         <p>
7684           You should remove the entries in the <prgn>prerm</prgn>
7685           script when called with a <tt>remove</tt> argument:
7686           <example compact="compact">
7687 install-info --quiet --remove /usr/share/info/foobar.info
7688           </example></p>
7689
7690         <p>
7691           If <prgn>install-info</prgn> cannot find a description entry
7692           in the Info file you must supply one.  See <manref
7693           name="install-info" section="8"> for details.</p>
7694       </sect>
7695
7696       <sect>
7697         <heading>Additional documentation</heading>
7698
7699         <p>
7700           Any additional documentation that comes with the package may
7701           be installed at the discretion of the package maintainer.
7702           Text documentation should be installed in the directory
7703           <file>/usr/share/doc/<var>package</var></file>, where
7704           <var>package</var> is the name of the package, and
7705           compressed with <tt>gzip -9</tt> unless it is small.
7706         </p>
7707
7708         <p>
7709           If a package comes with large amounts of documentation which
7710           many users of the package will not require you should create
7711           a separate binary package to contain it, so that it does not
7712           take up disk space on the machines of users who do not need
7713           or want it installed.</p>
7714
7715         <p>
7716           It is often a good idea to put text information files
7717           (<file>README</file>s, changelogs, and so forth) that come with
7718           the source package in <file>/usr/share/doc/<var>package</var></file>
7719           in the binary package.  However, you don't need to install
7720           the instructions for building and installing the package, of
7721           course!</p>
7722
7723         <p>
7724           Packages must not require the existance of any files in
7725           <file>/usr/share/doc/</file> in order to function
7726           <footnote>
7727             <p>
7728               The system administrator should be able to
7729               delete files in <file>/usr/share/doc/</file> without causing
7730               any programs to break.
7731             </p>
7732           </footnote>.
7733           Any files that are referenced by programs but are also
7734           useful as standalone documentation should be installed under
7735           <file>/usr/share/<var>package</var>/</file> with symbolic links from
7736           <file>/usr/share/doc/<var>package</var></file>.
7737         </p>
7738
7739         <p>
7740           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7741           link to another directory in <file>/usr/share/doc</file> only if
7742           the two packages both come from the same source and the
7743           first package Depends on the second.
7744         </p>
7745
7746         <p>
7747           Former Debian releases placed all additional documentation
7748           in <file>/usr/doc/<var>package</var></file>.  This has been
7749           changed to <file>/usr/share/doc/<var>package</var></file>,
7750           and packages must not put documentation in the directory
7751           <file>/usr/doc/<var>package</var></file>. <footnote>
7752             <p>At this phase of the transition, we no longer require a
7753             symbolic link in <file>/usr/doc/</file>. At a later point,
7754             policy shall change to make the symbolic links a bug.</p>
7755           </footnote>
7756         </p>
7757       </sect>
7758
7759       <sect>
7760         <heading>Preferred documentation formats</heading>
7761
7762         <p>
7763           The unification of Debian documentation is being carried out
7764           via HTML.</p>
7765
7766         <p>
7767           If your package comes with extensive documentation in a
7768           markup format that can be converted to various other formats
7769           you should if possible ship HTML versions in a binary
7770           package, in the directory
7771           <file>/usr/share/doc/<var>appropriate-package</var></file> or
7772           its subdirectories.<footnote>
7773             <p>
7774               The rationale: The important thing here is that HTML
7775               docs should be available in <em>some</em> package, not
7776               necessarily in the main binary package.
7777             </p>
7778           </footnote>
7779         </p>
7780
7781         <p>
7782           Other formats such as PostScript may be provided at the
7783           package maintainer's discretion.
7784         </p>
7785       </sect>
7786
7787       <sect id="copyrightfile">
7788         <heading>Copyright information</heading>
7789
7790         <p>
7791           Every package must be accompanied by a verbatim copy of its
7792           copyright and distribution license in the file
7793           <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7794           file must neither be compressed nor be a symbolic link.
7795         </p>
7796
7797         <p>
7798           In addition, the copyright file must say where the upstream
7799           sources (if any) were obtained.  It should name the original
7800           authors of the package and the Debian maintainer(s) who were
7801           involved with its creation.</p>
7802
7803         <p>
7804           A copy of the file which will be installed in
7805           <file>/usr/share/doc/<var>package</var>/copyright</file> should
7806           be in <file>debian/copyright</file> in the source package.
7807         </p>
7808
7809         <p>
7810           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7811           link to another directory in <file>/usr/share/doc</file> only if
7812           the two packages both come from the same source and the
7813           first package Depends on the second.  These rules are
7814           important because copyrights must be extractable by
7815           mechanical means.
7816         </p>
7817
7818         <p>
7819           Packages distributed under the UCB BSD license, the Artistic
7820           license, the GNU GPL, and the GNU LGPL should refer to the
7821           files <file>/usr/share/common-licenses/BSD</file>,
7822           <file>/usr/share/common-licenses/Artistic</file>,
7823           <file>/usr/share/common-licenses/GPL</file>, and
7824           <file>/usr/share/common-licenses/LGPL</file> respectively,
7825           rather than quoting them in the copyright file.
7826         </p>
7827
7828         <p>
7829           You should not use the copyright file as a general <file>README</file>
7830           file.  If your package has such a file it should be
7831           installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7832           <file>README.Debian</file> or some other appropriate place.</p>
7833       </sect>
7834
7835       <sect>
7836         <heading>Examples</heading>
7837
7838         <p>
7839           Any examples (configurations, source files, whatever),
7840           should be installed in a directory
7841           <file>/usr/share/doc/<var>package</var>/examples</file>.  These
7842           files should not be referenced by any program: they're there
7843           for the benefit of the system administrator and users as
7844           documentation only.  Architecture-specific example files
7845           should be installed in a directory
7846           <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7847           links to them from
7848           <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7849           latter directory itself may be a symbolic link to the
7850           former.
7851         </p>
7852
7853         <p>
7854           If the purpose of a package is to provide examples, then the
7855           example files may be installed into
7856           <file>/usr/share/doc/<var>package</var></file>.
7857         </p>
7858       </sect>
7859
7860       <sect id="changelogs">
7861         <heading>Changelog files</heading>
7862
7863         <p>
7864           The Debian changelog file (<file>debian/changelog</file>) should
7865           explain briefly what modifications were made in the Debian version
7866           of the package compared to the upstream one. Other changes and
7867           updates to the package should also be documented in this file.
7868         </p>
7869
7870         <p>
7871           Mistakes in changelogs are usually best rectified by
7872           making a new changelog entry rather than "rewriting history"
7873           by editing old changelog entries.
7874         </p>
7875
7876         <p>
7877           The format of the <file>debian/changelog</file> file is described
7878           in <ref id="dpkgchangelog">. In non-experimental packages you must
7879           use a format for <file>debian/changelog</file> which is supported
7880           by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7881             <p>
7882               If you wish to use an alternative format, you may do so as
7883               long as you include a parser for it in your source package.
7884               The parser must have an API compatible with that expected by
7885               <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7886               If there is general interest in the new format, you should
7887               contact the <package>dpkg</package> maintainer to have the
7888               parser script for it included in the <prgn>dpkg</prgn>
7889               package.  (You will need to agree that the parser and its
7890               manpage may be distributed under the GNU GPL, just as the rest
7891               of <prgn>dpkg</prgn> is.)
7892             </p>
7893           </footnote>
7894         </p>
7895
7896         <p>
7897           Packages that are not Debian-native must contain a
7898           compressed copy of the <file>debian/changelog</file> file from
7899           the Debian source tree in
7900           <file>/usr/share/doc/<var>package</var></file> with the name
7901           <file>changelog.Debian.gz</file>.
7902         </p>
7903
7904         <p>
7905           If an upstream changelog is available, it should be accessible as
7906           <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7907           plain text.  If the upstream changelog is distributed in
7908           HTML, it should be made available in that form as
7909           <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7910           and a plain text <file>changelog.gz</file> should be generated
7911           from it using, for example, <tt>lynx -dump -nolist</tt>.  If
7912           the upstream changelog files do not already conform to this
7913           naming convention, then this may be achieved either by
7914           renaming the files, or by adding a symbolic link, at the
7915           maintainer's discretion.<footnote>
7916             <p>
7917               Rationale: People should not have to look in places for
7918               upstream changelogs merely because they are given
7919               different names or are distributed in HTML format.
7920             </p>
7921           </footnote>
7922         </p>
7923
7924         <p>
7925           All of these files should be installed compressed using
7926           <tt>gzip -9</tt>, as they will become large with time even
7927           if they start out small.
7928         </p>
7929
7930         <p>
7931           If the package has only one changelog which is used both as
7932           the Debian changelog and the upstream one because there is
7933           no separate upstream maintainer then that changelog should
7934           usually be installed as
7935           <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7936           there is a separate upstream maintainer, but no upstream
7937           changelog, then the Debian changelog should still be called
7938           <file>changelog.Debian.gz</file>.</p>
7939
7940       </sect>
7941     </chapt>
7942
7943     <appendix id="pkg-scope">
7944       <heading>Introduction and scope of these appendices</heading>
7945
7946       <p>
7947         These appendices are taken essentially verbatim from the
7948         now-deprecated Packaging Manual, version 3.2.1.0.  They are
7949         the chapters which are likely to be of use to package
7950         maintainers and which have not already been included in the
7951         policy document itself. Most of these sections are very likely
7952         not relevant to policy; they should be treated as
7953         documentation for the packaging system. Please note that these
7954         appendices are included for convenience, and for historical
7955         reasons: they used to be part of policy package, and they have
7956         not yet been incorporated into dpkg documentation. However,
7957         they still have value, and hence they are presented here.
7958       </p>
7959       <p>
7960         They have not yet been checked to ensure that they are
7961         compatible with the contents of policy, and if there are any
7962         contradictions, the version in the main policy document takes
7963         precedence.  The remaining chapters of the old Packaging
7964         Manual have also not been read in detail to ensure that there
7965         are not parts which have been left out.  Both of these will be
7966         done in due course.
7967       </p>
7968
7969       <p>
7970         <prgn>dpkg</prgn> is a suite of programs for creating binary
7971         package files and installing and removing them on Unix
7972         systems.<footnote>
7973           <p>
7974             <prgn>dpkg</prgn> is targetted primarily at Debian
7975             GNU/Linux, but may work on or be ported to other
7976             systems.
7977           </p>
7978         </footnote>
7979       </p>
7980
7981       <p>
7982         The binary packages are designed for the management of
7983         installed executable programs (usually compiled binaries) and
7984         their associated data, though source code examples and
7985         documentation are provided as part of some packages.</p>
7986
7987       <p>
7988         This manual describes the technical aspects of creating Debian
7989         binary packages (<file>.deb</file> files).  It documents the
7990         behaviour of the package management programs
7991         <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7992         they interact with packages.</p>
7993
7994       <p>
7995         It also documents the interaction between
7996         <prgn>dselect</prgn>'s core and the access method scripts it
7997         uses to actually install the selected packages, and describes
7998         how to create a new access method.</p>
7999
8000       <p>
8001         This manual does not go into detail about the options and
8002         usage of the package building and installation tools.  It
8003         should therefore be read in conjuction with those programs'
8004         manpages.
8005       </p>
8006
8007       <p>
8008         The utility programs which are provided with <prgn>dpkg</prgn>
8009         for managing various system configuration and similar issues,
8010         such as <prgn>update-rc.d</prgn> and
8011         <prgn>install-info</prgn>, are not described in detail here -
8012         please see their manpages.
8013       </p>
8014
8015       <p>
8016         It is assumed that the reader is reasonably familiar with the
8017         <prgn>dpkg</prgn> System Administrators' manual.
8018         Unfortunately this manual does not yet exist.
8019       </p>
8020
8021       <p>
8022         The Debian version of the FSF's GNU hello program is provided
8023         as an example for people wishing to create Debian
8024         packages. The Debian <prgn>debmake</prgn> package is
8025         recommended as a very helpful tool in creating and maintaining
8026         Debian packages. However, while the tools and examples are
8027         helpful, they do not replace the need to read and follow the
8028         Policy and Programmer's Manual.</p>
8029     </appendix>
8030
8031     <appendix id="pkg-binarypkg"><heading>Binary packages (from old
8032     Packaging Manual)
8033       </heading>
8034
8035       <p>
8036         The binary package has two main sections.  The first part
8037         consists of various control information files and scripts used
8038         by <prgn>dpkg</prgn> when installing and removing.  See <ref
8039         id="pkg-controlarea">.
8040       </p>
8041
8042       <p>
8043         The second part is an archive containing the files and
8044         directories to be installed.
8045       </p>
8046
8047       <p>
8048         In the future binary packages may also contain other
8049         components, such as checksums and digital signatures. The
8050         format for the archive is described in full in the
8051         <file>deb(5)</file> manpage.
8052       </p>
8053
8054
8055       <sect id="pkg-bincreating"><heading>Creating package files -
8056       <prgn>dpkg-deb</prgn>
8057         </heading>
8058
8059         <p>
8060           All manipulation of binary package files is done by
8061           <prgn>dpkg-deb</prgn>; it's the only program that has
8062           knowledge of the format.  (<prgn>dpkg-deb</prgn> may be
8063           invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
8064           will spot that the options requested are appropriate to
8065           <prgn>dpkg-deb</prgn> and invoke that instead with the same
8066           arguments.)
8067         </p>
8068
8069         <p>
8070           In order to create a binary package you must make a
8071           directory tree which contains all the files and directories
8072           you want to have in the filesystem data part of the package.
8073           In Debian-format source packages this directory is usually
8074           <file>debian/tmp</file>, relative to the top of the package's
8075           source tree.
8076         </p>
8077
8078         <p>
8079           They should have the locations (relative to the root of the
8080           directory tree you're constructing) ownerships and
8081           permissions which you want them to have on the system when
8082           they are installed.
8083         </p>
8084
8085         <p>
8086           With current versions of <prgn>dpkg</prgn> the uid/username
8087           and gid/groupname mappings for the users and groups being
8088           used should be the same on the system where the package is
8089           built and the one where it is installed.
8090         </p>
8091
8092         <p>
8093           You need to add one special directory to the root of the
8094           miniature filesystem tree you're creating:
8095           <prgn>DEBIAN</prgn>.  It should contain the control
8096           information files, notably the binary package control file
8097           (see <ref id="pkg-controlfile">).
8098         </p>
8099
8100         <p>
8101           The <prgn>DEBIAN</prgn> directory will not appear in the
8102           filesystem archive of the package, and so won't be installed
8103           by <prgn>dpkg</prgn> when the package is installed.
8104         </p>
8105
8106         <p>
8107           When you've prepared the package, you should invoke:
8108           <example>
8109   dpkg --build <var>directory</var>
8110           </example>
8111         </p>
8112
8113         <p>
8114           This will build the package in
8115           <file><var>directory</var>.deb</file>.  (<prgn>dpkg</prgn> knows
8116           that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8117           it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8118           build the package.)
8119         </p>
8120
8121         <p>
8122           See the manpage <manref name="dpkg-deb" section="8"> for details of how
8123           to examine the contents of this newly-created file.  You may find the
8124           output of following commands enlightening:
8125           <example>
8126   dpkg-deb --info <var>filename</var>.deb
8127   dpkg-deb --contents <var>filename</var>.deb
8128   dpkg --contents <var>filename</var>.deb
8129           </example>
8130           To view the copyright file for a package you could use this command:
8131           <example>
8132   dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8133           </example>
8134         </p>
8135       </sect>
8136
8137       <sect id="pkg-controlarea">
8138         <heading>
8139           Package control information files
8140         </heading>
8141
8142         <p>
8143           The control information portion of a binary package is a
8144           collection of files with names known to <prgn>dpkg</prgn>.
8145           It will treat the contents of these files specially - some
8146           of them contain information used by <prgn>dpkg</prgn> when
8147           installing or removing the package; others are scripts which
8148           the package maintainer wants <prgn>dpkg</prgn> to run.
8149         </p>
8150
8151         <p>
8152           It is possible to put other files in the package control
8153           area, but this is not generally a good idea (though they
8154           will largely be ignored).
8155         </p>
8156
8157         <p>
8158           Here is a brief list of the control info files supported by
8159           <prgn>dpkg</prgn> and a summary of what they're used for.
8160         </p>
8161
8162         <p>
8163           <taglist>
8164             <tag><tt>control</tt>
8165             <item>
8166
8167               <p>
8168                 This is the key description file used by
8169                 <prgn>dpkg</prgn>.  It specifies the package's name
8170                 and version, gives its description for the user,
8171                 states its relationships with other packages, and so
8172                 forth.  See <ref id="pkg-controlfile">.
8173               </p>
8174
8175               <p>
8176                 It is usually generated automatically from information
8177                 in the source package by the
8178                 <prgn>dpkg-gencontrol</prgn> program, and with
8179                 assistance from <prgn>dpkg-shlibdeps</prgn>.  See <ref
8180                 id="pkg-sourcetools">.</p>
8181             </item>
8182
8183             <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8184             <tt>prerm</tt>
8185             </tag>
8186             <item>
8187
8188               <p>
8189                 These are exectuable files (usually scripts) which
8190                 <prgn>dpkg</prgn> runs during installation, upgrade
8191                 and removal of packages.  They allow the package to
8192                 deal with matters which are particular to that package
8193                 or require more complicated processing than that
8194                 provided by <prgn>dpkg</prgn>.  Details of when and
8195                 how they are called are in <ref
8196                 id="maintainerscripts">.
8197               </p>
8198
8199               <p>
8200                 It is very important to make these scripts
8201                 idempotent.
8202                 <footnote>
8203                   <p>
8204                     That means that if it runs successfully or fails
8205                     and then you call it again it doesn't bomb out,
8206                     but just ensures that everything is the way it
8207                     ought to be.
8208                   </p>
8209                 </footnote> This is so that if an error occurs, the
8210                 user interrupts <prgn>dpkg</prgn> or some other
8211                 unforeseen circumstance happens you don't leave the
8212                 user with a badly-broken package.
8213               </p>
8214
8215               <p>
8216                 The maintainer scripts are guaranteed to run with a
8217                 controlling terminal and can interact with the user.
8218                 If they need to prompt for passwords, do full-screen
8219                 interaction or something similar you should do these
8220                 things to and from <file>/dev/tty</file>, since
8221                 <prgn>dpkg</prgn> will at some point redirect scripts'
8222                 standard input and output so that it can log the
8223                 installation process.  Likewise, because these scripts
8224                 may be executed with standard output redirected into a
8225                 pipe for logging purposes, Perl scripts should set
8226                 unbuffered output by setting <tt>$|=1</tt> so that the
8227                 output is printed immediately rather than being
8228                 buffered.
8229               </p>
8230
8231               <p>
8232                 Each script should return a zero exit status for
8233                 success, or a nonzero one for failure.</p>
8234             </item>
8235
8236             <tag><tt>conffiles</tt>
8237             </tag>
8238             <item>
8239
8240               <p>
8241                 This file contains a list of configuration files which
8242                 are to be handled automatically by <prgn>dpkg</prgn>
8243                 (see <ref id="pkg-conffiles">).  Note that not necessarily
8244                 every configuration file should be listed here.</p>
8245             </item>
8246
8247             <tag><tt>shlibs</tt>
8248             </tag>
8249             <item>
8250
8251               <p>
8252                 This file contains a list of the shared libraries
8253                 supplied by the package, with dependency details for
8254                 each.  This is used by <prgn>dpkg-shlibdeps</prgn>
8255                 when it determines what dependencies are required in a
8256                 package control file. The <tt>shlibs</tt> file format
8257                 is described on <ref id="shlibs">.
8258               </p>
8259             </item>
8260           </taglist>
8261         </p>
8262
8263       <sect id="pkg-controlfile">
8264         <heading>
8265           The main control information file: <tt>control</tt>
8266         </heading>
8267         <p>
8268           The most important control information file used by
8269           <prgn>dpkg</prgn> when it installs a package is
8270           <tt>control</tt>.  It contains all the package"s "vital
8271           statistics".
8272         </p>
8273
8274         <p>
8275           The binary package control files of packages built from
8276           Debian sources are made by a special tool,
8277           <prgn>dpkg-gencontrol</prgn>, which reads
8278           <file>debian/control</file> and <file>debian/changelog</file> to
8279           find the information it needs.  See <ref id="pkg-sourcepkg"> for
8280           more details.
8281         </p>
8282
8283         <p>
8284           The fields in binary package control files are:
8285           <list compact="compact">
8286             <item>
8287               <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8288             </item>
8289             <item>
8290               <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8291             </item>
8292             <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8293                 (mandatory)
8294                 <footnote>
8295                   <p>
8296                     This field should appear in all packages, though
8297                     <prgn>dpkg</prgn> doesn't require it yet so that
8298                     old packages can still be installed.
8299                   </p>
8300                 </footnote>
8301               </p>
8302             </item>
8303             <item>
8304               <p><qref id="relationships"><tt>Depends</tt>,
8305                   <tt>Provides</tt> et al.</qref></p>
8306             </item>
8307             <item>
8308               <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8309             </item>
8310             <item>
8311               <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8312             </item>
8313             <item>
8314               <p><qref id="pkg-f-classification"><tt>Section</tt>,
8315                   <tt>Priority</tt></qref></p>
8316             </item>
8317             <item>
8318               <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8319             </item>
8320             <item>
8321               <p><qref id="descriptions"><tt>Description</tt></qref></p>
8322             </item>
8323             <item>
8324               <p>
8325                 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8326               </p>
8327             </item>
8328           </list>
8329
8330         <p>
8331           A description of the syntax of control files and the purpose
8332           of these fields is available in <ref id="pkg-controlfields">.
8333         </p>
8334       </sect>
8335
8336       <sect>
8337         <heading>Time Stamps</heading>
8338         <p>
8339           Maintainers are encouraged to preserve the modification
8340           times of the upstream source files in a package, as far as
8341           is reasonably possible.
8342           <footnote>
8343             <p>
8344               The rationale is that there is some information conveyed
8345               by knowing the age of the file, for example, you could
8346               recognize that some documentation is very old by looking
8347               at the modification time, so it would be nice if the
8348               modification time of the upstream source would be
8349               preserved.
8350             </p>
8351           </footnote>
8352         </p>
8353       </sect>
8354     </appendix>
8355
8356     <appendix id="pkg-sourcepkg">
8357       <heading>Source packages (from old Packaging Manual) </heading>
8358
8359       <p>
8360         The Debian binary packages in the distribution are generated
8361         from Debian sources, which are in a special format to assist
8362         the easy and automatic building of binaries.
8363       </p>
8364
8365       <sect id="pkg-sourcetools">
8366         <heading>Tools for processing source packages</heading>
8367
8368         <p>
8369           Various tools are provided for manipulating source packages;
8370           they pack and unpack sources and help build of binary
8371           packages and help manage the distribution of new versions.
8372         </p>
8373
8374         <p>
8375           They are introduced and typical uses described here; see
8376           <manref name="dpkg-source" section="1"> for full
8377           documentation about their arguments and operation.
8378         </p>
8379
8380         <p>
8381           For examples of how to construct a Debian source package,
8382           and how to use those utilities that are used by Debian
8383           source packages, please see the <prgn>hello</prgn> example
8384           package.
8385         </p>
8386
8387         <sect1>
8388           <heading>
8389             <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8390             packages
8391           </heading>
8392
8393           <p>
8394             This program is frequently used by hand, and is also
8395             called from package-independent automated building scripts
8396             such as <prgn>dpkg-buildpackage</prgn>.
8397           </p>
8398
8399           <p>
8400             To unpack a package it is typically invoked with
8401             <example>
8402   dpkg-source -x <var>.../path/to/filename</var>.dsc
8403             </example>
8404           </p>
8405
8406            <p>
8407             with the <file><var>filename</var>.tar.gz</file> and
8408             <file><var>filename</var>.diff.gz</file> (if applicable) in
8409             the same directory.  It unpacks into
8410             <file><var>package</var>-<var>version</var></file>, and if
8411             applicable
8412             <file><var>package</var>-<var>version</var>.orig</file>, in
8413             the current directory.
8414           </p>
8415
8416           <p>
8417             To create a packed source archive it is typically invoked:
8418             <example>
8419   dpkg-source -b <var>package</var>-<var>version</var>
8420           </example>
8421           </p>
8422
8423           <p>
8424             This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8425             <file>.diff.gz</file> (if appropriate) in the current
8426             directory.  <prgn>dpkg-source</prgn> does not clean the
8427             source tree first - this must be done separately if it is
8428             required.
8429           </p>
8430
8431           <p>
8432             See also <ref id="pkg-sourcearchives">.</p>
8433         </sect1>
8434
8435
8436         <sect1>
8437           <heading>
8438             <prgn>dpkg-buildpackage</prgn> - overall package-building
8439             control script
8440           </heading>
8441
8442           <p>
8443             <prgn>dpkg-buildpackage</prgn> is a script which invokes
8444             <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8445             targets <tt>clean</tt>, <tt>build</tt> and
8446             <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8447             <prgn>pgp</prgn> to build a signed source and binary
8448             package upload.
8449           </p>
8450
8451           <p>
8452             It is usually invoked by hand from the top level of the
8453             built or unbuilt source directory.  It may be invoked with
8454             no arguments; useful arguments include:
8455             <taglist compact="compact">
8456               <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8457               <item>
8458                 <p>
8459                   Do not PGP-sign the <tt>.changes</tt> file or the
8460                   source package <tt>.dsc</tt> file, respectively.</p>
8461               </item>
8462               <tag><tt>-p<var>pgp-command</var></tt></tag>
8463               <item>
8464                 <p>
8465                   Invoke <var>pgp-command</var> instead of finding
8466                   <tt>pgp</tt> on the <prgn>PATH</prgn>.
8467                   <var>pgp-command</var> must behave just like
8468                   <prgn>pgp</prgn>.</p>
8469               </item>
8470               <tag><tt>-r<var>root-command</var></tt></tag>
8471               <item>
8472                 <p>
8473                   When root privilege is required, invoke the command
8474                   <var>root-command</var>.  <var>root-command</var>
8475                   should invoke its first argument as a command, from
8476                   the <prgn>PATH</prgn> if necessary, and pass its
8477                   second and subsequent arguments to the command it
8478                   calls.  If no <var>root-command</var> is supplied
8479                   then <var>dpkg-buildpackage</var> will take no
8480                   special action to gain root privilege, so that for
8481                   most packages it will have to be invoked as root to
8482                   start with.</p>
8483               </item>
8484               <tag><tt>-b</tt>, <tt>-B</tt></tag>
8485               <item>
8486                 <p>
8487                   Two types of binary-only build and upload - see
8488                   <manref name="dpkg-source" section="1">.
8489                 </p>
8490               </item>
8491             </taglist>
8492           </p>
8493         </sect1>
8494
8495         <sect1>
8496           <heading>
8497             <prgn>dpkg-gencontrol</prgn> - generates binary package
8498             control files
8499           </heading>
8500
8501           <p>
8502             This program is usually called from <file>debian/rules</file>
8503             (see <ref id="pkg-sourcetree">) in the top level of the source
8504             tree.
8505           </p>
8506
8507           <p>
8508             This is usually done just before the files and directories in the
8509             temporary directory tree where the package is being built have their
8510             permissions and ownerships set and the package is constructed using
8511             <prgn>dpkg-deb/</prgn>
8512               <footnote>
8513               <p>
8514                 This is so that the control file which is produced has
8515                 the right permissions
8516               </p>
8517             </footnote>.
8518           </p>
8519
8520           <p>
8521             <prgn>dpkg-gencontrol</prgn> must be called after all the
8522             files which are to go into the package have been placed in
8523             the temporary build directory, so that its calculation of
8524             the installed size of a package is correct.
8525           </p>
8526
8527           <p>
8528             It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8529             be run after <prgn>dpkg-shlibdeps</prgn> so that the
8530             variable substitutions created by
8531             <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8532             are available.
8533           </p>
8534
8535           <p>
8536             For a package which generates only one binary package, and
8537             which builds it in <file>debian/tmp</file> relative to the top
8538             of the source package, it is usually sufficient to call
8539             <prgn>dpkg-gencontrol</prgn>.
8540           </p>
8541
8542           <p>
8543             Sources which build several binaries will typically need
8544             something like:
8545             <example>
8546   dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8547             </example> The <tt>-P</tt> tells
8548             <prgn>dpkg-gencontrol</prgn> that the package is being
8549             built in a non-default directory, and the <tt>-p</tt>
8550             tells it which package's control file should be generated.
8551           </p>
8552
8553           <p>
8554             <prgn>dpkg-gencontrol</prgn> also adds information to the
8555             list of files in <file>debian/files</file>, for the benefit of
8556             (for example) a future invocation of
8557             <prgn>dpkg-genchanges</prgn>.</p>
8558         </sect1>
8559
8560         <sect1>
8561           <heading>
8562             <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8563             dependencies
8564           </heading>
8565
8566           <p>
8567             This program is usually called from <file>debian/rules</file>
8568             just before <prgn>dpkg-gencontrol</prgn> (see <ref
8569             id="pkg-sourcetree">), in the top level of the source tree.
8570           </p>
8571
8572           <p>
8573             Its arguments are executables.
8574             <footnote>
8575               <p>
8576                 In a forthcoming dpkg version,
8577                 <prgn>dpkg-shlibdeps</prgn> would be required to be
8578                 called on shared libraries as well.
8579               </p>
8580               <p>
8581                 They may be specified either in the locations in the
8582                 source tree where they are created or in the locations
8583                 in the temporary build tree where they are installed
8584                 prior to binary package creation.
8585               </p>
8586             </footnote> for which shared library dependencies should
8587             be included in the binary package's control file.
8588           </p>
8589
8590           <p>
8591             If some of the found shared libraries should only
8592             warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8593             some warrant a <tt>Pre-Depends</tt>, this can be achieved
8594             by using the <tt>-d<var>dependency-field</var></tt> option
8595             before those executable(s).  (Each <tt>-d</tt> option
8596             takes effect until the next <tt>-d</tt>.)
8597           </p>
8598
8599           <p>
8600             <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8601             output control file to be modified.  Instead by default it
8602             adds to the <file>debian/substvars</file> file variable
8603             settings like <tt>shlibs:Depends</tt>.  These variable
8604             settings must be referenced in dependency fields in the
8605             appropriate per-binary-package sections of the source
8606             control file.
8607           </p>
8608
8609           <p>
8610             For example, the <prgn>procps</prgn> package generates two
8611             kinds of binaries, simple C binaries like <prgn>ps</prgn>
8612             which require a predependency and full-screen ncurses
8613             binaries like <prgn>top</prgn> which require only a
8614             recommendation.  It can say in its <file>debian/rules</file>:
8615             <example>
8616   dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8617             </example>
8618             and then in its main control file <file>debian/control</file>:
8619             <example>
8620   <var>...</var>
8621   Package: procps
8622   Pre-Depends: ${shlibs:Pre-Depends}
8623   Recommends: ${shlibs:Recommends}
8624   <var>...</var>
8625             </example>
8626           </p>
8627
8628           <p>
8629             Sources which produce several binary packages with
8630             different shared library dependency requirements can use
8631             the <tt>-p<var>varnameprefix</var></tt> option to override
8632             the default <tt>shlibs:</tt> prefix (one invocation of
8633             <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8634             They can thus produce several sets of dependency
8635             variables, each of the form
8636             <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8637             which can be referred to in the appropriate parts of the
8638             binary package control files.
8639           </p>
8640         </sect1>
8641
8642
8643         <sect1>
8644           <heading>
8645             <prgn>dpkg-distaddfile</prgn> - adds a file to
8646             <file>debian/files</file>
8647           </heading>
8648
8649           <p>
8650             Some packages' uploads need to include files other than
8651             the source and binary package files.
8652           </p>
8653
8654           <p>
8655             <prgn>dpkg-distaddfile</prgn> adds a file to the
8656             <file>debian/files</file> file so that it will be included in
8657             the <file>.changes</file> file when
8658             <prgn>dpkg-genchanges</prgn> is run.
8659           </p>
8660
8661           <p>
8662             It is usually invoked from the <tt>binary</tt> target of
8663             <file>debian/rules</file>:
8664             <example>
8665   dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8666             </example>
8667             The <var>filename</var> is relative to the directory where
8668             <prgn>dpkg-genchanges</prgn> will expect to find it - this
8669             is usually the directory above the top level of the source
8670             tree.  The <file>debian/rules</file> target should put the
8671             file there just before or just after calling
8672             <prgn>dpkg-distaddfile</prgn>.
8673           </p>
8674
8675           <p>
8676             The <var>section</var> and <var>priority</var> are passed
8677             unchanged into the resulting <file>.changes</file> file.  See
8678             <ref id="pkg-f-classification">.
8679           </p>
8680         </sect1>
8681
8682
8683         <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8684             control file
8685           </heading>
8686
8687           <p>
8688             This program is usually called by package-independent
8689             automatic building scripts such as
8690             <prgn>dpkg-buildpackage</prgn>, but it may also be called
8691             by hand.
8692           </p>
8693
8694           <p>
8695             It is usually called in the top level of a built source
8696             tree, and when invoked with no arguments will print out a
8697             straightforward <file>.changes</file> file based on the
8698             information in the source package's changelog and control
8699             file and the binary and source packages which should have
8700             been built.
8701           </p>
8702         </sect1>
8703
8704
8705         <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8706             a changelog
8707           </heading>
8708
8709           <p>
8710             This program is used internally by
8711             <prgn>dpkg-source</prgn> et al.  It may also occasionally
8712             be useful in <file>debian/rules</file> and elsewhere.  It
8713             parses a changelog, <file>debian/changelog</file> by default,
8714             and prints a control-file format representation of the
8715             information in it to standard output.
8716           </p>
8717         </sect1>
8718
8719         <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8720             information about the build and host system
8721           </heading>
8722
8723           <p>
8724             This program can be used manually, but is also invoked by
8725             <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8726             to set environment or make variables which specify the build and
8727             host architecture for the package building process.
8728           </p>
8729         </sect1>
8730       </sect>
8731
8732       <sect id="pkg-sourcetree"><heading>The Debianised source tree
8733         </heading>
8734
8735         <p>
8736           The source archive scheme described later is intended to
8737           allow a Debianised source tree with some associated control
8738           information to be reproduced and transported easily.  The
8739           Debianised source tree is a version of the original program
8740           with certain files added for the benefit of the
8741           Debianisation process, and with any other changes required
8742           made to the rest of the source code and installation
8743           scripts.
8744         </p>
8745
8746         <p>
8747           The extra files created for Debian are in the subdirectory
8748           <file>debian</file> of the top level of the Debianised source
8749           tree.  They are described below.
8750         </p>
8751
8752         <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8753         script
8754           </heading>
8755
8756           <p>
8757             This file is an executable makefile, and contains the
8758             package-specific recipies for compiling the package and
8759             building binary package(s) out of the source.
8760           </p>
8761
8762           <p>
8763             It must start with the line <tt>#!/usr/bin/make -f</tt>,
8764             so that it can be invoked by saying its name rather than
8765             invoking <prgn>make</prgn> explicitly.
8766           </p>
8767
8768           <p>
8769             Since an interactive <file>debian/rules</file> script makes it
8770             impossible to autocompile that package and also makes it
8771             hard for other people to reproduce the same binary
8772             package, all <strong>required targets</strong> have to be
8773             non-interactive. At a minimul, required targets are the
8774             ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8775             <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8776             <em>build</em>. It also follows that any target that these
8777             targets depend on must also be non-interactive.
8778           </p>
8779
8780           <p>
8781             The targets which are required to be present are:
8782             <taglist>
8783               <tag><tt>build</tt></tag>
8784               <item>
8785                 <p>
8786                   This should perform all non-interactive
8787                   configuration and compilation of the package.  If a
8788                   package has an interactive pre-build configuration
8789                   routine, the Debianised source package should be
8790                   built after this has taken place, so that it can be
8791                   built without rerunning the configuration.
8792                 </p>
8793
8794                 <p>
8795                   A package may also provide both of the targets
8796                   <tt>build-arch</tt> and <tt>build-indep</tt>.  The
8797                   <tt>build-arch</tt> target, if provided, should
8798                   perform all non-interactive configuration and
8799                   compilation required for producing all
8800                   architecture-dependant binary packages (those packages
8801                   for which the body of the <tt>Architecture</tt> field
8802                   in <tt>debian/control</tt> is not <tt>all</tt>).
8803                   Similarly, the <tt>build-indep</tt> target, if
8804                   provided, should perform all non-interactive
8805                   configuration and compilation required for producing
8806                   all architecture-independent binary packages (those
8807                   packages for which the body of the
8808                   <tt>Architecture</tt> field in <tt>debian/control</tt>
8809                   is <tt>all</tt>).  The <tt>build</tt> target should
8810                   depend on those of the targets <tt>build-arch</tt> and
8811                   <tt>build-indep</tt> that are provided in the rules
8812                   file.
8813                 </p>
8814
8815                 <p>
8816                   If one or both of the targets <tt>build-arch</tt> and
8817                   <tt>build-indep</tt> are not provided, then invoking
8818                   <file>debian/rules</file> with one of the not-provided
8819                   targets as arguments should produce a exit status code
8820                   of 2.  Usually this is provided automatically by make
8821                   if the target is missing.
8822                 </p>
8823
8824                 <p>
8825                   For some packages, notably ones where the same
8826                   source tree is compiled in different ways to produce
8827                   two binary packages, the <tt>build</tt> target does
8828                   not make much sense.  For these packages it is good
8829                   enough to provide two (or more) targets
8830                   (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8831                   for each of the ways of building the package, and a
8832                   <tt>build</tt> target that does nothing.  The
8833                   <tt>binary</tt> target will have to build the
8834                   package in each of the possible ways and make the
8835                   binary package out of each.
8836                 </p>
8837
8838                 <p>
8839                   The targets <tt>build</tt>, <tt>build-arch</tt>
8840                   and <tt>build-indep</tt> target must not do
8841                   anything that might require root privilege.
8842                 </p>
8843
8844                 <p>
8845                   The <tt>build</tt> target may need to run
8846                   <tt>clean</tt> first - see below.
8847                 </p>
8848
8849                 <p>
8850                   When a package has a configuration routine that takes
8851                   a long time, or when the makefiles are poorly
8852                   designed, or when <tt>build</tt> needs to run
8853                   <tt>clean</tt> first, it is a good idea to <tt>touch
8854                     build</tt> when the build process is complete.  This
8855                   will ensure that if <tt>debian/rules build</tt> is run
8856                   again it will not rebuild the whole program.
8857                 </p>
8858               </item>
8859
8860               <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8861                 <tt>binary-indep</tt>
8862               </tag>
8863               <item>
8864                 <p>
8865                   The <tt>binary</tt> target should be all that is
8866                   necessary for the user to build the binary
8867                   package. All these targets are required to be
8868                   non-interactive.  It is split into two parts:
8869                   <tt>binary-arch</tt> builds the packages' output
8870                   files which are specific to a particular
8871                   architecture, and <tt>binary-indep</tt> builds
8872                   those which are not.
8873                 </p>
8874
8875                 <p>
8876                   <tt>binary</tt> should usually be a target with
8877                   no commands which simply depends on
8878                   <prgn>binary-arch</prgn> and
8879                   <prgn>binary-indep</prgn>.
8880                 </p>
8881
8882                 <p>
8883                   Both <prgn>binary-*</prgn> targets should depend on
8884                   the <tt>build</tt> target, above, so that the
8885                   package is built if it has not been already.  It
8886                   should then create the relevant binary package(s),
8887                   using <prgn>dpkg-gencontrol</prgn> to make their
8888                   control files and <prgn>dpkg-deb</prgn> to build
8889                   them and place them in the parent of the top level
8890                   directory.
8891                 </p>
8892
8893                 <p>
8894                   If one of the <prgn>binary-*</prgn> targets has
8895                   nothing to do (this will be always be the case if
8896                   the source generates only a single binary package,
8897                   whether architecture-dependent or not) it
8898                   <em>must</em> still exist, but should always
8899                   succeed.
8900                 </p>
8901
8902                 <p>
8903                   <ref id="pkg-binarypkg"> describes how to construct
8904                   binary packages.
8905                 </p>
8906
8907                 <p>
8908                   The <tt>binary</tt> targets must be invoked as
8909                   root.
8910                 </p>
8911               </item>
8912
8913               <tag><tt>clean</tt></tag>
8914               <item>
8915
8916                 <p>
8917                   This should undo any effects that the
8918                   <tt>build</tt> and <tt>binary</tt> targets
8919                   may have had, except that it should leave alone any
8920                   output files created in the parent directory by a
8921                   run of <tt>binary</tt>. This target is required
8922                   to be non-interactive.
8923                 </p>
8924
8925                 <p>
8926                   If a <tt>build</tt> file is touched at the end
8927                   of the <tt>build</tt> target, as suggested
8928                   above, it must be removed as the first thing that
8929                   <tt>clean</tt> does, so that running
8930                   <tt>build</tt> again after an interrupted
8931                   <tt>clean</tt> doesn't think that everything is
8932                   already done.
8933                 </p>
8934
8935                 <p>
8936                   The <tt>clean</tt> target must be invoked as
8937                   root if <tt>binary</tt> has been invoked since
8938                   the last <tt>clean</tt>, or if
8939                   <tt>build</tt> has been invoked as root (since
8940                   <tt>build</tt> may create directories, for
8941                   example).
8942                 </p>
8943               </item>
8944
8945               <tag><tt>get-orig-source</tt> (optional)</tag>
8946               <item>
8947
8948                 <p>
8949                   This target fetches the most recent version of the
8950                   original source package from a canonical archive
8951                   site (via FTP or WWW, for example), does any
8952                   necessary rearrangement to turn it into the original
8953                   source tarfile format described below, and leaves it
8954                   in the current directory.
8955                 </p>
8956
8957                 <p>
8958                   This target may be invoked in any directory, and
8959                   should take care to clean up any temporary files it
8960                   may have left.
8961                 </p>
8962
8963                 <p>
8964                   This target is optional, but providing it if
8965                   possible is a good idea.
8966                 </p>
8967               </item>
8968             </taglist>
8969
8970           <p>
8971             The <tt>build</tt>, <tt>binary</tt> and
8972             <tt>clean</tt> targets must be invoked with a current
8973             directory of the package's top-level directory.
8974           </p>
8975
8976
8977           <p>
8978             Additional targets may exist in <file>debian/rules</file>,
8979             either as published or undocumented interfaces or for the
8980             package's internal use.
8981           </p>
8982
8983           <p>
8984             The architecture we build on and build for is determined by make
8985             variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8986             get the Debian architecture and the GNU style architecture
8987             specification string for the build machine as well as the host
8988             machine. Here is a list of supported make variables:
8989             <list compact="compact">
8990               <item>
8991                 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8992               </item>
8993               <item>
8994                 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8995                   specification string)</p>
8996               </item>
8997               <item>
8998                 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8999               </item>
9000               <item>
9001                 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
9002                   DEB_*_GNU_TYPE)</p>
9003             </list>
9004           </p>
9005
9006           <p>
9007             where <tt>*</tt> is either <tt>BUILD</tt> for specification of
9008             the build machine or <tt>HOST</tt> for specification of the machine
9009             we build for.
9010           </p>
9011
9012           <p>
9013             Backward compatibility can be provided in the rules file
9014             by setting the needed variables to suitable default
9015             values, please refer to the documentation of
9016             dpkg-architecture for details.
9017           </p>
9018
9019           <p>
9020             It is important to understand that the <tt>DEB_*_ARCH</tt>
9021             string does only determine which Debian architecture we
9022             build on resp. for. It should not be used to get the CPU
9023             or System information, the GNU style variables should be
9024             used for that.
9025           </p>
9026         </sect1>
9027
9028
9029         <sect1><heading><file>debian/control</file>
9030           </heading>
9031
9032           <p>
9033             This file contains version-independent details about the
9034             source package and about the binary packages it creates.
9035           </p>
9036
9037           <p>
9038             It is a series of sets of control fields, each
9039             syntactically similar to a binary package control file.
9040             The sets are separated by one or more blank lines.  The
9041             first set is information about the source package in
9042             general; each subsequent set describes one binary package
9043             that the source tree builds.
9044           </p>
9045
9046           <p>
9047             The syntax and semantics of the fields are described below
9048             in <ref id="pkg-controlfields">.
9049           </p>
9050
9051           <p>
9052             The general (binary-package-independent) fields are:
9053             <list compact="compact">
9054               <item>
9055                 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
9056               </item>
9057               <item>
9058                 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9059               </item>
9060               <item>
9061                 <p>
9062                   <qref id="pkg-f-classification"><tt>Section</tt> and
9063                     <tt>Priority</tt></qref>
9064                   (classification, mandatory)
9065                 </p>
9066               </item>
9067                <item>
9068                  <p>
9069                    <qref id="relationships"><tt>Build-Depends</tt> et
9070                      al.</qref> (source package interrelationships)
9071                  </p>
9072                </item>
9073               <item>
9074                 <p>
9075                   <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
9076                 </p>
9077               </item>
9078             </list>
9079
9080           <p>
9081             The per-binary-package fields are:
9082             <list compact="compact">
9083               <item>
9084                 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
9085               </item>
9086               <item>
9087                 <p>
9088                   <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
9089                   (mandatory)</p>
9090               </item>
9091               <item>
9092                 <p><qref id="descriptions"><tt>Description</tt></qref></p>
9093               </item>
9094               <item>
9095                 <p>
9096                   <qref id="pkg-f-classification"><tt>Section</tt> and
9097                     <tt>Priority</tt></qref> (classification)</p>
9098               </item>
9099               <item>
9100                 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
9101               </item>
9102               <item>
9103                 <p>
9104                   <qref id="relationships"><tt>Depends</tt> et
9105                   al.</qref> (binary package interrelationships)
9106                 </p>
9107               </item>
9108             </list>
9109
9110           <p>
9111             These fields are used by <prgn>dpkg-gencontrol</prgn> to
9112             generate control files for binary packages (see below), by
9113             <prgn>dpkg-genchanges</prgn> to generate the
9114             <tt>.changes</tt> file to accompany the upload, and by
9115             <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9116             source control file as part of a source archive.
9117           </p>
9118
9119           <p>
9120             The fields here may contain variable references - their
9121             values will be substituted by
9122             <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9123             or <prgn>dpkg-source</prgn> when they generate output
9124             control files.  See <ref id="pkg-srcsubstvars"> for details.
9125           </p>
9126
9127           <p> <sect2><heading>User-defined fields
9128             </heading>
9129
9130             <p>
9131               Additional user-defined fields may be added to the
9132               source package control file.  Such fields will be
9133               ignored, and not copied to (for example) binary or
9134               source package control files or upload control files.
9135             </p>
9136
9137             <p>
9138               If you wish to add additional unsupported fields to
9139               these output files you should use the mechanism
9140               described here.
9141             </p>
9142
9143             <p>
9144               Fields in the main source control information file with
9145               names starting <tt>X</tt>, followed by one or more of
9146               the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9147               be copied to the output files.  Only the part of the
9148               field name after the hyphen will be used in the output
9149               file.  Where the letter <tt>B</tt> is used the field
9150               will appear in binary package control files, where the
9151               letter <tt>S</tt> is used in source package control
9152               files and where <tt>C</tt> is used in upload control
9153               (<tt>.changes</tt>) files.
9154             </p>
9155
9156             <p>
9157               For example, if the main source information control file
9158               contains the field
9159               <example>
9160   XBS-Comment: I stand between the candle and the star.
9161               </example>
9162               then the binary and source package control files will contain the
9163               field
9164               <example>
9165   Comment: I stand between the candle and the star.
9166               </example>
9167             </p>
9168           </sect2>
9169
9170         </sect1>
9171
9172         <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9173           </heading>
9174
9175           <p>
9176             This file records the changes to the Debian-specific parts of the
9177             package
9178             <footnote>
9179               <p>
9180                 Though there is nothing stopping an author who is also
9181                 the Debian maintainer from using it for all their
9182                 changes, it will have to be renamed if the Debian and
9183                 upstream maintainers become different
9184                 people.
9185               </p>
9186             </footnote>.
9187           </p>
9188
9189           <p>
9190             It has a special format which allows the package building
9191             tools to discover which version of the package is being
9192             built and find out other release-specific information.
9193           </p>
9194
9195           <p>
9196             That format is a series of entries like this:
9197             <example>
9198   <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9199
9200    * <var>change details</var>
9201    <var>more change details</var>
9202    * <var>even more change details</var>
9203
9204   -- <var>maintainer name and email address</var>  <var>date</var>
9205             </example>
9206           </p>
9207
9208           <p>
9209             <var>package</var> and <var>version</var> are the source
9210             package name and version number.
9211           </p>
9212
9213           <p>
9214             <var>distribution(s)</var> lists the distributions where
9215             this version should be installed when it is uploaded - it
9216             is copied to the <tt>Distribution</tt> field in the
9217             <tt>.changes</tt> file.  See <ref id="pkg-f-Distribution">.
9218           </p>
9219
9220           <p>
9221             <var>urgency</var> is the value for the <tt>Urgency</tt>
9222             field in the <file>.changes</file> file for the upload.  See
9223             <ref id="pkg-f-Urgency">.  It is not possible to specify an
9224             urgency containing commas; commas are used to separate
9225             <tt><var>keyword</var>=<var>value</var></tt> settings in
9226             the <prgn>dpkg</prgn> changelog format (though there is
9227             currently only one useful <var>keyword</var>,
9228             <tt>urgency</tt>).
9229           </p>
9230
9231           <p>
9232             The change details may in fact be any series of lines
9233             starting with at least two spaces, but conventionally each
9234             change starts with an asterisk and a separating space and
9235             continuation lines are indented so as to bring them in
9236             line with the start of the text above.  Blank lines may be
9237             used here to separate groups of changes, if desired.
9238           </p>
9239
9240           <p>
9241             The maintainer name and email address should <em>not</em>
9242             necessarily be those of the usual package maintainer.
9243             They should be the details of the person doing
9244             <em>this</em> version.  The information here will be
9245             copied to the <file>.changes</file> file, and then later used
9246             to send an acknowledgement when the upload has been
9247             installed.
9248           </p>
9249
9250           <p>
9251             The <var>date</var> should be in RFC822 format
9252             <footnote>
9253               <p>
9254                 This is generated by the <prgn>822-date</prgn>
9255                 program.
9256               </p>
9257             </footnote>; it should include the timezone specified
9258             numerically, with the timezone name or abbreviation
9259             optionally present as a comment.
9260           </p>
9261
9262           <p>
9263             The first "title" line with the package name should start
9264             at the left hand margin; the "trailer" line with the
9265             maintainer and date details should be preceded by exactly
9266             one space.  The maintainer details and the date must be
9267             separated by exactly two spaces.
9268           </p>
9269
9270           <p>
9271             An Emacs mode for editing this format is available: it is
9272             called <tt>debian-changelog-mode</tt>.  You can have this
9273             mode selected automatically when you edit a Debian
9274             changelog by adding a local variables clause to the end of
9275             the changelog.
9276           </p>
9277
9278           <sect2><heading>Defining alternative changelog formats
9279             </heading>
9280
9281             <p>
9282               It is possible to use a different format to the standard
9283               one, by providing a parser for the format you wish to
9284               use.
9285             </p>
9286
9287             <p>
9288               In order to have <tt>dpkg-parsechangelog</tt> run your
9289               parser, you must include a line within the last 40 lines
9290               of your file matching the Perl regular expression:
9291               <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9292               parentheses should be the name of the format.  For
9293               example, you might say:
9294               <example>
9295   @@@ changelog-format: joebloggs @@@
9296               </example>
9297               Changelog format names are non-empty strings of alphanumerics.
9298             </p>
9299
9300             <p>
9301               If such a line exists then <tt>dpkg-parsechangelog</tt>
9302               will look for the parser as
9303               <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9304               or
9305               <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9306               it is an error for it not to find it, or for it not to
9307               be an executable program.  The default changelog format
9308               is <tt>dpkg</tt>, and a parser for it is provided with
9309               the <tt>dpkg</tt> package.
9310             </p>
9311
9312             <p>
9313               The parser will be invoked with the changelog open on
9314               standard input at the start of the file.  It should read
9315               the file (it may seek if it wishes) to determine the
9316               information required and return the parsed information
9317               to standard output in the form of a series of control
9318               fields in the standard format.  By default it should
9319               return information about only the most recent version in
9320               the changelog; it should accept a
9321               <tt>-v<var>version</var></tt> option to return changes
9322               information from all versions present <em>strictly
9323               after</em> <var>version</var>, and it should then be an
9324               error for <var>version</var> not to be present in the
9325               changelog.
9326             </p>
9327
9328             <p>
9329               The fields are:
9330               <list compact="compact">
9331                 <item>
9332                   <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9333                 </item>
9334                 <item>
9335                   <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9336                 </item>
9337                 <item>
9338                   <p>
9339                     <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9340                     (mandatory)
9341                   </p>
9342                 </item>
9343                 <item>
9344                   <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9345                 </item>
9346                 <item>
9347                   <p>
9348                     <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9349                     (mandatory)
9350                   </p>
9351                 </item>
9352                 <item>
9353                   <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9354                 </item>
9355                 <item>
9356                   <p>
9357                     <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9358                     (mandatory)
9359                   </p>
9360                 </item>
9361               </list>
9362
9363             <p>
9364               If several versions are being returned (due to the use
9365               of <tt>-v</tt>), the urgency value should be of the
9366               highest urgency code listed at the start of any of the
9367               versions requested followed by the concatenated
9368               (space-separated) comments from all the versions
9369               requested; the maintainer, version, distribution and
9370               date should always be from the most recent version.
9371             </p>
9372
9373             <p>
9374               For the format of the <tt>Changes</tt> field see <ref
9375               id="pkg-f-Changes">.
9376             </p>
9377
9378             <p>
9379               If the changelog format which is being parsed always or
9380               almost always leaves a blank line between individual
9381               change notes these blank lines should be stripped out,
9382               so as to make the resulting output compact.
9383             </p>
9384
9385             <p>
9386               If the changelog format does not contain date or package
9387               name information this information should be omitted from
9388               the output.  The parser should not attempt to synthesise
9389               it or find it from other sources.
9390             </p>
9391
9392             <p>
9393               If the changelog does not have the expected format the
9394               parser should exit with a nonzero exit status, rather
9395               than trying to muddle through and possibly generating
9396               incorrect output.
9397             </p>
9398
9399             <p>
9400               A changelog parser may not interact with the user at
9401               all.</p></sect2>
9402         </sect1>
9403
9404 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
9405
9406         <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9407         and variable substitutions
9408           </heading>
9409
9410           <p>
9411             When <prgn>dpkg-gencontrol</prgn>,
9412             <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9413             generate control files they do variable substitutions on
9414             their output just before writing it.  Variable
9415             substitutions have the form
9416             <tt>${<var>variable-name</var>}</tt>.  The optional file
9417             <file>debian/substvars</file> contains variable substitutions
9418             to be used; variables can also be set directly from
9419             <file>debian/rules</file> using the <tt>-V</tt> option to the
9420             source packaging commands, and certain predefined
9421             variables are available.
9422           </p>
9423
9424           <p>
9425             This file is usually generated and modified dynamically by
9426             <file>debian/rules</file> targets, in which case it must be
9427             removed by the <tt>clean</tt> target.
9428           </p>
9429
9430           <p>
9431             See <manref name="dpkg-source" section="1"> for full
9432             details about source variable substitutions, including the
9433             format of <file>debian/substvars</file>.</p>
9434         </sect1>
9435
9436         <sect1><heading><file>debian/files</file>
9437           </heading>
9438
9439           <p>
9440             This file is not a permanent part of the source tree; it
9441             is used while building packages to record which files are
9442             being generated.  <prgn>dpkg-genchanges</prgn> uses it
9443             when it generates a <file>.changes</file> file.
9444           </p>
9445
9446           <p>
9447             It should not exist in a shipped source package, and so it
9448             (and any backup files or temporary files such as
9449             <file>files.new</file>
9450               <footnote>
9451                 <p>
9452                   <file>files.new</file> is used as a temporary file by
9453                   <prgn>dpkg-gencontrol</prgn> and
9454                   <prgn>dpkg-distaddfile</prgn> - they write a new
9455                   version of <file>files</file> here before renaming it,
9456                   to avoid leaving a corrupted copy if an error
9457                   occurs
9458                 </p>
9459               </footnote>) should be removed by the
9460               <tt>clean</tt> target.  It may also be wise to
9461               ensure a fresh start by emptying or removing it at the
9462               start of the <tt>binary</tt> target.
9463           </p>
9464
9465           <p>
9466             <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9467             for the <file>.deb</file> file that will be created by
9468             <prgn>dpkg-deb</prgn> from the control file that it
9469             generates, so for most packages all that needs to be done
9470             with this file is to delete it in <tt>clean</tt>.
9471           </p>
9472
9473           <p>
9474             If a package upload includes files besides the source
9475             package and any binary packages whose control files were
9476             made with <prgn>dpkg-gencontrol</prgn> then they should be
9477             placed in the parent of the package's top-level directory
9478             and <prgn>dpkg-distaddfile</prgn> should be called to add
9479             the file to the list in <file>debian/files</file>.</p>
9480         </sect1>
9481
9482         <sect1><heading><file>debian/tmp</file>
9483           </heading>
9484
9485           <p>
9486             This is the canonical temporary location for the
9487             construction of binary packages by the <tt>binary</tt>
9488             target.  The directory <file>tmp</file> serves as the root of
9489             the filesystem tree as it is being constructed (for
9490             example, by using the package's upstream makefiles install
9491             targets and redirecting the output there), and it also
9492             contains the <tt>DEBIAN</tt> subdirectory.  See <ref
9493             id="pkg-bincreating">.
9494           </p>
9495
9496           <p>
9497             If several binary packages are generated from the same
9498             source tree it is usual to use several
9499             <file>debian/tmp<var>something</var></file> directories, for
9500             example <file>tmp-a</file> or <file>tmp-doc</file>.
9501           </p>
9502
9503           <p>
9504             Whatever <file>tmp</file> directories are created and used by
9505             <tt>binary</tt> must of course be removed by the
9506             <tt>clean</tt> target.</p></sect1>
9507       </sect>
9508
9509
9510       <sect id="pkg-sourcearchives"><heading>Source packages as archives
9511         </heading>
9512
9513         <p>
9514           As it exists on the FTP site, a Debian source package
9515           consists of three related files.  You must have the right
9516           versions of all three to be able to use them.
9517         </p>
9518
9519         <p>
9520           <taglist>
9521             <tag>Debian source control file - <tt>.dsc</tt></tag>
9522             <item>
9523
9524               <p>
9525                 This file contains a series of fields, identified and
9526                 separated just like the fields in the control file of
9527                 a binary package.  The fields are listed below; their
9528                 syntax is described above, in <ref id="pkg-controlfields">.
9529                 <list compact="compact">
9530                   <item>
9531                     <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9532                   </item>
9533                   <item>
9534                     <p><qref id="versions"><tt>Version</tt></qref></p>
9535                   </item>
9536                   <item>
9537                     <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9538                   </item>
9539                   <item>
9540                     <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9541                   </item>
9542                   <item>
9543                     <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9544                   </item>
9545                   <item>
9546                      <p>
9547                        <qref id="relationships"><tt>Build-Depends</tt> et
9548                          al.</qref> (source package interrelationships)
9549                      </p>
9550                   </item>
9551                   <item>
9552                     <p>
9553                       <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9554                   </item>
9555                   <item>
9556                     <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9557                   </item>
9558                 </list>
9559
9560               <p>
9561                 The source package control file is generated by
9562                 <prgn>dpkg-source</prgn> when it builds the source
9563                 archive, from other files in the source package,
9564                 described above.  When unpacking it is checked against
9565                 the files and directories in the other parts of the
9566                 source package, as described below.</p>
9567             </item>
9568
9569             <tag>
9570               Original source archive -
9571               <file>
9572                 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9573               </file>
9574             </tag>
9575
9576             <item>
9577
9578               <p>
9579                 This is a compressed (with <tt>gzip -9</tt>)
9580                 <prgn>tar</prgn> file containing the source code from
9581                 the upstream authors of the program.  The tarfile
9582                 unpacks into a directory
9583                 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9584                 and does not contain files anywhere other than in
9585                 there or in its subdirectories.</p>
9586             </item>
9587
9588             <tag>
9589               Debianisation diff -
9590               <file>
9591                 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9592               </file>
9593             </tag>
9594             <item>
9595
9596               <p>
9597                 This is a unified context diff (<tt>diff -u</tt>)
9598                 giving the changes which are required to turn the
9599                 original source into the Debian source.  These changes
9600                 may only include editing and creating plain files.
9601                 The permissions of files, the targets of symbolic
9602                 links and the characteristics of special files or
9603                 pipes may not be changed and no files may be removed
9604                 or renamed.
9605               </p>
9606
9607               <p>
9608                 All the directories in the diff must exist, except the
9609                 <file>debian</file> subdirectory of the top of the source
9610                 tree, which will be created by
9611                 <prgn>dpkg-source</prgn> if necessary when unpacking.
9612               </p>
9613
9614               <p>
9615                 The <prgn>dpkg-source</prgn> program will
9616                 automatically make the <file>debian/rules</file> file
9617                 executable (see below).</p></item>
9618           </taglist>
9619
9620
9621         <p>
9622           If there is no original source code - for example, if the
9623           package is specially prepared for Debian or the Debian
9624           maintainer is the same as the upstream maintainer - the
9625           format is slightly different: then there is no diff, and the
9626           tarfile is named
9627           <file><var>package</var>_<var>version</var>.tar.gz</file> and
9628           contains a directory
9629           <file><var>package</var>-<var>version</var></file>.
9630         </p>
9631       </sect>
9632
9633       <sect><heading>Unpacking a Debian source package without
9634       <prgn>dpkg-source</prgn>
9635         </heading>
9636
9637         <p>
9638           <tt>dpkg-source -x</tt> is the recommended way to unpack a
9639           Debian source package.  However, if it is not available it
9640           is possible to unpack a Debian source archive as follows:
9641         <enumlist compact="compact">
9642           <item>
9643             <p>
9644               Untar the tarfile, which will create a <file>.orig</file>
9645               directory.</p>
9646           </item>
9647           <item>
9648             <p>Rename the <file>.orig</file> directory to
9649               <file><var>package</var>-<var>version</var></file>.</p>
9650           </item>
9651             <item>
9652             <p>
9653               Create the subdirectory <file>debian</file> at the top of
9654               the source tree.</p>
9655           </item>
9656           <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9657           </item>
9658           <item><p>Untar the tarfile again if you want a copy of the original
9659               source code alongside the Debianised version.</p>
9660           </item>
9661         </enumlist>
9662
9663         <p>
9664           It is not possible to generate a valid Debian source archive
9665           without using <prgn>dpkg-source</prgn>.  In particular,
9666           attempting to use <prgn>diff</prgn> directly to generate the
9667           <file>.diff.gz</file> file will not work.
9668         </p>
9669
9670         <sect1><heading>Restrictions on objects in source packages
9671           </heading>
9672
9673           <p>
9674             The source package may not contain any hard links
9675             <footnote>
9676               <p>
9677                 This is not currently detected when building source
9678                 packages, but only when extracting
9679                 them.
9680               </p>
9681             </footnote>
9682             <footnote>
9683               <p>
9684                 Hard links may be permitted at some point in the
9685                 future, but would require a fair amount of
9686                 work.
9687               </p>
9688             </footnote>, device special files, sockets or setuid or
9689             setgid files.
9690             <footnote>
9691               <p>
9692                 Setgid directories are allowed.
9693               </p>
9694             </footnote>
9695           </p>
9696
9697           <p>
9698             The source packaging tools manage the changes between the
9699             original and Debianised source using <prgn>diff</prgn> and
9700             <prgn>patch</prgn>.  Turning the original source tree as
9701             included in the <file>.orig.tar.gz</file> into the debianised
9702             source must not involve any changes which cannot be
9703             handled by these tools.  Problematic changes which cause
9704             <prgn>dpkg-source</prgn> to halt with an error when
9705             building the source package are:
9706             <list compact="compact">
9707               <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9708               </item>
9709               <item><p>Changing the targets of symbolic links.</p>
9710               </item>
9711               <item><p>Creating directories, other than <file>debian</file>.</p>
9712               </item>
9713               <item><p>Changes to the contents of binary files.</p></item>
9714             </list> Changes which cause <prgn>dpkg-source</prgn> to
9715             print a warning but continue anyway are:
9716             <list compact="compact">
9717               <item>
9718                 <p>
9719                   Removing files, directories or symlinks.
9720                   <footnote>
9721                     <p>
9722                       Renaming a file is not treated specially - it is
9723                       seen as the removal of the old file (which
9724                       generates a warning, but is otherwise ignored),
9725                       and the creation of the new
9726                       one.</p>
9727                   </footnote>
9728                 </p>
9729               </item>
9730               <item>
9731                 <p>
9732                   Changed text files which are missing the usual final
9733                   newline (either in the original or the modified
9734                   source tree).
9735                 </p>
9736               </item>
9737             </list>
9738             Changes which are not represented, but which are not detected by
9739             <prgn>dpkg-source</prgn>, are:
9740             <list compact="compact">
9741               <item><p>Changing the permissions of files (other than
9742                   <file>debian/rules</file>) and directories.</p></item>
9743             </list>
9744           </p>
9745
9746           <p>
9747             The <file>debian</file> directory and <file>debian/rules</file>
9748             are handled specially by <prgn>dpkg-source</prgn> - before
9749             applying the changes it will create the <file>debian</file>
9750             directory, and afterwards it will make
9751             <file>debian/rules</file> world-exectuable.
9752           </p>
9753         </sect1>
9754       </sect>
9755     </appendix>
9756
9757     <appendix id="pkg-controlfields"><heading>Control files and their
9758         fields (from old Packaging Manual)
9759       </heading>
9760
9761       <p>
9762         Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9763         data in a common format, known as control files.  Binary and
9764         source packages have control data as do the <file>.changes</file>
9765         files which control the installation of uploaded files, and
9766         <prgn>dpkg</prgn>'s internal databases are in a similar
9767         format.
9768       </p>
9769
9770       <sect><heading>Syntax of control files
9771         </heading>
9772
9773         <p>
9774           A file consists of one or more paragraphs of fields.  The
9775           paragraphs are separated by blank lines.  Some control files
9776           only allow one paragraph; others allow several, in which
9777           case each paragraph often refers to a different package.
9778         </p>
9779
9780         <p>
9781           Each paragraph is a series of fields and values; each field
9782           consists of a name, followed by a colon and the value.  It
9783           ends at the end of the line.  Horizontal whitespace (spaces
9784           and tabs) may occur before or after the value and is ignored
9785           there; it is conventional to put a single space after the
9786           colon.
9787         </p>
9788
9789         <p>
9790           Some fields' values may span several lines; in this case
9791           each continuation line <em>must</em> start with a space or
9792           tab.  Any trailing spaces or tabs at the end of individual
9793           lines of a field value are ignored.
9794         </p>
9795
9796         <p>
9797           Except where otherwise stated only a single line of data is
9798           allowed and whitespace is not significant in a field body.
9799           Whitespace may never appear inside names (of packages,
9800           architectures, files or anything else), version numbers or
9801           in between the characters of multi-character version
9802           relationships.
9803         </p>
9804
9805         <p>
9806           Field names are not case-sensitive, but it is usual to
9807           capitalise the field names using mixed case as shown below.
9808         </p>
9809
9810         <p>
9811           Blank lines, or lines consisting only of spaces and tabs,
9812           are not allowed within field values or between fields - that
9813           would mean a new paragraph.
9814         </p>
9815
9816         <p>
9817           It is important to note that there are several fields which
9818           are optional as far as <prgn>dpkg</prgn> and the related
9819           tools are concerned, but which must appear in every Debian
9820           package, or whose omission may cause problems.
9821         </p>
9822       </sect>
9823
9824       <sect><heading>List of fields
9825         </heading>
9826
9827         <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9828           </heading>
9829
9830           <p>
9831             The name of the binary package.  Package names consist of
9832             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9833             (plus, minus and full stop).
9834             <footnote>
9835               <p>
9836                 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9837                 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9838                 and underscore) used to be legal and are still
9839                 accepted when found in a package file, but may not be
9840                 used in new packages
9841               </p>
9842             </footnote>
9843           </p>
9844
9845           <p>
9846             They must be at least two characters and must start with
9847             an alphanumeric.  In current versions of dpkg they are
9848             sort of case-sensitive<footnote><p>This is a
9849             bug.</p></footnote>; use lowercase package names unless
9850             the package you're building (or referring to, in other
9851             fields) is already using uppercase.</p>
9852         </sect1>
9853
9854         <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9855           </heading>
9856
9857           <p>
9858             This lists the source or binary package's version number -
9859             see <ref id="versions">.
9860           </p>
9861
9862         </sect1>
9863
9864         <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9865           </heading>
9866
9867           <p>
9868             This is the architecture string; it is a single word for
9869             the Debian architecture.
9870           </p>
9871
9872           <p>
9873             <prgn>dpkg</prgn> will check the declared architecture of
9874             a binary package against its own compiled-in value before
9875             it installs it.
9876           </p>
9877
9878           <p>
9879             The special value <tt>all</tt> indicates that the package
9880             is architecture-independent.
9881           </p>
9882
9883           <p>
9884             In the main <file>debian/control</file> file in the source
9885             package, or in the source package control file
9886             <file>.dsc</file>, a list of architectures (separated by
9887             spaces) is also allowed, as is the special value
9888             <tt>any</tt>.  A list indicates that the source will build
9889             an architecture-dependent package, and will only work
9890             correctly on the listed architectures.  <tt>any</tt>
9891             indicates that though the source package isn't dependent
9892             on any particular architecture and should compile fine on
9893             any one, the binary package(s) produced are not
9894             architecture-independent but will instead be specific to
9895             whatever the current build architecture is.
9896           </p>
9897
9898           <p>
9899             In a <file>.changes</file> file the <tt>Architecture</tt>
9900             field lists the architecture(s) of the package(s)
9901             currently being uploaded.  This will be a list; if the
9902             source for the package is being uploaded too the special
9903             entry <tt>source</tt> is also present.
9904           </p>
9905
9906           <p>
9907             See <ref id="pkg-debianrules"> for information how to get the
9908             architecture for the build process.
9909           </p>
9910         </sect1>
9911
9912         <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9913           </heading>
9914
9915           <p>
9916             The package maintainer's name and email address.  The name
9917             should come first, then the email address inside angle
9918             brackets <tt>&lt;&gt</tt> (in RFC822 format).
9919           </p>
9920
9921           <p>
9922             If the maintainer's name contains a full stop then the
9923             whole field will not work directly as an email address due
9924             to a misfeature in the syntax specified in RFC822; a
9925             program using this field as an address must check for this
9926             and correct the problem if necessary (for example by
9927             putting the name in round brackets and moving it to the
9928             end, and bringing the email address forward).
9929           </p>
9930
9931           <p>
9932             In a <file>.changes</file> file or parsed changelog data this
9933             contains the name and email address of the person
9934             responsible for the particular version in question - this
9935             may not be the package's usual maintainer.
9936           </p>
9937
9938           <p>
9939             This field is usually optional in as far as the
9940             <prgn>dpkg</prgn> are concerned, but its absence when
9941             building packages usually generates a warning.</p>
9942         </sect1>
9943
9944         <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9945           </heading>
9946
9947           <p>
9948             This field identifies the source package name.
9949           </p>
9950
9951           <p>
9952             In a main source control information or a
9953             <file>.changes</file> or <file>.dsc</file> file or parsed
9954             changelog data this may contain only the name of the
9955             source package.
9956           </p>
9957
9958           <p>
9959             In the control file of a binary package (or in a
9960             <file>Packages</file> file) it may be followed by a version
9961             number in parentheses.
9962             <footnote>
9963               <p>
9964                 It is usual to leave a space after the package name if
9965                 a version number is specified.
9966               </p>
9967             </footnote> This version number may be omitted (and is, by
9968             <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9969             the <tt>Version</tt> field of the binary package in
9970             question.  The field itself may be omitted from a binary
9971             package control file when the source package has the same
9972             name and version as the binary package.
9973           </p>
9974         </sect1>
9975
9976         <sect1><heading>Package interrelationship fields:
9977             <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9978             <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9979             <tt>Provides</tt>, <tt>Replaces</tt>
9980           </heading>
9981
9982           <p>
9983             These fields describe the package's relationships with
9984             other packages.  Their syntax and semantics are described
9985             in <ref id="relationships">.</p>
9986         </sect1>
9987
9988         <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9989           </heading>
9990
9991           <p>
9992             In a binary package <tt>Packages</tt> file or main source
9993             control file this field contains a description of the
9994             binary package, in a special format.  See <ref
9995             id="descriptions"> for details.
9996           </p>
9997
9998           <p>
9999             In a <file>.changes</file> file it contains a summary of the
10000             descriptions for the packages being uploaded.  The part of
10001             the field before the first newline is empty; thereafter
10002             each line has the name of a binary package and the summary
10003             description line from that binary package.  Each line is
10004             indented by one space.</p>
10005         </sect1>
10006
10007         <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
10008           </heading>
10009
10010           <p>
10011             This is a boolean field which may occur only in the
10012             control file of a binary package (or in the
10013             <file>Packages</file> file) or in a per-package fields
10014             paragraph of a main source control data file.
10015           </p>
10016
10017           <p>
10018             If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
10019             <prgn>dselect</prgn> will refuse to remove the package
10020             (though it can be upgraded and/or replaced).  The other
10021             possible value is <tt>no</tt>, which is the same as not
10022             having the field at all.</p>
10023         </sect1>
10024
10025         <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
10026         <tt>Priority</tt>
10027           </heading>
10028
10029           <p>
10030             These two fields classify the package.  The
10031             <tt>Priority</tt> represents how important that it is that
10032             the user have it installed; the <tt>Section</tt>
10033             represents an application area into which the package has
10034             been classified.
10035           </p>
10036
10037           <p>
10038             When they appear in the <file>debian/control</file> file these
10039             fields give values for the section and priority subfields
10040             of the <tt>Files</tt> field of the <file>.changes</file> file,
10041             and give defaults for the section and priority of the
10042             binary packages.
10043           </p>
10044
10045           <p>
10046             The section and priority are represented, though not as
10047             separate fields, in the information for each file in the
10048             <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
10049             <file>.changes</file> file.  The section value in a
10050             <file>.changes</file> file is used to decide where to install
10051             a package in the FTP archive.
10052           </p>
10053
10054           <p>
10055             These fields are not used by by <prgn>dpkg</prgn> proper,
10056             but by <prgn>dselect</prgn> when it sorts packages and
10057             selects defaults.
10058           </p>
10059
10060           <p>
10061             These fields can appear in binary package control files,
10062             in which case they provide a default value in case the
10063             <file>Packages</file> files are missing the information.
10064             <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
10065             the value from a <file>.deb</file> file if they have no other
10066             information; a value listed in a <file>Packages</file> file
10067             will always take precedence.  By default
10068             <prgn>dpkg-gencontrol</prgn> does not include the section
10069             and priority in the control file of a binary package - use
10070             the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
10071             achieve this effect.</p>
10072         </sect1>
10073
10074         <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
10075           </heading>
10076
10077           <p>
10078             This field is a list of binary packages.
10079           </p>
10080
10081           <p>
10082             When it appears in the <file>.dsc</file> file it is the list
10083             of binary packages which a source package can produce.  It
10084             does not necessarily produce all of these binary packages
10085             for every architecture.  The source control file doesn't
10086             contain details of which architectures are appropriate for
10087             which of the binary packages.
10088           </p>
10089
10090           <p>
10091             When it appears in a <file>.changes</file> file it lists the
10092             names of the binary packages actually being uploaded.
10093           </p>
10094
10095           <p>
10096             The syntax is a list of binary packages separated by
10097             commas.
10098             <footnote>
10099               <p>
10100                 A space after each comma is conventional.
10101               </p>
10102             </footnote> Currently the packages must be separated using
10103             only spaces in the <file>.changes</file> file.</p>
10104         </sect1>
10105
10106         <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10107           </heading>
10108
10109           <p>
10110             This field appears in the control files of binary
10111             packages, and in the <file>Packages</file> files.  It gives
10112             the total amount of disk space required to install the
10113             named package.
10114           </p>
10115
10116           <p>
10117             The disk space is represented in kilobytes as a simple
10118             decimal number.</p>
10119         </sect1>
10120
10121         <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10122           </heading>
10123
10124           <p>
10125             This field contains a list of files with information about
10126             each one.  The exact information and syntax varies with
10127             the context.  In all cases the part of the field
10128             contents on the same line as the field name is empty.  The
10129             remainder of the field is one line per file, each line
10130             being indented by one space and containing a number of
10131             sub-fields separated by spaces.
10132           </p>
10133
10134           <p>
10135             In the <file>.dsc</file> (Debian source control) file each
10136             line contains the MD5 checksum, size and filename of the
10137             tarfile and (if applicable) diff file which make up the
10138             remainder of the source package.
10139             <footnote>
10140               <p>
10141                 That is, the parts which are not the
10142                 <tt>.dsc</tt>.
10143               </p>
10144             </footnote> The exact forms of the filenames are described
10145             in <ref id="pkg-sourcearchives">.
10146           </p>
10147
10148           <p>
10149             In the <file>.changes</file> file this contains one line per
10150             file being uploaded.  Each line contains the MD5 checksum,
10151             size, section and priority and the filename.  The section
10152             and priority are the values of the corresponding fields in
10153             the main source control file - see <ref
10154             id="pkg-f-classification">.  If no section or priority is
10155             specified then <tt>-</tt> should be used, though section
10156             and priority values must be specified for new packages to
10157             be installed properly.
10158           </p>
10159
10160           <p>
10161             The special value <tt>byhand</tt> for the section in a
10162             <tt>.changes</tt> file indicates that the file in question
10163             is not an ordinary package file and must by installed by
10164             hand by the distribution maintainers.  If the section is
10165             <tt>byhand</tt> the priority should be <tt>-</tt>.
10166           </p>
10167
10168           <p>
10169             If a new Debian revision of a package is being shipped and
10170             no new original source archive is being distributed the
10171             <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10172             entry for the original source archive
10173             <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10174             but the <file>.changes</file> file should leave it out.  In
10175             this case the original source archive on the distribution
10176             site must match exactly, byte-for-byte, the original
10177             source archive which was used to generate the
10178             <file>.dsc</file> file and diff which are being uploaded.</p>
10179         </sect1>
10180
10181
10182         <sect1
10183         id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10184           </heading>
10185
10186           <p>
10187             The most recent version of the standards (the Debian Policy
10188             and associated texts) with which the package complies. This
10189             is updated manually when editing the source package to
10190             conform to newer standards; it can sometimes be used to
10191             tell when a package needs attention.
10192           </p>
10193
10194           <p>
10195             Its format is the same as that of a version number except
10196             that no epoch or Debian revision is allowed - see <ref
10197             id="versions">.</p>
10198         </sect1>
10199
10200
10201         <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10202           </heading>
10203
10204           <p>
10205             In a <file>.changes</file> file or parsed changelog output
10206             this contains the (space-separated) name(s) of the
10207             distribution(s) where this version of the package should
10208             be or was installed.  Distribution names follow the rules
10209             for package names.  (See <ref id="pkg-f-Package">).
10210           </p>
10211
10212           <p>
10213             Current distribution values are:
10214           <taglist>
10215             <tag><em>stable</em></tag>
10216             <item>
10217               <p>
10218                 This is the current "released" version of Debian
10219                 GNU/Linux.  A new version is released approximately
10220                 every 3 months after the <em>development</em> code has
10221                 been <em>frozen</em> for a month of testing.  Once the
10222                 distribution is <em>stable</em> only major bug fixes
10223                 are allowed. When changes are made to this
10224                 distribution, the release number is increased
10225                 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10226               </p>
10227             </item>
10228
10229             <tag><em>unstable</em></tag>
10230             <item>
10231               <p>
10232                 This distribution value refers to the
10233                 <em>developmental</em> part of the Debian distribution
10234                 tree. New packages, new upstream versions of packages
10235                 and bug fixes go into the <em>unstable</em> directory
10236                 tree. Download from this distribution at your own
10237                 risk.</p>
10238             </item>
10239
10240             <tag><em>contrib</em></tag>
10241             <item>
10242               <p>
10243                 The packages with this distribution value do not meet
10244                 the criteria for inclusion in the main Debian
10245                 distribution as defined by the Policy Manual, but meet
10246                 the criteria for the <em>contrib</em>
10247                 Distribution. There is currently no distinction
10248                 between stable and unstable packages in the
10249                 <em>contrib</em> or <em>non-free</em>
10250                 distributions. Use your best judgement in downloading
10251                 from this Distribution.</p>
10252             </item>
10253
10254             <tag><em>non-free</em></tag>
10255             <item>
10256               <p>
10257                 Like the packages in the <em>contrib</em> seciton,
10258                 the packages in <em>non-free</em> do not meet the
10259                 criteria for inclusion in the main Debian distribution
10260                 as defined by the Policy Manual. Again, use your best
10261                 judgement in downloading from this Distribution.</p>
10262
10263             <tag><em>experimental</em></tag>
10264             <item>
10265               <p>
10266                 The packages with this distribution value are deemed
10267                 by their maintainers to be high risk. Oftentimes they
10268                 represent early beta or developmental packages from
10269                 various sources that the maintainers want people to
10270                 try, but are not ready to be a part of the other parts
10271                 of the Debian distribution tree. Download at your own
10272                 risk.</p>
10273             </item>
10274
10275             <tag><em>frozen</em></tag>
10276             <item>
10277               <p>
10278                 From time to time, (currently, every 3 months) the
10279                 <em>unstable</em> distribution enters a state of
10280                 "code-freeze" in anticipation of release as a
10281                 <em>stable</em> version. During this period of testing
10282                 (usually 4 weeks) only fixes for existing or
10283                 newly-discovered bugs will be allowed.
10284               </p>
10285             </item>
10286           </taglist> You should list <em>all</em> distributions that
10287           the package should be installed into. Except in unusual
10288           circumstances, installations to <em>stable</em> should also
10289           go into <em>frozen</em> (if it exists) and
10290           <em>unstable</em>. Likewise, installations into
10291           <em>frozen</em> should also go into <em>unstable</em>.</p>
10292         </sect1>
10293
10294         <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10295           </heading>
10296
10297           <p>
10298             This is a description of how important it is to upgrade to
10299             this version from previous ones.  It consists of a single
10300             keyword usually taking one of the values <tt>LOW</tt>,
10301             <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10302             commentary (separated by a space) which is usually in
10303             parentheses.  For example:
10304             <example>
10305   Urgency: LOW (HIGH for diversions users)
10306             </example>
10307           </p>
10308
10309           <p>
10310             This field appears in the <file>.changes</file> file and in
10311             parsed changelogs; its value appears as the value of the
10312             <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10313             changelog (see <ref id="pkg-dpkgchangelog">).
10314           </p>
10315
10316           <p>
10317             Urgency keywords are not case-sensitive.</p>
10318         </sect1>
10319
10320         <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10321           </heading>
10322
10323           <p>
10324             In <tt>.changes</tt> files and parsed changelogs, this
10325             gives the date the package was built or last edited.</p>
10326         </sect1>
10327
10328         <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10329           </heading>
10330
10331           <p>
10332             This field occurs in <file>.changes</file> files, and
10333             specifies a format revision for the file.  The format
10334             described here is version <tt>1.5</tt>.  The syntax of the
10335             format value is the same as that of a package version
10336             number except that no epoch or Debian revision is allowed
10337             - see <ref id="versions">.</p>
10338         </sect1>
10339
10340         <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10341           </heading>
10342
10343           <p>
10344             In a <file>.changes</file> file or parsed changelog this field
10345             contains the human-readable changes data, describing the
10346             differences between the last version and the current one.
10347           </p>
10348
10349           <p>
10350             There should be nothing in this field before the first
10351             newline; all the subsequent lines must be indented by at
10352             least one space; blank lines must be represented by a line
10353             consiting only of a space and a full stop.
10354           </p>
10355
10356           <p>
10357             Each version's change information should be preceded by a
10358             "title" line giving at least the version, distribution(s)
10359             and urgency, in a human-readable way.
10360           </p>
10361
10362           <p>
10363             If data from several versions is being returned the entry
10364             for the most recent version should be returned first, and
10365             entries should be separated by the representation of a
10366             blank line (the "title" line may also be followed by the
10367             representation of blank line).</p>
10368         </sect1>
10369
10370         <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10371         <tt>MSDOS-Filename</tt>
10372           </heading>
10373
10374           <p>
10375             These fields in <tt>Packages</tt> files give the
10376             filename(s) of (the parts of) a package in the
10377             distribution directories, relative to the root of the
10378             Debian hierarchy.  If the package has been split into
10379             several parts the parts are all listed in order, separated
10380             by spaces.</p>
10381         </sect1>
10382
10383         <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10384           </heading>
10385
10386           <p>
10387             These fields in <file>Packages</file> files give the size (in
10388             bytes, expressed in decimal) and MD5 checksum of the
10389             file(s) which make(s) up a binary package in the
10390             distribution.  If the package is split into several parts
10391             the values for the parts are listed in order, separated by
10392             spaces.</p>
10393         </sect1>
10394
10395         <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10396           </heading>
10397
10398           <p>
10399             This field in <prgn>dpkg</prgn>'s status file records
10400             whether the user wants a package installed, removed or
10401             left alone, whether it is broken (requiring
10402             reinstallation) or not and what its current state on the
10403             system is.  Each of these pieces of information is a
10404             single word.</p>
10405         </sect1>
10406
10407         <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10408           </heading>
10409
10410           <p>
10411             If a package is not installed or not configured, this
10412             field in <prgn>dpkg</prgn>'s status file records the last
10413             version of the package which was successfully
10414             configured.</p>
10415         </sect1>
10416
10417         <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10418           </heading>
10419
10420           <p>
10421             This field in <prgn>dpkg</prgn>'s status file contains
10422             information about the automatically-managed configuration
10423             files held by a package.  This field should <em>not</em>
10424             appear anywhere in a package!</p>
10425         </sect1>
10426
10427         <sect1><heading>Obsolete fields
10428           </heading>
10429
10430           <p>
10431             These are still recognised by <prgn>dpkg</prgn> but should
10432             not appear anywhere any more.
10433             <taglist compact="compact">
10434
10435               <tag><tt>Revision</tt></tag>
10436               <tag><tt>Package-Revision</tt></tag>
10437               <tag><tt>Package_Revision</tt></tag>
10438               <item>
10439                 <p>
10440                   The Debian revision part of the package version was
10441                   at one point in a separate control file field.  This
10442                   field went through several names.</p>
10443               </item>
10444
10445               <tag><tt>Recommended</tt></tag>
10446               <item><p>Old name for <tt>Recommends</tt></p>
10447               </item>
10448
10449               <tag><tt>Optional</tt></tag>
10450               <item><p>Old name for <tt>Suggests</tt>.</p>
10451               </item>
10452               <tag><tt>Class</tt></tag>
10453               <item><p>Old name for <tt>Priority</tt>.</p>
10454               </item>
10455             </taglist>
10456           </p>
10457         </sect1>
10458       </sect>
10459     </appendix>
10460
10461     <appendix id="pkg-conffiles"><heading>Configuration file handling
10462     (from old Packaging Manual)
10463       </heading>
10464
10465       <p>
10466         <prgn>dpkg</prgn> can do a certain amount of automatic
10467         handling of package configuration files.
10468       </p>
10469
10470       <p>
10471         Whether this mechanism is appropriate depends on a number of
10472         factors, but basically there are two approaches to any
10473         particular configuration file.
10474       </p>
10475
10476       <p>
10477         The easy method is to ship a best-effort configuration in the
10478         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10479         handle updates.  If the user is unlikely to want to edit the
10480         file, but you need them to be able to without losing their
10481         changes, and a new package with a changed version of the file
10482         is only released infrequently, this is a good approach.
10483       </p>
10484
10485       <p>
10486         The hard method is to build the configuration file from
10487         scratch in the <prgn>postinst</prgn> script, and to take the
10488         responsibility for fixing any mistakes made in earlier
10489         versions of the package automatically.  This will be
10490         appropriate if the file is likely to need to be different on
10491         each system.
10492       </p>
10493
10494       <sect><heading>Automatic handling of configuration files by
10495       <prgn>dpkg</prgn>
10496         </heading>
10497
10498         <p>
10499           A package may contain a control area file called
10500           <tt>conffiles</tt>.  This file should be a list of filenames
10501           of configuration files needing automatic handling, separated
10502           by newlines.  The filenames should be absolute pathnames,
10503           and the files referred to should actually exist in the
10504           package.
10505         </p>
10506
10507         <p>
10508           When a package is upgraded <prgn>dpkg</prgn> will process
10509           the configuration files during the configuration stage,
10510           shortly before it runs the package's <prgn>postinst</prgn>
10511           script,
10512         </p>
10513
10514         <p>
10515           For each file it checks to see whether the version of the
10516           file included in the package is the same as the one that was
10517           included in the last version of the package (the one that is
10518           being upgraded from); it also compares the version currently
10519           installed on the system with the one shipped with the last
10520           version.
10521         </p>
10522
10523         <p>
10524           If neither the user nor the package maintainer has changed
10525           the file, it is left alone.  If one or the other has changed
10526           their version, then the changed version is preferred - i.e.,
10527           if the user edits their file, but the package maintainer
10528           doesn't ship a different version, the user's changes will
10529           stay, silently, but if the maintainer ships a new version
10530           and the user hasn't edited it the new version will be
10531           installed (with an informative message).  If both have
10532           changed their version the user is prompted about the problem
10533           and must resolve the differences themselves.
10534         </p>
10535
10536         <p>
10537           The comparisons are done by calculating the MD5 message
10538           digests of the files, and storing the MD5 of the file as it
10539           was included in the most recent version of the package.
10540         </p>
10541
10542         <p>
10543           When a package is installed for the first time
10544           <prgn>dpkg</prgn> will install the file that comes with it,
10545           unless that would mean overwriting a file already on the
10546           filesystem.
10547         </p>
10548
10549         <p>
10550           However, note that <prgn>dpkg</prgn> will <em>not</em>
10551           replace a conffile that was removed by the user (or by a
10552           script).  This is necessary because with some programs a
10553           missing file produces an effect hard or impossible to
10554           achieve in another way, so that a missing file needs to be
10555           kept that way if the user did it.
10556         </p>
10557
10558         <p>
10559           Note that a package should <em>not</em> modify a
10560           <prgn>dpkg</prgn>-handled conffile in its maintainer
10561           scripts.  Doing this will lead to <prgn>dpkg</prgn> giving
10562           the user confusing and possibly dangerous options for
10563           conffile update when the package is upgraded.</p>
10564       </sect>
10565
10566       <sect><heading>Fully-featured maintainer script configuration
10567       handling
10568         </heading>
10569
10570         <p>
10571           For files which contain site-specific information such as
10572           the hostname and networking details and so forth, it is
10573           better to create the file in the package's
10574           <prgn>postinst</prgn> script.
10575         </p>
10576
10577         <p>
10578           This will typically involve examining the state of the rest
10579           of the system to determine values and other information, and
10580           may involve prompting the user for some information which
10581           can't be obtained some other way.
10582         </p>
10583
10584         <p>
10585           When using this method there are a couple of important
10586           issues which should be considered:
10587         </p>
10588
10589         <p>
10590           If you discover a bug in the program which generates the
10591           configuration file, or if the format of the file changes
10592           from one version to the next, you will have to arrange for
10593           the postinst script to do something sensible - usually this
10594           will mean editing the installed configuration file to remove
10595           the problem or change the syntax.  You will have to do this
10596           very carefully, since the user may have changed the file,
10597           perhaps to fix the very problem that your script is trying
10598           to deal with - you will have to detect these situations and
10599           deal with them correctly.
10600         </p>
10601
10602         <p>
10603           If you do go down this route it's probably a good idea to
10604           make the program that generates the configuration file(s) a
10605           separate program in <file>/usr/sbin</file>, by convention called
10606           <file><var>package</var>config</file> and then run that if
10607           appropriate from the post-installation script.  The
10608           <tt><var>package</var>config</tt> program should not
10609           unquestioningly overwrite an existing configuration - if its
10610           mode of operation is geared towards setting up a package for
10611           the first time (rather than any arbitrary reconfiguration
10612           later) you should have it check whether the configuration
10613           already exists, and require a <tt>--force</tt> flag to
10614           overwrite it.</p></sect>
10615     </appendix>
10616
10617     <appendix id="pkg-alternatives"><heading>Alternative versions of
10618         an interface - <prgn>update-alternatives</prgn> (from old
10619     Packaging Manual)
10620       </heading>
10621
10622       <p>
10623         When several packages all provide different versions of the
10624         same program or file it is useful to have the system select a
10625         default, but to allow the system administrator to change it
10626         and have their decisions respected.
10627       </p>
10628
10629       <p>
10630         For example, there are several versions of the <prgn>vi</prgn>
10631         editor, and there is no reason to prevent all of them from
10632         being installed at once, each under their own name
10633         (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10634         Nevertheless it is desirable to have the name <tt>vi</tt>
10635         refer to something, at least by default.
10636       </p>
10637
10638       <p>
10639         If all the packages involved cooperate, this can be done with
10640         <prgn>update-alternatives</prgn>.
10641       </p>
10642
10643       <p>
10644         Each package provides its own version under its own name, and
10645         calls <prgn>update-alternatives</prgn> in its postinst to
10646         register its version (and again in its prerm to deregister
10647         it).
10648       </p>
10649
10650       <p>
10651         See the manpage <manref name="update-alternatives"
10652         section="8"> for details.
10653       </p>
10654
10655       <p>
10656         If <prgn>update-alternatives</prgn> does not seem appropriate
10657         you may wish to consider using diversions instead.</p>
10658     </appendix>
10659
10660     <appendix id="pkg-diversions"><heading>Diversions - overriding a
10661     package's version of a file (from old Packaging Manual)
10662       </heading>
10663
10664       <p>
10665         It is possible to have <prgn>dpkg</prgn> not overwrite a file
10666         when it reinstalls the package it belongs to, and to have it
10667         put the file from the package somewhere else instead.
10668       </p>
10669
10670       <p>
10671         This can be used locally to override a package's version of a
10672         file, or by one package to override another's version (or
10673         provide a wrapper for it).
10674       </p>
10675
10676       <p>
10677         Before deciding to use a diversion, read <ref
10678         id="pkg-alternatives"> to see if you really want a diversion
10679         rather than several alternative versions of a program.
10680       </p>
10681
10682       <p>
10683         There is a diversion list, which is read by <prgn>dpkg</prgn>,
10684         and updated by a special program <prgn>dpkg-divert</prgn>.
10685         Please see <manref name="dpkg-divert" section="8"> for full
10686         details of its operation.
10687       </p>
10688
10689       <p>
10690         When a package wishes to divert a file from another, it should
10691         call <prgn>dpkg-divert</prgn> in its preinst to add the
10692         diversion and rename the existing file.  For example,
10693         supposing that a <prgn>smailwrapper</prgn> package wishes to
10694         install a wrapper around <file>/usr/sbin/smail</file>:
10695         <example>
10696   if [ install = "$1"  ]; then
10697      dpkg-divert --package smailwrapper --add --rename \
10698         --divert /usr/sbin/smail.real /usr/sbin/smail
10699   fi
10700         </example> Testing <tt>$1</tt> is necessary so that the script
10701         doesn't try to add the diversion again when
10702         <prgn>smailwrapper</prgn> is upgraded.  The <tt>--package
10703         smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10704         copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10705         get installed as the true version.
10706       </p>
10707
10708       <p>
10709         The postrm has to do the reverse:
10710         <example>
10711   if [ remove = "$1" ]; then
10712      dpkg-divert --package smailwrapper --remove --rename \
10713         --divert /usr/sbin/smail.real /usr/sbin/smail
10714   fi
10715         </example>
10716       </p>
10717
10718       <p>
10719         Do not attempt to divert a file which is vitally important for
10720         the system's operation - when using <prgn>dpkg-divert</prgn>
10721         there is a time, after it has been diverted but before
10722         <prgn>dpkg</prgn> has installed the new version, when the file
10723         does not exist.</p>
10724     </appendix>
10725
10726   </book>
10727 </debiandoc>
10728 <!-- vim:set ai et sts=2 sw=2 tw=76: -->