]> git.donarmstrong.com Git - debian/debian-policy.git/blob - packaging.sgml
Initial revision
[debian/debian-policy.git] / packaging.sgml
1 <!doctype debiandoc system>
2
3 <!--
4  Debian GNU/Linux Packaging Manual.
5  Copyright (C)1996 Ian Jackson; released under the terms of the GNU
6  General Public License, version 2 or (at your option) any later.
7  Revised: David A. Morris (bweaver@debian.org)
8  Maintainer since 1998, Christian Schwarz <schwarz@debian.org>
9  -->
10
11 <book>
12
13 <title>Debian Packaging Manual
14 <author>Ian Jackson <email/ijackson@gnu.ai.mit.edu/
15 <author>Revised: David A. Morris <email/bweaver@debian.org/
16 <author>Maintainer: Christian Schwarz <email/schwarz@debian.org/
17 <version>version 2.4.1.0, 14 April 1998
18
19 <abstract>
20 This manual describes the technical aspects of creating Debian binary
21 and source packages.  It also documents the interface between
22 <prgn/dselect/ and its access method scripts.  It does not deal with
23 the Debian Project policy requirements, and it assumes familiarity
24 with <prgn/dpkg/'s functions from the system administrator's
25 perspective.
26
27 <copyright>Copyright &copy;1996 Ian Jackson.
28 <p>
29
30 This manual is free software; you may redistribute it and/or modify it
31 under the terms of the GNU General Public License as published by the
32 Free Software Foundation; either version 2, or (at your option) any
33 later version.
34 <p>
35
36 This is distributed in the hope that it will be useful, but
37 <em>without any warranty</em>; without even the implied warranty of
38 merchantability or fitness for a particular purpose.  See the GNU
39 General Public License for more details.
40 <p>
41
42 A copy of the GNU General Public License is available as
43 <tt>/usr/doc/copyright/GPL</tt> in the Debian GNU/Linux
44 distribution or on the World Wide Web at
45 <tt>http://www.gnu.org/copyleft/gpl.html</tt>. You can also obtain it
46 by writing to the Free Software Foundation, Inc., 59 Temple Place -
47 Suite 330, Boston, MA 02111-1307, USA.
48 <p>
49
50 <toc sect>
51
52 <!-- Describes the technical interface between a package and dpkg.
53
54 How to safely put shared libraries in a package.  Details of dpkg's
55 handling of individual files.  Sections on when to use which feature
56 (eg Replaces vs. Replaces/Conflicts vs. update-alternatives
57 vs. diversions) Cross-references to the policy document (see below)
58 where appropriate.  Description of the interface between dselect and
59 its access methods.  Hints on where to start with a new package (ie,
60 the hello package).  What to do about file aliasing.
61
62 file aliasing
63
64 Manpages are required for: update-rc.d, diversions,
65 update-alternatives, install-info in a package.
66
67 -->
68
69 <chapt id="scope">Introduction and scope of this manual
70 <p>
71
72 <prgn/dpkg/ is a suite of programs for creating binary package files
73 and installing and removing them on Unix systems.<footnote><prgn/dpkg/
74 is targetted primarily at Debian GNU/Linux, but may work on or be
75 ported to other systems.</footnote>
76 <p>
77
78 The binary packages are designed for the management of installed
79 executable programs (usually compiled binaries) and their associated
80 data, though source code examples and documentation are provided as
81 part of some packages.
82 <p>
83
84 This manual describes the technical aspects of creating Debian binary
85 packages (<tt/.deb/ files).  It documents the behaviour of the
86 package management programs <prgn/dpkg/, <prgn/dselect/ et al. and and the
87 way they interact with packages.
88 <p>
89
90 It also documents the interaction between <prgn/dselect/'s core and the
91 access method scripts it uses to actually install the selected
92 packages, and describes how to create a new access method.
93 <p>
94
95 This manual does not go into detail about the options and usage of the
96 package building and installation tools.  It should therefore be read
97 in conjuction with those programs' manpages.
98 <p>
99
100 The utility programs which are provided with <prgn/dpkg/ for managing
101 various system configuration and similar issues, such as
102 <prgn/update-rc.d/ and <prgn/install-info/, are not described in
103 detail here - please see their manpages.
104 <p>
105
106 It does <em/not/ describe the policy requirements imposed on Debian
107 packages, such as the permissions on files and directories,
108 documentation requirements, upload procedure, and so on.  You should
109 see the Debian packaging policy manual for these details.  (Many of
110 them will probably turn out to be helpful even if you don't plan to
111 upload your package and make it available as part of the
112 distribution.)
113 <p>
114
115 It is assumed that the reader is reasonably familiar with the
116 <prgn/dpkg/ System Administrators' manual.  Unfortunately this manual
117 does not yet exist.
118 <p>
119
120 The Debian version of the FSF's GNU hello program is provided as an
121 example for people wishing to create Debian packages. The Debian
122 <prgn/debmake/ package is recommended as a very helpful tool in
123 creating and maintaining Debian packages. However, while the tools and
124 examples are helpful, they do not replace the need to read and follow
125 the Policy and Programmer's Manual.
126
127 <chapt id="binarypkg">Binary packages
128 <p>
129
130 The binary package has two main sections.  The first part consists of
131 various control information files and scripts used by <prgn/dpkg/ when
132 installing and removing.  See <ref id="controlarea">.
133 <p>
134
135 The second part is an archive containing the files and directories to
136 be installed. 
137 <p>
138
139 In the future binary packages may also contain other components, such
140 as checksums and digital signatures. The format for the archive is
141 described in full in the <tt>deb(5)</> manpage.
142
143
144 <sect id="bincreating">Creating package files - <prgn/dpkg-deb/
145 <p>
146
147 All manipulation of binary package files is done by <prgn/dpkg-deb/;
148 it's the only program that has knowledge of the format.
149 (<prgn/dpkg-deb/ may be invoked by calling <prgn/dpkg/, as <prgn/dpkg/ will
150 spot that the options requested are appropriate to <prgn/dpkg-deb/ and
151 invoke that instead with the same arguments.)
152 <p>
153
154 In order to create a binary package you must make a directory tree
155 which contains all the files and directories you want to have in the
156 filesystem data part of the package.  In Debian-format source packages
157 this directory is usually <tt>debian/tmp</tt>, relative to the top of
158 the package's source tree.
159 <p>
160
161 They should have the locations (relative to the root of the directory
162 tree you're constructing) ownerships and permissions which you want
163 them to have on the system when they are installed.
164 <p>
165
166 With current versions of <prgn/dpkg/ the uid/username and gid/groupname
167 mappings for the users and groups being used should be the same on the
168 system where the package is built and the one where it is installed.
169 <p>
170
171 You need to add one special directory to the root of the miniature
172 filesystem tree you're creating: <prgn/DEBIAN/.  It should contain the
173 control information files, notably the binary package control file
174 (see <ref id="controlfile">).
175 <p>
176
177 The <prgn/DEBIAN/ directory will not appear in the filesystem archive of
178 the package, and so won't be installed by <prgn/dpkg/ when the package
179 is installed.
180 <p>
181
182 When you've prepared the package, you should invoke:
183 <example>
184 dpkg --build <var/directory/
185 </example>
186 <p>
187
188 This will build the package in <tt/<var/directory/.deb/.
189 (<prgn/dpkg/ knows that <tt/--build/ is a <prgn/dpkg-deb/ option, so it
190 invokes <prgn/dpkg-deb/ with the same arguments to build the package.)
191 <p>
192
193 See the manpage <manref name="dpkg-deb" section=8> for details of how
194 to examine the contents of this newly-created file.  You may find the
195 output of following commands enlightening:
196 <example>
197 dpkg-deb --info <var/filename/.deb
198 dpkg-deb --contents <var/filename/.deb
199 dpkg --contents <var/filename/.deb
200 </example>
201 To view the copyright file for a package you could use this command:
202 <example>
203 dpkg --fsys-tarfile <var/filename/.deb | tar xof usr/doc/<var/\*/copyright | less
204 </example>
205
206 <sect id="controlarea">Package control information files
207 <p>
208
209 The control information portion of a binary package is a collection of
210 files with names known to <prgn/dpkg/.  It will treat the contents of
211 these files specially - some of them contain information used by
212 <prgn/dpkg/ when installing or removing the package; others are scripts
213 which the package maintainer wants <prgn/dpkg/ to run.
214 <p>
215
216 It is possible to put other files in the package control area, but
217 this is not generally a good idea (though they will largely be
218 ignored).
219 <p>
220
221 Here is a brief list of the control info files supported by <prgn/dpkg/
222 and a summary of what they're used for.
223 <p>
224
225 <taglist>
226 <tag><tt/control/
227 <item>
228
229 This is the key description file used by <prgn/dpkg/.  It specifies the
230 package's name and version, gives its description for the user, states
231 its relationships with other packages, and so forth.
232 See <ref id="controlfile">.
233 <p>
234
235 It is usually generated automatically from information in the source
236 package by the <prgn/dpkg-gencontrol/ program, and with assistance
237 from <prgn/dpkg-shlibdeps/.  See <ref id="sourcetools">.
238
239 <tag><tt/postinst/, <tt/preinst/, <tt/postrm/, <tt/prerm/
240 <item>
241
242 These are exectuable files (usually scripts) which <prgn/dpkg/ runs
243 during installation, upgrade and removal of packages.  They allow the
244 package to deal with matters which are particular to that package or
245 require more complicated processing than that provided by <prgn/dpkg/.
246 Details of when and how they are called are in
247 <ref id="maintainerscripts">.
248 <p>
249
250 It is very important to make these scripts idempotent.<footnote>That
251 means that if it runs successfully or fails and then you call it again
252 it doesn't bomb out, but just ensures that everything is the way it
253 ought to be.</footnote>  This is so that if an error occurs, the user
254 interrupts <prgn/dpkg/ or some other unforeseen circumstance happens you
255 don't leave the user with a badly-broken package.
256 <p>
257
258 The maintainer scripts are guaranteed to run with a controlling
259 terminal and can interact with the user.  If they need to prompt for
260 passwords, do full-screen interaction or something similar you should
261 do these things to and from <tt>/dev/tty</>, since <prgn/dpkg/ will at
262 some point redirect scripts' standard input and output so that it can
263 log the installation process.  Likewise, because these scripts may be
264 executed with standard output redirected into a pipe for logging
265 purposes, Perl scripts should set unbuffered output by setting
266 <tt/$|=1/ so that the output is printed immediately rather than being
267 buffered.
268 <p>
269
270 Each script should return a zero exit status for success, or a nonzero
271 one for failure.
272
273 <tag><tt/conffiles/
274 <item>
275
276 This file contains a list of configuration files which are to be
277 handled automatically by <prgn/dpkg/ (see <ref id="conffiles">).  Note
278 that not necessarily every configuration file should be listed here.
279
280 <tag><tt/shlibs/
281 <item>
282
283 This file contains a list of the shared libraries supplied by the
284 package, with dependency details for each.  This is used by
285 <prgn/dpkg-shlibdeps/ when it determines what dependencies are
286 required in a package control file. The <tt/shlibs/ file format is 
287 described on <ref id="shlibs">.
288 <p>
289
290 </taglist>
291
292 <sect id="controlfile">The main control information file: <tt/control/
293 <p>
294
295 The most important control information file used by <prgn/dpkg/ when it
296 installs a package is <tt/control/.  It contains all the package's
297 `vital statistics'.
298 <p>
299
300 The binary package control files of packages built from Debian sources
301 are made by a special tool, <prgn/dpkg-gencontrol/, which reads
302 <tt>debian/control</> and <tt>debian/changelog</> to find the
303 information it needs.  See <ref id="sourcepkg"> for more details.
304 <p>
305
306 The fields in binary package control files are:
307 <list compact>
308
309 <item><qref id="f-Package"><tt/Package/</> (mandatory)
310 <item><qref id="versions"><tt/Version/</> (mandatory)
311
312 <item><qref id="f-Architecture"><tt/Architecture/</>
313 (mandatory)<footnote>This field should appear in all packages, though
314 <prgn/dpkg/ doesn't require it yet so that old packages can still be
315 installed.</footnote>
316
317 <item><qref id="relationships"><tt/Depends/, <tt/Provides/ et al.</>
318 <item><qref id="f-Essential"><tt/Essential/</>
319 <item><qref id="f-Maintainer"><tt/Maintainer/</>
320 <item><qref id="f-classification"><tt/Section/, <tt/Priority/</>
321 <item><qref id="f-Source"><tt/Source/</>
322 <item><qref id="descriptions"><tt/Description/</>
323 <item><qref id="f-Installed-Size"><tt/Installed-Size/</>
324
325 </list>
326 <p>
327
328 A description of the syntax of control files and the purpose of these
329 fields is available in <ref id="controlfields">.
330
331
332 <chapt id="sourcepkg">Source packages
333 <p>
334
335 The Debian binary packages in the distribution are generated from
336 Debian sources, which are in a special format to assist the easy and
337 automatic building of binaries.
338 <p>
339
340 There was a previous version of the Debian source format, which is now
341 being phased out.  Instructions for converting an old-style package
342 are given in the Debian policy manual.
343
344 <sect id="sourcetools">Tools for processing source packages
345 <p>
346
347 Various tools are provided for manipulating source packages; they pack
348 and unpack sources and help build of binary packages and help manage
349 the distribution of new versions.
350 <p>
351
352 They are introduced and typical uses described here; see <manref
353 name=dpkg-source section=1> for full documentation about their
354 arguments and operation.
355 <p>
356
357 For examples of how to construct a Debian source package, and how to
358 use those utilities that are used by Debian source packages, please
359 see the <prgn/hello/ example package.
360
361 <sect1><prgn/dpkg-source/ - packs and unpacks Debian source packages
362 <p>
363
364 This program is frequently used by hand, and is also called from
365 package-independent automated building scripts such as
366 <prgn/dpkg-buildpackage/.
367 <p>
368
369 To unpack a package it is typically invoked with
370 <example>
371 dpkg-source -x <var>.../path/to/filename</>.dsc
372 </example>
373 with the <tt/<var/filename/.tar.gz/ and
374 <tt/<var/filename/.diff.gz/ (if applicable) in the same directory.  It
375 unpacks into <tt/<var/package/-<var/version//, and if applicable
376 <tt/<var/package/-<var/version/.orig/, in the current directory.
377 <p>
378
379 To create a packed source archive it is typically invoked:
380 <example>
381 dpkg-source -b <var/package/-<var/version/
382 </example>
383 This will create the <tt/.dsc/, <tt/.tar.gz/ and <tt/.diff.gz/ (if
384 appropriate) in the current directory.  <prgn/dpkg-source/ does not
385 clean the source tree first - this must be done separately if it is
386 required.
387 <p>
388
389 See also <ref id="sourcearchives">.
390
391
392 <sect1><prgn/dpkg-buildpackage/ - overall package-building control
393 script
394 <p>
395
396 <prgn/dpkg-buildpackage/ is a script which invokes <prgn/dpkg-source/,
397 the <tt>debian/rules</> targets <prgn/clean/, <prgn/build/ and
398 <prgn/binary/, <prgn/dpkg-genchanges/ and <prgn/pgp/ to build a signed
399 source and binary package upload.
400 <p>
401
402 It is usually invoked by hand from the top level of the built or
403 unbuilt source directory.  It may be invoked with no arguments; useful
404 arguments include:
405 <taglist compact>
406 <tag><tt/-uc/, <tt/-us/
407 <item>Do not PGP-sign the <tt/.changes/ file or the source package
408 <tt/.dsc/ file, respectively.
409
410 <tag><tt/-p<var/pgp-command//
411 <item>Invoke <var/pgp-command/ instead of finding <tt/pgp/ on the
412 <prgn/PATH/.  <var/pgp-command/ must behave just like <prgn/pgp/.
413
414 <tag><tt/-r<var/root-command//
415 <item>When root privilege is required, invoke the command
416 <var/root-command/.  <var/root-command/ should invoke its first
417 argument as a command, from the <prgn/PATH/ if necessary, and pass its
418 second and subsequent arguments to the command it calls.  If no
419 <var/root-command/ is supplied then <var/dpkg-buildpackage/ will take
420 no special action to gain root privilege, so that for most packages it
421 will have to be invoked as root to start with.
422
423 <tag><tt/-b/, <tt/-B/
424 <item>Two types of binary-only build and upload - see <manref
425 name=dpkg-source section=1>.
426 </taglist>
427
428
429 <sect1><prgn/dpkg-gencontrol/ - generates binary package control files
430 <p>
431
432 This program is usually called from <tt>debian/rules</> (see <ref
433 id="sourcetree">) in the top level of the source tree.
434 <p>
435
436 This is usually done just before the files and directories in the
437 temporary directory tree where the package is being built have their
438 permissions and ownerships set and the package is constructed using
439 <prgn/dpkg-deb/<footnote>This is so that the control file which is
440 produced has the right permissions</footnote>.
441 <p>
442
443 <prgn/dpkg-gencontrol/ must be called after all the files which are to
444 go into the package have been placed in the temporary build directory,
445 so that its calculation of the installed size of a package is correct.
446 <p>
447
448 It is also necessary for <prgn/dpkg-gencontrol/ to be run after
449 <prgn/dpkg-shlibdeps/ so that the variable substitutions created by
450 <prgn/dpkg-shlibdeps/ in <tt>debian/substvars</> are available.
451 <p>
452
453 For a package which generates only one binary package, and which
454 builds it in <tt>debian/tmp</> relative to the top of the source
455 package, it is usually sufficient to call:
456 <example>
457 dpkg-gencontrol
458 </example>
459 <p>
460
461 Sources which build several binaries will typically need something
462 like:
463 <example>
464 dpkg-gencontrol -Pdebian/tmp-<var/pkg/ -p<var/package/
465 </example>
466 The <tt/-P/ tells <prgn/dpkg-gencontrol/ that the package is being
467 built in a non-default directory, and the <tt/-p/ tells it which
468 package's control file should be generated.
469 <p>
470
471 <prgn/dpkg-gencontrol/ also adds information to the list of files in
472 <tt>debian/files</>, for the benefit of (for example) a future
473 invocation of <prgn/dpkg-genchanges/.
474
475
476 <sect1><prgn/dpkg-shlibdeps/ - calculates shared library dependencies
477 <p>
478
479 This program is usually called from <tt>debian/rules</> just before
480 <prgn/dpkg-gencontrol/ (see <ref id="sourcetree">), in the top level
481 of the source tree.
482 <p>
483
484 Its arguments are executables<footnote>They may be specified either
485 in the locations in the source tree where they are created or in the
486 locations in the temporary build tree where they are installed prior
487 to binary package creation.</footnote> for which shared library
488 dependencies should be included in the binary package's control file.
489 <p>
490
491 If some of the executable(s) shared libraries should only warrant a
492 <tt/Recommends/ or <tt/Suggests/, or if some warrant a
493 <tt/Pre-Depends/, this can be achieved by using the
494 <tt/-d<var/dependency-field// option before those executable(s).
495 (Each <tt/-d/ option takes effect until the next <tt/-d/.)
496 <p>
497
498 <prgn/dpkg-shlibdeps/ does not directly cause the output control file
499 to be modified.  Instead by default it adds to the
500 <tt>debian/substvars</> file variable settings like
501 <tt/shlibs:Depends/.  These variable settings must be referenced in
502 dependency fields in the appropriate per-binary-package sections of
503 the source control file.
504 <p>
505
506 For example, the <prgn/procps/ package generates two kinds of
507 binaries, simple C binaries like <prgn/ps/ which require a
508 predependency and full-screen ncurses binaries like <prgn/top/ which
509 require only a recommendation.  It can say in its <tt>debian/rules</>:
510 <example>
511 dpkg-shlibdeps -dPre-Depends ps -dRecommends top
512 </example>
513 and then in its main control file <tt>debian/control</>:
514 <example>
515 <var/.../
516 Package: procps
517 Pre-Depends: ${shlibs:Pre-Depends}
518 Recommends: ${shlibs:Recommends}
519 <var/.../
520 </example>
521 <p>
522
523 Sources which produce several binary packages with different shared
524 library dependency requirements can use the <tt/-p<var/varnameprefix//
525 option to override the default <tt/shlib:/ prefix (one invocation of
526 <prgn/dpkg-shlibdeps/ per setting of this option).  They can thus
527 produce several sets of dependency variables, each of the form
528 <tt/<var/varnameprefix/:<var/dependencyfield//, which can be referred
529 to in the appropriate parts of the binary package control files.
530
531
532 <sect1><prgn/dpkg-distaddfile/ - adds a file to <tt>debian/files</>
533 <p>
534
535 Some packages' uploads need to include files other than the source and
536 binary package files.
537 <p>
538
539 <prgn/dpkg-distaddfile/ adds a file to the <tt>debian/files</> file so
540 that it will be included in the <tt/.changes/ file when
541 <prgn/dpkg-genchanges/ is run.
542 <p>
543
544 It is usually invoked from the <prgn/binary/ target of
545 <tt>debian/rules</>:
546 <example>
547 dpkg-distaddfile <var/filename/ <var/section/ <var/priority/
548 </example>
549 The <var/filename/ is relative to the directory where
550 <prgn/dpkg-genchanges/ will expect to find it - this is usually the
551 directory above the top level of the source tree.  The
552 <tt>debian/rules</> target should put the file there just before or
553 just after calling <prgn/dpkg-distaddfile/.
554 <p>
555
556 The <var/section/ and <var/priority/ are passed unchanged into the
557 resulting <tt/.changes/ file.  See <ref id="f-classification">.
558
559
560 <sect1><prgn/dpkg-genchanges/ - generates a <tt/.changes/ upload
561 control file
562 <p>
563
564 This program is usually called by package-independent automatic
565 building scripts such as <prgn/dpkg-buildpackage/, but it may also be
566 called by hand.
567 <p>
568
569 It is usually called in the top level of a built source tree, and when
570 invoked with no arguments will print out a straightforward
571 <tt/.changes/ file based on the information in the source package's
572 changelog and control file and the binary and source packages which
573 should have been built.
574
575
576 <sect1><prgn/dpkg-parsechangelog/ - produces parsed representation of
577 a changelog
578 <p>
579
580 This program is used internally by <prgn/dpkg-source/ et al.  It may
581 also occasionally be useful in <tt>debian/rules</> and elsewhere.  It
582 parses a changelog, <tt>debian/changelog</> by default, and prints a
583 control-file format representation of the information in it to
584 standard output.
585
586 <sect id="sourcetree">The Debianised source tree
587 <p>
588
589 The source archive scheme described later is intended to allow a
590 Debianised source tree with some associated control information to be
591 reproduced and transported easily.  The Debianised source tree is a
592 version of the original program with certain files added for the
593 benefit of the Debianisation process, and with any other changes
594 required made to the rest of the source code and installation scripts.
595 <p>
596
597 The extra files created for Debian are in the subdirectory <tt/debian/
598 of the top level of the Debianised source tree.  They are described
599 below.
600
601 <sect1><tt>debian/rules</tt> - the main building script
602 <p>
603
604 This file is an executable makefile, and contains the package-specific
605 recipies for compiling the package and building binary package(s) out
606 of the source.
607 <p>
608
609 It must start with the line <tt>#!/usr/bin/make -f</tt>, so that it
610 can be invoked by saying its name rather than invoking <prgn/make/
611 explicitly.
612 <p>
613
614 The targets which are required to be present are:
615
616 <taglist>
617 <tag/<tt/build//
618 <item>
619
620 This should perform all non-interactive configuration and compilation
621 of the package.  If a package has an interactive pre-build
622 configuration routine, the Debianised source package should be built
623 after this has taken place, so that it can be built without rerunning
624 the configuration.
625 <p>
626
627 For some packages, notably ones where the same source tree is compiled
628 in different ways to produce two binary packages, the <prgn/build/
629 target does not make much sense.  For these packages it is good enough
630 to provide two (or more) targets (<tt/build-a/ and <tt/build-b/ or
631 whatever) for each of the ways of building the package, and a
632 <prgn/build/ target that does nothing.  The <prgn/binary/ target will have
633 to build the package in each of the possible ways and make the binary
634 package out of each.
635 <p>
636
637 The <prgn/build/ target must not do anything that might require root
638 privilege.
639 <p>
640
641 The <prgn/build/ target may need to run <prgn/clean/ first - see below.
642 <p>
643
644 When a package has a configuration routine that takes a long time, or
645 when the makefiles are poorly designed, or when <prgn/build/ needs to
646 run <prgn/clean/ first, it is a good idea to <tt/touch build/ when the
647 build process is complete.  This will ensure that if <tt>debian/rules
648 build</tt> is run again it will not rebuild the whole program.
649
650 <tag/<tt/binary/, <tt/binary-arch/, <tt/binary-indep/
651 <item>
652
653 The <prgn/binary/ target should be all that is necessary for the user
654 to build the binary package.  It is split into two parts:
655 <prgn/binary-arch/ builds the packages' output files which are
656 specific to a particular architecture, and <prgn/binary-indep/
657 builds those which are not.
658 <p>
659
660 <prgn/binary/ should usually be a target with no commands which simply
661 depends on <prgn/binary-arch/ and <prgn/binary-indep/.
662 <p>
663
664 Both <prgn/binary-*/ targets should depend on the <prgn/build/ target,
665 above, so that the package is built if it has not been already.  It
666 should then create the relevant binary package(s), using
667 <prgn/dpkg-gencontrol/ to make their control files and <prgn/dpkg-deb/
668 to build them and place them in the parent of the top level directory.
669 <p>
670
671 If one of the <prgn/binary-*/ targets has nothing to do (this will be
672 always be the case if the source generates only a single binary
673 package, whether architecture-dependent or not) it <em/must/ still
674 exist, but should always succeed.
675 <p>
676
677 <ref id="binarypkg"> describes how to construct binary packages.
678 <p>
679
680 The <prgn/binary/ targets must be invoked as root.
681
682 <tag/<tt/clean//
683 <item>
684
685 This should undo any effects that the <prgn/build/ and <prgn/binary/
686 targets may have had, except that it should leave alone any output
687 files created in the parent directory by a run of <prgn/binary/.
688 <p>
689
690 If a <prgn/build/ file is touched at the end of the <prgn/build/ target,
691 as suggested above, it must be removed as the first thing that
692 <prgn/clean/ does, so that running <prgn/build/ again after an interrupted
693 <prgn/clean/ doesn't think that everything is already done.
694 <p>
695
696 The <prgn/clean/ target must be invoked as root if <prgn/binary/ has
697 been invoked since the last <prgn/clean/, or if <prgn/build/ has been
698 invoked as root (since <prgn/build/ may create directories, for
699 example).
700
701 <tag/<tt/get-orig-source/ (optional)/
702 <item>
703
704 This target fetches the most recent version of the original source
705 package from a canonical archive site (via FTP or WWW, for example),
706 does any necessary rearrangement to turn it into the original source
707 tarfile format described below, and leaves it in the current directory.
708 <p>
709
710 This target may be invoked in any directory, and should take care to
711 clean up any temporary files it may have left.
712 <p>
713
714 This target is optional, but providing it if possible is a good idea.
715
716 </taglist>
717
718 The <prgn/build/, <prgn/binary/ and <prgn/clean/ targets must be
719 invoked with a current directory of the package's top-level
720 directory.
721
722 <p>
723
724 Additional targets may exist in <tt>debian/rules</tt>, either as
725 published or undocumented interfaces or for the package's internal
726 use.
727
728
729 <sect1><tt>debian/control</tt>
730 <p>
731
732 This file contains version-independent details about the source
733 package and about the binary packages it creates.
734 <p>
735
736 It is a series of sets of control fields, each syntactically similar
737 to a binary package control file.  The sets are separated by one or
738 more blank lines.  The first set is information about the source
739 package in general; each subsequent set describes one binary package
740 that the source tree builds.
741 <p>
742
743 The syntax and semantics of the fields are described below in
744 <ref id="controlfields">.
745 <p>
746
747 The general (binary-package-independent) fields are:
748 <list compact>
749 <item><qref id="f-Source"><tt/Source/</> (mandatory)
750 <item><qref id="f-Maintainer"><tt/Maintainer/</>
751 <item><qref id="f-classification"><tt/Section/ and <tt/Priority/</>
752 (classification, mandatory)
753 <item><qref id="f-Standards-Version"><tt/Standards-Version/</>
754 </list>
755 <p>
756
757 The per-binary-package fields are:
758 <list compact>
759 <item><qref id="f-Package"><tt/Package/</> (mandatory)
760 <item><qref id="f-Architecture"><tt/Architecture/</> (mandatory)
761 <item><qref id="descriptions"><tt/Description/</>
762 <item><qref id="f-classification"><tt/Section/ and <tt/Priority/</> (classification)
763 <item><qref id="f-Essential"><tt/Essential/</>
764 <item><qref id="relationships"><tt/Depends/ et al.</> (package interrelationships)
765 </list>
766 <p>
767
768 These fields are used by <prgn/dpkg-gencontrol/ to generate control
769 files for binary packages (see below), by <prgn/dpkg-genchanges/ to
770 generate the <tt/.changes/ file to accompany the upload, and by
771 <prgn/dpkg-source/ when it creates the <tt/.dsc/ source control file as
772 part of a source archive.
773 <p>
774
775 The fields here may contain variable references - their values will be
776 substituted by <prgn/dpkg-gencontrol/, <prgn/dpkg-genchanges/ or
777 <prgn/dpkg-source/ when they generate output control files.  See <ref
778 id="srcsubstvars"> for details.
779 <p>
780
781 <sect2>User-defined fields
782 <p>
783
784 Additional user-defined fields may be added to the source package
785 control file.  Such fields will be ignored, and not copied to (for
786 example) binary or source package control files or upload control
787 files.
788 <p>
789
790 If you wish to add additional unsupported fields to these output files
791 you should use the mechanism described here.
792 <p>
793
794 Fields in the main source control information file with names starting
795 <tt/X/, followed by one or more of the letters <tt/BCS/ and a hyphen
796 <tt/-/, will be copied to the output files.  Only the part of the
797 field name after the hyphen will be used in the output file.  Where
798 the letter <tt/B/ is used the field will appear in binary package
799 control files, where the letter <tt/S/ is used in source package
800 control files and where <tt/C/ is used in upload control
801 (<tt/.changes/) files.
802 <p>
803
804 For example, if the main source information control file contains the
805 field
806 <example>
807 XBS-Comment: I stand between the candle and the star.
808 </example>
809 then the binary and source package control files will contain the
810 field
811 <example>
812 Comment: I stand between the candle and the star.
813 </example>
814
815 <sect1 id="dpkgchangelog"><tt>debian/changelog</>
816 <p>
817
818 This file records the changes to the Debian-specific parts of the
819 package<footnote>Though there is nothing stopping an author who is
820 also the Debian maintainer from using it for all their changes, it
821 will have to be renamed if the Debian and upstream maintainers become
822 different people.</footnote>.
823 <p>
824
825 It has a special format which allows the package building tools to
826 discover which version of the package is being built and find out
827 other release-specific information.
828 <p>
829
830 That format is a series of entries like this:
831 <p>
832 <example>
833 <var/package/ (<var/version/) <var/distribution(s)/; urgency=<var/urgency/
834
835   * <var/change details/
836     <var/more change details/
837   * <var/even more change details/
838
839  -- <var/maintainer name and email address/  <var/date/
840 </example>
841 <p>
842
843 <var/package/ and <var/version/ are the source package name and
844 version number. 
845 <p> 
846 <var/distribution(s)/ lists the distributions where
847 this version should be installed when it is uploaded - it is copied to
848 the <tt/Distribution/ field in the <tt/.changes/ file.  See <ref
849 id="f-Distribution">.
850 <p>
851
852 <var/urgency/ is the value for the <tt/Urgency/ field in the
853 <tt/.changes/ file for the upload.  See <ref id="f-Urgency">.  It is
854 not possible to specify an urgency containing commas; commas are used
855 to separate <tt/<var/keyword/=<var/value// settings in the <prgn/dpkg/
856 changelog format (though there is currently only one useful
857 <var/keyword/, <tt/urgency/).
858 <p>
859
860 The change details may in fact be any series of lines starting with at
861 least two spaces, but conventionally each change starts with an
862 asterisk and a separating space and continuation lines are indented so
863 as to bring them in line with the start of the text above.  Blank
864 lines may be used here to separate groups of changes, if desired.
865 <p>
866
867 The maintainer name and email address should <em/not/ necessarily be
868 those of the usual package maintainer.  They should be the details of
869 the person doing <em/this/ version.  The information here will be
870 copied to the <tt/.changes/ file, and then later used to send an
871 acknowledgement when the upload has been installed.
872 <p>
873
874 The <var/date/ should be in RFC822 format<footnote>This is generated
875 by the <prgn/822-date/ program.</footnote>; it should include the
876 timezone specified numerically, with the timezone name or abbreviation
877 optionally present as a comment.
878 <p>
879
880 The first `title' line with the package name should start at the left
881 hand margin; the `trailer' line with the maintainer and date details
882 should be preceded by exactly one space.  The maintainer details and
883 the date must be separated by exactly two spaces.
884 <p>
885
886 An Emacs mode for editing this format is available: it is called
887 <tt/debian-changelog-mode/.  You can have this mode selected
888 automatically when you edit a Debian changelog by adding a local
889 variables clause to the end of the changelog.
890
891 <sect2>Defining alternative changelog formats
892 <p>
893
894 It is possible to use a different format to the standard one, by
895 providing a parser for the format you wish to use.
896 <p>
897
898 In order to have <tt/dpkg-parsechangelog/ run your parser, you must
899 include a line within the last 40 lines of your file matching the Perl
900 regular expression:
901 <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt>
902 The part in parentheses should be the name of the format.  For
903 example, you might say:
904 <example>
905 @@@ changelog-format: joebloggs @@@
906 </example>
907 Changelog format names are non-empty strings of alphanumerics.
908 <p>
909
910 If such a line exists then <tt/dpkg-parsechangelog/ will look for the
911 parser as <tt>/usr/lib/dpkg/parsechangelog/<var/format-name/</> or
912 <tt>/usr/local/lib/dpkg/parsechangelog/<var/format-name/</>; it is an
913 error for it not to find it, or for it not to be an executable
914 program.  The default changelog format is <tt/dpkg/, and a parser for
915 it is provided with the <tt/dpkg/ package.
916 <p>
917
918 The parser will be invoked with the changelog open on standard input
919 at the start of the file.  It should read the file (it may seek if it
920 wishes) to determine the information required and return the parsed
921 information to standard output in the form of a series of control
922 fields in the standard format.  By default it should return
923 information about only the most recent version in the changelog; it
924 should accept a <tt/-v<var/version// option to return changes
925 information from all versions present <em/strictly after/
926 <var/version/, and it should then be an error for <var/version/ not to
927 be present in the changelog.
928 <p>
929
930 The fields are:
931 <list compact>
932 <item><qref id="f-Source"><tt/Source/</>
933 <item><qref id="versions"><tt/Version/</> (mandatory)
934 <item><qref id="f-Distribution"><tt/Distribution/</> (mandatory)
935 <item><qref id="f-Urgency"><tt/Urgency/</> (mandatory)
936 <item><qref id="f-Maintainer"><tt/Maintainer/</> (mandatory)
937 <item><qref id="f-Date"><tt/Date/</>
938 <item><qref id="f-Changes"><tt/Changes/</> (mandatory)
939 </list>
940 <p>
941
942 If several versions are being returned (due to the use of <tt/-v/),
943 the urgency value should be of the highest urgency code listed at the
944 start of any of the versions requested followed by the concatenated
945 (space-separated) comments from all the versions requested; the
946 maintainer, version, distribution and date should always be from the
947 most recent version.
948 <p>
949
950 For the format of the <tt/Changes/ field see <ref id="f-Changes">.
951 <p>
952
953 If the changelog format which is being parsed always or almost always
954 leaves a blank line between individual change notes these blank lines
955 should be stripped out, so as to make the resulting output compact.
956 <p>
957
958 If the changelog format does not contain date or package name
959 information this information should be omitted from the output.  The
960 parser should not attempt to synthesise it or find it from other
961 sources.
962 <p>
963
964 If the changelog does not have the expected format the parser should
965 exit with a nonzero exit status, rather than trying to muddle through
966 and possibly generating incorrect output.
967 <p>
968
969 A changelog parser may not interact with the user at all.
970
971 <sect1 id="srcsubstvars"><tt>debian/substvars</> and variable substitutions
972 <p>
973
974 When <prgn/dpkg-gencontrol/, <prgn/dpkg-genchanges/ and
975 <prgn/dpkg-source/ generate control files they do variable
976 substitutions on their output just before writing it.  Variable
977 substitutions have the form <tt/${<var/variable-name/}/.  The optional
978 file <tt>debian/substvars</> contains variable substitutions to be
979 used; variables can also be set directly from <tt>debian/rules</>
980 using the <tt/-V/ option to the source packaging commands, and certain
981 predefined variables are available.
982 <p>
983
984 The is usually generated and modified dynamically by
985 <tt>debian/rules</> targets; in this case it must be removed by the
986 <prgn/clean/ target.
987 <p>
988
989
990
991 See <manref name=dpkg-source section=1> for full details about source
992 variable substitutions, including the format of
993 <tt>debian/substvars</>.
994
995 <sect1><tt>debian/files</>
996 <p>
997
998 This file is not a permanent part of the source tree; it is used while
999 building packages to record which files are being generated.
1000 <prgn/dpkg-genchanges/ uses it when it generates a <tt/.changes/ file.
1001 <p>
1002
1003 It should not exist in a shipped source package, and so it (and any
1004 backup files or temporary files such as
1005 <tt/files.new/<footnote><tt/files.new/ is used as a temporary file by
1006 <prgn/dpkg-gencontrol/ and <prgn/dpkg-distaddfile/ - they write a new
1007 version of <tt/files/ here before renaming it, to avoid leaving a
1008 corrupted copy if an error occurs</footnote>) should be removed by the
1009 <prgn/clean/ target.  It may also be wise to ensure a fresh start by
1010 emptying or removing it at the start of the <prgn/binary/ target.
1011 <p>
1012
1013 <prgn/dpkg-gencontrol/ adds an entry to this file for the <tt/.deb/
1014 file that will be created by <prgn/dpkg-deb/ from the control file
1015 that it generates, so for most packages all that needs to be done with
1016 this file is to delete it in <prgn/clean/.
1017 <p>
1018
1019 If a package upload includes files besides the source package and any
1020 binary packages whose control files were made with
1021 <prgn/dpkg-gencontrol/ then they should be placed in the parent of the
1022 package's top-level directory and <prgn/dpkg-distaddfile/ should be
1023 called to add the file to the list in <tt>debian/files</>.
1024
1025 <sect1><tt>debian/tmp</>
1026 <p>
1027
1028 This is the canonical temporary location for the construction of
1029 binary packages by the <prgn/binary/ target.  The directory <tt/tmp/
1030 serves as the root of the filesystem tree as it is being constructed
1031 (for example, by using the package's upstream makefiles install
1032 targets and redirecting the output there), and it also contains the
1033 <tt/DEBIAN/ subdirectory.  See <ref id="bincreating">.
1034 <p>
1035
1036 If several binary packages are generated from the same source tree it
1037 is usual to use several <tt>debian/tmp<var/something/</> directories,
1038 for example <tt/tmp-a/ or <tt/tmp-doc/.
1039 <p>
1040
1041 Whatever <tt>tmp</> directories are created and used by <prgn/binary/
1042 must of course be removed by the <prgn/clean/ target.
1043
1044
1045 <sect id="sourcearchives">Source packages as archives
1046 <p>
1047
1048 As it exists on the FTP site, a Debian source package consists of
1049 three related files.  You must have the right versions of all three to
1050 be able to use them.
1051 <p>
1052
1053 <taglist>
1054 <tag/Debian source control file - <tt/.dsc//
1055 <item>
1056
1057 This file contains a series of fields, identified and separated just
1058 like the fields in the control file of a binary package.  The fields
1059 are listed below; their syntax is described above, in
1060 <ref id="controlfields">.
1061 <list compact>
1062 <item><qref id="f-Source"><tt/Source/</>
1063 <item><qref id="versions"><tt/Version/</>
1064 <item><qref id="f-Maintainer"><tt/Maintainer/</>
1065 <item><qref id="f-Binary"><tt/Binary/</>
1066 <item><qref id="f-Architecture"><tt/Architecture/</>
1067 <item><qref id="f-Standards-Version"><tt/Standards-Version/</>
1068 <item><qref id="f-Files"><tt/Files/</>
1069 </list>
1070 <p>
1071
1072 The source package control file is generated by <prgn/dpkg-source/
1073 when it builds the source archive, from other files in the source
1074 package, described above.  When unpacking it is checked against the
1075 files and directories in the other parts of the source package, as
1076 described below.
1077
1078 <tag/Original source archive - <tt/<var/package/_<var/upstream-version/.orig.tar.gz//
1079 <item>
1080
1081 This is a compressed (with <tt/gzip -9/) <prgn/tar/ file containing
1082 the source code from the upstream authors of the program.  The tarfile
1083 unpacks into a directory
1084 <tt/<var/package/-<var/upstream-version/.orig/, and does not contain
1085 files anywhere other than in there or in its subdirectories.
1086
1087 <tag/Debianisation diff - <tt/<var/package/_<var/upstream_version-revision/.diff.gz//
1088 <item>
1089
1090 This is a unified context diff (<tt/diff -u/) giving the changes which
1091 are required to turn the original source into the Debian source.
1092 These changes may only include editing and creating plain files.  The
1093 permissions of files, the targets of symbolic links and the
1094 characteristics of special files or pipes may not be changed and no
1095 files may be removed or renamed.
1096 <p>
1097
1098 All the directories in the diff must exist, except the <tt/debian/
1099 subdirectory of the top of the source tree, which will be created by
1100 <prgn/dpkg-source/ if necessary when unpacking.
1101 <p>
1102
1103 The <prgn/dpkg-source/ program will automatically make the
1104 <tt>debian/rules</tt> file executable (see below).
1105
1106 </taglist>
1107 <p>
1108
1109 If there is no original source code - for example, if the package is
1110 specially prepared for Debian or the Debian maintainer is the same as
1111 the upstream maintainer - the format is slightly different: then there
1112 is no diff, and the tarfile is named
1113 <tt/<var/package/_<var/version/.tar.gz</> and contains a directory
1114 <tt/<var/package/-<var/version/</>.
1115
1116 <sect>Unpacking a Debian source package without <prgn/dpkg-source/
1117 <p>
1118
1119 <tt/dpkg-source -x/ is the recommended way to unpack a Debian source
1120 package.  However, if it is not available it is possible to unpack a
1121 Debian source archive as follows:
1122
1123 <enumlist compact>
1124 <item>Untar the tarfile, which will create a <tt/.orig/ directory.
1125 <item>Rename the <tt/.orig/ directory to
1126 <tt/<var/package/-<var/version//.
1127 <item>Create the subdirectory <tt/debian/ at the top of the source
1128 tree.
1129 <item>Apply the diff using <tt/patch -p0/.
1130 <item>Untar the tarfile again if you want a copy of the original
1131 source code alongside the Debianised version.
1132 </enumlist>
1133 <p>
1134
1135 It is not possible to generate a valid Debian source archive without
1136 using <prgn/dpkg-source/.  In particular, attempting to use
1137 <prgn/diff/ directly to generate the <tt/.diff.gz/ file will not work.
1138
1139 <sect1>Restrictions on objects in source packages
1140 <p>
1141
1142 The source package may not contain any hard links<footnote>This is not
1143 currently detected when building source packages, but only when
1144 extracting them.</footnote><footnote>Hard links may be permitted at
1145 some point in the future, but would require a fair amount of
1146 work.</footnote>, device special files, sockets or setuid or setgid
1147 files.<footnote>Setgid directories are allowed.</footnote>
1148 <p>
1149
1150 The source packaging tools manage the changes between the original and
1151 Debianised source using <prgn/diff/ and <prgn/patch/.  Turning the
1152 original source tree as included in the <tt/.orig.tar.gz/ into the
1153 debianised source must not involve any changes which cannot be handled
1154 by these tools.  Problematic changes which cause <prgn/dpkg-source/ to
1155 halt with an error when building the source package are:
1156 <list compact>
1157 <item>Adding or removing symbolic links, sockets or pipes.
1158 <item>Changing the targets of symbolic links.
1159 <item>Creating directories, other than <tt/debian/.
1160 <item>Changes to the contents of binary files.
1161 </list>
1162 Changes which cause <prgn/dpkg-source/ to print a warning but continue
1163 anyway are:
1164 <list compact>
1165 <item>Removing files, directories or symlinks.  <footnote>Renaming a
1166 file is not treated specially - it is seen as the removal of the old
1167 file (which generates a warning, but is otherwise ignored), and the
1168 creation of the new one.</footnote>
1169 <item>Changed text files which are missing the usual final newline
1170 (either in the original or the modified source tree).
1171 </list>
1172 Changes which are not represented, but which are not detected by
1173 <prgn/dpkg-source/, are:
1174 <list compact>
1175 <item>Changing the permissions of files (other than
1176 <tt>debian/rules</>) and directories.
1177 </list>
1178 <p>
1179
1180 The <tt/debian/ directory and <tt>debian/rules</> are handled
1181 specially by <prgn/dpkg-source/ - before applying the changes it will
1182 create the <tt/debian/ directory, and afterwards it will make
1183 <tt>debian/rules</> world-exectuable.
1184
1185 <chapt id="controlfields">Control files and their fields
1186 <p>
1187
1188 Many of the tools in the <prgn/dpkg/ suite manipulate data in a common
1189 format, known as control files.  Binary and source packages have
1190 control data as do the <tt/.changes/ files which control the
1191 installation of uploaded files, and <prgn/dpkg/'s internal databases
1192 are in a similar format.
1193
1194 <sect>Syntax of control files
1195 <p>
1196
1197 A file consists of one or more paragraphs of fields.  The paragraphs
1198 are separated by blank lines.  Some control files only allow one
1199 paragraph; others allow several, in which case each paragraph often
1200 refers to a different package.
1201 <p>
1202
1203 Each paragraph is a series of fields and values; each field consists
1204 of a name, followed by a colon and the value.  It ends at the end of
1205 the line.  Horizontal whitespace (spaces and tabs) may occur before or
1206 after the value and is ignored there; it is conventional to put a
1207 single space after the colon.
1208 <p>
1209
1210 Some fields' values may span several lines; in this case each
1211 continuation line <em/must/ start with a space or tab.  Any trailing
1212 spaces or tabs at the end of individual lines of a field value are
1213 ignored.
1214 <p>
1215
1216 Except where otherwise stated only a single line of data is allowed
1217 and whitespace is not significant in a field body.  Whitespace may
1218 never appear inside names (of packages, architectures, files or
1219 anything else), version numbers or in between the characters of
1220 multi-character version relationships.
1221 <p>
1222
1223 Field names are not case-sensitive, but it is usual to capitalise the
1224 fields using mixed case as shown below.
1225 <p>
1226
1227 Blank lines, or lines consisting only of spaces and tabs, are not
1228 allowed within field values or between fields - that would mean a new
1229 paragraph.
1230 <p>
1231
1232 It is important to note that there are several fields which are
1233 optional as far as <prgn/dpkg/ and the related tools are concerned,
1234 but which must appear in every Debian package, or whose omission may
1235 cause problems.  When writing the control files for Debian packages
1236 you <em/must/ read the Debian policy manual in conjuction with the
1237 details below and the list of fields for the particular file.
1238
1239 <sect>List of fields
1240
1241 <sect1 id="f-Package"><tt/Package/
1242 <p>
1243
1244 The name of the binary package.  Package names consist of the
1245 alphanumerics and <tt/+/ <tt/-/ <tt/./ (plus, minus and full
1246 stop).<footnote>The characters <tt/@/ <tt/:/ <tt/=/ <tt/%/ <tt/_/ (at,
1247 colon, equals, percent and underscore) used to be legal and are still
1248 accepted when found in a package file, but may not be used in new
1249 packages</footnote>
1250 <p>
1251
1252 They must be at least two characters and must start with an
1253 alphanumeric.  In current versions of dpkg they are sort of
1254 case-sensitive<footnote>This is a bug.</footnote>; use lowercase
1255 package names unless the package you're building (or referring to, in
1256 other fields) is already using uppercase.
1257
1258 <sect1 id="f-Version"><tt/Version/
1259 <p>
1260
1261 This lists the source or binary package's version number - see <ref
1262 id="versions">.
1263
1264 <sect1 id="f-Architecture"><tt/Architecture/
1265 <p>
1266
1267 This is the architecture string; it is a single word for the CPU
1268 architecture.
1269 <p>
1270
1271 <prgn/dpkg/ will check the declared architecture of a binary package
1272 against its own compiled-in value before it installs it.
1273 <p>
1274
1275 The special value <tt/all/ indicates that the package is
1276 architecture-independent.
1277 <p>
1278
1279 In the main <tt>debian/control</> file in the source package, or in
1280 the source package control file <tt/.dsc/, a list of architectures
1281 (separated by spaces) is also allowed, as is the special value
1282 <tt/any/.  A list indicates that the source will build an
1283 architecture-dependent package, and will only work correctly on the
1284 listed architectures.  <tt/any/ indicates that though the source
1285 package isn't dependent on any particular architecture and should
1286 compile fine on any one, the binary package(s) produced are not
1287 architecture-independent but will instead be specific to whatever the
1288 current build architecture is.
1289 <p>
1290
1291 In a <tt/.changes/ file the <tt/Architecture/ field lists the
1292 architecture(s) of the package(s) currently being uploaded.  This will
1293 be a list; if the source for the package is being uploaded too the
1294 special entry <tt/source/ is also present.
1295 <p>
1296
1297 The current build architecture can be determined using <tt/dpkg
1298 --print-architecture/.<footnote>This actually invokes
1299 <example>
1300 gcc --print-libgcc-file-name
1301 </example>
1302 and parses and decomposes the output and looks the CPU type from the
1303 GCC configuration in a table in <prgn/dpkg/.  This is so that it will
1304 work if you're cross-compiling.
1305 </footnote>
1306 This value is automatically used by <prgn/dpkg-gencontrol/ when
1307 building the control file for a binary package for which the source
1308 control information doesn't specify architecture <tt/all/.
1309 <p>
1310
1311 There is a separate option, <tt/--print-installation-architecture/,
1312 for finding out what architecture <prgn/dpkg/ is willing to install.
1313 This information is also in the output of <tt/dpkg --version/.
1314
1315 <sect1 id="f-Maintainer"><tt/Maintainer/
1316 <p>
1317
1318 The package maintainer's name and email address.  The name should come
1319 first, then the email address inside angle brackets <tt/&lt;&gt/ (in
1320 RFC822 format).
1321 <p>
1322
1323 If the maintainer's name contains a full stop then the whole field
1324 will not work directly as an email address due to a misfeature in the
1325 syntax specified in RFC822; a program using this field as an address
1326 must check for this and correct the problem if necessary (for example
1327 by putting the name in round brackets and moving it to the end, and
1328 bringing the email address forward).
1329 <p>
1330
1331 In a <tt/.changes/ file or parsed changelog data this contains the
1332 name and email address of the person responsible for the particular
1333 version in question - this may not be the package's usual maintainer.
1334 <p>
1335
1336 This field is usually optional in as far as the <prgn/dpkg/ are
1337 concerned, but its absence when building packages usually generates a
1338 warning.
1339
1340 <sect1 id="f-Source"><tt/Source/
1341 <p>
1342
1343 This field identifies the source package name.
1344 <p>
1345
1346 In a main source control information or a <tt/.changes/ or <tt/.dsc/
1347 file or parsed changelog data this may contain only the name of the
1348 source package.
1349 <p>
1350
1351 In the control file of a binary package (or in a <tt/Packages/ file)
1352 it may be followed by a version number in parentheses.<footnote>It is
1353 usual to leave a space after the package name if a version number is
1354 specified.</footnote> This version number may be omitted (and is, by
1355 <prgn/dpkg-gencontrol/) if it has the same value as the <tt/Version/
1356 field of the binary package in question.  The field itself may be
1357 omitted from a binary package control file when the source package has
1358 the same name and version as the binary package.
1359
1360 <sect1>Package interrelationship fields:
1361 <tt/Depends/, <tt/Pre-Depends/, <tt/Recommends/
1362 <tt/Suggests/, <tt/Conflicts/, <tt/Provides/, <tt/Replaces/
1363 <p>
1364
1365 These fields describe the package's relationships with other packages.
1366 Their syntax and semantics are described in <ref id="relationships">.
1367
1368 <sect1 id="f-Description"><tt/Description/
1369 <p>
1370
1371 In a binary package <tt/Packages/ file or main source control file
1372 this field contains a description of the binary package, in a special
1373 format.  See <ref id="descriptions"> for details.
1374 <p>
1375
1376 In a <tt/.changes/ file it contains a summary of the descriptions for
1377 the packages being uploaded.  The part of the field before the first
1378 newline is empty; thereafter each line has the name of a binary
1379 package and the summary description line from that binary package.
1380 Each line is indented by one space.
1381
1382 <sect1 id="f-Essential"><tt/Essential/
1383 <p>
1384
1385 This is a boolean field which may occur only in the control file of a
1386 binary package (or in the <tt/Packages/ file) or in a per-package
1387 fields paragraph of a main source control data file.
1388 <p>
1389
1390 If set to <tt/yes/ then <prgn/dpkg/ and <prgn/dselect/ will refuse to
1391 remove the package (though it can be upgraded and/or replaced).  The
1392 other possible value is <tt/no/, which is the same as not having the
1393 field at all.
1394
1395 <sect1 id="f-classification"><tt/Section/ and <tt/Priority/
1396 <p>
1397
1398 These two fields classify the package.  The <tt/Priority/ represents
1399 how important that it is that the user have it installed; the
1400 <tt/Section/ represents an application area into which the package has
1401 been classified.
1402 <p>
1403
1404 When they appear in the <tt>debian/control</> file these fields give
1405 values for the section and priority subfields of the <tt/Files/ field
1406 of the <tt/.changes/ file, and give defaults for the section and
1407 priority of the binary packages.
1408 <p>
1409
1410 The section and priority are represented, though not as separate
1411 fields, in the information for each file in the <qref
1412 id="f-Files"><tt/Files/</> field of a <tt/.changes/ file.  The
1413 section value in a <tt/.changes/ file is used to decide where to
1414 install a package in the FTP archive.
1415 <p>
1416
1417 These fields are not used by by <prgn/dpkg/ proper, but by
1418 <prgn/dselect/ when it sorts packages and selects defaults.  See the
1419 Debian policy manual for the priorities in use and the criteria for
1420 selecting the priority for a Debian package, and look at the Debian
1421 FTP archive for a list of currently in-use priorities.
1422 <p>
1423
1424 These fields may appear in binary package control files, in which case
1425 they provide a default value in case the <tt/Packages/ files are
1426 missing the information.  <prgn/dpkg/ and <prgn/dselect/ will only use
1427 the value from a <tt/.deb/ file if they have no other information; a
1428 value listed in a <tt/Packages/ file will always take precedence.  By
1429 default <prgn/dpkg-genchanges/ does not include the section and
1430 priority in the control file of a binary package - use the <tt/-isp/,
1431 <tt/-is/ or <tt/-ip/ options to achieve this effect.
1432
1433 <sect1 id="f-Binary"><tt/Binary/
1434 <p>
1435
1436 This field is a list of binary packages.
1437 <p>
1438
1439 When it appears in the <tt/.dsc/ file it is the list of binary
1440 packages which a source package can produce.  It does not necessarily
1441 produce all of these binary packages for every architecture.  The
1442 source control file doesn't contain details of which architectures are
1443 appropriate for which of the binary packages.
1444 <p>
1445
1446 When it appears in a <tt/.changes/ file it lists the names of the
1447 binary packages actually being uploaded.
1448 <p>
1449
1450 The syntax is a list of binary packages separated by
1451 commas.<footnote>A space after each comma is conventional.</footnote>
1452 Currently the packages must be separated using only spaces in the
1453 <tt/.changes/ file.
1454
1455 <sect1 id="f-Installed-Size"><tt/Installed-Size/
1456 <p>
1457
1458 This field appears in the control files of binary packages, and in the
1459 <tt/Packages/ files.  It gives the total amount of disk space
1460 required to install the named package.
1461 <p>
1462
1463 The disk space is represented in kilobytes as a simple decimal number.
1464
1465 <sect1 id="f-Files"><tt/Files/
1466 <p>
1467
1468 This field contains a list of files with information about each one.
1469 The exact information and syntax varies with the context.  In all
1470 cases the the part of the field contents on the same line as the field
1471 name is empty.  The remainder of the field is one line per file, each
1472 line being indented by one space and containing a number of sub-fields
1473 separated by spaces.
1474 <p>
1475
1476 In the <tt/.dsc/ (Debian source control) file each line contains the
1477 MD5 checksum, size and filename of the tarfile and (if applicable)
1478 diff file which make up the remainder of the source
1479 package.<footnote>That is, the parts which are not the
1480 <tt/.dsc/.</footnote> The exact forms of the filenames are described
1481 in <ref id="sourcearchives">.
1482 <p>
1483
1484 In the <tt/.changes/ file this contains one line per file being
1485 uploaded.  Each line contains the MD5 checksum, size, section and
1486 priority and the filename.  The section and priority are the values of
1487 the corresponding fields in the main source control file - see <ref
1488 id="f-classification">.  If no section or priority is specified then
1489 <tt/-/ should be used, though section and priority values must be
1490 specified for new packages to be installed properly.
1491 <p>
1492
1493 The special value <tt/byhand/ for the section in a <tt/.changes/ file
1494 indicates that the file in question is not an ordinary package file
1495 and must by installed by hand by the distribution maintainers.  If the
1496 section is <tt/byhand/ the priority should be <tt/-/.
1497 <p>
1498
1499 If a new Debian revision of a package is being shipped and no new
1500 original source archive is being distributed the <tt/.dsc/ must still
1501 contain the <tt/Files/ field entry for the original source archive
1502 <tt/<var/package/-<var/upstream-version/.orig.tar.gz/, but the
1503 <tt/.changes/ file should leave it out.  In this case the original
1504 source archive on the distribution site must match exactly,
1505 byte-for-byte, the original source archive which was used to generate
1506 the <tt/.dsc/ file and diff which are being uploaded.
1507
1508
1509 <sect1 id="f-Standards-Version"><tt/Standards-Version/
1510 <p>
1511
1512 The most recent version of the standards (the <prgn/dpkg/ programmers'
1513 and policy manuals and associated texts) with which the package
1514 complies.  This is updated manually when editing the source package to
1515 conform to newer standards; it can sometimes be used to tell when a
1516 package needs attention.
1517 <p>
1518
1519 Its format is the same as that of a version number except that no
1520 epoch or Debian revision is allowed - see <ref id="versions">.
1521
1522
1523 <sect1 id="f-Distribution"><tt/Distribution/
1524 <p>
1525
1526 In a <tt/.changes/ file or parsed changelog output this contains the
1527 (space-separated) name(s) of the distribution(s) where this version of
1528 the package should be or was installed.  Distribution names follow the
1529 rules for package names.  (See <ref id="f-Package">).
1530 <p>
1531
1532 Current distribution values are:
1533 <taglist>
1534 <tag/<em/stable//
1535 <item>
1536 This is the current `released' version of Debian GNU/Linux.  A new
1537 version is released approximately every 3 months after the
1538 <em/development/ code has been <em/frozen/ for a month of testing.
1539 Once the distribution is <em/stable/ only major bug fixes are
1540 allowed. When changes are made to this distribution, the minor version
1541 number is increased (for example: 1.2 becomes 1.2.1 then 1.2.2, etc).
1542
1543 <tag/<em/unstable//
1544 <item>
1545 This distribution value refers to the <em/developmental/ part of the Debian
1546 distribution tree. New packages, new upstream versions of packages and
1547 bug fixes go into the <em/unstable/ directory tree. Download
1548 from this distribution at your own risk.
1549
1550 <tag/<em/contrib//
1551 <item>
1552 The packages with this distribution value do not meet the criteria for
1553 inclusion in the main Debian distribution as defined by the Policy
1554 Manual, but meet the criteria for the <em/contrib/ Distribution. There
1555 is currently no distinction between stable and unstable packages in
1556 the <em/contrib/ or <em/non-free/ distributions. Use your best
1557 judgement in downloading from this Distribution.
1558
1559 <tag/<em/non-free//
1560 <item>
1561 Like the packages in the <em/contrib/ seciton, the packages in
1562 <em/non-free/ do not meet the criteria for inclusion in the main
1563 Debian distribution as defined by the Policy Manual. Again, use your
1564 best judgement in downloading from this Distribution.
1565
1566 <tag/<em/experimental//
1567 <item>
1568 The packages with this distribution value are deemed by their
1569 maintainers to be high risk. Oftentimes they represent early beta or
1570 developmental packages from various sources that the maintainers want
1571 people to try, but are not ready to be a part of the other parts of
1572 the Debian distribution tree. Download at your own risk.
1573
1574 <tag/<em/frozen//
1575 <item>
1576 From time to time, (currently, every 3 months) the <em/unstable/
1577 distribution enters a state of `code-freeze' in anticipation of
1578 release as a <em/stable/ version. During this period of testing
1579 (usually 4 weeks) only fixes for existing or newly-discovered bugs
1580 will be allowed.
1581
1582 </taglist>
1583 <p>
1584 You should list <em/all/ distributions that the package should be
1585 installed into. Except in unusual circumstances, installations to
1586 <em/stable/ should also go into <em/frozen/ (if it exists) and
1587 <em/unstable/. Likewise, installations into <em/frozen/ should also go
1588 into <em/unstable/.
1589
1590 <sect1 id="f-Urgency"><tt/Urgency/
1591 <p>
1592
1593 This is a description of how important it is to upgrade to this
1594 version from previous ones.  It consists of a single keyword usually
1595 taking one of the values <tt/LOW/, <tt/MEDIUM/ or <tt/HIGH/) followed
1596 by an optional commentary (separated by a space) which is usually in
1597 parentheses.  For example:
1598 <example>
1599 Urgency: LOW (HIGH for diversions users)
1600 </example>
1601 <p>
1602
1603 This field appears in the <tt/.changes/ file and in parsed changelogs;
1604 its value appears as the value of the <tt/urgency/ attribute in a
1605 <prgn/dpkg/-style changelog (see <ref id="dpkgchangelog">).
1606 <p>
1607
1608 Urgency keywords are not case-sensitive.
1609
1610 <sect1 id="f-Date"><tt/Date/
1611 <p>
1612
1613 In <tt/.changes/ files and parsed changelogs, this gives the date the
1614 package was built or last edited.
1615
1616 <sect1 id="f-Format"><tt/Format/
1617 <p>
1618
1619 This field occurs in <tt/.changes/ files, and specifies a format
1620 revision for the file.  The format described here is version <tt/1.5/.
1621 The syntax of the format value is the same as that of a package
1622 version number except that no epoch or Debian revision is allowed -
1623 see <ref id="versions">.
1624
1625 <sect1 id="f-Changes"><tt/Changes/
1626 <p>
1627
1628 In a <tt/.changes/ file or parsed changelog this field contains the
1629 human-readable changes data, describing the differences between the
1630 last version and the current one.
1631 <p>
1632
1633 There should be nothing in this field before the first newline; all
1634 the subsequent lines must be indented by at least one space; blank
1635 lines must be represented by a line consiting only of a space and a
1636 full stop.
1637 <p>
1638
1639 Each version's change information should be preceded by a `title' line
1640 giving at least the version, distribution(s) and urgency, in a
1641 human-readable way.
1642 <p>
1643
1644 If data from several versions is being returned the entry for the most
1645 recent version should be returned first, and entries should be
1646 separated by the representation of a blank line (the `title' line may
1647 also be followed by the representation of blank line).
1648
1649 <sect1 id="f-Filename"><tt/Filename/ and <tt/MSDOS-Filename/
1650 <p>
1651
1652 These fields in <tt/Packages/ files give the filename(s) of (the parts
1653 of) a package in the distribution directories, relative to the root of
1654 the Debian hierarchy.  If the package has been split into several
1655 parts the parts are all listed in order, separated by spaces.
1656
1657 <sect1 id="f-Size"><tt/Size/ and <tt/MD5sum/
1658 <p>
1659
1660 These fields in <tt/Packages/ files give the size (in bytes, expressed
1661 in decimal) and MD5 checksum of the file(s) which make(s) up a binary
1662 package in the distribution.  If the package is split into several
1663 parts the values for the parts are listed in order, separated by
1664 spaces.
1665
1666 <sect1 id="f-Status"><tt/Status/
1667 <p>
1668
1669 This field in <prgn/dpkg/'s status file records whether the user wants a
1670 package installed, removed or left alone, whether it is broken
1671 (requiring reinstallation) or not and what its current state on the
1672 system is.  Each of these pieces of information is a single word.
1673
1674 <sect1 id="f-Config-Version"><tt/Config-Version/
1675 <p>
1676
1677 If a package is not installed or not configured, this field in
1678 <prgn/dpkg/'s status file records the last version of the package which
1679 was successfully configured.
1680
1681 <sect1 id="f-Conffiles"><tt/Conffiles/
1682 <p>
1683
1684 This field in <prgn/dpkg/'s status file contains information about the
1685 automatically-managed configuration files held by a package.  This
1686 field should <em/not/ appear anywhere in a package!
1687
1688 <sect1>Obsolete fields
1689 <p>
1690
1691 These are still recognised by <prgn/dpkg/ but should not appear anywhere
1692 any more.
1693
1694 <taglist compact>
1695
1696 <tag><tt/Revision/
1697 <tag><tt/Package-Revision/
1698 <tag><tt/Package_Revision/
1699 <item>
1700 The Debian revision part of the package version was at one point in a
1701 separate control file field.  This field went through several names.
1702
1703 <tag><tt/Recommended/
1704 <item>Old name for <tt/Recommends/
1705
1706 <tag><tt/Optional/
1707 <item>Old name for <tt/Suggests/.
1708
1709 <tag><tt/Class/
1710 <item>Old name for <tt/Priority/.
1711
1712 </taglist>
1713
1714 <chapt id="versions">Version numbering
1715 <p>
1716
1717 Every package has a version number, in its <tt/Version/ control file
1718 field.
1719 <p>
1720
1721 <prgn/dpkg/ imposes an ordering on version numbers, so that it can tell
1722 whether packages are being up- or downgraded and so that <prgn/dselect/
1723 can tell whether a package it finds available is newer than the one
1724 installed on the system.  The version number format has the most
1725 significant parts (as far as comparison is concerned) at the
1726 beginning.
1727 <p>
1728
1729 The version number format is:
1730 &lsqb<var/epoch/<tt/:/&rsqb;<var/upstream-version/&lsqb;<tt/-/<var/debian-revision/&rsqb;.
1731 <p>
1732
1733 The three components here are:
1734
1735 <taglist>
1736
1737 <tag><var/epoch/
1738 <item>
1739
1740 This is a single unsigned integer, which should usually be small.  It
1741 may be omitted, in which case zero is assumed.  If it is omitted then
1742 the <var/upstream-version/ may not contain any colons.
1743 <p>
1744
1745 It is provided to allow mistakes in the version numbers of older
1746 versions of a package, and also a package's previous version numbering
1747 schemes, to be left behind.
1748 <p>
1749
1750 <prgn/dpkg/ will not usually display the epoch unless it is essential
1751 (non-zero, or if the <var/upstream-version/ contains a colon);
1752 <prgn/dselect/ does not display epochs at all in the main part of the
1753 package selection display.
1754
1755 <tag><var/upstream-version/
1756 <item>
1757
1758 This is the main part of the version.  It is usually version number of
1759 the original (`upstream') package of which the <tt/.deb/ file has been
1760 made, if this is applicable.  Usually this will be in the same format
1761 as that specified by the upstream author(s); however, it may need to
1762 be reformatted to fit into <prgn/dpkg/'s format and comparison scheme.
1763 <p>
1764
1765 The comparison behaviour of <prgn/dpkg/ with respect to the
1766 <var/upstream-version/ is described below.  The <var/upstream-version/
1767 portion of the version number is mandatory.
1768 <p>
1769
1770 The <var/upstream-version/ may contain only alphanumerics and the
1771 characters <tt/+/ <tt/./ <tt/-/ <tt/:/ (full stop, plus, hyphen,
1772 colon) and should start with a digit.  If there is no
1773 <var/debian-revision/ then hyphens are not allowed; if there is no
1774 <var/epoch/ then colons are not allowed.
1775
1776 <tag><var/debian-revision/
1777 <item>
1778
1779 This part of the version represents the version of the modifications
1780 that were made to the package to make it a Debian binary package.  It
1781 is in the same format as the <var/upstream-version/ and <prgn/dpkg/
1782 compares it in the same way.
1783 <p>
1784
1785 It is optional; if it isn't present then the <var/upstream-version/
1786 may not contain a hyphen.  This format represents the case where a
1787 piece of software was written specifically to be turned into a Debian
1788 binary package, and so there is only one `debianization' of it and
1789 therefore no revision indication is required.
1790 <p>
1791
1792 It is conventional to restart the <var/debian-revision/ at <tt/1/ each
1793 time the <var/upstream-version/ is increased.
1794 <p>
1795
1796 <prgn/dpkg/ will break the <var/upstream-version/ and
1797 <var/debian-revision/ apart at the last hyphen in the string.  The
1798 absence of a <var/debian-revision/ compares earlier than the presence
1799 of one (but note that the <var/debian-revision/ is the least
1800 significant part of the version number).
1801 <p>
1802
1803 The <var/debian-revision/ may contain only alphanumerics and the
1804 characters <tt/+/ and <tt/./ (plus and full stop).
1805
1806 </taglist>
1807
1808 The <var/upstream-version/ and <var/debian-revision/ parts are
1809 compared by <prgn/dpkg/ using the same algorithm:
1810 <p>
1811
1812 The strings are compared from left to right.
1813 <p>
1814
1815 First the initial part of each string consisting entirely of non-digit
1816 characters is determined.  These two parts (one of which may be empty)
1817 are compared lexically.  If a difference is found it is returned.  The
1818 lexical comparison is a comparison of ASCII values modified so that
1819 all the letters sort earlier than all the non-letters.
1820 <p>
1821
1822 Then the initial part of the remainder of each string which consists
1823 entirely of digit characters is determined.  The numerical values of
1824 these two parts are compared, and any difference found is returned as
1825 the result of the comparison.  For these purposes an empty string
1826 (which can only occur at the end of one or both version strings being
1827 compared) counts as zero.
1828 <p>
1829
1830 These two steps are repeated (chopping initial non-digit strings and
1831 initial digit strings off from the start) until a difference is found
1832 or both strings are exhausted.
1833 <p>
1834
1835 Note that the purpose of epochs is to allow us to leave behind
1836 mistakes in version numbering, and to cope with situations where the
1837 version numbering changes.  It is <em/not/ there to cope with version
1838 numbers containing strings of letters which <prgn/dpkg/ cannot interpret
1839 (such as <tt/ALPHA/ or <tt/pre-/), or with silly orderings (the author
1840 of this manual has heard of a package whose versions went <tt/1.1/,
1841 <tt/1.2/, <tt/1.3/, <tt/1/, <tt/2.1/, <tt/2.2/, <tt/2/ and so forth).
1842 <p>
1843
1844 If an upstream package has problematic version numbers they should be
1845 converted to a sane form for use in the <tt/Version/ field.
1846 <p>
1847
1848 If you need to compare version numbers ina script, you may use
1849 <tt>dpkg --compare-versions ...</>. Type <tt>dpkg --help</> -->
1850 --for details on arguments.
1851
1852 <chapt id="maintainerscripts">Package maintainer scripts
1853 and installation procedure
1854 <sect>Introduction to package maintainer scripts
1855 <p>
1856
1857 It is possible supply scripts as part of a package which <prgn/dpkg/
1858 will run for you when your package is installed, upgraded or removed.
1859 <p>
1860
1861 These scripts should be the files <tt/preinst/, <tt/postinst/,
1862 <tt/prerm/ and <tt/postrm/ in the control area of the package.  They
1863 must be proper exectuable files; if they are scripts (which is
1864 recommended) they must start with the usual <tt/#!/ convention.  They
1865 should be readable and executable to anyone, and not world-writeable.
1866 <p>
1867
1868 <prgn/dpkg/ looks at the exit status from these scripts.  It is
1869 important that they exit with a non-zero status if there is an error,
1870 so that <prgn/dpkg/ can stop its processing.  For shell scripts this
1871 means that you <em/almost always/ need to use <tt/set -e/ (this is
1872 usually true when writing shell scripts, in fact).  It is also
1873 important, of course, that they don't exit with a non-zero status if
1874 everything went well.
1875 <p>
1876
1877 It is necessary for the error recovery procedures that the scripts be
1878 idempotent: ie, invoking the same script several times in the same
1879 situation should do no harm.  If the first call failed, or aborted
1880 half way through for some reason, the second call should merely do the
1881 things that were left undone the first time, if any, and exit with a
1882 success status.
1883 <p>
1884
1885 When a package is upgraded a combination of the scripts from the old
1886 and new packages is called in amongst the other steps of the upgrade
1887 procedure.  If your scripts are going to be at all complicated you
1888 need to be aware of this, and may need to check the arguments to your
1889 scripts.
1890 <p>
1891
1892 Broadly speaking the <prgn/preinst/ is called before (a particular
1893 version of) a package is installed, and the <prgn/postinst/ afterwards;
1894 the <prgn/prerm/ before (a version of) a package is removed and the
1895 <prgn/postrm/ afterwards.
1896 <p>
1897 <!--
1898  next paragraph by Guy Maor to close bug #2481
1899  --> 
1900
1901 Programs called from maintainer scripts should not normally have a
1902 path prepended to them. Before installation is started <prgn/dpkg/
1903 checks to see if the programs <prgn/ldconfig/,
1904 <prgn/start-stop-daemon/, <prgn/install-info/, and <prgn/update-rc.d/
1905 can be found via the <tt/PATH/ environment variable. Those programs,
1906 and any other program that one would expect to on the <tt/PATH/,
1907 should thus be invoked without an absolute pathname. Maintainer
1908 scripts should also not reset the <tt/PATH/, though they might choose
1909 to modify it by pre- or appending package-specific directories. These
1910 considerations really apply to all shell scripts.
1911
1912 <sect id="mscriptsinstact">Summary of ways maintainer scripts are called
1913 <p>
1914
1915 <list compact>
1916 <item><var/new-preinst/ <tt/install/
1917 <item><var/new-preinst/ <tt/install/ <var/old-version/
1918 <item><var/new-preinst/ <tt/upgrade/ <var/old-version/
1919 <item><var/old-preinst/ <tt/abort-upgrade/ <var/new-version/
1920 </list>
1921 <p>
1922
1923 <list compact>
1924 <item><var/postinst/ <tt/configure/ <var/most-recently-configured-version/
1925 <item><var/old-postinst/ <tt/abort-upgrade/ <var/new version/
1926 <item><var/conflictor's-postinst/ <tt/abort-remove/
1927     <tt/in-favour/ <var/package/ <var/new-version/
1928 <item><var/deconfigured's-postinst/ <tt/abort-deconfigure/
1929     <tt/in-favour/ <var/failed-install-package/ <var/version/
1930     <tt/removing/ <var/conflicting-package/ <var/version/
1931 </list>
1932 <p>
1933
1934 <list compact>
1935 <item><var/prerm/ <tt/remove/
1936 <item><var/old-prerm/ <tt/upgrade/ <var/new-version/
1937 <item><var/new-prerm/ <tt/failed-upgrade/ <var/old-version/
1938 <item><var/conflictor's-prerm/ <tt/remove/ <tt/in-favour/
1939     <var/package/ <var/new-version/
1940 <item><var/deconfigured's-prerm/ <tt/deconfigure/
1941     <tt/in-favour/ <var/package-being-installed/ <var/version/
1942     <tt/removing/ <var/conflicting-package/ <var/version/
1943 </list>
1944 <p>
1945
1946 <list compact>
1947 <item><var/postrm/ <tt/remove/
1948 <item><var/postrm/ <tt/purge/
1949 <item><var/old-postrm/ <tt/upgrade/ <var/new-version/
1950 <item><var/new-postrm/ <tt/failed-upgrade/ <var/old-version/
1951 <item><var/new-postrm/ <tt/abort-install/
1952 <item><var/new-postrm/ <tt/abort-install/ <var/old-version/
1953 <item><var/new-postrm/ <tt/abort-upgrade/ <var/old-version/
1954 <item><var/disappearer's-postrm/ <tt/disappear/ <var/overwriter/ <var/new-version/
1955 </list>
1956
1957
1958 <sect id="unpackphase">Details of unpack phase of installation or upgrade
1959 <p>
1960
1961 The procedure on installation/upgrade/overwrite/disappear (ie, when
1962 running <tt/dpkg --unpack/, or the unpack stage of <tt/dpkg
1963 --install/) is as follows.  In each case if an error occurs the
1964 actions in are general run backwards - this means that the maintainer
1965 scripts are run with different arguments in reverse order.  These are
1966 the `error unwind' calls listed below.
1967
1968 <enumlist>
1969 <item>
1970
1971 <enumlist>
1972 <item>
1973 If a version the package is already
1974 installed, call
1975 <example>
1976 <var/old-prerm/ upgrade <var/new-version/
1977 </example>
1978
1979 <item>
1980 If this gives an error (ie, a non-zero exit status), dpkg will
1981 attempt instead:
1982 <example>
1983 <var/new-prerm/ failed-upgrade <var/old-version/
1984 </example>
1985 Error unwind, for both the above cases:
1986 <example>
1987 <var/old-postinst/ abort-upgrade <var/new-version/
1988 </example>
1989
1990 </enumlist>
1991
1992 <item>
1993 If a `conflicting' package is being removed at the same time:
1994 <enumlist>
1995
1996 <item>
1997 If any packages depended on that conflicting package and
1998 <tt/--auto-deconfigure/ is specified, call, for each such package:
1999 <example>
2000 <var/deconfigured's-prerm/ deconfigure \
2001     in-favour <var/package-being-installed/ <var/version/ \
2002     removing <var/conflicting-package/ <var/version/
2003 </example>
2004 Error unwind:
2005 <example>
2006 <var/deconfigured's-postinst/ abort-deconfigure \
2007     in-favour <var/package-being-installed-but-failed/ <var/version/ \
2008     removing <var/conflicting-package/ <var/version/
2009 </example>
2010 The deconfigured packages are marked as requiring configuration, so
2011 that if <tt/--install/ is used they will be configured again if
2012 possible.
2013
2014 <item>
2015 To prepare for removal of the conflicting package, call:
2016 <example>
2017 <var/conflictor's-prerm/ remove in-favour <var/package/ <var/new-version/
2018 </example>
2019 Error unwind:
2020 <example>
2021 <var/conflictor's-postinst/ abort-remove \
2022     in-favour <var/package/ <var/new-version/
2023 </example>
2024
2025 </enumlist>
2026
2027 <item>
2028 <enumlist>
2029 <item>
2030 If the package is being upgraded, call:
2031 <example>
2032 <var/new-preinst/ upgrade <var/old-version/
2033 </example>
2034
2035 <item>
2036 Otherwise, if the package had some configuration files from a previous
2037 version installed (ie, it is in the `configuration files only' state):
2038 <example>
2039 <var/new-preinst/ install <var/old-version/
2040 </example>
2041
2042 <item>
2043 Otherwise (ie, the package was completely purged):
2044 <example>
2045 <var/new-preinst/ install
2046 </example>
2047 Error unwind versions, respectively:
2048 <example>
2049 <var/new-postrm/ abort-upgrade <var/old-version/
2050 <var/new-postrm/ abort-install <var/old-version/
2051 <var/new-postrm/ abort-install
2052 </example>
2053
2054 </enumlist>
2055
2056 <item>
2057 The new package's files are unpacked, overwriting any that may be on
2058 the system already, for example any from the old version of the same
2059 package or from another package (backups of the old files are left
2060 around, and if anything goes wrong dpkg will attempt to put them back
2061 as part of the error unwind).
2062 <p>
2063
2064 It is an error for a package to contains files which are on the system
2065 in another package, unless <tt/Replaces/ is used (see
2066 <ref id="replaces">).  Currently the <tt/--force-overwrite/ flag is
2067 enabled, downgrading it to a warning, but this may not always be the
2068 case.
2069 <p>
2070
2071 It is a more serious error for a package to contain a plain file or
2072 other kind of nondirectory where another package has a directory
2073 (again, unless <tt/Replaces/ is used).  This error can be overridden
2074 if desired using <tt/--force-overwrite-dir/, but this is not advisable.
2075 <p>
2076
2077 Packages which overwrite each other's files produce behaviour which
2078 though deterministic is hard for the system administrator to
2079 understand.  It can easily lead to `missing' programs if, for example,
2080 a package is installed which overwrites a file from another package,
2081 and is then removed again.<footnote>Part of the problem is due to what
2082 is arguably a bug in <prgn/dpkg/.</footnote>
2083 <p>
2084
2085 A directory will never be replaced by a symbolic links to a directory
2086 or vice versa; instead, the existing state (symlink or not) will be
2087 left alone and <prgn/dpkg/ will follow the symlink if there is one.
2088
2089 <item>
2090
2091 <enumlist>
2092 <item>
2093 If the package is being upgraded, call
2094 <example>
2095 <var/old-postrm/ upgrade <var/new-version/
2096 </example>
2097
2098 <item>
2099 If this fails, <prgn/dpkg/ will attempt:
2100 <example>
2101 <var/new-postrm/ failed-upgrade <var/old-version/
2102 </example>
2103 Error unwind, for both cases:
2104 <example>
2105 <var/old-preinst/ abort-upgrade <var/new-version/
2106 </example>
2107
2108 </enumlist>
2109
2110 This is the point of no return - if <prgn/dpkg/ gets this far, it won't
2111 back off past this point if an error occurs.  This will leave the
2112 package in a fairly bad state, which will require a successful
2113 reinstallation to clear up, but it's when <prgn/dpkg/ starts doing
2114 things that are irreversible.
2115
2116 <item>
2117 Any files which were in the old version of the package but not in the
2118 new are removed.
2119
2120 <item>
2121 The new file list replaces the old.
2122
2123 <item>
2124 The new maintainer scripts replace the old.
2125
2126 <item>
2127 Any packages all of whose files have been overwritten during the
2128 installation, and which aren't required for dependencies, are considered
2129 to have been removed.  For each such package,
2130
2131 <enumlist>
2132 <item>
2133 <prgn/dpkg/ calls:
2134 <example>
2135 <var/disappearer's-postrm/ disappear \
2136     <var/overwriter/ <var/overwriter-version/
2137 </example>
2138
2139 <item>
2140 The package's maintainer scripts are removed.
2141
2142 <item>
2143 It is noted in the status database as being in a sane state, namely
2144 not installed (any conffiles it may have are ignored, rather than
2145 being removed by <prgn/dpkg/).  Note that disappearing packages do not
2146 have their prerm called, because <prgn/dpkg/ doesn't know in advance
2147 that the package is going to vanish.
2148
2149 </enumlist>
2150
2151 <item>
2152 Any files in the package we're unpacking that are also listed in the
2153 file lists of other packages are removed from those lists.  (This will
2154 lobotomise the file list of the `conflicting' package if there is one.)
2155
2156 <item>
2157 The backup files made during installation, above, are deleted.
2158
2159 <item>
2160 The new package's status is now sane, and recorded as `unpacked'.  Here
2161 is another point of no return - if the conflicting package's removal
2162 fails we do not unwind the rest of the installation; the conflicting
2163 package is left in a half-removed limbo.
2164
2165 <item>
2166 If there was a conflicting package we go and do the removal actions
2167 (described below), starting with the removal of the conflicting
2168 package's files (any that are also in the package being installed
2169 have already been removed from the conflicting package's file list,
2170 and so do not get removed now).
2171
2172 </enumlist>
2173
2174 <sect>Details of configuration
2175 <p>
2176
2177 When we configure a package (this happens with <tt/dpkg --install/, or
2178 with <tt/--configure/), we first update the conffiles and then call:
2179 <example>
2180 <var/postinst/ configure <var/most-recently-configured-version/
2181 </example>
2182 <p>
2183
2184 No attempt is made to unwind after errors during configuration.
2185 <p>
2186
2187 If there is no most recently configured version <prgn/dpkg/ will pass a
2188 null argument; older versions of dpkg may pass
2189 <tt>&lt;unknown&gt;</tt> (including the angle brackets) in this case.
2190 Even older ones do not pass a second argument at all, under any
2191 circumstances.
2192
2193 <sect>Details of removal and/or configuration purging
2194 <p>
2195
2196 <enumlist>
2197 <item>
2198 <example>
2199 <var/prerm/ remove
2200 </example>
2201
2202 <item>
2203 The package's files are removed (except conffiles).
2204
2205 <item>
2206 <example>
2207 <var/postrm/ remove
2208 </example>
2209
2210 <item>
2211 All the maintainer scripts except the postrm are removed.
2212 <p>
2213
2214 If we aren't purging the package we stop here.  Note that packages
2215 which have no postrm and no conffiles are automatically purged when
2216 removed, as there is no difference except for the <prgn/dpkg/ status.
2217
2218 <item>
2219 The conffiles and any backup files (<tt/~/-files, <tt/#*#/ files,
2220 <tt/%/-files, <tt/.dpkg-{old,new,tmp}/, etc.) are removed.
2221
2222 <item>
2223 <example>
2224 <var/postrm/ purge
2225 </example>
2226
2227 <item>
2228 The package's file list is removed.
2229
2230 </enumlist>
2231
2232 No attempt is made to unwind after errors during removal.
2233
2234
2235 <chapt id="descriptions">Descriptions of packages - the
2236 <tt/Description/ field
2237 <p>
2238
2239 The <tt/Description/ control file field is used by <prgn/dselect/ when
2240 the user is selecting which packages to install and by <prgn/dpkg/
2241 when it displays information about the status of packages and so
2242 forth.  It is included on the FTP site in the <prgn/Packages/ files,
2243 and may also be used by the Debian WWW pages.
2244 <p>
2245
2246 The description is intended to describe the program to a user who has
2247 never met it before so that they know whether they want to install it.
2248 It should also give information about the significant dependencies and
2249 conflicts between this package and others, so that the user knows why
2250 these dependencies and conflicts have been declared.
2251 <p>
2252
2253 The field's format is as follows:
2254 <example>
2255 Description: <var/single line synopsis/
2256  <var/extended description over several lines/
2257 </example>
2258 <p>
2259
2260 The synopsis is often printed in lists of packages and so forth, and
2261 should be as informative as possible.  Every package should also have
2262 an extended description.
2263 <p>
2264
2265 <sect>Types of formatting line in the extended description
2266 <p>
2267
2268 <list>
2269 <item>
2270 Those starting with a single space are part of a paragraph.
2271 Successive lines of this form will be word-wrapped when displayed.
2272 The leading space will usually be stripped off.
2273
2274 <item>
2275 Those starting with two or more spaces.  These will be displayed
2276 verbatim.  If the display cannot be panned horizontally the
2277 displaying program will linewrap them `hard' (ie, without taking
2278 account of word breaks).  If it can they will be allowed to trail
2279 off to the right.  None, one or two initial spaces may be deleted,
2280 but the number of spaces deleted from each line will be the same
2281 (so that you can have indenting work correctly, for example).
2282
2283 <item>
2284 Those containing a single space followed by a single full stop
2285 character.  These are rendered as blank lines.  This is the <em/only/
2286 way to get a blank line - see below.
2287
2288 <item>
2289 Those containing a space, a full stop and some more characters.  These
2290 are for future expansion.  Do not use them.
2291 </list>
2292
2293 <sect>Notes about writing descriptions
2294 <p>
2295
2296 <em/Always/ start extended description lines with at least one
2297 whitespace character.  Fields in the control file and in the Packages
2298 file are separated by field names starting in the first column, just
2299 as message header fields are in RFC822.  Forgetting the whitespace
2300 will cause <prgn/dpkg-deb/<footnote>Version 0.93.23 or
2301 later.</footnote> to produce a syntax error when trying to build the
2302 package.  If you force it to build anyway <prgn/dpkg/ will refuse to
2303 install the resulting mess.
2304 <p>
2305
2306 <em/Do not/ include any completely <em/empty/ lines. These separate
2307 different records in the Packages file and different packages in the
2308 <tt>debian/control</> file, and are forbidden in package control
2309 files.  See the previous paragraph for what happens if you get this
2310 wrong.
2311 <p>
2312
2313 The single line synopsis should be kept brief - certainly under 80
2314 characters.  <prgn/dselect/ displays between 25 and 49 characters
2315 without panning if you're using an 80-column terminal, depending on
2316 what display options are in effect.
2317 <p>
2318
2319 Do not include the package name in the synopsis line.  The display
2320 software knows how to display this already, and you do not need to
2321 state it.  Remember that in many situations the user may only see
2322 the synopsis line - make it as informative as you can.
2323 <p>
2324
2325 The extended description should describe what the package does and
2326 how it relates to the rest of the system (in terms of, for
2327 example, which subsystem it is which part of).
2328 <p>
2329
2330 The blurb that comes with a program in its announcements and/or
2331 <prgn/README/ files is rarely suitable for use in a description.  It
2332 is usually aimed at people who are already in the community where the
2333 package is used.  The description field needs to make sense to anyone,
2334 even people who have no idea about any of the
2335 things the package deals with.
2336 <p>
2337
2338 Put important information first, both in the synopis and extended
2339 description.  Sometimes only the first part of the synopsis or of
2340 the description will be displayed.  You can assume that there will
2341 usually be a way to see the whole extended description.
2342 <p>
2343
2344 You may include information about dependencies and so forth in the
2345 extended description, if you wish.
2346 <p>
2347
2348 Do not use tab characters.  Their effect is not predictable.
2349 <p>
2350
2351 Do not try to linewrap the summary (the part on the same line as the
2352 field name <tt/Description/) into the extended description.  This will
2353 not work correctly when the full description is displayed, and makes
2354 no sense where only the summary is available.
2355
2356 <sect>Example description in control file for Smail
2357 <p>
2358
2359 <example>
2360 Package: smail
2361 Version: 3.1.29.1-13
2362 Maintainer: Ian Jackson &lt;iwj10@cus.cam.ac.uk&gt;
2363 Recommends: pine | mailx | elm | emacs | mail-user-agent
2364 Suggests: metamail
2365 Depends: cron, libc5
2366 Conflicts: sendmail
2367 Provides: mail-transport-agent
2368 Description: Electronic mail transport system.
2369  Smail is the recommended mail transport agent (MTA) for Debian.
2370  .
2371  An MTA is the innards of the mail system - it takes messages from
2372  user-friendly mailer programs and arranges for them to be delivered
2373  locally or passed on to other systems as required.
2374  .
2375  In order to make use of it you must have one or more user level
2376  mailreader programs such as elm, pine, mailx or Emacs (which has Rmail
2377  and VM as mailreaders) installed.  If you wish to send messages other
2378  than just to other users of your system you must also have appropriate
2379  networking support, in the form of IP or UUCP.
2380 </example>
2381
2382 <chapt id="relationships">Declaring relationships between packages
2383 <p>
2384
2385 Packages can declare in their control file that they have certain
2386 relationships to other packages - for example, that they may not be
2387 installed at the same time as certain other packages, and/or that they
2388 depend on the presence of others, or that they should overwrite files
2389 in certain other packages if present.
2390 <p>
2391
2392 This is done using the <tt/Depends/, <tt/Recommends/, <tt/Suggests/,
2393 <tt/Conflicts/, <tt/Provides/ and <tt/Replaces/ control file fields.
2394 <p>
2395
2396 <sect id="depsyntax">Syntax of relationship fields
2397 <p>
2398
2399 These fields all have a uniform syntax.  They are a list of package
2400 names separated by commas.
2401 <p>
2402
2403 In <tt/Depends/, <tt/Recommends/, <tt/Suggests/ and <tt/Pre-Depends/
2404 (the fields which declare dependencies of the package in which they
2405 occur on other packages) these package names may also be lists of
2406 alternative package names, separated by vertical bar symbols <tt/|/
2407 (pipe symbols).
2408 <p>
2409
2410 All the fields except <tt/Provides/ may restrict their applicability
2411 to particular versions of each named package.  This is done in
2412 parentheses after each individual package name; the parentheses should
2413 contain a relation from the list below followed by a version number,
2414 in the format described in <ref id="versions">.
2415 <p>
2416
2417 The relations allowed are
2418 <tt/&lt;&lt;/,
2419 <tt/&lt;=/,
2420 <tt/=/,
2421 <tt/&gt;=/ and
2422 <tt/&gt;&gt;/
2423 for strictly earlier, earlier or equal, exactly equal, later or equal
2424 and strictly later, respectively.  The forms <tt/&lt;/ and <tt/&gt;/
2425 were used to mean earlier/later or equal, rather than strictly
2426 earlier/later, so they should not appear in new packages (though
2427 <prgn/dpkg/ still supports them).
2428 <p>
2429
2430 Whitespace may appear at any point in the version specification, and
2431 must appear where it's necessary to disambiguate; it is not otherwise
2432 significant.  For consistency and in case of future changes to
2433 <prgn/dpkg/ it is recommended that a single space be used after a
2434 version relationship and before a version number; it is usual also to
2435 put a single space after each comma, on either side of each vertical
2436 bar, and before each open parenthesis.
2437 <p>
2438
2439 For example:
2440 <example>
2441 Package: metamail
2442 Version: 2.7-3
2443 Depends: libc5 (>= 5.2.18-4), mime-support, csh | tcsh
2444 </example>
2445
2446 <sect>Dependencies - <tt/Depends/, <tt/Recommends/, <tt/Suggests/, <tt/Pre-Depends/
2447 <p>
2448
2449 These four fields are used to declare a dependency by one package on
2450 another.  They appear in the depending package's control file.
2451 <p>
2452
2453 All but <tt/Pre-Depends/ (discussed below) take effect <em/only/ when
2454 a package is to be configured.  They do not prevent a package being on
2455 the system in an unconfigured state while its dependencies are
2456 unsatisfied, and it is possible to replace a package whose
2457 dependencies are satisfied and which is properly installed with a
2458 different version whose dependencies are not and cannot be satisfied;
2459 when this is done the depending package will be left unconfigured
2460 (since attempts to configure it will give errors) and will not
2461 function properly.
2462 <p>
2463
2464 For this reason packages in an installation run are usually all
2465 unpacked first and all configured later; this gives later versions of
2466 packages with dependencies on later versions of other packages the
2467 opportunity to have their dependencies satisfied.
2468 <p>
2469
2470 Thus <tt/Depends/ allows package maintainers to impose an order in
2471 which packages should be configured.
2472
2473 <taglist>
2474 <tag><tt/Depends/
2475 <item>
2476
2477 This declares an absolute dependency.
2478 <p>
2479
2480 <prgn/dpkg/ will not configure
2481 packages whose dependencies aren't satisfied.  If it is asked to make
2482 an installation which would cause an installed package's dependencies
2483 to become unsatisfied it will complain<footnote>Current versions
2484 (1.2.4) of <prgn/dpkg/ have a bug in this area which will cause some of
2485 these problems to be ignored.</footnote>, unless
2486 <tt/--auto-deconfigure/ is specified, in which case those packages
2487 will be deconfigured before the installation proceeds.
2488 <p>
2489
2490 <prgn/dselect/ makes it hard for the user to select packages for
2491 installation, removal or upgrade in a way that would mean that
2492 packages' <prgn/Depends/ fields would be unsatisfied.  The user can
2493 override this if they wish, for example if they know that <prgn/dselect/
2494 has an out-of-date view of the real package relationships.
2495 <p>
2496
2497 The <tt/Depends/ field should be used if the depended-on package is
2498 required for the depending package to provide a significant amount of
2499 functionality.
2500
2501 <tag><tt/Recommends/
2502 <item>
2503 This declares a strong, but not absolute, dependency.
2504 <p>
2505
2506 <tt/Recommends/ is ignored by <prgn/dpkg/, so that users using the
2507 command-line (who are presumed to know what they're doing) will not be
2508 impeded.
2509 <p>
2510
2511 It is treated by <prgn/dselect/ exactly as <tt/Depends/ is; this makes
2512 it hard for the user to select things so as to leave <tt/Recommends/
2513 fields unsatisfied, but they are able to do so by being persistent.
2514 <p>
2515
2516 The <tt/Recommends/ field should list packages that would be found
2517 together with this one in all but unusual installations.
2518
2519 <tag><tt/Suggests/
2520 <item>
2521
2522 This is used to declare that one package may be more useful with one
2523 or more others.  Using this field tells the packaging system and the
2524 user that the listed packages are be related to this one and can
2525 perhaps enhance its usefulness, but that installing this one without
2526 them is perfectly reasonable.
2527 <p>
2528
2529 <prgn/dselect/ will offer suggsted packages to the system administrator
2530 when they select the suggesting package, but the default is not to
2531 install the suggested package.
2532
2533 <tag><tt/Pre-Depends/
2534 <item>
2535
2536 This field is like <tt/Depends/, except that it also forces <prgn/dpkg/
2537 to complete installation of the packages named before even starting
2538 the installation of the package which declares the predependency.
2539 <p>
2540
2541 <prgn/dselect/ checks for predependencies when it is doing an
2542 installation run, and will attempt to find the packages which are
2543 required to be installed first and do so in the right order.
2544 <p>
2545
2546 However, this process is slow (because it requires repeated
2547 invocations of <prgn/dpkg/) and troublesome (because it requires
2548 guessing where to find the appropriate files).
2549 <p>
2550
2551 For these reasons, and because this field imposes restrictions on the
2552 order in which packages may be unpacked (which can be difficult for
2553 installations from multipart media, for example), <tt/Pre-Depends/
2554 should be used sparingly, preferably only by packages whose premature
2555 upgrade or installation would hamper the ability of the system to
2556 continue with any upgrade that might be in progress.
2557 <p>
2558
2559 When the package declaring it is being configured, a
2560 <tt/Pre-Dependency/ will be considered satisfied only if the depending
2561 package has been correctly configured, just as if an ordinary
2562 <tt/Depends/ had been used.
2563 <p>
2564
2565 However, when a package declaring a predependency is being unpacked
2566 the predependency can be satisfied even if the depended-on package(s)
2567 are only unpacked or half-configured, provided that they have been
2568 configured correctly at some point in the past (and not removed or
2569 partially removed since).  In this case both the previously-configured
2570 and currently unpacked or half-configured versions must satisfy any
2571 version clause in the <tt/Pre-Depends/ field.
2572
2573 </taglist>
2574
2575 When selecting which level of dependency to use you should consider
2576 how important the depended-on package is to the functionality of the
2577 one declaring the dependency.  Some packages are composed of
2578 components of varying degrees of importance.  Such a package should
2579 list using <tt/Depends/ the package(s) which are required by the more
2580 important components.  The other components' requirements may be
2581 mentioned as Suggestions or Recommendations, as appropriate to the
2582 components' relative importance.
2583
2584 <sect1>Dependencies on shared libraries
2585 <p>
2586
2587 The dependency fields listed above are used by packages which need
2588 shared libraries to declare dependencies on the appropriate packages.
2589 <p>
2590
2591 These dependencies are usually determined automatically using
2592 <prgn/dpkg-shlibdeps/ and inserted in the package control file using
2593 the control file substitution variables mechanism; see <ref
2594 id="srcsubstvars"> and <ref id="sourcetools">.
2595
2596 <sect1>Deconfiguration due to removal during bulk installations
2597 <p>
2598
2599 If <prgn/dpkg/ would like to remove a package due to a conflict, as
2600 described above, but this would violate a dependency of some other
2601 package on the system, <prgn/dpkg/ will usually not remove the
2602 conflicting package and halt with an error.
2603 <p>
2604
2605 However, if the <tt/--auto-deconfigure/ (<tt/-B/) option is used
2606 <prgn/dpkg/ will automatically `deconfigure' the package with the
2607 problematic dependency, so that the conflicting package can be removed
2608 and the package we're trying to install can be installed.  If
2609 <prgn/dpkg/ is being asked to install packages (rather than just
2610 unpacking them) it will try to reconfigure the package when it has
2611 unpacked all its arguments, in the hope that one of the other packages
2612 it is installing will satisfy the problematic dependency.
2613 <p>
2614
2615 <prgn/dselect/ supplies this argument to <prgn/dpkg/ when it invokes it,
2616 so that bulk installations proceed smoothly.
2617
2618 <sect id="conflicts">Alternative packages - <tt/Conflicts/ and <tt/Replaces/
2619 <p>
2620
2621 When one package declares a conflict with another <prgn/dpkg/ will
2622 refuse to allow them to be installed on the system at the same time.
2623 <p>
2624
2625 If one package is to be installed, the other must be removed first -
2626 if the package being installed is marked as replacing (<ref
2627 id="replaces">) the one on the system, or the one on the system is
2628 marked as deselected, or both packages are marked <tt/Essential/, then
2629 <prgn/dpkg/ will automatically remove the package which is causing the
2630 conflict, otherwise it will halt the installation of the new package
2631 with an error.
2632 <p>
2633
2634 <prgn/dselect/ makes it hard to select conflicting packages, though the
2635 user can override this if they wish.  If they do not override it then
2636 <prgn/dselect/ will select one of the packages for removal, and the user
2637 must make sure it is the right one.  In the future <prgn/dselect/ will
2638 look for the presence of a <tt/Replaces/ field to help decide which
2639 package should be installed and which removed.
2640 <p>
2641
2642 A package will not cause a conflict merely because its configuration
2643 files are still installed; it must be at least half-installed.
2644 <p>
2645
2646 A special exception is made for packages which declare a conflict with
2647 their own package name, or with a virtual package which they provide
2648 (see below): this does not prevent their installation, and allows a
2649 package to conflict with others providing a replacement for it.  You
2650 use this feature when you want the package in question to be the only
2651 package providing something.
2652 <p>
2653
2654 A <tt/Conflicts/ entry should almost never have an `earlier than'
2655 version clause.  This would prevent <prgn/dpkg/ from upgrading or
2656 installing the package which declared such a conflict until the
2657 upgrade or removal of the conflicted-with package had been completed.
2658 This aspect of installation ordering is not handled by <prgn/dselect/,
2659 so that the use <tt/Conflicts/ in this way is likely to cause problems
2660 for `bulk run' upgrades and installations.
2661 <p>
2662
2663
2664 <sect id="virtual">Virtual packages - <tt/Provides/
2665 <p>
2666
2667 As well as the names of actual (`concrete') packages, the package
2668 relationship fields <tt/Depends/, <tt/Recommends/, <tt/Suggests/ and
2669 <tt/Conflicts/ may mention virtual packages.
2670 <p>
2671
2672 A virtual package is one which appears in the <tt/Provides/ control
2673 file field of another package.  The effect is as if the package(s)
2674 which provide a particular virtual package name had been listed by
2675 name everywhere were the virtual package name appears.
2676 <p>
2677
2678 If there are both a real and a virtual package of the same name then
2679 the dependency may be satisfied (or the conflict caused) by either the
2680 real package or any of the virtual packages which provide it.  This is
2681 so that, for example, supposing we have
2682 <example>
2683 Package: vm
2684 Depends: emacs
2685 </example>
2686 and someone else releases an xemacs package they can say
2687 <example>
2688 Package: xemacs
2689 Provides: emacs
2690 </example>
2691 and all will work in the interim (until a purely virtual package name
2692 is decided on and the <tt/emacs/ and <tt/vm/ packages are changed to
2693 use it).
2694 <p>
2695
2696 If a dependency or a conflict has a version number attached then only
2697 real packages will be considered to see whether the relationship is
2698 satisfied (or the prohibition violated, for a conflict) - it is
2699 assumed that a real package which provides virtual package is not of
2700 the `right' version.  So, a <tt/Provides/ field may not contain
2701 version numbers, and the version number of the concrete package which
2702 provides a particular virtual package will not be looked at when
2703 considering a dependency on or conflict with the virtual package name.
2704 <p>
2705
2706 It is likely that the ability will be added in a future release of
2707 <prgn/dpkg/ to specify a version number for each virtual package it
2708 provides.  This feature is not yet present, however, and is expected
2709 to be used only infrequently.
2710 <p>
2711
2712 If you want to specify which of a set of real packages should be the
2713 default to satisfy a particular dependency on a virtual package, you
2714 should list the real package as alternative before the virtual.
2715 <p>
2716
2717
2718 <sect id="replaces"><tt/Replaces/ - overwriting files and replacing packages
2719 <p>
2720
2721 The <tt/Replaces/ control file field has two purposes, which come into
2722 play in different situations.
2723 <p>
2724
2725 Virtual packages (<ref id="virtual">) are not considered when looking
2726 at a <tt/Replaces/ field - the packages declared as being replaced
2727 must be mentioned by their real names.
2728
2729 <sect1>Overwriting files in other packages
2730 <p>
2731
2732 Firstly, as mentioned before, it is usually an error for a package to
2733 contains files which are on the system in another package, though
2734 currently the <tt/--force-overwrite/ flag is enabled by default,
2735 downgrading the error to a warning,
2736 <p>
2737
2738 If the overwriting package declares that it replaces the one
2739 containing the file being overwritten then <prgn/dpkg/ will proceed, and
2740 replace the file from the old package with that from the new.  The
2741 file will no longer be listed as `owned' by the old package.
2742 <p>
2743
2744 If a package is completely replaced in this way, so that <prgn/dpkg/
2745 does not know of any files it still contains, it is considered to have
2746 disappeared.  It will be marked as not wanted on the system (selected
2747 for removal) and not installed.  Any conffiles details noted in the
2748 package will be ignored, as they will have been taken over by the
2749 replacing package(s).  The package's <prgn/postrm/ script will be run to
2750 allow the package to do any final cleanup required.
2751 See <ref id="mscriptsinstact">.
2752 <p>
2753
2754 In the future <prgn/dpkg/ will discard files which overwrite those from
2755 another package which declares that it replaces the one being
2756 installed (so that you can install an older version of a package
2757 without problems).
2758 <p>
2759
2760 This usage of <tt/Replaces/ only takes effect when both packages are
2761 at least partially on the system at once, so that it can only happen
2762 if they do not conflict or if the conflict has been overridden.
2763
2764 <sect1>Replacing whole packages, forcing their removal
2765 <p>
2766
2767 Secondly, <tt/Replaces/ allows <prgn/dpkg/ and <prgn/dselect/ to resolve
2768 which package should be removed when a conflict - see
2769 <ref id="conflicts">.  This usage only takes effect when the two
2770 packages <em/do/ conflict, so that the two effects do not interfere
2771 with each other.
2772 <p>
2773
2774 <sect>Defaults for satisfying dependencies - ordering
2775 <p>
2776
2777 Ordering is significant in dependency fields.
2778 <p>
2779
2780 Usually dselect will suggest to the user that they select the package
2781 with the most `fundamental' class (eg, it will prefer Base packages to
2782 Optional ones), or the one that they `most wanted' to select in some
2783 sense.
2784 <p>
2785
2786 In the absence of other information <prgn/dselect/ will offer a
2787 default selection of the first named package in a list of
2788 alternatives.
2789 <p>
2790
2791 However, there is no way to specify the `order' of several packages
2792 which all provide the same thing, when that thing is listed as a
2793 dependency.
2794 <p>
2795
2796 Therefore a dependency on a virtual package should contain a concrete
2797 package name as the first alternative, so that this is the default.
2798 <p>
2799
2800 For example, consider the set of packages:
2801
2802 <example>
2803 Package: glibcdoc
2804 Recommends: info-browser
2805
2806 Package: info
2807 Provides: info-browser
2808
2809 Package: emacs
2810 Provides: info-browser
2811 </example>
2812 <p>
2813
2814 If <prgn/emacs/ and <prgn/info/ both have the same priority then
2815 <prgn/dselect/'s choice is essentially random.  Better would be
2816 <example>
2817 Package: glibcdoc
2818 Recommends: info | info-browser
2819 </example>
2820 so that <prgn/dselect/ defaults to selecting the lightweight standalone
2821 info browser.
2822
2823
2824
2825 <chapt id="conffiles">Configuration file handling
2826 <p>
2827
2828 <prgn/dpkg/ can do a certain amount of automatic handling of package
2829 configuration files.
2830 <p>
2831
2832 Whether this mechanism is appropriate depends on a number of factors,
2833 but basically there are two approaches to any particular configuration
2834 file.
2835 <p>
2836
2837 The easy method is to ship a best-effort configuration in the package,
2838 and use <prgn/dpkg/'s conffile mechanism to handle updates.  If the user
2839 is unlikely to want to edit the file, but you need them to be able to
2840 without losing their changes, and a new package with a changed version
2841 of the file is only released infrequently, this is a good approach.
2842 <p>
2843
2844 The hard method is to build the configuration file from scratch in the
2845 <prgn/postinst/ script, and to take the responsibility for fixing any
2846 mistakes made in earlier versions of the package automatically.  This
2847 will be appropriate if the file is likely to need to be different on
2848 each system.
2849
2850 <sect>Automatic handling of configuration files by <prgn/dpkg/
2851 <p>
2852
2853 A package may contain a control area file called <tt/conffiles/.  This
2854 file should be a list of filenames of configuration files needing
2855 automatic handling, separated by newlines.  The filenames should be
2856 absolute pathnames, and the files referred to should actually exist in
2857 the package.
2858 <p>
2859
2860 When a package is upgraded <prgn/dpkg/ will process the configuration
2861 files during the configuration stage, shortly before it runs the
2862 package's <prgn/postinst/ script,
2863 <p>
2864
2865 For each file it checks to see whether the version of the file
2866 included in the package is the same as the one that was included in
2867 the last version of the package (the one that is being upgraded
2868 from); it also compares the version currently installed on the system
2869 with the one shipped with the last version.
2870 <p>
2871
2872 If neither the user nor the package maintainer has changed the file,
2873 it is left alone.  If one or the other has changed their version, then
2874 the changed version is preferred - ie, if the user edits their file,
2875 but the package maintainer doesn't ship a different version, the
2876 user's changes will stay, silently, but if the maintainer ships a new
2877 version and the user hasn't edited it the new version will be
2878 installed (with an informative message).  If both have changed their
2879 version the user is prompted about the problem and must resolve the
2880 differences themselves.
2881 <p>
2882
2883 The comparisons are done by calculating the MD5 message digests of the
2884 files, and storing the MD5 of the file as it was included in the most
2885 recent version of the package.
2886 <p>
2887
2888 When a package is installed for the first time <prgn/dpkg/ will install
2889 the file that comes with it, unless that would mean overwriting a file
2890 already on the filesystem.
2891 <p>
2892
2893 However, note that <prgn/dpkg/ will <em/not/ replace a conffile that
2894 was removed by the user (or by a script).  This is necessary because
2895 with some programs a missing file produces an effect hard or
2896 impossible to achieve in another way, so that a missing file needs to
2897 be kept that way if the user did it.
2898 <p>
2899
2900 Note that a package should <em/not/ modify a <prgn/dpkg/-handled
2901 conffile in its maintainer scripts.  Doing this will lead to
2902 <prgn/dpkg/ giving the user confusing and possibly dangerous options
2903 for conffile update when the package is upgraded.
2904
2905 <sect>Fully-featured maintainer script configuration handling
2906 <p>
2907
2908 For files which contain site-specific information such as the hostname
2909 and networking details and so forth, it is better to create the file
2910 in the package's <prgn/postinst/ script.
2911 <p>
2912
2913 This will typically involve examining the state of the rest of the
2914 system to determine values and other information, and may involve
2915 prompting the user for some information which can't be obtained some
2916 other way.
2917 <p>
2918
2919 When using this method there are a couple of important issues which
2920 should be considered:
2921 <p>
2922
2923 If you discover a bug in the program which generates the configuration
2924 file, or if the format of the file changes from one version to the
2925 next, you will have to arrange for the postinst script to do something
2926 sensible - usually this will mean editing the installed configuration
2927 file to remove the problem or change the syntax.  You will have to do
2928 this very carefully, since the user may have changed the file, perhaps
2929 to fix the very problem that your script is trying to deal with - you
2930 will have to detect these situations and deal with them correctly.
2931 <p>
2932
2933 If you do go down this route it's probably a good idea to make the
2934 program that generates the configuration file(s) a separate program in
2935 <tt>/usr/sbin</>, by convention called <tt/<var/package/config/ and
2936 then run that if appropriate from the post-installation script.  The
2937 <tt/<var/package/config/ program should not unquestioningly overwrite
2938 an existing configuration - if its mode of operation is geared towards
2939 setting up a package for the first time (rather than any arbitrary
2940 reconfiguration later) you should have it check whether the
2941 configuration already exists, and require a <tt/--force/ flag to
2942 overwrite it.
2943
2944
2945
2946 <chapt id="alternatives">Alternative versions of an interface -
2947 <prgn/update-alternatives/
2948 <p>
2949
2950 When several packages all provide different versions of the same
2951 program or file it is useful to have the system select a default, but
2952 to allow the system administrator to change it and have their
2953 decisions respected.
2954 <p>
2955
2956 For example, there are several versions of the <prgn/vi/ editor, and
2957 there is no reason to prevent all of them from being installed at
2958 once, each under their own name (<prgn/nvi/, <prgn/vim/ or whatever).
2959 Nevertheless it is desirable to have the name <tt/vi/ refer to
2960 something, at least by default.
2961 <p>
2962
2963 If all the packages involved cooperate, this can be done with
2964 <prgn/update-alternatives/.
2965 <p>
2966
2967 Each package provides its own version under its own name, and calls
2968 <prgn/update-alternatives/ in its postinst to register its version
2969 (and again in its prerm to deregister it).
2970 <p>
2971
2972 See the manpage <manref name=update-alternatives section=8> for
2973 details.
2974 <p>
2975
2976 If <prgn/update-alternatives/ does not seem appropriate you may wish
2977 to consider using diversions instead.
2978
2979
2980 <chapt id="diversions">Diversions - overriding a package's version of a file
2981 <p>
2982
2983 It is possible to have <prgn/dpkg/ not overwrite a file when it
2984 reinstalls the package it belongs to, and to have it put the file from
2985 the package somewhere else instead.
2986 <p>
2987
2988 This can be used locally to override a package's version of a file, or
2989 by one package to override another's version (or provide a wrapper for
2990 it).
2991 <p>
2992
2993 Before deciding to use a diversion, read <ref id="alternatives"> to
2994 see if you really want a diversion rather than several alternative
2995 versions of a program.
2996 <p>
2997
2998 There is a diversion list, which is read by <prgn/dpkg/, and updated
2999 by a special program <prgn/dpkg-divert/.  Please see <manref
3000 name=dpkg-divert section=8> for full details of its operation.
3001 <p>
3002
3003 When a package wishes to divert a file from another, it should call
3004 <prgn/dpkg-divert/ in its preinst to add the diversion and rename the
3005 existing file.  For example, supposing that a <prgn/smailwrapper/
3006 package wishes to install a wrapper around <tt>/usr/sbin/smail</>:
3007 <example>
3008 if [ install = "$1" ]; then
3009     dpkg-divert --package smailwrapper --add --rename \
3010                 --divert /usr/sbin/smail.real /usr/sbin/smail
3011 fi
3012 </example>
3013 Testing <tt/$1/ is necessary so that the script doesn't try to add the
3014 diversion again when <prgn/smailwrapper/ is upgraded.  The
3015 <tt/--package smailwrapper/ ensures that <prgn/smailwrapper/'s copy of
3016 <tt>/usr/sbin/smail</> can bypass the diversion and get installed as
3017 the true version.
3018 <p>
3019
3020 The postrm has to do the reverse:
3021 <example>
3022 if [ remove = "$1" ]; then
3023     dpkg-divert --package smailwrapper --remove --rename \
3024                 --divert /usr/sbin/smail.real /usr/sbin/smail
3025 fi
3026 </example>
3027 <p>
3028
3029 Do not attempt to divert a file which is vitally important for the
3030 system's operation - when using <prgn/dpkg-divert/ there is a time,
3031 after it has been diverted but before <prgn/dpkg/ has installed the
3032 new version, when the file does not exist.
3033
3034
3035 <chapt id="sharedlibs">Shared libraries
3036 <p>
3037
3038 Packages containing shared libraries must be constructed with a little
3039 care to make sure that the shared library is always available.  This
3040 is especially important for packages whose shared libraries are
3041 vitally important, such as the libc.
3042 <p>
3043
3044 Firstly, your package should install the shared libraries under their
3045 normal names.  For example, the <prgn/libgdbm1/ package should install
3046 <tt/libgdbm.so.1.7.3/ as <tt>/usr/lib/libgdbm.so.1.7.3</tt>.  The
3047 files should not be renamed or relinked by any prerm or postrm
3048 scripts; <prgn/dpkg/ will take care of renaming things safely without
3049 affecting running programs, and attempts to interfere with this are
3050 likely to lead to problems.
3051 <p>
3052
3053 Secondly, your package should include the symlink that <prgn/ldconfig/
3054 would create for the shared libraries.  For example, the
3055 <prgn/libgdbm1/ package should include a symlink from
3056 <tt>/usr/lib/libgdbm.so.1</tt> to <tt/libgdbm.so.1.7.3/.  This is
3057 needed so that <prgn/ld.so/ can find the library in between the time
3058 <prgn/dpkg/ installs it and <prgn/ldconfig/ is run in the
3059 <prgn/postinst/ script.  Futhermore, and <em/this is very important/,
3060 the library must be placed before the symlink pointing to it in the
3061 <tt/.deb/ file.  This is so that by the time <prgn/dpkg/ comes to
3062 install the symlink (overwriting the previous symlink pointing at an
3063 older version of the library) the new shared library is already in
3064 place.  Currently the way to ensure the ordering is done properly is
3065 to install the library in the appropriate <tt>debian/tmp/.../lib</>
3066 directory before creating the symlink, by putting the commands in the
3067 <tt>debian/rules</> in the appropriate order.
3068 <p>
3069
3070 <!--
3071  next Paragraph added to close Bug #5299, Guy Maor
3072  -->
3073
3074 Thirdly, the development package should contain a symlink for the
3075 shared library without a version number.  For example, the
3076 <tt/libgdbm1-dev/ package should include a symlink from
3077 <tt>/usr/lib/libgdm.so</> to <tt/libgdm.so.1.7.3/.  This symlink is
3078 needed by <prgn/ld/ when compiling packages as it will only look for
3079 <tt/libgdm.so/ and <tt/libgdm.a/ when compiling dynamically or
3080 statically, respectively.
3081 <p>
3082
3083 <!--
3084  next paragraph changed by Christian Schwarz (see policy weekly #6)
3085  -->
3086
3087 Any package installing shared libraries in a directory that's listed
3088 in <tt>/etc/ld.so.conf</tt> or in one of the default library
3089 directories of <prgn/ld.so/ (currently, these are <tt>/usr/lib</tt>
3090 and <tt>/lib</tt>) must call <prgn/ldconfig/ in its <prgn/postinst/
3091 script if and only if the first argument is `configure'. However, it
3092 is important not to call <prgn/ldconfig/ in the postrm or preinst
3093 scripts in the case where the package is being upgraded (see <ref
3094 id="unpackphase">), as <prgn/ldconfig/ will see the temporary names
3095 that <prgn/dpkg/ uses for the files while it is installing them and
3096 will make the shared library links point to them, just before
3097 <prgn/dpkg/ continues the installation and removes the links!
3098 <p>
3099
3100 <!-- 
3101  moved from section 2.2 , DMorris 
3102  -->
3103
3104 <sect id="shlibs">The <tt/shlibs/ File Format
3105 <p>
3106
3107 This file is for use by <prgn/dpkg-shlibdeps/ and is required when
3108 your package provides shared libraries.
3109 <p>
3110
3111 Each line is of the form:
3112 <example>
3113 <var/library-name/ <var/version-or-soname/ <var/dependencies .../
3114 </example>
3115 <p>
3116
3117 <var/library-name/ is the name of the shared library, for example
3118 <tt/libc5/.
3119 <p>
3120
3121 <var/version-or-soname/ is the soname of the library - ie, the thing
3122 that must exactly match for the library to be recognised by
3123 <prgn/ld.so/.  Usually this is major version number of the library.
3124 <p>
3125
3126 <var/dependencies/ has the same syntax as a dependency field in a
3127 binary package control file.  It should give details of which
3128 package(s) are required to satisfy a binary built against the version
3129 of the library contained in the package.  See <ref id="depsyntax">.
3130 <p>
3131
3132 For example, if the package <tt/foo/ contains <tt/libfoo.so.1.2.3/,
3133 where the soname of the library is <tt/libfoo.so.1/, and the first
3134 version of the package which contained a minor number of at least
3135 <tt/2.3/ was <var/1.2.3-1/, then the package's <var/shlibs/ could
3136 say:
3137 <example>
3138 libfoo 1        foo (>= 1.2.3-1)
3139 </example>
3140 <p>
3141
3142 The version-specific dependency is to avoid warnings from <prgn/ld.so/
3143 about using older shared libraries with newer binaries.
3144
3145 <sect>Further Technical information on <tt/shlibs/</>
3146
3147 <!-- 
3148   following section mostly provided by Heiko Schlittermann
3149   edited by DMorris
3150  -->
3151
3152 <sect1><em/What/ are the <tt/shlibs/ files?
3153 <p>
3154
3155 The <tt>debian/shlibs</> file provides a way of checking
3156 for shared library dependencies on packaged binaries.  They are
3157 intended to be used by package maintainers to make their lives easier.
3158 <p>
3159
3160 Other <tt/shlibs/ files that exist on a Debian system are
3161 <list>
3162 <item> <tt>/etc/dpkg/shlibs.default</>
3163 <item> <tt>/etc/dpkg/shlibs.override</>
3164 <item> <tt>/var/lib/dpkg/info/*.shlibs</>
3165 <item> <tt>debian/shlibs.local</>
3166 </list>
3167
3168 These files are used by <prgn/dpkg-shlibdeps/ when creating a binary
3169 package.
3170
3171 <sect1><em/How/ does <prgn/dpkg-shlibdeps/ work?
3172 <p>
3173
3174 <prgn/dpkg-shlibdeps/ calls <prgn/ldd/ to determine the shared libraries
3175 used by the compiled binaries passed through its command line.
3176 <p>
3177
3178 For each shared library, <prgn/dpkg-shlibdeps/ needs to know 
3179 <list compact>
3180 <item>the package containing the library, and
3181 <item>the library version number,
3182 </list>
3183 <p>
3184 it scans the following files in this order.
3185 <enumlist compact>
3186 <item><tt>debian/shlibs.local</>
3187 <item><tt>/etc/dpkg/shlibs.override</>
3188 <item><tt>/var/lib/dpkg/info/*.shlibs</>
3189 <item><tt>/etc/dpkg/shlibs.default</>
3190 </enumlist>
3191
3192 <sect1><em/Who/ maintains the various <tt/shlibs/ files?
3193 <p>
3194
3195 <list compact>
3196 <item><tt>/etc/dpkg/shlibs.default</> - the maintainer of dpkg
3197 <item><tt>/var/lib/dpkg/info/<var/package/.shlibs</> - the maintainer of each 
3198 package
3199 <item><tt>/etc/dpkg/shlibs.override</> - the local system administrator
3200 <item><tt>debian/shlibs.local</> - the maintainer of the package
3201 </list>
3202
3203 The <tt/shlibs.default/ file is managed by <prgn/dpkg/. The entries in
3204 <tt/shlibs.default/ that are provided by <prgn/dpkg/ are just there to
3205 fix things until the shared library packages all have <tt/shlibs/
3206 files.
3207
3208 <sect1><em/How/ to use <prgn/dpkg-shlibdeps/ and the <tt/shlibs/ files?
3209
3210 <sect2>If your package doesn't provide a shared library
3211 <p>
3212
3213 Put a call to <prgn/dpkg-shlibs/ into your <tt>debian/rules</> file.
3214 If your package contains only binaries (e.g. no scripts) use:
3215 <example>
3216 dpkg-shlibdeps debian/tmp/usr/{bin,sbin}/*
3217 </example>
3218
3219 If <prgn/dpkg-shlibdeps/ doesn't complain, you're done. If it does
3220 complain you might need to create your own <tt>debian/shlibs.local</>
3221 file.
3222
3223 <sect2>If your package provides a shared library
3224 <p>
3225
3226 Create a <tt>debian/shlibs</> file and let <tt>debian/rules</> install
3227 it in the control area:
3228
3229 <example>
3230 install -m644 debian/shlibs debian/tmp/DEBIAN
3231 </example>
3232
3233 If your package contains additional binaries see above.
3234
3235 <sect1><em/How/ to write <tt>debian/shlibs.local</>
3236 <p>
3237
3238 This file is intended only as a <em/temporary/ fix if your binaries
3239 depend on a library which doesn't provide its own
3240 <tt>/var/lib/dpkg/*.shlibs</> file yet.
3241 <p>
3242
3243 Let's assume you are packaging a binary <tt/foo/. Your output in
3244 building the package might look like this.
3245
3246 <example>
3247 $ ldd foo
3248 libbar.so.1 => /usr/X11R6/lib/libbar.so.1.0
3249 libc.so.5 => /lib/libc.so.5.2.18
3250 libX11.so.6 => /usr/X11R6/lib/libX11.so.6.0
3251 </example>
3252
3253 And when you ran <prgn/dpkg-shlibdeps/
3254
3255 <example>
3256 $ dpkg-shlibdeps -o foo
3257 dpkg-shlibdeps: warning: unable to find dependency information 
3258 for shared library libbar 
3259 (soname 1, path /usr/X11R6/lib/libbar.so.1.0, dependency field Depends)
3260 shlibs:Depends=elf-x11r6lib, libc5 (>= 5.2.18)
3261 </example>
3262
3263 The <prgn/foo/ binary depends on the <prgn/libbar/ shared library, but
3264 no package seems to provide a <tt/*.shlibs/ file in
3265 <tt//var/lib/dpkg/info/.  Let's determine the package responsible:
3266 <p>
3267
3268 <example>
3269 $ dpkg -S /usr/X11R6/lib/libbar.so.1.0
3270 bar1: /usr/X11R6/lib/libbar.so.1.0
3271 $ dpkg -s bar1 | grep Version
3272 Version: 1.0-1
3273 </example>
3274
3275 This tells us that the <prgn/bar1/ package, version 1.0-1 is the one
3276 we are using. Now we can create our own <tt>debian/shlibs.local</> to
3277 temporarly fix the above problem. Include the following line into your
3278 <tt>debian/shlibs.local</> file.
3279
3280 <example>
3281     libbar 1 bar1 (>= 1.0-1)
3282 </example>
3283
3284 Now your package build should work. As soon as the maintainer of
3285 <prgn/libbar1/ provides a <tt/shlibs/ file, you can remove your
3286 <tt>debian/shlibs.local</> file.
3287
3288 <chapt id="methif"><prgn/dselect/'s interface to its installation methods
3289 <p>
3290
3291 <prgn/dselect/ calls scripts from its installation methods when it
3292 needs to actually access data from the distribution.  The core program
3293 <prgn/dselect/ itself just calls these scripts and provides the
3294 package and access method selection interfaces.  The installation
3295 methods are responsible for invoking <prgn/dpkg/ as appropriate.
3296 <p>
3297
3298 Each installation method has three scripts:
3299 <list compact>
3300 <item>Setup installation parameters.
3301 <item>Update list of available packages.
3302 <item>Install.
3303 </list>
3304 <p>
3305
3306 <prgn/dselect/ searches for methods in <tt>/usr/lib/dpkg/methods</>
3307 and <tt>/usr/local/lib/dpkg/methods</>.
3308
3309 <sect>Functions of the method scripts
3310 <p>
3311
3312 The setup script is run just after the user has chosen an installation
3313 method.  It should prompt the user for parameters like the site to
3314 NFS-mount or FTP from, the directory to use, or the directory or
3315 filesystem where the <tt/.deb/ files can be found, or the tape or
3316 floppy device to install from.  It should store the responses under
3317 <tt>/var/lib/dpkg/methods</> - see below.  If no available
3318 packages list is available it should perhaps offer to scan the
3319 available packages.
3320 <p>
3321
3322 The update script should obtain a list of available packages if
3323 possible, and run <tt/dpkg --update-avail/, <tt/dpkg --merge-avail/
3324 and/or <tt/dpkg --forget-old-unavail/ to load it into <prgn/dpkg/ and
3325 <prgn/dselect/'s database of available packages.  If no packages list
3326 was available and the user was offered and accepted the option of
3327 scanning the actual files available this scan should be done here,
3328 using <tt/dpkg --record-avail/.
3329 <p>
3330
3331 The install script should feed all the available <tt/.deb/ files to
3332 <tt/dpkg --iGOEB/ (this is equivalent to <tt/dpkg --install
3333 --refuse-downgrade --selected-only --skip-same-version
3334 --auto-deconfigure/).  The <tt/-R/ (<tt/--recursive/) option for
3335 traversing subdirectories may also be useful here).
3336 <p>
3337
3338 If any of these scripts needs to display a message for the user, it
3339 should wait for the user to hit `return' before exiting so that
3340 dselect doesn't immediately rewrite the screen.
3341 <p>
3342
3343 If a method script succeeds (returns a zero exit status)
3344 <prgn/dselect/ will return immediately to the main menu, with the
3345 `next' option highlighted ready for the user to select it.  If it
3346 fails <prgn/dselect/ will display a message and wait for the user to
3347 hit return.
3348
3349 <sect>Location and arguments of the method scripts
3350 <p>
3351
3352 A set of scripts (henceforth known as a group) may provide several
3353 methods on the `main menu' with different behaviour.  For example,
3354 there might be a generic get-packages-by-FTP group which might provide
3355 methods in the main menu for installation directly from one of the
3356 Debian mirror sites as well as for installation from a user-specified
3357 site.
3358 <p>
3359
3360 Each group of methods implemented by the same set of scripts should
3361 have a subdirectory <tt>/usr/lib/dpkg/methods/<var/group/</> or
3362 <tt>/usr/local/lib/dpkg/methods/<var/group/</>, containing:
3363 <taglist compact>
3364 <tag><tt/names/
3365 <item>a list of user-visible methods provided by these scripts.
3366 <tag><tt/setup/
3367 <tag><tt/update/
3368 <tag><tt/install/
3369 <item>executable programs, the scripts themselves.
3370 <tag><tt/desc.<var/option//
3371 <item>description file.
3372 </taglist>
3373 <p>
3374
3375 <tt/names/ will be formatted as a list of lines, each containing:
3376 <example>
3377 <var/sequence/ <var/method/ <var/summary/
3378 </example>
3379 <p>
3380
3381 <var/sequence/ is a two-digit number that will be used much like
3382 <tt/rc.d/ prefixes to control the order in the main menu.  If in doubt
3383 use 50.
3384 <p>
3385
3386 <var/method/ is a name which is displayed by <prgn/dselect/ as the
3387 name of the method, and which will be passed to <tt/setup/,
3388 <tt/update/ and <tt/unpack/ as their first argument.
3389 <p>
3390
3391 <var/summary/ is the brief description string for <prgn/dselect/'s menu.
3392 <p>
3393
3394 Each of the three scripts gets the same three arguments: <var/vardir/,
3395 <var/group/ and <var/method/.  <var/vardir/ is the base directory for
3396 storing <prgn/dpkg/ and <prgn/dselect/'s state, usually
3397 <tt>/var/lib/dpkg</>; this is passed in so that the <tt/--admindir/
3398 option to <prgn/dselect/ is honoured).
3399 <p>
3400
3401 Each option may have an extended description in
3402 <tt/desc.<var/option//.  This should be formatted like the extended
3403 description part of a <tt/Description/ field entry <em/shifted one
3404 character to the left/.
3405 <p>
3406
3407 <tt><var/vardir//methods</> will exist, and a method group may use a
3408 <tt><var/vardir//methods/<var/group/</> directory to store its state.
3409 <p>
3410
3411 The group name and method name must follow the rules for C identifiers.
3412
3413 <chapt id="conversion">Conversion procedure from old source packages
3414 <p>
3415
3416 This is a brief summary of the procedure for converting a
3417 pre-2.0.0.0-format source package into the new format.
3418 <p>
3419
3420 You are strongly advised to download and examine the <prgn/hello/
3421 package, and to read the section in the <prgn/dpkg/ programmers'
3422 manual describing the source packaging tools.  More detail about the
3423 exact functionality of these tools is available in <manref
3424 name=dpkg-source section=1>.
3425 <p>
3426
3427 <list>
3428
3429 <item>
3430 Download the original source code from wherever it can be found and do
3431 any rearrangement required to make it look like the original tree of
3432 the Debian source.  Put it in
3433 <tt><var/package/-<var/upstream-version/.orig/</> or
3434 <tt/<var/package/_<var/upstream-version/.orig.tar.gz/.
3435
3436 <item>
3437 Rename all files <tt/debian.*/ to <tt>debian/*</>.  There may be some
3438 exceptions to this, but this is a good start.
3439
3440 <item>
3441 Edit the <tt>debian/changelog</> - create or rename it if necessary.
3442 Add a new revision to the top with the appropriate details, and a
3443 local variables entry to the bottom to set Emacs to the right mode:
3444 <example>
3445 Local variables:
3446 mode: debian-changelog
3447 End:
3448 </example>
3449
3450 <item>
3451 Edit/create <tt>debian/control</>:
3452 <list compact>
3453 <item>
3454 Remove the <tt/Version/ field.  If it is generated unusually (not
3455 equal to the source version) you must use the -v option to
3456 dpkg-gencontrol (see below).  <tt/Section/, <tt/Priority/,
3457 <tt/Maintainer/ go above the first blank line, most of the rest below.
3458
3459 <item>
3460 Reorder the fields and add a blank line at an appropriate point,
3461 separating the source package fields from the binary package
3462 fields.
3463
3464 <item>
3465 Add the <tt/Source/ field.
3466
3467 <item>
3468 Add the <tt/Standards-Version/ field.  (Please check out the Debian
3469 Policy Manual for details about this field.)
3470
3471 <item>
3472 Change the <tt/Architecture/ field for each package to <tt/any/,
3473 <tt/all/ or whatever.  If there isn't an <tt/Architecture/ field add
3474 one.
3475
3476 <item>
3477 If any other use of sed or things used to happen to make the binary
3478 control files use <prgn/dpkg-gencontrol/'s variable substitution
3479 features to achieve the same effect.  Use <tt>debian/substvars</> if
3480 you need to put unusally-generated information (apart from details of
3481 <tt/.deb/ files) in the <tt/.changes/ file too.
3482 </list>
3483
3484 <item>
3485 Edit the <tt>debian/rules</>:
3486 <list compact>
3487 <item>
3488 Remove the <prgn/source/ and <prgn/diff/ and any <prgn/changes/ and
3489 <prgn/dist/ targets.  These things now happen in a package-independent
3490 way and are not done by <tt>debian/rules</>.
3491 <item>
3492 Split the <prgn/binary/ target into <prgn/binary-arch/ and
3493 <prgn/binary-indep/; in many cases all of <prgn/binary/ should go into
3494 <prgn/binary-arch/.  Create the <prgn/binary/ target and the unused of
3495 the two other <prgn/binary-*/ targets if there is one - you can copy
3496 the ones from the <prgn/hello/ package.
3497 <item>
3498 Change the <prgn/binary/ target to use <prgn/dpkg-gencontrol/ to make
3499 the package control file(s).  Move it to after all the files have been
3500 installed but just before the last <prgn/chown/ and <prgn/chmod/ in
3501 the target.
3502 <item>
3503 Change occurrences of <tt/debian-tmp/ to <tt>debian/tmp</>.
3504 <item>
3505 Change occurrences of <tt/debian.{post,pre}{inst,rm}/ to
3506 <tt>debian/*</>.
3507 <item>
3508 Remove the version number setting at the top, if there is one.
3509 <item>
3510 Ensure that the package's Debian-specific and upstream changelogs are
3511 installed.
3512 </list>
3513
3514 <item>
3515 Change the package to use <prgn/dpkg-shlibdeps/ to determine its
3516 shared library dependencies and substitute them in.  Shared library
3517 dependencies should no longer be hardwired in the source package.
3518
3519 <item>
3520 Check that the <tt>debian/README</> is really the copyright file, and
3521 if so rename it to <tt>debian/copyright</> and edit
3522 <tt>debian/rules</> to cope with this and to change the installation
3523 of the copyright file from <tt>/usr/doc/<var/package//copyright</>
3524 to <tt>/usr/doc/copyright/<var/package/</>.  If it isn't then
3525 find <tt>debian/copyright</> and decide what to do with the
3526 <tt>README</>.
3527
3528 <item>
3529 Check for various other anachronisms and problems:
3530 <list compact>
3531 <item>
3532 Remove any <tt/Package_Revision/, <tt/Package-Revision/ or
3533 <tt/Revision/ fields.
3534 <item>
3535 Rename <tt/Optional/ to <tt/Suggests/, <tt/Recommended/ to
3536 <tt/Recommends/.
3537 <item>
3538 Change <tt>/usr/doc/examples/<var/package/</> to
3539 <tt>/usr/doc/<var/package//examples</>.
3540 <item>
3541 Make sure that manpages are installed compressed.
3542 <item>
3543 Check that the description has an extended description, is
3544 well-formatted and meaningful and helpful to people wanting to know
3545 whether to install a package.
3546 </list>
3547
3548 <item>
3549 Look everything over.
3550
3551 <item>
3552 Do a test build using <tt/dpkg-buildpackage -us -uc -sa
3553 -r<var/whatever//.  Check the permissions and locations of files in
3554 the resulting package by examining the output of <tt/dpkg-deb
3555 --contents/, and check that the source build happened OK.  Test
3556 install the binary package(s) and test extract the source package(s).
3557
3558 <item>
3559 Sign the release: either rebuild everything with <tt/dpkg-buildpackage
3560 -sa/, or PGP-sign the <tt/.dsc/, rebuild the <tt/.changes/ using
3561 <tt/dpkg-genchanges -sa/, and then PGP-sign the <tt/.changes/.
3562
3563 </list>
3564 <p>
3565
3566 The use of <tt/-sa/ on <prgn/dpkg-buildpackage/ and
3567 <prgn/dpkg-genchanges/ is important when doing the first
3568 build/uploading of a new-format source package.  Unless this happens
3569 to be Debian revision <tt/0/ or <tt/1/ by default the original source
3570 tarfile will not be included in the uploaded files listed in the
3571 <tt/.changes/ file, and so it won't be installed on the FTP site.
3572 <tt/-sa/ requests that the original source be included regardless.
3573
3574 </book>