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