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;
8 Debian GNU/Linux Policy Manual.
9 Copyright (C)1996,1997,1998 Ian Jackson and Christian Schwarz;
10 released under the terms of the GNU
11 General Public License, version 2 or (at your option) any later.
12 Initial version 1996, Ian Jackson, ijackson@gnu.ai.mit.edu
13 Revised November 27, 1996, David A. Morris, bweaver@debian.org
14 New sections March 15, 1997, Christian Schwarz, schwarz@debian.org
15 Reworked/Restructured April-July 1997, Christian Schwarz, schwarz@debian.org
16 Maintainer since 1997, Christian Schwarz, schwarz@debian.org
17 Christoph Lameter contributed the "Web Standard"
18 The debian-policy mailing list has taken responsibility for the
19 contents of this document since September 1998, with the package
20 maintainers responsible for packaging administrivia only.
25 <title>Debian Policy Manual</title>
27 <name>Ian Jackson </name>
28 <email>ijackson@gnu.ai.mit.edu</email>
31 <name>Christian Schwarz</name>
32 <email>schwarz@debian.org</email>
35 <name>revised: David A. Morris</name>
36 <email>bweaver@debian.org</email>
39 <name>The Debian Policy mailing List</name>
40 <email>debian-policy@lists.debian.org</email>
42 <version>version &version;, &date;</version>
45 This manual describes the policy requirements for the Debian
46 GNU/Linux distribution. This includes the structure and
47 contents of the Debian archive and several design issues of
48 the operating system, as well as technical requirements that
49 each package must satisfy to be included in the distribution.
50 The policy package itself is maintained by a group of
51 maintainers that have no editorial powers. The current list
55 <p>Julian Gilbey <email>jdg@debian.org</email></p>
58 <p>Manoj Srivastava <email>srivasta@debian.org</email></p>
66 Copyright ©1996,1997,1998 Ian Jackson
67 and Christian Schwarz.
70 This manual is free software; you may redistribute it and/or
71 modify it under the terms of the GNU General Public License
72 as published by the Free Software Foundation; either version
73 2, or (at your option) any later version.
77 This is distributed in the hope that it will be useful, but
78 <em>without any warranty</em>; without even the implied
79 warranty of merchantability or fitness for a particular
80 purpose. See the GNU General Public License for more
85 A copy of the GNU General Public License is available as
86 <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
87 distribution or on the World Wide Web at
88 <url id="http://www.gnu.org/copyleft/gpl.html"
89 name="The GNU General Public Licence">. You can also
90 obtain it by writing to the Free Software Foundation, Inc.,
91 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
99 <heading>About this manual</heading>
101 <heading>Scope</heading>
103 This manual describes the policy requirements for the Debian
104 GNU/Linux distribution. This includes the structure and
105 contents of the Debian archive and several design issues of the
106 operating system, as well as technical requirements that
107 each package must satisfy to be included in the
113 This manual also describes Debian policy as it relates to
114 creating Debian packages. It is not a tutorial on how to build
115 packages, nor is it exhaustive where it comes to describing
116 the behavior of the packaging system. Instead, this manual
117 attempts to define the interface to the package management
118 system that the developers have to be conversant with.<footnote>
120 Informally, the criteria used for inclusion is that the
121 material meet one of the following requirements:
122 <taglist compact="compact">
123 <tag>Standard interfaces</tag>
126 The material presented represents an interface to
127 the packaging system that is mandated for use, and
128 is used by, a significant number of packages, and
129 therefore should not be changed without peer
130 review. Package maintainers can then rely on this
131 interfaces not changing, and the package
132 management software authors need to ensure
133 compatibility with these interface
134 definitions. (Control file and changelog file
135 formats are examples.)
138 <tag>Chosen Convention</tag>
141 If there are a number of technically viable choices
142 that can be made, but one needs to select one of
143 these options for inter-operability. The version
144 number format is one example.
148 Please note that these are not mutually exclusive;
149 selected conventions often become parts of standard
156 The footnotes present in this manual are
157 merely informative, and are not part of Debian policy itself.
162 In this manual, the words <em>must</em>, <em>should</em> and
163 <em>may</em>, and the adjectives <em>required</em>,
164 <em>recommended</em> and <em>optional</em>, are used to
165 distinguish the significance of the various guidelines in
166 this policy document. Packages that do not conform to the
167 guidelines denoted by <em>must</em> (or <em>required</em>)
168 will generally not be considered acceptable for the Debian
169 distribution. Non-conformance with guidelines denoted by
170 <em>should</em> (or <em>recommended</em>) will generally be
171 considered a bug, but will not necessarily render a package
172 unsuitable for distribution. Guidelines denoted by
173 <em>may</em> (or <em>optional</em>) are truly optional and
174 adherence is left to the maintainer's discretion.
177 These classifications are roughly equivalent to the bug
178 severities <em>serious</em> (for <em>must</em> or
179 <em>required</em> directive violations), <em>minor</em>,
180 <em>normal</em> or <em>important</em>
181 (for <em>should</em> or <em>recommended</em> directive
182 violations) and <em>wishlist</em> (for <em>optional</em>
184 <p>Compare RFC 2119. Note, however, that these words are
185 used in a different way in this document.</p>
189 Much of the information presented in this manual will be
190 useful even when building a package which is to be
191 distributed in some other way or is intended for local use
196 <heading>New versions of this document</heading>
198 The current version of this document is always accessible
199 from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
201 <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
202 (also available from the same directory are several other
203 formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
204 and <file>policy.ps.gz</file>) or from the <url
205 id="http://www.debian.org/doc/debian-policy/" name="Debian
206 Policy Manual"> webpage.</p>
209 In addition, this manual is distributed via the Debian package
210 <file>debian-policy</file>.
214 The <tt>debian-policy</tt> package also includes the file
215 <file>upgrading-checklist.txt</file> which indicates policy
216 changes between versions of this document.
220 <heading>Feedback</heading>
223 As the Debian GNU/Linux system is continuously evolving this
227 While the authors of this document have tried hard to avoid
228 typos and other errors, these do still occur. If you discover
229 an error in this manual or if you want to give any
230 comments, suggestions, or criticisms please send an email to
231 the Debian Policy List,
232 <email>debian-policy@lists.debian.org</email>, or submit a
233 bug report against the <tt>debian-policy</tt> package.
239 <heading>The Debian Archive</heading>
241 The Debian GNU/Linux system is maintained and distributed as a
242 collection of <em>packages</em>. Since there are so many of
243 them (currently well over 6000), they are split into
244 <em>sections</em> and given <em>priorities</em> to simplify
245 the handling of them.
248 The effort of the Debian project is to build a free operating
249 system, but not every package we want to make accessible is
250 <em>free</em> in our sense (see the Debian Free Software
251 Guidelines, below), or may be imported/exported without
252 restrictions. Thus, the archive is split into the sections
253 <em>main</em>, <em>non-free</em>, <em>contrib</em>,
254 <em>non-US/main</em>, <em>non-US/non-free</em>, and
255 <em>non-US/contrib</em>. The sections are explained in detail
260 The <em>main</em> and the <em>non-US/main</em> sections
261 together form the <em>Debian GNU/Linux distribution</em>.
265 Packages in the other sections are not considered to be part
266 of the Debian distribution, although we support their use and
267 provide infrastructure for them (such as our bug-tracking
268 system and mailing lists). This Debian Policy Manual applies
269 to these packages as well.</p>
271 <sect id="pkgcopyright">
272 <heading>Package copyright and sections</heading>
274 The aims of this section are:
276 <list compact="compact">
278 <p>to allow us to make as much software available as we
282 <p>to allow us to encourage everyone to write free
286 <p>to allow us to make it easy for people to produce
287 CD-ROMs of our system without violating any licenses,
288 import/export restrictions, or any other laws.</p>
293 <heading>The Debian Free Software Guidelines</heading>
295 The Debian Free Software Guidelines (DFSG) form our
296 definition of `free software'. These are:
298 <tag>Free Redistribution
302 The license of a Debian component may not restrict any
303 party from selling or giving away the software as a
304 component of an aggregate software distribution
305 containing programs from several different
306 sources. The license may not require a royalty or
307 other fee for such sale.
314 The program must include source code, and must allow
315 distribution in source code as well as compiled form.
322 The license must allow modifications and derived
323 works, and must allow them to be distributed under the
324 same terms as the license of the original software.
327 <tag>Integrity of The Author's Source Code
331 The license may restrict source-code from being
332 distributed in modified form <em>only</em> if the
333 license allows the distribution of ``patch files''
334 with the source code for the purpose of modifying the
335 program at build time. The license must explicitly
336 permit distribution of software built from modified
337 source code. The license may require derived works to
338 carry a different name or version number from the
339 original software. (This is a compromise. The Debian
340 Project encourages all authors to not restrict any
341 files, source or binary, from being modified.)
344 <tag>No Discrimination Against Persons or Groups
348 The license must not discriminate against any person
352 <tag>No Discrimination Against Fields of Endeavor
356 The license must not restrict anyone from making use
357 of the program in a specific field of endeavor. For
358 example, it may not restrict the program from being
359 used in a business, or from being used for genetic
363 <tag>Distribution of License
367 The rights attached to the program must apply to all
368 to whom the program is redistributed without the need
369 for execution of an additional license by those
373 <tag>License Must Not Be Specific to Debian
377 The rights attached to the program must not depend on
378 the program's being part of a Debian system. If the
379 program is extracted from Debian and used or
380 distributed without Debian but otherwise within the
381 terms of the program's license, all parties to whom
382 the program is redistributed must have the same
383 rights as those that are granted in conjunction with
387 <tag>License Must Not Contaminate Other Software
391 The license must not place restrictions on other
392 software that is distributed along with the licensed
393 software. For example, the license must not insist
394 that all other programs distributed on the same medium
395 must be free software.
398 <tag>Example Licenses
402 The ``GPL,'' ``BSD,'' and ``Artistic'' licenses are
403 examples of licenses that we consider <em>free</em>.
410 <heading>The main section</heading>
412 Every package in <em>main</em> and <em>non-US/main</em>
413 must comply with the DFSG (Debian Free Software
417 In addition, the packages in <em>main</em>
418 <list compact="compact">
421 must not require a package outside of <em>main</em>
422 for compilation or execution (thus, the package must
423 not declare a "Depends", "Recommends", or
424 "Build-Depends" relationship on a non-<em>main</em>
430 must not be so buggy that we refuse to support them,
436 must meet all policy requirements presented in this
443 Similarly, the packages in <em>non-US/main</em>
444 <list compact="compact">
447 must not require a package outside of <em>main</em>
448 or <em>non-US/main</em> for compilation or
454 must not be so buggy that we refuse to support them,
459 must meet all policy requirements presented in this
467 <heading>The contrib section</heading>
469 Every package in <em>contrib</em> and
470 <em>non-US/contrib</em> must comply with the DFSG.
474 In addition, the packages in <em>contrib</em> and
475 <em>non-US/contrib</em>
476 <list compact="compact">
479 must not be so buggy that we refuse to support them,
485 must meet all policy requirements presented in this
493 Furthermore, packages in <em>contrib</em> must not require
494 a package in a <em>non-US</em> section for compilation or
499 Examples of packages which would be included in
500 <em>contrib</em> or <em>non-US/contrib</em> are:
501 <list compact="compact">
504 free packages which require <em>contrib</em>,
505 <em>non-free</em> packages or packages which are not
506 in our archive at all for compilation or execution,
512 wrapper packages or other sorts of free accessories for
520 <heading>The non-free section</heading>
522 Packages must be placed in <em>non-free</em> or
523 <em>non-US/non-free</em> if they are not compliant with
524 the DFSG or are encumbered by patents or other legal
525 issues that make their distribution problematic.
528 In addition, the packages in <em>non-free</em> and
529 <em>non-US/non-free</em>
530 <list compact="compact">
533 must not be so buggy that we refuse to support them,
539 must meet all policy requirements presented in this
540 manual that it is possible for them to meet.<footnote>
542 It is possible that there are policy
543 requirements which the package is unable to
544 meet, for example, if the source is
545 unavailable. These situations will need to be
546 handled on a case-by-case basis.
556 <heading>The non-US sections</heading>
558 Non-free programs with cryptographic program code need to
559 be stored on the <em>non-us</em> server because of export
560 restrictions of the U.S.
563 Programs which use patented algorithms that have a
564 restrictied license also need to be stored on "non-us",
565 since that is located in a country where it is not allowed
566 to patent algorithms.
569 A package depends on another package which is distributed
570 via the non-us server has to be stored on the non-us
575 <heading>Further copyright considerations</heading>
577 Every package must be accompanied by a verbatim copy of
578 its copyright and distribution license in the file
579 <file>/usr/share/doc/<var>package</var>/copyright</file>
580 (see <ref id="copyrightfile"> for further details).
583 We reserve the right to restrict files from being included
584 anywhere in our archives if
585 <list compact="compact">
588 their use or distribution would break a law,
593 there is an ethical conflict in their distribution or
599 we would have to sign a license for them, or
604 their distribution would conflict with other project
612 Programs whose authors encourage the user to make
613 donations are fine for the main distribution, provided
614 that the authors do not claim that not donating is
615 immoral, unethical, illegal or something similar; in such
616 a case they must go in <em>non-free</em>.</p>
619 Packages whose copyright permission notices (or patent
620 problems) do not even allow redistribution of binaries
621 only, and where no special permission has been obtained,
622 must not be placed on the Debian FTP site and its mirrors
626 Note that under international copyright law (this applies
627 in the United States, too), <em>no</em> distribution or
628 modification of a work is allowed without an explicit
629 notice saying so. Therefore a program without a copyright
630 notice <em>is</em> copyrighted and you may not do anything
631 to it without risking being sued! Likewise if a program
632 has a copyright notice but no statement saying what is
633 permitted then nothing is permitted.</p>
636 Many authors are unaware of the problems that restrictive
637 copyrights (or lack of copyright notices) can cause for
638 the users of their supposedly-free software. It is often
639 worthwhile contacting such authors diplomatically to ask
640 them to modify their license terms. However, this can be a
641 politically difficult thing to do and you should ask for
642 advice on the <tt>debian-legal</tt> mailing list first, as
647 When in doubt about a copyright, send mail to
648 <email>debian-legal@lists.debian.org</email>. Be prepared
649 to provide us with the copyright statement. Software
650 covered by the GPL, public domain software and BSD-like
651 copyrights are safe; be wary of the phrases `commercial
652 use prohibited' and `distribution restricted'.
656 <heading>Subsections</heading>
659 The packages in the sections <em>main</em>,
660 <em>contrib</em> and <em>non-free</em> are grouped further
661 into <em>subsections</em> to simplify handling.
665 The section and subsection for each package should be
666 specified in the package's <tt>Section</tt> control
667 record. However, the maintainer of the Debian archive
668 may override this selection to ensure the consistency of
669 the Debian distribution. The <tt>Section</tt> field
670 should be of the form:
671 <list compact="compact">
674 <em>subsection</em> if the package is in the
675 <em>main</em> section,
680 <em>section/subsection</em> if the package is in
681 the <em>contrib</em> or <em>non-free</em> section,
687 <tt>non-US</tt>, <tt>non-US/contrib</tt> or
688 <tt>non-US/non-free</tt> if the package is in
689 <em>non-US/main</em>, <em>non-US/contrib</em> or
690 <em>non-US/non-free</em> respectively.
697 The Debian archive maintainers provide the authoritative
698 list of subsections. At present, they are:
699 <em>admin</em>, <em>base</em>, <em>comm</em>,
700 <em>contrib</em>, <em>devel</em>, <em>doc</em>,
701 <em>editors</em>, <em>electronics</em>, <em>games</em>,
702 <em>graphics</em>, <em>hamradio</em>,
703 <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
704 <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
705 <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
706 <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
707 <em>sound</em>, <em>tex</em>, <em>text</em>,
708 <em>utils</em>, <em>web</em>, <em>x11</em>.
712 <heading>Priorities</heading>
715 Each package should have a <em>priority</em> value, which is
716 included in the package's <em>control record</em>. This
717 information is used by the Debian package management tools
718 to separate high-priority packages from less-important
722 The following <em>priority levels</em> are recognised by the
723 Debian package management tools.
725 <tag><tt>required</tt></tag>
728 Packages which are necessary for the proper
729 functioning of the system. You must not remove these
730 packages or your system may become totally broken and
731 you may not even be able to use <prgn>dpkg</prgn> to
732 put things back. Systems with only the
733 <tt>required</tt> packages are probably unusable, but
734 they do have enough functionality to allow the
735 sysadmin to boot and install more software.</p>
737 <tag><tt>important</tt></tag>
740 Important programs, including those which one would
741 expect to find on any Unix-like system. If the
742 expectation is that an experienced Unix person who
743 found it missing would say `What on earth is going on,
744 where is <prgn>foo</prgn>?', it must be an
745 <tt>important</tt> package.<footnote>
747 This is an important criterion because we are
748 trying to produce, amongst other things, a free
752 Other packages without which the system will not run
753 well or be usable must also have priority
754 <tt>important</tt>. This does
755 <em>not</em> include Emacs, the X Window System, TeX
756 or any other large applications. The
757 <tt>important</tt> packages are just a bare minimum of
758 commonly-expected and necessary tools.</p>
760 <tag><tt>standard</tt></tag>
763 These packages provide a reasonably small but not too
764 limited character-mode system. This is what will be
765 installed by default if the user doesn't select anything
766 else. It doesn't include many large applications.</p>
768 <tag><tt>optional</tt></tag>
771 (In a sense everything that isn't required is
772 optional, but that's not what is meant here.) This is
773 all the software that you might reasonably want to
774 install if you didn't know what it was and don't have
775 specialized requirements. This is a much larger system
776 and includes the X Window System, a full TeX
777 distribution, and many applications. Note that
778 optional packages should not conflict with each other.
781 <tag><tt>extra</tt></tag>
784 This contains all packages that conflict with others
785 with required, important, standard or optional
786 priorities, or are only likely to be useful if you
787 already know what they are or have specialised
794 Packages must not depend on packages with lower priority
795 values (excluding build-time dependencies). In order to
796 ensure this, the priorities of one or more packages may need
802 <heading>Binary packages</heading>
805 The Debian GNU/Linux distribution is based on the Debian
806 package management system, called <prgn>dpkg</prgn>. Thus,
807 all packages in the Debian distribution must be provided
808 in the <tt>.deb</tt> file format.</p>
812 <heading>The package name</heading>
815 Every package must have a name that's unique within the Debian
819 Package names must consist of lower case letters
820 (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
821 and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
822 They must be at least two characters long and must start
823 with an alphanumeric character.
827 The package name is part of the file name of the
828 <tt>.deb</tt> file and is included in the control field
834 <heading>The maintainer of a package</heading>
836 Every package must have a Debian maintainer (the
837 maintainer may be one person or a group of people
838 reachable from a common email address, such as a mailing
839 list). The maintainer is responsible for ensuring that
840 the package is placed in the appropriate distributions.
844 The maintainer must be specified in the
845 <tt>Maintainer</tt> control field with their correct name
846 and a working email address. If one person maintains
847 several packages, he/she should try to avoid having
848 different forms of their name and email address in
849 the <tt>Maintainer</tt> fields of those packages.
853 If the maintainer of a package quits from the Debian
854 project, "Debian QA Group"
855 <email>packages@qa.debian.org</email> takes over the
856 maintainership of the package until someone else
857 volunteers for that task. These packages are called
858 <em>orphaned packages</em>.<footnote>
860 The detailed procedure for doing this gracefully can
861 be found in the Debian Developer's Reference, either
862 in the <tt>developers-reference</tt> package, or on
863 the Debian FTP server
864 <ftpsite>ftp.debian.org</ftpsite> as
865 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
867 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
868 name="Debian Developer's Reference"> webpage.
876 <heading>The description of a package</heading>
879 Every Debian package must have an extended description
880 stored in the appropriate field of the control record.</p>
883 The description should be written so that it gives the
884 system administrator enough information to decide whether
885 to install the package. This description should not just
886 be copied verbatim from the program's documentation.
887 Instructions for configuring or using the package should
888 not be included (that is what installation scripts,
889 manual pages, info files, etc., are for). Copyright
890 statements and other administrivia should not be included
891 either (that is what the copyright file is for).
897 <heading>Dependencies</heading>
900 Every package must specify the dependency information
901 about other packages that are required for the first to
905 For example, a dependency entry must be provided for any
906 shared libraries required by a dynamically-linked executable
907 binary in a package.</p>
910 Packages are not required to declare any dependencies they
911 have on other packages which are marked <tt>Essential</tt>
912 (see below), and should not do so unless they depend on a
913 particular version of that package.</p>
916 Sometimes, a package requires another package to be installed
917 <em>and</em> configured before it can be installed. In this
918 case, you must specify a <tt>Pre-Depends</tt> entry for
922 You should not specify a <tt>Pre-Depends</tt> entry for a
923 package before this has been discussed on the
924 <tt>debian-devel</tt> mailing list and a consensus about
925 doing that has been reached.</p></sect1>
928 <sect1 id="virtual_pkg_sect">
929 <heading>Virtual packages</heading>
932 Sometimes, there are several packages which offer
933 more-or-less the same functionality. In this case, it's
934 useful to define a <em>virtual package</em> whose name
935 describes that common functionality. (The virtual
936 packages only exist logically, not physically; that's why
937 they are called <em>virtual</em>.) The packages with this
938 particular function will then <em>provide</em> the virtual
939 package. Thus, any other package requiring that function
940 can simply depend on the virtual package without having to
941 specify all possible packages individually.</p>
944 All packages should use virtual package names where
945 appropriate, and arrange to create new ones if necessary.
946 They should not use virtual package names (except privately,
947 amongst a cooperating group of packages) unless they have
948 been agreed upon and appear in the list of virtual package
949 names. (See also <ref id="virtual">)</p>
952 The latest version of the authoritative list of virtual
953 package names can be found on
954 <ftpsite>ftp.debian.org</ftpsite> in
955 <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
956 or your local mirror. In addition, it is included in the
957 <tt>debian-policy</tt> package. The procedure for updating
958 the list is described at the top of the file.</p></sect1>
962 <heading>Base packages</heading>
965 The packages included in the <tt>base</tt> section have a
966 special function. They form a minimum subset of the Debian
967 GNU/Linux system that is installed before everything else
968 on a new system. Thus, only very few packages are allowed
969 to go into the <tt>base</tt> section to keep the required
970 disk usage very small.</p>
973 Most of these packages will have the priority value
974 <tt>required</tt> or at least <tt>important</tt>, and many
975 of them will be tagged <tt>essential</tt> (see below).</p>
978 You must not place any packages into the <tt>base</tt>
979 section before this has been discussed on the
980 <tt>debian-devel</tt> mailing list and a consensus about
981 doing that has been reached.</p></sect1>
985 <heading>Essential packages</heading>
988 Some packages are tagged <tt>essential</tt>. (They have
989 <tt>Essential: yes</tt> in their package control record.)
990 This flag is used for packages that are <em>essential</em>
994 Since these packages cannot be easily removed (one has to
995 specify an extra <em>force option</em> to
996 <prgn>dpkg</prgn> to do so), this flag must not be used
997 unless absolutely necessary. A shared library package
998 must not be tagged <tt>essential</tt>; dependencies will
999 prevent its premature removal, and we need to be able to
1000 remove it when it has been superseded.
1004 Since dpkg will not prevent upgrading of other packages
1005 while an <tt>essential</tt> package is in an unconfigured
1006 state, all <tt>essential</tt> packages must supply all of
1007 their core functionality even when unconfigured. If the
1008 package cannot satisfy this requirement it must not be
1009 tagged as essential, and any packages depending on this
1010 package must instead have explicit dependency fields as
1015 You must not tag any packages <tt>essential</tt> before
1016 this has been discussed on the <tt>debian-devel</tt>
1017 mailing list and a consensus about doing that has been
1022 <heading>Tasks</heading>
1025 The Debian install process allows the user to choose from
1026 a number of common tasks which a Debian system can be used to
1027 perform. Selecting a task with <prgn>tasksel</prgn> causes
1028 a set of packages that are useful in performing that task to be
1033 This set of packages is all available packages which have the
1034 name of the selected task in the <tt>Task</tt> field of their
1035 control file. The format of this field is a list of tasks,
1036 separated by commas.
1040 You should not tag any packages as belonging to a task
1041 before this has been discussed on the
1042 <em>debian-devel</em> mailing list and a consensus about
1043 doing that has been reached.
1047 For third parties (and historical reasons), tasksel also
1048 supports constructing tasks based on <em>task
1049 packages</em>. These are packages whose names begin with
1050 <em>task-</em>. Task packages should not be included in the
1055 <sect1 id="maintscripts">
1056 <heading>Maintainer Scripts</heading>
1059 The package installation scripts should avoid producing
1060 output which it is unnecessary for the user to see and
1061 should rely on <prgn>dpkg</prgn> to stave off boredom on
1062 the part of a user installing many packages. This means,
1063 amongst other things, using the <tt>--quiet</tt> option on
1064 <prgn>install-info</prgn>.</p>
1067 Errors which occur during the execution of an installation
1068 script must be checked and the installation must not
1069 continue after an error.
1073 Note that in general <ref id="scripts"> applies to package
1074 maintainer scripts, too.
1078 You should not use <prgn>dpkg-divert</prgn> on a file
1079 belonging to another package without consulting the
1080 maintainer of that package first.
1084 All packages which supply an instance of a common command
1085 name (or, in general, filename) should generally use
1086 <prgn>update-alternatives</prgn>, so that they may be
1087 installed together. If <prgn>update-alternatives</prgn>
1088 is not used, then each package must use
1089 <tt>Conflicts</tt> to ensure that other packages are
1090 de-installed. (In this case, it may be appropriate to
1091 specify a conflict against earlier versions of something
1092 that previously did not use
1093 <prgn>update-alternatives</prgn>; this is an exception to
1094 the usual rule that versioned conflicts should be
1100 <heading>Prompting in maintainer scripts</heading>
1102 Package maintainer scripts may prompt the user if
1103 necessary. Prompting may be accomplished by hand, or by
1104 communicating with a program, such as
1105 <prgn>debconf</prgn>, which conforms to the Debian
1106 Configuration management specification, version 2 or
1107 higher. These are included in the
1108 <file>debconf_specification</file> files in the
1109 <package>debian-policy</package> package.
1110 You may also find this file on the FTP site
1111 <ftpsite>ftp.debian.org</ftpsite> in
1112 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1113 or on your local mirror.<footnote>
1115 4% of Debian packages [see <url
1116 id="http://kitenet.net/programs/debconf/stats/"
1117 name="Debconf stats">] currently use
1118 <package>debconf</package> to prompt the user at
1119 install time, and this number is growing daily. The
1120 benefits of using debconf are briefly explained at
1122 id="http://kitenet.net/doc/debconf-doc/introduction.html"
1123 name="Debconf introduction">; they include
1124 preconfiguration, (mostly) noninteractive
1125 installation, elimination of redundant prompting,
1126 consistency of user interface, etc.
1129 With this increasing number of packages using
1130 <package>debconf</package>, plus the existance of a
1131 nascent second implementation of the Debian
1132 configuration management system
1133 (<package>cdebconf</package>), and the stabilization
1134 of the protocol these things use, the time has
1135 finally come to reflect the use of these things in
1142 Packages which use the Debian Configuration management
1143 specification may contain an additional
1144 <prgn>config</prgn> script and a <tt>templates</tt>
1145 file in their control archive. The <prgn>config</prgn>
1146 script might be run before the <prgn>preinst</prgn>
1147 script, and before the package is unpacked or any of its
1148 dependencies or pre-dependancies are satisfied.
1149 Therefore it must work using only the tools present in
1150 <em>essential</em> packages.<footnote>
1152 <package>Debconf</package> or another tool that
1153 implements the Debian Configuration management
1154 specification will also be installed, and any
1155 versioned dependencies on it will be satisfied
1156 before preconfiguration begins.
1162 Packages should try to minimize the amount of prompting
1163 they need to do, and they should ensure that the user
1164 will only ever be asked each question once. This means
1165 that packages should try to use appropriate shared
1166 configuration files (such as <file>/etc/papersize</file> and
1167 <file>/etc/news/server</file>), and shared
1168 <package>debconf</package> variables rather than each
1169 prompting for their own list of required pieces of
1174 It also means that an upgrade should not ask the same
1175 questions again, unless the user has used <tt>dpkg
1176 --purge</tt> to remove the package's configuration. The
1177 answers to configuration questions should be stored in an
1178 appropriate place in <file>/etc</file> so that the user can
1179 modify them, and how this has been done should be
1183 If a package has a vitally important piece of
1184 information to pass to the user (such as "don't run me
1185 as I am, you must edit the following configuration files
1186 first or you risk your system emitting badly-formatted
1187 messages"), it should display this in the
1188 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1189 prompt the user to hit return to acknowledge the
1190 message. Copyright messages do not count as vitally
1191 important (they belong in
1192 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1193 neither do instructions on how to use a program (these
1194 should be in on-line documentation, where all the users
1198 Any necessary prompting should almost always be confined
1199 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1200 script. If it is done in the <prgn>postinst</prgn>, it
1201 should be protected with a conditional so that
1202 unnecessary prompting doesn't happen if a package's
1203 installation fails and the <prgn>postinst</prgn> is
1204 called with <tt>abort-upgrade</tt>,
1205 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1210 <heading>Source packages</heading>
1212 <sect1 id="standardsversion">
1213 <heading>Standards conformance</heading>
1216 In the source package's <tt>Standards-Version</tt> control
1217 field, you should specify the most recent version number
1218 of this policy document with which your package complied
1219 when it was last updated. The current version number is
1224 This information may be used to file bug reports
1225 automatically if your package becomes too much out of
1230 The version number has four components: major and minor
1231 version number and major and minor patch level. When the
1232 standards change in a way that requires every package to
1233 change the major number will be changed. Significant
1234 changes that will require work in many packages will be
1235 signaled by a change to the minor number. The major patch
1236 level will be changed for any change to the meaning of the
1237 standards, however small; the minor patch level will be
1238 changed when only cosmetic, typographical or other edits
1239 are made which neither change the meaning of the document
1240 nor affect the contents of packages.</p>
1243 Thus only the first three components of the policy version
1244 are significant in the <em>Standards-Version</em> control
1245 field, and so either these three components or the all
1246 four components may be specified.<footnote>
1248 In the past, people specified the full version number
1249 in the Standards-Version field, for example `2.3.0.0'.
1250 Since minor patch-level changes don't introduce new
1251 policy, it was thought it would be better to relax
1252 policy and only require the first 3 components to be
1253 specified, in this example `2.3.0'. All four
1254 components may still be used if someone wishes to do
1261 You should regularly, and especially if your package has
1262 become out of date, check for the newest Policy Manual
1263 available and update your package, if necessary. When your
1264 package complies with the new standards you should update the
1265 <tt>Standards-Version</tt> source package field and
1266 release it.<footnote>
1268 See the file <file>upgrading-checklist</file> for
1269 information about policy which has changed between
1270 different versions of this document.
1278 <heading>Package relationships</heading>
1281 Source packages should specify which binary packages they
1282 require to be installed or not to be installed in order to
1283 build correctly. For example, if building a package
1284 requires a certain compiler, then the compiler should be
1285 specified as a build-time dependency.
1289 It is not necessary to explicitly specify build-time
1290 relationships on a minimal set of packages that are always
1291 needed to compile, link and put in a Debian package a
1292 standard "Hello World!" program written in C or C++. The
1293 required packages are called <em>build-essential</em>, and
1294 an informational list can be found in
1295 <file>/usr/share/doc/build-essential/list</file> (which is
1296 contained in the <tt>build-essential</tt>
1299 <list compact="compact">
1301 <p>This allows maintaining the list separately
1302 from the policy documents (the list does not
1303 need the kind of control that the policy
1309 Having a separate package allows one to install
1310 the build-essential packages on a machine, as
1311 well as allowing other packages such as tasks to
1312 require installation of the build-essential
1313 packages using the depends relation.
1318 The separate package allows bug reports against
1319 the list to be categorized separately from
1320 the policy management process in the BTS.
1330 When specifying the set of build-time dependencies, one
1331 should list only those packages explicitly required by the
1332 build. It is not necessary to list packages which are
1333 required merely because some other package in the list of
1334 build-time dependencies depends on them.<footnote>
1336 The reason for this is that dependencies change, and
1337 you should list all those packages, and <em>only</em>
1338 those packages that <em>you</em> need directly. What
1339 others need is their business. For example, if you
1340 only link against <file>libimlib</file>, you will need to
1341 build-depend on <package>libimlib2-dev</package> but
1342 not against any <tt>libjpeg*</tt> packages, even
1343 though <tt>libimlib2-dev</tt> currently depends on
1344 them: installation of <package>libimlib2-dev</package>
1345 will automatically ensure that all of its run-time
1346 dependencies are satisfied.
1352 If build-time dependencies are specified, it must be
1353 possible to build the package and produce working binaries
1354 on a system with only essential and build-essential
1355 packages installed and also those required to satisfy the
1356 build-time relationships (including any implied
1357 relationships). In particular, this means that version
1358 clauses should be used rigorously in build-time
1359 relationships so that one cannot produce bad or
1360 inconsistently configured packages when the relationships
1361 are properly satisfied.
1365 <heading>Changes to the upstream sources</heading>
1368 If changes to the source code are made that are not
1369 specific to the needs of the Debian system, they should be
1370 sent to the upstream authors in whatever form they prefer
1371 so as to be included in the upstream version of the
1375 If you need to configure the package differently for
1376 Debian or for Linux, and the upstream source doesn't
1377 provide a way to do so, you should add such configuration
1378 facilities (for example, a new <prgn>autoconf</prgn> test
1379 or <tt>#define</tt>) and send the patch to the upstream
1380 authors, with the default set to the way they originally
1381 had it. You can then easily override the default in your
1382 <file>debian/rules</file> or wherever is appropriate.</p>
1385 You should make sure that the <prgn>configure</prgn> utility
1386 detects the correct architecture specification string
1387 (refer to <ref id="arch-spec"> for details).</p>
1390 If you need to edit a <prgn>Makefile</prgn> where
1391 GNU-style <prgn>configure</prgn> scripts are used, you
1392 should edit the <file>.in</file> files rather than editing the
1393 <prgn>Makefile</prgn> directly. This allows the user to
1394 reconfigure the package if necessary. You should
1395 <em>not</em> configure the package and edit the generated
1396 <prgn>Makefile</prgn>! This makes it impossible for
1397 someone else to later reconfigure the package.</p></sect1>
1401 <heading>Documenting your changes</heading>
1404 You should document your changes and updates to the source
1405 package properly in the <file>debian/changelog</file> file. (Note
1406 that mistakes in changelogs are usually best rectified by
1407 making a new changelog entry rather than "rewriting history"
1408 by editing old changelog entries.)</p>
1411 In non-experimental packages you must use a format for
1412 <file>debian/changelog</file> which is supported by the most
1413 recent released version of <prgn>dpkg</prgn>.<footnote>
1415 If you wish to use an alternative format, you may do
1416 so as long as you include a parser for it in your
1417 source package. The parser must have an API
1418 compatible with that expected by
1419 <prgn>dpkg-genchanges</prgn> and
1420 <prgn>dpkg-gencontrol</prgn>. If there is general
1421 interest in the new format, you should contact the
1422 <package>dpkg</package> maintainer to have the parser
1423 script for it included in the <prgn>dpkg</prgn>
1424 package. (You will need to agree that the parser and
1425 its manpage may be distributed under the GNU GPL, just
1426 as the rest of `dpkg' is.)
1434 <heading>Error trapping in makefiles</heading>
1437 When <prgn>make</prgn> invokes a command in a makefile
1438 (including your package's upstream makefiles and
1439 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1440 means that <prgn>sh</prgn>'s usual bad error handling
1441 properties apply: if you include a miniature script as one
1442 of the commands in your makefile you'll find that if you
1443 don't do anything about it then errors are not detected
1444 and <prgn>make</prgn> will blithely continue after
1448 Every time you put more than one shell command (this
1449 includes using a loop) in a makefile command you
1450 must make sure that errors are trapped. For
1451 simple compound commands, such as changing directory and
1452 then running a program, using <tt>&&</tt> rather
1453 than semicolon as a command separator is sufficient. For
1454 more complex commands including most loops and
1455 conditionals you should include a separate <tt>set -e</tt>
1456 command at the start of every makefile command that's
1457 actually one of these miniature shell scripts.</p></sect1>
1461 <heading>Obsolete constructs and libraries</heading>
1464 The include file <tt><varargs.h></tt> is
1465 provided to support end-users compiling very old software;
1466 the library <tt>libtermcap</tt> is provided to support the
1467 execution of software which has been linked against it
1468 (either old programs or those such as Netscape which are
1469 only available in binary form).</p>
1472 Debian packages should be patched to use
1473 <tt><stdarg.h></tt> and <tt>ncurses</tt>
1480 <chapt id="controlfields"><heading>Control files and their fields</heading>
1483 Many of the tools in the package management suite manipulate
1484 data represented in a common format, known as <em>control
1485 data</em>. The data is often stored in <em>control
1486 files</em>. Binary and source packages have control files,
1487 and the <file>.changes</file> files which control the installation
1488 of uploaded files are also in control file format.
1489 <prgn>Dpkg</prgn>'s internal databases are in a similar
1493 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1496 A control file consists of one or more paragraphs of fields.
1497 The paragraphs are separated by blank lines. Some control
1498 files allow only one paragraph; others allow several, in
1499 which case each paragraph usually refers to a different
1500 package. (For example, in source packages, the first
1501 paragraph refers to the source package, and later paragraphs
1502 refer to binary packages generated from the source.)
1506 Each paragraph consists of a series of data fields; each
1507 field consists of the field name, followed by a colon and
1508 then the data/value associated with that field. It ends at
1509 the end of the line. Horizontal whitespace (spaces and
1510 tabs) may occur immediately before or after the value and is
1511 ignored there; it is conventional to put a single space
1512 after the colon. For example, a field might be:
1513 <example compact="compact">
1516 the field name is <tt>Package</tt> and the field value
1521 Some fields' values may span several lines; in this case
1522 each continuation line <em>must</em> start with a space or
1523 tab. Any trailing spaces or tabs at the end of individual
1524 lines of a field value are ignored.
1528 Except where otherwise stated only a single line of data is
1529 allowed and whitespace is not significant in a field body.
1530 Whitespace must not appear inside names (of packages,
1531 architectures, files or anything else) or version numbers,
1532 or between the characters of multi-character version
1537 Field names are not case-sensitive, but it is usual to
1538 capitalize the field names using mixed case as shown below.
1542 Blank lines, or lines consisting only of spaces and tabs,
1543 are not allowed within field values or between fields - that
1544 would mean a new paragraph.
1549 <sect><heading>List of fields</heading>
1551 This list here is not supposed to be exhaustive. Most fields
1552 are dealt with elsewhere in this document.
1554 <sect1 id="f-Package"><heading><tt>Package</tt>
1558 The name of the binary package. Package names consist of
1559 lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1560 plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1561 periods (<tt>.</tt>).
1565 They must be at least two characters long and must start
1566 with an alphanumeric character. The use of lowercase
1567 package names is required unless the package you're
1568 building (or referring to, in other fields) is already
1569 using uppercase characters.</p>
1572 <sect1 id="f-Version"><heading><tt>Version</tt>
1576 This lists the source or binary package's version number -
1577 see <ref id="versions">.
1583 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1587 The most recent version of the standards (the policy
1588 manual and associated texts) with which the package
1589 complies. This is updated manually when editing the
1590 source package to conform to newer standards; it can
1591 sometimes be used to tell when a package needs attention.
1592 Its format is described above; see
1593 <ref id="standardsversion">.
1598 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1602 In a <file>.changes</file> file or parsed changelog output
1603 this contains the (space-separated) name(s) of the
1604 distribution(s) where this version of the package should
1605 be installed. Valid distributions are determined by the
1606 archive maintainers.<footnote>
1607 Current distribution names are:
1608 <taglist compact="compact">
1609 <tag><em>stable</em></tag>
1612 This is the current `released' version of Debian
1613 GNU/Linux. Once the distribution is
1614 <em>stable</em> only security fixes and other
1615 major bug fixes are allowed. When changes are
1616 made to this distribution, the release number is
1617 increased (for example: 2.2r1 becomes 2.2r2 then
1622 <tag><em>unstable</em></tag>
1625 This distribution value refers to the
1626 <em>developmental</em> part of the Debian
1627 distribution tree. New packages, new upstream
1628 versions of packages and bug fixes go into the
1629 <em>unstable</em> directory tree. Download from
1630 this distribution at your own risk.
1634 <tag><em>testing</em></tag>
1637 This distribution value refers to the
1638 <em>testing</em> part of the Debian distribution
1639 tree. It receives its packages from the
1640 unstable distribution after a short time lag to
1641 ensure that there are no major issues with the
1642 unstable packages. It is less prone to breakage
1643 than unstable, but still risky. It is not
1644 possible to upload packages directly to
1649 <tag><em>frozen</em></tag>
1652 From time to time, the <em>testing</em>
1653 distribution enters a state of `code-freeze' in
1654 anticipation of release as a <em>stable</em>
1655 version. During this period of testing only
1656 fixes for existing or newly-discovered bugs will
1657 be allowed. The exact details of this stage are
1658 determined by the Release Manager.
1662 <tag><em>experimental</em></tag>
1665 The packages with this distribution value are
1666 deemed by their maintainers to be high
1667 risk. Oftentimes they represent early beta or
1668 developmental packages from various sources that
1669 the maintainers want people to try, but are not
1670 ready to be a part of the other parts of the
1671 Debian distribution tree. Download at your own
1677 You should list <em>all</em> distributions that the
1678 package should be installed into.
1687 <chapt id="versions"><heading>Version numbering</heading>
1690 Every package has a version number recorded in its
1691 <tt>Version</tt> control file field.
1695 The package management system imposes an ordering on version
1696 numbers, so that it can tell whether packages are being up- or
1697 downgraded and so that package system front end applications
1698 can tell whether a package it finds available is newer than
1699 the one installed on the system. The version number format
1700 has the most significant parts (as far as comparison is
1701 concerned) at the beginning.
1705 The version number format is:
1706 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1710 The three components here are:
1712 <tag><var>epoch</var></tag>
1715 This is a single (generally small) unsigned integer. It
1716 may be omitted, in which case zero is assumed. If it is
1717 omitted then the <var>upstream_version</var> may not
1722 It is provided to allow mistakes in the version numbers
1723 of older versions of a package, and also a package's
1724 previous version numbering schemes, to be left behind.
1728 <tag><var>upstream_version</var></tag>
1731 This is the main part of the version number. It is
1732 usually the version number of the original (`upstream')
1733 package from which the <file>.deb</file> file has been made,
1734 if this is applicable. Usually this will be in the same
1735 format as that specified by the upstream author(s);
1736 however, it may need to be reformatted to fit into the
1737 package management system's format and comparison
1742 The comparison behavior of the package management system
1743 with respect to the <var>upstream_version</var> is
1744 described below. The <var>upstream_version</var>
1745 portion of the version number is mandatory.
1749 The <var>upstream_version</var> may contain only
1750 alphanumerics<footnote>
1751 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1753 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1754 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1755 start with a digit. If there is no
1756 <var>debian_revision</var> then hyphens are not allowed;
1757 if there is no <var>epoch</var> then colons are not
1761 <tag><var>debian_revision</var></tag>
1764 This part of the version number specifies the version of
1765 the Debian package based on the upstream version. It
1766 may contain only alphanumerics and the characters
1767 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1768 compared in the same way as the
1769 <var>upstream_version</var> is.
1773 It is optional; if it isn't present then the
1774 <var>upstream_version</var> may not contain a hyphen.
1775 This format represents the case where a piece of
1776 software was written specifically to be turned into a
1777 Debian package, and so there is only one `debianization'
1778 of it and therefore no revision indication is required.
1782 It is conventional to restart the
1783 <var>debian_revision</var> at <tt>1</tt> each time the
1784 <var>upstream_version</var> is increased.
1788 The package management system will break the version
1789 number apart at the last hyphen in the string (if there
1790 is one) to determine the <var>upstream_version</var> and
1791 <var>debian_revision</var>. The absence of a
1792 <var>debian_revision</var> compares earlier than the
1793 presence of one (but note that the
1794 <var>debian_revision</var> is the least significant part
1795 of the version number).
1802 The <var>upstream_version</var> and <var>debian_revision</var>
1803 parts are compared by the package management system using the
1808 The strings are compared from left to right.
1812 First the initial part of each string consisting entirely of
1813 non-digit characters is determined. These two parts (one of
1814 which may be empty) are compared lexically. If a difference
1815 is found it is returned. The lexical comparison is a
1816 comparison of ASCII values modified so that all the letters
1817 sort earlier than all the non-letters.
1821 Then the initial part of the remainder of each string which
1822 consists entirely of digit characters is determined. The
1823 numerical values of these two parts are compared, and any
1824 difference found is returned as the result of the comparison.
1825 For these purposes an empty string (which can only occur at
1826 the end of one or both version strings being compared) counts
1831 These two steps (comparing and removing initial non-digit
1832 strings and initial digit strings) are repeated until a
1833 difference is found or both strings are exhausted.
1837 Note that the purpose of epochs is to allow us to leave behind
1838 mistakes in version numbering, and to cope with situations
1839 where the version numbering scheme changes. It is
1840 <em>not</em> intended to cope with version numbers containing
1841 strings of letters which the package management system cannot
1842 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1843 silly orderings (the author of this manual has heard of a
1844 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1845 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1846 <tt>2</tt> and so forth).
1850 If an upstream package has problematic version numbers they
1851 should be converted to a sane form for use in the
1852 <tt>Version</tt> field.
1856 <heading>Version numbers based on dates</heading>
1858 In general, Debian packages should use the same version
1859 numbers as the upstream sources.</p>
1862 However, in some cases where the upstream version number is
1863 based on a date (e.g., a development `snapshot' release) the
1864 package management system cannot handle these version
1865 numbers without epochs. For example, dpkg will consider
1866 `96May01' to be greater than `96Dec24'.</p>
1869 To prevent having to use epochs for every new upstream
1870 version, the version number should be changed to the
1871 following format in such cases: `19960501', `19961224'. It
1872 is up to the maintainer whether he/she wants to bother the
1873 upstream maintainer to change the version numbers upstream,
1877 Note that other version formats based on dates which are
1878 parsed correctly by the package management system should
1879 <em>not</em> be changed.</p>
1882 Native Debian packages (i.e., packages which have been
1883 written especially for Debian) whose version numbers include
1884 dates should always use the `YYYYMMDD' format.</p>
1888 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1890 <sect id="timestamps"><heading>Time Stamps</heading>
1892 Maintainers should preserve the modification times of the
1893 upstream source files in a package, as far as is reasonably
1896 The rationale is that there is some information conveyed
1897 by knowing the age of the file, for example, you could
1898 recognize that some documentation is very old by looking
1899 at the modification time, so it would be nice if the
1900 modification time of the upstream source would be
1907 <sect id="debianrules"><heading><file>debian/rules</file> - the
1908 main building script</heading>
1911 This file must be an executable makefile, and contains the
1912 package-specific recipes for compiling the package and
1913 building binary package(s) from the source.
1917 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1918 so that it can be invoked by saying its name rather than
1919 invoking <prgn>make</prgn> explicitly.
1923 Since an interactive <file>debian/rules</file> script makes it
1924 impossible to auto-compile that package and also makes it
1925 hard for other people to reproduce the same binary
1926 package, all <em>required targets</em> MUST be
1927 non-interactive. At a minimum, required targets are the
1928 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1929 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1930 <em>binary-indep</em>, and <em>build</em>. It also follows
1931 that any target that these targets depend on must also be
1936 The required and optional targets are as follows:
1938 <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1939 <tt>build-indep</tt> (optional)</tag>
1942 The <tt>build</tt> target should perform all
1943 non-interactive configuration and compilation of the
1944 package. If a package has an interactive pre-build
1945 configuration routine, the Debianized source package
1946 must either be built after this has taken place (so
1947 that the binary package can be built without rerunning
1948 the configuration) or the configuration routine
1949 modified to become non-interactive. (The latter is
1950 preferable if there are architecture-specific features
1951 detected by the configuration routine.)
1955 For some packages, notably ones where the same
1956 source tree is compiled in different ways to produce
1957 two binary packages, the <tt>build</tt> target
1958 does not make much sense. For these packages it is
1959 good enough to provide two (or more) targets
1960 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1961 for each of the ways of building the package, and a
1962 <tt>build</tt> target that does nothing. The
1963 <tt>binary</tt> target will have to build the
1964 package in each of the possible ways and make the
1965 binary package out of each.
1969 The <tt>build</tt> target must not do anything
1970 that might require root privilege.
1974 The <tt>build</tt> target may need to run the
1975 <tt>clean</tt> target first - see below.
1979 When a package has a configuration and build routine
1980 which takes a long time, or when the makefiles are
1981 poorly designed, or when <tt>build</tt> needs to
1982 run <tt>clean</tt> first, it is a good idea to
1983 <tt>touch build</tt> when the build process is
1984 complete. This will ensure that if <tt>debian/rules
1985 build</tt> is run again it will not rebuild the whole
1988 Another common way to do this is for <tt>build</tt>
1989 to depend on <prgn>build-stamp</prgn> and to do
1990 nothing else, and for the <prgn>build-stamp</prgn>
1991 target to do the building and to <tt>touch
1992 build-stamp</tt> on completion. This is
1993 especially useful if the build routine creates a
1994 file or directory called <tt>build</tt>; in such a
1995 case, <tt>build</tt> will need to be listed as
1996 a phony target (i.e., as a dependency of the
1997 <tt>.PHONY</tt> target). See the documentation of
1998 <prgn>make</prgn> for more information on phony
2005 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
2006 <tt>binary-indep</tt>
2010 The <tt>binary</tt> target must be all that is
2011 necessary for the user to build the binary package(s)
2012 produced from this source package. All of these
2013 targets are required to be non-interactive. It is
2014 split into two parts: <prgn>binary-arch</prgn> builds
2015 the binary packages which are specific to a particular
2016 architecture, and <tt>binary-indep</tt> builds
2017 those which are not.
2020 <tt>binary</tt> may be (and commonly is) a target with
2021 no commands which simply depends on
2022 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
2025 Both <tt>binary-*</tt> targets should depend on the
2026 <tt>build</tt> target, or on the appropriate
2027 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
2028 provided, so that the package is built if it has not
2029 been already. It should then create the relevant
2030 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
2031 make their control files and <prgn>dpkg-deb</prgn> to
2032 build them and place them in the parent of the top
2037 Both the <tt>binary-arch</tt> and
2038 <tt>binary-indep</tt> targets <em>must</em> exist.
2039 If one of them has nothing to do (which will always be
2040 the case if the source generates only a single binary
2041 package, whether architecture-dependent or not), it
2042 must still exist and must always succeed.
2046 The <tt>binary</tt> targets must be invoked as
2049 The <prgn>fakeroot</prgn> package often allows one
2050 to build a package correctly even without being
2057 <tag><tt>clean</tt></tag>
2060 This must undo any effects that the <tt>build</tt>
2061 and <tt>binary</tt> targets may have had, except
2062 that it should leave alone any output files created in
2063 the parent directory by a run of a <tt>binary</tt>
2064 target. This target must be non-interactive.
2068 If a <tt>build</tt> file is touched at the end of
2069 the <tt>build</tt> target, as suggested above, it
2070 should be removed as the first action that
2071 <tt>clean</tt> performs, so that running
2072 <tt>build</tt> again after an interrupted
2073 <tt>clean</tt> doesn't think that everything is
2078 The <tt>clean</tt> target may need to be
2079 invoked as root if <tt>binary</tt> has been
2080 invoked since the last <tt>clean</tt>, or if
2081 <tt>build</tt> has been invoked as root (since
2082 <tt>build</tt> may create directories, for
2087 <tag><tt>get-orig-source</tt> (optional)</tag>
2090 This target fetches the most recent version of the
2091 original source package from a canonical archive site
2092 (via FTP or WWW, for example), does any necessary
2093 rearrangement to turn it into the original source
2094 tar file format described below, and leaves it in the
2099 This target may be invoked in any directory, and
2100 should take care to clean up any temporary files it
2105 This target is optional, but providing it if
2106 possible is a good idea.
2112 The <tt>build</tt>, <tt>binary</tt> and
2113 <tt>clean</tt> targets must be invoked with the current
2114 directory being the package's top-level directory.
2119 Additional targets may exist in <file>debian/rules</file>,
2120 either as published or undocumented interfaces or for the
2121 package's internal use.
2125 The architectures we build on and build for are determined
2126 by <prgn>make</prgn> variables using the utility
2127 <prgn>dpkg-architecture</prgn>. You can determine the
2128 Debian architecture and the GNU style architecture
2129 specification string for the build machine (the machine type
2130 we are building on) as well as for the host machine (the
2131 machine type we are building for). Here is a list of
2132 supported <prgn>make</prgn> variables:
2133 <list compact="compact">
2135 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2138 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2139 specification string)</p>
2142 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2143 <tt>DEB_*_GNU_TYPE</tt>)</p>
2146 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2147 <tt>DEB_*_GNU_TYPE</tt>)</p>
2149 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2150 the build machine or <tt>HOST</tt> for specification of the
2155 Backward compatibility can be provided in the rules file
2156 by setting the needed variables to suitable default
2157 values; please refer to the documentation of
2158 <prgn>dpkg-architecture</prgn> for details.
2162 It is important to understand that the <tt>DEB_*_ARCH</tt>
2163 string only determines which Debian architecture we are
2164 building on or for. It should not be used to get the CPU
2165 or system information; the GNU style variables should be
2170 <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2174 This file records the changes to the Debian-specific parts of the
2177 Though there is nothing stopping an author who is also
2178 the Debian maintainer from using it for all their
2179 changes, it will have to be renamed if the Debian and
2180 upstream maintainers become different people. In such a
2181 case, however, it might be better to maintain the
2182 package as a non-native package.
2188 It has a special format which allows the package building
2189 tools to discover which version of the package is being
2190 built and find out other release-specific information.
2194 That format is a series of entries like this:
2195 <example compact="compact">
2196 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2198 <p>[optional blank line(s), stripped]</p>
2200 * <var>change details</var>
2201 <var>more change details</var>
2203 <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2205 * <var>even more change details</var>
2207 <p>[optional blank line(s), stripped]</p>
2209 -- <var>maintainer name</var> <<var>email
2210 address</var>><var>[two spaces]</var> <var>date</var>
2215 <var>package</var> and <var>version</var> are the source
2216 package name and version number.
2220 <var>distribution(s)</var> lists the distributions where
2221 this version should be installed when it is uploaded - it
2222 is copied to the <tt>Distribution</tt> field in the
2223 <file>.changes</file> file. See <ref id="f-Distribution">.
2227 <var>urgency</var> is the value for the <tt>Urgency</tt>
2228 field in the <file>.changes</file> file for the upload. It is
2229 not possible to specify an urgency containing commas; commas
2230 are used to separate
2231 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2232 <prgn>dpkg</prgn> changelog format (though there is
2233 currently only one useful <var>keyword</var>,
2234 <tt>urgency</tt>).<footnote>
2236 Recognised urgency values are <tt>low</tt>,
2237 <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2238 They have an effect on how quickly a package will be
2239 considered for inclusion into the <tt>testing</tt>
2240 distribution, and give an indication of the importance
2241 of any fixes included in this upload.
2247 The change details may in fact be any series of lines
2248 starting with at least two spaces, but conventionally each
2249 change starts with an asterisk and a separating space and
2250 continuation lines are indented so as to bring them in
2251 line with the start of the text above. Blank lines may be
2252 used here to separate groups of changes, if desired.
2256 If this upload resolves bugs recorded in the Bug Tracking
2257 System (BTS), they may be automatically closed on the
2258 inclusion of this package into the Debian archive by
2259 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2260 in the change details.<footnote>
2262 To be precise, the string should match the following
2263 Perl regular expression:
2265 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2267 Then all of the bug numbers listed will be closed by the
2268 archive maintenance script (<prgn>katie</prgn>), or in
2269 the case of an NMU, marked as fixed.
2275 The maintainer name and email address used in the changelog
2276 should be the details of the person uploading <em>this</em>
2277 version. They are <em>not</em> necessarily those of the
2278 usual package maintainer. The information here will be
2279 copied to the <tt>Changed-By</tt> field in the
2280 <tt>.changes</tt> file, and then later used to send an
2281 acknowledgement when the upload has been installed.
2285 The <var>date</var> should be in RFC822 format<footnote>
2287 This is generated by the <prgn>822-date</prgn>
2290 </footnote>; it should include the time zone specified
2291 numerically, with the time zone name or abbreviation
2292 optionally present as a comment in parentheses.
2296 The first `title' line with the package name should start
2297 at the left hand margin; the `trailer' line with the
2298 maintainer and date details should be preceded by exactly
2299 one space. The maintainer details and the date must be
2300 separated by exactly two spaces.
2303 <sect1><heading>Defining alternative changelog formats</heading>
2306 It is possible to use a different format to the standard
2307 one, by providing a parser for the format you wish to
2311 A changelog parser must not interact with the user at
2317 <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2318 and variable substitutions </heading>
2321 When <prgn>dpkg-gencontrol</prgn>,
2322 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2323 generate control files they perform variable substitutions
2324 on their output just before writing it. Variable
2325 substitutions have the form <tt>${<var>variable</var>}</tt>.
2326 The optional file <file>debian/substvars</file> contains
2327 variable substitutions to be used; variables can also be set
2328 directly from <file>debian/rules</file> using the <tt>-V</tt>
2329 option to the source packaging commands, and certain
2330 predefined variables are also available.
2334 The <file>debian/substvars</file> file is usually generated and
2335 modified dynamically by <file>debian/rules</file> targets; in
2336 this case it must be removed by the <tt>clean</tt>
2341 See <manref name="dpkg-source" section="1"> for full
2342 details about source variable substitutions, including the
2343 format of <file>debian/substvars</file>.</p>
2346 <sect id="debianfiles"><heading><file>debian/files</file>
2350 This file is not a permanent part of the source tree; it
2351 is used while building packages to record which files are
2352 being generated. <prgn>dpkg-genchanges</prgn> uses it
2353 when it generates a <file>.changes</file> file.
2357 It should not exist in a shipped source package, and so it
2358 (and any backup files or temporary files such as
2359 <file>files.new</file><footnote>
2361 <file>files.new</file> is used as a temporary file by
2362 <prgn>dpkg-gencontrol</prgn> and
2363 <prgn>dpkg-distaddfile</prgn> - they write a new
2364 version of <tt>files</tt> here before renaming it,
2365 to avoid leaving a corrupted copy if an error
2368 </footnote>) should be removed by the
2369 <tt>clean</tt> target. It may also be wise to
2370 ensure a fresh start by emptying or removing it at the
2371 start of the <tt>binary</tt> target.
2375 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2376 package, it adds an entry to <file>debian/files</file> for the
2377 <file>.deb</file> file that will be created when <tt>dpkg-deb
2378 --build</tt> is run for that binary package. So for most
2379 packages all that needs to be done with this file is to
2380 delete it in the <tt>clean</tt> target.
2384 If a package upload includes files besides the source
2385 package and any binary packages whose control files were
2386 made with <prgn>dpkg-gencontrol</prgn> then they should be
2387 placed in the parent of the package's top-level directory
2388 and <prgn>dpkg-distaddfile</prgn> should be called to add
2389 the file to the list in <file>debian/files</file>.</p>
2392 <sect id="restrictions"><heading>Restrictions on objects in source packages
2396 The source package may not contain any hard links<footnote>
2398 This is not currently detected when building source
2399 packages, but only when extracting
2403 Hard links may be permitted at some point in the
2404 future, but would require a fair amount of
2407 </footnote>, device special files, sockets or setuid or
2408 setgid files.<footnote>
2410 Setgid directories are allowed.
2415 <sect id="descriptions"><heading>Descriptions of packages - the
2416 <tt>Description</tt> field </heading>
2419 The description is intended to describe the program to a user
2420 who has never met it before so that they know whether they
2421 want to install it. It should also give information about the
2422 significant dependencies and conflicts between this package
2423 and others, so that the user knows why these dependencies and
2424 conflicts have been declared.
2427 <sect1><heading>Notes about writing descriptions
2431 The single line synopsis should be kept brief - certainly
2432 under 80 characters.
2436 Do not include the package name in the synopsis line. The
2437 display software knows how to display this already, and you
2438 do not need to state it. Remember that in many situations
2439 the user may only see the synopsis line - make it as
2440 informative as you can.
2444 Do not try to continue the single line synopsis into the
2445 extended description. This will not work correctly when
2446 the full description is displayed, and makes no sense
2447 where only the summary (the single line synopsis) is
2452 The extended description should describe what the package
2453 does and how it relates to the rest of the system (in terms
2454 of, for example, which subsystem it is which part of).
2458 The description field needs to make sense to anyone, even
2459 people who have no idea about any of the things the
2460 package deals with.<footnote>
2462 The blurb that comes with a program in its
2463 announcements and/or <prgn>README</prgn> files is
2464 rarely suitable for use in a description. It is
2465 usually aimed at people who are already in the
2466 community where the package is used.
2472 Put important information first, both in the synopsis and
2473 extended description. Sometimes only the first part of the
2474 synopsis or of the description will be displayed. You can
2475 assume that there will usually be a way to see the whole
2476 extended description.
2480 You may include information about dependencies and so forth
2481 in the extended description, if you wish.
2485 Do not use tab characters. Their effect is not predictable.
2493 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2494 and installation procedure
2497 <sect><heading>Introduction to package maintainer scripts
2501 It is possible to supply scripts as part of a package which
2502 the package management system will run for you when your
2503 package is installed, upgraded or removed.
2507 These scripts are the files <prgn>preinst</prgn>,
2508 <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2509 control area of the package. They must be proper executable
2510 files; if they are scripts (which is recommended), they must
2511 start with the usual <tt>#!</tt> convention. They should be
2512 readable and executable by anyone, and not world-writable.
2516 The package management system looks at the exit status from
2517 these scripts. It is important that they exit with a
2518 non-zero status if there is an error, so that the package
2519 management system can stop its processing. For shell
2520 scripts this means that you <em>almost always</em> need to
2521 use <tt>set -e</tt> (this is usually true when writing shell
2522 scripts, in fact). It is also important, of course, that
2523 they don't exit with a non-zero status if everything went
2528 When a package is upgraded a combination of the scripts from
2529 the old and new packages is called during the upgrade
2530 procedure. If your scripts are going to be at all
2531 complicated you need to be aware of this, and may need to
2532 check the arguments to your scripts.
2536 Broadly speaking the <prgn>preinst</prgn> is called before
2537 (a particular version of) a package is installed, and the
2538 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2539 before (a version of) a package is removed and the
2540 <prgn>postrm</prgn> afterwards.
2544 Programs called from maintainer scripts should not normally
2545 have a path prepended to them. Before installation is
2546 started, the package management system checks to see if the
2547 programs <prgn>ldconfig</prgn>,
2548 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2549 and <prgn>update-rc.d</prgn> can be found via the
2550 <tt>PATH</tt> environment variable. Those programs, and any
2551 other program that one would expect to be on the
2552 <tt>PATH</tt>, should thus be invoked without an absolute
2553 pathname. Maintainer scripts should also not reset the
2554 <tt>PATH</tt>, though they might choose to modify it by
2555 prepending or appending package-specific directories. These
2556 considerations really apply to all shell scripts.</p>
2560 <heading>Maintainer scripts Idempotency</heading>
2563 It is necessary for the error recovery procedures that the
2564 scripts be idempotent. This means that if it is run
2565 successfully, and then it is called again, it doesn't bomb
2566 out or cause any harm, but just ensures that everything is
2567 the way it ought to be. If the first call failed, or
2568 aborted half way through for some reason, the second call
2569 should merely do the things that were left undone the first
2570 time, if any, and exit with a success status if everything
2573 This is so that if an error occurs, the user interrupts
2574 <prgn>dpkg</prgn> or some other unforeseen circumstance
2575 happens you don't leave the user with a badly-broken
2576 package when <prgn>dpkg</prgn> attempts to repeat the
2584 <heading>Controlling terminal for maintainer scripts</heading>
2587 The maintainer scripts are guaranteed to run with a
2588 controlling terminal and can interact with the user.
2589 If they need to prompt for passwords, do full-screen
2590 interaction or something similar you should do these
2591 things to and from <file>/dev/tty</file>, since
2592 <prgn>dpkg</prgn> will at some point redirect scripts'
2593 standard input and output so that it can log the
2594 installation process. Likewise, because these scripts
2595 may be executed with standard output redirected into a
2596 pipe for logging purposes, Perl scripts should set
2597 unbuffered output by setting <tt>$|=1</tt> so that the
2598 output is printed immediately rather than being
2603 Each script should return a zero exit status for
2604 success, or a nonzero one for failure.
2608 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2613 <list compact="compact">
2615 <p><var>new-preinst</var> <tt>install</tt></p>
2618 <p><var>new-preinst</var> <tt>install</tt>
2619 <var>old-version</var></p>
2622 <p><var>new-preinst</var> <tt>upgrade</tt>
2623 <var>old-version</var></p>
2626 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2627 <var>new-version</var>
2633 <list compact="compact">
2635 <p><var>postinst</var> <tt>configure</tt>
2636 <var>most-recently-configured-version</var></p>
2639 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2640 <var>new-version</var></p>
2643 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2644 <tt>in-favour</tt> <var>package</var>
2645 <var>new-version</var></p>
2649 <var>deconfigured's-postinst</var>
2650 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2651 <var>failed-install-package</var> <var>version</var>
2652 <tt>removing</tt> <var>conflicting-package</var>
2659 <list compact="compact">
2661 <p><var>prerm</var> <tt>remove</tt></p>
2664 <p><var>old-prerm</var> <tt>upgrade</tt>
2665 <var>new-version</var></p>
2668 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2669 <var>old-version</var></p>
2672 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2673 <tt>in-favour</tt> <var>package</var>
2674 <var>new-version</var></p>
2678 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2679 <tt>in-favour</tt> <var>package-being-installed</var>
2680 <var>version</var> <tt>removing</tt>
2681 <var>conflicting-package</var>
2688 <list compact="compact">
2690 <p><var>postrm</var> <tt>remove</tt></p>
2693 <p><var>postrm</var> <tt>purge</tt></p>
2697 <var>old-postrm</var> <tt>upgrade</tt>
2698 <var>new-version</var></p>
2701 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2702 <var>old-version</var></p>
2705 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2708 <p><var>new-postrm</var> <tt>abort-install</tt>
2709 <var>old-version</var></p>
2712 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2713 <var>old-version</var></p>
2717 <var>disappearer's-postrm</var> <tt>disappear</tt>
2718 <var>overwriter</var>
2719 <var>overwriter-version</var></p></item>
2724 <sect id="unpackphase"><heading>Details of unpack phase of
2725 installation or upgrade
2729 The procedure on installation/upgrade/overwrite/disappear
2730 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2731 stage of <tt>dpkg --install</tt>) is as follows. In each
2732 case, if a major error occurs (unless listed below) the
2733 actions are, in general, run backwards - this means that the
2734 maintainer scripts are run with different arguments in
2735 reverse order. These are the `error unwind' calls listed
2743 <p>If a version of the package is already
2745 <example compact="compact">
2746 <var>old-prerm</var> upgrade <var>new-version</var>
2751 If the script runs but exits with a non-zero
2752 exit status, <prgn>dpkg</prgn> will attempt:
2753 <example compact="compact">
2754 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2756 Error unwind, for both the above cases:
2757 <example compact="compact">
2758 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2766 <p>If a `conflicting' package is being removed at the same time:
2770 If any packages depended on that conflicting
2771 package and <tt>--auto-deconfigure</tt> is
2772 specified, call, for each such package:
2773 <example compact="compact">
2774 <var>deconfigured's-prerm</var> deconfigure \
2775 in-favour <var>package-being-installed</var> <var>version</var> \
2776 removing <var>conflicting-package</var> <var>version</var>
2779 <example compact="compact">
2780 <var>deconfigured's-postinst</var> abort-deconfigure \
2781 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2782 removing <var>conflicting-package</var> <var>version</var>
2784 The deconfigured packages are marked as
2785 requiring configuration, so that if
2786 <tt>--install</tt> is used they will be
2787 configured again if possible.</p>
2790 <p>To prepare for removal of the conflicting package, call:
2791 <example compact="compact">
2792 <var>conflictor's-prerm</var> remove \
2793 in-favour <var>package</var> <var>new-version</var>
2796 <example compact="compact">
2797 <var>conflictor's-postinst</var> abort-remove \
2798 in-favour <var>package</var> <var>new-version</var>
2809 <p>If the package is being upgraded, call:
2810 <example compact="compact">
2811 <var>new-preinst</var> upgrade <var>old-version</var>
2816 Otherwise, if the package had some configuration
2817 files from a previous version installed (i.e., it
2818 is in the `configuration files only' state):
2819 <example compact="compact">
2820 <var>new-preinst</var> install <var>old-version</var>
2824 <p>Otherwise (i.e., the package was completely purged):
2825 <example compact="compact">
2826 <var>new-preinst</var> install
2828 Error unwind actions, respectively:
2829 <example compact="compact">
2830 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2831 <var>new-postrm</var> abort-install <var>old-version</var>
2832 <var>new-postrm</var> abort-install
2841 The new package's files are unpacked, overwriting any
2842 that may be on the system already, for example any
2843 from the old version of the same package or from
2844 another package. Backups of the old files are kept
2845 temporarily, and if anything goes wrong the package
2846 management system will attempt to put them back as
2847 part of the error unwind.
2851 It is an error for a package to contains files which
2852 are on the system in another package, unless
2853 <tt>Replaces</tt> is used (see <ref id="replaces">).
2855 The following paragraph is not currently the case:
2856 Currently the <tt>- - force-overwrite</tt> flag is
2857 enabled, downgrading it to a warning, but this may not
2863 It is a more serious error for a package to contain a
2864 plain file or other kind of non-directory where another
2865 package has a directory (again, unless
2866 <tt>Replaces</tt> is used). This error can be
2867 overridden if desired using
2868 <tt>--force-overwrite-dir</tt>, but this is not
2873 Packages which overwrite each other's files produce
2874 behavior which, though deterministic, is hard for the
2875 system administrator to understand. It can easily
2876 lead to `missing' programs if, for example, a package
2877 is installed which overwrites a file from another
2878 package, and is then removed again.<footnote>
2880 Part of the problem is due to what is arguably a
2881 bug in <prgn>dpkg</prgn>.
2887 A directory will never be replaced by a symbolic link
2888 to a directory or vice versa; instead, the existing
2889 state (symlink or not) will be left alone and
2890 <prgn>dpkg</prgn> will follow the symlink if there is
2898 <p>If the package is being upgraded, call
2899 <example compact="compact">
2900 <var>old-postrm</var> upgrade <var>new-version</var>
2905 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2906 <example compact="compact">
2907 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2909 Error unwind, for both cases:
2910 <example compact="compact">
2911 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2918 This is the point of no return - if
2919 <prgn>dpkg</prgn> gets this far, it won't back off
2920 past this point if an error occurs. This will
2921 leave the package in a fairly bad state, which
2922 will require a successful re-installation to clear
2923 up, but it's when <prgn>dpkg</prgn> starts doing
2924 things that are irreversible.
2929 Any files which were in the old version of the package
2930 but not in the new are removed.</p>
2933 <p>The new file list replaces the old.</p>
2936 <p>The new maintainer scripts replace the old.</p>
2940 <p>Any packages all of whose files have been overwritten during the
2941 installation, and which aren't required for
2942 dependencies, are considered to have been removed.
2943 For each such package
2946 <p><prgn>dpkg</prgn> calls:
2947 <example compact="compact">
2948 <var>disappearer's-postrm</var> disappear \
2949 <var>overwriter</var> <var>overwriter-version</var>
2954 <p>The package's maintainer scripts are removed.
2959 It is noted in the status database as being in a
2960 sane state, namely not installed (any conffiles
2961 it may have are ignored, rather than being
2962 removed by <prgn>dpkg</prgn>). Note that
2963 disappearing packages do not have their prerm
2964 called, because <prgn>dpkg</prgn> doesn't know
2965 in advance that the package is going to
2974 Any files in the package we're unpacking that are also
2975 listed in the file lists of other packages are removed
2976 from those lists. (This will lobotomize the file list
2977 of the `conflicting' package if there is one.)
2982 The backup files made during installation, above, are
2989 The new package's status is now sane, and recorded as
2994 Here is another point of no return - if the
2995 conflicting package's removal fails we do not unwind
2996 the rest of the installation; the conflicting package
2997 is left in a half-removed limbo.
3003 If there was a conflicting package we go and do the
3004 removal actions (described below), starting with the
3005 removal of the conflicting package's files (any that
3006 are also in the package being installed have already
3007 been removed from the conflicting package's file list,
3008 and so do not get removed now).
3015 <sect id="configdetails"><heading>Details of configuration</heading>
3018 When we configure a package (this happens with <tt>dpkg
3019 --install</tt> and <tt>dpkg --configure</tt>), we first
3020 update any <tt>conffile</tt>s and then call:
3021 <example compact="compact">
3022 <var>postinst</var> configure <var>most-recently-configured-version</var>
3027 No attempt is made to unwind after errors during
3032 If there is no most recently configured version
3033 <prgn>dpkg</prgn> will pass a null argument; older versions
3034 of dpkg may pass <tt><unknown></tt> (including the
3035 angle brackets) in this case. Even older ones do not pass a
3036 second argument at all, under any circumstances.
3040 <sect id="removedetails"><heading>Details of removal and/or
3041 configuration purging</heading>
3047 <example compact="compact">
3048 <var>prerm</var> remove
3054 The package's files are removed (except <tt>conffile</tt>s).
3059 <example compact="compact">
3060 <var>postrm</var> remove
3066 All the maintainer scripts except the <prgn>postrm</prgn>
3071 If we aren't purging the package we stop here. Note
3072 that packages which have no <prgn>postrm</prgn> and no
3073 <tt>conffile</tt>s are automatically purged when
3074 removed, as there is no difference except for the
3075 <prgn>dpkg</prgn> status.</p>
3079 The <tt>conffile</tt>s and any backup files
3080 (<tt>~</tt>-files, <tt>#*#</tt> files,
3081 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3086 <example compact="compact">
3087 <var>postrm</var> purge
3092 <p>The package's file list is removed.</p>
3095 No attempt is made to unwind after errors during
3102 <chapt id="relationships"><heading>Declaring relationships between
3106 Packages can declare in their control file that they have
3107 certain relationships to other packages - for example, that
3108 they may not be installed at the same time as certain other
3109 packages, and/or that they depend on the presence of others,
3110 or that they should overwrite files in certain other packages
3115 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3116 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3117 <tt>Conflicts</tt>, <tt>Provides</tt> and <tt>Replaces</tt>
3118 control file fields.
3122 Source packages may declare relationships to binary packages,
3123 saying that they require certain binary packages to be
3124 installed or absent at the time of building the package.
3128 This is done using the <tt>Build-Depends</tt>,
3129 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3130 <tt>Build-Conflicts-Indep</tt> control file fields.
3133 <sect id="depsyntax"><heading>Syntax of relationship fields
3137 These fields all have a uniform syntax. They are a list of
3138 package names separated by commas.
3142 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3143 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3144 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3145 control file fields of the package, which declare
3146 dependencies on other packages, the package names listed may
3147 also include lists of alternative package names, separated
3148 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3149 if any one of the alternative packages is installed, that
3150 part of the dependency is considered to be satisfied.
3154 All of the fields except for <tt>Provides</tt> may restrict
3155 their applicability to particular versions of each named
3156 package. This is done in parentheses after each individual
3157 package name; the parentheses should contain a relation from
3158 the list below followed by a version number, in the format
3159 described in <ref id="versions">.
3163 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3164 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3165 strictly earlier, earlier or equal, exactly equal, later or
3166 equal and strictly later, respectively. The deprecated
3167 forms <tt><</tt> and <tt>></tt> were used to mean
3168 earlier/later or equal, rather than strictly earlier/later,
3169 so they should not appear in new packages (though
3170 <prgn>dpkg</prgn> still supports them).
3174 Whitespace may appear at any point in the version
3175 specification subject to the rules in <ref
3176 id="controlsyntax">, and must appear where it's necessary to
3177 disambiguate; it is not otherwise significant. For
3178 consistency and in case of future changes to
3179 <prgn>dpkg</prgn> it is recommended that a single space be
3180 used after a version relationship and before a version
3181 number; it is also conventional to put a single space after
3182 each comma, on either side of each vertical bar, and before
3183 each open parenthesis.
3187 For example, a list of dependencies might appear as:
3188 <example compact="compact">
3191 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3196 All fields that specify build-time relationships
3197 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3198 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3199 may be restricted to a certain set of architectures. This
3200 is indicated in brackets after each individual package name and
3201 the optional version specification. The brackets enclose a
3202 list of Debian architecture names separated by whitespace.
3203 Exclamation marks may be prepended to each of the names.
3204 (It is not permitted for some names to be prepended with
3205 exclamation marks and others not.) If the current Debian
3206 host architecture is not in this list and there are no
3207 exclamation marks in the list, or it is in the list with a
3208 prepended exclamation mark, the package name and the
3209 associated version specification are ignored completely for
3210 the purposes of defining the relationships.
3215 <example compact="compact">
3217 Build-Depends-Indep: texinfo
3218 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3219 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3224 Note that the binary package relationship fields such as
3225 <tt>Depends</tt> appear in one of the binary package
3226 sections of the control file, whereas the build-time
3227 relationships such as <tt>Build-Depends</tt> appear in the
3228 source package section of the control file (which is the
3234 <heading>Binary Dependencies - <tt>Depends</tt>,
3235 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3236 <tt>Pre-Depends</tt>
3240 These five fields are used to declare a dependency
3241 relationship by one package on another. Except for
3242 <tt>Enhances</tt>, they appear in the depending (binary)
3243 package's control file. (<tt>Enhances</tt> appears in the
3244 recommending package's control file.)
3248 A <tt>Depends</tt> field takes effect <em>only</em> when a
3249 package is to be configured. It does not prevent a package
3250 being on the system in an unconfigured state while its
3251 dependencies are unsatisfied, and it is possible to replace
3252 a package whose dependencies are satisfied and which is
3253 properly installed with a different version whose
3254 dependencies are not and cannot be satisfied; when this is
3255 done the depending package will be left unconfigured (since
3256 attempts to configure it will give errors) and will not
3257 function properly. If it is necessary, a
3258 <tt>Pre-Depends</tt> field can be used, which has a partial
3259 effect even when a package is being unpacked, as explained
3260 in detail below. (The other three dependency fields,
3261 <tt>Recommends</tt>, <tt>Suggests</tt> and
3262 <tt>Enhances</tt>, are only used by the various front-ends
3263 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3267 For this reason packages in an installation run are usually
3268 all unpacked first and all configured later; this gives
3269 later versions of packages with dependencies on later
3270 versions of other packages the opportunity to have their
3271 dependencies satisfied.
3275 The <tt>Depends</tt> field thus allows package maintainers
3276 to impose an order in which packages should be configured.
3280 The meaning of the five dependency fields is as follows:
3282 <tag><tt>Depends</tt></tag>
3285 This declares an absolute dependency. A package will
3286 not be configured unless all of the packages listed in
3287 its <tt>Depends</tt> field have been correctly
3292 The <tt>Depends</tt> field should be used if the
3293 depended-on package is required for the depending
3294 package to provide a significant amount of
3298 The <tt>Depends</tt> field should also be used if the
3299 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3300 <prgn>postrm</prgn> scripts require the package to be
3301 present in order to run. Note, however, that the
3302 <prgn>postrm</prgn> cannot rely on any non-essential
3303 packages to be present during the <tt>purge</tt>
3307 <tag><tt>Recommends</tt></tag>
3309 <p>This declares a strong, but not absolute, dependency.
3313 The <tt>Recommends</tt> field should list packages
3314 that would be found together with this one in all but
3315 unusual installations.</p>
3318 <tag><tt>Suggests</tt></tag>
3321 This is used to declare that one package may be more
3322 useful with one or more others. Using this field
3323 tells the packaging system and the user that the
3324 listed packages are related to this one and can
3325 perhaps enhance its usefulness, but that installing
3326 this one without them is perfectly reasonable.
3330 <tag><tt>Enhances</tt></tag>
3333 This field is similar to Suggests but works in the
3334 opposite direction. It is used to declare that a
3335 package can enhance the functionality of another
3340 <tag><tt>Pre-Depends</tt></tag>
3343 This field is like <tt>Depends</tt>, except that it
3344 also forces <prgn>dpkg</prgn> to complete installation
3345 of the packages named before even starting the
3346 installation of the package which declares the
3347 pre-dependency, as follows:
3351 When a package declaring a pre-dependency is about to
3352 be <em>unpacked</em> the pre-dependency can be
3353 satisfied if the depended-on package is either fully
3354 configured, <em>or even if</em> the depended-on
3355 package(s) are only unpacked or half-configured,
3356 provided that they have been configured correctly at
3357 some point in the past (and not removed or partially
3358 removed since). In this case, both the
3359 previously-configured and currently unpacked or
3360 half-configured versions must satisfy any version
3361 clause in the <tt>Pre-Depends</tt> field.
3365 When the package declaring a pre-dependency is about
3366 to be <em>configured</em>, the pre-dependency will be
3367 treated as a normal <tt>Depends</tt>, that is, it will
3368 be considered satisfied only if the depended-on
3369 package has been correctly configured.
3373 <tt>Pre-Depends</tt> should be used sparingly,
3374 preferably only by packages whose premature upgrade or
3375 installation would hamper the ability of the system to
3376 continue with any upgrade that might be in progress.
3380 <tt>Pre-Depends</tt> are also required if the
3381 <prgn>preinst</prgn> script depends on the named
3382 package. It is best to avoid this situation if
3388 When selecting which level of dependency to use you should
3389 consider how important the depended-on package is to the
3390 functionality of the one declaring the dependency. Some
3391 packages are composed of components of varying degrees of
3392 importance. Such a package should list using
3393 <tt>Depends</tt> the package(s) which are required by the
3394 more important components. The other components'
3395 requirements may be mentioned as Suggestions or
3396 Recommendations, as appropriate to the components' relative
3401 <sect id="conflicts"><heading>Conflicting binary packages -
3402 <tt>Conflicts</tt></heading>
3405 When one binary package declares a conflict with another
3406 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3407 refuse to allow them to be installed on the system at the
3412 If one package is to be installed, the other must be removed
3413 first - if the package being installed is marked as
3414 replacing (see <ref id="replaces">) the one on the system,
3415 or the one on the system is marked as deselected, or both
3416 packages are marked <tt>Essential</tt>, then
3417 <prgn>dpkg</prgn> will automatically remove the package
3418 which is causing the conflict, otherwise it will halt the
3419 installation of the new package with an error. This
3420 mechanism is specifically designed to produce an error when
3421 the installed package is <tt>Essential</tt>, but the new
3426 A package will not cause a conflict merely because its
3427 configuration files are still installed; it must be at least
3432 A special exception is made for packages which declare a
3433 conflict with their own package name, or with a virtual
3434 package which they provide (see below): this does not
3435 prevent their installation, and allows a package to conflict
3436 with others providing a replacement for it. You use this
3437 feature when you want the package in question to be the only
3438 package providing some feature.
3442 A <tt>Conflicts</tt> entry should almost never have an
3443 `earlier than' version clause. This would prevent
3444 <prgn>dpkg</prgn> from upgrading or installing the package
3445 which declared such a conflict until the upgrade or removal
3446 of the conflicted-with package had been completed.
3450 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3454 As well as the names of actual (`concrete') packages, the
3455 package relationship fields <tt>Depends</tt>,
3456 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3457 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3458 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3459 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3460 may mention `virtual packages'.
3464 A <em>virtual package</em> is one which appears in the
3465 <tt>Provides</tt> control file field of another package.
3466 The effect is as if the package(s) which provide a
3467 particular virtual package name had been listed by name
3468 everywhere the virtual package name appears. (See also <ref
3469 id="virtual_pkg_sect">)
3473 If there are both concrete and virtual packages of the same
3474 name, then the dependency may be satisfied (or the conflict
3475 caused) by either the concrete package with the name in
3476 question or any other concrete package which provides the
3477 virtual package with the name in question. This is so that,
3478 for example, supposing we have
3479 <example compact="compact">
3483 and someone else releases an enhanced version of the
3484 <tt>bar</tt> package (for example, a non-US variant), they
3486 <example compact="compact">
3490 and the <tt>bar-plus</tt> package will now also satisfy the
3491 dependency for the <tt>foo</tt> package.
3495 If a dependency or a conflict has a version number attached
3496 then only real packages will be considered to see whether
3497 the relationship is satisfied (or the prohibition violated,
3498 for a conflict) - it is assumed that a real package which
3499 provides the virtual package is not of the `right' version.
3500 So, a <tt>Provides</tt> field may not contain version
3501 numbers, and the version number of the concrete package
3502 which provides a particular virtual package will not be
3503 looked at when considering a dependency on or conflict with
3504 the virtual package name.
3508 It is likely that the ability will be added in a future
3509 release of <prgn>dpkg</prgn> to specify a version number for
3510 each virtual package it provides. This feature is not yet
3511 present, however, and is expected to be used only
3516 If you want to specify which of a set of real packages
3517 should be the default to satisfy a particular dependency on
3518 a virtual package, you should list the real package as an
3519 alternative before the virtual one.
3524 <sect id="replaces"><heading>Overwriting files and replacing
3525 packages - <tt>Replaces</tt></heading>
3528 The <tt>Replaces</tt> control file field has two distinct
3529 purposes, which come into play in different situations.
3532 <sect1><heading>Overwriting files in other packages</heading>
3535 Firstly, as mentioned before, it is usually an error for a
3536 package to contain files which are on the system in
3541 However, if the overwriting package declares that it
3542 <tt>Replaces</tt> the one containing the file being
3543 overwritten, then <prgn>dpkg</prgn> will replace the file
3544 from the old package with that from the new. The file
3545 will no longer be listed as `owned' by the old package.
3549 If a package is completely replaced in this way, so that
3550 <prgn>dpkg</prgn> does not know of any files it still
3551 contains, it is considered to have `disappeared'. It will
3552 be marked as not wanted on the system (selected for
3553 removal) and not installed. Any <tt>conffile</tt>s
3554 details noted for the package will be ignored, as they
3555 will have been taken over by the overwriting package. The
3556 package's <prgn>postrm</prgn> script will be run with a
3557 special argument to allow the package to do any final
3558 cleanup required. See <ref id="mscriptsinstact">.
3562 If an installed package, <tt>foo</tt> say, declares that
3563 it replaces another, <tt>bar</tt>, and an attempt is made
3564 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3565 files in the <tt>bar</tt> package which would overwrite
3566 those already present in <tt>foo</tt>. This is so that
3567 you can install an older version of a package without
3572 For this usage of <tt>Replaces</tt>, virtual packages (see
3573 <ref id="virtual">) are not considered when looking at a
3574 <tt>Replaces</tt> field - the packages declared as being
3575 replaced must be mentioned by their real names.
3579 Furthermore, this usage of <tt>Replaces</tt> only takes
3580 effect when both packages are at least partially on the
3581 system at once, so that it can only happen if they do not
3582 conflict or if the conflict has been overridden.
3587 <sect1><heading>Replacing whole packages, forcing their
3591 Secondly, <tt>Replaces</tt> allows the packaging system to
3592 resolve which package should be removed when there is a
3593 conflict - see <ref id="conflicts">. This usage only
3594 takes effect when the two packages <em>do</em> conflict,
3595 so that the two usages of this field do not interfere with
3600 In this situation, the package declared as being replaced
3601 can be a virtual package, so for example, all mail
3602 transport agents (MTAs) would have the following fields in
3603 their control files:
3604 <example compact="compact">
3605 Provides: mail-transport-agent
3606 Conflicts: mail-transport-agent
3607 Replaces: mail-transport-agent
3609 ensuring that only one MTA can be installed at any one
3614 <sect><heading>Relationships between source and binary packages -
3615 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3616 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3620 A source package may declare a dependency or a conflict on a
3621 binary package, indicating which packages are required to be
3622 present on the system in order to build the binary packages
3623 from the source package. This is done with the control file
3624 fields <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3625 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>.
3626 The dependencies and conflicts they define must be satisfied
3627 (as defined earlier for binary packages) in order to invoke
3628 the targets in <tt>debian/rules</tt>, as follows:<footnote>
3630 If you make "build-arch" or "binary-arch", you need
3631 Build-Depends. If you make "build-indep" or
3632 "binary-indep", you need Build-Depends and
3633 Build-Depends-Indep. If you make "build" or "binary",
3637 There is no Build-Depends-Arch; the autobuilders will
3638 only need the Build-Depends if they know how to build
3639 only build-arch and binary-arch. Anyone building the
3640 build-indep/binary-indep targets is basically assumed to
3641 be building the whole package and so installs all build
3645 The purpose of the original split, I recall, was so that
3646 the autobuilders wouldn't need to install extra packages
3647 needed only for the binary-indep targets. But without a
3648 build-arch/build-indep split, this didn't work, since
3649 most of the work is done in the build target, not in the
3655 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3658 The <tt>Build-Depends</tt> and
3659 <tt>Build-Conflicts</tt> fields must be satisfied when
3660 any of the following targets is invoked:
3661 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>,
3662 <tt>build-arch</tt>, <tt>build-indep</tt>
3663 and <tt>binary-indep</tt>.
3666 <tag><tt>Build-Depends-Indep</tt>,
3667 <tt>Build-Conflicts-Indep</tt></tag>
3670 The <tt>Build-Depends-Indep</tt> and
3671 <tt>Build-Conflicts-Indep</tt> fields must be
3672 satisfied when any of the following targets is
3673 invoked: <tt>build</tt>, <tt>build-indep</tt>,
3674 <tt>binary</tt> and <tt>binary-indep</tt>.
3685 <chapt id="conffiles"><heading>Configuration file handling
3689 This chapter has been superseded by <ref id="config-files">.
3693 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3696 Packages containing shared libraries must be constructed with
3697 a little care to make sure that the shared library is always
3698 available. This is especially important for packages whose
3699 shared libraries are vitally important, such as the C library
3700 (currently <tt>libc6</tt>).
3704 Firstly, the package should install the shared libraries under
3705 their normal names. For example, the <tt>libgdbmg1</tt>
3706 package should install <tt>libgdbm.so.1.7.3</tt> as
3707 <file>/usr/lib/libgdbm.so.1.7.3</file>. The files should not be
3708 renamed or re-linked by any <prgn>prerm</prgn> or
3709 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3710 of renaming things safely without affecting running programs,
3711 and attempts to interfere with this are likely to lead to
3716 Secondly, the package should include the symbolic link that
3717 <prgn>ldconfig</prgn> would create for the shared libraries.
3718 For example, the <prgn>libgdbmg1</prgn> package should include
3719 a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3720 <file>libgdbm.so.1.7.3</file>. This is needed so that the dynamic
3721 linker (for example <prgn>ld.so</prgn> or
3722 <prgn>ld-linux.so.*</prgn>) can find the library between the
3723 time that <prgn>dpkg</prgn> installs it and the time that
3724 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3727 The package management system requires the library to be
3728 placed before the symbolic link pointing to it in the
3729 <file>.deb</file> file. This is so that when
3730 <prgn>dpkg</prgn> comes to install the symlink
3731 (overwriting the previous symlink pointing at an older
3732 version of the library), the new shared library is already
3733 in place. In the past, this was achieved by creating the
3734 library in the temporary packaging directory before
3735 creating the symlink. Unfortunately, this was not always
3736 effective, since the building of the tar file in the
3737 <file>.deb</file> depended on the behavior of the underlying
3738 file system. Some file systems (such as reiserfs) reorder
3739 the files so that the order of creation is forgotten.
3740 Starting with release <tt>1.7.0</tt>, <prgn>dpkg</prgn>
3741 will reorder the files itself as necessary when building a
3742 package. Thus it is no longer important to concern
3743 oneself with the order of file creation.
3749 Thirdly, the associated development package should contain a
3750 symlink for the shared library without a version number. For
3751 example, the <tt>libgdbmg1-dev</tt> package should include a
3752 symlink from <tt>/usr/lib/libgdbm.so</tt> to
3753 <file>libgdbm.so.1.7.3</file>. This symlink is needed by the
3754 linker (<prgn>ld</prgn>) when compiling packages, as it will
3755 only look for <file>libgdbm.so</file> when compiling dynamically.
3759 Any package installing shared libraries in one of the default
3760 library directories of the dynamic linker (which are currently
3761 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3762 listed in <file>/etc/ld.so.conf</file><footnote>
3765 <list compact="compact">
3766 <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3767 <item><p>/usr/local/lib</p></item>
3768 <item><p>/usr/lib/libc5-compat</p></item>
3769 <item><p>/lib/libc5-compat</p></item>
3770 <item><p>/usr/X11R6/lib</p></item>
3774 must use <prgn>ldconfig</prgn> to update the shared library
3775 system. The package must call <prgn>ldconfig</prgn> in the
3776 <prgn>postinst</prgn> script if the first argument is
3777 <tt>configure</tt>; the <prgn>postinst</prgn> script may
3778 optionally invoke <prgn>ldconfig</prgn> at other times. The
3779 package should call <prgn>ldconfig</prgn> in the
3780 <prgn>postrm</prgn> script if the first argument is
3781 <tt>remove</tt>. The maintainer scripts must not invoke
3782 <prgn>ldconfig</prgn> under any circumstances other than those
3783 described in this paragraph.<footnote>
3784 <p>During install or upgrade, the preinst is called before
3785 the new files are installed, so calling "ldconfig" is
3786 pointless. The preinst of an existing package can also be
3787 called if an upgrade fails. However, this happens during
3788 the critical time when a shared libs may exist on-disk
3789 under a temporary name. Thus, it is dangerous and
3790 forbidden by current policy to call "ldconfig" at this
3791 time. When a package is installed or upgraded, "postinst
3792 configure" runs after the new files are safely on-disk.
3793 Since it is perfectly safe to invoke ldconfig
3794 unconditionally in a postinst, it is OK for a package to
3795 simply put ldconfig in its postinst without checking the
3796 argument. The postinst can also be called to recover from
3797 a failed upgrade. This happens before any new files are
3798 unpacked, so there is no reason to call "ldconfig" at this
3799 point. For a package that is being removed, prerm is
3800 called with all the files intact, so calling ldconfig is
3801 useless. The other calls to "prerm" happen in the case of
3802 upgrade at a time when all the files of the old package
3803 are on-disk, so again calling "ldconfig" is pointless. If
3804 An installed shared lib has been removed from the system
3805 just before "postrm remove" is run. This is the proper
3806 time to call "ldconfig" to notify the system of that fact.
3807 The postrm can be called at several other times. At the
3808 time of "postrm purge", "postrm abort-install", or "postrm
3809 abort-upgrade", calling "ldconfig" is useless because the
3810 shared lib files are not on-disk. However, when "postrm"
3811 is invoked with arguments "upgrade", "failed-upgrade", or
3812 "disappear", a shared lib may exist on-disk under a
3819 <heading>Handling shared library dependencies - the
3820 <tt>shlibs</tt> system</heading>
3823 If a package contains a binary or library which links to a
3824 shared library, we must ensure that when the package is
3825 installed on the system, all of the libraries needed are
3826 also installed. This requirement led to the creation of the
3827 <tt>shlibs</tt> system, which is very simple in its design:
3828 any package which <em>provides</em> a shared library also
3829 provides information on the package dependencies required to
3830 ensure the presence of this library, and any package which
3831 <em>uses</em> a shared library uses this information to
3832 determine the dependencies it requires. The files which
3833 contain the mapping from shared libraries to the necessary
3834 dependency information are called <file>shlibs</file> files.
3838 Thus, when a package is built which contains any shared
3839 libraries, it must provide a <file>shlibs</file> file for other
3840 packages to use, and when a package is built which contains
3841 any shared libraries or compiled binaries, it must run
3842 <prgn>dpkg-shlibdeps</prgn> on these to determine the
3843 libraries used and hence the dependencies needed by this
3846 In the past, the shared libraries linked to were
3847 determined by calling <prgn>ldd</prgn>, but now
3848 <prgn>objdump</prgn> is used to do this. The only
3849 change this makes to package building is that
3850 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
3851 libraries, whereas in the past this was unnecessary.
3852 The rest of this footnote explains the advantage that
3857 We say that a binary <tt>foo</tt> <em>directly</em> uses
3858 a library <tt>libbar</tt> if it is explicitly linked
3859 with that library (that is, it uses the flag
3860 <tt>-lbar</tt> during the linking stage). Other
3861 libraries that are needed by <tt>libbar</tt> are linked
3862 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
3863 linker will load them automatically when it loads
3864 <tt>libbar</tt>. A package should depend on
3865 the libraries it directly uses, and the dependencies for
3866 those libraries should automatically pull in the other
3871 Unfortunately, the <prgn>ldd</prgn> program shows both
3872 the directly and indirectly used libraries, meaning that
3873 the dependencies determined included both direct and
3874 indirect dependencies. The use of <prgn>objdump</prgn>
3875 avoids this problem by determining only the directly
3880 A good example of where this helps is the following. We
3881 could update <tt>libimlib</tt> with a new version that
3882 supports a new graphics format called dgf (but retaining
3883 the same major version number). If we used the old
3884 <prgn>ldd</prgn> method, every package that uses
3885 <tt>libimlib</tt> would need to be recompiled so it
3886 would also depend on <tt>libdgf</tt> or it wouldn't run
3887 due to missing symbols. However with the new system,
3888 packages using <tt>libimlib</tt> can rely on
3889 <tt>libimlib</tt> itself having the dependency on
3890 <tt>libdgf</tt> and so they would not need rebuilding.
3896 In the following sections, we will first describe where the
3897 various <tt>shlibs</tt> files are to be found, then how to
3898 use <prgn>dpkg-shlibdeps</prgn>, and finally the
3899 <tt>shlibs</tt> file format and how to create them if your
3900 package contains a shared library.
3904 <sect><heading>The <tt>shlibs</tt> files present on the system
3908 There are several places where <tt>shlibs</tt> files are
3909 found. The following list gives them in the order in which
3910 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
3911 one which gives the required information is used.)
3917 <p><file>debian/shlibs.local</file></p>
3919 This lists overrides for this package. Its use is
3920 described below (see <ref id="shlibslocal">).
3925 <p><file>/etc/dpkg/shlibs.override</file></p>
3927 This lists global overrides. This list is normally
3928 empty. It is maintained by the local system
3934 <p><file>DEBIAN/shlibs</file> files in the `build directory'</p>
3936 When packages are being built, any
3937 <file>debian/shlibs</file> files are copied into the
3938 control file area of the temporary build directory and
3939 given the name <file>shlibs</file>. These files give
3940 details of any shared libraries included in the
3943 An example may help here. Let us say that the
3944 source package <tt>foo</tt> generates two binary
3945 packages, <tt>libfoo2</tt> and
3946 <tt>foo-runtime</tt>. When building the binary
3947 packages, the two packages are created in the
3948 directories <file>debian/libfoo2</file> and
3949 <file>debian/foo-runtime</file> respectively.
3950 (<file>debian/tmp</file> could be used instead of one
3951 of these.) Since <tt>libfoo2</tt> provides the
3952 <tt>libfoo</tt> shared library, it will require a
3953 <tt>shlibs</tt> file, which will be installed in
3954 <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
3956 <file>/var/lib/dpkg/info/libfoo2.shlibs</file>. Then
3957 when <prgn>dpkg-shlibdeps</prgn> is run on the
3959 <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
3961 <file>debian/libfoo2/DEBIAN/shlibs</file> file to
3962 determine whether <tt>foo-prog</tt>'s library
3963 dependencies are satisfied by any of the libraries
3964 provided by <tt>libfoo2</tt>. For this reason,
3965 <prgn>dpkg-shlibdeps</prgn> must only be run once
3966 all of the individual binary packages'
3967 <tt>shlibs</tt> files have been installed into the
3975 <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
3977 These are the <file>shlibs</file> files corresponding to
3978 all of the packages installed on the system, and are
3979 maintained by the relevant package maintainers.
3984 <p><file>/etc/dpkg/shlibs.default</file></p>
3986 This file lists any shared libraries whose packages
3987 have failed to provide correct <file>shlibs</file> files.
3988 It was used when the <file>shlibs</file> setup was first
3989 introduced, but it is now normally empty. It is
3990 maintained by the <tt>dpkg</tt> maintainer.
3998 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
3999 <file>shlibs</file> files</heading>
4002 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4003 <file>debian/rules</file> file. If your package contains only
4004 compiled binaries and libraries (but no scripts), you can
4005 use a command such as:
4006 <example compact="compact">
4007 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4008 debian/tmp/usr/lib/*
4010 Otherwise, you will need to explicitly list the compiled
4011 binaries and libraries.<footnote>
4013 If you are using <tt>debhelper</tt>, the
4014 <prgn>dh_shlibdeps</prgn> program will do this work for
4015 you. It will also correctly handle multi-binary
4022 This command puts the dependency information into the
4023 <file>debian/substvars</file> file, which is then used by
4024 <prgn>dpkg-gencontrol</prgn>. You will need to place a
4025 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4026 field in the control file for this to work.
4030 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4031 done. If it does complain you might need to create your own
4032 <file>debian/shlibs.local</file> file, as explained below (see
4033 <ref id="shlibslocal">).
4037 If you have multiple binary packages, you will need to call
4038 <prgn>dpkg-shlibdeps</prgn> on each one which contains
4039 compiled libraries or binaries. In such a case, you will
4040 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4041 utilities to specify a different <file>substvars</file> file.
4042 For more details on this and other options, see <manref
4043 name="dpkg-shlibdeps" section="1">.
4047 <sect id="shlibs"><heading>The <file>shlibs</file> File Format
4051 Each <file>shlibs</file> file has the same format. Lines
4052 beginning with <tt>#</tt> are considered to be comments and
4053 are ignored. Each line is of the form:
4054 <example compact="compact">
4055 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4060 We will explain this by reference to the example of the
4061 <tt>zlib1g</tt> package, which (at the time of writing)
4062 installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4066 <var>library-name</var> is the name of the shared library,
4067 in this case <tt>libz</tt>. (This must match the name part
4068 of the soname, see below.)
4072 <var>soname-version-number</var> is the version part of the
4073 soname of the library. The soname is the thing that must
4074 exactly match for the library to be recognized by the
4075 dynamic linker, and is usually of the form
4076 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4077 example, <tt>libz.so.1</tt>.<footnote>
4079 This can be determined using the command
4080 <example compact="compact">
4081 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4085 The version part is the part which comes after
4086 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4090 <var>dependencies</var> has the same syntax as a dependency
4091 field in a binary package control file. It should give
4092 details of which packages are required to satisfy a binary
4093 built against the version of the library contained in the
4094 package. See <ref id="depsyntax"> for details.
4098 In our example, if the first version of the <tt>zlib1g</tt>
4099 package which contained a minor number of at least
4100 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4101 <tt>shlibs</tt> entry for this library could say:
4102 <example compact="compact">
4103 libz 1 zlib1g (>= 1:1.1.3)
4105 The version-specific dependency is to avoid warnings from
4106 the dynamic linker about using older shared libraries with
4112 <heading>Providing a <file>shlibs</file> file</heading>
4115 If your package provides a shared library, you should create
4116 a <file>shlibs</file> file following the format described above.
4117 It is usual to call this file <file>debian/shlibs</file> (but if
4118 you have multiple binary packages, you might want to call it
4119 <file>debian/shlibs.<var>package</var></file> instead). Then
4120 let <file>debian/rules</file> install it in the control area:
4121 <example compact="compact">
4122 install -m644 debian/shlibs debian/tmp/DEBIAN
4124 or, in the case of a multi-binary package:
4125 <example compact="compact">
4126 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4128 An alternative way of doing this is to create the
4129 <file>shlibs</file> file in the control area directly from
4130 <file>debian/rules</file> without using a <file>debian/shlibs</file>
4131 file at all,<footnote>
4133 This is what <prgn>dh_makeshlibs</prgn> in the
4134 <tt>debhelper</tt> suite does.
4137 since the <file>debian/shlibs</file> file itself is ignored by
4138 <prgn>dpkg-shlibdeps</prgn>.
4142 As <prgn>dpkg-shlibdeps</prgn> reads the
4143 <file>DEBIAN/shlibs</file> files in all of the binary packages
4144 being built from this source package, all of the
4145 <file>DEBIAN/shlibs</file> files should be installed before
4146 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4151 <sect id="shlibslocal">
4152 <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4155 This file is intended only as a <em>temporary</em> fix if
4156 your binaries or libraries depend on a library whose package
4157 does not yet provide a correct <file>shlibs</file> file.
4161 We will assume that you are trying to package a binary
4162 <tt>foo</tt>. When you try running
4163 <prgn>dpkg-shlibdeps</prgn> you get the following error
4164 message (<tt>-O</tt> displays the dependency information on
4165 <tt>stdout</tt> instead of writing it to
4166 <tt>debian/substvars</tt>, and the lines have been wrapped
4167 for ease of reading):
4168 <example compact="compact">
4169 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4170 dpkg-shlibdeps: warning: unable to find dependency
4171 information for shared library libbar (soname 1,
4172 path /usr/lib/libbar.so.1, dependency field Depends)
4173 shlibs:Depends=libc6 (>= 2.2.2-2)
4175 You can then run <prgn>ldd</prgn> on the binary to find the
4176 full location of the library concerned:
4177 <example compact="compact">
4179 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4180 libc.so.6 => /lib/libc.so.6 (0x40032000)
4181 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4183 So the <prgn>foo</prgn> binary depends on the
4184 <prgn>libbar</prgn> shared library, but no package seems to
4185 provide a <file>*.shlibs</file> file handling
4186 <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>. Let's
4187 determine the package responsible:
4188 <example compact="compact">
4189 $ dpkg -S /usr/lib/libbar.so.1
4190 bar1: /usr/lib/libbar.so.1
4191 $ dpkg -s bar1 | grep Version
4194 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4195 is the one we are using. Now we can file a bug against the
4196 <tt>bar1</tt> package and create our own
4197 <file>debian/shlibs.local</file> to locally fix the problem.
4198 Including the following line into your
4199 <file>debian/shlibs.local</file> file:
4200 <example compact="compact">
4201 libbar 1 bar1 (>= 1.0-1)
4203 should allow the package build to work.
4207 As soon as the maintainer of <tt>bar1</tt> provides a
4208 correct <file>shlibs</file> file, you should remove this line
4209 from your <file>debian/shlibs.local</file> file. (You should
4210 probably also then have a versioned <tt>Build-Depends</tt>
4211 on <tt>bar1</tt> to help ensure that others do not have the
4212 same problem building your package.)
4217 <chapt id="opersys"><heading>The Operating System</heading>
4220 <heading>Filesystem hierarchy</heading>
4224 <heading>Filesystem Structure</heading>
4227 The location of all installed files and directories must
4228 comply with the Filesystem Hierarchy Standard (FHS),
4229 version 2.1, except where doing so would violate other
4230 terms of Debian Policy. The version of this document
4231 referred here can be found in the <tt>debian-policy</tt>
4233 <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4234 name="FHS (Debian copy)"> alongside this manual (or, if
4235 you have the <package>debian-policy</package> installed,
4237 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4238 (local copy)">). The
4239 latest version, which may be a more recent version, may
4241 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4242 Specific questions about following the standard may be
4243 asked on the <tt>debian-devel</tt> mailing list, or
4244 referred to the FHS mailing list (see the
4245 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4251 <heading>Site-specific programs</heading>
4254 As mandated by the FHS, packages must not place any
4255 files in <file>/usr/local</file>, either by putting them in
4256 the file system archive to be unpacked by <prgn>dpkg</prgn>
4257 or by manipulating them in their maintainer scripts.
4261 However, the package may create empty directories below
4262 <file>/usr/local</file> so that the system administrator knows
4263 where to place site-specific files. These directories
4264 should be removed on package removal if they are
4269 Note, that this applies only to directories <em>below</em>
4270 <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4271 Packages must not create sub-directories in the directory
4272 <file>/usr/local</file> itself, except those listed in FHS,
4273 section 4.5. However, you may create directories below
4274 them as you wish. You must not remove any of the
4275 directories listed in 4.5, even if you created them.
4279 Since <file>/usr/local</file> can be mounted read-only from a
4280 remote server, these directories must be created and
4281 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4282 maintainer scripts and not be included in the
4283 <file>.deb</file> archive. These scripts must not fail if
4284 either of these operations fail.
4288 For example, the <tt>emacsen-common</tt> package could
4289 contain something like
4290 <example compact="compact">
4291 if [ ! -e /usr/local/share/emacs ]
4293 if mkdir /usr/local/share/emacs 2>/dev/null
4295 chown root:staff /usr/local/share/emacs
4296 chmod 2775 /usr/local/share/emacs
4300 in its <prgn>postinst</prgn> script, and
4301 <example compact="compact">
4302 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4303 rmdir /usr/local/share/emacs 2>/dev/null || true
4305 in the <prgn>prerm</prgn> script. (Note that this form is
4306 used to ensure that if the script is interrupted, the
4307 directory <file>/usr/local/share/emacs</file> will still be
4312 If you do create a directory in <file>/usr/local</file> for
4313 local additions to a package, you should ensure that
4314 settings in <file>/usr/local</file> take precedence over the
4315 equivalents in <file>/usr</file>.
4319 However, because <file>/usr/local</file> and its contents are
4320 for exclusive use of the local administrator, a package
4321 must not rely on the presence or absence of files or
4322 directories in <file>/usr/local</file> for normal operation.
4326 The <file>/usr/local</file> directory itself and all the
4327 subdirectories created by the package should (by default) have
4328 permissions 2775 (group-writable and set-group-id) and be
4329 owned by <tt>root.staff</tt>.
4334 <heading>The system-wide mail directory</heading>
4336 The system-wide mail directory is <file>/var/mail</file>. This
4337 directory is part of the base system and should not owned
4338 by any particular mail agents. The use of the old
4339 location <file>/var/spool/mail</file> is deprecated, even
4340 though the spool may still be physically located there.
4341 To maintain partial upgrade compatibility for systems
4342 which have <file>/var/spool/mail</file> as their physical mail
4343 spool, packages using <file>/var/mail</file> must depend on
4344 either <package>libc6</package> (>= 2.1.3-13), or on
4345 <package>base-files</package> (>= 2.2.0), or on later
4346 versions of either one of these packages.
4352 <heading>Users and groups</heading>
4355 <heading>Introduction</heading>
4357 The Debian system can be configured to use either plain or
4362 Some user ids (UIDs) and group ids (GIDs) are reserved
4363 globally for use by certain packages. Because some
4364 packages need to include files which are owned by these
4365 users or groups, or need the ids compiled into binaries,
4366 these ids must be used on any Debian system only for the
4367 purpose for which they are allocated. This is a serious
4368 restriction, and we should avoid getting in the way of
4369 local administration policies. In particular, many sites
4370 allocate users and/or local system groups starting at 100.
4374 Apart from this we should have dynamically allocated ids,
4375 which should by default be arranged in some sensible
4376 order, but the behavior should be configurable.
4380 Packages other than <tt>base-passwd</tt> must not modify
4381 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4382 <file>/etc/group</file> or <file>/etc/gshadow</file>.
4387 <heading>UID and GID classes</heading>
4389 The UID and GID numbers are divided into classes as
4395 Globally allocated by the Debian project, the same
4396 on every Debian system. These ids will appear in
4397 the <file>passwd</file> and <file>group</file> files of all
4398 Debian systems, new ids in this range being added
4399 automatically as the <tt>base-passwd</tt> package is
4404 Packages which need a single statically allocated
4405 uid or gid should use one of these; their
4406 maintainers should ask the <tt>base-passwd</tt>
4414 Dynamically allocated system users and groups.
4415 Packages which need a user or group, but can have
4416 this user or group allocated dynamically and
4417 differently on each system, should use <tt>adduser
4418 --system</tt> to create the group and/or user.
4419 <prgn>adduser</prgn> will check for the existence of
4420 the user or group, and if necessary choose an unused
4421 id based on the ranges specified in
4422 <file>adduser.conf</file>.
4426 <tag>1000-29999:</tag>
4429 Dynamically allocated user accounts. By default
4430 <prgn>adduser</prgn> will choose UIDs and GIDs for
4431 user accounts in this range, though
4432 <file>adduser.conf</file> may be used to modify this
4437 <tag>30000-59999:</tag>
4442 <tag>60000-64999:</tag>
4445 Globally allocated by the Debian project, but only
4446 created on demand. The ids are allocated centrally
4447 and statically, but the actual accounts are only
4448 created on users' systems on demand.
4452 These ids are for packages which are obscure or
4453 which require many statically-allocated ids. These
4454 packages should check for and create the accounts in
4455 <file>/etc/passwd</file> or <file>/etc/group</file> (using
4456 <prgn>adduser</prgn> if it has this facility) if
4457 necessary. Packages which are likely to require
4458 further allocations should have a `hole' left after
4459 them in the allocation, to give them room to
4464 <tag>65000-65533:</tag>
4472 User <tt>nobody</tt>. The corresponding gid refers
4473 to the group <tt>nogroup</tt>.
4480 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4481 not</em> be used, because it is the error return
4490 <sect id="sysvinit">
4491 <heading>System run levels and <file>init.d</file> scripts</heading>
4493 <sect1 id="/etc/init.d">
4494 <heading>Introduction</heading>
4497 The <file>/etc/init.d</file> directory contains the scripts
4498 executed by <prgn>init</prgn> at boot time and when the
4499 init state (or `runlevel') is changed (see <manref
4500 name="init" section="8">).
4504 There are at least two different, yet functionally
4505 equivalent, ways of handling these scripts. For the sake
4506 of simplicity, this document describes only the symbolic
4507 link method. However, it must not be assumed by maintainer
4508 scripts that this method is being used, and any automated
4509 manipulation of the various runlevel behaviours by
4510 maintainer scripts must be performed using
4511 <prgn>update-rc.d</prgn> as described below and not by
4512 manually installing or removing symlinks. For information
4513 on the implementation details of the other method,
4514 implemented in the <tt>file-rc</tt> package, please refer
4515 to the documentation of that package.
4519 These scripts are referenced by symbolic links in the
4520 <file>/etc/rc<var>n</var>.d</file> directories. When changing
4521 runlevels, <prgn>init</prgn> looks in the directory
4522 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4523 execute, where <tt><var>n</var></tt> is the runlevel that
4524 is being changed to, or <tt>S</tt> for the boot-up
4529 The names of the links all have the form
4530 <file>S<var>mm</var><var>script</var></file> or
4531 <file>K<var>mm</var><var>script</var></file> where
4532 <var>mm</var> is a two-digit number and <var>script</var>
4533 is the name of the script (this should be the same as the
4534 name of the actual script in <file>/etc/init.d</file>).
4538 When <prgn>init</prgn> changes runlevel first the targets
4539 of the links whose names start with a <tt>K</tt> are
4540 executed, each with the single argument <tt>stop</tt>,
4541 followed by the scripts prefixed with an <tt>S</tt>, each
4542 with the single argument <tt>start</tt>. (The links are
4543 those in the <file>/etc/rc<var>n</var>.d</file> directory
4544 corresponding to the new runlevel.) The <tt>K</tt> links
4545 are responsible for killing services and the <tt>S</tt>
4546 link for starting services upon entering the runlevel.
4550 For example, if we are changing from runlevel 2 to
4551 runlevel 3, init will first execute all of the <tt>K</tt>
4552 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4553 all of the <tt>S</tt> prefixed scripts in that directory.
4554 The links starting with <tt>K</tt> will cause the
4555 referred-to file to be executed with an argument of
4556 <tt>stop</tt>, and the <tt>S</tt> links with an argument
4561 The two-digit number <var>mm</var> is used to determine
4562 the order in which to run the scripts: low-numbered links
4563 have their scripts run first. For example, the
4564 <tt>K20</tt> scripts will be executed before the
4565 <tt>K30</tt> scripts. This is used when a certain service
4566 must be started before another. For example, the name
4567 server <prgn>bind</prgn> might need to be started before
4568 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4569 can set up its access lists. In this case, the script
4570 that starts <prgn>bind</prgn> would have a lower number
4571 than the script that starts <prgn>inn</prgn> so that it
4573 <example compact="compact">
4580 The two runlevels 0 (halt) and 6 (reboot) are slightly
4581 different. In these runlevels, the links with an
4582 <tt>S</tt> prefix are still called after those with a
4583 <tt>K</tt> prefix, but they too are called with the single
4584 argument <tt>stop</tt>.
4588 Also, if the script name ends <tt>.sh</tt>, the script
4589 will be sourced in runlevel <tt>S</tt> rather that being
4590 run in a forked subprocess, but will be explicitly run by
4591 <prgn>sh</prgn> in all other runlevels.
4596 <heading>Writing the scripts</heading>
4599 Packages that include daemons for system services should
4600 place scripts in <file>/etc/init.d</file> to start or stop
4601 services at boot time or during a change of runlevel.
4602 These scripts should be named
4603 <file>/etc/init.d/<var>package</var></file>, and they should
4604 accept one argument, saying what to do:
4607 <tag><tt>start</tt></tag>
4608 <item><p>start the service,</p></item>
4610 <tag><tt>stop</tt></tag>
4611 <item><p>stop the service,</p></item>
4613 <tag><tt>restart</tt></tag>
4614 <item><p>stop and restart the service,</p></item>
4616 <tag><tt>reload</tt></tag>
4617 <item><p>cause the configuration of the service to be
4618 reloaded without actually stopping and restarting
4619 the service,</p></item>
4621 <tag><tt>force-reload</tt></tag>
4622 <item><p>cause the configuration to be reloaded if the
4623 service supports this, otherwise restart the
4627 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4628 <tt>force-reload</tt> options should be supported by all
4629 scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4630 option is optional.</p>
4633 The <file>init.d</file> scripts should ensure that they will
4634 behave sensibly if invoked with <tt>start</tt> when the
4635 service is already running, or with <tt>stop</tt> when it
4636 isn't, and that they don't kill unfortunately-named user
4637 processes. The best way to achieve this is usually to use
4638 <prgn>start-stop-daemon</prgn>.</p>
4641 If a service reloads its configuration automatically (as
4642 in the case of <prgn>cron</prgn>, for example), the
4643 <tt>reload</tt> option of the <file>init.d</file> script
4644 should behave as if the configuration has been reloaded
4648 The <file>/etc/init.d</file> scripts must be treated as
4649 configuration files, either (if they are present in the
4650 package, that is, in the .deb file) by marking them as
4651 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4652 by managing them correctly in the maintainer scripts (see
4653 <ref id="config-files">). This is important since we want
4654 to give the local system administrator the chance to adapt
4655 the scripts to the local system, e.g., to disable a
4656 service without de-installing the package, or to specify
4657 some special command line options when starting a service,
4658 while making sure her changes aren't lost during the next
4663 These scripts should not fail obscurely when the
4664 configuration files remain but the package has been
4665 removed, as configuration files remain on the system after
4666 the package has been removed. Only when <prgn>dpkg</prgn>
4667 is executed with the <tt>--purge</tt> option will
4668 configuration files be removed. In particular, as the
4669 <file>/etc/init.d/<var>package</var></file> script itself is
4670 usually a <tt>conffile</tt>, it will remain on the system
4671 if the package is removed but not purged. Therefore, you
4672 should include a <tt>test</tt> statement at the top of the
4674 <example compact="compact">
4675 test -f <var>program-executed-later-in-script</var> || exit 0
4680 Often there are some variables in the <file>init.d</file>
4681 scripts whose values control the behaviour of the scripts,
4682 and which a system administrator is likely to want to
4683 change. As the scripts themselves are frequently
4684 <tt>conffile</tt>s, modifying them requires that the
4685 administrator merge in their changes each time the package
4686 is upgraded and the <tt>conffile</tt> changes. To ease
4687 the burden on the system administrator, such configurable
4688 values should not be placed directly in the script.
4689 Instead, they should be placed in a file in
4690 <file>/etc/default</file>, which typically will have the same
4691 base name as the <file>init.d</file> script. This extra file
4692 should be sourced by the script when the script runs. It
4693 must contain only variable settings and comments in POSIX
4694 <prgn>sh</prgn> format. It may either be a
4695 <tt>conffile</tt> or a configuration file maintained by
4696 the package maintainer scripts. See <ref id="config-files">
4701 To ensure that vital configurable values are always
4702 available, the <file>init.d</file> script should set default
4703 values for each of the shell variables it uses, either
4704 before sourcing the <file>/etc/default/</file> file or
4705 afterwards using something like the <tt>:
4706 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
4707 script must behave sensibly and not fail if the
4708 <file>/etc/default</file> file is deleted.
4713 <heading>Interfacing with the initscript system</heading>
4716 Maintainers should use the abstraction layer provided by
4717 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4718 programs to deal with initscripts in their packages'
4719 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4720 and <prgn>postrm</prgn>.
4723 Directly managing the /etc/rc?.d links and directly
4724 invoking the <file>/etc/init.d/</file> initscripts should
4725 be done only by packages providing the initscript
4726 subsystem (such as <prgn>sysvinit</prgn> and
4727 <prgn>file-rc</prgn>).
4732 <heading>Managing the links</heading>
4735 The program <prgn>update-rc.d</prgn> is provided for
4736 package maintainers to arrange for the proper creation and
4737 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4738 or their functional equivalent if another method is being
4739 used. This may be used by maintainers in their packages'
4740 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4743 You must not include any <file>/etc/rc<var>n</var>.d</file>
4744 symbolic links in the actual archive or manually create or
4745 remove the symbolic links in maintainer scripts; you must
4746 use the <prgn>update-rc.d</prgn> program instead. (The
4747 former will fail if an alternative method of maintaining
4748 runlevel information is being used.) You must not include
4749 the <file>/etc/rc<var>n</var>.d</file> directories themselves
4750 in the archive either. (Only the <tt>sysvinit</tt>
4755 By default <prgn>update-rc.d</prgn> will start services in
4756 each of the multi-user state runlevels (2, 3, 4, and 5)
4757 and stop them in the halt runlevel (0), the single-user
4758 runlevel (1) and the reboot runlevel (6). The system
4759 administrator will have the opportunity to customize
4760 runlevels by simply adding, moving, or removing the
4761 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4762 symbolic links are being used, or by modifying
4763 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4768 To get the default behavior for your package, put in your
4769 <prgn>postinst</prgn> script
4770 <example compact="compact">
4771 update-rc.d <var>package</var> defaults
4773 and in your <prgn>postrm</prgn>
4774 <example compact="compact">
4775 if [ "$1" = purge ]; then
4776 update-rc.d <var>package</var> remove
4778 </example>. Note that is your package changes runlevels
4779 or priority, you may have to remove and recreate the
4780 links, since otherwise the old links may
4781 persist. Refer to the documentation of
4782 <prgn>update-rc.d</prgn></p>
4785 This will use a default sequence number of 20. If it does
4786 not matter when or in which order the <file>init.d</file>
4787 script is run, use this default. If it does, then you
4788 should talk to the maintainer of the <prgn>sysvinit</prgn>
4789 package or post to <tt>debian-devel</tt>, and they will
4790 help you choose a number.
4794 For more information about using <tt>update-rc.d</tt>,
4795 please consult its manpage <manref name="update-rc.d"
4801 <heading>Running initscripts</heading>
4803 The program <prgn>invoke-rc.d</prgn> is provided to make
4804 it easier for package maintainers to properly invoke an
4805 initscript, obeying runlevel and other locally-defined
4806 constraints that might limit a package's right to start,
4807 stop and otherwise manage services. This program may be
4808 used by maintainers in their packages' scripts.
4811 The use of <prgn>invoke-rc.d</prgn> to invoke the
4812 <file>/etc/init.d/*</file> initscripts is strongly
4813 recommended<footnote>
4815 In the future, the use of invoke-rc.d to invoke
4816 initscripts shall be made mandatory. Maintainers are
4817 advised to switch to invoke-rc.d as soon as
4819 </footnote>, instead of calling them directly.
4823 By default, <prgn>invoke-rc.d</prgn> will pass any
4824 action requests (start, stop, reload, restart...) to the
4825 <file>/etc/init.d</file> script, filtering out requests
4826 to start or restart a service out of its intended
4830 Most packages will simply need to change:
4831 <example compact="compact">/etc/init.d/<package>
4832 <action></example> in their <prgn>postinst</prgn>
4833 and <prgn>prerm</prgn> scripts to:
4834 <example compact="compact">
4835 if [ -x /usr/sbin/invoke-rc.d ] ; then
4836 invoke-rc.d <var>package</var> <action>
4838 /etc/init.d/<var>package</var> <action>
4842 A package should register its initscript services using
4843 <prgn>update-rc.d</prgn> before it tries to invoke them
4844 using <prgn>invoke-rc.d</prgn>. Invocation of
4845 unregistered services may fail.
4848 For more information about using
4849 <prgn>invoke-rc.d</prgn>, please consult its manpage
4850 <manref name="invoke-rc.d" section="8">.
4857 <heading>Boot-time initialization</heading>
4860 There used to be another directory, <file>/etc/rc.boot</file>,
4861 which contained scripts which were run once per machine
4862 boot. This has been deprecated in favour of links from
4863 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
4864 described in <ref id="/etc/init.d">. Packages must not
4865 place files in <file>/etc/rc.boot</file>.</p>
4868 <heading>Example</heading>
4871 The <prgn>bind</prgn> DNS (nameserver) package wants to
4872 make sure that the nameserver is running in multiuser
4873 runlevels, and is properly shut down with the system. It
4874 puts a script in <file>/etc/init.d</file>, naming the script
4875 appropriately <tt>bind</tt>. As you can see, the script
4876 interprets the argument <tt>reload</tt> to send the
4877 nameserver a <tt>HUP</tt> signal (causing it to reload its
4878 configuration); this way the system administrator can say
4879 <file>/etc/init.d/bind reload</file> to reload the name
4880 server. The script has one configurable value, which can
4881 be used to pass parameters to the named program at
4882 startup; this value is read from
4883 <file>/etc/default/bind</file> (see below).
4887 <example compact="compact">
4890 # Original version by Robert Leslie
4891 # <rob@mars.org>, edited by iwj and cs
4893 test -x /usr/sbin/named || exit 0
4895 # Source defaults file.
4897 if [ -f /etc/default/bind ]; then
4904 echo -n "Starting domain name service: named"
4905 start-stop-daemon --start --quiet --exec /usr/sbin/named \
4910 echo -n "Stopping domain name service: named"
4911 start-stop-daemon --stop --quiet \
4912 --pidfile /var/run/named.pid --exec /usr/sbin/named
4916 echo -n "Restarting domain name service: named"
4917 start-stop-daemon --stop --quiet \
4918 --pidfile /var/run/named.pid --exec /usr/sbin/named
4919 start-stop-daemon --start --verbose --exec /usr/sbin/named \
4923 force-reload|reload)
4924 echo -n "Reloading configuration of domain name service: named"
4925 start-stop-daemon --stop --signal 1 --quiet \
4926 --pidfile /var/run/named.pid --exec /usr/sbin/named
4930 echo "Usage: /etc/init.d/bind " \
4931 " {start|stop|restart|reload|force-reload}" >&2
4941 Complementing the above init script is a configuration
4942 file <file>/etc/default/bind</file>, which contains
4943 configurable parameters used by the script. This would be
4944 created by the <prgn>postinst</prgn> script if it was not
4945 already present, and removed on purge by the
4946 <prgn>postrm</prgn> script.
4947 <example compact="compact">
4948 # Specified parameters to pass to named. See named(8).
4949 # You may uncomment the following line, and edit to taste.
4955 Another example on which you can base your
4956 <file>/etc/init.d</file> scripts is found in
4957 <file>/etc/init.d/skeleton</file>.
4961 If this package is happy with the default setup from
4962 <prgn>update-rc.d</prgn>, namely an ordering number of 20
4963 and having named running in all runlevels, it can say in
4964 its <prgn>postinst</prgn>:
4965 <example compact="compact">
4966 update-rc.d bind defaults >/dev/null
4968 And in its <prgn>postrm</prgn>, to remove the links when the
4970 <example compact="compact">
4971 if [ "$1" = purge ]; then
4972 update-rc.d bind remove >/dev/null
4980 <heading>Console messages from <file>init.d</file> scripts</heading>
4983 This section describes the formats to be used for messages
4984 written to standard output by the <file>/etc/init.d</file>
4985 scripts. The intent is to improve the consistency of
4986 Debian's startup and shutdown look and feel. For this
4987 reason, please look very carefully at the details. We want
4988 the messages to have the same format in terms of wording,
4989 spaces, punctuation and case of letters.
4993 Here is a list of overall rules that you should use when you
4994 create output messages. They can be useful if you have a
4995 non-standard message that is not covered specifically in the
5003 Every message should fit in one line (fewer than 80
5004 characters), start with a capital letter and end with
5005 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5011 If you want to express that the computer is working on
5012 something (that is, performing a specific task, not
5013 starting or stopping a program), we use an "ellipsis"
5014 (three dots: <tt>...</tt>). Note that we don't insert
5015 spaces before or after the dots. If the task has been
5016 completed we write <tt>done.</tt> and a line feed.
5022 Design your messages as if the computer is telling you
5023 what he is doing (let him be polite :-), but don't
5024 mention "him" directly. For example, if you think of
5026 <example compact="compact">
5027 I'm starting network daemons: nfsd mountd.
5030 <example compact="compact">
5031 Starting network daemons: nfsd mountd.
5039 There are standard message formats for the following
5040 situations. They should be used by the <tt>init.d</tt>
5047 <p>When daemons are started</p>
5050 If your script starts one or more daemons, the output
5051 should look like this (a single line, no leading
5053 <example compact="compact">
5054 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5056 The <var>description</var> should describe the
5057 subsystem the daemon or set of daemons are part of,
5058 while <var>daemon-1</var> up to <var>daemon-n</var>
5059 denote each daemon's name (typically the file name of
5064 For example, the output of <file>/etc/init.d/lpd</file>
5066 <example compact="compact">
5067 Starting printer spooler: lpd.
5072 This can be achieved by saying
5073 <example compact="compact">
5074 echo -n "Starting printer spooler: lpd"
5075 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5078 in the script. If you have more than one daemon to
5079 start, you should do the following:
5080 <example compact="compact">
5081 echo -n "Starting remote file system services:"
5082 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5083 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5084 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5087 This makes it possible for the user to see what takes
5088 so long and when the final daemon has been started.
5089 You should be careful where to put spaces: in the
5090 example above the system administrator can easily
5091 comment out a line if he don't wants to start a
5092 specific daemon, while the displayed message still
5098 <p>When a system parameter is being set</p>
5101 If you have to set up different system parameters
5102 during the system boot, you should use this format:
5103 <example compact="compact">
5104 Setting <var>parameter</var> to `<var>value</var>'.
5109 You can use a statement such as the following to get
5111 <example compact="compact">
5112 echo "Setting DNS domainname to \`$domainname'."
5117 Note that the left quotation mark (<tt>`</tt>) is
5118 different from the right one (<tt>'</tt>).
5123 <p>When a daemon is stopped or restarted</p>
5126 When you stop or restart a daemon, you should issue a
5127 message identical to the startup message, except that
5128 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5129 or <tt>Restarting</tt> respectively.
5133 For example, stopping the printer daemon will like
5135 <example compact="compact">
5136 Stopping printer spooler: lpd.
5142 <p>When something is executed</p>
5145 There are several examples where you have to run a
5146 program at system startup or shutdown to perform a
5147 specific task, for example, setting the system's clock
5148 using <prgn>netdate</prgn> or killing all processes
5149 when the system shuts down. Your message should look
5151 <example compact="compact">
5152 Doing something very useful...done.
5154 You should print the <tt>done.</tt> immediately after
5155 the job has been completed, so that the user is
5156 informed why she has to wait. You can get this
5158 <example compact="compact">
5159 echo -n "Doing something very useful..."
5168 <p>When the configuration is reloaded</p>
5171 When a daemon is forced to reload its configuration
5172 files you should use the following format:
5173 <example compact="compact">
5174 Reloading <var>description</var> configuration...done.
5176 where <var>description</var> is the same as in the
5177 daemon starting message.
5185 <heading>Cron jobs</heading>
5188 Packages must not modify the configuration file
5189 <file>/etc/crontab</file>, and they must not modify the files in
5190 <file>/var/spool/cron/crontabs</file>.</p>
5193 If a package wants to install a job that has to be executed
5194 via cron, it should place a file with the name of the
5195 package in one or more of the following directories:
5196 <example compact="compact">
5201 As these directory names imply, the files within them are
5202 executed on a daily, weekly, or monthly basis,
5203 respectively. The exact times are listed in
5204 <file>/etc/crontab</file>.</p>
5207 All files installed in any of these directories must be
5208 scripts (e.g., shell scripts or Perl scripts) so that they
5209 can easily be modified by the local system administrator.
5210 In addition, they should be treated as configuration
5215 If a certain job has to be executed more frequently than
5216 daily, the package should install a file
5217 <file>/etc/cron.d/<var>package</var></file>. This file uses the
5218 same syntax as <file>/etc/crontab</file> and is processed by
5219 <prgn>cron</prgn> automatically. The file must also be
5220 treated as a configuration file. (Note that entries in the
5221 <file>/etc/cron.d</file> directory are not handled by
5222 <prgn>anacron</prgn>. Thus, you should only use this
5223 directory for jobs which may be skipped if the system is not
5227 The scripts or crontab entries in these directories should
5228 check if all necessary programs are installed before they
5229 try to execute them. Otherwise, problems will arise when a
5230 package was removed but not purged since configuration files
5231 are kept on the system in this situation.</p>
5235 <heading>Menus</heading>
5238 Menu entries should follow the current menu policy found in
5239 the <tt>menu-policy</tt> files in the <tt>debian-policy</tt>
5240 package. It may also be found on the Debian FTP site
5241 <ftpsite>ftp.debian.org</ftpsite> as the file
5242 <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>,
5243 or in the equivalent location on your local mirror.
5247 The Debian <tt>menu</tt> package provides a standard
5248 interface between packages providing applications and
5249 documents, and <em>menu programs</em> (either X window
5250 managers or text-based menu programs such as
5251 <prgn>pdmenu</prgn>).
5255 All packages that provide applications that need not be
5256 passed any special command line arguments for normal
5257 operation should register a menu entry for those
5258 applications, so that users of the <tt>menu</tt> package
5259 will automatically get menu entries in their window
5260 managers, as well in shells like <tt>pdmenu</tt>.</p>
5263 Please also refer to the <em>Debian Menu System</em>
5264 documentation that comes with the <tt>menu</tt> package for
5265 information about how to register your applications and web
5271 <heading>Multimedia handlers</heading>
5274 Packages which provide the ability to view/show/play,
5275 compose, edit or print MIME types should register themselves
5276 as such following the current MIME support policy found in
5277 the <tt>mime-policy</tt> files in the <tt>debian-policy</tt>
5278 package. It may also be found on the Debian FTP site
5279 <ftpsite>ftp.debian.org</ftpsite> as the file
5280 <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>,
5281 or in the equivalent location on your local mirror.
5285 MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5286 is a mechanism for encoding files and data streams and
5287 providing meta-information about them, in particular their
5288 type (e.g. audio or video) and format (e.g. PNG, HTML,
5293 Registration of MIME type handlers allows programs like mail
5294 user agents and web browsers to to invoke these handlers to
5295 view, edit or display MIME types they don't support
5301 <heading>Keyboard configuration</heading>
5304 To achieve a consistent keyboard configuration so that all
5305 applications interpret a keyboard event the same way, all
5306 programs in the Debian distribution must be configured to
5307 comply with the following guidelines.
5311 The following keys must have the specified interpretations:
5314 <tag><tt><--</tt></tag>
5315 <item><p>delete the character to the left of the cursor</p></item>
5317 <tag><tt>Delete</tt></tag>
5318 <item><p>delete the character to the right of the cursor</p></item>
5320 <tag><tt>Control+H</tt></tag>
5321 <item><p>emacs: the help prefix</p></item>
5324 The interpretation of any keyboard events should be
5325 independent of the terminal that is used, be it a virtual
5326 console, an X terminal emulator, an rlogin/telnet session,
5331 The following list explains how the different programs
5332 should be set up to achieve this:
5337 <item><p><tt><--</tt> generates <tt>KB_BackSpace</tt>
5340 <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5345 X translations are set up to make
5346 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5347 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5348 is the vt220 escape code for the `delete character'
5349 key). This must be done by loading the X resources
5350 using <prgn>xrdb</prgn> on all local X displays, not
5351 using the application defaults, so that the
5352 translation resources used correspond to the
5353 <prgn>xmodmap</prgn> settings.</p></item>
5357 The Linux console is configured to make
5358 <tt><--</tt> generate DEL, and <tt>Delete</tt>
5359 generate <tt>ESC [ 3 ~</tt>.</p></item>
5363 X applications are configured so that <tt><</tt>
5364 deletes left, and <tt>Delete</tt> deletes right. Motif
5365 applications already work like this.</p></item>
5367 <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5371 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5372 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5373 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5377 Emacs is programmed to map <tt>KB_Backspace</tt> or
5378 the <tt>stty erase</tt> character to
5379 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5380 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5381 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5385 Other applications use the <tt>stty erase</tt>
5386 character and <tt>kdch1</tt> for the two delete keys,
5387 with ASCII DEL being `delete previous character' and
5388 <tt>kdch1</tt> being `delete character under
5395 This will solve the problem except for the following
5403 Some terminals have a <tt><--</tt> key that cannot
5404 be made to produce anything except <tt>^H</tt>. On
5405 these terminals Emacs help will be unavailable on
5406 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5407 character takes precedence in Emacs, and has been set
5408 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
5409 available) can be used instead.</p></item>
5413 Some operating systems use <tt>^H</tt> for <tt>stty
5414 erase</tt>. However, modern telnet versions and all
5415 rlogin versions propagate <tt>stty</tt> settings, and
5416 almost all UNIX versions honour <tt>stty erase</tt>.
5417 Where the <tt>stty</tt> settings are not propagated
5418 correctly, things can be made to work by using
5419 <tt>stty</tt> manually.</p></item>
5423 Some systems (including previous Debian versions) use
5424 <prgn>xmodmap</prgn> to arrange for both
5425 <tt><--</tt> and <tt>Delete</tt> to generate
5426 <tt>KB_Delete</tt>. We can change the behavior of
5427 their X clients using the same X resources that we use
5428 to do it for our own clients, or configure our clients
5429 using their resources when things are the other way
5430 around. On displays configured like this
5431 <tt>Delete</tt> will not work, but <tt><--</tt>
5436 Some operating systems have different <tt>kdch1</tt>
5437 settings in their <tt>terminfo</tt> database for
5438 <tt>xterm</tt> and others. On these systems the
5439 <tt>Delete</tt> key will not work correctly when you
5440 log in from a system conforming to our policy, but
5441 <tt><--</tt> will.</p></item>
5447 <heading>Environment variables</heading>
5450 A program must not depend on environment variables to get
5451 reasonable defaults. (That's because these environment
5452 variables would have to be set in a system-wide
5453 configuration file like <file>/etc/profile</file>, which is not
5454 supported by all shells.)</p>
5457 If a program usually depends on environment variables for its
5458 configuration, the program should be changed to fall back to
5459 a reasonable default configuration if these environment
5460 variables are not present. If this cannot be done easily
5461 (e.g., if the source code of a non-free program is not
5462 available), the program must be replaced by a small
5463 `wrapper' shell script which sets the environment variables
5464 if they are not already defined, and calls the original program.</p>
5467 Here is an example of a wrapper script for this purpose:
5469 <example compact="compact">
5471 BAR=${BAR:-/var/lib/fubar}
5473 exec /usr/lib/foo/foo "$@"
5478 Furthermore, as <file>/etc/profile</file> is a configuration
5479 file of the <prgn>base-files</prgn> package, other packages must not
5480 put any environment variables or other commands into that
5486 <heading>Files</heading>
5489 <heading>Binaries</heading>
5492 Two different packages must not install programs with
5493 different functionality but with the same filenames. (The
5494 case of two programs having the same functionality but
5495 different implementations is handled via `alternatives' or
5496 the `Conflicts' mechanism. See <ref id="maintscripts"> and
5497 <ref id="conflicts"> respectively.) If this case happens,
5498 one of the programs must be renamed. The maintainers should
5499 report this to the <tt>debian-devel</tt> mailing list and
5500 try to find a consensus about which program will have to be
5501 renamed. If a consensus cannot be reached, <em>both</em>
5502 programs must be renamed.
5506 By default, when a package is being built, any binaries
5507 created should include debugging information, as well as
5508 being compiled with optimization. You should also turn on
5509 as many reasonable compilation warnings as possible; this
5510 makes life easier for porters, who can then look at build
5511 logs for possible problems. For the C programming language,
5512 this means the following compilation parameters should be
5514 <example compact="compact">
5516 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5518 install -s # (or use strip on the files in debian/tmp)
5523 Note that by default all installed binaries should be stripped,
5524 either by using the <tt>-s</tt> flag to
5525 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5526 the binaries after they have been copied into
5527 <file>debian/tmp</file> but before the tree is made into a
5531 Although binaries in the build tree should be compiled with
5532 debugging information by default, it can often be difficult
5533 to debug programs if they are also subjected to compiler
5534 optimization. For this reason, it is recommended to support
5535 the standardized environment
5536 variable <tt>DEB_BUILD_OPTIONS</tt>. This variable can
5537 contain several flags to change how a package is compiled
5545 The presence of this string means that the package
5546 should be complied with a minimum of optimization.
5547 For C programs, it is best to add <tt>-O0</tt>
5548 to <tt>CFLAGS</tt> (although this is usually the
5549 default). Some programs might fail to build or run at
5550 this level of optimization; it may be necessary to
5551 use <tt>-O1</tt>, for example.
5557 This string means that the debugging symbols should
5558 not be stripped from the binary during installation,
5559 so that debugging information may be included in the package.
5565 The following makefile snippet is an example of how one may
5566 implement the build options; you will probably have to
5567 massage this example in order to make it work for your
5569 <example compact="compact">
5572 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5573 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5574 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5575 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5577 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5582 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5583 INSTALL_PROGRAM += -s
5589 It is up to the package maintainer to decide what
5590 compilation options are best for the package. Certain
5591 binaries (such as computationally-intensive programs) will
5592 function better with certain flags (<tt>-O3</tt>, for
5593 example); feel free to use them. Please use good judgment
5594 here. Don't use flags for the sake of it; only use them
5595 if there is good reason to do so. Feel free to override
5596 the upstream author's ideas about which compilation
5597 options are best: they are often inappropriate for our
5604 <heading>Libraries</heading>
5606 In general, libraries must have a shared version in the
5607 library package and a static version in the development
5608 package. The shared version must be compiled with
5609 <tt>-fPIC</tt>, and the static version must not be. In
5610 other words, each source unit ( <tt>*.c</tt>, for example,
5611 for C files) will need to be compiled twice.
5614 In some cases, it is acceptable for a library to be
5615 available in static form only; these cases include:
5618 <p>libraries for languages whose shared library support
5619 is immature or unstable</p>
5623 libraries whose interfaces are in flux or under
5624 development (commonly the case when the library's
5625 major version number is zero, or where the ABI breaks
5631 libraries which are explicitly intended to be
5632 available only in static form by their upstream
5636 If a library is available only in static form, then it must follow
5637 the conventions for a development package.
5640 All libraries must have a shared version in the
5641 <tt>lib*</tt> package and a static version in the
5642 <tt>lib*-dev</tt> package. The shared version must be
5643 compiled with <tt>-fPIC</tt>, and the static version must
5644 not be. In other words, each <tt>*.c</tt> file will need to
5645 be compiled twice.</p>
5648 You must specify the gcc option <tt>-D_REENTRANT</tt>
5649 when building a library (either static or shared) to make
5650 the library compatible with LinuxThreads.</p>
5653 Note that all installed shared libraries should be
5655 <example compact="compact">
5656 strip --strip-unneeded <var>your-lib</var>
5658 (The option <tt>--strip-unneeded</tt> makes
5659 <prgn>strip</prgn> remove only the symbols which aren't
5660 needed for relocation processing.) Shared libraries can
5661 function perfectly well when stripped, since the symbols for
5662 dynamic linking are in a separate part of the ELF object
5665 You might also want to use the options
5666 <tt>--remove-section=.comment</tt> and
5667 <tt>--remove-section=.note</tt> on both shared libraries
5668 and executables, and <tt>--strip-debug</tt> on static
5675 Note that under some circumstances it may be useful to
5676 install a shared library unstripped, for example when
5677 building a separate package to support debugging.
5681 Shared object files (often <file>.so</file> files) that are not
5682 public libraries, that is, they are not meant to be linked
5683 to by third party executables (binaries of other packages),
5684 should be installed in subdirectories of the
5685 <file>/usr/lib</file> directory. Such files are exempt from the
5686 rules that govern ordinary shared libraries, except that
5687 they must not be installed executable and should be
5690 A common example are the so-called ``plug-ins'',
5691 internal shared objects that are dynamically loaded by
5692 programs using <manref name="dlopen" section="3">.
5698 Packages containing shared libraries that may be linked to
5699 by other packages' binaries, but which for some
5700 <em>compelling</em> reason can not be installed in
5701 <file>/usr/lib</file> directory, may install the shared library
5702 files in subdirectories of the <file>/usr/lib</file> directory,
5703 in which case they should arrange to add that directory in
5704 <file>/etc/ld.so.conf</file> in the package's post-installation
5705 script, and remove it in the package's post-removal script.
5709 An ever increasing number of packages are using
5710 <prgn>libtool</prgn> to do their linking. The latest GNU
5711 libtools (>= 1.3a) can take advantage of the metadata in the
5712 installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5713 files). The main advantage of <prgn>libtool</prgn>'s
5714 <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5715 store and subsequently access metadata with respect to the
5716 libraries it builds. <prgn>libtool</prgn> will search for
5717 those files, which contain a lot of useful information about
5718 a library (such as library dependency information for static
5719 linking). Also, they're <em>essential</em> for programs
5720 using <tt>libltdl</tt>.<footnote>
5722 Although <prgn>libtool</prgn> is fully capable of
5723 linking against shared libraries which don't have
5724 <tt>.la</tt> files, as it is a mere shell script it can
5725 add considerably to the build time of a
5726 <prgn>libtool</prgn>-using package if that shell script
5727 has to derive all this information from first principles
5728 for each library every time it is linked. With the
5729 advent of <prgn>libtool</prgn> version 1.4 (and to a
5730 lesser extent <prgn>libtool</prgn> version 1.3), the
5731 <file>.la</file> files also store information about
5732 inter-library dependencies which cannot necessarily be
5733 derived after the <file>.la</file> file is deleted.
5739 Packages that use <prgn>libtool</prgn> to create shared
5740 libraries should include the <file>.la</file> files in the
5741 <tt>-dev</tt> package, unless the package relies on
5742 <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5743 the <tt>.la</tt> files must go in the run-time library
5748 You must make sure that you use only released versions of
5749 shared libraries to build your packages; otherwise other
5750 users will not be able to run your binaries
5751 properly. Producing source packages that depend on
5752 unreleased compilers is also usually a bad
5758 <heading>Shared libraries</heading>
5761 Packages involving shared libraries should be split up
5762 into several binary packages.</p>
5765 For a straightforward library which has a development
5766 environment and a runtime kit including just shared
5767 libraries you need to create two packages:
5768 <file><var>libraryname</var><var>soversion</var></file>, where
5769 <file><var>soversion</var></file> is the version number in the
5770 soname of the shared library<footnote>
5772 The soname is the shared object name: it's the thing
5773 that has to match exactly between building an executable
5774 and running it for the dynamic linker to be able run the
5775 program. For example, if the soname of the library is
5776 <file>libfoo.so.6</file>, the library package would be
5777 called <file>libfoo6</file>.
5780 and <tt><var>libraryname</var><var>soversion</var>-dev</tt>.
5781 Alternatively, if it would be confusing to directly append
5782 <var>soversion</var> to <var>libraryname</var> (e.g. because
5783 <var>libraryname</var> itself ends in a number), you may use
5784 <tt><var>libraryname</var>-<var>soversion</var></tt> and
5785 <tt><var>libraryname</var>-<var>soversion</var>-dev</tt>
5790 If you prefer only to support one development version at a
5791 time you may name the development package
5792 <file><var>libraryname</var>-dev</file>; otherwise you may need
5793 to use <prgn>dpkg</prgn>'s Conflicts mechanism (see <ref
5794 id="conflicts">) to ensure that the user only installs one
5795 development version at a time (as different development
5796 versions are likely to have the same header files in them,
5797 which would cause a filename clash if both were installed).
5798 Typically the development version should also have an exact
5799 version dependency on the runtime library, to make sure that
5800 compilation and linking happens correctly. The
5801 <tt>${Source-Version}</tt> substitution variable can be
5802 useful for this purpose.
5806 Packages which use the shared library should have a
5807 dependency on the name of the shared library package,
5808 <file><var>libraryname</var><var>soversion</var></file>. When
5809 the soname changes you can have both versions of the library
5810 installed while migrating from the old library to the new.
5814 If your package has some run-time support programs which use
5815 the shared library you must not put them in the shared
5816 library package. If you do that then you won't be able to
5817 install several versions of the shared library without
5818 getting filename clashes. Instead, either create a third
5819 package for the runtime binaries (this package might
5820 typically be named <tt><var>libraryname</var>-runtime</tt>;
5821 note the absence of the <var>soversion</var> in the package
5822 name), or if the development package is small you may
5823 include them in there.
5827 If you have several shared libraries built from the same
5828 source tree you may lump them all together into a single
5829 shared library package, provided that you change all of
5830 their sonames at once (so that you don't get filename
5831 clashes if you try to install different versions of the
5832 combined shared libraries package).
5836 Shared libraries should not be installed executable, since
5837 the dynamic linker does not require this and trying to
5838 execute a shared library usually results in a core dump.
5843 <heading>Scripts</heading>
5846 All command scripts, including the package maintainer
5847 scripts inside the package and used by <prgn>dpkg</prgn>,
5848 should have a <tt>#!</tt> line naming the shell to be used
5849 to interpret them.</p>
5852 In the case of Perl scripts this should be
5853 <tt>#!/usr/bin/perl</tt>.</p>
5856 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5857 should almost certainly start with <tt>set -e</tt> so that
5858 errors are detected. Every script should use
5859 <tt>set -e</tt> or check the exit status of <em>every</em>
5863 The standard shell interpreter <file>/bin/sh</file> can be a
5864 symbolic link to any POSIX compatible shell, if <tt>echo
5865 -n</tt> does not generate a newline.<footnote>
5867 Debian policy specifies POSIX behavior for
5868 <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5869 use in the Linux community (in particular including this
5870 policy, the Linux kernel source, many Debian scripts,
5871 etc.). This <tt>echo -n</tt> mechanism is valid but not
5872 required under POSIX, hence this explicit addition.
5873 Also, rumour has it that this shall be mandated under
5877 Thus, shell scripts specifying <file>/bin/sh</file> as
5878 interpreter should only use POSIX features. If a script
5879 requires non-POSIX features from the shell interpreter, the
5880 appropriate shell must be specified in the first line of the
5881 script (e.g., <tt>#!/bin/bash</tt>) and the package must
5882 depend on the package providing the shell (unless the shell
5883 package is marked `Essential', as in the case of
5888 You may wish to restrict your script to POSIX features when
5889 possible so that it may use <file>/bin/sh</file> as its
5890 interpreter. If your script works with <prgn>dash</prgn>
5891 (originally called <prgn>ash</prgn>), it's probably POSIX
5892 compliant, but if you are in doubt, use
5893 <file>/bin/bash</file>.
5897 Perl scripts should check for errors when making any
5898 system calls, including <tt>open</tt>, <tt>print</tt>,
5899 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5903 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5904 scripting languages. See <em>Csh Programming Considered
5905 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5906 can be found at <url
5907 id="http://language.perl.com/versus/csh.whynot">.<footnote>
5909 It can also be found on
5910 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5911 or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5912 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5915 If an upstream package comes with <prgn>csh</prgn> scripts
5916 then you must make sure that they start with
5917 <tt>#!/bin/csh</tt> and make your package depend on the
5918 <prgn>c-shell</prgn> virtual package.
5922 Any scripts which create files in world-writeable
5923 directories (e.g., in <file>/tmp</file>) must use a
5924 mechanism which will fail if a file with the same name
5928 The Debian base system provides the <prgn>tempfile</prgn>
5929 and <prgn>mktemp</prgn> utilities for use by scripts for
5930 this purpose.</p></sect>
5934 <heading>Symbolic links</heading>
5937 In general, symbolic links within a top-level directory
5938 should be relative, and symbolic links pointing from one
5939 top-level directory into another should be absolute. (A
5940 top-level directory is a sub-directory of the root
5941 directory <file>/</file>.)</p>
5944 In addition, symbolic links should be specified as short as
5945 possible, i.e., link targets like <file>foo/../bar</file> are
5949 Note that when creating a relative link using
5950 <prgn>ln</prgn> it is not necessary for the target of the
5951 link to exist relative to the working directory you're
5952 running <prgn>ln</prgn> from, nor is it necessary to change
5953 directory to the directory where the link is to be made.
5954 Simply include the string that should appear as the target
5955 of the link (this will be a pathname relative to the
5956 directory in which the link resides) as the first argument
5957 to <prgn>ln</prgn>.</p>
5960 For example, in your <prgn>Makefile</prgn> or
5961 <file>debian/rules</file>, you can do things like:
5962 <example compact="compact">
5963 ln -fs gcc $(prefix)/bin/cc
5964 ln -fs gcc debian/tmp/usr/bin/cc
5965 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5966 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5970 A symbolic link pointing to a compressed file should always
5971 have the same file extension as the referenced file. (For
5972 example, if a file <file>foo.gz</file> is referenced by a
5973 symbolic link, the filename of the link has to end with
5974 `<file>.gz</file>' too, as in <file>bar.gz</file>.)
5979 <heading>Device files</heading>
5982 Packages must not include device files in the package file
5986 If a package needs any special device files that are not
5987 included in the base system, it must call
5988 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
5989 after notifying the user<footnote>
5991 This notification could be done via a (low-priority)
5992 debconf message, or an echo (printf) statement.
5998 Packages must not remove any device files in the
5999 <prgn>postrm</prgn> or any other script. This is left to the
6000 system administrator.</p>
6003 Debian uses the serial devices
6004 <file>/dev/ttyS*</file>. Programs using the old
6005 <file>/dev/cu*</file> devices should be changed to use
6006 <file>/dev/ttyS*</file>.</p>
6009 <sect id="config-files">
6010 <heading>Configuration files</heading>
6012 <heading>Definitions</heading>
6015 <tag>configuration file</tag>
6018 A file that affects the operation of a program, or
6019 provides site- or host-specific information, or
6020 otherwise customizes the behavior of a program.
6021 Typically, configuration files are intended to be
6022 modified by the system administrator (if needed or
6023 desired) to conform to local policy or to provide
6024 more useful site-specific behavior.
6028 <tag><tt>conffile</tt></tag>
6031 A file listed in a package's <tt>conffiles</tt>
6032 file, and is treated specially by <prgn>dpkg</prgn>
6033 (see <ref id="configdetails">).
6040 The distinction between these two is important; they are
6041 not interchangeable concepts. Almost all
6042 <tt>conffile</tt>s are configuration files, but many
6043 configuration files are not <tt>conffiles</tt>.
6047 Note that a script that embeds configuration information
6048 (such as most of the files in <file>/etc/default</file> and
6049 <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6050 configuration file and should be treated as such.
6055 <heading>Location</heading>
6057 Any configuration files created or used by your package
6058 must reside in <file>/etc</file>. If there are several you
6059 should consider creating a subdirectory of <file>/etc</file>
6060 named after your package.</p>
6063 If your package creates or uses configuration files
6064 outside of <file>/etc</file>, and it is not feasible to modify
6065 the package to use the <file>/etc</file>, you should still put
6066 the files in <file>/etc</file> and create symbolic links to
6067 those files from the location that the package
6072 <heading>Behavior</heading>
6074 Configuration file handling must conform to the following
6076 <list compact="compact">
6079 local changes must be preserved during a package
6085 configuration files must be preserved when the
6086 package is removed, and only deleted when the
6094 The easy way to achieve this behavior is to make the
6095 configuration file a <tt>conffile</tt>. This is
6096 appropriate only if it is possible to distribute a default
6097 version that will work for most installations, although
6098 some system administrators may choose to modify it. This
6099 implies that the default version will be part of the
6100 package distribution, and must not be modified by the
6101 maintainer scripts during installation (or at any other
6106 In order to ensure that local changes are preserved
6107 correctly, no package may contain or make hard links to
6108 conffiles.<footnote>
6110 Rationale: There are two problems with hard links.
6111 The first is that some editors break the link while
6112 editing one of the files, so that the two files may
6113 unwittingly become unlinked and different. The second
6114 is that <prgn>dpkg</prgn> might break the hard link
6115 while upgrading <tt>conffile</tt>s.
6121 The other way to do it is via the maintainer scripts. In
6122 this case, the configuration file must not be listed as a
6123 <tt>conffile</tt> and must not be part of the package
6124 distribution. If the existence of a file is required for
6125 the package to be sensibly configured it is the
6126 responsibility of the package maintainer to provide
6127 maintainer scripts which correctly create, update and
6128 maintain the file and remove it on purge. (See <ref
6129 id="maintainerscripts"> for more information.) These
6130 scripts must be idempotent (i.e., must work correctly if
6131 <prgn>dpkg</prgn> needs to re-run them due to errors
6132 during installation or removal), must cope with all the
6133 variety of ways <prgn>dpkg</prgn> can call maintainer
6134 scripts, must not overwrite or otherwise mangle the user's
6135 configuration without asking, must not ask unnecessary
6136 questions (particularly during upgrades), and otherwise be
6141 The scripts are not required to configure every possible
6142 option for the package, but only those necessary to get
6143 the package running on a given system. Ideally the
6144 sysadmin should not have to do any configuration other
6145 than that done (semi-)automatically by the
6146 <prgn>postinst</prgn> script.
6150 A common practice is to create a script called
6151 <file><var>package</var>-configure</file> and have the
6152 package's <prgn>postinst</prgn> call it if and only if the
6153 configuration file does not already exist. In certain
6154 cases it is useful for there to be an example or template
6155 file which the maintainer scripts use. Such files should
6156 be in <file>/usr/share/<var>package</var></file> or
6157 <file>/usr/lib/<var>package</var></file> (depending on whether
6158 they are architecture-independent or not). There should
6159 be symbolic links to them from
6160 <file>/usr/share/doc/<var>package</var>/examples</file> if
6161 they are examples, and should be perfectly ordinary
6162 <prgn>dpkg</prgn>-handled files (<em>not</em>
6163 configuration files).
6167 These two styles of configuration file handling must
6168 not be mixed, for that way lies madness:
6169 <prgn>dpkg</prgn> will ask about overwriting the file
6170 every time the package is upgraded.
6175 <heading>Sharing configuration files</heading>
6177 Packages which specify the same file as a
6178 <tt>conffile</tt> must be tagged as <em>conflicting</em>
6179 with each other. (This is an instance of the general rule
6180 about not sharing files. Note that neither alternatives
6181 nor diversions are likely to be appropriate in this case;
6182 in particular, <prgn>dpkg</prgn> does not handle diverted
6183 <tt>conffile</tt>s well.)
6187 The maintainer scripts must not alter a <tt>conffile</tt>
6188 of <em>any</em> package, including the one the scripts
6193 If two or more packages use the same configuration file
6194 and it is reasonable for both to be installed at the same
6195 time, one of these packages must be defined as
6196 <em>owner</em> of the configuration file, i.e., it will be
6197 the package which handles that file as a configuration
6198 file. Other packages that use the configuration file must
6199 depend on the owning package if they require the
6200 configuration file to operate. If the other package will
6201 use the configuration file if present, but is capable of
6202 operating without it, no dependency need be declared.</p>
6205 If it is desirable for two or more related packages to
6206 share a configuration file <em>and</em> for all of the
6207 related packages to be able to modify that configuration
6208 file, then the following should be done:
6209 <enumlist compact="compact">
6212 One of the related packages (the "owning" package)
6213 will manage the configuration file with maintainer
6214 scripts as described in the previous section.
6219 The owning package should also provide a program
6220 that the other packages may use to modify the
6226 The related packages must use the provided program
6227 to make any desired modifications to the
6228 configuration file. They should either depend on
6229 the core package to guarantee that the configuration
6230 modifier program is available or accept gracefully
6231 that they cannot modify the configuration file if it
6232 is not. (This is in addition to the fact that the
6233 configuration file may not even be present in the
6241 Sometimes it's appropriate to create a new package which
6242 provides the basic infrastructure for the other packages
6243 and which manages the shared configuration files. (The
6244 <tt>sgml-base</tt> package is a good example.)
6249 <heading>User configuration files ("dotfiles")</heading>
6252 The files in <file>/etc/skel</file> will automatically be
6253 copied into new user accounts by <prgn>adduser</prgn>.
6254 No other program should reference the files in
6255 <file>/etc/skel</file>.
6259 Therefore, if a program needs a dotfile to exist in
6260 advance in <file>$HOME</file> to work sensibly, that dotfile
6261 should be installed in <file>/etc/skel</file> and treated as a
6266 However, programs that require dotfiles in order to
6267 operate sensibly (dotfiles that they do not create
6268 themselves automatically, that is) are a bad thing.
6269 Furthermore, programs should be configured by the Debian
6270 default installation to behave as closely to the upstream
6271 default behaviour as possible.
6275 Therefore, if a program in a Debian package needs to be
6276 configured in some way in order to operate sensibly, that
6277 should be done using a site-wide configuration file placed
6278 in <file>/etc</file>. Only if the program doesn't support a
6279 site-wide default configuration and the package maintainer
6280 doesn't have time to add it may a default per-user file be
6281 placed in <file>/etc/skel</file>.
6285 <file>/etc/skel</file> should be as empty as we can make it.
6286 This is particularly true because there is no easy (or
6287 necessarily desirable) mechanism for ensuring that the
6288 appropriate dotfiles are copied into the accounts of
6289 existing users when a package is installed.
6295 <heading>Log files</heading>
6297 Log files should usually be named
6298 <file>/var/log/<var>package</var>.log</file>. If you have many
6299 log files, or need a separate directory for permission
6300 reasons (<file>/var/log</file> is writable only by
6301 <file>root</file>), you should usually create a directory named
6302 <file>/var/log/<var>package</var></file> and place your log
6307 Log files must be rotated occasionally so that they don't
6308 grow indefinitely; the best way to do this is to drop a log
6309 rotation configuration file into the directory
6310 <file>/etc/logrotate.d</file> and use the facilities provided by
6311 logrotate.<footnote>
6313 The traditional approach to log files has been to set up
6314 <em>ad hoc</em> log rotation schemes using simple shell
6315 scripts and cron. While this approach is highly
6316 customizable, it requires quite a lot of sysadmin work.
6317 Even though the original Debian system helped a little
6318 by automatically installing a system which can be used
6319 as a template, this was deemed not enough.
6323 The use of <prgn>logrotate</prgn>, a program developed
6324 by Red Hat, is better, as it centralizes log management.
6325 It has both a configuration file
6326 (<file>/etc/logrotate.conf</file>) and a directory where
6327 packages can drop their individual log rotation
6328 configurations (<file>/etc/logrotate.d</file>).
6331 Here is a good example for a logrotate config
6332 file (for more information see <manref name="logrotate"
6334 <example compact="compact">
6340 /etc/init.d/foo force-reload
6344 This rotates all files under <file>/var/log/foo</file>, saves 12
6345 compressed generations, and forces the daemon to reload its
6346 configuration information after the log rotation.
6350 Log files should be removed when the package is
6351 purged (but not when it is only removed). This should be
6352 done by the <prgn>postrm</prgn> script when it is called
6353 with the argument <tt>purge</tt> (see <ref
6354 id="removedetails">).
6359 <heading>Permissions and owners</heading>
6362 The rules in this section are guidelines for general use.
6363 If necessary you may deviate from the details below.
6364 However, if you do so you must make sure that what is done
6365 is secure and you should try to be as consistent as possible
6366 with the rest of the system. You should probably also
6367 discuss it on <prgn>debian-devel</prgn> first.
6371 Files should be owned by <tt>root.root</tt>, and made
6372 writable only by the owner and universally readable (and
6373 executable, if appropriate), that is mode 644 or 755.
6377 Directories should be mode 755 or (for group-writability)
6378 mode 2775. The ownership of the directory should be
6379 consistent with its mode: if a directory is mode 2775, it
6380 should be owned by the group that needs write access to
6385 Setuid and setgid executables should be mode 4755 or 2755
6386 respectively, and owned by the appropriate user or group.
6387 They should not be made unreadable (modes like 4711 or
6388 2711 or even 4111); doing so achieves no extra security,
6389 because anyone can find the binary in the freely available
6390 Debian package; it is merely inconvenient. For the same
6391 reason you should not restrict read or execute permissions
6392 on non-set-id executables.
6396 Some setuid programs need to be restricted to particular
6397 sets of users, using file permissions. In this case they
6398 should be owned by the uid to which they are set-id, and by
6399 the group which should be allowed to execute them. They
6400 should have mode 4754; again there is no point in making
6401 them unreadable to those users who must not be allowed to
6406 It is possible to arrange that the system administrator can
6407 reconfigure the package to correspond to their local
6408 security policy by changing the permissions on a binary:
6409 they can do this by using <prgn>dpkg-statoverride</prgn>, as
6410 described below.<footnote>
6412 Ordinary files installed by <prgn>dpkg</prgn> (as
6413 opposed to <tt>conffile</tt>s and other similar objects)
6414 normally have their permissions reset to the distributed
6415 permissions when the package is reinstalled. However,
6416 the use of <prgn>dpkg-statoverride</prgn> overrides this
6417 default behaviour. If you use this method, you should
6418 remember to describe <prgn>dpkg-statoverride</prgn> in
6419 the package documentation; being a relatively new
6420 addition to Debian, it is probably not yet well-known.
6423 Another method you should consider is to create a group for
6424 people allowed to use the program(s) and make any setuid
6425 executables executable only by that group.
6429 If you need to create a new user or group for your package
6430 there are two possibilities. Firstly, you may need to
6431 make some files in the binary package be owned by this
6432 user or group, or you may need to compile the user or
6433 group id (rather than just the name) into the binary
6434 (though this latter should be avoided if possible, as in
6435 this case you need a statically allocated id).</p>
6438 If you need a statically allocated id, you must ask for a
6439 user or group id from the <tt>base-passwd</tt> maintainer,
6440 and must not release the package until you have been
6441 allocated one. Once you have been allocated one you must
6442 either make the package depend on a version of the
6443 <tt>base-passwd</tt> package with the id present in
6444 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6445 your package to create the user or group itself with the
6446 correct id (using <tt>adduser</tt>) in its
6447 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
6448 the <prgn>postinst</prgn> is to be preferred if it is
6449 possible, otherwise a pre-dependency will be needed on the
6450 <tt>adduser</tt> package.)
6454 On the other hand, the program might be able to determine
6455 the uid or gid from the user or group name at runtime, so
6456 that a dynamically allocated id can be used. In this case
6457 you should choose an appropriate user or group name,
6458 discussing this on <prgn>debian-devel</prgn> and checking
6459 with the base system maintainer that it is unique and that
6460 they do not wish you to use a statically allocated id
6461 instead. When this has been checked you must arrange for
6462 your package to create the user or group if necessary using
6463 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6464 <prgn>postinst</prgn> script (again, the latter is to be
6465 preferred if it is possible).
6469 Note that changing the numeric value of an id associated
6470 with a name is very difficult, and involves searching the
6471 file system for all appropriate files. You need to think
6472 carefully whether a static or dynamic id is required, since
6473 changing your mind later will cause problems.
6476 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6478 This section is not intended as policy, but as a
6479 description of the use of <prgn>dpkg-statoverride</prgn>.
6483 <prgn>dpkg-statoverride</prgn> is a replacement for the
6484 deprecated <tt>suidmanager</tt> package. Packages which
6485 previously used <tt>suidmanager</tt> should have a
6486 <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6487 <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6488 and <tt>suidunregister</tt> should now be simply removed
6489 from the maintainer scripts.
6493 If a system administrator wishes to have a file (or
6494 directory or other such thing) installed with owner and
6495 permissions different from those in the distributed Debian
6496 package, he can use the <prgn>dpkg-statoverride</prgn>
6497 program to instruct <prgn>dpkg</prgn> to use the different
6498 settings every time the file is installed. Thus the
6499 package maintainer should distribute the files with their
6500 normal permissions, and leave it for the system
6501 administrator to make any desired changes. For example, a
6502 daemon which is normally required to be setuid root, but
6503 in certain situations could be used without being setuid,
6504 should be installed setuid in the <tt>.deb</tt>. Then the
6505 local system administrator can change this if they wish.
6506 If there are two standard ways of doing it, the package
6507 maintainer can use <tt>debconf</tt> to find out the
6508 preference, and call <prgn>dpkg-statoverride</prgn> in the
6509 maintainer script if necessary to accommodate the system
6510 administrator's choice.
6514 Given the above, <prgn>dpkg-statoverride</prgn> is
6515 essentially a tool for system administrators and would not
6516 normally be needed in the maintainer scripts. There is
6517 one type of situation, though, where calls to
6518 <prgn>dpkg-statoverride</prgn> would be needed in the
6519 maintainer scripts, and that involves packages which use
6520 dynamically allocated user or group ids. In such a
6521 situation, something like the following idiom can be very
6522 helpful in the package's <prgn>postinst</prgn>, where
6523 <tt>sysuser</tt> is a dynamically allocated id:
6525 for i in /usr/bin/foo /usr/sbin/bar
6527 if ! dpkg-statoverride --list $i >/dev/null
6529 dpkg-statoverride --update --add sysuser root 4755 $i
6533 The corresponding <tt>dpkg-statoverride --remove</tt>
6534 calls can then be made unconditionally when the package is
6541 <chapt id="customized-programs">
6542 <heading>Customized programs</heading>
6544 <sect id="arch-spec">
6545 <heading>Architecture specification strings</heading>
6548 If a program needs to specify an <em>architecture specification
6549 string</em> in some place, the following format should be
6550 used: <var>arch</var>-<var>os</var><footnote>
6552 The following architectures and operating systems are
6553 currently recognised by <prgn>dpkg-archictecture</prgn>.
6554 The architecture, <tt><var>arch</var></tt>, is one of
6555 the following: <tt>alpha</tt>, <tt>arm</tt>,
6556 <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6557 <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6558 <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6559 <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>. The
6560 operating system, <tt><var>os</var></tt>, is one of:
6561 <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6562 <tt>openbsd</tt>. Use of <tt>gnu</tt> in this string is
6563 reserved for the GNU/Hurd operating system.
6569 Note that we don't want to use
6570 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6571 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6572 since this would make our programs incompatible with other
6573 Linux distributions. We also don't use something like
6574 <tt><var>arch</var>-unknown-linux</tt>, since the
6575 <tt>unknown</tt> does not look very good.
6580 <heading>Daemons</heading>
6583 The configuration files <file>/etc/services</file>,
6584 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6585 by the <prgn>netbase</prgn> package and must not be modified
6590 If a package requires a new entry in one of these files, the
6591 maintainer should get in contact with the
6592 <prgn>netbase</prgn> maintainer, who will add the entries
6593 and release a new version of the <prgn>netbase</prgn>
6598 The configuration file <file>/etc/inetd.conf</file> must not be
6599 modified by the package's scripts except via the
6600 <prgn>update-inetd</prgn> script or the
6601 <file>DebianNet.pm</file> Perl module. See their documentation
6602 for details on how to add entries.
6606 If a package wants to install an example entry into
6607 <file>/etc/inetd.conf</file>, the entry must be preceded with
6608 exactly one hash character (<tt>#</tt>). Such lines are
6609 treated as `commented out by user' by the
6610 <prgn>update-inetd</prgn> script and are not changed or
6611 activated during package updates.
6616 <heading>Using pseudo-ttys and modifying wtmp, utmp and
6620 Some programs need to create pseudo-ttys. This should be done
6621 using Unix98 ptys if the C library supports it. The resulting
6622 program must not be installed setuid root, unless that
6623 is required for other functionality.
6627 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6628 <file>/var/log/lastlog</file> must be installed writeable by
6629 group <tt>utmp</tt>. Programs which need to modify those
6630 files must be installed setgid <tt>utmp</tt>.
6635 <heading>Editors and pagers</heading>
6638 Some programs have the ability to launch an editor or pager
6639 program to edit or display a text document. Since there are
6640 lots of different editors and pagers available in the Debian
6641 distribution, the system administrator and each user should
6642 have the possibility to choose his/her preferred editor and
6647 In addition, every program should choose a good default
6648 editor/pager if none is selected by the user or system
6653 Thus, every program that launches an editor or pager must
6654 use the EDITOR or PAGER environment variable to determine
6655 the editor or pager the user wishes to use. If these
6656 variables are not set, the programs <file>/usr/bin/editor</file>
6657 and <file>/usr/bin/pager</file> should be used, respectively.
6661 These two files are managed through the <prgn>dpkg</prgn>
6662 `alternatives' mechanism. Thus every package providing an
6663 editor or pager must call the
6664 <prgn>update-alternatives</prgn> script to register these
6669 If it is very hard to adapt a program to make use of the
6670 EDITOR or PAGER variables, that program may be configured to
6671 use <file>/usr/bin/sensible-editor</file> and
6672 <file>/usr/bin/sensible-pager</file> as the editor or pager
6673 program respectively. These are two scripts provided in the
6674 Debian base system that check the EDITOR and PAGER variables
6675 and launch the appropriate program, and fall back to
6676 <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6677 variable is not set.
6681 A program may also use the VISUAL environment variable to
6682 determine the user's choice of editor. If it exists, it
6683 should take precedence over EDITOR. This is in fact what
6684 <file>/usr/bin/sensible-editor</file> does.
6688 It is not required for a package to depend on
6689 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6690 package to provide such virtual packages.<footnote>
6692 The Debian base system already provides an editor and a
6699 <sect id="web-appl">
6700 <heading>Web servers and applications</heading>
6703 This section describes the locations and URLs that should
6704 be used by all web servers and web applications in the
6712 Cgi-bin executable files are installed in the
6714 <example compact="compact">
6715 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6717 and should be referred to as
6718 <example compact="compact">
6719 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6724 <item><p>Access to HTML documents</p>
6727 HTML documents for a package are stored in
6728 <file>/usr/share/doc/<var>package</var></file>
6729 and can be referred to as
6730 <example compact="compact">
6731 http://localhost/doc/<var>package</var>/<var>filename</var>
6735 The web server should restrict access to the document
6736 tree so that only clients on the same host can read
6737 the documents. If the web server does not support such
6738 access controls, then it should not provide access at
6739 all, or ask about providing access during installation.
6743 <item><p>Web Document Root</p>
6746 Web Applications should try to avoid storing files in
6747 the Web Document Root. Instead they should use the
6748 /usr/share/doc/<var>package</var> directory for
6749 documents and register the Web Application via the
6750 menu package. If access to the web document root is
6751 unavoidable then use
6752 <example compact="compact">
6755 as the Document Root. This might be just a symbolic
6756 link to the location where the system administrator
6757 has put the real document root.
6761 </enumlist></p></sect>
6764 <sect id="mail-transport-agents">
6765 <heading>Mail transport, delivery and user agents</heading>
6768 Debian packages which process electronic mail, whether mail
6769 user agents (MUAs) or mail transport agents (MTAs), must
6770 ensure that they are compatible with the configuration
6771 decisions below. Failure to do this may result in lost
6772 mail, broken <tt>From:</tt> lines, and other serious brain
6777 The mail spool is <file>/var/mail</file> and the interface to
6778 send a mail message is <file>/usr/sbin/sendmail</file> (as per
6779 the FHS). On older systems, the mail spool may be
6780 physically located in <file>/var/spool/mail</file>, but all
6781 access to the mail spool should be via the
6782 <file>/var/mail</file> symlink. The mail spool is part of the
6783 base system and not part of the MTA package.
6787 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6788 programs (such as IMAP daemons) must lock the mailbox in an
6789 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6790 be combined with dot locking. To avoid deadlocks, a program
6791 should use <tt>fcntl()</tt> first and dot locking after
6792 this, or alternatively implement the two locking methods in
6793 a non blocking way<footnote>
6795 If it is not possible to establish both locks, the
6796 system shouldn't wait for the second lock to be
6797 established, but remove the first lock, wait a (random)
6798 time, and start over locking again.
6800 </footnote>. Using the functions <tt>maillock</tt> and
6801 <tt>mailunlock</tt> provided by the
6802 <tt>liblockfile*</tt><footnote>
6804 You will need to depend on <tt>liblockfile1
6805 (>>1.01)</tt> to use these functions.
6807 </footnote> packages is the recommended way to realize this.
6811 Mailboxes are generally mode 660
6812 <tt><var>user</var>.mail</tt> unless the system
6813 administrator has chosen otherwise. A MUA may remove a
6814 mailbox (unless it has nonstandard permissions) in which
6815 case the MTA or another MUA must recreate it if needed.
6816 Mailboxes must be writable by group mail.
6820 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6821 be setgid mail to do the locking mentioned above (and
6822 must obviously avoid accessing other users' mailboxes
6823 using this privilege).</p>
6826 <file>/etc/aliases</file> is the source file for the system mail
6827 aliases (e.g., postmaster, usenet, etc.), it is the one
6828 which the sysadmin and <prgn>postinst</prgn> scripts may
6829 edit. After <file>/etc/aliases</file> is edited the program or
6830 human editing it must call <prgn>newaliases</prgn>. All MTA
6831 packages must come with a <prgn>newaliases</prgn> program,
6832 even if it does nothing, but older MTA packages did not do
6833 this so programs should not fail if <prgn>newaliases</prgn>
6834 cannot be found. Note that because of this, all MTA
6835 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6836 <tt>Replaces: mail-transport-agent</tt> control file
6841 The convention of writing <tt>forward to
6842 <var>address</var></tt> in the mailbox itself is not
6843 supported. Use a <tt>.forward</tt> file instead.</p>
6846 The <prgn>rmail</prgn> program used by UUCP
6847 for incoming mail should be <file>/usr/sbin/rmail</file>.
6848 Likewise, <prgn>rsmtp</prgn>, for receiving
6849 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6853 If your package needs to know what hostname to use on (for
6854 example) outgoing news and mail messages which are generated
6855 locally, you should use the file <file>/etc/mailname</file>. It
6856 will contain the portion after the username and <tt>@</tt>
6857 (at) sign for email addresses of users on the machine
6858 (followed by a newline).
6862 Such package should check for the existence of this file
6863 when it is being configured. If it exists, it should be
6864 used without comment, although an MTA's configuration script
6865 may wish to prompt the user even if it finds that this file
6866 exists. If the file does not exist, the package should
6867 prompt the user for the value (preferably using
6868 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6869 as well as using it in the package's configuration. The
6870 prompt should make it clear that the name will not just be
6871 used by that package. For example, in this situation the
6872 <tt>inn</tt> package could say something like:
6873 <example compact="compact">
6874 Please enter the `mail name' of your system. This is the
6875 hostname portion of the address to be shown on outgoing
6876 news and mail messages. The default is
6877 <var>syshostname</var>, your system's host name. Mail
6878 name [`<var>syshostname</var>']:
6880 where <var>syshostname</var> is the output of <tt>hostname
6886 <heading>News system configuration</heading>
6889 All the configuration files related to the NNTP (news)
6890 servers and clients should be located under
6891 <file>/etc/news</file>.</p>
6894 There are some configuration issues that apply to a number
6895 of news clients and server packages on the machine. These
6899 <tag><file>/etc/news/organization</file></tag>
6900 <item><p>A string which should appear as the
6901 organization header for all messages posted
6902 by NNTP clients on the machine</p></item>
6904 <tag><file>/etc/news/server</file></tag>
6905 <item><p>Contains the FQDN of the upstream NNTP
6906 server, or localhost if the local machine is
6907 an NNTP server.</p></item>
6910 Other global files may be added as required for cross-package news
6911 configuration.</p></sect>
6915 <heading>Programs for the X Window System</heading>
6918 <heading>Providing X support and package priorities</heading>
6921 Programs that can be configured with support for the X
6922 Window System must be configured to do so and must declare
6923 any package dependencies necessary to satisfy their
6924 runtime requirements when using the X Window System. If
6925 such a package is of higher priority than the X packages
6926 on which it depends, it is required that either the
6927 X-specific components be split into a separate package, or
6928 that an alternative version of the package, which includes
6929 X support, be provided, or that the package's priority be
6935 <heading>Packages providing an X server</heading>
6938 Packages that provide an X server that, directly or
6939 indirectly, communicates with real input and display
6940 hardware should declare in their control data that they
6941 provide the virtual package <tt>xserver</tt>.<footnote>
6943 This implements current practice, and provides an
6944 actual policy for usage of the <tt>xserver</tt>
6945 virtual package which appears in the virtual packages
6946 list. In a nutshell, X servers that interface
6947 directly with the display and input hardware or via
6948 another subsystem (e.g., GGI) should provide
6949 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
6950 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
6957 <heading>Packages providing a terminal emulator</heading>
6960 Packages that provide a terminal emulator for the X Window
6961 System which meet the criteria listed below should declare
6962 in their control data that they provide the virtual
6963 package <tt>x-terminal-emulator</tt>. They should also
6964 register themselves as an alternative for
6965 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
6970 To be an <tt>x-terminal-emulator</tt>, a program must:
6971 <list compact="compact">
6973 Be able to emulate a DEC VT100 terminal, or a
6974 compatible terminal.
6978 Support the command-line option <tt>-e
6979 <var>command</var></tt>, which creates a new
6980 terminal window<footnote>
6982 "New terminal window" does not necessarily mean
6983 a new top-level X window directly parented by
6984 the window manager; it could, if the terminal
6985 emulator application were so coded, be a new
6986 "view" in a multiple-document interface (MDI).
6989 and runs the specified <var>command</var>.
6993 Support the command-line option <tt>-T
6994 <var>title</var></tt>, which creates a new terminal
6995 window with the window title <var>title</var>.
7002 <heading>Packages providing a window manager</heading>
7005 Packages that provide a window manager should declare in
7006 their control data that they provide the virtual package
7007 <tt>x-window-manager</tt>. They should also register
7008 themselves as an alternative for
7009 <file>/usr/bin/x-window-manager</file>, with a priority
7010 calculated as follows:
7011 <list compact="compact">
7012 <item><p>Start with a priority of 20.</p></item>
7016 If the window manager supports the Debian menu
7017 system, add 20 points if this support is available
7018 in the package's default configuration (i.e., no
7019 configuration files belonging to the system or user
7020 have to be edited to activate the feature); if
7021 configuration files must be modified, add only 10
7027 If the window manager complies with <url
7028 id="http://www.freedesktop.org/standards/wm-spec.html"
7029 name="The Window Manager Specification Project">,
7030 written by the <url id="http://www.freedesktop.org"
7031 name="Free Desktop Group">, add 20 points.
7037 If the window manager permits the X session to be
7038 restarted using a <em>different</em> window manager
7039 (without killing the X server) in its default
7040 configuration, add 10 points; otherwise add none.
7048 <heading>Packages providing fonts</heading>
7051 Packages that provide fonts for the X Window
7054 For the purposes of Debian Policy, a "font for the X
7055 Window System" is one which is accessed via X protocol
7056 requests. Fonts for the Linux console, for PostScript
7057 renderers, or any other purpose, do not fit this
7058 definition. Any tool which makes such fonts available
7059 to the X Window System, however, must abide by this
7063 must do a number of things to ensure that they are both
7064 available without modification of the X or font server
7065 configuration, and that they do not corrupt files used by
7066 other font packages to register information about
7071 Fonts of any type supported by the X Window System
7072 must be in a separate binary package from any
7073 executables, libraries, or documentation (except
7074 that specific to the fonts shipped, such as their
7075 license information). If one or more of the fonts
7076 so packaged are necessary for proper operation of
7077 the package with which they are associated the font
7078 package may be Recommended; if the fonts merely
7079 provide an enhancement, a Suggests relationship may
7080 be used. Packages must not Depend on font
7083 This is because the X server may retrieve fonts
7084 from the local filesystem or over the network
7085 from an X font server; the Debian package system
7086 is empowered to deal only with the local
7095 BDF fonts must be converted to PCF fonts with the
7096 <prgn>bdftopcf</prgn> utility (available in the
7097 <tt>xutils</tt> package, <tt>gzip</tt>ped, and
7098 placed in a directory that corresponds to their
7100 <list compact="compact">
7102 100 dpi fonts must be placed in
7103 <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7107 75 dpi fonts must be placed in
7108 <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7112 Character-cell fonts, cursor fonts, and other
7113 low-resolution fonts must be placed in
7114 <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7121 Speedo fonts must be placed in
7122 <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7126 Type 1 fonts must be placed in
7127 <file>/usr/X11R6/lib/X11/fonts/Type1/</file>. If font
7128 metric files are available, they must be placed here
7134 Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7135 other than those listed above must be neither
7136 created nor used. (The <file>PEX</file>, <file>CID</file>,
7137 and <file>cyrillic</file> directories are excepted for
7138 historical reasons, but installation of files into
7139 these directories remains discouraged.)
7145 Font packages may, instead of placing files directly
7146 in the X font directories listed above, provide
7147 symbolic links in that font directory pointing to
7148 the files' actual location in the filesystem. Such
7149 a location must comply with the FHS.
7155 Font packages should not contain both 75dpi and
7156 100dpi versions of a font. If both are available,
7157 they should be provided in separate binary packages
7158 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7159 the names of the packages containing the
7160 corresponding fonts.
7166 Fonts destined for the <file>misc</file> subdirectory
7167 should not be included in the same package as 75dpi
7168 or 100dpi fonts; instead, they should be provided in
7169 a separate package with <tt>-misc</tt> appended to
7176 Font packages must not provide the files
7177 <file>fonts.dir</file>, <file>fonts.alias</file>, or
7178 <file>fonts.scale</file> in a font directory:
7181 <file>fonts.dir</file> files must not be provided at all.
7186 <file>fonts.alias</file> and <file>fonts.scale</file>
7187 files, if needed, should be provided in the
7189 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7190 where <var>fontdir</var> is the name of the
7192 <file>/usr/X11R6/lib/X11/fonts/</file> where the
7193 package's corresponding fonts are stored
7194 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7195 <var>package</var> is the name of the package
7196 that provides these fonts, and
7197 <var>extension</var> is either <tt>scale</tt>
7198 or <tt>alias</tt>, whichever corresponds to
7208 Font packages must declare a dependency on
7209 <tt>xutils (>> 4.0.3)</tt> in their control
7216 Font packages that provide one or more
7217 <file>fonts.scale</file> files as described above must
7218 invoke <prgn>update-fonts-scale</prgn> on each
7219 directory into which they installed fonts
7220 <em>before</em> invoking
7221 <prgn>update-fonts-dir</prgn> on that directory.
7222 This invocation must occur in both the
7223 <prgn>postinst</prgn> (for all arguments) and
7224 <prgn>postrm</prgn> (for all arguments except
7225 <tt>upgrade</tt>) scripts.
7231 Font packages that provide one or more
7232 <file>fonts.alias</file> files as described above must
7233 invoke <prgn>update-fonts-alias</prgn> on each
7234 directory into which they installed fonts. This
7235 invocation must occur in both the
7236 <prgn>postinst</prgn> (for all arguments) and
7237 <prgn>postrm</prgn> (for all arguments except
7238 <tt>upgrade</tt>) scripts.
7244 Font packages must invoke
7245 <prgn>update-fonts-dir</prgn> on each directory into
7246 which they installed fonts. This invocation must
7247 occur in both the <prgn>postinst</prgn> (for all
7248 arguments) and <prgn>postrm</prgn> (for all
7249 arguments except <tt>upgrade</tt>) scripts.
7255 Font packages must not provide alias names for the
7256 fonts they include which collide with alias names
7257 already in use by fonts already packaged.
7263 Font packages must not provide fonts with the same
7264 XLFD registry name as another font already packaged.
7272 <heading>Application defaults files</heading>
7275 Application defaults files must be installed in the
7276 directory <file>/etc/X11/app-defaults/</file> (use of a
7277 localized subdirectory of <file>/etc/X11/</file> as described
7278 in the <em>X Toolkit Intrinsics - C Language
7279 Interface</em> manual is also permitted). They must be
7280 registered as <tt>conffile</tt>s or handled as
7281 configuration files. Packages must not provide the
7282 directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7286 Customization of programs' X resources may also be
7287 supported with the provision of a file with the same name
7288 as that of the package placed in the
7289 <file>/etc/X11/Xresources/</file> directory, which must
7290 registered as a <tt>conffile</tt> or handled as a
7291 configuration file.<footnote>
7293 Note that this mechanism is not the same as using
7294 app-defaults; app-defaults are tied to the client
7295 binary on the local filesystem, whereas X resources
7296 are stored in the X server and affect all connecting
7300 <em>Important:</em> packages that install files into the
7301 <file>/etc/X11/Xresources/</file> directory must conflict with
7302 <tt>xbase (<< 3.3.2.3a-2)</tt>; if this is not done
7303 it is possible for the installing package to destroy a
7304 previously-existing <file>/etc/X11/Xresources</file> file
7305 which had been customized by the system administrator.
7310 <heading>Installation directory issues</heading>
7313 Packages using the X Window System should not be
7314 configured to install files under the <file>/usr/X11R6/</file>
7315 directory unless they use <prgn>imake</prgn>. The
7316 <file>/usr/X11R6/</file> directory hierarchy should be
7317 regarded as deprecated for all packages except the X
7318 Window System itself, and those which use the
7319 <prgn>imake</prgn> program it provides, in which case the
7320 packages may transition out of the <file>/usr/X11R6/</file>
7321 directory at the maintainer's discretion.<footnote>
7323 <prgn>Imake</prgn>-using programs are exempt because,
7324 as long as they are written correctly, the pathnames
7325 they use to locate resources and install themselves
7326 are derived wholly from the X Window System
7327 configuration. Thus, in the event that the X Window
7328 System moves to <file>/usr/X11R7/</file>,
7329 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7330 that is required for these programs is a recompile
7331 against the corresponding X Window System library
7332 development packages.
7335 Programs that use GNU <prgn>autoconf</prgn> and
7336 <prgn>automake</prgn> are usually easily configured at
7337 compile time to use <file>/usr/</file> instead of
7338 <file>/usr/X11R6/</file>, and this should be done whenever
7339 possible. Configuration files for window managers and
7340 display managers should be placed in a subdirectory of
7341 <file>/etc/X11/</file> corresponding to the package name due
7342 to these programs' tight integration with the mechanisms
7343 of the X Window System. Application-level programs should
7344 use the <file>/etc/</file> directory unless otherwise mandated
7345 by policy. The installation of files into subdirectories
7346 of <file>/usr/X11R6/include/X11/</file> and
7347 <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7348 package maintainers should determine if subdirectories of
7349 <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7350 instead. (The use of symbolic links from the
7351 <file>X11R6</file> directories to other FHS-compliant
7352 locations is encouraged if the program is not easily
7353 configured to look elsewhere for its files.) Packages
7354 must not provide or install files into the directories
7355 <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7356 <file>/usr/lib/X11/</file>. Files within a package should,
7357 however, make reference to these directories, rather than
7358 their <tt>X11R6</tt>-named counterparts
7359 <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7360 and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7361 referred to have not been moved to other FHS-compliant
7367 <heading>The OSF/Motif and OpenMotif libraries</heading>
7370 <em>Programs that require the non-DFSG-compliant OSF/Motif or
7371 OpenMotif libraries</em><footnote>
7373 OSF/Motif and OpenMotif are collectively referred to as
7374 "Motif" in this policy document.
7377 should be compiled against and tested with LessTif (a free
7378 re-implementation of Motif) instead. If the maintainer
7379 judges that the program or programs do not work
7380 sufficiently well with LessTif to be distributed and
7381 supported, but do so when compiled against Motif, then two
7382 versions of the package should be created; one linked
7383 statically against Motif and with <tt>-smotif</tt>
7384 appended to the package name, and one linked dynamically
7385 against Motif and with <tt>-dmotif</tt> appended to the
7386 package name. Both Motif-linked versions are dependent
7387 upon non-DFSG-compliant software and thus cannot be
7388 uploaded to the <em>main</em> distribution; if the
7389 software is itself DFSG-compliant it may be uploaded to
7390 the <em>contrib</em> distribution. While known existing
7391 versions of Motif permit unlimited redistribution of
7392 binaries linked against the library (whether statically or
7393 dynamically), it is the package maintainer's
7394 responsibility to determine whether this is permitted by
7395 the license of the copy of Motif in his or her possession.
7401 <heading>Perl programs and modules</heading>
7403 Perl programs and modules should follow the current Perl
7404 policy as defined in the file found on
7405 <ftpsite>ftp.debian.org</ftpsite> in
7406 <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>
7407 or your local mirror. In addition, it is included in the
7408 <tt>debian-policy</tt> package.
7413 <heading>Emacs lisp programs</heading>
7416 Please refer to the `Debian Emacs Policy' (documented in
7417 <file>debian-emacs-policy.gz</file> of the
7418 <prgn>emacsen-common</prgn> package) for details of how to
7419 package emacs lisp programs.
7424 <heading>Games</heading>
7427 The permissions on <file>/var/games</file> are mode 755, owner
7428 <tt>root</tt> and group <tt>root</tt>.
7432 Each game decides on its own security policy.</p>
7435 Games which require protected, privileged access to
7436 high-score files, savegames, etc., may be made
7437 set-<em>group</em>-id (mode 2755) and owned by
7438 <tt>root.games</tt>, and use files and directories with
7439 appropriate permissions (770 <tt>root.games</tt>, for
7440 example). They must not be made
7441 set-<em>user</em>-id, as this causes security problems. (If
7442 an attacker can subvert any set-user-id game they can
7443 overwrite the executable of any other, causing other players
7444 of these games to run a Trojan horse program. With a
7445 set-group-id game the attacker only gets access to less
7446 important game data, and if they can get at the other
7447 players' accounts at all it will take considerably more
7451 Some packages, for example some fortune cookie programs, are
7452 configured by the upstream authors to install with their
7453 data files or other static information made unreadable so
7454 that they can only be accessed through set-id programs
7455 provided. You should not do this in a Debian package: anyone can
7456 download the <file>.deb</file> file and read the data from it,
7457 so there is no point making the files unreadable. Not
7458 making the files unreadable also means that you don't have
7459 to make so many programs set-id, which reduces the risk of a
7463 As described in the FHS, binaries of games should be
7464 installed in the directory <file>/usr/games</file>. This also
7465 applies to games that use the X Window System. Manual pages
7466 for games (X and non-X games) should be installed in
7467 <file>/usr/share/man/man6</file>.</p>
7471 <chapt id="docs"><heading>Documentation</heading>
7475 <heading>Manual pages</heading>
7478 You should install manual pages in <prgn>nroff</prgn> source
7479 form, in appropriate places under <file>/usr/share/man</file>. You
7480 should only use sections 1 to 9 (see the FHS for more
7481 details). You must not install a preformatted `cat
7485 Each program, utility, and function should have an
7486 associated manpage included in the same package. It is
7487 suggested that all configuration files also have a manual
7488 page included as well.
7492 If no manual page is available for a particular program,
7493 utility, function or configuration file and this is reported
7494 as a bug to the Debian Bug Tracking System, a symbolic link
7495 from the requested manual page to the <manref
7496 name="undocumented" section="7"> manual page may be
7497 provided. This symbolic link can be created from
7498 <file>debian/rules</file> like this:
7499 <example compact="compact">
7500 ln -s ../man7/undocumented.7.gz \
7501 debian/tmp/usr/share/man/man[1-9]/<var>requested_manpage</var>.[1-9].gz
7503 This manpage claims that the lack of a manpage has been
7504 reported as a bug, so you may only do this if it really has
7505 (you can report it yourself, if you like). Do not close the
7506 bug report until a proper manpage is available.</p>
7509 You may forward a complaint about a missing manpage to the
7510 upstream authors, and mark the bug as forwarded in the
7511 Debian bug tracking system. Even though the GNU Project do
7512 not in general consider the lack of a manpage to be a bug,
7513 we do; if they tell you that they don't consider it a bug
7514 you should leave the bug in our bug tracking system open
7518 Manual pages should be installed compressed using <tt>gzip
7522 If one manpage needs to be accessible via several names it
7523 is better to use a symbolic link than the <file>.so</file>
7524 feature, but there is no need to fiddle with the relevant
7525 parts of the upstream source to change from <file>.so</file> to
7526 symlinks: don't do it unless it's easy. You should not
7527 create hard links in the manual page directories, nor put
7528 absolute filenames in <file>.so</file> directives. The filename
7529 in a <file>.so</file> in a manpage should be relative to the
7530 base of the manpage tree (usually
7531 <file>/usr/share/man</file>). If you do not create any links
7532 (whether symlinks, hard links, or <tt>.so</tt> directives)
7533 in the filesystem to the alternate names of the manpage,
7534 then you should not rely on <prgn>man</prgn> finding your
7535 manpage under those names based solely on the information in
7536 the manpage's header.<footnote>
7538 Supporting this in <prgn>man</prgn> often requires
7539 unreasonable processing time to find a manual page or to
7540 report that none exists, and moves knowledge into man's
7541 database that would be better left in the filesystem.
7542 This support is therefore deprecated and will cease to
7543 be present in the future.
7550 <heading>Info documents</heading>
7553 Info documents should be installed in <file>/usr/share/info</file>.
7554 They should be compressed with <tt>gzip -9</tt>.</p>
7557 Your package should call <prgn>install-info</prgn> to update
7558 the Info <file>dir</file> file in its <prgn>postinst</prgn>
7559 script when called with a <tt>configure</tt> argument, for
7561 <example compact="compact">
7562 install-info --quiet --section Development Development \
7563 /usr/share/info/foobar.info
7567 It is a good idea to specify a section for the location of
7568 your program; this is done with the <tt>--section</tt>
7569 switch. To determine which section to use, you should look
7570 at <file>/usr/share/info/dir</file> on your system and choose the most
7571 relevant (or create a new section if none of the current
7572 sections are relevant). Note that the <tt>--section</tt>
7573 flag takes two arguments; the first is a regular expression
7574 to match (case-insensitively) against an existing section,
7575 the second is used when creating a new one.</p>
7578 You should remove the entries in the <prgn>prerm</prgn>
7579 script when called with a <tt>remove</tt> argument:
7580 <example compact="compact">
7581 install-info --quiet --remove /usr/share/info/foobar.info
7585 If <prgn>install-info</prgn> cannot find a description entry
7586 in the Info file you must supply one. See <manref
7587 name="install-info" section="8"> for details.</p>
7591 <heading>Additional documentation</heading>
7594 Any additional documentation that comes with the package may
7595 be installed at the discretion of the package maintainer.
7596 Text documentation should be installed in the directory
7597 <file>/usr/share/doc/<var>package</var></file>, where
7598 <var>package</var> is the name of the package, and
7599 compressed with <tt>gzip -9</tt> unless it is small.</p>
7602 If a package comes with large amounts of documentation which
7603 many users of the package will not require you should create
7604 a separate binary package to contain it, so that it does not
7605 take up disk space on the machines of users who do not need
7606 or want it installed.</p>
7609 It is often a good idea to put text information files
7610 (<file>README</file>s, changelogs, and so forth) that come with
7611 the source package in <file>/usr/share/doc/<var>package</var></file>
7612 in the binary package. However, you don't need to install
7613 the instructions for building and installing the package, of
7617 Files in <file>/usr/share/doc</file> should not be referenced by
7618 any program, and the system administrator should be able to
7619 delete them without causing any programs to break. Any files
7620 that are referenced by programs but are also useful as
7621 standalone documentation should be installed under
7622 <file>/usr/share/<var>package</var>/</file> with symbolic links
7623 from <file>/usr/share/doc/<var>package</var>/</file>.
7629 <heading>Accessing the documentation</heading>
7632 Former Debian releases placed all additional documentation
7633 in <file>/usr/doc/<var>package</var></file>. This has now
7634 changed to <file>/usr/share/doc/<var>package</var></file>,
7635 and packages must not put documentation in the directory
7636 <file>/usr/doc/<var>package</var></file>. <footnote>
7637 <p>At this phase of the transition, we no longer require a
7638 symbolic link in <file>/usr/doc/</file>. At a later point,
7639 policy shall change to make the symbolic links a bug.</p>
7645 <heading>Preferred documentation formats</heading>
7648 The unification of Debian documentation is being carried out
7652 If your package comes with extensive documentation in a
7653 markup format that can be converted to various other formats
7654 you should if possible ship HTML versions in a binary
7655 package, in the directory
7656 <file>/usr/share/doc/<var>appropriate-package</var></file> or
7657 its subdirectories.<footnote>
7659 The rationale: The important thing here is that HTML
7660 docs should be available in <em>some</em> package, not
7661 necessarily in the main binary package.
7667 Other formats such as PostScript may be provided at the
7668 package maintainer's discretion.
7672 <sect id="copyrightfile">
7673 <heading>Copyright information</heading>
7676 Every package must be accompanied by a verbatim copy of its
7677 copyright and distribution license in the file
7678 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7679 file must neither be compressed nor be a symbolic link.
7683 In addition, the copyright file must say where the upstream
7684 sources (if any) were obtained, and should explain briefly what
7685 modifications were made in the Debian version of the package
7686 compared to the upstream one. It should name the original
7687 authors of the package and the Debian maintainer(s) who were
7688 involved with its creation.</p>
7691 A copy of the file which will be installed in
7692 <file>/usr/share/doc/<var>package</var>/copyright</file> should
7693 be in <file>debian/copyright</file> in the source package.
7697 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7698 link to another directory in <file>/usr/share/doc</file> only if
7699 the two packages both come from the same source and the
7700 first package Depends on the second. These rules are
7701 important because copyrights must be extractable by
7706 Packages distributed under the UCB BSD license, the Artistic
7707 license, the GNU GPL, and the GNU LGPL should refer to the
7708 files <file>/usr/share/common-licenses/BSD</file>,
7709 <file>/usr/share/common-licenses/Artistic</file>,
7710 <file>/usr/share/common-licenses/GPL</file>, and
7711 <file>/usr/share/common-licenses/LGPL</file> respectively,
7712 rather than quoting them in the copyright file.
7716 You should not use the copyright file as a general <file>README</file>
7717 file. If your package has such a file it should be
7718 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7719 <file>README.Debian</file> or some other appropriate place.</p>
7723 <heading>Examples</heading>
7726 Any examples (configurations, source files, whatever),
7727 should be installed in a directory
7728 <file>/usr/share/doc/<var>package</var>/examples</file>. These
7729 files should not be referenced by any program: they're there
7730 for the benefit of the system administrator and users as
7731 documentation only. Architecture-specific example files
7732 should be installed in a directory
7733 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7735 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7736 latter directory itself may be a symbolic link to the
7741 <sect id="instchangelog">
7742 <heading>Changelog files</heading>
7745 Packages that are not Debian-native must contain a
7746 compressed copy of the <file>debian/changelog</file> file from
7747 the Debian source tree in
7748 <file>/usr/share/doc/<var>package</var></file> with the name
7749 <file>changelog.Debian.gz</file>. If an upstream changelog is
7750 available, it should be accessible as
7751 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7752 plain text. If the upstream changelog is distributed in
7753 HTML, it should be made available in that form as
7754 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7755 and a plain text <file>changelog.gz</file> should be generated
7756 from it using, for example, <tt>lynx -dump -nolist</tt>. If
7757 the upstream changelog files do not already conform to this
7758 naming convention, then this may be achieved either by
7759 renaming the files, or by adding a symbolic link, at the
7760 maintainer's discretion.<footnote>
7762 Rationale: People should not have to look in places for
7763 upstream changelogs merely because they are given
7764 different names or are distributed in HTML format.
7770 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7771 link to another directory in <file>/usr/share/doc</file> only if
7772 the two packages both come from the same source and the
7773 first package Depends on the second.
7778 All of these files should be installed compressed using
7779 <tt>gzip -9</tt>, as they will become large with time even
7780 if they start out small.
7784 If the package has only one changelog which is used both as
7785 the Debian changelog and the upstream one because there is
7786 no separate upstream maintainer then that changelog should
7787 usually be installed as
7788 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7789 there is a separate upstream maintainer, but no upstream
7790 changelog, then the Debian changelog should still be called
7791 <file>changelog.Debian.gz</file>.</p>
7795 <appendix id="pkg-scope">
7796 <heading>Introduction and scope of these appendices</heading>
7799 These appendices are taken essentially verbatim from the
7800 now-deprecated Packaging Manual, version 3.2.1.0. They are
7801 the chapters which are likely to be of use to package
7802 maintainers and which have not already been included in the
7803 policy document itself. Most of these sections are very likely
7804 not relevant to policy; they should be treated as
7805 documentation for the packaging system. Please note that these
7806 appendices are included for convenience, and for historical
7807 reasons: they used to be part of policy package, and they have
7808 not yet been incorporated into dpkg documentation. However,
7809 they still have value, and hence they are presented here.
7812 They have not yet been checked to ensure that they are
7813 compatible with the contents of policy, and if there are any
7814 contradictions, the version in the main policy document takes
7815 precedence. The remaining chapters of the old Packaging
7816 Manual have also not been read in detail to ensure that there
7817 are not parts which have been left out. Both of these will be
7822 <prgn>dpkg</prgn> is a suite of programs for creating binary
7823 package files and installing and removing them on Unix
7826 <prgn>dpkg</prgn> is targetted primarily at Debian
7827 GNU/Linux, but may work on or be ported to other
7834 The binary packages are designed for the management of
7835 installed executable programs (usually compiled binaries) and
7836 their associated data, though source code examples and
7837 documentation are provided as part of some packages.</p>
7840 This manual describes the technical aspects of creating Debian
7841 binary packages (<file>.deb</file> files). It documents the
7842 behaviour of the package management programs
7843 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7844 they interact with packages.</p>
7847 It also documents the interaction between
7848 <prgn>dselect</prgn>'s core and the access method scripts it
7849 uses to actually install the selected packages, and describes
7850 how to create a new access method.</p>
7853 This manual does not go into detail about the options and
7854 usage of the package building and installation tools. It
7855 should therefore be read in conjuction with those programs'
7860 The utility programs which are provided with <prgn>dpkg</prgn>
7861 for managing various system configuration and similar issues,
7862 such as <prgn>update-rc.d</prgn> and
7863 <prgn>install-info</prgn>, are not described in detail here -
7864 please see their manpages.
7868 It does <em>not</em> describe the policy requirements imposed
7869 on Debian packages, such as the permissions on files and
7870 directories, documentation requirements, upload procedure, and
7871 so on. You should see the Debian packaging policy manual for
7872 these details. (Many of them will probably turn out to be
7873 helpful even if you don't plan to upload your package and make
7874 it available as part of the distribution.)
7878 It is assumed that the reader is reasonably familiar with the
7879 <prgn>dpkg</prgn> System Administrators' manual.
7880 Unfortunately this manual does not yet exist.
7884 The Debian version of the FSF's GNU hello program is provided
7885 as an example for people wishing to create Debian
7886 packages. The Debian <prgn>debmake</prgn> package is
7887 recommended as a very helpful tool in creating and maintaining
7888 Debian packages. However, while the tools and examples are
7889 helpful, they do not replace the need to read and follow the
7890 Policy and Programmer's Manual.</p>
7893 <appendix id="pkg-binarypkg"><heading>Binary packages (from old
7898 The binary package has two main sections. The first part
7899 consists of various control information files and scripts used
7900 by <prgn>dpkg</prgn> when installing and removing. See <ref
7901 id="pkg-controlarea">.
7905 The second part is an archive containing the files and
7906 directories to be installed.
7910 In the future binary packages may also contain other
7911 components, such as checksums and digital signatures. The
7912 format for the archive is described in full in the
7913 <file>deb(5)</file> manpage.
7917 <sect id="pkg-bincreating"><heading>Creating package files -
7918 <prgn>dpkg-deb</prgn>
7922 All manipulation of binary package files is done by
7923 <prgn>dpkg-deb</prgn>; it's the only program that has
7924 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
7925 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
7926 will spot that the options requested are appropriate to
7927 <prgn>dpkg-deb</prgn> and invoke that instead with the same
7932 In order to create a binary package you must make a
7933 directory tree which contains all the files and directories
7934 you want to have in the filesystem data part of the package.
7935 In Debian-format source packages this directory is usually
7936 <file>debian/tmp</file>, relative to the top of the package's
7941 They should have the locations (relative to the root of the
7942 directory tree you're constructing) ownerships and
7943 permissions which you want them to have on the system when
7948 With current versions of <prgn>dpkg</prgn> the uid/username
7949 and gid/groupname mappings for the users and groups being
7950 used should be the same on the system where the package is
7951 built and the one where it is installed.
7955 You need to add one special directory to the root of the
7956 miniature filesystem tree you're creating:
7957 <prgn>DEBIAN</prgn>. It should contain the control
7958 information files, notably the binary package control file
7959 (see <ref id="pkg-controlfile">).
7963 The <prgn>DEBIAN</prgn> directory will not appear in the
7964 filesystem archive of the package, and so won't be installed
7965 by <prgn>dpkg</prgn> when the package is installed.
7969 When you've prepared the package, you should invoke:
7971 dpkg --build <var>directory</var>
7976 This will build the package in
7977 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
7978 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
7979 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
7984 See the manpage <manref name="dpkg-deb" section="8"> for details of how
7985 to examine the contents of this newly-created file. You may find the
7986 output of following commands enlightening:
7988 dpkg-deb --info <var>filename</var>.deb
7989 dpkg-deb --contents <var>filename</var>.deb
7990 dpkg --contents <var>filename</var>.deb
7992 To view the copyright file for a package you could use this command:
7994 dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
7999 <sect id="pkg-controlarea">
8001 Package control information files
8005 The control information portion of a binary package is a
8006 collection of files with names known to <prgn>dpkg</prgn>.
8007 It will treat the contents of these files specially - some
8008 of them contain information used by <prgn>dpkg</prgn> when
8009 installing or removing the package; others are scripts which
8010 the package maintainer wants <prgn>dpkg</prgn> to run.
8014 It is possible to put other files in the package control
8015 area, but this is not generally a good idea (though they
8016 will largely be ignored).
8020 Here is a brief list of the control info files supported by
8021 <prgn>dpkg</prgn> and a summary of what they're used for.
8026 <tag><tt>control</tt>
8030 This is the key description file used by
8031 <prgn>dpkg</prgn>. It specifies the package's name
8032 and version, gives its description for the user,
8033 states its relationships with other packages, and so
8034 forth. See <ref id="pkg-controlfile">.
8038 It is usually generated automatically from information
8039 in the source package by the
8040 <prgn>dpkg-gencontrol</prgn> program, and with
8041 assistance from <prgn>dpkg-shlibdeps</prgn>. See <ref
8042 id="pkg-sourcetools">.</p>
8045 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8051 These are exectuable files (usually scripts) which
8052 <prgn>dpkg</prgn> runs during installation, upgrade
8053 and removal of packages. They allow the package to
8054 deal with matters which are particular to that package
8055 or require more complicated processing than that
8056 provided by <prgn>dpkg</prgn>. Details of when and
8057 how they are called are in <ref
8058 id="maintainerscripts">.
8062 It is very important to make these scripts
8066 That means that if it runs successfully or fails
8067 and then you call it again it doesn't bomb out,
8068 but just ensures that everything is the way it
8071 </footnote> This is so that if an error occurs, the
8072 user interrupts <prgn>dpkg</prgn> or some other
8073 unforeseen circumstance happens you don't leave the
8074 user with a badly-broken package.
8078 The maintainer scripts are guaranteed to run with a
8079 controlling terminal and can interact with the user.
8080 If they need to prompt for passwords, do full-screen
8081 interaction or something similar you should do these
8082 things to and from <file>/dev/tty</file>, since
8083 <prgn>dpkg</prgn> will at some point redirect scripts'
8084 standard input and output so that it can log the
8085 installation process. Likewise, because these scripts
8086 may be executed with standard output redirected into a
8087 pipe for logging purposes, Perl scripts should set
8088 unbuffered output by setting <tt>$|=1</tt> so that the
8089 output is printed immediately rather than being
8094 Each script should return a zero exit status for
8095 success, or a nonzero one for failure.</p>
8098 <tag><tt>conffiles</tt>
8103 This file contains a list of configuration files which
8104 are to be handled automatically by <prgn>dpkg</prgn>
8105 (see <ref id="pkg-conffiles">). Note that not necessarily
8106 every configuration file should be listed here.</p>
8109 <tag><tt>shlibs</tt>
8114 This file contains a list of the shared libraries
8115 supplied by the package, with dependency details for
8116 each. This is used by <prgn>dpkg-shlibdeps</prgn>
8117 when it determines what dependencies are required in a
8118 package control file. The <tt>shlibs</tt> file format
8119 is described on <ref id="shlibs">.
8125 <sect id="pkg-controlfile">
8127 The main control information file: <tt>control</tt>
8130 The most important control information file used by
8131 <prgn>dpkg</prgn> when it installs a package is
8132 <tt>control</tt>. It contains all the package's `vital
8137 The binary package control files of packages built from
8138 Debian sources are made by a special tool,
8139 <prgn>dpkg-gencontrol</prgn>, which reads
8140 <file>debian/control</file> and <file>debian/changelog</file> to
8141 find the information it needs. See <ref id="pkg-sourcepkg"> for
8146 The fields in binary package control files are:
8147 <list compact="compact">
8149 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8152 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8154 <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8158 This field should appear in all packages, though
8159 <prgn>dpkg</prgn> doesn't require it yet so that
8160 old packages can still be installed.
8166 <p><qref id="relationships"><tt>Depends</tt>,
8167 <tt>Provides</tt> et al.</qref></p>
8170 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8173 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8176 <p><qref id="pkg-f-classification"><tt>Section</tt>,
8177 <tt>Priority</tt></qref></p>
8180 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8183 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8187 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8193 A description of the syntax of control files and the purpose
8194 of these fields is available in <ref id="pkg-controlfields">.
8199 <heading>Time Stamps</heading>
8201 Maintainers are encouraged to preserve the modification
8202 times of the upstream source files in a package, as far as
8203 is reasonably possible.
8206 The rationale is that there is some information conveyed
8207 by knowing the age of the file, for example, you could
8208 recognize that some documentation is very old by looking
8209 at the modification time, so it would be nice if the
8210 modification time of the upstream source would be
8218 <appendix id="pkg-sourcepkg">
8219 <heading>Source packages (from old Packaging Manual) </heading>
8222 The Debian binary packages in the distribution are generated
8223 from Debian sources, which are in a special format to assist
8224 the easy and automatic building of binaries.
8228 There was a previous version of the Debian source format,
8229 which is now being phased out. Instructions for converting an
8230 old-style package are given in the Debian policy manual.
8233 <sect id="pkg-sourcetools">
8234 <heading>Tools for processing source packages</heading>
8237 Various tools are provided for manipulating source packages;
8238 they pack and unpack sources and help build of binary
8239 packages and help manage the distribution of new versions.
8243 They are introduced and typical uses described here; see
8244 <manref name="dpkg-source" section="1"> for full
8245 documentation about their arguments and operation.
8249 For examples of how to construct a Debian source package,
8250 and how to use those utilities that are used by Debian
8251 source packages, please see the <prgn>hello</prgn> example
8257 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8262 This program is frequently used by hand, and is also
8263 called from package-independent automated building scripts
8264 such as <prgn>dpkg-buildpackage</prgn>.
8268 To unpack a package it is typically invoked with
8270 dpkg-source -x <var>.../path/to/filename</var>.dsc
8275 with the <file><var>filename</var>.tar.gz</file> and
8276 <file><var>filename</var>.diff.gz</file> (if applicable) in
8277 the same directory. It unpacks into
8278 <file><var>package</var>-<var>version</var></file>, and if
8280 <file><var>package</var>-<var>version</var>.orig</file>, in
8281 the current directory.
8285 To create a packed source archive it is typically invoked:
8287 dpkg-source -b <var>package</var>-<var>version</var>
8292 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8293 <file>.diff.gz</file> (if appropriate) in the current
8294 directory. <prgn>dpkg-source</prgn> does not clean the
8295 source tree first - this must be done separately if it is
8300 See also <ref id="pkg-sourcearchives">.</p>
8306 <prgn>dpkg-buildpackage</prgn> - overall package-building
8311 <prgn>dpkg-buildpackage</prgn> is a script which invokes
8312 <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8313 targets <tt>clean</tt>, <tt>build</tt> and
8314 <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8315 <prgn>pgp</prgn> to build a signed source and binary
8320 It is usually invoked by hand from the top level of the
8321 built or unbuilt source directory. It may be invoked with
8322 no arguments; useful arguments include:
8323 <taglist compact="compact">
8324 <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8327 Do not PGP-sign the <tt>.changes</tt> file or the
8328 source package <tt>.dsc</tt> file, respectively.</p>
8330 <tag><tt>-p<var>pgp-command</var></tt></tag>
8333 Invoke <var>pgp-command</var> instead of finding
8334 <tt>pgp</tt> on the <prgn>PATH</prgn>.
8335 <var>pgp-command</var> must behave just like
8336 <prgn>pgp</prgn>.</p>
8338 <tag><tt>-r<var>root-command</var></tt></tag>
8341 When root privilege is required, invoke the command
8342 <var>root-command</var>. <var>root-command</var>
8343 should invoke its first argument as a command, from
8344 the <prgn>PATH</prgn> if necessary, and pass its
8345 second and subsequent arguments to the command it
8346 calls. If no <var>root-command</var> is supplied
8347 then <var>dpkg-buildpackage</var> will take no
8348 special action to gain root privilege, so that for
8349 most packages it will have to be invoked as root to
8352 <tag><tt>-b</tt>, <tt>-B</tt></tag>
8355 Two types of binary-only build and upload - see
8356 <manref name="dpkg-source" section="1">.
8365 <prgn>dpkg-gencontrol</prgn> - generates binary package
8370 This program is usually called from <file>debian/rules</file>
8371 (see <ref id="pkg-sourcetree">) in the top level of the source
8376 This is usually done just before the files and directories in the
8377 temporary directory tree where the package is being built have their
8378 permissions and ownerships set and the package is constructed using
8379 <prgn>dpkg-deb/</prgn>
8382 This is so that the control file which is produced has
8383 the right permissions
8389 <prgn>dpkg-gencontrol</prgn> must be called after all the
8390 files which are to go into the package have been placed in
8391 the temporary build directory, so that its calculation of
8392 the installed size of a package is correct.
8396 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8397 be run after <prgn>dpkg-shlibdeps</prgn> so that the
8398 variable substitutions created by
8399 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8404 For a package which generates only one binary package, and
8405 which builds it in <file>debian/tmp</file> relative to the top
8406 of the source package, it is usually sufficient to call
8407 <prgn>dpkg-gencontrol</prgn>.
8411 Sources which build several binaries will typically need
8414 dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8415 </example> The <tt>-P</tt> tells
8416 <prgn>dpkg-gencontrol</prgn> that the package is being
8417 built in a non-default directory, and the <tt>-p</tt>
8418 tells it which package's control file should be generated.
8422 <prgn>dpkg-gencontrol</prgn> also adds information to the
8423 list of files in <file>debian/files</file>, for the benefit of
8424 (for example) a future invocation of
8425 <prgn>dpkg-genchanges</prgn>.</p>
8430 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8435 This program is usually called from <file>debian/rules</file>
8436 just before <prgn>dpkg-gencontrol</prgn> (see <ref
8437 id="pkg-sourcetree">), in the top level of the source tree.
8441 Its arguments are executables.
8444 In a forthcoming dpkg version,
8445 <prgn>dpkg-shlibdeps</prgn> would be required to be
8446 called on shared libraries as well.
8449 They may be specified either in the locations in the
8450 source tree where they are created or in the locations
8451 in the temporary build tree where they are installed
8452 prior to binary package creation.
8454 </footnote> for which shared library dependencies should
8455 be included in the binary package's control file.
8459 If some of the found shared libraries should only
8460 warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8461 some warrant a <tt>Pre-Depends</tt>, this can be achieved
8462 by using the <tt>-d<var>dependency-field</var></tt> option
8463 before those executable(s). (Each <tt>-d</tt> option
8464 takes effect until the next <tt>-d</tt>.)
8468 <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8469 output control file to be modified. Instead by default it
8470 adds to the <file>debian/substvars</file> file variable
8471 settings like <tt>shlibs:Depends</tt>. These variable
8472 settings must be referenced in dependency fields in the
8473 appropriate per-binary-package sections of the source
8478 For example, the <prgn>procps</prgn> package generates two
8479 kinds of binaries, simple C binaries like <prgn>ps</prgn>
8480 which require a predependency and full-screen ncurses
8481 binaries like <prgn>top</prgn> which require only a
8482 recommendation. It can say in its <file>debian/rules</file>:
8484 dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8486 and then in its main control file <file>debian/control</file>:
8490 Pre-Depends: ${shlibs:Pre-Depends}
8491 Recommends: ${shlibs:Recommends}
8497 Sources which produce several binary packages with
8498 different shared library dependency requirements can use
8499 the <tt>-p<var>varnameprefix</var></tt> option to override
8500 the default <tt>shlibs:</tt> prefix (one invocation of
8501 <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8502 They can thus produce several sets of dependency
8503 variables, each of the form
8504 <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8505 which can be referred to in the appropriate parts of the
8506 binary package control files.
8513 <prgn>dpkg-distaddfile</prgn> - adds a file to
8514 <file>debian/files</file>
8518 Some packages' uploads need to include files other than
8519 the source and binary package files.
8523 <prgn>dpkg-distaddfile</prgn> adds a file to the
8524 <file>debian/files</file> file so that it will be included in
8525 the <file>.changes</file> file when
8526 <prgn>dpkg-genchanges</prgn> is run.
8530 It is usually invoked from the <tt>binary</tt> target of
8531 <file>debian/rules</file>:
8533 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8535 The <var>filename</var> is relative to the directory where
8536 <prgn>dpkg-genchanges</prgn> will expect to find it - this
8537 is usually the directory above the top level of the source
8538 tree. The <file>debian/rules</file> target should put the
8539 file there just before or just after calling
8540 <prgn>dpkg-distaddfile</prgn>.
8544 The <var>section</var> and <var>priority</var> are passed
8545 unchanged into the resulting <file>.changes</file> file. See
8546 <ref id="pkg-f-classification">.
8551 <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8556 This program is usually called by package-independent
8557 automatic building scripts such as
8558 <prgn>dpkg-buildpackage</prgn>, but it may also be called
8563 It is usually called in the top level of a built source
8564 tree, and when invoked with no arguments will print out a
8565 straightforward <file>.changes</file> file based on the
8566 information in the source package's changelog and control
8567 file and the binary and source packages which should have
8573 <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8578 This program is used internally by
8579 <prgn>dpkg-source</prgn> et al. It may also occasionally
8580 be useful in <file>debian/rules</file> and elsewhere. It
8581 parses a changelog, <file>debian/changelog</file> by default,
8582 and prints a control-file format representation of the
8583 information in it to standard output.
8587 <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8588 information about the build and host system
8592 This program can be used manually, but is also invoked by
8593 <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8594 to set environment or make variables which specify the build and
8595 host architecture for the package building process.
8600 <sect id="pkg-sourcetree"><heading>The Debianised source tree
8604 The source archive scheme described later is intended to
8605 allow a Debianised source tree with some associated control
8606 information to be reproduced and transported easily. The
8607 Debianised source tree is a version of the original program
8608 with certain files added for the benefit of the
8609 Debianisation process, and with any other changes required
8610 made to the rest of the source code and installation
8615 The extra files created for Debian are in the subdirectory
8616 <file>debian</file> of the top level of the Debianised source
8617 tree. They are described below.
8620 <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8625 This file is an executable makefile, and contains the
8626 package-specific recipies for compiling the package and
8627 building binary package(s) out of the source.
8631 It must start with the line <tt>#!/usr/bin/make -f</tt>,
8632 so that it can be invoked by saying its name rather than
8633 invoking <prgn>make</prgn> explicitly.
8637 Since an interactive <file>debian/rules</file> script makes it
8638 impossible to autocompile that package and also makes it
8639 hard for other people to reproduce the same binary
8640 package, all <strong>required targets</strong> have to be
8641 non-interactive. At a minimul, required targets are the
8642 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8643 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8644 <em>build</em>. It also follows that any target that these
8645 targets depend on must also be non-interactive.
8649 The targets which are required to be present are:
8651 <tag><tt>build</tt></tag>
8654 This should perform all non-interactive
8655 configuration and compilation of the package. If a
8656 package has an interactive pre-build configuration
8657 routine, the Debianised source package should be
8658 built after this has taken place, so that it can be
8659 built without rerunning the configuration.
8663 A package may also provide both of the targets
8664 <tt>build-arch</tt> and <tt>build-indep</tt>. The
8665 <tt>build-arch</tt> target, if provided, should
8666 perform all non-interactive configuration and
8667 compilation required for producing all
8668 architecture-dependant binary packages (those packages
8669 for which the body of the <tt>Architecture</tt> field
8670 in <tt>debian/control</tt> is not <tt>all</tt>).
8671 Similarly, the <tt>build-indep</tt> target, if
8672 provided, should perform all non-interactive
8673 configuration and compilation required for producing
8674 all architecture-independent binary packages (those
8675 packages for which the body of the
8676 <tt>Architecture</tt> field in <tt>debian/control</tt>
8677 is <tt>all</tt>). The <tt>build</tt> target should
8678 depend on those of the targets <tt>build-arch</tt> and
8679 <tt>build-indep</tt> that are provided in the rules
8684 If one or both of the targets <tt>build-arch</tt> and
8685 <tt>build-indep</tt> are not provided, then invoking
8686 <file>debian/rules</file> with one of the not-provided
8687 targets as arguments should produce a exit status code
8688 of 2. Usually this is provided automatically by make
8689 if the target is missing.
8693 For some packages, notably ones where the same
8694 source tree is compiled in different ways to produce
8695 two binary packages, the <tt>build</tt> target does
8696 not make much sense. For these packages it is good
8697 enough to provide two (or more) targets
8698 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8699 for each of the ways of building the package, and a
8700 <tt>build</tt> target that does nothing. The
8701 <tt>binary</tt> target will have to build the
8702 package in each of the possible ways and make the
8703 binary package out of each.
8707 The targets <tt>build</tt>, <tt>build-arch</tt>
8708 and <tt>build-indep</tt> target must not do
8709 anything that might require root privilege.
8713 The <tt>build</tt> target may need to run
8714 <tt>clean</tt> first - see below.
8718 When a package has a configuration routine that takes
8719 a long time, or when the makefiles are poorly
8720 designed, or when <tt>build</tt> needs to run
8721 <tt>clean</tt> first, it is a good idea to <tt>touch
8722 build</tt> when the build process is complete. This
8723 will ensure that if <tt>debian/rules build</tt> is run
8724 again it will not rebuild the whole program.
8728 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8729 <tt>binary-indep</tt>
8733 The <tt>binary</tt> target should be all that is
8734 necessary for the user to build the binary
8735 package. All these targets are required to be
8736 non-interactive. It is split into two parts:
8737 <tt>binary-arch</tt> builds the packages' output
8738 files which are specific to a particular
8739 architecture, and <tt>binary-indep</tt> builds
8740 those which are not.
8744 <tt>binary</tt> should usually be a target with
8745 no commands which simply depends on
8746 <prgn>binary-arch</prgn> and
8747 <prgn>binary-indep</prgn>.
8751 Both <prgn>binary-*</prgn> targets should depend on
8752 the <tt>build</tt> target, above, so that the
8753 package is built if it has not been already. It
8754 should then create the relevant binary package(s),
8755 using <prgn>dpkg-gencontrol</prgn> to make their
8756 control files and <prgn>dpkg-deb</prgn> to build
8757 them and place them in the parent of the top level
8762 If one of the <prgn>binary-*</prgn> targets has
8763 nothing to do (this will be always be the case if
8764 the source generates only a single binary package,
8765 whether architecture-dependent or not) it
8766 <em>must</em> still exist, but should always
8771 <ref id="pkg-binarypkg"> describes how to construct
8776 The <tt>binary</tt> targets must be invoked as
8781 <tag><tt>clean</tt></tag>
8785 This should undo any effects that the
8786 <tt>build</tt> and <tt>binary</tt> targets
8787 may have had, except that it should leave alone any
8788 output files created in the parent directory by a
8789 run of <tt>binary</tt>. This target is required
8790 to be non-interactive.
8794 If a <tt>build</tt> file is touched at the end
8795 of the <tt>build</tt> target, as suggested
8796 above, it must be removed as the first thing that
8797 <tt>clean</tt> does, so that running
8798 <tt>build</tt> again after an interrupted
8799 <tt>clean</tt> doesn't think that everything is
8804 The <tt>clean</tt> target must be invoked as
8805 root if <tt>binary</tt> has been invoked since
8806 the last <tt>clean</tt>, or if
8807 <tt>build</tt> has been invoked as root (since
8808 <tt>build</tt> may create directories, for
8813 <tag><tt>get-orig-source</tt> (optional)</tag>
8817 This target fetches the most recent version of the
8818 original source package from a canonical archive
8819 site (via FTP or WWW, for example), does any
8820 necessary rearrangement to turn it into the original
8821 source tarfile format described below, and leaves it
8822 in the current directory.
8826 This target may be invoked in any directory, and
8827 should take care to clean up any temporary files it
8832 This target is optional, but providing it if
8833 possible is a good idea.
8839 The <tt>build</tt>, <tt>binary</tt> and
8840 <tt>clean</tt> targets must be invoked with a current
8841 directory of the package's top-level directory.
8846 Additional targets may exist in <file>debian/rules</file>,
8847 either as published or undocumented interfaces or for the
8848 package's internal use.
8852 The architecture we build on and build for is determined by make
8853 variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8854 get the Debian architecture and the GNU style architecture
8855 specification string for the build machine as well as the host
8856 machine. Here is a list of supported make variables:
8857 <list compact="compact">
8859 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8862 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8863 specification string)</p>
8866 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8869 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8875 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
8876 the build machine or <tt>HOST</tt> for specification of the machine
8881 Backward compatibility can be provided in the rules file
8882 by setting the needed variables to suitable default
8883 values, please refer to the documentation of
8884 dpkg-architecture for details.
8888 It is important to understand that the <tt>DEB_*_ARCH</tt>
8889 string does only determine which Debian architecture we
8890 build on resp. for. It should not be used to get the CPU
8891 or System information, the GNU style variables should be
8897 <sect1><heading><file>debian/control</file>
8901 This file contains version-independent details about the
8902 source package and about the binary packages it creates.
8906 It is a series of sets of control fields, each
8907 syntactically similar to a binary package control file.
8908 The sets are separated by one or more blank lines. The
8909 first set is information about the source package in
8910 general; each subsequent set describes one binary package
8911 that the source tree builds.
8915 The syntax and semantics of the fields are described below
8916 in <ref id="pkg-controlfields">.
8920 The general (binary-package-independent) fields are:
8921 <list compact="compact">
8923 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
8926 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8930 <qref id="pkg-f-classification"><tt>Section</tt> and
8931 <tt>Priority</tt></qref>
8932 (classification, mandatory)
8937 <qref id="relationships"><tt>Build-Depends</tt> et
8938 al.</qref> (source package interrelationships)
8943 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
8949 The per-binary-package fields are:
8950 <list compact="compact">
8952 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8956 <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8960 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8964 <qref id="pkg-f-classification"><tt>Section</tt> and
8965 <tt>Priority</tt></qref> (classification)</p>
8968 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8972 <qref id="relationships"><tt>Depends</tt> et
8973 al.</qref> (binary package interrelationships)
8979 These fields are used by <prgn>dpkg-gencontrol</prgn> to
8980 generate control files for binary packages (see below), by
8981 <prgn>dpkg-genchanges</prgn> to generate the
8982 <tt>.changes</tt> file to accompany the upload, and by
8983 <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
8984 source control file as part of a source archive.
8988 The fields here may contain variable references - their
8989 values will be substituted by
8990 <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
8991 or <prgn>dpkg-source</prgn> when they generate output
8992 control files. See <ref id="pkg-srcsubstvars"> for details.
8995 <p> <sect2><heading>User-defined fields
8999 Additional user-defined fields may be added to the
9000 source package control file. Such fields will be
9001 ignored, and not copied to (for example) binary or
9002 source package control files or upload control files.
9006 If you wish to add additional unsupported fields to
9007 these output files you should use the mechanism
9012 Fields in the main source control information file with
9013 names starting <tt>X</tt>, followed by one or more of
9014 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9015 be copied to the output files. Only the part of the
9016 field name after the hyphen will be used in the output
9017 file. Where the letter <tt>B</tt> is used the field
9018 will appear in binary package control files, where the
9019 letter <tt>S</tt> is used in source package control
9020 files and where <tt>C</tt> is used in upload control
9021 (<tt>.changes</tt>) files.
9025 For example, if the main source information control file
9028 XBS-Comment: I stand between the candle and the star.
9030 then the binary and source package control files will contain the
9033 Comment: I stand between the candle and the star.
9040 <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9044 This file records the changes to the Debian-specific parts of the
9048 Though there is nothing stopping an author who is also
9049 the Debian maintainer from using it for all their
9050 changes, it will have to be renamed if the Debian and
9051 upstream maintainers become different
9058 It has a special format which allows the package building
9059 tools to discover which version of the package is being
9060 built and find out other release-specific information.
9064 That format is a series of entries like this:
9066 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9068 * <var>change details</var>
9069 <var>more change details</var>
9070 * <var>even more change details</var>
9072 -- <var>maintainer name and email address</var> <var>date</var>
9077 <var>package</var> and <var>version</var> are the source
9078 package name and version number.
9082 <var>distribution(s)</var> lists the distributions where
9083 this version should be installed when it is uploaded - it
9084 is copied to the <tt>Distribution</tt> field in the
9085 <tt>.changes</tt> file. See <ref id="pkg-f-Distribution">.
9089 <var>urgency</var> is the value for the <tt>Urgency</tt>
9090 field in the <file>.changes</file> file for the upload. See
9091 <ref id="pkg-f-Urgency">. It is not possible to specify an
9092 urgency containing commas; commas are used to separate
9093 <tt><var>keyword</var>=<var>value</var></tt> settings in
9094 the <prgn>dpkg</prgn> changelog format (though there is
9095 currently only one useful <var>keyword</var>,
9100 The change details may in fact be any series of lines
9101 starting with at least two spaces, but conventionally each
9102 change starts with an asterisk and a separating space and
9103 continuation lines are indented so as to bring them in
9104 line with the start of the text above. Blank lines may be
9105 used here to separate groups of changes, if desired.
9109 The maintainer name and email address should <em>not</em>
9110 necessarily be those of the usual package maintainer.
9111 They should be the details of the person doing
9112 <em>this</em> version. The information here will be
9113 copied to the <file>.changes</file> file, and then later used
9114 to send an acknowledgement when the upload has been
9119 The <var>date</var> should be in RFC822 format
9122 This is generated by the <prgn>822-date</prgn>
9125 </footnote>; it should include the timezone specified
9126 numerically, with the timezone name or abbreviation
9127 optionally present as a comment.
9131 The first `title' line with the package name should start
9132 at the left hand margin; the `trailer' line with the
9133 maintainer and date details should be preceded by exactly
9134 one space. The maintainer details and the date must be
9135 separated by exactly two spaces.
9139 An Emacs mode for editing this format is available: it is
9140 called <tt>debian-changelog-mode</tt>. You can have this
9141 mode selected automatically when you edit a Debian
9142 changelog by adding a local variables clause to the end of
9146 <sect2><heading>Defining alternative changelog formats
9150 It is possible to use a different format to the standard
9151 one, by providing a parser for the format you wish to
9156 In order to have <tt>dpkg-parsechangelog</tt> run your
9157 parser, you must include a line within the last 40 lines
9158 of your file matching the Perl regular expression:
9159 <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9160 parentheses should be the name of the format. For
9161 example, you might say:
9163 @@@ changelog-format: joebloggs @@@
9165 Changelog format names are non-empty strings of alphanumerics.
9169 If such a line exists then <tt>dpkg-parsechangelog</tt>
9170 will look for the parser as
9171 <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9173 <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9174 it is an error for it not to find it, or for it not to
9175 be an executable program. The default changelog format
9176 is <tt>dpkg</tt>, and a parser for it is provided with
9177 the <tt>dpkg</tt> package.
9181 The parser will be invoked with the changelog open on
9182 standard input at the start of the file. It should read
9183 the file (it may seek if it wishes) to determine the
9184 information required and return the parsed information
9185 to standard output in the form of a series of control
9186 fields in the standard format. By default it should
9187 return information about only the most recent version in
9188 the changelog; it should accept a
9189 <tt>-v<var>version</var></tt> option to return changes
9190 information from all versions present <em>strictly
9191 after</em> <var>version</var>, and it should then be an
9192 error for <var>version</var> not to be present in the
9198 <list compact="compact">
9200 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9203 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9207 <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9212 <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9216 <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9221 <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9225 <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9232 If several versions are being returned (due to the use
9233 of <tt>-v</tt>), the urgency value should be of the
9234 highest urgency code listed at the start of any of the
9235 versions requested followed by the concatenated
9236 (space-separated) comments from all the versions
9237 requested; the maintainer, version, distribution and
9238 date should always be from the most recent version.
9242 For the format of the <tt>Changes</tt> field see <ref
9243 id="pkg-f-Changes">.
9247 If the changelog format which is being parsed always or
9248 almost always leaves a blank line between individual
9249 change notes these blank lines should be stripped out,
9250 so as to make the resulting output compact.
9254 If the changelog format does not contain date or package
9255 name information this information should be omitted from
9256 the output. The parser should not attempt to synthesise
9257 it or find it from other sources.
9261 If the changelog does not have the expected format the
9262 parser should exit with a nonzero exit status, rather
9263 than trying to muddle through and possibly generating
9268 A changelog parser may not interact with the user at
9272 <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9273 and variable substitutions
9277 When <prgn>dpkg-gencontrol</prgn>,
9278 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9279 generate control files they do variable substitutions on
9280 their output just before writing it. Variable
9281 substitutions have the form
9282 <tt>${<var>variable-name</var>}</tt>. The optional file
9283 <file>debian/substvars</file> contains variable substitutions
9284 to be used; variables can also be set directly from
9285 <file>debian/rules</file> using the <tt>-V</tt> option to the
9286 source packaging commands, and certain predefined
9287 variables are available.
9291 The is usually generated and modified dynamically by
9292 <file>debian/rules</file> targets; in this case it must be
9293 removed by the <tt>clean</tt> target.
9297 See <manref name="dpkg-source" section="1"> for full
9298 details about source variable substitutions, including the
9299 format of <file>debian/substvars</file>.</p>
9302 <sect1><heading><file>debian/files</file>
9306 This file is not a permanent part of the source tree; it
9307 is used while building packages to record which files are
9308 being generated. <prgn>dpkg-genchanges</prgn> uses it
9309 when it generates a <file>.changes</file> file.
9313 It should not exist in a shipped source package, and so it
9314 (and any backup files or temporary files such as
9315 <file>files.new</file>
9318 <file>files.new</file> is used as a temporary file by
9319 <prgn>dpkg-gencontrol</prgn> and
9320 <prgn>dpkg-distaddfile</prgn> - they write a new
9321 version of <file>files</file> here before renaming it,
9322 to avoid leaving a corrupted copy if an error
9325 </footnote>) should be removed by the
9326 <tt>clean</tt> target. It may also be wise to
9327 ensure a fresh start by emptying or removing it at the
9328 start of the <tt>binary</tt> target.
9332 <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9333 for the <file>.deb</file> file that will be created by
9334 <prgn>dpkg-deb</prgn> from the control file that it
9335 generates, so for most packages all that needs to be done
9336 with this file is to delete it in <tt>clean</tt>.
9340 If a package upload includes files besides the source
9341 package and any binary packages whose control files were
9342 made with <prgn>dpkg-gencontrol</prgn> then they should be
9343 placed in the parent of the package's top-level directory
9344 and <prgn>dpkg-distaddfile</prgn> should be called to add
9345 the file to the list in <file>debian/files</file>.</p>
9348 <sect1><heading><file>debian/tmp</file>
9352 This is the canonical temporary location for the
9353 construction of binary packages by the <tt>binary</tt>
9354 target. The directory <file>tmp</file> serves as the root of
9355 the filesystem tree as it is being constructed (for
9356 example, by using the package's upstream makefiles install
9357 targets and redirecting the output there), and it also
9358 contains the <tt>DEBIAN</tt> subdirectory. See <ref
9359 id="pkg-bincreating">.
9363 If several binary packages are generated from the same
9364 source tree it is usual to use several
9365 <file>debian/tmp<var>something</var></file> directories, for
9366 example <file>tmp-a</file> or <file>tmp-doc</file>.
9370 Whatever <file>tmp</file> directories are created and used by
9371 <tt>binary</tt> must of course be removed by the
9372 <tt>clean</tt> target.</p></sect1>
9376 <sect id="pkg-sourcearchives"><heading>Source packages as archives
9380 As it exists on the FTP site, a Debian source package
9381 consists of three related files. You must have the right
9382 versions of all three to be able to use them.
9387 <tag>Debian source control file - <tt>.dsc</tt></tag>
9391 This file contains a series of fields, identified and
9392 separated just like the fields in the control file of
9393 a binary package. The fields are listed below; their
9394 syntax is described above, in <ref id="pkg-controlfields">.
9395 <list compact="compact">
9397 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9400 <p><qref id="versions"><tt>Version</tt></qref></p>
9403 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9406 <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9409 <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9413 <qref id="relationships"><tt>Build-Depends</tt> et
9414 al.</qref> (source package interrelationships)
9419 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9422 <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9427 The source package control file is generated by
9428 <prgn>dpkg-source</prgn> when it builds the source
9429 archive, from other files in the source package,
9430 described above. When unpacking it is checked against
9431 the files and directories in the other parts of the
9432 source package, as described below.</p>
9436 Original source archive -
9438 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9445 This is a compressed (with <tt>gzip -9</tt>)
9446 <prgn>tar</prgn> file containing the source code from
9447 the upstream authors of the program. The tarfile
9448 unpacks into a directory
9449 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9450 and does not contain files anywhere other than in
9451 there or in its subdirectories.</p>
9455 Debianisation diff -
9457 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9463 This is a unified context diff (<tt>diff -u</tt>)
9464 giving the changes which are required to turn the
9465 original source into the Debian source. These changes
9466 may only include editing and creating plain files.
9467 The permissions of files, the targets of symbolic
9468 links and the characteristics of special files or
9469 pipes may not be changed and no files may be removed
9474 All the directories in the diff must exist, except the
9475 <file>debian</file> subdirectory of the top of the source
9476 tree, which will be created by
9477 <prgn>dpkg-source</prgn> if necessary when unpacking.
9481 The <prgn>dpkg-source</prgn> program will
9482 automatically make the <file>debian/rules</file> file
9483 executable (see below).</p></item>
9488 If there is no original source code - for example, if the
9489 package is specially prepared for Debian or the Debian
9490 maintainer is the same as the upstream maintainer - the
9491 format is slightly different: then there is no diff, and the
9493 <file><var>package</var>_<var>version</var>.tar.gz</file> and
9494 contains a directory
9495 <file><var>package</var>-<var>version</var></file>.
9499 <sect><heading>Unpacking a Debian source package without
9500 <prgn>dpkg-source</prgn>
9504 <tt>dpkg-source -x</tt> is the recommended way to unpack a
9505 Debian source package. However, if it is not available it
9506 is possible to unpack a Debian source archive as follows:
9507 <enumlist compact="compact">
9510 Untar the tarfile, which will create a <file>.orig</file>
9514 <p>Rename the <file>.orig</file> directory to
9515 <file><var>package</var>-<var>version</var></file>.</p>
9519 Create the subdirectory <file>debian</file> at the top of
9520 the source tree.</p>
9522 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9524 <item><p>Untar the tarfile again if you want a copy of the original
9525 source code alongside the Debianised version.</p>
9530 It is not possible to generate a valid Debian source archive
9531 without using <prgn>dpkg-source</prgn>. In particular,
9532 attempting to use <prgn>diff</prgn> directly to generate the
9533 <file>.diff.gz</file> file will not work.
9536 <sect1><heading>Restrictions on objects in source packages
9540 The source package may not contain any hard links
9543 This is not currently detected when building source
9544 packages, but only when extracting
9550 Hard links may be permitted at some point in the
9551 future, but would require a fair amount of
9554 </footnote>, device special files, sockets or setuid or
9558 Setgid directories are allowed.
9564 The source packaging tools manage the changes between the
9565 original and Debianised source using <prgn>diff</prgn> and
9566 <prgn>patch</prgn>. Turning the original source tree as
9567 included in the <file>.orig.tar.gz</file> into the debianised
9568 source must not involve any changes which cannot be
9569 handled by these tools. Problematic changes which cause
9570 <prgn>dpkg-source</prgn> to halt with an error when
9571 building the source package are:
9572 <list compact="compact">
9573 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9575 <item><p>Changing the targets of symbolic links.</p>
9577 <item><p>Creating directories, other than <file>debian</file>.</p>
9579 <item><p>Changes to the contents of binary files.</p></item>
9580 </list> Changes which cause <prgn>dpkg-source</prgn> to
9581 print a warning but continue anyway are:
9582 <list compact="compact">
9585 Removing files, directories or symlinks.
9588 Renaming a file is not treated specially - it is
9589 seen as the removal of the old file (which
9590 generates a warning, but is otherwise ignored),
9591 and the creation of the new
9598 Changed text files which are missing the usual final
9599 newline (either in the original or the modified
9604 Changes which are not represented, but which are not detected by
9605 <prgn>dpkg-source</prgn>, are:
9606 <list compact="compact">
9607 <item><p>Changing the permissions of files (other than
9608 <file>debian/rules</file>) and directories.</p></item>
9613 The <file>debian</file> directory and <file>debian/rules</file>
9614 are handled specially by <prgn>dpkg-source</prgn> - before
9615 applying the changes it will create the <file>debian</file>
9616 directory, and afterwards it will make
9617 <file>debian/rules</file> world-exectuable.
9623 <appendix id="pkg-controlfields"><heading>Control files and their
9624 fields (from old Packaging Manual)
9628 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9629 data in a common format, known as control files. Binary and
9630 source packages have control data as do the <file>.changes</file>
9631 files which control the installation of uploaded files, and
9632 <prgn>dpkg</prgn>'s internal databases are in a similar
9636 <sect><heading>Syntax of control files
9640 A file consists of one or more paragraphs of fields. The
9641 paragraphs are separated by blank lines. Some control files
9642 only allow one paragraph; others allow several, in which
9643 case each paragraph often refers to a different package.
9647 Each paragraph is a series of fields and values; each field
9648 consists of a name, followed by a colon and the value. It
9649 ends at the end of the line. Horizontal whitespace (spaces
9650 and tabs) may occur before or after the value and is ignored
9651 there; it is conventional to put a single space after the
9656 Some fields' values may span several lines; in this case
9657 each continuation line <em>must</em> start with a space or
9658 tab. Any trailing spaces or tabs at the end of individual
9659 lines of a field value are ignored.
9663 Except where otherwise stated only a single line of data is
9664 allowed and whitespace is not significant in a field body.
9665 Whitespace may never appear inside names (of packages,
9666 architectures, files or anything else), version numbers or
9667 in between the characters of multi-character version
9672 Field names are not case-sensitive, but it is usual to
9673 capitalise the field names using mixed case as shown below.
9677 Blank lines, or lines consisting only of spaces and tabs,
9678 are not allowed within field values or between fields - that
9679 would mean a new paragraph.
9683 It is important to note that there are several fields which
9684 are optional as far as <prgn>dpkg</prgn> and the related
9685 tools are concerned, but which must appear in every Debian
9686 package, or whose omission may cause problems. When writing
9687 the control files for Debian packages you <em>must</em> read
9688 the Debian policy manual in conjuction with the details
9689 below and the list of fields for the particular file.</p>
9692 <sect><heading>List of fields
9695 <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9699 The name of the binary package. Package names consist of
9700 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9701 (plus, minus and full stop).
9704 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9705 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9706 and underscore) used to be legal and are still
9707 accepted when found in a package file, but may not be
9708 used in new packages
9714 They must be at least two characters and must start with
9715 an alphanumeric. In current versions of dpkg they are
9716 sort of case-sensitive<footnote><p>This is a
9717 bug.</p></footnote>; use lowercase package names unless
9718 the package you're building (or referring to, in other
9719 fields) is already using uppercase.</p>
9722 <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9726 This lists the source or binary package's version number -
9727 see <ref id="versions">.
9732 <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9736 This is the architecture string; it is a single word for
9737 the Debian architecture.
9741 <prgn>dpkg</prgn> will check the declared architecture of
9742 a binary package against its own compiled-in value before
9747 The special value <tt>all</tt> indicates that the package
9748 is architecture-independent.
9752 In the main <file>debian/control</file> file in the source
9753 package, or in the source package control file
9754 <file>.dsc</file>, a list of architectures (separated by
9755 spaces) is also allowed, as is the special value
9756 <tt>any</tt>. A list indicates that the source will build
9757 an architecture-dependent package, and will only work
9758 correctly on the listed architectures. <tt>any</tt>
9759 indicates that though the source package isn't dependent
9760 on any particular architecture and should compile fine on
9761 any one, the binary package(s) produced are not
9762 architecture-independent but will instead be specific to
9763 whatever the current build architecture is.
9767 In a <file>.changes</file> file the <tt>Architecture</tt>
9768 field lists the architecture(s) of the package(s)
9769 currently being uploaded. This will be a list; if the
9770 source for the package is being uploaded too the special
9771 entry <tt>source</tt> is also present.
9775 See <ref id="pkg-debianrules"> for information how to get the
9776 architecture for the build process.
9780 <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9784 The package maintainer's name and email address. The name
9785 should come first, then the email address inside angle
9786 brackets <tt><></tt> (in RFC822 format).
9790 If the maintainer's name contains a full stop then the
9791 whole field will not work directly as an email address due
9792 to a misfeature in the syntax specified in RFC822; a
9793 program using this field as an address must check for this
9794 and correct the problem if necessary (for example by
9795 putting the name in round brackets and moving it to the
9796 end, and bringing the email address forward).
9800 In a <file>.changes</file> file or parsed changelog data this
9801 contains the name and email address of the person
9802 responsible for the particular version in question - this
9803 may not be the package's usual maintainer.
9807 This field is usually optional in as far as the
9808 <prgn>dpkg</prgn> are concerned, but its absence when
9809 building packages usually generates a warning.</p>
9812 <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9816 This field identifies the source package name.
9820 In a main source control information or a
9821 <file>.changes</file> or <file>.dsc</file> file or parsed
9822 changelog data this may contain only the name of the
9827 In the control file of a binary package (or in a
9828 <file>Packages</file> file) it may be followed by a version
9829 number in parentheses.
9832 It is usual to leave a space after the package name if
9833 a version number is specified.
9835 </footnote> This version number may be omitted (and is, by
9836 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9837 the <tt>Version</tt> field of the binary package in
9838 question. The field itself may be omitted from a binary
9839 package control file when the source package has the same
9840 name and version as the binary package.
9844 <sect1><heading>Package interrelationship fields:
9845 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9846 <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9847 <tt>Provides</tt>, <tt>Replaces</tt>
9851 These fields describe the package's relationships with
9852 other packages. Their syntax and semantics are described
9853 in <ref id="relationships">.</p>
9856 <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9860 In a binary package <tt>Packages</tt> file or main source
9861 control file this field contains a description of the
9862 binary package, in a special format. See <ref
9863 id="descriptions"> for details.
9867 In a <file>.changes</file> file it contains a summary of the
9868 descriptions for the packages being uploaded. The part of
9869 the field before the first newline is empty; thereafter
9870 each line has the name of a binary package and the summary
9871 description line from that binary package. Each line is
9872 indented by one space.</p>
9875 <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
9879 This is a boolean field which may occur only in the
9880 control file of a binary package (or in the
9881 <file>Packages</file> file) or in a per-package fields
9882 paragraph of a main source control data file.
9886 If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
9887 <prgn>dselect</prgn> will refuse to remove the package
9888 (though it can be upgraded and/or replaced). The other
9889 possible value is <tt>no</tt>, which is the same as not
9890 having the field at all.</p>
9893 <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
9898 These two fields classify the package. The
9899 <tt>Priority</tt> represents how important that it is that
9900 the user have it installed; the <tt>Section</tt>
9901 represents an application area into which the package has
9906 When they appear in the <file>debian/control</file> file these
9907 fields give values for the section and priority subfields
9908 of the <tt>Files</tt> field of the <file>.changes</file> file,
9909 and give defaults for the section and priority of the
9914 The section and priority are represented, though not as
9915 separate fields, in the information for each file in the
9916 <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
9917 <file>.changes</file> file. The section value in a
9918 <file>.changes</file> file is used to decide where to install
9919 a package in the FTP archive.
9923 These fields are not used by by <prgn>dpkg</prgn> proper,
9924 but by <prgn>dselect</prgn> when it sorts packages and
9925 selects defaults. See the Debian policy manual for the
9926 priorities in use and the criteria for selecting the
9927 priority for a Debian package, and look at the Debian FTP
9928 archive for a list of currently in-use priorities.
9932 These fields may appear in binary package control files,
9933 in which case they provide a default value in case the
9934 <file>Packages</file> files are missing the information.
9935 <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
9936 the value from a <file>.deb</file> file if they have no other
9937 information; a value listed in a <file>Packages</file> file
9938 will always take precedence. By default
9939 <prgn>dpkg-gencontrol</prgn> does not include the section
9940 and priority in the control file of a binary package - use
9941 the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
9942 achieve this effect.</p>
9945 <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
9949 This field is a list of binary packages.
9953 When it appears in the <file>.dsc</file> file it is the list
9954 of binary packages which a source package can produce. It
9955 does not necessarily produce all of these binary packages
9956 for every architecture. The source control file doesn't
9957 contain details of which architectures are appropriate for
9958 which of the binary packages.
9962 When it appears in a <file>.changes</file> file it lists the
9963 names of the binary packages actually being uploaded.
9967 The syntax is a list of binary packages separated by
9971 A space after each comma is conventional.
9973 </footnote> Currently the packages must be separated using
9974 only spaces in the <file>.changes</file> file.</p>
9977 <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
9981 This field appears in the control files of binary
9982 packages, and in the <file>Packages</file> files. It gives
9983 the total amount of disk space required to install the
9988 The disk space is represented in kilobytes as a simple
9992 <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
9996 This field contains a list of files with information about
9997 each one. The exact information and syntax varies with
9998 the context. In all cases the the part of the field
9999 contents on the same line as the field name is empty. The
10000 remainder of the field is one line per file, each line
10001 being indented by one space and containing a number of
10002 sub-fields separated by spaces.
10006 In the <file>.dsc</file> (Debian source control) file each
10007 line contains the MD5 checksum, size and filename of the
10008 tarfile and (if applicable) diff file which make up the
10009 remainder of the source package.
10012 That is, the parts which are not the
10015 </footnote> The exact forms of the filenames are described
10016 in <ref id="pkg-sourcearchives">.
10020 In the <file>.changes</file> file this contains one line per
10021 file being uploaded. Each line contains the MD5 checksum,
10022 size, section and priority and the filename. The section
10023 and priority are the values of the corresponding fields in
10024 the main source control file - see <ref
10025 id="pkg-f-classification">. If no section or priority is
10026 specified then <tt>-</tt> should be used, though section
10027 and priority values must be specified for new packages to
10028 be installed properly.
10032 The special value <tt>byhand</tt> for the section in a
10033 <tt>.changes</tt> file indicates that the file in question
10034 is not an ordinary package file and must by installed by
10035 hand by the distribution maintainers. If the section is
10036 <tt>byhand</tt> the priority should be <tt>-</tt>.
10040 If a new Debian revision of a package is being shipped and
10041 no new original source archive is being distributed the
10042 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10043 entry for the original source archive
10044 <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10045 but the <file>.changes</file> file should leave it out. In
10046 this case the original source archive on the distribution
10047 site must match exactly, byte-for-byte, the original
10048 source archive which was used to generate the
10049 <file>.dsc</file> file and diff which are being uploaded.</p>
10054 id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10058 The most recent version of the standards (the
10059 <prgn>dpkg</prgn> programmers' and policy manuals and
10060 associated texts) with which the package complies. This
10061 is updated manually when editing the source package to
10062 conform to newer standards; it can sometimes be used to
10063 tell when a package needs attention.
10067 Its format is the same as that of a version number except
10068 that no epoch or Debian revision is allowed - see <ref
10069 id="versions">.</p>
10073 <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10077 In a <file>.changes</file> file or parsed changelog output
10078 this contains the (space-separated) name(s) of the
10079 distribution(s) where this version of the package should
10080 be or was installed. Distribution names follow the rules
10081 for package names. (See <ref id="pkg-f-Package">).
10085 Current distribution values are:
10087 <tag><em>stable</em></tag>
10090 This is the current `released' version of Debian
10091 GNU/Linux. A new version is released approximately
10092 every 3 months after the <em>development</em> code has
10093 been <em>frozen</em> for a month of testing. Once the
10094 distribution is <em>stable</em> only major bug fixes
10095 are allowed. When changes are made to this
10096 distribution, the release number is increased
10097 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10101 <tag><em>unstable</em></tag>
10104 This distribution value refers to the
10105 <em>developmental</em> part of the Debian distribution
10106 tree. New packages, new upstream versions of packages
10107 and bug fixes go into the <em>unstable</em> directory
10108 tree. Download from this distribution at your own
10112 <tag><em>contrib</em></tag>
10115 The packages with this distribution value do not meet
10116 the criteria for inclusion in the main Debian
10117 distribution as defined by the Policy Manual, but meet
10118 the criteria for the <em>contrib</em>
10119 Distribution. There is currently no distinction
10120 between stable and unstable packages in the
10121 <em>contrib</em> or <em>non-free</em>
10122 distributions. Use your best judgement in downloading
10123 from this Distribution.</p>
10126 <tag><em>non-free</em></tag>
10129 Like the packages in the <em>contrib</em> seciton,
10130 the packages in <em>non-free</em> do not meet the
10131 criteria for inclusion in the main Debian distribution
10132 as defined by the Policy Manual. Again, use your best
10133 judgement in downloading from this Distribution.</p>
10135 <tag><em>experimental</em></tag>
10138 The packages with this distribution value are deemed
10139 by their maintainers to be high risk. Oftentimes they
10140 represent early beta or developmental packages from
10141 various sources that the maintainers want people to
10142 try, but are not ready to be a part of the other parts
10143 of the Debian distribution tree. Download at your own
10147 <tag><em>frozen</em></tag>
10150 From time to time, (currently, every 3 months) the
10151 <em>unstable</em> distribution enters a state of
10152 `code-freeze' in anticipation of release as a
10153 <em>stable</em> version. During this period of testing
10154 (usually 4 weeks) only fixes for existing or
10155 newly-discovered bugs will be allowed.
10158 </taglist> You should list <em>all</em> distributions that
10159 the package should be installed into. Except in unusual
10160 circumstances, installations to <em>stable</em> should also
10161 go into <em>frozen</em> (if it exists) and
10162 <em>unstable</em>. Likewise, installations into
10163 <em>frozen</em> should also go into <em>unstable</em>.</p>
10166 <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10170 This is a description of how important it is to upgrade to
10171 this version from previous ones. It consists of a single
10172 keyword usually taking one of the values <tt>LOW</tt>,
10173 <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10174 commentary (separated by a space) which is usually in
10175 parentheses. For example:
10177 Urgency: LOW (HIGH for diversions users)
10182 This field appears in the <file>.changes</file> file and in
10183 parsed changelogs; its value appears as the value of the
10184 <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10185 changelog (see <ref id="pkg-dpkgchangelog">).
10189 Urgency keywords are not case-sensitive.</p>
10192 <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10196 In <tt>.changes</tt> files and parsed changelogs, this
10197 gives the date the package was built or last edited.</p>
10200 <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10204 This field occurs in <file>.changes</file> files, and
10205 specifies a format revision for the file. The format
10206 described here is version <tt>1.5</tt>. The syntax of the
10207 format value is the same as that of a package version
10208 number except that no epoch or Debian revision is allowed
10209 - see <ref id="versions">.</p>
10212 <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10216 In a <file>.changes</file> file or parsed changelog this field
10217 contains the human-readable changes data, describing the
10218 differences between the last version and the current one.
10222 There should be nothing in this field before the first
10223 newline; all the subsequent lines must be indented by at
10224 least one space; blank lines must be represented by a line
10225 consiting only of a space and a full stop.
10229 Each version's change information should be preceded by a
10230 `title' line giving at least the version, distribution(s)
10231 and urgency, in a human-readable way.
10235 If data from several versions is being returned the entry
10236 for the most recent version should be returned first, and
10237 entries should be separated by the representation of a
10238 blank line (the `title' line may also be followed by the
10239 representation of blank line).</p>
10242 <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10243 <tt>MSDOS-Filename</tt>
10247 These fields in <tt>Packages</tt> files give the
10248 filename(s) of (the parts of) a package in the
10249 distribution directories, relative to the root of the
10250 Debian hierarchy. If the package has been split into
10251 several parts the parts are all listed in order, separated
10255 <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10259 These fields in <file>Packages</file> files give the size (in
10260 bytes, expressed in decimal) and MD5 checksum of the
10261 file(s) which make(s) up a binary package in the
10262 distribution. If the package is split into several parts
10263 the values for the parts are listed in order, separated by
10267 <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10271 This field in <prgn>dpkg</prgn>'s status file records
10272 whether the user wants a package installed, removed or
10273 left alone, whether it is broken (requiring
10274 reinstallation) or not and what its current state on the
10275 system is. Each of these pieces of information is a
10279 <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10283 If a package is not installed or not configured, this
10284 field in <prgn>dpkg</prgn>'s status file records the last
10285 version of the package which was successfully
10289 <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10293 This field in <prgn>dpkg</prgn>'s status file contains
10294 information about the automatically-managed configuration
10295 files held by a package. This field should <em>not</em>
10296 appear anywhere in a package!</p>
10299 <sect1><heading>Obsolete fields
10303 These are still recognised by <prgn>dpkg</prgn> but should
10304 not appear anywhere any more.
10305 <taglist compact="compact">
10307 <tag><tt>Revision</tt></tag>
10308 <tag><tt>Package-Revision</tt></tag>
10309 <tag><tt>Package_Revision</tt></tag>
10312 The Debian revision part of the package version was
10313 at one point in a separate control file field. This
10314 field went through several names.</p>
10317 <tag><tt>Recommended</tt></tag>
10318 <item><p>Old name for <tt>Recommends</tt></p>
10321 <tag><tt>Optional</tt></tag>
10322 <item><p>Old name for <tt>Suggests</tt>.</p>
10324 <tag><tt>Class</tt></tag>
10325 <item><p>Old name for <tt>Priority</tt>.</p>
10333 <appendix id="pkg-conffiles"><heading>Configuration file handling
10334 (from old Packaging Manual)
10338 <prgn>dpkg</prgn> can do a certain amount of automatic
10339 handling of package configuration files.
10343 Whether this mechanism is appropriate depends on a number of
10344 factors, but basically there are two approaches to any
10345 particular configuration file.
10349 The easy method is to ship a best-effort configuration in the
10350 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10351 handle updates. If the user is unlikely to want to edit the
10352 file, but you need them to be able to without losing their
10353 changes, and a new package with a changed version of the file
10354 is only released infrequently, this is a good approach.
10358 The hard method is to build the configuration file from
10359 scratch in the <prgn>postinst</prgn> script, and to take the
10360 responsibility for fixing any mistakes made in earlier
10361 versions of the package automatically. This will be
10362 appropriate if the file is likely to need to be different on
10366 <sect><heading>Automatic handling of configuration files by
10371 A package may contain a control area file called
10372 <tt>conffiles</tt>. This file should be a list of filenames
10373 of configuration files needing automatic handling, separated
10374 by newlines. The filenames should be absolute pathnames,
10375 and the files referred to should actually exist in the
10380 When a package is upgraded <prgn>dpkg</prgn> will process
10381 the configuration files during the configuration stage,
10382 shortly before it runs the package's <prgn>postinst</prgn>
10387 For each file it checks to see whether the version of the
10388 file included in the package is the same as the one that was
10389 included in the last version of the package (the one that is
10390 being upgraded from); it also compares the version currently
10391 installed on the system with the one shipped with the last
10396 If neither the user nor the package maintainer has changed
10397 the file, it is left alone. If one or the other has changed
10398 their version, then the changed version is preferred - i.e.,
10399 if the user edits their file, but the package maintainer
10400 doesn't ship a different version, the user's changes will
10401 stay, silently, but if the maintainer ships a new version
10402 and the user hasn't edited it the new version will be
10403 installed (with an informative message). If both have
10404 changed their version the user is prompted about the problem
10405 and must resolve the differences themselves.
10409 The comparisons are done by calculating the MD5 message
10410 digests of the files, and storing the MD5 of the file as it
10411 was included in the most recent version of the package.
10415 When a package is installed for the first time
10416 <prgn>dpkg</prgn> will install the file that comes with it,
10417 unless that would mean overwriting a file already on the
10422 However, note that <prgn>dpkg</prgn> will <em>not</em>
10423 replace a conffile that was removed by the user (or by a
10424 script). This is necessary because with some programs a
10425 missing file produces an effect hard or impossible to
10426 achieve in another way, so that a missing file needs to be
10427 kept that way if the user did it.
10431 Note that a package should <em>not</em> modify a
10432 <prgn>dpkg</prgn>-handled conffile in its maintainer
10433 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
10434 the user confusing and possibly dangerous options for
10435 conffile update when the package is upgraded.</p>
10438 <sect><heading>Fully-featured maintainer script configuration
10443 For files which contain site-specific information such as
10444 the hostname and networking details and so forth, it is
10445 better to create the file in the package's
10446 <prgn>postinst</prgn> script.
10450 This will typically involve examining the state of the rest
10451 of the system to determine values and other information, and
10452 may involve prompting the user for some information which
10453 can't be obtained some other way.
10457 When using this method there are a couple of important
10458 issues which should be considered:
10462 If you discover a bug in the program which generates the
10463 configuration file, or if the format of the file changes
10464 from one version to the next, you will have to arrange for
10465 the postinst script to do something sensible - usually this
10466 will mean editing the installed configuration file to remove
10467 the problem or change the syntax. You will have to do this
10468 very carefully, since the user may have changed the file,
10469 perhaps to fix the very problem that your script is trying
10470 to deal with - you will have to detect these situations and
10471 deal with them correctly.
10475 If you do go down this route it's probably a good idea to
10476 make the program that generates the configuration file(s) a
10477 separate program in <file>/usr/sbin</file>, by convention called
10478 <file><var>package</var>config</file> and then run that if
10479 appropriate from the post-installation script. The
10480 <tt><var>package</var>config</tt> program should not
10481 unquestioningly overwrite an existing configuration - if its
10482 mode of operation is geared towards setting up a package for
10483 the first time (rather than any arbitrary reconfiguration
10484 later) you should have it check whether the configuration
10485 already exists, and require a <tt>--force</tt> flag to
10486 overwrite it.</p></sect>
10489 <appendix id="pkg-alternatives"><heading>Alternative versions of
10490 an interface - <prgn>update-alternatives</prgn> (from old
10495 When several packages all provide different versions of the
10496 same program or file it is useful to have the system select a
10497 default, but to allow the system administrator to change it
10498 and have their decisions respected.
10502 For example, there are several versions of the <prgn>vi</prgn>
10503 editor, and there is no reason to prevent all of them from
10504 being installed at once, each under their own name
10505 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10506 Nevertheless it is desirable to have the name <tt>vi</tt>
10507 refer to something, at least by default.
10511 If all the packages involved cooperate, this can be done with
10512 <prgn>update-alternatives</prgn>.
10516 Each package provides its own version under its own name, and
10517 calls <prgn>update-alternatives</prgn> in its postinst to
10518 register its version (and again in its prerm to deregister
10523 See the manpage <manref name="update-alternatives"
10524 section="8"> for details.
10528 If <prgn>update-alternatives</prgn> does not seem appropriate
10529 you may wish to consider using diversions instead.</p>
10532 <appendix id="pkg-diversions"><heading>Diversions - overriding a
10533 package's version of a file (from old Packaging Manual)
10537 It is possible to have <prgn>dpkg</prgn> not overwrite a file
10538 when it reinstalls the package it belongs to, and to have it
10539 put the file from the package somewhere else instead.
10543 This can be used locally to override a package's version of a
10544 file, or by one package to override another's version (or
10545 provide a wrapper for it).
10549 Before deciding to use a diversion, read <ref
10550 id="pkg-alternatives"> to see if you really want a diversion
10551 rather than several alternative versions of a program.
10555 There is a diversion list, which is read by <prgn>dpkg</prgn>,
10556 and updated by a special program <prgn>dpkg-divert</prgn>.
10557 Please see <manref name="dpkg-divert" section="8"> for full
10558 details of its operation.
10562 When a package wishes to divert a file from another, it should
10563 call <prgn>dpkg-divert</prgn> in its preinst to add the
10564 diversion and rename the existing file. For example,
10565 supposing that a <prgn>smailwrapper</prgn> package wishes to
10566 install a wrapper around <file>/usr/sbin/smail</file>:
10568 if [ install = "$1" ]; then
10569 dpkg-divert --package smailwrapper --add --rename \
10570 --divert /usr/sbin/smail.real /usr/sbin/smail
10572 </example> Testing <tt>$1</tt> is necessary so that the script
10573 doesn't try to add the diversion again when
10574 <prgn>smailwrapper</prgn> is upgraded. The <tt>--package
10575 smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10576 copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10577 get installed as the true version.
10581 The postrm has to do the reverse:
10583 if [ remove = "$1" ]; then
10584 dpkg-divert --package smailwrapper --remove --rename \
10585 --divert /usr/sbin/smail.real /usr/sbin/smail
10591 Do not attempt to divert a file which is vitally important for
10592 the system's operation - when using <prgn>dpkg-divert</prgn>
10593 there is a time, after it has been diverted but before
10594 <prgn>dpkg</prgn> has installed the new version, when the file
10595 does not exist.</p>