]> git.donarmstrong.com Git - debian/debian-policy.git/blob - packaging.sgml
New version
[debian/debian-policy.git] / packaging.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
7 <!--
8  Debian GNU/Linux Packaging Manual.
9  Copyright (C)1996 Ian Jackson; released under the terms of the GNU
10  General Public License, version 2 or (at your option) any later.
11  Revised: David A. Morris (bweaver@debian.org)
12  Maintainer since 1998, Christian Schwarz <schwarz@debian.org>
13  -->
14
15 <debiandoc>
16   <book>
17
18     <titlepag><title>Debian Packaging Manual</title>
19       <author>
20         <name>Ian Jackson </name>
21         <email>ijackson@gnu.ai.mit.edu</email>
22       </author>
23       <author>
24         <name>Revised: David A. Morris</name>
25         <email>bweaver@debian.org</email>
26       </author>
27       <author>
28         <name>Maintainer: Christian Schwarz </name>
29         <email>schwarz@debian.org</email>
30       </author>
31       <author>
32         <name>Maintainer: Manoj Srivastava </name>
33         <email>srivasta@debian.org</email>
34       </author>
35       <author>
36         <name>Maintainer: The Debian Policy group </name>
37         <email>debian-policy@lists.debian.org</email>
38       </author>
39       <version>version &version;, &date;</version>
40         
41       <abstract>
42         This manual describes the technical aspects of creating Debian
43         binary and source packages.  It also documents the interface
44         between <prgn>dselect</prgn> and its access method scripts.
45         It does not deal with the Debian Project policy requirements,
46         and it assumes familiarity with <prgn>dpkg</prgn>'s functions
47         from the system administrator's perspective.
48
49       <copyright>
50         <copyrightsummary>Copyright &copy;1996 Ian Jackson.</copyrightsummary>
51         <p>
52           This manual is free software; you may redistribute it and/or
53           modify it under the terms of the GNU General Public License
54           as published by the Free Software Foundation; either version
55           2, or (at your option) any later version.
56         </p>
57
58         <p>
59           This is distributed in the hope that it will be useful, but
60           <em>without any warranty</em>; without even the implied
61           warranty of merchantability or fitness for a particular
62           purpose.  See the GNU General Public License for more
63           details.
64           </p>
65
66         <p>
67           A copy of the GNU General Public License is available as
68           <tt>/usr/doc/copyright/GPL</tt> in the Debian GNU/Linux
69           distribution or on the World Wide Web at
70           <tt>http://www.gnu.org/copyleft/gpl.html</tt>. You can also
71           obtain it by writing to the Free Software Foundation, Inc.,
72           59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
73         </p>
74       </copyright>
75
76     <toc detail="sect">
77
78     <!-- Describes the technical interface between a package and dpkg.
79
80     How to safely put shared libraries in a package.  Details of
81     dpkg's handling of individual files.  Sections on when to use
82     which feature (eg Replaces vs. Replaces/Conflicts
83     vs. update-alternatives vs. diversions) Cross-references to the
84     policy document (see below) where appropriate.  Description of the
85     interface between dselect and its access methods.  Hints on where
86     to start with a new package (ie, the hello package).  What to do
87     about file aliasing.
88     
89     file aliasing
90     
91     Manpages are required for: update-rc.d, diversions,
92     update-alternatives, install-info in a package.
93
94     -->
95
96     <chapt id="scope">
97       <heading>Introduction and scope of this manual</heading>
98
99       <p>
100         <prgn>dpkg</prgn> is a suite of programs for creating binary
101         package files and installing and removing them on Unix
102         systems.<footnote>
103           <p>
104             <prgn>dpkg</prgn> is targetted primarily at Debian
105             GNU/Linux, but may work on or be ported to other
106             systems.
107           </p>
108         </footnote>
109       </p>
110
111       <p>
112         The binary packages are designed for the management of
113         installed executable programs (usually compiled binaries) and
114         their associated data, though source code examples and
115         documentation are provided as part of some packages.</p>
116
117       <p>
118         This manual describes the technical aspects of creating Debian
119         binary packages (<tt>.deb</tt> files).  It documents the
120         behaviour of the package management programs
121         <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and and the way
122         they interact with packages.</p>
123
124       <p>
125         It also documents the interaction between
126         <prgn>dselect</prgn>'s core and the access method scripts it
127         uses to actually install the selected packages, and describes
128         how to create a new access method.</p>
129         
130       <p>
131         This manual does not go into detail about the options and
132         usage of the package building and installation tools.  It
133         should therefore be read in conjuction with those programs'
134         manpages.
135       </p>      
136
137       <p>
138         The utility programs which are provided with <prgn>dpkg</prgn>
139         for managing various system configuration and similar issues,
140         such as <prgn>update-rc.d</prgn> and
141         <prgn>install-info</prgn>, are not described in detail here -
142         please see their manpages.
143       </p>
144         
145       <p>
146         It does <em>not</em> describe the policy requirements imposed
147         on Debian packages, such as the permissions on files and
148         directories, documentation requirements, upload procedure, and
149         so on.  You should see the Debian packaging policy manual for
150         these details.  (Many of them will probably turn out to be
151         helpful even if you don't plan to upload your package and make
152         it available as part of the distribution.)
153       </p>
154         
155       <p>
156         It is assumed that the reader is reasonably familiar with the
157         <prgn>dpkg</prgn> System Administrators' manual.
158         Unfortunately this manual does not yet exist.
159       </p>
160         
161       <p>
162         The Debian version of the FSF's GNU hello program is provided
163         as an example for people wishing to create Debian
164         packages. The Debian <prgn>debmake</prgn> package is
165         recommended as a very helpful tool in creating and maintaining
166         Debian packages. However, while the tools and examples are
167         helpful, they do not replace the need to read and follow the
168         Policy and Programmer's Manual.</p>
169     </chapt>
170       
171     <chapt id="binarypkg"><heading>Binary packages
172       </heading>
173         
174       <p>
175         The binary package has two main sections.  The first part
176         consists of various control information files and scripts used
177         by <prgn>dpkg</prgn> when installing and removing.  See <ref
178         id="controlarea">.
179       </p>
180         
181       <p>
182         The second part is an archive containing the files and
183         directories to be installed.
184       </p>
185         
186       <p>
187         In the future binary packages may also contain other
188         components, such as checksums and digital signatures. The
189         format for the archive is described in full in the
190         <tt>deb(5)</tt> manpage.
191       </p>
192         
193         
194       <sect id="bincreating"><heading>Creating package files -
195       <prgn>dpkg-deb</prgn>
196         </heading>
197           
198         <p>
199           All manipulation of binary package files is done by
200           <prgn>dpkg-deb</prgn>; it's the only program that has
201           knowledge of the format.  (<prgn>dpkg-deb</prgn> may be
202           invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
203           will spot that the options requested are appropriate to
204           <prgn>dpkg-deb</prgn> and invoke that instead with the same
205           arguments.)
206         </p>
207           
208         <p>
209           In order to create a binary package you must make a
210           directory tree which contains all the files and directories
211           you want to have in the filesystem data part of the package.
212           In Debian-format source packages this directory is usually
213           <tt>debian/tmp</tt>, relative to the top of the package's
214           source tree.
215         </p>
216           
217         <p>
218           They should have the locations (relative to the root of the
219           directory tree you're constructing) ownerships and
220           permissions which you want them to have on the system when
221           they are installed.
222         </p>
223           
224         <p>
225           With current versions of <prgn>dpkg</prgn> the uid/username
226           and gid/groupname mappings for the users and groups being
227           used should be the same on the system where the package is
228           built and the one where it is installed.
229         </p>
230           
231         <p>
232           You need to add one special directory to the root of the
233           miniature filesystem tree you're creating:
234           <prgn>DEBIAN</prgn>.  It should contain the control
235           information files, notably the binary package control file
236           (see <ref id="controlfile">).
237         </p>
238           
239         <p>
240           The <prgn>DEBIAN</prgn> directory will not appear in the
241           filesystem archive of the package, and so won't be installed
242           by <prgn>dpkg</prgn> when the package is installed.
243         </p>
244           
245         <p>
246           When you've prepared the package, you should invoke:
247           <example>
248             dpkg --build <var>directory</var>
249           </example>
250         </p>
251           
252         <p>
253           This will build the package in
254           <tt><var>directory</var>.deb</tt>.  (<prgn>dpkg</prgn> knows
255           that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
256           it invokes <prgn>dpkg-deb</prgn> with the same arguments to
257           build the package.)
258         </p>
259           
260         <p>
261           See the manpage <manref name="dpkg-deb" section="8"> for details of how
262           to examine the contents of this newly-created file.  You may find the
263           output of following commands enlightening:
264           <example>
265 dpkg-deb --info <var>filename</var>.deb
266 dpkg-deb --contents <var>filename</var>.deb
267 dpkg --contents <var>filename</var>.deb
268 </example>
269           To view the copyright file for a package you could use this command:
270 <example>
271 dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/doc/<var>\*</var>copyright | less
272 </example></p>
273         
274       <sect id="controlarea">
275         <heading>
276           Package control information files
277         </heading>
278           
279         <p>
280           The control information portion of a binary package is a
281           collection of files with names known to <prgn>dpkg</prgn>.
282           It will treat the contents of these files specially - some
283           of them contain information used by <prgn>dpkg</prgn> when
284           installing or removing the package; others are scripts which
285           the package maintainer wants <prgn>dpkg</prgn> to run.
286         </p>
287           
288         <p>
289           It is possible to put other files in the package control
290           area, but this is not generally a good idea (though they
291           will largely be ignored).
292         </p>
293           
294         <p>
295           Here is a brief list of the control info files supported by
296           <prgn>dpkg</prgn> and a summary of what they're used for.
297         </p>
298           
299         <p>
300           <taglist>
301             <tag><tt>control</tt>
302             <item>
303               
304               <p>
305                 This is the key description file used by
306                 <prgn>dpkg</prgn>.  It specifies the package's name
307                 and version, gives its description for the user,
308                 states its relationships with other packages, and so
309                 forth.  See <ref id="controlfile">.
310               </p>
311                 
312               <p>
313                 It is usually generated automatically from information
314                 in the source package by the
315                 <prgn>dpkg-gencontrol</prgn> program, and with
316                 assistance from <prgn>dpkg-shlibdeps</prgn>.  See <ref
317                 id="sourcetools">.</p>
318             </item>
319               
320             <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
321             <tt>prerm</tt>
322             </tag>
323             <item>
324               
325               <p>
326                 These are exectuable files (usually scripts) which
327                 <prgn>dpkg</prgn> runs during installation, upgrade
328                 and removal of packages.  They allow the package to
329                 deal with matters which are particular to that package
330                 or require more complicated processing than that
331                 provided by <prgn>dpkg</prgn>.  Details of when and
332                 how they are called are in <ref
333                 id="maintainerscripts">.
334               </p>
335                 
336               <p>
337                 It is very important to make these scripts
338                 idempotent.
339                 <footnote>
340                   <p>
341                     That means that if it runs successfully or fails
342                     and then you call it again it doesn't bomb out,
343                     but just ensures that everything is the way it
344                     ought to be.
345                   </p>
346                 </footnote> This is so that if an error occurs, the
347                 user interrupts <prgn>dpkg</prgn> or some other
348                 unforeseen circumstance happens you don't leave the
349                 user with a badly-broken package.
350               </p>
351                 
352               <p>
353                 The maintainer scripts are guaranteed to run with a
354                 controlling terminal and can interact with the user.
355                 If they need to prompt for passwords, do full-screen
356                 interaction or something similar you should do these
357                 things to and from <tt>/dev/tty</tt>, since
358                 <prgn>dpkg</prgn> will at some point redirect scripts'
359                 standard input and output so that it can log the
360                 installation process.  Likewise, because these scripts
361                 may be executed with standard output redirected into a
362                 pipe for logging purposes, Perl scripts should set
363                 unbuffered output by setting <tt>$|=1</tt> so that the
364                 output is printed immediately rather than being
365                 buffered.
366               </p>
367                 
368               <p>
369                 Each script should return a zero exit status for
370                 success, or a nonzero one for failure.</p>
371             </item>
372               
373             <tag><tt>conffiles</tt>
374             </tag>
375             <item>
376               
377               <p>
378                 This file contains a list of configuration files which
379                 are to be handled automatically by <prgn>dpkg</prgn>
380                 (see <ref id="conffiles">).  Note that not necessarily
381                 every configuration file should be listed here.</p>
382             </item>
383               
384             <tag><tt>shlibs</tt>
385             </tag>
386             <item>
387               
388               <p>
389                 This file contains a list of the shared libraries
390                 supplied by the package, with dependency details for
391                 each.  This is used by <prgn>dpkg-shlibdeps</prgn>
392                 when it determines what dependencies are required in a
393                 package control file. The <tt>shlibs</tt> file format
394                 is described on <ref id="shlibs">.
395               </p>
396             </item>
397           </taglist>
398         </p>
399         
400       <sect id="controlfile">
401         <heading>
402           The main control information file: <tt>control</tt>
403         </heading>
404         <p>
405           The most important control information file used by
406           <prgn>dpkg</prgn> when it installs a package is
407           <tt>control</tt>.  It contains all the package's `vital
408           statistics'.
409         </p>
410
411         <p>       
412           The binary package control files of packages built from
413           Debian sources are made by a special tool,
414           <prgn>dpkg-gencontrol</prgn>, which reads
415           <tt>debian/control</tt> and <tt>debian/changelog</tt> to
416           find the information it needs.  See <ref id="sourcepkg"> for
417           more details.
418         </p>
419
420         <p>       
421           The fields in binary package control files are:
422           <list compact="compact">
423             <item>
424               <p><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</p>
425             </item>
426             <item>
427               <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
428             </item>
429             <item><p><qref id="f-Architecture"><tt>Architecture</tt></qref>
430                 (mandatory)
431                 <footnote>
432                   <p>
433                     This field should appear in all packages, though
434                     <prgn>dpkg</prgn> doesn't require it yet so that
435                     old packages can still be installed.
436                   </p>
437                 </footnote>
438               </p>
439             </item>
440             <item>
441               <p><qref id="relationships"><tt>Depends</tt>,
442                   <tt>Provides</tt> et al.</qref></p>
443             </item>
444             <item>
445               <p><qref id="f-Essential"><tt>Essential</tt></qref></p>
446             </item>
447             <item>
448               <p><qref id="f-Maintainer"><tt>Maintainer</tt></qref></p>
449             </item>
450             <item>
451               <p><qref id="f-classification"><tt>Section</tt>,
452                   <tt>Priority</tt></qref></p>
453             </item>
454             <item>
455               <p><qref id="f-Source"><tt>Source</tt></qref></p>
456             </item>
457             <item>
458               <p><qref id="descriptions"><tt>Description</tt></qref></p>
459             </item>
460             <item>
461               <p>
462                 <qref id="f-Installed-Size"><tt>Installed-Size</tt></qref>
463               </p>
464             </item> 
465           </list>
466             
467         <p>
468           A description of the syntax of control files and the purpose
469           of these fields is available in <ref id="controlfields">.
470         </p>
471       </sect>
472       <sect>
473         <heading>Time Stamps</heading>
474         <p>
475           Maintainers are encouraged to preserve the modification
476           times of the upstream source files in a package, as far as
477           is reasonably possible. 
478           <footnote>
479             <p>
480               The rationale is that there is some information conveyed
481               by knowing the age of the file, for example, you could
482               recognize that some documentation is very old by looking
483               at the modification time, so it would be nice if the
484               modification time of the upstream source would be
485               preserved.
486             </p>
487           </footnote>
488         </p>
489       </sect>
490       
491     <chapt id="sourcepkg">
492       <heading>Source packages</heading>
493
494       <p>       
495         The Debian binary packages in the distribution are generated
496         from Debian sources, which are in a special format to assist
497         the easy and automatic building of binaries.
498       </p>
499
500       <p>       
501         There was a previous version of the Debian source format,
502         which is now being phased out.  Instructions for converting an
503         old-style package are given in the Debian policy manual.
504       </p>
505         
506       <sect id="sourcetools">
507         <heading>Tools for processing source packages</heading> 
508
509         <p>       
510           Various tools are provided for manipulating source packages;
511           they pack and unpack sources and help build of binary
512           packages and help manage the distribution of new versions.
513         </p>
514
515         <p>       
516           They are introduced and typical uses described here; see
517           <manref name="dpkg-source" section="1"> for full
518           documentation about their arguments and operation.
519         </p>
520
521         <p>       
522           For examples of how to construct a Debian source package,
523           and how to use those utilities that are used by Debian
524           source packages, please see the <prgn>hello</prgn> example
525           package.
526         </p>
527           
528         <sect1>
529           <heading>
530             <prgn>dpkg-source</prgn> - packs and unpacks Debian source
531             packages
532           </heading>
533
534           <p>       
535             This program is frequently used by hand, and is also
536             called from package-independent automated building scripts
537             such as <prgn>dpkg-buildpackage</prgn>.
538           </p>
539
540           <p>       
541             To unpack a package it is typically invoked with
542             <example>
543               dpkg-source -x <var>.../path/to/filename</var>.dsc
544             </example> 
545           </p>
546
547            <p>  
548             with the <tt><var>filename</var>.tar.gz</tt> and
549             <tt><var>filename</var>.diff.gz</tt> (if applicable) in
550             the same directory.  It unpacks into
551             <tt><var>package</var>-<var>version</var></tt>, and if
552             applicable
553             <tt><var>package</var>-<var>version</var>.orig</tt>, in
554             the current directory.
555           </p>
556
557           <p>       
558             To create a packed source archive it is typically invoked:
559             <example>
560               dpkg-source -b <var>package</var>-<var>version</var>
561           </example>
562           </p>
563
564           <p>
565             This will create the <tt>.dsc</tt>, <tt>.tar.gz</tt> and
566             <tt>.diff.gz</tt> (if appropriate) in the current
567             directory.  <prgn>dpkg-source</prgn> does not clean the
568             source tree first - this must be done separately if it is
569             required.
570           </p>
571
572           <p>       
573             See also <ref id="sourcearchives">.</p>
574         </sect1>
575           
576           
577         <sect1>
578           <heading>
579             <prgn>dpkg-buildpackage</prgn> - overall package-building
580             control script
581           </heading>
582
583           <p>       
584             <prgn>dpkg-buildpackage</prgn> is a script which invokes
585             <prgn>dpkg-source</prgn>, the <tt>debian/rules</tt>
586             targets <prgn>clean</prgn>, <prgn>build</prgn> and
587             <prgn>binary</prgn>, <prgn>dpkg-genchanges</prgn> and
588             <prgn>pgp</prgn> to build a signed source and binary
589             package upload.
590           </p>
591
592           <p>       
593             It is usually invoked by hand from the top level of the
594             built or unbuilt source directory.  It may be invoked with
595             no arguments; useful arguments include:
596             <taglist compact="compact">
597               <tag><tt>-uc</tt>, <tt>-us</tt></tag>
598               <item>
599                 <p>
600                   Do not PGP-sign the <tt>.changes</tt> file or the
601                   source package <tt>.dsc</tt> file, respectively.</p>
602               </item>
603               <tag><tt>-p<var>pgp-command</var></tt></tag>
604               <item>
605                 <p>
606                   Invoke <var>pgp-command</var> instead of finding
607                   <tt>pgp</tt> on the <prgn>PATH</prgn>.
608                   <var>pgp-command</var> must behave just like
609                   <prgn>pgp</prgn>.</p>
610               </item>
611               <tag><tt>-r<var>root-command</var></tt></tag>
612               <item>
613                 <p>
614                   When root privilege is required, invoke the command
615                   <var>root-command</var>.  <var>root-command</var>
616                   should invoke its first argument as a command, from
617                   the <prgn>PATH</prgn> if necessary, and pass its
618                   second and subsequent arguments to the command it
619                   calls.  If no <var>root-command</var> is supplied
620                   then <var>dpkg-buildpackage</var> will take no
621                   special action to gain root privilege, so that for
622                   most packages it will have to be invoked as root to
623                   start with.</p>
624               </item>
625               <tag><tt>-b</tt>, <tt>-B</tt></tag>
626               <item>
627                 <p>
628                   Two types of binary-only build and upload - see
629                   <manref name="dpkg-source" section="1">.
630                 </p>
631               </item>
632             </taglist>
633           </p>
634         </sect1>
635           
636         <sect1>
637           <heading>
638             <prgn>dpkg-gencontrol</prgn> - generates binary package
639             control files
640           </heading>
641
642           <p>       
643             This program is usually called from <tt>debian/rules</tt>
644             (see <ref id="sourcetree">) in the top level of the source
645             tree.
646           </p>
647
648           <p>       
649             This is usually done just before the files and directories in the
650             temporary directory tree where the package is being built have their
651             permissions and ownerships set and the package is constructed using
652             <prgn>dpkg-deb/</prgn>
653               <footnote>
654               <p>
655                 This is so that the control file which is produced has
656                 the right permissions
657               </p>
658             </footnote>.
659           </p>
660
661           <p>       
662             <prgn>dpkg-gencontrol</prgn> must be called after all the
663             files which are to go into the package have been placed in
664             the temporary build directory, so that its calculation of
665             the installed size of a package is correct.
666           </p>
667
668           <p>       
669             It is also necessary for <prgn>dpkg-gencontrol</prgn> to
670             be run after <prgn>dpkg-shlibdeps</prgn> so that the
671             variable substitutions created by
672             <prgn>dpkg-shlibdeps</prgn> in <tt>debian/substvars</tt>
673             are available.
674           </p>
675
676           <p>       
677             For a package which generates only one binary package, and
678             which builds it in <tt>debian/tmp</tt> relative to the top
679             of the source package, it is usually sufficient to call:
680             <example>
681               dpkg-gencontrol
682             </example>
683           </p>
684
685           <p>       
686             Sources which build several binaries will typically need
687             something like:
688             <example>
689               dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
690             </example> The <tt>-P</tt> tells
691             <prgn>dpkg-gencontrol</prgn> that the package is being
692             built in a non-default directory, and the <tt>-p</tt>
693             tells it which package's control file should be generated.
694           </p>
695
696           <p>       
697             <prgn>dpkg-gencontrol</prgn> also adds information to the
698             list of files in <tt>debian/files</tt>, for the benefit of
699             (for example) a future invocation of
700             <prgn>dpkg-genchanges</prgn>.</p>
701         </sect1>
702           
703         <sect1>
704           <heading>
705             <prgn>dpkg-shlibdeps</prgn> - calculates shared library
706             dependencies
707           </heading>
708
709           <p>       
710             This program is usually called from <tt>debian/rules</tt>
711             just before <prgn>dpkg-gencontrol</prgn> (see <ref
712             id="sourcetree">), in the top level of the source tree.
713           </p>
714
715           <p>       
716             Its arguments are executables
717             <footnote>
718               <p>
719                 They may be specified either in the locations in the
720                 source tree where they are created or in the locations
721                 in the temporary build tree where they are installed
722                 prior to binary package creation.
723               </p>
724             </footnote> for which shared library dependencies should
725             be included in the binary package's control file.
726           </p>
727
728           <p>       
729             If some of the executable(s) shared libraries should only
730             warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
731             some warrant a <tt>Pre-Depends</tt>, this can be achieved
732             by using the <tt>-d<var>dependency-field</var></tt> option
733             before those executable(s).  (Each <tt>-d</tt> option
734             takes effect until the next <tt>-d</tt>.)
735           </p>
736
737           <p>       
738             <prgn>dpkg-shlibdeps</prgn> does not directly cause the
739             output control file to be modified.  Instead by default it
740             adds to the <tt>debian/substvars</tt> file variable
741             settings like <tt>shlibs:Depends</tt>.  These variable
742             settings must be referenced in dependency fields in the
743             appropriate per-binary-package sections of the source
744             control file.
745           </p>
746
747           <p>       
748             For example, the <prgn>procps</prgn> package generates two
749             kinds of binaries, simple C binaries like <prgn>ps</prgn>
750             which require a predependency and full-screen ncurses
751             binaries like <prgn>top</prgn> which require only a
752             recommendation.  It can say in its <tt>debian/rules</tt>:
753             <example>
754               dpkg-shlibdeps -dPre-Depends ps -dRecommends top
755             </example>
756             and then in its main control file <tt>debian/control</tt>:
757             <example>
758               <var>...</var>
759               Package: procps
760               Pre-Depends: ${shlibs:Pre-Depends}
761               Recommends: ${shlibs:Recommends}
762               <var>...</var>
763             </example>
764           </p>
765
766           <p>       
767             Sources which produce several binary packages with
768             different shared library dependency requirements can use
769             the <tt>-p<var>varnameprefix</var></tt> option to override
770             the default <tt>shlib:</tt> prefix (one invocation of
771             <prgn>dpkg-shlibdeps</prgn> per setting of this option).
772             They can thus produce several sets of dependency
773             variables, each of the form
774             <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
775             which can be referred to in the appropriate parts of the
776             binary package control files.
777           </p>
778         </sect1>
779           
780           
781         <sect1>
782           <heading>
783             <prgn>dpkg-distaddfile</prgn> - adds a file to
784             <tt>debian/files</tt>
785           </heading>
786
787           <p>       
788             Some packages' uploads need to include files other than
789             the source and binary package files.
790           </p>
791
792           <p>       
793             <prgn>dpkg-distaddfile</prgn> adds a file to the
794             <tt>debian/files</tt> file so that it will be included in
795             the <tt>.changes</tt> file when
796             <prgn>dpkg-genchanges</prgn> is run.
797           </p>
798
799           <p>       
800             It is usually invoked from the <prgn>binary</prgn> target of
801             <tt>debian/rules</tt>:
802             <example>
803               dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
804             </example>
805             The <var>filename</var> is relative to the directory where
806             <prgn>dpkg-genchanges</prgn> will expect to find it - this
807             is usually the directory above the top level of the source
808             tree.  The <tt>debian/rules</tt> target should put the
809             file there just before or just after calling
810             <prgn>dpkg-distaddfile</prgn>.
811           </p>
812
813           <p>       
814             The <var>section</var> and <var>priority</var> are passed
815             unchanged into the resulting <tt>.changes</tt> file.  See
816             <ref id="f-classification">.
817           </p>
818         </sect1>
819           
820           
821         <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <tt>.changes</tt> upload
822             control file
823           </heading>
824
825           <p>       
826             This program is usually called by package-independent
827             automatic building scripts such as
828             <prgn>dpkg-buildpackage</prgn>, but it may also be called
829             by hand.
830           </p>
831
832           <p>       
833             It is usually called in the top level of a built source
834             tree, and when invoked with no arguments will print out a
835             straightforward <tt>.changes</tt> file based on the
836             information in the source package's changelog and control
837             file and the binary and source packages which should have
838             been built.
839           </p>
840         </sect1>
841           
842           
843         <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
844             a changelog
845           </heading>
846
847           <p>       
848             This program is used internally by
849             <prgn>dpkg-source</prgn> et al.  It may also occasionally
850             be useful in <tt>debian/rules</tt> and elsewhere.  It
851             parses a changelog, <tt>debian/changelog</tt> by default,
852             and prints a control-file format representation of the
853             information in it to standard output.
854           </p>
855         </sect1>
856       </sect>
857         
858       <sect id="sourcetree"><heading>The Debianised source tree
859         </heading>
860
861         <p>       
862           The source archive scheme described later is intended to
863           allow a Debianised source tree with some associated control
864           information to be reproduced and transported easily.  The
865           Debianised source tree is a version of the original program
866           with certain files added for the benefit of the
867           Debianisation process, and with any other changes required
868           made to the rest of the source code and installation
869           scripts.
870         </p>
871
872         <p>       
873           The extra files created for Debian are in the subdirectory
874           <tt>debian</tt> of the top level of the Debianised source
875           tree.  They are described below.
876         </p>
877           
878         <sect1><heading><tt>debian/rules</tt> - the main building
879         script
880           </heading>
881
882           <p>       
883             This file is an executable makefile, and contains the
884             package-specific recipies for compiling the package and
885             building binary package(s) out of the source.
886           </p>
887
888           <p>       
889             It must start with the line <tt>#!/usr/bin/make -f</tt>,
890             so that it can be invoked by saying its name rather than
891             invoking <prgn>make</prgn> explicitly.
892           </p>
893
894           <p>
895             Since an interactive <tt>debian/rules</tt> script makes it
896             impossible to autocompile that package and also makes it
897             hard for other people to reproduce the same binary
898             package, all <strong>required targets</strong> have to be
899             non-interactive. At a minimul, required targets are the
900             ones called by <prgn>dpkg-buildpackage</prgn>, namely,
901             <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
902             <em>build</em>. It also follows that any target that these
903             targets depend on must also be non-interactive.
904           </p>
905
906           <p>       
907             The targets which are required to be present are:       
908             <taglist>
909               <tag><tt>build</tt></tag>
910               <item>
911                 <p>
912                   This should perform all non-interactive
913                   configuration and compilation of the package.  If a
914                   package has an interactive pre-build configuration
915                   routine, the Debianised source package should be
916                   built after this has taken place, so that it can be
917                   built without rerunning the configuration.
918                 </p>
919
920                 <p>               
921                   For some packages, notably ones where the same
922                   source tree is compiled in different ways to produce
923                   two binary packages, the <prgn>build</prgn> target
924                   does not make much sense.  For these packages it is
925                   good enough to provide two (or more) targets
926                   (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
927                   for each of the ways of building the package, and a
928                   <prgn>build</prgn> target that does nothing.  The
929                   <prgn>binary</prgn> target will have to build the
930                   package in each of the possible ways and make the
931                   binary package out of each.
932                 </p>
933
934                 <p>               
935                   The <prgn>build</prgn> target must not do anything
936                   that might require root privilege.
937                 </p>
938
939                 <p>               
940                   The <prgn>build</prgn> target may need to run
941                   <prgn>clean</prgn> first - see below.
942                 </p>
943
944                 <p>               
945                   When a package has a configuration routine that
946                   takes a long time, or when the makefiles are poorly
947                   designed, or when <prgn>build</prgn> needs to run
948                   <prgn>clean</prgn> first, it is a good idea to
949                   <tt>touch build</tt> when the build process is
950                   complete.  This will ensure that if <tt>debian/rules
951                     build</tt> is run again it will not rebuild the
952                     whole program.
953                 </p>
954               </item>
955                 
956               <tag><tt>binary</tt>, <tt>binary-arch</tt>,
957                 <tt>binary-indep</tt>
958               </tag> 
959               <item>
960                 <p>
961                   The <prgn>binary</prgn> target should be all that is
962                   necessary for the user to build the binary
963                   package. All these targets are required to be
964                   non-interactive.  It is split into two parts:
965                   <prgn>binary-arch</prgn> builds the packages' output
966                   files which are specific to a particular
967                   architecture, and <prgn>binary-indep</prgn> builds
968                   those which are not.
969                 </p>
970
971                 <p>               
972                   <prgn>binary</prgn> should usually be a target with
973                   no commands which simply depends on
974                   <prgn>binary-arch</prgn> and
975                   <prgn>binary-indep</prgn>.
976                 </p>
977
978                 <p>               
979                   Both <prgn>binary-*</prgn> targets should depend on
980                   the <prgn>build</prgn> target, above, so that the
981                   package is built if it has not been already.  It
982                   should then create the relevant binary package(s),
983                   using <prgn>dpkg-gencontrol</prgn> to make their
984                   control files and <prgn>dpkg-deb</prgn> to build
985                   them and place them in the parent of the top level
986                   directory.
987                 </p>
988
989                 <p>               
990                   If one of the <prgn>binary-*</prgn> targets has
991                   nothing to do (this will be always be the case if
992                   the source generates only a single binary package,
993                   whether architecture-dependent or not) it
994                   <em>must</em> still exist, but should always
995                   succeed.
996                 </p>
997
998                 <p>               
999                   <ref id="binarypkg"> describes how to construct
1000                   binary packages.
1001                 </p>
1002
1003                 <p>               
1004                   The <prgn>binary</prgn> targets must be invoked as
1005                   root.
1006                 </p>
1007               </item>
1008                 
1009               <tag><tt>clean</tt></tag>
1010               <item>
1011                 
1012                 <p>
1013                   This should undo any effects that the
1014                   <prgn>build</prgn> and <prgn>binary</prgn> targets
1015                   may have had, except that it should leave alone any
1016                   output files created in the parent directory by a
1017                   run of <prgn>binary</prgn>. This target is required
1018                   to be non-interactive.
1019                 </p>
1020
1021                 <p>               
1022                   If a <prgn>build</prgn> file is touched at the end
1023                   of the <prgn>build</prgn> target, as suggested
1024                   above, it must be removed as the first thing that
1025                   <prgn>clean</prgn> does, so that running
1026                   <prgn>build</prgn> again after an interrupted
1027                   <prgn>clean</prgn> doesn't think that everything is
1028                   already done.
1029                 </p>
1030
1031                 <p>               
1032                   The <prgn>clean</prgn> target must be invoked as
1033                   root if <prgn>binary</prgn> has been invoked since
1034                   the last <prgn>clean</prgn>, or if
1035                   <prgn>build</prgn> has been invoked as root (since
1036                   <prgn>build</prgn> may create directories, for
1037                   example).
1038                 </p>
1039               </item>
1040                 
1041               <tag><tt>get-orig-source</tt> (optional)</tag>
1042               <item>
1043                 
1044                 <p>
1045                   This target fetches the most recent version of the
1046                   original source package from a canonical archive
1047                   site (via FTP or WWW, for example), does any
1048                   necessary rearrangement to turn it into the original
1049                   source tarfile format described below, and leaves it
1050                   in the current directory.
1051                 </p>
1052
1053                 <p>               
1054                   This target may be invoked in any directory, and
1055                   should take care to clean up any temporary files it
1056                   may have left.
1057                 </p>
1058
1059                 <p>               
1060                   This target is optional, but providing it if
1061                   possible is a good idea.
1062                 </p>
1063               </item>
1064             </taglist>
1065               
1066           <p>
1067             The <prgn>build</prgn>, <prgn>binary</prgn> and
1068             <prgn>clean</prgn> targets must be invoked with a current
1069             directory of the package's top-level directory.
1070           </p>
1071             
1072
1073           <p>       
1074             Additional targets may exist in <tt>debian/rules</tt>,
1075             either as published or undocumented interfaces or for the
1076             package's internal use.
1077           </p>
1078         </sect1>
1079           
1080           
1081         <sect1><heading><tt>debian/control</tt>
1082           </heading>
1083
1084           <p>       
1085             This file contains version-independent details about the
1086             source package and about the binary packages it creates.
1087           </p>
1088
1089           <p>       
1090             It is a series of sets of control fields, each
1091             syntactically similar to a binary package control file.
1092             The sets are separated by one or more blank lines.  The
1093             first set is information about the source package in
1094             general; each subsequent set describes one binary package
1095             that the source tree builds.
1096           </p>
1097
1098           <p>       
1099             The syntax and semantics of the fields are described below
1100             in <ref id="controlfields">.
1101           </p>
1102
1103           <p>       
1104             The general (binary-package-independent) fields are:
1105             <list compact="compact">
1106               <item>
1107                 <p><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</p>
1108               </item>
1109               <item>
1110                 <p><qref id="f-Maintainer"><tt>Maintainer</tt></qref></p>
1111               </item>
1112               <item>
1113                 <p>
1114                   <qref id="f-classification"><tt>Section</tt> and
1115                     <tt>Priority</tt></qref> 
1116                   (classification, mandatory)
1117                 </p>
1118               </item>
1119               <item>
1120                 <p>
1121                   <qref id="f-Standards-Version"><tt>Standards-Version</tt></qref>
1122                 </p>
1123               </item> 
1124             </list>
1125
1126           <p>       
1127             The per-binary-package fields are:
1128             <list compact="compact">
1129               <item>
1130                 <p><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</p>
1131               </item>
1132               <item>
1133                 <p>
1134                   <qref id="f-Architecture"><tt>Architecture</tt></qref>
1135                   (mandatory)</p>
1136               </item>
1137               <item>
1138                 <p><qref id="descriptions"><tt>Description</tt></qref></p>
1139               </item>
1140               <item>
1141                 <p>
1142                   <qref id="f-classification"><tt>Section</tt> and
1143                     <tt>Priority</tt></qref> (classification)</p>
1144               </item>
1145               <item>
1146                 <p><qref id="f-Essential"><tt>Essential</tt></qref></p>
1147               </item>
1148               <item>
1149                 <p>
1150                   <qref id="relationships"><tt>Depends</tt> et
1151                   al.</qref> (package interrelationships)
1152                 </p>
1153               </item>
1154             </list>
1155
1156           <p>       
1157             These fields are used by <prgn>dpkg-gencontrol</prgn> to
1158             generate control files for binary packages (see below), by
1159             <prgn>dpkg-genchanges</prgn> to generate the
1160             <tt>.changes</tt> file to accompany the upload, and by
1161             <prgn>dpkg-source</prgn> when it creates the <tt>.dsc</tt>
1162             source control file as part of a source archive.
1163           </p>
1164
1165           <p>       
1166             The fields here may contain variable references - their
1167             values will be substituted by
1168             <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
1169             or <prgn>dpkg-source</prgn> when they generate output
1170             control files.  See <ref id="srcsubstvars"> for details.
1171           </p>
1172
1173           <p> <sect2><heading>User-defined fields
1174             </heading>
1175
1176             <p>       
1177               Additional user-defined fields may be added to the
1178               source package control file.  Such fields will be
1179               ignored, and not copied to (for example) binary or
1180               source package control files or upload control files.
1181             </p>
1182
1183             <p>       
1184               If you wish to add additional unsupported fields to
1185               these output files you should use the mechanism
1186               described here.
1187             </p>
1188
1189             <p>       
1190               Fields in the main source control information file with
1191               names starting <tt>X</tt>, followed by one or more of
1192               the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
1193               be copied to the output files.  Only the part of the
1194               field name after the hyphen will be used in the output
1195               file.  Where the letter <tt>B</tt> is used the field
1196               will appear in binary package control files, where the
1197               letter <tt>S</tt> is used in source package control
1198               files and where <tt>C</tt> is used in upload control
1199               (<tt>.changes</tt>) files.
1200             </p>
1201
1202             <p>       
1203               For example, if the main source information control file
1204               contains the field
1205               <example>
1206                 XBS-Comment: I stand between the candle and the star.
1207               </example>
1208               then the binary and source package control files will contain the
1209               field
1210               <example>
1211                 Comment: I stand between the candle and the star.
1212               </example>
1213             </p>
1214           </sect2>
1215         
1216         </sect1>
1217
1218         <sect1 id="dpkgchangelog"><heading><tt>debian/changelog</tt>
1219           </heading>
1220
1221           <p>       
1222             This file records the changes to the Debian-specific parts of the
1223             package
1224             <footnote>
1225               <p>
1226                 Though there is nothing stopping an author who is also
1227                 the Debian maintainer from using it for all their
1228                 changes, it will have to be renamed if the Debian and
1229                 upstream maintainers become different
1230                 people.
1231               </p>
1232             </footnote>.
1233           </p>
1234
1235           <p>       
1236             It has a special format which allows the package building
1237             tools to discover which version of the package is being
1238             built and find out other release-specific information.
1239           </p>
1240
1241           <p>
1242             That format is a series of entries like this:       
1243             <example>
1244               <var>package</var> (<var>version</var>) <var>distribution(s)</var>;
1245               urgency=<var>urgency</var>
1246               
1247               * <var>change details</var>
1248               <var>more change details</var>
1249               * <var>even more change details</var>
1250               
1251               -- <var>maintainer name and email address</var>  <var>date</var>
1252             </example>
1253           </p>
1254
1255           <p>       
1256             <var>package</var> and <var>version</var> are the source
1257             package name and version number.
1258           </p> 
1259
1260           <p>       
1261             <var>distribution(s)</var> lists the distributions where
1262             this version should be installed when it is uploaded - it
1263             is copied to the <tt>Distribution</tt> field in the
1264             <tt>.changes</tt> file.  See <ref id="f-Distribution">.
1265           </p>
1266
1267           <p>       
1268             <var>urgency</var> is the value for the <tt>Urgency</tt>
1269             field in the <tt>.changes</tt> file for the upload.  See
1270             <ref id="f-Urgency">.  It is not possible to specify an
1271             urgency containing commas; commas are used to separate
1272             <tt><var>keyword</var>=<var>value</var></tt> settings in
1273             the <prgn>dpkg</prgn> changelog format (though there is
1274             currently only one useful <var>keyword</var>,
1275             <tt>urgency</tt>).
1276           </p>
1277
1278           <p>       
1279             The change details may in fact be any series of lines
1280             starting with at least two spaces, but conventionally each
1281             change starts with an asterisk and a separating space and
1282             continuation lines are indented so as to bring them in
1283             line with the start of the text above.  Blank lines may be
1284             used here to separate groups of changes, if desired.
1285           </p>
1286
1287           <p>       
1288             The maintainer name and email address should <em>not</em>
1289             necessarily be those of the usual package maintainer.
1290             They should be the details of the person doing
1291             <em>this</em> version.  The information here will be
1292             copied to the <tt>.changes</tt> file, and then later used
1293             to send an acknowledgement when the upload has been
1294             installed.
1295           </p>
1296
1297           <p>       
1298             The <var>date</var> should be in RFC822 format
1299             <footnote>
1300               <p>
1301                 This is generated by the <prgn>822-date</prgn>
1302                 program.
1303               </p>
1304             </footnote>; it should include the timezone specified
1305             numerically, with the timezone name or abbreviation
1306             optionally present as a comment.
1307           </p>
1308
1309           <p>       
1310             The first `title' line with the package name should start
1311             at the left hand margin; the `trailer' line with the
1312             maintainer and date details should be preceded by exactly
1313             one space.  The maintainer details and the date must be
1314             separated by exactly two spaces.
1315           </p>
1316
1317           <p>       
1318             An Emacs mode for editing this format is available: it is
1319             called <tt>debian-changelog-mode</tt>.  You can have this
1320             mode selected automatically when you edit a Debian
1321             changelog by adding a local variables clause to the end of
1322             the changelog.
1323           </p>
1324             
1325           <sect2><heading>Defining alternative changelog formats
1326             </heading>
1327
1328             <p>       
1329               It is possible to use a different format to the standard
1330               one, by providing a parser for the format you wish to
1331               use.
1332             </p>
1333
1334             <p>       
1335               In order to have <tt>dpkg-parsechangelog</tt> run your
1336               parser, you must include a line within the last 40 lines
1337               of your file matching the Perl regular expression:
1338               <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
1339               parentheses should be the name of the format.  For
1340               example, you might say:
1341               <example>
1342                 @@@ changelog-format: joebloggs @@@
1343               </example>
1344               Changelog format names are non-empty strings of alphanumerics.
1345             </p>
1346
1347             <p>       
1348               If such a line exists then <tt>dpkg-parsechangelog</tt>
1349               will look for the parser as
1350               <tt>/usr/lib/dpkg/parsechangelog/<var>format-name</var></tt>
1351               or
1352               <tt>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></tt>;
1353               it is an error for it not to find it, or for it not to
1354               be an executable program.  The default changelog format
1355               is <tt>dpkg</tt>, and a parser for it is provided with
1356               the <tt>dpkg</tt> package.
1357             </p>
1358
1359             <p>       
1360               The parser will be invoked with the changelog open on
1361               standard input at the start of the file.  It should read
1362               the file (it may seek if it wishes) to determine the
1363               information required and return the parsed information
1364               to standard output in the form of a series of control
1365               fields in the standard format.  By default it should
1366               return information about only the most recent version in
1367               the changelog; it should accept a
1368               <tt>-v<var>version</var></tt> option to return changes
1369               information from all versions present <em>strictly
1370               after</em> <var>version</var>, and it should then be an
1371               error for <var>version</var> not to be present in the
1372               changelog.
1373             </p>
1374
1375             <p>       
1376               The fields are:
1377               <list compact="compact">
1378                 <item>
1379                   <p><qref id="f-Source"><tt>Source</tt></qref></p>
1380                 </item>
1381                 <item>
1382                   <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
1383                 </item>
1384                 <item>
1385                   <p>
1386                     <qref id="f-Distribution"><tt>Distribution</tt></qref>
1387                     (mandatory)
1388                   </p> 
1389                 </item>
1390                 <item>
1391                   <p><qref id="f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
1392                 </item>
1393                 <item>
1394                   <p>
1395                     <qref id="f-Maintainer"><tt>Maintainer</tt></qref>
1396                     (mandatory)
1397                   </p>
1398                 </item>
1399                 <item>
1400                   <p><qref id="f-Date"><tt>Date</tt></qref></p>
1401                 </item>
1402                 <item>
1403                   <p>
1404                     <qref id="f-Changes"><tt>Changes</tt></qref>
1405                     (mandatory)
1406                   </p>
1407                 </item>
1408               </list>
1409
1410             <p>       
1411               If several versions are being returned (due to the use
1412               of <tt>-v</tt>), the urgency value should be of the
1413               highest urgency code listed at the start of any of the
1414               versions requested followed by the concatenated
1415               (space-separated) comments from all the versions
1416               requested; the maintainer, version, distribution and
1417               date should always be from the most recent version.
1418             </p>
1419
1420             <p>       
1421               For the format of the <tt>Changes</tt> field see <ref
1422               id="f-Changes">.
1423             </p>
1424
1425             <p>       
1426               If the changelog format which is being parsed always or
1427               almost always leaves a blank line between individual
1428               change notes these blank lines should be stripped out,
1429               so as to make the resulting output compact.
1430             </p>
1431
1432             <p>       
1433               If the changelog format does not contain date or package
1434               name information this information should be omitted from
1435               the output.  The parser should not attempt to synthesise
1436               it or find it from other sources.
1437             </p>
1438
1439             <p>       
1440               If the changelog does not have the expected format the
1441               parser should exit with a nonzero exit status, rather
1442               than trying to muddle through and possibly generating
1443               incorrect output.
1444             </p>
1445
1446             <p>       
1447               A changelog parser may not interact with the user at
1448               all.</p></sect2>
1449         </sect1>
1450           
1451         <sect1 id="srcsubstvars"><heading><tt>debian/substvars</tt>
1452         and variable substitutions
1453           </heading>
1454
1455           <p>       
1456             When <prgn>dpkg-gencontrol</prgn>,
1457             <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
1458             generate control files they do variable substitutions on
1459             their output just before writing it.  Variable
1460             substitutions have the form
1461             <tt>${<var>variable-name</var>}</tt>.  The optional file
1462             <tt>debian/substvars</tt> contains variable substitutions
1463             to be used; variables can also be set directly from
1464             <tt>debian/rules</tt> using the <tt>-V</tt> option to the
1465             source packaging commands, and certain predefined
1466             variables are available.
1467           </p>
1468
1469           <p>       
1470             The is usually generated and modified dynamically by
1471             <tt>debian/rules</tt> targets; in this case it must be
1472             removed by the <prgn>clean</prgn> target.
1473           </p>
1474
1475           <p>
1476             See <manref name="dpkg-source" section="1"> for full
1477             details about source variable substitutions, including the
1478             format of <tt>debian/substvars</tt>.</p>
1479         </sect1>
1480           
1481         <sect1><heading><tt>debian/files</tt>
1482           </heading>
1483
1484           <p>       
1485             This file is not a permanent part of the source tree; it
1486             is used while building packages to record which files are
1487             being generated.  <prgn>dpkg-genchanges</prgn> uses it
1488             when it generates a <tt>.changes</tt> file.
1489           </p>
1490
1491           <p>       
1492             It should not exist in a shipped source package, and so it
1493             (and any backup files or temporary files such as
1494             <tt>files.new</tt>
1495               <footnote>
1496                 <p>
1497                   <tt>files.new</tt> is used as a temporary file by
1498                   <prgn>dpkg-gencontrol</prgn> and
1499                   <prgn>dpkg-distaddfile</prgn> - they write a new
1500                   version of <tt>files</tt> here before renaming it,
1501                   to avoid leaving a corrupted copy if an error
1502                   occurs
1503                 </p>
1504               </footnote>) should be removed by the
1505               <prgn>clean</prgn> target.  It may also be wise to
1506               ensure a fresh start by emptying or removing it at the
1507               start of the <prgn>binary</prgn> target.
1508           </p>
1509
1510           <p>       
1511             <prgn>dpkg-gencontrol</prgn> adds an entry to this file
1512             for the <tt>.deb</tt> file that will be created by
1513             <prgn>dpkg-deb</prgn> from the control file that it
1514             generates, so for most packages all that needs to be done
1515             with this file is to delete it in <prgn>clean</prgn>.
1516           </p>
1517
1518           <p>       
1519             If a package upload includes files besides the source
1520             package and any binary packages whose control files were
1521             made with <prgn>dpkg-gencontrol</prgn> then they should be
1522             placed in the parent of the package's top-level directory
1523             and <prgn>dpkg-distaddfile</prgn> should be called to add
1524             the file to the list in <tt>debian/files</tt>.</p>
1525         </sect1>
1526           
1527         <sect1><heading><tt>debian/tmp</tt>
1528           </heading>
1529
1530           <p>       
1531             This is the canonical temporary location for the
1532             construction of binary packages by the <prgn>binary</prgn>
1533             target.  The directory <tt>tmp</tt> serves as the root of
1534             the filesystem tree as it is being constructed (for
1535             example, by using the package's upstream makefiles install
1536             targets and redirecting the output there), and it also
1537             contains the <tt>DEBIAN</tt> subdirectory.  See <ref
1538             id="bincreating">.
1539           </p>
1540
1541           <p>       
1542             If several binary packages are generated from the same
1543             source tree it is usual to use several
1544             <tt>debian/tmp<var>something</var></tt> directories, for
1545             example <tt>tmp-a</tt> or <tt>tmp-doc</tt>.
1546           </p>
1547
1548           <p>       
1549             Whatever <tt>tmp</tt> directories are created and used by
1550             <prgn>binary</prgn> must of course be removed by the
1551             <prgn>clean</prgn> target.</p></sect1>
1552       </sect>
1553         
1554         
1555       <sect id="sourcearchives"><heading>Source packages as archives
1556         </heading>
1557
1558         <p>       
1559           As it exists on the FTP site, a Debian source package
1560           consists of three related files.  You must have the right
1561           versions of all three to be able to use them.
1562         </p>
1563
1564         <p>       
1565           <taglist>
1566             <tag>Debian source control file - <tt>.dsc</tt></tag>
1567             <item>
1568               
1569               <p>
1570                 This file contains a series of fields, identified and
1571                 separated just like the fields in the control file of
1572                 a binary package.  The fields are listed below; their
1573                 syntax is described above, in <ref id="controlfields">.
1574                 <list compact="compact">
1575                   <item>
1576                     <p><qref id="f-Source"><tt>Source</tt></qref></p>
1577                   </item>
1578                   <item>
1579                     <p><qref id="versions"><tt>Version</tt></qref></p>
1580                   </item>
1581                   <item>
1582                     <p><qref id="f-Maintainer"><tt>Maintainer</tt></qref></p>
1583                   </item>
1584                   <item>
1585                     <p><qref id="f-Binary"><tt>Binary</tt></qref></p>
1586                   </item>
1587                   <item>
1588                     <p><qref id="f-Architecture"><tt>Architecture</tt></qref></p>
1589                   </item>
1590                   <item>
1591                     <p>
1592                       <qref id="f-Standards-Version"><tt>Standards-Version</tt></qref></p>
1593                   </item>
1594                   <item>
1595                     <p><qref id="f-Files"><tt>Files</tt></qref></p>
1596                   </item>
1597                 </list>
1598
1599               <p>               
1600                 The source package control file is generated by
1601                 <prgn>dpkg-source</prgn> when it builds the source
1602                 archive, from other files in the source package,
1603                 described above.  When unpacking it is checked against
1604                 the files and directories in the other parts of the
1605                 source package, as described below.</p>
1606             </item>
1607               
1608             <tag>
1609               Original source archive -
1610               <tt>
1611                 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
1612               </tt>
1613             </tag> 
1614
1615             <item>
1616               
1617               <p>
1618                 This is a compressed (with <tt>gzip -9</tt>)
1619                 <prgn>tar</prgn> file containing the source code from
1620                 the upstream authors of the program.  The tarfile
1621                 unpacks into a directory
1622                 <tt><var>package</var>-<var>upstream-version</var>.orig</tt>,
1623                 and does not contain files anywhere other than in
1624                 there or in its subdirectories.</p>
1625             </item>
1626               
1627             <tag>
1628               Debianisation diff -
1629               <tt>
1630                 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
1631               </tt>
1632             </tag> 
1633             <item>
1634               
1635               <p>
1636                 This is a unified context diff (<tt>diff -u</tt>)
1637                 giving the changes which are required to turn the
1638                 original source into the Debian source.  These changes
1639                 may only include editing and creating plain files.
1640                 The permissions of files, the targets of symbolic
1641                 links and the characteristics of special files or
1642                 pipes may not be changed and no files may be removed
1643                 or renamed.
1644               </p>
1645
1646               <p>               
1647                 All the directories in the diff must exist, except the
1648                 <tt>debian</tt> subdirectory of the top of the source
1649                 tree, which will be created by
1650                 <prgn>dpkg-source</prgn> if necessary when unpacking.
1651               </p>
1652
1653               <p>               
1654                 The <prgn>dpkg-source</prgn> program will
1655                 automatically make the <tt>debian/rules</tt> file
1656                 executable (see below).</p></item>
1657           </taglist>
1658             
1659
1660         <p>       
1661           If there is no original source code - for example, if the
1662           package is specially prepared for Debian or the Debian
1663           maintainer is the same as the upstream maintainer - the
1664           format is slightly different: then there is no diff, and the
1665           tarfile is named
1666           <tt><var>package</var>_<var>version</var>.tar.gz</tt> and
1667           contains a directory
1668           <tt><var>package</var>-<var>version</var></tt>.
1669         </p>
1670       </sect>
1671         
1672       <sect><heading>Unpacking a Debian source package without
1673       <prgn>dpkg-source</prgn>
1674         </heading>
1675
1676         <p>       
1677           <tt>dpkg-source -x</tt> is the recommended way to unpack a
1678           Debian source package.  However, if it is not available it
1679           is possible to unpack a Debian source archive as follows:
1680         <enumlist compact="compact">
1681           <item> 
1682             <p>
1683               Untar the tarfile, which will create a <tt>.orig</tt>
1684               directory.</p>
1685           </item>
1686           <item>
1687             <p>Rename the <tt>.orig</tt> directory to
1688               <tt><var>package</var>-<var>version</var></tt>.</p>
1689           </item>
1690             <item>
1691             <p>
1692               Create the subdirectory <tt>debian</tt> at the top of
1693               the source tree.</p>
1694           </item>
1695           <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
1696           </item>
1697           <item><p>Untar the tarfile again if you want a copy of the original
1698               source code alongside the Debianised version.</p>
1699           </item>
1700         </enumlist>
1701         
1702         <p>       
1703           It is not possible to generate a valid Debian source archive
1704           without using <prgn>dpkg-source</prgn>.  In particular,
1705           attempting to use <prgn>diff</prgn> directly to generate the
1706           <tt>.diff.gz</tt> file will not work.
1707         </p>
1708           
1709         <sect1><heading>Restrictions on objects in source packages
1710           </heading>
1711
1712           <p>       
1713             The source package may not contain any hard links
1714             <footnote>
1715               <p>
1716                 This is not currently detected when building source
1717                 packages, but only when extracting
1718                 them.
1719               </p>
1720             </footnote>
1721             <footnote>
1722               <p>
1723                 Hard links may be permitted at some point in the
1724                 future, but would require a fair amount of
1725                 work.
1726               </p>
1727             </footnote>, device special files, sockets or setuid or
1728             setgid files.
1729             <footnote>
1730               <p>
1731                 Setgid directories are allowed.
1732               </p>
1733             </footnote>
1734           </p>
1735
1736           <p>       
1737             The source packaging tools manage the changes between the
1738             original and Debianised source using <prgn>diff</prgn> and
1739             <prgn>patch</prgn>.  Turning the original source tree as
1740             included in the <tt>.orig.tar.gz</tt> into the debianised
1741             source must not involve any changes which cannot be
1742             handled by these tools.  Problematic changes which cause
1743             <prgn>dpkg-source</prgn> to halt with an error when
1744             building the source package are:
1745             <list compact="compact">
1746               <item><p>Adding or removing symbolic links, sockets or pipes.</p>
1747               </item>
1748               <item><p>Changing the targets of symbolic links.</p>
1749               </item>
1750               <item><p>Creating directories, other than <tt>debian</tt>.</p>
1751               </item>
1752               <item><p>Changes to the contents of binary files.</p></item>
1753             </list> Changes which cause <prgn>dpkg-source</prgn> to
1754             print a warning but continue anyway are:
1755             <list compact="compact">
1756               <item>
1757                 <p>
1758                   Removing files, directories or symlinks.
1759                   <footnote>
1760                     <p>
1761                       Renaming a file is not treated specially - it is
1762                       seen as the removal of the old file (which
1763                       generates a warning, but is otherwise ignored),
1764                       and the creation of the new
1765                       one.</p>
1766                   </footnote>
1767                 </p>
1768               </item>
1769               <item>
1770                 <p>
1771                   Changed text files which are missing the usual final
1772                   newline (either in the original or the modified
1773                   source tree).
1774                 </p>
1775               </item>
1776             </list>
1777             Changes which are not represented, but which are not detected by
1778             <prgn>dpkg-source</prgn>, are:
1779             <list compact="compact">
1780               <item><p>Changing the permissions of files (other than
1781                   <tt>debian/rules</tt>) and directories.</p></item>
1782             </list>
1783           </p>
1784
1785           <p>       
1786             The <tt>debian</tt> directory and <tt>debian/rules</tt>
1787             are handled specially by <prgn>dpkg-source</prgn> - before
1788             applying the changes it will create the <tt>debian</tt>
1789             directory, and afterwards it will make
1790             <tt>debian/rules</tt> world-exectuable.
1791           </p>
1792         </sect1>
1793       </sect>
1794     </chapt>
1795       
1796     <chapt id="controlfields"><heading>Control files and their fields
1797       </heading>
1798
1799       <p>       
1800         Many of the tools in the <prgn>dpkg</prgn> suite manipulate
1801         data in a common format, known as control files.  Binary and
1802         source packages have control data as do the <tt>.changes</tt>
1803         files which control the installation of uploaded files, and
1804         <prgn>dpkg</prgn>'s internal databases are in a similar
1805         format.
1806       </p>
1807         
1808       <sect><heading>Syntax of control files
1809         </heading>
1810
1811         <p>       
1812           A file consists of one or more paragraphs of fields.  The
1813           paragraphs are separated by blank lines.  Some control files
1814           only allow one paragraph; others allow several, in which
1815           case each paragraph often refers to a different package.
1816         </p>
1817
1818         <p>       
1819           Each paragraph is a series of fields and values; each field
1820           consists of a name, followed by a colon and the value.  It
1821           ends at the end of the line.  Horizontal whitespace (spaces
1822           and tabs) may occur before or after the value and is ignored
1823           there; it is conventional to put a single space after the
1824           colon.
1825         </p>
1826
1827         <p>       
1828           Some fields' values may span several lines; in this case
1829           each continuation line <em>must</em> start with a space or
1830           tab.  Any trailing spaces or tabs at the end of individual
1831           lines of a field value are ignored.
1832         </p>
1833
1834         <p>       
1835           Except where otherwise stated only a single line of data is
1836           allowed and whitespace is not significant in a field body.
1837           Whitespace may never appear inside names (of packages,
1838           architectures, files or anything else), version numbers or
1839           in between the characters of multi-character version
1840           relationships.
1841         </p>
1842
1843         <p>       
1844           Field names are not case-sensitive, but it is usual to
1845           capitalise the fields using mixed case as shown below.
1846         </p>
1847
1848         <p>       
1849           Blank lines, or lines consisting only of spaces and tabs,
1850           are not allowed within field values or between fields - that
1851           would mean a new paragraph.
1852         </p>
1853
1854         <p>       
1855           It is important to note that there are several fields which
1856           are optional as far as <prgn>dpkg</prgn> and the related
1857           tools are concerned, but which must appear in every Debian
1858           package, or whose omission may cause problems.  When writing
1859           the control files for Debian packages you <em>must</em> read
1860           the Debian policy manual in conjuction with the details
1861           below and the list of fields for the particular file.</p>
1862       </sect>
1863         
1864       <sect><heading>List of fields
1865         </heading>
1866           
1867         <sect1 id="f-Package"><heading><tt>Package</tt>
1868           </heading>
1869
1870           <p>       
1871             The name of the binary package.  Package names consist of
1872             the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
1873             (plus, minus and full stop).
1874             <footnote>
1875               <p>
1876                 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
1877                 <tt>t</tt>t> <tt>_</tt> (at, colon, equals, percent
1878                 and underscore) used to be legal and are still
1879                 accepted when found in a package file, but may not be
1880                 used in new packages
1881               </p>
1882             </footnote>
1883           </p>
1884
1885           <p>       
1886             They must be at least two characters and must start with
1887             an alphanumeric.  In current versions of dpkg they are
1888             sort of case-sensitive<footnote><p>This is a
1889             bug.</p></footnote>; use lowercase package names unless
1890             the package you're building (or referring to, in other
1891             fields) is already using uppercase.</p>
1892         </sect1>
1893           
1894         <sect1 id="f-Version"><heading><tt>Version</tt>
1895           </heading>
1896
1897           <p>       
1898             This lists the source or binary package's version number -
1899             see <ref id="versions">.
1900           </p>
1901
1902         </sect1>
1903           
1904         <sect1 id="f-Architecture"><heading><tt>Architecture</tt>
1905           </heading>
1906
1907           <p>       
1908             This is the architecture string; it is a single word for
1909             the CPU architecture.
1910           </p>
1911
1912           <p>       
1913             <prgn>dpkg</prgn> will check the declared architecture of
1914             a binary package against its own compiled-in value before
1915             it installs it.
1916           </p>
1917
1918           <p>       
1919             The special value <tt>all</tt> indicates that the package
1920             is architecture-independent.
1921           </p>
1922
1923           <p>       
1924             In the main <tt>debian/control</tt> file in the source
1925             package, or in the source package control file
1926             <tt>.dsc</tt>, a list of architectures (separated by
1927             spaces) is also allowed, as is the special value
1928             <tt>any</tt>.  A list indicates that the source will build
1929             an architecture-dependent package, and will only work
1930             correctly on the listed architectures.  <tt>any</tt>
1931             indicates that though the source package isn't dependent
1932             on any particular architecture and should compile fine on
1933             any one, the binary package(s) produced are not
1934             architecture-independent but will instead be specific to
1935             whatever the current build architecture is.
1936           </p>
1937
1938           <p>       
1939             In a <tt>.changes</tt> file the <tt>Architecture</tt>
1940             field lists the architecture(s) of the package(s)
1941             currently being uploaded.  This will be a list; if the
1942             source for the package is being uploaded too the special
1943             entry <tt>source</tt> is also present.
1944           </p>
1945
1946           <p>       
1947             The current build architecture can be determined using <tt>dpkg
1948               --print-architecture</tt>.
1949             <footnote>
1950               <p>
1951                 This actually invokes
1952                 <example>
1953                   gcc --print-libgcc-file-name
1954                 </example> and parses and decomposes the output and
1955                 looks the CPU type from the GCC configuration in a
1956                 table in <prgn>dpkg</prgn>.  This is so that it will
1957                 work if you're cross-compiling.
1958               </p>
1959             </footnote> This value is automatically used by
1960             <prgn>dpkg-gencontrol</prgn> when building the control
1961             file for a binary package for which the source control
1962             information doesn't specify architecture <tt>all</tt>.
1963           </p>
1964
1965           <p>       
1966             There is a separate option,
1967             <tt>--print-installation-architecture</tt>, for finding
1968             out what architecture <prgn>dpkg</prgn> is willing to
1969             install.  This information is also in the output of
1970             <tt>dpkg --version</tt>.</p>
1971         </sect1>
1972           
1973         <sect1 id="f-Maintainer"><heading><tt>Maintainer</tt>
1974           </heading>
1975
1976           <p>       
1977             The package maintainer's name and email address.  The name
1978             should come first, then the email address inside angle
1979             brackets <tt>&lt;&gt</tt> (in RFC822 format).
1980           </p>
1981
1982           <p>       
1983             If the maintainer's name contains a full stop then the
1984             whole field will not work directly as an email address due
1985             to a misfeature in the syntax specified in RFC822; a
1986             program using this field as an address must check for this
1987             and correct the problem if necessary (for example by
1988             putting the name in round brackets and moving it to the
1989             end, and bringing the email address forward).
1990           </p>
1991
1992           <p>       
1993             In a <tt>.changes</tt> file or parsed changelog data this
1994             contains the name and email address of the person
1995             responsible for the particular version in question - this
1996             may not be the package's usual maintainer.
1997           </p>
1998
1999           <p>       
2000             This field is usually optional in as far as the
2001             <prgn>dpkg</prgn> are concerned, but its absence when
2002             building packages usually generates a warning.</p>
2003         </sect1>
2004           
2005         <sect1 id="f-Source"><heading><tt>Source</tt>
2006           </heading>
2007
2008           <p>       
2009             This field identifies the source package name.
2010           </p>
2011
2012           <p>       
2013             In a main source control information or a
2014             <tt>.changes</tt> or <tt>.dsc</tt> file or parsed
2015             changelog data this may contain only the name of the
2016             source package.
2017           </p>
2018
2019           <p>       
2020             In the control file of a binary package (or in a
2021             <tt>Packages</tt> file) it may be followed by a version
2022             number in parentheses.
2023             <footnote>
2024               <p>
2025                 It is usual to leave a space after the package name if
2026                 a version number is specified.
2027               </p>
2028             </footnote> This version number may be omitted (and is, by
2029             <prgn>dpkg-gencontrol</prgn>) if it has the same value as
2030             the <tt>Version</tt> field of the binary package in
2031             question.  The field itself may be omitted from a binary
2032             package control file when the source package has the same
2033             name and version as the binary package.
2034           </p>
2035         </sect1>
2036           
2037         <sect1><heading>Package interrelationship fields:
2038             <tt>Depends</tt>, <tt>Pre-Depends</tt>,
2039             <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
2040             <tt>Provides</tt>, <tt>Replaces</tt>
2041           </heading>
2042
2043           <p>       
2044             These fields describe the package's relationships with
2045             other packages.  Their syntax and semantics are described
2046             in <ref id="relationships">.</p>
2047         </sect1>
2048           
2049         <sect1 id="f-Description"><heading><tt>Description</tt>
2050           </heading>
2051
2052           <p>       
2053             In a binary package <tt>Packages</tt> file or main source
2054             control file this field contains a description of the
2055             binary package, in a special format.  See <ref
2056             id="descriptions"> for details.
2057           </p>
2058
2059           <p>       
2060             In a <tt>.changes</tt> file it contains a summary of the
2061             descriptions for the packages being uploaded.  The part of
2062             the field before the first newline is empty; thereafter
2063             each line has the name of a binary package and the summary
2064             description line from that binary package.  Each line is
2065             indented by one space.</p>
2066         </sect1>
2067           
2068         <sect1 id="f-Essential"><heading><tt>Essential</tt>
2069           </heading>
2070
2071           <p>       
2072             This is a boolean field which may occur only in the
2073             control file of a binary package (or in the
2074             <tt>Packages</tt> file) or in a per-package fields
2075             paragraph of a main source control data file.
2076           </p>
2077
2078           <p>       
2079             If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
2080             <prgn>dselect</prgn> will refuse to remove the package
2081             (though it can be upgraded and/or replaced).  The other
2082             possible value is <tt>no</tt>, which is the same as not
2083             having the field at all.</p>
2084         </sect1>
2085           
2086         <sect1 id="f-classification"><heading><tt>Section</tt> and
2087         <tt>Priority</tt>
2088           </heading>
2089
2090           <p>       
2091             These two fields classify the package.  The
2092             <tt>Priority</tt> represents how important that it is that
2093             the user have it installed; the <tt>Section</tt>
2094             represents an application area into which the package has
2095             been classified.
2096           </p>
2097
2098           <p>       
2099             When they appear in the <tt>debian/control</tt> file these
2100             fields give values for the section and priority subfields
2101             of the <tt>Files</tt> field of the <tt>.changes</tt> file,
2102             and give defaults for the section and priority of the
2103             binary packages.
2104           </p>
2105
2106           <p>       
2107             The section and priority are represented, though not as
2108             separate fields, in the information for each file in the
2109             <qref id="f-Files"><tt>-File</tt></qref>field of a
2110             <tt>.changes</tt> file.  The section value in a
2111             <tt>.changes</tt> file is used to decide where to install
2112             a package in the FTP archive.
2113           </p>
2114
2115           <p>       
2116             These fields are not used by by <prgn>dpkg</prgn> proper,
2117             but by <prgn>dselect</prgn> when it sorts packages and
2118             selects defaults.  See the Debian policy manual for the
2119             priorities in use and the criteria for selecting the
2120             priority for a Debian package, and look at the Debian FTP
2121             archive for a list of currently in-use priorities.
2122           </p>
2123
2124           <p>       
2125             These fields may appear in binary package control files,
2126             in which case they provide a default value in case the
2127             <tt>Packages</tt> files are missing the information.
2128             <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
2129             the value from a <tt>.deb</tt> file if they have no other
2130             information; a value listed in a <tt>Packages</tt> file
2131             will always take precedence.  By default
2132             <prgn>dpkg-genchanges</prgn> does not include the section
2133             and priority in the control file of a binary package - use
2134             the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
2135             achieve this effect.</p>
2136         </sect1>
2137           
2138         <sect1 id="f-Binary"><heading><tt>Binary</tt>
2139           </heading>
2140
2141           <p>       
2142             This field is a list of binary packages.
2143           </p>
2144
2145           <p>       
2146             When it appears in the <tt>.dsc</tt> file it is the list
2147             of binary packages which a source package can produce.  It
2148             does not necessarily produce all of these binary packages
2149             for every architecture.  The source control file doesn't
2150             contain details of which architectures are appropriate for
2151             which of the binary packages.
2152           </p>
2153
2154           <p>       
2155             When it appears in a <tt>.changes</tt> file it lists the
2156             names of the binary packages actually being uploaded.
2157           </p>
2158
2159           <p>       
2160             The syntax is a list of binary packages separated by
2161             commas.
2162             <footnote>
2163               <p>
2164                 A space after each comma is conventional.
2165               </p>
2166             </footnote> Currently the packages must be separated using
2167             only spaces in the <tt>.changes</tt> file.</p>
2168         </sect1>
2169           
2170         <sect1 id="f-Installed-Size"><heading><tt>Installed-Size</tt>
2171           </heading>
2172
2173           <p>       
2174             This field appears in the control files of binary
2175             packages, and in the <tt>Packages</tt> files.  It gives
2176             the total amount of disk space required to install the
2177             named package.
2178           </p>
2179
2180           <p>       
2181             The disk space is represented in kilobytes as a simple
2182             decimal number.</p>
2183         </sect1>
2184           
2185         <sect1 id="f-Files"><heading><tt>Files</tt>
2186           </heading>
2187
2188           <p>       
2189             This field contains a list of files with information about
2190             each one.  The exact information and syntax varies with
2191             the context.  In all cases the the part of the field
2192             contents on the same line as the field name is empty.  The
2193             remainder of the field is one line per file, each line
2194             being indented by one space and containing a number of
2195             sub-fields separated by spaces.
2196           </p>
2197
2198           <p>       
2199             In the <tt>.dsc</tt> (Debian source control) file each
2200             line contains the MD5 checksum, size and filename of the
2201             tarfile and (if applicable) diff file which make up the
2202             remainder of the source package.
2203             <footnote>
2204               <p>
2205                 That is, the parts which are not the
2206                 <tt>.dsc</tt>.
2207               </p>
2208             </footnote> The exact forms of the filenames are described
2209             in <ref id="sourcearchives">.
2210           </p>
2211
2212           <p>       
2213             In the <tt>.changes</tt> file this contains one line per
2214             file being uploaded.  Each line contains the MD5 checksum,
2215             size, section and priority and the filename.  The section
2216             and priority are the values of the corresponding fields in
2217             the main source control file - see <ref
2218             id="f-classification">.  If no section or priority is
2219             specified then <tt>-</tt> should be used, though section
2220             and priority values must be specified for new packages to
2221             be installed properly.
2222           </p>
2223
2224           <p>       
2225             The special value <tt>byhand</tt> for the section in a
2226             <tt>.changes</tt> file indicates that the file in question
2227             is not an ordinary package file and must by installed by
2228             hand by the distribution maintainers.  If the section is
2229             <tt>byhand</tt> the priority should be <tt>-</tt>.
2230           </p>
2231
2232           <p>       
2233             If a new Debian revision of a package is being shipped and
2234             no new original source archive is being distributed the
2235             <tt>.dsc</tt> must still contain the <tt>Files</tt> field
2236             entry for the original source archive
2237             <tt><var>package</var>-<var>upstream-version</var>.orig.tar.gz</tt>,
2238             but the <tt>.changes</tt> file should leave it out.  In
2239             this case the original source archive on the distribution
2240             site must match exactly, byte-for-byte, the original
2241             source archive which was used to generate the
2242             <tt>.dsc</tt> file and diff which are being uploaded.</p>
2243         </sect1>
2244           
2245           
2246         <sect1
2247         id="f-Standards-Version"><heading><tt>Standards-Version</tt>
2248           </heading>
2249
2250           <p>       
2251             The most recent version of the standards (the
2252             <prgn>dpkg</prgn> programmers' and policy manuals and
2253             associated texts) with which the package complies.  This
2254             is updated manually when editing the source package to
2255             conform to newer standards; it can sometimes be used to
2256             tell when a package needs attention.
2257           </p>
2258
2259           <p>       
2260             Its format is the same as that of a version number except
2261             that no epoch or Debian revision is allowed - see <ref
2262             id="versions">.</p>
2263         </sect1>
2264           
2265           
2266         <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
2267           </heading>
2268
2269           <p>       
2270             In a <tt>.changes</tt> file or parsed changelog output
2271             this contains the (space-separated) name(s) of the
2272             distribution(s) where this version of the package should
2273             be or was installed.  Distribution names follow the rules
2274             for package names.  (See <ref id="f-Package">).
2275           </p>
2276
2277           <p>       
2278             Current distribution values are:
2279           <taglist>
2280             <tag><em>stable</em></tag>
2281             <item>
2282               <p> 
2283                 This is the current `released' version of Debian
2284                 GNU/Linux.  A new version is released approximately
2285                 every 3 months after the <em>development</em> code has
2286                 been <em>frozen</em> for a month of testing.  Once the
2287                 distribution is <em>stable</em> only major bug fixes
2288                 are allowed. When changes are made to this
2289                 distribution, the minor version number is increased
2290                 (for example: 1.2 becomes 1.2.1 then 1.2.2, etc).
2291               </p>
2292             </item>
2293                 
2294             <tag><em>unstable</em></tag>
2295             <item>
2296               <p>
2297                 This distribution value refers to the
2298                 <em>developmental</em> part of the Debian distribution
2299                 tree. New packages, new upstream versions of packages
2300                 and bug fixes go into the <em>unstable</em> directory
2301                 tree. Download from this distribution at your own
2302                 risk.</p>
2303             </item>
2304             
2305             <tag><em>contrib</em></tag>
2306             <item>
2307               <p>
2308                 The packages with this distribution value do not meet
2309                 the criteria for inclusion in the main Debian
2310                 distribution as defined by the Policy Manual, but meet
2311                 the criteria for the <em>contrib</em>
2312                 Distribution. There is currently no distinction
2313                 between stable and unstable packages in the
2314                 <em>contrib</em> or <em>non-free</em>
2315                 distributions. Use your best judgement in downloading
2316                 from this Distribution.</p>
2317             </item>
2318                 
2319             <tag><em>non-free</em></tag>
2320             <item>
2321               <p>
2322                 Like the packages in the <em>contrib</em> seciton,
2323                 the packages in <em>non-free</em> do not meet the
2324                 criteria for inclusion in the main Debian distribution
2325                 as defined by the Policy Manual. Again, use your best
2326                 judgement in downloading from this Distribution.</p>
2327               
2328             <tag><em>experimental</em></tag>
2329             <item>
2330               <p>
2331                 The packages with this distribution value are deemed
2332                 by their maintainers to be high risk. Oftentimes they
2333                 represent early beta or developmental packages from
2334                 various sources that the maintainers want people to
2335                 try, but are not ready to be a part of the other parts
2336                 of the Debian distribution tree. Download at your own
2337                 risk.</p>
2338             </item>
2339                 
2340             <tag><em>frozen</em></tag>
2341             <item>
2342               <p>
2343                 From time to time, (currently, every 3 months) the
2344                 <em>unstable</em> distribution enters a state of
2345                 `code-freeze' in anticipation of release as a
2346                 <em>stable</em> version. During this period of testing
2347                 (usually 4 weeks) only fixes for existing or
2348                 newly-discovered bugs will be allowed.
2349               </p>
2350             </item>
2351           </taglist> You should list <em>all</em> distributions that
2352           the package should be installed into. Except in unusual
2353           circumstances, installations to <em>stable</em> should also
2354           go into <em>frozen</em> (if it exists) and
2355           <em>unstable</em>. Likewise, installations into
2356           <em>frozen</em> should also go into <em>unstable</em>.</p>
2357         </sect1>
2358           
2359         <sect1 id="f-Urgency"><heading><tt>Urgency</tt>
2360           </heading>
2361
2362           <p>       
2363             This is a description of how important it is to upgrade to
2364             this version from previous ones.  It consists of a single
2365             keyword usually taking one of the values <tt>LOW</tt>,
2366             <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
2367             commentary (separated by a space) which is usually in
2368             parentheses.  For example:
2369             <example>
2370               Urgency: LOW (HIGH for diversions users)
2371             </example>
2372           </p>
2373
2374           <p>       
2375             This field appears in the <tt>.changes</tt> file and in
2376             parsed changelogs; its value appears as the value of the
2377             <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
2378             changelog (see <ref id="dpkgchangelog">).
2379           </p>
2380
2381           <p>       
2382             Urgency keywords are not case-sensitive.</p>
2383         </sect1>
2384           
2385         <sect1 id="f-Date"><heading><tt>Date</tt>
2386           </heading>
2387
2388           <p>       
2389             In <tt>.changes</tt> files and parsed changelogs, this
2390             gives the date the package was built or last edited.</p>
2391         </sect1>
2392           
2393         <sect1 id="f-Format"><heading><tt>Format</tt>
2394           </heading>
2395
2396           <p>       
2397             This field occurs in <tt>.changes</tt> files, and
2398             specifies a format revision for the file.  The format
2399             described here is version <tt>1.5</tt>.  The syntax of the
2400             format value is the same as that of a package version
2401             number except that no epoch or Debian revision is allowed
2402             - see <ref id="versions">.</p>
2403         </sect1>
2404           
2405         <sect1 id="f-Changes"><heading><tt>Changes</tt>
2406           </heading>
2407
2408           <p>       
2409             In a <tt>.changes</tt> file or parsed changelog this field
2410             contains the human-readable changes data, describing the
2411             differences between the last version and the current one.
2412           </p>
2413
2414           <p>       
2415             There should be nothing in this field before the first
2416             newline; all the subsequent lines must be indented by at
2417             least one space; blank lines must be represented by a line
2418             consiting only of a space and a full stop.
2419           </p>
2420
2421           <p>       
2422             Each version's change information should be preceded by a
2423             `title' line giving at least the version, distribution(s)
2424             and urgency, in a human-readable way.
2425           </p>
2426
2427           <p>       
2428             If data from several versions is being returned the entry
2429             for the most recent version should be returned first, and
2430             entries should be separated by the representation of a
2431             blank line (the `title' line may also be followed by the
2432             representation of blank line).</p>
2433         </sect1>
2434           
2435         <sect1 id="f-Filename"><heading><tt>Filename</tt> and
2436         <tt>MSDOS-Filename</tt>
2437           </heading>
2438
2439           <p>       
2440             These fields in <tt>Packages</tt> files give the
2441             filename(s) of (the parts of) a package in the
2442             distribution directories, relative to the root of the
2443             Debian hierarchy.  If the package has been split into
2444             several parts the parts are all listed in order, separated
2445             by spaces.</p>
2446         </sect1>
2447           
2448         <sect1 id="f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
2449           </heading>
2450
2451           <p>       
2452             These fields in <tt>Packages</tt> files give the size (in
2453             bytes, expressed in decimal) and MD5 checksum of the
2454             file(s) which make(s) up a binary package in the
2455             distribution.  If the package is split into several parts
2456             the values for the parts are listed in order, separated by
2457             spaces.</p>
2458         </sect1>
2459           
2460         <sect1 id="f-Status"><heading><tt>Status</tt>
2461           </heading>
2462
2463           <p>       
2464             This field in <prgn>dpkg</prgn>'s status file records
2465             whether the user wants a package installed, removed or
2466             left alone, whether it is broken (requiring
2467             reinstallation) or not and what its current state on the
2468             system is.  Each of these pieces of information is a
2469             single word.</p>
2470         </sect1>
2471           
2472         <sect1 id="f-Config-Version"><heading><tt>Config-Version</tt>
2473           </heading>
2474
2475           <p>       
2476             If a package is not installed or not configured, this
2477             field in <prgn>dpkg</prgn>'s status file records the last
2478             version of the package which was successfully
2479             configured.</p>
2480         </sect1>
2481           
2482         <sect1 id="f-Conffiles"><heading><tt>Conffiles</tt>
2483           </heading>
2484
2485           <p>       
2486             This field in <prgn>dpkg</prgn>'s status file contains
2487             information about the automatically-managed configuration
2488             files held by a package.  This field should <em>not</em>
2489             appear anywhere in a package!</p>
2490         </sect1>
2491           
2492         <sect1><heading>Obsolete fields
2493           </heading>
2494
2495           <p>       
2496             These are still recognised by <prgn>dpkg</prgn> but should
2497             not appear anywhere any more.
2498             <taglist compact="compact">
2499               
2500               <tag><tt>Revision</tt></tag>
2501               <tag><tt>Package-Revision</tt></tag>
2502               <tag><tt>Package_Revision</tt></tag>
2503               <item>
2504                 <p>
2505                   The Debian revision part of the package version was
2506                   at one point in a separate control file field.  This
2507                   field went through several names.</p>
2508               </item>
2509                   
2510               <tag><tt>Recommended</tt></tag>
2511               <item><p>Old name for <tt>Recommends</tt></p>
2512               </item>
2513                 
2514               <tag><tt>Optional</tt></tag>
2515               <item><p>Old name for <tt>Suggests</tt>.</p>
2516               </item>
2517               <tag><tt>Class</tt></tag>
2518               <item><p>Old name for <tt>Priority</tt>.</p>
2519               </item>
2520             </taglist>
2521           </p>
2522         </sect1>
2523       </sect>
2524     </chapt>
2525
2526     <chapt id="versions"><heading>Version numbering
2527       </heading>
2528
2529       <p>       
2530         Every package has a version number, in its <tt>Version</tt>
2531         control file field.
2532       </p>
2533
2534       <p>       
2535         <prgn>dpkg</prgn> imposes an ordering on version numbers, so
2536         that it can tell whether packages are being up- or downgraded
2537         and so that <prgn>dselect</prgn> can tell whether a package it
2538         finds available is newer than the one installed on the system.
2539         The version number format has the most significant parts (as
2540         far as comparison is concerned) at the beginning.
2541       </p>
2542
2543       <p>       
2544         The version number format is:
2545         &lsqb<var>epoch/<tt>:</tt>&rsqb;<var>upstream-version</var>&lsqb;<tt>-/<var>debian-revision</var>&rsqb;.</tt></var>
2546       </p>
2547
2548       <p>       
2549         The three components here are:
2550         <taglist>
2551           <tag><var>epoch</var></tag>
2552           <item>
2553             
2554             <p>
2555               This is a single unsigned integer, which should usually
2556               be small.  It may be omitted, in which case zero is
2557               assumed.  If it is omitted then the
2558               <var>upstream-version</var> may not contain any colons.
2559             </p>
2560
2561             <p>       
2562               It is provided to allow mistakes in the version numbers
2563               of older versions of a package, and also a package's
2564               previous version numbering schemes, to be left behind.
2565             </p>
2566
2567             <p>       
2568               <prgn>dpkg</prgn> will not usually display the epoch
2569               unless it is essential (non-zero, or if the
2570               <var>upstream-version</var> contains a colon);
2571               <prgn>dselect</prgn> does not display epochs at all in
2572               the main part of the package selection display.</p>
2573           </item>
2574             
2575           <tag><var>upstream-version</var></tag>
2576           <item>
2577             
2578             <p>
2579               This is the main part of the version.  It is usually
2580               version number of the original (`upstream') package of
2581               which the <tt>.deb</tt> file has been made, if this is
2582               applicable.  Usually this will be in the same format as
2583               that specified by the upstream author(s); however, it
2584               may need to be reformatted to fit into
2585               <prgn>dpkg</prgn>'s format and comparison scheme.
2586             </p>
2587
2588             <p>       
2589               The comparison behaviour of <prgn>dpkg</prgn> with
2590               respect to the <var>upstream-version</var> is described
2591               below.  The <var>upstream-version</var> portion of the
2592               version number is mandatory.
2593             </p>
2594
2595             <p>       
2596               The <var>upstream-version</var> may contain only
2597               alphanumerics and the characters <tt>+</tt> <tt>.</tt>
2598               <tt>-</tt> <tt>:</tt> (full stop, plus, hyphen, colon)
2599               and should start with a digit.  If there is no
2600               <var>debian-revision</var> then hyphens are not allowed;
2601               if there is no <var>epoch</var> then colons are not
2602               allowed.</p>
2603           </item>
2604             
2605           <tag><var>debian-revision</var></tag>
2606           <item>
2607             
2608             <p>
2609               This part of the version represents the version of the
2610               modifications that were made to the package to make it a
2611               Debian binary package.  It is in the same format as the
2612               <var>upstream-version</var> and <prgn>dpkg</prgn>
2613               compares it in the same way.
2614             </p>
2615
2616             <p>       
2617               It is optional; if it isn't present then the
2618               <var>upstream-version</var> may not contain a hyphen.
2619               This format represents the case where a piece of
2620               software was written specifically to be turned into a
2621               Debian binary package, and so there is only one
2622               `debianization' of it and therefore no revision
2623               indication is required.
2624             </p>
2625
2626             <p>       
2627               It is conventional to restart the
2628               <var>debian-revision</var> at <tt>1</tt> each time the
2629               <var>upstream-version</var> is increased.
2630             </p>
2631
2632             <p>       
2633               <prgn>dpkg</prgn> will break the
2634               <var>upstream-version</var> and
2635               <var>debian-revision</var> apart at the last hyphen in
2636               the string.  The absence of a <var>debian-revision</var>
2637               compares earlier than the presence of one (but note that
2638               the <var>debian-revision</var> is the least significant
2639               part of the version number).
2640             </p>
2641
2642             <p>       
2643               The <var>debian-revision</var> may contain only
2644               alphanumerics and the characters <tt>+</tt> and
2645               <tt>.</tt> (plus and full stop).
2646             </p>
2647           </item>
2648         </taglist>
2649         The <var>upstream-version</var> and <var>debian-revision</var> parts are
2650         compared by <prgn>dpkg</prgn> using the same algorithm:
2651       </p>
2652
2653       <p>       
2654         The strings are compared from left to right.
2655       </p>
2656
2657       <p>       
2658         First the initial part of each string consisting entirely of
2659         non-digit characters is determined.  These two parts (one of
2660         which may be empty) are compared lexically.  If a difference
2661         is found it is returned.  The lexical comparison is a
2662         comparison of ASCII values modified so that all the letters
2663         sort earlier than all the non-letters.
2664       </p>
2665
2666       <p>       
2667         Then the initial part of the remainder of each string which
2668         consists entirely of digit characters is determined.  The
2669         numerical values of these two parts are compared, and any
2670         difference found is returned as the result of the comparison.
2671         For these purposes an empty string (which can only occur at
2672         the end of one or both version strings being compared) counts
2673         as zero.
2674       </p>
2675
2676       <p>       
2677         These two steps are repeated (chopping initial non-digit
2678         strings and initial digit strings off from the start) until a
2679         difference is found or both strings are exhausted.
2680       </p>
2681
2682       <p>       
2683         Note that the purpose of epochs is to allow us to leave behind
2684         mistakes in version numbering, and to cope with situations
2685         where the version numbering changes.  It is <em>not</em> there
2686         to cope with version numbers containing strings of letters
2687         which <prgn>dpkg</prgn> cannot interpret (such as
2688         <tt>ALPHA</tt> or <tt>pre-</tt>), or with silly orderings (the
2689         author of this manual has heard of a package whose versions
2690         went <tt>1.1</tt>, <tt>1.2</tt>, <tt>1.3</tt>, <tt>1</tt>,
2691         <tt>2.1</tt>, <tt>2.2</tt>, <tt>2</tt> and so forth).
2692       </p>
2693
2694       <p>       
2695         If an upstream package has problematic version numbers they
2696         should be converted to a sane form for use in the
2697         <tt>Version</tt> field.
2698       </p>
2699
2700       <p>       
2701         If you need to compare version numbers in a script, you may use
2702         <tt>dpkg --compare-versions ...</tt>. Type <tt>dpkg
2703         --help</tt> --> --for details on arguments.
2704       </p>
2705     </chapt>
2706       
2707     <chapt id="maintainerscripts"><heading>Package maintainer scripts
2708         and installation procedure
2709       </heading>
2710
2711       <sect><heading>Introduction to package maintainer scripts
2712         </heading>
2713
2714         <p>       
2715           It is possible supply scripts as part of a package which
2716           <prgn>dpkg</prgn> will run for you when your package is
2717           installed, upgraded or removed.
2718         </p>
2719
2720         <p>       
2721           These scripts should be the files <tt>preinst</tt>,
2722           <tt>postinst</tt>, <tt>prerm</tt> and <tt>postrm</tt> in the
2723           control area of the package.  They must be proper exectuable
2724           files; if they are scripts (which is recommended) they must
2725           start with the usual <tt>#!</tt> convention.  They should be
2726           readable and executable to anyone, and not world-writeable.
2727         </p>
2728
2729         <p>       
2730           <prgn>dpkg</prgn> looks at the exit status from these
2731           scripts.  It is important that they exit with a non-zero
2732           status if there is an error, so that <prgn>dpkg</prgn> can
2733           stop its processing.  For shell scripts this means that you
2734           <em>almost always</em> need to use <tt>set -e</tt> (this is
2735           usually true when writing shell scripts, in fact).  It is
2736           also important, of course, that they don't exit with a
2737           non-zero status if everything went well.
2738         </p>
2739
2740         <p>       
2741           It is necessary for the error recovery procedures that the
2742           scripts be idempotent: ie, invoking the same script several
2743           times in the same situation should do no harm.  If the first
2744           call failed, or aborted half way through for some reason,
2745           the second call should merely do the things that were left
2746           undone the first time, if any, and exit with a success
2747           status.
2748         </p>
2749
2750         <p>       
2751           When a package is upgraded a combination of the scripts from
2752           the old and new packages is called in amongst the other
2753           steps of the upgrade procedure.  If your scripts are going
2754           to be at all complicated you need to be aware of this, and
2755           may need to check the arguments to your scripts.
2756         </p>
2757
2758         <p>       
2759           Broadly speaking the <prgn>preinst</prgn> is called before
2760           (a particular version of) a package is installed, and the
2761           <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2762           before (a version of) a package is removed and the
2763           <prgn>postrm</prgn> afterwards.       
2764         </p>
2765           <!--
2766           next paragraph by Guy Maor to close bug #2481
2767           -->
2768  
2769           <p> Programs called from maintainer scripts should not
2770           normally have a path prepended to them. Before installation
2771           is started <prgn>dpkg</prgn> checks to see if the programs
2772           <prgn>ldconfig</prgn>, <prgn>start-stop-daemon</prgn>,
2773           <prgn>install-info</prgn>, and <prgn>update-rc.d</prgn> can
2774           be found via the <tt>PATH</tt> environment variable. Those
2775           programs, and any other program that one would expect to on
2776           the <tt>PATH</tt>, should thus be invoked without an
2777           absolute pathname. Maintainer scripts should also not reset
2778           the <tt>PATH</tt>, though they might choose to modify it by
2779           pre- or appending package-specific directories. These
2780           considerations really apply to all shell scripts.</p>
2781       </sect>
2782         
2783       <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2784       scripts are called
2785         </heading>
2786
2787         <p>       
2788           <list compact="compact">
2789             <item>
2790               <p><var>new-preinst</var> <tt>install</tt></p>
2791             </item>
2792             <item>
2793               <p><var>new-preinst</var> <tt>install</tt>
2794               <var>old-version</var></p>
2795             </item>
2796             <item>
2797               <p><var>new-preinst</var> <tt>upgrade</tt>
2798               <var>old-version</var></p>
2799             </item>
2800             <item>
2801               <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2802               <var>new-version</var>
2803               </p>
2804             </item> 
2805           </list>
2806
2807         <p>       
2808           <list compact="compact">
2809             <item>
2810               <p><var>postinst</var> <tt>configure</tt>
2811                 <var>most-recently-configured-version</var></p>
2812             </item>
2813             <item>
2814               <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2815               <var>new version</var></p>
2816             </item>
2817             <item>
2818               <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2819                 <tt>in-favour</tt> <var>package</var>
2820                 <var>new-version</var></p>
2821             </item>
2822             <item>
2823               <p>
2824                 <var>deconfigured's-postinst</var>
2825                 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2826                 <var>failed-install-package</var> <var>version</var>
2827                 <tt>removing</tt> <var>conflicting-package</var>
2828                 <var>version</var>
2829               </p>
2830             </item>
2831           </list>
2832
2833         <p>       
2834           <list compact="compact">
2835             <item>
2836               <p><var>prerm</var> <tt>remove</tt></p>
2837             </item>
2838             <item>
2839               <p><var>old-prerm</var> <tt>upgrade</tt>
2840                 <var>new-version</var></p>
2841             </item>
2842             <item>
2843               <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2844                 <var>old-version</var></p>
2845             </item>
2846             <item>
2847               <p><var>conflictor's-prerm</var> <tt>remove</tt>
2848                 <tt>in-favour</tt> <var>package</var>
2849                 <var>new-version</var></p>
2850             </item>
2851             <item>
2852               <p>
2853                 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2854                 <tt>in-favour</tt> <var>package-being-installed</var>
2855                 <var>version</var> <tt>removing</tt>
2856                 <var>conflicting-package</var>
2857                 <var>version</var>
2858               </p>
2859             </item>
2860           </list>
2861
2862         <p>       
2863           <list compact="compact">
2864             <item>
2865               <p><var>postrm</var> <tt>remove</tt></p>
2866             </item>
2867             <item>
2868               <p><var>postrm</var> <tt>purge</tt></p>
2869             </item>
2870             <item>
2871               <p>
2872                 <var>old-postrm</var> <tt>upgrade</tt>
2873                 <var>new-version</var></p>
2874             </item>
2875             <item>
2876               <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2877                 <var>old-version</var></p>
2878             </item>
2879             <item>
2880               <p><var>new-postrm</var> <tt>abort-install</tt></p>
2881             </item>
2882             <item>
2883               <p><var>new-postrm</var> <tt>abort-install</tt>
2884                 <var>old-version</var></p>
2885             </item>
2886             <item>
2887               <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2888                 <var>old-version</var></p>
2889             </item>
2890             <item>
2891               <p>
2892                 <var>disappearer's-postrm</var> <tt>disappear</tt>
2893                 <var>r>overwrit</var>r>
2894                 <var>new-version</var></p></item>
2895           </list>
2896         </p>
2897         
2898         
2899       <sect id="unpackphase"><heading>Details of unpack phase of
2900       installation or upgrade
2901         </heading>
2902
2903         <p>       
2904           The procedure on installation/upgrade/overwrite/disappear
2905           (ie, when running <tt>dpkg --unpack</tt>, or the unpack
2906           stage of <tt>dpkg
2907             --install</tt>) is as follows.  In each case if an error occurs the
2908           actions in are general run backwards - this means that the maintainer
2909           scripts are run with different arguments in reverse order.  These are
2910           the `error unwind' calls listed below.
2911           
2912           <enumlist>
2913             <item>
2914               <p>
2915                 <enumlist>
2916                   <item>
2917                     <p>If a version the package is already
2918                       installed, call
2919                       <example>
2920                         <var>old-prerm</var> upgrade <var>new-version</var>
2921                       </example></p>
2922                   </item>
2923                   <item>
2924                     <p>
2925                       If this gives an error (ie, a non-zero exit
2926                       status), dpkg will attempt instead:
2927                       <example>
2928                         <var>new-prerm</var> failed-upgrade <var>old-version</var>
2929                       </example>
2930                       Error unwind, for both the above cases:
2931                       <example>
2932                         <var>old-postinst</var> abort-upgrade <var>new-version</var>
2933                       </example>
2934                     </p>
2935                   </item>
2936                 </enumlist>
2937               </p>
2938             </item>
2939             <item>
2940               <p>If a `conflicting' package is being removed at the same time:
2941                 <enumlist>
2942                   <item>
2943                     <p>
2944                       If any packages depended on that conflicting
2945                       package and <tt>--auto-deconfigure</tt> is
2946                       specified, call, for each such package:
2947                       <example>
2948                         <var>deconfigured's-prerm</var> deconfigure \
2949                         in-favour <var>package-being-installed</var> <var>version</var> \
2950                         removing <var>conflicting-package</var> <var>version</var>
2951                       </example>
2952                       Error unwind:
2953                       <example>
2954                         <var>deconfigured's-postinst</var> abort-deconfigure \
2955                         in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2956                         removing <var>conflicting-package</var> <var>version</var>
2957                       </example> 
2958                       The deconfigured packages are marked as
2959                       requiring configuration, so that if
2960                       <tt>--install</tt> is used they will be
2961                       configured again if possible.</p>
2962                   </item>
2963                   <item>
2964                     <p>To prepare for removal of the conflicting package, call:
2965                       <example>
2966                         <var>conflictor's-prerm</var> remove in-favour <var>package</var> <var>new-version</var>
2967                       </example>
2968                       Error unwind:
2969                       <example>
2970                         <var>conflictor's-postinst</var> abort-remove \
2971                         in-favour <var>package</var> <var>new-version</var>
2972                       </example>
2973                     </p>
2974                   </item>
2975                 </enumlist>
2976               </p>
2977             </item>
2978             <item>
2979               <p>
2980                 <enumlist>
2981                   <item>
2982                     <p>If the package is being upgraded, call:
2983                       <example>
2984                         <var>new-preinst</var> upgrade <var>old-version</var>
2985                       </example></p>
2986                   </item>
2987                   <item>
2988                     <p>
2989                       Otherwise, if the package had some configuration
2990                       files from a previous version installed (ie, it
2991                       is in the `configuration files only' state):
2992                       <example>
2993                         <var>new-preinst</var> install <var>old-version</var>
2994                       </example></p>
2995                     
2996                   <item>
2997                     <p>Otherwise (ie, the package was completely purged):
2998                       <example>
2999                         <var>new-preinst</var> install
3000                       </example>
3001                       Error unwind versions, respectively:
3002                       <example>
3003                         <var>new-postrm</var> abort-upgrade <var>old-version</var>
3004                         <var>new-postrm</var> abort-install <var>old-version</var>
3005                         <var>new-postrm</var> abort-install
3006                       </example>
3007                     </p>
3008                   </item>
3009                 </enumlist>
3010               </p>
3011             </item>
3012             <item>
3013
3014               <p>
3015                 The new package's files are unpacked, overwriting any
3016                 that may be on the system already, for example any
3017                 from the old version of the same package or from
3018                 another package (backups of the old files are left
3019                 around, and if anything goes wrong dpkg will attempt
3020                 to put them back as part of the error unwind).
3021               </p>
3022
3023               <p>               
3024                 It is an error for a package to contains files which
3025                 are on the system in another package, unless
3026                 <tt>Replaces</tt> is used (see <ref id="replaces">).
3027                 Currently the <tt>--force-overwrite</tt> flag is
3028                 enabled, downgrading it to a warning, but this may not
3029                 always be the case.
3030               </p>
3031
3032               <p>               
3033                 It is a more serious error for a package to contain a
3034                 plain file or other kind of nondirectory where another
3035                 package has a directory (again, unless
3036                 <tt>Replaces</tt> is used).  This error can be
3037                 overridden if desired using
3038                 <tt>--force-overwrite-dir</tt>, but this is not
3039                 advisable.
3040               </p>
3041
3042               <p>               
3043                 Packages which overwrite each other's files produce
3044                 behaviour which though deterministic is hard for the
3045                 system administrator to understand.  It can easily
3046                 lead to `missing' programs if, for example, a package
3047                 is installed which overwrites a file from another
3048                 package, and is then removed again.
3049                 <footnote>
3050                   <p>
3051                     Part of the problem is due to what is arguably a
3052                     bug in <prgn>dpkg</prgn> .
3053                   </p>
3054                 </footnote>
3055               </p>
3056
3057               <p>               
3058                 A directory will never be replaced by a symbolic links
3059                 to a directory or vice versa; instead, the existing
3060                 state (symlink or not) will be left alone and
3061                 <prgn>dpkg</prgn> will follow the symlink if there is
3062                 one.</p>
3063             </item>
3064               
3065             <item>
3066               
3067               <p><enumlist>
3068                   <item>
3069                     <p>If the package is being upgraded, call
3070                       <example>
3071                         <var>old-postrm</var> upgrade <var>new-version</var>
3072                       </example></p>
3073                   </item>
3074                   <item>
3075                     <p>If this fails, <prgn>dpkg</prgn> will attempt:
3076                       <example>
3077                         <var>new-postrm</var> failed-upgrade <var>old-version</var>
3078                       </example>
3079                       Error unwind, for both cases:
3080                       <example>
3081                         <var>old-preinst</var> abort-upgrade <var>new-version</var>
3082                       </example>
3083                     </p>
3084                   </item>
3085                 </enumlist>
3086                 This is the point of no return - if <prgn>dpkg</prgn>
3087                 gets this far, it won't back off past this point if an
3088                 error occurs.  This will leave the package in a fairly
3089                 bad state, which will require a successful
3090                 reinstallation to clear up, but it's when
3091                 <prgn>dpkg</prgn> starts doing things that are
3092                 irreversible.</p>
3093             </item>
3094             <item>
3095               <p>               
3096                 Any files which were in the old version of the package
3097                 but not in the new are removed.</p>
3098             </item>
3099             <item>
3100                 <p>The new file list replaces the old.</p>
3101             </item>
3102             <item>
3103                 <p>The new maintainer scripts replace the old.</p>
3104             </item>
3105                 
3106             <item>
3107               <p>Any packages all of whose files have been overwritten during the
3108                 installation, and which aren't required for
3109                 dependencies, are considered to have been removed.
3110                 For each such package,
3111                 <enumlist>
3112                   <item>
3113                     <p><prgn>dpkg</prgn> calls:
3114                       <example>
3115                         <var>disappearer's-postrm</var> disappear \
3116                         <var>overwriter</var> <var>overwriter-version</var>
3117                       </example></p>
3118                   </item>
3119                   <item>
3120                       <p>The package's maintainer scripts are removed.
3121                     </p>
3122                   </item>
3123                   <item>
3124                     <p>
3125                       It is noted in the status database as being in a
3126                       sane state, namely not installed (any conffiles
3127                       it may have are ignored, rather than being
3128                       removed by <prgn>dpkg</prgn>).  Note that
3129                       disappearing packages do not have their prerm
3130                       called, because <prgn>dpkg</prgn> doesn't know
3131                       in advance that the package is going to
3132                       vanish.
3133                     </p>
3134                   </item>
3135                 </enumlist>
3136               </p>
3137             </item>
3138             <item>
3139               <p>
3140                 Any files in the package we're unpacking that are also
3141                 listed in the file lists of other packages are removed
3142                 from those lists.  (This will lobotomise the file list
3143                 of the `conflicting' package if there is one.)
3144               </p>
3145             </item>
3146             <item>
3147               <p>
3148                 The backup files made during installation, above, are
3149                 deleted.
3150               </p>
3151             </item>
3152                 
3153             <item>
3154               <p>
3155                 The new package's status is now sane, and recorded as
3156                 `unpacked'.  Here is another point of no return - if
3157                 the conflicting package's removal fails we do not
3158                 unwind the rest of the installation; the conflicting
3159                 package is left in a half-removed limbo.
3160               </p>
3161             </item>
3162             <item>
3163               <p>
3164                 If there was a conflicting package we go and do the
3165                 removal actions (described below), starting with the
3166                 removal of the conflicting package's files (any that
3167                 are also in the package being installed have already
3168                 been removed from the conflicting package's file list,
3169                 and so do not get removed now).
3170               </p>
3171             </item>
3172           </enumlist>
3173         </p>
3174       </sect>
3175
3176       <sect><heading>Details of configuration
3177         </heading>
3178
3179         <p>       
3180           When we configure a package (this happens with <tt>dpkg
3181           --install</tt>, or with <tt>--configure</tt>), we first
3182           update the conffiles and then call:
3183           <example>
3184             <var>postinst</var> configure <var>most-recently-configured-version</var>
3185           </example>
3186         </p>
3187
3188         <p>       
3189           No attempt is made to unwind after errors during
3190           configuration.
3191         </p>
3192
3193         <p>       
3194           If there is no most recently configured version
3195           <prgn>dpkg</prgn> will pass a null argument; older versions
3196           of dpkg may pass <tt>&lt;unknown&gt;</tt> (including the
3197           angle brackets) in this case.  Even older ones do not pass a
3198           second argument at all, under any circumstances.
3199         </p>
3200       </sect>
3201         
3202       <sect><heading>Details of removal and/or configuration purging
3203         </heading>
3204
3205         <p>       
3206           <enumlist>
3207             <item>
3208               <p><example>
3209                   <var>prerm</var> remove
3210                 </example></p>
3211             </item>
3212             <item>
3213               <p>
3214                 The package's files are removed (except conffiles).
3215               </p>
3216             </item>
3217             <item>
3218               <p><example>
3219                   <var>postrm</var> remove
3220                 </example></p>
3221             </item>
3222             <item>
3223               <p>All the maintainer scripts except the postrm are removed.
3224               </p>
3225
3226               <p>               
3227                 If we aren't purging the package we stop here.  Note
3228                 that packages which have no postrm and no conffiles
3229                 are automatically purged when removed, as there is no
3230                 difference except for the <prgn>dpkg</prgn>
3231                 status.</p>
3232             </item>
3233             <item>
3234               <p>
3235                 The conffiles and any backup files (<tt>~</tt>-files,
3236                 <tt>#*#</tt> files, <tt>%</tt>-files,
3237                 <tt>.dpkg-{old,new,tmp}</tt>, etc.) are removed.</p>
3238             </item>
3239             <item>
3240               <p><example>
3241                   <var>postrm</var> purge
3242                 </example></p>
3243             </item>
3244             <item>
3245                 <p>The package's file list is removed.</p>
3246             </item>
3247           </enumlist>
3248           No attempt is made to unwind after errors during
3249           removal.</p>
3250       </sect>
3251     </chapt>
3252       
3253     <chapt id="descriptions"><heading>Descriptions of packages - the
3254         <tt>Description</tt> field
3255       </heading>
3256
3257       <p>       
3258         The <tt>Description</tt> control file field is used by
3259         <prgn>dselect</prgn> when the user is selecting which packages
3260         to install and by <prgn>dpkg</prgn> when it displays
3261         information about the status of packages and so forth.  It is
3262         included on the FTP site in the <prgn>Packages</prgn> files,
3263         and may also be used by the Debian WWW pages.
3264       </p>
3265
3266       <p>       
3267         The description is intended to describe the program to a user
3268         who has never met it before so that they know whether they
3269         want to install it.  It should also give information about the
3270         significant dependencies and conflicts between this package
3271         and others, so that the user knows why these dependencies and
3272         conflicts have been declared.
3273       </p>
3274
3275       <p>       
3276         The field's format is as follows:
3277         <example>
3278           Description: <var>single line synopsis</var>
3279           <var>extended description over several lines</var>
3280         </example>
3281       </p>
3282
3283       <p>       
3284         The synopsis is often printed in lists of packages and so
3285         forth, and should be as informative as possible.  Every
3286         package should also have an extended description.
3287       </p>
3288
3289       <sect><heading>Types of formatting line in the extended
3290           description
3291         </heading>
3292
3293         <p>       
3294           <list>
3295             <item>
3296               <p>
3297                 Those starting with a single space are part of a
3298                 paragraph.  Successive lines of this form will be
3299                 word-wrapped when displayed.  The leading space will
3300                 usually be stripped off.
3301               </p>
3302             </item>
3303                 
3304             <item>
3305               <p>
3306                 Those starting with two or more spaces.  These will be
3307                 displayed verbatim.  If the display cannot be panned
3308                 horizontally the displaying program will linewrap them
3309                 `hard' (ie, without taking account of word breaks).
3310                 If it can they will be allowed to trail off to the
3311                 right.  None, one or two initial spaces may be
3312                 deleted, but the number of spaces deleted from each
3313                 line will be the same (so that you can have indenting
3314                 work correctly, for example).
3315               </p>
3316             </item>
3317                 
3318             <item>
3319               <p>Those containing a single space followed by a single full stop
3320                 character.  These are rendered as blank lines.  This
3321                 is the <em>only</em> way to get a blank line - see
3322                 below.</p>
3323             </item>
3324               
3325             <item>
3326               <p>
3327                 Those containing a space, a full stop and some more
3328                 characters.  These are for future expansion.  Do not
3329                 use them.</p>
3330             </item>
3331           </list>
3332         </p>
3333       </sect>
3334
3335       <sect><heading>Notes about writing descriptions
3336         </heading>
3337
3338         <p>       
3339           <em>Always</em> start extended description lines with at least one
3340           whitespace character.  Fields in the control file and in the Packages
3341           file are separated by field names starting in the first column, just
3342           as message header fields are in RFC822.  Forgetting the whitespace
3343           will cause <prgn>dpkg-deb</prgn>
3344           <footnote>
3345             <p>
3346               Version 0.93.23 or later.
3347             </p>
3348           </footnote> to produce a syntax error when trying to build
3349           the package.  If you force it to build anyway
3350           <prgn>dpkg</prgn> will refuse to install the resulting
3351           mess.
3352         </p>
3353
3354         <p>       
3355           <em>Do not</em> include any completely <em>empty</em>
3356           lines. These separate different records in the Packages file
3357           and different packages in the <tt>debian/control</tt> file,
3358           and are forbidden in package control files.  See the
3359           previous paragraph for what happens if you get this wrong.
3360         </p>
3361
3362         <p>       
3363           The single line synopsis should be kept brief - certainly
3364           under 80 characters.  <prgn>dselect</prgn> displays between
3365           25 and 49 characters without panning if you're using an
3366           80-column terminal, depending on what display options are in
3367           effect.
3368         </p>
3369
3370         <p>       
3371           Do not include the package name in the synopsis line.  The
3372           display software knows how to display this already, and you
3373           do not need to state it.  Remember that in many situations
3374           the user may only see the synopsis line - make it as
3375           informative as you can.
3376         </p>
3377
3378         <p>       
3379           The extended description should describe what the package
3380           does and how it relates to the rest of the system (in terms
3381           of, for example, which subsystem it is which part of).
3382         </p>
3383
3384         <p>       
3385           The blurb that comes with a program in its announcements
3386           and/or <prgn>README</prgn> files is rarely suitable for use
3387           in a description.  It is usually aimed at people who are
3388           already in the community where the package is used.  The
3389           description field needs to make sense to anyone, even people
3390           who have no idea about any of the things the package deals
3391           with.
3392         </p>
3393
3394         <p>       
3395           Put important information first, both in the synopis and
3396           extended description.  Sometimes only the first part of the
3397           synopsis or of the description will be displayed.  You can
3398           assume that there will usually be a way to see the whole
3399           extended description.
3400         </p>
3401
3402         <p>       
3403           You may include information about dependencies and so forth
3404           in the extended description, if you wish.
3405         </p>
3406
3407         <p>       
3408           Do not use tab characters.  Their effect is not predictable.
3409         </p>
3410
3411         <p>       
3412           Do not try to linewrap the summary (the part on the same
3413           line as the field name <tt>Description</tt>) into the
3414           extended description.  This will not work correctly when the
3415           full description is displayed, and makes no sense where only
3416           the summary is available.</p>
3417       </sect>
3418         
3419       <sect><heading>Example description in control file for Smail
3420         </heading>
3421
3422         <p>       
3423           <example>
3424             Package: smail
3425             Version: 3.1.29.1-13
3426             Maintainer: Ian Jackson &lt;iwj10@cus.cam.ac.uk&gt;
3427             Recommends: pine | mailx | elm | emacs | mail-user-agent
3428             Suggests: metamail
3429             Depends: cron, libc5
3430             Conflicts: sendmail
3431             Provides: mail-transport-agent
3432             Description: Electronic mail transport system.
3433             Smail is the recommended mail transport agent (MTA) for Debian.
3434             .
3435             An MTA is the innards of the mail system - it takes messages from
3436             user-friendly mailer programs and arranges for them to be delivered
3437             locally or passed on to other systems as required.
3438             .
3439             In order to make use of it you must have one or more user level
3440             mailreader programs such as elm, pine, mailx or Emacs (which has Rmail
3441             and VM as mailreaders) installed.  If you wish to send messages other
3442             than just to other users of your system you must also have appropriate
3443             networking support, in the form of IP or UUCP.
3444           </example>
3445         </p>
3446       </sect>
3447     </chapt>
3448
3449     <chapt id="relationships"><heading>Declaring relationships between
3450     packages
3451       </heading>
3452
3453       <p>       
3454         Packages can declare in their control file that they have
3455         certain relationships to other packages - for example, that
3456         they may not be installed at the same time as certain other
3457         packages, and/or that they depend on the presence of others,
3458         or that they should overwrite files in certain other packages
3459         if present.
3460       </p>
3461
3462       <p>       
3463         This is done using the <tt>Depends</tt>, <tt>Recommends</tt>,
3464         <tt>Suggests</tt>, <tt>Conflicts</tt>, <tt>Provides</tt> and
3465         <tt>Replaces</tt> control file fields.
3466       </p>
3467
3468       <sect id="depsyntax"><heading>Syntax of relationship fields
3469         </heading>
3470
3471         <p>       
3472           These fields all have a uniform syntax.  They are a list of
3473           package names separated by commas.
3474         </p>
3475
3476         <p>       
3477           In <tt>Depends</tt>, <tt>Recommends</tt>, <tt>Suggests</tt>
3478           and <tt>Pre-Depends</tt> (the fields which declare
3479           dependencies of the package in which they occur on other
3480           packages) these package names may also be lists of
3481           alternative package names, separated by vertical bar symbols
3482           <tt>|</tt> (pipe symbols).
3483         </p>
3484
3485         <p>       
3486           All the fields except <tt>Provides</tt> may restrict their
3487           applicability to particular versions of each named package.
3488           This is done in parentheses after each individual package
3489           name; the parentheses should contain a relation from the
3490           list below followed by a version number, in the format
3491           described in <ref id="versions">.
3492         </p>
3493
3494         <p>       
3495           The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
3496           <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for
3497           strictly earlier, earlier or equal, exactly equal, later or
3498           equal and strictly later, respectively.  The forms
3499           <tt>&lt;</tt> and <tt>&gt;</tt> were used to mean
3500           earlier/later or equal, rather than strictly earlier/later,
3501           so they should not appear in new packages (though
3502           <prgn>dpkg</prgn> still supports them).
3503         </p>
3504
3505         <p>       
3506           Whitespace may appear at any point in the version
3507           specification, and must appear where it's necessary to
3508           disambiguate; it is not otherwise significant.  For
3509           consistency and in case of future changes to
3510           <prgn>dpkg</prgn> it is recommended that a single space be
3511           used after a version relationship and before a version
3512           number; it is usual also to put a single space after each
3513           comma, on either side of each vertical bar, and before each
3514           open parenthesis.
3515         </p>
3516
3517         <p>       
3518           For example:
3519           <example>
3520             Package: metamail
3521             Version: 2.7-3
3522             Depends: libc5 (>= 5.2.18-4), mime-support, csh | tcsh
3523           </example>
3524         </p>
3525       </sect>
3526
3527       <sect><heading>Dependencies - <tt>Depends</tt>, <tt>Recommends</tt>,
3528           <tt>tt>Sugge</tt>tt>, <tt>Pre-Depends</tt>
3529         </heading>
3530
3531         <p>       
3532           These four fields are used to declare a dependency by one
3533           package on another.  They appear in the depending package's
3534           control file.
3535         </p>
3536
3537         <p>       
3538           All but <tt>Pre-Depends</tt> (discussed below) take effect
3539           <em>only</em> when a package is to be configured.  They do
3540           not prevent a package being on the system in an unconfigured
3541           state while its dependencies are unsatisfied, and it is
3542           possible to replace a package whose dependencies are
3543           satisfied and which is properly installed with a different
3544           version whose dependencies are not and cannot be satisfied;
3545           when this is done the depending package will be left
3546           unconfigured (since attempts to configure it will give
3547           errors) and will not function properly.
3548         </p>
3549
3550         <p>       
3551           For this reason packages in an installation run are usually
3552           all unpacked first and all configured later; this gives
3553           later versions of packages with dependencies on later
3554           versions of other packages the opportunity to have their
3555           dependencies satisfied.
3556         </p>
3557
3558         <p>       
3559           Thus <tt>Depends</tt> allows package maintainers to impose
3560           an order in which packages should be configured.
3561           <taglist>
3562             <tag><tt>Depends</tt></tag>
3563             <item>
3564               
3565               <p>This declares an absolute dependency.
3566               </p>
3567
3568               <p>               
3569                 <prgn>dpkg</prgn> will not configure packages whose
3570                 dependencies aren't satisfied.  If it is asked to make
3571                 an installation which would cause an installed
3572                 package's dependencies to become unsatisfied it will
3573                 complain
3574                 <footnote>
3575                   <p>
3576                     Current versions (1.2.4) of <prgn>dpkg</prgn> have
3577                     a bug in this area which will cause some of these
3578                     problems to be ignored.
3579                   </p>
3580                 </footnote>, unless <tt>--auto-deconfigure</tt> is
3581                 specified, in which case those packages will be
3582                 deconfigured before the installation proceeds.
3583               </p>
3584
3585               <p>               
3586                 <prgn>dselect</prgn> makes it hard for the user to
3587                 select packages for installation, removal or upgrade
3588                 in a way that would mean that packages'
3589                 <prgn>Depends</prgn> fields would be unsatisfied.  The
3590                 user can override this if they wish, for example if
3591                 they know that <prgn>dselect</prgn> has an out-of-date
3592                 view of the real package relationships.
3593               </p>
3594
3595               <p>               
3596                 The <tt>Depends</tt> field should be used if the
3597                 depended-on package is required for the depending
3598                 package to provide a significant amount of
3599                 functionality.</p>
3600             </item>
3601               
3602             <tag><tt>Recommends</tt></tag>
3603             <item>
3604               <p>This declares a strong, but not absolute, dependency.
3605               </p>
3606
3607               <p>               
3608                 <tt>Recommends</tt> is ignored by <prgn>dpkg</prgn>,
3609                 so that users using the command-line (who are presumed
3610                 to know what they're doing) will not be impeded.
3611               </p>
3612
3613               <p>               
3614                 It is treated by <prgn>dselect</prgn> exactly as
3615                 <tt>Depends</tt> is; this makes it hard for the user
3616                 to select things so as to leave <tt>Recommends</tt>
3617                 fields unsatisfied, but they are able to do so by
3618                 being persistent.
3619               </p>
3620
3621               <p>               
3622                 The <tt>Recommends</tt> field should list packages
3623                 that would be found together with this one in all but
3624                 unusual installations.</p>
3625             </item>
3626               
3627             <tag><tt>Suggests</tt></tag>
3628             <item>
3629               
3630               <p>
3631                 This is used to declare that one package may be more
3632                 useful with one or more others.  Using this field
3633                 tells the packaging system and the user that the
3634                 listed packages are be related to this one and can
3635                 perhaps enhance its usefulness, but that installing
3636                 this one without them is perfectly reasonable.
3637               </p>
3638
3639               <p>               
3640                 <prgn>dselect</prgn> will offer suggsted packages to
3641                 the system administrator when they select the
3642                 suggesting package, but the default is not to install
3643                 the suggested package.</p>
3644             </item>
3645               
3646             <tag><tt>Pre-Depends</tt></tag>
3647             <item>
3648               
3649               <p>This field is like <tt>Depends</tt>, except that it also forces
3650                 <prgn>dpkg</prgn> to complete installation of the
3651                 packages named before even starting the installation
3652                 of the package which declares the predependency.
3653               </p>
3654
3655               <p>               
3656                 <prgn>dselect</prgn> checks for predependencies when
3657                 it is doing an installation run, and will attempt to
3658                 find the packages which are required to be installed
3659                 first and do so in the right order.
3660               </p>
3661
3662               <p>               
3663                 However, this process is slow (because it requires
3664                 repeated invocations of <prgn>dpkg</prgn>) and
3665                 troublesome (because it requires guessing where to
3666                 find the appropriate files).
3667               </p>
3668
3669               <p>               
3670                 For these reasons, and because this field imposes
3671                 restrictions on the order in which packages may be
3672                 unpacked (which can be difficult for installations
3673                 from multipart media, for example),
3674                 <tt>Pre-Depends</tt> should be used sparingly,
3675                 preferably only by packages whose premature upgrade or
3676                 installation would hamper the ability of the system to
3677                 continue with any upgrade that might be in progress.
3678               </p>
3679
3680               <p>               
3681                 When the package declaring it is being configured, a
3682                 <tt>Pre-Dependency</tt> will be considered satisfied
3683                 only if the depending package has been correctly
3684                 configured, just as if an ordinary <tt>Depends</tt>
3685                 had been used.
3686               </p>
3687
3688               <p>               
3689                 However, when a package declaring a predependency is
3690                 being unpacked the predependency can be satisfied even
3691                 if the depended-on package(s) are only unpacked or
3692                 half-configured, provided that they have been
3693                 configured correctly at some point in the past (and
3694                 not removed or partially removed since).  In this case
3695                 both the previously-configured and currently unpacked
3696                 or half-configured versions must satisfy any version
3697                 clause in the <tt>Pre-Depends</tt> field.
3698               </p>
3699             </item>
3700           </taglist>
3701         </p>
3702         <p> 
3703           When selecting which level of dependency to use you should
3704           consider how important the depended-on package is to the
3705           functionality of the one declaring the dependency.  Some
3706           packages are composed of components of varying degrees of
3707           importance.  Such a package should list using
3708           <tt>Depends</tt> the package(s) which are required by the
3709           more important components.  The other components'
3710           requirements may be mentioned as Suggestions or
3711           Recommendations, as appropriate to the components' relative
3712           importance.
3713         </p>
3714
3715       <sect1><heading>Dependencies on shared libraries
3716         </heading>
3717         
3718         <p>         
3719             The dependency fields listed above are used by packages
3720             which need shared libraries to declare dependencies on the
3721             appropriate packages.
3722         </p>
3723
3724         <p>         
3725           These dependencies are usually determined automatically
3726           using <prgn>dpkg-shlibdeps</prgn> and inserted in the
3727           package control file using the control file substitution
3728           variables mechanism; see <ref id="srcsubstvars"> and 
3729           <ref id="sourcetools">.
3730         </p>
3731       </sect1>
3732           
3733       <sect1><heading>Deconfiguration due to removal during bulk
3734       installations
3735         </heading>
3736           
3737         <p>         
3738           If <prgn>dpkg</prgn> would like to remove a package due to a
3739           conflict, as described above, but this would violate a
3740           dependency of some other package on the system,
3741           <prgn>dpkg</prgn> will usually not remove the conflicting
3742           package and halt with an error.
3743         </p>
3744           
3745         <p>         
3746           However, if the <tt>--auto-deconfigure</tt> (<tt>-B</tt>)
3747           option is used <prgn>dpkg</prgn> will automatically
3748           `deconfigure' the package with the problematic dependency,
3749           so that the conflicting package can be removed and the
3750           package we're trying to install can be installed.  If
3751           <prgn>dpkg</prgn> is being asked to install packages (rather
3752           than just unpacking them) it will try to reconfigure the
3753           package when it has unpacked all its arguments, in the hope
3754           that one of the other packages it is installing will satisfy
3755           the problematic dependency.
3756         </p>
3757
3758           <p>       
3759             <prgn>dselect</prgn> supplies this argument to
3760             <prgn>dpkg</prgn> when it invokes it, so that bulk
3761             installations proceed smoothly.
3762         </p>
3763       </sect1>
3764
3765       <sect id="conflicts"><heading>Alternative packages -
3766           <tt>tt>Confli</tt>tt> and <tt>Replaces</tt>
3767         </heading>
3768
3769         <p>       
3770           When one package declares a conflict with another
3771           <prgn>dpkg</prgn> will refuse to allow them to be installed
3772           on the system at the same time.
3773         </p>
3774
3775         <p>       
3776           If one package is to be installed, the other must be removed first -
3777           if the package being installed is marked as replacing (<ref
3778                                                                       id="replaces">) the one on the system, or the one on the system is
3779           marked as deselected, or both packages are marked
3780           <tt>Essential</tt>, then <prgn>dpkg</prgn> will
3781           automatically remove the package which is causing the
3782           conflict, otherwise it will halt the installation of the new
3783           package with an error.
3784         </p>
3785
3786         <p>       
3787           <prgn>dselect</prgn> makes it hard to select conflicting
3788           packages, though the user can override this if they wish.
3789           If they do not override it then <prgn>dselect</prgn> will
3790           select one of the packages for removal, and the user must
3791           make sure it is the right one.  In the future
3792           <prgn>dselect</prgn> will look for the presence of a
3793           <tt>Replaces</tt> field to help decide which package should
3794           be installed and which removed.
3795         </p>
3796
3797         <p>       
3798           A package will not cause a conflict merely because its
3799           configuration files are still installed; it must be at least
3800           half-installed.
3801         </p>
3802
3803         <p>       
3804           A special exception is made for packages which declare a
3805           conflict with their own package name, or with a virtual
3806           package which they provide (see below): this does not
3807           prevent their installation, and allows a package to conflict
3808           with others providing a replacement for it.  You use this
3809           feature when you want the package in question to be the only
3810           package providing something.
3811         </p>
3812
3813         <p>       
3814           A <tt>Conflicts</tt> entry should almost never have an
3815           `earlier than' version clause.  This would prevent
3816           <prgn>dpkg</prgn> from upgrading or installing the package
3817           which declared such a conflict until the upgrade or removal
3818           of the conflicted-with package had been completed.  This
3819           aspect of installation ordering is not handled by
3820           <prgn>dselect</prgn>, so that the use <tt>Conflicts</tt> in
3821           this way is likely to cause problems for `bulk run' upgrades
3822           and installations.
3823         </p>
3824       </sect>
3825         
3826       <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3827         </heading>
3828
3829         <p>       
3830           As well as the names of actual (`concrete') packages, the
3831           package relationship fields <tt>Depends</tt>,
3832           <tt>Recommends</tt>, <tt>Suggests</tt> and
3833           <tt>Conflicts</tt> may mention virtual packages.
3834         </p>
3835
3836         <p>       
3837           A virtual package is one which appears in the
3838           <tt>Provides</tt> control file field of another package.
3839           The effect is as if the package(s) which provide a
3840           particular virtual package name had been listed by name
3841           everywhere were the virtual package name appears.
3842         </p>
3843
3844         <p>       
3845           If there are both a real and a virtual package of the same
3846           name then the dependency may be satisfied (or the conflict
3847           caused) by either the real package or any of the virtual
3848           packages which provide it.  This is so that, for example,
3849           supposing we have
3850           <example>
3851             Package: vm
3852             Depends: emacs
3853           </example>
3854           and someone else releases an xemacs package they can say
3855           <example>
3856             Package: xemacs
3857             Provides: emacs
3858           </example> and all will work in the interim (until a purely
3859           virtual package name is decided on and the <tt>emacs</tt>
3860           and <tt>vm</tt> packages are changed to use it).
3861         </p>
3862
3863         <p>       
3864           If a dependency or a conflict has a version number attached
3865           then only real packages will be considered to see whether
3866           the relationship is satisfied (or the prohibition violated,
3867           for a conflict) - it is assumed that a real package which
3868           provides virtual package is not of the `right' version.  So,
3869           a <tt>Provides</tt> field may not contain version numbers,
3870           and the version number of the concrete package which
3871           provides a particular virtual package will not be looked at
3872           when considering a dependency on or conflict with the
3873           virtual package name.
3874         </p>
3875
3876         <p>       
3877           It is likely that the ability will be added in a future
3878           release of <prgn>dpkg</prgn> to specify a version number for
3879           each virtual package it provides.  This feature is not yet
3880           present, however, and is expected to be used only
3881           infrequently.
3882         </p>
3883
3884         <p>       
3885           If you want to specify which of a set of real packages should be the
3886           default to satisfy a particular dependency on a virtual package, you
3887           should list the real package as alternative before the virtual.
3888         </p>
3889       </sect>
3890         
3891         
3892       <sect id="replaces"><heading><tt>Replaces</tt> - overwriting
3893       files and replacing packages
3894         </heading>
3895
3896         <p>       
3897           The <tt>Replaces</tt> control file field has two purposes,
3898           which come into play in different situations.
3899         </p>
3900
3901         <p>       
3902           Virtual packages (<ref id="virtual">) are not considered
3903           when looking at a <tt>Replaces</tt> field - the packages
3904           declared as being replaced must be mentioned by their real
3905           names.
3906         </p>
3907           
3908         <sect1><heading>Overwriting files in other packages
3909           </heading>
3910
3911           <p>       
3912             Firstly, as mentioned before, it is usually an error for a
3913             package to contains files which are on the system in
3914             another package, though currently the
3915             <tt>--force-overwrite</tt> flag is enabled by default,
3916             downgrading the error to a warning,
3917           </p>
3918
3919           <p>       
3920             If the overwriting package declares that it replaces the
3921             one containing the file being overwritten then
3922             <prgn>dpkg</prgn> will proceed, and replace the file from
3923             the old package with that from the new.  The file will no
3924             longer be listed as `owned' by the old package.
3925           </p>
3926
3927           <p>       
3928             If a package is completely replaced in this way, so that
3929             <prgn>dpkg</prgn> does not know of any files it still
3930             contains, it is considered to have disappeared.  It will
3931             be marked as not wanted on the system (selected for
3932             removal) and not installed.  Any conffiles details noted
3933             in the package will be ignored, as they will have been
3934             taken over by the replacing package(s).  The package's
3935             <prgn>postrm</prgn> script will be run to allow the
3936             package to do any final cleanup required.  See <ref
3937             id="mscriptsinstact">.
3938           </p>
3939
3940           <p>       
3941             In the future <prgn>dpkg</prgn> will discard files which
3942             overwrite those from another package which declares that
3943             it replaces the one being installed (so that you can
3944             install an older version of a package without problems).
3945           </p>
3946
3947           <p>       
3948             This usage of <tt>Replaces</tt> only takes effect when
3949             both packages are at least partially on the system at
3950             once, so that it can only happen if they do not conflict
3951             or if the conflict has been overridden.</p>
3952         </sect1>
3953           
3954         <sect1><heading>Replacing whole packages, forcing their
3955         removal
3956           </heading>
3957
3958           <p>       
3959             Secondly, <tt>Replaces</tt> allows <prgn>dpkg</prgn> and
3960             <prgn>dselect</prgn> to resolve which package should be
3961             removed when a conflict - see <ref id="conflicts">.  This
3962             usage only takes effect when the two packages <em>do</em>
3963             conflict, so that the two effects do not interfere with
3964             each other.
3965           </p>
3966         </sect1>
3967       </sect>
3968         
3969       <sect><heading>Defaults for satisfying dependencies - ordering
3970         </heading>
3971
3972         <p>       
3973           Ordering is significant in dependency fields.
3974         </p>
3975
3976         <p>       
3977           Usually dselect will suggest to the user that they select
3978           the package with the most `fundamental' class (eg, it will
3979           prefer Base packages to Optional ones), or the one that they
3980           `most wanted' to select in some sense.
3981         </p>
3982
3983         <p>       
3984           In the absence of other information <prgn>dselect</prgn>
3985           will offer a default selection of the first named package in
3986           a list of alternatives.
3987         </p>
3988
3989         <p>       
3990           However, there is no way to specify the `order' of several
3991           packages which all provide the same thing, when that thing
3992           is listed as a dependency.
3993         </p>
3994
3995         <p>       
3996           Therefore a dependency on a virtual package should contain a
3997           concrete package name as the first alternative, so that this
3998           is the default.
3999         </p>
4000
4001         <p>       
4002           For example, consider the set of packages:
4003           <example>
4004             Package: glibcdoc
4005             Recommends: info-browser
4006             
4007             Package: info
4008             Provides: info-browser
4009             
4010             Package: emacs
4011             Provides: info-browser
4012           </example>
4013         </p>
4014
4015         <p>       
4016           If <prgn>emacs</prgn> and <prgn>info</prgn> both have the
4017           same priority then <prgn>dselect</prgn>'s choice is
4018           essentially random.  Better would be
4019           <example>
4020             Package: glibcdoc
4021             Recommends: info | info-browser
4022           </example>
4023           so that <prgn>dselect</prgn> defaults to selecting the
4024           lightweight standalone info browser.
4025         </p>
4026       </sect>
4027     </chapt>
4028       
4029     <chapt id="conffiles"><heading>Configuration file handling
4030       </heading>
4031
4032       <p>       
4033         <prgn>dpkg</prgn> can do a certain amount of automatic
4034         handling of package configuration files.
4035       </p>
4036
4037       <p>       
4038         Whether this mechanism is appropriate depends on a number of
4039         factors, but basically there are two approaches to any
4040         particular configuration file.
4041       </p>
4042
4043       <p>       
4044         The easy method is to ship a best-effort configuration in the
4045         package, and use <prgn>dpkg</prgn>'s conffile mechanism to
4046         handle updates.  If the user is unlikely to want to edit the
4047         file, but you need them to be able to without losing their
4048         changes, and a new package with a changed version of the file
4049         is only released infrequently, this is a good approach.
4050       </p>
4051
4052       <p>       
4053         The hard method is to build the configuration file from
4054         scratch in the <prgn>postinst</prgn> script, and to take the
4055         responsibility for fixing any mistakes made in earlier
4056         versions of the package automatically.  This will be
4057         appropriate if the file is likely to need to be different on
4058         each system.
4059       </p>
4060         
4061       <sect><heading>Automatic handling of configuration files by
4062       <prgn>dpkg</prgn>
4063         </heading>
4064
4065         <p>       
4066           A package may contain a control area file called
4067           <tt>conffiles</tt>.  This file should be a list of filenames
4068           of configuration files needing automatic handling, separated
4069           by newlines.  The filenames should be absolute pathnames,
4070           and the files referred to should actually exist in the
4071           package.
4072         </p>
4073
4074         <p>       
4075           When a package is upgraded <prgn>dpkg</prgn> will process
4076           the configuration files during the configuration stage,
4077           shortly before it runs the package's <prgn>postinst</prgn>
4078           script,
4079         </p>
4080
4081         <p>       
4082           For each file it checks to see whether the version of the
4083           file included in the package is the same as the one that was
4084           included in the last version of the package (the one that is
4085           being upgraded from); it also compares the version currently
4086           installed on the system with the one shipped with the last
4087           version.
4088         </p>
4089
4090         <p>       
4091           If neither the user nor the package maintainer has changed
4092           the file, it is left alone.  If one or the other has changed
4093           their version, then the changed version is preferred - ie,
4094           if the user edits their file, but the package maintainer
4095           doesn't ship a different version, the user's changes will
4096           stay, silently, but if the maintainer ships a new version
4097           and the user hasn't edited it the new version will be
4098           installed (with an informative message).  If both have
4099           changed their version the user is prompted about the problem
4100           and must resolve the differences themselves.
4101         </p>
4102
4103         <p>       
4104           The comparisons are done by calculating the MD5 message
4105           digests of the files, and storing the MD5 of the file as it
4106           was included in the most recent version of the package.
4107         </p>
4108
4109         <p>       
4110           When a package is installed for the first time
4111           <prgn>dpkg</prgn> will install the file that comes with it,
4112           unless that would mean overwriting a file already on the
4113           filesystem.
4114         </p>
4115
4116         <p>       
4117           However, note that <prgn>dpkg</prgn> will <em>not</em>
4118           replace a conffile that was removed by the user (or by a
4119           script).  This is necessary because with some programs a
4120           missing file produces an effect hard or impossible to
4121           achieve in another way, so that a missing file needs to be
4122           kept that way if the user did it.
4123         </p>
4124
4125         <p>       
4126           Note that a package should <em>not</em> modify a
4127           <prgn>dpkg</prgn>-handled conffile in its maintainer
4128           scripts.  Doing this will lead to <prgn>dpkg</prgn> giving
4129           the user confusing and possibly dangerous options for
4130           conffile update when the package is upgraded.</p>
4131       </sect>
4132         
4133       <sect><heading>Fully-featured maintainer script configuration
4134       handling
4135         </heading>
4136
4137         <p>       
4138           For files which contain site-specific information such as
4139           the hostname and networking details and so forth, it is
4140           better to create the file in the package's
4141           <prgn>postinst</prgn> script.
4142         </p>
4143
4144         <p>       
4145           This will typically involve examining the state of the rest
4146           of the system to determine values and other information, and
4147           may involve prompting the user for some information which
4148           can't be obtained some other way.
4149         </p>
4150
4151         <p>       
4152           When using this method there are a couple of important
4153           issues which should be considered:
4154         </p>
4155
4156         <p>       
4157           If you discover a bug in the program which generates the
4158           configuration file, or if the format of the file changes
4159           from one version to the next, you will have to arrange for
4160           the postinst script to do something sensible - usually this
4161           will mean editing the installed configuration file to remove
4162           the problem or change the syntax.  You will have to do this
4163           very carefully, since the user may have changed the file,
4164           perhaps to fix the very problem that your script is trying
4165           to deal with - you will have to detect these situations and
4166           deal with them correctly.
4167         </p>
4168
4169         <p>       
4170           If you do go down this route it's probably a good idea to
4171           make the program that generates the configuration file(s) a
4172           separate program in <tt>/usr/sbin</tt>, by convention called
4173           <tt><var>package</var>config</tt> and then run that if
4174           appropriate from the post-installation script.  The
4175           <tt><var>package</var>config</tt> program should not
4176           unquestioningly overwrite an existing configuration - if its
4177           mode of operation is geared towards setting up a package for
4178           the first time (rather than any arbitrary reconfiguration
4179           later) you should have it check whether the configuration
4180           already exists, and require a <tt>--force</tt> flag to
4181           overwrite it.</p></sect>
4182     </chapt>
4183       
4184       
4185       
4186     <chapt id="alternatives"><heading>Alternative versions of an interface -
4187         <prgn>update-alternatives</prgn>
4188       </heading>
4189
4190       <p>       
4191         When several packages all provide different versions of the
4192         same program or file it is useful to have the system select a
4193         default, but to allow the system administrator to change it
4194         and have their decisions respected.
4195       </p>
4196
4197       <p>       
4198         For example, there are several versions of the <prgn>vi</prgn>
4199         editor, and there is no reason to prevent all of them from
4200         being installed at once, each under their own name
4201         (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
4202         Nevertheless it is desirable to have the name <tt>vi</tt>
4203         refer to something, at least by default.
4204       </p>
4205
4206       <p>       
4207         If all the packages involved cooperate, this can be done with
4208         <prgn>update-alternatives</prgn>.
4209       </p>
4210
4211       <p>       
4212         Each package provides its own version under its own name, and
4213         calls <prgn>update-alternatives</prgn> in its postinst to
4214         register its version (and again in its prerm to deregister
4215         it).
4216       </p>
4217
4218       <p>       
4219         See the manpage <manref name="update-alternatives"
4220         section="8"> for details.
4221       </p>
4222
4223       <p>       
4224         If <prgn>update-alternatives</prgn> does not seem appropriate
4225         you may wish to consider using diversions instead.</p>
4226     </chapt>
4227       
4228       
4229     <chapt id="diversions"><heading>Diversions - overriding a
4230     package's version of a file
4231       </heading>
4232
4233       <p>       
4234         It is possible to have <prgn>dpkg</prgn> not overwrite a file
4235         when it reinstalls the package it belongs to, and to have it
4236         put the file from the package somewhere else instead.
4237       </p>
4238
4239       <p>       
4240         This can be used locally to override a package's version of a
4241         file, or by one package to override another's version (or
4242         provide a wrapper for it).
4243       </p>
4244
4245       <p>       
4246         Before deciding to use a diversion, read <ref
4247         id="alternatives"> to see if you really want a diversion
4248         rather than several alternative versions of a program.
4249       </p>
4250
4251       <p>       
4252         There is a diversion list, which is read by <prgn>dpkg</prgn>,
4253         and updated by a special program <prgn>dpkg-divert</prgn>.
4254         Please see <manref name="dpkg-divert" section="8"> for full
4255         details of its operation.
4256       </p>
4257
4258       <p>       
4259         When a package wishes to divert a file from another, it should
4260         call <prgn>dpkg-divert</prgn> in its preinst to add the
4261         diversion and rename the existing file.  For example,
4262         supposing that a <prgn>smailwrapper</prgn> package wishes to
4263         install a wrapper around <tt>/usr/sbin/smail</tt>:
4264         <example>
4265           if [ install = "$1" ]; then
4266           dpkg-divert --package smailwrapper --add --rename \
4267           --divert /usr/sbin/smail.real /usr/sbin/smail
4268           fi
4269         </example> Testing <tt>$1</tt> is necessary so that the script
4270         doesn't try to add the diversion again when
4271         <prgn>smailwrapper</prgn> is upgraded.  The <tt>--package
4272         smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
4273         copy of <tt>/usr/sbin/smail</tt> can bypass the diversion and
4274         get installed as the true version.
4275       </p>
4276
4277       <p>       
4278         The postrm has to do the reverse:
4279         <example>
4280           if [ remove = "$1" ]; then
4281           dpkg-divert --package smailwrapper --remove --rename \
4282           --divert /usr/sbin/smail.real /usr/sbin/smail
4283           fi
4284         </example>
4285       </p>
4286
4287       <p>       
4288         Do not attempt to divert a file which is vitally important for
4289         the system's operation - when using <prgn>dpkg-divert</prgn>
4290         there is a time, after it has been diverted but before
4291         <prgn>dpkg</prgn> has installed the new version, when the file
4292         does not exist.</p>
4293     </chapt>
4294       
4295       
4296     <chapt id="sharedlibs"><heading>Shared libraries
4297       </heading>
4298
4299       <p>       
4300         Packages containing shared libraries must be constructed with
4301         a little care to make sure that the shared library is always
4302         available.  This is especially important for packages whose
4303         shared libraries are vitally important, such as the libc.
4304       </p>
4305
4306       <p>       
4307         Firstly, your package should install the shared libraries
4308         under their normal names.  For example, the
4309         <prgn>libgdbm1</prgn> package should install
4310         <tt>libgdbm.so.1.7.3</tt> as
4311         <tt>/usr/lib/libgdbm.so.1.7.3</tt>.  The files should not be
4312         renamed or relinked by any prerm or postrm scripts;
4313         <prgn>dpkg</prgn> will take care of renaming things safely
4314         without affecting running programs, and attempts to interfere
4315         with this are likely to lead to problems.
4316       </p>
4317
4318       <p>       
4319         Secondly, your package should include the symlink that
4320         <prgn>ldconfig</prgn> would create for the shared libraries.
4321         For example, the <prgn>libgdbm1</prgn> package should include
4322         a symlink from <tt>/usr/lib/libgdbm.so.1</tt> to
4323         <tt>libgdbm.so.1.7.3</tt>.  This is needed so that
4324         <prgn>ld.so</prgn> can find the library in between the time
4325         <prgn>dpkg</prgn> installs it and <prgn>ldconfig</prgn> is run
4326         in the <prgn>postinst</prgn> script.  Futhermore, and <em>this
4327         is very important</em>, the library must be placed before the
4328         symlink pointing to it in the <tt>.deb</tt> file.  This is so
4329         that by the time <prgn>dpkg</prgn> comes to install the
4330         symlink (overwriting the previous symlink pointing at an older
4331         version of the library) the new shared library is already in
4332         place.  Currently the way to ensure the ordering is done
4333         properly is to install the library in the appropriate
4334         <tt>debian/tmp/.../lib</tt> directory before creating the
4335         symlink, by putting the commands in the <tt>debian/rules</tt>
4336         in the appropriate order.
4337       </p>
4338
4339         <!--
4340         next Paragraph added to close Bug #5299, Guy Maor
4341         -->
4342         
4343       <p>       
4344         Thirdly, the development package should contain a symlink for
4345         the shared library without a version number.  For example, the
4346         <tt>libgdbm1-dev</tt> package should include a symlink from
4347         <tt>/usr/lib/libgdm.so</tt> to <tt>libgdm.so.1.7.3</tt>.  This
4348         symlink is needed by <prgn>ld</prgn> when compiling packages
4349         as it will only look for <tt>libgdm.so</tt> and
4350         <tt>libgdm.a</tt> when compiling dynamically or statically,
4351         respectively.
4352       </p>
4353
4354         <!--
4355         next paragraph changed by Christian Schwarz (see policy weekly #6)
4356         -->
4357         
4358       <p>       
4359         Any package installing shared libraries in a directory that's listed
4360         in <tt>/etc/ld.so.conf</tt> or in one of the default library
4361         directories of <prgn>ld.so</prgn> (currently, these are <tt>/usr/lib</tt>
4362         and <tt>/lib</tt>) must call <prgn>ldconfig</prgn> in its <prgn>postinst</prgn>
4363         script if and only if the first argument is `configure'. However, it
4364         is important not to call <prgn>ldconfig</prgn> in the postrm or preinst
4365         scripts in the case where the package is being upgraded (see <ref
4366                                                                           id="unpackphase">), as <prgn>ldconfig</prgn> will see the temporary names
4367         that <prgn>dpkg</prgn> uses for the files while it is
4368         installing them and will make the shared library links point
4369         to them, just before <prgn>dpkg</prgn> continues the
4370         installation and removes the links!
4371       </p>
4372
4373         <!-- 
4374         moved from section 2.2 , DMorris 
4375         -->
4376         
4377       <sect id="shlibs"><heading>The <tt>shlibs</tt> File Format
4378         </heading>
4379
4380         <p>       
4381           This file is for use by <prgn>dpkg-shlibdeps</prgn> and is
4382           required when your package provides shared libraries.
4383         </p>
4384
4385         <p>       
4386           Each line is of the form:
4387           <example>
4388             <var>library-name</var> <var>version-or-soname</var> <var>dependencies ...</var>
4389           </example>
4390         </p>
4391
4392         <p>       
4393           <var>library-name</var> is the name of the shared library,
4394           for example <tt>libc5</tt>.
4395         </p>
4396
4397         <p>       
4398           <var>version-or-soname</var> is the soname of the library -
4399           ie, the thing that must exactly match for the library to be
4400           recognised by <prgn>ld.so</prgn>.  Usually this is major
4401           version number of the library.
4402         </p>
4403
4404         <p>       
4405           <var>dependencies</var> has the same syntax as a dependency
4406           field in a binary package control file.  It should give
4407           details of which package(s) are required to satisfy a binary
4408           built against the version of the library contained in the
4409           package.  See <ref id="depsyntax">.
4410         </p>
4411
4412         <p>       
4413           For example, if the package <tt>foo</tt> contains
4414           <tt>libfoo.so.1.2.3</tt>, where the soname of the library is
4415           <tt>libfoo.so.1</tt>, and the first version of the package
4416           which contained a minor number of at least <tt>2.3</tt> was
4417           <var>1.2.3-1</var>, then the package's <var>shlibs</var>
4418           could say:
4419           <example>
4420             libfoo 1    foo (>= 1.2.3-1)
4421           </example>
4422         </p>
4423
4424         <p>       
4425           The version-specific dependency is to avoid warnings from
4426           <prgn>ld.so</prgn> about using older shared libraries with
4427           newer binaries.</p>
4428       </sect>
4429         
4430       <sect><heading>Further Technical information on
4431           <tt>shlibs</tt></heading>
4432
4433         
4434         <!-- 
4435         following section mostly provided by Heiko Schlittermann
4436         edited by DMorris
4437         -->
4438         
4439         <sect1><heading><em>What</em> are the <tt>shlibs</tt> files?
4440           </heading>
4441
4442           <p>       
4443             The <tt>debian/shlibs</tt> file provides a way of checking
4444             for shared library dependencies on packaged binaries.
4445             They are intended to be used by package maintainers to
4446             make their lives easier.
4447           </p>
4448
4449           <p>       
4450             Other <tt>shlibs</tt> files that exist on a Debian system are
4451             <list>
4452               <item> <p><tt>/etc/dpkg/shlibs.default</tt></p></item>
4453               <item> <p><tt>/etc/dpkg/shlibs.override</tt></p></item>
4454               <item> <p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
4455               <item> <p><tt>debian/shlibs.local</tt></p></item>
4456             </list> 
4457             These files are used by <prgn>dpkg-shlibdeps</prgn> when
4458             creating a binary package.</p>
4459         </sect1>
4460           
4461         <sect1><heading><em>How</em> does <prgn>dpkg-shlibdeps</prgn>
4462         work?
4463           </heading>
4464
4465           <p>       
4466             <prgn>dpkg-shlibdeps</prgn> calls <prgn>ldd</prgn> to
4467             determine the shared libraries used by the compiled
4468             binaries passed through its command line.
4469           </p>
4470
4471           <p>       
4472             For each shared library, <prgn>dpkg-shlibdeps</prgn> needs to know 
4473             <list compact="compact">
4474               <item><p>the package containing the library, and</p></item>
4475               <item><p>the library version number,</p></item>
4476
4477             </list>       <p>
4478             it scans the following files in this order.
4479             <enumlist compact="compact">
4480               <item><p><tt>debian/shlibs.local</tt></p></item>
4481               <item><p><tt>/etc/dpkg/shlibs.override</tt></p></item>
4482               <item><p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
4483               <item><p><tt>/etc/dpkg/shlibs.default</tt></p></item>
4484             </enumlist></p>
4485         </sect1>
4486           
4487         <sect1><heading><em>Who</em> maintains the various
4488         <tt>shlibs</tt> files?
4489           </heading>
4490
4491           <p>       
4492             <list compact="compact">
4493               <item>
4494                 <p><tt>/etc/dpkg/shlibs.default</tt> - the maintainer
4495                   of dpkg</p>
4496               </item>
4497               <item>
4498                 <p>
4499                   <tt>/var/lib/dpkg/info/<var>package</var>.shlibs</tt>
4500                   - the maintainer of each package</p>
4501               </item>
4502               <item>
4503                 <p>
4504                   <tt>/etc/dpkg/shlibs.override</tt> - the local
4505                   system administrator</p>
4506               </item>
4507               <item>
4508                 <p><tt>debian/shlibs.local</tt> - the maintainer of
4509                 the package
4510                 </p>
4511               </item> 
4512             </list> 
4513             The <tt>shlibs.default</tt> file is managed by
4514             <prgn>dpkg</prgn>. The entries in <tt>shlibs.default</tt>
4515             that are provided by <prgn>dpkg</prgn> are just there to
4516             fix things until the shared library packages all have
4517             <tt>shlibs</tt> files.
4518           </p>
4519         </sect1>
4520
4521         <sect1><heading><em>How</em> to use <prgn>dpkg-shlibdeps</prgn> and
4522             the <tt>shlibs</tt> files?
4523           </heading>
4524             
4525           <sect2><heading>If your package doesn't provide a shared
4526           library
4527             </heading>
4528
4529             <p>       
4530               Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4531               <tt>debian/rules</tt> file.  If your package contains
4532               only binaries (e.g. no scripts) use:
4533               <example>
4534                 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/*
4535               </example>
4536               If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4537               done. If it does complain you might need to create your
4538               own <tt>debian/shlibs.local</tt> file.</p>
4539           </sect2>
4540
4541           <sect2><heading>If your package provides a shared library
4542             </heading>
4543
4544             <p>       
4545               Create a <tt>debian/shlibs</tt> file and let
4546               <tt>debian/rules</tt> install it in the control area:           
4547               <example>
4548                 install -m644 debian/shlibs debian/tmp/DEBIAN
4549               </example>
4550               If your package contains additional binaries see above.
4551             </p>
4552           </sect2>
4553         </sect1>
4554
4555         <sect1><heading><em>How</em> to write
4556         <tt>debian/shlibs.local</tt>
4557           </heading>
4558
4559           <p>       
4560             This file is intended only as a <em>temporary</em> fix if
4561             your binaries depend on a library which doesn't provide
4562             its own <tt>/var/lib/dpkg/*.shlibs</tt> file yet.
4563           </p>
4564
4565           <p>       
4566             Let's assume you are packaging a binary <tt>foo</tt>. Your
4567             output in building the package might look like this.            
4568             <example>
4569               $ ldd foo
4570               libbar.so.1 => /usr/X11R6/lib/libbar.so.1.0
4571               libc.so.5 => /lib/libc.so.5.2.18
4572               libX11.so.6 => /usr/X11R6/lib/libX11.so.6.0
4573             </example>
4574             And when you ran <prgn>dpkg-shlibdeps</prgn>
4575             <example>
4576               $ dpkg-shlibdeps -o foo
4577               dpkg-shlibdeps: warning: unable to find dependency information 
4578               for shared library libbar 
4579               (soname 1, path /usr/X11R6/lib/libbar.so.1.0, dependency field Depends)
4580               shlibs:Depends=elf-x11r6lib, libc5 (>= 5.2.18)
4581             </example>
4582             The <prgn>foo</prgn> binary depends on the
4583             <prgn>libbar</prgn> shared library, but no package seems
4584             to provide a <tt>*.shlibs</tt> file in
4585             <tt></tt>var/lib/dpkg/info/.  Let's determine the package
4586             responsible:
4587           </p>
4588
4589           <p>
4590             <example>
4591               $ dpkg -S /usr/X11R6/lib/libbar.so.1.0
4592               bar1: /usr/X11R6/lib/libbar.so.1.0
4593               $ dpkg -s bar1 | grep Version
4594               Version: 1.0-1
4595             </example>
4596             This tells us that the <prgn>bar1</prgn> package, version
4597             1.0-1 is the one we are using. Now we can create our own
4598             <tt>debian/shlibs.local</tt> to temporarly fix the above
4599             problem. Include the following line into your
4600             <tt>debian/shlibs.local</tt> file.
4601             <example>
4602               libbar 1 bar1 (>= 1.0-1)
4603             </example>
4604             Now your package build should work. As soon as the
4605             maintainer of <prgn>libbar1</prgn> provides a
4606             <tt>shlibs</tt> file, you can remove your
4607             <tt>debian/shlibs.local</tt> file.
4608           </p>
4609         </sect1>
4610       </sect>
4611     </chapt>
4612
4613     <chapt id="methif"><heading><prgn>dselect</prgn>'s interface to
4614     its installation methods
4615       </heading>
4616
4617       <p>       
4618         <prgn>dselect</prgn> calls scripts from its installation
4619         methods when it needs to actually access data from the
4620         distribution.  The core program <prgn>dselect</prgn> itself
4621         just calls these scripts and provides the package and access
4622         method selection interfaces.  The installation methods are
4623         responsible for invoking <prgn>dpkg</prgn> as appropriate.
4624       </p>
4625
4626       <p>       
4627         Each installation method has three scripts:
4628         <list compact="compact">
4629           <item><p>Setup installation parameters.</p></item>
4630           <item><p>Update list of available packages.</p></item>
4631           <item><p>Install.</p></item>
4632         </list>
4633
4634       <p>       
4635         <prgn>dselect</prgn> searches for methods in
4636         <tt>/usr/lib/dpkg/methods</tt> and
4637         <tt>/usr/local/lib/dpkg/methods</tt>.
4638       </p>
4639         
4640       <sect><heading>Functions of the method scripts
4641         </heading>
4642
4643         <p>       
4644           The setup script is run just after the user has chosen an
4645           installation method.  It should prompt the user for
4646           parameters like the site to NFS-mount or FTP from, the
4647           directory to use, or the directory or filesystem where the
4648           <tt>.deb</tt> files can be found, or the tape or floppy
4649           device to install from.  It should store the responses under
4650           <tt>/var/lib/dpkg/methods</tt> - see below.  If no available
4651           packages list is available it should perhaps offer to scan
4652           the available packages.
4653         </p>
4654
4655         <p>       
4656           The update script should obtain a list of available packages
4657           if possible, and run <tt>dpkg --update-avail</tt>, <tt>dpkg
4658           --merge-avail</tt> and/or <tt>dpkg --forget-old-unavail</tt>
4659           to load it into <prgn>dpkg</prgn> and <prgn>dselect</prgn>'s
4660           database of available packages.  If no packages list was
4661           available and the user was offered and accepted the option
4662           of scanning the actual files available this scan should be
4663           done here, using <tt>dpkg --record-avail</tt>.
4664         </p>
4665
4666         <p>       
4667           The install script should feed all the available
4668           <tt>.deb</tt> files to <tt>dpkg --iGOEB</tt> (this is
4669           equivalent to <tt>dpkg --install
4670             --refuse-downgrade --selected-only --skip-same-version
4671             --auto-deconfigure</tt>).  The <tt>-R</tt>
4672           (<tt>--recursive</tt>) option for traversing subdirectories
4673           may also be useful here).
4674         </p>
4675
4676         <p>       
4677           If any of these scripts needs to display a message for the
4678           user, it should wait for the user to hit `return' before
4679           exiting so that dselect doesn't immediately rewrite the
4680           screen.
4681         </p>
4682
4683         <p>       
4684           If a method script succeeds (returns a zero exit status)
4685           <prgn>dselect</prgn> will return immediately to the main
4686           menu, with the `next' option highlighted ready for the user
4687           to select it.  If it fails <prgn>dselect</prgn> will display
4688           a message and wait for the user to hit return.</p>
4689       </sect>
4690         
4691       <sect><heading>Location and arguments of the method scripts
4692         </heading>
4693
4694         <p>       
4695           A set of scripts (henceforth known as a group) may provide
4696           several methods on the `main menu' with different behaviour.
4697           For example, there might be a generic get-packages-by-FTP
4698           group which might provide methods in the main menu for
4699           installation directly from one of the Debian mirror sites as
4700           well as for installation from a user-specified site.
4701         </p>
4702
4703         <p>       
4704           Each group of methods implemented by the same set of scripts
4705           should have a subdirectory
4706           <tt>/usr/lib/dpkg/methods/<var>group</var></tt> or
4707           <tt>/usr/local/lib/dpkg/methods/<var>group</var></tt>,
4708           containing:
4709           <taglist compact="compact">
4710             <tag><tt>names</tt></tag>
4711             <item><p>a list of user-visible methods provided by these scripts.</p>
4712             </item>
4713             <tag><tt>setup</tt></tag>
4714             <tag><tt>update</tt></tag>
4715             <tag><tt>install</tt></tag>
4716             <item><p>executable programs, the scripts themselves.</p>
4717             </item>
4718             <tag><tt>desc.<var>option</var></tt></tag>
4719             <item><p>description file.</p></item>
4720           </taglist>
4721         </p>
4722
4723         <p>       
4724           <tt>names</tt> will be formatted as a list of lines, each containing:
4725           <example>
4726             <var>sequence</var> <var>method</var> <var>summary</var>
4727           </example>
4728         </p>
4729         <p>       
4730           <var>sequence</var> is a two-digit number that will be used
4731           much like <tt>rc.d</tt> prefixes to control the order in the
4732           main menu.  If in doubt use 50.
4733         </p>
4734
4735         <p>       
4736           <var>method</var> is a name which is displayed by
4737           <prgn>dselect</prgn> as the name of the method, and which
4738           will be passed to <tt>setup</tt>, <tt>update</tt> and
4739           <tt>unpack</tt> as their first argument.
4740         </p>
4741
4742         <p>       
4743           <var>summary</var> is the brief description string for
4744           <prgn>dselect</prgn>'s menu.
4745         </p>
4746
4747         <p>       
4748           Each of the three scripts gets the same three arguments:
4749           <var>vardir</var>, <var>group</var> and <var>method</var>.
4750           <var>vardir</var> is the base directory for storing
4751           <prgn>dpkg</prgn> and <prgn>dselect</prgn>'s state, usually
4752           <tt>/var/lib/dpkg</tt>; this is passed in so that the
4753           <tt>--admindir</tt> option to <prgn>dselect</prgn> is
4754           honoured).
4755         </p>
4756
4757         <p>       
4758           Each option may have an extended description in
4759           <tt>desc.<var>option</var></tt>.  This should be formatted
4760           like the extended description part of a <tt>Description</tt>
4761           field entry <em>shifted one character to the left</em>.
4762         </p>
4763
4764         <p>       
4765           <tt><var>vardir</var>/methods</tt> will exist, and a method
4766           group may use a
4767           <tt><var>vardir</var>/methods/<var>group</var></tt>
4768           directory to store its state.
4769         </p>
4770
4771         <p>       
4772           The group name and method name must follow the rules for C
4773           identifiers.
4774         </p>
4775       </sect>
4776     </chapt>
4777       
4778     <chapt id="conversion"><heading>Conversion procedure from old
4779     source packages
4780       </heading>
4781
4782       <p>       
4783         This is a brief summary of the procedure for converting a
4784         pre-2.0.0.0-format source package into the new format.
4785       </p>
4786
4787       <p>       
4788         You are strongly advised to download and examine the <prgn>hello</prgn>
4789         package, and to read the section in the <prgn>dpkg</prgn> programmers'
4790         manual describing the source packaging tools.  More detail about the
4791         exact functionality of these tools is available in 
4792         <manref name="dpkg-source"  section="1">.
4793       </p>
4794
4795       <p>       
4796         <list>
4797           <item>
4798             <p>
4799               Download the original source code from wherever it can
4800               be found and do any rearrangement required to make it
4801               look like the original tree of the Debian source.  Put
4802               it in
4803               <tt><var>package</var>-<var>upstream-version</var>.orig/</tt>
4804               or
4805               <tt><var>package</var>_<var>upstream-version</var>.orig.tar.gz</tt>.
4806             </p>
4807           </item>
4808           
4809           <item>
4810             <p>
4811               Rename all files <tt>debian.*</tt> to <tt>debian/*</tt>.
4812               There may be some exceptions to this, but this is a good
4813               start.</p>
4814           </item>
4815
4816           <item>
4817             <p>
4818               Edit the <tt>debian/changelog</tt> - create or rename it
4819               if necessary.  Add a new revision to the top with the
4820               appropriate details, and a local variables entry to the
4821               bottom to set Emacs to the right mode:
4822               <example>
4823                 Local variables:
4824                 mode: debian-changelog
4825                 End:
4826               </example>
4827             </p>
4828           </item>
4829           
4830           <item>
4831             <p>
4832               Edit/create <tt>debian/control</tt>:
4833               <list compact="compact">
4834                 <item>
4835                   <p>
4836                     Remove the <tt>Version</tt> field.  If it is
4837                     generated unusually (not equal to the source
4838                     version) you must use the -v option to
4839                     dpkg-gencontrol (see below).  <tt>Section</tt>,
4840                     <tt>Priority</tt>, <tt>Maintainer</tt> go above
4841                     the first blank line, most of the rest
4842                     below.
4843                   </p>
4844                 </item>
4845                 
4846                 <item>
4847                   <p>
4848                     Reorder the fields and add a blank line at an
4849                     appropriate point, separating the source package
4850                     fields from the binary package fields.
4851                   </p>
4852                 </item>
4853                 
4854                 <item>
4855                   <p>Add the <tt>Source</tt> field.</p></item>
4856                 
4857                 <item>
4858                   <p>
4859                     Add the <tt>Standards-Version</tt> field.  (Please
4860                     check out the Debian Policy Manual for details
4861                     about this field.)</p>
4862                 </item>
4863                 
4864                 <item>
4865                   <p>
4866                     Change the <tt>Architecture</tt> field for each
4867                     package to <tt>any</tt>, <tt>all</tt> or whatever.
4868                     If there isn't an <tt>Architecture</tt> field add
4869                     one.</p>
4870                 </item>
4871                 
4872                 <item>
4873                   <p>
4874                     If any other use of sed or things used to happen
4875                     to make the binary control files use
4876                     <prgn>dpkg-gencontrol</prgn>'s variable
4877                     substitution features to achieve the same effect.
4878                     Use <tt>debian/substvars</tt> if you need to put
4879                     unusally-generated information (apart from details
4880                     of <tt>.deb</tt> files) in the <tt>.changes</tt>
4881                     file too.</p>
4882                 </item>
4883               </list>
4884             </p>
4885           </item>
4886           
4887           <item>
4888             <p>Edit the <tt>debian/rules</tt>:
4889               <list compact="compact">
4890                 <item>
4891                   <p>
4892                     Remove the <prgn>source</prgn> and
4893                     <prgn>diff</prgn> and any <prgn>changes</prgn> and
4894                     <prgn>dist</prgn> targets.  These things now
4895                     happen in a package-independent way and are not
4896                     done by <tt>debian/rules</tt>.</p>
4897                 </item>
4898                 <item>
4899                   <p>
4900                     Split the <prgn>binary</prgn> target into
4901                     <prgn>binary-arch</prgn> and
4902                     <prgn>binary-indep</prgn>; in many cases all of
4903                     <prgn>binary</prgn> should go into
4904                     <prgn>binary-arch</prgn>.  Create the
4905                     <prgn>binary</prgn> target and the unused of the
4906                     two other <prgn>binary-*</prgn> targets if there
4907                     is one - you can copy the ones from the
4908                     <prgn>hello</prgn> package.</p>
4909                 </item>
4910                 <item>
4911                   <p>
4912                     Change the <prgn>binary</prgn> target to use
4913                     <prgn>dpkg-gencontrol</prgn> to make the package
4914                     control file(s).  Move it to after all the files
4915                     have been installed but just before the last
4916                     <prgn>chown</prgn> and <prgn>chmod</prgn> in the
4917                     target.</p>
4918                 </item>
4919                 <item>
4920                   <p>
4921                     Change occurrences of <tt>debian-tmp</tt> to
4922                     <tt>debian/tmp</tt>.</p>
4923                 </item>
4924                 <item>
4925                   <p>
4926                     Change occurrences of
4927                     <tt>debian.{post,pre}{inst,rm}</tt> to
4928                     <tt>debian/*</tt>.</p>
4929                 </item>
4930                 <item>
4931                   <p>
4932                     Remove the version number setting at the top, if
4933                     there is one.</p>
4934                 </item>
4935                 <item>
4936                   <p>
4937                     Ensure that the package's Debian-specific and
4938                     upstream changelogs are installed.</p>
4939                 </item>
4940               </list>
4941             </p>
4942           </item>
4943           
4944           <item>
4945             <p>
4946               Change the package to use <prgn>dpkg-shlibdeps</prgn> to
4947               determine its shared library dependencies and substitute
4948               them in.  Shared library dependencies should no longer
4949               be hardwired in the source package.</p>
4950           </item>
4951           
4952           <item>
4953             <p>
4954               Check that the <tt>debian/README</tt> is really the
4955               copyright file, and if so rename it to
4956               <tt>debian/copyright</tt> and edit <tt>debian/rules</tt>
4957               to cope with this and to change the installation of the
4958               copyright file from
4959               <tt>/usr/doc/<var>package</var>/copyright</tt> to
4960               <tt>/usr/doc/copyright/<var>package</var></tt>.  If it
4961               isn't then find <tt>debian/copyright</tt> and decide
4962               what to do with the <tt>README</tt>.</p>
4963           </item>
4964           
4965           <item>
4966             <p>Check for various other anachronisms and problems:
4967               <list compact="compact">
4968                 <item>
4969                   <p>
4970                     Remove any <tt>Package_Revision</tt>,
4971                     <tt>Package-Revision</tt> or <tt>Revision</tt>
4972                     fields.</p>
4973                 </item>
4974                 <item>
4975                   <p>
4976                     Rename <tt>Optional</tt> to <tt>Suggests</tt>,
4977                     <tt>Recommended</tt> to
4978                     <tt>Recommends</tt>.</p>
4979                 </item>
4980                 <item>
4981                   <p>
4982                     Change
4983                     <tt>/usr/doc/examples/<var>package</var></tt> to
4984                     <tt>/usr/doc/<var>package</var>/examples</tt>.</p>
4985                 </item>
4986                 <item>
4987                   <p>
4988                     Make sure that manpages are installed
4989                     compressed.</p>
4990                 </item>
4991                 <item>
4992                   <p>
4993                     Check that the description has an extended
4994                     description, is well-formatted and meaningful and
4995                     helpful to people wanting to know whether to
4996                     install a package.</p>
4997                 </item>
4998               </list>
4999             </p>
5000           </item>
5001           
5002           <item>
5003             <p>Look everything over.</p></item>
5004           
5005           <item>
5006             <p>
5007               Do a test build using <tt>dpkg-buildpackage -us -uc -sa
5008                 -r<var>whatever</var></tt>.  Check the permissions and
5009               locations of files in the resulting package by examining
5010               the output of <tt>dpkg-deb --contents</tt>, and check
5011               that the source build happened OK.  Test install the
5012               binary package(s) and test extract the source
5013               package(s).</p>
5014           </item>
5015           
5016           <item>
5017             <p>
5018               Sign the release: either rebuild everything with
5019               <tt>dpkg-buildpackage -sa</tt>, or PGP-sign the
5020               <tt>.dsc</tt>, rebuild the <tt>.changes</tt> using
5021               <tt>dpkg-genchanges -sa</tt>, and then PGP-sign the
5022               <tt>.changes</tt>.</p>
5023           </item>
5024           
5025         </list>
5026       </p>
5027
5028       <p>       
5029         The use of <tt>-sa</tt> on <prgn>dpkg-buildpackage</prgn> and
5030         <prgn>dpkg-genchanges</prgn> is important when doing the first
5031         build/uploading of a new-format source package.  Unless this
5032         happens to be Debian revision <tt>0</tt> or <tt>1</tt> by
5033         default the original source tarfile will not be included in
5034         the uploaded files listed in the <tt>.changes</tt> file, and
5035         so it won't be installed on the FTP site.  <tt>-sa</tt>
5036         requests that the original source be included
5037         regardless.</p>
5038     </chapt>
5039     
5040   </book>
5041 </debiandoc>
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063