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