1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3 within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
10 <title>Debian Policy Manual</title>
11 <author><ref id="authors"></author>
12 <version>version &version;, &date;</version>
15 This manual describes the policy requirements for the Debian
16 GNU/Linux distribution. This includes the structure and
17 contents of the Debian archive and several design issues of
18 the operating system, as well as technical requirements that
19 each package must satisfy to be included in the distribution.
24 Copyright © 1996,1997,1998 Ian Jackson
25 and Christian Schwarz.
28 This manual is free software; you may redistribute it and/or
29 modify it under the terms of the GNU General Public License
30 as published by the Free Software Foundation; either version
31 2, or (at your option) any later version.
35 This is distributed in the hope that it will be useful, but
36 <em>without any warranty</em>; without even the implied
37 warranty of merchantability or fitness for a particular
38 purpose. See the GNU General Public License for more
43 A copy of the GNU General Public License is available as
44 <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
45 distribution or on the World Wide Web at
46 <url id="http://www.gnu.org/copyleft/gpl.html"
47 name="the GNU General Public Licence">. You can also
48 obtain it by writing to the Free Software Foundation, Inc.,
49 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
57 <heading>About this manual</heading>
59 <heading>Scope</heading>
61 This manual describes the policy requirements for the Debian
62 GNU/Linux distribution. This includes the structure and
63 contents of the Debian archive and several design issues of the
64 operating system, as well as technical requirements that
65 each package must satisfy to be included in the
70 This manual also describes Debian policy as it relates to
71 creating Debian packages. It is not a tutorial on how to build
72 packages, nor is it exhaustive where it comes to describing
73 the behavior of the packaging system. Instead, this manual
74 attempts to define the interface to the package management
75 system that the developers have to be conversant with.<footnote>
77 Informally, the criteria used for inclusion is that the
78 material meet one of the following requirements:
79 <taglist compact="compact">
80 <tag>Standard interfaces</tag>
83 The material presented represents an interface to
84 the packaging system that is mandated for use, and
85 is used by, a significant number of packages, and
86 therefore should not be changed without peer
87 review. Package maintainers can then rely on this
88 interfaces not changing, and the package
89 management software authors need to ensure
90 compatibility with these interface
91 definitions. (Control file and changelog file
92 formats are examples.)
95 <tag>Chosen Convention</tag>
98 If there are a number of technically viable choices
99 that can be made, but one needs to select one of
100 these options for inter-operability. The version
101 number format is one example.
105 Please note that these are not mutually exclusive;
106 selected conventions often become parts of standard
113 The footnotes present in this manual are
114 merely informative, and are not part of Debian policy itself.
118 The appendices to this manual are not necessarily normative,
119 either. Please see <ref id="pkg-scope"> for more information.
123 In the normative part of this manual,
124 the words <em>must</em>, <em>should</em> and
125 <em>may</em>, and the adjectives <em>required</em>,
126 <em>recommended</em> and <em>optional</em>, are used to
127 distinguish the significance of the various guidelines in
128 this policy document. Packages that do not conform to the
129 guidelines denoted by <em>must</em> (or <em>required</em>)
130 will generally not be considered acceptable for the Debian
131 distribution. Non-conformance with guidelines denoted by
132 <em>should</em> (or <em>recommended</em>) will generally be
133 considered a bug, but will not necessarily render a package
134 unsuitable for distribution. Guidelines denoted by
135 <em>may</em> (or <em>optional</em>) are truly optional and
136 adherence is left to the maintainer's discretion.
139 These classifications are roughly equivalent to the bug
140 severities <em>serious</em> (for <em>must</em> or
141 <em>required</em> directive violations), <em>minor</em>,
142 <em>normal</em> or <em>important</em>
143 (for <em>should</em> or <em>recommended</em> directive
144 violations) and <em>wishlist</em> (for <em>optional</em>
146 <p>Compare RFC 2119. Note, however, that these words are
147 used in a different way in this document.</p>
151 Much of the information presented in this manual will be
152 useful even when building a package which is to be
153 distributed in some other way or is intended for local use
159 <heading>New versions of this document</heading>
161 The current version of this document is always accessible
162 from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
164 <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
165 (also available from the same directory are several other
166 formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
167 and <file>policy.ps.gz</file>) or from the <url
168 id="http://www.debian.org/doc/debian-policy/" name="Debian
169 Policy Manual"> webpage.</p>
172 In addition, this manual is distributed via the Debian package
173 <file>debian-policy</file>.
177 The <tt>debian-policy</tt> package also includes the file
178 <file>upgrading-checklist.txt</file> which indicates policy
179 changes between versions of this document.
184 <heading>Authors and Maintainers</heading>
187 Originally called "Debian GNU/Linux Policy Manual", this
188 manual was initially written in 1996 by Ian Jackson.
189 It was revised on November 27th, 1996 by David A. Morris.
190 Christian Schwarz added new sections on March 15th, 1997,
191 and reworked/restructured it in April-July 1997.
192 Christoph Lameter contributed the "Web Standard".
193 Julian Gilbey largely restructured it in 2001.
197 Since September 1998, the responsibility for the contents of
198 this document lies on the debian-policy mailing list. Proposals
199 are discussed there and inserted into policy after a certain
200 consensus is established.
201 <!-- insert shameless policy-process plug here eventually -->
202 The actual editing is done by a group of maintainers that have
203 no editorial powers. These are the current maintainers:
206 <item>Julian Gilbey</item>
207 <item>Branden Robinson</item>
208 <item>Josip Rodin</item>
209 <item>Manoj Srivastava</item>
214 While the authors of this document have tried hard to avoid
215 typos and other errors, these do still occur. If you discover
216 an error in this manual or if you want to give any
217 comments, suggestions, or criticisms please send an email to
218 the Debian Policy List,
219 <email>debian-policy@lists.debian.org</email>, or submit a
220 bug report against the <tt>debian-policy</tt> package.
224 Please do not try to reach the individual authors or maintainers
225 of the Policy Manual regarding changes to the Policy.
231 <heading>The Debian Archive</heading>
233 The Debian GNU/Linux system is maintained and distributed as a
234 collection of <em>packages</em>. Since there are so many of
235 them (currently well over 6000), they are split into
236 <em>sections</em> and given <em>priorities</em> to simplify
237 the handling of them.
240 The effort of the Debian project is to build a free operating
241 system, but not every package we want to make accessible is
242 <em>free</em> in our sense (see the Debian Free Software
243 Guidelines, below), or may be imported/exported without
244 restrictions. Thus, the archive is split into the sections
245 <em>main</em>, <em>non-free</em>, <em>contrib</em>,
246 <em>non-US/main</em>, <em>non-US/non-free</em>, and
247 <em>non-US/contrib</em>. The sections are explained in detail
252 The <em>main</em> and the <em>non-US/main</em> sections
253 together form the <em>Debian GNU/Linux distribution</em>.
257 Packages in the other sections are not considered to be part
258 of the Debian distribution, although we support their use and
259 provide infrastructure for them (such as our bug-tracking
260 system and mailing lists). This Debian Policy Manual applies
261 to these packages as well.</p>
263 <sect id="pkgcopyright">
264 <heading>Package copyright and sections</heading>
266 The aims of this section are:
268 <list compact="compact">
270 <p>to allow us to make as much software available as we
274 <p>to allow us to encourage everyone to write free
278 <p>to allow us to make it easy for people to produce
279 CD-ROMs of our system without violating any licenses,
280 import/export restrictions, or any other laws.</p>
285 <heading>The Debian Free Software Guidelines</heading>
287 The Debian Free Software Guidelines (DFSG) form our
288 definition of "free software". These are:
290 <tag>Free Redistribution
294 The license of a Debian component may not restrict any
295 party from selling or giving away the software as a
296 component of an aggregate software distribution
297 containing programs from several different
298 sources. The license may not require a royalty or
299 other fee for such sale.
306 The program must include source code, and must allow
307 distribution in source code as well as compiled form.
314 The license must allow modifications and derived
315 works, and must allow them to be distributed under the
316 same terms as the license of the original software.
319 <tag>Integrity of The Author's Source Code
323 The license may restrict source-code from being
324 distributed in modified form <em>only</em> if the
325 license allows the distribution of "patch files"
326 with the source code for the purpose of modifying the
327 program at build time. The license must explicitly
328 permit distribution of software built from modified
329 source code. The license may require derived works to
330 carry a different name or version number from the
331 original software. (This is a compromise. The Debian
332 Project encourages all authors to not restrict any
333 files, source or binary, from being modified.)
336 <tag>No Discrimination Against Persons or Groups
340 The license must not discriminate against any person
344 <tag>No Discrimination Against Fields of Endeavor
348 The license must not restrict anyone from making use
349 of the program in a specific field of endeavor. For
350 example, it may not restrict the program from being
351 used in a business, or from being used for genetic
355 <tag>Distribution of License
359 The rights attached to the program must apply to all
360 to whom the program is redistributed without the need
361 for execution of an additional license by those
365 <tag>License Must Not Be Specific to Debian
369 The rights attached to the program must not depend on
370 the program's being part of a Debian system. If the
371 program is extracted from Debian and used or
372 distributed without Debian but otherwise within the
373 terms of the program's license, all parties to whom
374 the program is redistributed must have the same
375 rights as those that are granted in conjunction with
379 <tag>License Must Not Contaminate Other Software
383 The license must not place restrictions on other
384 software that is distributed along with the licensed
385 software. For example, the license must not insist
386 that all other programs distributed on the same medium
387 must be free software.
390 <tag>Example Licenses
394 The "GPL," "BSD," and "Artistic" licenses are examples of
395 licenses that we consider <em>free</em>.
402 <heading>The main section</heading>
404 Every package in <em>main</em> and <em>non-US/main</em>
405 must comply with the DFSG (Debian Free Software
409 In addition, the packages in <em>main</em>
410 <list compact="compact">
413 must not require a package outside of <em>main</em>
414 for compilation or execution (thus, the package must
415 not declare a "Depends", "Recommends", or
416 "Build-Depends" relationship on a non-<em>main</em>
422 must not be so buggy that we refuse to support them,
428 must meet all policy requirements presented in this
435 Similarly, the packages in <em>non-US/main</em>
436 <list compact="compact">
439 must not require a package outside of <em>main</em>
440 or <em>non-US/main</em> for compilation or
446 must not be so buggy that we refuse to support them,
451 must meet all policy requirements presented in this
459 <heading>The contrib section</heading>
461 Every package in <em>contrib</em> and
462 <em>non-US/contrib</em> must comply with the DFSG.
466 In addition, the packages in <em>contrib</em> and
467 <em>non-US/contrib</em>
468 <list compact="compact">
471 must not be so buggy that we refuse to support them,
477 must meet all policy requirements presented in this
485 Furthermore, packages in <em>contrib</em> must not require
486 a package in a <em>non-US</em> section for compilation or
491 Examples of packages which would be included in
492 <em>contrib</em> or <em>non-US/contrib</em> are:
493 <list compact="compact">
496 free packages which require <em>contrib</em>,
497 <em>non-free</em> packages or packages which are not
498 in our archive at all for compilation or execution,
504 wrapper packages or other sorts of free accessories for
512 <heading>The non-free section</heading>
514 Packages must be placed in <em>non-free</em> or
515 <em>non-US/non-free</em> if they are not compliant with
516 the DFSG or are encumbered by patents or other legal
517 issues that make their distribution problematic.
520 In addition, the packages in <em>non-free</em> and
521 <em>non-US/non-free</em>
522 <list compact="compact">
525 must not be so buggy that we refuse to support them,
531 must meet all policy requirements presented in this
532 manual that it is possible for them to meet.<footnote>
534 It is possible that there are policy
535 requirements which the package is unable to
536 meet, for example, if the source is
537 unavailable. These situations will need to be
538 handled on a case-by-case basis.
548 <heading>The non-US sections</heading>
550 Non-free programs with cryptographic program code need to
551 be stored on the <em>non-us</em> server because of export
552 restrictions of the U.S.
555 Programs which use patented algorithms that have a
556 restrictied license also need to be stored on "non-us",
557 since that is located in a country where it is not allowed
558 to patent algorithms.
561 A package depends on another package which is distributed
562 via the non-us server has to be stored on the non-us
567 <heading>Further copyright considerations</heading>
569 Every package must be accompanied by a verbatim copy of
570 its copyright and distribution license in the file
571 <file>/usr/share/doc/<var>package</var>/copyright</file>
572 (see <ref id="copyrightfile"> for further details).
575 We reserve the right to restrict files from being included
576 anywhere in our archives if
577 <list compact="compact">
580 their use or distribution would break a law,
585 there is an ethical conflict in their distribution or
591 we would have to sign a license for them, or
596 their distribution would conflict with other project
604 Programs whose authors encourage the user to make
605 donations are fine for the main distribution, provided
606 that the authors do not claim that not donating is
607 immoral, unethical, illegal or something similar; in such
608 a case they must go in <em>non-free</em>.</p>
611 Packages whose copyright permission notices (or patent
612 problems) do not even allow redistribution of binaries
613 only, and where no special permission has been obtained,
614 must not be placed on the Debian FTP site and its mirrors
618 Note that under international copyright law (this applies
619 in the United States, too), <em>no</em> distribution or
620 modification of a work is allowed without an explicit
621 notice saying so. Therefore a program without a copyright
622 notice <em>is</em> copyrighted and you may not do anything
623 to it without risking being sued! Likewise if a program
624 has a copyright notice but no statement saying what is
625 permitted then nothing is permitted.</p>
628 Many authors are unaware of the problems that restrictive
629 copyrights (or lack of copyright notices) can cause for
630 the users of their supposedly-free software. It is often
631 worthwhile contacting such authors diplomatically to ask
632 them to modify their license terms. However, this can be a
633 politically difficult thing to do and you should ask for
634 advice on the <tt>debian-legal</tt> mailing list first, as
639 When in doubt about a copyright, send mail to
640 <email>debian-legal@lists.debian.org</email>. Be prepared
641 to provide us with the copyright statement. Software
642 covered by the GPL, public domain software and BSD-like
643 copyrights are safe; be wary of the phrases "commercial
644 use prohibited" and "distribution restricted".
648 <heading>Subsections</heading>
651 The packages in the sections <em>main</em>,
652 <em>contrib</em> and <em>non-free</em> are grouped further
653 into <em>subsections</em> to simplify handling.
657 The section and subsection for each package should be
658 specified in the package's <tt>Section</tt> control
659 record. However, the maintainer of the Debian archive
660 may override this selection to ensure the consistency of
661 the Debian distribution. The <tt>Section</tt> field
662 should be of the form:
663 <list compact="compact">
666 <em>subsection</em> if the package is in the
667 <em>main</em> section,
672 <em>section/subsection</em> if the package is in
673 the <em>contrib</em> or <em>non-free</em> section,
679 <tt>non-US</tt>, <tt>non-US/contrib</tt> or
680 <tt>non-US/non-free</tt> if the package is in
681 <em>non-US/main</em>, <em>non-US/contrib</em> or
682 <em>non-US/non-free</em> respectively.
689 The Debian archive maintainers provide the authoritative
690 list of subsections. At present, they are:
691 <em>admin</em>, <em>base</em>, <em>comm</em>,
692 <em>contrib</em>, <em>devel</em>, <em>doc</em>,
693 <em>editors</em>, <em>electronics</em>, <em>games</em>,
694 <em>graphics</em>, <em>hamradio</em>,
695 <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
696 <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
697 <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
698 <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
699 <em>sound</em>, <em>tex</em>, <em>text</em>,
700 <em>utils</em>, <em>web</em>, <em>x11</em>.
704 <heading>Priorities</heading>
707 Each package should have a <em>priority</em> value, which is
708 included in the package's <em>control record</em>. This
709 information is used by the Debian package management tools
710 to separate high-priority packages from less-important
714 The following <em>priority levels</em> are recognised by the
715 Debian package management tools.
717 <tag><tt>required</tt></tag>
720 Packages which are necessary for the proper
721 functioning of the system. You must not remove these
722 packages or your system may become totally broken and
723 you may not even be able to use <prgn>dpkg</prgn> to
724 put things back. Systems with only the
725 <tt>required</tt> packages are probably unusable, but
726 they do have enough functionality to allow the
727 sysadmin to boot and install more software.</p>
729 <tag><tt>important</tt></tag>
732 Important programs, including those which one would
733 expect to find on any Unix-like system. If the
734 expectation is that an experienced Unix person who
735 found it missing would say "What on earth is going on,
736 where is <prgn>foo</prgn>?", it must be an
737 <tt>important</tt> package.<footnote>
739 This is an important criterion because we are
740 trying to produce, amongst other things, a free
744 Other packages without which the system will not run
745 well or be usable must also have priority
746 <tt>important</tt>. This does
747 <em>not</em> include Emacs, the X Window System, TeX
748 or any other large applications. The
749 <tt>important</tt> packages are just a bare minimum of
750 commonly-expected and necessary tools.</p>
752 <tag><tt>standard</tt></tag>
755 These packages provide a reasonably small but not too
756 limited character-mode system. This is what will be
757 installed by default if the user doesn't select anything
758 else. It doesn't include many large applications.</p>
760 <tag><tt>optional</tt></tag>
763 (In a sense everything that isn't required is
764 optional, but that's not what is meant here.) This is
765 all the software that you might reasonably want to
766 install if you didn't know what it was and don't have
767 specialized requirements. This is a much larger system
768 and includes the X Window System, a full TeX
769 distribution, and many applications. Note that
770 optional packages should not conflict with each other.
773 <tag><tt>extra</tt></tag>
776 This contains all packages that conflict with others
777 with required, important, standard or optional
778 priorities, or are only likely to be useful if you
779 already know what they are or have specialised
786 Packages must not depend on packages with lower priority
787 values (excluding build-time dependencies). In order to
788 ensure this, the priorities of one or more packages may need
794 <heading>Binary packages</heading>
797 The Debian GNU/Linux distribution is based on the Debian
798 package management system, called <prgn>dpkg</prgn>. Thus,
799 all packages in the Debian distribution must be provided
800 in the <tt>.deb</tt> file format.</p>
804 <heading>The package name</heading>
807 Every package must have a name that's unique within the Debian
811 Package names must consist of lower case letters
812 (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
813 and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
814 They must be at least two characters long and must start
815 with an alphanumeric character.
819 The package name is part of the file name of the
820 <tt>.deb</tt> file and is included in the control field
826 <heading>The maintainer of a package</heading>
828 Every package must have a Debian maintainer (the
829 maintainer may be one person or a group of people
830 reachable from a common email address, such as a mailing
831 list). The maintainer is responsible for ensuring that
832 the package is placed in the appropriate distributions.
836 The maintainer must be specified in the
837 <tt>Maintainer</tt> control field with their correct name
838 and a working email address. If one person maintains
839 several packages, he/she should try to avoid having
840 different forms of their name and email address in
841 the <tt>Maintainer</tt> fields of those packages.
845 If the maintainer of a package quits from the Debian
846 project, "Debian QA Group"
847 <email>packages@qa.debian.org</email> takes over the
848 maintainership of the package until someone else
849 volunteers for that task. These packages are called
850 <em>orphaned packages</em>.<footnote>
852 The detailed procedure for doing this gracefully can
853 be found in the Debian Developer's Reference, either
854 in the <tt>developers-reference</tt> package, or on
855 the Debian FTP server
856 <ftpsite>ftp.debian.org</ftpsite> as
857 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
859 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
860 name="Debian Developer's Reference"> webpage.
868 <heading>The description of a package</heading>
871 Every Debian package must have an extended description
872 stored in the appropriate field of the control record.</p>
875 The description should be written so that it gives the
876 system administrator enough information to decide whether
877 to install the package. This description should not just
878 be copied verbatim from the program's documentation.
879 Instructions for configuring or using the package should
880 not be included (that is what installation scripts,
881 manual pages, info files, etc., are for). Copyright
882 statements and other administrivia should not be included
883 either (that is what the copyright file is for).
887 Please refer to <ref id="descriptions"> for more information.
894 <heading>Dependencies</heading>
897 Every package must specify the dependency information
898 about other packages that are required for the first to
902 For example, a dependency entry must be provided for any
903 shared libraries required by a dynamically-linked executable
904 binary in a package.</p>
907 Packages are not required to declare any dependencies they
908 have on other packages which are marked <tt>Essential</tt>
909 (see below), and should not do so unless they depend on a
910 particular version of that package.</p>
913 Sometimes, a package requires another package to be installed
914 <em>and</em> configured before it can be installed. In this
915 case, you must specify a <tt>Pre-Depends</tt> entry for
919 You should not specify a <tt>Pre-Depends</tt> entry for a
920 package before this has been discussed on the
921 <tt>debian-devel</tt> mailing list and a consensus about
922 doing that has been reached.</p></sect1>
925 <sect1 id="virtual_pkg">
926 <heading>Virtual packages</heading>
929 Sometimes, there are several packages which offer
930 more-or-less the same functionality. In this case, it's
931 useful to define a <em>virtual package</em> whose name
932 describes that common functionality. (The virtual
933 packages only exist logically, not physically; that's why
934 they are called <em>virtual</em>.) The packages with this
935 particular function will then <em>provide</em> the virtual
936 package. Thus, any other package requiring that function
937 can simply depend on the virtual package without having to
938 specify all possible packages individually.</p>
941 All packages should use virtual package names where
942 appropriate, and arrange to create new ones if necessary.
943 They should not use virtual package names (except privately,
944 amongst a cooperating group of packages) unless they have
945 been agreed upon and appear in the list of virtual package
946 names. (See also <ref id="virtual">)</p>
949 The latest version of the authoritative list of virtual
950 package names can be found in the <tt>debian-policy</tt> package.
951 It's also available from the Debian web mirrors at
952 <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
953 id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>
954 and from the Debian archive mirrors at
955 <tt><url name="/doc/package-developer/virtual-package-names-list.txt"
956 id="http://ftp.debian.org/debian/doc/package-developer/virtual-package-names-list.txt"></tt>.
960 The procedure for updating the list is described in the preface
967 <heading>Base system</heading>
970 The <tt>base system</tt> is a minimum subset of the Debian
971 GNU/Linux system that is installed before everything else
972 on a new system. Thus, only very few packages are allowed
973 to go into the <tt>base</tt> section to keep the required
974 disk usage very small.</p>
977 Most of these packages will have the priority value
978 <tt>required</tt> or at least <tt>important</tt>, and many
979 of them will be tagged <tt>essential</tt> (see below).</p>
986 <heading>Essential packages</heading>
989 Some packages are tagged <tt>essential</tt>. (They have
990 <tt>Essential: yes</tt> in their package control record.)
991 This flag is used for packages that are <em>essential</em>
995 Since these packages cannot be easily removed (one has to
996 specify an extra <em>force option</em> to
997 <prgn>dpkg</prgn> to do so), this flag must not be used
998 unless absolutely necessary. A shared library package
999 must not be tagged <tt>essential</tt>; dependencies will
1000 prevent its premature removal, and we need to be able to
1001 remove it when it has been superseded.
1005 Since dpkg will not prevent upgrading of other packages
1006 while an <tt>essential</tt> package is in an unconfigured
1007 state, all <tt>essential</tt> packages must supply all of
1008 their core functionality even when unconfigured. If the
1009 package cannot satisfy this requirement it must not be
1010 tagged as essential, and any packages depending on this
1011 package must instead have explicit dependency fields as
1016 You must not tag any packages <tt>essential</tt> before
1017 this has been discussed on the <tt>debian-devel</tt>
1018 mailing list and a consensus about doing that has been
1023 <heading>Tasks</heading>
1026 The Debian install process allows the user to choose from
1027 a number of common tasks which a Debian system can be used to
1028 perform. Selecting a task with <prgn>tasksel</prgn> causes
1029 a set of packages that are useful in performing that task to be
1034 This set of packages is all available packages which have the
1035 name of the selected task in the <tt>Task</tt> field of their
1036 control file. The format of this field is a list of tasks,
1037 separated by commas.
1041 You should not tag any packages as belonging to a task
1042 before this has been discussed on the
1043 <em>debian-devel</em> mailing list and a consensus about
1044 doing that has been reached.
1048 For third parties (and historical reasons), tasksel also
1049 supports constructing tasks based on <em>task
1050 packages</em>. These are packages whose names begin with
1051 <em>task-</em>. Task packages should not be included in the
1056 <sect1 id="maintscripts">
1057 <heading>Maintainer Scripts</heading>
1060 The package installation scripts should avoid producing
1061 output which it is unnecessary for the user to see and
1062 should rely on <prgn>dpkg</prgn> to stave off boredom on
1063 the part of a user installing many packages. This means,
1064 amongst other things, using the <tt>--quiet</tt> option on
1065 <prgn>install-info</prgn>.</p>
1068 Errors which occur during the execution of an installation
1069 script must be checked and the installation must not
1070 continue after an error.
1074 Note that in general <ref id="scripts"> applies to package
1075 maintainer scripts, too.
1079 You should not use <prgn>dpkg-divert</prgn> on a file
1080 belonging to another package without consulting the
1081 maintainer of that package first.
1085 All packages which supply an instance of a common command
1086 name (or, in general, filename) should generally use
1087 <prgn>update-alternatives</prgn>, so that they may be
1088 installed together. If <prgn>update-alternatives</prgn>
1089 is not used, then each package must use
1090 <tt>Conflicts</tt> to ensure that other packages are
1091 de-installed. (In this case, it may be appropriate to
1092 specify a conflict against earlier versions of something
1093 that previously did not use
1094 <prgn>update-alternatives</prgn>; this is an exception to
1095 the usual rule that versioned conflicts should be
1101 <heading>Prompting in maintainer scripts</heading>
1103 Package maintainer scripts may prompt the user if
1104 necessary. Prompting may be accomplished by hand, or by
1105 communicating with a program, such as
1106 <prgn>debconf</prgn>, which conforms to the Debian
1107 Configuration management specification, version 2 or
1108 higher. These are included in the
1109 <file>debconf_specification</file> files in the
1110 <package>debian-policy</package> package.
1111 You may also find this file on the FTP site
1112 <ftpsite>ftp.debian.org</ftpsite> in
1113 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1114 or on your local mirror.<footnote>
1116 4% of Debian packages [see <url
1117 id="http://kitenet.net/programs/debconf/stats/"
1118 name="Debconf stats">] currently use
1119 <package>debconf</package> to prompt the user at
1120 install time, and this number is growing daily. The
1121 benefits of using debconf are briefly explained at
1123 id="http://kitenet.net/doc/debconf-doc/introduction.html"
1124 name="Debconf introduction">; they include
1125 preconfiguration, (mostly) noninteractive
1126 installation, elimination of redundant prompting,
1127 consistency of user interface, etc.
1130 With this increasing number of packages using
1131 <package>debconf</package>, plus the existance of a
1132 nascent second implementation of the Debian
1133 configuration management system
1134 (<package>cdebconf</package>), and the stabilization
1135 of the protocol these things use, the time has
1136 finally come to reflect the use of these things in
1143 Packages which use the Debian Configuration management
1144 specification may contain an additional
1145 <prgn>config</prgn> script and a <tt>templates</tt>
1146 file in their control archive. The <prgn>config</prgn>
1147 script might be run before the <prgn>preinst</prgn>
1148 script, and before the package is unpacked or any of its
1149 dependencies or pre-dependancies are satisfied.
1150 Therefore it must work using only the tools present in
1151 <em>essential</em> packages.<footnote>
1153 <package>Debconf</package> or another tool that
1154 implements the Debian Configuration management
1155 specification will also be installed, and any
1156 versioned dependencies on it will be satisfied
1157 before preconfiguration begins.
1163 Packages should try to minimize the amount of prompting
1164 they need to do, and they should ensure that the user
1165 will only ever be asked each question once. This means
1166 that packages should try to use appropriate shared
1167 configuration files (such as <file>/etc/papersize</file> and
1168 <file>/etc/news/server</file>), and shared
1169 <package>debconf</package> variables rather than each
1170 prompting for their own list of required pieces of
1175 It also means that an upgrade should not ask the same
1176 questions again, unless the user has used <tt>dpkg
1177 --purge</tt> to remove the package's configuration. The
1178 answers to configuration questions should be stored in an
1179 appropriate place in <file>/etc</file> so that the user can
1180 modify them, and how this has been done should be
1184 If a package has a vitally important piece of
1185 information to pass to the user (such as "don't run me
1186 as I am, you must edit the following configuration files
1187 first or you risk your system emitting badly-formatted
1188 messages"), it should display this in the
1189 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1190 prompt the user to hit return to acknowledge the
1191 message. Copyright messages do not count as vitally
1192 important (they belong in
1193 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1194 neither do instructions on how to use a program (these
1195 should be in on-line documentation, where all the users
1199 Any necessary prompting should almost always be confined
1200 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1201 script. If it is done in the <prgn>postinst</prgn>, it
1202 should be protected with a conditional so that
1203 unnecessary prompting doesn't happen if a package's
1204 installation fails and the <prgn>postinst</prgn> is
1205 called with <tt>abort-upgrade</tt>,
1206 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1211 <heading>Source packages</heading>
1213 <sect1 id="standardsversion">
1214 <heading>Standards conformance</heading>
1217 In the source package's <tt>Standards-Version</tt> control
1218 field, you should specify the most recent version number
1219 of this policy document with which your package complied
1220 when it was last updated. The current version number is
1225 This information may be used to file bug reports
1226 automatically if your package becomes too much out of
1231 The version number has four components: major and minor
1232 version number and major and minor patch level. When the
1233 standards change in a way that requires every package to
1234 change the major number will be changed. Significant
1235 changes that will require work in many packages will be
1236 signaled by a change to the minor number. The major patch
1237 level will be changed for any change to the meaning of the
1238 standards, however small; the minor patch level will be
1239 changed when only cosmetic, typographical or other edits
1240 are made which neither change the meaning of the document
1241 nor affect the contents of packages.</p>
1244 Thus only the first three components of the policy version
1245 are significant in the <em>Standards-Version</em> control
1246 field, and so either these three components or the all
1247 four components may be specified.<footnote>
1249 In the past, people specified the full version number
1250 in the Standards-Version field, for example "2.3.0.0".
1251 Since minor patch-level changes don"t introduce new
1252 policy, it was thought it would be better to relax
1253 policy and only require the first 3 components to be
1254 specified, in this example "2.3.0". All four
1255 components may still be used if someone wishes to do
1262 You should regularly, and especially if your package has
1263 become out of date, check for the newest Policy Manual
1264 available and update your package, if necessary. When your
1265 package complies with the new standards you should update the
1266 <tt>Standards-Version</tt> source package field and
1267 release it.<footnote>
1269 See the file <file>upgrading-checklist</file> for
1270 information about policy which has changed between
1271 different versions of this document.
1278 <sect1 id="pkg-relations">
1279 <heading>Package relationships</heading>
1282 Source packages should specify which binary packages they
1283 require to be installed or not to be installed in order to
1284 build correctly. For example, if building a package
1285 requires a certain compiler, then the compiler should be
1286 specified as a build-time dependency.
1290 It is not necessary to explicitly specify build-time
1291 relationships on a minimal set of packages that are always
1292 needed to compile, link and put in a Debian package a
1293 standard "Hello World!" program written in C or C++. The
1294 required packages are called <em>build-essential</em>, and
1295 an informational list can be found in
1296 <file>/usr/share/doc/build-essential/list</file> (which is
1297 contained in the <tt>build-essential</tt>
1300 <list compact="compact">
1302 <p>This allows maintaining the list separately
1303 from the policy documents (the list does not
1304 need the kind of control that the policy
1310 Having a separate package allows one to install
1311 the build-essential packages on a machine, as
1312 well as allowing other packages such as tasks to
1313 require installation of the build-essential
1314 packages using the depends relation.
1319 The separate package allows bug reports against
1320 the list to be categorized separately from
1321 the policy management process in the BTS.
1331 When specifying the set of build-time dependencies, one
1332 should list only those packages explicitly required by the
1333 build. It is not necessary to list packages which are
1334 required merely because some other package in the list of
1335 build-time dependencies depends on them.<footnote>
1337 The reason for this is that dependencies change, and
1338 you should list all those packages, and <em>only</em>
1339 those packages that <em>you</em> need directly. What
1340 others need is their business. For example, if you
1341 only link against <file>libimlib</file>, you will need to
1342 build-depend on <package>libimlib2-dev</package> but
1343 not against any <tt>libjpeg*</tt> packages, even
1344 though <tt>libimlib2-dev</tt> currently depends on
1345 them: installation of <package>libimlib2-dev</package>
1346 will automatically ensure that all of its run-time
1347 dependencies are satisfied.
1353 If build-time dependencies are specified, it must be
1354 possible to build the package and produce working binaries
1355 on a system with only essential and build-essential
1356 packages installed and also those required to satisfy the
1357 build-time relationships (including any implied
1358 relationships). In particular, this means that version
1359 clauses should be used rigorously in build-time
1360 relationships so that one cannot produce bad or
1361 inconsistently configured packages when the relationships
1362 are properly satisfied.
1366 <ref id="relationships"> explains the technical details.
1370 <heading>Changes to the upstream sources</heading>
1373 If changes to the source code are made that are not
1374 specific to the needs of the Debian system, they should be
1375 sent to the upstream authors in whatever form they prefer
1376 so as to be included in the upstream version of the
1380 If you need to configure the package differently for
1381 Debian or for Linux, and the upstream source doesn't
1382 provide a way to do so, you should add such configuration
1383 facilities (for example, a new <prgn>autoconf</prgn> test
1384 or <tt>#define</tt>) and send the patch to the upstream
1385 authors, with the default set to the way they originally
1386 had it. You can then easily override the default in your
1387 <file>debian/rules</file> or wherever is appropriate.</p>
1390 You should make sure that the <prgn>configure</prgn> utility
1391 detects the correct architecture specification string
1392 (refer to <ref id="arch-spec"> for details).</p>
1395 If you need to edit a <prgn>Makefile</prgn> where
1396 GNU-style <prgn>configure</prgn> scripts are used, you
1397 should edit the <file>.in</file> files rather than editing the
1398 <prgn>Makefile</prgn> directly. This allows the user to
1399 reconfigure the package if necessary. You should
1400 <em>not</em> configure the package and edit the generated
1401 <prgn>Makefile</prgn>! This makes it impossible for
1402 someone else to later reconfigure the package.</p>
1405 You should document your changes and updates to the source
1406 package properly in the <file>debian/changelog</file> file.
1407 For more information, please see <ref id="changelogs">.
1413 <heading>Error trapping in makefiles</heading>
1416 When <prgn>make</prgn> invokes a command in a makefile
1417 (including your package's upstream makefiles and
1418 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1419 means that <prgn>sh</prgn>'s usual bad error handling
1420 properties apply: if you include a miniature script as one
1421 of the commands in your makefile you'll find that if you
1422 don't do anything about it then errors are not detected
1423 and <prgn>make</prgn> will blithely continue after
1427 Every time you put more than one shell command (this
1428 includes using a loop) in a makefile command you
1429 must make sure that errors are trapped. For
1430 simple compound commands, such as changing directory and
1431 then running a program, using <tt>&&</tt> rather
1432 than semicolon as a command separator is sufficient. For
1433 more complex commands including most loops and
1434 conditionals you should include a separate <tt>set -e</tt>
1435 command at the start of every makefile command that's
1436 actually one of these miniature shell scripts.</p></sect1>
1440 <heading>Obsolete constructs and libraries</heading>
1443 The include file <tt><varargs.h></tt> is
1444 provided to support end-users compiling very old software;
1445 the library <tt>libtermcap</tt> is provided to support the
1446 execution of software which has been linked against it
1447 (either old programs or those such as Netscape which are
1448 only available in binary form).</p>
1451 Debian packages should be patched to use
1452 <tt><stdarg.h></tt> and <tt>ncurses</tt>
1459 <chapt id="controlfields"><heading>Control files and their fields</heading>
1462 Many of the tools in the package management suite manipulate
1463 data represented in a common format, known as <em>control
1464 data</em>. The data is often stored in <em>control
1465 files</em>. Binary and source packages have control files,
1466 and the <file>.changes</file> files which control the installation
1467 of uploaded files are also in control file format.
1468 <prgn>dpkg</prgn>'s internal databases are in a similar
1472 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1475 A control file consists of one or more paragraphs of fields.
1476 The paragraphs are separated by blank lines. Some control
1477 files allow only one paragraph; others allow several, in
1478 which case each paragraph usually refers to a different
1479 package. (For example, in source packages, the first
1480 paragraph refers to the source package, and later paragraphs
1481 refer to binary packages generated from the source.)
1485 Each paragraph consists of a series of data fields; each
1486 field consists of the field name, followed by a colon and
1487 then the data/value associated with that field. It ends at
1488 the end of the line. Horizontal whitespace (spaces and
1489 tabs) may occur immediately before or after the value and is
1490 ignored there; it is conventional to put a single space
1491 after the colon. For example, a field might be:
1492 <example compact="compact">
1495 the field name is <tt>Package</tt> and the field value
1500 Some fields' values may span several lines; in this case
1501 each continuation line <em>must</em> start with a space or
1502 tab. Any trailing spaces or tabs at the end of individual
1503 lines of a field value are ignored.
1507 Except where otherwise stated only a single line of data is
1508 allowed and whitespace is not significant in a field body.
1509 Whitespace must not appear inside names (of packages,
1510 architectures, files or anything else) or version numbers,
1511 or between the characters of multi-character version
1516 Field names are not case-sensitive, but it is usual to
1517 capitalize the field names using mixed case as shown below.
1521 Blank lines, or lines consisting only of spaces and tabs,
1522 are not allowed within field values or between fields - that
1523 would mean a new paragraph.
1528 <sect><heading>List of fields</heading>
1530 This list here is not supposed to be exhaustive. Most fields
1531 are dealt with elsewhere in this document.
1533 <sect1 id="f-Package"><heading><tt>Package</tt>
1537 The name of the binary package. Package names consist of
1538 lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1539 plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1540 periods (<tt>.</tt>).
1544 They must be at least two characters long and must start
1545 with an alphanumeric character. The use of lowercase
1546 package names is required unless the package you're
1547 building (or referring to, in other fields) is already
1548 using uppercase characters.</p>
1551 <sect1 id="f-Version"><heading><tt>Version</tt>
1555 This lists the source or binary package's version number -
1556 see <ref id="versions">.
1562 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1566 The most recent version of the standards (the policy
1567 manual and associated texts) with which the package
1568 complies. This is updated manually when editing the
1569 source package to conform to newer standards; it can
1570 sometimes be used to tell when a package needs attention.
1571 Its format is described above; see
1572 <ref id="standardsversion">.
1577 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1581 In a <file>.changes</file> file or parsed changelog output
1582 this contains the (space-separated) name(s) of the
1583 distribution(s) where this version of the package should
1584 be installed. Valid distributions are determined by the
1585 archive maintainers.<footnote>
1586 Current distribution names are:
1587 <taglist compact="compact">
1588 <tag><em>stable</em></tag>
1591 This is the current "released" version of Debian
1592 GNU/Linux. Once the distribution is
1593 <em>stable</em> only security fixes and other
1594 major bug fixes are allowed. When changes are
1595 made to this distribution, the release number is
1596 increased (for example: 2.2r1 becomes 2.2r2 then
1601 <tag><em>unstable</em></tag>
1604 This distribution value refers to the
1605 <em>developmental</em> part of the Debian
1606 distribution tree. New packages, new upstream
1607 versions of packages and bug fixes go into the
1608 <em>unstable</em> directory tree. Download from
1609 this distribution at your own risk.
1613 <tag><em>testing</em></tag>
1616 This distribution value refers to the
1617 <em>testing</em> part of the Debian distribution
1618 tree. It receives its packages from the
1619 unstable distribution after a short time lag to
1620 ensure that there are no major issues with the
1621 unstable packages. It is less prone to breakage
1622 than unstable, but still risky. It is not
1623 possible to upload packages directly to
1628 <tag><em>frozen</em></tag>
1631 From time to time, the <em>testing</em>
1632 distribution enters a state of "code-freeze" in
1633 anticipation of release as a <em>stable</em>
1634 version. During this period of testing only
1635 fixes for existing or newly-discovered bugs will
1636 be allowed. The exact details of this stage are
1637 determined by the Release Manager.
1641 <tag><em>experimental</em></tag>
1644 The packages with this distribution value are
1645 deemed by their maintainers to be high
1646 risk. Oftentimes they represent early beta or
1647 developmental packages from various sources that
1648 the maintainers want people to try, but are not
1649 ready to be a part of the other parts of the
1650 Debian distribution tree. Download at your own
1656 You should list <em>all</em> distributions that the
1657 package should be installed into.
1666 <chapt id="versions"><heading>Version numbering</heading>
1669 Every package has a version number recorded in its
1670 <tt>Version</tt> control file field.
1674 The package management system imposes an ordering on version
1675 numbers, so that it can tell whether packages are being up- or
1676 downgraded and so that package system front end applications
1677 can tell whether a package it finds available is newer than
1678 the one installed on the system. The version number format
1679 has the most significant parts (as far as comparison is
1680 concerned) at the beginning.
1684 The version number format is:
1685 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1689 The three components here are:
1691 <tag><var>epoch</var></tag>
1694 This is a single (generally small) unsigned integer. It
1695 may be omitted, in which case zero is assumed. If it is
1696 omitted then the <var>upstream_version</var> may not
1701 It is provided to allow mistakes in the version numbers
1702 of older versions of a package, and also a package's
1703 previous version numbering schemes, to be left behind.
1707 <tag><var>upstream_version</var></tag>
1710 This is the main part of the version number. It is
1711 usually the version number of the original ("upstream")
1712 package from which the <file>.deb</file> file has been made,
1713 if this is applicable. Usually this will be in the same
1714 format as that specified by the upstream author(s);
1715 however, it may need to be reformatted to fit into the
1716 package management system's format and comparison
1721 The comparison behavior of the package management system
1722 with respect to the <var>upstream_version</var> is
1723 described below. The <var>upstream_version</var>
1724 portion of the version number is mandatory.
1728 The <var>upstream_version</var> may contain only
1729 alphanumerics<footnote>
1730 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1732 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1733 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1734 start with a digit. If there is no
1735 <var>debian_revision</var> then hyphens are not allowed;
1736 if there is no <var>epoch</var> then colons are not
1740 <tag><var>debian_revision</var></tag>
1743 This part of the version number specifies the version of
1744 the Debian package based on the upstream version. It
1745 may contain only alphanumerics and the characters
1746 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1747 compared in the same way as the
1748 <var>upstream_version</var> is.
1752 It is optional; if it isn't present then the
1753 <var>upstream_version</var> may not contain a hyphen.
1754 This format represents the case where a piece of
1755 software was written specifically to be turned into a
1756 Debian package, and so there is only one "debianization"
1757 of it and therefore no revision indication is required.
1761 It is conventional to restart the
1762 <var>debian_revision</var> at <tt>1</tt> each time the
1763 <var>upstream_version</var> is increased.
1767 The package management system will break the version
1768 number apart at the last hyphen in the string (if there
1769 is one) to determine the <var>upstream_version</var> and
1770 <var>debian_revision</var>. The absence of a
1771 <var>debian_revision</var> compares earlier than the
1772 presence of one (but note that the
1773 <var>debian_revision</var> is the least significant part
1774 of the version number).
1781 The <var>upstream_version</var> and <var>debian_revision</var>
1782 parts are compared by the package management system using the
1787 The strings are compared from left to right.
1791 First the initial part of each string consisting entirely of
1792 non-digit characters is determined. These two parts (one of
1793 which may be empty) are compared lexically. If a difference
1794 is found it is returned. The lexical comparison is a
1795 comparison of ASCII values modified so that all the letters
1796 sort earlier than all the non-letters.
1800 Then the initial part of the remainder of each string which
1801 consists entirely of digit characters is determined. The
1802 numerical values of these two parts are compared, and any
1803 difference found is returned as the result of the comparison.
1804 For these purposes an empty string (which can only occur at
1805 the end of one or both version strings being compared) counts
1810 These two steps (comparing and removing initial non-digit
1811 strings and initial digit strings) are repeated until a
1812 difference is found or both strings are exhausted.
1816 Note that the purpose of epochs is to allow us to leave behind
1817 mistakes in version numbering, and to cope with situations
1818 where the version numbering scheme changes. It is
1819 <em>not</em> intended to cope with version numbers containing
1820 strings of letters which the package management system cannot
1821 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1822 silly orderings (the author of this manual has heard of a
1823 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1824 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1825 <tt>2</tt> and so forth).
1829 If an upstream package has problematic version numbers they
1830 should be converted to a sane form for use in the
1831 <tt>Version</tt> field.
1835 <heading>Version numbers based on dates</heading>
1837 In general, Debian packages should use the same version
1838 numbers as the upstream sources.</p>
1841 However, in some cases where the upstream version number is
1842 based on a date (e.g., a development "snapshot" release) the
1843 package management system cannot handle these version
1844 numbers without epochs. For example, dpkg will consider
1845 "96May01" to be greater than "96Dec24".</p>
1848 To prevent having to use epochs for every new upstream
1849 version, the version number should be changed to the
1850 following format in such cases: "19960501", "19961224". It
1851 is up to the maintainer whether he/she wants to bother the
1852 upstream maintainer to change the version numbers upstream,
1856 Note that other version formats based on dates which are
1857 parsed correctly by the package management system should
1858 <em>not</em> be changed.</p>
1861 Native Debian packages (i.e., packages which have been
1862 written especially for Debian) whose version numbers include
1863 dates should always use the "YYYYMMDD" format.</p>
1867 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1869 <sect id="timestamps"><heading>Time Stamps</heading>
1871 Maintainers should preserve the modification times of the
1872 upstream source files in a package, as far as is reasonably
1875 The rationale is that there is some information conveyed
1876 by knowing the age of the file, for example, you could
1877 recognize that some documentation is very old by looking
1878 at the modification time, so it would be nice if the
1879 modification time of the upstream source would be
1886 <sect id="debianrules"><heading><file>debian/rules</file> - the
1887 main building script</heading>
1890 This file must be an executable makefile, and contains the
1891 package-specific recipes for compiling the package and
1892 building binary package(s) from the source.
1896 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1897 so that it can be invoked by saying its name rather than
1898 invoking <prgn>make</prgn> explicitly.
1902 Since an interactive <file>debian/rules</file> script makes it
1903 impossible to auto-compile that package and also makes it
1904 hard for other people to reproduce the same binary
1905 package, all <em>required targets</em> MUST be
1906 non-interactive. At a minimum, required targets are the
1907 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1908 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1909 <em>binary-indep</em>, and <em>build</em>. It also follows
1910 that any target that these targets depend on must also be
1915 The required and optional targets are as follows:
1917 <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1918 <tt>build-indep</tt> (optional)</tag>
1921 The <tt>build</tt> target should perform all
1922 non-interactive configuration and compilation of the
1923 package. If a package has an interactive pre-build
1924 configuration routine, the Debianized source package
1925 must either be built after this has taken place (so
1926 that the binary package can be built without rerunning
1927 the configuration) or the configuration routine
1928 modified to become non-interactive. (The latter is
1929 preferable if there are architecture-specific features
1930 detected by the configuration routine.)
1934 For some packages, notably ones where the same
1935 source tree is compiled in different ways to produce
1936 two binary packages, the <tt>build</tt> target
1937 does not make much sense. For these packages it is
1938 good enough to provide two (or more) targets
1939 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1940 for each of the ways of building the package, and a
1941 <tt>build</tt> target that does nothing. The
1942 <tt>binary</tt> target will have to build the
1943 package in each of the possible ways and make the
1944 binary package out of each.
1948 The <tt>build</tt> target must not do anything
1949 that might require root privilege.
1953 The <tt>build</tt> target may need to run the
1954 <tt>clean</tt> target first - see below.
1958 When a package has a configuration and build routine
1959 which takes a long time, or when the makefiles are
1960 poorly designed, or when <tt>build</tt> needs to
1961 run <tt>clean</tt> first, it is a good idea to
1962 <tt>touch build</tt> when the build process is
1963 complete. This will ensure that if <tt>debian/rules
1964 build</tt> is run again it will not rebuild the whole
1967 Another common way to do this is for <tt>build</tt>
1968 to depend on <prgn>build-stamp</prgn> and to do
1969 nothing else, and for the <prgn>build-stamp</prgn>
1970 target to do the building and to <tt>touch
1971 build-stamp</tt> on completion. This is
1972 especially useful if the build routine creates a
1973 file or directory called <tt>build</tt>; in such a
1974 case, <tt>build</tt> will need to be listed as
1975 a phony target (i.e., as a dependency of the
1976 <tt>.PHONY</tt> target). See the documentation of
1977 <prgn>make</prgn> for more information on phony
1984 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1985 <tt>binary-indep</tt>
1989 The <tt>binary</tt> target must be all that is
1990 necessary for the user to build the binary package(s)
1991 produced from this source package. All of these
1992 targets are required to be non-interactive. It is
1993 split into two parts: <prgn>binary-arch</prgn> builds
1994 the binary packages which are specific to a particular
1995 architecture, and <tt>binary-indep</tt> builds
1996 those which are not.
1999 <tt>binary</tt> may be (and commonly is) a target with
2000 no commands which simply depends on
2001 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
2004 Both <tt>binary-*</tt> targets should depend on the
2005 <tt>build</tt> target, or on the appropriate
2006 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
2007 provided, so that the package is built if it has not
2008 been already. It should then create the relevant
2009 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
2010 make their control files and <prgn>dpkg-deb</prgn> to
2011 build them and place them in the parent of the top
2016 Both the <tt>binary-arch</tt> and
2017 <tt>binary-indep</tt> targets <em>must</em> exist.
2018 If one of them has nothing to do (which will always be
2019 the case if the source generates only a single binary
2020 package, whether architecture-dependent or not), it
2021 must still exist and must always succeed.
2025 The <tt>binary</tt> targets must be invoked as
2028 The <prgn>fakeroot</prgn> package often allows one
2029 to build a package correctly even without being
2036 <tag><tt>clean</tt></tag>
2039 This must undo any effects that the <tt>build</tt>
2040 and <tt>binary</tt> targets may have had, except
2041 that it should leave alone any output files created in
2042 the parent directory by a run of a <tt>binary</tt>
2043 target. This target must be non-interactive.
2047 If a <tt>build</tt> file is touched at the end of
2048 the <tt>build</tt> target, as suggested above, it
2049 should be removed as the first action that
2050 <tt>clean</tt> performs, so that running
2051 <tt>build</tt> again after an interrupted
2052 <tt>clean</tt> doesn't think that everything is
2057 The <tt>clean</tt> target may need to be
2058 invoked as root if <tt>binary</tt> has been
2059 invoked since the last <tt>clean</tt>, or if
2060 <tt>build</tt> has been invoked as root (since
2061 <tt>build</tt> may create directories, for
2066 <tag><tt>get-orig-source</tt> (optional)</tag>
2069 This target fetches the most recent version of the
2070 original source package from a canonical archive site
2071 (via FTP or WWW, for example), does any necessary
2072 rearrangement to turn it into the original source
2073 tar file format described below, and leaves it in the
2078 This target may be invoked in any directory, and
2079 should take care to clean up any temporary files it
2084 This target is optional, but providing it if
2085 possible is a good idea.
2091 The <tt>build</tt>, <tt>binary</tt> and
2092 <tt>clean</tt> targets must be invoked with the current
2093 directory being the package's top-level directory.
2098 Additional targets may exist in <file>debian/rules</file>,
2099 either as published or undocumented interfaces or for the
2100 package's internal use.
2104 The architectures we build on and build for are determined
2105 by <prgn>make</prgn> variables using the utility
2106 <prgn>dpkg-architecture</prgn>. You can determine the
2107 Debian architecture and the GNU style architecture
2108 specification string for the build machine (the machine type
2109 we are building on) as well as for the host machine (the
2110 machine type we are building for). Here is a list of
2111 supported <prgn>make</prgn> variables:
2112 <list compact="compact">
2114 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2117 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2118 specification string)</p>
2121 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2122 <tt>DEB_*_GNU_TYPE</tt>)</p>
2125 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2126 <tt>DEB_*_GNU_TYPE</tt>)</p>
2128 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2129 the build machine or <tt>HOST</tt> for specification of the
2134 Backward compatibility can be provided in the rules file
2135 by setting the needed variables to suitable default
2136 values; please refer to the documentation of
2137 <prgn>dpkg-architecture</prgn> for details.
2141 It is important to understand that the <tt>DEB_*_ARCH</tt>
2142 string only determines which Debian architecture we are
2143 building on or for. It should not be used to get the CPU
2144 or system information; the GNU style variables should be
2149 <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2153 This file records the changes to the Debian-specific parts of the
2156 Though there is nothing stopping an author who is also
2157 the Debian maintainer from using it for all their
2158 changes, it will have to be renamed if the Debian and
2159 upstream maintainers become different people. In such a
2160 case, however, it might be better to maintain the
2161 package as a non-native package.
2167 It has a special format which allows the package building
2168 tools to discover which version of the package is being
2169 built and find out other release-specific information.
2173 That format is a series of entries like this:
2174 <example compact="compact">
2175 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2177 <p>[optional blank line(s), stripped]</p>
2179 * <var>change details</var>
2180 <var>more change details</var>
2182 <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2184 * <var>even more change details</var>
2186 <p>[optional blank line(s), stripped]</p>
2188 -- <var>maintainer name</var> <<var>email
2189 address</var>><var>[two spaces]</var> <var>date</var>
2194 <var>package</var> and <var>version</var> are the source
2195 package name and version number.
2199 <var>distribution(s)</var> lists the distributions where
2200 this version should be installed when it is uploaded - it
2201 is copied to the <tt>Distribution</tt> field in the
2202 <file>.changes</file> file. See <ref id="f-Distribution">.
2206 <var>urgency</var> is the value for the <tt>Urgency</tt>
2207 field in the <file>.changes</file> file for the upload. It is
2208 not possible to specify an urgency containing commas; commas
2209 are used to separate
2210 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2211 <prgn>dpkg</prgn> changelog format (though there is
2212 currently only one useful <var>keyword</var>,
2213 <tt>urgency</tt>).<footnote>
2215 Recognised urgency values are <tt>low</tt>,
2216 <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2217 They have an effect on how quickly a package will be
2218 considered for inclusion into the <tt>testing</tt>
2219 distribution, and give an indication of the importance
2220 of any fixes included in this upload.
2226 The change details may in fact be any series of lines
2227 starting with at least two spaces, but conventionally each
2228 change starts with an asterisk and a separating space and
2229 continuation lines are indented so as to bring them in
2230 line with the start of the text above. Blank lines may be
2231 used here to separate groups of changes, if desired.
2235 If this upload resolves bugs recorded in the Bug Tracking
2236 System (BTS), they may be automatically closed on the
2237 inclusion of this package into the Debian archive by
2238 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2239 in the change details.<footnote>
2241 To be precise, the string should match the following
2242 Perl regular expression:
2244 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2246 Then all of the bug numbers listed will be closed by the
2247 archive maintenance script (<prgn>katie</prgn>), or in
2248 the case of an NMU, marked as fixed.
2254 The maintainer name and email address used in the changelog
2255 should be the details of the person uploading <em>this</em>
2256 version. They are <em>not</em> necessarily those of the
2257 usual package maintainer. The information here will be
2258 copied to the <tt>Changed-By</tt> field in the
2259 <tt>.changes</tt> file, and then later used to send an
2260 acknowledgement when the upload has been installed.
2264 The <var>date</var> should be in RFC822 format<footnote>
2266 This is generated by the <prgn>822-date</prgn>
2269 </footnote>; it should include the time zone specified
2270 numerically, with the time zone name or abbreviation
2271 optionally present as a comment in parentheses.
2275 The first "title" line with the package name should start
2276 at the left hand margin; the "trailer" line with the
2277 maintainer and date details should be preceded by exactly
2278 one space. The maintainer details and the date must be
2279 separated by exactly two spaces.
2282 <sect1><heading>Defining alternative changelog formats</heading>
2285 It is possible to use a different format to the standard
2286 one, by providing a parser for the format you wish to
2290 A changelog parser must not interact with the user at
2296 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
2298 <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2299 and variable substitutions </heading>
2302 When <prgn>dpkg-gencontrol</prgn>,
2303 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2304 generate control files they perform variable substitutions
2305 on their output just before writing it. Variable
2306 substitutions have the form <tt>${<var>variable</var>}</tt>.
2307 The optional file <file>debian/substvars</file> contains
2308 variable substitutions to be used; variables can also be set
2309 directly from <file>debian/rules</file> using the <tt>-V</tt>
2310 option to the source packaging commands, and certain
2311 predefined variables are also available.
2315 The <file>debian/substvars</file> file is usually generated and
2316 modified dynamically by <file>debian/rules</file> targets, in
2317 which case it must be removed by the <tt>clean</tt> target.
2321 See <manref name="dpkg-source" section="1"> for full
2322 details about source variable substitutions, including the
2323 format of <file>debian/substvars</file>.</p>
2326 <sect id="debianfiles"><heading><file>debian/files</file>
2330 This file is not a permanent part of the source tree; it
2331 is used while building packages to record which files are
2332 being generated. <prgn>dpkg-genchanges</prgn> uses it
2333 when it generates a <file>.changes</file> file.
2337 It should not exist in a shipped source package, and so it
2338 (and any backup files or temporary files such as
2339 <file>files.new</file><footnote>
2341 <file>files.new</file> is used as a temporary file by
2342 <prgn>dpkg-gencontrol</prgn> and
2343 <prgn>dpkg-distaddfile</prgn> - they write a new
2344 version of <tt>files</tt> here before renaming it,
2345 to avoid leaving a corrupted copy if an error
2348 </footnote>) should be removed by the
2349 <tt>clean</tt> target. It may also be wise to
2350 ensure a fresh start by emptying or removing it at the
2351 start of the <tt>binary</tt> target.
2355 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2356 package, it adds an entry to <file>debian/files</file> for the
2357 <file>.deb</file> file that will be created when <tt>dpkg-deb
2358 --build</tt> is run for that binary package. So for most
2359 packages all that needs to be done with this file is to
2360 delete it in the <tt>clean</tt> target.
2364 If a package upload includes files besides the source
2365 package and any binary packages whose control files were
2366 made with <prgn>dpkg-gencontrol</prgn> then they should be
2367 placed in the parent of the package's top-level directory
2368 and <prgn>dpkg-distaddfile</prgn> should be called to add
2369 the file to the list in <file>debian/files</file>.</p>
2372 <sect id="restrictions"><heading>Restrictions on objects in source packages
2376 The source package may not contain any hard links<footnote>
2378 This is not currently detected when building source
2379 packages, but only when extracting
2383 Hard links may be permitted at some point in the
2384 future, but would require a fair amount of
2387 </footnote>, device special files, sockets or setuid or
2388 setgid files.<footnote>
2390 Setgid directories are allowed.
2396 <sect id="descriptions"><heading>Descriptions of packages - the
2397 <tt>Description</tt> field</heading>
2400 The "Description" control file field consists of two parts,
2401 the synopsis or the short description, and the long description.
2402 The field's format is as follows:
2406 Description: <single line synopsis>
2407 <extended description over several lines>
2411 The description is intended to describe the program to a user
2412 who has never met it before so that they know whether they
2413 want to install it. It should also give information about the
2414 significant dependencies and conflicts between this package
2415 and others, so that the user knows why these dependencies and
2416 conflicts have been declared.
2420 Put important information first, both in the synopsis and
2421 extended description. Sometimes only the first part of the
2422 synopsis or of the description will be displayed. You can
2423 assume that there will usually be a way to see the whole
2424 extended description.
2427 <sect1 id="synopsis"><heading>The single line synopsis</heading>
2430 The single line synopsis should be kept brief - certainly
2431 under 80 characters.
2435 Do not include the package name in the synopsis line. The
2436 display software knows how to display this already, and you
2437 do not need to state it. Remember that in many situations
2438 the user may only see the synopsis line - make it as
2439 informative as you can.
2444 <sect1 id="extendeddesc"><heading>The extended description</heading>
2447 Do not try to continue the single line synopsis into the
2448 extended description. This will not work correctly when
2449 the full description is displayed, and makes no sense
2450 where only the summary (the single line synopsis) is
2455 The extended description should describe what the package
2456 does and how it relates to the rest of the system (in terms
2457 of, for example, which subsystem it is which part of).
2461 The description field needs to make sense to anyone, even
2462 people who have no idea about any of the things the
2463 package deals with.<footnote>
2464 The blurb that comes with a program in its
2465 announcements and/or <prgn>README</prgn> files is
2466 rarely suitable for use in a description. It is
2467 usually aimed at people who are already in the
2468 community where the package is used.
2473 The lines in the extended description can have these formats:
2479 Those starting with a single space are part of a paragraph.
2480 Successive lines of this form will be word-wrapped when
2481 displayed. The leading space will usually be stripped off.
2485 Those starting with two or more spaces. These will be
2486 displayed verbatim. If the display cannot be panned
2487 horizontally, the displaying program will linewrap them "hard"
2488 (i.e., without taking account of word breaks). If it can they
2489 will be allowed to trail off to the right. None, one or two
2490 initial spaces may be deleted, but the number of spaces
2491 deleted from each line will be the same (so that you can have
2492 indenting work correctly, for example).
2496 Those containing a single space followed by a single full stop
2497 character. These are rendered as blank lines. This is the
2498 <em>only</em> way to get a blank line<footnote>
2499 Completely empty lines will not be rendered as blank lines.
2500 Instead, they will cause the parser to think you're starting
2501 a whole new record in the control file, and will therefore
2502 likely abort with an error.
2507 Those containing a space, a full stop and some more characters.
2508 These are for future expansion. Do not use them.
2514 Do not use tab characters. Their effect is not predictable.
2524 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2525 and installation procedure
2528 <sect><heading>Introduction to package maintainer scripts
2532 It is possible to supply scripts as part of a package which
2533 the package management system will run for you when your
2534 package is installed, upgraded or removed.
2538 These scripts are the files <prgn>preinst</prgn>,
2539 <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2540 control area of the package. They must be proper executable
2541 files; if they are scripts (which is recommended), they must
2542 start with the usual <tt>#!</tt> convention. They should be
2543 readable and executable by anyone, and not world-writable.
2547 The package management system looks at the exit status from
2548 these scripts. It is important that they exit with a
2549 non-zero status if there is an error, so that the package
2550 management system can stop its processing. For shell
2551 scripts this means that you <em>almost always</em> need to
2552 use <tt>set -e</tt> (this is usually true when writing shell
2553 scripts, in fact). It is also important, of course, that
2554 they don't exit with a non-zero status if everything went
2559 When a package is upgraded a combination of the scripts from
2560 the old and new packages is called during the upgrade
2561 procedure. If your scripts are going to be at all
2562 complicated you need to be aware of this, and may need to
2563 check the arguments to your scripts.
2567 Broadly speaking the <prgn>preinst</prgn> is called before
2568 (a particular version of) a package is installed, and the
2569 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2570 before (a version of) a package is removed and the
2571 <prgn>postrm</prgn> afterwards.
2575 Programs called from maintainer scripts should not normally
2576 have a path prepended to them. Before installation is
2577 started, the package management system checks to see if the
2578 programs <prgn>ldconfig</prgn>,
2579 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2580 and <prgn>update-rc.d</prgn> can be found via the
2581 <tt>PATH</tt> environment variable. Those programs, and any
2582 other program that one would expect to be on the
2583 <tt>PATH</tt>, should thus be invoked without an absolute
2584 pathname. Maintainer scripts should also not reset the
2585 <tt>PATH</tt>, though they might choose to modify it by
2586 prepending or appending package-specific directories. These
2587 considerations really apply to all shell scripts.</p>
2591 <heading>Maintainer scripts Idempotency</heading>
2594 It is necessary for the error recovery procedures that the
2595 scripts be idempotent. This means that if it is run
2596 successfully, and then it is called again, it doesn't bomb
2597 out or cause any harm, but just ensures that everything is
2598 the way it ought to be. If the first call failed, or
2599 aborted half way through for some reason, the second call
2600 should merely do the things that were left undone the first
2601 time, if any, and exit with a success status if everything
2604 This is so that if an error occurs, the user interrupts
2605 <prgn>dpkg</prgn> or some other unforeseen circumstance
2606 happens you don't leave the user with a badly-broken
2607 package when <prgn>dpkg</prgn> attempts to repeat the
2615 <heading>Controlling terminal for maintainer scripts</heading>
2618 The maintainer scripts are guaranteed to run with a
2619 controlling terminal and can interact with the user.
2620 If they need to prompt for passwords, do full-screen
2621 interaction or something similar you should do these
2622 things to and from <file>/dev/tty</file>, since
2623 <prgn>dpkg</prgn> will at some point redirect scripts'
2624 standard input and output so that it can log the
2625 installation process. Likewise, because these scripts
2626 may be executed with standard output redirected into a
2627 pipe for logging purposes, Perl scripts should set
2628 unbuffered output by setting <tt>$|=1</tt> so that the
2629 output is printed immediately rather than being
2634 Each script should return a zero exit status for
2635 success, or a nonzero one for failure.
2639 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2644 <list compact="compact">
2646 <p><var>new-preinst</var> <tt>install</tt></p>
2649 <p><var>new-preinst</var> <tt>install</tt>
2650 <var>old-version</var></p>
2653 <p><var>new-preinst</var> <tt>upgrade</tt>
2654 <var>old-version</var></p>
2657 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2658 <var>new-version</var>
2664 <list compact="compact">
2666 <p><var>postinst</var> <tt>configure</tt>
2667 <var>most-recently-configured-version</var></p>
2670 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2671 <var>new-version</var></p>
2674 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2675 <tt>in-favour</tt> <var>package</var>
2676 <var>new-version</var></p>
2680 <var>deconfigured's-postinst</var>
2681 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2682 <var>failed-install-package</var> <var>version</var>
2683 <tt>removing</tt> <var>conflicting-package</var>
2690 <list compact="compact">
2692 <p><var>prerm</var> <tt>remove</tt></p>
2695 <p><var>old-prerm</var> <tt>upgrade</tt>
2696 <var>new-version</var></p>
2699 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2700 <var>old-version</var></p>
2703 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2704 <tt>in-favour</tt> <var>package</var>
2705 <var>new-version</var></p>
2709 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2710 <tt>in-favour</tt> <var>package-being-installed</var>
2711 <var>version</var> <tt>removing</tt>
2712 <var>conflicting-package</var>
2719 <list compact="compact">
2721 <p><var>postrm</var> <tt>remove</tt></p>
2724 <p><var>postrm</var> <tt>purge</tt></p>
2728 <var>old-postrm</var> <tt>upgrade</tt>
2729 <var>new-version</var></p>
2732 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2733 <var>old-version</var></p>
2736 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2739 <p><var>new-postrm</var> <tt>abort-install</tt>
2740 <var>old-version</var></p>
2743 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2744 <var>old-version</var></p>
2748 <var>disappearer's-postrm</var> <tt>disappear</tt>
2749 <var>overwriter</var>
2750 <var>overwriter-version</var></p></item>
2755 <sect id="unpackphase"><heading>Details of unpack phase of
2756 installation or upgrade
2760 The procedure on installation/upgrade/overwrite/disappear
2761 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2762 stage of <tt>dpkg --install</tt>) is as follows. In each
2763 case, if a major error occurs (unless listed below) the
2764 actions are, in general, run backwards - this means that the
2765 maintainer scripts are run with different arguments in
2766 reverse order. These are the "error unwind" calls listed
2774 <p>If a version of the package is already
2776 <example compact="compact">
2777 <var>old-prerm</var> upgrade <var>new-version</var>
2782 If the script runs but exits with a non-zero
2783 exit status, <prgn>dpkg</prgn> will attempt:
2784 <example compact="compact">
2785 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2787 Error unwind, for both the above cases:
2788 <example compact="compact">
2789 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2797 <p>If a "conflicting" package is being removed at the same time:
2801 If any packages depended on that conflicting
2802 package and <tt>--auto-deconfigure</tt> is
2803 specified, call, for each such package:
2804 <example compact="compact">
2805 <var>deconfigured's-prerm</var> deconfigure \
2806 in-favour <var>package-being-installed</var> <var>version</var> \
2807 removing <var>conflicting-package</var> <var>version</var>
2810 <example compact="compact">
2811 <var>deconfigured's-postinst</var> abort-deconfigure \
2812 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2813 removing <var>conflicting-package</var> <var>version</var>
2815 The deconfigured packages are marked as
2816 requiring configuration, so that if
2817 <tt>--install</tt> is used they will be
2818 configured again if possible.</p>
2821 <p>To prepare for removal of the conflicting package, call:
2822 <example compact="compact">
2823 <var>conflictor's-prerm</var> remove \
2824 in-favour <var>package</var> <var>new-version</var>
2827 <example compact="compact">
2828 <var>conflictor's-postinst</var> abort-remove \
2829 in-favour <var>package</var> <var>new-version</var>
2840 <p>If the package is being upgraded, call:
2841 <example compact="compact">
2842 <var>new-preinst</var> upgrade <var>old-version</var>
2847 Otherwise, if the package had some configuration
2848 files from a previous version installed (i.e., it
2849 is in the "configuration files only" state):
2850 <example compact="compact">
2851 <var>new-preinst</var> install <var>old-version</var>
2855 <p>Otherwise (i.e., the package was completely purged):
2856 <example compact="compact">
2857 <var>new-preinst</var> install
2859 Error unwind actions, respectively:
2860 <example compact="compact">
2861 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2862 <var>new-postrm</var> abort-install <var>old-version</var>
2863 <var>new-postrm</var> abort-install
2872 The new package's files are unpacked, overwriting any
2873 that may be on the system already, for example any
2874 from the old version of the same package or from
2875 another package. Backups of the old files are kept
2876 temporarily, and if anything goes wrong the package
2877 management system will attempt to put them back as
2878 part of the error unwind.
2882 It is an error for a package to contains files which
2883 are on the system in another package, unless
2884 <tt>Replaces</tt> is used (see <ref id="replaces">).
2886 The following paragraph is not currently the case:
2887 Currently the <tt>- - force-overwrite</tt> flag is
2888 enabled, downgrading it to a warning, but this may not
2894 It is a more serious error for a package to contain a
2895 plain file or other kind of non-directory where another
2896 package has a directory (again, unless
2897 <tt>Replaces</tt> is used). This error can be
2898 overridden if desired using
2899 <tt>--force-overwrite-dir</tt>, but this is not
2904 Packages which overwrite each other's files produce
2905 behavior which, though deterministic, is hard for the
2906 system administrator to understand. It can easily
2907 lead to "missing" programs if, for example, a package
2908 is installed which overwrites a file from another
2909 package, and is then removed again.<footnote>
2911 Part of the problem is due to what is arguably a
2912 bug in <prgn>dpkg</prgn>.
2918 A directory will never be replaced by a symbolic link
2919 to a directory or vice versa; instead, the existing
2920 state (symlink or not) will be left alone and
2921 <prgn>dpkg</prgn> will follow the symlink if there is
2929 <p>If the package is being upgraded, call
2930 <example compact="compact">
2931 <var>old-postrm</var> upgrade <var>new-version</var>
2936 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2937 <example compact="compact">
2938 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2940 Error unwind, for both cases:
2941 <example compact="compact">
2942 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2949 This is the point of no return - if
2950 <prgn>dpkg</prgn> gets this far, it won't back off
2951 past this point if an error occurs. This will
2952 leave the package in a fairly bad state, which
2953 will require a successful re-installation to clear
2954 up, but it's when <prgn>dpkg</prgn> starts doing
2955 things that are irreversible.
2960 Any files which were in the old version of the package
2961 but not in the new are removed.</p>
2964 <p>The new file list replaces the old.</p>
2967 <p>The new maintainer scripts replace the old.</p>
2971 <p>Any packages all of whose files have been overwritten during the
2972 installation, and which aren't required for
2973 dependencies, are considered to have been removed.
2974 For each such package
2977 <p><prgn>dpkg</prgn> calls:
2978 <example compact="compact">
2979 <var>disappearer's-postrm</var> disappear \
2980 <var>overwriter</var> <var>overwriter-version</var>
2985 <p>The package's maintainer scripts are removed.
2990 It is noted in the status database as being in a
2991 sane state, namely not installed (any conffiles
2992 it may have are ignored, rather than being
2993 removed by <prgn>dpkg</prgn>). Note that
2994 disappearing packages do not have their prerm
2995 called, because <prgn>dpkg</prgn> doesn't know
2996 in advance that the package is going to
3005 Any files in the package we're unpacking that are also
3006 listed in the file lists of other packages are removed
3007 from those lists. (This will lobotomize the file list
3008 of the "conflicting" package if there is one.)
3013 The backup files made during installation, above, are
3020 The new package's status is now sane, and recorded as
3025 Here is another point of no return - if the
3026 conflicting package's removal fails we do not unwind
3027 the rest of the installation; the conflicting package
3028 is left in a half-removed limbo.
3034 If there was a conflicting package we go and do the
3035 removal actions (described below), starting with the
3036 removal of the conflicting package's files (any that
3037 are also in the package being installed have already
3038 been removed from the conflicting package's file list,
3039 and so do not get removed now).
3046 <sect id="configdetails"><heading>Details of configuration</heading>
3049 When we configure a package (this happens with <tt>dpkg
3050 --install</tt> and <tt>dpkg --configure</tt>), we first
3051 update any <tt>conffile</tt>s and then call:
3052 <example compact="compact">
3053 <var>postinst</var> configure <var>most-recently-configured-version</var>
3058 No attempt is made to unwind after errors during
3063 If there is no most recently configured version
3064 <prgn>dpkg</prgn> will pass a null argument; older versions
3065 of dpkg may pass <tt><unknown></tt> (including the
3066 angle brackets) in this case. Even older ones do not pass a
3067 second argument at all, under any circumstances.
3071 <sect id="removedetails"><heading>Details of removal and/or
3072 configuration purging</heading>
3078 <example compact="compact">
3079 <var>prerm</var> remove
3085 The package's files are removed (except <tt>conffile</tt>s).
3090 <example compact="compact">
3091 <var>postrm</var> remove
3097 All the maintainer scripts except the <prgn>postrm</prgn>
3102 If we aren't purging the package we stop here. Note
3103 that packages which have no <prgn>postrm</prgn> and no
3104 <tt>conffile</tt>s are automatically purged when
3105 removed, as there is no difference except for the
3106 <prgn>dpkg</prgn> status.</p>
3110 The <tt>conffile</tt>s and any backup files
3111 (<tt>~</tt>-files, <tt>#*#</tt> files,
3112 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3117 <example compact="compact">
3118 <var>postrm</var> purge
3123 <p>The package's file list is removed.</p>
3126 No attempt is made to unwind after errors during
3133 <chapt id="relationships"><heading>Declaring relationships between
3136 <sect id="depsyntax"><heading>Syntax of relationship fields
3140 These fields all have a uniform syntax. They are a list of
3141 package names separated by commas.
3145 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3146 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3147 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3148 control file fields of the package, which declare
3149 dependencies on other packages, the package names listed may
3150 also include lists of alternative package names, separated
3151 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3152 if any one of the alternative packages is installed, that
3153 part of the dependency is considered to be satisfied.
3157 All of the fields except for <tt>Provides</tt> may restrict
3158 their applicability to particular versions of each named
3159 package. This is done in parentheses after each individual
3160 package name; the parentheses should contain a relation from
3161 the list below followed by a version number, in the format
3162 described in <ref id="versions">.
3166 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3167 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3168 strictly earlier, earlier or equal, exactly equal, later or
3169 equal and strictly later, respectively. The deprecated
3170 forms <tt><</tt> and <tt>></tt> were used to mean
3171 earlier/later or equal, rather than strictly earlier/later,
3172 so they should not appear in new packages (though
3173 <prgn>dpkg</prgn> still supports them).
3177 Whitespace may appear at any point in the version
3178 specification subject to the rules in <ref
3179 id="controlsyntax">, and must appear where it's necessary to
3180 disambiguate; it is not otherwise significant. For
3181 consistency and in case of future changes to
3182 <prgn>dpkg</prgn> it is recommended that a single space be
3183 used after a version relationship and before a version
3184 number; it is also conventional to put a single space after
3185 each comma, on either side of each vertical bar, and before
3186 each open parenthesis.
3190 For example, a list of dependencies might appear as:
3191 <example compact="compact">
3194 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3199 All fields that specify build-time relationships
3200 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3201 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3202 may be restricted to a certain set of architectures. This
3203 is indicated in brackets after each individual package name and
3204 the optional version specification. The brackets enclose a
3205 list of Debian architecture names separated by whitespace.
3206 Exclamation marks may be prepended to each of the names.
3207 (It is not permitted for some names to be prepended with
3208 exclamation marks and others not.) If the current Debian
3209 host architecture is not in this list and there are no
3210 exclamation marks in the list, or it is in the list with a
3211 prepended exclamation mark, the package name and the
3212 associated version specification are ignored completely for
3213 the purposes of defining the relationships.
3218 <example compact="compact">
3220 Build-Depends-Indep: texinfo
3221 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3222 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3227 Note that the binary package relationship fields such as
3228 <tt>Depends</tt> appear in one of the binary package
3229 sections of the control file, whereas the build-time
3230 relationships such as <tt>Build-Depends</tt> appear in the
3231 source package section of the control file (which is the
3237 <heading>Binary Dependencies - <tt>Depends</tt>,
3238 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3239 <tt>Pre-Depends</tt>
3243 Packages can declare in their control file that they have
3244 certain relationships to other packages - for example, that
3245 they may not be installed at the same time as certain other
3246 packages, and/or that they depend on the presence of others.
3250 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3251 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt> and
3252 <tt>Conflicts</tt> control file fields.
3256 These six fields are used to declare a dependency
3257 relationship by one package on another. Except for
3258 <tt>Enhances</tt>, they appear in the depending (binary)
3259 package's control file. (<tt>Enhances</tt> appears in the
3260 recommending package's control file.)
3264 A <tt>Depends</tt> field takes effect <em>only</em> when a
3265 package is to be configured. It does not prevent a package
3266 being on the system in an unconfigured state while its
3267 dependencies are unsatisfied, and it is possible to replace
3268 a package whose dependencies are satisfied and which is
3269 properly installed with a different version whose
3270 dependencies are not and cannot be satisfied; when this is
3271 done the depending package will be left unconfigured (since
3272 attempts to configure it will give errors) and will not
3273 function properly. If it is necessary, a
3274 <tt>Pre-Depends</tt> field can be used, which has a partial
3275 effect even when a package is being unpacked, as explained
3276 in detail below. (The other three dependency fields,
3277 <tt>Recommends</tt>, <tt>Suggests</tt> and
3278 <tt>Enhances</tt>, are only used by the various front-ends
3279 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3283 For this reason packages in an installation run are usually
3284 all unpacked first and all configured later; this gives
3285 later versions of packages with dependencies on later
3286 versions of other packages the opportunity to have their
3287 dependencies satisfied.
3291 The <tt>Depends</tt> field thus allows package maintainers
3292 to impose an order in which packages should be configured.
3296 The meaning of the five dependency fields is as follows:
3298 <tag><tt>Depends</tt></tag>
3301 This declares an absolute dependency. A package will
3302 not be configured unless all of the packages listed in
3303 its <tt>Depends</tt> field have been correctly
3308 The <tt>Depends</tt> field should be used if the
3309 depended-on package is required for the depending
3310 package to provide a significant amount of
3314 The <tt>Depends</tt> field should also be used if the
3315 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3316 <prgn>postrm</prgn> scripts require the package to be
3317 present in order to run. Note, however, that the
3318 <prgn>postrm</prgn> cannot rely on any non-essential
3319 packages to be present during the <tt>purge</tt>
3323 <tag><tt>Recommends</tt></tag>
3325 <p>This declares a strong, but not absolute, dependency.
3329 The <tt>Recommends</tt> field should list packages
3330 that would be found together with this one in all but
3331 unusual installations.</p>
3334 <tag><tt>Suggests</tt></tag>
3337 This is used to declare that one package may be more
3338 useful with one or more others. Using this field
3339 tells the packaging system and the user that the
3340 listed packages are related to this one and can
3341 perhaps enhance its usefulness, but that installing
3342 this one without them is perfectly reasonable.
3346 <tag><tt>Enhances</tt></tag>
3349 This field is similar to Suggests but works in the
3350 opposite direction. It is used to declare that a
3351 package can enhance the functionality of another
3356 <tag><tt>Pre-Depends</tt></tag>
3359 This field is like <tt>Depends</tt>, except that it
3360 also forces <prgn>dpkg</prgn> to complete installation
3361 of the packages named before even starting the
3362 installation of the package which declares the
3363 pre-dependency, as follows:
3367 When a package declaring a pre-dependency is about to
3368 be <em>unpacked</em> the pre-dependency can be
3369 satisfied if the depended-on package is either fully
3370 configured, <em>or even if</em> the depended-on
3371 package(s) are only unpacked or half-configured,
3372 provided that they have been configured correctly at
3373 some point in the past (and not removed or partially
3374 removed since). In this case, both the
3375 previously-configured and currently unpacked or
3376 half-configured versions must satisfy any version
3377 clause in the <tt>Pre-Depends</tt> field.
3381 When the package declaring a pre-dependency is about
3382 to be <em>configured</em>, the pre-dependency will be
3383 treated as a normal <tt>Depends</tt>, that is, it will
3384 be considered satisfied only if the depended-on
3385 package has been correctly configured.
3389 <tt>Pre-Depends</tt> should be used sparingly,
3390 preferably only by packages whose premature upgrade or
3391 installation would hamper the ability of the system to
3392 continue with any upgrade that might be in progress.
3396 <tt>Pre-Depends</tt> are also required if the
3397 <prgn>preinst</prgn> script depends on the named
3398 package. It is best to avoid this situation if
3404 When selecting which level of dependency to use you should
3405 consider how important the depended-on package is to the
3406 functionality of the one declaring the dependency. Some
3407 packages are composed of components of varying degrees of
3408 importance. Such a package should list using
3409 <tt>Depends</tt> the package(s) which are required by the
3410 more important components. The other components'
3411 requirements may be mentioned as Suggestions or
3412 Recommendations, as appropriate to the components' relative
3417 <sect id="conflicts"><heading>Conflicting binary packages -
3418 <tt>Conflicts</tt></heading>
3421 When one binary package declares a conflict with another
3422 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3423 refuse to allow them to be installed on the system at the
3428 If one package is to be installed, the other must be removed
3429 first - if the package being installed is marked as
3430 replacing (see <ref id="replaces">) the one on the system,
3431 or the one on the system is marked as deselected, or both
3432 packages are marked <tt>Essential</tt>, then
3433 <prgn>dpkg</prgn> will automatically remove the package
3434 which is causing the conflict, otherwise it will halt the
3435 installation of the new package with an error. This
3436 mechanism is specifically designed to produce an error when
3437 the installed package is <tt>Essential</tt>, but the new
3442 A package will not cause a conflict merely because its
3443 configuration files are still installed; it must be at least
3448 A special exception is made for packages which declare a
3449 conflict with their own package name, or with a virtual
3450 package which they provide (see below): this does not
3451 prevent their installation, and allows a package to conflict
3452 with others providing a replacement for it. You use this
3453 feature when you want the package in question to be the only
3454 package providing some feature.
3458 A <tt>Conflicts</tt> entry should almost never have an
3459 "earlier than" version clause. This would prevent
3460 <prgn>dpkg</prgn> from upgrading or installing the package
3461 which declared such a conflict until the upgrade or removal
3462 of the conflicted-with package had been completed.
3466 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3470 As well as the names of actual ("concrete") packages, the
3471 package relationship fields <tt>Depends</tt>,
3472 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3473 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3474 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3475 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3476 may mention "virtual packages".
3480 A <em>virtual package</em> is one which appears in the
3481 <tt>Provides</tt> control file field of another package.
3482 The effect is as if the package(s) which provide a
3483 particular virtual package name had been listed by name
3484 everywhere the virtual package name appears. (See also <ref
3489 If there are both concrete and virtual packages of the same
3490 name, then the dependency may be satisfied (or the conflict
3491 caused) by either the concrete package with the name in
3492 question or any other concrete package which provides the
3493 virtual package with the name in question. This is so that,
3494 for example, supposing we have
3495 <example compact="compact">
3499 and someone else releases an enhanced version of the
3500 <tt>bar</tt> package (for example, a non-US variant), they
3502 <example compact="compact">
3506 and the <tt>bar-plus</tt> package will now also satisfy the
3507 dependency for the <tt>foo</tt> package.
3511 If a dependency or a conflict has a version number attached
3512 then only real packages will be considered to see whether
3513 the relationship is satisfied (or the prohibition violated,
3514 for a conflict) - it is assumed that a real package which
3515 provides the virtual package is not of the "right" version.
3516 So, a <tt>Provides</tt> field may not contain version
3517 numbers, and the version number of the concrete package
3518 which provides a particular virtual package will not be
3519 looked at when considering a dependency on or conflict with
3520 the virtual package name.
3524 It is likely that the ability will be added in a future
3525 release of <prgn>dpkg</prgn> to specify a version number for
3526 each virtual package it provides. This feature is not yet
3527 present, however, and is expected to be used only
3532 If you want to specify which of a set of real packages
3533 should be the default to satisfy a particular dependency on
3534 a virtual package, you should list the real package as an
3535 alternative before the virtual one.
3540 <sect id="replaces"><heading>Overwriting files and replacing
3541 packages - <tt>Replaces</tt></heading>
3544 Packages can declare in their control file that they should
3545 overwrite files in certain other packages, or completely
3546 replace other packages. The <tt>Replaces</tt> control file
3547 field has these two distinct purposes.
3550 <sect1><heading>Overwriting files in other packages</heading>
3553 Firstly, as mentioned before, it is usually an error for a
3554 package to contain files which are on the system in
3559 However, if the overwriting package declares that it
3560 <tt>Replaces</tt> the one containing the file being
3561 overwritten, then <prgn>dpkg</prgn> will replace the file
3562 from the old package with that from the new. The file
3563 will no longer be listed as "owned" by the old package.
3567 If a package is completely replaced in this way, so that
3568 <prgn>dpkg</prgn> does not know of any files it still
3569 contains, it is considered to have "disappeared". It will
3570 be marked as not wanted on the system (selected for
3571 removal) and not installed. Any <tt>conffile</tt>s
3572 details noted for the package will be ignored, as they
3573 will have been taken over by the overwriting package. The
3574 package's <prgn>postrm</prgn> script will be run with a
3575 special argument to allow the package to do any final
3576 cleanup required. See <ref id="mscriptsinstact">.
3580 If an installed package, <tt>foo</tt> say, declares that
3581 it replaces another, <tt>bar</tt>, and an attempt is made
3582 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3583 files in the <tt>bar</tt> package which would overwrite
3584 those already present in <tt>foo</tt>. This is so that
3585 you can install an older version of a package without
3590 For this usage of <tt>Replaces</tt>, virtual packages (see
3591 <ref id="virtual">) are not considered when looking at a
3592 <tt>Replaces</tt> field - the packages declared as being
3593 replaced must be mentioned by their real names.
3597 Furthermore, this usage of <tt>Replaces</tt> only takes
3598 effect when both packages are at least partially on the
3599 system at once, so that it can only happen if they do not
3600 conflict or if the conflict has been overridden.
3605 <sect1><heading>Replacing whole packages, forcing their
3609 Secondly, <tt>Replaces</tt> allows the packaging system to
3610 resolve which package should be removed when there is a
3611 conflict - see <ref id="conflicts">. This usage only
3612 takes effect when the two packages <em>do</em> conflict,
3613 so that the two usages of this field do not interfere with
3618 In this situation, the package declared as being replaced
3619 can be a virtual package, so for example, all mail
3620 transport agents (MTAs) would have the following fields in
3621 their control files:
3622 <example compact="compact">
3623 Provides: mail-transport-agent
3624 Conflicts: mail-transport-agent
3625 Replaces: mail-transport-agent
3627 ensuring that only one MTA can be installed at any one
3632 <sect><heading>Relationships between source and binary packages -
3633 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3634 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3638 Source packages that require certain binary packages to be
3639 installed or absent at the time of building the package
3640 can declare relationships to those binary packages.
3644 This is done using the <tt>Build-Depends</tt>,
3645 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3646 <tt>Build-Conflicts-Indep</tt> control file fields.
3650 Build-dependencies on "build-essential" binary packages can be
3651 omitted. Please see <ref id="pkg-relations"> for more information.
3655 The dependencies and conflicts they define must be satisfied
3656 (as defined earlier for binary packages) in order to invoke
3657 the targets in <tt>debian/rules</tt>, as follows:<footnote>
3659 If you make "build-arch" or "binary-arch", you need
3660 Build-Depends. If you make "build-indep" or
3661 "binary-indep", you need Build-Depends and
3662 Build-Depends-Indep. If you make "build" or "binary",
3666 There is no Build-Depends-Arch; the autobuilders will
3667 only need the Build-Depends if they know how to build
3668 only build-arch and binary-arch. Anyone building the
3669 build-indep/binary-indep targets is basically assumed to
3670 be building the whole package and so installs all build
3674 The purpose of the original split, I recall, was so that
3675 the autobuilders wouldn't need to install extra packages
3676 needed only for the binary-indep targets. But without a
3677 build-arch/build-indep split, this didn't work, since
3678 most of the work is done in the build target, not in the
3684 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3687 The <tt>Build-Depends</tt> and
3688 <tt>Build-Conflicts</tt> fields must be satisfied when
3689 any of the following targets is invoked:
3690 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
3691 <tt>binary-arch</tt>, <tt>build-arch</tt>,
3692 <tt>build-indep</tt> and <tt>binary-indep</tt>.
3695 <tag><tt>Build-Depends-Indep</tt>,
3696 <tt>Build-Conflicts-Indep</tt></tag>
3699 The <tt>Build-Depends-Indep</tt> and
3700 <tt>Build-Conflicts-Indep</tt> fields must be
3701 satisfied when any of the following targets is
3702 invoked: <tt>build</tt>, <tt>clean</tt>,
3703 <tt>build-indep</tt>, <tt>binary</tt> and
3704 <tt>binary-indep</tt>.
3715 <chapt id="conffiles"><heading>Configuration file handling
3719 This chapter has been superseded by <ref id="config-files">.
3723 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3726 Packages containing shared libraries must be constructed with
3727 a little care to make sure that the shared library is always
3728 available. This is especially important for packages whose
3729 shared libraries are vitally important, such as the C library
3730 (currently <tt>libc6</tt>).
3734 Packages involving shared libraries should be split up into
3735 several binary packages. This section mostly deals with how
3736 this separation is to be accomplished; rules for files within
3737 the shared library packages are in <ref id="libraries"> instead.
3740 <sect id="sharedlibs-runtime">
3741 <heading>Run-time shared libraries</heading>
3744 The run-time shared library needs to be placed in a package called
3745 <package><var>libraryname</var><var>soversion</var></package>, where
3746 <file><var>soversion</var></file> is the version number in the
3747 soname of the shared library<footnote>
3749 The soname is the shared object name: it's the thing
3750 that has to match exactly between building an executable
3751 and running it for the dynamic linker to be able run the
3752 program. For example, if the soname of the library is
3753 <file>libfoo.so.6</file>, the library package would be
3754 called <file>libfoo6</file>.
3757 Alternatively, if it would be confusing to directly append
3758 <var>soversion</var> to <var>libraryname</var> (e.g. because
3759 <var>libraryname</var> itself ends in a number), you may use
3760 <package><var>libraryname</var>-<var>soversion</var></package> and
3761 <package><var>libraryname</var>-<var>soversion</var>-dev</package>
3766 If you have several shared libraries built from the same
3767 source tree you may lump them all together into a single
3768 shared library package, provided that you change all of
3769 their sonames at once (so that you don't get filename
3770 clashes if you try to install different versions of the
3771 combined shared libraries package).
3775 The package should install the shared libraries under
3776 their normal names. For example, the <package>libgdbmg1</package>
3777 package should install <file>libgdbm.so.1.7.3</file> as
3778 <file>/usr/lib/libgdbm.so.1.7.3</file>. The files should not be
3779 renamed or re-linked by any <prgn>prerm</prgn> or
3780 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3781 of renaming things safely without affecting running programs,
3782 and attempts to interfere with this are likely to lead to
3787 Shared libraries should not be installed executable, since
3788 the dynamic linker does not require this and trying to
3789 execute a shared library usually results in a core dump.
3793 The run-time library package should include the symbolic link that
3794 <prgn>ldconfig</prgn> would create for the shared libraries.
3795 For example, the <package>libgdbmg1</package> package should include
3796 a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3797 <file>libgdbm.so.1.7.3</file>. This is needed so that the dynamic
3798 linker (for example <prgn>ld.so</prgn> or
3799 <prgn>ld-linux.so.*</prgn>) can find the library between the
3800 time that <prgn>dpkg</prgn> installs it and the time that
3801 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3804 The package management system requires the library to be
3805 placed before the symbolic link pointing to it in the
3806 <file>.deb</file> file. This is so that when
3807 <prgn>dpkg</prgn> comes to install the symlink
3808 (overwriting the previous symlink pointing at an older
3809 version of the library), the new shared library is already
3810 in place. In the past, this was achieved by creating the
3811 library in the temporary packaging directory before
3812 creating the symlink. Unfortunately, this was not always
3813 effective, since the building of the tar file in the
3814 <file>.deb</file> depended on the behavior of the underlying
3815 file system. Some file systems (such as reiserfs) reorder
3816 the files so that the order of creation is forgotten.
3817 Since version 1.7.0, <prgn>dpkg</prgn>
3818 reorders the files itself as necessary when building a
3819 package. Thus it is no longer important to concern
3820 oneself with the order of file creation.
3825 <sect1 id="ldconfig">
3826 <heading><tt>ldconfig</tt></heading>
3829 Any package installing shared libraries in one of the default
3830 library directories of the dynamic linker (which are currently
3831 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3832 listed in <file>/etc/ld.so.conf</file><footnote>
3835 <list compact="compact">
3836 <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3837 <item><p>/usr/local/lib</p></item>
3838 <item><p>/usr/lib/libc5-compat</p></item>
3839 <item><p>/lib/libc5-compat</p></item>
3840 <item><p>/usr/X11R6/lib</p></item>
3844 must use <prgn>ldconfig</prgn> to update the shared library
3849 The package must call <prgn>ldconfig</prgn> in the
3850 <prgn>postinst</prgn> script if the first argument is
3851 <tt>configure</tt>; the <prgn>postinst</prgn> script may
3852 optionally invoke <prgn>ldconfig</prgn> at other times. The
3853 package should call <prgn>ldconfig</prgn> in the
3854 <prgn>postrm</prgn> script if the first argument is
3855 <tt>remove</tt>. The maintainer scripts must not invoke
3856 <prgn>ldconfig</prgn> under any circumstances other than those
3857 described in this paragraph.<footnote>
3858 <p>During install or upgrade, the preinst is called before
3859 the new files are installed, so calling "ldconfig" is
3860 pointless. The preinst of an existing package can also be
3861 called if an upgrade fails. However, this happens during
3862 the critical time when a shared libs may exist on-disk
3863 under a temporary name. Thus, it is dangerous and
3864 forbidden by current policy to call "ldconfig" at this
3867 <p>When a package is installed or upgraded, "postinst
3868 configure" runs after the new files are safely on-disk.
3869 Since it is perfectly safe to invoke ldconfig
3870 unconditionally in a postinst, it is OK for a package to
3871 simply put ldconfig in its postinst without checking the
3872 argument. The postinst can also be called to recover from
3873 a failed upgrade. This happens before any new files are
3874 unpacked, so there is no reason to call "ldconfig" at this
3877 <p>For a package that is being removed, prerm is
3878 called with all the files intact, so calling ldconfig is
3879 useless. The other calls to "prerm" happen in the case of
3880 upgrade at a time when all the files of the old package
3881 are on-disk, so again calling "ldconfig" is pointless.
3883 <p>postrm, on the other hand, is called with the "remove"
3884 argument just after the files are removed, so this is the
3885 proper time to call "ldconfig" to notify the system of the
3886 fact shared libraries from the package are removed.
3887 The postrm can be called at several other times. At the
3888 time of "postrm purge", "postrm abort-install", or "postrm
3889 abort-upgrade", calling "ldconfig" is useless because the
3890 shared lib files are not on-disk. However, when "postrm"
3891 is invoked with arguments "upgrade", "failed-upgrade", or
3892 "disappear", a shared lib may exist on-disk under a
3901 <sect id="sharedlibs-runtime-progs">
3902 <heading>Run-time support programs</heading>
3905 If your package has some run-time support programs which use
3906 the shared library you must not put them in the shared
3907 library package. If you do that then you won't be able to
3908 install several versions of the shared library without
3909 getting filename clashes.
3913 Instead, either create another package for the runtime binaries
3914 (this package might typically be named
3915 <package><var>libraryname</var>-runtime</package>; note the absence
3916 of the <var>soversion</var> in the package name), or if the
3917 development package is small, include them in there.
3921 <sect id="sharedlibs-static">
3922 <heading>Static libraries</heading>
3925 The static library (<file><var>libraryname.a</var></file>)
3926 is usually provided in addition to the shared version.
3927 It is placed into the development package (see below).
3931 In some cases, it is acceptable for a library to be
3932 available in static form only; these cases include:
3934 <item>libraries for languages whose shared library support
3935 is immature or unstable</item>
3936 <item>libraries whose interfaces are in flux or under
3937 development (commonly the case when the library's
3938 major version number is zero, or where the ABI breaks
3939 across patchlevels)</item>
3940 <item>libraries which are explicitly intended to be
3941 available only in static form by their upstream
3946 <sect id="sharedlibs-dev">
3947 <heading>Development files</heading>
3950 The development files associated to a shared library need to be
3951 placed in a package called
3952 <package><var>libraryname</var><var>soversion</var>-dev</package>,
3953 or if you prefer only to support one development version at a
3954 time, <package><var>libraryname</var>-dev</package>.
3958 In case several development versions of a library exist, you may
3959 need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
3960 <ref id="conflicts">) to ensure that the user only installs one
3961 development version at a time (as different development versions are
3962 likely to have the same header files in them, which would cause a
3963 filename clash if both were installed).
3967 The development package should contain a symlink for the associated
3968 shared library without a version number. For example, the
3969 <package>libgdbmg1-dev</package> package should include a symlink
3970 from <file>/usr/lib/libgdbm.so</file> to
3971 <file>libgdbm.so.1.7.3</file>. This symlink is needed by the linker
3972 (<prgn>ld</prgn>) when compiling packages, as it will only look for
3973 <file>libgdbm.so</file> when compiling dynamically.
3977 <sect id="sharedlibs-intradeps">
3978 <heading>Dependencies between the packages of the same library</heading>
3981 Typically the development version should have an exact
3982 version dependency on the runtime library, to make sure that
3983 compilation and linking happens correctly. The
3984 <tt>${Source-Version}</tt> substitution variable can be
3985 useful for this purpose.
3989 <sect id="sharedlibs-shlibdeps">
3990 <heading>Dependencies between the library and other packages -
3991 the <tt>shlibs</tt> system</heading>
3994 If a package contains a binary or library which links to a
3995 shared library, we must ensure that when the package is
3996 installed on the system, all of the libraries needed are
3997 also installed. This requirement led to the creation of the
3998 <tt>shlibs</tt> system, which is very simple in its design:
3999 any package which <em>provides</em> a shared library also
4000 provides information on the package dependencies required to
4001 ensure the presence of this library, and any package which
4002 <em>uses</em> a shared library uses this information to
4003 determine the dependencies it requires. The files which
4004 contain the mapping from shared libraries to the necessary
4005 dependency information are called <file>shlibs</file> files.
4009 Thus, when a package is built which contains any shared
4010 libraries, it must provide a <file>shlibs</file> file for other
4011 packages to use, and when a package is built which contains
4012 any shared libraries or compiled binaries, it must run
4013 <prgn>dpkg-shlibdeps</prgn> on these to determine the
4014 libraries used and hence the dependencies needed by this
4017 In the past, the shared libraries linked to were
4018 determined by calling <prgn>ldd</prgn>, but now
4019 <prgn>objdump</prgn> is used to do this. The only
4020 change this makes to package building is that
4021 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
4022 libraries, whereas in the past this was unnecessary.
4023 The rest of this footnote explains the advantage that
4028 We say that a binary <tt>foo</tt> <em>directly</em> uses
4029 a library <tt>libbar</tt> if it is explicitly linked
4030 with that library (that is, it uses the flag
4031 <tt>-lbar</tt> during the linking stage). Other
4032 libraries that are needed by <tt>libbar</tt> are linked
4033 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
4034 linker will load them automatically when it loads
4035 <tt>libbar</tt>. A package should depend on
4036 the libraries it directly uses, and the dependencies for
4037 those libraries should automatically pull in the other
4042 Unfortunately, the <prgn>ldd</prgn> program shows both
4043 the directly and indirectly used libraries, meaning that
4044 the dependencies determined included both direct and
4045 indirect dependencies. The use of <prgn>objdump</prgn>
4046 avoids this problem by determining only the directly
4051 A good example of where this helps is the following. We
4052 could update <tt>libimlib</tt> with a new version that
4053 supports a new graphics format called dgf (but retaining
4054 the same major version number). If we used the old
4055 <prgn>ldd</prgn> method, every package that uses
4056 <tt>libimlib</tt> would need to be recompiled so it
4057 would also depend on <tt>libdgf</tt> or it wouldn't run
4058 due to missing symbols. However with the new system,
4059 packages using <tt>libimlib</tt> can rely on
4060 <tt>libimlib</tt> itself having the dependency on
4061 <tt>libdgf</tt> and so they would not need rebuilding.
4067 In the following sections, we will first describe where the
4068 various <tt>shlibs</tt> files are to be found, then how to
4069 use <prgn>dpkg-shlibdeps</prgn>, and finally the
4070 <tt>shlibs</tt> file format and how to create them if your
4071 package contains a shared library.
4075 <heading>The <tt>shlibs</tt> files present on the system</heading>
4078 There are several places where <tt>shlibs</tt> files are
4079 found. The following list gives them in the order in which
4080 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
4081 one which gives the required information is used.)
4087 <p><file>debian/shlibs.local</file></p>
4089 This lists overrides for this package. Its use is
4090 described below (see <ref id="shlibslocal">).
4095 <p><file>/etc/dpkg/shlibs.override</file></p>
4097 This lists global overrides. This list is normally
4098 empty. It is maintained by the local system
4104 <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
4106 When packages are being built, any
4107 <file>debian/shlibs</file> files are copied into the
4108 control file area of the temporary build directory and
4109 given the name <file>shlibs</file>. These files give
4110 details of any shared libraries included in the
4113 An example may help here. Let us say that the
4114 source package <tt>foo</tt> generates two binary
4115 packages, <tt>libfoo2</tt> and
4116 <tt>foo-runtime</tt>. When building the binary
4117 packages, the two packages are created in the
4118 directories <file>debian/libfoo2</file> and
4119 <file>debian/foo-runtime</file> respectively.
4120 (<file>debian/tmp</file> could be used instead of one
4121 of these.) Since <tt>libfoo2</tt> provides the
4122 <tt>libfoo</tt> shared library, it will require a
4123 <tt>shlibs</tt> file, which will be installed in
4124 <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
4126 <file>/var/lib/dpkg/info/libfoo2.shlibs</file>. Then
4127 when <prgn>dpkg-shlibdeps</prgn> is run on the
4129 <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
4131 <file>debian/libfoo2/DEBIAN/shlibs</file> file to
4132 determine whether <tt>foo-prog</tt>'s library
4133 dependencies are satisfied by any of the libraries
4134 provided by <tt>libfoo2</tt>. For this reason,
4135 <prgn>dpkg-shlibdeps</prgn> must only be run once
4136 all of the individual binary packages'
4137 <tt>shlibs</tt> files have been installed into the
4145 <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
4147 These are the <file>shlibs</file> files corresponding to
4148 all of the packages installed on the system, and are
4149 maintained by the relevant package maintainers.
4154 <p><file>/etc/dpkg/shlibs.default</file></p>
4156 This file lists any shared libraries whose packages
4157 have failed to provide correct <file>shlibs</file> files.
4158 It was used when the <file>shlibs</file> setup was first
4159 introduced, but it is now normally empty. It is
4160 maintained by the <tt>dpkg</tt> maintainer.
4168 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4169 <file>shlibs</file> files</heading>
4172 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4173 <file>debian/rules</file> file. If your package contains only
4174 compiled binaries and libraries (but no scripts), you can
4175 use a command such as:
4176 <example compact="compact">
4177 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4178 debian/tmp/usr/lib/*
4180 Otherwise, you will need to explicitly list the compiled
4181 binaries and libraries.<footnote>
4183 If you are using <tt>debhelper</tt>, the
4184 <prgn>dh_shlibdeps</prgn> program will do this work for
4185 you. It will also correctly handle multi-binary
4192 This command puts the dependency information into the
4193 <file>debian/substvars</file> file, which is then used by
4194 <prgn>dpkg-gencontrol</prgn>. You will need to place a
4195 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4196 field in the control file for this to work.
4200 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4201 done. If it does complain you might need to create your own
4202 <file>debian/shlibs.local</file> file, as explained below (see
4203 <ref id="shlibslocal">).
4207 If you have multiple binary packages, you will need to call
4208 <prgn>dpkg-shlibdeps</prgn> on each one which contains
4209 compiled libraries or binaries. In such a case, you will
4210 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4211 utilities to specify a different <file>substvars</file> file.
4212 For more details on this and other options, see <manref
4213 name="dpkg-shlibdeps" section="1">.
4218 <heading>The <file>shlibs</file> File Format</heading>
4221 Each <file>shlibs</file> file has the same format. Lines
4222 beginning with <tt>#</tt> are considered to be comments and
4223 are ignored. Each line is of the form:
4224 <example compact="compact">
4225 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4230 We will explain this by reference to the example of the
4231 <tt>zlib1g</tt> package, which (at the time of writing)
4232 installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4236 <var>library-name</var> is the name of the shared library,
4237 in this case <tt>libz</tt>. (This must match the name part
4238 of the soname, see below.)
4242 <var>soname-version-number</var> is the version part of the
4243 soname of the library. The soname is the thing that must
4244 exactly match for the library to be recognized by the
4245 dynamic linker, and is usually of the form
4246 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4247 example, <tt>libz.so.1</tt>.<footnote>
4249 This can be determined using the command
4250 <example compact="compact">
4251 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4255 The version part is the part which comes after
4256 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4260 <var>dependencies</var> has the same syntax as a dependency
4261 field in a binary package control file. It should give
4262 details of which packages are required to satisfy a binary
4263 built against the version of the library contained in the
4264 package. See <ref id="depsyntax"> for details.
4268 In our example, if the first version of the <tt>zlib1g</tt>
4269 package which contained a minor number of at least
4270 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4271 <tt>shlibs</tt> entry for this library could say:
4272 <example compact="compact">
4273 libz 1 zlib1g (>= 1:1.1.3)
4275 The version-specific dependency is to avoid warnings from
4276 the dynamic linker about using older shared libraries with
4282 <heading>Providing a <file>shlibs</file> file</heading>
4285 If your package provides a shared library, you should create
4286 a <file>shlibs</file> file following the format described above.
4287 It is usual to call this file <file>debian/shlibs</file> (but if
4288 you have multiple binary packages, you might want to call it
4289 <file>debian/shlibs.<var>package</var></file> instead). Then
4290 let <file>debian/rules</file> install it in the control area:
4291 <example compact="compact">
4292 install -m644 debian/shlibs debian/tmp/DEBIAN
4294 or, in the case of a multi-binary package:
4295 <example compact="compact">
4296 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4298 An alternative way of doing this is to create the
4299 <file>shlibs</file> file in the control area directly from
4300 <file>debian/rules</file> without using a <file>debian/shlibs</file>
4301 file at all,<footnote>
4303 This is what <prgn>dh_makeshlibs</prgn> in the
4304 <tt>debhelper</tt> suite does.
4307 since the <file>debian/shlibs</file> file itself is ignored by
4308 <prgn>dpkg-shlibdeps</prgn>.
4312 As <prgn>dpkg-shlibdeps</prgn> reads the
4313 <file>DEBIAN/shlibs</file> files in all of the binary packages
4314 being built from this source package, all of the
4315 <file>DEBIAN/shlibs</file> files should be installed before
4316 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4321 <sect1 id="shlibslocal">
4322 <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4325 This file is intended only as a <em>temporary</em> fix if
4326 your binaries or libraries depend on a library whose package
4327 does not yet provide a correct <file>shlibs</file> file.
4331 We will assume that you are trying to package a binary
4332 <tt>foo</tt>. When you try running
4333 <prgn>dpkg-shlibdeps</prgn> you get the following error
4334 message (<tt>-O</tt> displays the dependency information on
4335 <tt>stdout</tt> instead of writing it to
4336 <tt>debian/substvars</tt>, and the lines have been wrapped
4337 for ease of reading):
4338 <example compact="compact">
4339 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4340 dpkg-shlibdeps: warning: unable to find dependency
4341 information for shared library libbar (soname 1,
4342 path /usr/lib/libbar.so.1, dependency field Depends)
4343 shlibs:Depends=libc6 (>= 2.2.2-2)
4345 You can then run <prgn>ldd</prgn> on the binary to find the
4346 full location of the library concerned:
4347 <example compact="compact">
4349 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4350 libc.so.6 => /lib/libc.so.6 (0x40032000)
4351 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4353 So the <prgn>foo</prgn> binary depends on the
4354 <prgn>libbar</prgn> shared library, but no package seems to
4355 provide a <file>*.shlibs</file> file handling
4356 <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>. Let's
4357 determine the package responsible:
4358 <example compact="compact">
4359 $ dpkg -S /usr/lib/libbar.so.1
4360 bar1: /usr/lib/libbar.so.1
4361 $ dpkg -s bar1 | grep Version
4364 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4365 is the one we are using. Now we can file a bug against the
4366 <tt>bar1</tt> package and create our own
4367 <file>debian/shlibs.local</file> to locally fix the problem.
4368 Including the following line into your
4369 <file>debian/shlibs.local</file> file:
4370 <example compact="compact">
4371 libbar 1 bar1 (>= 1.0-1)
4373 should allow the package build to work.
4377 As soon as the maintainer of <tt>bar1</tt> provides a
4378 correct <file>shlibs</file> file, you should remove this line
4379 from your <file>debian/shlibs.local</file> file. (You should
4380 probably also then have a versioned <tt>Build-Depends</tt>
4381 on <tt>bar1</tt> to help ensure that others do not have the
4382 same problem building your package.)
4390 <chapt id="opersys"><heading>The Operating System</heading>
4393 <heading>Filesystem hierarchy</heading>
4397 <heading>Filesystem Structure</heading>
4400 The location of all installed files and directories must
4401 comply with the Filesystem Hierarchy Standard (FHS),
4402 version 2.1, except where doing so would violate other
4403 terms of Debian Policy. The version of this document
4404 referred here can be found in the <tt>debian-policy</tt>
4406 <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4407 name="FHS (Debian copy)"> alongside this manual (or, if
4408 you have the <package>debian-policy</package> installed,
4410 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4411 (local copy)">). The
4412 latest version, which may be a more recent version, may
4414 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4415 Specific questions about following the standard may be
4416 asked on the <tt>debian-devel</tt> mailing list, or
4417 referred to the FHS mailing list (see the
4418 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4424 <heading>Site-specific programs</heading>
4427 As mandated by the FHS, packages must not place any
4428 files in <file>/usr/local</file>, either by putting them in
4429 the file system archive to be unpacked by <prgn>dpkg</prgn>
4430 or by manipulating them in their maintainer scripts.
4434 However, the package may create empty directories below
4435 <file>/usr/local</file> so that the system administrator knows
4436 where to place site-specific files. These directories
4437 should be removed on package removal if they are
4442 Note, that this applies only to directories <em>below</em>
4443 <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4444 Packages must not create sub-directories in the directory
4445 <file>/usr/local</file> itself, except those listed in FHS,
4446 section 4.5. However, you may create directories below
4447 them as you wish. You must not remove any of the
4448 directories listed in 4.5, even if you created them.
4452 Since <file>/usr/local</file> can be mounted read-only from a
4453 remote server, these directories must be created and
4454 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4455 maintainer scripts and not be included in the
4456 <file>.deb</file> archive. These scripts must not fail if
4457 either of these operations fail.
4461 For example, the <tt>emacsen-common</tt> package could
4462 contain something like
4463 <example compact="compact">
4464 if [ ! -e /usr/local/share/emacs ]
4466 if mkdir /usr/local/share/emacs 2>/dev/null
4468 chown root:staff /usr/local/share/emacs
4469 chmod 2775 /usr/local/share/emacs
4473 in its <prgn>postinst</prgn> script, and
4474 <example compact="compact">
4475 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4476 rmdir /usr/local/share/emacs 2>/dev/null || true
4478 in the <prgn>prerm</prgn> script. (Note that this form is
4479 used to ensure that if the script is interrupted, the
4480 directory <file>/usr/local/share/emacs</file> will still be
4485 If you do create a directory in <file>/usr/local</file> for
4486 local additions to a package, you should ensure that
4487 settings in <file>/usr/local</file> take precedence over the
4488 equivalents in <file>/usr</file>.
4492 However, because <file>/usr/local</file> and its contents are
4493 for exclusive use of the local administrator, a package
4494 must not rely on the presence or absence of files or
4495 directories in <file>/usr/local</file> for normal operation.
4499 The <file>/usr/local</file> directory itself and all the
4500 subdirectories created by the package should (by default) have
4501 permissions 2775 (group-writable and set-group-id) and be
4502 owned by <tt>root.staff</tt>.
4507 <heading>The system-wide mail directory</heading>
4509 The system-wide mail directory is <file>/var/mail</file>. This
4510 directory is part of the base system and should not owned
4511 by any particular mail agents. The use of the old
4512 location <file>/var/spool/mail</file> is deprecated, even
4513 though the spool may still be physically located there.
4514 To maintain partial upgrade compatibility for systems
4515 which have <file>/var/spool/mail</file> as their physical mail
4516 spool, packages using <file>/var/mail</file> must depend on
4517 either <package>libc6</package> (>= 2.1.3-13), or on
4518 <package>base-files</package> (>= 2.2.0), or on later
4519 versions of either one of these packages.
4525 <heading>Users and groups</heading>
4528 <heading>Introduction</heading>
4530 The Debian system can be configured to use either plain or
4535 Some user ids (UIDs) and group ids (GIDs) are reserved
4536 globally for use by certain packages. Because some
4537 packages need to include files which are owned by these
4538 users or groups, or need the ids compiled into binaries,
4539 these ids must be used on any Debian system only for the
4540 purpose for which they are allocated. This is a serious
4541 restriction, and we should avoid getting in the way of
4542 local administration policies. In particular, many sites
4543 allocate users and/or local system groups starting at 100.
4547 Apart from this we should have dynamically allocated ids,
4548 which should by default be arranged in some sensible
4549 order, but the behavior should be configurable.
4553 Packages other than <tt>base-passwd</tt> must not modify
4554 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4555 <file>/etc/group</file> or <file>/etc/gshadow</file>.
4560 <heading>UID and GID classes</heading>
4562 The UID and GID numbers are divided into classes as
4568 Globally allocated by the Debian project, the same
4569 on every Debian system. These ids will appear in
4570 the <file>passwd</file> and <file>group</file> files of all
4571 Debian systems, new ids in this range being added
4572 automatically as the <tt>base-passwd</tt> package is
4577 Packages which need a single statically allocated
4578 uid or gid should use one of these; their
4579 maintainers should ask the <tt>base-passwd</tt>
4587 Dynamically allocated system users and groups.
4588 Packages which need a user or group, but can have
4589 this user or group allocated dynamically and
4590 differently on each system, should use <tt>adduser
4591 --system</tt> to create the group and/or user.
4592 <prgn>adduser</prgn> will check for the existence of
4593 the user or group, and if necessary choose an unused
4594 id based on the ranges specified in
4595 <file>adduser.conf</file>.
4599 <tag>1000-29999:</tag>
4602 Dynamically allocated user accounts. By default
4603 <prgn>adduser</prgn> will choose UIDs and GIDs for
4604 user accounts in this range, though
4605 <file>adduser.conf</file> may be used to modify this
4610 <tag>30000-59999:</tag>
4615 <tag>60000-64999:</tag>
4618 Globally allocated by the Debian project, but only
4619 created on demand. The ids are allocated centrally
4620 and statically, but the actual accounts are only
4621 created on users' systems on demand.
4625 These ids are for packages which are obscure or
4626 which require many statically-allocated ids. These
4627 packages should check for and create the accounts in
4628 <file>/etc/passwd</file> or <file>/etc/group</file> (using
4629 <prgn>adduser</prgn> if it has this facility) if
4630 necessary. Packages which are likely to require
4631 further allocations should have a "hole" left after
4632 them in the allocation, to give them room to
4637 <tag>65000-65533:</tag>
4645 User <tt>nobody</tt>. The corresponding gid refers
4646 to the group <tt>nogroup</tt>.
4653 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4654 not</em> be used, because it is the error return
4663 <sect id="sysvinit">
4664 <heading>System run levels and <file>init.d</file> scripts</heading>
4666 <sect1 id="/etc/init.d">
4667 <heading>Introduction</heading>
4670 The <file>/etc/init.d</file> directory contains the scripts
4671 executed by <prgn>init</prgn> at boot time and when the
4672 init state (or "runlevel") is changed (see <manref
4673 name="init" section="8">).
4677 There are at least two different, yet functionally
4678 equivalent, ways of handling these scripts. For the sake
4679 of simplicity, this document describes only the symbolic
4680 link method. However, it must not be assumed by maintainer
4681 scripts that this method is being used, and any automated
4682 manipulation of the various runlevel behaviours by
4683 maintainer scripts must be performed using
4684 <prgn>update-rc.d</prgn> as described below and not by
4685 manually installing or removing symlinks. For information
4686 on the implementation details of the other method,
4687 implemented in the <tt>file-rc</tt> package, please refer
4688 to the documentation of that package.
4692 These scripts are referenced by symbolic links in the
4693 <file>/etc/rc<var>n</var>.d</file> directories. When changing
4694 runlevels, <prgn>init</prgn> looks in the directory
4695 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4696 execute, where <tt><var>n</var></tt> is the runlevel that
4697 is being changed to, or <tt>S</tt> for the boot-up
4702 The names of the links all have the form
4703 <file>S<var>mm</var><var>script</var></file> or
4704 <file>K<var>mm</var><var>script</var></file> where
4705 <var>mm</var> is a two-digit number and <var>script</var>
4706 is the name of the script (this should be the same as the
4707 name of the actual script in <file>/etc/init.d</file>).
4711 When <prgn>init</prgn> changes runlevel first the targets
4712 of the links whose names start with a <tt>K</tt> are
4713 executed, each with the single argument <tt>stop</tt>,
4714 followed by the scripts prefixed with an <tt>S</tt>, each
4715 with the single argument <tt>start</tt>. (The links are
4716 those in the <file>/etc/rc<var>n</var>.d</file> directory
4717 corresponding to the new runlevel.) The <tt>K</tt> links
4718 are responsible for killing services and the <tt>S</tt>
4719 link for starting services upon entering the runlevel.
4723 For example, if we are changing from runlevel 2 to
4724 runlevel 3, init will first execute all of the <tt>K</tt>
4725 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4726 all of the <tt>S</tt> prefixed scripts in that directory.
4727 The links starting with <tt>K</tt> will cause the
4728 referred-to file to be executed with an argument of
4729 <tt>stop</tt>, and the <tt>S</tt> links with an argument
4734 The two-digit number <var>mm</var> is used to determine
4735 the order in which to run the scripts: low-numbered links
4736 have their scripts run first. For example, the
4737 <tt>K20</tt> scripts will be executed before the
4738 <tt>K30</tt> scripts. This is used when a certain service
4739 must be started before another. For example, the name
4740 server <prgn>bind</prgn> might need to be started before
4741 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4742 can set up its access lists. In this case, the script
4743 that starts <prgn>bind</prgn> would have a lower number
4744 than the script that starts <prgn>inn</prgn> so that it
4746 <example compact="compact">
4753 The two runlevels 0 (halt) and 6 (reboot) are slightly
4754 different. In these runlevels, the links with an
4755 <tt>S</tt> prefix are still called after those with a
4756 <tt>K</tt> prefix, but they too are called with the single
4757 argument <tt>stop</tt>.
4761 Also, if the script name ends <tt>.sh</tt>, the script
4762 will be sourced in runlevel <tt>S</tt> rather that being
4763 run in a forked subprocess, but will be explicitly run by
4764 <prgn>sh</prgn> in all other runlevels.
4769 <heading>Writing the scripts</heading>
4772 Packages that include daemons for system services should
4773 place scripts in <file>/etc/init.d</file> to start or stop
4774 services at boot time or during a change of runlevel.
4775 These scripts should be named
4776 <file>/etc/init.d/<var>package</var></file>, and they should
4777 accept one argument, saying what to do:
4780 <tag><tt>start</tt></tag>
4781 <item><p>start the service,</p></item>
4783 <tag><tt>stop</tt></tag>
4784 <item><p>stop the service,</p></item>
4786 <tag><tt>restart</tt></tag>
4787 <item><p>stop and restart the service if it's already
4788 running, otherwise start the service</p></item>
4790 <tag><tt>reload</tt></tag>
4791 <item><p>cause the configuration of the service to be
4792 reloaded without actually stopping and restarting
4793 the service,</p></item>
4795 <tag><tt>force-reload</tt></tag>
4796 <item><p>cause the configuration to be reloaded if the
4797 service supports this, otherwise restart the
4801 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4802 <tt>force-reload</tt> options should be supported by all
4803 scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4804 option is optional.</p>
4807 The <file>init.d</file> scripts should ensure that they will
4808 behave sensibly if invoked with <tt>start</tt> when the
4809 service is already running, or with <tt>stop</tt> when it
4810 isn't, and that they don't kill unfortunately-named user
4811 processes. The best way to achieve this is usually to use
4812 <prgn>start-stop-daemon</prgn>.</p>
4815 If a service reloads its configuration automatically (as
4816 in the case of <prgn>cron</prgn>, for example), the
4817 <tt>reload</tt> option of the <file>init.d</file> script
4818 should behave as if the configuration has been reloaded
4822 The <file>/etc/init.d</file> scripts must be treated as
4823 configuration files, either (if they are present in the
4824 package, that is, in the .deb file) by marking them as
4825 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4826 by managing them correctly in the maintainer scripts (see
4827 <ref id="config-files">). This is important since we want
4828 to give the local system administrator the chance to adapt
4829 the scripts to the local system, e.g., to disable a
4830 service without de-installing the package, or to specify
4831 some special command line options when starting a service,
4832 while making sure her changes aren't lost during the next
4837 These scripts should not fail obscurely when the
4838 configuration files remain but the package has been
4839 removed, as configuration files remain on the system after
4840 the package has been removed. Only when <prgn>dpkg</prgn>
4841 is executed with the <tt>--purge</tt> option will
4842 configuration files be removed. In particular, as the
4843 <file>/etc/init.d/<var>package</var></file> script itself is
4844 usually a <tt>conffile</tt>, it will remain on the system
4845 if the package is removed but not purged. Therefore, you
4846 should include a <tt>test</tt> statement at the top of the
4848 <example compact="compact">
4849 test -f <var>program-executed-later-in-script</var> || exit 0
4854 Often there are some variables in the <file>init.d</file>
4855 scripts whose values control the behaviour of the scripts,
4856 and which a system administrator is likely to want to
4857 change. As the scripts themselves are frequently
4858 <tt>conffile</tt>s, modifying them requires that the
4859 administrator merge in their changes each time the package
4860 is upgraded and the <tt>conffile</tt> changes. To ease
4861 the burden on the system administrator, such configurable
4862 values should not be placed directly in the script.
4863 Instead, they should be placed in a file in
4864 <file>/etc/default</file>, which typically will have the same
4865 base name as the <file>init.d</file> script. This extra file
4866 should be sourced by the script when the script runs. It
4867 must contain only variable settings and comments in POSIX
4868 <prgn>sh</prgn> format. It may either be a
4869 <tt>conffile</tt> or a configuration file maintained by
4870 the package maintainer scripts. See <ref id="config-files">
4875 To ensure that vital configurable values are always
4876 available, the <file>init.d</file> script should set default
4877 values for each of the shell variables it uses, either
4878 before sourcing the <file>/etc/default/</file> file or
4879 afterwards using something like the <tt>:
4880 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
4881 script must behave sensibly and not fail if the
4882 <file>/etc/default</file> file is deleted.
4887 <heading>Interfacing with the initscript system</heading>
4890 Maintainers should use the abstraction layer provided by
4891 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4892 programs to deal with initscripts in their packages'
4893 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4894 and <prgn>postrm</prgn>.
4897 Directly managing the /etc/rc?.d links and directly
4898 invoking the <file>/etc/init.d/</file> initscripts should
4899 be done only by packages providing the initscript
4900 subsystem (such as <prgn>sysvinit</prgn> and
4901 <prgn>file-rc</prgn>).
4906 <heading>Managing the links</heading>
4909 The program <prgn>update-rc.d</prgn> is provided for
4910 package maintainers to arrange for the proper creation and
4911 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4912 or their functional equivalent if another method is being
4913 used. This may be used by maintainers in their packages'
4914 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4917 You must not include any <file>/etc/rc<var>n</var>.d</file>
4918 symbolic links in the actual archive or manually create or
4919 remove the symbolic links in maintainer scripts; you must
4920 use the <prgn>update-rc.d</prgn> program instead. (The
4921 former will fail if an alternative method of maintaining
4922 runlevel information is being used.) You must not include
4923 the <file>/etc/rc<var>n</var>.d</file> directories themselves
4924 in the archive either. (Only the <tt>sysvinit</tt>
4929 By default <prgn>update-rc.d</prgn> will start services in
4930 each of the multi-user state runlevels (2, 3, 4, and 5)
4931 and stop them in the halt runlevel (0), the single-user
4932 runlevel (1) and the reboot runlevel (6). The system
4933 administrator will have the opportunity to customize
4934 runlevels by simply adding, moving, or removing the
4935 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4936 symbolic links are being used, or by modifying
4937 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4942 To get the default behavior for your package, put in your
4943 <prgn>postinst</prgn> script
4944 <example compact="compact">
4945 update-rc.d <var>package</var> defaults
4947 and in your <prgn>postrm</prgn>
4948 <example compact="compact">
4949 if [ "$1" = purge ]; then
4950 update-rc.d <var>package</var> remove
4952 </example>. Note that if your package changes runlevels
4953 or priority, you may have to remove and recreate the links,
4954 since otherwise the old links may persist. Refer to the
4955 documentation of <prgn>update-rc.d</prgn></p>
4958 This will use a default sequence number of 20. If it does
4959 not matter when or in which order the <file>init.d</file>
4960 script is run, use this default. If it does, then you
4961 should talk to the maintainer of the <prgn>sysvinit</prgn>
4962 package or post to <tt>debian-devel</tt>, and they will
4963 help you choose a number.
4967 For more information about using <tt>update-rc.d</tt>,
4968 please consult its manpage <manref name="update-rc.d"
4974 <heading>Running initscripts</heading>
4976 The program <prgn>invoke-rc.d</prgn> is provided to make
4977 it easier for package maintainers to properly invoke an
4978 initscript, obeying runlevel and other locally-defined
4979 constraints that might limit a package's right to start,
4980 stop and otherwise manage services. This program may be
4981 used by maintainers in their packages' scripts.
4984 The use of <prgn>invoke-rc.d</prgn> to invoke the
4985 <file>/etc/init.d/*</file> initscripts is strongly
4986 recommended<footnote>
4988 In the future, the use of invoke-rc.d to invoke
4989 initscripts shall be made mandatory. Maintainers are
4990 advised to switch to invoke-rc.d as soon as
4992 </footnote>, instead of calling them directly.
4996 By default, <prgn>invoke-rc.d</prgn> will pass any
4997 action requests (start, stop, reload, restart...) to the
4998 <file>/etc/init.d</file> script, filtering out requests
4999 to start or restart a service out of its intended
5003 Most packages will simply need to change:
5004 <example compact="compact">/etc/init.d/<package>
5005 <action></example> in their <prgn>postinst</prgn>
5006 and <prgn>prerm</prgn> scripts to:
5007 <example compact="compact">
5008 if [ -x /usr/sbin/invoke-rc.d ] ; then
5009 invoke-rc.d <var>package</var> <action>
5011 /etc/init.d/<var>package</var> <action>
5015 A package should register its initscript services using
5016 <prgn>update-rc.d</prgn> before it tries to invoke them
5017 using <prgn>invoke-rc.d</prgn>. Invocation of
5018 unregistered services may fail.
5021 For more information about using
5022 <prgn>invoke-rc.d</prgn>, please consult its manpage
5023 <manref name="invoke-rc.d" section="8">.
5030 <heading>Boot-time initialization</heading>
5033 There used to be another directory, <file>/etc/rc.boot</file>,
5034 which contained scripts which were run once per machine
5035 boot. This has been deprecated in favour of links from
5036 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
5037 described in <ref id="/etc/init.d">. Packages must not
5038 place files in <file>/etc/rc.boot</file>.</p>
5041 <heading>Example</heading>
5044 The <prgn>bind</prgn> DNS (nameserver) package wants to
5045 make sure that the nameserver is running in multiuser
5046 runlevels, and is properly shut down with the system. It
5047 puts a script in <file>/etc/init.d</file>, naming the script
5048 appropriately <tt>bind</tt>. As you can see, the script
5049 interprets the argument <tt>reload</tt> to send the
5050 nameserver a <tt>HUP</tt> signal (causing it to reload its
5051 configuration); this way the system administrator can say
5052 <tt>/etc/init.d/bind reload</tt> to reload the name
5053 server. The script has one configurable value, which can
5054 be used to pass parameters to the named program at
5055 startup; this value is read from
5056 <file>/etc/default/bind</file> (see below).
5060 <example compact="compact">
5063 # Original version by Robert Leslie
5064 # <rob@mars.org>, edited by iwj and cs
5066 test -x /usr/sbin/named || exit 0
5068 # Source defaults file.
5070 if [ -f /etc/default/bind ]; then
5077 echo -n "Starting domain name service: named"
5078 start-stop-daemon --start --quiet --exec /usr/sbin/named \
5083 echo -n "Stopping domain name service: named"
5084 start-stop-daemon --stop --quiet \
5085 --pidfile /var/run/named.pid --exec /usr/sbin/named
5089 echo -n "Restarting domain name service: named"
5090 start-stop-daemon --stop --quiet \
5091 --pidfile /var/run/named.pid --exec /usr/sbin/named
5092 start-stop-daemon --start --verbose --exec /usr/sbin/named \
5096 force-reload|reload)
5097 echo -n "Reloading configuration of domain name service: named"
5098 start-stop-daemon --stop --signal 1 --quiet \
5099 --pidfile /var/run/named.pid --exec /usr/sbin/named
5103 echo "Usage: /etc/init.d/bind " \
5104 " {start|stop|restart|reload|force-reload}" >&2
5114 Complementing the above init script is a configuration
5115 file <file>/etc/default/bind</file>, which contains
5116 configurable parameters used by the script. This would be
5117 created by the <prgn>postinst</prgn> script if it was not
5118 already present, and removed on purge by the
5119 <prgn>postrm</prgn> script.
5120 <example compact="compact">
5121 # Specified parameters to pass to named. See named(8).
5122 # You may uncomment the following line, and edit to taste.
5128 Another example on which you can base your
5129 <file>/etc/init.d</file> scripts is found in
5130 <file>/etc/init.d/skeleton</file>.
5134 If this package is happy with the default setup from
5135 <prgn>update-rc.d</prgn>, namely an ordering number of 20
5136 and having named running in all runlevels, it can say in
5137 its <prgn>postinst</prgn>:
5138 <example compact="compact">
5139 update-rc.d bind defaults >/dev/null
5141 And in its <prgn>postrm</prgn>, to remove the links when the
5143 <example compact="compact">
5144 if [ "$1" = purge ]; then
5145 update-rc.d bind remove >/dev/null
5153 <heading>Console messages from <file>init.d</file> scripts</heading>
5156 This section describes the formats to be used for messages
5157 written to standard output by the <file>/etc/init.d</file>
5158 scripts. The intent is to improve the consistency of
5159 Debian's startup and shutdown look and feel. For this
5160 reason, please look very carefully at the details. We want
5161 the messages to have the same format in terms of wording,
5162 spaces, punctuation and case of letters.
5166 Here is a list of overall rules that you should use when you
5167 create output messages. They can be useful if you have a
5168 non-standard message that is not covered specifically in the
5176 Every message should fit in one line (fewer than 80
5177 characters), start with a capital letter and end with
5178 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5184 If you want to express that the computer is working on
5185 something (that is, performing a specific task, not
5186 starting or stopping a program), we use an "ellipsis"
5187 (three dots: <tt>...</tt>). Note that we don't insert
5188 spaces before or after the dots. If the task has been
5189 completed we write <tt>done.</tt> and a line feed.
5195 Design your messages as if the computer is telling you
5196 what he is doing (let him be polite :-), but don't
5197 mention "him" directly. For example, if you think of
5199 <example compact="compact">
5200 I'm starting network daemons: nfsd mountd.
5203 <example compact="compact">
5204 Starting network daemons: nfsd mountd.
5212 There are standard message formats for the following
5213 situations. They should be used by the <tt>init.d</tt>
5220 <p>When daemons are started</p>
5223 If your script starts one or more daemons, the output
5224 should look like this (a single line, no leading
5226 <example compact="compact">
5227 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5229 The <var>description</var> should describe the
5230 subsystem the daemon or set of daemons are part of,
5231 while <var>daemon-1</var> up to <var>daemon-n</var>
5232 denote each daemon's name (typically the file name of
5237 For example, the output of <file>/etc/init.d/lpd</file>
5239 <example compact="compact">
5240 Starting printer spooler: lpd.
5245 This can be achieved by saying
5246 <example compact="compact">
5247 echo -n "Starting printer spooler: lpd"
5248 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5251 in the script. If you have more than one daemon to
5252 start, you should do the following:
5253 <example compact="compact">
5254 echo -n "Starting remote file system services:"
5255 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5256 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5257 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5260 This makes it possible for the user to see what takes
5261 so long and when the final daemon has been started.
5262 You should be careful where to put spaces: in the
5263 example above the system administrator can easily
5264 comment out a line if he don't wants to start a
5265 specific daemon, while the displayed message still
5271 <p>When a system parameter is being set</p>
5274 If you have to set up different system parameters
5275 during the system boot, you should use this format:
5276 <example compact="compact">
5277 Setting <var>parameter</var> to "<var>value</var>".
5282 You can use a statement such as the following to get
5284 <example compact="compact">
5285 echo "Setting DNS domainname to \"$domainname\"."
5290 Note that the same symbol (<tt>"</tt>) is used for the left
5291 and right quotation marks. A grave accent (<tt>`</tt>) is
5292 not a quote character; neither is an apostrophe
5298 <p>When a daemon is stopped or restarted</p>
5301 When you stop or restart a daemon, you should issue a
5302 message identical to the startup message, except that
5303 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5304 or <tt>Restarting</tt> respectively.
5308 For example, stopping the printer daemon will like
5310 <example compact="compact">
5311 Stopping printer spooler: lpd.
5317 <p>When something is executed</p>
5320 There are several examples where you have to run a
5321 program at system startup or shutdown to perform a
5322 specific task, for example, setting the system's clock
5323 using <prgn>netdate</prgn> or killing all processes
5324 when the system shuts down. Your message should look
5326 <example compact="compact">
5327 Doing something very useful...done.
5329 You should print the <tt>done.</tt> immediately after
5330 the job has been completed, so that the user is
5331 informed why she has to wait. You can get this
5333 <example compact="compact">
5334 echo -n "Doing something very useful..."
5343 <p>When the configuration is reloaded</p>
5346 When a daemon is forced to reload its configuration
5347 files you should use the following format:
5348 <example compact="compact">
5349 Reloading <var>description</var> configuration...done.
5351 where <var>description</var> is the same as in the
5352 daemon starting message.
5360 <heading>Cron jobs</heading>
5363 Packages must not modify the configuration file
5364 <file>/etc/crontab</file>, and they must not modify the files in
5365 <file>/var/spool/cron/crontabs</file>.</p>
5368 If a package wants to install a job that has to be executed
5369 via cron, it should place a file with the name of the
5370 package in one or more of the following directories:
5371 <example compact="compact">
5376 As these directory names imply, the files within them are
5377 executed on a daily, weekly, or monthly basis,
5378 respectively. The exact times are listed in
5379 <file>/etc/crontab</file>.</p>
5382 All files installed in any of these directories must be
5383 scripts (e.g., shell scripts or Perl scripts) so that they
5384 can easily be modified by the local system administrator.
5385 In addition, they should be treated as configuration
5390 If a certain job has to be executed more frequently than
5391 daily, the package should install a file
5392 <file>/etc/cron.d/<var>package</var></file>. This file uses the
5393 same syntax as <file>/etc/crontab</file> and is processed by
5394 <prgn>cron</prgn> automatically. The file must also be
5395 treated as a configuration file. (Note that entries in the
5396 <file>/etc/cron.d</file> directory are not handled by
5397 <prgn>anacron</prgn>. Thus, you should only use this
5398 directory for jobs which may be skipped if the system is not
5402 The scripts or crontab entries in these directories should
5403 check if all necessary programs are installed before they
5404 try to execute them. Otherwise, problems will arise when a
5405 package was removed but not purged since configuration files
5406 are kept on the system in this situation.</p>
5410 <heading>Menus</heading>
5413 The Debian <tt>menu</tt> package provides a standard
5414 interface between packages providing applications and
5415 documents, and <em>menu programs</em> (either X window
5416 managers or text-based menu programs such as
5417 <prgn>pdmenu</prgn>).
5421 All packages that provide applications that need not be
5422 passed any special command line arguments for normal
5423 operation should register a menu entry for those
5424 applications, so that users of the <tt>menu</tt> package
5425 will automatically get menu entries in their window
5426 managers, as well in shells like <tt>pdmenu</tt>.
5430 Menu entries should follow the current menu policy.
5434 The menu policy can be found in the <tt>menu-policy</tt>
5435 files in the <tt>debian-policy</tt> package.
5436 They are also available from the Debian web mirrors at
5437 <tt><url name="/doc/packaging-manuals/menu-policy/"
5438 id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>
5439 and from the Debian archive mirrors at
5440 <tt><url name="/doc/package-developer/menu-policy.txt.gz"
5441 id="http://ftp.debian.org/debian/doc/package-developer/menu-policy.txt.gz"></tt>.
5445 Please also refer to the <em>Debian Menu System</em>
5446 documentation that comes with the <tt>menu</tt> package for
5447 information about how to register your applications and web
5453 <heading>Multimedia handlers</heading>
5456 MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5457 is a mechanism for encoding files and data streams and
5458 providing meta-information about them, in particular their
5459 type (e.g. audio or video) and format (e.g. PNG, HTML,
5464 Registration of MIME type handlers allows programs like mail
5465 user agents and web browsers to to invoke these handlers to
5466 view, edit or display MIME types they don't support
5471 Packages which provide the ability to view/show/play,
5472 compose, edit or print MIME types should register themselves
5473 as such following the current MIME support policy.
5477 The MIME support policy can be found in the <tt>mime-policy</tt>
5478 files in the <tt>debian-policy</tt> package.
5479 They are also available from the Debian web mirrors at
5480 <tt><url name="/doc/packaging-manuals/mime-policy/"
5481 id="http://www.debian.org/doc/packaging-manuals/mime-policy/"></tt>
5482 and from the Debian archive mirrors at
5483 <tt><url name="/doc/package-developer/mime-policy.txt.gz"
5484 id="http://ftp.debian.org/debian/doc/package-developer/mime-policy.txt.gz"></tt>.
5490 <heading>Keyboard configuration</heading>
5493 To achieve a consistent keyboard configuration so that all
5494 applications interpret a keyboard event the same way, all
5495 programs in the Debian distribution must be configured to
5496 comply with the following guidelines.
5500 The following keys must have the specified interpretations:
5503 <tag><tt><--</tt></tag>
5504 <item><p>delete the character to the left of the cursor</p></item>
5506 <tag><tt>Delete</tt></tag>
5507 <item><p>delete the character to the right of the cursor</p></item>
5509 <tag><tt>Control+H</tt></tag>
5510 <item><p>emacs: the help prefix</p></item>
5513 The interpretation of any keyboard events should be
5514 independent of the terminal that is used, be it a virtual
5515 console, an X terminal emulator, an rlogin/telnet session,
5520 The following list explains how the different programs
5521 should be set up to achieve this:
5526 <item><p><tt><--</tt> generates <tt>KB_BackSpace</tt>
5529 <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5534 X translations are set up to make
5535 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5536 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5537 is the vt220 escape code for the "delete character"
5538 key). This must be done by loading the X resources
5539 using <prgn>xrdb</prgn> on all local X displays, not
5540 using the application defaults, so that the
5541 translation resources used correspond to the
5542 <prgn>xmodmap</prgn> settings.</p></item>
5546 The Linux console is configured to make
5547 <tt><--</tt> generate DEL, and <tt>Delete</tt>
5548 generate <tt>ESC [ 3 ~</tt>.</p></item>
5552 X applications are configured so that <tt><</tt>
5553 deletes left, and <tt>Delete</tt> deletes right. Motif
5554 applications already work like this.</p></item>
5556 <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5560 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5561 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5562 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5566 Emacs is programmed to map <tt>KB_Backspace</tt> or
5567 the <tt>stty erase</tt> character to
5568 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5569 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5570 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5574 Other applications use the <tt>stty erase</tt>
5575 character and <tt>kdch1</tt> for the two delete keys,
5576 with ASCII DEL being "delete previous character" and
5577 <tt>kdch1</tt> being "delete character under
5584 This will solve the problem except for the following
5592 Some terminals have a <tt><--</tt> key that cannot
5593 be made to produce anything except <tt>^H</tt>. On
5594 these terminals Emacs help will be unavailable on
5595 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5596 character takes precedence in Emacs, and has been set
5597 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
5598 available) can be used instead.</p></item>
5602 Some operating systems use <tt>^H</tt> for <tt>stty
5603 erase</tt>. However, modern telnet versions and all
5604 rlogin versions propagate <tt>stty</tt> settings, and
5605 almost all UNIX versions honour <tt>stty erase</tt>.
5606 Where the <tt>stty</tt> settings are not propagated
5607 correctly, things can be made to work by using
5608 <tt>stty</tt> manually.</p></item>
5612 Some systems (including previous Debian versions) use
5613 <prgn>xmodmap</prgn> to arrange for both
5614 <tt><--</tt> and <tt>Delete</tt> to generate
5615 <tt>KB_Delete</tt>. We can change the behavior of
5616 their X clients using the same X resources that we use
5617 to do it for our own clients, or configure our clients
5618 using their resources when things are the other way
5619 around. On displays configured like this
5620 <tt>Delete</tt> will not work, but <tt><--</tt>
5625 Some operating systems have different <tt>kdch1</tt>
5626 settings in their <tt>terminfo</tt> database for
5627 <tt>xterm</tt> and others. On these systems the
5628 <tt>Delete</tt> key will not work correctly when you
5629 log in from a system conforming to our policy, but
5630 <tt><--</tt> will.</p></item>
5636 <heading>Environment variables</heading>
5639 A program must not depend on environment variables to get
5640 reasonable defaults. (That's because these environment
5641 variables would have to be set in a system-wide
5642 configuration file like <file>/etc/profile</file>, which is not
5643 supported by all shells.)</p>
5646 If a program usually depends on environment variables for its
5647 configuration, the program should be changed to fall back to
5648 a reasonable default configuration if these environment
5649 variables are not present. If this cannot be done easily
5650 (e.g., if the source code of a non-free program is not
5651 available), the program must be replaced by a small
5652 "wrapper" shell script which sets the environment variables
5653 if they are not already defined, and calls the original program.</p>
5656 Here is an example of a wrapper script for this purpose:
5658 <example compact="compact">
5660 BAR=${BAR:-/var/lib/fubar}
5662 exec /usr/lib/foo/foo "$@"
5667 Furthermore, as <file>/etc/profile</file> is a configuration
5668 file of the <prgn>base-files</prgn> package, other packages must not
5669 put any environment variables or other commands into that
5675 <heading>Files</heading>
5678 <heading>Binaries</heading>
5681 Two different packages must not install programs with
5682 different functionality but with the same filenames. (The
5683 case of two programs having the same functionality but
5684 different implementations is handled via "alternatives" or
5685 the "Conflicts" mechanism. See <ref id="maintscripts"> and
5686 <ref id="conflicts"> respectively.) If this case happens,
5687 one of the programs must be renamed. The maintainers should
5688 report this to the <tt>debian-devel</tt> mailing list and
5689 try to find a consensus about which program will have to be
5690 renamed. If a consensus cannot be reached, <em>both</em>
5691 programs must be renamed.
5695 By default, when a package is being built, any binaries
5696 created should include debugging information, as well as
5697 being compiled with optimization. You should also turn on
5698 as many reasonable compilation warnings as possible; this
5699 makes life easier for porters, who can then look at build
5700 logs for possible problems. For the C programming language,
5701 this means the following compilation parameters should be
5703 <example compact="compact">
5705 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5707 install -s # (or use strip on the files in debian/tmp)
5712 Note that by default all installed binaries should be stripped,
5713 either by using the <tt>-s</tt> flag to
5714 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5715 the binaries after they have been copied into
5716 <file>debian/tmp</file> but before the tree is made into a
5720 Although binaries in the build tree should be compiled with
5721 debugging information by default, it can often be difficult
5722 to debug programs if they are also subjected to compiler
5723 optimization. For this reason, it is recommended to support
5724 the standardized environment
5725 variable <tt>DEB_BUILD_OPTIONS</tt>. This variable can
5726 contain several flags to change how a package is compiled
5734 The presence of this string means that the package
5735 should be complied with a minimum of optimization.
5736 For C programs, it is best to add <tt>-O0</tt>
5737 to <tt>CFLAGS</tt> (although this is usually the
5738 default). Some programs might fail to build or run at
5739 this level of optimization; it may be necessary to
5740 use <tt>-O1</tt>, for example.
5746 This string means that the debugging symbols should
5747 not be stripped from the binary during installation,
5748 so that debugging information may be included in the package.
5754 The following makefile snippet is an example of how one may
5755 implement the build options; you will probably have to
5756 massage this example in order to make it work for your
5758 <example compact="compact">
5761 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5762 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5763 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5764 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5766 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5771 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5772 INSTALL_PROGRAM += -s
5778 It is up to the package maintainer to decide what
5779 compilation options are best for the package. Certain
5780 binaries (such as computationally-intensive programs) will
5781 function better with certain flags (<tt>-O3</tt>, for
5782 example); feel free to use them. Please use good judgment
5783 here. Don't use flags for the sake of it; only use them
5784 if there is good reason to do so. Feel free to override
5785 the upstream author's ideas about which compilation
5786 options are best: they are often inappropriate for our
5792 <sect id="libraries">
5793 <heading>Libraries</heading>
5796 The shared version of a library must be compiled with
5797 <tt>-fPIC</tt>, and the static version must not be. In other
5798 words, each source unit (<tt>*.c</tt>, for example, for C files)
5799 will need to be compiled twice.
5804 You must specify the gcc option <tt>-D_REENTRANT</tt>
5805 when building a library (either static or shared) to make
5806 the library compatible with LinuxThreads.
5810 All installed shared libraries should be stripped with
5811 <example compact="compact">
5812 strip --strip-unneeded <var>your-lib</var>
5814 (The option <tt>--strip-unneeded</tt> makes
5815 <prgn>strip</prgn> remove only the symbols which aren't
5816 needed for relocation processing.) Shared libraries can
5817 function perfectly well when stripped, since the symbols for
5818 dynamic linking are in a separate part of the ELF object
5821 You might also want to use the options
5822 <tt>--remove-section=.comment</tt> and
5823 <tt>--remove-section=.note</tt> on both shared libraries
5824 and executables, and <tt>--strip-debug</tt> on static
5831 Note that under some circumstances it may be useful to
5832 install a shared library unstripped, for example when
5833 building a separate package to support debugging.
5837 Shared object files (often <file>.so</file> files) that are not
5838 public libraries, that is, they are not meant to be linked
5839 to by third party executables (binaries of other packages),
5840 should be installed in subdirectories of the
5841 <file>/usr/lib</file> directory. Such files are exempt from the
5842 rules that govern ordinary shared libraries, except that
5843 they must not be installed executable and should be
5846 A common example are the so-called "plug-ins",
5847 internal shared objects that are dynamically loaded by
5848 programs using <manref name="dlopen" section="3">.
5854 Packages containing shared libraries that may be linked to
5855 by other packages' binaries, but which for some
5856 <em>compelling</em> reason can not be installed in
5857 <file>/usr/lib</file> directory, may install the shared library
5858 files in subdirectories of the <file>/usr/lib</file> directory,
5859 in which case they should arrange to add that directory in
5860 <file>/etc/ld.so.conf</file> in the package's post-installation
5861 script, and remove it in the package's post-removal script.
5865 An ever increasing number of packages are using
5866 <prgn>libtool</prgn> to do their linking. The latest GNU
5867 libtools (>= 1.3a) can take advantage of the metadata in the
5868 installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5869 files). The main advantage of <prgn>libtool</prgn>'s
5870 <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5871 store and subsequently access metadata with respect to the
5872 libraries it builds. <prgn>libtool</prgn> will search for
5873 those files, which contain a lot of useful information about
5874 a library (such as library dependency information for static
5875 linking). Also, they're <em>essential</em> for programs
5876 using <tt>libltdl</tt>.<footnote>
5878 Although <prgn>libtool</prgn> is fully capable of
5879 linking against shared libraries which don't have
5880 <tt>.la</tt> files, as it is a mere shell script it can
5881 add considerably to the build time of a
5882 <prgn>libtool</prgn>-using package if that shell script
5883 has to derive all this information from first principles
5884 for each library every time it is linked. With the
5885 advent of <prgn>libtool</prgn> version 1.4 (and to a
5886 lesser extent <prgn>libtool</prgn> version 1.3), the
5887 <file>.la</file> files also store information about
5888 inter-library dependencies which cannot necessarily be
5889 derived after the <file>.la</file> file is deleted.
5895 Packages that use <prgn>libtool</prgn> to create shared
5896 libraries should include the <file>.la</file> files in the
5897 <tt>-dev</tt> package, unless the package relies on
5898 <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5899 the <tt>.la</tt> files must go in the run-time library
5904 You must make sure that you use only released versions of
5905 shared libraries to build your packages; otherwise other
5906 users will not be able to run your binaries
5907 properly. Producing source packages that depend on
5908 unreleased compilers is also usually a bad
5915 <heading>Shared libraries</heading>
5917 This section has moved to <ref id="sharedlibs">.
5923 <heading>Scripts</heading>
5926 All command scripts, including the package maintainer
5927 scripts inside the package and used by <prgn>dpkg</prgn>,
5928 should have a <tt>#!</tt> line naming the shell to be used
5929 to interpret them.</p>
5932 In the case of Perl scripts this should be
5933 <tt>#!/usr/bin/perl</tt>.</p>
5936 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5937 should almost certainly start with <tt>set -e</tt> so that
5938 errors are detected. Every script should use
5939 <tt>set -e</tt> or check the exit status of <em>every</em>
5943 The standard shell interpreter <file>/bin/sh</file> can be a
5944 symbolic link to any POSIX compatible shell, if <tt>echo
5945 -n</tt> does not generate a newline.<footnote>
5947 Debian policy specifies POSIX behavior for
5948 <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5949 use in the Linux community (in particular including this
5950 policy, the Linux kernel source, many Debian scripts,
5951 etc.). This <tt>echo -n</tt> mechanism is valid but not
5952 required under POSIX, hence this explicit addition.
5953 Also, rumour has it that this shall be mandated under
5957 Thus, shell scripts specifying <file>/bin/sh</file> as
5958 interpreter should only use POSIX features. If a script
5959 requires non-POSIX features from the shell interpreter, the
5960 appropriate shell must be specified in the first line of the
5961 script (e.g., <tt>#!/bin/bash</tt>) and the package must
5962 depend on the package providing the shell (unless the shell
5963 package is marked "Essential", as in the case of
5968 You may wish to restrict your script to POSIX features when
5969 possible so that it may use <file>/bin/sh</file> as its
5970 interpreter. If your script works with <prgn>dash</prgn>
5971 (originally called <prgn>ash</prgn>), it's probably POSIX
5972 compliant, but if you are in doubt, use
5973 <file>/bin/bash</file>.
5977 Perl scripts should check for errors when making any
5978 system calls, including <tt>open</tt>, <tt>print</tt>,
5979 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5983 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5984 scripting languages. See <em>Csh Programming Considered
5985 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5986 can be found at <url
5987 id="http://language.perl.com/versus/csh.whynot">.<footnote>
5989 It can also be found on
5990 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5991 or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5992 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5995 If an upstream package comes with <prgn>csh</prgn> scripts
5996 then you must make sure that they start with
5997 <tt>#!/bin/csh</tt> and make your package depend on the
5998 <prgn>c-shell</prgn> virtual package.
6002 Any scripts which create files in world-writeable
6003 directories (e.g., in <file>/tmp</file>) must use a
6004 mechanism which will fail if a file with the same name
6008 The Debian base system provides the <prgn>tempfile</prgn>
6009 and <prgn>mktemp</prgn> utilities for use by scripts for
6010 this purpose.</p></sect>
6014 <heading>Symbolic links</heading>
6017 In general, symbolic links within a top-level directory
6018 should be relative, and symbolic links pointing from one
6019 top-level directory into another should be absolute. (A
6020 top-level directory is a sub-directory of the root
6021 directory <file>/</file>.)</p>
6024 In addition, symbolic links should be specified as short as
6025 possible, i.e., link targets like <file>foo/../bar</file> are
6029 Note that when creating a relative link using
6030 <prgn>ln</prgn> it is not necessary for the target of the
6031 link to exist relative to the working directory you're
6032 running <prgn>ln</prgn> from, nor is it necessary to change
6033 directory to the directory where the link is to be made.
6034 Simply include the string that should appear as the target
6035 of the link (this will be a pathname relative to the
6036 directory in which the link resides) as the first argument
6037 to <prgn>ln</prgn>.</p>
6040 For example, in your <prgn>Makefile</prgn> or
6041 <file>debian/rules</file>, you can do things like:
6042 <example compact="compact">
6043 ln -fs gcc $(prefix)/bin/cc
6044 ln -fs gcc debian/tmp/usr/bin/cc
6045 ln -fs ../sbin/sendmail $(prefix)/bin/runq
6046 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
6050 A symbolic link pointing to a compressed file should always
6051 have the same file extension as the referenced file. (For
6052 example, if a file <file>foo.gz</file> is referenced by a
6053 symbolic link, the filename of the link has to end with
6054 "<file>.gz</file>" too, as in <file>bar.gz</file>.)
6059 <heading>Device files</heading>
6062 Packages must not include device files in the package file
6066 If a package needs any special device files that are not
6067 included in the base system, it must call
6068 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
6069 after notifying the user<footnote>
6071 This notification could be done via a (low-priority)
6072 debconf message, or an echo (printf) statement.
6078 Packages must not remove any device files in the
6079 <prgn>postrm</prgn> or any other script. This is left to the
6080 system administrator.</p>
6083 Debian uses the serial devices
6084 <file>/dev/ttyS*</file>. Programs using the old
6085 <file>/dev/cu*</file> devices should be changed to use
6086 <file>/dev/ttyS*</file>.</p>
6089 <sect id="config-files">
6090 <heading>Configuration files</heading>
6092 <heading>Definitions</heading>
6095 <tag>configuration file</tag>
6098 A file that affects the operation of a program, or
6099 provides site- or host-specific information, or
6100 otherwise customizes the behavior of a program.
6101 Typically, configuration files are intended to be
6102 modified by the system administrator (if needed or
6103 desired) to conform to local policy or to provide
6104 more useful site-specific behavior.
6108 <tag><tt>conffile</tt></tag>
6111 A file listed in a package's <tt>conffiles</tt>
6112 file, and is treated specially by <prgn>dpkg</prgn>
6113 (see <ref id="configdetails">).
6120 The distinction between these two is important; they are
6121 not interchangeable concepts. Almost all
6122 <tt>conffile</tt>s are configuration files, but many
6123 configuration files are not <tt>conffiles</tt>.
6127 Note that a script that embeds configuration information
6128 (such as most of the files in <file>/etc/default</file> and
6129 <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6130 configuration file and should be treated as such.
6135 <heading>Location</heading>
6137 Any configuration files created or used by your package
6138 must reside in <file>/etc</file>. If there are several,
6139 consider creating a subdirectory of <file>/etc</file>
6140 named after your package.</p>
6143 If your package creates or uses configuration files
6144 outside of <file>/etc</file>, and it is not feasible to modify
6145 the package to use <file>/etc</file> directly, put the files
6146 in <file>/etc</file> and create symbolic links to those files
6147 from the location that the package requires.</p>
6151 <heading>Behavior</heading>
6153 Configuration file handling must conform to the following
6155 <list compact="compact">
6158 local changes must be preserved during a package
6164 configuration files must be preserved when the
6165 package is removed, and only deleted when the
6173 The easy way to achieve this behavior is to make the
6174 configuration file a <tt>conffile</tt>. This is
6175 appropriate only if it is possible to distribute a default
6176 version that will work for most installations, although
6177 some system administrators may choose to modify it. This
6178 implies that the default version will be part of the
6179 package distribution, and must not be modified by the
6180 maintainer scripts during installation (or at any other
6185 In order to ensure that local changes are preserved
6186 correctly, no package may contain or make hard links to
6187 conffiles.<footnote>
6189 Rationale: There are two problems with hard links.
6190 The first is that some editors break the link while
6191 editing one of the files, so that the two files may
6192 unwittingly become unlinked and different. The second
6193 is that <prgn>dpkg</prgn> might break the hard link
6194 while upgrading <tt>conffile</tt>s.
6200 The other way to do it is via the maintainer scripts. In
6201 this case, the configuration file must not be listed as a
6202 <tt>conffile</tt> and must not be part of the package
6203 distribution. If the existence of a file is required for
6204 the package to be sensibly configured it is the
6205 responsibility of the package maintainer to provide
6206 maintainer scripts which correctly create, update and
6207 maintain the file and remove it on purge. (See <ref
6208 id="maintainerscripts"> for more information.) These
6209 scripts must be idempotent (i.e., must work correctly if
6210 <prgn>dpkg</prgn> needs to re-run them due to errors
6211 during installation or removal), must cope with all the
6212 variety of ways <prgn>dpkg</prgn> can call maintainer
6213 scripts, must not overwrite or otherwise mangle the user's
6214 configuration without asking, must not ask unnecessary
6215 questions (particularly during upgrades), and otherwise be
6220 The scripts are not required to configure every possible
6221 option for the package, but only those necessary to get
6222 the package running on a given system. Ideally the
6223 sysadmin should not have to do any configuration other
6224 than that done (semi-)automatically by the
6225 <prgn>postinst</prgn> script.
6229 A common practice is to create a script called
6230 <file><var>package</var>-configure</file> and have the
6231 package's <prgn>postinst</prgn> call it if and only if the
6232 configuration file does not already exist. In certain
6233 cases it is useful for there to be an example or template
6234 file which the maintainer scripts use. Such files should
6235 be in <file>/usr/share/<var>package</var></file> or
6236 <file>/usr/lib/<var>package</var></file> (depending on whether
6237 they are architecture-independent or not). There should
6238 be symbolic links to them from
6239 <file>/usr/share/doc/<var>package</var>/examples</file> if
6240 they are examples, and should be perfectly ordinary
6241 <prgn>dpkg</prgn>-handled files (<em>not</em>
6242 configuration files).
6246 These two styles of configuration file handling must
6247 not be mixed, for that way lies madness:
6248 <prgn>dpkg</prgn> will ask about overwriting the file
6249 every time the package is upgraded.
6254 <heading>Sharing configuration files</heading>
6256 Packages which specify the same file as a
6257 <tt>conffile</tt> must be tagged as <em>conflicting</em>
6258 with each other. (This is an instance of the general rule
6259 about not sharing files. Note that neither alternatives
6260 nor diversions are likely to be appropriate in this case;
6261 in particular, <prgn>dpkg</prgn> does not handle diverted
6262 <tt>conffile</tt>s well.)
6266 The maintainer scripts must not alter a <tt>conffile</tt>
6267 of <em>any</em> package, including the one the scripts
6272 If two or more packages use the same configuration file
6273 and it is reasonable for both to be installed at the same
6274 time, one of these packages must be defined as
6275 <em>owner</em> of the configuration file, i.e., it will be
6276 the package which handles that file as a configuration
6277 file. Other packages that use the configuration file must
6278 depend on the owning package if they require the
6279 configuration file to operate. If the other package will
6280 use the configuration file if present, but is capable of
6281 operating without it, no dependency need be declared.</p>
6284 If it is desirable for two or more related packages to
6285 share a configuration file <em>and</em> for all of the
6286 related packages to be able to modify that configuration
6287 file, then the following should be done:
6288 <enumlist compact="compact">
6291 One of the related packages (the "owning" package)
6292 will manage the configuration file with maintainer
6293 scripts as described in the previous section.
6298 The owning package should also provide a program
6299 that the other packages may use to modify the
6305 The related packages must use the provided program
6306 to make any desired modifications to the
6307 configuration file. They should either depend on
6308 the core package to guarantee that the configuration
6309 modifier program is available or accept gracefully
6310 that they cannot modify the configuration file if it
6311 is not. (This is in addition to the fact that the
6312 configuration file may not even be present in the
6320 Sometimes it's appropriate to create a new package which
6321 provides the basic infrastructure for the other packages
6322 and which manages the shared configuration files. (The
6323 <tt>sgml-base</tt> package is a good example.)
6328 <heading>User configuration files ("dotfiles")</heading>
6331 The files in <file>/etc/skel</file> will automatically be
6332 copied into new user accounts by <prgn>adduser</prgn>.
6333 No other program should reference the files in
6334 <file>/etc/skel</file>.
6338 Therefore, if a program needs a dotfile to exist in
6339 advance in <file>$HOME</file> to work sensibly, that dotfile
6340 should be installed in <file>/etc/skel</file> and treated as a
6345 However, programs that require dotfiles in order to
6346 operate sensibly are a bad thing, unless they do create
6347 the dotfiles themselves automatically.
6351 Furthermore, programs should be configured by the Debian
6352 default installation to behave as closely to the upstream
6353 default behaviour as possible.
6357 Therefore, if a program in a Debian package needs to be
6358 configured in some way in order to operate sensibly, that
6359 should be done using a site-wide configuration file placed
6360 in <file>/etc</file>. Only if the program doesn't support a
6361 site-wide default configuration and the package maintainer
6362 doesn't have time to add it may a default per-user file be
6363 placed in <file>/etc/skel</file>.
6367 <file>/etc/skel</file> should be as empty as we can make it.
6368 This is particularly true because there is no easy (or
6369 necessarily desirable) mechanism for ensuring that the
6370 appropriate dotfiles are copied into the accounts of
6371 existing users when a package is installed.
6377 <heading>Log files</heading>
6379 Log files should usually be named
6380 <file>/var/log/<var>package</var>.log</file>. If you have many
6381 log files, or need a separate directory for permission
6382 reasons (<file>/var/log</file> is writable only by
6383 <file>root</file>), you should usually create a directory named
6384 <file>/var/log/<var>package</var></file> and place your log
6389 Log files must be rotated occasionally so that they don't
6390 grow indefinitely; the best way to do this is to drop a log
6391 rotation configuration file into the directory
6392 <file>/etc/logrotate.d</file> and use the facilities provided by
6393 logrotate.<footnote>
6395 The traditional approach to log files has been to set up
6396 <em>ad hoc</em> log rotation schemes using simple shell
6397 scripts and cron. While this approach is highly
6398 customizable, it requires quite a lot of sysadmin work.
6399 Even though the original Debian system helped a little
6400 by automatically installing a system which can be used
6401 as a template, this was deemed not enough.
6405 The use of <prgn>logrotate</prgn>, a program developed
6406 by Red Hat, is better, as it centralizes log management.
6407 It has both a configuration file
6408 (<file>/etc/logrotate.conf</file>) and a directory where
6409 packages can drop their individual log rotation
6410 configurations (<file>/etc/logrotate.d</file>).
6413 Here is a good example for a logrotate config
6414 file (for more information see <manref name="logrotate"
6416 <example compact="compact">
6422 /etc/init.d/foo force-reload
6426 This rotates all files under <file>/var/log/foo</file>, saves 12
6427 compressed generations, and forces the daemon to reload its
6428 configuration information after the log rotation.
6432 Log files should be removed when the package is
6433 purged (but not when it is only removed). This should be
6434 done by the <prgn>postrm</prgn> script when it is called
6435 with the argument <tt>purge</tt> (see <ref
6436 id="removedetails">).
6441 <heading>Permissions and owners</heading>
6444 The rules in this section are guidelines for general use.
6445 If necessary you may deviate from the details below.
6446 However, if you do so you must make sure that what is done
6447 is secure and you should try to be as consistent as possible
6448 with the rest of the system. You should probably also
6449 discuss it on <prgn>debian-devel</prgn> first.
6453 Files should be owned by <tt>root.root</tt>, and made
6454 writable only by the owner and universally readable (and
6455 executable, if appropriate), that is mode 644 or 755.
6459 Directories should be mode 755 or (for group-writability)
6460 mode 2775. The ownership of the directory should be
6461 consistent with its mode: if a directory is mode 2775, it
6462 should be owned by the group that needs write access to
6467 Setuid and setgid executables should be mode 4755 or 2755
6468 respectively, and owned by the appropriate user or group.
6469 They should not be made unreadable (modes like 4711 or
6470 2711 or even 4111); doing so achieves no extra security,
6471 because anyone can find the binary in the freely available
6472 Debian package; it is merely inconvenient. For the same
6473 reason you should not restrict read or execute permissions
6474 on non-set-id executables.
6478 Some setuid programs need to be restricted to particular
6479 sets of users, using file permissions. In this case they
6480 should be owned by the uid to which they are set-id, and by
6481 the group which should be allowed to execute them. They
6482 should have mode 4754; again there is no point in making
6483 them unreadable to those users who must not be allowed to
6488 It is possible to arrange that the system administrator can
6489 reconfigure the package to correspond to their local
6490 security policy by changing the permissions on a binary:
6491 they can do this by using <prgn>dpkg-statoverride</prgn>, as
6492 described below.<footnote>
6494 Ordinary files installed by <prgn>dpkg</prgn> (as
6495 opposed to <tt>conffile</tt>s and other similar objects)
6496 normally have their permissions reset to the distributed
6497 permissions when the package is reinstalled. However,
6498 the use of <prgn>dpkg-statoverride</prgn> overrides this
6499 default behaviour. If you use this method, you should
6500 remember to describe <prgn>dpkg-statoverride</prgn> in
6501 the package documentation; being a relatively new
6502 addition to Debian, it is probably not yet well-known.
6505 Another method you should consider is to create a group for
6506 people allowed to use the program(s) and make any setuid
6507 executables executable only by that group.
6511 If you need to create a new user or group for your package
6512 there are two possibilities. Firstly, you may need to
6513 make some files in the binary package be owned by this
6514 user or group, or you may need to compile the user or
6515 group id (rather than just the name) into the binary
6516 (though this latter should be avoided if possible, as in
6517 this case you need a statically allocated id).</p>
6520 If you need a statically allocated id, you must ask for a
6521 user or group id from the <tt>base-passwd</tt> maintainer,
6522 and must not release the package until you have been
6523 allocated one. Once you have been allocated one you must
6524 either make the package depend on a version of the
6525 <tt>base-passwd</tt> package with the id present in
6526 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6527 your package to create the user or group itself with the
6528 correct id (using <tt>adduser</tt>) in its
6529 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
6530 the <prgn>postinst</prgn> is to be preferred if it is
6531 possible, otherwise a pre-dependency will be needed on the
6532 <tt>adduser</tt> package.)
6536 On the other hand, the program might be able to determine
6537 the uid or gid from the user or group name at runtime, so
6538 that a dynamically allocated id can be used. In this case
6539 you should choose an appropriate user or group name,
6540 discussing this on <prgn>debian-devel</prgn> and checking
6541 with the <package/base-passwd/ maintainer that it is unique and that
6542 they do not wish you to use a statically allocated id
6543 instead. When this has been checked you must arrange for
6544 your package to create the user or group if necessary using
6545 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6546 <prgn>postinst</prgn> script (again, the latter is to be
6547 preferred if it is possible).
6551 Note that changing the numeric value of an id associated
6552 with a name is very difficult, and involves searching the
6553 file system for all appropriate files. You need to think
6554 carefully whether a static or dynamic id is required, since
6555 changing your mind later will cause problems.
6558 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6560 This section is not intended as policy, but as a
6561 description of the use of <prgn>dpkg-statoverride</prgn>.
6565 <prgn>dpkg-statoverride</prgn> is a replacement for the
6566 deprecated <tt>suidmanager</tt> package. Packages which
6567 previously used <tt>suidmanager</tt> should have a
6568 <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6569 <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6570 and <tt>suidunregister</tt> should now be simply removed
6571 from the maintainer scripts.
6575 If a system administrator wishes to have a file (or
6576 directory or other such thing) installed with owner and
6577 permissions different from those in the distributed Debian
6578 package, he can use the <prgn>dpkg-statoverride</prgn>
6579 program to instruct <prgn>dpkg</prgn> to use the different
6580 settings every time the file is installed. Thus the
6581 package maintainer should distribute the files with their
6582 normal permissions, and leave it for the system
6583 administrator to make any desired changes. For example, a
6584 daemon which is normally required to be setuid root, but
6585 in certain situations could be used without being setuid,
6586 should be installed setuid in the <tt>.deb</tt>. Then the
6587 local system administrator can change this if they wish.
6588 If there are two standard ways of doing it, the package
6589 maintainer can use <tt>debconf</tt> to find out the
6590 preference, and call <prgn>dpkg-statoverride</prgn> in the
6591 maintainer script if necessary to accommodate the system
6592 administrator's choice.
6596 Given the above, <prgn>dpkg-statoverride</prgn> is
6597 essentially a tool for system administrators and would not
6598 normally be needed in the maintainer scripts. There is
6599 one type of situation, though, where calls to
6600 <prgn>dpkg-statoverride</prgn> would be needed in the
6601 maintainer scripts, and that involves packages which use
6602 dynamically allocated user or group ids. In such a
6603 situation, something like the following idiom can be very
6604 helpful in the package's <prgn>postinst</prgn>, where
6605 <tt>sysuser</tt> is a dynamically allocated id:
6607 for i in /usr/bin/foo /usr/sbin/bar
6609 if ! dpkg-statoverride --list $i >/dev/null
6611 dpkg-statoverride --update --add sysuser root 4755 $i
6615 The corresponding <tt>dpkg-statoverride --remove</tt>
6616 calls can then be made unconditionally when the package is
6623 <chapt id="customized-programs">
6624 <heading>Customized programs</heading>
6626 <sect id="arch-spec">
6627 <heading>Architecture specification strings</heading>
6630 If a program needs to specify an <em>architecture specification
6631 string</em> in some place, the following format should be
6632 used: <var>arch</var>-<var>os</var><footnote>
6634 The following architectures and operating systems are
6635 currently recognised by <prgn>dpkg-archictecture</prgn>.
6636 The architecture, <tt><var>arch</var></tt>, is one of
6637 the following: <tt>alpha</tt>, <tt>arm</tt>,
6638 <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6639 <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6640 <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6641 <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>. The
6642 operating system, <tt><var>os</var></tt>, is one of:
6643 <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6644 <tt>openbsd</tt>. Use of <tt>gnu</tt> in this string is
6645 reserved for the GNU/Hurd operating system.
6651 Note that we don't want to use
6652 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6653 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6654 since this would make our programs incompatible with other
6655 Linux distributions. We also don't use something like
6656 <tt><var>arch</var>-unknown-linux</tt>, since the
6657 <tt>unknown</tt> does not look very good.
6662 <heading>Daemons</heading>
6665 The configuration files <file>/etc/services</file>,
6666 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6667 by the <prgn>netbase</prgn> package and must not be modified
6672 If a package requires a new entry in one of these files, the
6673 maintainer should get in contact with the
6674 <prgn>netbase</prgn> maintainer, who will add the entries
6675 and release a new version of the <prgn>netbase</prgn>
6680 The configuration file <file>/etc/inetd.conf</file> must not be
6681 modified by the package's scripts except via the
6682 <prgn>update-inetd</prgn> script or the
6683 <file>DebianNet.pm</file> Perl module. See their documentation
6684 for details on how to add entries.
6688 If a package wants to install an example entry into
6689 <file>/etc/inetd.conf</file>, the entry must be preceded with
6690 exactly one hash character (<tt>#</tt>). Such lines are
6691 treated as "commented out by user" by the
6692 <prgn>update-inetd</prgn> script and are not changed or
6693 activated during package updates.
6698 <heading>Using pseudo-ttys and modifying wtmp, utmp and
6702 Some programs need to create pseudo-ttys. This should be done
6703 using Unix98 ptys if the C library supports it. The resulting
6704 program must not be installed setuid root, unless that
6705 is required for other functionality.
6709 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6710 <file>/var/log/lastlog</file> must be installed writeable by
6711 group <tt>utmp</tt>. Programs which need to modify those
6712 files must be installed setgid <tt>utmp</tt>.
6717 <heading>Editors and pagers</heading>
6720 Some programs have the ability to launch an editor or pager
6721 program to edit or display a text document. Since there are
6722 lots of different editors and pagers available in the Debian
6723 distribution, the system administrator and each user should
6724 have the possibility to choose his/her preferred editor and
6729 In addition, every program should choose a good default
6730 editor/pager if none is selected by the user or system
6735 Thus, every program that launches an editor or pager must
6736 use the EDITOR or PAGER environment variable to determine
6737 the editor or pager the user wishes to use. If these
6738 variables are not set, the programs <file>/usr/bin/editor</file>
6739 and <file>/usr/bin/pager</file> should be used, respectively.
6743 These two files are managed through the <prgn>dpkg</prgn>
6744 "alternatives" mechanism. Thus every package providing an
6745 editor or pager must call the
6746 <prgn>update-alternatives</prgn> script to register these
6751 If it is very hard to adapt a program to make use of the
6752 EDITOR or PAGER variables, that program may be configured to
6753 use <file>/usr/bin/sensible-editor</file> and
6754 <file>/usr/bin/sensible-pager</file> as the editor or pager
6755 program respectively. These are two scripts provided in the
6756 Debian base system that check the EDITOR and PAGER variables
6757 and launch the appropriate program, and fall back to
6758 <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6759 variable is not set.
6763 A program may also use the VISUAL environment variable to
6764 determine the user's choice of editor. If it exists, it
6765 should take precedence over EDITOR. This is in fact what
6766 <file>/usr/bin/sensible-editor</file> does.
6770 It is not required for a package to depend on
6771 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6772 package to provide such virtual packages.<footnote>
6774 The Debian base system already provides an editor and a
6781 <sect id="web-appl">
6782 <heading>Web servers and applications</heading>
6785 This section describes the locations and URLs that should
6786 be used by all web servers and web applications in the
6794 Cgi-bin executable files are installed in the
6796 <example compact="compact">
6797 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6799 and should be referred to as
6800 <example compact="compact">
6801 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6806 <item><p>Access to HTML documents</p>
6809 HTML documents for a package are stored in
6810 <file>/usr/share/doc/<var>package</var></file>
6811 and can be referred to as
6812 <example compact="compact">
6813 http://localhost/doc/<var>package</var>/<var>filename</var>
6817 The web server should restrict access to the document
6818 tree so that only clients on the same host can read
6819 the documents. If the web server does not support such
6820 access controls, then it should not provide access at
6821 all, or ask about providing access during installation.
6825 <item><p>Web Document Root</p>
6828 Web Applications should try to avoid storing files in
6829 the Web Document Root. Instead they should use the
6830 /usr/share/doc/<var>package</var> directory for
6831 documents and register the Web Application via the
6832 menu package. If access to the web document root is
6833 unavoidable then use
6834 <example compact="compact">
6837 as the Document Root. This might be just a symbolic
6838 link to the location where the system administrator
6839 has put the real document root.
6843 </enumlist></p></sect>
6846 <sect id="mail-transport-agents">
6847 <heading>Mail transport, delivery and user agents</heading>
6850 Debian packages which process electronic mail, whether mail
6851 user agents (MUAs) or mail transport agents (MTAs), must
6852 ensure that they are compatible with the configuration
6853 decisions below. Failure to do this may result in lost
6854 mail, broken <tt>From:</tt> lines, and other serious brain
6859 The mail spool is <file>/var/mail</file> and the interface to
6860 send a mail message is <file>/usr/sbin/sendmail</file> (as per
6861 the FHS). On older systems, the mail spool may be
6862 physically located in <file>/var/spool/mail</file>, but all
6863 access to the mail spool should be via the
6864 <file>/var/mail</file> symlink. The mail spool is part of the
6865 base system and not part of the MTA package.
6869 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6870 programs (such as IMAP daemons) must lock the mailbox in an
6871 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6872 be combined with dot locking. To avoid deadlocks, a program
6873 should use <tt>fcntl()</tt> first and dot locking after
6874 this, or alternatively implement the two locking methods in
6875 a non blocking way<footnote>
6877 If it is not possible to establish both locks, the
6878 system shouldn't wait for the second lock to be
6879 established, but remove the first lock, wait a (random)
6880 time, and start over locking again.
6882 </footnote>. Using the functions <tt>maillock</tt> and
6883 <tt>mailunlock</tt> provided by the
6884 <tt>liblockfile*</tt><footnote>
6886 You will need to depend on <tt>liblockfile1
6887 (>>1.01)</tt> to use these functions.
6889 </footnote> packages is the recommended way to realize this.
6893 Mailboxes are generally mode 660
6894 <tt><var>user</var>.mail</tt> unless the system
6895 administrator has chosen otherwise. A MUA may remove a
6896 mailbox (unless it has nonstandard permissions) in which
6897 case the MTA or another MUA must recreate it if needed.
6898 Mailboxes must be writable by group mail.
6902 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6903 be setgid mail to do the locking mentioned above (and
6904 must obviously avoid accessing other users' mailboxes
6905 using this privilege).</p>
6908 <file>/etc/aliases</file> is the source file for the system mail
6909 aliases (e.g., postmaster, usenet, etc.), it is the one
6910 which the sysadmin and <prgn>postinst</prgn> scripts may
6911 edit. After <file>/etc/aliases</file> is edited the program or
6912 human editing it must call <prgn>newaliases</prgn>. All MTA
6913 packages must come with a <prgn>newaliases</prgn> program,
6914 even if it does nothing, but older MTA packages did not do
6915 this so programs should not fail if <prgn>newaliases</prgn>
6916 cannot be found. Note that because of this, all MTA
6917 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6918 <tt>Replaces: mail-transport-agent</tt> control file
6923 The convention of writing <tt>forward to
6924 <var>address</var></tt> in the mailbox itself is not
6925 supported. Use a <tt>.forward</tt> file instead.</p>
6928 The <prgn>rmail</prgn> program used by UUCP
6929 for incoming mail should be <file>/usr/sbin/rmail</file>.
6930 Likewise, <prgn>rsmtp</prgn>, for receiving
6931 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6935 If your package needs to know what hostname to use on (for
6936 example) outgoing news and mail messages which are generated
6937 locally, you should use the file <file>/etc/mailname</file>. It
6938 will contain the portion after the username and <tt>@</tt>
6939 (at) sign for email addresses of users on the machine
6940 (followed by a newline).
6944 Such package should check for the existence of this file
6945 when it is being configured. If it exists, it should be
6946 used without comment, although an MTA's configuration script
6947 may wish to prompt the user even if it finds that this file
6948 exists. If the file does not exist, the package should
6949 prompt the user for the value (preferably using
6950 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6951 as well as using it in the package's configuration. The
6952 prompt should make it clear that the name will not just be
6953 used by that package. For example, in this situation the
6954 <tt>inn</tt> package could say something like:
6955 <example compact="compact">
6956 Please enter the "mail name" of your system. This is the
6957 hostname portion of the address to be shown on outgoing
6958 news and mail messages. The default is
6959 <var>syshostname</var>, your system's host name. Mail
6960 name ["<var>syshostname</var>"]:
6962 where <var>syshostname</var> is the output of <tt>hostname
6968 <heading>News system configuration</heading>
6971 All the configuration files related to the NNTP (news)
6972 servers and clients should be located under
6973 <file>/etc/news</file>.</p>
6976 There are some configuration issues that apply to a number
6977 of news clients and server packages on the machine. These
6981 <tag><file>/etc/news/organization</file></tag>
6982 <item><p>A string which should appear as the
6983 organization header for all messages posted
6984 by NNTP clients on the machine</p></item>
6986 <tag><file>/etc/news/server</file></tag>
6987 <item><p>Contains the FQDN of the upstream NNTP
6988 server, or localhost if the local machine is
6989 an NNTP server.</p></item>
6992 Other global files may be added as required for cross-package news
6993 configuration.</p></sect>
6997 <heading>Programs for the X Window System</heading>
7000 <heading>Providing X support and package priorities</heading>
7003 Programs that can be configured with support for the X
7004 Window System must be configured to do so and must declare
7005 any package dependencies necessary to satisfy their
7006 runtime requirements when using the X Window System. If
7007 such a package is of higher priority than the X packages
7008 on which it depends, it is required that either the
7009 X-specific components be split into a separate package, or
7010 that an alternative version of the package, which includes
7011 X support, be provided, or that the package's priority be
7017 <heading>Packages providing an X server</heading>
7020 Packages that provide an X server that, directly or
7021 indirectly, communicates with real input and display
7022 hardware should declare in their control data that they
7023 provide the virtual package <tt>xserver</tt>.<footnote>
7025 This implements current practice, and provides an
7026 actual policy for usage of the <tt>xserver</tt>
7027 virtual package which appears in the virtual packages
7028 list. In a nutshell, X servers that interface
7029 directly with the display and input hardware or via
7030 another subsystem (e.g., GGI) should provide
7031 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
7032 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
7039 <heading>Packages providing a terminal emulator</heading>
7042 Packages that provide a terminal emulator for the X Window
7043 System which meet the criteria listed below should declare
7044 in their control data that they provide the virtual
7045 package <tt>x-terminal-emulator</tt>. They should also
7046 register themselves as an alternative for
7047 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
7052 To be an <tt>x-terminal-emulator</tt>, a program must:
7053 <list compact="compact">
7055 Be able to emulate a DEC VT100 terminal, or a
7056 compatible terminal.
7060 Support the command-line option <tt>-e
7061 <var>command</var></tt>, which creates a new
7062 terminal window<footnote>
7064 "New terminal window" does not necessarily mean
7065 a new top-level X window directly parented by
7066 the window manager; it could, if the terminal
7067 emulator application were so coded, be a new
7068 "view" in a multiple-document interface (MDI).
7071 and runs the specified <var>command</var>.
7075 Support the command-line option <tt>-T
7076 <var>title</var></tt>, which creates a new terminal
7077 window with the window title <var>title</var>.
7084 <heading>Packages providing a window manager</heading>
7087 Packages that provide a window manager should declare in
7088 their control data that they provide the virtual package
7089 <tt>x-window-manager</tt>. They should also register
7090 themselves as an alternative for
7091 <file>/usr/bin/x-window-manager</file>, with a priority
7092 calculated as follows:
7093 <list compact="compact">
7094 <item><p>Start with a priority of 20.</p></item>
7098 If the window manager supports the Debian menu
7099 system, add 20 points if this support is available
7100 in the package's default configuration (i.e., no
7101 configuration files belonging to the system or user
7102 have to be edited to activate the feature); if
7103 configuration files must be modified, add only 10
7109 If the window manager complies with <url
7110 id="http://www.freedesktop.org/standards/wm-spec.html"
7111 name="The Window Manager Specification Project">,
7112 written by the <url id="http://www.freedesktop.org"
7113 name="Free Desktop Group">, add 20 points.
7119 If the window manager permits the X session to be
7120 restarted using a <em>different</em> window manager
7121 (without killing the X server) in its default
7122 configuration, add 10 points; otherwise add none.
7130 <heading>Packages providing fonts</heading>
7133 Packages that provide fonts for the X Window
7136 For the purposes of Debian Policy, a "font for the X
7137 Window System" is one which is accessed via X protocol
7138 requests. Fonts for the Linux console, for PostScript
7139 renderers, or any other purpose, do not fit this
7140 definition. Any tool which makes such fonts available
7141 to the X Window System, however, must abide by this
7145 must do a number of things to ensure that they are both
7146 available without modification of the X or font server
7147 configuration, and that they do not corrupt files used by
7148 other font packages to register information about
7153 Fonts of any type supported by the X Window System
7154 must be in a separate binary package from any
7155 executables, libraries, or documentation (except
7156 that specific to the fonts shipped, such as their
7157 license information). If one or more of the fonts
7158 so packaged are necessary for proper operation of
7159 the package with which they are associated the font
7160 package may be Recommended; if the fonts merely
7161 provide an enhancement, a Suggests relationship may
7162 be used. Packages must not Depend on font
7165 This is because the X server may retrieve fonts
7166 from the local filesystem or over the network
7167 from an X font server; the Debian package system
7168 is empowered to deal only with the local
7177 BDF fonts must be converted to PCF fonts with the
7178 <prgn>bdftopcf</prgn> utility (available in the
7179 <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7180 placed in a directory that corresponds to their
7182 <list compact="compact">
7184 100 dpi fonts must be placed in
7185 <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7189 75 dpi fonts must be placed in
7190 <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7194 Character-cell fonts, cursor fonts, and other
7195 low-resolution fonts must be placed in
7196 <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7203 Speedo fonts must be placed in
7204 <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7208 Type 1 fonts must be placed in
7209 <file>/usr/X11R6/lib/X11/fonts/Type1/</file>. If font
7210 metric files are available, they must be placed here
7216 Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7217 other than those listed above must be neither
7218 created nor used. (The <file>PEX</file>, <file>CID</file>,
7219 and <file>cyrillic</file> directories are excepted for
7220 historical reasons, but installation of files into
7221 these directories remains discouraged.)
7227 Font packages may, instead of placing files directly
7228 in the X font directories listed above, provide
7229 symbolic links in that font directory pointing to
7230 the files' actual location in the filesystem. Such
7231 a location must comply with the FHS.
7237 Font packages should not contain both 75dpi and
7238 100dpi versions of a font. If both are available,
7239 they should be provided in separate binary packages
7240 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7241 the names of the packages containing the
7242 corresponding fonts.
7248 Fonts destined for the <file>misc</file> subdirectory
7249 should not be included in the same package as 75dpi
7250 or 100dpi fonts; instead, they should be provided in
7251 a separate package with <tt>-misc</tt> appended to
7258 Font packages must not provide the files
7259 <file>fonts.dir</file>, <file>fonts.alias</file>, or
7260 <file>fonts.scale</file> in a font directory:
7263 <file>fonts.dir</file> files must not be provided at all.
7268 <file>fonts.alias</file> and <file>fonts.scale</file>
7269 files, if needed, should be provided in the
7271 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7272 where <var>fontdir</var> is the name of the
7274 <file>/usr/X11R6/lib/X11/fonts/</file> where the
7275 package's corresponding fonts are stored
7276 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7277 <var>package</var> is the name of the package
7278 that provides these fonts, and
7279 <var>extension</var> is either <tt>scale</tt>
7280 or <tt>alias</tt>, whichever corresponds to
7290 Font packages must declare a dependency on
7291 <tt>xutils (>> 4.0.3)</tt> in their control
7298 Font packages that provide one or more
7299 <file>fonts.scale</file> files as described above must
7300 invoke <prgn>update-fonts-scale</prgn> on each
7301 directory into which they installed fonts
7302 <em>before</em> invoking
7303 <prgn>update-fonts-dir</prgn> on that directory.
7304 This invocation must occur in both the
7305 <prgn>postinst</prgn> (for all arguments) and
7306 <prgn>postrm</prgn> (for all arguments except
7307 <tt>upgrade</tt>) scripts.
7313 Font packages that provide one or more
7314 <file>fonts.alias</file> files as described above must
7315 invoke <prgn>update-fonts-alias</prgn> on each
7316 directory into which they installed fonts. This
7317 invocation must occur in both the
7318 <prgn>postinst</prgn> (for all arguments) and
7319 <prgn>postrm</prgn> (for all arguments except
7320 <tt>upgrade</tt>) scripts.
7326 Font packages must invoke
7327 <prgn>update-fonts-dir</prgn> on each directory into
7328 which they installed fonts. This invocation must
7329 occur in both the <prgn>postinst</prgn> (for all
7330 arguments) and <prgn>postrm</prgn> (for all
7331 arguments except <tt>upgrade</tt>) scripts.
7337 Font packages must not provide alias names for the
7338 fonts they include which collide with alias names
7339 already in use by fonts already packaged.
7345 Font packages must not provide fonts with the same
7346 XLFD registry name as another font already packaged.
7354 <heading>Application defaults files</heading>
7357 Application defaults files must be installed in the
7358 directory <file>/etc/X11/app-defaults/</file> (use of a
7359 localized subdirectory of <file>/etc/X11/</file> as described
7360 in the <em>X Toolkit Intrinsics - C Language
7361 Interface</em> manual is also permitted). They must be
7362 registered as <tt>conffile</tt>s or handled as
7363 configuration files. Packages must not provide the
7364 directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7368 Customization of programs' X resources may also be
7369 supported with the provision of a file with the same name
7370 as that of the package placed in the
7371 <file>/etc/X11/Xresources/</file> directory, which must
7372 registered as a <tt>conffile</tt> or handled as a
7373 configuration file.<footnote>
7375 Note that this mechanism is not the same as using
7376 app-defaults; app-defaults are tied to the client
7377 binary on the local filesystem, whereas X resources
7378 are stored in the X server and affect all connecting
7382 <em>Important:</em> packages that install files into the
7383 <file>/etc/X11/Xresources/</file> directory must conflict with
7384 <tt>xbase (<< 3.3.2.3a-2)</tt>; if this is not done
7385 it is possible for the installing package to destroy a
7386 previously-existing <file>/etc/X11/Xresources</file> file
7387 which had been customized by the system administrator.
7392 <heading>Installation directory issues</heading>
7395 Packages using the X Window System should not be
7396 configured to install files under the <file>/usr/X11R6/</file>
7397 directory unless they use <prgn>imake</prgn>. The
7398 <file>/usr/X11R6/</file> directory hierarchy should be
7399 regarded as deprecated for all packages except the X
7400 Window System itself, and those which use the
7401 <prgn>imake</prgn> program it provides, in which case the
7402 packages may transition out of the <file>/usr/X11R6/</file>
7403 directory at the maintainer's discretion.<footnote>
7405 <prgn>Imake</prgn>-using programs are exempt because,
7406 as long as they are written correctly, the pathnames
7407 they use to locate resources and install themselves
7408 are derived wholly from the X Window System
7409 configuration. Thus, in the event that the X Window
7410 System moves to <file>/usr/X11R7/</file>,
7411 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7412 that is required for these programs is a recompile
7413 against the corresponding X Window System library
7414 development packages.
7417 Programs that use GNU <prgn>autoconf</prgn> and
7418 <prgn>automake</prgn> are usually easily configured at
7419 compile time to use <file>/usr/</file> instead of
7420 <file>/usr/X11R6/</file>, and this should be done whenever
7421 possible. Configuration files for window managers and
7422 display managers should be placed in a subdirectory of
7423 <file>/etc/X11/</file> corresponding to the package name due
7424 to these programs' tight integration with the mechanisms
7425 of the X Window System. Application-level programs should
7426 use the <file>/etc/</file> directory unless otherwise mandated
7427 by policy. The installation of files into subdirectories
7428 of <file>/usr/X11R6/include/X11/</file> and
7429 <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7430 package maintainers should determine if subdirectories of
7431 <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7432 instead. (The use of symbolic links from the
7433 <file>X11R6</file> directories to other FHS-compliant
7434 locations is encouraged if the program is not easily
7435 configured to look elsewhere for its files.) Packages
7436 must not provide or install files into the directories
7437 <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7438 <file>/usr/lib/X11/</file>. Files within a package should,
7439 however, make reference to these directories, rather than
7440 their <tt>X11R6</tt>-named counterparts
7441 <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7442 and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7443 referred to have not been moved to other FHS-compliant
7449 <heading>The OSF/Motif and OpenMotif libraries</heading>
7452 <em>Programs that require the non-DFSG-compliant OSF/Motif or
7453 OpenMotif libraries</em><footnote>
7455 OSF/Motif and OpenMotif are collectively referred to as
7456 "Motif" in this policy document.
7459 should be compiled against and tested with LessTif (a free
7460 re-implementation of Motif) instead. If the maintainer
7461 judges that the program or programs do not work
7462 sufficiently well with LessTif to be distributed and
7463 supported, but do so when compiled against Motif, then two
7464 versions of the package should be created; one linked
7465 statically against Motif and with <tt>-smotif</tt>
7466 appended to the package name, and one linked dynamically
7467 against Motif and with <tt>-dmotif</tt> appended to the
7468 package name. Both Motif-linked versions are dependent
7469 upon non-DFSG-compliant software and thus cannot be
7470 uploaded to the <em>main</em> distribution; if the
7471 software is itself DFSG-compliant it may be uploaded to
7472 the <em>contrib</em> distribution. While known existing
7473 versions of Motif permit unlimited redistribution of
7474 binaries linked against the library (whether statically or
7475 dynamically), it is the package maintainer's
7476 responsibility to determine whether this is permitted by
7477 the license of the copy of Motif in his or her possession.
7483 <heading>Perl programs and modules</heading>
7486 Perl programs and modules should follow the current Perl policy.
7490 The Perl policy can be found in the <tt>perl-policy</tt>
7491 files in the <tt>debian-policy</tt> package.
7492 They are also available from the Debian web mirrors at
7493 <tt><url name="/doc/packaging-manuals/perl-policy/"
7494 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>
7495 and from the Debian archive mirrors at
7496 <tt><url name="/doc/package-developer/perl-policy.txt.gz"
7497 id="http://ftp.debian.org/debian/doc/package-developer/perl-policy.txt.gz"></tt>.
7502 <heading>Emacs lisp programs</heading>
7505 Please refer to the "Debian Emacs Policy" for details of how to
7506 package emacs lisp programs.
7510 The Emacs policy is available in
7511 <file>debian-emacs-policy.gz</file> of the
7512 <package>emacsen-common</package> package.
7513 It is also available from the Debian web mirrors at
7514 <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
7515 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
7520 <heading>Games</heading>
7523 The permissions on <file>/var/games</file> are mode 755, owner
7524 <tt>root</tt> and group <tt>root</tt>.
7528 Each game decides on its own security policy.</p>
7531 Games which require protected, privileged access to
7532 high-score files, savegames, etc., may be made
7533 set-<em>group</em>-id (mode 2755) and owned by
7534 <tt>root.games</tt>, and use files and directories with
7535 appropriate permissions (770 <tt>root.games</tt>, for
7536 example). They must not be made
7537 set-<em>user</em>-id, as this causes security problems. (If
7538 an attacker can subvert any set-user-id game they can
7539 overwrite the executable of any other, causing other players
7540 of these games to run a Trojan horse program. With a
7541 set-group-id game the attacker only gets access to less
7542 important game data, and if they can get at the other
7543 players' accounts at all it will take considerably more
7547 Some packages, for example some fortune cookie programs, are
7548 configured by the upstream authors to install with their
7549 data files or other static information made unreadable so
7550 that they can only be accessed through set-id programs
7551 provided. You should not do this in a Debian package: anyone can
7552 download the <file>.deb</file> file and read the data from it,
7553 so there is no point making the files unreadable. Not
7554 making the files unreadable also means that you don't have
7555 to make so many programs set-id, which reduces the risk of a
7559 As described in the FHS, binaries of games should be
7560 installed in the directory <file>/usr/games</file>. This also
7561 applies to games that use the X Window System. Manual pages
7562 for games (X and non-X games) should be installed in
7563 <file>/usr/share/man/man6</file>.</p>
7567 <chapt id="docs"><heading>Documentation</heading>
7571 <heading>Manual pages</heading>
7574 You should install manual pages in <prgn>nroff</prgn> source
7575 form, in appropriate places under <file>/usr/share/man</file>.
7576 You should only use sections 1 to 9 (see the FHS for more
7577 details). You must not install a preformatted "cat page".
7581 Each program, utility, and function should have an
7582 associated manual page included in the same package. It is
7583 suggested that all configuration files also have a manual
7584 page included as well. Manual pages for protocols and other
7585 auxiliary things are optional.
7589 If no manual page is available, this is considered as a bug
7590 and should be reported to the Debian Bug Tracking System (the
7591 maintainer of the package is allowed to write this bug report
7592 themselves, if they so desire). Do not close the bug report
7593 until a proper manpage is available.<footnote>
7595 It is not very hard to write a man page. See the
7596 <url id="http://www.schweikhardt.net/man_page_howto.html"
7597 name="Man-Page-HOWTO">,
7598 <manref name="man" section="7">, the examples
7599 created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7600 the helper programs <prgn>help2man</prgn>, or the
7601 directory <file>/usr/share/doc/man-db/examples</file>.
7607 You may forward a complaint about a missing manpage to the
7608 upstream authors, and mark the bug as forwarded in the
7609 Debian bug tracking system. Even though the GNU Project do
7610 not in general consider the lack of a manpage to be a bug,
7611 we do; if they tell you that they don't consider it a bug
7612 you should leave the bug in our bug tracking system open
7617 Manual pages should be installed compressed using <tt>gzip -9</tt>.
7621 If one manpage needs to be accessible via several names it
7622 is better to use a symbolic link than the <file>.so</file>
7623 feature, but there is no need to fiddle with the relevant
7624 parts of the upstream source to change from <file>.so</file> to
7625 symlinks: don't do it unless it's easy. You should not
7626 create hard links in the manual page directories, nor put
7627 absolute filenames in <file>.so</file> directives. The filename
7628 in a <file>.so</file> in a manpage should be relative to the
7629 base of the manpage tree (usually
7630 <file>/usr/share/man</file>). If you do not create any links
7631 (whether symlinks, hard links, or <tt>.so</tt> directives)
7632 in the filesystem to the alternate names of the manpage,
7633 then you should not rely on <prgn>man</prgn> finding your
7634 manpage under those names based solely on the information in
7635 the manpage's header.<footnote>
7637 Supporting this in <prgn>man</prgn> often requires
7638 unreasonable processing time to find a manual page or to
7639 report that none exists, and moves knowledge into man's
7640 database that would be better left in the filesystem.
7641 This support is therefore deprecated and will cease to
7642 be present in the future.
7649 <heading>Info documents</heading>
7652 Info documents should be installed in <file>/usr/share/info</file>.
7653 They should be compressed with <tt>gzip -9</tt>.
7657 Your package should call <prgn>install-info</prgn> to update
7658 the Info <file>dir</file> file in its <prgn>postinst</prgn>
7659 script when called with a <tt>configure</tt> argument, for
7661 <example compact="compact">
7662 install-info --quiet --section Development Development \
7663 /usr/share/info/foobar.info
7667 It is a good idea to specify a section for the location of
7668 your program; this is done with the <tt>--section</tt>
7669 switch. To determine which section to use, you should look
7670 at <file>/usr/share/info/dir</file> on your system and choose the most
7671 relevant (or create a new section if none of the current
7672 sections are relevant). Note that the <tt>--section</tt>
7673 flag takes two arguments; the first is a regular expression
7674 to match (case-insensitively) against an existing section,
7675 the second is used when creating a new one.</p>
7678 You should remove the entries in the <prgn>prerm</prgn>
7679 script when called with a <tt>remove</tt> argument:
7680 <example compact="compact">
7681 install-info --quiet --remove /usr/share/info/foobar.info
7685 If <prgn>install-info</prgn> cannot find a description entry
7686 in the Info file you must supply one. See <manref
7687 name="install-info" section="8"> for details.</p>
7691 <heading>Additional documentation</heading>
7694 Any additional documentation that comes with the package may
7695 be installed at the discretion of the package maintainer.
7696 Text documentation should be installed in the directory
7697 <file>/usr/share/doc/<var>package</var></file>, where
7698 <var>package</var> is the name of the package, and
7699 compressed with <tt>gzip -9</tt> unless it is small.
7703 If a package comes with large amounts of documentation which
7704 many users of the package will not require you should create
7705 a separate binary package to contain it, so that it does not
7706 take up disk space on the machines of users who do not need
7707 or want it installed.</p>
7710 It is often a good idea to put text information files
7711 (<file>README</file>s, changelogs, and so forth) that come with
7712 the source package in <file>/usr/share/doc/<var>package</var></file>
7713 in the binary package. However, you don't need to install
7714 the instructions for building and installing the package, of
7718 Packages must not require the existance of any files in
7719 <file>/usr/share/doc/</file> in order to function
7722 The system administrator should be able to
7723 delete files in <file>/usr/share/doc/</file> without causing
7724 any programs to break.
7727 Any files that are referenced by programs but are also
7728 useful as standalone documentation should be installed under
7729 <file>/usr/share/<var>package</var>/</file> with symbolic links from
7730 <file>/usr/share/doc/<var>package</var></file>.
7734 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7735 link to another directory in <file>/usr/share/doc</file> only if
7736 the two packages both come from the same source and the
7737 first package Depends on the second.
7741 Former Debian releases placed all additional documentation
7742 in <file>/usr/doc/<var>package</var></file>. This has been
7743 changed to <file>/usr/share/doc/<var>package</var></file>,
7744 and packages must not put documentation in the directory
7745 <file>/usr/doc/<var>package</var></file>. <footnote>
7746 <p>At this phase of the transition, we no longer require a
7747 symbolic link in <file>/usr/doc/</file>. At a later point,
7748 policy shall change to make the symbolic links a bug.</p>
7754 <heading>Preferred documentation formats</heading>
7757 The unification of Debian documentation is being carried out
7761 If your package comes with extensive documentation in a
7762 markup format that can be converted to various other formats
7763 you should if possible ship HTML versions in a binary
7764 package, in the directory
7765 <file>/usr/share/doc/<var>appropriate-package</var></file> or
7766 its subdirectories.<footnote>
7768 The rationale: The important thing here is that HTML
7769 docs should be available in <em>some</em> package, not
7770 necessarily in the main binary package.
7776 Other formats such as PostScript may be provided at the
7777 package maintainer's discretion.
7781 <sect id="copyrightfile">
7782 <heading>Copyright information</heading>
7785 Every package must be accompanied by a verbatim copy of its
7786 copyright and distribution license in the file
7787 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7788 file must neither be compressed nor be a symbolic link.
7792 In addition, the copyright file must say where the upstream
7793 sources (if any) were obtained. It should name the original
7794 authors of the package and the Debian maintainer(s) who were
7795 involved with its creation.</p>
7798 A copy of the file which will be installed in
7799 <file>/usr/share/doc/<var>package</var>/copyright</file> should
7800 be in <file>debian/copyright</file> in the source package.
7804 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7805 link to another directory in <file>/usr/share/doc</file> only if
7806 the two packages both come from the same source and the
7807 first package Depends on the second. These rules are
7808 important because copyrights must be extractable by
7813 Packages distributed under the UCB BSD license, the Artistic
7814 license, the GNU GPL, and the GNU LGPL should refer to the
7815 files <file>/usr/share/common-licenses/BSD</file>,
7816 <file>/usr/share/common-licenses/Artistic</file>,
7817 <file>/usr/share/common-licenses/GPL</file>, and
7818 <file>/usr/share/common-licenses/LGPL</file> respectively,
7819 rather than quoting them in the copyright file.
7823 You should not use the copyright file as a general <file>README</file>
7824 file. If your package has such a file it should be
7825 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7826 <file>README.Debian</file> or some other appropriate place.</p>
7830 <heading>Examples</heading>
7833 Any examples (configurations, source files, whatever),
7834 should be installed in a directory
7835 <file>/usr/share/doc/<var>package</var>/examples</file>. These
7836 files should not be referenced by any program: they're there
7837 for the benefit of the system administrator and users as
7838 documentation only. Architecture-specific example files
7839 should be installed in a directory
7840 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7842 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7843 latter directory itself may be a symbolic link to the
7848 If the purpose of a package is to provide examples, then the
7849 example files may be installed into
7850 <file>/usr/share/doc/<var>package</var></file>.
7854 <sect id="changelogs">
7855 <heading>Changelog files</heading>
7858 The Debian changelog file (<file>debian/changelog</file>) should
7859 explain briefly what modifications were made in the Debian version
7860 of the package compared to the upstream one. Other changes and
7861 updates to the package should also be documented in this file.
7865 Mistakes in changelogs are usually best rectified by
7866 making a new changelog entry rather than "rewriting history"
7867 by editing old changelog entries.
7871 The format of the <file>debian/changelog</file> file is described
7872 in <ref id="dpkgchangelog">. In non-experimental packages you must
7873 use a format for <file>debian/changelog</file> which is supported
7874 by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7876 If you wish to use an alternative format, you may do so as
7877 long as you include a parser for it in your source package.
7878 The parser must have an API compatible with that expected by
7879 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7880 If there is general interest in the new format, you should
7881 contact the <package>dpkg</package> maintainer to have the
7882 parser script for it included in the <prgn>dpkg</prgn>
7883 package. (You will need to agree that the parser and its
7884 manpage may be distributed under the GNU GPL, just as the rest
7885 of <prgn>dpkg</prgn> is.)
7891 Packages that are not Debian-native must contain a
7892 compressed copy of the <file>debian/changelog</file> file from
7893 the Debian source tree in
7894 <file>/usr/share/doc/<var>package</var></file> with the name
7895 <file>changelog.Debian.gz</file>.
7899 If an upstream changelog is available, it should be accessible as
7900 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7901 plain text. If the upstream changelog is distributed in
7902 HTML, it should be made available in that form as
7903 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7904 and a plain text <file>changelog.gz</file> should be generated
7905 from it using, for example, <tt>lynx -dump -nolist</tt>. If
7906 the upstream changelog files do not already conform to this
7907 naming convention, then this may be achieved either by
7908 renaming the files, or by adding a symbolic link, at the
7909 maintainer's discretion.<footnote>
7911 Rationale: People should not have to look in places for
7912 upstream changelogs merely because they are given
7913 different names or are distributed in HTML format.
7919 All of these files should be installed compressed using
7920 <tt>gzip -9</tt>, as they will become large with time even
7921 if they start out small.
7925 If the package has only one changelog which is used both as
7926 the Debian changelog and the upstream one because there is
7927 no separate upstream maintainer then that changelog should
7928 usually be installed as
7929 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7930 there is a separate upstream maintainer, but no upstream
7931 changelog, then the Debian changelog should still be called
7932 <file>changelog.Debian.gz</file>.</p>
7937 <appendix id="pkg-scope">
7938 <heading>Introduction and scope of these appendices</heading>
7941 These appendices are taken essentially verbatim from the
7942 now-deprecated Packaging Manual, version 3.2.1.0. They are
7943 the chapters which are likely to be of use to package
7944 maintainers and which have not already been included in the
7945 policy document itself. Most of these sections are very likely
7946 not relevant to policy; they should be treated as
7947 documentation for the packaging system. Please note that these
7948 appendices are included for convenience, and for historical
7949 reasons: they used to be part of policy package, and they have
7950 not yet been incorporated into dpkg documentation. However,
7951 they still have value, and hence they are presented here.
7954 They have not yet been checked to ensure that they are
7955 compatible with the contents of policy, and if there are any
7956 contradictions, the version in the main policy document takes
7957 precedence. The remaining chapters of the old Packaging
7958 Manual have also not been read in detail to ensure that there
7959 are not parts which have been left out. Both of these will be
7964 <prgn>dpkg</prgn> is a suite of programs for creating binary
7965 package files and installing and removing them on Unix
7968 <prgn>dpkg</prgn> is targetted primarily at Debian
7969 GNU/Linux, but may work on or be ported to other
7976 The binary packages are designed for the management of
7977 installed executable programs (usually compiled binaries) and
7978 their associated data, though source code examples and
7979 documentation are provided as part of some packages.</p>
7982 This manual describes the technical aspects of creating Debian
7983 binary packages (<file>.deb</file> files). It documents the
7984 behaviour of the package management programs
7985 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7986 they interact with packages.</p>
7989 It also documents the interaction between
7990 <prgn>dselect</prgn>'s core and the access method scripts it
7991 uses to actually install the selected packages, and describes
7992 how to create a new access method.</p>
7995 This manual does not go into detail about the options and
7996 usage of the package building and installation tools. It
7997 should therefore be read in conjuction with those programs'
8002 The utility programs which are provided with <prgn>dpkg</prgn>
8003 for managing various system configuration and similar issues,
8004 such as <prgn>update-rc.d</prgn> and
8005 <prgn>install-info</prgn>, are not described in detail here -
8006 please see their manpages.
8010 It is assumed that the reader is reasonably familiar with the
8011 <prgn>dpkg</prgn> System Administrators' manual.
8012 Unfortunately this manual does not yet exist.
8016 The Debian version of the FSF's GNU hello program is provided
8017 as an example for people wishing to create Debian
8018 packages. The Debian <prgn>debmake</prgn> package is
8019 recommended as a very helpful tool in creating and maintaining
8020 Debian packages. However, while the tools and examples are
8021 helpful, they do not replace the need to read and follow the
8022 Policy and Programmer's Manual.</p>
8025 <appendix id="pkg-binarypkg"><heading>Binary packages (from old
8030 The binary package has two main sections. The first part
8031 consists of various control information files and scripts used
8032 by <prgn>dpkg</prgn> when installing and removing. See <ref
8033 id="pkg-controlarea">.
8037 The second part is an archive containing the files and
8038 directories to be installed.
8042 In the future binary packages may also contain other
8043 components, such as checksums and digital signatures. The
8044 format for the archive is described in full in the
8045 <file>deb(5)</file> manpage.
8049 <sect id="pkg-bincreating"><heading>Creating package files -
8050 <prgn>dpkg-deb</prgn>
8054 All manipulation of binary package files is done by
8055 <prgn>dpkg-deb</prgn>; it's the only program that has
8056 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
8057 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
8058 will spot that the options requested are appropriate to
8059 <prgn>dpkg-deb</prgn> and invoke that instead with the same
8064 In order to create a binary package you must make a
8065 directory tree which contains all the files and directories
8066 you want to have in the filesystem data part of the package.
8067 In Debian-format source packages this directory is usually
8068 <file>debian/tmp</file>, relative to the top of the package's
8073 They should have the locations (relative to the root of the
8074 directory tree you're constructing) ownerships and
8075 permissions which you want them to have on the system when
8080 With current versions of <prgn>dpkg</prgn> the uid/username
8081 and gid/groupname mappings for the users and groups being
8082 used should be the same on the system where the package is
8083 built and the one where it is installed.
8087 You need to add one special directory to the root of the
8088 miniature filesystem tree you're creating:
8089 <prgn>DEBIAN</prgn>. It should contain the control
8090 information files, notably the binary package control file
8091 (see <ref id="pkg-controlfile">).
8095 The <prgn>DEBIAN</prgn> directory will not appear in the
8096 filesystem archive of the package, and so won't be installed
8097 by <prgn>dpkg</prgn> when the package is installed.
8101 When you've prepared the package, you should invoke:
8103 dpkg --build <var>directory</var>
8108 This will build the package in
8109 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
8110 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8111 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8116 See the manpage <manref name="dpkg-deb" section="8"> for details of how
8117 to examine the contents of this newly-created file. You may find the
8118 output of following commands enlightening:
8120 dpkg-deb --info <var>filename</var>.deb
8121 dpkg-deb --contents <var>filename</var>.deb
8122 dpkg --contents <var>filename</var>.deb
8124 To view the copyright file for a package you could use this command:
8126 dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8131 <sect id="pkg-controlarea">
8133 Package control information files
8137 The control information portion of a binary package is a
8138 collection of files with names known to <prgn>dpkg</prgn>.
8139 It will treat the contents of these files specially - some
8140 of them contain information used by <prgn>dpkg</prgn> when
8141 installing or removing the package; others are scripts which
8142 the package maintainer wants <prgn>dpkg</prgn> to run.
8146 It is possible to put other files in the package control
8147 area, but this is not generally a good idea (though they
8148 will largely be ignored).
8152 Here is a brief list of the control info files supported by
8153 <prgn>dpkg</prgn> and a summary of what they're used for.
8158 <tag><tt>control</tt>
8162 This is the key description file used by
8163 <prgn>dpkg</prgn>. It specifies the package's name
8164 and version, gives its description for the user,
8165 states its relationships with other packages, and so
8166 forth. See <ref id="pkg-controlfile">.
8170 It is usually generated automatically from information
8171 in the source package by the
8172 <prgn>dpkg-gencontrol</prgn> program, and with
8173 assistance from <prgn>dpkg-shlibdeps</prgn>. See <ref
8174 id="pkg-sourcetools">.</p>
8177 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8183 These are exectuable files (usually scripts) which
8184 <prgn>dpkg</prgn> runs during installation, upgrade
8185 and removal of packages. They allow the package to
8186 deal with matters which are particular to that package
8187 or require more complicated processing than that
8188 provided by <prgn>dpkg</prgn>. Details of when and
8189 how they are called are in <ref
8190 id="maintainerscripts">.
8194 It is very important to make these scripts
8198 That means that if it runs successfully or fails
8199 and then you call it again it doesn't bomb out,
8200 but just ensures that everything is the way it
8203 </footnote> This is so that if an error occurs, the
8204 user interrupts <prgn>dpkg</prgn> or some other
8205 unforeseen circumstance happens you don't leave the
8206 user with a badly-broken package.
8210 The maintainer scripts are guaranteed to run with a
8211 controlling terminal and can interact with the user.
8212 If they need to prompt for passwords, do full-screen
8213 interaction or something similar you should do these
8214 things to and from <file>/dev/tty</file>, since
8215 <prgn>dpkg</prgn> will at some point redirect scripts'
8216 standard input and output so that it can log the
8217 installation process. Likewise, because these scripts
8218 may be executed with standard output redirected into a
8219 pipe for logging purposes, Perl scripts should set
8220 unbuffered output by setting <tt>$|=1</tt> so that the
8221 output is printed immediately rather than being
8226 Each script should return a zero exit status for
8227 success, or a nonzero one for failure.</p>
8230 <tag><tt>conffiles</tt>
8235 This file contains a list of configuration files which
8236 are to be handled automatically by <prgn>dpkg</prgn>
8237 (see <ref id="pkg-conffiles">). Note that not necessarily
8238 every configuration file should be listed here.</p>
8241 <tag><tt>shlibs</tt>
8246 This file contains a list of the shared libraries
8247 supplied by the package, with dependency details for
8248 each. This is used by <prgn>dpkg-shlibdeps</prgn>
8249 when it determines what dependencies are required in a
8250 package control file. The <tt>shlibs</tt> file format
8251 is described on <ref id="shlibs">.
8257 <sect id="pkg-controlfile">
8259 The main control information file: <tt>control</tt>
8262 The most important control information file used by
8263 <prgn>dpkg</prgn> when it installs a package is
8264 <tt>control</tt>. It contains all the package"s "vital
8269 The binary package control files of packages built from
8270 Debian sources are made by a special tool,
8271 <prgn>dpkg-gencontrol</prgn>, which reads
8272 <file>debian/control</file> and <file>debian/changelog</file> to
8273 find the information it needs. See <ref id="pkg-sourcepkg"> for
8278 The fields in binary package control files are:
8279 <list compact="compact">
8281 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8284 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8286 <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8290 This field should appear in all packages, though
8291 <prgn>dpkg</prgn> doesn't require it yet so that
8292 old packages can still be installed.
8298 <p><qref id="relationships"><tt>Depends</tt>,
8299 <tt>Provides</tt> et al.</qref></p>
8302 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8305 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8308 <p><qref id="pkg-f-classification"><tt>Section</tt>,
8309 <tt>Priority</tt></qref></p>
8312 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8315 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8319 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8325 A description of the syntax of control files and the purpose
8326 of these fields is available in <ref id="pkg-controlfields">.
8331 <heading>Time Stamps</heading>
8333 Maintainers are encouraged to preserve the modification
8334 times of the upstream source files in a package, as far as
8335 is reasonably possible.
8338 The rationale is that there is some information conveyed
8339 by knowing the age of the file, for example, you could
8340 recognize that some documentation is very old by looking
8341 at the modification time, so it would be nice if the
8342 modification time of the upstream source would be
8350 <appendix id="pkg-sourcepkg">
8351 <heading>Source packages (from old Packaging Manual) </heading>
8354 The Debian binary packages in the distribution are generated
8355 from Debian sources, which are in a special format to assist
8356 the easy and automatic building of binaries.
8359 <sect id="pkg-sourcetools">
8360 <heading>Tools for processing source packages</heading>
8363 Various tools are provided for manipulating source packages;
8364 they pack and unpack sources and help build of binary
8365 packages and help manage the distribution of new versions.
8369 They are introduced and typical uses described here; see
8370 <manref name="dpkg-source" section="1"> for full
8371 documentation about their arguments and operation.
8375 For examples of how to construct a Debian source package,
8376 and how to use those utilities that are used by Debian
8377 source packages, please see the <prgn>hello</prgn> example
8383 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8388 This program is frequently used by hand, and is also
8389 called from package-independent automated building scripts
8390 such as <prgn>dpkg-buildpackage</prgn>.
8394 To unpack a package it is typically invoked with
8396 dpkg-source -x <var>.../path/to/filename</var>.dsc
8401 with the <file><var>filename</var>.tar.gz</file> and
8402 <file><var>filename</var>.diff.gz</file> (if applicable) in
8403 the same directory. It unpacks into
8404 <file><var>package</var>-<var>version</var></file>, and if
8406 <file><var>package</var>-<var>version</var>.orig</file>, in
8407 the current directory.
8411 To create a packed source archive it is typically invoked:
8413 dpkg-source -b <var>package</var>-<var>version</var>
8418 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8419 <file>.diff.gz</file> (if appropriate) in the current
8420 directory. <prgn>dpkg-source</prgn> does not clean the
8421 source tree first - this must be done separately if it is
8426 See also <ref id="pkg-sourcearchives">.</p>
8432 <prgn>dpkg-buildpackage</prgn> - overall package-building
8437 <prgn>dpkg-buildpackage</prgn> is a script which invokes
8438 <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8439 targets <tt>clean</tt>, <tt>build</tt> and
8440 <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8441 <prgn>pgp</prgn> to build a signed source and binary
8446 It is usually invoked by hand from the top level of the
8447 built or unbuilt source directory. It may be invoked with
8448 no arguments; useful arguments include:
8449 <taglist compact="compact">
8450 <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8453 Do not PGP-sign the <tt>.changes</tt> file or the
8454 source package <tt>.dsc</tt> file, respectively.</p>
8456 <tag><tt>-p<var>pgp-command</var></tt></tag>
8459 Invoke <var>pgp-command</var> instead of finding
8460 <tt>pgp</tt> on the <prgn>PATH</prgn>.
8461 <var>pgp-command</var> must behave just like
8462 <prgn>pgp</prgn>.</p>
8464 <tag><tt>-r<var>root-command</var></tt></tag>
8467 When root privilege is required, invoke the command
8468 <var>root-command</var>. <var>root-command</var>
8469 should invoke its first argument as a command, from
8470 the <prgn>PATH</prgn> if necessary, and pass its
8471 second and subsequent arguments to the command it
8472 calls. If no <var>root-command</var> is supplied
8473 then <var>dpkg-buildpackage</var> will take no
8474 special action to gain root privilege, so that for
8475 most packages it will have to be invoked as root to
8478 <tag><tt>-b</tt>, <tt>-B</tt></tag>
8481 Two types of binary-only build and upload - see
8482 <manref name="dpkg-source" section="1">.
8491 <prgn>dpkg-gencontrol</prgn> - generates binary package
8496 This program is usually called from <file>debian/rules</file>
8497 (see <ref id="pkg-sourcetree">) in the top level of the source
8502 This is usually done just before the files and directories in the
8503 temporary directory tree where the package is being built have their
8504 permissions and ownerships set and the package is constructed using
8505 <prgn>dpkg-deb/</prgn>
8508 This is so that the control file which is produced has
8509 the right permissions
8515 <prgn>dpkg-gencontrol</prgn> must be called after all the
8516 files which are to go into the package have been placed in
8517 the temporary build directory, so that its calculation of
8518 the installed size of a package is correct.
8522 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8523 be run after <prgn>dpkg-shlibdeps</prgn> so that the
8524 variable substitutions created by
8525 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8530 For a package which generates only one binary package, and
8531 which builds it in <file>debian/tmp</file> relative to the top
8532 of the source package, it is usually sufficient to call
8533 <prgn>dpkg-gencontrol</prgn>.
8537 Sources which build several binaries will typically need
8540 dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8541 </example> The <tt>-P</tt> tells
8542 <prgn>dpkg-gencontrol</prgn> that the package is being
8543 built in a non-default directory, and the <tt>-p</tt>
8544 tells it which package's control file should be generated.
8548 <prgn>dpkg-gencontrol</prgn> also adds information to the
8549 list of files in <file>debian/files</file>, for the benefit of
8550 (for example) a future invocation of
8551 <prgn>dpkg-genchanges</prgn>.</p>
8556 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8561 This program is usually called from <file>debian/rules</file>
8562 just before <prgn>dpkg-gencontrol</prgn> (see <ref
8563 id="pkg-sourcetree">), in the top level of the source tree.
8567 Its arguments are executables.
8570 In a forthcoming dpkg version,
8571 <prgn>dpkg-shlibdeps</prgn> would be required to be
8572 called on shared libraries as well.
8575 They may be specified either in the locations in the
8576 source tree where they are created or in the locations
8577 in the temporary build tree where they are installed
8578 prior to binary package creation.
8580 </footnote> for which shared library dependencies should
8581 be included in the binary package's control file.
8585 If some of the found shared libraries should only
8586 warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8587 some warrant a <tt>Pre-Depends</tt>, this can be achieved
8588 by using the <tt>-d<var>dependency-field</var></tt> option
8589 before those executable(s). (Each <tt>-d</tt> option
8590 takes effect until the next <tt>-d</tt>.)
8594 <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8595 output control file to be modified. Instead by default it
8596 adds to the <file>debian/substvars</file> file variable
8597 settings like <tt>shlibs:Depends</tt>. These variable
8598 settings must be referenced in dependency fields in the
8599 appropriate per-binary-package sections of the source
8604 For example, the <prgn>procps</prgn> package generates two
8605 kinds of binaries, simple C binaries like <prgn>ps</prgn>
8606 which require a predependency and full-screen ncurses
8607 binaries like <prgn>top</prgn> which require only a
8608 recommendation. It can say in its <file>debian/rules</file>:
8610 dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8612 and then in its main control file <file>debian/control</file>:
8616 Pre-Depends: ${shlibs:Pre-Depends}
8617 Recommends: ${shlibs:Recommends}
8623 Sources which produce several binary packages with
8624 different shared library dependency requirements can use
8625 the <tt>-p<var>varnameprefix</var></tt> option to override
8626 the default <tt>shlibs:</tt> prefix (one invocation of
8627 <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8628 They can thus produce several sets of dependency
8629 variables, each of the form
8630 <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8631 which can be referred to in the appropriate parts of the
8632 binary package control files.
8639 <prgn>dpkg-distaddfile</prgn> - adds a file to
8640 <file>debian/files</file>
8644 Some packages' uploads need to include files other than
8645 the source and binary package files.
8649 <prgn>dpkg-distaddfile</prgn> adds a file to the
8650 <file>debian/files</file> file so that it will be included in
8651 the <file>.changes</file> file when
8652 <prgn>dpkg-genchanges</prgn> is run.
8656 It is usually invoked from the <tt>binary</tt> target of
8657 <file>debian/rules</file>:
8659 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8661 The <var>filename</var> is relative to the directory where
8662 <prgn>dpkg-genchanges</prgn> will expect to find it - this
8663 is usually the directory above the top level of the source
8664 tree. The <file>debian/rules</file> target should put the
8665 file there just before or just after calling
8666 <prgn>dpkg-distaddfile</prgn>.
8670 The <var>section</var> and <var>priority</var> are passed
8671 unchanged into the resulting <file>.changes</file> file. See
8672 <ref id="pkg-f-classification">.
8677 <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8682 This program is usually called by package-independent
8683 automatic building scripts such as
8684 <prgn>dpkg-buildpackage</prgn>, but it may also be called
8689 It is usually called in the top level of a built source
8690 tree, and when invoked with no arguments will print out a
8691 straightforward <file>.changes</file> file based on the
8692 information in the source package's changelog and control
8693 file and the binary and source packages which should have
8699 <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8704 This program is used internally by
8705 <prgn>dpkg-source</prgn> et al. It may also occasionally
8706 be useful in <file>debian/rules</file> and elsewhere. It
8707 parses a changelog, <file>debian/changelog</file> by default,
8708 and prints a control-file format representation of the
8709 information in it to standard output.
8713 <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8714 information about the build and host system
8718 This program can be used manually, but is also invoked by
8719 <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8720 to set environment or make variables which specify the build and
8721 host architecture for the package building process.
8726 <sect id="pkg-sourcetree"><heading>The Debianised source tree
8730 The source archive scheme described later is intended to
8731 allow a Debianised source tree with some associated control
8732 information to be reproduced and transported easily. The
8733 Debianised source tree is a version of the original program
8734 with certain files added for the benefit of the
8735 Debianisation process, and with any other changes required
8736 made to the rest of the source code and installation
8741 The extra files created for Debian are in the subdirectory
8742 <file>debian</file> of the top level of the Debianised source
8743 tree. They are described below.
8746 <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8751 This file is an executable makefile, and contains the
8752 package-specific recipies for compiling the package and
8753 building binary package(s) out of the source.
8757 It must start with the line <tt>#!/usr/bin/make -f</tt>,
8758 so that it can be invoked by saying its name rather than
8759 invoking <prgn>make</prgn> explicitly.
8763 Since an interactive <file>debian/rules</file> script makes it
8764 impossible to autocompile that package and also makes it
8765 hard for other people to reproduce the same binary
8766 package, all <strong>required targets</strong> have to be
8767 non-interactive. At a minimul, required targets are the
8768 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8769 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8770 <em>build</em>. It also follows that any target that these
8771 targets depend on must also be non-interactive.
8775 The targets which are required to be present are:
8777 <tag><tt>build</tt></tag>
8780 This should perform all non-interactive
8781 configuration and compilation of the package. If a
8782 package has an interactive pre-build configuration
8783 routine, the Debianised source package should be
8784 built after this has taken place, so that it can be
8785 built without rerunning the configuration.
8789 A package may also provide both of the targets
8790 <tt>build-arch</tt> and <tt>build-indep</tt>. The
8791 <tt>build-arch</tt> target, if provided, should
8792 perform all non-interactive configuration and
8793 compilation required for producing all
8794 architecture-dependant binary packages (those packages
8795 for which the body of the <tt>Architecture</tt> field
8796 in <tt>debian/control</tt> is not <tt>all</tt>).
8797 Similarly, the <tt>build-indep</tt> target, if
8798 provided, should perform all non-interactive
8799 configuration and compilation required for producing
8800 all architecture-independent binary packages (those
8801 packages for which the body of the
8802 <tt>Architecture</tt> field in <tt>debian/control</tt>
8803 is <tt>all</tt>). The <tt>build</tt> target should
8804 depend on those of the targets <tt>build-arch</tt> and
8805 <tt>build-indep</tt> that are provided in the rules
8810 If one or both of the targets <tt>build-arch</tt> and
8811 <tt>build-indep</tt> are not provided, then invoking
8812 <file>debian/rules</file> with one of the not-provided
8813 targets as arguments should produce a exit status code
8814 of 2. Usually this is provided automatically by make
8815 if the target is missing.
8819 For some packages, notably ones where the same
8820 source tree is compiled in different ways to produce
8821 two binary packages, the <tt>build</tt> target does
8822 not make much sense. For these packages it is good
8823 enough to provide two (or more) targets
8824 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8825 for each of the ways of building the package, and a
8826 <tt>build</tt> target that does nothing. The
8827 <tt>binary</tt> target will have to build the
8828 package in each of the possible ways and make the
8829 binary package out of each.
8833 The targets <tt>build</tt>, <tt>build-arch</tt>
8834 and <tt>build-indep</tt> target must not do
8835 anything that might require root privilege.
8839 The <tt>build</tt> target may need to run
8840 <tt>clean</tt> first - see below.
8844 When a package has a configuration routine that takes
8845 a long time, or when the makefiles are poorly
8846 designed, or when <tt>build</tt> needs to run
8847 <tt>clean</tt> first, it is a good idea to <tt>touch
8848 build</tt> when the build process is complete. This
8849 will ensure that if <tt>debian/rules build</tt> is run
8850 again it will not rebuild the whole program.
8854 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8855 <tt>binary-indep</tt>
8859 The <tt>binary</tt> target should be all that is
8860 necessary for the user to build the binary
8861 package. All these targets are required to be
8862 non-interactive. It is split into two parts:
8863 <tt>binary-arch</tt> builds the packages' output
8864 files which are specific to a particular
8865 architecture, and <tt>binary-indep</tt> builds
8866 those which are not.
8870 <tt>binary</tt> should usually be a target with
8871 no commands which simply depends on
8872 <prgn>binary-arch</prgn> and
8873 <prgn>binary-indep</prgn>.
8877 Both <prgn>binary-*</prgn> targets should depend on
8878 the <tt>build</tt> target, above, so that the
8879 package is built if it has not been already. It
8880 should then create the relevant binary package(s),
8881 using <prgn>dpkg-gencontrol</prgn> to make their
8882 control files and <prgn>dpkg-deb</prgn> to build
8883 them and place them in the parent of the top level
8888 If one of the <prgn>binary-*</prgn> targets has
8889 nothing to do (this will be always be the case if
8890 the source generates only a single binary package,
8891 whether architecture-dependent or not) it
8892 <em>must</em> still exist, but should always
8897 <ref id="pkg-binarypkg"> describes how to construct
8902 The <tt>binary</tt> targets must be invoked as
8907 <tag><tt>clean</tt></tag>
8911 This should undo any effects that the
8912 <tt>build</tt> and <tt>binary</tt> targets
8913 may have had, except that it should leave alone any
8914 output files created in the parent directory by a
8915 run of <tt>binary</tt>. This target is required
8916 to be non-interactive.
8920 If a <tt>build</tt> file is touched at the end
8921 of the <tt>build</tt> target, as suggested
8922 above, it must be removed as the first thing that
8923 <tt>clean</tt> does, so that running
8924 <tt>build</tt> again after an interrupted
8925 <tt>clean</tt> doesn't think that everything is
8930 The <tt>clean</tt> target must be invoked as
8931 root if <tt>binary</tt> has been invoked since
8932 the last <tt>clean</tt>, or if
8933 <tt>build</tt> has been invoked as root (since
8934 <tt>build</tt> may create directories, for
8939 <tag><tt>get-orig-source</tt> (optional)</tag>
8943 This target fetches the most recent version of the
8944 original source package from a canonical archive
8945 site (via FTP or WWW, for example), does any
8946 necessary rearrangement to turn it into the original
8947 source tarfile format described below, and leaves it
8948 in the current directory.
8952 This target may be invoked in any directory, and
8953 should take care to clean up any temporary files it
8958 This target is optional, but providing it if
8959 possible is a good idea.
8965 The <tt>build</tt>, <tt>binary</tt> and
8966 <tt>clean</tt> targets must be invoked with a current
8967 directory of the package's top-level directory.
8972 Additional targets may exist in <file>debian/rules</file>,
8973 either as published or undocumented interfaces or for the
8974 package's internal use.
8978 The architecture we build on and build for is determined by make
8979 variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8980 get the Debian architecture and the GNU style architecture
8981 specification string for the build machine as well as the host
8982 machine. Here is a list of supported make variables:
8983 <list compact="compact">
8985 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8988 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8989 specification string)</p>
8992 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8995 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
9001 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
9002 the build machine or <tt>HOST</tt> for specification of the machine
9007 Backward compatibility can be provided in the rules file
9008 by setting the needed variables to suitable default
9009 values, please refer to the documentation of
9010 dpkg-architecture for details.
9014 It is important to understand that the <tt>DEB_*_ARCH</tt>
9015 string does only determine which Debian architecture we
9016 build on resp. for. It should not be used to get the CPU
9017 or System information, the GNU style variables should be
9023 <sect1><heading><file>debian/control</file>
9027 This file contains version-independent details about the
9028 source package and about the binary packages it creates.
9032 It is a series of sets of control fields, each
9033 syntactically similar to a binary package control file.
9034 The sets are separated by one or more blank lines. The
9035 first set is information about the source package in
9036 general; each subsequent set describes one binary package
9037 that the source tree builds.
9041 The syntax and semantics of the fields are described below
9042 in <ref id="pkg-controlfields">.
9046 The general (binary-package-independent) fields are:
9047 <list compact="compact">
9049 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
9052 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9056 <qref id="pkg-f-classification"><tt>Section</tt> and
9057 <tt>Priority</tt></qref>
9058 (classification, mandatory)
9063 <qref id="relationships"><tt>Build-Depends</tt> et
9064 al.</qref> (source package interrelationships)
9069 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
9075 The per-binary-package fields are:
9076 <list compact="compact">
9078 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
9082 <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
9086 <p><qref id="descriptions"><tt>Description</tt></qref></p>
9090 <qref id="pkg-f-classification"><tt>Section</tt> and
9091 <tt>Priority</tt></qref> (classification)</p>
9094 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
9098 <qref id="relationships"><tt>Depends</tt> et
9099 al.</qref> (binary package interrelationships)
9105 These fields are used by <prgn>dpkg-gencontrol</prgn> to
9106 generate control files for binary packages (see below), by
9107 <prgn>dpkg-genchanges</prgn> to generate the
9108 <tt>.changes</tt> file to accompany the upload, and by
9109 <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9110 source control file as part of a source archive.
9114 The fields here may contain variable references - their
9115 values will be substituted by
9116 <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9117 or <prgn>dpkg-source</prgn> when they generate output
9118 control files. See <ref id="pkg-srcsubstvars"> for details.
9121 <p> <sect2><heading>User-defined fields
9125 Additional user-defined fields may be added to the
9126 source package control file. Such fields will be
9127 ignored, and not copied to (for example) binary or
9128 source package control files or upload control files.
9132 If you wish to add additional unsupported fields to
9133 these output files you should use the mechanism
9138 Fields in the main source control information file with
9139 names starting <tt>X</tt>, followed by one or more of
9140 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9141 be copied to the output files. Only the part of the
9142 field name after the hyphen will be used in the output
9143 file. Where the letter <tt>B</tt> is used the field
9144 will appear in binary package control files, where the
9145 letter <tt>S</tt> is used in source package control
9146 files and where <tt>C</tt> is used in upload control
9147 (<tt>.changes</tt>) files.
9151 For example, if the main source information control file
9154 XBS-Comment: I stand between the candle and the star.
9156 then the binary and source package control files will contain the
9159 Comment: I stand between the candle and the star.
9166 <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9170 This file records the changes to the Debian-specific parts of the
9174 Though there is nothing stopping an author who is also
9175 the Debian maintainer from using it for all their
9176 changes, it will have to be renamed if the Debian and
9177 upstream maintainers become different
9184 It has a special format which allows the package building
9185 tools to discover which version of the package is being
9186 built and find out other release-specific information.
9190 That format is a series of entries like this:
9192 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9194 * <var>change details</var>
9195 <var>more change details</var>
9196 * <var>even more change details</var>
9198 -- <var>maintainer name and email address</var> <var>date</var>
9203 <var>package</var> and <var>version</var> are the source
9204 package name and version number.
9208 <var>distribution(s)</var> lists the distributions where
9209 this version should be installed when it is uploaded - it
9210 is copied to the <tt>Distribution</tt> field in the
9211 <tt>.changes</tt> file. See <ref id="pkg-f-Distribution">.
9215 <var>urgency</var> is the value for the <tt>Urgency</tt>
9216 field in the <file>.changes</file> file for the upload. See
9217 <ref id="pkg-f-Urgency">. It is not possible to specify an
9218 urgency containing commas; commas are used to separate
9219 <tt><var>keyword</var>=<var>value</var></tt> settings in
9220 the <prgn>dpkg</prgn> changelog format (though there is
9221 currently only one useful <var>keyword</var>,
9226 The change details may in fact be any series of lines
9227 starting with at least two spaces, but conventionally each
9228 change starts with an asterisk and a separating space and
9229 continuation lines are indented so as to bring them in
9230 line with the start of the text above. Blank lines may be
9231 used here to separate groups of changes, if desired.
9235 The maintainer name and email address should <em>not</em>
9236 necessarily be those of the usual package maintainer.
9237 They should be the details of the person doing
9238 <em>this</em> version. The information here will be
9239 copied to the <file>.changes</file> file, and then later used
9240 to send an acknowledgement when the upload has been
9245 The <var>date</var> should be in RFC822 format
9248 This is generated by the <prgn>822-date</prgn>
9251 </footnote>; it should include the timezone specified
9252 numerically, with the timezone name or abbreviation
9253 optionally present as a comment.
9257 The first "title" line with the package name should start
9258 at the left hand margin; the "trailer" line with the
9259 maintainer and date details should be preceded by exactly
9260 one space. The maintainer details and the date must be
9261 separated by exactly two spaces.
9265 An Emacs mode for editing this format is available: it is
9266 called <tt>debian-changelog-mode</tt>. You can have this
9267 mode selected automatically when you edit a Debian
9268 changelog by adding a local variables clause to the end of
9272 <sect2><heading>Defining alternative changelog formats
9276 It is possible to use a different format to the standard
9277 one, by providing a parser for the format you wish to
9282 In order to have <tt>dpkg-parsechangelog</tt> run your
9283 parser, you must include a line within the last 40 lines
9284 of your file matching the Perl regular expression:
9285 <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9286 parentheses should be the name of the format. For
9287 example, you might say:
9289 @@@ changelog-format: joebloggs @@@
9291 Changelog format names are non-empty strings of alphanumerics.
9295 If such a line exists then <tt>dpkg-parsechangelog</tt>
9296 will look for the parser as
9297 <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9299 <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9300 it is an error for it not to find it, or for it not to
9301 be an executable program. The default changelog format
9302 is <tt>dpkg</tt>, and a parser for it is provided with
9303 the <tt>dpkg</tt> package.
9307 The parser will be invoked with the changelog open on
9308 standard input at the start of the file. It should read
9309 the file (it may seek if it wishes) to determine the
9310 information required and return the parsed information
9311 to standard output in the form of a series of control
9312 fields in the standard format. By default it should
9313 return information about only the most recent version in
9314 the changelog; it should accept a
9315 <tt>-v<var>version</var></tt> option to return changes
9316 information from all versions present <em>strictly
9317 after</em> <var>version</var>, and it should then be an
9318 error for <var>version</var> not to be present in the
9324 <list compact="compact">
9326 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9329 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9333 <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9338 <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9342 <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9347 <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9351 <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9358 If several versions are being returned (due to the use
9359 of <tt>-v</tt>), the urgency value should be of the
9360 highest urgency code listed at the start of any of the
9361 versions requested followed by the concatenated
9362 (space-separated) comments from all the versions
9363 requested; the maintainer, version, distribution and
9364 date should always be from the most recent version.
9368 For the format of the <tt>Changes</tt> field see <ref
9369 id="pkg-f-Changes">.
9373 If the changelog format which is being parsed always or
9374 almost always leaves a blank line between individual
9375 change notes these blank lines should be stripped out,
9376 so as to make the resulting output compact.
9380 If the changelog format does not contain date or package
9381 name information this information should be omitted from
9382 the output. The parser should not attempt to synthesise
9383 it or find it from other sources.
9387 If the changelog does not have the expected format the
9388 parser should exit with a nonzero exit status, rather
9389 than trying to muddle through and possibly generating
9394 A changelog parser may not interact with the user at
9398 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
9400 <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9401 and variable substitutions
9405 When <prgn>dpkg-gencontrol</prgn>,
9406 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9407 generate control files they do variable substitutions on
9408 their output just before writing it. Variable
9409 substitutions have the form
9410 <tt>${<var>variable-name</var>}</tt>. The optional file
9411 <file>debian/substvars</file> contains variable substitutions
9412 to be used; variables can also be set directly from
9413 <file>debian/rules</file> using the <tt>-V</tt> option to the
9414 source packaging commands, and certain predefined
9415 variables are available.
9419 This file is usually generated and modified dynamically by
9420 <file>debian/rules</file> targets, in which case it must be
9421 removed by the <tt>clean</tt> target.
9425 See <manref name="dpkg-source" section="1"> for full
9426 details about source variable substitutions, including the
9427 format of <file>debian/substvars</file>.</p>
9430 <sect1><heading><file>debian/files</file>
9434 This file is not a permanent part of the source tree; it
9435 is used while building packages to record which files are
9436 being generated. <prgn>dpkg-genchanges</prgn> uses it
9437 when it generates a <file>.changes</file> file.
9441 It should not exist in a shipped source package, and so it
9442 (and any backup files or temporary files such as
9443 <file>files.new</file>
9446 <file>files.new</file> is used as a temporary file by
9447 <prgn>dpkg-gencontrol</prgn> and
9448 <prgn>dpkg-distaddfile</prgn> - they write a new
9449 version of <file>files</file> here before renaming it,
9450 to avoid leaving a corrupted copy if an error
9453 </footnote>) should be removed by the
9454 <tt>clean</tt> target. It may also be wise to
9455 ensure a fresh start by emptying or removing it at the
9456 start of the <tt>binary</tt> target.
9460 <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9461 for the <file>.deb</file> file that will be created by
9462 <prgn>dpkg-deb</prgn> from the control file that it
9463 generates, so for most packages all that needs to be done
9464 with this file is to delete it in <tt>clean</tt>.
9468 If a package upload includes files besides the source
9469 package and any binary packages whose control files were
9470 made with <prgn>dpkg-gencontrol</prgn> then they should be
9471 placed in the parent of the package's top-level directory
9472 and <prgn>dpkg-distaddfile</prgn> should be called to add
9473 the file to the list in <file>debian/files</file>.</p>
9476 <sect1><heading><file>debian/tmp</file>
9480 This is the canonical temporary location for the
9481 construction of binary packages by the <tt>binary</tt>
9482 target. The directory <file>tmp</file> serves as the root of
9483 the filesystem tree as it is being constructed (for
9484 example, by using the package's upstream makefiles install
9485 targets and redirecting the output there), and it also
9486 contains the <tt>DEBIAN</tt> subdirectory. See <ref
9487 id="pkg-bincreating">.
9491 If several binary packages are generated from the same
9492 source tree it is usual to use several
9493 <file>debian/tmp<var>something</var></file> directories, for
9494 example <file>tmp-a</file> or <file>tmp-doc</file>.
9498 Whatever <file>tmp</file> directories are created and used by
9499 <tt>binary</tt> must of course be removed by the
9500 <tt>clean</tt> target.</p></sect1>
9504 <sect id="pkg-sourcearchives"><heading>Source packages as archives
9508 As it exists on the FTP site, a Debian source package
9509 consists of three related files. You must have the right
9510 versions of all three to be able to use them.
9515 <tag>Debian source control file - <tt>.dsc</tt></tag>
9519 This file contains a series of fields, identified and
9520 separated just like the fields in the control file of
9521 a binary package. The fields are listed below; their
9522 syntax is described above, in <ref id="pkg-controlfields">.
9523 <list compact="compact">
9525 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9528 <p><qref id="versions"><tt>Version</tt></qref></p>
9531 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9534 <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9537 <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9541 <qref id="relationships"><tt>Build-Depends</tt> et
9542 al.</qref> (source package interrelationships)
9547 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9550 <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9555 The source package control file is generated by
9556 <prgn>dpkg-source</prgn> when it builds the source
9557 archive, from other files in the source package,
9558 described above. When unpacking it is checked against
9559 the files and directories in the other parts of the
9560 source package, as described below.</p>
9564 Original source archive -
9566 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9573 This is a compressed (with <tt>gzip -9</tt>)
9574 <prgn>tar</prgn> file containing the source code from
9575 the upstream authors of the program. The tarfile
9576 unpacks into a directory
9577 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9578 and does not contain files anywhere other than in
9579 there or in its subdirectories.</p>
9583 Debianisation diff -
9585 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9591 This is a unified context diff (<tt>diff -u</tt>)
9592 giving the changes which are required to turn the
9593 original source into the Debian source. These changes
9594 may only include editing and creating plain files.
9595 The permissions of files, the targets of symbolic
9596 links and the characteristics of special files or
9597 pipes may not be changed and no files may be removed
9602 All the directories in the diff must exist, except the
9603 <file>debian</file> subdirectory of the top of the source
9604 tree, which will be created by
9605 <prgn>dpkg-source</prgn> if necessary when unpacking.
9609 The <prgn>dpkg-source</prgn> program will
9610 automatically make the <file>debian/rules</file> file
9611 executable (see below).</p></item>
9616 If there is no original source code - for example, if the
9617 package is specially prepared for Debian or the Debian
9618 maintainer is the same as the upstream maintainer - the
9619 format is slightly different: then there is no diff, and the
9621 <file><var>package</var>_<var>version</var>.tar.gz</file> and
9622 contains a directory
9623 <file><var>package</var>-<var>version</var></file>.
9627 <sect><heading>Unpacking a Debian source package without
9628 <prgn>dpkg-source</prgn>
9632 <tt>dpkg-source -x</tt> is the recommended way to unpack a
9633 Debian source package. However, if it is not available it
9634 is possible to unpack a Debian source archive as follows:
9635 <enumlist compact="compact">
9638 Untar the tarfile, which will create a <file>.orig</file>
9642 <p>Rename the <file>.orig</file> directory to
9643 <file><var>package</var>-<var>version</var></file>.</p>
9647 Create the subdirectory <file>debian</file> at the top of
9648 the source tree.</p>
9650 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9652 <item><p>Untar the tarfile again if you want a copy of the original
9653 source code alongside the Debianised version.</p>
9658 It is not possible to generate a valid Debian source archive
9659 without using <prgn>dpkg-source</prgn>. In particular,
9660 attempting to use <prgn>diff</prgn> directly to generate the
9661 <file>.diff.gz</file> file will not work.
9664 <sect1><heading>Restrictions on objects in source packages
9668 The source package may not contain any hard links
9671 This is not currently detected when building source
9672 packages, but only when extracting
9678 Hard links may be permitted at some point in the
9679 future, but would require a fair amount of
9682 </footnote>, device special files, sockets or setuid or
9686 Setgid directories are allowed.
9692 The source packaging tools manage the changes between the
9693 original and Debianised source using <prgn>diff</prgn> and
9694 <prgn>patch</prgn>. Turning the original source tree as
9695 included in the <file>.orig.tar.gz</file> into the debianised
9696 source must not involve any changes which cannot be
9697 handled by these tools. Problematic changes which cause
9698 <prgn>dpkg-source</prgn> to halt with an error when
9699 building the source package are:
9700 <list compact="compact">
9701 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9703 <item><p>Changing the targets of symbolic links.</p>
9705 <item><p>Creating directories, other than <file>debian</file>.</p>
9707 <item><p>Changes to the contents of binary files.</p></item>
9708 </list> Changes which cause <prgn>dpkg-source</prgn> to
9709 print a warning but continue anyway are:
9710 <list compact="compact">
9713 Removing files, directories or symlinks.
9716 Renaming a file is not treated specially - it is
9717 seen as the removal of the old file (which
9718 generates a warning, but is otherwise ignored),
9719 and the creation of the new
9726 Changed text files which are missing the usual final
9727 newline (either in the original or the modified
9732 Changes which are not represented, but which are not detected by
9733 <prgn>dpkg-source</prgn>, are:
9734 <list compact="compact">
9735 <item><p>Changing the permissions of files (other than
9736 <file>debian/rules</file>) and directories.</p></item>
9741 The <file>debian</file> directory and <file>debian/rules</file>
9742 are handled specially by <prgn>dpkg-source</prgn> - before
9743 applying the changes it will create the <file>debian</file>
9744 directory, and afterwards it will make
9745 <file>debian/rules</file> world-exectuable.
9751 <appendix id="pkg-controlfields"><heading>Control files and their
9752 fields (from old Packaging Manual)
9756 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9757 data in a common format, known as control files. Binary and
9758 source packages have control data as do the <file>.changes</file>
9759 files which control the installation of uploaded files, and
9760 <prgn>dpkg</prgn>'s internal databases are in a similar
9764 <sect><heading>Syntax of control files
9768 A file consists of one or more paragraphs of fields. The
9769 paragraphs are separated by blank lines. Some control files
9770 only allow one paragraph; others allow several, in which
9771 case each paragraph often refers to a different package.
9775 Each paragraph is a series of fields and values; each field
9776 consists of a name, followed by a colon and the value. It
9777 ends at the end of the line. Horizontal whitespace (spaces
9778 and tabs) may occur before or after the value and is ignored
9779 there; it is conventional to put a single space after the
9784 Some fields' values may span several lines; in this case
9785 each continuation line <em>must</em> start with a space or
9786 tab. Any trailing spaces or tabs at the end of individual
9787 lines of a field value are ignored.
9791 Except where otherwise stated only a single line of data is
9792 allowed and whitespace is not significant in a field body.
9793 Whitespace may never appear inside names (of packages,
9794 architectures, files or anything else), version numbers or
9795 in between the characters of multi-character version
9800 Field names are not case-sensitive, but it is usual to
9801 capitalise the field names using mixed case as shown below.
9805 Blank lines, or lines consisting only of spaces and tabs,
9806 are not allowed within field values or between fields - that
9807 would mean a new paragraph.
9811 It is important to note that there are several fields which
9812 are optional as far as <prgn>dpkg</prgn> and the related
9813 tools are concerned, but which must appear in every Debian
9814 package, or whose omission may cause problems.
9818 <sect><heading>List of fields
9821 <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9825 The name of the binary package. Package names consist of
9826 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9827 (plus, minus and full stop).
9830 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9831 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9832 and underscore) used to be legal and are still
9833 accepted when found in a package file, but may not be
9834 used in new packages
9840 They must be at least two characters and must start with
9841 an alphanumeric. In current versions of dpkg they are
9842 sort of case-sensitive<footnote><p>This is a
9843 bug.</p></footnote>; use lowercase package names unless
9844 the package you're building (or referring to, in other
9845 fields) is already using uppercase.</p>
9848 <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9852 This lists the source or binary package's version number -
9853 see <ref id="versions">.
9858 <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9862 This is the architecture string; it is a single word for
9863 the Debian architecture.
9867 <prgn>dpkg</prgn> will check the declared architecture of
9868 a binary package against its own compiled-in value before
9873 The special value <tt>all</tt> indicates that the package
9874 is architecture-independent.
9878 In the main <file>debian/control</file> file in the source
9879 package, or in the source package control file
9880 <file>.dsc</file>, a list of architectures (separated by
9881 spaces) is also allowed, as is the special value
9882 <tt>any</tt>. A list indicates that the source will build
9883 an architecture-dependent package, and will only work
9884 correctly on the listed architectures. <tt>any</tt>
9885 indicates that though the source package isn't dependent
9886 on any particular architecture and should compile fine on
9887 any one, the binary package(s) produced are not
9888 architecture-independent but will instead be specific to
9889 whatever the current build architecture is.
9893 In a <file>.changes</file> file the <tt>Architecture</tt>
9894 field lists the architecture(s) of the package(s)
9895 currently being uploaded. This will be a list; if the
9896 source for the package is being uploaded too the special
9897 entry <tt>source</tt> is also present.
9901 See <ref id="pkg-debianrules"> for information how to get the
9902 architecture for the build process.
9906 <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9910 The package maintainer's name and email address. The name
9911 should come first, then the email address inside angle
9912 brackets <tt><></tt> (in RFC822 format).
9916 If the maintainer's name contains a full stop then the
9917 whole field will not work directly as an email address due
9918 to a misfeature in the syntax specified in RFC822; a
9919 program using this field as an address must check for this
9920 and correct the problem if necessary (for example by
9921 putting the name in round brackets and moving it to the
9922 end, and bringing the email address forward).
9926 In a <file>.changes</file> file or parsed changelog data this
9927 contains the name and email address of the person
9928 responsible for the particular version in question - this
9929 may not be the package's usual maintainer.
9933 This field is usually optional in as far as the
9934 <prgn>dpkg</prgn> are concerned, but its absence when
9935 building packages usually generates a warning.</p>
9938 <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9942 This field identifies the source package name.
9946 In a main source control information or a
9947 <file>.changes</file> or <file>.dsc</file> file or parsed
9948 changelog data this may contain only the name of the
9953 In the control file of a binary package (or in a
9954 <file>Packages</file> file) it may be followed by a version
9955 number in parentheses.
9958 It is usual to leave a space after the package name if
9959 a version number is specified.
9961 </footnote> This version number may be omitted (and is, by
9962 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9963 the <tt>Version</tt> field of the binary package in
9964 question. The field itself may be omitted from a binary
9965 package control file when the source package has the same
9966 name and version as the binary package.
9970 <sect1><heading>Package interrelationship fields:
9971 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9972 <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9973 <tt>Provides</tt>, <tt>Replaces</tt>
9977 These fields describe the package's relationships with
9978 other packages. Their syntax and semantics are described
9979 in <ref id="relationships">.</p>
9982 <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9986 In a binary package <tt>Packages</tt> file or main source
9987 control file this field contains a description of the
9988 binary package, in a special format. See <ref
9989 id="descriptions"> for details.
9993 In a <file>.changes</file> file it contains a summary of the
9994 descriptions for the packages being uploaded. The part of
9995 the field before the first newline is empty; thereafter
9996 each line has the name of a binary package and the summary
9997 description line from that binary package. Each line is
9998 indented by one space.</p>
10001 <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
10005 This is a boolean field which may occur only in the
10006 control file of a binary package (or in the
10007 <file>Packages</file> file) or in a per-package fields
10008 paragraph of a main source control data file.
10012 If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
10013 <prgn>dselect</prgn> will refuse to remove the package
10014 (though it can be upgraded and/or replaced). The other
10015 possible value is <tt>no</tt>, which is the same as not
10016 having the field at all.</p>
10019 <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
10024 These two fields classify the package. The
10025 <tt>Priority</tt> represents how important that it is that
10026 the user have it installed; the <tt>Section</tt>
10027 represents an application area into which the package has
10032 When they appear in the <file>debian/control</file> file these
10033 fields give values for the section and priority subfields
10034 of the <tt>Files</tt> field of the <file>.changes</file> file,
10035 and give defaults for the section and priority of the
10040 The section and priority are represented, though not as
10041 separate fields, in the information for each file in the
10042 <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
10043 <file>.changes</file> file. The section value in a
10044 <file>.changes</file> file is used to decide where to install
10045 a package in the FTP archive.
10049 These fields are not used by by <prgn>dpkg</prgn> proper,
10050 but by <prgn>dselect</prgn> when it sorts packages and
10055 These fields can appear in binary package control files,
10056 in which case they provide a default value in case the
10057 <file>Packages</file> files are missing the information.
10058 <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
10059 the value from a <file>.deb</file> file if they have no other
10060 information; a value listed in a <file>Packages</file> file
10061 will always take precedence. By default
10062 <prgn>dpkg-gencontrol</prgn> does not include the section
10063 and priority in the control file of a binary package - use
10064 the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
10065 achieve this effect.</p>
10068 <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
10072 This field is a list of binary packages.
10076 When it appears in the <file>.dsc</file> file it is the list
10077 of binary packages which a source package can produce. It
10078 does not necessarily produce all of these binary packages
10079 for every architecture. The source control file doesn't
10080 contain details of which architectures are appropriate for
10081 which of the binary packages.
10085 When it appears in a <file>.changes</file> file it lists the
10086 names of the binary packages actually being uploaded.
10090 The syntax is a list of binary packages separated by
10094 A space after each comma is conventional.
10096 </footnote> Currently the packages must be separated using
10097 only spaces in the <file>.changes</file> file.</p>
10100 <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10104 This field appears in the control files of binary
10105 packages, and in the <file>Packages</file> files. It gives
10106 the total amount of disk space required to install the
10111 The disk space is represented in kilobytes as a simple
10112 decimal number.</p>
10115 <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10119 This field contains a list of files with information about
10120 each one. The exact information and syntax varies with
10121 the context. In all cases the part of the field
10122 contents on the same line as the field name is empty. The
10123 remainder of the field is one line per file, each line
10124 being indented by one space and containing a number of
10125 sub-fields separated by spaces.
10129 In the <file>.dsc</file> (Debian source control) file each
10130 line contains the MD5 checksum, size and filename of the
10131 tarfile and (if applicable) diff file which make up the
10132 remainder of the source package.
10135 That is, the parts which are not the
10138 </footnote> The exact forms of the filenames are described
10139 in <ref id="pkg-sourcearchives">.
10143 In the <file>.changes</file> file this contains one line per
10144 file being uploaded. Each line contains the MD5 checksum,
10145 size, section and priority and the filename. The section
10146 and priority are the values of the corresponding fields in
10147 the main source control file - see <ref
10148 id="pkg-f-classification">. If no section or priority is
10149 specified then <tt>-</tt> should be used, though section
10150 and priority values must be specified for new packages to
10151 be installed properly.
10155 The special value <tt>byhand</tt> for the section in a
10156 <tt>.changes</tt> file indicates that the file in question
10157 is not an ordinary package file and must by installed by
10158 hand by the distribution maintainers. If the section is
10159 <tt>byhand</tt> the priority should be <tt>-</tt>.
10163 If a new Debian revision of a package is being shipped and
10164 no new original source archive is being distributed the
10165 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10166 entry for the original source archive
10167 <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10168 but the <file>.changes</file> file should leave it out. In
10169 this case the original source archive on the distribution
10170 site must match exactly, byte-for-byte, the original
10171 source archive which was used to generate the
10172 <file>.dsc</file> file and diff which are being uploaded.</p>
10177 id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10181 The most recent version of the standards (the Debian Policy
10182 and associated texts) with which the package complies. This
10183 is updated manually when editing the source package to
10184 conform to newer standards; it can sometimes be used to
10185 tell when a package needs attention.
10189 Its format is the same as that of a version number except
10190 that no epoch or Debian revision is allowed - see <ref
10191 id="versions">.</p>
10195 <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10199 In a <file>.changes</file> file or parsed changelog output
10200 this contains the (space-separated) name(s) of the
10201 distribution(s) where this version of the package should
10202 be or was installed. Distribution names follow the rules
10203 for package names. (See <ref id="pkg-f-Package">).
10207 Current distribution values are:
10209 <tag><em>stable</em></tag>
10212 This is the current "released" version of Debian
10213 GNU/Linux. A new version is released approximately
10214 every 3 months after the <em>development</em> code has
10215 been <em>frozen</em> for a month of testing. Once the
10216 distribution is <em>stable</em> only major bug fixes
10217 are allowed. When changes are made to this
10218 distribution, the release number is increased
10219 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10223 <tag><em>unstable</em></tag>
10226 This distribution value refers to the
10227 <em>developmental</em> part of the Debian distribution
10228 tree. New packages, new upstream versions of packages
10229 and bug fixes go into the <em>unstable</em> directory
10230 tree. Download from this distribution at your own
10234 <tag><em>contrib</em></tag>
10237 The packages with this distribution value do not meet
10238 the criteria for inclusion in the main Debian
10239 distribution as defined by the Policy Manual, but meet
10240 the criteria for the <em>contrib</em>
10241 Distribution. There is currently no distinction
10242 between stable and unstable packages in the
10243 <em>contrib</em> or <em>non-free</em>
10244 distributions. Use your best judgement in downloading
10245 from this Distribution.</p>
10248 <tag><em>non-free</em></tag>
10251 Like the packages in the <em>contrib</em> seciton,
10252 the packages in <em>non-free</em> do not meet the
10253 criteria for inclusion in the main Debian distribution
10254 as defined by the Policy Manual. Again, use your best
10255 judgement in downloading from this Distribution.</p>
10257 <tag><em>experimental</em></tag>
10260 The packages with this distribution value are deemed
10261 by their maintainers to be high risk. Oftentimes they
10262 represent early beta or developmental packages from
10263 various sources that the maintainers want people to
10264 try, but are not ready to be a part of the other parts
10265 of the Debian distribution tree. Download at your own
10269 <tag><em>frozen</em></tag>
10272 From time to time, (currently, every 3 months) the
10273 <em>unstable</em> distribution enters a state of
10274 "code-freeze" in anticipation of release as a
10275 <em>stable</em> version. During this period of testing
10276 (usually 4 weeks) only fixes for existing or
10277 newly-discovered bugs will be allowed.
10280 </taglist> You should list <em>all</em> distributions that
10281 the package should be installed into. Except in unusual
10282 circumstances, installations to <em>stable</em> should also
10283 go into <em>frozen</em> (if it exists) and
10284 <em>unstable</em>. Likewise, installations into
10285 <em>frozen</em> should also go into <em>unstable</em>.</p>
10288 <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10292 This is a description of how important it is to upgrade to
10293 this version from previous ones. It consists of a single
10294 keyword usually taking one of the values <tt>LOW</tt>,
10295 <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10296 commentary (separated by a space) which is usually in
10297 parentheses. For example:
10299 Urgency: LOW (HIGH for diversions users)
10304 This field appears in the <file>.changes</file> file and in
10305 parsed changelogs; its value appears as the value of the
10306 <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10307 changelog (see <ref id="pkg-dpkgchangelog">).
10311 Urgency keywords are not case-sensitive.</p>
10314 <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10318 In <tt>.changes</tt> files and parsed changelogs, this
10319 gives the date the package was built or last edited.</p>
10322 <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10326 This field occurs in <file>.changes</file> files, and
10327 specifies a format revision for the file. The format
10328 described here is version <tt>1.5</tt>. The syntax of the
10329 format value is the same as that of a package version
10330 number except that no epoch or Debian revision is allowed
10331 - see <ref id="versions">.</p>
10334 <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10338 In a <file>.changes</file> file or parsed changelog this field
10339 contains the human-readable changes data, describing the
10340 differences between the last version and the current one.
10344 There should be nothing in this field before the first
10345 newline; all the subsequent lines must be indented by at
10346 least one space; blank lines must be represented by a line
10347 consiting only of a space and a full stop.
10351 Each version's change information should be preceded by a
10352 "title" line giving at least the version, distribution(s)
10353 and urgency, in a human-readable way.
10357 If data from several versions is being returned the entry
10358 for the most recent version should be returned first, and
10359 entries should be separated by the representation of a
10360 blank line (the "title" line may also be followed by the
10361 representation of blank line).</p>
10364 <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10365 <tt>MSDOS-Filename</tt>
10369 These fields in <tt>Packages</tt> files give the
10370 filename(s) of (the parts of) a package in the
10371 distribution directories, relative to the root of the
10372 Debian hierarchy. If the package has been split into
10373 several parts the parts are all listed in order, separated
10377 <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10381 These fields in <file>Packages</file> files give the size (in
10382 bytes, expressed in decimal) and MD5 checksum of the
10383 file(s) which make(s) up a binary package in the
10384 distribution. If the package is split into several parts
10385 the values for the parts are listed in order, separated by
10389 <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10393 This field in <prgn>dpkg</prgn>'s status file records
10394 whether the user wants a package installed, removed or
10395 left alone, whether it is broken (requiring
10396 reinstallation) or not and what its current state on the
10397 system is. Each of these pieces of information is a
10401 <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10405 If a package is not installed or not configured, this
10406 field in <prgn>dpkg</prgn>'s status file records the last
10407 version of the package which was successfully
10411 <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10415 This field in <prgn>dpkg</prgn>'s status file contains
10416 information about the automatically-managed configuration
10417 files held by a package. This field should <em>not</em>
10418 appear anywhere in a package!</p>
10421 <sect1><heading>Obsolete fields
10425 These are still recognised by <prgn>dpkg</prgn> but should
10426 not appear anywhere any more.
10427 <taglist compact="compact">
10429 <tag><tt>Revision</tt></tag>
10430 <tag><tt>Package-Revision</tt></tag>
10431 <tag><tt>Package_Revision</tt></tag>
10434 The Debian revision part of the package version was
10435 at one point in a separate control file field. This
10436 field went through several names.</p>
10439 <tag><tt>Recommended</tt></tag>
10440 <item><p>Old name for <tt>Recommends</tt></p>
10443 <tag><tt>Optional</tt></tag>
10444 <item><p>Old name for <tt>Suggests</tt>.</p>
10446 <tag><tt>Class</tt></tag>
10447 <item><p>Old name for <tt>Priority</tt>.</p>
10455 <appendix id="pkg-conffiles"><heading>Configuration file handling
10456 (from old Packaging Manual)
10460 <prgn>dpkg</prgn> can do a certain amount of automatic
10461 handling of package configuration files.
10465 Whether this mechanism is appropriate depends on a number of
10466 factors, but basically there are two approaches to any
10467 particular configuration file.
10471 The easy method is to ship a best-effort configuration in the
10472 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10473 handle updates. If the user is unlikely to want to edit the
10474 file, but you need them to be able to without losing their
10475 changes, and a new package with a changed version of the file
10476 is only released infrequently, this is a good approach.
10480 The hard method is to build the configuration file from
10481 scratch in the <prgn>postinst</prgn> script, and to take the
10482 responsibility for fixing any mistakes made in earlier
10483 versions of the package automatically. This will be
10484 appropriate if the file is likely to need to be different on
10488 <sect><heading>Automatic handling of configuration files by
10493 A package may contain a control area file called
10494 <tt>conffiles</tt>. This file should be a list of filenames
10495 of configuration files needing automatic handling, separated
10496 by newlines. The filenames should be absolute pathnames,
10497 and the files referred to should actually exist in the
10502 When a package is upgraded <prgn>dpkg</prgn> will process
10503 the configuration files during the configuration stage,
10504 shortly before it runs the package's <prgn>postinst</prgn>
10509 For each file it checks to see whether the version of the
10510 file included in the package is the same as the one that was
10511 included in the last version of the package (the one that is
10512 being upgraded from); it also compares the version currently
10513 installed on the system with the one shipped with the last
10518 If neither the user nor the package maintainer has changed
10519 the file, it is left alone. If one or the other has changed
10520 their version, then the changed version is preferred - i.e.,
10521 if the user edits their file, but the package maintainer
10522 doesn't ship a different version, the user's changes will
10523 stay, silently, but if the maintainer ships a new version
10524 and the user hasn't edited it the new version will be
10525 installed (with an informative message). If both have
10526 changed their version the user is prompted about the problem
10527 and must resolve the differences themselves.
10531 The comparisons are done by calculating the MD5 message
10532 digests of the files, and storing the MD5 of the file as it
10533 was included in the most recent version of the package.
10537 When a package is installed for the first time
10538 <prgn>dpkg</prgn> will install the file that comes with it,
10539 unless that would mean overwriting a file already on the
10544 However, note that <prgn>dpkg</prgn> will <em>not</em>
10545 replace a conffile that was removed by the user (or by a
10546 script). This is necessary because with some programs a
10547 missing file produces an effect hard or impossible to
10548 achieve in another way, so that a missing file needs to be
10549 kept that way if the user did it.
10553 Note that a package should <em>not</em> modify a
10554 <prgn>dpkg</prgn>-handled conffile in its maintainer
10555 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
10556 the user confusing and possibly dangerous options for
10557 conffile update when the package is upgraded.</p>
10560 <sect><heading>Fully-featured maintainer script configuration
10565 For files which contain site-specific information such as
10566 the hostname and networking details and so forth, it is
10567 better to create the file in the package's
10568 <prgn>postinst</prgn> script.
10572 This will typically involve examining the state of the rest
10573 of the system to determine values and other information, and
10574 may involve prompting the user for some information which
10575 can't be obtained some other way.
10579 When using this method there are a couple of important
10580 issues which should be considered:
10584 If you discover a bug in the program which generates the
10585 configuration file, or if the format of the file changes
10586 from one version to the next, you will have to arrange for
10587 the postinst script to do something sensible - usually this
10588 will mean editing the installed configuration file to remove
10589 the problem or change the syntax. You will have to do this
10590 very carefully, since the user may have changed the file,
10591 perhaps to fix the very problem that your script is trying
10592 to deal with - you will have to detect these situations and
10593 deal with them correctly.
10597 If you do go down this route it's probably a good idea to
10598 make the program that generates the configuration file(s) a
10599 separate program in <file>/usr/sbin</file>, by convention called
10600 <file><var>package</var>config</file> and then run that if
10601 appropriate from the post-installation script. The
10602 <tt><var>package</var>config</tt> program should not
10603 unquestioningly overwrite an existing configuration - if its
10604 mode of operation is geared towards setting up a package for
10605 the first time (rather than any arbitrary reconfiguration
10606 later) you should have it check whether the configuration
10607 already exists, and require a <tt>--force</tt> flag to
10608 overwrite it.</p></sect>
10611 <appendix id="pkg-alternatives"><heading>Alternative versions of
10612 an interface - <prgn>update-alternatives</prgn> (from old
10617 When several packages all provide different versions of the
10618 same program or file it is useful to have the system select a
10619 default, but to allow the system administrator to change it
10620 and have their decisions respected.
10624 For example, there are several versions of the <prgn>vi</prgn>
10625 editor, and there is no reason to prevent all of them from
10626 being installed at once, each under their own name
10627 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10628 Nevertheless it is desirable to have the name <tt>vi</tt>
10629 refer to something, at least by default.
10633 If all the packages involved cooperate, this can be done with
10634 <prgn>update-alternatives</prgn>.
10638 Each package provides its own version under its own name, and
10639 calls <prgn>update-alternatives</prgn> in its postinst to
10640 register its version (and again in its prerm to deregister
10645 See the manpage <manref name="update-alternatives"
10646 section="8"> for details.
10650 If <prgn>update-alternatives</prgn> does not seem appropriate
10651 you may wish to consider using diversions instead.</p>
10654 <appendix id="pkg-diversions"><heading>Diversions - overriding a
10655 package's version of a file (from old Packaging Manual)
10659 It is possible to have <prgn>dpkg</prgn> not overwrite a file
10660 when it reinstalls the package it belongs to, and to have it
10661 put the file from the package somewhere else instead.
10665 This can be used locally to override a package's version of a
10666 file, or by one package to override another's version (or
10667 provide a wrapper for it).
10671 Before deciding to use a diversion, read <ref
10672 id="pkg-alternatives"> to see if you really want a diversion
10673 rather than several alternative versions of a program.
10677 There is a diversion list, which is read by <prgn>dpkg</prgn>,
10678 and updated by a special program <prgn>dpkg-divert</prgn>.
10679 Please see <manref name="dpkg-divert" section="8"> for full
10680 details of its operation.
10684 When a package wishes to divert a file from another, it should
10685 call <prgn>dpkg-divert</prgn> in its preinst to add the
10686 diversion and rename the existing file. For example,
10687 supposing that a <prgn>smailwrapper</prgn> package wishes to
10688 install a wrapper around <file>/usr/sbin/smail</file>:
10690 if [ install = "$1" ]; then
10691 dpkg-divert --package smailwrapper --add --rename \
10692 --divert /usr/sbin/smail.real /usr/sbin/smail
10694 </example> Testing <tt>$1</tt> is necessary so that the script
10695 doesn't try to add the diversion again when
10696 <prgn>smailwrapper</prgn> is upgraded. The <tt>--package
10697 smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10698 copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10699 get installed as the true version.
10703 The postrm has to do the reverse:
10705 if [ remove = "$1" ]; then
10706 dpkg-divert --package smailwrapper --remove --rename \
10707 --divert /usr/sbin/smail.real /usr/sbin/smail
10713 Do not attempt to divert a file which is vitally important for
10714 the system's operation - when using <prgn>dpkg-divert</prgn>
10715 there is a time, after it has been diverted but before
10716 <prgn>dpkg</prgn> has installed the new version, when the file
10717 does not exist.</p>
10722 <!-- vim:set ai et sts=2 sw=2 tw=76: -->