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