]> git.donarmstrong.com Git - debian/debian-policy.git/blob - policy.sgml
explicate that appendices aren't necessarily normative
[debian/debian-policy.git] / policy.sgml
1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3      within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
5 ]>
6 <debiandoc>
7
8   <book>
9     <titlepag>
10       <title>Debian Policy Manual</title>
11       <author><ref id="authors"></author>
12       <version>version &version;, &date;</version>
13
14       <abstract>
15         This manual describes the policy requirements for the Debian
16         GNU/Linux distribution.  This includes the structure and
17         contents of the Debian archive and several design issues of
18         the operating system, as well as technical requirements that
19         each package must satisfy to be included in the distribution.
20       </abstract>
21
22       <copyright>
23         <copyrightsummary>
24           Copyright &copy; 1996,1997,1998 Ian Jackson
25           and Christian Schwarz.
26         </copyrightsummary>
27         <p>
28           This manual is free software; you may redistribute it and/or
29           modify it under the terms of the GNU General Public License
30           as published by the Free Software Foundation; either version
31           2, or (at your option) any later version.
32         </p>
33
34         <p>
35           This is distributed in the hope that it will be useful, but
36           <em>without any warranty</em>; without even the implied
37           warranty of merchantability or fitness for a particular
38           purpose.  See the GNU General Public License for more
39           details.
40         </p>
41
42         <p>
43           A copy of the GNU General Public License is available as
44           <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
45           distribution or on the World Wide Web at
46           <url id="http://www.gnu.org/copyleft/gpl.html"
47                name="the GNU General Public Licence">. You can also
48           obtain it by writing to the Free Software Foundation, Inc.,
49           59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
50         </p>
51       </copyright>
52     </titlepag>
53
54     <toc detail="sect1">
55
56     <chapt id="scope">
57       <heading>About this manual</heading>
58       <sect>
59         <heading>Scope</heading>
60         <p>
61           This manual describes the policy requirements for the Debian
62           GNU/Linux distribution. This includes the structure and
63           contents of the Debian archive and several design issues of the
64           operating system, as well as technical requirements that
65           each package must satisfy to be included in the
66           distribution.
67         </p>
68
69         <p>
70           This manual also describes Debian policy as it relates to
71           creating Debian packages. It is not a tutorial on how to build
72           packages, nor is it exhaustive where it comes to describing
73           the behavior of the packaging system. Instead, this manual
74           attempts to define the interface to the package management
75           system that the developers have to be conversant with.<footnote>
76             <p>
77               Informally, the criteria used for inclusion is that the
78               material meet one of the following requirements:
79               <taglist compact="compact">
80                 <tag>Standard interfaces</tag>
81                 <item>
82                   <p>
83                     The material presented represents an interface to
84                     the packaging system that is mandated for use, and
85                     is used by, a significant number of packages, and
86                     therefore should not be changed without peer
87                     review. Package maintainers can then rely on this
88                     interfaces not changing, and the package
89                     management software authors need to ensure
90                     compatibility with these interface
91                     definitions. (Control file and changelog file
92                     formats are examples.)
93                   </p>
94                 </item>
95                 <tag>Chosen Convention</tag>
96                 <item>
97                   <p>
98                     If there are a number of technically viable choices
99                     that can be made, but one needs to select one of
100                     these options for inter-operability. The version
101                     number format is one example.
102                   </p>
103                 </item>
104               </taglist>
105               Please note that these are not mutually exclusive;
106               selected conventions often become parts of standard
107               interfaces.
108             </p>
109           </footnote>
110         </p>
111
112         <p>
113           The footnotes present in this manual are
114           merely informative, and are not part of Debian policy itself.
115         </p>
116
117         <p>
118           The appendices to this manual are not necessarily normative,
119           either. Please see <ref id="pkg-scope"> for more information.
120         </p>
121
122         <p>
123           In the normative part of this manual,
124           the words <em>must</em>, <em>should</em> and
125           <em>may</em>, and the adjectives <em>required</em>,
126           <em>recommended</em> and <em>optional</em>, are used to
127           distinguish the significance of the various guidelines in
128           this policy document. Packages that do not conform to the
129           guidelines denoted by <em>must</em> (or <em>required</em>)
130           will generally not be considered acceptable for the Debian
131           distribution. Non-conformance with guidelines denoted by
132           <em>should</em> (or <em>recommended</em>) will generally be
133           considered a bug, but will not necessarily render a package
134           unsuitable for distribution. Guidelines denoted by
135           <em>may</em> (or <em>optional</em>) are truly optional and
136           adherence is left to the maintainer's discretion.
137         </p>
138         <p>
139           These classifications are roughly equivalent to the bug
140           severities <em>serious</em> (for <em>must</em> or
141           <em>required</em> directive violations), <em>minor</em>,
142           <em>normal</em> or <em>important</em>
143           (for <em>should</em> or <em>recommended</em> directive
144           violations) and <em>wishlist</em> (for <em>optional</em>
145           items).<footnote>
146             <p>Compare RFC 2119.  Note, however, that these words are
147           used in a different way in this document.</p>
148           </footnote>
149         </p>
150         <p>
151           Much of the information presented in this manual will be
152           useful even when building a package which is to be
153           distributed in some other way or is intended for local use
154           only.
155         </p>
156       </sect>
157
158       <sect>
159         <heading>New versions of this document</heading>
160         <p>
161           The current version of this document is always accessible
162           from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
163           as
164           <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
165           (also available from the same directory are several other
166           formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
167           and <file>policy.ps.gz</file>) or from the <url
168           id="http://www.debian.org/doc/debian-policy/" name="Debian
169           Policy Manual"> webpage.</p>
170
171         <p>
172           In addition, this manual is distributed via the Debian package
173           <file>debian-policy</file>.
174         </p>
175
176         <p>
177           The <tt>debian-policy</tt> package also includes the file
178           <file>upgrading-checklist.txt</file> which indicates policy
179           changes between versions of this document.
180         </p>
181       </sect>
182
183       <sect id="authors">
184         <heading>Authors and Maintainers</heading>
185
186         <p>
187           Originally called "Debian GNU/Linux Policy Manual", this
188           manual was initially written in 1996 by Ian Jackson.
189           It was revised on November 27th, 1996 by David A. Morris.
190           Christian Schwarz added new sections on March 15th, 1997,
191           and reworked/restructured it in April-July 1997.
192           Christoph Lameter contributed the "Web Standard".
193           Julian Gilbey largely restructured it in 2001.
194         </p>
195
196         <p>
197           Since September 1998, the responsibility for the contents of
198           this document lies on the debian-policy mailing list. Proposals
199           are discussed there and inserted into policy after a certain
200           consensus is established.
201           <!-- insert shameless policy-process plug here eventually -->
202           The actual editing is done by a group of maintainers that have
203           no editorial powers. These are the current maintainers:
204
205           <enumlist>
206             <item>Julian Gilbey</item>
207             <item>Branden Robinson</item>
208             <item>Josip Rodin</item>
209             <item>Manoj Srivastava</item>
210           </enumlist>
211         </p>
212
213         <p>
214           While the authors of this document have tried hard to avoid
215           typos and other errors, these do still occur. If you discover
216           an error in this manual or if you want to give any
217           comments, suggestions, or criticisms please send an email to
218           the Debian Policy List,
219           <email>debian-policy@lists.debian.org</email>, or submit a
220           bug report against the <tt>debian-policy</tt> package.
221         </p>
222
223         <p>
224           Please do not try to reach the individual authors or maintainers
225           of the Policy Manual regarding changes to the Policy.
226         </p>
227       </sect>
228     </chapt>
229
230     <chapt id="archive">
231       <heading>The Debian Archive</heading>
232       <p>
233         The Debian GNU/Linux system is maintained and distributed as a
234         collection of <em>packages</em>. Since there are so many of
235         them (currently well over 6000), they are split into
236         <em>sections</em> and given <em>priorities</em> to simplify
237         the handling of them.
238       </p>
239       <p>
240         The effort of the Debian project is to build a free operating
241         system, but not every package we want to make accessible is
242         <em>free</em> in our sense (see the Debian Free Software
243         Guidelines, below), or may be imported/exported without
244         restrictions. Thus, the archive is split into the sections
245         <em>main</em>, <em>non-free</em>, <em>contrib</em>,
246         <em>non-US/main</em>, <em>non-US/non-free</em>, and
247         <em>non-US/contrib</em>.  The sections are explained in detail
248         below.
249       </p>
250
251       <p>
252         The <em>main</em> and the <em>non-US/main</em> sections
253         together form the <em>Debian GNU/Linux distribution</em>.
254       </p>
255
256       <p>
257         Packages in the other sections are not considered to be part
258         of the Debian distribution, although we support their use and
259         provide infrastructure for them (such as our bug-tracking
260         system and mailing lists). This Debian Policy Manual applies
261         to these packages as well.</p>
262
263       <sect id="pkgcopyright">
264         <heading>Package copyright and sections</heading>
265         <p>
266           The aims of this section are:
267
268           <list compact="compact">
269             <item>
270               <p>to allow us to make as much software available as we
271                 can,</p>
272             </item>
273             <item>
274               <p>to allow us to encourage everyone to write free
275               software, and</p>
276             </item>
277             <item>
278               <p>to allow us to make it easy for people to produce
279                 CD-ROMs of our system without violating any licenses,
280                 import/export restrictions, or any other laws.</p>
281             </item>
282           </list>
283         </p>
284         <sect1>
285           <heading>The Debian Free Software Guidelines</heading>
286           <p>
287             The Debian Free Software Guidelines (DFSG) form our
288             definition of "free software".  These are:
289             <taglist>
290               <tag>Free Redistribution
291               </tag>
292               <item>
293                 <p>
294                   The license of a Debian component may not restrict any
295                   party from selling or giving away the software as a
296                   component of an aggregate software distribution
297                   containing programs from several different
298                   sources. The license may not require a royalty or
299                   other fee for such sale.
300                 </p>
301               </item>
302               <tag>Source Code
303               </tag>
304               <item>
305                 <p>
306                   The program must include source code, and must allow
307                   distribution in source code as well as compiled form.
308                 </p>
309               </item>
310               <tag>Derived Works
311               </tag>
312               <item>
313                 <p>
314                   The license must allow modifications and derived
315                   works, and must allow them to be distributed under the
316                   same terms as the license of the original software.
317                 </p>
318               </item>
319               <tag>Integrity of The Author's Source Code
320               </tag>
321               <item>
322                 <p>
323                   The license may restrict source-code from being
324                   distributed in modified form <em>only</em> if the
325                   license allows the distribution of "patch files"
326                   with the source code for the purpose of modifying the
327                   program at build time. The license must explicitly
328                   permit distribution of software built from modified
329                   source code. The license may require derived works to
330                   carry a different name or version number from the
331                   original software.  (This is a compromise. The Debian
332                   Project encourages all authors to not restrict any
333                   files, source or binary, from being modified.)
334                 </p>
335               </item>
336               <tag>No Discrimination Against Persons or Groups
337               </tag>
338               <item>
339                 <p>
340                   The license must not discriminate against any person
341                   or group of persons.
342                 </p>
343               </item>
344               <tag>No Discrimination Against Fields of Endeavor
345               </tag>
346               <item>
347                 <p>
348                   The license must not restrict anyone from making use
349                   of the program in a specific field of endeavor. For
350                   example, it may not restrict the program from being
351                   used in a business, or from being used for genetic
352                   research.
353                 </p>
354               </item>
355               <tag>Distribution of License
356               </tag>
357               <item>
358                 <p>
359                   The rights attached to the program must apply to all
360                   to whom the program is redistributed without the need
361                   for execution of an additional license by those
362                   parties.
363                 </p>
364               </item>
365               <tag>License Must Not Be Specific to Debian
366               </tag>
367               <item>
368                 <p>
369                   The rights attached to the program must not depend on
370                   the program's being part of a Debian system. If the
371                   program is extracted from Debian and used or
372                   distributed without Debian but otherwise within the
373                   terms of the program's license, all parties to whom
374                   the program is redistributed must have the same
375                   rights as those that are granted in conjunction with
376                   the Debian system.
377                 </p>
378               </item>
379               <tag>License Must Not Contaminate Other Software
380               </tag>
381               <item>
382                 <p>
383                   The license must not place restrictions on other
384                   software that is distributed along with the licensed
385                   software. For example, the license must not insist
386                   that all other programs distributed on the same medium
387                   must be free software.
388                 </p>
389               </item>
390               <tag>Example Licenses
391               </tag>
392               <item>
393                 <p>
394                   The "GPL," "BSD," and "Artistic" licenses are examples of
395                   licenses that we consider <em>free</em>.
396                 </p>
397               </item>
398             </taglist>
399           </p>
400         </sect1>
401         <sect1>
402           <heading>The main section</heading>
403           <p>
404             Every package in <em>main</em> and <em>non-US/main</em>
405             must comply with the DFSG (Debian Free Software
406             Guidelines).</p>
407
408           <p>
409             In addition, the packages in <em>main</em>
410             <list compact="compact">
411               <item>
412                 <p>
413                   must not require a package outside of <em>main</em>
414                   for compilation or execution (thus, the package must
415                   not declare a "Depends", "Recommends", or
416                   "Build-Depends" relationship on a non-<em>main</em>
417                   package),
418                 </p>
419               </item>
420               <item>
421                 <p>
422                   must not be so buggy that we refuse to support them,
423                   and
424                 </p>
425               </item>
426               <item>
427                 <p>
428                   must meet all policy requirements presented in this
429                   manual.
430                 </p>
431               </item>
432             </list>
433           </p>
434           <p>
435             Similarly, the packages in <em>non-US/main</em>
436             <list compact="compact">
437               <item>
438                 <p>
439                    must not require a package outside of <em>main</em>
440                    or <em>non-US/main</em> for compilation or
441                    execution,
442                 </p>
443               </item>
444               <item>
445                 <p>
446                   must not be so buggy that we refuse to support them,
447                 </p>
448               </item>
449               <item>
450                 <p>
451                   must meet all policy requirements presented in this
452                   manual.
453                 </p>
454               </item>
455             </list>
456           </p>
457         </sect1>
458         <sect1>
459           <heading>The contrib section</heading>
460           <p>
461             Every package in <em>contrib</em> and
462             <em>non-US/contrib</em> must comply with the DFSG.
463           </p>
464
465           <p>
466             In addition, the packages in <em>contrib</em> and
467             <em>non-US/contrib</em>
468             <list compact="compact">
469               <item>
470                 <p>
471                   must not be so buggy that we refuse to support them,
472                   and
473                 </p>
474               </item>
475               <item>
476                 <p>
477                   must meet all policy requirements presented in this
478                   manual.
479                 </p>
480               </item>
481             </list>
482           </p>
483
484           <p>
485             Furthermore, packages in <em>contrib</em> must not require
486             a package in a <em>non-US</em> section for compilation or
487             execution.
488           </p>
489
490           <p>
491             Examples of packages which would be included in
492             <em>contrib</em> or <em>non-US/contrib</em> are:
493             <list compact="compact">
494               <item>
495                 <p>
496                   free packages which require <em>contrib</em>,
497                   <em>non-free</em> packages or packages which are not
498                   in our archive at all for compilation or execution,
499                   and
500                 </p>
501               </item>
502               <item>
503                 <p>
504                   wrapper packages or other sorts of free accessories for
505                   non-free programs.
506                 </p>
507               </item>
508             </list>
509           </p>
510         </sect1>
511         <sect1>
512           <heading>The non-free section</heading>
513           <p>
514             Packages must be placed in <em>non-free</em> or
515             <em>non-US/non-free</em> if they are not compliant with
516             the DFSG or are encumbered by patents or other legal
517             issues that make their distribution problematic.
518           </p>
519           <p>
520             In addition, the packages in <em>non-free</em> and
521             <em>non-US/non-free</em>
522             <list compact="compact">
523               <item>
524                 <p>
525                   must not be so buggy that we refuse to support them,
526                   and
527                 </p>
528               </item>
529               <item>
530                 <p>
531                   must meet all policy requirements presented in this
532                   manual that it is possible for them to meet.<footnote>
533                     <p>
534                       It is possible that there are policy
535                       requirements which the package is unable to
536                       meet, for example, if the source is
537                       unavailable.  These situations will need to be
538                       handled on a case-by-case basis.
539                     </p>
540                   </footnote>
541                 </p>
542               </item>
543             </list>
544           </p>
545         </sect1>
546
547         <sect1>
548           <heading>The non-US sections</heading>
549           <p>
550             Non-free programs with cryptographic program code need to
551             be stored on the <em>non-us</em> server because of export
552             restrictions of the U.S.
553           </p>
554           <p>
555             Programs which use patented algorithms that have a
556             restrictied license also need to be stored on "non-us",
557             since that is located in a country where it is not allowed
558             to patent algorithms.
559           </p>
560           <p>
561             A package depends on another package which is distributed
562             via the non-us server has to be stored on the non-us
563             server as well.
564           </p>
565         </sect1>
566         <sect1>
567           <heading>Further copyright considerations</heading>
568           <p>
569             Every package must be accompanied by a verbatim copy of
570             its copyright and distribution license in the file
571             <file>/usr/share/doc/<var>package</var>/copyright</file>
572             (see <ref id="copyrightfile"> for further details).
573           </p>
574           <p>
575             We reserve the right to restrict files from being included
576             anywhere in our archives if
577             <list compact="compact">
578               <item>
579                 <p>
580                   their use or distribution would break a law,
581                 </p>
582               </item>
583               <item>
584                 <p>
585                   there is an ethical conflict in their distribution or
586                   use,
587                 </p>
588               </item>
589               <item>
590                 <p>
591                   we would have to sign a license for them, or
592                 </p>
593               </item>
594               <item>
595                 <p>
596                   their distribution would conflict with other project
597                   policies.
598                 </p>
599               </item>
600             </list>
601           </p>
602
603           <p>
604             Programs whose authors encourage the user to make
605             donations are fine for the main distribution, provided
606             that the authors do not claim that not donating is
607             immoral, unethical, illegal or something similar; in such
608             a case they must go in <em>non-free</em>.</p>
609
610           <p>
611             Packages whose copyright permission notices (or patent
612             problems) do not even allow redistribution of binaries
613             only, and where no special permission has been obtained,
614             must not be placed on the Debian FTP site and its mirrors
615             at all.</p>
616
617           <p>
618             Note that under international copyright law (this applies
619             in the United States, too), <em>no</em> distribution or
620             modification of a work is allowed without an explicit
621             notice saying so.  Therefore a program without a copyright
622             notice <em>is</em> copyrighted and you may not do anything
623             to it without risking being sued! Likewise if a program
624             has a copyright notice but no statement saying what is
625             permitted then nothing is permitted.</p>
626
627           <p>
628             Many authors are unaware of the problems that restrictive
629             copyrights (or lack of copyright notices) can cause for
630             the users of their supposedly-free software.  It is often
631             worthwhile contacting such authors diplomatically to ask
632             them to modify their license terms. However, this can be a
633             politically difficult thing to do and you should ask for
634             advice on the <tt>debian-legal</tt> mailing list first, as
635             explained below.
636           </p>
637
638           <p>
639             When in doubt about a copyright, send mail to
640             <email>debian-legal@lists.debian.org</email>.  Be prepared
641             to provide us with the copyright statement.  Software
642             covered by the GPL, public domain software and BSD-like
643             copyrights are safe; be wary of the phrases "commercial
644             use prohibited" and "distribution restricted".
645           </p>
646         </sect1>
647         <sect1>
648           <heading>Subsections</heading>
649
650           <p>
651             The packages in the sections <em>main</em>,
652             <em>contrib</em> and <em>non-free</em> are grouped further
653             into <em>subsections</em> to simplify handling.
654           </p>
655
656           <p>
657             The section and subsection for each package should be
658             specified in the package's <tt>Section</tt> control
659             record.  However, the maintainer of the Debian archive
660             may override this selection to ensure the consistency of
661             the Debian distribution.  The <tt>Section</tt> field
662             should be of the form:
663             <list compact="compact">
664               <item>
665                 <p>
666                   <em>subsection</em> if the package is in the
667                   <em>main</em> section,
668                 </p>
669               </item>
670               <item>
671                 <p>
672                   <em>section/subsection</em> if the package is in
673                   the <em>contrib</em> or <em>non-free</em> section,
674                   and
675                 </p>
676               </item>
677               <item>
678                 <p>
679                   <tt>non-US</tt>, <tt>non-US/contrib</tt> or
680                   <tt>non-US/non-free</tt> if the package is in
681                   <em>non-US/main</em>, <em>non-US/contrib</em> or
682                   <em>non-US/non-free</em> respectively.
683                 </p>
684               </item>
685             </list>
686           </p>
687
688           <p>
689             The Debian archive maintainers provide the authoritative
690             list of subsections.  At present, they are:
691             <em>admin</em>, <em>base</em>, <em>comm</em>,
692             <em>contrib</em>, <em>devel</em>, <em>doc</em>,
693             <em>editors</em>, <em>electronics</em>, <em>games</em>,
694             <em>graphics</em>, <em>hamradio</em>,
695             <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
696             <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
697             <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
698             <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
699             <em>sound</em>, <em>tex</em>, <em>text</em>,
700             <em>utils</em>, <em>web</em>, <em>x11</em>.
701           </p>
702         </sect1>
703       <sect>
704         <heading>Priorities</heading>
705
706         <p>
707           Each package should have a <em>priority</em> value, which is
708           included in the package's <em>control record</em>. This
709           information is used by the Debian package management tools
710           to separate high-priority packages from less-important
711           packages.</p>
712
713         <p>
714           The following <em>priority levels</em> are recognised by the
715           Debian package management tools.
716           <taglist>
717             <tag><tt>required</tt></tag>
718             <item>
719               <p>
720                 Packages which are necessary for the proper
721                 functioning of the system.  You must not remove these
722                 packages or your system may become totally broken and
723                 you may not even be able to use <prgn>dpkg</prgn> to
724                 put things back.  Systems with only the
725                 <tt>required</tt> packages are probably unusable, but
726                 they do have enough functionality to allow the
727                 sysadmin to boot and install more software.</p>
728             </item>
729             <tag><tt>important</tt></tag>
730             <item>
731               <p>
732                 Important programs, including those which one would
733                 expect to find on any Unix-like system.  If the
734                 expectation is that an experienced Unix person who
735                 found it missing would say "What on earth is going on,
736                 where is <prgn>foo</prgn>?", it must be an
737                 <tt>important</tt> package.<footnote>
738                   <p>
739                     This is an important criterion because we are
740                     trying to produce, amongst other things, a free
741                     Unix.
742                   </p>
743                 </footnote>
744                 Other packages without which the system will not run
745                 well or be usable must also have priority
746                 <tt>important</tt>.  This does
747                 <em>not</em> include Emacs, the X Window System, TeX
748                 or any other large applications.  The
749                 <tt>important</tt> packages are just a bare minimum of
750                 commonly-expected and necessary tools.</p>
751             </item>
752             <tag><tt>standard</tt></tag>
753             <item>
754               <p>
755                 These packages provide a reasonably small but not too
756                 limited character-mode system.  This is what will be
757                 installed by default if the user doesn't select anything
758                 else.  It doesn't include many large applications.</p>
759             </item>
760             <tag><tt>optional</tt></tag>
761             <item>
762               <p>
763                 (In a sense everything that isn't required is
764                 optional, but that's not what is meant here.) This is
765                 all the software that you might reasonably want to
766                 install if you didn't know what it was and don't have
767                 specialized requirements. This is a much larger system
768                 and includes the X Window System, a full TeX
769                 distribution, and many applications. Note that
770                 optional packages should not conflict with each other.
771               </p>
772             </item>
773             <tag><tt>extra</tt></tag>
774             <item>
775               <p>
776                 This contains all packages that conflict with others
777                 with required, important, standard or optional
778                 priorities, or are only likely to be useful if you
779                 already know what they are or have specialised
780                 requirements.
781               </p>
782             </item>
783           </taglist></p>
784
785         <p>
786           Packages must not depend on packages with lower priority
787           values (excluding build-time dependencies).  In order to
788           ensure this, the priorities of one or more packages may need
789           to be adjusted.
790         </p>
791       </sect>
792
793       <sect>
794         <heading>Binary packages</heading>
795
796         <p>
797           The Debian GNU/Linux distribution is based on the Debian
798           package management system, called <prgn>dpkg</prgn>. Thus,
799           all packages in the Debian distribution must be provided
800           in the <tt>.deb</tt> file format.</p>
801
802
803         <sect1>
804           <heading>The package name</heading>
805
806           <p>
807             Every package must have a name that's unique within the Debian
808             archive.</p>
809
810           <p>
811             Package names must consist of lower case letters
812             (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
813             and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
814             They must be at least two characters long and must start
815             with an alphanumeric character.
816           </p>
817
818           <p>
819             The package name is part of the file name of the
820             <tt>.deb</tt> file and is included in the control field
821             information.
822           </p>
823         </sect1>
824
825         <sect1>
826           <heading>The maintainer of a package</heading>
827          <p>
828             Every package must have a Debian maintainer (the
829             maintainer may be one person or a group of people
830             reachable from a common email address, such as a mailing
831             list).  The maintainer is responsible for ensuring that
832             the package is placed in the appropriate distributions.
833           </p>
834
835           <p>
836             The maintainer must be specified in the
837             <tt>Maintainer</tt> control field with their correct name
838             and a working email address.  If one person maintains
839             several packages, he/she should try to avoid having
840             different forms of their name and email address in
841             the <tt>Maintainer</tt> fields of those packages.
842           </p>
843
844           <p>
845             If the maintainer of a package quits from the Debian
846             project, "Debian QA Group"
847             <email>packages@qa.debian.org</email> takes over the
848             maintainership of the package until someone else
849             volunteers for that task. These packages are called
850             <em>orphaned packages</em>.<footnote>
851               <p>
852                 The detailed procedure for doing this gracefully can
853                 be found in the Debian Developer's Reference, either
854                 in the <tt>developers-reference</tt> package, or on
855                 the Debian FTP server
856                 <ftpsite>ftp.debian.org</ftpsite> as
857                 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
858                 or from the <url
859                 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
860                 name="Debian Developer's Reference"> webpage.
861               </p>
862             </footnote>
863           </p>
864         </sect1>
865
866
867         <sect1>
868           <heading>The description of a package</heading>
869
870           <p>
871             Every Debian package must have an extended description
872             stored in the appropriate field of the control record.</p>
873
874           <p>
875             The description should be written so that it gives the
876             system administrator enough information to decide whether
877             to install the package. This description should not just
878             be copied verbatim from the program's documentation.
879             Instructions for configuring or using the package should
880             not be included (that is what installation scripts,
881             manual pages, info files, etc., are for).  Copyright
882             statements and other administrivia should not be included
883             either (that is what the copyright file is for).
884           </p>
885
886           <p>
887             Please refer to <ref id="descriptions"> for more information.
888           </p>
889
890         </sect1>
891
892
893         <sect1>
894           <heading>Dependencies</heading>
895
896           <p>
897             Every package must specify the dependency information
898             about other packages that are required for the first to
899             work correctly.</p>
900
901           <p>
902             For example, a dependency entry must be provided for any
903             shared libraries required by a dynamically-linked executable
904             binary in a package.</p>
905
906           <p>
907             Packages are not required to declare any dependencies they
908             have on other packages which are marked <tt>Essential</tt>
909             (see below), and should not do so unless they depend on a
910             particular version of that package.</p>
911
912           <p>
913             Sometimes, a package requires another package to be installed
914             <em>and</em> configured before it can be installed. In this
915             case, you must specify a <tt>Pre-Depends</tt> entry for
916             the package.</p>
917
918           <p>
919             You should not specify a <tt>Pre-Depends</tt> entry for a
920             package before this has been discussed on the
921             <tt>debian-devel</tt> mailing list and a consensus about
922             doing that has been reached.</p></sect1>
923
924
925         <sect1 id="virtual_pkg_sect">
926           <heading>Virtual packages</heading>
927
928           <p>
929             Sometimes, there are several packages which offer
930             more-or-less the same functionality. In this case, it's
931             useful to define a <em>virtual package</em> whose name
932             describes that common functionality.  (The virtual
933             packages only exist logically, not physically; that's why
934             they are called <em>virtual</em>.) The packages with this
935             particular function will then <em>provide</em> the virtual
936             package. Thus, any other package requiring that function
937             can simply depend on the virtual package without having to
938             specify all possible packages individually.</p>
939
940           <p>
941             All packages should use virtual package names where
942             appropriate, and arrange to create new ones if necessary.
943             They should not use virtual package names (except privately,
944             amongst a cooperating group of packages) unless they have
945             been agreed upon and appear in the list of virtual package
946             names. (See also <ref id="virtual">)</p>
947
948           <p>
949             The latest version of the authoritative list of virtual
950             package names can be found on
951             <ftpsite>ftp.debian.org</ftpsite> in
952             <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
953             or your local mirror. In addition, it is included in the
954             <tt>debian-policy</tt> package. The procedure for updating
955             the list is described at the top of the file.</p></sect1>
956
957
958         <sect1>
959           <heading>Base system</heading>
960
961           <p>
962             The  <tt>base system</tt> is a minimum subset of the Debian
963             GNU/Linux system that is installed before everything else
964             on a new system. Thus, only very few packages are allowed
965             to go into the <tt>base</tt> section to keep the required
966             disk usage very small.</p>
967
968           <p>
969             Most of these packages will have the priority value
970             <tt>required</tt> or at least <tt>important</tt>, and many
971             of them will be tagged <tt>essential</tt> (see below).</p>
972
973
974         </sect1>
975
976
977         <sect1>
978           <heading>Essential packages</heading>
979
980           <p>
981             Some packages are tagged <tt>essential</tt>. (They have
982             <tt>Essential: yes</tt> in their package control record.)
983             This flag is used for packages that are <em>essential</em>
984             for a system.</p>
985
986           <p>
987             Since these packages cannot be easily removed (one has to
988             specify an extra <em>force option</em> to
989             <prgn>dpkg</prgn> to do so), this flag must not be used
990             unless absolutely necessary.  A shared library package
991             must not be tagged <tt>essential</tt>; dependencies will
992             prevent its premature removal, and we need to be able to
993             remove it when it has been superseded.
994           </p>
995
996           <p>
997             Since dpkg will not prevent upgrading of other packages
998             while an <tt>essential</tt> package is in an unconfigured
999             state, all <tt>essential</tt> packages must supply all of
1000             their core functionality even when unconfigured. If the
1001             package cannot satisfy this requirement it must not be
1002             tagged as essential, and any packages depending on this
1003             package must instead have explicit dependency fields as
1004             appropriate.
1005           </p>
1006
1007           <p>
1008             You must not tag any packages <tt>essential</tt> before
1009             this has been discussed on the <tt>debian-devel</tt>
1010             mailing list and a consensus about doing that has been
1011             reached.
1012           </p>
1013         </sect1>
1014          <sect1>
1015           <heading>Tasks</heading>
1016
1017           <p>
1018             The Debian install process allows the user to choose from
1019             a number of common tasks which a Debian system can be used to
1020             perform. Selecting a task with <prgn>tasksel</prgn> causes
1021             a set of packages that are useful in performing that task to be
1022             installed.
1023           </p>
1024
1025           <p>
1026             This set of packages is all available packages which have the
1027             name of the selected task in the <tt>Task</tt> field of their
1028             control file. The format of this field is a list of tasks,
1029             separated by commas.
1030           </p>
1031
1032           <p>
1033             You should not tag any packages as belonging to a task
1034             before this has been discussed on the
1035             <em>debian-devel</em> mailing list and a consensus about
1036             doing that has been reached.
1037           </p>
1038
1039           <p>
1040             For third parties (and historical reasons), tasksel also
1041             supports constructing tasks based on <em>task
1042             packages</em>. These are packages whose names begin with
1043             <em>task-</em>. Task packages should not be included in the
1044             Debian archive.
1045           </p>
1046         </sect1>
1047
1048         <sect1 id="maintscripts">
1049           <heading>Maintainer Scripts</heading>
1050
1051           <p>
1052             The package installation scripts should avoid producing
1053             output which it is unnecessary for the user to see and
1054             should rely on <prgn>dpkg</prgn> to stave off boredom on
1055             the part of a user installing many packages.  This means,
1056             amongst other things, using the <tt>--quiet</tt> option on
1057             <prgn>install-info</prgn>.</p>
1058
1059           <p>
1060             Errors which occur during the execution of an installation
1061             script must be checked and the installation must not
1062             continue after an error.
1063           </p>
1064
1065           <p>
1066             Note that in general <ref id="scripts"> applies to package
1067             maintainer scripts, too.
1068           </p>
1069
1070           <p>
1071             You should not use <prgn>dpkg-divert</prgn> on a file
1072             belonging to another package without consulting the
1073             maintainer of that package first.
1074           </p>
1075
1076           <p>
1077             All packages which supply an instance of a common command
1078             name (or, in general, filename) should generally use
1079             <prgn>update-alternatives</prgn>, so that they may be
1080             installed together.  If <prgn>update-alternatives</prgn>
1081             is not used, then each package must use
1082             <tt>Conflicts</tt> to ensure that other packages are
1083             de-installed.  (In this case, it may be appropriate to
1084             specify a conflict against earlier versions of something
1085             that previously did not use
1086             <prgn>update-alternatives</prgn>; this is an exception to
1087             the usual rule that versioned conflicts should be
1088             avoided.)
1089           </p>
1090
1091
1092           <sect2>
1093             <heading>Prompting in maintainer scripts</heading>
1094             <p>
1095               Package maintainer scripts may prompt the user if
1096               necessary. Prompting may be accomplished by hand, or by
1097               communicating with a program, such as
1098               <prgn>debconf</prgn>, which conforms to the Debian
1099               Configuration management specification, version 2 or
1100               higher.  These are included in the
1101               <file>debconf_specification</file> files in the
1102               <package>debian-policy</package> package.
1103               You may also find this file on the FTP site
1104               <ftpsite>ftp.debian.org</ftpsite> in
1105               <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1106               or on your local mirror.<footnote>
1107                 <p>
1108                   4% of Debian packages [see <url
1109                   id="http://kitenet.net/programs/debconf/stats/"
1110                   name="Debconf stats">] currently use
1111                   <package>debconf</package> to prompt the user at
1112                   install time, and this number is growing daily. The
1113                   benefits of using debconf are briefly explained at
1114                   <url
1115                   id="http://kitenet.net/doc/debconf-doc/introduction.html"
1116                   name="Debconf introduction">; they include
1117                   preconfiguration, (mostly) noninteractive
1118                   installation, elimination of redundant prompting,
1119                   consistency of user interface, etc.
1120                 </p>
1121                 <p>
1122                   With this increasing number of packages using
1123                   <package>debconf</package>, plus the existance of a
1124                   nascent second implementation of the Debian
1125                   configuration management system
1126                   (<package>cdebconf</package>), and the stabilization
1127                   of the protocol these things use, the time has
1128                   finally come to reflect the use of these things in
1129                   policy.
1130
1131                 </p>
1132               </footnote>
1133             </p>
1134             <p>
1135               Packages which use the Debian Configuration management
1136               specification may contain an additional
1137               <prgn>config</prgn> script and a <tt>templates</tt>
1138               file in their control archive. The <prgn>config</prgn>
1139               script might be run before the <prgn>preinst</prgn>
1140               script, and before the package is unpacked or any of its
1141               dependencies or pre-dependancies are satisfied.
1142               Therefore it must work using only the tools present in
1143               <em>essential</em> packages.<footnote>
1144                 <p>
1145                   <package>Debconf</package> or another tool that
1146                   implements the Debian Configuration management
1147                   specification will also be installed, and any
1148                   versioned dependencies on it will be satisfied
1149                   before preconfiguration begins.
1150                 </p>
1151               </footnote>
1152             </p>
1153
1154             <p>
1155               Packages should try to minimize the amount of prompting
1156               they need to do, and they should ensure that the user
1157               will only ever be asked each question once.  This means
1158               that packages should try to use appropriate shared
1159               configuration files (such as <file>/etc/papersize</file> and
1160               <file>/etc/news/server</file>), and shared
1161               <package>debconf</package> variables rather than each
1162               prompting for their own list of required pieces of
1163               information.
1164             </p>
1165
1166             <p>
1167               It also means that an upgrade should not ask the same
1168               questions again, unless the user has used <tt>dpkg
1169                 --purge</tt> to remove the package's configuration.  The
1170               answers to configuration questions should be stored in an
1171               appropriate place in <file>/etc</file> so that the user can
1172               modify them, and how this has been done should be
1173               documented.</p>
1174
1175             <p>
1176               If a package has a vitally important piece of
1177               information to pass to the user (such as "don't run me
1178               as I am, you must edit the following configuration files
1179               first or you risk your system emitting badly-formatted
1180               messages"), it should display this in the
1181               <prgn>config</prgn> or <prgn>postinst</prgn> script and
1182               prompt the user to hit return to acknowledge the
1183               message.  Copyright messages do not count as vitally
1184               important (they belong in
1185               <file>/usr/share/doc/<var>package</var>/copyright</file>);
1186               neither do instructions on how to use a program (these
1187               should be in on-line documentation, where all the users
1188               can see them).</p>
1189
1190             <p>
1191               Any necessary prompting should almost always be confined
1192               to the <prgn>config</prgn> or <prgn>postinst</prgn>
1193               script. If it is done in the <prgn>postinst</prgn>, it
1194               should be protected with a conditional so that
1195               unnecessary prompting doesn't happen if a package's
1196               installation fails and the <prgn>postinst</prgn> is
1197               called with <tt>abort-upgrade</tt>,
1198               <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1199         </sect1>
1200       </sect>
1201
1202       <sect>
1203         <heading>Source packages</heading>
1204
1205         <sect1 id="standardsversion">
1206           <heading>Standards conformance</heading>
1207
1208           <p>
1209             In the source package's <tt>Standards-Version</tt> control
1210             field, you should specify the most recent version number
1211             of this policy document with which your package complied
1212             when it was last updated.  The current version number is
1213             &version;.
1214           </p>
1215
1216           <p>
1217             This information may be used to file bug reports
1218             automatically if your package becomes too much out of
1219             date.
1220           </p>
1221
1222           <p>
1223             The version number has four components: major and minor
1224             version number and major and minor patch level.  When the
1225             standards change in a way that requires every package to
1226             change the major number will be changed.  Significant
1227             changes that will require work in many packages will be
1228             signaled by a change to the minor number.  The major patch
1229             level will be changed for any change to the meaning of the
1230             standards, however small; the minor patch level will be
1231             changed when only cosmetic, typographical or other edits
1232             are made which neither change the meaning of the document
1233             nor affect the contents of packages.</p>
1234
1235           <p>
1236             Thus only the first three components of the policy version
1237             are significant in the <em>Standards-Version</em> control
1238             field, and so either these three components or the all
1239             four components may be specified.<footnote>
1240               <p>
1241                 In the past, people specified the full version number
1242                 in the Standards-Version field, for example "2.3.0.0".
1243                 Since minor patch-level changes don"t introduce new
1244                 policy, it was thought it would be better to relax
1245                 policy and only require the first 3 components to be
1246                 specified, in this example "2.3.0".  All four
1247                 components may still be used if someone wishes to do
1248                 so.
1249               </p>
1250             </footnote>
1251           </p>
1252
1253           <p>
1254             You should regularly, and especially if your package has
1255             become out of date, check for the newest Policy Manual
1256             available and update your package, if necessary. When your
1257             package complies with the new standards you should update the
1258             <tt>Standards-Version</tt> source package field and
1259             release it.<footnote>
1260               <p>
1261                 See the file <file>upgrading-checklist</file> for
1262                 information about policy which has changed between
1263                 different versions of this document.
1264               </p>
1265             </footnote>
1266           </p>
1267         </sect1>
1268
1269
1270         <sect1 id="pkg-relations">
1271           <heading>Package relationships</heading>
1272
1273           <p>
1274             Source packages should specify which binary packages they
1275             require to be installed or not to be installed in order to
1276             build correctly.  For example, if building a package
1277             requires a certain compiler, then the compiler should be
1278             specified as a build-time dependency.
1279           </p>
1280
1281           <p>
1282             It is not necessary to explicitly specify build-time
1283             relationships on a minimal set of packages that are always
1284             needed to compile, link and put in a Debian package a
1285             standard "Hello World!" program written in C or C++.  The
1286             required packages are called <em>build-essential</em>, and
1287             an informational list can be found in
1288             <file>/usr/share/doc/build-essential/list</file> (which is
1289             contained in the <tt>build-essential</tt>
1290             package).<footnote>
1291               <p>Rationale:
1292                 <list compact="compact">
1293                   <item>
1294                     <p>This allows maintaining the list separately
1295                       from the policy documents (the list does not
1296                       need the kind of control that the policy
1297                       documents do).
1298                     </p>
1299                   </item>
1300                   <item>
1301                     <p>
1302                       Having a separate package allows one to install
1303                       the build-essential packages on a machine, as
1304                       well as allowing other packages such as tasks to
1305                       require installation of the build-essential
1306                       packages using the depends relation.
1307                     </p>
1308                   </item>
1309                   <item>
1310                     <p>
1311                       The separate package allows bug reports against
1312                       the list to be categorized separately from
1313                       the policy management process in the BTS.
1314                     </p>
1315                   </item>
1316                 </list>
1317               </p>
1318
1319             </footnote>
1320           </p>
1321
1322           <p>
1323             When specifying the set of build-time dependencies, one
1324             should list only those packages explicitly required by the
1325             build.  It is not necessary to list packages which are
1326             required merely because some other package in the list of
1327             build-time dependencies depends on them.<footnote>
1328               <p>
1329                 The reason for this is that dependencies change, and
1330                 you should list all those packages, and <em>only</em>
1331                 those packages that <em>you</em> need directly.  What
1332                 others need is their business.  For example, if you
1333                 only link against <file>libimlib</file>, you will need to
1334                 build-depend on <package>libimlib2-dev</package> but
1335                 not against any <tt>libjpeg*</tt> packages, even
1336                 though <tt>libimlib2-dev</tt> currently depends on
1337                 them: installation of <package>libimlib2-dev</package>
1338                 will automatically ensure that all of its run-time
1339                 dependencies are satisfied.
1340               </p>
1341             </footnote>
1342           </p>
1343
1344           <p>
1345             If build-time dependencies are specified, it must be
1346             possible to build the package and produce working binaries
1347             on a system with only essential and build-essential
1348             packages installed and also those required to satisfy the
1349             build-time relationships (including any implied
1350             relationships).  In particular, this means that version
1351             clauses should be used rigorously in build-time
1352             relationships so that one cannot produce bad or
1353             inconsistently configured packages when the relationships
1354             are properly satisfied.
1355           </p>
1356
1357           <p>
1358             <ref id="relationships"> explains the technical details.
1359           </p>
1360
1361         <sect1>
1362           <heading>Changes to the upstream sources</heading>
1363
1364           <p>
1365             If changes to the source code are made that are not
1366             specific to the needs of the Debian system, they should be
1367             sent to the upstream authors in whatever form they prefer
1368             so as to be included in the upstream version of the
1369             package.</p>
1370
1371           <p>
1372             If you need to configure the package differently for
1373             Debian or for Linux, and the upstream source doesn't
1374             provide a way to do so, you should add such configuration
1375             facilities (for example, a new <prgn>autoconf</prgn> test
1376             or <tt>#define</tt>) and send the patch to the upstream
1377             authors, with the default set to the way they originally
1378             had it.  You can then easily override the default in your
1379             <file>debian/rules</file> or wherever is appropriate.</p>
1380
1381           <p>
1382             You should make sure that the <prgn>configure</prgn> utility
1383             detects the correct architecture specification string
1384             (refer to <ref id="arch-spec"> for details).</p>
1385
1386           <p>
1387             If you need to edit a <prgn>Makefile</prgn> where
1388             GNU-style <prgn>configure</prgn> scripts are used, you
1389             should edit the <file>.in</file> files rather than editing the
1390             <prgn>Makefile</prgn> directly.  This allows the user to
1391             reconfigure the package if necessary.  You should
1392             <em>not</em> configure the package and edit the generated
1393             <prgn>Makefile</prgn>!  This makes it impossible for
1394             someone else to later reconfigure the package.</p>
1395
1396           <p>
1397             You should document your changes and updates to the source
1398             package properly in the <file>debian/changelog</file> file.
1399             For more information, please see <ref id="changelogs">.
1400           </p>
1401         </sect1>
1402
1403
1404         <sect1>
1405           <heading>Error trapping in makefiles</heading>
1406
1407           <p>
1408             When <prgn>make</prgn> invokes a command in a makefile
1409             (including your package's upstream makefiles and
1410             <file>debian/rules</file>), it does so using <prgn>sh</prgn>.  This
1411             means that <prgn>sh</prgn>'s usual bad error handling
1412             properties apply: if you include a miniature script as one
1413             of the commands in your makefile you'll find that if you
1414             don't do anything about it then errors are not detected
1415             and <prgn>make</prgn> will blithely continue after
1416             problems.</p>
1417
1418           <p>
1419             Every time you put more than one shell command (this
1420             includes using a loop) in a makefile command you
1421             must make sure that errors are trapped.  For
1422             simple compound commands, such as changing directory and
1423             then running a program, using <tt>&amp;&amp;</tt> rather
1424             than semicolon as a command separator is sufficient.  For
1425             more complex commands including most loops and
1426             conditionals you should include a separate <tt>set -e</tt>
1427             command at the start of every makefile command that's
1428             actually one of these miniature shell scripts.</p></sect1>
1429
1430
1431         <sect1>
1432           <heading>Obsolete constructs and libraries</heading>
1433
1434           <p>
1435             The include file <tt>&lt;varargs.h&gt;</tt> is
1436             provided to support end-users compiling very old software;
1437             the library <tt>libtermcap</tt> is provided to support the
1438             execution of software which has been linked against it
1439             (either old programs or those such as Netscape which are
1440             only available in binary form).</p>
1441
1442           <p>
1443             Debian packages should be patched to use
1444             <tt>&lt;stdarg.h&gt;</tt> and <tt>ncurses</tt>
1445             instead.
1446           </p>
1447         </sect1>
1448       </sect>
1449     </chapt>
1450
1451     <chapt id="controlfields"><heading>Control files and their fields</heading>
1452
1453       <p>
1454         Many of the tools in the package management suite manipulate
1455         data represented in a common format, known as <em>control
1456         data</em>.  The data is often stored in <em>control
1457         files</em>.  Binary and source packages have control files,
1458         and the <file>.changes</file> files which control the installation
1459         of uploaded files are also in control file format.
1460         <prgn>dpkg</prgn>'s internal databases are in a similar
1461         format.
1462       </p>
1463
1464       <sect id="controlsyntax"><heading>Syntax of control files</heading>
1465
1466         <p>
1467           A control file consists of one or more paragraphs of fields.
1468           The paragraphs are separated by blank lines.  Some control
1469           files allow only one paragraph; others allow several, in
1470           which case each paragraph usually refers to a different
1471           package.  (For example, in source packages, the first
1472           paragraph refers to the source package, and later paragraphs
1473           refer to binary packages generated from the source.)
1474         </p>
1475
1476         <p>
1477           Each paragraph consists of a series of data fields; each
1478           field consists of the field name, followed by a colon and
1479           then the data/value associated with that field.  It ends at
1480           the end of the line.  Horizontal whitespace (spaces and
1481           tabs) may occur immediately before or after the value and is
1482           ignored there; it is conventional to put a single space
1483           after the colon.  For example, a field might be:
1484           <example compact="compact">
1485 Package: libc6
1486           </example>
1487           the field name is <tt>Package</tt> and the field value
1488           <tt>libc6</tt>.
1489         </p>
1490
1491         <p>
1492           Some fields' values may span several lines; in this case
1493           each continuation line <em>must</em> start with a space or
1494           tab.  Any trailing spaces or tabs at the end of individual
1495           lines of a field value are ignored.
1496         </p>
1497
1498         <p>
1499           Except where otherwise stated only a single line of data is
1500           allowed and whitespace is not significant in a field body.
1501           Whitespace must not appear inside names (of packages,
1502           architectures, files or anything else) or version numbers,
1503           or between the characters of multi-character version
1504           relationships.
1505         </p>
1506
1507         <p>
1508           Field names are not case-sensitive, but it is usual to
1509           capitalize the field names using mixed case as shown below.
1510         </p>
1511
1512         <p>
1513           Blank lines, or lines consisting only of spaces and tabs,
1514           are not allowed within field values or between fields - that
1515           would mean a new paragraph.
1516         </p>
1517
1518       </sect>
1519
1520       <sect><heading>List of fields</heading>
1521         <p>
1522           This list here is not supposed to be exhaustive. Most fields
1523           are dealt with elsewhere in this document.
1524         </p>
1525         <sect1 id="f-Package"><heading><tt>Package</tt>
1526           </heading>
1527
1528           <p>
1529             The name of the binary package.  Package names consist of
1530             lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1531             plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1532             periods (<tt>.</tt>).
1533           </p>
1534
1535           <p>
1536             They must be at least two characters long and must start
1537             with an alphanumeric character.  The use of lowercase
1538             package names is required unless the package you're
1539             building (or referring to, in other fields) is already
1540             using uppercase characters.</p>
1541         </sect1>
1542
1543         <sect1 id="f-Version"><heading><tt>Version</tt>
1544           </heading>
1545
1546           <p>
1547             This lists the source or binary package's version number -
1548             see <ref id="versions">.
1549           </p>
1550
1551         </sect1>
1552
1553         <sect1
1554                id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1555           </heading>
1556
1557           <p>
1558             The most recent version of the standards (the policy
1559             manual and associated texts) with which the package
1560             complies.  This is updated manually when editing the
1561             source package to conform to newer standards; it can
1562             sometimes be used to tell when a package needs attention.
1563             Its format is described above; see
1564             <ref id="standardsversion">.
1565           </p>
1566         </sect1>
1567
1568
1569         <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1570           </heading>
1571
1572           <p>
1573             In a <file>.changes</file> file or parsed changelog output
1574             this contains the (space-separated) name(s) of the
1575             distribution(s) where this version of the package should
1576             be installed.  Valid distributions are determined by the
1577             archive maintainers.<footnote>
1578                 Current distribution names are:
1579                 <taglist compact="compact">
1580                   <tag><em>stable</em></tag>
1581                   <item>
1582                     <p>
1583                       This is the current "released" version of Debian
1584                       GNU/Linux.  Once the distribution is
1585                       <em>stable</em> only security fixes and other
1586                       major bug fixes are allowed. When changes are
1587                       made to this distribution, the release number is
1588                       increased (for example: 2.2r1 becomes 2.2r2 then
1589                       2.2r3, etc).
1590                     </p>
1591                   </item>
1592
1593                   <tag><em>unstable</em></tag>
1594                   <item>
1595                     <p>
1596                       This distribution value refers to the
1597                       <em>developmental</em> part of the Debian
1598                       distribution tree. New packages, new upstream
1599                       versions of packages and bug fixes go into the
1600                       <em>unstable</em> directory tree. Download from
1601                       this distribution at your own risk.
1602                     </p>
1603                   </item>
1604
1605                   <tag><em>testing</em></tag>
1606                   <item>
1607                     <p>
1608                       This distribution value refers to the
1609                       <em>testing</em> part of the Debian distribution
1610                       tree.  It receives its packages from the
1611                       unstable distribution after a short time lag to
1612                       ensure that there are no major issues with the
1613                       unstable packages.  It is less prone to breakage
1614                       than unstable, but still risky.  It is not
1615                       possible to upload packages directly to
1616                       <em>testing</em>.
1617                     </p>
1618                   </item>
1619
1620                   <tag><em>frozen</em></tag>
1621                   <item>
1622                     <p>
1623                       From time to time, the <em>testing</em>
1624                       distribution enters a state of "code-freeze" in
1625                       anticipation of release as a <em>stable</em>
1626                       version. During this period of testing only
1627                       fixes for existing or newly-discovered bugs will
1628                       be allowed.  The exact details of this stage are
1629                       determined by the Release Manager.
1630                     </p>
1631                   </item>
1632
1633                   <tag><em>experimental</em></tag>
1634                   <item>
1635                     <p>
1636                       The packages with this distribution value are
1637                       deemed by their maintainers to be high
1638                       risk. Oftentimes they represent early beta or
1639                       developmental packages from various sources that
1640                       the maintainers want people to try, but are not
1641                       ready to be a part of the other parts of the
1642                       Debian distribution tree. Download at your own
1643                       risk.
1644                     </p>
1645                   </item>
1646                 </taglist>
1647
1648                 You should list <em>all</em> distributions that the
1649                 package should be installed into.
1650             </footnote>
1651           </p>
1652         </sect1>
1653
1654
1655       </sect>
1656     </chapt>
1657
1658     <chapt id="versions"><heading>Version numbering</heading>
1659
1660       <p>
1661         Every package has a version number recorded in its
1662         <tt>Version</tt> control file field.
1663       </p>
1664
1665       <p>
1666         The package management system imposes an ordering on version
1667         numbers, so that it can tell whether packages are being up- or
1668         downgraded and so that package system front end applications
1669         can tell whether a package it finds available is newer than
1670         the one installed on the system.  The version number format
1671         has the most significant parts (as far as comparison is
1672         concerned) at the beginning.
1673       </p>
1674
1675       <p>
1676         The version number format is:
1677         &lsqb;<var>epoch</var><tt>:</tt>&rsqb;<var>upstream_version</var>&lsqb;<tt>-</tt><var>debian_revision</var>&rsqb;
1678       </p>
1679
1680       <p>
1681         The three components here are:
1682         <taglist>
1683           <tag><var>epoch</var></tag>
1684           <item>
1685             <p>
1686               This is a single (generally small) unsigned integer.  It
1687               may be omitted, in which case zero is assumed.  If it is
1688               omitted then the <var>upstream_version</var> may not
1689               contain any colons.
1690             </p>
1691
1692             <p>
1693               It is provided to allow mistakes in the version numbers
1694               of older versions of a package, and also a package's
1695               previous version numbering schemes, to be left behind.
1696             </p>
1697           </item>
1698
1699           <tag><var>upstream_version</var></tag>
1700           <item>
1701             <p>
1702               This is the main part of the version number.  It is
1703               usually the version number of the original ("upstream")
1704               package from which the <file>.deb</file> file has been made,
1705               if this is applicable.  Usually this will be in the same
1706               format as that specified by the upstream author(s);
1707               however, it may need to be reformatted to fit into the
1708               package management system's format and comparison
1709               scheme.
1710             </p>
1711
1712             <p>
1713               The comparison behavior of the package management system
1714               with respect to the <var>upstream_version</var> is
1715               described below.  The <var>upstream_version</var>
1716               portion of the version number is mandatory.
1717             </p>
1718
1719             <p>
1720               The <var>upstream_version</var> may contain only
1721               alphanumerics<footnote>
1722                 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1723               </footnote>
1724               and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1725               <tt>:</tt> (full stop, plus, hyphen, colon) and should
1726               start with a digit.  If there is no
1727               <var>debian_revision</var> then hyphens are not allowed;
1728               if there is no <var>epoch</var> then colons are not
1729               allowed.</p>
1730           </item>
1731
1732           <tag><var>debian_revision</var></tag>
1733           <item>
1734             <p>
1735               This part of the version number specifies the version of
1736               the Debian package based on the upstream version.  It
1737               may contain only alphanumerics and the characters
1738               <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1739               compared in the same way as the
1740               <var>upstream_version</var> is.
1741             </p>
1742
1743             <p>
1744               It is optional; if it isn't present then the
1745               <var>upstream_version</var> may not contain a hyphen.
1746               This format represents the case where a piece of
1747               software was written specifically to be turned into a
1748               Debian package, and so there is only one "debianization"
1749               of it and therefore no revision indication is required.
1750             </p>
1751
1752             <p>
1753               It is conventional to restart the
1754               <var>debian_revision</var> at <tt>1</tt> each time the
1755               <var>upstream_version</var> is increased.
1756             </p>
1757
1758             <p>
1759               The package management system will break the version
1760               number apart at the last hyphen in the string (if there
1761               is one) to determine the <var>upstream_version</var> and
1762               <var>debian_revision</var>.  The absence of a
1763               <var>debian_revision</var> compares earlier than the
1764               presence of one (but note that the
1765               <var>debian_revision</var> is the least significant part
1766               of the version number).
1767             </p>
1768           </item>
1769         </taglist>
1770       </p>
1771
1772       <p>
1773         The <var>upstream_version</var> and <var>debian_revision</var>
1774         parts are compared by the package management system using the
1775         same algorithm:
1776       </p>
1777
1778       <p>
1779         The strings are compared from left to right.
1780       </p>
1781
1782       <p>
1783         First the initial part of each string consisting entirely of
1784         non-digit characters is determined.  These two parts (one of
1785         which may be empty) are compared lexically.  If a difference
1786         is found it is returned.  The lexical comparison is a
1787         comparison of ASCII values modified so that all the letters
1788         sort earlier than all the non-letters.
1789       </p>
1790
1791       <p>
1792         Then the initial part of the remainder of each string which
1793         consists entirely of digit characters is determined.  The
1794         numerical values of these two parts are compared, and any
1795         difference found is returned as the result of the comparison.
1796         For these purposes an empty string (which can only occur at
1797         the end of one or both version strings being compared) counts
1798         as zero.
1799       </p>
1800
1801       <p>
1802         These two steps (comparing and removing initial non-digit
1803         strings and initial digit strings) are repeated until a
1804         difference is found or both strings are exhausted.
1805       </p>
1806
1807       <p>
1808         Note that the purpose of epochs is to allow us to leave behind
1809         mistakes in version numbering, and to cope with situations
1810         where the version numbering scheme changes.  It is
1811         <em>not</em> intended to cope with version numbers containing
1812         strings of letters which the package management system cannot
1813         interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1814         silly orderings (the author of this manual has heard of a
1815         package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1816         <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1817         <tt>2</tt> and so forth).
1818       </p>
1819
1820       <p>
1821         If an upstream package has problematic version numbers they
1822         should be converted to a sane form for use in the
1823         <tt>Version</tt> field.
1824       </p>
1825
1826       <sect>
1827         <heading>Version numbers based on dates</heading>
1828         <p>
1829           In general, Debian packages should use the same version
1830           numbers as the upstream sources.</p>
1831
1832         <p>
1833           However, in some cases where the upstream version number is
1834           based on a date (e.g., a development "snapshot" release) the
1835           package management system cannot handle these version
1836           numbers without epochs. For example, dpkg will consider
1837           "96May01" to be greater than "96Dec24".</p>
1838
1839         <p>
1840           To prevent having to use epochs for every new upstream
1841           version, the version number should be changed to the
1842           following format in such cases: "19960501", "19961224". It
1843           is up to the maintainer whether he/she wants to bother the
1844           upstream maintainer to change the version numbers upstream,
1845           too.</p>
1846
1847         <p>
1848           Note that other version formats based on dates which are
1849           parsed correctly by the package management system should
1850           <em>not</em> be changed.</p>
1851
1852         <p>
1853           Native Debian packages (i.e., packages which have been
1854           written especially for Debian) whose version numbers include
1855           dates should always use the "YYYYMMDD" format.</p>
1856       </sect>
1857     </chapt>
1858
1859     <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1860
1861       <sect id="timestamps"><heading>Time Stamps</heading>
1862         <p>
1863           Maintainers should preserve the modification times of the
1864           upstream source files in a package, as far as is reasonably
1865           possible.<footnote>
1866             <p>
1867               The rationale is that there is some information conveyed
1868               by knowing the age of the file, for example, you could
1869               recognize that some documentation is very old by looking
1870               at the modification time, so it would be nice if the
1871               modification time of the upstream source would be
1872               preserved.
1873             </p>
1874           </footnote>
1875         </p>
1876       </sect>
1877
1878       <sect id="debianrules"><heading><file>debian/rules</file> - the
1879           main building script</heading>
1880
1881         <p>
1882           This file must be an executable makefile, and contains the
1883           package-specific recipes for compiling the package and
1884           building binary package(s) from the source.
1885         </p>
1886
1887         <p>
1888           It must start with the line <tt>#!/usr/bin/make -f</tt>,
1889           so that it can be invoked by saying its name rather than
1890           invoking <prgn>make</prgn> explicitly.
1891         </p>
1892
1893         <p>
1894           Since an interactive <file>debian/rules</file> script makes it
1895           impossible to auto-compile that package and also makes it
1896           hard for other people to reproduce the same binary
1897           package, all <em>required targets</em> MUST be
1898           non-interactive. At a minimum, required targets are the
1899           ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1900           <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1901           <em>binary-indep</em>, and <em>build</em>. It also follows
1902           that any target that these targets depend on must also be
1903           non-interactive.
1904         </p>
1905
1906         <p>
1907           The required and optional targets are as follows:
1908           <taglist>
1909             <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1910               <tt>build-indep</tt> (optional)</tag>
1911             <item>
1912               <p>
1913                 The <tt>build</tt> target should perform all
1914                 non-interactive configuration and compilation of the
1915                 package.  If a package has an interactive pre-build
1916                 configuration routine, the Debianized source package
1917                 must either be built after this has taken place (so
1918                 that the binary package can be built without rerunning
1919                 the configuration) or the configuration routine
1920                 modified to become non-interactive.  (The latter is
1921                 preferable if there are architecture-specific features
1922                 detected by the configuration routine.)
1923               </p>
1924
1925               <p>
1926                 For some packages, notably ones where the same
1927                 source tree is compiled in different ways to produce
1928                 two binary packages, the <tt>build</tt> target
1929                 does not make much sense.  For these packages it is
1930                 good enough to provide two (or more) targets
1931                 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1932                 for each of the ways of building the package, and a
1933                 <tt>build</tt> target that does nothing.  The
1934                 <tt>binary</tt> target will have to build the
1935                 package in each of the possible ways and make the
1936                 binary package out of each.
1937               </p>
1938
1939               <p>
1940                 The <tt>build</tt> target must not do anything
1941                 that might require root privilege.
1942               </p>
1943
1944               <p>
1945                 The <tt>build</tt> target may need to run the
1946                 <tt>clean</tt> target first - see below.
1947               </p>
1948
1949               <p>
1950                 When a package has a configuration and build routine
1951                 which takes a long time, or when the makefiles are
1952                 poorly designed, or when <tt>build</tt> needs to
1953                 run <tt>clean</tt> first, it is a good idea to
1954                 <tt>touch build</tt> when the build process is
1955                 complete.  This will ensure that if <tt>debian/rules
1956                 build</tt> is run again it will not rebuild the whole
1957                 program.<footnote>
1958                   <p>
1959                     Another common way to do this is for <tt>build</tt>
1960                     to depend on <prgn>build-stamp</prgn> and to do
1961                     nothing else, and for the <prgn>build-stamp</prgn>
1962                     target to do the building and to <tt>touch
1963                     build-stamp</tt> on completion.  This is
1964                     especially useful if the build routine creates a
1965                     file or directory called <tt>build</tt>; in such a
1966                     case, <tt>build</tt> will need to be listed as
1967                     a phony target (i.e., as a dependency of the
1968                     <tt>.PHONY</tt> target).  See the documentation of
1969                     <prgn>make</prgn> for more information on phony
1970                     targets.
1971                   </p>
1972                 </footnote>
1973               </p>
1974             </item>
1975
1976             <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1977               <tt>binary-indep</tt>
1978             </tag>
1979             <item>
1980               <p>
1981                 The <tt>binary</tt> target must be all that is
1982                 necessary for the user to build the binary package(s)
1983                 produced from this source package.  All of these
1984                 targets are required to be non-interactive.  It is
1985                 split into two parts: <prgn>binary-arch</prgn> builds
1986                 the binary packages which are specific to a particular
1987                 architecture, and <tt>binary-indep</tt> builds
1988                 those which are not.
1989               </p>
1990               <p>
1991                 <tt>binary</tt> may be (and commonly is) a target with
1992                 no commands which simply depends on
1993                 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
1994               </p>
1995               <p>
1996                 Both <tt>binary-*</tt> targets should depend on the
1997                 <tt>build</tt> target, or on the appropriate
1998                 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
1999                 provided, so that the package is built if it has not
2000                 been already.  It should then create the relevant
2001                 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
2002                 make their control files and <prgn>dpkg-deb</prgn> to
2003                 build them and place them in the parent of the top
2004                 level directory.
2005               </p>
2006
2007               <p>
2008                 Both the <tt>binary-arch</tt> and
2009                 <tt>binary-indep</tt> targets <em>must</em> exist.
2010                 If one of them has nothing to do (which will always be
2011                 the case if the source generates only a single binary
2012                 package, whether architecture-dependent or not), it
2013                 must still exist and must always succeed.
2014               </p>
2015
2016               <p>
2017                 The <tt>binary</tt> targets must be invoked as
2018                 root.<footnote>
2019                   <p>
2020                     The <prgn>fakeroot</prgn> package often allows one
2021                     to build a package correctly even without being
2022                     root.
2023                   </p>
2024                 </footnote>
2025               </p>
2026             </item>
2027
2028             <tag><tt>clean</tt></tag>
2029             <item>
2030               <p>
2031                 This must undo any effects that the <tt>build</tt>
2032                 and <tt>binary</tt> targets may have had, except
2033                 that it should leave alone any output files created in
2034                 the parent directory by a run of a <tt>binary</tt>
2035                 target. This target must be non-interactive.
2036               </p>
2037
2038               <p>
2039                 If a <tt>build</tt> file is touched at the end of
2040                 the <tt>build</tt> target, as suggested above, it
2041                 should be removed as the first action that
2042                 <tt>clean</tt> performs, so that running
2043                 <tt>build</tt> again after an interrupted
2044                 <tt>clean</tt> doesn't think that everything is
2045                 already done.
2046               </p>
2047
2048               <p>
2049                 The <tt>clean</tt> target may need to be
2050                 invoked as root if <tt>binary</tt> has been
2051                 invoked since the last <tt>clean</tt>, or if
2052                 <tt>build</tt> has been invoked as root (since
2053                 <tt>build</tt> may create directories, for
2054                 example).
2055               </p>
2056             </item>
2057
2058             <tag><tt>get-orig-source</tt> (optional)</tag>
2059             <item>
2060               <p>
2061                 This target fetches the most recent version of the
2062                 original source package from a canonical archive site
2063                 (via FTP or WWW, for example), does any necessary
2064                 rearrangement to turn it into the original source
2065                 tar file format described below, and leaves it in the
2066                 current directory.
2067               </p>
2068
2069               <p>
2070                 This target may be invoked in any directory, and
2071                 should take care to clean up any temporary files it
2072                 may have left.
2073               </p>
2074
2075               <p>
2076                 This target is optional, but providing it if
2077                 possible is a good idea.
2078               </p>
2079             </item>
2080           </taglist>
2081
2082         <p>
2083           The <tt>build</tt>, <tt>binary</tt> and
2084           <tt>clean</tt> targets must be invoked with the current
2085           directory being the package's top-level directory.
2086         </p>
2087
2088
2089         <p>
2090           Additional targets may exist in <file>debian/rules</file>,
2091           either as published or undocumented interfaces or for the
2092           package's internal use.
2093         </p>
2094
2095         <p>
2096           The architectures we build on and build for are determined
2097           by <prgn>make</prgn> variables using the utility
2098           <prgn>dpkg-architecture</prgn>.  You can determine the
2099           Debian architecture and the GNU style architecture
2100           specification string for the build machine (the machine type
2101           we are building on) as well as for the host machine (the
2102           machine type we are building for).  Here is a list of
2103           supported <prgn>make</prgn> variables:
2104           <list compact="compact">
2105             <item>
2106               <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2107             </item>
2108             <item>
2109               <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2110                 specification string)</p>
2111             </item>
2112             <item>
2113               <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2114               <tt>DEB_*_GNU_TYPE</tt>)</p>
2115             </item>
2116             <item>
2117               <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2118                 <tt>DEB_*_GNU_TYPE</tt>)</p>
2119           </list>
2120           where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2121           the build machine or <tt>HOST</tt> for specification of the
2122           host machine.
2123         </p>
2124
2125         <p>
2126           Backward compatibility can be provided in the rules file
2127           by setting the needed variables to suitable default
2128           values; please refer to the documentation of
2129           <prgn>dpkg-architecture</prgn> for details.
2130         </p>
2131
2132         <p>
2133           It is important to understand that the <tt>DEB_*_ARCH</tt>
2134           string only determines which Debian architecture we are
2135           building on or for. It should not be used to get the CPU
2136           or system information; the GNU style variables should be
2137           used for that.
2138         </p>
2139       </sect>
2140
2141       <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2142         </heading>
2143
2144         <p>
2145           This file records the changes to the Debian-specific parts of the
2146           package<footnote>
2147             <p>
2148               Though there is nothing stopping an author who is also
2149               the Debian maintainer from using it for all their
2150               changes, it will have to be renamed if the Debian and
2151               upstream maintainers become different people.  In such a
2152               case, however, it might be better to maintain the
2153               package as a non-native package.
2154             </p>
2155           </footnote>.
2156         </p>
2157
2158         <p>
2159           It has a special format which allows the package building
2160           tools to discover which version of the package is being
2161           built and find out other release-specific information.
2162         </p>
2163
2164         <p>
2165           That format is a series of entries like this:
2166           <example compact="compact">
2167 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2168             <comment>
2169               <p>[optional blank line(s), stripped]</p>
2170             </comment>
2171   * <var>change details</var>
2172     <var>more change details</var>
2173             <comment>
2174               <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2175             </comment>
2176   * <var>even more change details</var>
2177             <comment>
2178               <p>[optional blank line(s), stripped]</p>
2179             </comment>
2180             -- <var>maintainer name</var> &lt;<var>email
2181               address</var>&gt;<var>[two spaces]</var>  <var>date</var>
2182           </example>
2183         </p>
2184
2185         <p>
2186           <var>package</var> and <var>version</var> are the source
2187           package name and version number.
2188         </p>
2189
2190         <p>
2191           <var>distribution(s)</var> lists the distributions where
2192           this version should be installed when it is uploaded - it
2193           is copied to the <tt>Distribution</tt> field in the
2194           <file>.changes</file> file.  See <ref id="f-Distribution">.
2195         </p>
2196
2197         <p>
2198           <var>urgency</var> is the value for the <tt>Urgency</tt>
2199           field in the <file>.changes</file> file for the upload. It is
2200           not possible to specify an urgency containing commas; commas
2201           are used to separate
2202           <tt><var>keyword</var>=<var>value</var></tt> settings in the
2203           <prgn>dpkg</prgn> changelog format (though there is
2204           currently only one useful <var>keyword</var>,
2205           <tt>urgency</tt>).<footnote>
2206             <p>
2207               Recognised urgency values are <tt>low</tt>,
2208               <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2209               They have an effect on how quickly a package will be
2210               considered for inclusion into the <tt>testing</tt>
2211               distribution, and give an indication of the importance
2212               of any fixes included in this upload.
2213             </p>
2214           </footnote>
2215         </p>
2216
2217         <p>
2218           The change details may in fact be any series of lines
2219           starting with at least two spaces, but conventionally each
2220           change starts with an asterisk and a separating space and
2221           continuation lines are indented so as to bring them in
2222           line with the start of the text above.  Blank lines may be
2223           used here to separate groups of changes, if desired.
2224         </p>
2225
2226         <p>
2227           If this upload resolves bugs recorded in the Bug Tracking
2228           System (BTS), they may be automatically closed on the
2229           inclusion of this package into the Debian archive by
2230           including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2231           in the change details.<footnote>
2232             <p>
2233               To be precise, the string should match the following
2234               Perl regular expression:
2235               <example>
2236 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2237               </example>
2238               Then all of the bug numbers listed will be closed by the
2239               archive maintenance script (<prgn>katie</prgn>), or in
2240               the case of an NMU, marked as fixed.
2241             </p>
2242           </footnote>
2243         </p>
2244
2245         <p>
2246           The maintainer name and email address used in the changelog
2247           should be the details of the person uploading <em>this</em>
2248           version.  They are <em>not</em> necessarily those of the
2249           usual package maintainer.  The information here will be
2250           copied to the <tt>Changed-By</tt> field in the
2251           <tt>.changes</tt> file, and then later used to send an
2252           acknowledgement when the upload has been installed.
2253         </p>
2254
2255         <p>
2256           The <var>date</var> should be in RFC822 format<footnote>
2257             <p>
2258               This is generated by the <prgn>822-date</prgn>
2259               program.
2260             </p>
2261           </footnote>; it should include the time zone specified
2262           numerically, with the time zone name or abbreviation
2263           optionally present as a comment in parentheses.
2264         </p>
2265
2266         <p>
2267           The first "title" line with the package name should start
2268           at the left hand margin; the "trailer" line with the
2269           maintainer and date details should be preceded by exactly
2270           one space.  The maintainer details and the date must be
2271           separated by exactly two spaces.
2272         </p>
2273
2274         <sect1><heading>Defining alternative changelog formats</heading>
2275
2276           <p>
2277             It is possible to use a different format to the standard
2278             one, by providing a parser for the format you wish to
2279             use.
2280           </p>
2281           <p>
2282             A changelog parser must not interact with the user at
2283             all.
2284           </p>
2285         </sect1>
2286       </sect>
2287
2288 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
2289
2290       <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2291           and variable substitutions      </heading>
2292
2293         <p>
2294           When <prgn>dpkg-gencontrol</prgn>,
2295           <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2296           generate control files they perform variable substitutions
2297           on their output just before writing it.  Variable
2298           substitutions have the form <tt>${<var>variable</var>}</tt>.
2299           The optional file <file>debian/substvars</file> contains
2300           variable substitutions to be used; variables can also be set
2301           directly from <file>debian/rules</file> using the <tt>-V</tt>
2302           option to the source packaging commands, and certain
2303           predefined variables are also available.
2304         </p>
2305
2306         <p>
2307           The <file>debian/substvars</file> file is usually generated and
2308           modified dynamically by <file>debian/rules</file> targets, in
2309           which case it must be removed by the <tt>clean</tt> target.
2310         </p>
2311
2312         <p>
2313           See <manref name="dpkg-source" section="1"> for full
2314           details about source variable substitutions, including the
2315           format of <file>debian/substvars</file>.</p>
2316       </sect>
2317
2318       <sect id="debianfiles"><heading><file>debian/files</file>
2319         </heading>
2320
2321         <p>
2322           This file is not a permanent part of the source tree; it
2323           is used while building packages to record which files are
2324           being generated.  <prgn>dpkg-genchanges</prgn> uses it
2325           when it generates a <file>.changes</file> file.
2326         </p>
2327
2328         <p>
2329           It should not exist in a shipped source package, and so it
2330           (and any backup files or temporary files such as
2331           <file>files.new</file><footnote>
2332             <p>
2333               <file>files.new</file> is used as a temporary file by
2334               <prgn>dpkg-gencontrol</prgn> and
2335               <prgn>dpkg-distaddfile</prgn> - they write a new
2336               version of <tt>files</tt> here before renaming it,
2337               to avoid leaving a corrupted copy if an error
2338               occurs
2339             </p>
2340           </footnote>) should be removed by the
2341           <tt>clean</tt> target.  It may also be wise to
2342           ensure a fresh start by emptying or removing it at the
2343           start of the <tt>binary</tt> target.
2344         </p>
2345
2346         <p>
2347           When <prgn>dpkg-gencontrol</prgn> is run for a binary
2348           package, it adds an entry to <file>debian/files</file> for the
2349           <file>.deb</file> file that will be created when <tt>dpkg-deb
2350           --build</tt> is run for that binary package.  So for most
2351           packages all that needs to be done with this file is to
2352           delete it in the <tt>clean</tt> target.
2353         </p>
2354
2355         <p>
2356           If a package upload includes files besides the source
2357           package and any binary packages whose control files were
2358           made with <prgn>dpkg-gencontrol</prgn> then they should be
2359           placed in the parent of the package's top-level directory
2360           and <prgn>dpkg-distaddfile</prgn> should be called to add
2361           the file to the list in <file>debian/files</file>.</p>
2362       </sect>
2363
2364       <sect id="restrictions"><heading>Restrictions on objects in source packages
2365         </heading>
2366
2367         <p>
2368           The source package may not contain any hard links<footnote>
2369             <p>
2370               This is not currently detected when building source
2371               packages, but only when extracting
2372               them.
2373             </p>
2374             <p>
2375               Hard links may be permitted at some point in the
2376               future, but would require a fair amount of
2377               work.
2378             </p>
2379           </footnote>, device special files, sockets or setuid or
2380           setgid files.<footnote>
2381             <p>
2382               Setgid directories are allowed.
2383             </p>
2384           </footnote>
2385         </p>
2386       </sect>
2387
2388       <sect id="descriptions"><heading>Descriptions of packages - the
2389           <tt>Description</tt> field</heading>
2390
2391         <p>
2392           The "Description" control file field consists of two parts,
2393           the synopsis or the short description, and the long description.
2394           The field's format is as follows:
2395         </p>
2396
2397         <p><example>
2398         Description: &lt;single line synopsis&gt;
2399          &lt;extended description over several lines&gt;
2400 </example></p>
2401
2402         <p>
2403           The description is intended to describe the program to a user
2404           who has never met it before so that they know whether they
2405           want to install it.  It should also give information about the
2406           significant dependencies and conflicts between this package
2407           and others, so that the user knows why these dependencies and
2408           conflicts have been declared.
2409         </p>
2410
2411         <p>
2412           Put important information first, both in the synopsis and
2413           extended description.  Sometimes only the first part of the
2414           synopsis or of the description will be displayed.  You can
2415           assume that there will usually be a way to see the whole
2416           extended description.
2417         </p>
2418
2419         <sect1 id="synopsis"><heading>The single line synopsis</heading>
2420
2421           <p>
2422             The single line synopsis should be kept brief - certainly
2423             under 80 characters.
2424           </p>
2425
2426           <p>
2427             Do not include the package name in the synopsis line.  The
2428             display software knows how to display this already, and you
2429             do not need to state it.  Remember that in many situations
2430             the user may only see the synopsis line - make it as
2431             informative as you can.
2432           </p>
2433
2434         </sect1>
2435
2436         <sect1 id="extendeddesc"><heading>The extended description</heading>
2437
2438           <p>
2439             Do not try to continue the single line synopsis into the
2440             extended description.  This will not work correctly when
2441             the full description is displayed, and makes no sense
2442             where only the summary (the single line synopsis) is
2443             available.
2444           </p>
2445
2446           <p>
2447             The extended description should describe what the package
2448             does and how it relates to the rest of the system (in terms
2449             of, for example, which subsystem it is which part of).
2450           </p>
2451
2452           <p>
2453             The description field needs to make sense to anyone, even
2454             people who have no idea about any of the things the
2455             package deals with.<footnote>
2456                 The blurb that comes with a program in its
2457                 announcements and/or <prgn>README</prgn> files is
2458                 rarely suitable for use in a description.  It is
2459                 usually aimed at people who are already in the
2460                 community where the package is used.
2461             </footnote>
2462           </p>
2463
2464           <p>
2465             The lines in the extended description can have these formats:
2466           </p>
2467
2468           <p><list>
2469
2470             <item>
2471               Those starting with a single space are part of a paragraph.
2472               Successive lines of this form will be word-wrapped when
2473               displayed. The leading space will usually be stripped off.
2474             </item>
2475
2476             <item>
2477               Those starting with two or more spaces. These will be
2478               displayed verbatim. If the display cannot be panned
2479               horizontally, the displaying program will linewrap them "hard"
2480               (i.e., without taking account of word breaks). If it can they
2481               will be allowed to trail off to the right. None, one or two
2482               initial spaces may be deleted, but the number of spaces
2483               deleted from each line will be the same (so that you can have
2484               indenting work correctly, for example).
2485             </item>
2486
2487             <item>
2488               Those containing a single space followed by a single full stop
2489               character. These are rendered as blank lines. This is the
2490               <em>only</em> way to get a blank line<footnote>
2491                 Completely empty lines will not be rendered as blank lines. 
2492                 Instead, they will cause the parser to think you're starting
2493                 a whole new record in the control file, and will therefore
2494                 likely abort with an error.
2495               </footnote>.
2496             </item>
2497
2498             <item>
2499               Those containing a space, a full stop and some more characters.
2500               These are for future expansion. Do not use them.
2501             </item>
2502
2503           </list></p>
2504
2505           <p>
2506             Do not use tab characters.  Their effect is not predictable.
2507           </p>
2508
2509         </sect1>
2510
2511       </sect>
2512
2513     </chapt>
2514
2515
2516     <chapt id="maintainerscripts"><heading>Package maintainer scripts
2517         and installation procedure
2518       </heading>
2519
2520       <sect><heading>Introduction to package maintainer scripts
2521         </heading>
2522
2523         <p>
2524           It is possible to supply scripts as part of a package which
2525           the package management system will run for you when your
2526           package is installed, upgraded or removed.
2527         </p>
2528
2529         <p>
2530           These scripts are the files <prgn>preinst</prgn>,
2531           <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2532           control area of the package.  They must be proper executable
2533           files; if they are scripts (which is recommended), they must
2534           start with the usual <tt>#!</tt> convention.  They should be
2535           readable and executable by anyone, and not world-writable.
2536         </p>
2537
2538         <p>
2539           The package management system looks at the exit status from
2540           these scripts.  It is important that they exit with a
2541           non-zero status if there is an error, so that the package
2542           management system can stop its processing.  For shell
2543           scripts this means that you <em>almost always</em> need to
2544           use <tt>set -e</tt> (this is usually true when writing shell
2545           scripts, in fact).  It is also important, of course, that
2546           they don't exit with a non-zero status if everything went
2547           well.
2548         </p>
2549
2550         <p>
2551           When a package is upgraded a combination of the scripts from
2552           the old and new packages is called during the upgrade
2553           procedure.  If your scripts are going to be at all
2554           complicated you need to be aware of this, and may need to
2555           check the arguments to your scripts.
2556         </p>
2557
2558         <p>
2559           Broadly speaking the <prgn>preinst</prgn> is called before
2560           (a particular version of) a package is installed, and the
2561           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2562           before (a version of) a package is removed and the
2563           <prgn>postrm</prgn> afterwards.
2564         </p>
2565
2566         <p>
2567           Programs called from maintainer scripts should not normally
2568           have a path prepended to them. Before installation is
2569           started, the package management system checks to see if the
2570           programs <prgn>ldconfig</prgn>,
2571           <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2572           and <prgn>update-rc.d</prgn> can be found via the
2573           <tt>PATH</tt> environment variable. Those programs, and any
2574           other program that one would expect to be on the
2575           <tt>PATH</tt>, should thus be invoked without an absolute
2576           pathname. Maintainer scripts should also not reset the
2577           <tt>PATH</tt>, though they might choose to modify it by
2578           prepending or appending package-specific directories. These
2579           considerations really apply to all shell scripts.</p>
2580       </sect>
2581
2582       <sect>
2583         <heading>Maintainer scripts Idempotency</heading>
2584
2585         <p>
2586           It is necessary for the error recovery procedures that the
2587           scripts be idempotent.  This means that if it is run
2588           successfully, and then it is called again, it doesn't bomb
2589           out or cause any harm, but just ensures that everything is
2590           the way it ought to be.  If the first call failed, or
2591           aborted half way through for some reason, the second call
2592           should merely do the things that were left undone the first
2593           time, if any, and exit with a success status if everything
2594           is OK.<footnote>
2595             <p>
2596               This is so that if an error occurs, the user interrupts
2597               <prgn>dpkg</prgn> or some other unforeseen circumstance
2598               happens you don't leave the user with a badly-broken
2599               package when <prgn>dpkg</prgn> attempts to repeat the
2600               action.
2601             </p>
2602           </footnote>
2603         </p>
2604       </sect>
2605
2606       <sect>
2607         <heading>Controlling terminal for maintainer scripts</heading>
2608
2609         <p>
2610           The maintainer scripts are guaranteed to run with a
2611           controlling terminal and can interact with the user.
2612           If they need to prompt for passwords, do full-screen
2613           interaction or something similar you should do these
2614           things to and from <file>/dev/tty</file>, since
2615           <prgn>dpkg</prgn> will at some point redirect scripts'
2616           standard input and output so that it can log the
2617           installation process.  Likewise, because these scripts
2618           may be executed with standard output redirected into a
2619           pipe for logging purposes, Perl scripts should set
2620           unbuffered output by setting <tt>$|=1</tt> so that the
2621           output is printed immediately rather than being
2622           buffered.
2623         </p>
2624
2625         <p>
2626           Each script should return a zero exit status for
2627           success, or a nonzero one for failure.
2628         </p>
2629       </sect>
2630
2631       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2632           scripts are called
2633         </heading>
2634
2635         <p>
2636           <list compact="compact">
2637             <item>
2638               <p><var>new-preinst</var> <tt>install</tt></p>
2639             </item>
2640             <item>
2641               <p><var>new-preinst</var> <tt>install</tt>
2642                 <var>old-version</var></p>
2643             </item>
2644             <item>
2645               <p><var>new-preinst</var> <tt>upgrade</tt>
2646                 <var>old-version</var></p>
2647             </item>
2648             <item>
2649               <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2650                 <var>new-version</var>
2651               </p>
2652             </item>
2653           </list>
2654
2655         <p>
2656           <list compact="compact">
2657             <item>
2658               <p><var>postinst</var> <tt>configure</tt>
2659                 <var>most-recently-configured-version</var></p>
2660             </item>
2661             <item>
2662               <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2663                 <var>new-version</var></p>
2664             </item>
2665             <item>
2666               <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2667                 <tt>in-favour</tt> <var>package</var>
2668                 <var>new-version</var></p>
2669             </item>
2670             <item>
2671               <p>
2672                 <var>deconfigured's-postinst</var>
2673                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2674                 <var>failed-install-package</var> <var>version</var>
2675                 <tt>removing</tt> <var>conflicting-package</var>
2676                 <var>version</var>
2677               </p>
2678             </item>
2679           </list>
2680
2681         <p>
2682           <list compact="compact">
2683             <item>
2684               <p><var>prerm</var> <tt>remove</tt></p>
2685             </item>
2686             <item>
2687               <p><var>old-prerm</var> <tt>upgrade</tt>
2688                 <var>new-version</var></p>
2689             </item>
2690             <item>
2691               <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2692                 <var>old-version</var></p>
2693             </item>
2694             <item>
2695               <p><var>conflictor's-prerm</var> <tt>remove</tt>
2696                 <tt>in-favour</tt> <var>package</var>
2697                 <var>new-version</var></p>
2698             </item>
2699             <item>
2700               <p>
2701                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2702                 <tt>in-favour</tt> <var>package-being-installed</var>
2703                 <var>version</var> <tt>removing</tt>
2704                 <var>conflicting-package</var>
2705                 <var>version</var>
2706               </p>
2707             </item>
2708           </list>
2709
2710         <p>
2711           <list compact="compact">
2712             <item>
2713               <p><var>postrm</var> <tt>remove</tt></p>
2714             </item>
2715             <item>
2716               <p><var>postrm</var> <tt>purge</tt></p>
2717             </item>
2718             <item>
2719               <p>
2720                 <var>old-postrm</var> <tt>upgrade</tt>
2721                 <var>new-version</var></p>
2722             </item>
2723             <item>
2724               <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2725                 <var>old-version</var></p>
2726             </item>
2727             <item>
2728               <p><var>new-postrm</var> <tt>abort-install</tt></p>
2729             </item>
2730             <item>
2731               <p><var>new-postrm</var> <tt>abort-install</tt>
2732                 <var>old-version</var></p>
2733             </item>
2734             <item>
2735               <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2736                 <var>old-version</var></p>
2737             </item>
2738             <item>
2739               <p>
2740                 <var>disappearer's-postrm</var> <tt>disappear</tt>
2741                 <var>overwriter</var>
2742                 <var>overwriter-version</var></p></item>
2743           </list>
2744         </p>
2745
2746
2747       <sect id="unpackphase"><heading>Details of unpack phase of
2748           installation or upgrade
2749         </heading>
2750
2751         <p>
2752           The procedure on installation/upgrade/overwrite/disappear
2753           (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2754           stage of <tt>dpkg --install</tt>) is as follows.  In each
2755           case, if a major error occurs (unless listed below) the
2756           actions are, in general, run backwards - this means that the
2757           maintainer scripts are run with different arguments in
2758           reverse order.  These are the "error unwind" calls listed
2759           below.
2760
2761           <enumlist>
2762             <item>
2763               <p>
2764                 <enumlist>
2765                   <item>
2766                     <p>If a version of the package is already
2767                       installed, call
2768                       <example compact="compact">
2769 <var>old-prerm</var> upgrade <var>new-version</var>
2770                       </example></p>
2771                   </item>
2772                   <item>
2773                     <p>
2774                       If the script runs but exits with a non-zero
2775                       exit status, <prgn>dpkg</prgn> will attempt:
2776                       <example compact="compact">
2777 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2778                       </example>
2779                       Error unwind, for both the above cases:
2780                       <example compact="compact">
2781 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2782                       </example>
2783                     </p>
2784                   </item>
2785                 </enumlist>
2786               </p>
2787             </item>
2788             <item>
2789               <p>If a "conflicting" package is being removed at the same time:
2790                 <enumlist>
2791                   <item>
2792                     <p>
2793                       If any packages depended on that conflicting
2794                       package and <tt>--auto-deconfigure</tt> is
2795                       specified, call, for each such package:
2796                       <example compact="compact">
2797 <var>deconfigured's-prerm</var> deconfigure \
2798   in-favour <var>package-being-installed</var> <var>version</var> \
2799     removing <var>conflicting-package</var> <var>version</var>
2800                       </example>
2801                       Error unwind:
2802                       <example compact="compact">
2803 <var>deconfigured's-postinst</var> abort-deconfigure \
2804   in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2805     removing <var>conflicting-package</var> <var>version</var>
2806                       </example>
2807                       The deconfigured packages are marked as
2808                       requiring configuration, so that if
2809                       <tt>--install</tt> is used they will be
2810                       configured again if possible.</p>
2811                   </item>
2812                   <item>
2813                     <p>To prepare for removal of the conflicting package, call:
2814                       <example compact="compact">
2815 <var>conflictor's-prerm</var> remove \
2816   in-favour <var>package</var> <var>new-version</var>
2817                       </example>
2818                       Error unwind:
2819                       <example compact="compact">
2820 <var>conflictor's-postinst</var> abort-remove \
2821   in-favour <var>package</var> <var>new-version</var>
2822                       </example>
2823                     </p>
2824                   </item>
2825                 </enumlist>
2826               </p>
2827             </item>
2828             <item>
2829               <p>
2830                 <enumlist>
2831                   <item>
2832                     <p>If the package is being upgraded, call:
2833                       <example compact="compact">
2834 <var>new-preinst</var> upgrade <var>old-version</var>
2835                       </example></p>
2836                   </item>
2837                   <item>
2838                     <p>
2839                       Otherwise, if the package had some configuration
2840                       files from a previous version installed (i.e., it
2841                       is in the "configuration files only" state):
2842                       <example compact="compact">
2843 <var>new-preinst</var> install <var>old-version</var>
2844                       </example></p>
2845
2846                   <item>
2847                     <p>Otherwise (i.e., the package was completely purged):
2848                       <example compact="compact">
2849 <var>new-preinst</var> install
2850                       </example>
2851                       Error unwind actions, respectively:
2852                       <example compact="compact">
2853 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2854 <var>new-postrm</var> abort-install <var>old-version</var>
2855 <var>new-postrm</var> abort-install
2856                       </example>
2857                     </p>
2858                   </item>
2859                 </enumlist>
2860               </p>
2861             </item>
2862             <item>
2863               <p>
2864                 The new package's files are unpacked, overwriting any
2865                 that may be on the system already, for example any
2866                 from the old version of the same package or from
2867                 another package.  Backups of the old files are kept
2868                 temporarily, and if anything goes wrong the package
2869                 management system will attempt to put them back as
2870                 part of the error unwind.
2871               </p>
2872
2873               <p>
2874                 It is an error for a package to contains files which
2875                 are on the system in another package, unless
2876                 <tt>Replaces</tt> is used (see <ref id="replaces">).
2877                 <!--
2878                 The following paragraph is not currently the case:
2879                 Currently the <tt>- - force-overwrite</tt> flag is
2880                 enabled, downgrading it to a warning, but this may not
2881                 always be the case.
2882                 -->
2883               </p>
2884
2885               <p>
2886                 It is a more serious error for a package to contain a
2887                 plain file or other kind of non-directory where another
2888                 package has a directory (again, unless
2889                 <tt>Replaces</tt> is used).  This error can be
2890                 overridden if desired using
2891                 <tt>--force-overwrite-dir</tt>, but this is not
2892                 advisable.
2893               </p>
2894
2895               <p>
2896                 Packages which overwrite each other's files produce
2897                 behavior which, though deterministic, is hard for the
2898                 system administrator to understand.  It can easily
2899                 lead to "missing" programs if, for example, a package
2900                 is installed which overwrites a file from another
2901                 package, and is then removed again.<footnote>
2902                   <p>
2903                     Part of the problem is due to what is arguably a
2904                     bug in <prgn>dpkg</prgn>.
2905                   </p>
2906                 </footnote>
2907               </p>
2908
2909               <p>
2910                 A directory will never be replaced by a symbolic link
2911                 to a directory or vice versa; instead, the existing
2912                 state (symlink or not) will be left alone and
2913                 <prgn>dpkg</prgn> will follow the symlink if there is
2914                 one.</p>
2915             </item>
2916
2917             <item>
2918               <p>
2919                 <enumlist>
2920                   <item>
2921                     <p>If the package is being upgraded, call
2922                       <example compact="compact">
2923 <var>old-postrm</var> upgrade <var>new-version</var>
2924                       </example>
2925                     </p>
2926                   </item>
2927                   <item>
2928                     <p>If this fails, <prgn>dpkg</prgn> will attempt:
2929                       <example compact="compact">
2930 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2931                       </example>
2932                       Error unwind, for both cases:
2933                       <example compact="compact">
2934 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2935                       </example>
2936                     </p>
2937                   </item>
2938                 </enumlist>
2939               </p>
2940               <p>
2941                 This is the point of no return - if
2942                 <prgn>dpkg</prgn> gets this far, it won't back off
2943                 past this point if an error occurs.  This will
2944                 leave the package in a fairly bad state, which
2945                 will require a successful re-installation to clear
2946                 up, but it's when <prgn>dpkg</prgn> starts doing
2947                 things that are irreversible.
2948               </p>
2949             </item>
2950             <item>
2951               <p>
2952                 Any files which were in the old version of the package
2953                 but not in the new are removed.</p>
2954             </item>
2955             <item>
2956               <p>The new file list replaces the old.</p>
2957             </item>
2958             <item>
2959               <p>The new maintainer scripts replace the old.</p>
2960             </item>
2961
2962             <item>
2963               <p>Any packages all of whose files have been overwritten during the
2964                 installation, and which aren't required for
2965                 dependencies, are considered to have been removed.
2966                 For each such package
2967                 <enumlist>
2968                   <item>
2969                     <p><prgn>dpkg</prgn> calls:
2970                       <example compact="compact">
2971 <var>disappearer's-postrm</var> disappear \
2972   <var>overwriter</var> <var>overwriter-version</var>
2973                       </example>
2974                     </p>
2975                   </item>
2976                   <item>
2977                     <p>The package's maintainer scripts are removed.
2978                     </p>
2979                   </item>
2980                   <item>
2981                     <p>
2982                       It is noted in the status database as being in a
2983                       sane state, namely not installed (any conffiles
2984                       it may have are ignored, rather than being
2985                       removed by <prgn>dpkg</prgn>).  Note that
2986                       disappearing packages do not have their prerm
2987                       called, because <prgn>dpkg</prgn> doesn't know
2988                       in advance that the package is going to
2989                       vanish.
2990                     </p>
2991                   </item>
2992                 </enumlist>
2993               </p>
2994             </item>
2995             <item>
2996               <p>
2997                 Any files in the package we're unpacking that are also
2998                 listed in the file lists of other packages are removed
2999                 from those lists.  (This will lobotomize the file list
3000                 of the "conflicting" package if there is one.)
3001               </p>
3002             </item>
3003             <item>
3004               <p>
3005                 The backup files made during installation, above, are
3006                 deleted.
3007               </p>
3008             </item>
3009
3010             <item>
3011               <p>
3012                 The new package's status is now sane, and recorded as
3013                 "unpacked".
3014               </p>
3015
3016               <p>
3017                 Here is another point of no return - if the
3018                 conflicting package's removal fails we do not unwind
3019                 the rest of the installation; the conflicting package
3020                 is left in a half-removed limbo.
3021               </p>
3022             </item>
3023
3024             <item>
3025               <p>
3026                 If there was a conflicting package we go and do the
3027                 removal actions (described below), starting with the
3028                 removal of the conflicting package's files (any that
3029                 are also in the package being installed have already
3030                 been removed from the conflicting package's file list,
3031                 and so do not get removed now).
3032               </p>
3033             </item>
3034           </enumlist>
3035         </p>
3036       </sect>
3037
3038       <sect id="configdetails"><heading>Details of configuration</heading>
3039
3040         <p>
3041           When we configure a package (this happens with <tt>dpkg
3042             --install</tt> and <tt>dpkg --configure</tt>), we first
3043           update any <tt>conffile</tt>s and then call:
3044           <example compact="compact">
3045 <var>postinst</var> configure <var>most-recently-configured-version</var>
3046           </example>
3047         </p>
3048
3049         <p>
3050           No attempt is made to unwind after errors during
3051           configuration.
3052         </p>
3053
3054         <p>
3055           If there is no most recently configured version
3056           <prgn>dpkg</prgn> will pass a null argument; older versions
3057           of dpkg may pass <tt>&lt;unknown&gt;</tt> (including the
3058           angle brackets) in this case.  Even older ones do not pass a
3059           second argument at all, under any circumstances.
3060         </p>
3061       </sect>
3062
3063       <sect id="removedetails"><heading>Details of removal and/or
3064       configuration purging</heading>
3065
3066         <p>
3067           <enumlist>
3068             <item>
3069               <p>
3070                 <example compact="compact">
3071 <var>prerm</var> remove
3072                 </example>
3073               </p>
3074             </item>
3075             <item>
3076               <p>
3077                 The package's files are removed (except <tt>conffile</tt>s).
3078               </p>
3079             </item>
3080             <item>
3081               <p>
3082                 <example compact="compact">
3083 <var>postrm</var> remove
3084                 </example>
3085               </p>
3086             </item>
3087             <item>
3088               <p>
3089                 All the maintainer scripts except the <prgn>postrm</prgn>
3090                 are removed.
3091               </p>
3092
3093               <p>
3094                 If we aren't purging the package we stop here.  Note
3095                 that packages which have no <prgn>postrm</prgn> and no
3096                 <tt>conffile</tt>s are automatically purged when
3097                 removed, as there is no difference except for the
3098                 <prgn>dpkg</prgn> status.</p>
3099             </item>
3100             <item>
3101               <p>
3102                 The <tt>conffile</tt>s and any backup files
3103                 (<tt>~</tt>-files, <tt>#*#</tt> files,
3104                 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3105                 are removed.</p>
3106             </item>
3107             <item>
3108               <p>
3109                 <example compact="compact">
3110 <var>postrm</var> purge
3111                 </example>
3112               </p>
3113             </item>
3114             <item>
3115               <p>The package's file list is removed.</p>
3116             </item>
3117           </enumlist>
3118           No attempt is made to unwind after errors during
3119           removal.
3120         </p>
3121       </sect>
3122     </chapt>
3123
3124
3125     <chapt id="relationships"><heading>Declaring relationships between
3126         packages</heading>
3127
3128       <sect id="depsyntax"><heading>Syntax of relationship fields
3129         </heading>
3130
3131         <p>
3132           These fields all have a uniform syntax.  They are a list of
3133           package names separated by commas.
3134         </p>
3135
3136         <p>
3137           In the <tt>Depends</tt>, <tt>Recommends</tt>,
3138           <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3139           <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3140           control file fields of the package, which declare
3141           dependencies on other packages, the package names listed may
3142           also include lists of alternative package names, separated
3143           by vertical bar (pipe) symbols <tt>|</tt>.  In such a case,
3144           if any one of the alternative packages is installed, that
3145           part of the dependency is considered to be satisfied.
3146         </p>
3147
3148         <p>
3149           All of the fields except for <tt>Provides</tt> may restrict
3150           their applicability to particular versions of each named
3151           package.  This is done in parentheses after each individual
3152           package name; the parentheses should contain a relation from
3153           the list below followed by a version number, in the format
3154           described in <ref id="versions">.
3155         </p>
3156
3157         <p>
3158           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
3159           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
3160           strictly earlier, earlier or equal, exactly equal, later or
3161           equal and strictly later, respectively.  The deprecated
3162           forms <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
3163           earlier/later or equal, rather than strictly earlier/later,
3164           so they should not appear in new packages (though
3165           <prgn>dpkg</prgn> still supports them).
3166         </p>
3167
3168         <p>
3169           Whitespace may appear at any point in the version
3170           specification subject to the rules in <ref
3171           id="controlsyntax">, and must appear where it's necessary to
3172           disambiguate; it is not otherwise significant.  For
3173           consistency and in case of future changes to
3174           <prgn>dpkg</prgn> it is recommended that a single space be
3175           used after a version relationship and before a version
3176           number; it is also conventional to put a single space after
3177           each comma, on either side of each vertical bar, and before
3178           each open parenthesis.
3179         </p>
3180
3181         <p>
3182           For example, a list of dependencies might appear as:
3183           <example compact="compact">
3184 Package: mutt
3185 Version: 1.3.17-1
3186 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3187           </example>
3188         </p>
3189
3190         <p>
3191           All fields that specify build-time relationships
3192           (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3193           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3194           may be restricted to a certain set of architectures.  This
3195           is indicated in brackets after each individual package name and
3196           the optional version specification.  The brackets enclose a
3197           list of Debian architecture names separated by whitespace.
3198           Exclamation marks may be prepended to each of the names.
3199           (It is not permitted for some names to be prepended with
3200           exclamation marks and others not.) If the current Debian
3201           host architecture is not in this list and there are no
3202           exclamation marks in the list, or it is in the list with a
3203           prepended exclamation mark, the package name and the
3204           associated version specification are ignored completely for
3205           the purposes of defining the relationships.
3206         </p>
3207
3208         <p>
3209           For example:
3210           <example compact="compact">
3211 Source: glibc
3212 Build-Depends-Indep: texinfo
3213 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3214   hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3215           </example>
3216         </p>
3217
3218         <p>
3219           Note that the binary package relationship fields such as
3220           <tt>Depends</tt> appear in one of the binary package
3221           sections of the control file, whereas the build-time
3222           relationships such as <tt>Build-Depends</tt> appear in the
3223           source package section of the control file (which is the
3224           first section).
3225         </p>
3226       </sect>
3227
3228       <sect>
3229         <heading>Binary Dependencies - <tt>Depends</tt>,
3230           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3231           <tt>Pre-Depends</tt>
3232         </heading>
3233
3234         <p>
3235           Packages can declare in their control file that they have
3236           certain relationships to other packages - for example, that
3237           they may not be installed at the same time as certain other
3238           packages, and/or that they depend on the presence of others.
3239         </p>
3240   
3241         <p>
3242           This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3243           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt> and
3244           <tt>Conflicts</tt> control file fields.
3245         </p>
3246
3247         <p>
3248           These six fields are used to declare a dependency
3249           relationship by one package on another.  Except for
3250           <tt>Enhances</tt>, they appear in the depending (binary)
3251           package's control file.  (<tt>Enhances</tt> appears in the
3252           recommending package's control file.)
3253         </p>
3254
3255         <p>
3256           A <tt>Depends</tt> field takes effect <em>only</em> when a
3257           package is to be configured.  It does not prevent a package
3258           being on the system in an unconfigured state while its
3259           dependencies are unsatisfied, and it is possible to replace
3260           a package whose dependencies are satisfied and which is
3261           properly installed with a different version whose
3262           dependencies are not and cannot be satisfied; when this is
3263           done the depending package will be left unconfigured (since
3264           attempts to configure it will give errors) and will not
3265           function properly.  If it is necessary, a
3266           <tt>Pre-Depends</tt> field can be used, which has a partial
3267           effect even when a package is being unpacked, as explained
3268           in detail below.  (The other three dependency fields,
3269           <tt>Recommends</tt>, <tt>Suggests</tt> and
3270           <tt>Enhances</tt>, are only used by the various front-ends
3271           to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3272         </p>
3273
3274         <p>
3275           For this reason packages in an installation run are usually
3276           all unpacked first and all configured later; this gives
3277           later versions of packages with dependencies on later
3278           versions of other packages the opportunity to have their
3279           dependencies satisfied.
3280         </p>
3281
3282         <p>
3283           The <tt>Depends</tt> field thus allows package maintainers
3284           to impose an order in which packages should be configured.
3285         </p>
3286
3287         <p>
3288           The meaning of the five dependency fields is as follows:
3289           <taglist>
3290             <tag><tt>Depends</tt></tag>
3291             <item>
3292               <p>
3293                 This declares an absolute dependency.  A package will
3294                 not be configured unless all of the packages listed in
3295                 its <tt>Depends</tt> field have been correctly
3296                 configured.
3297               </p>
3298
3299               <p>
3300                 The <tt>Depends</tt> field should be used if the
3301                 depended-on package is required for the depending
3302                 package to provide a significant amount of
3303                 functionality.
3304               </p>
3305               <p>
3306                 The <tt>Depends</tt> field should also be used if the
3307                 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3308                 <prgn>postrm</prgn> scripts require the package to be
3309                 present in order to run.  Note, however, that the
3310                 <prgn>postrm</prgn> cannot rely on any non-essential
3311                 packages to be present during the <tt>purge</tt>
3312                 phase.
3313             </item>
3314
3315             <tag><tt>Recommends</tt></tag>
3316             <item>
3317               <p>This declares a strong, but not absolute, dependency.
3318               </p>
3319
3320               <p>
3321                 The <tt>Recommends</tt> field should list packages
3322                 that would be found together with this one in all but
3323                 unusual installations.</p>
3324             </item>
3325
3326             <tag><tt>Suggests</tt></tag>
3327             <item>
3328               <p>
3329                 This is used to declare that one package may be more
3330                 useful with one or more others.  Using this field
3331                 tells the packaging system and the user that the
3332                 listed packages are related to this one and can
3333                 perhaps enhance its usefulness, but that installing
3334                 this one without them is perfectly reasonable.
3335               </p>
3336             </item>
3337
3338             <tag><tt>Enhances</tt></tag>
3339             <item>
3340               <p>
3341                 This field is similar to Suggests but works in the
3342                 opposite direction. It is used to declare that a
3343                 package can enhance the functionality of another
3344                 package.
3345               </p>
3346             </item>
3347
3348             <tag><tt>Pre-Depends</tt></tag>
3349             <item>
3350               <p>
3351                 This field is like <tt>Depends</tt>, except that it
3352                 also forces <prgn>dpkg</prgn> to complete installation
3353                 of the packages named before even starting the
3354                 installation of the package which declares the
3355                 pre-dependency, as follows:
3356               </p>
3357
3358               <p>
3359                 When a package declaring a pre-dependency is about to
3360                 be <em>unpacked</em> the pre-dependency can be
3361                 satisfied if the depended-on package is either fully
3362                 configured, <em>or even if</em> the depended-on
3363                 package(s) are only unpacked or half-configured,
3364                 provided that they have been configured correctly at
3365                 some point in the past (and not removed or partially
3366                 removed since).  In this case, both the
3367                 previously-configured and currently unpacked or
3368                 half-configured versions must satisfy any version
3369                 clause in the <tt>Pre-Depends</tt> field.
3370               </p>
3371
3372               <p>
3373                 When the package declaring a pre-dependency is about
3374                 to be <em>configured</em>, the pre-dependency will be
3375                 treated as a normal <tt>Depends</tt>, that is, it will
3376                 be considered satisfied only if the depended-on
3377                 package has been correctly configured.
3378               </p>
3379
3380               <p>
3381                 <tt>Pre-Depends</tt> should be used sparingly,
3382                 preferably only by packages whose premature upgrade or
3383                 installation would hamper the ability of the system to
3384                 continue with any upgrade that might be in progress.
3385               </p>
3386
3387               <p>
3388                 <tt>Pre-Depends</tt> are also required if the
3389                 <prgn>preinst</prgn> script depends on the named
3390                 package.  It is best to avoid this situation if
3391                 possible.
3392             </item>
3393           </taglist>
3394         </p>
3395         <p>
3396           When selecting which level of dependency to use you should
3397           consider how important the depended-on package is to the
3398           functionality of the one declaring the dependency.  Some
3399           packages are composed of components of varying degrees of
3400           importance.  Such a package should list using
3401           <tt>Depends</tt> the package(s) which are required by the
3402           more important components.  The other components'
3403           requirements may be mentioned as Suggestions or
3404           Recommendations, as appropriate to the components' relative
3405           importance.
3406         </p>
3407
3408
3409       <sect id="conflicts"><heading>Conflicting binary packages -
3410            <tt>Conflicts</tt></heading>
3411
3412         <p>
3413           When one binary package declares a conflict with another
3414           using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3415           refuse to allow them to be installed on the system at the
3416           same time.
3417         </p>
3418
3419         <p>
3420           If one package is to be installed, the other must be removed
3421           first - if the package being installed is marked as
3422           replacing (see <ref id="replaces">) the one on the system,
3423           or the one on the system is marked as deselected, or both
3424           packages are marked <tt>Essential</tt>, then
3425           <prgn>dpkg</prgn> will automatically remove the package
3426           which is causing the conflict, otherwise it will halt the
3427           installation of the new package with an error.  This
3428           mechanism is specifically designed to produce an error when
3429           the installed package is <tt>Essential</tt>, but the new
3430           package is not.
3431         </p>
3432
3433         <p>
3434           A package will not cause a conflict merely because its
3435           configuration files are still installed; it must be at least
3436           half-installed.
3437         </p>
3438
3439         <p>
3440           A special exception is made for packages which declare a
3441           conflict with their own package name, or with a virtual
3442           package which they provide (see below): this does not
3443           prevent their installation, and allows a package to conflict
3444           with others providing a replacement for it.  You use this
3445           feature when you want the package in question to be the only
3446           package providing some feature.
3447         </p>
3448
3449         <p>
3450           A <tt>Conflicts</tt> entry should almost never have an
3451           "earlier than" version clause.  This would prevent
3452           <prgn>dpkg</prgn> from upgrading or installing the package
3453           which declared such a conflict until the upgrade or removal
3454           of the conflicted-with package had been completed.
3455         </p>
3456       </sect>
3457
3458       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3459         </heading>
3460
3461         <p>
3462           As well as the names of actual ("concrete") packages, the
3463           package relationship fields <tt>Depends</tt>,
3464           <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3465           <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3466           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3467           <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3468           may mention "virtual packages".
3469         </p>
3470
3471         <p>
3472           A <em>virtual package</em> is one which appears in the
3473           <tt>Provides</tt> control file field of another package.
3474           The effect is as if the package(s) which provide a
3475           particular virtual package name had been listed by name
3476           everywhere the virtual package name appears. (See also <ref
3477             id="virtual_pkg_sect">)
3478         </p>
3479
3480         <p>
3481           If there are both concrete and virtual packages of the same
3482           name, then the dependency may be satisfied (or the conflict
3483           caused) by either the concrete package with the name in
3484           question or any other concrete package which provides the
3485           virtual package with the name in question.  This is so that,
3486           for example, supposing we have
3487           <example compact="compact">
3488 Package: foo
3489 Depends: bar
3490           </example>
3491           and someone else releases an enhanced version of the
3492           <tt>bar</tt> package (for example, a non-US variant), they
3493           can say:
3494           <example compact="compact">
3495 Package: bar-plus
3496 Provides: bar
3497           </example>
3498           and the <tt>bar-plus</tt> package will now also satisfy the
3499           dependency for the <tt>foo</tt> package.
3500         </p>
3501
3502         <p>
3503           If a dependency or a conflict has a version number attached
3504           then only real packages will be considered to see whether
3505           the relationship is satisfied (or the prohibition violated,
3506           for a conflict) - it is assumed that a real package which
3507           provides the virtual package is not of the "right" version.
3508           So, a <tt>Provides</tt> field may not contain version
3509           numbers, and the version number of the concrete package
3510           which provides a particular virtual package will not be
3511           looked at when considering a dependency on or conflict with
3512           the virtual package name.
3513         </p>
3514
3515         <p>
3516           It is likely that the ability will be added in a future
3517           release of <prgn>dpkg</prgn> to specify a version number for
3518           each virtual package it provides.  This feature is not yet
3519           present, however, and is expected to be used only
3520           infrequently.
3521         </p>
3522
3523         <p>
3524           If you want to specify which of a set of real packages
3525           should be the default to satisfy a particular dependency on
3526           a virtual package, you should list the real package as an
3527           alternative before the virtual one.
3528         </p>
3529       </sect>
3530
3531
3532       <sect id="replaces"><heading>Overwriting files and replacing
3533           packages - <tt>Replaces</tt></heading>
3534
3535         <p>
3536           Packages can declare in their control file that they should
3537           overwrite files in certain other packages, or completely
3538           replace other packages. The <tt>Replaces</tt> control file
3539           field has these two distinct purposes.
3540         </p>
3541
3542         <sect1><heading>Overwriting files in other packages</heading>
3543
3544           <p>
3545             Firstly, as mentioned before, it is usually an error for a
3546             package to contain files which are on the system in
3547             another package.
3548           </p>
3549
3550           <p>
3551             However, if the overwriting package declares that it
3552             <tt>Replaces</tt> the one containing the file being
3553             overwritten, then <prgn>dpkg</prgn> will replace the file
3554             from the old package with that from the new.  The file
3555             will no longer be listed as "owned" by the old package.
3556           </p>
3557
3558           <p>
3559             If a package is completely replaced in this way, so that
3560             <prgn>dpkg</prgn> does not know of any files it still
3561             contains, it is considered to have "disappeared".  It will
3562             be marked as not wanted on the system (selected for
3563             removal) and not installed.  Any <tt>conffile</tt>s
3564             details noted for the package will be ignored, as they
3565             will have been taken over by the overwriting package.  The
3566             package's <prgn>postrm</prgn> script will be run with a
3567             special argument to allow the package to do any final
3568             cleanup required.  See <ref id="mscriptsinstact">.
3569           </p>
3570
3571           <p>
3572             If an installed package, <tt>foo</tt> say, declares that
3573             it replaces another, <tt>bar</tt>, and an attempt is made
3574             to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3575             files in the <tt>bar</tt> package which would overwrite
3576             those already present in <tt>foo</tt>.  This is so that
3577             you can install an older version of a package without
3578             problems.
3579           </p>
3580
3581           <p>
3582             For this usage of <tt>Replaces</tt>, virtual packages (see
3583             <ref id="virtual">) are not considered when looking at a
3584             <tt>Replaces</tt> field - the packages declared as being
3585             replaced must be mentioned by their real names.
3586           </p>
3587
3588           <p>
3589             Furthermore, this usage of <tt>Replaces</tt> only takes
3590             effect when both packages are at least partially on the
3591             system at once, so that it can only happen if they do not
3592             conflict or if the conflict has been overridden.
3593           </p>
3594
3595         </sect1>
3596
3597         <sect1><heading>Replacing whole packages, forcing their
3598             removal</heading>
3599
3600           <p>
3601             Secondly, <tt>Replaces</tt> allows the packaging system to
3602             resolve which package should be removed when there is a
3603             conflict - see <ref id="conflicts">.  This usage only
3604             takes effect when the two packages <em>do</em> conflict,
3605             so that the two usages of this field do not interfere with
3606             each other.
3607           </p>
3608
3609           <p>
3610             In this situation, the package declared as being replaced
3611             can be a virtual package, so for example, all mail
3612             transport agents (MTAs) would have the following fields in
3613             their control files:
3614             <example compact="compact">
3615 Provides: mail-transport-agent
3616 Conflicts: mail-transport-agent
3617 Replaces: mail-transport-agent
3618             </example>
3619             ensuring that only one MTA can be installed at any one
3620             time.
3621         </sect1>
3622       </sect>
3623
3624       <sect><heading>Relationships between source and binary packages -
3625           <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3626           <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3627         </heading>
3628
3629         <p>
3630           Source packages that require certain binary packages to be
3631           installed or absent at the time of building the package
3632           can declare relationships to those binary packages.
3633         </p>
3634   
3635         <p>
3636           This is done using the <tt>Build-Depends</tt>,
3637           <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3638           <tt>Build-Conflicts-Indep</tt> control file fields.
3639         </p>
3640
3641         <p>
3642           Build-dependencies on "build-essential" binary packages can be
3643           omitted. Please see <ref id="pkg-relations"> for more information.
3644         </p>
3645
3646         <p>
3647           The dependencies and conflicts they define must be satisfied
3648           (as defined earlier for binary packages) in order to invoke
3649           the targets in <tt>debian/rules</tt>, as follows:<footnote>
3650             <p>
3651               If you make "build-arch" or "binary-arch", you need
3652               Build-Depends.  If you make "build-indep" or
3653               "binary-indep", you need Build-Depends and
3654               Build-Depends-Indep.  If you make "build" or "binary",
3655               you need both.
3656             </p>
3657             <p>
3658               There is no Build-Depends-Arch; the autobuilders will
3659               only need the Build-Depends if they know how to build
3660               only build-arch and binary-arch.  Anyone building the
3661               build-indep/binary-indep targets is basically assumed to
3662               be building the whole package and so installs all build
3663               dependencies.
3664             </p>
3665             <p>
3666               The purpose of the original split, I recall, was so that
3667               the autobuilders wouldn't need to install extra packages
3668               needed only for the binary-indep targets.  But without a
3669               build-arch/build-indep split, this didn't work, since
3670               most of the work is done in the build target, not in the
3671               binary target.
3672             </p>
3673           </footnote>
3674
3675           <taglist>
3676             <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3677             <item>
3678               <p>
3679                 The <tt>Build-Depends</tt> and
3680                 <tt>Build-Conflicts</tt> fields must be satisfied when
3681                 any of the following targets is invoked:
3682                 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
3683                 <tt>binary-arch</tt>, <tt>build-arch</tt>,
3684                 <tt>build-indep</tt> and <tt>binary-indep</tt>.
3685               </p>
3686             </item>
3687             <tag><tt>Build-Depends-Indep</tt>,
3688               <tt>Build-Conflicts-Indep</tt></tag>
3689             <item>
3690               <p>
3691                 The <tt>Build-Depends-Indep</tt> and
3692                 <tt>Build-Conflicts-Indep</tt> fields must be
3693                 satisfied when any of the following targets is
3694                 invoked: <tt>build</tt>, <tt>clean</tt>,
3695                 <tt>build-indep</tt>, <tt>binary</tt> and
3696                 <tt>binary-indep</tt>.
3697               </p>
3698             </item>
3699           </taglist>
3700
3701         </p>
3702
3703       </sect>
3704     </chapt>
3705
3706
3707     <chapt id="conffiles"><heading>Configuration file handling
3708       </heading>
3709
3710       <p>
3711         This chapter has been superseded by <ref id="config-files">.
3712       </p>
3713
3714
3715     <chapt id="sharedlibs"><heading>Shared libraries</heading>
3716
3717       <p>
3718         Packages containing shared libraries must be constructed with
3719         a little care to make sure that the shared library is always
3720         available.  This is especially important for packages whose
3721         shared libraries are vitally important, such as the C library
3722         (currently <tt>libc6</tt>).
3723       </p>
3724
3725       <p>
3726         Packages involving shared libraries should be split up into
3727         several binary packages. This section mostly deals with how
3728         this separation is to be accomplished; rules for files within
3729         the shared library packages are in <ref id="libraries"> instead.
3730       </p>
3731
3732       <sect id="sharedlibs-runtime">
3733         <heading>Run-time shared libraries</heading>
3734
3735       <p>
3736         The run-time shared library needs to be placed in a package called
3737         <package><var>libraryname</var><var>soversion</var></package>, where
3738         <file><var>soversion</var></file> is the version number in the
3739         soname of the shared library<footnote>
3740             <p>
3741               The soname is the shared object name: it's the thing
3742               that has to match exactly between building an executable
3743               and running it for the dynamic linker to be able run the
3744               program.  For example, if the soname of the library is
3745               <file>libfoo.so.6</file>, the library package would be
3746               called <file>libfoo6</file>.
3747             </p>
3748           </footnote>.
3749         Alternatively, if it would be confusing to directly append
3750         <var>soversion</var> to <var>libraryname</var> (e.g. because
3751         <var>libraryname</var> itself ends in a number), you may use
3752         <package><var>libraryname</var>-<var>soversion</var></package> and
3753         <package><var>libraryname</var>-<var>soversion</var>-dev</package>
3754         instead.
3755       </p>
3756
3757       <p>
3758         If you have several shared libraries built from the same
3759         source tree you may lump them all together into a single
3760         shared library package, provided that you change all of
3761         their sonames at once (so that you don't get filename
3762         clashes if you try to install different versions of the
3763         combined shared libraries package).
3764       </p>
3765
3766       <p>
3767         The package should install the shared libraries under
3768         their normal names.  For example, the <package>libgdbmg1</package>
3769         package should install <file>libgdbm.so.1.7.3</file> as
3770         <file>/usr/lib/libgdbm.so.1.7.3</file>.  The files should not be
3771         renamed or re-linked by any <prgn>prerm</prgn> or
3772         <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3773         of renaming things safely without affecting running programs,
3774         and attempts to interfere with this are likely to lead to
3775         problems.
3776       </p>
3777
3778       <p>
3779         Shared libraries should not be installed executable, since
3780         the dynamic linker does not require this and trying to
3781         execute a shared library usually results in a core dump.
3782       </p>
3783
3784       <p>
3785         The run-time library package should include the symbolic link that
3786         <prgn>ldconfig</prgn> would create for the shared libraries.
3787         For example, the <package>libgdbmg1</package> package should include
3788         a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3789         <file>libgdbm.so.1.7.3</file>.  This is needed so that the dynamic
3790         linker (for example <prgn>ld.so</prgn> or
3791         <prgn>ld-linux.so.*</prgn>) can find the library between the
3792         time that <prgn>dpkg</prgn> installs it and the time that
3793         <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3794         script.<footnote>
3795           <p>
3796             The package management system requires the library to be
3797             placed before the symbolic link pointing to it in the
3798             <file>.deb</file> file.  This is so that when
3799             <prgn>dpkg</prgn> comes to install the symlink
3800             (overwriting the previous symlink pointing at an older
3801             version of the library), the new shared library is already
3802             in place.  In the past, this was achieved by creating the
3803             library in the temporary packaging directory before
3804             creating the symlink.  Unfortunately, this was not always
3805             effective, since the building of the tar file in the
3806             <file>.deb</file> depended on the behavior of the underlying
3807             file system.  Some file systems (such as reiserfs) reorder
3808             the files so that the order of creation is forgotten.
3809             Since version 1.7.0, <prgn>dpkg</prgn>
3810             reorders the files itself as necessary when building a
3811             package.  Thus it is no longer important to concern
3812             oneself with the order of file creation.
3813           </p>
3814         </footnote>
3815       </p>
3816
3817       <sect1 id="ldconfig">
3818         <heading><tt>ldconfig</tt></heading>
3819
3820       <p>
3821         Any package installing shared libraries in one of the default
3822         library directories of the dynamic linker (which are currently
3823         <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3824         listed in <file>/etc/ld.so.conf</file><footnote>
3825           <p>
3826             These are currently
3827             <list compact="compact">
3828               <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3829               <item><p>/usr/local/lib</p></item>
3830               <item><p>/usr/lib/libc5-compat</p></item>
3831               <item><p>/lib/libc5-compat</p></item>
3832               <item><p>/usr/X11R6/lib</p></item>
3833             </list>
3834           </p>
3835         </footnote>
3836         must use <prgn>ldconfig</prgn> to update the shared library
3837         system.
3838       </p>
3839
3840       <p>
3841         The package must call <prgn>ldconfig</prgn> in the
3842         <prgn>postinst</prgn> script if the first argument is
3843         <tt>configure</tt>; the <prgn>postinst</prgn> script may
3844         optionally invoke <prgn>ldconfig</prgn> at other times.  The
3845         package should call <prgn>ldconfig</prgn> in the
3846         <prgn>postrm</prgn> script if the first argument is
3847         <tt>remove</tt>.  The maintainer scripts must not invoke
3848         <prgn>ldconfig</prgn> under any circumstances other than those
3849         described in this paragraph.<footnote>
3850           <p>During install or upgrade, the preinst is called before
3851             the new files are installed, so calling "ldconfig" is
3852             pointless.  The preinst of an existing package can also be
3853             called if an upgrade fails.  However, this happens during
3854             the critical time when a shared libs may exist on-disk
3855             under a temporary name.  Thus, it is dangerous and
3856             forbidden by current policy to call "ldconfig" at this
3857             time.
3858           </p>
3859           <p>When a package is installed or upgraded, "postinst
3860             configure" runs after the new files are safely on-disk.
3861             Since it is perfectly safe to invoke ldconfig
3862             unconditionally in a postinst, it is OK for a package to
3863             simply put ldconfig in its postinst without checking the
3864             argument.  The postinst can also be called to recover from
3865             a failed upgrade.  This happens before any new files are
3866             unpacked, so there is no reason to call "ldconfig" at this
3867             point.
3868           </p>
3869           <p>For a package that is being removed, prerm is
3870             called with all the files intact, so calling ldconfig is
3871             useless.  The other calls to "prerm" happen in the case of
3872             upgrade at a time when all the files of the old package
3873             are on-disk, so again calling "ldconfig" is pointless.
3874           </p>
3875           <p>postrm, on the other hand, is called with the "remove"
3876             argument just after the files are removed, so this is the
3877             proper time to call "ldconfig" to notify the system of the
3878             fact shared libraries from the package are removed.
3879             The postrm can be called at several other times.  At the
3880             time of "postrm purge", "postrm abort-install", or "postrm
3881             abort-upgrade", calling "ldconfig" is useless because the
3882             shared lib files are not on-disk.  However, when "postrm"
3883             is invoked with arguments "upgrade", "failed-upgrade", or
3884             "disappear", a shared lib may exist on-disk under a
3885             temporary filename.
3886           </p>
3887         </footnote>
3888       </p>
3889       </sect1>
3890
3891       </sect>
3892
3893       <sect id="sharedlibs-runtime-progs">
3894         <heading>Run-time support programs</heading>
3895
3896       <p>
3897         If your package has some run-time support programs which use
3898         the shared library you must not put them in the shared
3899         library package.  If you do that then you won't be able to
3900         install several versions of the shared library without
3901         getting filename clashes.
3902       </p>
3903
3904       <p>
3905         Instead, either create another package for the runtime binaries
3906         (this package might typically be named
3907         <package><var>libraryname</var>-runtime</package>; note the absence
3908         of the <var>soversion</var> in the package name), or if the
3909         development package is small, include them in there.
3910       </p>
3911       </sect>
3912
3913       <sect id="sharedlibs-static">
3914         <heading>Static libraries</heading>
3915
3916       <p>
3917         The static library (<file><var>libraryname.a</var></file>)
3918         is usually provided in addition to the shared version.
3919         It is placed into the development package (see below).
3920       </p>
3921
3922       <p>
3923         In some cases, it is acceptable for a library to be
3924         available in static form only; these cases include:
3925         <list>
3926           <item>libraries for languages whose shared library support
3927                 is immature or unstable</item>
3928           <item>libraries whose interfaces are in flux or under
3929                 development (commonly the case when the library's
3930                 major version number is zero, or where the ABI breaks
3931                 across patchlevels)</item>
3932           <item>libraries which are explicitly intended to be
3933                 available only in static form by their upstream
3934                 author(s)</item>
3935         </list>
3936       </p>
3937
3938       <sect id="sharedlibs-dev">
3939         <heading>Development files</heading>
3940
3941       <p>
3942         The development files associated to a shared library need to be
3943         placed in a package called
3944         <package><var>libraryname</var><var>soversion</var>-dev</package>,
3945         or if you prefer only to support one development version at a
3946         time, <package><var>libraryname</var>-dev</package>.
3947       </p>
3948
3949       <p>
3950         In case several development versions of a library exist, you may
3951         need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
3952         <ref id="conflicts">) to ensure that the user only installs one
3953         development version at a time (as different development versions are
3954         likely to have the same header files in them, which would cause a
3955         filename clash if both were installed).
3956       </p>
3957
3958       <p>
3959         The development package should contain a symlink for the associated
3960         shared library without a version number. For example, the
3961         <package>libgdbmg1-dev</package> package should include a symlink
3962         from <file>/usr/lib/libgdbm.so</file> to
3963         <file>libgdbm.so.1.7.3</file>.  This symlink is needed by the linker
3964         (<prgn>ld</prgn>) when compiling packages, as it will only look for
3965         <file>libgdbm.so</file> when compiling dynamically.
3966       </p>
3967       </sect>
3968
3969       <sect id="sharedlibs-intradeps">
3970         <heading>Dependencies between the packages of the same library</heading>
3971
3972         <p>
3973           Typically the development version should have an exact
3974           version dependency on the runtime library, to make sure that
3975           compilation and linking happens correctly.  The
3976           <tt>${Source-Version}</tt> substitution variable can be
3977           useful for this purpose.
3978         </p>
3979       </sect>
3980
3981       <sect id="sharedlibs-shlibdeps">
3982         <heading>Dependencies between the library and other packages -
3983         the <tt>shlibs</tt> system</heading>
3984
3985         <p>
3986           If a package contains a binary or library which links to a
3987           shared library, we must ensure that when the package is
3988           installed on the system, all of the libraries needed are
3989           also installed.  This requirement led to the creation of the
3990           <tt>shlibs</tt> system, which is very simple in its design:
3991           any package which <em>provides</em> a shared library also
3992           provides information on the package dependencies required to
3993           ensure the presence of this library, and any package which
3994           <em>uses</em> a shared library uses this information to
3995           determine the dependencies it requires.  The files which
3996           contain the mapping from shared libraries to the necessary
3997           dependency information are called <file>shlibs</file> files.
3998         </p>
3999
4000         <p>
4001           Thus, when a package is built which contains any shared
4002           libraries, it must provide a <file>shlibs</file> file for other
4003           packages to use, and when a package is built which contains
4004           any shared libraries or compiled binaries, it must run
4005           <prgn>dpkg-shlibdeps</prgn> on these to determine the
4006           libraries used and hence the dependencies needed by this
4007           package.<footnote>
4008             <p>
4009               In the past, the shared libraries linked to were
4010               determined by calling <prgn>ldd</prgn>, but now
4011               <prgn>objdump</prgn> is used to do this.  The only
4012               change this makes to package building is that
4013               <prgn>dpkg-shlibdeps</prgn> must also be run on shared
4014               libraries, whereas in the past this was unnecessary.
4015               The rest of this footnote explains the advantage that
4016               this method gives.
4017             </p>
4018
4019             <p>
4020               We say that a binary <tt>foo</tt> <em>directly</em> uses
4021               a library <tt>libbar</tt> if it is explicitly linked
4022               with that library (that is, it uses the flag
4023               <tt>-lbar</tt> during the linking stage).  Other
4024               libraries that are needed by <tt>libbar</tt> are linked
4025               <em>indirectly</em> to <tt>foo</tt>, and the dynamic
4026               linker will load them automatically when it loads
4027               <tt>libbar</tt>.  A package should depend on
4028               the libraries it directly uses, and the dependencies for
4029               those libraries should automatically pull in the other
4030               libraries.
4031             </p>
4032
4033             <p>
4034               Unfortunately, the <prgn>ldd</prgn> program shows both
4035               the directly and indirectly used libraries, meaning that
4036               the dependencies determined included both direct and
4037               indirect dependencies.  The use of <prgn>objdump</prgn>
4038               avoids this problem by determining only the directly
4039               used libraries.
4040             </p>
4041
4042             <p>
4043               A good example of where this helps is the following.  We
4044               could update <tt>libimlib</tt> with a new version that
4045               supports a new graphics format called dgf (but retaining
4046               the same major version number).  If we used the old
4047               <prgn>ldd</prgn> method, every package that uses
4048               <tt>libimlib</tt> would need to be recompiled so it
4049               would also depend on <tt>libdgf</tt> or it wouldn't run
4050               due to missing symbols.  However with the new system,
4051               packages using <tt>libimlib</tt> can rely on
4052               <tt>libimlib</tt> itself having the dependency on
4053               <tt>libdgf</tt> and so they would not need rebuilding.
4054             </p>
4055           </footnote>
4056         </p>
4057
4058         <p>
4059           In the following sections, we will first describe where the
4060           various <tt>shlibs</tt> files are to be found, then how to
4061           use <prgn>dpkg-shlibdeps</prgn>, and finally the
4062           <tt>shlibs</tt> file format and how to create them if your
4063           package contains a shared library.
4064         </p>
4065
4066       <sect1>
4067         <heading>The <tt>shlibs</tt> files present on the system</heading>
4068
4069         <p>
4070           There are several places where <tt>shlibs</tt> files are
4071           found.  The following list gives them in the order in which
4072           they are read by <prgn>dpkg-shlibdeps</prgn>.  (The first
4073           one which gives the required information is used.)
4074         </p>
4075
4076         <p>
4077           <list>
4078             <item>
4079               <p><file>debian/shlibs.local</file></p>
4080               <p>
4081                 This lists overrides for this package.  Its use is
4082                 described below (see <ref id="shlibslocal">).
4083               </p>
4084             </item>
4085
4086             <item>
4087               <p><file>/etc/dpkg/shlibs.override</file></p>
4088               <p>
4089                 This lists global overrides.  This list is normally
4090                 empty.  It is maintained by the local system
4091                 administrator.
4092               </p>
4093             </item>
4094
4095             <item>
4096               <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
4097               <p>
4098                 When packages are being built, any
4099                 <file>debian/shlibs</file> files are copied into the
4100                 control file area of the temporary build directory and
4101                 given the name <file>shlibs</file>.  These files give
4102                 details of any shared libraries included in the
4103                 package.<footnote>
4104                   <p>
4105                     An example may help here.  Let us say that the
4106                     source package <tt>foo</tt> generates two binary
4107                     packages, <tt>libfoo2</tt> and
4108                     <tt>foo-runtime</tt>.  When building the binary
4109                     packages, the two packages are created in the
4110                     directories <file>debian/libfoo2</file> and
4111                     <file>debian/foo-runtime</file> respectively.
4112                     (<file>debian/tmp</file> could be used instead of one
4113                     of these.)  Since <tt>libfoo2</tt> provides the
4114                     <tt>libfoo</tt> shared library, it will require a
4115                     <tt>shlibs</tt> file, which will be installed in
4116                     <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
4117                     to become
4118                     <file>/var/lib/dpkg/info/libfoo2.shlibs</file>.  Then
4119                     when <prgn>dpkg-shlibdeps</prgn> is run on the
4120                     executable
4121                     <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
4122                     will examine the
4123                     <file>debian/libfoo2/DEBIAN/shlibs</file> file to
4124                     determine whether <tt>foo-prog</tt>'s library
4125                     dependencies are satisfied by any of the libraries
4126                     provided by <tt>libfoo2</tt>.  For this reason,
4127                     <prgn>dpkg-shlibdeps</prgn> must only be run once
4128                     all of the individual binary packages'
4129                     <tt>shlibs</tt> files have been installed into the
4130                     build directory.
4131                   </p>
4132                 </footnote>
4133               </p>
4134             </item>
4135
4136             <item>
4137               <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
4138               <p>
4139                 These are the <file>shlibs</file> files corresponding to
4140                 all of the packages installed on the system, and are
4141                 maintained by the relevant package maintainers.
4142               </p>
4143             </item>
4144
4145             <item>
4146               <p><file>/etc/dpkg/shlibs.default</file></p>
4147               <p>
4148                 This file lists any shared libraries whose packages
4149                 have failed to provide correct <file>shlibs</file> files.
4150                 It was used when the <file>shlibs</file> setup was first
4151                 introduced, but it is now normally empty.  It is
4152                 maintained by the <tt>dpkg</tt> maintainer.
4153               </p>
4154             </item>
4155           </list>
4156         </p>
4157       </sect1>
4158
4159       <sect1>
4160         <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4161             <file>shlibs</file> files</heading>
4162
4163         <p>
4164           Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4165           <file>debian/rules</file> file.  If your package contains only
4166           compiled binaries and libraries (but no scripts), you can
4167           use a command such as:
4168           <example compact="compact">
4169 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4170   debian/tmp/usr/lib/*
4171           </example>
4172           Otherwise, you will need to explicitly list the compiled
4173           binaries and libraries.<footnote>
4174             <p>
4175               If you are using <tt>debhelper</tt>, the
4176               <prgn>dh_shlibdeps</prgn> program will do this work for
4177               you.  It will also correctly handle multi-binary
4178               packages.
4179             </p>
4180           </footnote>
4181         </p>
4182
4183         <p>
4184           This command puts the dependency information into the
4185           <file>debian/substvars</file> file, which is then used by
4186           <prgn>dpkg-gencontrol</prgn>.  You will need to place a
4187           <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4188           field in the control file for this to work.
4189         </p>
4190
4191         <p>
4192           If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4193           done.  If it does complain you might need to create your own
4194           <file>debian/shlibs.local</file> file, as explained below (see
4195           <ref id="shlibslocal">).
4196         </p>
4197
4198         <p>
4199           If you have multiple binary packages, you will need to call
4200           <prgn>dpkg-shlibdeps</prgn> on each one which contains
4201           compiled libraries or binaries.  In such a case, you will
4202           need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4203           utilities to specify a different <file>substvars</file> file.
4204           For more details on this and other options, see <manref
4205           name="dpkg-shlibdeps" section="1">.
4206         </p>
4207       </sect1>
4208
4209       <sect1 id="shlibs">
4210         <heading>The <file>shlibs</file> File Format</heading>
4211
4212         <p>
4213           Each <file>shlibs</file> file has the same format.  Lines
4214           beginning with <tt>#</tt> are considered to be comments and
4215           are ignored.  Each line is of the form:
4216           <example compact="compact">
4217 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4218           </example>
4219         </p>
4220
4221         <p>
4222           We will explain this by reference to the example of the
4223           <tt>zlib1g</tt> package, which (at the time of writing)
4224           installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4225         </p>
4226
4227         <p>
4228           <var>library-name</var> is the name of the shared library,
4229           in this case <tt>libz</tt>.  (This must match the name part
4230           of the soname, see below.)
4231         </p>
4232
4233         <p>
4234           <var>soname-version-number</var> is the version part of the
4235           soname of the library.  The soname is the thing that must
4236           exactly match for the library to be recognized by the
4237           dynamic linker, and is usually of the form
4238           <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4239           example, <tt>libz.so.1</tt>.<footnote>
4240             <p>
4241               This can be determined using the command
4242               <example compact="compact">
4243 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4244               </example>
4245             </p>
4246           </footnote>
4247           The version part is the part which comes after
4248           <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4249         </p>
4250
4251         <p>
4252           <var>dependencies</var> has the same syntax as a dependency
4253           field in a binary package control file.  It should give
4254           details of which packages are required to satisfy a binary
4255           built against the version of the library contained in the
4256           package.  See <ref id="depsyntax"> for details.
4257         </p>
4258
4259         <p>
4260           In our example, if the first version of the <tt>zlib1g</tt>
4261           package which contained a minor number of at least
4262           <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4263           <tt>shlibs</tt> entry for this library could say:
4264           <example compact="compact">
4265 libz 1 zlib1g (>= 1:1.1.3)
4266           </example>
4267           The version-specific dependency is to avoid warnings from
4268           the dynamic linker about using older shared libraries with
4269           newer binaries.
4270         </p>
4271       </sect1>
4272
4273       <sect1>
4274         <heading>Providing a <file>shlibs</file> file</heading>
4275
4276         <p>
4277           If your package provides a shared library, you should create
4278           a <file>shlibs</file> file following the format described above.
4279           It is usual to call this file <file>debian/shlibs</file> (but if
4280           you have multiple binary packages, you might want to call it
4281           <file>debian/shlibs.<var>package</var></file> instead).  Then
4282           let <file>debian/rules</file> install it in the control area:
4283           <example compact="compact">
4284 install -m644 debian/shlibs debian/tmp/DEBIAN
4285           </example>
4286           or, in the case of a multi-binary package:
4287           <example compact="compact">
4288 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4289           </example>
4290           An alternative way of doing this is to create the
4291           <file>shlibs</file> file in the control area directly from
4292           <file>debian/rules</file> without using a <file>debian/shlibs</file>
4293           file at all,<footnote>
4294             <p>
4295               This is what <prgn>dh_makeshlibs</prgn> in the
4296               <tt>debhelper</tt> suite does.
4297             </p>
4298           </footnote>
4299           since the <file>debian/shlibs</file> file itself is ignored by
4300           <prgn>dpkg-shlibdeps</prgn>.
4301         </p>
4302
4303         <p>
4304           As <prgn>dpkg-shlibdeps</prgn> reads the
4305           <file>DEBIAN/shlibs</file> files in all of the binary packages
4306           being built from this source package, all of the
4307           <file>DEBIAN/shlibs</file> files should be installed before
4308           <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4309           packages.
4310         </p>
4311       </sect1>
4312
4313       <sect1 id="shlibslocal">
4314         <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4315
4316         <p>
4317           This file is intended only as a <em>temporary</em> fix if
4318           your binaries or libraries depend on a library whose package
4319           does not yet provide a correct <file>shlibs</file> file.
4320         </p>
4321
4322         <p>
4323           We will assume that you are trying to package a binary
4324           <tt>foo</tt>.  When you try running
4325           <prgn>dpkg-shlibdeps</prgn> you get the following error
4326           message (<tt>-O</tt> displays the dependency information on
4327           <tt>stdout</tt> instead of writing it to
4328           <tt>debian/substvars</tt>, and the lines have been wrapped
4329           for ease of reading):
4330           <example compact="compact">
4331 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4332 dpkg-shlibdeps: warning: unable to find dependency
4333   information for shared library libbar (soname 1,
4334   path /usr/lib/libbar.so.1, dependency field Depends)
4335 shlibs:Depends=libc6 (>= 2.2.2-2)
4336           </example>
4337           You can then run <prgn>ldd</prgn> on the binary to find the
4338           full location of the library concerned:
4339           <example compact="compact">
4340 $ ldd foo
4341 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4342 libc.so.6 => /lib/libc.so.6 (0x40032000)
4343 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4344           </example>
4345           So the <prgn>foo</prgn> binary depends on the
4346           <prgn>libbar</prgn> shared library, but no package seems to
4347           provide a <file>*.shlibs</file> file handling
4348           <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>.  Let's
4349           determine the package responsible:
4350           <example compact="compact">
4351 $ dpkg -S /usr/lib/libbar.so.1
4352 bar1: /usr/lib/libbar.so.1
4353 $ dpkg -s bar1 | grep Version
4354 Version: 1.0-1
4355           </example>
4356           This tells us that the <tt>bar1</tt> package, version 1.0-1,
4357           is the one we are using.  Now we can file a bug against the
4358           <tt>bar1</tt> package and create our own
4359           <file>debian/shlibs.local</file> to locally fix the problem.
4360           Including the following line into your
4361           <file>debian/shlibs.local</file> file:
4362           <example compact="compact">
4363 libbar 1 bar1 (>= 1.0-1)
4364           </example>
4365           should allow the package build to work.
4366         </p>
4367
4368         <p>
4369           As soon as the maintainer of <tt>bar1</tt> provides a
4370           correct <file>shlibs</file> file, you should remove this line
4371           from your <file>debian/shlibs.local</file> file.  (You should
4372           probably also then have a versioned <tt>Build-Depends</tt>
4373           on <tt>bar1</tt> to help ensure that others do not have the
4374           same problem building your package.)
4375         </p>
4376       </sect1>
4377
4378       </sect>
4379
4380     </chapt>
4381
4382     <chapt id="opersys"><heading>The Operating System</heading>
4383
4384       <sect>
4385         <heading>Filesystem hierarchy</heading>
4386
4387
4388         <sect1>
4389           <heading>Filesystem Structure</heading>
4390
4391           <p>
4392             The location of all installed files and directories must
4393             comply with the Filesystem Hierarchy Standard (FHS),
4394             version 2.1, except where doing so would violate other
4395             terms of Debian Policy. The version of this document
4396             referred here can be found in the <tt>debian-policy</tt>
4397             package or on
4398             <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4399               name="FHS (Debian copy)"> alongside this manual (or, if
4400             you have the <package>debian-policy</package> installed,
4401             you can try <url
4402               id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4403               (local copy)">). The
4404             latest version, which may be a more recent version, may
4405             be found on
4406             <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4407             Specific questions about following the standard may be
4408             asked on the <tt>debian-devel</tt> mailing list, or
4409             referred to the FHS mailing list (see the
4410             <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4411             more information).
4412           </p>
4413         </sect1>
4414
4415         <sect1>
4416           <heading>Site-specific programs</heading>
4417
4418           <p>
4419             As mandated by the FHS, packages must not place any
4420             files in <file>/usr/local</file>, either by putting them in
4421             the file system archive to be unpacked by <prgn>dpkg</prgn>
4422             or by manipulating them in their maintainer scripts.
4423           </p>
4424
4425           <p>
4426             However, the package may create empty directories below
4427             <file>/usr/local</file> so that the system administrator knows
4428             where to place site-specific files.  These directories
4429             should be removed on package removal if they are
4430             empty.
4431           </p>
4432
4433           <p>
4434             Note, that this applies only to directories <em>below</em>
4435             <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4436             Packages must not create sub-directories in the directory
4437             <file>/usr/local</file> itself, except those listed in FHS,
4438             section 4.5.  However, you may create directories below
4439             them as you wish. You must not remove any of the
4440             directories listed in 4.5, even if you created them.
4441           </p>
4442
4443           <p>
4444             Since <file>/usr/local</file> can be mounted read-only from a
4445             remote server, these directories must be created and
4446             removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4447             maintainer scripts and not be included in the
4448             <file>.deb</file> archive.  These scripts must not fail if
4449             either of these operations fail.
4450           </p>
4451
4452           <p>
4453             For example, the <tt>emacsen-common</tt> package could
4454             contain something like
4455             <example compact="compact">
4456 if [ ! -e /usr/local/share/emacs ]
4457 then
4458   if mkdir /usr/local/share/emacs 2>/dev/null
4459   then
4460     chown root:staff /usr/local/share/emacs
4461     chmod 2775 /usr/local/share/emacs
4462   fi
4463 fi
4464             </example>
4465             in its <prgn>postinst</prgn> script, and
4466             <example compact="compact">
4467 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4468 rmdir /usr/local/share/emacs 2>/dev/null || true
4469             </example>
4470             in the <prgn>prerm</prgn> script.  (Note that this form is
4471             used to ensure that if the script is interrupted, the
4472             directory <file>/usr/local/share/emacs</file> will still be
4473             removed.)
4474           </p>
4475
4476           <p>
4477             If you do create a directory in <file>/usr/local</file> for
4478             local additions to a package, you should ensure that
4479             settings in <file>/usr/local</file> take precedence over the
4480             equivalents in <file>/usr</file>.
4481           </p>
4482
4483           <p>
4484             However, because <file>/usr/local</file> and its contents are
4485             for exclusive use of the local administrator, a package
4486             must not rely on the presence or absence of files or
4487             directories in <file>/usr/local</file> for normal operation.
4488           </p>
4489
4490           <p>
4491             The <file>/usr/local</file> directory itself and all the
4492             subdirectories created by the package should (by default) have
4493             permissions 2775 (group-writable and set-group-id) and be
4494             owned by <tt>root.staff</tt>.
4495           </p>
4496         </sect1>
4497
4498         <sect1>
4499           <heading>The system-wide mail directory</heading>
4500           <p>
4501             The system-wide mail directory is <file>/var/mail</file>. This
4502             directory is part of the base system and should not owned
4503             by any particular mail agents.  The use of the old
4504             location <file>/var/spool/mail</file> is deprecated, even
4505             though the spool may still be physically located there.
4506             To maintain partial upgrade compatibility for systems
4507             which have <file>/var/spool/mail</file> as their physical mail
4508             spool, packages using <file>/var/mail</file> must depend on
4509             either <package>libc6</package> (&gt;= 2.1.3-13), or on
4510             <package>base-files</package> (&gt;= 2.2.0), or on later
4511             versions of either one of these packages.
4512           </p>
4513         </sect1>
4514       </sect>
4515
4516       <sect>
4517         <heading>Users and groups</heading>
4518
4519         <sect1>
4520           <heading>Introduction</heading>
4521           <p>
4522             The Debian system can be configured to use either plain or
4523             shadow passwords.
4524           </p>
4525
4526           <p>
4527             Some user ids (UIDs) and group ids (GIDs) are reserved
4528             globally for use by certain packages.  Because some
4529             packages need to include files which are owned by these
4530             users or groups, or need the ids compiled into binaries,
4531             these ids must be used on any Debian system only for the
4532             purpose for which they are allocated. This is a serious
4533             restriction, and we should avoid getting in the way of
4534             local administration policies. In particular, many sites
4535             allocate users and/or local system groups starting at 100.
4536           </p>
4537
4538           <p>
4539             Apart from this we should have dynamically allocated ids,
4540             which should by default be arranged in some sensible
4541             order, but the behavior should be configurable.
4542           </p>
4543
4544           <p>
4545             Packages other than <tt>base-passwd</tt> must not modify
4546             <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4547             <file>/etc/group</file> or <file>/etc/gshadow</file>.
4548           </p>
4549         </sect1>
4550
4551         <sect1>
4552           <heading>UID and GID classes</heading>
4553           <p>
4554             The UID and GID numbers are divided into classes as
4555             follows:
4556             <taglist>
4557               <tag>0-99:</tag>
4558               <item>
4559                 <p>
4560                   Globally allocated by the Debian project, the same
4561                   on every Debian system.  These ids will appear in
4562                   the <file>passwd</file> and <file>group</file> files of all
4563                   Debian systems, new ids in this range being added
4564                   automatically as the <tt>base-passwd</tt> package is
4565                   updated.
4566                 </p>
4567
4568                 <p>
4569                   Packages which need a single statically allocated
4570                   uid or gid should use one of these; their
4571                   maintainers should ask the <tt>base-passwd</tt>
4572                   maintainer for ids.
4573                 </p>
4574               </item>
4575
4576               <tag>100-999:</tag>
4577               <item>
4578                 <p>
4579                   Dynamically allocated system users and groups.
4580                   Packages which need a user or group, but can have
4581                   this user or group allocated dynamically and
4582                   differently on each system, should use <tt>adduser
4583                   --system</tt> to create the group and/or user.
4584                   <prgn>adduser</prgn> will check for the existence of
4585                   the user or group, and if necessary choose an unused
4586                   id based on the ranges specified in
4587                   <file>adduser.conf</file>.
4588                 </p>
4589               </item>
4590
4591               <tag>1000-29999:</tag>
4592               <item>
4593                 <p>
4594                   Dynamically allocated user accounts.  By default
4595                   <prgn>adduser</prgn> will choose UIDs and GIDs for
4596                   user accounts in this range, though
4597                   <file>adduser.conf</file> may be used to modify this
4598                   behavior.
4599                 </p>
4600               </item>
4601
4602               <tag>30000-59999:</tag>
4603               <item>
4604                 <p>Reserved.</p>
4605               </item>
4606
4607               <tag>60000-64999:</tag>
4608               <item>
4609                 <p>
4610                   Globally allocated by the Debian project, but only
4611                   created on demand. The ids are allocated centrally
4612                   and statically, but the actual accounts are only
4613                   created on users' systems on demand.
4614                 </p>
4615
4616                 <p>
4617                   These ids are for packages which are obscure or
4618                   which require many statically-allocated ids.  These
4619                   packages should check for and create the accounts in
4620                   <file>/etc/passwd</file> or <file>/etc/group</file> (using
4621                   <prgn>adduser</prgn> if it has this facility) if
4622                   necessary.  Packages which are likely to require
4623                   further allocations should have a "hole" left after
4624                   them in the allocation, to give them room to
4625                   grow.
4626                 </p>
4627               </item>
4628
4629               <tag>65000-65533:</tag>
4630               <item>
4631                 <p>Reserved.</p>
4632               </item>
4633
4634               <tag>65534:</tag>
4635               <item>
4636                 <p>
4637                   User <tt>nobody</tt>. The corresponding gid refers
4638                   to the group <tt>nogroup</tt>.
4639                 </p>
4640               </item>
4641
4642               <tag>65535:</tag>
4643               <item>
4644                 <p>
4645                   <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4646                   not</em> be used, because it is the error return
4647                   sentinel value.
4648                 </p>
4649               </item>
4650             </taglist>
4651           </p>
4652         </sect1>
4653       </sect>
4654
4655       <sect id="sysvinit">
4656         <heading>System run levels and <file>init.d</file> scripts</heading>
4657
4658         <sect1 id="/etc/init.d">
4659           <heading>Introduction</heading>
4660
4661           <p>
4662             The <file>/etc/init.d</file> directory contains the scripts
4663             executed by <prgn>init</prgn> at boot time and when the
4664             init state (or "runlevel") is changed (see <manref
4665             name="init" section="8">).
4666           </p>
4667
4668           <p>
4669             There are at least two different, yet functionally
4670             equivalent, ways of handling these scripts.  For the sake
4671             of simplicity, this document describes only the symbolic
4672             link method. However, it must not be assumed by maintainer
4673             scripts that this method is being used, and any automated
4674             manipulation of the various runlevel behaviours by
4675             maintainer scripts must be performed using
4676             <prgn>update-rc.d</prgn> as described below and not by
4677             manually installing or removing symlinks.  For information
4678             on the implementation details of the other method,
4679             implemented in the <tt>file-rc</tt> package, please refer
4680             to the documentation of that package.
4681           </p>
4682
4683           <p>
4684             These scripts are referenced by symbolic links in the
4685             <file>/etc/rc<var>n</var>.d</file> directories.  When changing
4686             runlevels, <prgn>init</prgn> looks in the directory
4687             <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4688             execute, where <tt><var>n</var></tt> is the runlevel that
4689             is being changed to, or <tt>S</tt> for the boot-up
4690             scripts.
4691           </p>
4692
4693           <p>
4694             The names of the links all have the form
4695             <file>S<var>mm</var><var>script</var></file> or
4696             <file>K<var>mm</var><var>script</var></file> where
4697             <var>mm</var> is a two-digit number and <var>script</var>
4698             is the name of the script (this should be the same as the
4699             name of the actual script in <file>/etc/init.d</file>).
4700           </p>
4701
4702           <p>
4703             When <prgn>init</prgn> changes runlevel first the targets
4704             of the links whose names start with a <tt>K</tt> are
4705             executed, each with the single argument <tt>stop</tt>,
4706             followed by the scripts prefixed with an <tt>S</tt>, each
4707             with the single argument <tt>start</tt>.  (The links are
4708             those in the <file>/etc/rc<var>n</var>.d</file> directory
4709             corresponding to the new runlevel.)  The <tt>K</tt> links
4710             are responsible for killing services and the <tt>S</tt>
4711             link for starting services upon entering the runlevel.
4712           </p>
4713
4714           <p>
4715             For example, if we are changing from runlevel 2 to
4716             runlevel 3, init will first execute all of the <tt>K</tt>
4717             prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4718             all of the <tt>S</tt> prefixed scripts in that directory.
4719             The links starting with <tt>K</tt> will cause the
4720             referred-to file to be executed with an argument of
4721             <tt>stop</tt>, and the <tt>S</tt> links with an argument
4722             of <tt>start</tt>.
4723           </p>
4724
4725           <p>
4726             The two-digit number <var>mm</var> is used to determine
4727             the order in which to run the scripts: low-numbered links
4728             have their scripts run first.  For example, the
4729             <tt>K20</tt> scripts will be executed before the
4730             <tt>K30</tt> scripts.  This is used when a certain service
4731             must be started before another.  For example, the name
4732             server <prgn>bind</prgn> might need to be started before
4733             the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4734             can set up its access lists.  In this case, the script
4735             that starts <prgn>bind</prgn> would have a lower number
4736             than the script that starts <prgn>inn</prgn> so that it
4737             runs first:
4738             <example compact="compact">
4739 /etc/rc2.d/S17bind
4740 /etc/rc2.d/S70inn
4741             </example>
4742           </p>
4743
4744           <p>
4745             The two runlevels 0 (halt) and 6 (reboot) are slightly
4746             different.  In these runlevels, the links with an
4747             <tt>S</tt> prefix are still called after those with a
4748             <tt>K</tt> prefix, but they too are called with the single
4749             argument <tt>stop</tt>.
4750           </p>
4751
4752           <p>
4753             Also, if the script name ends <tt>.sh</tt>, the script
4754             will be sourced in runlevel <tt>S</tt> rather that being
4755             run in a forked subprocess, but will be explicitly run by
4756             <prgn>sh</prgn> in all other runlevels.
4757           </p>
4758         </sect1>
4759
4760         <sect1>
4761           <heading>Writing the scripts</heading>
4762
4763           <p>
4764             Packages that include daemons for system services should
4765             place scripts in <file>/etc/init.d</file> to start or stop
4766             services at boot time or during a change of runlevel.
4767             These scripts should be named
4768             <file>/etc/init.d/<var>package</var></file>, and they should
4769             accept one argument, saying what to do:
4770
4771             <taglist>
4772               <tag><tt>start</tt></tag>
4773               <item><p>start the service,</p></item>
4774
4775               <tag><tt>stop</tt></tag>
4776               <item><p>stop the service,</p></item>
4777
4778               <tag><tt>restart</tt></tag>
4779               <item><p>stop and restart the service if it's already
4780                   running, otherwise start the service</p></item>
4781
4782               <tag><tt>reload</tt></tag>
4783               <item><p>cause the configuration of the service to be
4784                   reloaded without actually stopping and restarting
4785                   the service,</p></item>
4786
4787               <tag><tt>force-reload</tt></tag>
4788               <item><p>cause the configuration to be reloaded if the
4789                   service supports this, otherwise restart the
4790                   service.</p></item>
4791             </taglist>
4792
4793             The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4794             <tt>force-reload</tt> options should be supported by all
4795             scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4796             option is optional.</p>
4797
4798           <p>
4799             The <file>init.d</file> scripts should ensure that they will
4800             behave sensibly if invoked with <tt>start</tt> when the
4801             service is already running, or with <tt>stop</tt> when it
4802             isn't, and that they don't kill unfortunately-named user
4803             processes.  The best way to achieve this is usually to use
4804             <prgn>start-stop-daemon</prgn>.</p>
4805
4806           <p>
4807             If a service reloads its configuration automatically (as
4808             in the case of <prgn>cron</prgn>, for example), the
4809             <tt>reload</tt> option of the <file>init.d</file> script
4810             should behave as if the configuration has been reloaded
4811             successfully.</p>
4812
4813           <p>
4814             The <file>/etc/init.d</file> scripts must be treated as
4815             configuration files, either (if they are present in the
4816             package, that is, in the .deb file) by marking them as
4817             <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4818             by managing them correctly in the maintainer scripts (see
4819             <ref id="config-files">).  This is important since we want
4820             to give the local system administrator the chance to adapt
4821             the scripts to the local system, e.g., to disable a
4822             service without de-installing the package, or to specify
4823             some special command line options when starting a service,
4824             while making sure her changes aren't lost during the next
4825             package upgrade.
4826           </p>
4827
4828           <p>
4829             These scripts should not fail obscurely when the
4830             configuration files remain but the package has been
4831             removed, as configuration files remain on the system after
4832             the package has been removed.  Only when <prgn>dpkg</prgn>
4833             is executed with the <tt>--purge</tt> option will
4834             configuration files be removed.  In particular, as the
4835             <file>/etc/init.d/<var>package</var></file> script itself is
4836             usually a <tt>conffile</tt>, it will remain on the system
4837             if the package is removed but not purged.  Therefore, you
4838             should include a <tt>test</tt> statement at the top of the
4839             script, like this:
4840             <example compact="compact">
4841 test -f <var>program-executed-later-in-script</var> || exit 0
4842             </example>
4843           </p>
4844
4845           <p>
4846             Often there are some variables in the <file>init.d</file>
4847             scripts whose values control the behaviour of the scripts,
4848             and which a system administrator is likely to want to
4849             change.  As the scripts themselves are frequently
4850             <tt>conffile</tt>s, modifying them requires that the
4851             administrator merge in their changes each time the package
4852             is upgraded and the <tt>conffile</tt> changes.  To ease
4853             the burden on the system administrator, such configurable
4854             values should not be placed directly in the script.
4855             Instead, they should be placed in a file in
4856             <file>/etc/default</file>, which typically will have the same
4857             base name as the <file>init.d</file> script.  This extra file
4858             should be sourced by the script when the script runs.  It
4859             must contain only variable settings and comments in POSIX
4860             <prgn>sh</prgn> format.  It may either be a
4861             <tt>conffile</tt> or a configuration file maintained by
4862             the package maintainer scripts.  See <ref id="config-files">
4863             for more details.
4864           </p>
4865
4866           <p>
4867             To ensure that vital configurable values are always
4868             available, the <file>init.d</file> script should set default
4869             values for each of the shell variables it uses, either
4870             before sourcing the <file>/etc/default/</file> file or
4871             afterwards using something like the <tt>:
4872             ${VAR:=default}</tt> syntax.  Also, the <file>init.d</file>
4873             script must behave sensibly and not fail if the
4874             <file>/etc/default</file> file is deleted.
4875           </p>
4876         </sect1>
4877
4878         <sect1>
4879           <heading>Interfacing with the initscript system</heading>
4880
4881           <p>
4882             Maintainers should use the abstraction layer provided by
4883             the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4884             programs to deal with initscripts in their packages'
4885             scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4886             and <prgn>postrm</prgn>.
4887           </p>
4888           <p>
4889             Directly managing the /etc/rc?.d links and directly
4890             invoking the <file>/etc/init.d/</file> initscripts should
4891             be done only by packages providing the initscript
4892             subsystem (such as <prgn>sysvinit</prgn> and
4893             <prgn>file-rc</prgn>).
4894
4895           </p>
4896
4897           <sect2>
4898             <heading>Managing the links</heading>
4899
4900             <p>
4901               The program <prgn>update-rc.d</prgn> is provided for
4902               package maintainers to arrange for the proper creation and
4903               removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4904               or their functional equivalent if another method is being
4905               used.  This may be used by maintainers in their packages'
4906               <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4907
4908             <p>
4909               You must not include any <file>/etc/rc<var>n</var>.d</file>
4910               symbolic links in the actual archive or manually create or
4911               remove the symbolic links in maintainer scripts; you must
4912               use the <prgn>update-rc.d</prgn> program instead.  (The
4913               former will fail if an alternative method of maintaining
4914               runlevel information is being used.)  You must not include
4915               the <file>/etc/rc<var>n</var>.d</file> directories themselves
4916               in the archive either.  (Only the <tt>sysvinit</tt>
4917               package may do so.)
4918             </p>
4919
4920             <p>
4921               By default <prgn>update-rc.d</prgn> will start services in
4922               each of the multi-user state runlevels (2, 3, 4, and 5)
4923               and stop them in the halt runlevel (0), the single-user
4924               runlevel (1) and the reboot runlevel (6).  The system
4925               administrator will have the opportunity to customize
4926               runlevels by simply adding, moving, or removing the
4927               symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4928               symbolic links are being used, or by modifying
4929               <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4930               is being used.
4931             </p>
4932
4933             <p>
4934               To get the default behavior for your package, put in your
4935               <prgn>postinst</prgn> script
4936               <example compact="compact">
4937                 update-rc.d <var>package</var> defaults
4938               </example>
4939               and in your <prgn>postrm</prgn>
4940               <example compact="compact">
4941                 if [ "$1" = purge ]; then
4942                 update-rc.d <var>package</var> remove
4943                 fi
4944               </example>. Note that if your package changes runlevels
4945               or priority, you may have to remove and recreate the links,
4946               since otherwise the old links may persist. Refer to the
4947               documentation of <prgn>update-rc.d</prgn></p>
4948
4949             <p>
4950               This will use a default sequence number of 20.  If it does
4951               not matter when or in which order the <file>init.d</file>
4952               script is run, use this default.  If it does, then you
4953               should talk to the maintainer of the <prgn>sysvinit</prgn>
4954               package or post to <tt>debian-devel</tt>, and they will
4955               help you choose a number.
4956             </p>
4957
4958             <p>
4959               For more information about using <tt>update-rc.d</tt>,
4960               please consult its manpage <manref name="update-rc.d"
4961                 section="8">.
4962             </p>
4963           </sect2>
4964
4965           <sect2>
4966             <heading>Running initscripts</heading>
4967             <p>
4968               The program <prgn>invoke-rc.d</prgn> is provided to make
4969               it easier for package maintainers to properly invoke an
4970               initscript, obeying runlevel and other locally-defined
4971               constraints that might limit a package's right to start,
4972               stop and otherwise manage services. This program may be
4973               used by maintainers in their packages' scripts.
4974             </p>
4975             <p>
4976               The use of <prgn>invoke-rc.d</prgn> to invoke the
4977               <file>/etc/init.d/*</file> initscripts is strongly
4978               recommended<footnote>
4979                 <p>
4980                   In the future, the use of invoke-rc.d to invoke
4981                   initscripts shall be made mandatory. Maintainers are
4982                   advised to switch to invoke-rc.d as soon as
4983                   possible.</p>
4984               </footnote>, instead of calling them directly.
4985             </p>
4986
4987             <p>
4988               By default, <prgn>invoke-rc.d</prgn> will pass any
4989               action requests (start, stop, reload, restart...) to the
4990               <file>/etc/init.d</file> script, filtering out requests
4991               to start or restart a service out of its intended
4992               runlevels.
4993             </p>
4994             <p>
4995               Most packages will simply need to change:
4996               <example compact="compact">/etc/init.d/&lt;package&gt;
4997               &lt;action&gt;</example> in their <prgn>postinst</prgn>
4998               and <prgn>prerm</prgn> scripts to:
4999               <example compact="compact">
5000           if [ -x /usr/sbin/invoke-rc.d ] ; then
5001                 invoke-rc.d <var>package</var> &lt;action&gt;
5002           else
5003              /etc/init.d/<var>package</var> &lt;action&gt;
5004           fi
5005               </example></p>
5006             <p>
5007               A package should register its initscript services using
5008               <prgn>update-rc.d</prgn> before it tries to invoke them
5009               using <prgn>invoke-rc.d</prgn>. Invocation of
5010               unregistered services may fail.
5011             </p>
5012             <p>
5013               For more information about using
5014               <prgn>invoke-rc.d</prgn>, please consult its manpage
5015               <manref name="invoke-rc.d" section="8">.
5016             </p>
5017           </sect2>
5018         </sect1>
5019
5020
5021         <sect1>
5022           <heading>Boot-time initialization</heading>
5023
5024           <p>
5025             There used to be another directory, <file>/etc/rc.boot</file>,
5026             which contained scripts which were run once per machine
5027             boot. This has been deprecated in favour of links from
5028             <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
5029             described in <ref id="/etc/init.d">.  Packages must not
5030             place files in <file>/etc/rc.boot</file>.</p>
5031
5032         <sect1>
5033           <heading>Example</heading>
5034
5035           <p>
5036             The <prgn>bind</prgn> DNS (nameserver) package wants to
5037             make sure that the nameserver is running in multiuser
5038             runlevels, and is properly shut down with the system.  It
5039             puts a script in <file>/etc/init.d</file>, naming the script
5040             appropriately <tt>bind</tt>.  As you can see, the script
5041             interprets the argument <tt>reload</tt> to send the
5042             nameserver a <tt>HUP</tt> signal (causing it to reload its
5043             configuration); this way the system administrator can say
5044             <tt>/etc/init.d/bind reload</tt> to reload the name
5045             server.  The script has one configurable value, which can
5046             be used to pass parameters to the named program at
5047             startup; this value is read from
5048             <file>/etc/default/bind</file> (see below).
5049           </p>
5050
5051           <p>
5052             <example compact="compact">
5053 #!/bin/sh
5054 #
5055 # Original version by Robert Leslie
5056 # &lt;rob@mars.org&gt;, edited by iwj and cs
5057
5058 test -x /usr/sbin/named || exit 0
5059
5060 # Source defaults file.
5061 PARAMS=''
5062 if [ -f /etc/default/bind ]; then
5063   . /etc/default/bind
5064 fi
5065
5066
5067 case "$1" in
5068 start)
5069   echo -n "Starting domain name service: named"
5070   start-stop-daemon --start --quiet --exec /usr/sbin/named \
5071                     -- $PARAMS
5072   echo "."
5073   ;;
5074 stop)
5075   echo -n "Stopping domain name service: named"
5076   start-stop-daemon --stop --quiet  \
5077     --pidfile /var/run/named.pid --exec /usr/sbin/named
5078   echo "."
5079   ;;
5080 restart)
5081   echo -n "Restarting domain name service: named"
5082   start-stop-daemon --stop --quiet  \
5083     --pidfile /var/run/named.pid --exec /usr/sbin/named
5084   start-stop-daemon --start --verbose --exec /usr/sbin/named \
5085                     -- $PARAMS
5086   echo "."
5087   ;;
5088 force-reload|reload)
5089   echo -n "Reloading configuration of domain name service: named"
5090   start-stop-daemon --stop --signal 1 --quiet  \
5091     --pidfile /var/run/named.pid --exec /usr/sbin/named
5092   echo "."
5093   ;;
5094 *)
5095   echo "Usage: /etc/init.d/bind " \
5096          " {start|stop|restart|reload|force-reload}" >&2
5097   exit 1
5098   ;;
5099 esac
5100
5101 exit 0
5102             </example>
5103           </p>
5104
5105           <p>
5106             Complementing the above init script is a configuration
5107             file <file>/etc/default/bind</file>, which contains
5108             configurable parameters used by the script.  This would be
5109             created by the <prgn>postinst</prgn> script if it was not
5110             already present, and removed on purge by the
5111             <prgn>postrm</prgn> script.
5112             <example compact="compact">
5113 # Specified parameters to pass to named. See named(8).
5114 # You may uncomment the following line, and edit to taste.
5115 #PARAMS="-u nobody"
5116             </example>
5117           </p>
5118
5119           <p>
5120             Another example on which you can base your
5121             <file>/etc/init.d</file> scripts is found in
5122             <file>/etc/init.d/skeleton</file>.
5123           </p>
5124
5125           <p>
5126             If this package is happy with the default setup from
5127             <prgn>update-rc.d</prgn>, namely an ordering number of 20
5128             and having named running in all runlevels, it can say in
5129             its <prgn>postinst</prgn>:
5130             <example compact="compact">
5131 update-rc.d bind defaults >/dev/null
5132             </example>
5133             And in its <prgn>postrm</prgn>, to remove the links when the
5134             package is purged:
5135             <example compact="compact">
5136 if [ "$1" = purge ]; then
5137   update-rc.d bind remove >/dev/null
5138 fi
5139             </example>
5140           </p>
5141         </sect1>
5142       </sect>
5143
5144       <sect>
5145         <heading>Console messages from <file>init.d</file> scripts</heading>
5146
5147         <p>
5148           This section describes the formats to be used for messages
5149           written to standard output by the <file>/etc/init.d</file>
5150           scripts.  The intent is to improve the consistency of
5151           Debian's startup and shutdown look and feel.  For this
5152           reason, please look very carefully at the details.  We want
5153           the messages to have the same format in terms of wording,
5154           spaces, punctuation and case of letters.
5155         </p>
5156
5157         <p>
5158           Here is a list of overall rules that you should use when you
5159           create output messages.  They can be useful if you have a
5160           non-standard message that is not covered specifically in the
5161           sections below.
5162         </p>
5163
5164         <p>
5165           <list>
5166             <item>
5167               <p>
5168                 Every message should fit in one line (fewer than 80
5169                 characters), start with a capital letter and end with
5170                 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5171               </p>
5172             </item>
5173
5174             <item>
5175               <p>
5176                 If you want to express that the computer is working on
5177                 something (that is, performing a specific task, not
5178                 starting or stopping a program), we use an "ellipsis"
5179                 (three dots: <tt>...</tt>).  Note that we don't insert
5180                 spaces before or after the dots.  If the task has been
5181                 completed we write <tt>done.</tt> and a line feed.
5182               </p>
5183             </item>
5184
5185             <item>
5186               <p>
5187                 Design your messages as if the computer is telling you
5188                 what he is doing (let him be polite :-), but don't
5189                 mention "him" directly.  For example, if you think of
5190                 saying
5191                 <example compact="compact">
5192 I'm starting network daemons: nfsd mountd.
5193                 </example>
5194                 just say
5195                 <example compact="compact">
5196 Starting network daemons: nfsd mountd.
5197                 </example>
5198               </p>
5199             </item>
5200           </list>
5201         </p>
5202
5203         <p>
5204           There are standard message formats for the following
5205           situations.  They should be used by the <tt>init.d</tt>
5206           scripts.
5207         </p>
5208
5209         <p>
5210           <list>
5211             <item>
5212               <p>When daemons are started</p>
5213
5214               <p>
5215                 If your script starts one or more daemons, the output
5216                 should look like this (a single line, no leading
5217                 spaces):
5218                 <example compact="compact">
5219 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5220                 </example>
5221                 The <var>description</var> should describe the
5222                 subsystem the daemon or set of daemons are part of,
5223                 while <var>daemon-1</var> up to <var>daemon-n</var>
5224                 denote each daemon's name (typically the file name of
5225                 the program).
5226               </p>
5227
5228               <p>
5229                 For example, the output of <file>/etc/init.d/lpd</file>
5230                 would look like:
5231                 <example compact="compact">
5232 Starting printer spooler: lpd.
5233                 </example>
5234               </p>
5235
5236               <p>
5237                 This can be achieved by saying
5238                 <example compact="compact">
5239 echo -n "Starting printer spooler: lpd"
5240 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5241 echo "."
5242                 </example>
5243                 in the script. If you have more than one daemon to
5244                 start, you should do the following:
5245                 <example compact="compact">
5246 echo -n "Starting remote file system services:"
5247 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5248 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5249 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5250 echo "."
5251                 </example>
5252                 This makes it possible for the user to see what takes
5253                 so long and when the final daemon has been started.
5254                 You should be careful where to put spaces: in the
5255                 example above the system administrator can easily
5256                 comment out a line if he don't wants to start a
5257                 specific daemon, while the displayed message still
5258                 looks good.
5259               </p>
5260             </item>
5261
5262             <item>
5263               <p>When a system parameter is being set</p>
5264
5265               <p>
5266                 If you have to set up different system parameters
5267                 during the system boot, you should use this format:
5268                 <example compact="compact">
5269 Setting <var>parameter</var> to "<var>value</var>".
5270                 </example>
5271               </p>
5272
5273               <p>
5274                 You can use a statement such as the following to get
5275                 the quotes right:
5276                 <example compact="compact">
5277 echo "Setting DNS domainname to \"$domainname\"."
5278                 </example>
5279               </p>
5280
5281               <p>
5282                 Note that the same symbol (<tt>"</tt>) is used for the left
5283                 and right quotation marks.  A grave accent (<tt>`</tt>) is
5284                 not a quote character; neither is an apostrophe
5285                 (<tt>'</tt>).
5286               </p>
5287             </item>
5288
5289             <item>
5290               <p>When a daemon is stopped or restarted</p>
5291
5292               <p>
5293                 When you stop or restart a daemon, you should issue a
5294                 message identical to the startup message, except that
5295                 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5296                 or <tt>Restarting</tt> respectively.
5297               </p>
5298
5299               <p>
5300                 For example, stopping the printer daemon will like
5301                 like this:
5302                 <example compact="compact">
5303 Stopping printer spooler: lpd.
5304                 </example>
5305               </p>
5306             </item>
5307
5308             <item>
5309               <p>When something is executed</p>
5310
5311               <p>
5312                 There are several examples where you have to run a
5313                 program at system startup or shutdown to perform a
5314                 specific task, for example, setting the system's clock
5315                 using <prgn>netdate</prgn> or killing all processes
5316                 when the system shuts down.  Your message should look
5317                 like this:
5318                 <example compact="compact">
5319 Doing something very useful...done.
5320                 </example>
5321                 You should print the <tt>done.</tt> immediately after
5322                 the job has been completed, so that the user is
5323                 informed why she has to wait.  You can get this
5324                 behavior by saying
5325                 <example compact="compact">
5326 echo -n "Doing something very useful..."
5327 do_something
5328 echo "done."
5329                 </example>
5330                 in your script.
5331               </p>
5332             </item>
5333
5334             <item>
5335               <p>When the configuration is reloaded</p>
5336
5337               <p>
5338                 When a daemon is forced to reload its configuration
5339                 files you should use the following format:
5340                 <example compact="compact">
5341 Reloading <var>description</var> configuration...done.
5342                 </example>
5343                 where <var>description</var> is the same as in the
5344                 daemon starting message.
5345               </p>
5346             </item>
5347           </list>
5348         </p>
5349       </sect>
5350
5351       <sect>
5352         <heading>Cron jobs</heading>
5353
5354         <p>
5355           Packages must not modify the configuration file
5356           <file>/etc/crontab</file>, and they must not modify the files in
5357           <file>/var/spool/cron/crontabs</file>.</p>
5358
5359         <p>
5360           If a package wants to install a job that has to be executed
5361           via cron, it should place a file with the name of the
5362           package in one or more of the following directories:
5363           <example compact="compact">
5364 /etc/cron.daily
5365 /etc/cron.weekly
5366 /etc/cron.monthly
5367           </example>
5368           As these directory names imply, the files within them are
5369           executed on a daily, weekly, or monthly basis,
5370           respectively. The exact times are listed in
5371           <file>/etc/crontab</file>.</p>
5372
5373         <p>
5374           All files installed in any of these directories must be
5375           scripts (e.g., shell scripts or Perl scripts) so that they
5376           can easily be modified by the local system administrator.
5377           In addition, they should be treated as configuration
5378           files.
5379         </p>
5380
5381         <p>
5382           If a certain job has to be executed more frequently than
5383           daily, the package should install a file
5384           <file>/etc/cron.d/<var>package</var></file>. This file uses the
5385           same syntax as <file>/etc/crontab</file> and is processed by
5386           <prgn>cron</prgn> automatically. The file must also be
5387           treated as a configuration file. (Note that entries in the
5388           <file>/etc/cron.d</file> directory are not handled by
5389           <prgn>anacron</prgn>. Thus, you should only use this
5390           directory for jobs which may be skipped if the system is not
5391           running.)</p>
5392
5393         <p>
5394           The scripts or crontab entries in these directories should
5395           check if all necessary programs are installed before they
5396           try to execute them. Otherwise, problems will arise when a
5397           package was removed but not purged since configuration files
5398           are kept on the system in this situation.</p>
5399       </sect>
5400
5401       <sect>
5402         <heading>Menus</heading>
5403
5404         <p>
5405           Menu entries should follow the current menu policy found in
5406           the <tt>menu-policy</tt> files in the <tt>debian-policy</tt>
5407           package.  It may also be found on the Debian FTP site
5408           <ftpsite>ftp.debian.org</ftpsite> as the file
5409           <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>,
5410           or in the equivalent location on your local mirror.
5411         </p>
5412
5413         <p>
5414           The Debian <tt>menu</tt> package provides a standard
5415           interface between packages providing applications and
5416           documents, and <em>menu programs</em> (either X window
5417           managers or text-based menu programs such as
5418           <prgn>pdmenu</prgn>).
5419         </p>
5420
5421         <p>
5422           All packages that provide applications that need not be
5423           passed any special command line arguments for normal
5424           operation should register a menu entry for those
5425           applications, so that users of the <tt>menu</tt> package
5426           will automatically get menu entries in their window
5427           managers, as well in shells like <tt>pdmenu</tt>.</p>
5428
5429         <p>
5430           Please also refer to the <em>Debian Menu System</em>
5431           documentation that comes with the <tt>menu</tt> package for
5432           information about how to register your applications and web
5433           documents.
5434         </p>
5435       </sect>
5436
5437       <sect>
5438         <heading>Multimedia handlers</heading>
5439
5440         <p>
5441           Packages which provide the ability to view/show/play,
5442           compose, edit or print MIME types should register themselves
5443           as such following the current MIME support policy found in
5444           the <tt>mime-policy</tt> files in the <tt>debian-policy</tt>
5445           package.  It may also be found on the Debian FTP site
5446           <ftpsite>ftp.debian.org</ftpsite> as the file
5447           <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>,
5448           or in the equivalent location on your local mirror.
5449         </p>
5450
5451         <p>
5452           MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5453           is a mechanism for encoding files and data streams and
5454           providing meta-information about them, in particular their
5455           type (e.g.  audio or video) and format (e.g. PNG, HTML,
5456           MP3).
5457         </p>
5458
5459         <p>
5460           Registration of MIME type handlers allows programs like mail
5461           user agents and web browsers to to invoke these handlers to
5462           view, edit or display MIME types they don't support
5463           directly.
5464         </p>
5465       </sect>
5466
5467       <sect>
5468         <heading>Keyboard configuration</heading>
5469
5470         <p>
5471           To achieve a consistent keyboard configuration so that all
5472           applications interpret a keyboard event the same way, all
5473           programs in the Debian distribution must be configured to
5474           comply with the following guidelines.
5475         </p>
5476
5477         <p>
5478           The following keys must have the specified interpretations:
5479
5480           <taglist>
5481             <tag><tt>&lt;--</tt></tag>
5482             <item><p>delete the character to the left of the cursor</p></item>
5483
5484             <tag><tt>Delete</tt></tag>
5485             <item><p>delete the character to the right of the cursor</p></item>
5486
5487             <tag><tt>Control+H</tt></tag>
5488             <item><p>emacs: the help prefix</p></item>
5489           </taglist>
5490
5491           The interpretation of any keyboard events should be
5492           independent of the terminal that is used, be it a virtual
5493           console, an X terminal emulator, an rlogin/telnet session,
5494           etc.
5495         </p>
5496
5497         <p>
5498           The following list explains how the different programs
5499           should be set up to achieve this:
5500         </p>
5501
5502         <p>
5503           <list>
5504             <item><p><tt>&lt;--</tt> generates <tt>KB_BackSpace</tt>
5505                 in X.</p></item>
5506
5507             <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5508                 X.</p></item>
5509
5510             <item>
5511               <p>
5512                 X translations are set up to make
5513                 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5514                 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5515                 is the vt220 escape code for the "delete character"
5516                 key).  This must be done by loading the X resources
5517                 using <prgn>xrdb</prgn> on all local X displays, not
5518                 using the application defaults, so that the
5519                 translation resources used correspond to the
5520                 <prgn>xmodmap</prgn> settings.</p></item>
5521
5522             <item>
5523               <p>
5524                 The Linux console is configured to make
5525                 <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
5526                 generate <tt>ESC [ 3 ~</tt>.</p></item>
5527
5528             <item>
5529               <p>
5530                 X applications are configured so that <tt>&lt;</tt>
5531                 deletes left, and <tt>Delete</tt> deletes right.  Motif
5532                 applications already work like this.</p></item>
5533
5534             <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5535
5536             <item>
5537               <p>
5538                 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5539                 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5540                 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5541
5542             <item>
5543               <p>
5544                 Emacs is programmed to map <tt>KB_Backspace</tt> or
5545                 the <tt>stty erase</tt> character to
5546                 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5547                 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5548                 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5549
5550             <item>
5551               <p>
5552                 Other applications use the <tt>stty erase</tt>
5553                 character and <tt>kdch1</tt> for the two delete keys,
5554                 with ASCII DEL being "delete previous character" and
5555                 <tt>kdch1</tt> being "delete character under
5556                 cursor".</p></item>
5557
5558           </list>
5559         </p>
5560
5561         <p>
5562           This will solve the problem except for the following
5563           cases:
5564         </p>
5565
5566         <p>
5567           <list>
5568             <item>
5569               <p>
5570                 Some terminals have a <tt>&lt;--</tt> key that cannot
5571                 be made to produce anything except <tt>^H</tt>.  On
5572                 these terminals Emacs help will be unavailable on
5573                 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5574                 character takes precedence in Emacs, and has been set
5575                 correctly).  <tt>M-x help</tt> or <tt>F1</tt> (if
5576                 available) can be used instead.</p></item>
5577
5578             <item>
5579               <p>
5580                 Some operating systems use <tt>^H</tt> for <tt>stty
5581                 erase</tt>.  However, modern telnet versions and all
5582                 rlogin versions propagate <tt>stty</tt> settings, and
5583                 almost all UNIX versions honour <tt>stty erase</tt>.
5584                 Where the <tt>stty</tt> settings are not propagated
5585                 correctly, things can be made to work by using
5586                 <tt>stty</tt> manually.</p></item>
5587
5588             <item>
5589               <p>
5590                 Some systems (including previous Debian versions) use
5591                 <prgn>xmodmap</prgn> to arrange for both
5592                 <tt>&lt;--</tt> and <tt>Delete</tt> to generate
5593                 <tt>KB_Delete</tt>.  We can change the behavior of
5594                 their X clients using the same X resources that we use
5595                 to do it for our own clients, or configure our clients
5596                 using their resources when things are the other way
5597                 around.  On displays configured like this
5598                 <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
5599                 will.</p></item>
5600
5601             <item>
5602               <p>
5603                 Some operating systems have different <tt>kdch1</tt>
5604                 settings in their <tt>terminfo</tt> database for
5605                 <tt>xterm</tt> and others.  On these systems the
5606                 <tt>Delete</tt> key will not work correctly when you
5607                 log in from a system conforming to our policy, but
5608                 <tt>&lt;--</tt> will.</p></item>
5609           </list>
5610         </p>
5611       </sect>
5612
5613       <sect>
5614         <heading>Environment variables</heading>
5615
5616         <p>
5617           A program must not depend on environment variables to get
5618           reasonable defaults.  (That's because these environment
5619           variables would have to be set in a system-wide
5620           configuration file like <file>/etc/profile</file>, which is not
5621           supported by all shells.)</p>
5622
5623         <p>
5624           If a program usually depends on environment variables for its
5625           configuration, the program should be changed to fall back to
5626           a reasonable default configuration if these environment
5627           variables are not present. If this cannot be done easily
5628           (e.g., if the source code of a non-free program is not
5629           available), the program must be replaced by a small
5630           "wrapper" shell script which sets the environment variables
5631           if they are not already defined, and calls the original program.</p>
5632
5633         <p>
5634           Here is an example of a wrapper script for this purpose:
5635
5636           <example compact="compact">
5637 #!/bin/sh
5638 BAR=${BAR:-/var/lib/fubar}
5639 export BAR
5640 exec /usr/lib/foo/foo "$@"
5641           </example>
5642         </p>
5643
5644         <p>
5645           Furthermore, as <file>/etc/profile</file> is a configuration
5646           file of the <prgn>base-files</prgn> package, other packages must not
5647           put any environment variables or other commands into that
5648           file.</p>
5649       </sect>
5650     </chapt>
5651
5652     <chapt id="files">
5653       <heading>Files</heading>
5654
5655       <sect>
5656         <heading>Binaries</heading>
5657
5658         <p>
5659           Two different packages must not install programs with
5660           different functionality but with the same filenames.  (The
5661           case of two programs having the same functionality but
5662           different implementations is handled via "alternatives" or
5663           the "Conflicts" mechanism.  See <ref id="maintscripts"> and
5664           <ref id="conflicts"> respectively.)  If this case happens,
5665           one of the programs must be renamed.  The maintainers should
5666           report this to the <tt>debian-devel</tt> mailing list and
5667           try to find a consensus about which program will have to be
5668           renamed.  If a consensus cannot be reached, <em>both</em>
5669           programs must be renamed.
5670         </p>
5671
5672         <p>
5673          By default, when a package is being built, any binaries
5674          created should include debugging information, as well as
5675          being compiled with optimization.  You should also turn on
5676          as many reasonable compilation warnings as possible; this
5677          makes life easier for porters, who can then look at build
5678          logs for possible problems.  For the C programming language,
5679          this means the following compilation parameters should be
5680          used:
5681           <example compact="compact">
5682 CC = gcc
5683 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5684 LDFLAGS = # none
5685 install -s # (or use strip on the files in debian/tmp)
5686           </example>
5687         </p>
5688
5689         <p>
5690           Note that by default all installed binaries should be stripped,
5691           either by using the <tt>-s</tt> flag to
5692           <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5693           the binaries after they have been copied into
5694           <file>debian/tmp</file> but before the tree is made into a
5695           package.</p>
5696
5697         <p>
5698           Although binaries in the build tree should be compiled with
5699           debugging information by default, it can often be difficult
5700           to debug programs if they are also subjected to compiler
5701           optimization.  For this reason, it is recommended to support
5702           the standardized environment
5703           variable <tt>DEB_BUILD_OPTIONS</tt>.  This variable can
5704           contain several flags to change how a package is compiled
5705           and built.
5706         </p>
5707         <p>
5708           <taglist>
5709             <tag>noopt</tag>
5710             <item>
5711               <p>
5712                 The presence of this string means that the package
5713                 should be complied with a minimum of optimization.
5714                 For C programs, it is best to add <tt>-O0</tt>
5715                 to <tt>CFLAGS</tt> (although this is usually the
5716                 default).  Some programs might fail to build or run at
5717                 this level of optimization; it may be necessary to
5718                 use <tt>-O1</tt>, for example.
5719               </p>
5720             </item>
5721             <tag>nostrip</tag>
5722             <item>
5723               <p>
5724                 This string means that the debugging symbols should
5725                 not be stripped from the binary during installation,
5726                 so that debugging information may be included in the package.
5727               </p>
5728             </item>
5729           </taglist>
5730         </p>
5731         <p>
5732           The following makefile snippet is an example of how one may
5733           implement the build options; you will probably have to
5734           massage this example in order to make it work for your
5735           package.
5736           <example compact="compact">
5737 CFLAGS = -Wall -g
5738 INSTALL = install
5739 INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
5740 INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
5741 INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
5742 INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
5743
5744 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5745 CFLAGS += -O0
5746 else
5747 CFLAGS += -O2
5748 endif
5749 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5750 INSTALL_PROGRAM += -s
5751 endif
5752           </example>
5753         </p>
5754
5755         <p>
5756           It is up to the package maintainer to decide what
5757           compilation options are best for the package.  Certain
5758           binaries (such as computationally-intensive programs) will
5759           function better with certain flags (<tt>-O3</tt>, for
5760           example); feel free to use them.  Please use good judgment
5761           here.  Don't use flags for the sake of it; only use them
5762           if there is good reason to do so.  Feel free to override
5763           the upstream author's ideas about which compilation
5764           options are best: they are often inappropriate for our
5765           environment.
5766         </p>
5767       </sect>
5768
5769
5770       <sect id="libraries">
5771         <heading>Libraries</heading>
5772
5773         <p>
5774           The shared version of a library must be compiled with
5775           <tt>-fPIC</tt>, and the static version must not be. In other
5776           words, each source unit (<tt>*.c</tt>, for example, for C files)
5777           will need to be compiled twice.
5778         </p>
5779
5780
5781         <p>
5782           You must specify the gcc option <tt>-D_REENTRANT</tt>
5783           when building a library (either static or shared) to make
5784           the library compatible with LinuxThreads.
5785         </p>
5786
5787         <p>
5788           All installed shared libraries should be stripped with
5789           <example compact="compact">
5790 strip --strip-unneeded <var>your-lib</var>
5791           </example>
5792           (The option <tt>--strip-unneeded</tt> makes
5793           <prgn>strip</prgn> remove only the symbols which aren't
5794           needed for relocation processing.)  Shared libraries can
5795           function perfectly well when stripped, since the symbols for
5796           dynamic linking are in a separate part of the ELF object
5797           file.<footnote>
5798             <p>
5799               You might also want to use the options
5800               <tt>--remove-section=.comment</tt> and
5801               <tt>--remove-section=.note</tt> on both shared libraries
5802               and executables, and <tt>--strip-debug</tt> on static
5803               libraries.
5804             </p>
5805           </footnote>
5806         </p>
5807
5808         <p>
5809           Note that under some circumstances it may be useful to
5810           install a shared library unstripped, for example when
5811           building a separate package to support debugging.
5812         </p>
5813
5814         <p>
5815           Shared object files (often <file>.so</file> files) that are not
5816           public libraries, that is, they are not meant to be linked
5817           to by third party executables (binaries of other packages),
5818           should be installed in subdirectories of the
5819           <file>/usr/lib</file> directory.  Such files are exempt from the
5820           rules that govern ordinary shared libraries, except that
5821           they must not be installed executable and should be
5822           stripped.<footnote>
5823             <p>
5824               A common example are the so-called "plug-ins",
5825               internal shared objects that are dynamically loaded by
5826               programs using <manref name="dlopen" section="3">.
5827             </p>
5828           </footnote>
5829         </p>
5830
5831         <p>
5832           Packages containing shared libraries that may be linked to
5833           by other packages' binaries, but which for some
5834           <em>compelling</em> reason can not be installed in
5835           <file>/usr/lib</file> directory, may install the shared library
5836           files in subdirectories of the <file>/usr/lib</file> directory,
5837           in which case they should arrange to add that directory in
5838           <file>/etc/ld.so.conf</file> in the package's post-installation
5839           script, and remove it in the package's post-removal script.
5840         </p>
5841
5842         <p>
5843           An ever increasing number of packages are using
5844           <prgn>libtool</prgn> to do their linking.  The latest GNU
5845           libtools (>= 1.3a) can take advantage of the metadata in the
5846           installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5847           files).  The main advantage of <prgn>libtool</prgn>'s
5848           <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5849           store and subsequently access metadata with respect to the
5850           libraries it builds.  <prgn>libtool</prgn> will search for
5851           those files, which contain a lot of useful information about
5852           a library (such as library dependency information for static
5853           linking).  Also, they're <em>essential</em> for programs
5854           using <tt>libltdl</tt>.<footnote>
5855             <p>
5856               Although <prgn>libtool</prgn> is fully capable of
5857               linking against shared libraries which don't have
5858               <tt>.la</tt> files, as it is a mere shell script it can
5859               add considerably to the build time of a
5860               <prgn>libtool</prgn>-using package if that shell script
5861               has to derive all this information from first principles
5862               for each library every time it is linked.  With the
5863               advent of <prgn>libtool</prgn> version 1.4 (and to a
5864               lesser extent <prgn>libtool</prgn> version 1.3), the
5865               <file>.la</file> files also store information about
5866               inter-library dependencies which cannot necessarily be
5867               derived after the <file>.la</file> file is deleted.
5868             </p>
5869           </footnote>
5870         </p>
5871
5872         <p>
5873           Packages that use <prgn>libtool</prgn> to create shared
5874           libraries should include the <file>.la</file> files in the
5875           <tt>-dev</tt> package, unless the package relies on
5876           <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5877           the <tt>.la</tt> files must go in the run-time library
5878           package.
5879         </p>
5880
5881         <p>
5882           You must make sure that you use only released versions of
5883           shared libraries to build your packages; otherwise other
5884           users will not be able to run your binaries
5885           properly. Producing source packages that depend on
5886           unreleased compilers is also usually a bad
5887           idea.
5888         </p>
5889       </sect>
5890
5891
5892       <sect>
5893         <heading>Shared libraries</heading>
5894         <p>
5895           This section has moved to <ref id="sharedlibs">.
5896         </p>
5897       </sect>
5898
5899
5900       <sect id="scripts">
5901         <heading>Scripts</heading>
5902
5903         <p>
5904           All command scripts, including the package maintainer
5905           scripts inside the package and used by <prgn>dpkg</prgn>,
5906           should have a <tt>#!</tt> line naming the shell to be used
5907           to interpret them.</p>
5908
5909         <p>
5910           In the case of Perl scripts this should be
5911           <tt>#!/usr/bin/perl</tt>.</p>
5912
5913         <p>
5914           Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5915           should almost certainly start with <tt>set -e</tt> so that
5916           errors are detected.  Every script should use
5917           <tt>set -e</tt> or check the exit status of <em>every</em>
5918           command.</p>
5919
5920         <p>
5921           The standard shell interpreter <file>/bin/sh</file> can be a
5922           symbolic link to any POSIX compatible shell, if <tt>echo
5923           -n</tt> does not generate a newline.<footnote>
5924             <p>
5925               Debian policy specifies POSIX behavior for
5926               <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5927               use in the Linux community (in particular including this
5928               policy, the Linux kernel source, many Debian scripts,
5929               etc.).  This <tt>echo -n</tt> mechanism is valid but not
5930               required under POSIX, hence this explicit addition.
5931               Also, rumour has it that this shall be mandated under
5932               the LSB anyway.
5933             </p>
5934           </footnote>
5935           Thus, shell scripts specifying <file>/bin/sh</file> as
5936           interpreter should only use POSIX features. If a script
5937           requires non-POSIX features from the shell interpreter, the
5938           appropriate shell must be specified in the first line of the
5939           script (e.g., <tt>#!/bin/bash</tt>) and the package must
5940           depend on the package providing the shell (unless the shell
5941           package is marked "Essential", as in the case of
5942           <prgn>bash</prgn>).
5943         </p>
5944
5945         <p>
5946           You may wish to restrict your script to POSIX features when
5947           possible so that it may use <file>/bin/sh</file> as its
5948           interpreter. If your script works with <prgn>dash</prgn>
5949           (originally called <prgn>ash</prgn>), it's probably POSIX
5950           compliant, but if you are in doubt, use
5951           <file>/bin/bash</file>.
5952         </p>
5953
5954         <p>
5955           Perl scripts should check for errors when making any
5956           system calls, including <tt>open</tt>, <tt>print</tt>,
5957           <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5958         </p>
5959
5960         <p>
5961           <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5962           scripting languages.  See <em>Csh Programming Considered
5963           Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5964           can be found at <url
5965           id="http://language.perl.com/versus/csh.whynot">.<footnote>
5966             <p>
5967               It can also be found on
5968               <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5969               or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5970               <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5971               </p>
5972           </footnote>
5973           If an upstream package comes with <prgn>csh</prgn> scripts
5974           then you must make sure that they start with
5975           <tt>#!/bin/csh</tt> and make your package depend on the
5976           <prgn>c-shell</prgn> virtual package.
5977         </p>
5978
5979         <p>
5980           Any scripts which create files in world-writeable
5981           directories (e.g., in <file>/tmp</file>) must use a
5982           mechanism which will fail if a file with the same name
5983           already exists.</p>
5984
5985         <p>
5986           The Debian base system provides the <prgn>tempfile</prgn>
5987           and <prgn>mktemp</prgn> utilities for use by scripts for
5988           this purpose.</p></sect>
5989
5990
5991       <sect>
5992         <heading>Symbolic links</heading>
5993
5994         <p>
5995           In general, symbolic links within a top-level directory
5996           should be relative, and symbolic links pointing from one
5997           top-level directory into another should be absolute. (A
5998           top-level directory is a sub-directory of the root
5999           directory <file>/</file>.)</p>
6000
6001         <p>
6002           In addition, symbolic links should be specified as short as
6003           possible, i.e., link targets like <file>foo/../bar</file> are
6004           deprecated.</p>
6005
6006         <p>
6007           Note that when creating a relative link using
6008           <prgn>ln</prgn> it is not necessary for the target of the
6009           link to exist relative to the working directory you're
6010           running <prgn>ln</prgn> from, nor is it necessary to change
6011           directory to the directory where the link is to be made.
6012           Simply include the string that should appear as the target
6013           of the link (this will be a pathname relative to the
6014           directory in which the link resides) as the first argument
6015           to <prgn>ln</prgn>.</p>
6016
6017         <p>
6018           For example, in your <prgn>Makefile</prgn> or
6019           <file>debian/rules</file>, you can do things like:
6020           <example compact="compact">
6021 ln -fs gcc $(prefix)/bin/cc
6022 ln -fs gcc debian/tmp/usr/bin/cc
6023 ln -fs ../sbin/sendmail $(prefix)/bin/runq
6024 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
6025           </example></p>
6026
6027         <p>
6028           A symbolic link pointing to a compressed file should always
6029           have the same file extension as the referenced file. (For
6030           example, if a file <file>foo.gz</file> is referenced by a
6031           symbolic link, the filename of the link has to end with
6032           "<file>.gz</file>" too, as in <file>bar.gz</file>.)
6033         </p>
6034       </sect>
6035
6036       <sect>
6037         <heading>Device files</heading>
6038
6039         <p>
6040           Packages must not include device files in the package file
6041           tree.</p>
6042
6043         <p>
6044           If a package needs any special device files that are not
6045           included in the base system, it must call
6046           <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
6047           after notifying the user<footnote>
6048             <p>
6049               This notification could be done via a (low-priority)
6050               debconf message, or an echo (printf) statement.
6051             </p>
6052           </footnote>
6053           .</p>
6054
6055         <p>
6056           Packages must not remove any device files in the
6057           <prgn>postrm</prgn> or any other script. This is left to the
6058           system administrator.</p>
6059
6060         <p>
6061           Debian uses the serial devices
6062           <file>/dev/ttyS*</file>. Programs using the old
6063           <file>/dev/cu*</file> devices should be changed to use
6064           <file>/dev/ttyS*</file>.</p>
6065       </sect>
6066
6067       <sect id="config-files">
6068         <heading>Configuration files</heading>
6069         <sect1>
6070           <heading>Definitions</heading>
6071           <p>
6072             <taglist>
6073               <tag>configuration file</tag>
6074               <item>
6075                 <p>
6076                   A file that affects the operation of a program, or
6077                   provides site- or host-specific information, or
6078                   otherwise customizes the behavior of a program.
6079                   Typically, configuration files are intended to be
6080                   modified by the system administrator (if needed or
6081                   desired) to conform to local policy or to provide
6082                   more useful site-specific behavior.
6083                 </p>
6084               </item>
6085
6086               <tag><tt>conffile</tt></tag>
6087               <item>
6088                 <p>
6089                   A file listed in a package's <tt>conffiles</tt>
6090                   file, and is treated specially by <prgn>dpkg</prgn>
6091                   (see <ref id="configdetails">).
6092                 </p>
6093               </item>
6094             </taglist>
6095           </p>
6096
6097           <p>
6098             The distinction between these two is important; they are
6099             not interchangeable concepts. Almost all
6100             <tt>conffile</tt>s are configuration files, but many
6101             configuration files are not <tt>conffiles</tt>.
6102           </p>
6103
6104           <p>
6105             Note that a script that embeds configuration information
6106             (such as most of the files in <file>/etc/default</file> and
6107             <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6108             configuration file and should be treated as such.
6109           </p>
6110         </sect1>
6111
6112         <sect1>
6113           <heading>Location</heading>
6114           <p>
6115             Any configuration files created or used by your package
6116             must reside in <file>/etc</file>. If there are several,
6117             consider creating a subdirectory of <file>/etc</file>
6118             named after your package.</p>
6119
6120           <p>
6121             If your package creates or uses configuration files
6122             outside of <file>/etc</file>, and it is not feasible to modify
6123             the package to use <file>/etc</file> directly, put the files
6124             in <file>/etc</file> and create symbolic links to those files
6125             from the location that the package requires.</p>
6126         </sect1>
6127
6128         <sect1>
6129           <heading>Behavior</heading>
6130           <p>
6131             Configuration file handling must conform to the following
6132             behavior:
6133             <list compact="compact">
6134               <item>
6135                 <p>
6136                   local changes must be preserved during a package
6137                   upgrade, and
6138                 </p>
6139               </item>
6140               <item>
6141                 <p>
6142                   configuration files must be preserved when the
6143                   package is removed, and only deleted when the
6144                   package is purged.
6145                 </p>
6146               </item>
6147             </list>
6148           </p>
6149
6150           <p>
6151             The easy way to achieve this behavior is to make the
6152             configuration file a <tt>conffile</tt>. This is
6153             appropriate only if it is possible to distribute a default
6154             version that will work for most installations, although
6155             some system administrators may choose to modify it. This
6156             implies that the default version will be part of the
6157             package distribution, and must not be modified by the
6158             maintainer scripts during installation (or at any other
6159             time).
6160           </p>
6161
6162           <p>
6163             In order to ensure that local changes are preserved
6164             correctly, no package may contain or make hard links to
6165             conffiles.<footnote>
6166               <p>
6167                 Rationale: There are two problems with hard links.
6168                 The first is that some editors break the link while
6169                 editing one of the files, so that the two files may
6170                 unwittingly become unlinked and different.  The second
6171                 is that <prgn>dpkg</prgn> might break the hard link
6172                 while upgrading <tt>conffile</tt>s.
6173               </p>
6174             </footnote>
6175             </p>
6176
6177             <p>
6178             The other way to do it is via the maintainer scripts.  In
6179             this case, the configuration file must not be listed as a
6180             <tt>conffile</tt> and must not be part of the package
6181             distribution. If the existence of a file is required for
6182             the package to be sensibly configured it is the
6183             responsibility of the package maintainer to provide
6184             maintainer scripts which correctly create, update and
6185             maintain the file and remove it on purge.  (See <ref
6186             id="maintainerscripts"> for more information.)  These
6187             scripts must be idempotent (i.e., must work correctly if
6188             <prgn>dpkg</prgn> needs to re-run them due to errors
6189             during installation or removal), must cope with all the
6190             variety of ways <prgn>dpkg</prgn> can call maintainer
6191             scripts, must not overwrite or otherwise mangle the user's
6192             configuration without asking, must not ask unnecessary
6193             questions (particularly during upgrades), and otherwise be
6194             good citizens.
6195           </p>
6196
6197           <p>
6198             The scripts are not required to configure every possible
6199             option for the package, but only those necessary to get
6200             the package running on a given system. Ideally the
6201             sysadmin should not have to do any configuration other
6202             than that done (semi-)automatically by the
6203             <prgn>postinst</prgn> script.
6204           </p>
6205
6206           <p>
6207             A common practice is to create a script called
6208             <file><var>package</var>-configure</file> and have the
6209             package's <prgn>postinst</prgn> call it if and only if the
6210             configuration file does not already exist.  In certain
6211             cases it is useful for there to be an example or template
6212             file which the maintainer scripts use.  Such files should
6213             be in <file>/usr/share/<var>package</var></file> or
6214             <file>/usr/lib/<var>package</var></file> (depending on whether
6215             they are architecture-independent or not).  There should
6216             be symbolic links to them from
6217             <file>/usr/share/doc/<var>package</var>/examples</file> if
6218             they are examples, and should be perfectly ordinary
6219             <prgn>dpkg</prgn>-handled files (<em>not</em>
6220             configuration files).
6221           </p>
6222
6223           <p>
6224             These two styles of configuration file handling must
6225             not be mixed, for that way lies madness:
6226             <prgn>dpkg</prgn> will ask about overwriting the file
6227             every time the package is upgraded.
6228           </p>
6229         </sect1>
6230
6231         <sect1>
6232           <heading>Sharing configuration files</heading>
6233           <p>
6234             Packages which specify the same file as a
6235             <tt>conffile</tt> must be tagged as <em>conflicting</em>
6236             with each other.  (This is an instance of the general rule
6237             about not sharing files.  Note that neither alternatives
6238             nor diversions are likely to be appropriate in this case;
6239             in particular, <prgn>dpkg</prgn> does not handle diverted
6240             <tt>conffile</tt>s well.)
6241           </p>
6242
6243           <p>
6244             The maintainer scripts must not alter a <tt>conffile</tt>
6245             of <em>any</em> package, including the one the scripts
6246             belong to.
6247           </p>
6248
6249           <p>
6250             If two or more packages use the same configuration file
6251             and it is reasonable for both to be installed at the same
6252             time, one of these packages must be defined as
6253             <em>owner</em> of the configuration file, i.e., it will be
6254             the package which handles that file as a configuration
6255             file.  Other packages that use the configuration file must
6256             depend on the owning package if they require the
6257             configuration file to operate. If the other package will
6258             use the configuration file if present, but is capable of
6259             operating without it, no dependency need be declared.</p>
6260
6261           <p>
6262             If it is desirable for two or more related packages to
6263             share a configuration file <em>and</em> for all of the
6264             related packages to be able to modify that configuration
6265             file, then the following should be done:
6266             <enumlist compact="compact">
6267               <item>
6268                 <p>
6269                   One of the related packages (the "owning" package)
6270                   will manage the configuration file with maintainer
6271                   scripts as described in the previous section.
6272                 </p>
6273               </item>
6274               <item>
6275                 <p>
6276                   The owning package should also provide a program
6277                   that the other packages may use to modify the
6278                   configuration file.
6279                 </p>
6280               </item>
6281               <item>
6282                 <p>
6283                   The related packages must use the provided program
6284                   to make any desired modifications to the
6285                   configuration file.  They should either depend on
6286                   the core package to guarantee that the configuration
6287                   modifier program is available or accept gracefully
6288                   that they cannot modify the configuration file if it
6289                   is not.  (This is in addition to the fact that the
6290                   configuration file may not even be present in the
6291                   latter scenario.)
6292                 </p>
6293               </item>
6294             </enumlist>
6295           </p>
6296
6297           <p>
6298             Sometimes it's appropriate to create a new package which
6299             provides the basic infrastructure for the other packages
6300             and which manages the shared configuration files.  (The
6301             <tt>sgml-base</tt> package is a good example.)
6302           </p>
6303         </sect1>
6304
6305         <sect1>
6306           <heading>User configuration files ("dotfiles")</heading>
6307
6308           <p>
6309             The files in <file>/etc/skel</file> will automatically be
6310             copied into new user accounts by <prgn>adduser</prgn>.
6311             No other program should reference the files in
6312             <file>/etc/skel</file>.
6313           </p>
6314
6315           <p>
6316             Therefore, if a program needs a dotfile to exist in
6317             advance in <file>$HOME</file> to work sensibly, that dotfile
6318             should be installed in <file>/etc/skel</file> and treated as a
6319             configuration file.
6320           </p>
6321
6322           <p>
6323             However, programs that require dotfiles in order to
6324             operate sensibly are a bad thing, unless they do create
6325             the dotfiles themselves automatically.
6326           </p>
6327
6328           <p>
6329             Furthermore, programs should be configured by the Debian
6330             default installation to behave as closely to the upstream
6331             default behaviour as possible.
6332           </p>
6333
6334           <p>
6335             Therefore, if a program in a Debian package needs to be
6336             configured in some way in order to operate sensibly, that
6337             should be done using a site-wide configuration file placed
6338             in <file>/etc</file>.  Only if the program doesn't support a
6339             site-wide default configuration and the package maintainer
6340             doesn't have time to add it may a default per-user file be
6341             placed in <file>/etc/skel</file>.
6342           </p>
6343
6344           <p>
6345             <file>/etc/skel</file> should be as empty as we can make it.
6346             This is particularly true because there is no easy (or
6347             necessarily desirable) mechanism for ensuring that the
6348             appropriate dotfiles are copied into the accounts of
6349             existing users when a package is installed.
6350           </p>
6351         </sect1>
6352       </sect>
6353
6354       <sect>
6355         <heading>Log files</heading>
6356         <p>
6357           Log files should usually be named
6358           <file>/var/log/<var>package</var>.log</file>.  If you have many
6359           log files, or need a separate directory for permission
6360           reasons (<file>/var/log</file> is writable only by
6361           <file>root</file>), you should usually create a directory named
6362           <file>/var/log/<var>package</var></file> and place your log
6363           files there.
6364         </p>
6365
6366         <p>
6367           Log files must be rotated occasionally so that they don't
6368           grow indefinitely; the best way to do this is to drop a log
6369           rotation configuration file into the directory
6370           <file>/etc/logrotate.d</file> and use the facilities provided by
6371           logrotate.<footnote>
6372             <p>
6373               The traditional approach to log files has been to set up
6374               <em>ad hoc</em> log rotation schemes using simple shell
6375               scripts and cron.  While this approach is highly
6376               customizable, it requires quite a lot of sysadmin work.
6377               Even though the original Debian system helped a little
6378               by automatically installing a system which can be used
6379               as a template, this was deemed not enough.
6380             </p>
6381
6382             <p>
6383               The use of <prgn>logrotate</prgn>, a program developed
6384               by Red Hat, is better, as it centralizes log management.
6385               It has both a configuration file
6386               (<file>/etc/logrotate.conf</file>) and a directory where
6387               packages can drop their individual log rotation
6388               configurations (<file>/etc/logrotate.d</file>).
6389             </p>
6390           </footnote>
6391           Here is a good example for a logrotate config
6392           file (for more information see <manref name="logrotate"
6393             section="8">):
6394           <example compact="compact">
6395 /var/log/foo/* {
6396 rotate 12
6397 weekly
6398 compress
6399 postrotate
6400 /etc/init.d/foo force-reload
6401 endscript
6402 }
6403           </example>
6404           This rotates all files under <file>/var/log/foo</file>, saves 12
6405           compressed generations, and forces the daemon to reload its
6406           configuration information after the log rotation.
6407         </p>
6408
6409         <p>
6410           Log files should be removed when the package is
6411           purged (but not when it is only removed).  This should be
6412           done by the <prgn>postrm</prgn> script when it is called
6413           with the argument <tt>purge</tt> (see <ref
6414           id="removedetails">).
6415         </p>
6416       </sect>
6417
6418       <sect>
6419         <heading>Permissions and owners</heading>
6420
6421         <p>
6422           The rules in this section are guidelines for general use.
6423           If necessary you may deviate from the details below.
6424           However, if you do so you must make sure that what is done
6425           is secure and you should try to be as consistent as possible
6426           with the rest of the system.  You should probably also
6427           discuss it on <prgn>debian-devel</prgn> first.
6428         </p>
6429
6430         <p>
6431           Files should be owned by <tt>root.root</tt>, and made
6432           writable only by the owner and universally readable (and
6433           executable, if appropriate), that is mode 644 or 755.
6434         </p>
6435
6436         <p>
6437           Directories should be mode 755 or (for group-writability)
6438           mode 2775.  The ownership of the directory should be
6439           consistent with its mode: if a directory is mode 2775, it
6440           should be owned by the group that needs write access to
6441           it.
6442         </p>
6443
6444         <p>
6445           Setuid and setgid executables should be mode 4755 or 2755
6446           respectively, and owned by the appropriate user or group.
6447           They should not be made unreadable (modes like 4711 or
6448           2711 or even 4111); doing so achieves no extra security,
6449           because anyone can find the binary in the freely available
6450           Debian package; it is merely inconvenient.  For the same
6451           reason you should not restrict read or execute permissions
6452           on non-set-id executables.
6453         </p>
6454
6455         <p>
6456           Some setuid programs need to be restricted to particular
6457           sets of users, using file permissions.  In this case they
6458           should be owned by the uid to which they are set-id, and by
6459           the group which should be allowed to execute them.  They
6460           should have mode 4754; again there is no point in making
6461           them unreadable to those users who must not be allowed to
6462           execute them.
6463         </p>
6464
6465         <p>
6466           It is possible to arrange that the system administrator can
6467           reconfigure the package to correspond to their local
6468           security policy by changing the permissions on a binary:
6469           they can do this by using <prgn>dpkg-statoverride</prgn>, as
6470           described below.<footnote>
6471             <p>
6472               Ordinary files installed by <prgn>dpkg</prgn> (as
6473               opposed to <tt>conffile</tt>s and other similar objects)
6474               normally have their permissions reset to the distributed
6475               permissions when the package is reinstalled.  However,
6476               the use of <prgn>dpkg-statoverride</prgn> overrides this
6477               default behaviour.  If you use this method, you should
6478               remember to describe <prgn>dpkg-statoverride</prgn> in
6479               the package documentation; being a relatively new
6480               addition to Debian, it is probably not yet well-known.
6481             </p>
6482           </footnote>
6483           Another method you should consider is to create a group for
6484           people allowed to use the program(s) and make any setuid
6485           executables executable only by that group.
6486         </p>
6487
6488         <p>
6489           If you need to create a new user or group for your package
6490           there are two possibilities.  Firstly, you may need to
6491           make some files in the binary package be owned by this
6492           user or group, or you may need to compile the user or
6493           group id (rather than just the name) into the binary
6494           (though this latter should be avoided if possible, as in
6495           this case you need a statically allocated id).</p>
6496
6497         <p>
6498           If you need a statically allocated id, you must ask for a
6499           user or group id from the <tt>base-passwd</tt> maintainer,
6500           and must not release the package until you have been
6501           allocated one.  Once you have been allocated one you must
6502           either make the package depend on a version of the
6503           <tt>base-passwd</tt> package with the id present in
6504           <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6505           your package to create the user or group itself with the
6506           correct id (using <tt>adduser</tt>) in its
6507           <prgn>preinst</prgn> or <prgn>postinst</prgn>.  (Doing it in
6508           the <prgn>postinst</prgn> is to be preferred if it is
6509           possible, otherwise a pre-dependency will be needed on the
6510           <tt>adduser</tt> package.)
6511         </p>
6512
6513         <p>
6514           On the other hand, the program might be able to determine
6515           the uid or gid from the user or group name at runtime, so
6516           that a dynamically allocated id can be used.  In this case
6517           you should choose an appropriate user or group name,
6518           discussing this on <prgn>debian-devel</prgn> and checking
6519           with the <package/base-passwd/ maintainer that it is unique and that
6520           they do not wish you to use a statically allocated id
6521           instead.  When this has been checked you must arrange for
6522           your package to create the user or group if necessary using
6523           <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6524           <prgn>postinst</prgn> script (again, the latter is to be
6525           preferred if it is possible).
6526         </p>
6527
6528         <p>
6529           Note that changing the numeric value of an id associated
6530           with a name is very difficult, and involves searching the
6531           file system for all appropriate files.  You need to think
6532           carefully whether a static or dynamic id is required, since
6533           changing your mind later will cause problems.
6534         </p>
6535
6536         <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6537           <p>
6538             This section is not intended as policy, but as a
6539             description of the use of <prgn>dpkg-statoverride</prgn>.
6540           </p>
6541
6542           <p>
6543             <prgn>dpkg-statoverride</prgn> is a replacement for the
6544             deprecated <tt>suidmanager</tt> package.  Packages which
6545             previously used <tt>suidmanager</tt> should have a
6546             <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6547             <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6548             and <tt>suidunregister</tt> should now be simply removed
6549             from the maintainer scripts.
6550           </p>
6551
6552           <p>
6553             If a system administrator wishes to have a file (or
6554             directory or other such thing) installed with owner and
6555             permissions different from those in the distributed Debian
6556             package, he can use the <prgn>dpkg-statoverride</prgn>
6557             program to instruct <prgn>dpkg</prgn> to use the different
6558             settings every time the file is installed.  Thus the
6559             package maintainer should distribute the files with their
6560             normal permissions, and leave it for the system
6561             administrator to make any desired changes.  For example, a
6562             daemon which is normally required to be setuid root, but
6563             in certain situations could be used without being setuid,
6564             should be installed setuid in the <tt>.deb</tt>.  Then the
6565             local system administrator can change this if they wish.
6566             If there are two standard ways of doing it, the package
6567             maintainer can use <tt>debconf</tt> to find out the
6568             preference, and call <prgn>dpkg-statoverride</prgn> in the
6569             maintainer script if necessary to accommodate the system
6570             administrator's choice.
6571           </p>
6572
6573           <p>
6574             Given the above, <prgn>dpkg-statoverride</prgn> is
6575             essentially a tool for system administrators and would not
6576             normally be needed in the maintainer scripts.  There is
6577             one type of situation, though, where calls to
6578             <prgn>dpkg-statoverride</prgn> would be needed in the
6579             maintainer scripts, and that involves packages which use
6580             dynamically allocated user or group ids.  In such a
6581             situation, something like the following idiom can be very
6582             helpful in the package's <prgn>postinst</prgn>, where
6583             <tt>sysuser</tt> is a dynamically allocated id:
6584             <example>
6585 for i in /usr/bin/foo /usr/sbin/bar
6586 do
6587   if ! dpkg-statoverride --list $i >/dev/null
6588   then
6589     dpkg-statoverride --update --add sysuser root 4755 $i
6590   fi
6591 done
6592             </example>
6593             The corresponding <tt>dpkg-statoverride --remove</tt>
6594             calls can then be made unconditionally when the package is
6595             purged.
6596           </p>
6597         </sect1>
6598       </sect>
6599     </chapt>
6600
6601     <chapt id="customized-programs">
6602       <heading>Customized programs</heading>
6603
6604       <sect id="arch-spec">
6605         <heading>Architecture specification strings</heading>
6606
6607         <p>
6608           If a program needs to specify an <em>architecture specification
6609             string</em> in some place, the following format should be
6610             used: <var>arch</var>-<var>os</var><footnote>
6611             <p>
6612               The following architectures and operating systems are
6613               currently recognised by <prgn>dpkg-archictecture</prgn>.
6614               The architecture, <tt><var>arch</var></tt>, is one of
6615               the following: <tt>alpha</tt>, <tt>arm</tt>,
6616               <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6617               <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6618               <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6619               <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>.  The
6620               operating system, <tt><var>os</var></tt>, is one of:
6621               <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6622               <tt>openbsd</tt>.  Use of <tt>gnu</tt> in this string is
6623               reserved for the GNU/Hurd operating system.
6624             </p>
6625           </footnote>.
6626         </p>
6627
6628         <p>
6629           Note that we don't want to use
6630           <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6631           <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6632           since this would make our programs incompatible with other
6633           Linux distributions.  We also don't use something like
6634           <tt><var>arch</var>-unknown-linux</tt>, since the
6635           <tt>unknown</tt> does not look very good.
6636         </p>
6637       </sect>
6638
6639       <sect>
6640         <heading>Daemons</heading>
6641
6642         <p>
6643           The configuration files <file>/etc/services</file>,
6644           <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6645           by the <prgn>netbase</prgn> package and must not be modified
6646           by other packages.
6647         </p>
6648
6649         <p>
6650           If a package requires a new entry in one of these files, the
6651           maintainer should get in contact with the
6652           <prgn>netbase</prgn> maintainer, who will add the entries
6653           and release a new version of the <prgn>netbase</prgn>
6654           package.
6655         </p>
6656
6657         <p>
6658           The configuration file <file>/etc/inetd.conf</file> must not be
6659           modified by the package's scripts except via the
6660           <prgn>update-inetd</prgn> script or the
6661           <file>DebianNet.pm</file> Perl module.  See their documentation
6662           for details on how to add entries.
6663         </p>
6664
6665         <p>
6666           If a package wants to install an example entry into
6667           <file>/etc/inetd.conf</file>, the entry must be preceded with
6668           exactly one hash character (<tt>#</tt>). Such lines are
6669           treated as "commented out by user" by the
6670           <prgn>update-inetd</prgn> script and are not changed or
6671           activated during package updates.
6672         </p>
6673       </sect>
6674
6675       <sect>
6676         <heading>Using pseudo-ttys and modifying wtmp, utmp and
6677         lastlog</heading>
6678
6679         <p>
6680           Some programs need to create pseudo-ttys. This should be done
6681           using Unix98 ptys if the C library supports it. The resulting
6682           program must not be installed setuid root, unless that
6683           is required for other functionality.
6684         </p>
6685
6686         <p>
6687           The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6688           <file>/var/log/lastlog</file> must be installed writeable by
6689           group <tt>utmp</tt>.  Programs which need to modify those
6690           files must be installed setgid <tt>utmp</tt>.
6691         </p>
6692       </sect>
6693
6694       <sect>
6695         <heading>Editors and pagers</heading>
6696
6697         <p>
6698           Some programs have the ability to launch an editor or pager
6699           program to edit or display a text document.  Since there are
6700           lots of different editors and pagers available in the Debian
6701           distribution, the system administrator and each user should
6702           have the possibility to choose his/her preferred editor and
6703           pager.
6704         </p>
6705
6706         <p>
6707           In addition, every program should choose a good default
6708           editor/pager if none is selected by the user or system
6709           administrator.
6710         </p>
6711
6712         <p>
6713           Thus, every program that launches an editor or pager must
6714           use the EDITOR or PAGER environment variable to determine
6715           the editor or pager the user wishes to use.  If these
6716           variables are not set, the programs <file>/usr/bin/editor</file>
6717           and <file>/usr/bin/pager</file> should be used, respectively.
6718         </p>
6719
6720         <p>
6721           These two files are managed through the <prgn>dpkg</prgn>
6722           "alternatives" mechanism.  Thus every package providing an
6723           editor or pager must call the
6724           <prgn>update-alternatives</prgn> script to register these
6725           programs.
6726         </p>
6727
6728         <p>
6729           If it is very hard to adapt a program to make use of the
6730           EDITOR or PAGER variables, that program may be configured to
6731           use <file>/usr/bin/sensible-editor</file> and
6732           <file>/usr/bin/sensible-pager</file> as the editor or pager
6733           program respectively.  These are two scripts provided in the
6734           Debian base system that check the EDITOR and PAGER variables
6735           and launch the appropriate program, and fall back to
6736           <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6737           variable is not set.
6738         </p>
6739
6740         <p>
6741           A program may also use the VISUAL environment variable to
6742           determine the user's choice of editor.  If it exists, it
6743           should take precedence over EDITOR.  This is in fact what
6744           <file>/usr/bin/sensible-editor</file> does.
6745         </p>
6746
6747         <p>
6748           It is not required for a package to depend on
6749           <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6750           package to provide such virtual packages.<footnote>
6751             <p>
6752               The Debian base system already provides an editor and a
6753               pager program,
6754             </p>
6755           </footnote>
6756         </p>
6757       </sect>
6758
6759       <sect id="web-appl">
6760         <heading>Web servers and applications</heading>
6761
6762         <p>
6763           This section describes the locations and URLs that should
6764           be used by all web servers and web applications in the
6765           Debian system.
6766         </p>
6767
6768         <p>
6769           <enumlist>
6770             <item>
6771               <p>
6772                 Cgi-bin executable files are installed in the
6773                 directory
6774                 <example compact="compact">
6775 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6776                 </example>
6777                 and should be referred to as
6778                 <example compact="compact">
6779 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6780                 </example>
6781               </p>
6782             </item>
6783
6784             <item><p>Access to HTML documents</p>
6785
6786               <p>
6787                 HTML documents for a package are stored in
6788                 <file>/usr/share/doc/<var>package</var></file>
6789                 and can be referred to as
6790                 <example compact="compact">
6791 http://localhost/doc/<var>package</var>/<var>filename</var>
6792                 </example>
6793               </p>
6794              <p>
6795                 The web server should restrict access to the document
6796                 tree so that only clients on the same host can read
6797                 the documents. If the web server does not support such
6798                 access controls, then it should not provide access at
6799                 all, or ask about providing access during installation.
6800               </p>
6801             </item>
6802
6803             <item><p>Web Document Root</p>
6804
6805               <p>
6806                 Web Applications should try to avoid storing files in
6807                 the Web Document Root.  Instead they should use the
6808                 /usr/share/doc/<var>package</var> directory for
6809                 documents and register the Web Application via the
6810                 menu package.  If access to the web document root is
6811                 unavoidable then use
6812                 <example compact="compact">
6813 /var/www
6814                 </example>
6815                 as the Document Root.  This might be just a symbolic
6816                 link to the location where the system administrator
6817                 has put the real document root.
6818               </p>
6819             </item>
6820
6821           </enumlist></p></sect>
6822
6823
6824       <sect id="mail-transport-agents">
6825         <heading>Mail transport, delivery and user agents</heading>
6826
6827         <p>
6828           Debian packages which process electronic mail, whether mail
6829           user agents (MUAs) or mail transport agents (MTAs), must
6830           ensure that they are compatible with the configuration
6831           decisions below.  Failure to do this may result in lost
6832           mail, broken <tt>From:</tt> lines, and other serious brain
6833           damage!
6834         </p>
6835
6836         <p>
6837           The mail spool is <file>/var/mail</file> and the interface to
6838           send a mail message is <file>/usr/sbin/sendmail</file> (as per
6839           the FHS).  On older systems, the mail spool may be
6840           physically located in <file>/var/spool/mail</file>, but all
6841           access to the mail spool should be via the
6842           <file>/var/mail</file> symlink.  The mail spool is part of the
6843           base system and not part of the MTA package.
6844         </p>
6845
6846         <p>
6847           All Debian MUAs, MTAs, MDAs and other mailbox accessing
6848           programs (such as IMAP daemons) must lock the mailbox in an
6849           NFS-safe way. This means that <tt>fcntl()</tt> locking must
6850           be combined with dot locking.  To avoid deadlocks, a program
6851           should use <tt>fcntl()</tt> first and dot locking after
6852           this, or alternatively implement the two locking methods in
6853           a non blocking way<footnote>
6854             <p>
6855               If it is not possible to establish both locks, the
6856               system shouldn't wait for the second lock to be
6857               established, but remove the first lock, wait a (random)
6858               time, and start over locking again.
6859             </p>
6860           </footnote>. Using the functions <tt>maillock</tt> and
6861           <tt>mailunlock</tt> provided by the
6862           <tt>liblockfile*</tt><footnote>
6863             <p>
6864               You will need to depend on <tt>liblockfile1
6865                 (&gt;&gt;1.01)</tt> to use these functions.
6866             </p>
6867           </footnote> packages is the recommended way to realize this.
6868         </p>
6869
6870         <p>
6871           Mailboxes are generally mode 660
6872           <tt><var>user</var>.mail</tt> unless the system
6873           administrator has chosen otherwise.  A MUA may remove a
6874           mailbox (unless it has nonstandard permissions) in which
6875           case the MTA or another MUA must recreate it if needed.
6876           Mailboxes must be writable by group mail.
6877         </p>
6878
6879         <p>
6880           The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6881           be setgid mail to do the locking mentioned above (and
6882           must obviously avoid accessing other users' mailboxes
6883           using this privilege).</p>
6884
6885         <p>
6886           <file>/etc/aliases</file> is the source file for the system mail
6887           aliases (e.g., postmaster, usenet, etc.), it is the one
6888           which the sysadmin and <prgn>postinst</prgn> scripts may
6889           edit.  After <file>/etc/aliases</file> is edited the program or
6890           human editing it must call <prgn>newaliases</prgn>.  All MTA
6891           packages must come with a <prgn>newaliases</prgn> program,
6892           even if it does nothing, but older MTA packages did not do
6893           this so programs should not fail if <prgn>newaliases</prgn>
6894           cannot be found.  Note that because of this, all MTA
6895           packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6896           <tt>Replaces: mail-transport-agent</tt> control file
6897           fields.
6898         </p>
6899
6900         <p>
6901           The convention of writing <tt>forward to
6902             <var>address</var></tt> in the mailbox itself is not
6903           supported.  Use a <tt>.forward</tt> file instead.</p>
6904
6905         <p>
6906           The <prgn>rmail</prgn> program used by UUCP
6907           for incoming mail should be  <file>/usr/sbin/rmail</file>.
6908           Likewise, <prgn>rsmtp</prgn>, for receiving
6909           batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6910           is supported.</p>
6911
6912         <p>
6913           If your package needs to know what hostname to use on (for
6914           example) outgoing news and mail messages which are generated
6915           locally, you should use the file <file>/etc/mailname</file>.  It
6916           will contain the portion after the username and <tt>@</tt>
6917           (at) sign for email addresses of users on the machine
6918           (followed by a newline).
6919         </p>
6920
6921         <p>
6922           Such package should check for the existence of this file
6923           when it is being configured.  If it exists, it should be
6924           used without comment, although an MTA's configuration script
6925           may wish to prompt the user even if it finds that this file
6926           exists.  If the file does not exist, the package should
6927           prompt the user for the value (preferably using
6928           <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6929           as well as using it in the package's configuration.  The
6930           prompt should make it clear that the name will not just be
6931           used by that package.  For example, in this situation the
6932           <tt>inn</tt> package could say something like:
6933           <example compact="compact">
6934 Please enter the "mail name" of your system.  This is the
6935 hostname portion of the address to be shown on outgoing
6936 news and mail messages.  The default is
6937 <var>syshostname</var>, your system's host name.  Mail
6938 name ["<var>syshostname</var>"]:
6939           </example>
6940           where <var>syshostname</var> is the output of <tt>hostname
6941             --fqdn</tt>.
6942         </p>
6943       </sect>
6944
6945       <sect>
6946         <heading>News system configuration</heading>
6947
6948         <p>
6949           All the configuration files related to the NNTP (news)
6950           servers and clients should be located under
6951           <file>/etc/news</file>.</p>
6952
6953         <p>
6954           There are some configuration issues that apply to a number
6955           of news clients and server packages on the machine. These
6956           are:
6957
6958           <taglist>
6959             <tag><file>/etc/news/organization</file></tag>
6960             <item><p>A string which should appear as the
6961                 organization header for all messages posted
6962                 by NNTP clients on the machine</p></item>
6963
6964             <tag><file>/etc/news/server</file></tag>
6965             <item><p>Contains the FQDN of the upstream NNTP
6966                 server, or localhost if the local machine is
6967                 an NNTP server.</p></item>
6968           </taglist>
6969
6970           Other global files may be added as required for cross-package news
6971           configuration.</p></sect>
6972
6973
6974       <sect>
6975         <heading>Programs for the X Window System</heading>
6976
6977         <sect1>
6978           <heading>Providing X support and package priorities</heading>
6979
6980           <p>
6981             Programs that can be configured with support for the X
6982             Window System must be configured to do so and must declare
6983             any package dependencies necessary to satisfy their
6984             runtime requirements when using the X Window System.  If
6985             such a package is of higher priority than the X packages
6986             on which it depends, it is required that either the
6987             X-specific components be split into a separate package, or
6988             that an alternative version of the package, which includes
6989             X support, be provided, or that the package's priority be
6990             lowered.
6991           </p>
6992         </sect1>
6993
6994         <sect1>
6995           <heading>Packages providing an X server</heading>
6996
6997           <p>
6998             Packages that provide an X server that, directly or
6999             indirectly, communicates with real input and display
7000             hardware should declare in their control data that they
7001             provide the virtual package <tt>xserver</tt>.<footnote>
7002               <p>
7003                 This implements current practice, and provides an
7004                 actual policy for usage of the <tt>xserver</tt>
7005                 virtual package which appears in the virtual packages
7006                 list.  In a nutshell, X servers that interface
7007                 directly with the display and input hardware or via
7008                 another subsystem (e.g., GGI) should provide
7009                 <tt>xserver</tt>.  Things like <tt>Xvfb</tt>,
7010                 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
7011               </p>
7012             </footnote>
7013           </p>
7014         </sect1>
7015
7016         <sect1>
7017           <heading>Packages providing a terminal emulator</heading>
7018
7019           <p>
7020             Packages that provide a terminal emulator for the X Window
7021             System which meet the criteria listed below should declare
7022             in their control data that they provide the virtual
7023             package <tt>x-terminal-emulator</tt>.  They should also
7024             register themselves as an alternative for
7025             <file>/usr/bin/x-terminal-emulator</file>, with a priority of
7026             20.
7027           </p>
7028
7029           <p>
7030             To be an <tt>x-terminal-emulator</tt>, a program must:
7031             <list compact="compact">
7032               <item><p>
7033                   Be able to emulate a DEC VT100 terminal, or a
7034                   compatible terminal.
7035                 </p></item>
7036
7037               <item><p>
7038                   Support the command-line option <tt>-e
7039                     <var>command</var></tt>, which creates a new
7040                   terminal window<footnote>
7041                     <p>
7042                       "New terminal window" does not necessarily mean
7043                       a new top-level X window directly parented by
7044                       the window manager; it could, if the terminal
7045                       emulator application were so coded, be a new
7046                       "view" in a multiple-document interface (MDI).
7047                     </p>
7048                   </footnote>
7049                   and runs the specified <var>command</var>.
7050                 </p></item>
7051
7052               <item><p>
7053                   Support the command-line option <tt>-T
7054                     <var>title</var></tt>, which creates a new terminal
7055                   window with the window title <var>title</var>.
7056                 </p></item>
7057             </list>
7058           </p>
7059         </sect1>
7060
7061         <sect1>
7062           <heading>Packages providing a window manager</heading>
7063
7064           <p>
7065             Packages that provide a window manager should declare in
7066             their control data that they provide the virtual package
7067             <tt>x-window-manager</tt>.  They should also register
7068             themselves as an alternative for
7069             <file>/usr/bin/x-window-manager</file>, with a priority
7070             calculated as follows:
7071             <list compact="compact">
7072               <item><p>Start with a priority of 20.</p></item>
7073
7074               <item>
7075                 <p>
7076                   If the window manager supports the Debian menu
7077                   system, add 20 points if this support is available
7078                   in the package's default configuration (i.e., no
7079                   configuration files belonging to the system or user
7080                   have to be edited to activate the feature); if
7081                   configuration files must be modified, add only 10
7082                   points.
7083                 </p>
7084               </item>
7085               <item>
7086                 <p>
7087                   If the window manager complies with  <url
7088                     id="http://www.freedesktop.org/standards/wm-spec.html"
7089                     name="The Window Manager Specification Project">,
7090                   written by the <url id="http://www.freedesktop.org"
7091                     name="Free Desktop Group">, add 20 points.
7092                 </p>
7093               </item>
7094
7095               <item>
7096                 <p>
7097                   If the window manager permits the X session to be
7098                   restarted using a <em>different</em> window manager
7099                   (without killing the X server) in its default
7100                   configuration, add 10 points; otherwise add none.
7101                 </p>
7102               </item>
7103             </list>
7104           </p>
7105         </sect1>
7106
7107         <sect1>
7108           <heading>Packages providing fonts</heading>
7109
7110           <p>
7111             Packages that provide fonts for the X Window
7112             System<footnote>
7113               <p>
7114                 For the purposes of Debian Policy, a "font for the X
7115                 Window System" is one which is accessed via X protocol
7116                 requests.  Fonts for the Linux console, for PostScript
7117                 renderers, or any other purpose, do not fit this
7118                 definition.  Any tool which makes such fonts available
7119                 to the X Window System, however, must abide by this
7120                 font policy.
7121               </p>
7122             </footnote>
7123             must do a number of things to ensure that they are both
7124             available without modification of the X or font server
7125             configuration, and that they do not corrupt files used by
7126             other font packages to register information about
7127             themselves.
7128             <enumlist>
7129               <item>
7130                 <p>
7131                   Fonts of any type supported by the X Window System
7132                   must be in a separate binary package from any
7133                   executables, libraries, or documentation (except
7134                   that specific to the fonts shipped, such as their
7135                   license information).  If one or more of the fonts
7136                   so packaged are necessary for proper operation of
7137                   the package with which they are associated the font
7138                   package may be Recommended; if the fonts merely
7139                   provide an enhancement, a Suggests relationship may
7140                   be used.  Packages must not Depend on font
7141                   packages.<footnote>
7142                     <p>
7143                       This is because the X server may retrieve fonts
7144                       from the local filesystem or over the network
7145                       from an X font server; the Debian package system
7146                       is empowered to deal only with the local
7147                       filesystem.
7148                     </p>
7149                   </footnote>
7150                 </p>
7151               </item>
7152
7153               <item>
7154                 <p>
7155                   BDF fonts must be converted to PCF fonts with the
7156                   <prgn>bdftopcf</prgn> utility (available in the
7157                   <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7158                   placed in a directory that corresponds to their
7159                   resolution:
7160                   <list compact="compact">
7161                     <item><p>
7162                         100 dpi fonts must be placed in
7163                         <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7164                       </p></item>
7165
7166                     <item><p>
7167                         75 dpi fonts must be placed in
7168                         <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7169                       </p></item>
7170
7171                     <item><p>
7172                         Character-cell fonts, cursor fonts, and other
7173                         low-resolution fonts must be placed in
7174                         <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7175                       </p></item>
7176                   </list>
7177                 </p>
7178               </item>
7179
7180               <item><p>
7181                   Speedo fonts must be placed in
7182                   <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7183                 </p></item>
7184
7185               <item><p>
7186                   Type 1 fonts must be placed in
7187                   <file>/usr/X11R6/lib/X11/fonts/Type1/</file>.  If font
7188                   metric files are available, they must be placed here
7189                   as well.
7190                 </p></item>
7191
7192               <item>
7193                 <p>
7194                   Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7195                   other than those listed above must be neither
7196                   created nor used.  (The <file>PEX</file>, <file>CID</file>,
7197                   and <file>cyrillic</file> directories are excepted for
7198                   historical reasons, but installation of files into
7199                   these directories remains discouraged.)
7200                 </p>
7201               </item>
7202
7203               <item>
7204                 <p>
7205                   Font packages may, instead of placing files directly
7206                   in the X font directories listed above, provide
7207                   symbolic links in that font directory pointing to
7208                   the files' actual location in the filesystem.  Such
7209                   a location must comply with the FHS.
7210                 </p>
7211               </item>
7212
7213               <item>
7214                 <p>
7215                   Font packages should not contain both 75dpi and
7216                   100dpi versions of a font.  If both are available,
7217                   they should be provided in separate binary packages
7218                   with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7219                   the names of the packages containing the
7220                   corresponding fonts.
7221                 </p>
7222               </item>
7223
7224               <item>
7225                 <p>
7226                   Fonts destined for the <file>misc</file> subdirectory
7227                   should not be included in the same package as 75dpi
7228                   or 100dpi fonts; instead, they should be provided in
7229                   a separate package with <tt>-misc</tt> appended to
7230                   its name.
7231                 </p>
7232               </item>
7233
7234               <item>
7235                 <p>
7236                   Font packages must not provide the files
7237                   <file>fonts.dir</file>, <file>fonts.alias</file>, or
7238                   <file>fonts.scale</file> in a font directory:
7239                   <list>
7240                     <item><p>
7241                         <file>fonts.dir</file> files must not be provided at all.
7242                       </p></item>
7243
7244                     <item>
7245                       <p>
7246                         <file>fonts.alias</file> and <file>fonts.scale</file>
7247                         files, if needed, should be provided in the
7248                         directory
7249                         <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7250                         where <var>fontdir</var> is the name of the
7251                         subdirectory of
7252                         <file>/usr/X11R6/lib/X11/fonts/</file> where the
7253                         package's corresponding fonts are stored
7254                         (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7255                         <var>package</var> is the name of the package
7256                         that provides these fonts, and
7257                         <var>extension</var> is either <tt>scale</tt>
7258                         or <tt>alias</tt>, whichever corresponds to
7259                         the file contents.
7260                       </p>
7261                     </item>
7262                   </list>
7263                 </p>
7264               </item>
7265
7266               <item>
7267                 <p>
7268                   Font packages must declare a dependency on
7269                   <tt>xutils (&gt;&gt; 4.0.3)</tt> in their control
7270                   data.
7271                 </p>
7272               </item>
7273
7274               <item>
7275                 <p>
7276                   Font packages that provide one or more
7277                   <file>fonts.scale</file> files as described above must
7278                   invoke <prgn>update-fonts-scale</prgn> on each
7279                   directory into which they installed fonts
7280                   <em>before</em> invoking
7281                   <prgn>update-fonts-dir</prgn> on that directory.
7282                   This invocation must occur in both the
7283                   <prgn>postinst</prgn> (for all arguments) and
7284                   <prgn>postrm</prgn> (for all arguments except
7285                   <tt>upgrade</tt>) scripts.
7286                 </p>
7287               </item>
7288
7289               <item>
7290                 <p>
7291                   Font packages that provide one or more
7292                   <file>fonts.alias</file> files as described above must
7293                   invoke <prgn>update-fonts-alias</prgn> on each
7294                   directory into which they installed fonts.  This
7295                   invocation must occur in both the
7296                   <prgn>postinst</prgn> (for all arguments) and
7297                   <prgn>postrm</prgn> (for all arguments except
7298                   <tt>upgrade</tt>) scripts.
7299                 </p>
7300               </item>
7301
7302               <item>
7303                 <p>
7304                   Font packages must invoke
7305                   <prgn>update-fonts-dir</prgn> on each directory into
7306                   which they installed fonts.  This invocation must
7307                   occur in both the <prgn>postinst</prgn> (for all
7308                   arguments) and <prgn>postrm</prgn> (for all
7309                   arguments except <tt>upgrade</tt>) scripts.
7310                 </p>
7311               </item>
7312
7313               <item>
7314                 <p>
7315                   Font packages must not provide alias names for the
7316                   fonts they include which collide with alias names
7317                   already in use by fonts already packaged.
7318                 </p>
7319               </item>
7320
7321               <item>
7322                 <p>
7323                   Font packages must not provide fonts with the same
7324                   XLFD registry name as another font already packaged.
7325                 </p>
7326               </item>
7327             </enumlist>
7328           </p>
7329         </sect1>
7330
7331         <sect1>
7332           <heading>Application defaults files</heading>
7333
7334           <p>
7335             Application defaults files must be installed in the
7336             directory <file>/etc/X11/app-defaults/</file> (use of a
7337             localized subdirectory of <file>/etc/X11/</file> as described
7338             in the <em>X Toolkit Intrinsics - C Language
7339             Interface</em> manual is also permitted).  They must be
7340             registered as <tt>conffile</tt>s or handled as
7341             configuration files.  Packages must not provide the
7342             directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7343           </p>
7344
7345           <p>
7346             Customization of programs' X resources may also be
7347             supported with the provision of a file with the same name
7348             as that of the package placed in the
7349             <file>/etc/X11/Xresources/</file> directory, which must
7350             registered as a <tt>conffile</tt> or handled as a
7351             configuration file.<footnote>
7352               <p>
7353                 Note that this mechanism is not the same as using
7354                 app-defaults; app-defaults are tied to the client
7355                 binary on the local filesystem, whereas X resources
7356                 are stored in the X server and affect all connecting
7357                 clients.
7358               </p>
7359             </footnote>
7360             <em>Important:</em> packages that install files into the
7361             <file>/etc/X11/Xresources/</file> directory must conflict with
7362             <tt>xbase (&lt;&lt; 3.3.2.3a-2)</tt>; if this is not done
7363             it is possible for the installing package to destroy a
7364             previously-existing <file>/etc/X11/Xresources</file> file
7365             which had been customized by the system administrator.
7366           </p>
7367         </sect1>
7368
7369         <sect1>
7370           <heading>Installation directory issues</heading>
7371
7372           <p>
7373             Packages using the X Window System should not be
7374             configured to install files under the <file>/usr/X11R6/</file>
7375             directory unless they use <prgn>imake</prgn>. The
7376             <file>/usr/X11R6/</file> directory hierarchy should be
7377             regarded as deprecated for all packages except the X
7378             Window System itself, and those which use the
7379             <prgn>imake</prgn> program it provides, in which case the
7380             packages may transition out of the <file>/usr/X11R6/</file>
7381             directory at the maintainer's discretion.<footnote>
7382               <p>
7383                 <prgn>Imake</prgn>-using programs are exempt because,
7384                 as long as they are written correctly, the pathnames
7385                 they use to locate resources and install themselves
7386                 are derived wholly from the X Window System
7387                 configuration.  Thus, in the event that the X Window
7388                 System moves to <file>/usr/X11R7/</file>,
7389                 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7390                 that is required for these programs is a recompile
7391                 against the corresponding X Window System library
7392                 development packages.
7393               </p>
7394             </footnote>
7395             Programs that use GNU <prgn>autoconf</prgn> and
7396             <prgn>automake</prgn> are usually easily configured at
7397             compile time to use <file>/usr/</file> instead of
7398             <file>/usr/X11R6/</file>, and this should be done whenever
7399             possible.  Configuration files for window managers and
7400             display managers should be placed in a subdirectory of
7401             <file>/etc/X11/</file> corresponding to the package name due
7402             to these programs' tight integration with the mechanisms
7403             of the X Window System.  Application-level programs should
7404             use the <file>/etc/</file> directory unless otherwise mandated
7405             by policy.  The installation of files into subdirectories
7406             of <file>/usr/X11R6/include/X11/</file> and
7407             <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7408             package maintainers should determine if subdirectories of
7409             <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7410             instead.  (The use of symbolic links from the
7411             <file>X11R6</file> directories to other FHS-compliant
7412             locations is encouraged if the program is not easily
7413             configured to look elsewhere for its files.)  Packages
7414             must not provide or install files into the directories
7415             <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7416             <file>/usr/lib/X11/</file>.  Files within a package should,
7417             however, make reference to these directories, rather than
7418             their <tt>X11R6</tt>-named counterparts
7419             <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7420             and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7421             referred to have not been moved to other FHS-compliant
7422             locations.
7423           </p>
7424         </sect1>
7425
7426         <sect1>
7427           <heading>The OSF/Motif and OpenMotif libraries</heading>
7428
7429           <p>
7430             <em>Programs that require the non-DFSG-compliant OSF/Motif or
7431               OpenMotif libraries</em><footnote>
7432               <p>
7433                 OSF/Motif and OpenMotif are collectively referred to as
7434                 "Motif" in this policy document.
7435               </p>
7436             </footnote>
7437             should be compiled against and tested with LessTif (a free
7438             re-implementation of Motif) instead.  If the maintainer
7439             judges that the program or programs do not work
7440             sufficiently well with LessTif to be distributed and
7441             supported, but do so when compiled against Motif, then two
7442             versions of the package should be created; one linked
7443             statically against Motif and with <tt>-smotif</tt>
7444             appended to the package name, and one linked dynamically
7445             against Motif and with <tt>-dmotif</tt> appended to the
7446             package name.  Both Motif-linked versions are dependent
7447             upon non-DFSG-compliant software and thus cannot be
7448             uploaded to the <em>main</em> distribution; if the
7449             software is itself DFSG-compliant it may be uploaded to
7450             the <em>contrib</em> distribution.  While known existing
7451             versions of Motif permit unlimited redistribution of
7452             binaries linked against the library (whether statically or
7453             dynamically), it is the package maintainer's
7454             responsibility to determine whether this is permitted by
7455             the license of the copy of Motif in his or her possession.
7456           </p>
7457         </sect1>
7458       </sect>
7459
7460       <sect>
7461         <heading>Perl programs and modules</heading>
7462         <p>
7463           Perl programs and modules should follow the current Perl
7464           policy as defined in the file found on
7465           <ftpsite>ftp.debian.org</ftpsite> in
7466           <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>
7467           or your local mirror.  In addition, it is included in the
7468           <tt>debian-policy</tt> package.
7469         </p>
7470       </sect>
7471
7472       <sect>
7473         <heading>Emacs lisp programs</heading>
7474
7475         <p>
7476           Please refer to the "Debian Emacs Policy" (documented in
7477           <file>debian-emacs-policy.gz</file> of the
7478           <prgn>emacsen-common</prgn> package) for details of how to
7479           package emacs lisp programs.
7480         </p>
7481       </sect>
7482
7483       <sect>
7484         <heading>Games</heading>
7485
7486         <p>
7487           The permissions on <file>/var/games</file> are mode 755, owner
7488           <tt>root</tt> and group <tt>root</tt>.
7489         </p>
7490
7491         <p>
7492           Each game decides on its own security policy.</p>
7493
7494         <p>
7495           Games which require protected, privileged access to
7496           high-score files, savegames, etc., may be made
7497           set-<em>group</em>-id (mode 2755) and owned by
7498           <tt>root.games</tt>, and use files and directories with
7499           appropriate permissions (770 <tt>root.games</tt>, for
7500           example).  They must not be made
7501           set-<em>user</em>-id, as this causes security problems. (If
7502           an attacker can subvert any set-user-id game they can
7503           overwrite the executable of any other, causing other players
7504           of these games to run a Trojan horse program.  With a
7505           set-group-id game the attacker only gets access to less
7506           important game data, and if they can get at the other
7507           players' accounts at all it will take considerably more
7508           effort.)</p>
7509
7510         <p>
7511           Some packages, for example some fortune cookie programs, are
7512           configured by the upstream authors to install with their
7513           data files or other static information made unreadable so
7514           that they can only be accessed through set-id programs
7515           provided.  You should not do this in a Debian package: anyone can
7516           download the <file>.deb</file> file and read the data from it,
7517           so there is no point making the files unreadable.  Not
7518           making the files unreadable also means that you don't have
7519           to make so many programs set-id, which reduces the risk of a
7520           security hole.</p>
7521
7522         <p>
7523           As described in the FHS, binaries of games should be
7524           installed in the directory <file>/usr/games</file>. This also
7525           applies to games that use the X Window System. Manual pages
7526           for games (X and non-X games) should be installed in
7527           <file>/usr/share/man/man6</file>.</p>
7528       </sect>
7529     </chapt>
7530
7531     <chapt id="docs"><heading>Documentation</heading>
7532
7533
7534       <sect>
7535         <heading>Manual pages</heading>
7536
7537         <p>
7538           You should install manual pages in <prgn>nroff</prgn> source
7539           form, in appropriate places under <file>/usr/share/man</file>.
7540           You should only use sections 1 to 9 (see the FHS for more
7541           details).  You must not install a preformatted "cat page".
7542         </p>
7543
7544         <p>
7545           Each program, utility, and function should have an
7546           associated manual page included in the same package. It is
7547           suggested that all configuration files also have a manual
7548           page included as well. Manual pages for protocols and other
7549           auxiliary things are optional.
7550         </p>
7551
7552         <p>
7553           If no manual page is available, this is considered as a bug
7554           and should be reported to the Debian Bug Tracking System (the
7555           maintainer of the package is allowed to write this bug report
7556           themselves, if they so desire).  Do not close the bug report
7557           until a proper manpage is available.<footnote>
7558             <p>
7559               It is not very hard to write a man page. See the 
7560               <url id="http://www.schweikhardt.net/man_page_howto.html"
7561                 name="Man-Page-HOWTO">, 
7562               <manref name="man" section="7">, the examples
7563               created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7564               the helper programs <prgn>help2man</prgn>, or the
7565               directory <file>/usr/share/doc/man-db/examples</file>.
7566             </p>
7567           </footnote>
7568         </p>
7569
7570         <p>
7571           You may forward a complaint about a missing manpage to the
7572           upstream authors, and mark the bug as forwarded in the
7573           Debian bug tracking system.  Even though the GNU Project do
7574           not in general consider the lack of a manpage to be a bug,
7575           we do; if they tell you that they don't consider it a bug
7576           you should leave the bug in our bug tracking system open
7577           anyway.
7578         </p>
7579
7580         <p>
7581           Manual pages should be installed compressed using <tt>gzip -9</tt>.
7582         </p>
7583
7584         <p>
7585           If one manpage needs to be accessible via several names it
7586           is better to use a symbolic link than the <file>.so</file>
7587           feature, but there is no need to fiddle with the relevant
7588           parts of the upstream source to change from <file>.so</file> to
7589           symlinks: don't do it unless it's easy.  You should not
7590           create hard links in the manual page directories, nor put
7591           absolute filenames in <file>.so</file> directives.  The filename
7592           in a <file>.so</file> in a manpage should be relative to the
7593           base of the manpage tree (usually
7594           <file>/usr/share/man</file>). If you do not create any links
7595           (whether symlinks, hard links, or <tt>.so</tt> directives)
7596           in the filesystem to the alternate names of the manpage,
7597           then you should not rely on <prgn>man</prgn> finding your
7598           manpage under those names based solely on the information in
7599           the manpage's header.<footnote>
7600             <p>
7601               Supporting this in <prgn>man</prgn> often requires
7602               unreasonable processing time to find a manual page or to
7603               report that none exists, and moves knowledge into man's
7604               database that would be better left in the filesystem.
7605               This support is therefore deprecated and will cease to
7606               be present in the future.
7607             </p>
7608           </footnote>
7609         </p>
7610       </sect>
7611
7612       <sect>
7613         <heading>Info documents</heading>
7614
7615         <p>
7616           Info documents should be installed in <file>/usr/share/info</file>.
7617           They should be compressed with <tt>gzip -9</tt>.
7618         </p>
7619
7620         <p>
7621           Your package should call <prgn>install-info</prgn> to update
7622           the Info <file>dir</file> file in its <prgn>postinst</prgn>
7623           script when called with a <tt>configure</tt> argument, for
7624           example:
7625           <example compact="compact">
7626 install-info --quiet --section Development Development \
7627   /usr/share/info/foobar.info
7628           </example></p>
7629
7630         <p>
7631           It is a good idea to specify a section for the location of
7632           your program; this is done with the <tt>--section</tt>
7633           switch.  To determine which section to use, you should look
7634           at <file>/usr/share/info/dir</file> on your system and choose the most
7635           relevant (or create a new section if none of the current
7636           sections are relevant).  Note that the <tt>--section</tt>
7637           flag takes two arguments; the first is a regular expression
7638           to match (case-insensitively) against an existing section,
7639           the second is used when creating a new one.</p>
7640
7641         <p>
7642           You should remove the entries in the <prgn>prerm</prgn>
7643           script when called with a <tt>remove</tt> argument:
7644           <example compact="compact">
7645 install-info --quiet --remove /usr/share/info/foobar.info
7646           </example></p>
7647
7648         <p>
7649           If <prgn>install-info</prgn> cannot find a description entry
7650           in the Info file you must supply one.  See <manref
7651           name="install-info" section="8"> for details.</p>
7652       </sect>
7653
7654       <sect>
7655         <heading>Additional documentation</heading>
7656
7657         <p>
7658           Any additional documentation that comes with the package may
7659           be installed at the discretion of the package maintainer.
7660           Text documentation should be installed in the directory
7661           <file>/usr/share/doc/<var>package</var></file>, where
7662           <var>package</var> is the name of the package, and
7663           compressed with <tt>gzip -9</tt> unless it is small.
7664         </p>
7665
7666         <p>
7667           If a package comes with large amounts of documentation which
7668           many users of the package will not require you should create
7669           a separate binary package to contain it, so that it does not
7670           take up disk space on the machines of users who do not need
7671           or want it installed.</p>
7672
7673         <p>
7674           It is often a good idea to put text information files
7675           (<file>README</file>s, changelogs, and so forth) that come with
7676           the source package in <file>/usr/share/doc/<var>package</var></file>
7677           in the binary package.  However, you don't need to install
7678           the instructions for building and installing the package, of
7679           course!</p>
7680
7681         <p>
7682           Packages must not require the existance of any files in
7683           <file>/usr/share/doc/</file> in order to function
7684           <footnote>
7685             <p>
7686               The system administrator should be able to
7687               delete files in <file>/usr/share/doc/</file> without causing
7688               any programs to break.
7689             </p>
7690           </footnote>.
7691           Any files that are referenced by programs but are also
7692           useful as standalone documentation should be installed under
7693           <file>/usr/share/<var>package</var>/</file> with symbolic links from
7694           <file>/usr/share/doc/<var>package</var></file>.
7695         </p>
7696
7697         <p>
7698           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7699           link to another directory in <file>/usr/share/doc</file> only if
7700           the two packages both come from the same source and the
7701           first package Depends on the second.
7702         </p>
7703
7704         <p>
7705           Former Debian releases placed all additional documentation
7706           in <file>/usr/doc/<var>package</var></file>.  This has been
7707           changed to <file>/usr/share/doc/<var>package</var></file>,
7708           and packages must not put documentation in the directory
7709           <file>/usr/doc/<var>package</var></file>. <footnote>
7710             <p>At this phase of the transition, we no longer require a
7711             symbolic link in <file>/usr/doc/</file>. At a later point,
7712             policy shall change to make the symbolic links a bug.</p>
7713           </footnote>
7714         </p>
7715       </sect>
7716
7717       <sect>
7718         <heading>Preferred documentation formats</heading>
7719
7720         <p>
7721           The unification of Debian documentation is being carried out
7722           via HTML.</p>
7723
7724         <p>
7725           If your package comes with extensive documentation in a
7726           markup format that can be converted to various other formats
7727           you should if possible ship HTML versions in a binary
7728           package, in the directory
7729           <file>/usr/share/doc/<var>appropriate-package</var></file> or
7730           its subdirectories.<footnote>
7731             <p>
7732               The rationale: The important thing here is that HTML
7733               docs should be available in <em>some</em> package, not
7734               necessarily in the main binary package.
7735             </p>
7736           </footnote>
7737         </p>
7738
7739         <p>
7740           Other formats such as PostScript may be provided at the
7741           package maintainer's discretion.
7742         </p>
7743       </sect>
7744
7745       <sect id="copyrightfile">
7746         <heading>Copyright information</heading>
7747
7748         <p>
7749           Every package must be accompanied by a verbatim copy of its
7750           copyright and distribution license in the file
7751           <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7752           file must neither be compressed nor be a symbolic link.
7753         </p>
7754
7755         <p>
7756           In addition, the copyright file must say where the upstream
7757           sources (if any) were obtained.  It should name the original
7758           authors of the package and the Debian maintainer(s) who were
7759           involved with its creation.</p>
7760
7761         <p>
7762           A copy of the file which will be installed in
7763           <file>/usr/share/doc/<var>package</var>/copyright</file> should
7764           be in <file>debian/copyright</file> in the source package.
7765         </p>
7766
7767         <p>
7768           <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7769           link to another directory in <file>/usr/share/doc</file> only if
7770           the two packages both come from the same source and the
7771           first package Depends on the second.  These rules are
7772           important because copyrights must be extractable by
7773           mechanical means.
7774         </p>
7775
7776         <p>
7777           Packages distributed under the UCB BSD license, the Artistic
7778           license, the GNU GPL, and the GNU LGPL should refer to the
7779           files <file>/usr/share/common-licenses/BSD</file>,
7780           <file>/usr/share/common-licenses/Artistic</file>,
7781           <file>/usr/share/common-licenses/GPL</file>, and
7782           <file>/usr/share/common-licenses/LGPL</file> respectively,
7783           rather than quoting them in the copyright file.
7784         </p>
7785
7786         <p>
7787           You should not use the copyright file as a general <file>README</file>
7788           file.  If your package has such a file it should be
7789           installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7790           <file>README.Debian</file> or some other appropriate place.</p>
7791       </sect>
7792
7793       <sect>
7794         <heading>Examples</heading>
7795
7796         <p>
7797           Any examples (configurations, source files, whatever),
7798           should be installed in a directory
7799           <file>/usr/share/doc/<var>package</var>/examples</file>.  These
7800           files should not be referenced by any program: they're there
7801           for the benefit of the system administrator and users as
7802           documentation only.  Architecture-specific example files
7803           should be installed in a directory
7804           <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7805           links to them from
7806           <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7807           latter directory itself may be a symbolic link to the
7808           former.
7809         </p>
7810
7811         <p>
7812           If the purpose of a package is to provide examples, then the
7813           example files may be installed into
7814           <file>/usr/share/doc/<var>package</var></file>.
7815         </p>
7816       </sect>
7817
7818       <sect id="changelogs">
7819         <heading>Changelog files</heading>
7820
7821         <p>
7822           The Debian changelog file (<file>debian/changelog</file>) should
7823           explain briefly what modifications were made in the Debian version
7824           of the package compared to the upstream one. Other changes and
7825           updates to the package should also be documented in this file.
7826         </p>
7827
7828         <p>
7829           Mistakes in changelogs are usually best rectified by
7830           making a new changelog entry rather than "rewriting history"
7831           by editing old changelog entries.
7832         </p>
7833
7834         <p>
7835           The format of the <file>debian/changelog</file> file is described
7836           in <ref id="dpkgchangelog">. In non-experimental packages you must
7837           use a format for <file>debian/changelog</file> which is supported
7838           by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7839             <p>
7840               If you wish to use an alternative format, you may do so as
7841               long as you include a parser for it in your source package.
7842               The parser must have an API compatible with that expected by
7843               <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7844               If there is general interest in the new format, you should
7845               contact the <package>dpkg</package> maintainer to have the
7846               parser script for it included in the <prgn>dpkg</prgn>
7847               package.  (You will need to agree that the parser and its
7848               manpage may be distributed under the GNU GPL, just as the rest
7849               of <prgn>dpkg</prgn> is.)
7850             </p>
7851           </footnote>
7852         </p>
7853
7854         <p>
7855           Packages that are not Debian-native must contain a
7856           compressed copy of the <file>debian/changelog</file> file from
7857           the Debian source tree in
7858           <file>/usr/share/doc/<var>package</var></file> with the name
7859           <file>changelog.Debian.gz</file>.
7860         </p>
7861
7862         <p>
7863           If an upstream changelog is available, it should be accessible as
7864           <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7865           plain text.  If the upstream changelog is distributed in
7866           HTML, it should be made available in that form as
7867           <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7868           and a plain text <file>changelog.gz</file> should be generated
7869           from it using, for example, <tt>lynx -dump -nolist</tt>.  If
7870           the upstream changelog files do not already conform to this
7871           naming convention, then this may be achieved either by
7872           renaming the files, or by adding a symbolic link, at the
7873           maintainer's discretion.<footnote>
7874             <p>
7875               Rationale: People should not have to look in places for
7876               upstream changelogs merely because they are given
7877               different names or are distributed in HTML format.
7878             </p>
7879           </footnote>
7880         </p>
7881
7882         <p>
7883           All of these files should be installed compressed using
7884           <tt>gzip -9</tt>, as they will become large with time even
7885           if they start out small.
7886         </p>
7887
7888         <p>
7889           If the package has only one changelog which is used both as
7890           the Debian changelog and the upstream one because there is
7891           no separate upstream maintainer then that changelog should
7892           usually be installed as
7893           <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7894           there is a separate upstream maintainer, but no upstream
7895           changelog, then the Debian changelog should still be called
7896           <file>changelog.Debian.gz</file>.</p>
7897
7898       </sect>
7899     </chapt>
7900
7901     <appendix id="pkg-scope">
7902       <heading>Introduction and scope of these appendices</heading>
7903
7904       <p>
7905         These appendices are taken essentially verbatim from the
7906         now-deprecated Packaging Manual, version 3.2.1.0.  They are
7907         the chapters which are likely to be of use to package
7908         maintainers and which have not already been included in the
7909         policy document itself. Most of these sections are very likely
7910         not relevant to policy; they should be treated as
7911         documentation for the packaging system. Please note that these
7912         appendices are included for convenience, and for historical
7913         reasons: they used to be part of policy package, and they have
7914         not yet been incorporated into dpkg documentation. However,
7915         they still have value, and hence they are presented here.
7916       </p>
7917       <p>
7918         They have not yet been checked to ensure that they are
7919         compatible with the contents of policy, and if there are any
7920         contradictions, the version in the main policy document takes
7921         precedence.  The remaining chapters of the old Packaging
7922         Manual have also not been read in detail to ensure that there
7923         are not parts which have been left out.  Both of these will be
7924         done in due course.
7925       </p>
7926
7927       <p>
7928         <prgn>dpkg</prgn> is a suite of programs for creating binary
7929         package files and installing and removing them on Unix
7930         systems.<footnote>
7931           <p>
7932             <prgn>dpkg</prgn> is targetted primarily at Debian
7933             GNU/Linux, but may work on or be ported to other
7934             systems.
7935           </p>
7936         </footnote>
7937       </p>
7938
7939       <p>
7940         The binary packages are designed for the management of
7941         installed executable programs (usually compiled binaries) and
7942         their associated data, though source code examples and
7943         documentation are provided as part of some packages.</p>
7944
7945       <p>
7946         This manual describes the technical aspects of creating Debian
7947         binary packages (<file>.deb</file> files).  It documents the
7948         behaviour of the package management programs
7949         <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7950         they interact with packages.</p>
7951
7952       <p>
7953         It also documents the interaction between
7954         <prgn>dselect</prgn>'s core and the access method scripts it
7955         uses to actually install the selected packages, and describes
7956         how to create a new access method.</p>
7957
7958       <p>
7959         This manual does not go into detail about the options and
7960         usage of the package building and installation tools.  It
7961         should therefore be read in conjuction with those programs'
7962         manpages.
7963       </p>
7964
7965       <p>
7966         The utility programs which are provided with <prgn>dpkg</prgn>
7967         for managing various system configuration and similar issues,
7968         such as <prgn>update-rc.d</prgn> and
7969         <prgn>install-info</prgn>, are not described in detail here -
7970         please see their manpages.
7971       </p>
7972
7973       <p>
7974         It is assumed that the reader is reasonably familiar with the
7975         <prgn>dpkg</prgn> System Administrators' manual.
7976         Unfortunately this manual does not yet exist.
7977       </p>
7978
7979       <p>
7980         The Debian version of the FSF's GNU hello program is provided
7981         as an example for people wishing to create Debian
7982         packages. The Debian <prgn>debmake</prgn> package is
7983         recommended as a very helpful tool in creating and maintaining
7984         Debian packages. However, while the tools and examples are
7985         helpful, they do not replace the need to read and follow the
7986         Policy and Programmer's Manual.</p>
7987     </appendix>
7988
7989     <appendix id="pkg-binarypkg"><heading>Binary packages (from old
7990     Packaging Manual)
7991       </heading>
7992
7993       <p>
7994         The binary package has two main sections.  The first part
7995         consists of various control information files and scripts used
7996         by <prgn>dpkg</prgn> when installing and removing.  See <ref
7997         id="pkg-controlarea">.
7998       </p>
7999
8000       <p>
8001         The second part is an archive containing the files and
8002         directories to be installed.
8003       </p>
8004
8005       <p>
8006         In the future binary packages may also contain other
8007         components, such as checksums and digital signatures. The
8008         format for the archive is described in full in the
8009         <file>deb(5)</file> manpage.
8010       </p>
8011
8012
8013       <sect id="pkg-bincreating"><heading>Creating package files -
8014       <prgn>dpkg-deb</prgn>
8015         </heading>
8016
8017         <p>
8018           All manipulation of binary package files is done by
8019           <prgn>dpkg-deb</prgn>; it's the only program that has
8020           knowledge of the format.  (<prgn>dpkg-deb</prgn> may be
8021           invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
8022           will spot that the options requested are appropriate to
8023           <prgn>dpkg-deb</prgn> and invoke that instead with the same
8024           arguments.)
8025         </p>
8026
8027         <p>
8028           In order to create a binary package you must make a
8029           directory tree which contains all the files and directories
8030           you want to have in the filesystem data part of the package.
8031           In Debian-format source packages this directory is usually
8032           <file>debian/tmp</file>, relative to the top of the package's
8033           source tree.
8034         </p>
8035
8036         <p>
8037           They should have the locations (relative to the root of the
8038           directory tree you're constructing) ownerships and
8039           permissions which you want them to have on the system when
8040           they are installed.
8041         </p>
8042
8043         <p>
8044           With current versions of <prgn>dpkg</prgn> the uid/username
8045           and gid/groupname mappings for the users and groups being
8046           used should be the same on the system where the package is
8047           built and the one where it is installed.
8048         </p>
8049
8050         <p>
8051           You need to add one special directory to the root of the
8052           miniature filesystem tree you're creating:
8053           <prgn>DEBIAN</prgn>.  It should contain the control
8054           information files, notably the binary package control file
8055           (see <ref id="pkg-controlfile">).
8056         </p>
8057
8058         <p>
8059           The <prgn>DEBIAN</prgn> directory will not appear in the
8060           filesystem archive of the package, and so won't be installed
8061           by <prgn>dpkg</prgn> when the package is installed.
8062         </p>
8063
8064         <p>
8065           When you've prepared the package, you should invoke:
8066           <example>
8067   dpkg --build <var>directory</var>
8068           </example>
8069         </p>
8070
8071         <p>
8072           This will build the package in
8073           <file><var>directory</var>.deb</file>.  (<prgn>dpkg</prgn> knows
8074           that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8075           it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8076           build the package.)
8077         </p>
8078
8079         <p>
8080           See the manpage <manref name="dpkg-deb" section="8"> for details of how
8081           to examine the contents of this newly-created file.  You may find the
8082           output of following commands enlightening:
8083           <example>
8084   dpkg-deb --info <var>filename</var>.deb
8085   dpkg-deb --contents <var>filename</var>.deb
8086   dpkg --contents <var>filename</var>.deb
8087           </example>
8088           To view the copyright file for a package you could use this command:
8089           <example>
8090   dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8091           </example>
8092         </p>
8093       </sect>
8094
8095       <sect id="pkg-controlarea">
8096         <heading>
8097           Package control information files
8098         </heading>
8099
8100         <p>
8101           The control information portion of a binary package is a
8102           collection of files with names known to <prgn>dpkg</prgn>.
8103           It will treat the contents of these files specially - some
8104           of them contain information used by <prgn>dpkg</prgn> when
8105           installing or removing the package; others are scripts which
8106           the package maintainer wants <prgn>dpkg</prgn> to run.
8107         </p>
8108
8109         <p>
8110           It is possible to put other files in the package control
8111           area, but this is not generally a good idea (though they
8112           will largely be ignored).
8113         </p>
8114
8115         <p>
8116           Here is a brief list of the control info files supported by
8117           <prgn>dpkg</prgn> and a summary of what they're used for.
8118         </p>
8119
8120         <p>
8121           <taglist>
8122             <tag><tt>control</tt>
8123             <item>
8124
8125               <p>
8126                 This is the key description file used by
8127                 <prgn>dpkg</prgn>.  It specifies the package's name
8128                 and version, gives its description for the user,
8129                 states its relationships with other packages, and so
8130                 forth.  See <ref id="pkg-controlfile">.
8131               </p>
8132
8133               <p>
8134                 It is usually generated automatically from information
8135                 in the source package by the
8136                 <prgn>dpkg-gencontrol</prgn> program, and with
8137                 assistance from <prgn>dpkg-shlibdeps</prgn>.  See <ref
8138                 id="pkg-sourcetools">.</p>
8139             </item>
8140
8141             <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8142             <tt>prerm</tt>
8143             </tag>
8144             <item>
8145
8146               <p>
8147                 These are exectuable files (usually scripts) which
8148                 <prgn>dpkg</prgn> runs during installation, upgrade
8149                 and removal of packages.  They allow the package to
8150                 deal with matters which are particular to that package
8151                 or require more complicated processing than that
8152                 provided by <prgn>dpkg</prgn>.  Details of when and
8153                 how they are called are in <ref
8154                 id="maintainerscripts">.
8155               </p>
8156
8157               <p>
8158                 It is very important to make these scripts
8159                 idempotent.
8160                 <footnote>
8161                   <p>
8162                     That means that if it runs successfully or fails
8163                     and then you call it again it doesn't bomb out,
8164                     but just ensures that everything is the way it
8165                     ought to be.
8166                   </p>
8167                 </footnote> This is so that if an error occurs, the
8168                 user interrupts <prgn>dpkg</prgn> or some other
8169                 unforeseen circumstance happens you don't leave the
8170                 user with a badly-broken package.
8171               </p>
8172
8173               <p>
8174                 The maintainer scripts are guaranteed to run with a
8175                 controlling terminal and can interact with the user.
8176                 If they need to prompt for passwords, do full-screen
8177                 interaction or something similar you should do these
8178                 things to and from <file>/dev/tty</file>, since
8179                 <prgn>dpkg</prgn> will at some point redirect scripts'
8180                 standard input and output so that it can log the
8181                 installation process.  Likewise, because these scripts
8182                 may be executed with standard output redirected into a
8183                 pipe for logging purposes, Perl scripts should set
8184                 unbuffered output by setting <tt>$|=1</tt> so that the
8185                 output is printed immediately rather than being
8186                 buffered.
8187               </p>
8188
8189               <p>
8190                 Each script should return a zero exit status for
8191                 success, or a nonzero one for failure.</p>
8192             </item>
8193
8194             <tag><tt>conffiles</tt>
8195             </tag>
8196             <item>
8197
8198               <p>
8199                 This file contains a list of configuration files which
8200                 are to be handled automatically by <prgn>dpkg</prgn>
8201                 (see <ref id="pkg-conffiles">).  Note that not necessarily
8202                 every configuration file should be listed here.</p>
8203             </item>
8204
8205             <tag><tt>shlibs</tt>
8206             </tag>
8207             <item>
8208
8209               <p>
8210                 This file contains a list of the shared libraries
8211                 supplied by the package, with dependency details for
8212                 each.  This is used by <prgn>dpkg-shlibdeps</prgn>
8213                 when it determines what dependencies are required in a
8214                 package control file. The <tt>shlibs</tt> file format
8215                 is described on <ref id="shlibs">.
8216               </p>
8217             </item>
8218           </taglist>
8219         </p>
8220
8221       <sect id="pkg-controlfile">
8222         <heading>
8223           The main control information file: <tt>control</tt>
8224         </heading>
8225         <p>
8226           The most important control information file used by
8227           <prgn>dpkg</prgn> when it installs a package is
8228           <tt>control</tt>.  It contains all the package"s "vital
8229           statistics".
8230         </p>
8231
8232         <p>
8233           The binary package control files of packages built from
8234           Debian sources are made by a special tool,
8235           <prgn>dpkg-gencontrol</prgn>, which reads
8236           <file>debian/control</file> and <file>debian/changelog</file> to
8237           find the information it needs.  See <ref id="pkg-sourcepkg"> for
8238           more details.
8239         </p>
8240
8241         <p>
8242           The fields in binary package control files are:
8243           <list compact="compact">
8244             <item>
8245               <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8246             </item>
8247             <item>
8248               <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8249             </item>
8250             <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8251                 (mandatory)
8252                 <footnote>
8253                   <p>
8254                     This field should appear in all packages, though
8255                     <prgn>dpkg</prgn> doesn't require it yet so that
8256                     old packages can still be installed.
8257                   </p>
8258                 </footnote>
8259               </p>
8260             </item>
8261             <item>
8262               <p><qref id="relationships"><tt>Depends</tt>,
8263                   <tt>Provides</tt> et al.</qref></p>
8264             </item>
8265             <item>
8266               <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8267             </item>
8268             <item>
8269               <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8270             </item>
8271             <item>
8272               <p><qref id="pkg-f-classification"><tt>Section</tt>,
8273                   <tt>Priority</tt></qref></p>
8274             </item>
8275             <item>
8276               <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8277             </item>
8278             <item>
8279               <p><qref id="descriptions"><tt>Description</tt></qref></p>
8280             </item>
8281             <item>
8282               <p>
8283                 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8284               </p>
8285             </item>
8286           </list>
8287
8288         <p>
8289           A description of the syntax of control files and the purpose
8290           of these fields is available in <ref id="pkg-controlfields">.
8291         </p>
8292       </sect>
8293
8294       <sect>
8295         <heading>Time Stamps</heading>
8296         <p>
8297           Maintainers are encouraged to preserve the modification
8298           times of the upstream source files in a package, as far as
8299           is reasonably possible.
8300           <footnote>
8301             <p>
8302               The rationale is that there is some information conveyed
8303               by knowing the age of the file, for example, you could
8304               recognize that some documentation is very old by looking
8305               at the modification time, so it would be nice if the
8306               modification time of the upstream source would be
8307               preserved.
8308             </p>
8309           </footnote>
8310         </p>
8311       </sect>
8312     </appendix>
8313
8314     <appendix id="pkg-sourcepkg">
8315       <heading>Source packages (from old Packaging Manual) </heading>
8316
8317       <p>
8318         The Debian binary packages in the distribution are generated
8319         from Debian sources, which are in a special format to assist
8320         the easy and automatic building of binaries.
8321       </p>
8322
8323       <sect id="pkg-sourcetools">
8324         <heading>Tools for processing source packages</heading>
8325
8326         <p>
8327           Various tools are provided for manipulating source packages;
8328           they pack and unpack sources and help build of binary
8329           packages and help manage the distribution of new versions.
8330         </p>
8331
8332         <p>
8333           They are introduced and typical uses described here; see
8334           <manref name="dpkg-source" section="1"> for full
8335           documentation about their arguments and operation.
8336         </p>
8337
8338         <p>
8339           For examples of how to construct a Debian source package,
8340           and how to use those utilities that are used by Debian
8341           source packages, please see the <prgn>hello</prgn> example
8342           package.
8343         </p>
8344
8345         <sect1>
8346           <heading>
8347             <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8348             packages
8349           </heading>
8350
8351           <p>
8352             This program is frequently used by hand, and is also
8353             called from package-independent automated building scripts
8354             such as <prgn>dpkg-buildpackage</prgn>.
8355           </p>
8356
8357           <p>
8358             To unpack a package it is typically invoked with
8359             <example>
8360   dpkg-source -x <var>.../path/to/filename</var>.dsc
8361             </example>
8362           </p>
8363
8364            <p>
8365             with the <file><var>filename</var>.tar.gz</file> and
8366             <file><var>filename</var>.diff.gz</file> (if applicable) in
8367             the same directory.  It unpacks into
8368             <file><var>package</var>-<var>version</var></file>, and if
8369             applicable
8370             <file><var>package</var>-<var>version</var>.orig</file>, in
8371             the current directory.
8372           </p>
8373
8374           <p>
8375             To create a packed source archive it is typically invoked:
8376             <example>
8377   dpkg-source -b <var>package</var>-<var>version</var>
8378           </example>
8379           </p>
8380
8381           <p>
8382             This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8383             <file>.diff.gz</file> (if appropriate) in the current
8384             directory.  <prgn>dpkg-source</prgn> does not clean the
8385             source tree first - this must be done separately if it is
8386             required.
8387           </p>
8388
8389           <p>
8390             See also <ref id="pkg-sourcearchives">.</p>
8391         </sect1>
8392
8393
8394         <sect1>
8395           <heading>
8396             <prgn>dpkg-buildpackage</prgn> - overall package-building
8397             control script
8398           </heading>
8399
8400           <p>
8401             <prgn>dpkg-buildpackage</prgn> is a script which invokes
8402             <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8403             targets <tt>clean</tt>, <tt>build</tt> and
8404             <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8405             <prgn>pgp</prgn> to build a signed source and binary
8406             package upload.
8407           </p>
8408
8409           <p>
8410             It is usually invoked by hand from the top level of the
8411             built or unbuilt source directory.  It may be invoked with
8412             no arguments; useful arguments include:
8413             <taglist compact="compact">
8414               <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8415               <item>
8416                 <p>
8417                   Do not PGP-sign the <tt>.changes</tt> file or the
8418                   source package <tt>.dsc</tt> file, respectively.</p>
8419               </item>
8420               <tag><tt>-p<var>pgp-command</var></tt></tag>
8421               <item>
8422                 <p>
8423                   Invoke <var>pgp-command</var> instead of finding
8424                   <tt>pgp</tt> on the <prgn>PATH</prgn>.
8425                   <var>pgp-command</var> must behave just like
8426                   <prgn>pgp</prgn>.</p>
8427               </item>
8428               <tag><tt>-r<var>root-command</var></tt></tag>
8429               <item>
8430                 <p>
8431                   When root privilege is required, invoke the command
8432                   <var>root-command</var>.  <var>root-command</var>
8433                   should invoke its first argument as a command, from
8434                   the <prgn>PATH</prgn> if necessary, and pass its
8435                   second and subsequent arguments to the command it
8436                   calls.  If no <var>root-command</var> is supplied
8437                   then <var>dpkg-buildpackage</var> will take no
8438                   special action to gain root privilege, so that for
8439                   most packages it will have to be invoked as root to
8440                   start with.</p>
8441               </item>
8442               <tag><tt>-b</tt>, <tt>-B</tt></tag>
8443               <item>
8444                 <p>
8445                   Two types of binary-only build and upload - see
8446                   <manref name="dpkg-source" section="1">.
8447                 </p>
8448               </item>
8449             </taglist>
8450           </p>
8451         </sect1>
8452
8453         <sect1>
8454           <heading>
8455             <prgn>dpkg-gencontrol</prgn> - generates binary package
8456             control files
8457           </heading>
8458
8459           <p>
8460             This program is usually called from <file>debian/rules</file>
8461             (see <ref id="pkg-sourcetree">) in the top level of the source
8462             tree.
8463           </p>
8464
8465           <p>
8466             This is usually done just before the files and directories in the
8467             temporary directory tree where the package is being built have their
8468             permissions and ownerships set and the package is constructed using
8469             <prgn>dpkg-deb/</prgn>
8470               <footnote>
8471               <p>
8472                 This is so that the control file which is produced has
8473                 the right permissions
8474               </p>
8475             </footnote>.
8476           </p>
8477
8478           <p>
8479             <prgn>dpkg-gencontrol</prgn> must be called after all the
8480             files which are to go into the package have been placed in
8481             the temporary build directory, so that its calculation of
8482             the installed size of a package is correct.
8483           </p>
8484
8485           <p>
8486             It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8487             be run after <prgn>dpkg-shlibdeps</prgn> so that the
8488             variable substitutions created by
8489             <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8490             are available.
8491           </p>
8492
8493           <p>
8494             For a package which generates only one binary package, and
8495             which builds it in <file>debian/tmp</file> relative to the top
8496             of the source package, it is usually sufficient to call
8497             <prgn>dpkg-gencontrol</prgn>.
8498           </p>
8499
8500           <p>
8501             Sources which build several binaries will typically need
8502             something like:
8503             <example>
8504   dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8505             </example> The <tt>-P</tt> tells
8506             <prgn>dpkg-gencontrol</prgn> that the package is being
8507             built in a non-default directory, and the <tt>-p</tt>
8508             tells it which package's control file should be generated.
8509           </p>
8510
8511           <p>
8512             <prgn>dpkg-gencontrol</prgn> also adds information to the
8513             list of files in <file>debian/files</file>, for the benefit of
8514             (for example) a future invocation of
8515             <prgn>dpkg-genchanges</prgn>.</p>
8516         </sect1>
8517
8518         <sect1>
8519           <heading>
8520             <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8521             dependencies
8522           </heading>
8523
8524           <p>
8525             This program is usually called from <file>debian/rules</file>
8526             just before <prgn>dpkg-gencontrol</prgn> (see <ref
8527             id="pkg-sourcetree">), in the top level of the source tree.
8528           </p>
8529
8530           <p>
8531             Its arguments are executables.
8532             <footnote>
8533               <p>
8534                 In a forthcoming dpkg version,
8535                 <prgn>dpkg-shlibdeps</prgn> would be required to be
8536                 called on shared libraries as well.
8537               </p>
8538               <p>
8539                 They may be specified either in the locations in the
8540                 source tree where they are created or in the locations
8541                 in the temporary build tree where they are installed
8542                 prior to binary package creation.
8543               </p>
8544             </footnote> for which shared library dependencies should
8545             be included in the binary package's control file.
8546           </p>
8547
8548           <p>
8549             If some of the found shared libraries should only
8550             warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8551             some warrant a <tt>Pre-Depends</tt>, this can be achieved
8552             by using the <tt>-d<var>dependency-field</var></tt> option
8553             before those executable(s).  (Each <tt>-d</tt> option
8554             takes effect until the next <tt>-d</tt>.)
8555           </p>
8556
8557           <p>
8558             <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8559             output control file to be modified.  Instead by default it
8560             adds to the <file>debian/substvars</file> file variable
8561             settings like <tt>shlibs:Depends</tt>.  These variable
8562             settings must be referenced in dependency fields in the
8563             appropriate per-binary-package sections of the source
8564             control file.
8565           </p>
8566
8567           <p>
8568             For example, the <prgn>procps</prgn> package generates two
8569             kinds of binaries, simple C binaries like <prgn>ps</prgn>
8570             which require a predependency and full-screen ncurses
8571             binaries like <prgn>top</prgn> which require only a
8572             recommendation.  It can say in its <file>debian/rules</file>:
8573             <example>
8574   dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8575             </example>
8576             and then in its main control file <file>debian/control</file>:
8577             <example>
8578   <var>...</var>
8579   Package: procps
8580   Pre-Depends: ${shlibs:Pre-Depends}
8581   Recommends: ${shlibs:Recommends}
8582   <var>...</var>
8583             </example>
8584           </p>
8585
8586           <p>
8587             Sources which produce several binary packages with
8588             different shared library dependency requirements can use
8589             the <tt>-p<var>varnameprefix</var></tt> option to override
8590             the default <tt>shlibs:</tt> prefix (one invocation of
8591             <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8592             They can thus produce several sets of dependency
8593             variables, each of the form
8594             <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8595             which can be referred to in the appropriate parts of the
8596             binary package control files.
8597           </p>
8598         </sect1>
8599
8600
8601         <sect1>
8602           <heading>
8603             <prgn>dpkg-distaddfile</prgn> - adds a file to
8604             <file>debian/files</file>
8605           </heading>
8606
8607           <p>
8608             Some packages' uploads need to include files other than
8609             the source and binary package files.
8610           </p>
8611
8612           <p>
8613             <prgn>dpkg-distaddfile</prgn> adds a file to the
8614             <file>debian/files</file> file so that it will be included in
8615             the <file>.changes</file> file when
8616             <prgn>dpkg-genchanges</prgn> is run.
8617           </p>
8618
8619           <p>
8620             It is usually invoked from the <tt>binary</tt> target of
8621             <file>debian/rules</file>:
8622             <example>
8623   dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8624             </example>
8625             The <var>filename</var> is relative to the directory where
8626             <prgn>dpkg-genchanges</prgn> will expect to find it - this
8627             is usually the directory above the top level of the source
8628             tree.  The <file>debian/rules</file> target should put the
8629             file there just before or just after calling
8630             <prgn>dpkg-distaddfile</prgn>.
8631           </p>
8632
8633           <p>
8634             The <var>section</var> and <var>priority</var> are passed
8635             unchanged into the resulting <file>.changes</file> file.  See
8636             <ref id="pkg-f-classification">.
8637           </p>
8638         </sect1>
8639
8640
8641         <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8642             control file
8643           </heading>
8644
8645           <p>
8646             This program is usually called by package-independent
8647             automatic building scripts such as
8648             <prgn>dpkg-buildpackage</prgn>, but it may also be called
8649             by hand.
8650           </p>
8651
8652           <p>
8653             It is usually called in the top level of a built source
8654             tree, and when invoked with no arguments will print out a
8655             straightforward <file>.changes</file> file based on the
8656             information in the source package's changelog and control
8657             file and the binary and source packages which should have
8658             been built.
8659           </p>
8660         </sect1>
8661
8662
8663         <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8664             a changelog
8665           </heading>
8666
8667           <p>
8668             This program is used internally by
8669             <prgn>dpkg-source</prgn> et al.  It may also occasionally
8670             be useful in <file>debian/rules</file> and elsewhere.  It
8671             parses a changelog, <file>debian/changelog</file> by default,
8672             and prints a control-file format representation of the
8673             information in it to standard output.
8674           </p>
8675         </sect1>
8676
8677         <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8678             information about the build and host system
8679           </heading>
8680
8681           <p>
8682             This program can be used manually, but is also invoked by
8683             <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8684             to set environment or make variables which specify the build and
8685             host architecture for the package building process.
8686           </p>
8687         </sect1>
8688       </sect>
8689
8690       <sect id="pkg-sourcetree"><heading>The Debianised source tree
8691         </heading>
8692
8693         <p>
8694           The source archive scheme described later is intended to
8695           allow a Debianised source tree with some associated control
8696           information to be reproduced and transported easily.  The
8697           Debianised source tree is a version of the original program
8698           with certain files added for the benefit of the
8699           Debianisation process, and with any other changes required
8700           made to the rest of the source code and installation
8701           scripts.
8702         </p>
8703
8704         <p>
8705           The extra files created for Debian are in the subdirectory
8706           <file>debian</file> of the top level of the Debianised source
8707           tree.  They are described below.
8708         </p>
8709
8710         <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8711         script
8712           </heading>
8713
8714           <p>
8715             This file is an executable makefile, and contains the
8716             package-specific recipies for compiling the package and
8717             building binary package(s) out of the source.
8718           </p>
8719
8720           <p>
8721             It must start with the line <tt>#!/usr/bin/make -f</tt>,
8722             so that it can be invoked by saying its name rather than
8723             invoking <prgn>make</prgn> explicitly.
8724           </p>
8725
8726           <p>
8727             Since an interactive <file>debian/rules</file> script makes it
8728             impossible to autocompile that package and also makes it
8729             hard for other people to reproduce the same binary
8730             package, all <strong>required targets</strong> have to be
8731             non-interactive. At a minimul, required targets are the
8732             ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8733             <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8734             <em>build</em>. It also follows that any target that these
8735             targets depend on must also be non-interactive.
8736           </p>
8737
8738           <p>
8739             The targets which are required to be present are:
8740             <taglist>
8741               <tag><tt>build</tt></tag>
8742               <item>
8743                 <p>
8744                   This should perform all non-interactive
8745                   configuration and compilation of the package.  If a
8746                   package has an interactive pre-build configuration
8747                   routine, the Debianised source package should be
8748                   built after this has taken place, so that it can be
8749                   built without rerunning the configuration.
8750                 </p>
8751
8752                 <p>
8753                   A package may also provide both of the targets
8754                   <tt>build-arch</tt> and <tt>build-indep</tt>.  The
8755                   <tt>build-arch</tt> target, if provided, should
8756                   perform all non-interactive configuration and
8757                   compilation required for producing all
8758                   architecture-dependant binary packages (those packages
8759                   for which the body of the <tt>Architecture</tt> field
8760                   in <tt>debian/control</tt> is not <tt>all</tt>).
8761                   Similarly, the <tt>build-indep</tt> target, if
8762                   provided, should perform all non-interactive
8763                   configuration and compilation required for producing
8764                   all architecture-independent binary packages (those
8765                   packages for which the body of the
8766                   <tt>Architecture</tt> field in <tt>debian/control</tt>
8767                   is <tt>all</tt>).  The <tt>build</tt> target should
8768                   depend on those of the targets <tt>build-arch</tt> and
8769                   <tt>build-indep</tt> that are provided in the rules
8770                   file.
8771                 </p>
8772
8773                 <p>
8774                   If one or both of the targets <tt>build-arch</tt> and
8775                   <tt>build-indep</tt> are not provided, then invoking
8776                   <file>debian/rules</file> with one of the not-provided
8777                   targets as arguments should produce a exit status code
8778                   of 2.  Usually this is provided automatically by make
8779                   if the target is missing.
8780                 </p>
8781
8782                 <p>
8783                   For some packages, notably ones where the same
8784                   source tree is compiled in different ways to produce
8785                   two binary packages, the <tt>build</tt> target does
8786                   not make much sense.  For these packages it is good
8787                   enough to provide two (or more) targets
8788                   (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8789                   for each of the ways of building the package, and a
8790                   <tt>build</tt> target that does nothing.  The
8791                   <tt>binary</tt> target will have to build the
8792                   package in each of the possible ways and make the
8793                   binary package out of each.
8794                 </p>
8795
8796                 <p>
8797                   The targets <tt>build</tt>, <tt>build-arch</tt>
8798                   and <tt>build-indep</tt> target must not do
8799                   anything that might require root privilege.
8800                 </p>
8801
8802                 <p>
8803                   The <tt>build</tt> target may need to run
8804                   <tt>clean</tt> first - see below.
8805                 </p>
8806
8807                 <p>
8808                   When a package has a configuration routine that takes
8809                   a long time, or when the makefiles are poorly
8810                   designed, or when <tt>build</tt> needs to run
8811                   <tt>clean</tt> first, it is a good idea to <tt>touch
8812                     build</tt> when the build process is complete.  This
8813                   will ensure that if <tt>debian/rules build</tt> is run
8814                   again it will not rebuild the whole program.
8815                 </p>
8816               </item>
8817
8818               <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8819                 <tt>binary-indep</tt>
8820               </tag>
8821               <item>
8822                 <p>
8823                   The <tt>binary</tt> target should be all that is
8824                   necessary for the user to build the binary
8825                   package. All these targets are required to be
8826                   non-interactive.  It is split into two parts:
8827                   <tt>binary-arch</tt> builds the packages' output
8828                   files which are specific to a particular
8829                   architecture, and <tt>binary-indep</tt> builds
8830                   those which are not.
8831                 </p>
8832
8833                 <p>
8834                   <tt>binary</tt> should usually be a target with
8835                   no commands which simply depends on
8836                   <prgn>binary-arch</prgn> and
8837                   <prgn>binary-indep</prgn>.
8838                 </p>
8839
8840                 <p>
8841                   Both <prgn>binary-*</prgn> targets should depend on
8842                   the <tt>build</tt> target, above, so that the
8843                   package is built if it has not been already.  It
8844                   should then create the relevant binary package(s),
8845                   using <prgn>dpkg-gencontrol</prgn> to make their
8846                   control files and <prgn>dpkg-deb</prgn> to build
8847                   them and place them in the parent of the top level
8848                   directory.
8849                 </p>
8850
8851                 <p>
8852                   If one of the <prgn>binary-*</prgn> targets has
8853                   nothing to do (this will be always be the case if
8854                   the source generates only a single binary package,
8855                   whether architecture-dependent or not) it
8856                   <em>must</em> still exist, but should always
8857                   succeed.
8858                 </p>
8859
8860                 <p>
8861                   <ref id="pkg-binarypkg"> describes how to construct
8862                   binary packages.
8863                 </p>
8864
8865                 <p>
8866                   The <tt>binary</tt> targets must be invoked as
8867                   root.
8868                 </p>
8869               </item>
8870
8871               <tag><tt>clean</tt></tag>
8872               <item>
8873
8874                 <p>
8875                   This should undo any effects that the
8876                   <tt>build</tt> and <tt>binary</tt> targets
8877                   may have had, except that it should leave alone any
8878                   output files created in the parent directory by a
8879                   run of <tt>binary</tt>. This target is required
8880                   to be non-interactive.
8881                 </p>
8882
8883                 <p>
8884                   If a <tt>build</tt> file is touched at the end
8885                   of the <tt>build</tt> target, as suggested
8886                   above, it must be removed as the first thing that
8887                   <tt>clean</tt> does, so that running
8888                   <tt>build</tt> again after an interrupted
8889                   <tt>clean</tt> doesn't think that everything is
8890                   already done.
8891                 </p>
8892
8893                 <p>
8894                   The <tt>clean</tt> target must be invoked as
8895                   root if <tt>binary</tt> has been invoked since
8896                   the last <tt>clean</tt>, or if
8897                   <tt>build</tt> has been invoked as root (since
8898                   <tt>build</tt> may create directories, for
8899                   example).
8900                 </p>
8901               </item>
8902
8903               <tag><tt>get-orig-source</tt> (optional)</tag>
8904               <item>
8905
8906                 <p>
8907                   This target fetches the most recent version of the
8908                   original source package from a canonical archive
8909                   site (via FTP or WWW, for example), does any
8910                   necessary rearrangement to turn it into the original
8911                   source tarfile format described below, and leaves it
8912                   in the current directory.
8913                 </p>
8914
8915                 <p>
8916                   This target may be invoked in any directory, and
8917                   should take care to clean up any temporary files it
8918                   may have left.
8919                 </p>
8920
8921                 <p>
8922                   This target is optional, but providing it if
8923                   possible is a good idea.
8924                 </p>
8925               </item>
8926             </taglist>
8927
8928           <p>
8929             The <tt>build</tt>, <tt>binary</tt> and
8930             <tt>clean</tt> targets must be invoked with a current
8931             directory of the package's top-level directory.
8932           </p>
8933
8934
8935           <p>
8936             Additional targets may exist in <file>debian/rules</file>,
8937             either as published or undocumented interfaces or for the
8938             package's internal use.
8939           </p>
8940
8941           <p>
8942             The architecture we build on and build for is determined by make
8943             variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8944             get the Debian architecture and the GNU style architecture
8945             specification string for the build machine as well as the host
8946             machine. Here is a list of supported make variables:
8947             <list compact="compact">
8948               <item>
8949                 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8950               </item>
8951               <item>
8952                 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8953                   specification string)</p>
8954               </item>
8955               <item>
8956                 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8957               </item>
8958               <item>
8959                 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8960                   DEB_*_GNU_TYPE)</p>
8961             </list>
8962           </p>
8963
8964           <p>
8965             where <tt>*</tt> is either <tt>BUILD</tt> for specification of
8966             the build machine or <tt>HOST</tt> for specification of the machine
8967             we build for.
8968           </p>
8969
8970           <p>
8971             Backward compatibility can be provided in the rules file
8972             by setting the needed variables to suitable default
8973             values, please refer to the documentation of
8974             dpkg-architecture for details.
8975           </p>
8976
8977           <p>
8978             It is important to understand that the <tt>DEB_*_ARCH</tt>
8979             string does only determine which Debian architecture we
8980             build on resp. for. It should not be used to get the CPU
8981             or System information, the GNU style variables should be
8982             used for that.
8983           </p>
8984         </sect1>
8985
8986
8987         <sect1><heading><file>debian/control</file>
8988           </heading>
8989
8990           <p>
8991             This file contains version-independent details about the
8992             source package and about the binary packages it creates.
8993           </p>
8994
8995           <p>
8996             It is a series of sets of control fields, each
8997             syntactically similar to a binary package control file.
8998             The sets are separated by one or more blank lines.  The
8999             first set is information about the source package in
9000             general; each subsequent set describes one binary package
9001             that the source tree builds.
9002           </p>
9003
9004           <p>
9005             The syntax and semantics of the fields are described below
9006             in <ref id="pkg-controlfields">.
9007           </p>
9008
9009           <p>
9010             The general (binary-package-independent) fields are:
9011             <list compact="compact">
9012               <item>
9013                 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
9014               </item>
9015               <item>
9016                 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9017               </item>
9018               <item>
9019                 <p>
9020                   <qref id="pkg-f-classification"><tt>Section</tt> and
9021                     <tt>Priority</tt></qref>
9022                   (classification, mandatory)
9023                 </p>
9024               </item>
9025                <item>
9026                  <p>
9027                    <qref id="relationships"><tt>Build-Depends</tt> et
9028                      al.</qref> (source package interrelationships)
9029                  </p>
9030                </item>
9031               <item>
9032                 <p>
9033                   <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
9034                 </p>
9035               </item>
9036             </list>
9037
9038           <p>
9039             The per-binary-package fields are:
9040             <list compact="compact">
9041               <item>
9042                 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
9043               </item>
9044               <item>
9045                 <p>
9046                   <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
9047                   (mandatory)</p>
9048               </item>
9049               <item>
9050                 <p><qref id="descriptions"><tt>Description</tt></qref></p>
9051               </item>
9052               <item>
9053                 <p>
9054                   <qref id="pkg-f-classification"><tt>Section</tt> and
9055                     <tt>Priority</tt></qref> (classification)</p>
9056               </item>
9057               <item>
9058                 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
9059               </item>
9060               <item>
9061                 <p>
9062                   <qref id="relationships"><tt>Depends</tt> et
9063                   al.</qref> (binary package interrelationships)
9064                 </p>
9065               </item>
9066             </list>
9067
9068           <p>
9069             These fields are used by <prgn>dpkg-gencontrol</prgn> to
9070             generate control files for binary packages (see below), by
9071             <prgn>dpkg-genchanges</prgn> to generate the
9072             <tt>.changes</tt> file to accompany the upload, and by
9073             <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9074             source control file as part of a source archive.
9075           </p>
9076
9077           <p>
9078             The fields here may contain variable references - their
9079             values will be substituted by
9080             <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9081             or <prgn>dpkg-source</prgn> when they generate output
9082             control files.  See <ref id="pkg-srcsubstvars"> for details.
9083           </p>
9084
9085           <p> <sect2><heading>User-defined fields
9086             </heading>
9087
9088             <p>
9089               Additional user-defined fields may be added to the
9090               source package control file.  Such fields will be
9091               ignored, and not copied to (for example) binary or
9092               source package control files or upload control files.
9093             </p>
9094
9095             <p>
9096               If you wish to add additional unsupported fields to
9097               these output files you should use the mechanism
9098               described here.
9099             </p>
9100
9101             <p>
9102               Fields in the main source control information file with
9103               names starting <tt>X</tt>, followed by one or more of
9104               the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9105               be copied to the output files.  Only the part of the
9106               field name after the hyphen will be used in the output
9107               file.  Where the letter <tt>B</tt> is used the field
9108               will appear in binary package control files, where the
9109               letter <tt>S</tt> is used in source package control
9110               files and where <tt>C</tt> is used in upload control
9111               (<tt>.changes</tt>) files.
9112             </p>
9113
9114             <p>
9115               For example, if the main source information control file
9116               contains the field
9117               <example>
9118   XBS-Comment: I stand between the candle and the star.
9119               </example>
9120               then the binary and source package control files will contain the
9121               field
9122               <example>
9123   Comment: I stand between the candle and the star.
9124               </example>
9125             </p>
9126           </sect2>
9127
9128         </sect1>
9129
9130         <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9131           </heading>
9132
9133           <p>
9134             This file records the changes to the Debian-specific parts of the
9135             package
9136             <footnote>
9137               <p>
9138                 Though there is nothing stopping an author who is also
9139                 the Debian maintainer from using it for all their
9140                 changes, it will have to be renamed if the Debian and
9141                 upstream maintainers become different
9142                 people.
9143               </p>
9144             </footnote>.
9145           </p>
9146
9147           <p>
9148             It has a special format which allows the package building
9149             tools to discover which version of the package is being
9150             built and find out other release-specific information.
9151           </p>
9152
9153           <p>
9154             That format is a series of entries like this:
9155             <example>
9156   <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9157
9158    * <var>change details</var>
9159    <var>more change details</var>
9160    * <var>even more change details</var>
9161
9162   -- <var>maintainer name and email address</var>  <var>date</var>
9163             </example>
9164           </p>
9165
9166           <p>
9167             <var>package</var> and <var>version</var> are the source
9168             package name and version number.
9169           </p>
9170
9171           <p>
9172             <var>distribution(s)</var> lists the distributions where
9173             this version should be installed when it is uploaded - it
9174             is copied to the <tt>Distribution</tt> field in the
9175             <tt>.changes</tt> file.  See <ref id="pkg-f-Distribution">.
9176           </p>
9177
9178           <p>
9179             <var>urgency</var> is the value for the <tt>Urgency</tt>
9180             field in the <file>.changes</file> file for the upload.  See
9181             <ref id="pkg-f-Urgency">.  It is not possible to specify an
9182             urgency containing commas; commas are used to separate
9183             <tt><var>keyword</var>=<var>value</var></tt> settings in
9184             the <prgn>dpkg</prgn> changelog format (though there is
9185             currently only one useful <var>keyword</var>,
9186             <tt>urgency</tt>).
9187           </p>
9188
9189           <p>
9190             The change details may in fact be any series of lines
9191             starting with at least two spaces, but conventionally each
9192             change starts with an asterisk and a separating space and
9193             continuation lines are indented so as to bring them in
9194             line with the start of the text above.  Blank lines may be
9195             used here to separate groups of changes, if desired.
9196           </p>
9197
9198           <p>
9199             The maintainer name and email address should <em>not</em>
9200             necessarily be those of the usual package maintainer.
9201             They should be the details of the person doing
9202             <em>this</em> version.  The information here will be
9203             copied to the <file>.changes</file> file, and then later used
9204             to send an acknowledgement when the upload has been
9205             installed.
9206           </p>
9207
9208           <p>
9209             The <var>date</var> should be in RFC822 format
9210             <footnote>
9211               <p>
9212                 This is generated by the <prgn>822-date</prgn>
9213                 program.
9214               </p>
9215             </footnote>; it should include the timezone specified
9216             numerically, with the timezone name or abbreviation
9217             optionally present as a comment.
9218           </p>
9219
9220           <p>
9221             The first "title" line with the package name should start
9222             at the left hand margin; the "trailer" line with the
9223             maintainer and date details should be preceded by exactly
9224             one space.  The maintainer details and the date must be
9225             separated by exactly two spaces.
9226           </p>
9227
9228           <p>
9229             An Emacs mode for editing this format is available: it is
9230             called <tt>debian-changelog-mode</tt>.  You can have this
9231             mode selected automatically when you edit a Debian
9232             changelog by adding a local variables clause to the end of
9233             the changelog.
9234           </p>
9235
9236           <sect2><heading>Defining alternative changelog formats
9237             </heading>
9238
9239             <p>
9240               It is possible to use a different format to the standard
9241               one, by providing a parser for the format you wish to
9242               use.
9243             </p>
9244
9245             <p>
9246               In order to have <tt>dpkg-parsechangelog</tt> run your
9247               parser, you must include a line within the last 40 lines
9248               of your file matching the Perl regular expression:
9249               <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9250               parentheses should be the name of the format.  For
9251               example, you might say:
9252               <example>
9253   @@@ changelog-format: joebloggs @@@
9254               </example>
9255               Changelog format names are non-empty strings of alphanumerics.
9256             </p>
9257
9258             <p>
9259               If such a line exists then <tt>dpkg-parsechangelog</tt>
9260               will look for the parser as
9261               <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9262               or
9263               <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9264               it is an error for it not to find it, or for it not to
9265               be an executable program.  The default changelog format
9266               is <tt>dpkg</tt>, and a parser for it is provided with
9267               the <tt>dpkg</tt> package.
9268             </p>
9269
9270             <p>
9271               The parser will be invoked with the changelog open on
9272               standard input at the start of the file.  It should read
9273               the file (it may seek if it wishes) to determine the
9274               information required and return the parsed information
9275               to standard output in the form of a series of control
9276               fields in the standard format.  By default it should
9277               return information about only the most recent version in
9278               the changelog; it should accept a
9279               <tt>-v<var>version</var></tt> option to return changes
9280               information from all versions present <em>strictly
9281               after</em> <var>version</var>, and it should then be an
9282               error for <var>version</var> not to be present in the
9283               changelog.
9284             </p>
9285
9286             <p>
9287               The fields are:
9288               <list compact="compact">
9289                 <item>
9290                   <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9291                 </item>
9292                 <item>
9293                   <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9294                 </item>
9295                 <item>
9296                   <p>
9297                     <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9298                     (mandatory)
9299                   </p>
9300                 </item>
9301                 <item>
9302                   <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9303                 </item>
9304                 <item>
9305                   <p>
9306                     <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9307                     (mandatory)
9308                   </p>
9309                 </item>
9310                 <item>
9311                   <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9312                 </item>
9313                 <item>
9314                   <p>
9315                     <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9316                     (mandatory)
9317                   </p>
9318                 </item>
9319               </list>
9320
9321             <p>
9322               If several versions are being returned (due to the use
9323               of <tt>-v</tt>), the urgency value should be of the
9324               highest urgency code listed at the start of any of the
9325               versions requested followed by the concatenated
9326               (space-separated) comments from all the versions
9327               requested; the maintainer, version, distribution and
9328               date should always be from the most recent version.
9329             </p>
9330
9331             <p>
9332               For the format of the <tt>Changes</tt> field see <ref
9333               id="pkg-f-Changes">.
9334             </p>
9335
9336             <p>
9337               If the changelog format which is being parsed always or
9338               almost always leaves a blank line between individual
9339               change notes these blank lines should be stripped out,
9340               so as to make the resulting output compact.
9341             </p>
9342
9343             <p>
9344               If the changelog format does not contain date or package
9345               name information this information should be omitted from
9346               the output.  The parser should not attempt to synthesise
9347               it or find it from other sources.
9348             </p>
9349
9350             <p>
9351               If the changelog does not have the expected format the
9352               parser should exit with a nonzero exit status, rather
9353               than trying to muddle through and possibly generating
9354               incorrect output.
9355             </p>
9356
9357             <p>
9358               A changelog parser may not interact with the user at
9359               all.</p></sect2>
9360         </sect1>
9361
9362 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
9363
9364         <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9365         and variable substitutions
9366           </heading>
9367
9368           <p>
9369             When <prgn>dpkg-gencontrol</prgn>,
9370             <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9371             generate control files they do variable substitutions on
9372             their output just before writing it.  Variable
9373             substitutions have the form
9374             <tt>${<var>variable-name</var>}</tt>.  The optional file
9375             <file>debian/substvars</file> contains variable substitutions
9376             to be used; variables can also be set directly from
9377             <file>debian/rules</file> using the <tt>-V</tt> option to the
9378             source packaging commands, and certain predefined
9379             variables are available.
9380           </p>
9381
9382           <p>
9383             This file is usually generated and modified dynamically by
9384             <file>debian/rules</file> targets, in which case it must be
9385             removed by the <tt>clean</tt> target.
9386           </p>
9387
9388           <p>
9389             See <manref name="dpkg-source" section="1"> for full
9390             details about source variable substitutions, including the
9391             format of <file>debian/substvars</file>.</p>
9392         </sect1>
9393
9394         <sect1><heading><file>debian/files</file>
9395           </heading>
9396
9397           <p>
9398             This file is not a permanent part of the source tree; it
9399             is used while building packages to record which files are
9400             being generated.  <prgn>dpkg-genchanges</prgn> uses it
9401             when it generates a <file>.changes</file> file.
9402           </p>
9403
9404           <p>
9405             It should not exist in a shipped source package, and so it
9406             (and any backup files or temporary files such as
9407             <file>files.new</file>
9408               <footnote>
9409                 <p>
9410                   <file>files.new</file> is used as a temporary file by
9411                   <prgn>dpkg-gencontrol</prgn> and
9412                   <prgn>dpkg-distaddfile</prgn> - they write a new
9413                   version of <file>files</file> here before renaming it,
9414                   to avoid leaving a corrupted copy if an error
9415                   occurs
9416                 </p>
9417               </footnote>) should be removed by the
9418               <tt>clean</tt> target.  It may also be wise to
9419               ensure a fresh start by emptying or removing it at the
9420               start of the <tt>binary</tt> target.
9421           </p>
9422
9423           <p>
9424             <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9425             for the <file>.deb</file> file that will be created by
9426             <prgn>dpkg-deb</prgn> from the control file that it
9427             generates, so for most packages all that needs to be done
9428             with this file is to delete it in <tt>clean</tt>.
9429           </p>
9430
9431           <p>
9432             If a package upload includes files besides the source
9433             package and any binary packages whose control files were
9434             made with <prgn>dpkg-gencontrol</prgn> then they should be
9435             placed in the parent of the package's top-level directory
9436             and <prgn>dpkg-distaddfile</prgn> should be called to add
9437             the file to the list in <file>debian/files</file>.</p>
9438         </sect1>
9439
9440         <sect1><heading><file>debian/tmp</file>
9441           </heading>
9442
9443           <p>
9444             This is the canonical temporary location for the
9445             construction of binary packages by the <tt>binary</tt>
9446             target.  The directory <file>tmp</file> serves as the root of
9447             the filesystem tree as it is being constructed (for
9448             example, by using the package's upstream makefiles install
9449             targets and redirecting the output there), and it also
9450             contains the <tt>DEBIAN</tt> subdirectory.  See <ref
9451             id="pkg-bincreating">.
9452           </p>
9453
9454           <p>
9455             If several binary packages are generated from the same
9456             source tree it is usual to use several
9457             <file>debian/tmp<var>something</var></file> directories, for
9458             example <file>tmp-a</file> or <file>tmp-doc</file>.
9459           </p>
9460
9461           <p>
9462             Whatever <file>tmp</file> directories are created and used by
9463             <tt>binary</tt> must of course be removed by the
9464             <tt>clean</tt> target.</p></sect1>
9465       </sect>
9466
9467
9468       <sect id="pkg-sourcearchives"><heading>Source packages as archives
9469         </heading>
9470
9471         <p>
9472           As it exists on the FTP site, a Debian source package
9473           consists of three related files.  You must have the right
9474           versions of all three to be able to use them.
9475         </p>
9476
9477         <p>
9478           <taglist>
9479             <tag>Debian source control file - <tt>.dsc</tt></tag>
9480             <item>
9481
9482               <p>
9483                 This file contains a series of fields, identified and
9484                 separated just like the fields in the control file of
9485                 a binary package.  The fields are listed below; their
9486                 syntax is described above, in <ref id="pkg-controlfields">.
9487                 <list compact="compact">
9488                   <item>
9489                     <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9490                   </item>
9491                   <item>
9492                     <p><qref id="versions"><tt>Version</tt></qref></p>
9493                   </item>
9494                   <item>
9495                     <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9496                   </item>
9497                   <item>
9498                     <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9499                   </item>
9500                   <item>
9501                     <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9502                   </item>
9503                   <item>
9504                      <p>
9505                        <qref id="relationships"><tt>Build-Depends</tt> et
9506                          al.</qref> (source package interrelationships)
9507                      </p>
9508                   </item>
9509                   <item>
9510                     <p>
9511                       <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9512                   </item>
9513                   <item>
9514                     <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9515                   </item>
9516                 </list>
9517
9518               <p>
9519                 The source package control file is generated by
9520                 <prgn>dpkg-source</prgn> when it builds the source
9521                 archive, from other files in the source package,
9522                 described above.  When unpacking it is checked against
9523                 the files and directories in the other parts of the
9524                 source package, as described below.</p>
9525             </item>
9526
9527             <tag>
9528               Original source archive -
9529               <file>
9530                 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9531               </file>
9532             </tag>
9533
9534             <item>
9535
9536               <p>
9537                 This is a compressed (with <tt>gzip -9</tt>)
9538                 <prgn>tar</prgn> file containing the source code from
9539                 the upstream authors of the program.  The tarfile
9540                 unpacks into a directory
9541                 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9542                 and does not contain files anywhere other than in
9543                 there or in its subdirectories.</p>
9544             </item>
9545
9546             <tag>
9547               Debianisation diff -
9548               <file>
9549                 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9550               </file>
9551             </tag>
9552             <item>
9553
9554               <p>
9555                 This is a unified context diff (<tt>diff -u</tt>)
9556                 giving the changes which are required to turn the
9557                 original source into the Debian source.  These changes
9558                 may only include editing and creating plain files.
9559                 The permissions of files, the targets of symbolic
9560                 links and the characteristics of special files or
9561                 pipes may not be changed and no files may be removed
9562                 or renamed.
9563               </p>
9564
9565               <p>
9566                 All the directories in the diff must exist, except the
9567                 <file>debian</file> subdirectory of the top of the source
9568                 tree, which will be created by
9569                 <prgn>dpkg-source</prgn> if necessary when unpacking.
9570               </p>
9571
9572               <p>
9573                 The <prgn>dpkg-source</prgn> program will
9574                 automatically make the <file>debian/rules</file> file
9575                 executable (see below).</p></item>
9576           </taglist>
9577
9578
9579         <p>
9580           If there is no original source code - for example, if the
9581           package is specially prepared for Debian or the Debian
9582           maintainer is the same as the upstream maintainer - the
9583           format is slightly different: then there is no diff, and the
9584           tarfile is named
9585           <file><var>package</var>_<var>version</var>.tar.gz</file> and
9586           contains a directory
9587           <file><var>package</var>-<var>version</var></file>.
9588         </p>
9589       </sect>
9590
9591       <sect><heading>Unpacking a Debian source package without
9592       <prgn>dpkg-source</prgn>
9593         </heading>
9594
9595         <p>
9596           <tt>dpkg-source -x</tt> is the recommended way to unpack a
9597           Debian source package.  However, if it is not available it
9598           is possible to unpack a Debian source archive as follows:
9599         <enumlist compact="compact">
9600           <item>
9601             <p>
9602               Untar the tarfile, which will create a <file>.orig</file>
9603               directory.</p>
9604           </item>
9605           <item>
9606             <p>Rename the <file>.orig</file> directory to
9607               <file><var>package</var>-<var>version</var></file>.</p>
9608           </item>
9609             <item>
9610             <p>
9611               Create the subdirectory <file>debian</file> at the top of
9612               the source tree.</p>
9613           </item>
9614           <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9615           </item>
9616           <item><p>Untar the tarfile again if you want a copy of the original
9617               source code alongside the Debianised version.</p>
9618           </item>
9619         </enumlist>
9620
9621         <p>
9622           It is not possible to generate a valid Debian source archive
9623           without using <prgn>dpkg-source</prgn>.  In particular,
9624           attempting to use <prgn>diff</prgn> directly to generate the
9625           <file>.diff.gz</file> file will not work.
9626         </p>
9627
9628         <sect1><heading>Restrictions on objects in source packages
9629           </heading>
9630
9631           <p>
9632             The source package may not contain any hard links
9633             <footnote>
9634               <p>
9635                 This is not currently detected when building source
9636                 packages, but only when extracting
9637                 them.
9638               </p>
9639             </footnote>
9640             <footnote>
9641               <p>
9642                 Hard links may be permitted at some point in the
9643                 future, but would require a fair amount of
9644                 work.
9645               </p>
9646             </footnote>, device special files, sockets or setuid or
9647             setgid files.
9648             <footnote>
9649               <p>
9650                 Setgid directories are allowed.
9651               </p>
9652             </footnote>
9653           </p>
9654
9655           <p>
9656             The source packaging tools manage the changes between the
9657             original and Debianised source using <prgn>diff</prgn> and
9658             <prgn>patch</prgn>.  Turning the original source tree as
9659             included in the <file>.orig.tar.gz</file> into the debianised
9660             source must not involve any changes which cannot be
9661             handled by these tools.  Problematic changes which cause
9662             <prgn>dpkg-source</prgn> to halt with an error when
9663             building the source package are:
9664             <list compact="compact">
9665               <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9666               </item>
9667               <item><p>Changing the targets of symbolic links.</p>
9668               </item>
9669               <item><p>Creating directories, other than <file>debian</file>.</p>
9670               </item>
9671               <item><p>Changes to the contents of binary files.</p></item>
9672             </list> Changes which cause <prgn>dpkg-source</prgn> to
9673             print a warning but continue anyway are:
9674             <list compact="compact">
9675               <item>
9676                 <p>
9677                   Removing files, directories or symlinks.
9678                   <footnote>
9679                     <p>
9680                       Renaming a file is not treated specially - it is
9681                       seen as the removal of the old file (which
9682                       generates a warning, but is otherwise ignored),
9683                       and the creation of the new
9684                       one.</p>
9685                   </footnote>
9686                 </p>
9687               </item>
9688               <item>
9689                 <p>
9690                   Changed text files which are missing the usual final
9691                   newline (either in the original or the modified
9692                   source tree).
9693                 </p>
9694               </item>
9695             </list>
9696             Changes which are not represented, but which are not detected by
9697             <prgn>dpkg-source</prgn>, are:
9698             <list compact="compact">
9699               <item><p>Changing the permissions of files (other than
9700                   <file>debian/rules</file>) and directories.</p></item>
9701             </list>
9702           </p>
9703
9704           <p>
9705             The <file>debian</file> directory and <file>debian/rules</file>
9706             are handled specially by <prgn>dpkg-source</prgn> - before
9707             applying the changes it will create the <file>debian</file>
9708             directory, and afterwards it will make
9709             <file>debian/rules</file> world-exectuable.
9710           </p>
9711         </sect1>
9712       </sect>
9713     </appendix>
9714
9715     <appendix id="pkg-controlfields"><heading>Control files and their
9716         fields (from old Packaging Manual)
9717       </heading>
9718
9719       <p>
9720         Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9721         data in a common format, known as control files.  Binary and
9722         source packages have control data as do the <file>.changes</file>
9723         files which control the installation of uploaded files, and
9724         <prgn>dpkg</prgn>'s internal databases are in a similar
9725         format.
9726       </p>
9727
9728       <sect><heading>Syntax of control files
9729         </heading>
9730
9731         <p>
9732           A file consists of one or more paragraphs of fields.  The
9733           paragraphs are separated by blank lines.  Some control files
9734           only allow one paragraph; others allow several, in which
9735           case each paragraph often refers to a different package.
9736         </p>
9737
9738         <p>
9739           Each paragraph is a series of fields and values; each field
9740           consists of a name, followed by a colon and the value.  It
9741           ends at the end of the line.  Horizontal whitespace (spaces
9742           and tabs) may occur before or after the value and is ignored
9743           there; it is conventional to put a single space after the
9744           colon.
9745         </p>
9746
9747         <p>
9748           Some fields' values may span several lines; in this case
9749           each continuation line <em>must</em> start with a space or
9750           tab.  Any trailing spaces or tabs at the end of individual
9751           lines of a field value are ignored.
9752         </p>
9753
9754         <p>
9755           Except where otherwise stated only a single line of data is
9756           allowed and whitespace is not significant in a field body.
9757           Whitespace may never appear inside names (of packages,
9758           architectures, files or anything else), version numbers or
9759           in between the characters of multi-character version
9760           relationships.
9761         </p>
9762
9763         <p>
9764           Field names are not case-sensitive, but it is usual to
9765           capitalise the field names using mixed case as shown below.
9766         </p>
9767
9768         <p>
9769           Blank lines, or lines consisting only of spaces and tabs,
9770           are not allowed within field values or between fields - that
9771           would mean a new paragraph.
9772         </p>
9773
9774         <p>
9775           It is important to note that there are several fields which
9776           are optional as far as <prgn>dpkg</prgn> and the related
9777           tools are concerned, but which must appear in every Debian
9778           package, or whose omission may cause problems.
9779         </p>
9780       </sect>
9781
9782       <sect><heading>List of fields
9783         </heading>
9784
9785         <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9786           </heading>
9787
9788           <p>
9789             The name of the binary package.  Package names consist of
9790             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9791             (plus, minus and full stop).
9792             <footnote>
9793               <p>
9794                 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9795                 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9796                 and underscore) used to be legal and are still
9797                 accepted when found in a package file, but may not be
9798                 used in new packages
9799               </p>
9800             </footnote>
9801           </p>
9802
9803           <p>
9804             They must be at least two characters and must start with
9805             an alphanumeric.  In current versions of dpkg they are
9806             sort of case-sensitive<footnote><p>This is a
9807             bug.</p></footnote>; use lowercase package names unless
9808             the package you're building (or referring to, in other
9809             fields) is already using uppercase.</p>
9810         </sect1>
9811
9812         <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9813           </heading>
9814
9815           <p>
9816             This lists the source or binary package's version number -
9817             see <ref id="versions">.
9818           </p>
9819
9820         </sect1>
9821
9822         <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9823           </heading>
9824
9825           <p>
9826             This is the architecture string; it is a single word for
9827             the Debian architecture.
9828           </p>
9829
9830           <p>
9831             <prgn>dpkg</prgn> will check the declared architecture of
9832             a binary package against its own compiled-in value before
9833             it installs it.
9834           </p>
9835
9836           <p>
9837             The special value <tt>all</tt> indicates that the package
9838             is architecture-independent.
9839           </p>
9840
9841           <p>
9842             In the main <file>debian/control</file> file in the source
9843             package, or in the source package control file
9844             <file>.dsc</file>, a list of architectures (separated by
9845             spaces) is also allowed, as is the special value
9846             <tt>any</tt>.  A list indicates that the source will build
9847             an architecture-dependent package, and will only work
9848             correctly on the listed architectures.  <tt>any</tt>
9849             indicates that though the source package isn't dependent
9850             on any particular architecture and should compile fine on
9851             any one, the binary package(s) produced are not
9852             architecture-independent but will instead be specific to
9853             whatever the current build architecture is.
9854           </p>
9855
9856           <p>
9857             In a <file>.changes</file> file the <tt>Architecture</tt>
9858             field lists the architecture(s) of the package(s)
9859             currently being uploaded.  This will be a list; if the
9860             source for the package is being uploaded too the special
9861             entry <tt>source</tt> is also present.
9862           </p>
9863
9864           <p>
9865             See <ref id="pkg-debianrules"> for information how to get the
9866             architecture for the build process.
9867           </p>
9868         </sect1>
9869
9870         <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9871           </heading>
9872
9873           <p>
9874             The package maintainer's name and email address.  The name
9875             should come first, then the email address inside angle
9876             brackets <tt>&lt;&gt</tt> (in RFC822 format).
9877           </p>
9878
9879           <p>
9880             If the maintainer's name contains a full stop then the
9881             whole field will not work directly as an email address due
9882             to a misfeature in the syntax specified in RFC822; a
9883             program using this field as an address must check for this
9884             and correct the problem if necessary (for example by
9885             putting the name in round brackets and moving it to the
9886             end, and bringing the email address forward).
9887           </p>
9888
9889           <p>
9890             In a <file>.changes</file> file or parsed changelog data this
9891             contains the name and email address of the person
9892             responsible for the particular version in question - this
9893             may not be the package's usual maintainer.
9894           </p>
9895
9896           <p>
9897             This field is usually optional in as far as the
9898             <prgn>dpkg</prgn> are concerned, but its absence when
9899             building packages usually generates a warning.</p>
9900         </sect1>
9901
9902         <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9903           </heading>
9904
9905           <p>
9906             This field identifies the source package name.
9907           </p>
9908
9909           <p>
9910             In a main source control information or a
9911             <file>.changes</file> or <file>.dsc</file> file or parsed
9912             changelog data this may contain only the name of the
9913             source package.
9914           </p>
9915
9916           <p>
9917             In the control file of a binary package (or in a
9918             <file>Packages</file> file) it may be followed by a version
9919             number in parentheses.
9920             <footnote>
9921               <p>
9922                 It is usual to leave a space after the package name if
9923                 a version number is specified.
9924               </p>
9925             </footnote> This version number may be omitted (and is, by
9926             <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9927             the <tt>Version</tt> field of the binary package in
9928             question.  The field itself may be omitted from a binary
9929             package control file when the source package has the same
9930             name and version as the binary package.
9931           </p>
9932         </sect1>
9933
9934         <sect1><heading>Package interrelationship fields:
9935             <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9936             <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9937             <tt>Provides</tt>, <tt>Replaces</tt>
9938           </heading>
9939
9940           <p>
9941             These fields describe the package's relationships with
9942             other packages.  Their syntax and semantics are described
9943             in <ref id="relationships">.</p>
9944         </sect1>
9945
9946         <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9947           </heading>
9948
9949           <p>
9950             In a binary package <tt>Packages</tt> file or main source
9951             control file this field contains a description of the
9952             binary package, in a special format.  See <ref
9953             id="descriptions"> for details.
9954           </p>
9955
9956           <p>
9957             In a <file>.changes</file> file it contains a summary of the
9958             descriptions for the packages being uploaded.  The part of
9959             the field before the first newline is empty; thereafter
9960             each line has the name of a binary package and the summary
9961             description line from that binary package.  Each line is
9962             indented by one space.</p>
9963         </sect1>
9964
9965         <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
9966           </heading>
9967
9968           <p>
9969             This is a boolean field which may occur only in the
9970             control file of a binary package (or in the
9971             <file>Packages</file> file) or in a per-package fields
9972             paragraph of a main source control data file.
9973           </p>
9974
9975           <p>
9976             If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
9977             <prgn>dselect</prgn> will refuse to remove the package
9978             (though it can be upgraded and/or replaced).  The other
9979             possible value is <tt>no</tt>, which is the same as not
9980             having the field at all.</p>
9981         </sect1>
9982
9983         <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
9984         <tt>Priority</tt>
9985           </heading>
9986
9987           <p>
9988             These two fields classify the package.  The
9989             <tt>Priority</tt> represents how important that it is that
9990             the user have it installed; the <tt>Section</tt>
9991             represents an application area into which the package has
9992             been classified.
9993           </p>
9994
9995           <p>
9996             When they appear in the <file>debian/control</file> file these
9997             fields give values for the section and priority subfields
9998             of the <tt>Files</tt> field of the <file>.changes</file> file,
9999             and give defaults for the section and priority of the
10000             binary packages.
10001           </p>
10002
10003           <p>
10004             The section and priority are represented, though not as
10005             separate fields, in the information for each file in the
10006             <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
10007             <file>.changes</file> file.  The section value in a
10008             <file>.changes</file> file is used to decide where to install
10009             a package in the FTP archive.
10010           </p>
10011
10012           <p>
10013             These fields are not used by by <prgn>dpkg</prgn> proper,
10014             but by <prgn>dselect</prgn> when it sorts packages and
10015             selects defaults.
10016           </p>
10017
10018           <p>
10019             These fields can appear in binary package control files,
10020             in which case they provide a default value in case the
10021             <file>Packages</file> files are missing the information.
10022             <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
10023             the value from a <file>.deb</file> file if they have no other
10024             information; a value listed in a <file>Packages</file> file
10025             will always take precedence.  By default
10026             <prgn>dpkg-gencontrol</prgn> does not include the section
10027             and priority in the control file of a binary package - use
10028             the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
10029             achieve this effect.</p>
10030         </sect1>
10031
10032         <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
10033           </heading>
10034
10035           <p>
10036             This field is a list of binary packages.
10037           </p>
10038
10039           <p>
10040             When it appears in the <file>.dsc</file> file it is the list
10041             of binary packages which a source package can produce.  It
10042             does not necessarily produce all of these binary packages
10043             for every architecture.  The source control file doesn't
10044             contain details of which architectures are appropriate for
10045             which of the binary packages.
10046           </p>
10047
10048           <p>
10049             When it appears in a <file>.changes</file> file it lists the
10050             names of the binary packages actually being uploaded.
10051           </p>
10052
10053           <p>
10054             The syntax is a list of binary packages separated by
10055             commas.
10056             <footnote>
10057               <p>
10058                 A space after each comma is conventional.
10059               </p>
10060             </footnote> Currently the packages must be separated using
10061             only spaces in the <file>.changes</file> file.</p>
10062         </sect1>
10063
10064         <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10065           </heading>
10066
10067           <p>
10068             This field appears in the control files of binary
10069             packages, and in the <file>Packages</file> files.  It gives
10070             the total amount of disk space required to install the
10071             named package.
10072           </p>
10073
10074           <p>
10075             The disk space is represented in kilobytes as a simple
10076             decimal number.</p>
10077         </sect1>
10078
10079         <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10080           </heading>
10081
10082           <p>
10083             This field contains a list of files with information about
10084             each one.  The exact information and syntax varies with
10085             the context.  In all cases the part of the field
10086             contents on the same line as the field name is empty.  The
10087             remainder of the field is one line per file, each line
10088             being indented by one space and containing a number of
10089             sub-fields separated by spaces.
10090           </p>
10091
10092           <p>
10093             In the <file>.dsc</file> (Debian source control) file each
10094             line contains the MD5 checksum, size and filename of the
10095             tarfile and (if applicable) diff file which make up the
10096             remainder of the source package.
10097             <footnote>
10098               <p>
10099                 That is, the parts which are not the
10100                 <tt>.dsc</tt>.
10101               </p>
10102             </footnote> The exact forms of the filenames are described
10103             in <ref id="pkg-sourcearchives">.
10104           </p>
10105
10106           <p>
10107             In the <file>.changes</file> file this contains one line per
10108             file being uploaded.  Each line contains the MD5 checksum,
10109             size, section and priority and the filename.  The section
10110             and priority are the values of the corresponding fields in
10111             the main source control file - see <ref
10112             id="pkg-f-classification">.  If no section or priority is
10113             specified then <tt>-</tt> should be used, though section
10114             and priority values must be specified for new packages to
10115             be installed properly.
10116           </p>
10117
10118           <p>
10119             The special value <tt>byhand</tt> for the section in a
10120             <tt>.changes</tt> file indicates that the file in question
10121             is not an ordinary package file and must by installed by
10122             hand by the distribution maintainers.  If the section is
10123             <tt>byhand</tt> the priority should be <tt>-</tt>.
10124           </p>
10125
10126           <p>
10127             If a new Debian revision of a package is being shipped and
10128             no new original source archive is being distributed the
10129             <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10130             entry for the original source archive
10131             <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10132             but the <file>.changes</file> file should leave it out.  In
10133             this case the original source archive on the distribution
10134             site must match exactly, byte-for-byte, the original
10135             source archive which was used to generate the
10136             <file>.dsc</file> file and diff which are being uploaded.</p>
10137         </sect1>
10138
10139
10140         <sect1
10141         id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10142           </heading>
10143
10144           <p>
10145             The most recent version of the standards (the Debian Policy
10146             and associated texts) with which the package complies. This
10147             is updated manually when editing the source package to
10148             conform to newer standards; it can sometimes be used to
10149             tell when a package needs attention.
10150           </p>
10151
10152           <p>
10153             Its format is the same as that of a version number except
10154             that no epoch or Debian revision is allowed - see <ref
10155             id="versions">.</p>
10156         </sect1>
10157
10158
10159         <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10160           </heading>
10161
10162           <p>
10163             In a <file>.changes</file> file or parsed changelog output
10164             this contains the (space-separated) name(s) of the
10165             distribution(s) where this version of the package should
10166             be or was installed.  Distribution names follow the rules
10167             for package names.  (See <ref id="pkg-f-Package">).
10168           </p>
10169
10170           <p>
10171             Current distribution values are:
10172           <taglist>
10173             <tag><em>stable</em></tag>
10174             <item>
10175               <p>
10176                 This is the current "released" version of Debian
10177                 GNU/Linux.  A new version is released approximately
10178                 every 3 months after the <em>development</em> code has
10179                 been <em>frozen</em> for a month of testing.  Once the
10180                 distribution is <em>stable</em> only major bug fixes
10181                 are allowed. When changes are made to this
10182                 distribution, the release number is increased
10183                 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10184               </p>
10185             </item>
10186
10187             <tag><em>unstable</em></tag>
10188             <item>
10189               <p>
10190                 This distribution value refers to the
10191                 <em>developmental</em> part of the Debian distribution
10192                 tree. New packages, new upstream versions of packages
10193                 and bug fixes go into the <em>unstable</em> directory
10194                 tree. Download from this distribution at your own
10195                 risk.</p>
10196             </item>
10197
10198             <tag><em>contrib</em></tag>
10199             <item>
10200               <p>
10201                 The packages with this distribution value do not meet
10202                 the criteria for inclusion in the main Debian
10203                 distribution as defined by the Policy Manual, but meet
10204                 the criteria for the <em>contrib</em>
10205                 Distribution. There is currently no distinction
10206                 between stable and unstable packages in the
10207                 <em>contrib</em> or <em>non-free</em>
10208                 distributions. Use your best judgement in downloading
10209                 from this Distribution.</p>
10210             </item>
10211
10212             <tag><em>non-free</em></tag>
10213             <item>
10214               <p>
10215                 Like the packages in the <em>contrib</em> seciton,
10216                 the packages in <em>non-free</em> do not meet the
10217                 criteria for inclusion in the main Debian distribution
10218                 as defined by the Policy Manual. Again, use your best
10219                 judgement in downloading from this Distribution.</p>
10220
10221             <tag><em>experimental</em></tag>
10222             <item>
10223               <p>
10224                 The packages with this distribution value are deemed
10225                 by their maintainers to be high risk. Oftentimes they
10226                 represent early beta or developmental packages from
10227                 various sources that the maintainers want people to
10228                 try, but are not ready to be a part of the other parts
10229                 of the Debian distribution tree. Download at your own
10230                 risk.</p>
10231             </item>
10232
10233             <tag><em>frozen</em></tag>
10234             <item>
10235               <p>
10236                 From time to time, (currently, every 3 months) the
10237                 <em>unstable</em> distribution enters a state of
10238                 "code-freeze" in anticipation of release as a
10239                 <em>stable</em> version. During this period of testing
10240                 (usually 4 weeks) only fixes for existing or
10241                 newly-discovered bugs will be allowed.
10242               </p>
10243             </item>
10244           </taglist> You should list <em>all</em> distributions that
10245           the package should be installed into. Except in unusual
10246           circumstances, installations to <em>stable</em> should also
10247           go into <em>frozen</em> (if it exists) and
10248           <em>unstable</em>. Likewise, installations into
10249           <em>frozen</em> should also go into <em>unstable</em>.</p>
10250         </sect1>
10251
10252         <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10253           </heading>
10254
10255           <p>
10256             This is a description of how important it is to upgrade to
10257             this version from previous ones.  It consists of a single
10258             keyword usually taking one of the values <tt>LOW</tt>,
10259             <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10260             commentary (separated by a space) which is usually in
10261             parentheses.  For example:
10262             <example>
10263   Urgency: LOW (HIGH for diversions users)
10264             </example>
10265           </p>
10266
10267           <p>
10268             This field appears in the <file>.changes</file> file and in
10269             parsed changelogs; its value appears as the value of the
10270             <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10271             changelog (see <ref id="pkg-dpkgchangelog">).
10272           </p>
10273
10274           <p>
10275             Urgency keywords are not case-sensitive.</p>
10276         </sect1>
10277
10278         <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10279           </heading>
10280
10281           <p>
10282             In <tt>.changes</tt> files and parsed changelogs, this
10283             gives the date the package was built or last edited.</p>
10284         </sect1>
10285
10286         <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10287           </heading>
10288
10289           <p>
10290             This field occurs in <file>.changes</file> files, and
10291             specifies a format revision for the file.  The format
10292             described here is version <tt>1.5</tt>.  The syntax of the
10293             format value is the same as that of a package version
10294             number except that no epoch or Debian revision is allowed
10295             - see <ref id="versions">.</p>
10296         </sect1>
10297
10298         <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10299           </heading>
10300
10301           <p>
10302             In a <file>.changes</file> file or parsed changelog this field
10303             contains the human-readable changes data, describing the
10304             differences between the last version and the current one.
10305           </p>
10306
10307           <p>
10308             There should be nothing in this field before the first
10309             newline; all the subsequent lines must be indented by at
10310             least one space; blank lines must be represented by a line
10311             consiting only of a space and a full stop.
10312           </p>
10313
10314           <p>
10315             Each version's change information should be preceded by a
10316             "title" line giving at least the version, distribution(s)
10317             and urgency, in a human-readable way.
10318           </p>
10319
10320           <p>
10321             If data from several versions is being returned the entry
10322             for the most recent version should be returned first, and
10323             entries should be separated by the representation of a
10324             blank line (the "title" line may also be followed by the
10325             representation of blank line).</p>
10326         </sect1>
10327
10328         <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10329         <tt>MSDOS-Filename</tt>
10330           </heading>
10331
10332           <p>
10333             These fields in <tt>Packages</tt> files give the
10334             filename(s) of (the parts of) a package in the
10335             distribution directories, relative to the root of the
10336             Debian hierarchy.  If the package has been split into
10337             several parts the parts are all listed in order, separated
10338             by spaces.</p>
10339         </sect1>
10340
10341         <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10342           </heading>
10343
10344           <p>
10345             These fields in <file>Packages</file> files give the size (in
10346             bytes, expressed in decimal) and MD5 checksum of the
10347             file(s) which make(s) up a binary package in the
10348             distribution.  If the package is split into several parts
10349             the values for the parts are listed in order, separated by
10350             spaces.</p>
10351         </sect1>
10352
10353         <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10354           </heading>
10355
10356           <p>
10357             This field in <prgn>dpkg</prgn>'s status file records
10358             whether the user wants a package installed, removed or
10359             left alone, whether it is broken (requiring
10360             reinstallation) or not and what its current state on the
10361             system is.  Each of these pieces of information is a
10362             single word.</p>
10363         </sect1>
10364
10365         <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10366           </heading>
10367
10368           <p>
10369             If a package is not installed or not configured, this
10370             field in <prgn>dpkg</prgn>'s status file records the last
10371             version of the package which was successfully
10372             configured.</p>
10373         </sect1>
10374
10375         <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10376           </heading>
10377
10378           <p>
10379             This field in <prgn>dpkg</prgn>'s status file contains
10380             information about the automatically-managed configuration
10381             files held by a package.  This field should <em>not</em>
10382             appear anywhere in a package!</p>
10383         </sect1>
10384
10385         <sect1><heading>Obsolete fields
10386           </heading>
10387
10388           <p>
10389             These are still recognised by <prgn>dpkg</prgn> but should
10390             not appear anywhere any more.
10391             <taglist compact="compact">
10392
10393               <tag><tt>Revision</tt></tag>
10394               <tag><tt>Package-Revision</tt></tag>
10395               <tag><tt>Package_Revision</tt></tag>
10396               <item>
10397                 <p>
10398                   The Debian revision part of the package version was
10399                   at one point in a separate control file field.  This
10400                   field went through several names.</p>
10401               </item>
10402
10403               <tag><tt>Recommended</tt></tag>
10404               <item><p>Old name for <tt>Recommends</tt></p>
10405               </item>
10406
10407               <tag><tt>Optional</tt></tag>
10408               <item><p>Old name for <tt>Suggests</tt>.</p>
10409               </item>
10410               <tag><tt>Class</tt></tag>
10411               <item><p>Old name for <tt>Priority</tt>.</p>
10412               </item>
10413             </taglist>
10414           </p>
10415         </sect1>
10416       </sect>
10417     </appendix>
10418
10419     <appendix id="pkg-conffiles"><heading>Configuration file handling
10420     (from old Packaging Manual)
10421       </heading>
10422
10423       <p>
10424         <prgn>dpkg</prgn> can do a certain amount of automatic
10425         handling of package configuration files.
10426       </p>
10427
10428       <p>
10429         Whether this mechanism is appropriate depends on a number of
10430         factors, but basically there are two approaches to any
10431         particular configuration file.
10432       </p>
10433
10434       <p>
10435         The easy method is to ship a best-effort configuration in the
10436         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10437         handle updates.  If the user is unlikely to want to edit the
10438         file, but you need them to be able to without losing their
10439         changes, and a new package with a changed version of the file
10440         is only released infrequently, this is a good approach.
10441       </p>
10442
10443       <p>
10444         The hard method is to build the configuration file from
10445         scratch in the <prgn>postinst</prgn> script, and to take the
10446         responsibility for fixing any mistakes made in earlier
10447         versions of the package automatically.  This will be
10448         appropriate if the file is likely to need to be different on
10449         each system.
10450       </p>
10451
10452       <sect><heading>Automatic handling of configuration files by
10453       <prgn>dpkg</prgn>
10454         </heading>
10455
10456         <p>
10457           A package may contain a control area file called
10458           <tt>conffiles</tt>.  This file should be a list of filenames
10459           of configuration files needing automatic handling, separated
10460           by newlines.  The filenames should be absolute pathnames,
10461           and the files referred to should actually exist in the
10462           package.
10463         </p>
10464
10465         <p>
10466           When a package is upgraded <prgn>dpkg</prgn> will process
10467           the configuration files during the configuration stage,
10468           shortly before it runs the package's <prgn>postinst</prgn>
10469           script,
10470         </p>
10471
10472         <p>
10473           For each file it checks to see whether the version of the
10474           file included in the package is the same as the one that was
10475           included in the last version of the package (the one that is
10476           being upgraded from); it also compares the version currently
10477           installed on the system with the one shipped with the last
10478           version.
10479         </p>
10480
10481         <p>
10482           If neither the user nor the package maintainer has changed
10483           the file, it is left alone.  If one or the other has changed
10484           their version, then the changed version is preferred - i.e.,
10485           if the user edits their file, but the package maintainer
10486           doesn't ship a different version, the user's changes will
10487           stay, silently, but if the maintainer ships a new version
10488           and the user hasn't edited it the new version will be
10489           installed (with an informative message).  If both have
10490           changed their version the user is prompted about the problem
10491           and must resolve the differences themselves.
10492         </p>
10493
10494         <p>
10495           The comparisons are done by calculating the MD5 message
10496           digests of the files, and storing the MD5 of the file as it
10497           was included in the most recent version of the package.
10498         </p>
10499
10500         <p>
10501           When a package is installed for the first time
10502           <prgn>dpkg</prgn> will install the file that comes with it,
10503           unless that would mean overwriting a file already on the
10504           filesystem.
10505         </p>
10506
10507         <p>
10508           However, note that <prgn>dpkg</prgn> will <em>not</em>
10509           replace a conffile that was removed by the user (or by a
10510           script).  This is necessary because with some programs a
10511           missing file produces an effect hard or impossible to
10512           achieve in another way, so that a missing file needs to be
10513           kept that way if the user did it.
10514         </p>
10515
10516         <p>
10517           Note that a package should <em>not</em> modify a
10518           <prgn>dpkg</prgn>-handled conffile in its maintainer
10519           scripts.  Doing this will lead to <prgn>dpkg</prgn> giving
10520           the user confusing and possibly dangerous options for
10521           conffile update when the package is upgraded.</p>
10522       </sect>
10523
10524       <sect><heading>Fully-featured maintainer script configuration
10525       handling
10526         </heading>
10527
10528         <p>
10529           For files which contain site-specific information such as
10530           the hostname and networking details and so forth, it is
10531           better to create the file in the package's
10532           <prgn>postinst</prgn> script.
10533         </p>
10534
10535         <p>
10536           This will typically involve examining the state of the rest
10537           of the system to determine values and other information, and
10538           may involve prompting the user for some information which
10539           can't be obtained some other way.
10540         </p>
10541
10542         <p>
10543           When using this method there are a couple of important
10544           issues which should be considered:
10545         </p>
10546
10547         <p>
10548           If you discover a bug in the program which generates the
10549           configuration file, or if the format of the file changes
10550           from one version to the next, you will have to arrange for
10551           the postinst script to do something sensible - usually this
10552           will mean editing the installed configuration file to remove
10553           the problem or change the syntax.  You will have to do this
10554           very carefully, since the user may have changed the file,
10555           perhaps to fix the very problem that your script is trying
10556           to deal with - you will have to detect these situations and
10557           deal with them correctly.
10558         </p>
10559
10560         <p>
10561           If you do go down this route it's probably a good idea to
10562           make the program that generates the configuration file(s) a
10563           separate program in <file>/usr/sbin</file>, by convention called
10564           <file><var>package</var>config</file> and then run that if
10565           appropriate from the post-installation script.  The
10566           <tt><var>package</var>config</tt> program should not
10567           unquestioningly overwrite an existing configuration - if its
10568           mode of operation is geared towards setting up a package for
10569           the first time (rather than any arbitrary reconfiguration
10570           later) you should have it check whether the configuration
10571           already exists, and require a <tt>--force</tt> flag to
10572           overwrite it.</p></sect>
10573     </appendix>
10574
10575     <appendix id="pkg-alternatives"><heading>Alternative versions of
10576         an interface - <prgn>update-alternatives</prgn> (from old
10577     Packaging Manual)
10578       </heading>
10579
10580       <p>
10581         When several packages all provide different versions of the
10582         same program or file it is useful to have the system select a
10583         default, but to allow the system administrator to change it
10584         and have their decisions respected.
10585       </p>
10586
10587       <p>
10588         For example, there are several versions of the <prgn>vi</prgn>
10589         editor, and there is no reason to prevent all of them from
10590         being installed at once, each under their own name
10591         (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10592         Nevertheless it is desirable to have the name <tt>vi</tt>
10593         refer to something, at least by default.
10594       </p>
10595
10596       <p>
10597         If all the packages involved cooperate, this can be done with
10598         <prgn>update-alternatives</prgn>.
10599       </p>
10600
10601       <p>
10602         Each package provides its own version under its own name, and
10603         calls <prgn>update-alternatives</prgn> in its postinst to
10604         register its version (and again in its prerm to deregister
10605         it).
10606       </p>
10607
10608       <p>
10609         See the manpage <manref name="update-alternatives"
10610         section="8"> for details.
10611       </p>
10612
10613       <p>
10614         If <prgn>update-alternatives</prgn> does not seem appropriate
10615         you may wish to consider using diversions instead.</p>
10616     </appendix>
10617
10618     <appendix id="pkg-diversions"><heading>Diversions - overriding a
10619     package's version of a file (from old Packaging Manual)
10620       </heading>
10621
10622       <p>
10623         It is possible to have <prgn>dpkg</prgn> not overwrite a file
10624         when it reinstalls the package it belongs to, and to have it
10625         put the file from the package somewhere else instead.
10626       </p>
10627
10628       <p>
10629         This can be used locally to override a package's version of a
10630         file, or by one package to override another's version (or
10631         provide a wrapper for it).
10632       </p>
10633
10634       <p>
10635         Before deciding to use a diversion, read <ref
10636         id="pkg-alternatives"> to see if you really want a diversion
10637         rather than several alternative versions of a program.
10638       </p>
10639
10640       <p>
10641         There is a diversion list, which is read by <prgn>dpkg</prgn>,
10642         and updated by a special program <prgn>dpkg-divert</prgn>.
10643         Please see <manref name="dpkg-divert" section="8"> for full
10644         details of its operation.
10645       </p>
10646
10647       <p>
10648         When a package wishes to divert a file from another, it should
10649         call <prgn>dpkg-divert</prgn> in its preinst to add the
10650         diversion and rename the existing file.  For example,
10651         supposing that a <prgn>smailwrapper</prgn> package wishes to
10652         install a wrapper around <file>/usr/sbin/smail</file>:
10653         <example>
10654   if [ install = "$1"  ]; then
10655      dpkg-divert --package smailwrapper --add --rename \
10656         --divert /usr/sbin/smail.real /usr/sbin/smail
10657   fi
10658         </example> Testing <tt>$1</tt> is necessary so that the script
10659         doesn't try to add the diversion again when
10660         <prgn>smailwrapper</prgn> is upgraded.  The <tt>--package
10661         smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10662         copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10663         get installed as the true version.
10664       </p>
10665
10666       <p>
10667         The postrm has to do the reverse:
10668         <example>
10669   if [ remove = "$1" ]; then
10670      dpkg-divert --package smailwrapper --remove --rename \
10671         --divert /usr/sbin/smail.real /usr/sbin/smail
10672   fi
10673         </example>
10674       </p>
10675
10676       <p>
10677         Do not attempt to divert a file which is vitally important for
10678         the system's operation - when using <prgn>dpkg-divert</prgn>
10679         there is a time, after it has been diverted but before
10680         <prgn>dpkg</prgn> has installed the new version, when the file
10681         does not exist.</p>
10682     </appendix>
10683
10684   </book>
10685 </debiandoc>
10686 <!-- vim:set ai et sts=2 sw=2 tw=76: -->