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