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