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 system</heading>
965 The <tt>base system</tt> is a minimum subset of the Debian
966 GNU/Linux system that is installed before everything else
967 on a new system. Thus, only very few packages are allowed
968 to go into the <tt>base</tt> section to keep the required
969 disk usage very small.</p>
972 Most of these packages will have the priority value
973 <tt>required</tt> or at least <tt>important</tt>, and many
974 of them will be tagged <tt>essential</tt> (see below).</p>
981 <heading>Essential packages</heading>
984 Some packages are tagged <tt>essential</tt>. (They have
985 <tt>Essential: yes</tt> in their package control record.)
986 This flag is used for packages that are <em>essential</em>
990 Since these packages cannot be easily removed (one has to
991 specify an extra <em>force option</em> to
992 <prgn>dpkg</prgn> to do so), this flag must not be used
993 unless absolutely necessary. A shared library package
994 must not be tagged <tt>essential</tt>; dependencies will
995 prevent its premature removal, and we need to be able to
996 remove it when it has been superseded.
1000 Since dpkg will not prevent upgrading of other packages
1001 while an <tt>essential</tt> package is in an unconfigured
1002 state, all <tt>essential</tt> packages must supply all of
1003 their core functionality even when unconfigured. If the
1004 package cannot satisfy this requirement it must not be
1005 tagged as essential, and any packages depending on this
1006 package must instead have explicit dependency fields as
1011 You must not tag any packages <tt>essential</tt> before
1012 this has been discussed on the <tt>debian-devel</tt>
1013 mailing list and a consensus about doing that has been
1018 <heading>Tasks</heading>
1021 The Debian install process allows the user to choose from
1022 a number of common tasks which a Debian system can be used to
1023 perform. Selecting a task with <prgn>tasksel</prgn> causes
1024 a set of packages that are useful in performing that task to be
1029 This set of packages is all available packages which have the
1030 name of the selected task in the <tt>Task</tt> field of their
1031 control file. The format of this field is a list of tasks,
1032 separated by commas.
1036 You should not tag any packages as belonging to a task
1037 before this has been discussed on the
1038 <em>debian-devel</em> mailing list and a consensus about
1039 doing that has been reached.
1043 For third parties (and historical reasons), tasksel also
1044 supports constructing tasks based on <em>task
1045 packages</em>. These are packages whose names begin with
1046 <em>task-</em>. Task packages should not be included in the
1051 <sect1 id="maintscripts">
1052 <heading>Maintainer Scripts</heading>
1055 The package installation scripts should avoid producing
1056 output which it is unnecessary for the user to see and
1057 should rely on <prgn>dpkg</prgn> to stave off boredom on
1058 the part of a user installing many packages. This means,
1059 amongst other things, using the <tt>--quiet</tt> option on
1060 <prgn>install-info</prgn>.</p>
1063 Errors which occur during the execution of an installation
1064 script must be checked and the installation must not
1065 continue after an error.
1069 Note that in general <ref id="scripts"> applies to package
1070 maintainer scripts, too.
1074 You should not use <prgn>dpkg-divert</prgn> on a file
1075 belonging to another package without consulting the
1076 maintainer of that package first.
1080 All packages which supply an instance of a common command
1081 name (or, in general, filename) should generally use
1082 <prgn>update-alternatives</prgn>, so that they may be
1083 installed together. If <prgn>update-alternatives</prgn>
1084 is not used, then each package must use
1085 <tt>Conflicts</tt> to ensure that other packages are
1086 de-installed. (In this case, it may be appropriate to
1087 specify a conflict against earlier versions of something
1088 that previously did not use
1089 <prgn>update-alternatives</prgn>; this is an exception to
1090 the usual rule that versioned conflicts should be
1096 <heading>Prompting in maintainer scripts</heading>
1098 Package maintainer scripts may prompt the user if
1099 necessary. Prompting may be accomplished by hand, or by
1100 communicating with a program, such as
1101 <prgn>debconf</prgn>, which conforms to the Debian
1102 Configuration management specification, version 2 or
1103 higher. These are included in the
1104 <file>debconf_specification</file> files in the
1105 <package>debian-policy</package> package.
1106 You may also find this file on the FTP site
1107 <ftpsite>ftp.debian.org</ftpsite> in
1108 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1109 or on your local mirror.<footnote>
1111 4% of Debian packages [see <url
1112 id="http://kitenet.net/programs/debconf/stats/"
1113 name="Debconf stats">] currently use
1114 <package>debconf</package> to prompt the user at
1115 install time, and this number is growing daily. The
1116 benefits of using debconf are briefly explained at
1118 id="http://kitenet.net/doc/debconf-doc/introduction.html"
1119 name="Debconf introduction">; they include
1120 preconfiguration, (mostly) noninteractive
1121 installation, elimination of redundant prompting,
1122 consistency of user interface, etc.
1125 With this increasing number of packages using
1126 <package>debconf</package>, plus the existance of a
1127 nascent second implementation of the Debian
1128 configuration management system
1129 (<package>cdebconf</package>), and the stabilization
1130 of the protocol these things use, the time has
1131 finally come to reflect the use of these things in
1138 Packages which use the Debian Configuration management
1139 specification may contain an additional
1140 <prgn>config</prgn> script and a <tt>templates</tt>
1141 file in their control archive. The <prgn>config</prgn>
1142 script might be run before the <prgn>preinst</prgn>
1143 script, and before the package is unpacked or any of its
1144 dependencies or pre-dependancies are satisfied.
1145 Therefore it must work using only the tools present in
1146 <em>essential</em> packages.<footnote>
1148 <package>Debconf</package> or another tool that
1149 implements the Debian Configuration management
1150 specification will also be installed, and any
1151 versioned dependencies on it will be satisfied
1152 before preconfiguration begins.
1158 Packages should try to minimize the amount of prompting
1159 they need to do, and they should ensure that the user
1160 will only ever be asked each question once. This means
1161 that packages should try to use appropriate shared
1162 configuration files (such as <file>/etc/papersize</file> and
1163 <file>/etc/news/server</file>), and shared
1164 <package>debconf</package> variables rather than each
1165 prompting for their own list of required pieces of
1170 It also means that an upgrade should not ask the same
1171 questions again, unless the user has used <tt>dpkg
1172 --purge</tt> to remove the package's configuration. The
1173 answers to configuration questions should be stored in an
1174 appropriate place in <file>/etc</file> so that the user can
1175 modify them, and how this has been done should be
1179 If a package has a vitally important piece of
1180 information to pass to the user (such as "don't run me
1181 as I am, you must edit the following configuration files
1182 first or you risk your system emitting badly-formatted
1183 messages"), it should display this in the
1184 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1185 prompt the user to hit return to acknowledge the
1186 message. Copyright messages do not count as vitally
1187 important (they belong in
1188 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1189 neither do instructions on how to use a program (these
1190 should be in on-line documentation, where all the users
1194 Any necessary prompting should almost always be confined
1195 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1196 script. If it is done in the <prgn>postinst</prgn>, it
1197 should be protected with a conditional so that
1198 unnecessary prompting doesn't happen if a package's
1199 installation fails and the <prgn>postinst</prgn> is
1200 called with <tt>abort-upgrade</tt>,
1201 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1206 <heading>Source packages</heading>
1208 <sect1 id="standardsversion">
1209 <heading>Standards conformance</heading>
1212 In the source package's <tt>Standards-Version</tt> control
1213 field, you should specify the most recent version number
1214 of this policy document with which your package complied
1215 when it was last updated. The current version number is
1220 This information may be used to file bug reports
1221 automatically if your package becomes too much out of
1226 The version number has four components: major and minor
1227 version number and major and minor patch level. When the
1228 standards change in a way that requires every package to
1229 change the major number will be changed. Significant
1230 changes that will require work in many packages will be
1231 signaled by a change to the minor number. The major patch
1232 level will be changed for any change to the meaning of the
1233 standards, however small; the minor patch level will be
1234 changed when only cosmetic, typographical or other edits
1235 are made which neither change the meaning of the document
1236 nor affect the contents of packages.</p>
1239 Thus only the first three components of the policy version
1240 are significant in the <em>Standards-Version</em> control
1241 field, and so either these three components or the all
1242 four components may be specified.<footnote>
1244 In the past, people specified the full version number
1245 in the Standards-Version field, for example `2.3.0.0'.
1246 Since minor patch-level changes don't introduce new
1247 policy, it was thought it would be better to relax
1248 policy and only require the first 3 components to be
1249 specified, in this example `2.3.0'. All four
1250 components may still be used if someone wishes to do
1257 You should regularly, and especially if your package has
1258 become out of date, check for the newest Policy Manual
1259 available and update your package, if necessary. When your
1260 package complies with the new standards you should update the
1261 <tt>Standards-Version</tt> source package field and
1262 release it.<footnote>
1264 See the file <file>upgrading-checklist</file> for
1265 information about policy which has changed between
1266 different versions of this document.
1274 <heading>Package relationships</heading>
1277 Source packages should specify which binary packages they
1278 require to be installed or not to be installed in order to
1279 build correctly. For example, if building a package
1280 requires a certain compiler, then the compiler should be
1281 specified as a build-time dependency.
1285 It is not necessary to explicitly specify build-time
1286 relationships on a minimal set of packages that are always
1287 needed to compile, link and put in a Debian package a
1288 standard "Hello World!" program written in C or C++. The
1289 required packages are called <em>build-essential</em>, and
1290 an informational list can be found in
1291 <file>/usr/share/doc/build-essential/list</file> (which is
1292 contained in the <tt>build-essential</tt>
1295 <list compact="compact">
1297 <p>This allows maintaining the list separately
1298 from the policy documents (the list does not
1299 need the kind of control that the policy
1305 Having a separate package allows one to install
1306 the build-essential packages on a machine, as
1307 well as allowing other packages such as tasks to
1308 require installation of the build-essential
1309 packages using the depends relation.
1314 The separate package allows bug reports against
1315 the list to be categorized separately from
1316 the policy management process in the BTS.
1326 When specifying the set of build-time dependencies, one
1327 should list only those packages explicitly required by the
1328 build. It is not necessary to list packages which are
1329 required merely because some other package in the list of
1330 build-time dependencies depends on them.<footnote>
1332 The reason for this is that dependencies change, and
1333 you should list all those packages, and <em>only</em>
1334 those packages that <em>you</em> need directly. What
1335 others need is their business. For example, if you
1336 only link against <file>libimlib</file>, you will need to
1337 build-depend on <package>libimlib2-dev</package> but
1338 not against any <tt>libjpeg*</tt> packages, even
1339 though <tt>libimlib2-dev</tt> currently depends on
1340 them: installation of <package>libimlib2-dev</package>
1341 will automatically ensure that all of its run-time
1342 dependencies are satisfied.
1348 If build-time dependencies are specified, it must be
1349 possible to build the package and produce working binaries
1350 on a system with only essential and build-essential
1351 packages installed and also those required to satisfy the
1352 build-time relationships (including any implied
1353 relationships). In particular, this means that version
1354 clauses should be used rigorously in build-time
1355 relationships so that one cannot produce bad or
1356 inconsistently configured packages when the relationships
1357 are properly satisfied.
1361 <heading>Changes to the upstream sources</heading>
1364 If changes to the source code are made that are not
1365 specific to the needs of the Debian system, they should be
1366 sent to the upstream authors in whatever form they prefer
1367 so as to be included in the upstream version of the
1371 If you need to configure the package differently for
1372 Debian or for Linux, and the upstream source doesn't
1373 provide a way to do so, you should add such configuration
1374 facilities (for example, a new <prgn>autoconf</prgn> test
1375 or <tt>#define</tt>) and send the patch to the upstream
1376 authors, with the default set to the way they originally
1377 had it. You can then easily override the default in your
1378 <file>debian/rules</file> or wherever is appropriate.</p>
1381 You should make sure that the <prgn>configure</prgn> utility
1382 detects the correct architecture specification string
1383 (refer to <ref id="arch-spec"> for details).</p>
1386 If you need to edit a <prgn>Makefile</prgn> where
1387 GNU-style <prgn>configure</prgn> scripts are used, you
1388 should edit the <file>.in</file> files rather than editing the
1389 <prgn>Makefile</prgn> directly. This allows the user to
1390 reconfigure the package if necessary. You should
1391 <em>not</em> configure the package and edit the generated
1392 <prgn>Makefile</prgn>! This makes it impossible for
1393 someone else to later reconfigure the package.</p></sect1>
1397 <heading>Documenting your changes</heading>
1400 You should document your changes and updates to the source
1401 package properly in the <file>debian/changelog</file> file. (Note
1402 that mistakes in changelogs are usually best rectified by
1403 making a new changelog entry rather than "rewriting history"
1404 by editing old changelog entries.)</p>
1407 In non-experimental packages you must use a format for
1408 <file>debian/changelog</file> which is supported by the most
1409 recent released version of <prgn>dpkg</prgn>.<footnote>
1411 If you wish to use an alternative format, you may do
1412 so as long as you include a parser for it in your
1413 source package. The parser must have an API
1414 compatible with that expected by
1415 <prgn>dpkg-genchanges</prgn> and
1416 <prgn>dpkg-gencontrol</prgn>. If there is general
1417 interest in the new format, you should contact the
1418 <package>dpkg</package> maintainer to have the parser
1419 script for it included in the <prgn>dpkg</prgn>
1420 package. (You will need to agree that the parser and
1421 its manpage may be distributed under the GNU GPL, just
1422 as the rest of `dpkg' is.)
1430 <heading>Error trapping in makefiles</heading>
1433 When <prgn>make</prgn> invokes a command in a makefile
1434 (including your package's upstream makefiles and
1435 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1436 means that <prgn>sh</prgn>'s usual bad error handling
1437 properties apply: if you include a miniature script as one
1438 of the commands in your makefile you'll find that if you
1439 don't do anything about it then errors are not detected
1440 and <prgn>make</prgn> will blithely continue after
1444 Every time you put more than one shell command (this
1445 includes using a loop) in a makefile command you
1446 must make sure that errors are trapped. For
1447 simple compound commands, such as changing directory and
1448 then running a program, using <tt>&&</tt> rather
1449 than semicolon as a command separator is sufficient. For
1450 more complex commands including most loops and
1451 conditionals you should include a separate <tt>set -e</tt>
1452 command at the start of every makefile command that's
1453 actually one of these miniature shell scripts.</p></sect1>
1457 <heading>Obsolete constructs and libraries</heading>
1460 The include file <tt><varargs.h></tt> is
1461 provided to support end-users compiling very old software;
1462 the library <tt>libtermcap</tt> is provided to support the
1463 execution of software which has been linked against it
1464 (either old programs or those such as Netscape which are
1465 only available in binary form).</p>
1468 Debian packages should be patched to use
1469 <tt><stdarg.h></tt> and <tt>ncurses</tt>
1476 <chapt id="controlfields"><heading>Control files and their fields</heading>
1479 Many of the tools in the package management suite manipulate
1480 data represented in a common format, known as <em>control
1481 data</em>. The data is often stored in <em>control
1482 files</em>. Binary and source packages have control files,
1483 and the <file>.changes</file> files which control the installation
1484 of uploaded files are also in control file format.
1485 <prgn>Dpkg</prgn>'s internal databases are in a similar
1489 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1492 A control file consists of one or more paragraphs of fields.
1493 The paragraphs are separated by blank lines. Some control
1494 files allow only one paragraph; others allow several, in
1495 which case each paragraph usually refers to a different
1496 package. (For example, in source packages, the first
1497 paragraph refers to the source package, and later paragraphs
1498 refer to binary packages generated from the source.)
1502 Each paragraph consists of a series of data fields; each
1503 field consists of the field name, followed by a colon and
1504 then the data/value associated with that field. It ends at
1505 the end of the line. Horizontal whitespace (spaces and
1506 tabs) may occur immediately before or after the value and is
1507 ignored there; it is conventional to put a single space
1508 after the colon. For example, a field might be:
1509 <example compact="compact">
1512 the field name is <tt>Package</tt> and the field value
1517 Some fields' values may span several lines; in this case
1518 each continuation line <em>must</em> start with a space or
1519 tab. Any trailing spaces or tabs at the end of individual
1520 lines of a field value are ignored.
1524 Except where otherwise stated only a single line of data is
1525 allowed and whitespace is not significant in a field body.
1526 Whitespace must not appear inside names (of packages,
1527 architectures, files or anything else) or version numbers,
1528 or between the characters of multi-character version
1533 Field names are not case-sensitive, but it is usual to
1534 capitalize the field names using mixed case as shown below.
1538 Blank lines, or lines consisting only of spaces and tabs,
1539 are not allowed within field values or between fields - that
1540 would mean a new paragraph.
1545 <sect><heading>List of fields</heading>
1547 This list here is not supposed to be exhaustive. Most fields
1548 are dealt with elsewhere in this document.
1550 <sect1 id="f-Package"><heading><tt>Package</tt>
1554 The name of the binary package. Package names consist of
1555 lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1556 plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1557 periods (<tt>.</tt>).
1561 They must be at least two characters long and must start
1562 with an alphanumeric character. The use of lowercase
1563 package names is required unless the package you're
1564 building (or referring to, in other fields) is already
1565 using uppercase characters.</p>
1568 <sect1 id="f-Version"><heading><tt>Version</tt>
1572 This lists the source or binary package's version number -
1573 see <ref id="versions">.
1579 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1583 The most recent version of the standards (the policy
1584 manual and associated texts) with which the package
1585 complies. This is updated manually when editing the
1586 source package to conform to newer standards; it can
1587 sometimes be used to tell when a package needs attention.
1588 Its format is described above; see
1589 <ref id="standardsversion">.
1594 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1598 In a <file>.changes</file> file or parsed changelog output
1599 this contains the (space-separated) name(s) of the
1600 distribution(s) where this version of the package should
1601 be installed. Valid distributions are determined by the
1602 archive maintainers.<footnote>
1603 Current distribution names are:
1604 <taglist compact="compact">
1605 <tag><em>stable</em></tag>
1608 This is the current `released' version of Debian
1609 GNU/Linux. Once the distribution is
1610 <em>stable</em> only security fixes and other
1611 major bug fixes are allowed. When changes are
1612 made to this distribution, the release number is
1613 increased (for example: 2.2r1 becomes 2.2r2 then
1618 <tag><em>unstable</em></tag>
1621 This distribution value refers to the
1622 <em>developmental</em> part of the Debian
1623 distribution tree. New packages, new upstream
1624 versions of packages and bug fixes go into the
1625 <em>unstable</em> directory tree. Download from
1626 this distribution at your own risk.
1630 <tag><em>testing</em></tag>
1633 This distribution value refers to the
1634 <em>testing</em> part of the Debian distribution
1635 tree. It receives its packages from the
1636 unstable distribution after a short time lag to
1637 ensure that there are no major issues with the
1638 unstable packages. It is less prone to breakage
1639 than unstable, but still risky. It is not
1640 possible to upload packages directly to
1645 <tag><em>frozen</em></tag>
1648 From time to time, the <em>testing</em>
1649 distribution enters a state of `code-freeze' in
1650 anticipation of release as a <em>stable</em>
1651 version. During this period of testing only
1652 fixes for existing or newly-discovered bugs will
1653 be allowed. The exact details of this stage are
1654 determined by the Release Manager.
1658 <tag><em>experimental</em></tag>
1661 The packages with this distribution value are
1662 deemed by their maintainers to be high
1663 risk. Oftentimes they represent early beta or
1664 developmental packages from various sources that
1665 the maintainers want people to try, but are not
1666 ready to be a part of the other parts of the
1667 Debian distribution tree. Download at your own
1673 You should list <em>all</em> distributions that the
1674 package should be installed into.
1683 <chapt id="versions"><heading>Version numbering</heading>
1686 Every package has a version number recorded in its
1687 <tt>Version</tt> control file field.
1691 The package management system imposes an ordering on version
1692 numbers, so that it can tell whether packages are being up- or
1693 downgraded and so that package system front end applications
1694 can tell whether a package it finds available is newer than
1695 the one installed on the system. The version number format
1696 has the most significant parts (as far as comparison is
1697 concerned) at the beginning.
1701 The version number format is:
1702 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1706 The three components here are:
1708 <tag><var>epoch</var></tag>
1711 This is a single (generally small) unsigned integer. It
1712 may be omitted, in which case zero is assumed. If it is
1713 omitted then the <var>upstream_version</var> may not
1718 It is provided to allow mistakes in the version numbers
1719 of older versions of a package, and also a package's
1720 previous version numbering schemes, to be left behind.
1724 <tag><var>upstream_version</var></tag>
1727 This is the main part of the version number. It is
1728 usually the version number of the original (`upstream')
1729 package from which the <file>.deb</file> file has been made,
1730 if this is applicable. Usually this will be in the same
1731 format as that specified by the upstream author(s);
1732 however, it may need to be reformatted to fit into the
1733 package management system's format and comparison
1738 The comparison behavior of the package management system
1739 with respect to the <var>upstream_version</var> is
1740 described below. The <var>upstream_version</var>
1741 portion of the version number is mandatory.
1745 The <var>upstream_version</var> may contain only
1746 alphanumerics<footnote>
1747 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1749 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1750 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1751 start with a digit. If there is no
1752 <var>debian_revision</var> then hyphens are not allowed;
1753 if there is no <var>epoch</var> then colons are not
1757 <tag><var>debian_revision</var></tag>
1760 This part of the version number specifies the version of
1761 the Debian package based on the upstream version. It
1762 may contain only alphanumerics and the characters
1763 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1764 compared in the same way as the
1765 <var>upstream_version</var> is.
1769 It is optional; if it isn't present then the
1770 <var>upstream_version</var> may not contain a hyphen.
1771 This format represents the case where a piece of
1772 software was written specifically to be turned into a
1773 Debian package, and so there is only one `debianization'
1774 of it and therefore no revision indication is required.
1778 It is conventional to restart the
1779 <var>debian_revision</var> at <tt>1</tt> each time the
1780 <var>upstream_version</var> is increased.
1784 The package management system will break the version
1785 number apart at the last hyphen in the string (if there
1786 is one) to determine the <var>upstream_version</var> and
1787 <var>debian_revision</var>. The absence of a
1788 <var>debian_revision</var> compares earlier than the
1789 presence of one (but note that the
1790 <var>debian_revision</var> is the least significant part
1791 of the version number).
1798 The <var>upstream_version</var> and <var>debian_revision</var>
1799 parts are compared by the package management system using the
1804 The strings are compared from left to right.
1808 First the initial part of each string consisting entirely of
1809 non-digit characters is determined. These two parts (one of
1810 which may be empty) are compared lexically. If a difference
1811 is found it is returned. The lexical comparison is a
1812 comparison of ASCII values modified so that all the letters
1813 sort earlier than all the non-letters.
1817 Then the initial part of the remainder of each string which
1818 consists entirely of digit characters is determined. The
1819 numerical values of these two parts are compared, and any
1820 difference found is returned as the result of the comparison.
1821 For these purposes an empty string (which can only occur at
1822 the end of one or both version strings being compared) counts
1827 These two steps (comparing and removing initial non-digit
1828 strings and initial digit strings) are repeated until a
1829 difference is found or both strings are exhausted.
1833 Note that the purpose of epochs is to allow us to leave behind
1834 mistakes in version numbering, and to cope with situations
1835 where the version numbering scheme changes. It is
1836 <em>not</em> intended to cope with version numbers containing
1837 strings of letters which the package management system cannot
1838 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1839 silly orderings (the author of this manual has heard of a
1840 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1841 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1842 <tt>2</tt> and so forth).
1846 If an upstream package has problematic version numbers they
1847 should be converted to a sane form for use in the
1848 <tt>Version</tt> field.
1852 <heading>Version numbers based on dates</heading>
1854 In general, Debian packages should use the same version
1855 numbers as the upstream sources.</p>
1858 However, in some cases where the upstream version number is
1859 based on a date (e.g., a development `snapshot' release) the
1860 package management system cannot handle these version
1861 numbers without epochs. For example, dpkg will consider
1862 `96May01' to be greater than `96Dec24'.</p>
1865 To prevent having to use epochs for every new upstream
1866 version, the version number should be changed to the
1867 following format in such cases: `19960501', `19961224'. It
1868 is up to the maintainer whether he/she wants to bother the
1869 upstream maintainer to change the version numbers upstream,
1873 Note that other version formats based on dates which are
1874 parsed correctly by the package management system should
1875 <em>not</em> be changed.</p>
1878 Native Debian packages (i.e., packages which have been
1879 written especially for Debian) whose version numbers include
1880 dates should always use the `YYYYMMDD' format.</p>
1884 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1886 <sect id="timestamps"><heading>Time Stamps</heading>
1888 Maintainers should preserve the modification times of the
1889 upstream source files in a package, as far as is reasonably
1892 The rationale is that there is some information conveyed
1893 by knowing the age of the file, for example, you could
1894 recognize that some documentation is very old by looking
1895 at the modification time, so it would be nice if the
1896 modification time of the upstream source would be
1903 <sect id="debianrules"><heading><file>debian/rules</file> - the
1904 main building script</heading>
1907 This file must be an executable makefile, and contains the
1908 package-specific recipes for compiling the package and
1909 building binary package(s) from the source.
1913 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1914 so that it can be invoked by saying its name rather than
1915 invoking <prgn>make</prgn> explicitly.
1919 Since an interactive <file>debian/rules</file> script makes it
1920 impossible to auto-compile that package and also makes it
1921 hard for other people to reproduce the same binary
1922 package, all <em>required targets</em> MUST be
1923 non-interactive. At a minimum, required targets are the
1924 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1925 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1926 <em>binary-indep</em>, and <em>build</em>. It also follows
1927 that any target that these targets depend on must also be
1932 The required and optional targets are as follows:
1934 <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1935 <tt>build-indep</tt> (optional)</tag>
1938 The <tt>build</tt> target should perform all
1939 non-interactive configuration and compilation of the
1940 package. If a package has an interactive pre-build
1941 configuration routine, the Debianized source package
1942 must either be built after this has taken place (so
1943 that the binary package can be built without rerunning
1944 the configuration) or the configuration routine
1945 modified to become non-interactive. (The latter is
1946 preferable if there are architecture-specific features
1947 detected by the configuration routine.)
1951 For some packages, notably ones where the same
1952 source tree is compiled in different ways to produce
1953 two binary packages, the <tt>build</tt> target
1954 does not make much sense. For these packages it is
1955 good enough to provide two (or more) targets
1956 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1957 for each of the ways of building the package, and a
1958 <tt>build</tt> target that does nothing. The
1959 <tt>binary</tt> target will have to build the
1960 package in each of the possible ways and make the
1961 binary package out of each.
1965 The <tt>build</tt> target must not do anything
1966 that might require root privilege.
1970 The <tt>build</tt> target may need to run the
1971 <tt>clean</tt> target first - see below.
1975 When a package has a configuration and build routine
1976 which takes a long time, or when the makefiles are
1977 poorly designed, or when <tt>build</tt> needs to
1978 run <tt>clean</tt> first, it is a good idea to
1979 <tt>touch build</tt> when the build process is
1980 complete. This will ensure that if <tt>debian/rules
1981 build</tt> is run again it will not rebuild the whole
1984 Another common way to do this is for <tt>build</tt>
1985 to depend on <prgn>build-stamp</prgn> and to do
1986 nothing else, and for the <prgn>build-stamp</prgn>
1987 target to do the building and to <tt>touch
1988 build-stamp</tt> on completion. This is
1989 especially useful if the build routine creates a
1990 file or directory called <tt>build</tt>; in such a
1991 case, <tt>build</tt> will need to be listed as
1992 a phony target (i.e., as a dependency of the
1993 <tt>.PHONY</tt> target). See the documentation of
1994 <prgn>make</prgn> for more information on phony
2001 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
2002 <tt>binary-indep</tt>
2006 The <tt>binary</tt> target must be all that is
2007 necessary for the user to build the binary package(s)
2008 produced from this source package. All of these
2009 targets are required to be non-interactive. It is
2010 split into two parts: <prgn>binary-arch</prgn> builds
2011 the binary packages which are specific to a particular
2012 architecture, and <tt>binary-indep</tt> builds
2013 those which are not.
2016 <tt>binary</tt> may be (and commonly is) a target with
2017 no commands which simply depends on
2018 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
2021 Both <tt>binary-*</tt> targets should depend on the
2022 <tt>build</tt> target, or on the appropriate
2023 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
2024 provided, so that the package is built if it has not
2025 been already. It should then create the relevant
2026 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
2027 make their control files and <prgn>dpkg-deb</prgn> to
2028 build them and place them in the parent of the top
2033 Both the <tt>binary-arch</tt> and
2034 <tt>binary-indep</tt> targets <em>must</em> exist.
2035 If one of them has nothing to do (which will always be
2036 the case if the source generates only a single binary
2037 package, whether architecture-dependent or not), it
2038 must still exist and must always succeed.
2042 The <tt>binary</tt> targets must be invoked as
2045 The <prgn>fakeroot</prgn> package often allows one
2046 to build a package correctly even without being
2053 <tag><tt>clean</tt></tag>
2056 This must undo any effects that the <tt>build</tt>
2057 and <tt>binary</tt> targets may have had, except
2058 that it should leave alone any output files created in
2059 the parent directory by a run of a <tt>binary</tt>
2060 target. This target must be non-interactive.
2064 If a <tt>build</tt> file is touched at the end of
2065 the <tt>build</tt> target, as suggested above, it
2066 should be removed as the first action that
2067 <tt>clean</tt> performs, so that running
2068 <tt>build</tt> again after an interrupted
2069 <tt>clean</tt> doesn't think that everything is
2074 The <tt>clean</tt> target may need to be
2075 invoked as root if <tt>binary</tt> has been
2076 invoked since the last <tt>clean</tt>, or if
2077 <tt>build</tt> has been invoked as root (since
2078 <tt>build</tt> may create directories, for
2083 <tag><tt>get-orig-source</tt> (optional)</tag>
2086 This target fetches the most recent version of the
2087 original source package from a canonical archive site
2088 (via FTP or WWW, for example), does any necessary
2089 rearrangement to turn it into the original source
2090 tar file format described below, and leaves it in the
2095 This target may be invoked in any directory, and
2096 should take care to clean up any temporary files it
2101 This target is optional, but providing it if
2102 possible is a good idea.
2108 The <tt>build</tt>, <tt>binary</tt> and
2109 <tt>clean</tt> targets must be invoked with the current
2110 directory being the package's top-level directory.
2115 Additional targets may exist in <file>debian/rules</file>,
2116 either as published or undocumented interfaces or for the
2117 package's internal use.
2121 The architectures we build on and build for are determined
2122 by <prgn>make</prgn> variables using the utility
2123 <prgn>dpkg-architecture</prgn>. You can determine the
2124 Debian architecture and the GNU style architecture
2125 specification string for the build machine (the machine type
2126 we are building on) as well as for the host machine (the
2127 machine type we are building for). Here is a list of
2128 supported <prgn>make</prgn> variables:
2129 <list compact="compact">
2131 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2134 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2135 specification string)</p>
2138 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2139 <tt>DEB_*_GNU_TYPE</tt>)</p>
2142 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2143 <tt>DEB_*_GNU_TYPE</tt>)</p>
2145 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2146 the build machine or <tt>HOST</tt> for specification of the
2151 Backward compatibility can be provided in the rules file
2152 by setting the needed variables to suitable default
2153 values; please refer to the documentation of
2154 <prgn>dpkg-architecture</prgn> for details.
2158 It is important to understand that the <tt>DEB_*_ARCH</tt>
2159 string only determines which Debian architecture we are
2160 building on or for. It should not be used to get the CPU
2161 or system information; the GNU style variables should be
2166 <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2170 This file records the changes to the Debian-specific parts of the
2173 Though there is nothing stopping an author who is also
2174 the Debian maintainer from using it for all their
2175 changes, it will have to be renamed if the Debian and
2176 upstream maintainers become different people. In such a
2177 case, however, it might be better to maintain the
2178 package as a non-native package.
2184 It has a special format which allows the package building
2185 tools to discover which version of the package is being
2186 built and find out other release-specific information.
2190 That format is a series of entries like this:
2191 <example compact="compact">
2192 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2194 <p>[optional blank line(s), stripped]</p>
2196 * <var>change details</var>
2197 <var>more change details</var>
2199 <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2201 * <var>even more change details</var>
2203 <p>[optional blank line(s), stripped]</p>
2205 -- <var>maintainer name</var> <<var>email
2206 address</var>><var>[two spaces]</var> <var>date</var>
2211 <var>package</var> and <var>version</var> are the source
2212 package name and version number.
2216 <var>distribution(s)</var> lists the distributions where
2217 this version should be installed when it is uploaded - it
2218 is copied to the <tt>Distribution</tt> field in the
2219 <file>.changes</file> file. See <ref id="f-Distribution">.
2223 <var>urgency</var> is the value for the <tt>Urgency</tt>
2224 field in the <file>.changes</file> file for the upload. It is
2225 not possible to specify an urgency containing commas; commas
2226 are used to separate
2227 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2228 <prgn>dpkg</prgn> changelog format (though there is
2229 currently only one useful <var>keyword</var>,
2230 <tt>urgency</tt>).<footnote>
2232 Recognised urgency values are <tt>low</tt>,
2233 <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2234 They have an effect on how quickly a package will be
2235 considered for inclusion into the <tt>testing</tt>
2236 distribution, and give an indication of the importance
2237 of any fixes included in this upload.
2243 The change details may in fact be any series of lines
2244 starting with at least two spaces, but conventionally each
2245 change starts with an asterisk and a separating space and
2246 continuation lines are indented so as to bring them in
2247 line with the start of the text above. Blank lines may be
2248 used here to separate groups of changes, if desired.
2252 If this upload resolves bugs recorded in the Bug Tracking
2253 System (BTS), they may be automatically closed on the
2254 inclusion of this package into the Debian archive by
2255 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2256 in the change details.<footnote>
2258 To be precise, the string should match the following
2259 Perl regular expression:
2261 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2263 Then all of the bug numbers listed will be closed by the
2264 archive maintenance script (<prgn>katie</prgn>), or in
2265 the case of an NMU, marked as fixed.
2271 The maintainer name and email address used in the changelog
2272 should be the details of the person uploading <em>this</em>
2273 version. They are <em>not</em> necessarily those of the
2274 usual package maintainer. The information here will be
2275 copied to the <tt>Changed-By</tt> field in the
2276 <tt>.changes</tt> file, and then later used to send an
2277 acknowledgement when the upload has been installed.
2281 The <var>date</var> should be in RFC822 format<footnote>
2283 This is generated by the <prgn>822-date</prgn>
2286 </footnote>; it should include the time zone specified
2287 numerically, with the time zone name or abbreviation
2288 optionally present as a comment in parentheses.
2292 The first `title' line with the package name should start
2293 at the left hand margin; the `trailer' line with the
2294 maintainer and date details should be preceded by exactly
2295 one space. The maintainer details and the date must be
2296 separated by exactly two spaces.
2299 <sect1><heading>Defining alternative changelog formats</heading>
2302 It is possible to use a different format to the standard
2303 one, by providing a parser for the format you wish to
2307 A changelog parser must not interact with the user at
2313 <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2314 and variable substitutions </heading>
2317 When <prgn>dpkg-gencontrol</prgn>,
2318 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2319 generate control files they perform variable substitutions
2320 on their output just before writing it. Variable
2321 substitutions have the form <tt>${<var>variable</var>}</tt>.
2322 The optional file <file>debian/substvars</file> contains
2323 variable substitutions to be used; variables can also be set
2324 directly from <file>debian/rules</file> using the <tt>-V</tt>
2325 option to the source packaging commands, and certain
2326 predefined variables are also available.
2330 The <file>debian/substvars</file> file is usually generated and
2331 modified dynamically by <file>debian/rules</file> targets; in
2332 this case it must be removed by the <tt>clean</tt>
2337 See <manref name="dpkg-source" section="1"> for full
2338 details about source variable substitutions, including the
2339 format of <file>debian/substvars</file>.</p>
2342 <sect id="debianfiles"><heading><file>debian/files</file>
2346 This file is not a permanent part of the source tree; it
2347 is used while building packages to record which files are
2348 being generated. <prgn>dpkg-genchanges</prgn> uses it
2349 when it generates a <file>.changes</file> file.
2353 It should not exist in a shipped source package, and so it
2354 (and any backup files or temporary files such as
2355 <file>files.new</file><footnote>
2357 <file>files.new</file> is used as a temporary file by
2358 <prgn>dpkg-gencontrol</prgn> and
2359 <prgn>dpkg-distaddfile</prgn> - they write a new
2360 version of <tt>files</tt> here before renaming it,
2361 to avoid leaving a corrupted copy if an error
2364 </footnote>) should be removed by the
2365 <tt>clean</tt> target. It may also be wise to
2366 ensure a fresh start by emptying or removing it at the
2367 start of the <tt>binary</tt> target.
2371 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2372 package, it adds an entry to <file>debian/files</file> for the
2373 <file>.deb</file> file that will be created when <tt>dpkg-deb
2374 --build</tt> is run for that binary package. So for most
2375 packages all that needs to be done with this file is to
2376 delete it in the <tt>clean</tt> target.
2380 If a package upload includes files besides the source
2381 package and any binary packages whose control files were
2382 made with <prgn>dpkg-gencontrol</prgn> then they should be
2383 placed in the parent of the package's top-level directory
2384 and <prgn>dpkg-distaddfile</prgn> should be called to add
2385 the file to the list in <file>debian/files</file>.</p>
2388 <sect id="restrictions"><heading>Restrictions on objects in source packages
2392 The source package may not contain any hard links<footnote>
2394 This is not currently detected when building source
2395 packages, but only when extracting
2399 Hard links may be permitted at some point in the
2400 future, but would require a fair amount of
2403 </footnote>, device special files, sockets or setuid or
2404 setgid files.<footnote>
2406 Setgid directories are allowed.
2411 <sect id="descriptions"><heading>Descriptions of packages - the
2412 <tt>Description</tt> field </heading>
2415 The description is intended to describe the program to a user
2416 who has never met it before so that they know whether they
2417 want to install it. It should also give information about the
2418 significant dependencies and conflicts between this package
2419 and others, so that the user knows why these dependencies and
2420 conflicts have been declared.
2423 <sect1><heading>Notes about writing descriptions
2427 The single line synopsis should be kept brief - certainly
2428 under 80 characters.
2432 Do not include the package name in the synopsis line. The
2433 display software knows how to display this already, and you
2434 do not need to state it. Remember that in many situations
2435 the user may only see the synopsis line - make it as
2436 informative as you can.
2440 Do not try to continue the single line synopsis into the
2441 extended description. This will not work correctly when
2442 the full description is displayed, and makes no sense
2443 where only the summary (the single line synopsis) is
2448 The extended description should describe what the package
2449 does and how it relates to the rest of the system (in terms
2450 of, for example, which subsystem it is which part of).
2454 The description field needs to make sense to anyone, even
2455 people who have no idea about any of the things the
2456 package deals with.<footnote>
2458 The blurb that comes with a program in its
2459 announcements and/or <prgn>README</prgn> files is
2460 rarely suitable for use in a description. It is
2461 usually aimed at people who are already in the
2462 community where the package is used.
2468 Put important information first, both in the synopsis and
2469 extended description. Sometimes only the first part of the
2470 synopsis or of the description will be displayed. You can
2471 assume that there will usually be a way to see the whole
2472 extended description.
2476 You may include information about dependencies and so forth
2477 in the extended description, if you wish.
2481 Do not use tab characters. Their effect is not predictable.
2489 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2490 and installation procedure
2493 <sect><heading>Introduction to package maintainer scripts
2497 It is possible to supply scripts as part of a package which
2498 the package management system will run for you when your
2499 package is installed, upgraded or removed.
2503 These scripts are the files <prgn>preinst</prgn>,
2504 <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2505 control area of the package. They must be proper executable
2506 files; if they are scripts (which is recommended), they must
2507 start with the usual <tt>#!</tt> convention. They should be
2508 readable and executable by anyone, and not world-writable.
2512 The package management system looks at the exit status from
2513 these scripts. It is important that they exit with a
2514 non-zero status if there is an error, so that the package
2515 management system can stop its processing. For shell
2516 scripts this means that you <em>almost always</em> need to
2517 use <tt>set -e</tt> (this is usually true when writing shell
2518 scripts, in fact). It is also important, of course, that
2519 they don't exit with a non-zero status if everything went
2524 When a package is upgraded a combination of the scripts from
2525 the old and new packages is called during the upgrade
2526 procedure. If your scripts are going to be at all
2527 complicated you need to be aware of this, and may need to
2528 check the arguments to your scripts.
2532 Broadly speaking the <prgn>preinst</prgn> is called before
2533 (a particular version of) a package is installed, and the
2534 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2535 before (a version of) a package is removed and the
2536 <prgn>postrm</prgn> afterwards.
2540 Programs called from maintainer scripts should not normally
2541 have a path prepended to them. Before installation is
2542 started, the package management system checks to see if the
2543 programs <prgn>ldconfig</prgn>,
2544 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2545 and <prgn>update-rc.d</prgn> can be found via the
2546 <tt>PATH</tt> environment variable. Those programs, and any
2547 other program that one would expect to be on the
2548 <tt>PATH</tt>, should thus be invoked without an absolute
2549 pathname. Maintainer scripts should also not reset the
2550 <tt>PATH</tt>, though they might choose to modify it by
2551 prepending or appending package-specific directories. These
2552 considerations really apply to all shell scripts.</p>
2556 <heading>Maintainer scripts Idempotency</heading>
2559 It is necessary for the error recovery procedures that the
2560 scripts be idempotent. This means that if it is run
2561 successfully, and then it is called again, it doesn't bomb
2562 out or cause any harm, but just ensures that everything is
2563 the way it ought to be. If the first call failed, or
2564 aborted half way through for some reason, the second call
2565 should merely do the things that were left undone the first
2566 time, if any, and exit with a success status if everything
2569 This is so that if an error occurs, the user interrupts
2570 <prgn>dpkg</prgn> or some other unforeseen circumstance
2571 happens you don't leave the user with a badly-broken
2572 package when <prgn>dpkg</prgn> attempts to repeat the
2580 <heading>Controlling terminal for maintainer scripts</heading>
2583 The maintainer scripts are guaranteed to run with a
2584 controlling terminal and can interact with the user.
2585 If they need to prompt for passwords, do full-screen
2586 interaction or something similar you should do these
2587 things to and from <file>/dev/tty</file>, since
2588 <prgn>dpkg</prgn> will at some point redirect scripts'
2589 standard input and output so that it can log the
2590 installation process. Likewise, because these scripts
2591 may be executed with standard output redirected into a
2592 pipe for logging purposes, Perl scripts should set
2593 unbuffered output by setting <tt>$|=1</tt> so that the
2594 output is printed immediately rather than being
2599 Each script should return a zero exit status for
2600 success, or a nonzero one for failure.
2604 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2609 <list compact="compact">
2611 <p><var>new-preinst</var> <tt>install</tt></p>
2614 <p><var>new-preinst</var> <tt>install</tt>
2615 <var>old-version</var></p>
2618 <p><var>new-preinst</var> <tt>upgrade</tt>
2619 <var>old-version</var></p>
2622 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2623 <var>new-version</var>
2629 <list compact="compact">
2631 <p><var>postinst</var> <tt>configure</tt>
2632 <var>most-recently-configured-version</var></p>
2635 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2636 <var>new-version</var></p>
2639 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2640 <tt>in-favour</tt> <var>package</var>
2641 <var>new-version</var></p>
2645 <var>deconfigured's-postinst</var>
2646 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2647 <var>failed-install-package</var> <var>version</var>
2648 <tt>removing</tt> <var>conflicting-package</var>
2655 <list compact="compact">
2657 <p><var>prerm</var> <tt>remove</tt></p>
2660 <p><var>old-prerm</var> <tt>upgrade</tt>
2661 <var>new-version</var></p>
2664 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2665 <var>old-version</var></p>
2668 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2669 <tt>in-favour</tt> <var>package</var>
2670 <var>new-version</var></p>
2674 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2675 <tt>in-favour</tt> <var>package-being-installed</var>
2676 <var>version</var> <tt>removing</tt>
2677 <var>conflicting-package</var>
2684 <list compact="compact">
2686 <p><var>postrm</var> <tt>remove</tt></p>
2689 <p><var>postrm</var> <tt>purge</tt></p>
2693 <var>old-postrm</var> <tt>upgrade</tt>
2694 <var>new-version</var></p>
2697 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2698 <var>old-version</var></p>
2701 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2704 <p><var>new-postrm</var> <tt>abort-install</tt>
2705 <var>old-version</var></p>
2708 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2709 <var>old-version</var></p>
2713 <var>disappearer's-postrm</var> <tt>disappear</tt>
2714 <var>overwriter</var>
2715 <var>overwriter-version</var></p></item>
2720 <sect id="unpackphase"><heading>Details of unpack phase of
2721 installation or upgrade
2725 The procedure on installation/upgrade/overwrite/disappear
2726 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2727 stage of <tt>dpkg --install</tt>) is as follows. In each
2728 case, if a major error occurs (unless listed below) the
2729 actions are, in general, run backwards - this means that the
2730 maintainer scripts are run with different arguments in
2731 reverse order. These are the `error unwind' calls listed
2739 <p>If a version of the package is already
2741 <example compact="compact">
2742 <var>old-prerm</var> upgrade <var>new-version</var>
2747 If the script runs but exits with a non-zero
2748 exit status, <prgn>dpkg</prgn> will attempt:
2749 <example compact="compact">
2750 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2752 Error unwind, for both the above cases:
2753 <example compact="compact">
2754 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2762 <p>If a `conflicting' package is being removed at the same time:
2766 If any packages depended on that conflicting
2767 package and <tt>--auto-deconfigure</tt> is
2768 specified, call, for each such package:
2769 <example compact="compact">
2770 <var>deconfigured's-prerm</var> deconfigure \
2771 in-favour <var>package-being-installed</var> <var>version</var> \
2772 removing <var>conflicting-package</var> <var>version</var>
2775 <example compact="compact">
2776 <var>deconfigured's-postinst</var> abort-deconfigure \
2777 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2778 removing <var>conflicting-package</var> <var>version</var>
2780 The deconfigured packages are marked as
2781 requiring configuration, so that if
2782 <tt>--install</tt> is used they will be
2783 configured again if possible.</p>
2786 <p>To prepare for removal of the conflicting package, call:
2787 <example compact="compact">
2788 <var>conflictor's-prerm</var> remove \
2789 in-favour <var>package</var> <var>new-version</var>
2792 <example compact="compact">
2793 <var>conflictor's-postinst</var> abort-remove \
2794 in-favour <var>package</var> <var>new-version</var>
2805 <p>If the package is being upgraded, call:
2806 <example compact="compact">
2807 <var>new-preinst</var> upgrade <var>old-version</var>
2812 Otherwise, if the package had some configuration
2813 files from a previous version installed (i.e., it
2814 is in the `configuration files only' state):
2815 <example compact="compact">
2816 <var>new-preinst</var> install <var>old-version</var>
2820 <p>Otherwise (i.e., the package was completely purged):
2821 <example compact="compact">
2822 <var>new-preinst</var> install
2824 Error unwind actions, respectively:
2825 <example compact="compact">
2826 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2827 <var>new-postrm</var> abort-install <var>old-version</var>
2828 <var>new-postrm</var> abort-install
2837 The new package's files are unpacked, overwriting any
2838 that may be on the system already, for example any
2839 from the old version of the same package or from
2840 another package. Backups of the old files are kept
2841 temporarily, and if anything goes wrong the package
2842 management system will attempt to put them back as
2843 part of the error unwind.
2847 It is an error for a package to contains files which
2848 are on the system in another package, unless
2849 <tt>Replaces</tt> is used (see <ref id="replaces">).
2851 The following paragraph is not currently the case:
2852 Currently the <tt>- - force-overwrite</tt> flag is
2853 enabled, downgrading it to a warning, but this may not
2859 It is a more serious error for a package to contain a
2860 plain file or other kind of non-directory where another
2861 package has a directory (again, unless
2862 <tt>Replaces</tt> is used). This error can be
2863 overridden if desired using
2864 <tt>--force-overwrite-dir</tt>, but this is not
2869 Packages which overwrite each other's files produce
2870 behavior which, though deterministic, is hard for the
2871 system administrator to understand. It can easily
2872 lead to `missing' programs if, for example, a package
2873 is installed which overwrites a file from another
2874 package, and is then removed again.<footnote>
2876 Part of the problem is due to what is arguably a
2877 bug in <prgn>dpkg</prgn>.
2883 A directory will never be replaced by a symbolic link
2884 to a directory or vice versa; instead, the existing
2885 state (symlink or not) will be left alone and
2886 <prgn>dpkg</prgn> will follow the symlink if there is
2894 <p>If the package is being upgraded, call
2895 <example compact="compact">
2896 <var>old-postrm</var> upgrade <var>new-version</var>
2901 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2902 <example compact="compact">
2903 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2905 Error unwind, for both cases:
2906 <example compact="compact">
2907 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2914 This is the point of no return - if
2915 <prgn>dpkg</prgn> gets this far, it won't back off
2916 past this point if an error occurs. This will
2917 leave the package in a fairly bad state, which
2918 will require a successful re-installation to clear
2919 up, but it's when <prgn>dpkg</prgn> starts doing
2920 things that are irreversible.
2925 Any files which were in the old version of the package
2926 but not in the new are removed.</p>
2929 <p>The new file list replaces the old.</p>
2932 <p>The new maintainer scripts replace the old.</p>
2936 <p>Any packages all of whose files have been overwritten during the
2937 installation, and which aren't required for
2938 dependencies, are considered to have been removed.
2939 For each such package
2942 <p><prgn>dpkg</prgn> calls:
2943 <example compact="compact">
2944 <var>disappearer's-postrm</var> disappear \
2945 <var>overwriter</var> <var>overwriter-version</var>
2950 <p>The package's maintainer scripts are removed.
2955 It is noted in the status database as being in a
2956 sane state, namely not installed (any conffiles
2957 it may have are ignored, rather than being
2958 removed by <prgn>dpkg</prgn>). Note that
2959 disappearing packages do not have their prerm
2960 called, because <prgn>dpkg</prgn> doesn't know
2961 in advance that the package is going to
2970 Any files in the package we're unpacking that are also
2971 listed in the file lists of other packages are removed
2972 from those lists. (This will lobotomize the file list
2973 of the `conflicting' package if there is one.)
2978 The backup files made during installation, above, are
2985 The new package's status is now sane, and recorded as
2990 Here is another point of no return - if the
2991 conflicting package's removal fails we do not unwind
2992 the rest of the installation; the conflicting package
2993 is left in a half-removed limbo.
2999 If there was a conflicting package we go and do the
3000 removal actions (described below), starting with the
3001 removal of the conflicting package's files (any that
3002 are also in the package being installed have already
3003 been removed from the conflicting package's file list,
3004 and so do not get removed now).
3011 <sect id="configdetails"><heading>Details of configuration</heading>
3014 When we configure a package (this happens with <tt>dpkg
3015 --install</tt> and <tt>dpkg --configure</tt>), we first
3016 update any <tt>conffile</tt>s and then call:
3017 <example compact="compact">
3018 <var>postinst</var> configure <var>most-recently-configured-version</var>
3023 No attempt is made to unwind after errors during
3028 If there is no most recently configured version
3029 <prgn>dpkg</prgn> will pass a null argument; older versions
3030 of dpkg may pass <tt><unknown></tt> (including the
3031 angle brackets) in this case. Even older ones do not pass a
3032 second argument at all, under any circumstances.
3036 <sect id="removedetails"><heading>Details of removal and/or
3037 configuration purging</heading>
3043 <example compact="compact">
3044 <var>prerm</var> remove
3050 The package's files are removed (except <tt>conffile</tt>s).
3055 <example compact="compact">
3056 <var>postrm</var> remove
3062 All the maintainer scripts except the <prgn>postrm</prgn>
3067 If we aren't purging the package we stop here. Note
3068 that packages which have no <prgn>postrm</prgn> and no
3069 <tt>conffile</tt>s are automatically purged when
3070 removed, as there is no difference except for the
3071 <prgn>dpkg</prgn> status.</p>
3075 The <tt>conffile</tt>s and any backup files
3076 (<tt>~</tt>-files, <tt>#*#</tt> files,
3077 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3082 <example compact="compact">
3083 <var>postrm</var> purge
3088 <p>The package's file list is removed.</p>
3091 No attempt is made to unwind after errors during
3098 <chapt id="relationships"><heading>Declaring relationships between
3102 Packages can declare in their control file that they have
3103 certain relationships to other packages - for example, that
3104 they may not be installed at the same time as certain other
3105 packages, and/or that they depend on the presence of others,
3106 or that they should overwrite files in certain other packages
3111 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3112 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3113 <tt>Conflicts</tt>, <tt>Provides</tt> and <tt>Replaces</tt>
3114 control file fields.
3118 Source packages may declare relationships to binary packages,
3119 saying that they require certain binary packages to be
3120 installed or absent at the time of building the package.
3124 This is done using the <tt>Build-Depends</tt>,
3125 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3126 <tt>Build-Conflicts-Indep</tt> control file fields.
3129 <sect id="depsyntax"><heading>Syntax of relationship fields
3133 These fields all have a uniform syntax. They are a list of
3134 package names separated by commas.
3138 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3139 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3140 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3141 control file fields of the package, which declare
3142 dependencies on other packages, the package names listed may
3143 also include lists of alternative package names, separated
3144 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3145 if any one of the alternative packages is installed, that
3146 part of the dependency is considered to be satisfied.
3150 All of the fields except for <tt>Provides</tt> may restrict
3151 their applicability to particular versions of each named
3152 package. This is done in parentheses after each individual
3153 package name; the parentheses should contain a relation from
3154 the list below followed by a version number, in the format
3155 described in <ref id="versions">.
3159 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3160 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3161 strictly earlier, earlier or equal, exactly equal, later or
3162 equal and strictly later, respectively. The deprecated
3163 forms <tt><</tt> and <tt>></tt> were used to mean
3164 earlier/later or equal, rather than strictly earlier/later,
3165 so they should not appear in new packages (though
3166 <prgn>dpkg</prgn> still supports them).
3170 Whitespace may appear at any point in the version
3171 specification subject to the rules in <ref
3172 id="controlsyntax">, and must appear where it's necessary to
3173 disambiguate; it is not otherwise significant. For
3174 consistency and in case of future changes to
3175 <prgn>dpkg</prgn> it is recommended that a single space be
3176 used after a version relationship and before a version
3177 number; it is also conventional to put a single space after
3178 each comma, on either side of each vertical bar, and before
3179 each open parenthesis.
3183 For example, a list of dependencies might appear as:
3184 <example compact="compact">
3187 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3192 All fields that specify build-time relationships
3193 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3194 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3195 may be restricted to a certain set of architectures. This
3196 is indicated in brackets after each individual package name and
3197 the optional version specification. The brackets enclose a
3198 list of Debian architecture names separated by whitespace.
3199 Exclamation marks may be prepended to each of the names.
3200 (It is not permitted for some names to be prepended with
3201 exclamation marks and others not.) If the current Debian
3202 host architecture is not in this list and there are no
3203 exclamation marks in the list, or it is in the list with a
3204 prepended exclamation mark, the package name and the
3205 associated version specification are ignored completely for
3206 the purposes of defining the relationships.
3211 <example compact="compact">
3213 Build-Depends-Indep: texinfo
3214 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3215 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3220 Note that the binary package relationship fields such as
3221 <tt>Depends</tt> appear in one of the binary package
3222 sections of the control file, whereas the build-time
3223 relationships such as <tt>Build-Depends</tt> appear in the
3224 source package section of the control file (which is the
3230 <heading>Binary Dependencies - <tt>Depends</tt>,
3231 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3232 <tt>Pre-Depends</tt>
3236 These five fields are used to declare a dependency
3237 relationship by one package on another. Except for
3238 <tt>Enhances</tt>, they appear in the depending (binary)
3239 package's control file. (<tt>Enhances</tt> appears in the
3240 recommending package's control file.)
3244 A <tt>Depends</tt> field takes effect <em>only</em> when a
3245 package is to be configured. It does not prevent a package
3246 being on the system in an unconfigured state while its
3247 dependencies are unsatisfied, and it is possible to replace
3248 a package whose dependencies are satisfied and which is
3249 properly installed with a different version whose
3250 dependencies are not and cannot be satisfied; when this is
3251 done the depending package will be left unconfigured (since
3252 attempts to configure it will give errors) and will not
3253 function properly. If it is necessary, a
3254 <tt>Pre-Depends</tt> field can be used, which has a partial
3255 effect even when a package is being unpacked, as explained
3256 in detail below. (The other three dependency fields,
3257 <tt>Recommends</tt>, <tt>Suggests</tt> and
3258 <tt>Enhances</tt>, are only used by the various front-ends
3259 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3263 For this reason packages in an installation run are usually
3264 all unpacked first and all configured later; this gives
3265 later versions of packages with dependencies on later
3266 versions of other packages the opportunity to have their
3267 dependencies satisfied.
3271 The <tt>Depends</tt> field thus allows package maintainers
3272 to impose an order in which packages should be configured.
3276 The meaning of the five dependency fields is as follows:
3278 <tag><tt>Depends</tt></tag>
3281 This declares an absolute dependency. A package will
3282 not be configured unless all of the packages listed in
3283 its <tt>Depends</tt> field have been correctly
3288 The <tt>Depends</tt> field should be used if the
3289 depended-on package is required for the depending
3290 package to provide a significant amount of
3294 The <tt>Depends</tt> field should also be used if the
3295 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3296 <prgn>postrm</prgn> scripts require the package to be
3297 present in order to run. Note, however, that the
3298 <prgn>postrm</prgn> cannot rely on any non-essential
3299 packages to be present during the <tt>purge</tt>
3303 <tag><tt>Recommends</tt></tag>
3305 <p>This declares a strong, but not absolute, dependency.
3309 The <tt>Recommends</tt> field should list packages
3310 that would be found together with this one in all but
3311 unusual installations.</p>
3314 <tag><tt>Suggests</tt></tag>
3317 This is used to declare that one package may be more
3318 useful with one or more others. Using this field
3319 tells the packaging system and the user that the
3320 listed packages are related to this one and can
3321 perhaps enhance its usefulness, but that installing
3322 this one without them is perfectly reasonable.
3326 <tag><tt>Enhances</tt></tag>
3329 This field is similar to Suggests but works in the
3330 opposite direction. It is used to declare that a
3331 package can enhance the functionality of another
3336 <tag><tt>Pre-Depends</tt></tag>
3339 This field is like <tt>Depends</tt>, except that it
3340 also forces <prgn>dpkg</prgn> to complete installation
3341 of the packages named before even starting the
3342 installation of the package which declares the
3343 pre-dependency, as follows:
3347 When a package declaring a pre-dependency is about to
3348 be <em>unpacked</em> the pre-dependency can be
3349 satisfied if the depended-on package is either fully
3350 configured, <em>or even if</em> the depended-on
3351 package(s) are only unpacked or half-configured,
3352 provided that they have been configured correctly at
3353 some point in the past (and not removed or partially
3354 removed since). In this case, both the
3355 previously-configured and currently unpacked or
3356 half-configured versions must satisfy any version
3357 clause in the <tt>Pre-Depends</tt> field.
3361 When the package declaring a pre-dependency is about
3362 to be <em>configured</em>, the pre-dependency will be
3363 treated as a normal <tt>Depends</tt>, that is, it will
3364 be considered satisfied only if the depended-on
3365 package has been correctly configured.
3369 <tt>Pre-Depends</tt> should be used sparingly,
3370 preferably only by packages whose premature upgrade or
3371 installation would hamper the ability of the system to
3372 continue with any upgrade that might be in progress.
3376 <tt>Pre-Depends</tt> are also required if the
3377 <prgn>preinst</prgn> script depends on the named
3378 package. It is best to avoid this situation if
3384 When selecting which level of dependency to use you should
3385 consider how important the depended-on package is to the
3386 functionality of the one declaring the dependency. Some
3387 packages are composed of components of varying degrees of
3388 importance. Such a package should list using
3389 <tt>Depends</tt> the package(s) which are required by the
3390 more important components. The other components'
3391 requirements may be mentioned as Suggestions or
3392 Recommendations, as appropriate to the components' relative
3397 <sect id="conflicts"><heading>Conflicting binary packages -
3398 <tt>Conflicts</tt></heading>
3401 When one binary package declares a conflict with another
3402 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3403 refuse to allow them to be installed on the system at the
3408 If one package is to be installed, the other must be removed
3409 first - if the package being installed is marked as
3410 replacing (see <ref id="replaces">) the one on the system,
3411 or the one on the system is marked as deselected, or both
3412 packages are marked <tt>Essential</tt>, then
3413 <prgn>dpkg</prgn> will automatically remove the package
3414 which is causing the conflict, otherwise it will halt the
3415 installation of the new package with an error. This
3416 mechanism is specifically designed to produce an error when
3417 the installed package is <tt>Essential</tt>, but the new
3422 A package will not cause a conflict merely because its
3423 configuration files are still installed; it must be at least
3428 A special exception is made for packages which declare a
3429 conflict with their own package name, or with a virtual
3430 package which they provide (see below): this does not
3431 prevent their installation, and allows a package to conflict
3432 with others providing a replacement for it. You use this
3433 feature when you want the package in question to be the only
3434 package providing some feature.
3438 A <tt>Conflicts</tt> entry should almost never have an
3439 `earlier than' version clause. This would prevent
3440 <prgn>dpkg</prgn> from upgrading or installing the package
3441 which declared such a conflict until the upgrade or removal
3442 of the conflicted-with package had been completed.
3446 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3450 As well as the names of actual (`concrete') packages, the
3451 package relationship fields <tt>Depends</tt>,
3452 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3453 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3454 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3455 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3456 may mention `virtual packages'.
3460 A <em>virtual package</em> is one which appears in the
3461 <tt>Provides</tt> control file field of another package.
3462 The effect is as if the package(s) which provide a
3463 particular virtual package name had been listed by name
3464 everywhere the virtual package name appears. (See also <ref
3465 id="virtual_pkg_sect">)
3469 If there are both concrete and virtual packages of the same
3470 name, then the dependency may be satisfied (or the conflict
3471 caused) by either the concrete package with the name in
3472 question or any other concrete package which provides the
3473 virtual package with the name in question. This is so that,
3474 for example, supposing we have
3475 <example compact="compact">
3479 and someone else releases an enhanced version of the
3480 <tt>bar</tt> package (for example, a non-US variant), they
3482 <example compact="compact">
3486 and the <tt>bar-plus</tt> package will now also satisfy the
3487 dependency for the <tt>foo</tt> package.
3491 If a dependency or a conflict has a version number attached
3492 then only real packages will be considered to see whether
3493 the relationship is satisfied (or the prohibition violated,
3494 for a conflict) - it is assumed that a real package which
3495 provides the virtual package is not of the `right' version.
3496 So, a <tt>Provides</tt> field may not contain version
3497 numbers, and the version number of the concrete package
3498 which provides a particular virtual package will not be
3499 looked at when considering a dependency on or conflict with
3500 the virtual package name.
3504 It is likely that the ability will be added in a future
3505 release of <prgn>dpkg</prgn> to specify a version number for
3506 each virtual package it provides. This feature is not yet
3507 present, however, and is expected to be used only
3512 If you want to specify which of a set of real packages
3513 should be the default to satisfy a particular dependency on
3514 a virtual package, you should list the real package as an
3515 alternative before the virtual one.
3520 <sect id="replaces"><heading>Overwriting files and replacing
3521 packages - <tt>Replaces</tt></heading>
3524 The <tt>Replaces</tt> control file field has two distinct
3525 purposes, which come into play in different situations.
3528 <sect1><heading>Overwriting files in other packages</heading>
3531 Firstly, as mentioned before, it is usually an error for a
3532 package to contain files which are on the system in
3537 However, if the overwriting package declares that it
3538 <tt>Replaces</tt> the one containing the file being
3539 overwritten, then <prgn>dpkg</prgn> will replace the file
3540 from the old package with that from the new. The file
3541 will no longer be listed as `owned' by the old package.
3545 If a package is completely replaced in this way, so that
3546 <prgn>dpkg</prgn> does not know of any files it still
3547 contains, it is considered to have `disappeared'. It will
3548 be marked as not wanted on the system (selected for
3549 removal) and not installed. Any <tt>conffile</tt>s
3550 details noted for the package will be ignored, as they
3551 will have been taken over by the overwriting package. The
3552 package's <prgn>postrm</prgn> script will be run with a
3553 special argument to allow the package to do any final
3554 cleanup required. See <ref id="mscriptsinstact">.
3558 If an installed package, <tt>foo</tt> say, declares that
3559 it replaces another, <tt>bar</tt>, and an attempt is made
3560 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3561 files in the <tt>bar</tt> package which would overwrite
3562 those already present in <tt>foo</tt>. This is so that
3563 you can install an older version of a package without
3568 For this usage of <tt>Replaces</tt>, virtual packages (see
3569 <ref id="virtual">) are not considered when looking at a
3570 <tt>Replaces</tt> field - the packages declared as being
3571 replaced must be mentioned by their real names.
3575 Furthermore, this usage of <tt>Replaces</tt> only takes
3576 effect when both packages are at least partially on the
3577 system at once, so that it can only happen if they do not
3578 conflict or if the conflict has been overridden.
3583 <sect1><heading>Replacing whole packages, forcing their
3587 Secondly, <tt>Replaces</tt> allows the packaging system to
3588 resolve which package should be removed when there is a
3589 conflict - see <ref id="conflicts">. This usage only
3590 takes effect when the two packages <em>do</em> conflict,
3591 so that the two usages of this field do not interfere with
3596 In this situation, the package declared as being replaced
3597 can be a virtual package, so for example, all mail
3598 transport agents (MTAs) would have the following fields in
3599 their control files:
3600 <example compact="compact">
3601 Provides: mail-transport-agent
3602 Conflicts: mail-transport-agent
3603 Replaces: mail-transport-agent
3605 ensuring that only one MTA can be installed at any one
3610 <sect><heading>Relationships between source and binary packages -
3611 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3612 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3616 A source package may declare a dependency or a conflict on a
3617 binary package, indicating which packages are required to be
3618 present on the system in order to build the binary packages
3619 from the source package. This is done with the control file
3620 fields <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3621 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>.
3622 The dependencies and conflicts they define must be satisfied
3623 (as defined earlier for binary packages) in order to invoke
3624 the targets in <tt>debian/rules</tt>, as follows:<footnote>
3626 If you make "build-arch" or "binary-arch", you need
3627 Build-Depends. If you make "build-indep" or
3628 "binary-indep", you need Build-Depends and
3629 Build-Depends-Indep. If you make "build" or "binary",
3633 There is no Build-Depends-Arch; the autobuilders will
3634 only need the Build-Depends if they know how to build
3635 only build-arch and binary-arch. Anyone building the
3636 build-indep/binary-indep targets is basically assumed to
3637 be building the whole package and so installs all build
3641 The purpose of the original split, I recall, was so that
3642 the autobuilders wouldn't need to install extra packages
3643 needed only for the binary-indep targets. But without a
3644 build-arch/build-indep split, this didn't work, since
3645 most of the work is done in the build target, not in the
3651 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3654 The <tt>Build-Depends</tt> and
3655 <tt>Build-Conflicts</tt> fields must be satisfied when
3656 any of the following targets is invoked:
3657 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>,
3658 <tt>build-arch</tt>, <tt>build-indep</tt>
3659 and <tt>binary-indep</tt>.
3662 <tag><tt>Build-Depends-Indep</tt>,
3663 <tt>Build-Conflicts-Indep</tt></tag>
3666 The <tt>Build-Depends-Indep</tt> and
3667 <tt>Build-Conflicts-Indep</tt> fields must be
3668 satisfied when any of the following targets is
3669 invoked: <tt>build</tt>, <tt>build-indep</tt>,
3670 <tt>binary</tt> and <tt>binary-indep</tt>.
3681 <chapt id="conffiles"><heading>Configuration file handling
3685 This chapter has been superseded by <ref id="config-files">.
3689 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3692 Packages containing shared libraries must be constructed with
3693 a little care to make sure that the shared library is always
3694 available. This is especially important for packages whose
3695 shared libraries are vitally important, such as the C library
3696 (currently <tt>libc6</tt>).
3700 Firstly, the package should install the shared libraries under
3701 their normal names. For example, the <tt>libgdbmg1</tt>
3702 package should install <tt>libgdbm.so.1.7.3</tt> as
3703 <file>/usr/lib/libgdbm.so.1.7.3</file>. The files should not be
3704 renamed or re-linked by any <prgn>prerm</prgn> or
3705 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3706 of renaming things safely without affecting running programs,
3707 and attempts to interfere with this are likely to lead to
3712 Secondly, the package should include the symbolic link that
3713 <prgn>ldconfig</prgn> would create for the shared libraries.
3714 For example, the <prgn>libgdbmg1</prgn> package should include
3715 a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3716 <file>libgdbm.so.1.7.3</file>. This is needed so that the dynamic
3717 linker (for example <prgn>ld.so</prgn> or
3718 <prgn>ld-linux.so.*</prgn>) can find the library between the
3719 time that <prgn>dpkg</prgn> installs it and the time that
3720 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3723 The package management system requires the library to be
3724 placed before the symbolic link pointing to it in the
3725 <file>.deb</file> file. This is so that when
3726 <prgn>dpkg</prgn> comes to install the symlink
3727 (overwriting the previous symlink pointing at an older
3728 version of the library), the new shared library is already
3729 in place. In the past, this was achieved by creating the
3730 library in the temporary packaging directory before
3731 creating the symlink. Unfortunately, this was not always
3732 effective, since the building of the tar file in the
3733 <file>.deb</file> depended on the behavior of the underlying
3734 file system. Some file systems (such as reiserfs) reorder
3735 the files so that the order of creation is forgotten.
3736 Starting with release <tt>1.7.0</tt>, <prgn>dpkg</prgn>
3737 will reorder the files itself as necessary when building a
3738 package. Thus it is no longer important to concern
3739 oneself with the order of file creation.
3745 Thirdly, the associated development package should contain a
3746 symlink for the shared library without a version number. For
3747 example, the <tt>libgdbmg1-dev</tt> package should include a
3748 symlink from <tt>/usr/lib/libgdbm.so</tt> to
3749 <file>libgdbm.so.1.7.3</file>. This symlink is needed by the
3750 linker (<prgn>ld</prgn>) when compiling packages, as it will
3751 only look for <file>libgdbm.so</file> when compiling dynamically.
3755 Any package installing shared libraries in one of the default
3756 library directories of the dynamic linker (which are currently
3757 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3758 listed in <file>/etc/ld.so.conf</file><footnote>
3761 <list compact="compact">
3762 <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3763 <item><p>/usr/local/lib</p></item>
3764 <item><p>/usr/lib/libc5-compat</p></item>
3765 <item><p>/lib/libc5-compat</p></item>
3766 <item><p>/usr/X11R6/lib</p></item>
3770 must use <prgn>ldconfig</prgn> to update the shared library
3771 system. The package must call <prgn>ldconfig</prgn> in the
3772 <prgn>postinst</prgn> script if the first argument is
3773 <tt>configure</tt>; the <prgn>postinst</prgn> script may
3774 optionally invoke <prgn>ldconfig</prgn> at other times. The
3775 package should call <prgn>ldconfig</prgn> in the
3776 <prgn>postrm</prgn> script if the first argument is
3777 <tt>remove</tt>. The maintainer scripts must not invoke
3778 <prgn>ldconfig</prgn> under any circumstances other than those
3779 described in this paragraph.<footnote>
3780 <p>During install or upgrade, the preinst is called before
3781 the new files are installed, so calling "ldconfig" is
3782 pointless. The preinst of an existing package can also be
3783 called if an upgrade fails. However, this happens during
3784 the critical time when a shared libs may exist on-disk
3785 under a temporary name. Thus, it is dangerous and
3786 forbidden by current policy to call "ldconfig" at this
3789 <p>When a package is installed or upgraded, "postinst
3790 configure" runs after the new files are safely on-disk.
3791 Since it is perfectly safe to invoke ldconfig
3792 unconditionally in a postinst, it is OK for a package to
3793 simply put ldconfig in its postinst without checking the
3794 argument. The postinst can also be called to recover from
3795 a failed upgrade. This happens before any new files are
3796 unpacked, so there is no reason to call "ldconfig" at this
3799 <p>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.
3805 <p>postrm, on the other hand, is called with the "remove"
3806 argument just after the files are removed, so this is the
3807 proper time to call "ldconfig" to notify the system of the
3808 fact shared libraries from the package are removed.
3809 The postrm can be called at several other times. At the
3810 time of "postrm purge", "postrm abort-install", or "postrm
3811 abort-upgrade", calling "ldconfig" is useless because the
3812 shared lib files are not on-disk. However, when "postrm"
3813 is invoked with arguments "upgrade", "failed-upgrade", or
3814 "disappear", a shared lib may exist on-disk under a
3821 <heading>Handling shared library dependencies - the
3822 <tt>shlibs</tt> system</heading>
3825 If a package contains a binary or library which links to a
3826 shared library, we must ensure that when the package is
3827 installed on the system, all of the libraries needed are
3828 also installed. This requirement led to the creation of the
3829 <tt>shlibs</tt> system, which is very simple in its design:
3830 any package which <em>provides</em> a shared library also
3831 provides information on the package dependencies required to
3832 ensure the presence of this library, and any package which
3833 <em>uses</em> a shared library uses this information to
3834 determine the dependencies it requires. The files which
3835 contain the mapping from shared libraries to the necessary
3836 dependency information are called <file>shlibs</file> files.
3840 Thus, when a package is built which contains any shared
3841 libraries, it must provide a <file>shlibs</file> file for other
3842 packages to use, and when a package is built which contains
3843 any shared libraries or compiled binaries, it must run
3844 <prgn>dpkg-shlibdeps</prgn> on these to determine the
3845 libraries used and hence the dependencies needed by this
3848 In the past, the shared libraries linked to were
3849 determined by calling <prgn>ldd</prgn>, but now
3850 <prgn>objdump</prgn> is used to do this. The only
3851 change this makes to package building is that
3852 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
3853 libraries, whereas in the past this was unnecessary.
3854 The rest of this footnote explains the advantage that
3859 We say that a binary <tt>foo</tt> <em>directly</em> uses
3860 a library <tt>libbar</tt> if it is explicitly linked
3861 with that library (that is, it uses the flag
3862 <tt>-lbar</tt> during the linking stage). Other
3863 libraries that are needed by <tt>libbar</tt> are linked
3864 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
3865 linker will load them automatically when it loads
3866 <tt>libbar</tt>. A package should depend on
3867 the libraries it directly uses, and the dependencies for
3868 those libraries should automatically pull in the other
3873 Unfortunately, the <prgn>ldd</prgn> program shows both
3874 the directly and indirectly used libraries, meaning that
3875 the dependencies determined included both direct and
3876 indirect dependencies. The use of <prgn>objdump</prgn>
3877 avoids this problem by determining only the directly
3882 A good example of where this helps is the following. We
3883 could update <tt>libimlib</tt> with a new version that
3884 supports a new graphics format called dgf (but retaining
3885 the same major version number). If we used the old
3886 <prgn>ldd</prgn> method, every package that uses
3887 <tt>libimlib</tt> would need to be recompiled so it
3888 would also depend on <tt>libdgf</tt> or it wouldn't run
3889 due to missing symbols. However with the new system,
3890 packages using <tt>libimlib</tt> can rely on
3891 <tt>libimlib</tt> itself having the dependency on
3892 <tt>libdgf</tt> and so they would not need rebuilding.
3898 In the following sections, we will first describe where the
3899 various <tt>shlibs</tt> files are to be found, then how to
3900 use <prgn>dpkg-shlibdeps</prgn>, and finally the
3901 <tt>shlibs</tt> file format and how to create them if your
3902 package contains a shared library.
3906 <sect><heading>The <tt>shlibs</tt> files present on the system
3910 There are several places where <tt>shlibs</tt> files are
3911 found. The following list gives them in the order in which
3912 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
3913 one which gives the required information is used.)
3919 <p><file>debian/shlibs.local</file></p>
3921 This lists overrides for this package. Its use is
3922 described below (see <ref id="shlibslocal">).
3927 <p><file>/etc/dpkg/shlibs.override</file></p>
3929 This lists global overrides. This list is normally
3930 empty. It is maintained by the local system
3936 <p><file>DEBIAN/shlibs</file> files in the `build directory'</p>
3938 When packages are being built, any
3939 <file>debian/shlibs</file> files are copied into the
3940 control file area of the temporary build directory and
3941 given the name <file>shlibs</file>. These files give
3942 details of any shared libraries included in the
3945 An example may help here. Let us say that the
3946 source package <tt>foo</tt> generates two binary
3947 packages, <tt>libfoo2</tt> and
3948 <tt>foo-runtime</tt>. When building the binary
3949 packages, the two packages are created in the
3950 directories <file>debian/libfoo2</file> and
3951 <file>debian/foo-runtime</file> respectively.
3952 (<file>debian/tmp</file> could be used instead of one
3953 of these.) Since <tt>libfoo2</tt> provides the
3954 <tt>libfoo</tt> shared library, it will require a
3955 <tt>shlibs</tt> file, which will be installed in
3956 <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
3958 <file>/var/lib/dpkg/info/libfoo2.shlibs</file>. Then
3959 when <prgn>dpkg-shlibdeps</prgn> is run on the
3961 <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
3963 <file>debian/libfoo2/DEBIAN/shlibs</file> file to
3964 determine whether <tt>foo-prog</tt>'s library
3965 dependencies are satisfied by any of the libraries
3966 provided by <tt>libfoo2</tt>. For this reason,
3967 <prgn>dpkg-shlibdeps</prgn> must only be run once
3968 all of the individual binary packages'
3969 <tt>shlibs</tt> files have been installed into the
3977 <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
3979 These are the <file>shlibs</file> files corresponding to
3980 all of the packages installed on the system, and are
3981 maintained by the relevant package maintainers.
3986 <p><file>/etc/dpkg/shlibs.default</file></p>
3988 This file lists any shared libraries whose packages
3989 have failed to provide correct <file>shlibs</file> files.
3990 It was used when the <file>shlibs</file> setup was first
3991 introduced, but it is now normally empty. It is
3992 maintained by the <tt>dpkg</tt> maintainer.
4000 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4001 <file>shlibs</file> files</heading>
4004 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4005 <file>debian/rules</file> file. If your package contains only
4006 compiled binaries and libraries (but no scripts), you can
4007 use a command such as:
4008 <example compact="compact">
4009 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4010 debian/tmp/usr/lib/*
4012 Otherwise, you will need to explicitly list the compiled
4013 binaries and libraries.<footnote>
4015 If you are using <tt>debhelper</tt>, the
4016 <prgn>dh_shlibdeps</prgn> program will do this work for
4017 you. It will also correctly handle multi-binary
4024 This command puts the dependency information into the
4025 <file>debian/substvars</file> file, which is then used by
4026 <prgn>dpkg-gencontrol</prgn>. You will need to place a
4027 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4028 field in the control file for this to work.
4032 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4033 done. If it does complain you might need to create your own
4034 <file>debian/shlibs.local</file> file, as explained below (see
4035 <ref id="shlibslocal">).
4039 If you have multiple binary packages, you will need to call
4040 <prgn>dpkg-shlibdeps</prgn> on each one which contains
4041 compiled libraries or binaries. In such a case, you will
4042 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4043 utilities to specify a different <file>substvars</file> file.
4044 For more details on this and other options, see <manref
4045 name="dpkg-shlibdeps" section="1">.
4049 <sect id="shlibs"><heading>The <file>shlibs</file> File Format
4053 Each <file>shlibs</file> file has the same format. Lines
4054 beginning with <tt>#</tt> are considered to be comments and
4055 are ignored. Each line is of the form:
4056 <example compact="compact">
4057 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4062 We will explain this by reference to the example of the
4063 <tt>zlib1g</tt> package, which (at the time of writing)
4064 installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4068 <var>library-name</var> is the name of the shared library,
4069 in this case <tt>libz</tt>. (This must match the name part
4070 of the soname, see below.)
4074 <var>soname-version-number</var> is the version part of the
4075 soname of the library. The soname is the thing that must
4076 exactly match for the library to be recognized by the
4077 dynamic linker, and is usually of the form
4078 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4079 example, <tt>libz.so.1</tt>.<footnote>
4081 This can be determined using the command
4082 <example compact="compact">
4083 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4087 The version part is the part which comes after
4088 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4092 <var>dependencies</var> has the same syntax as a dependency
4093 field in a binary package control file. It should give
4094 details of which packages are required to satisfy a binary
4095 built against the version of the library contained in the
4096 package. See <ref id="depsyntax"> for details.
4100 In our example, if the first version of the <tt>zlib1g</tt>
4101 package which contained a minor number of at least
4102 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4103 <tt>shlibs</tt> entry for this library could say:
4104 <example compact="compact">
4105 libz 1 zlib1g (>= 1:1.1.3)
4107 The version-specific dependency is to avoid warnings from
4108 the dynamic linker about using older shared libraries with
4114 <heading>Providing a <file>shlibs</file> file</heading>
4117 If your package provides a shared library, you should create
4118 a <file>shlibs</file> file following the format described above.
4119 It is usual to call this file <file>debian/shlibs</file> (but if
4120 you have multiple binary packages, you might want to call it
4121 <file>debian/shlibs.<var>package</var></file> instead). Then
4122 let <file>debian/rules</file> install it in the control area:
4123 <example compact="compact">
4124 install -m644 debian/shlibs debian/tmp/DEBIAN
4126 or, in the case of a multi-binary package:
4127 <example compact="compact">
4128 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4130 An alternative way of doing this is to create the
4131 <file>shlibs</file> file in the control area directly from
4132 <file>debian/rules</file> without using a <file>debian/shlibs</file>
4133 file at all,<footnote>
4135 This is what <prgn>dh_makeshlibs</prgn> in the
4136 <tt>debhelper</tt> suite does.
4139 since the <file>debian/shlibs</file> file itself is ignored by
4140 <prgn>dpkg-shlibdeps</prgn>.
4144 As <prgn>dpkg-shlibdeps</prgn> reads the
4145 <file>DEBIAN/shlibs</file> files in all of the binary packages
4146 being built from this source package, all of the
4147 <file>DEBIAN/shlibs</file> files should be installed before
4148 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4153 <sect id="shlibslocal">
4154 <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4157 This file is intended only as a <em>temporary</em> fix if
4158 your binaries or libraries depend on a library whose package
4159 does not yet provide a correct <file>shlibs</file> file.
4163 We will assume that you are trying to package a binary
4164 <tt>foo</tt>. When you try running
4165 <prgn>dpkg-shlibdeps</prgn> you get the following error
4166 message (<tt>-O</tt> displays the dependency information on
4167 <tt>stdout</tt> instead of writing it to
4168 <tt>debian/substvars</tt>, and the lines have been wrapped
4169 for ease of reading):
4170 <example compact="compact">
4171 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4172 dpkg-shlibdeps: warning: unable to find dependency
4173 information for shared library libbar (soname 1,
4174 path /usr/lib/libbar.so.1, dependency field Depends)
4175 shlibs:Depends=libc6 (>= 2.2.2-2)
4177 You can then run <prgn>ldd</prgn> on the binary to find the
4178 full location of the library concerned:
4179 <example compact="compact">
4181 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4182 libc.so.6 => /lib/libc.so.6 (0x40032000)
4183 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4185 So the <prgn>foo</prgn> binary depends on the
4186 <prgn>libbar</prgn> shared library, but no package seems to
4187 provide a <file>*.shlibs</file> file handling
4188 <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>. Let's
4189 determine the package responsible:
4190 <example compact="compact">
4191 $ dpkg -S /usr/lib/libbar.so.1
4192 bar1: /usr/lib/libbar.so.1
4193 $ dpkg -s bar1 | grep Version
4196 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4197 is the one we are using. Now we can file a bug against the
4198 <tt>bar1</tt> package and create our own
4199 <file>debian/shlibs.local</file> to locally fix the problem.
4200 Including the following line into your
4201 <file>debian/shlibs.local</file> file:
4202 <example compact="compact">
4203 libbar 1 bar1 (>= 1.0-1)
4205 should allow the package build to work.
4209 As soon as the maintainer of <tt>bar1</tt> provides a
4210 correct <file>shlibs</file> file, you should remove this line
4211 from your <file>debian/shlibs.local</file> file. (You should
4212 probably also then have a versioned <tt>Build-Depends</tt>
4213 on <tt>bar1</tt> to help ensure that others do not have the
4214 same problem building your package.)
4219 <chapt id="opersys"><heading>The Operating System</heading>
4222 <heading>Filesystem hierarchy</heading>
4226 <heading>Filesystem Structure</heading>
4229 The location of all installed files and directories must
4230 comply with the Filesystem Hierarchy Standard (FHS),
4231 version 2.1, except where doing so would violate other
4232 terms of Debian Policy. The version of this document
4233 referred here can be found in the <tt>debian-policy</tt>
4235 <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4236 name="FHS (Debian copy)"> alongside this manual (or, if
4237 you have the <package>debian-policy</package> installed,
4239 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4240 (local copy)">). The
4241 latest version, which may be a more recent version, may
4243 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4244 Specific questions about following the standard may be
4245 asked on the <tt>debian-devel</tt> mailing list, or
4246 referred to the FHS mailing list (see the
4247 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4253 <heading>Site-specific programs</heading>
4256 As mandated by the FHS, packages must not place any
4257 files in <file>/usr/local</file>, either by putting them in
4258 the file system archive to be unpacked by <prgn>dpkg</prgn>
4259 or by manipulating them in their maintainer scripts.
4263 However, the package may create empty directories below
4264 <file>/usr/local</file> so that the system administrator knows
4265 where to place site-specific files. These directories
4266 should be removed on package removal if they are
4271 Note, that this applies only to directories <em>below</em>
4272 <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4273 Packages must not create sub-directories in the directory
4274 <file>/usr/local</file> itself, except those listed in FHS,
4275 section 4.5. However, you may create directories below
4276 them as you wish. You must not remove any of the
4277 directories listed in 4.5, even if you created them.
4281 Since <file>/usr/local</file> can be mounted read-only from a
4282 remote server, these directories must be created and
4283 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4284 maintainer scripts and not be included in the
4285 <file>.deb</file> archive. These scripts must not fail if
4286 either of these operations fail.
4290 For example, the <tt>emacsen-common</tt> package could
4291 contain something like
4292 <example compact="compact">
4293 if [ ! -e /usr/local/share/emacs ]
4295 if mkdir /usr/local/share/emacs 2>/dev/null
4297 chown root:staff /usr/local/share/emacs
4298 chmod 2775 /usr/local/share/emacs
4302 in its <prgn>postinst</prgn> script, and
4303 <example compact="compact">
4304 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4305 rmdir /usr/local/share/emacs 2>/dev/null || true
4307 in the <prgn>prerm</prgn> script. (Note that this form is
4308 used to ensure that if the script is interrupted, the
4309 directory <file>/usr/local/share/emacs</file> will still be
4314 If you do create a directory in <file>/usr/local</file> for
4315 local additions to a package, you should ensure that
4316 settings in <file>/usr/local</file> take precedence over the
4317 equivalents in <file>/usr</file>.
4321 However, because <file>/usr/local</file> and its contents are
4322 for exclusive use of the local administrator, a package
4323 must not rely on the presence or absence of files or
4324 directories in <file>/usr/local</file> for normal operation.
4328 The <file>/usr/local</file> directory itself and all the
4329 subdirectories created by the package should (by default) have
4330 permissions 2775 (group-writable and set-group-id) and be
4331 owned by <tt>root.staff</tt>.
4336 <heading>The system-wide mail directory</heading>
4338 The system-wide mail directory is <file>/var/mail</file>. This
4339 directory is part of the base system and should not owned
4340 by any particular mail agents. The use of the old
4341 location <file>/var/spool/mail</file> is deprecated, even
4342 though the spool may still be physically located there.
4343 To maintain partial upgrade compatibility for systems
4344 which have <file>/var/spool/mail</file> as their physical mail
4345 spool, packages using <file>/var/mail</file> must depend on
4346 either <package>libc6</package> (>= 2.1.3-13), or on
4347 <package>base-files</package> (>= 2.2.0), or on later
4348 versions of either one of these packages.
4354 <heading>Users and groups</heading>
4357 <heading>Introduction</heading>
4359 The Debian system can be configured to use either plain or
4364 Some user ids (UIDs) and group ids (GIDs) are reserved
4365 globally for use by certain packages. Because some
4366 packages need to include files which are owned by these
4367 users or groups, or need the ids compiled into binaries,
4368 these ids must be used on any Debian system only for the
4369 purpose for which they are allocated. This is a serious
4370 restriction, and we should avoid getting in the way of
4371 local administration policies. In particular, many sites
4372 allocate users and/or local system groups starting at 100.
4376 Apart from this we should have dynamically allocated ids,
4377 which should by default be arranged in some sensible
4378 order, but the behavior should be configurable.
4382 Packages other than <tt>base-passwd</tt> must not modify
4383 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4384 <file>/etc/group</file> or <file>/etc/gshadow</file>.
4389 <heading>UID and GID classes</heading>
4391 The UID and GID numbers are divided into classes as
4397 Globally allocated by the Debian project, the same
4398 on every Debian system. These ids will appear in
4399 the <file>passwd</file> and <file>group</file> files of all
4400 Debian systems, new ids in this range being added
4401 automatically as the <tt>base-passwd</tt> package is
4406 Packages which need a single statically allocated
4407 uid or gid should use one of these; their
4408 maintainers should ask the <tt>base-passwd</tt>
4416 Dynamically allocated system users and groups.
4417 Packages which need a user or group, but can have
4418 this user or group allocated dynamically and
4419 differently on each system, should use <tt>adduser
4420 --system</tt> to create the group and/or user.
4421 <prgn>adduser</prgn> will check for the existence of
4422 the user or group, and if necessary choose an unused
4423 id based on the ranges specified in
4424 <file>adduser.conf</file>.
4428 <tag>1000-29999:</tag>
4431 Dynamically allocated user accounts. By default
4432 <prgn>adduser</prgn> will choose UIDs and GIDs for
4433 user accounts in this range, though
4434 <file>adduser.conf</file> may be used to modify this
4439 <tag>30000-59999:</tag>
4444 <tag>60000-64999:</tag>
4447 Globally allocated by the Debian project, but only
4448 created on demand. The ids are allocated centrally
4449 and statically, but the actual accounts are only
4450 created on users' systems on demand.
4454 These ids are for packages which are obscure or
4455 which require many statically-allocated ids. These
4456 packages should check for and create the accounts in
4457 <file>/etc/passwd</file> or <file>/etc/group</file> (using
4458 <prgn>adduser</prgn> if it has this facility) if
4459 necessary. Packages which are likely to require
4460 further allocations should have a `hole' left after
4461 them in the allocation, to give them room to
4466 <tag>65000-65533:</tag>
4474 User <tt>nobody</tt>. The corresponding gid refers
4475 to the group <tt>nogroup</tt>.
4482 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4483 not</em> be used, because it is the error return
4492 <sect id="sysvinit">
4493 <heading>System run levels and <file>init.d</file> scripts</heading>
4495 <sect1 id="/etc/init.d">
4496 <heading>Introduction</heading>
4499 The <file>/etc/init.d</file> directory contains the scripts
4500 executed by <prgn>init</prgn> at boot time and when the
4501 init state (or `runlevel') is changed (see <manref
4502 name="init" section="8">).
4506 There are at least two different, yet functionally
4507 equivalent, ways of handling these scripts. For the sake
4508 of simplicity, this document describes only the symbolic
4509 link method. However, it must not be assumed by maintainer
4510 scripts that this method is being used, and any automated
4511 manipulation of the various runlevel behaviours by
4512 maintainer scripts must be performed using
4513 <prgn>update-rc.d</prgn> as described below and not by
4514 manually installing or removing symlinks. For information
4515 on the implementation details of the other method,
4516 implemented in the <tt>file-rc</tt> package, please refer
4517 to the documentation of that package.
4521 These scripts are referenced by symbolic links in the
4522 <file>/etc/rc<var>n</var>.d</file> directories. When changing
4523 runlevels, <prgn>init</prgn> looks in the directory
4524 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4525 execute, where <tt><var>n</var></tt> is the runlevel that
4526 is being changed to, or <tt>S</tt> for the boot-up
4531 The names of the links all have the form
4532 <file>S<var>mm</var><var>script</var></file> or
4533 <file>K<var>mm</var><var>script</var></file> where
4534 <var>mm</var> is a two-digit number and <var>script</var>
4535 is the name of the script (this should be the same as the
4536 name of the actual script in <file>/etc/init.d</file>).
4540 When <prgn>init</prgn> changes runlevel first the targets
4541 of the links whose names start with a <tt>K</tt> are
4542 executed, each with the single argument <tt>stop</tt>,
4543 followed by the scripts prefixed with an <tt>S</tt>, each
4544 with the single argument <tt>start</tt>. (The links are
4545 those in the <file>/etc/rc<var>n</var>.d</file> directory
4546 corresponding to the new runlevel.) The <tt>K</tt> links
4547 are responsible for killing services and the <tt>S</tt>
4548 link for starting services upon entering the runlevel.
4552 For example, if we are changing from runlevel 2 to
4553 runlevel 3, init will first execute all of the <tt>K</tt>
4554 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4555 all of the <tt>S</tt> prefixed scripts in that directory.
4556 The links starting with <tt>K</tt> will cause the
4557 referred-to file to be executed with an argument of
4558 <tt>stop</tt>, and the <tt>S</tt> links with an argument
4563 The two-digit number <var>mm</var> is used to determine
4564 the order in which to run the scripts: low-numbered links
4565 have their scripts run first. For example, the
4566 <tt>K20</tt> scripts will be executed before the
4567 <tt>K30</tt> scripts. This is used when a certain service
4568 must be started before another. For example, the name
4569 server <prgn>bind</prgn> might need to be started before
4570 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4571 can set up its access lists. In this case, the script
4572 that starts <prgn>bind</prgn> would have a lower number
4573 than the script that starts <prgn>inn</prgn> so that it
4575 <example compact="compact">
4582 The two runlevels 0 (halt) and 6 (reboot) are slightly
4583 different. In these runlevels, the links with an
4584 <tt>S</tt> prefix are still called after those with a
4585 <tt>K</tt> prefix, but they too are called with the single
4586 argument <tt>stop</tt>.
4590 Also, if the script name ends <tt>.sh</tt>, the script
4591 will be sourced in runlevel <tt>S</tt> rather that being
4592 run in a forked subprocess, but will be explicitly run by
4593 <prgn>sh</prgn> in all other runlevels.
4598 <heading>Writing the scripts</heading>
4601 Packages that include daemons for system services should
4602 place scripts in <file>/etc/init.d</file> to start or stop
4603 services at boot time or during a change of runlevel.
4604 These scripts should be named
4605 <file>/etc/init.d/<var>package</var></file>, and they should
4606 accept one argument, saying what to do:
4609 <tag><tt>start</tt></tag>
4610 <item><p>start the service,</p></item>
4612 <tag><tt>stop</tt></tag>
4613 <item><p>stop the service,</p></item>
4615 <tag><tt>restart</tt></tag>
4616 <item><p>stop and restart the service,</p></item>
4618 <tag><tt>reload</tt></tag>
4619 <item><p>cause the configuration of the service to be
4620 reloaded without actually stopping and restarting
4621 the service,</p></item>
4623 <tag><tt>force-reload</tt></tag>
4624 <item><p>cause the configuration to be reloaded if the
4625 service supports this, otherwise restart the
4629 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4630 <tt>force-reload</tt> options should be supported by all
4631 scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4632 option is optional.</p>
4635 The <file>init.d</file> scripts should ensure that they will
4636 behave sensibly if invoked with <tt>start</tt> when the
4637 service is already running, or with <tt>stop</tt> when it
4638 isn't, and that they don't kill unfortunately-named user
4639 processes. The best way to achieve this is usually to use
4640 <prgn>start-stop-daemon</prgn>.</p>
4643 If a service reloads its configuration automatically (as
4644 in the case of <prgn>cron</prgn>, for example), the
4645 <tt>reload</tt> option of the <file>init.d</file> script
4646 should behave as if the configuration has been reloaded
4650 The <file>/etc/init.d</file> scripts must be treated as
4651 configuration files, either (if they are present in the
4652 package, that is, in the .deb file) by marking them as
4653 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4654 by managing them correctly in the maintainer scripts (see
4655 <ref id="config-files">). This is important since we want
4656 to give the local system administrator the chance to adapt
4657 the scripts to the local system, e.g., to disable a
4658 service without de-installing the package, or to specify
4659 some special command line options when starting a service,
4660 while making sure her changes aren't lost during the next
4665 These scripts should not fail obscurely when the
4666 configuration files remain but the package has been
4667 removed, as configuration files remain on the system after
4668 the package has been removed. Only when <prgn>dpkg</prgn>
4669 is executed with the <tt>--purge</tt> option will
4670 configuration files be removed. In particular, as the
4671 <file>/etc/init.d/<var>package</var></file> script itself is
4672 usually a <tt>conffile</tt>, it will remain on the system
4673 if the package is removed but not purged. Therefore, you
4674 should include a <tt>test</tt> statement at the top of the
4676 <example compact="compact">
4677 test -f <var>program-executed-later-in-script</var> || exit 0
4682 Often there are some variables in the <file>init.d</file>
4683 scripts whose values control the behaviour of the scripts,
4684 and which a system administrator is likely to want to
4685 change. As the scripts themselves are frequently
4686 <tt>conffile</tt>s, modifying them requires that the
4687 administrator merge in their changes each time the package
4688 is upgraded and the <tt>conffile</tt> changes. To ease
4689 the burden on the system administrator, such configurable
4690 values should not be placed directly in the script.
4691 Instead, they should be placed in a file in
4692 <file>/etc/default</file>, which typically will have the same
4693 base name as the <file>init.d</file> script. This extra file
4694 should be sourced by the script when the script runs. It
4695 must contain only variable settings and comments in POSIX
4696 <prgn>sh</prgn> format. It may either be a
4697 <tt>conffile</tt> or a configuration file maintained by
4698 the package maintainer scripts. See <ref id="config-files">
4703 To ensure that vital configurable values are always
4704 available, the <file>init.d</file> script should set default
4705 values for each of the shell variables it uses, either
4706 before sourcing the <file>/etc/default/</file> file or
4707 afterwards using something like the <tt>:
4708 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
4709 script must behave sensibly and not fail if the
4710 <file>/etc/default</file> file is deleted.
4715 <heading>Interfacing with the initscript system</heading>
4718 Maintainers should use the abstraction layer provided by
4719 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4720 programs to deal with initscripts in their packages'
4721 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4722 and <prgn>postrm</prgn>.
4725 Directly managing the /etc/rc?.d links and directly
4726 invoking the <file>/etc/init.d/</file> initscripts should
4727 be done only by packages providing the initscript
4728 subsystem (such as <prgn>sysvinit</prgn> and
4729 <prgn>file-rc</prgn>).
4734 <heading>Managing the links</heading>
4737 The program <prgn>update-rc.d</prgn> is provided for
4738 package maintainers to arrange for the proper creation and
4739 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4740 or their functional equivalent if another method is being
4741 used. This may be used by maintainers in their packages'
4742 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4745 You must not include any <file>/etc/rc<var>n</var>.d</file>
4746 symbolic links in the actual archive or manually create or
4747 remove the symbolic links in maintainer scripts; you must
4748 use the <prgn>update-rc.d</prgn> program instead. (The
4749 former will fail if an alternative method of maintaining
4750 runlevel information is being used.) You must not include
4751 the <file>/etc/rc<var>n</var>.d</file> directories themselves
4752 in the archive either. (Only the <tt>sysvinit</tt>
4757 By default <prgn>update-rc.d</prgn> will start services in
4758 each of the multi-user state runlevels (2, 3, 4, and 5)
4759 and stop them in the halt runlevel (0), the single-user
4760 runlevel (1) and the reboot runlevel (6). The system
4761 administrator will have the opportunity to customize
4762 runlevels by simply adding, moving, or removing the
4763 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4764 symbolic links are being used, or by modifying
4765 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4770 To get the default behavior for your package, put in your
4771 <prgn>postinst</prgn> script
4772 <example compact="compact">
4773 update-rc.d <var>package</var> defaults
4775 and in your <prgn>postrm</prgn>
4776 <example compact="compact">
4777 if [ "$1" = purge ]; then
4778 update-rc.d <var>package</var> remove
4780 </example>. Note that is your package changes runlevels
4781 or priority, you may have to remove and recreate the
4782 links, since otherwise the old links may
4783 persist. Refer to the documentation of
4784 <prgn>update-rc.d</prgn></p>
4787 This will use a default sequence number of 20. If it does
4788 not matter when or in which order the <file>init.d</file>
4789 script is run, use this default. If it does, then you
4790 should talk to the maintainer of the <prgn>sysvinit</prgn>
4791 package or post to <tt>debian-devel</tt>, and they will
4792 help you choose a number.
4796 For more information about using <tt>update-rc.d</tt>,
4797 please consult its manpage <manref name="update-rc.d"
4803 <heading>Running initscripts</heading>
4805 The program <prgn>invoke-rc.d</prgn> is provided to make
4806 it easier for package maintainers to properly invoke an
4807 initscript, obeying runlevel and other locally-defined
4808 constraints that might limit a package's right to start,
4809 stop and otherwise manage services. This program may be
4810 used by maintainers in their packages' scripts.
4813 The use of <prgn>invoke-rc.d</prgn> to invoke the
4814 <file>/etc/init.d/*</file> initscripts is strongly
4815 recommended<footnote>
4817 In the future, the use of invoke-rc.d to invoke
4818 initscripts shall be made mandatory. Maintainers are
4819 advised to switch to invoke-rc.d as soon as
4821 </footnote>, instead of calling them directly.
4825 By default, <prgn>invoke-rc.d</prgn> will pass any
4826 action requests (start, stop, reload, restart...) to the
4827 <file>/etc/init.d</file> script, filtering out requests
4828 to start or restart a service out of its intended
4832 Most packages will simply need to change:
4833 <example compact="compact">/etc/init.d/<package>
4834 <action></example> in their <prgn>postinst</prgn>
4835 and <prgn>prerm</prgn> scripts to:
4836 <example compact="compact">
4837 if [ -x /usr/sbin/invoke-rc.d ] ; then
4838 invoke-rc.d <var>package</var> <action>
4840 /etc/init.d/<var>package</var> <action>
4844 A package should register its initscript services using
4845 <prgn>update-rc.d</prgn> before it tries to invoke them
4846 using <prgn>invoke-rc.d</prgn>. Invocation of
4847 unregistered services may fail.
4850 For more information about using
4851 <prgn>invoke-rc.d</prgn>, please consult its manpage
4852 <manref name="invoke-rc.d" section="8">.
4859 <heading>Boot-time initialization</heading>
4862 There used to be another directory, <file>/etc/rc.boot</file>,
4863 which contained scripts which were run once per machine
4864 boot. This has been deprecated in favour of links from
4865 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
4866 described in <ref id="/etc/init.d">. Packages must not
4867 place files in <file>/etc/rc.boot</file>.</p>
4870 <heading>Example</heading>
4873 The <prgn>bind</prgn> DNS (nameserver) package wants to
4874 make sure that the nameserver is running in multiuser
4875 runlevels, and is properly shut down with the system. It
4876 puts a script in <file>/etc/init.d</file>, naming the script
4877 appropriately <tt>bind</tt>. As you can see, the script
4878 interprets the argument <tt>reload</tt> to send the
4879 nameserver a <tt>HUP</tt> signal (causing it to reload its
4880 configuration); this way the system administrator can say
4881 <file>/etc/init.d/bind reload</file> to reload the name
4882 server. The script has one configurable value, which can
4883 be used to pass parameters to the named program at
4884 startup; this value is read from
4885 <file>/etc/default/bind</file> (see below).
4889 <example compact="compact">
4892 # Original version by Robert Leslie
4893 # <rob@mars.org>, edited by iwj and cs
4895 test -x /usr/sbin/named || exit 0
4897 # Source defaults file.
4899 if [ -f /etc/default/bind ]; then
4906 echo -n "Starting domain name service: named"
4907 start-stop-daemon --start --quiet --exec /usr/sbin/named \
4912 echo -n "Stopping domain name service: named"
4913 start-stop-daemon --stop --quiet \
4914 --pidfile /var/run/named.pid --exec /usr/sbin/named
4918 echo -n "Restarting domain name service: named"
4919 start-stop-daemon --stop --quiet \
4920 --pidfile /var/run/named.pid --exec /usr/sbin/named
4921 start-stop-daemon --start --verbose --exec /usr/sbin/named \
4925 force-reload|reload)
4926 echo -n "Reloading configuration of domain name service: named"
4927 start-stop-daemon --stop --signal 1 --quiet \
4928 --pidfile /var/run/named.pid --exec /usr/sbin/named
4932 echo "Usage: /etc/init.d/bind " \
4933 " {start|stop|restart|reload|force-reload}" >&2
4943 Complementing the above init script is a configuration
4944 file <file>/etc/default/bind</file>, which contains
4945 configurable parameters used by the script. This would be
4946 created by the <prgn>postinst</prgn> script if it was not
4947 already present, and removed on purge by the
4948 <prgn>postrm</prgn> script.
4949 <example compact="compact">
4950 # Specified parameters to pass to named. See named(8).
4951 # You may uncomment the following line, and edit to taste.
4957 Another example on which you can base your
4958 <file>/etc/init.d</file> scripts is found in
4959 <file>/etc/init.d/skeleton</file>.
4963 If this package is happy with the default setup from
4964 <prgn>update-rc.d</prgn>, namely an ordering number of 20
4965 and having named running in all runlevels, it can say in
4966 its <prgn>postinst</prgn>:
4967 <example compact="compact">
4968 update-rc.d bind defaults >/dev/null
4970 And in its <prgn>postrm</prgn>, to remove the links when the
4972 <example compact="compact">
4973 if [ "$1" = purge ]; then
4974 update-rc.d bind remove >/dev/null
4982 <heading>Console messages from <file>init.d</file> scripts</heading>
4985 This section describes the formats to be used for messages
4986 written to standard output by the <file>/etc/init.d</file>
4987 scripts. The intent is to improve the consistency of
4988 Debian's startup and shutdown look and feel. For this
4989 reason, please look very carefully at the details. We want
4990 the messages to have the same format in terms of wording,
4991 spaces, punctuation and case of letters.
4995 Here is a list of overall rules that you should use when you
4996 create output messages. They can be useful if you have a
4997 non-standard message that is not covered specifically in the
5005 Every message should fit in one line (fewer than 80
5006 characters), start with a capital letter and end with
5007 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5013 If you want to express that the computer is working on
5014 something (that is, performing a specific task, not
5015 starting or stopping a program), we use an "ellipsis"
5016 (three dots: <tt>...</tt>). Note that we don't insert
5017 spaces before or after the dots. If the task has been
5018 completed we write <tt>done.</tt> and a line feed.
5024 Design your messages as if the computer is telling you
5025 what he is doing (let him be polite :-), but don't
5026 mention "him" directly. For example, if you think of
5028 <example compact="compact">
5029 I'm starting network daemons: nfsd mountd.
5032 <example compact="compact">
5033 Starting network daemons: nfsd mountd.
5041 There are standard message formats for the following
5042 situations. They should be used by the <tt>init.d</tt>
5049 <p>When daemons are started</p>
5052 If your script starts one or more daemons, the output
5053 should look like this (a single line, no leading
5055 <example compact="compact">
5056 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5058 The <var>description</var> should describe the
5059 subsystem the daemon or set of daemons are part of,
5060 while <var>daemon-1</var> up to <var>daemon-n</var>
5061 denote each daemon's name (typically the file name of
5066 For example, the output of <file>/etc/init.d/lpd</file>
5068 <example compact="compact">
5069 Starting printer spooler: lpd.
5074 This can be achieved by saying
5075 <example compact="compact">
5076 echo -n "Starting printer spooler: lpd"
5077 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5080 in the script. If you have more than one daemon to
5081 start, you should do the following:
5082 <example compact="compact">
5083 echo -n "Starting remote file system services:"
5084 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5085 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5086 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5089 This makes it possible for the user to see what takes
5090 so long and when the final daemon has been started.
5091 You should be careful where to put spaces: in the
5092 example above the system administrator can easily
5093 comment out a line if he don't wants to start a
5094 specific daemon, while the displayed message still
5100 <p>When a system parameter is being set</p>
5103 If you have to set up different system parameters
5104 during the system boot, you should use this format:
5105 <example compact="compact">
5106 Setting <var>parameter</var> to `<var>value</var>'.
5111 You can use a statement such as the following to get
5113 <example compact="compact">
5114 echo "Setting DNS domainname to \`$domainname'."
5119 Note that the left quotation mark (<tt>`</tt>) is
5120 different from the right one (<tt>'</tt>).
5125 <p>When a daemon is stopped or restarted</p>
5128 When you stop or restart a daemon, you should issue a
5129 message identical to the startup message, except that
5130 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5131 or <tt>Restarting</tt> respectively.
5135 For example, stopping the printer daemon will like
5137 <example compact="compact">
5138 Stopping printer spooler: lpd.
5144 <p>When something is executed</p>
5147 There are several examples where you have to run a
5148 program at system startup or shutdown to perform a
5149 specific task, for example, setting the system's clock
5150 using <prgn>netdate</prgn> or killing all processes
5151 when the system shuts down. Your message should look
5153 <example compact="compact">
5154 Doing something very useful...done.
5156 You should print the <tt>done.</tt> immediately after
5157 the job has been completed, so that the user is
5158 informed why she has to wait. You can get this
5160 <example compact="compact">
5161 echo -n "Doing something very useful..."
5170 <p>When the configuration is reloaded</p>
5173 When a daemon is forced to reload its configuration
5174 files you should use the following format:
5175 <example compact="compact">
5176 Reloading <var>description</var> configuration...done.
5178 where <var>description</var> is the same as in the
5179 daemon starting message.
5187 <heading>Cron jobs</heading>
5190 Packages must not modify the configuration file
5191 <file>/etc/crontab</file>, and they must not modify the files in
5192 <file>/var/spool/cron/crontabs</file>.</p>
5195 If a package wants to install a job that has to be executed
5196 via cron, it should place a file with the name of the
5197 package in one or more of the following directories:
5198 <example compact="compact">
5203 As these directory names imply, the files within them are
5204 executed on a daily, weekly, or monthly basis,
5205 respectively. The exact times are listed in
5206 <file>/etc/crontab</file>.</p>
5209 All files installed in any of these directories must be
5210 scripts (e.g., shell scripts or Perl scripts) so that they
5211 can easily be modified by the local system administrator.
5212 In addition, they should be treated as configuration
5217 If a certain job has to be executed more frequently than
5218 daily, the package should install a file
5219 <file>/etc/cron.d/<var>package</var></file>. This file uses the
5220 same syntax as <file>/etc/crontab</file> and is processed by
5221 <prgn>cron</prgn> automatically. The file must also be
5222 treated as a configuration file. (Note that entries in the
5223 <file>/etc/cron.d</file> directory are not handled by
5224 <prgn>anacron</prgn>. Thus, you should only use this
5225 directory for jobs which may be skipped if the system is not
5229 The scripts or crontab entries in these directories should
5230 check if all necessary programs are installed before they
5231 try to execute them. Otherwise, problems will arise when a
5232 package was removed but not purged since configuration files
5233 are kept on the system in this situation.</p>
5237 <heading>Menus</heading>
5240 Menu entries should follow the current menu policy found in
5241 the <tt>menu-policy</tt> files in the <tt>debian-policy</tt>
5242 package. It may also be found on the Debian FTP site
5243 <ftpsite>ftp.debian.org</ftpsite> as the file
5244 <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>,
5245 or in the equivalent location on your local mirror.
5249 The Debian <tt>menu</tt> package provides a standard
5250 interface between packages providing applications and
5251 documents, and <em>menu programs</em> (either X window
5252 managers or text-based menu programs such as
5253 <prgn>pdmenu</prgn>).
5257 All packages that provide applications that need not be
5258 passed any special command line arguments for normal
5259 operation should register a menu entry for those
5260 applications, so that users of the <tt>menu</tt> package
5261 will automatically get menu entries in their window
5262 managers, as well in shells like <tt>pdmenu</tt>.</p>
5265 Please also refer to the <em>Debian Menu System</em>
5266 documentation that comes with the <tt>menu</tt> package for
5267 information about how to register your applications and web
5273 <heading>Multimedia handlers</heading>
5276 Packages which provide the ability to view/show/play,
5277 compose, edit or print MIME types should register themselves
5278 as such following the current MIME support policy found in
5279 the <tt>mime-policy</tt> files in the <tt>debian-policy</tt>
5280 package. It may also be found on the Debian FTP site
5281 <ftpsite>ftp.debian.org</ftpsite> as the file
5282 <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>,
5283 or in the equivalent location on your local mirror.
5287 MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5288 is a mechanism for encoding files and data streams and
5289 providing meta-information about them, in particular their
5290 type (e.g. audio or video) and format (e.g. PNG, HTML,
5295 Registration of MIME type handlers allows programs like mail
5296 user agents and web browsers to to invoke these handlers to
5297 view, edit or display MIME types they don't support
5303 <heading>Keyboard configuration</heading>
5306 To achieve a consistent keyboard configuration so that all
5307 applications interpret a keyboard event the same way, all
5308 programs in the Debian distribution must be configured to
5309 comply with the following guidelines.
5313 The following keys must have the specified interpretations:
5316 <tag><tt><--</tt></tag>
5317 <item><p>delete the character to the left of the cursor</p></item>
5319 <tag><tt>Delete</tt></tag>
5320 <item><p>delete the character to the right of the cursor</p></item>
5322 <tag><tt>Control+H</tt></tag>
5323 <item><p>emacs: the help prefix</p></item>
5326 The interpretation of any keyboard events should be
5327 independent of the terminal that is used, be it a virtual
5328 console, an X terminal emulator, an rlogin/telnet session,
5333 The following list explains how the different programs
5334 should be set up to achieve this:
5339 <item><p><tt><--</tt> generates <tt>KB_BackSpace</tt>
5342 <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5347 X translations are set up to make
5348 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5349 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5350 is the vt220 escape code for the `delete character'
5351 key). This must be done by loading the X resources
5352 using <prgn>xrdb</prgn> on all local X displays, not
5353 using the application defaults, so that the
5354 translation resources used correspond to the
5355 <prgn>xmodmap</prgn> settings.</p></item>
5359 The Linux console is configured to make
5360 <tt><--</tt> generate DEL, and <tt>Delete</tt>
5361 generate <tt>ESC [ 3 ~</tt>.</p></item>
5365 X applications are configured so that <tt><</tt>
5366 deletes left, and <tt>Delete</tt> deletes right. Motif
5367 applications already work like this.</p></item>
5369 <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5373 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5374 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5375 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5379 Emacs is programmed to map <tt>KB_Backspace</tt> or
5380 the <tt>stty erase</tt> character to
5381 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5382 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5383 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5387 Other applications use the <tt>stty erase</tt>
5388 character and <tt>kdch1</tt> for the two delete keys,
5389 with ASCII DEL being `delete previous character' and
5390 <tt>kdch1</tt> being `delete character under
5397 This will solve the problem except for the following
5405 Some terminals have a <tt><--</tt> key that cannot
5406 be made to produce anything except <tt>^H</tt>. On
5407 these terminals Emacs help will be unavailable on
5408 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5409 character takes precedence in Emacs, and has been set
5410 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
5411 available) can be used instead.</p></item>
5415 Some operating systems use <tt>^H</tt> for <tt>stty
5416 erase</tt>. However, modern telnet versions and all
5417 rlogin versions propagate <tt>stty</tt> settings, and
5418 almost all UNIX versions honour <tt>stty erase</tt>.
5419 Where the <tt>stty</tt> settings are not propagated
5420 correctly, things can be made to work by using
5421 <tt>stty</tt> manually.</p></item>
5425 Some systems (including previous Debian versions) use
5426 <prgn>xmodmap</prgn> to arrange for both
5427 <tt><--</tt> and <tt>Delete</tt> to generate
5428 <tt>KB_Delete</tt>. We can change the behavior of
5429 their X clients using the same X resources that we use
5430 to do it for our own clients, or configure our clients
5431 using their resources when things are the other way
5432 around. On displays configured like this
5433 <tt>Delete</tt> will not work, but <tt><--</tt>
5438 Some operating systems have different <tt>kdch1</tt>
5439 settings in their <tt>terminfo</tt> database for
5440 <tt>xterm</tt> and others. On these systems the
5441 <tt>Delete</tt> key will not work correctly when you
5442 log in from a system conforming to our policy, but
5443 <tt><--</tt> will.</p></item>
5449 <heading>Environment variables</heading>
5452 A program must not depend on environment variables to get
5453 reasonable defaults. (That's because these environment
5454 variables would have to be set in a system-wide
5455 configuration file like <file>/etc/profile</file>, which is not
5456 supported by all shells.)</p>
5459 If a program usually depends on environment variables for its
5460 configuration, the program should be changed to fall back to
5461 a reasonable default configuration if these environment
5462 variables are not present. If this cannot be done easily
5463 (e.g., if the source code of a non-free program is not
5464 available), the program must be replaced by a small
5465 `wrapper' shell script which sets the environment variables
5466 if they are not already defined, and calls the original program.</p>
5469 Here is an example of a wrapper script for this purpose:
5471 <example compact="compact">
5473 BAR=${BAR:-/var/lib/fubar}
5475 exec /usr/lib/foo/foo "$@"
5480 Furthermore, as <file>/etc/profile</file> is a configuration
5481 file of the <prgn>base-files</prgn> package, other packages must not
5482 put any environment variables or other commands into that
5488 <heading>Files</heading>
5491 <heading>Binaries</heading>
5494 Two different packages must not install programs with
5495 different functionality but with the same filenames. (The
5496 case of two programs having the same functionality but
5497 different implementations is handled via `alternatives' or
5498 the `Conflicts' mechanism. See <ref id="maintscripts"> and
5499 <ref id="conflicts"> respectively.) If this case happens,
5500 one of the programs must be renamed. The maintainers should
5501 report this to the <tt>debian-devel</tt> mailing list and
5502 try to find a consensus about which program will have to be
5503 renamed. If a consensus cannot be reached, <em>both</em>
5504 programs must be renamed.
5508 By default, when a package is being built, any binaries
5509 created should include debugging information, as well as
5510 being compiled with optimization. You should also turn on
5511 as many reasonable compilation warnings as possible; this
5512 makes life easier for porters, who can then look at build
5513 logs for possible problems. For the C programming language,
5514 this means the following compilation parameters should be
5516 <example compact="compact">
5518 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5520 install -s # (or use strip on the files in debian/tmp)
5525 Note that by default all installed binaries should be stripped,
5526 either by using the <tt>-s</tt> flag to
5527 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5528 the binaries after they have been copied into
5529 <file>debian/tmp</file> but before the tree is made into a
5533 Although binaries in the build tree should be compiled with
5534 debugging information by default, it can often be difficult
5535 to debug programs if they are also subjected to compiler
5536 optimization. For this reason, it is recommended to support
5537 the standardized environment
5538 variable <tt>DEB_BUILD_OPTIONS</tt>. This variable can
5539 contain several flags to change how a package is compiled
5547 The presence of this string means that the package
5548 should be complied with a minimum of optimization.
5549 For C programs, it is best to add <tt>-O0</tt>
5550 to <tt>CFLAGS</tt> (although this is usually the
5551 default). Some programs might fail to build or run at
5552 this level of optimization; it may be necessary to
5553 use <tt>-O1</tt>, for example.
5559 This string means that the debugging symbols should
5560 not be stripped from the binary during installation,
5561 so that debugging information may be included in the package.
5567 The following makefile snippet is an example of how one may
5568 implement the build options; you will probably have to
5569 massage this example in order to make it work for your
5571 <example compact="compact">
5574 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5575 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5576 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5577 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5579 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5584 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5585 INSTALL_PROGRAM += -s
5591 It is up to the package maintainer to decide what
5592 compilation options are best for the package. Certain
5593 binaries (such as computationally-intensive programs) will
5594 function better with certain flags (<tt>-O3</tt>, for
5595 example); feel free to use them. Please use good judgment
5596 here. Don't use flags for the sake of it; only use them
5597 if there is good reason to do so. Feel free to override
5598 the upstream author's ideas about which compilation
5599 options are best: they are often inappropriate for our
5606 <heading>Libraries</heading>
5608 In general, libraries must have a shared version in the
5609 library package and a static version in the development
5610 package. The shared version must be compiled with
5611 <tt>-fPIC</tt>, and the static version must not be. In
5612 other words, each source unit ( <tt>*.c</tt>, for example,
5613 for C files) will need to be compiled twice.
5616 In some cases, it is acceptable for a library to be
5617 available in static form only; these cases include:
5620 <p>libraries for languages whose shared library support
5621 is immature or unstable</p>
5625 libraries whose interfaces are in flux or under
5626 development (commonly the case when the library's
5627 major version number is zero, or where the ABI breaks
5633 libraries which are explicitly intended to be
5634 available only in static form by their upstream
5638 If a library is available only in static form, then it must follow
5639 the conventions for a development package.
5642 All libraries must have a shared version in the
5643 <tt>lib*</tt> package and a static version in the
5644 <tt>lib*-dev</tt> package. The shared version must be
5645 compiled with <tt>-fPIC</tt>, and the static version must
5646 not be. In other words, each <tt>*.c</tt> file will need to
5647 be compiled twice.</p>
5650 You must specify the gcc option <tt>-D_REENTRANT</tt>
5651 when building a library (either static or shared) to make
5652 the library compatible with LinuxThreads.</p>
5655 Note that all installed shared libraries should be
5657 <example compact="compact">
5658 strip --strip-unneeded <var>your-lib</var>
5660 (The option <tt>--strip-unneeded</tt> makes
5661 <prgn>strip</prgn> remove only the symbols which aren't
5662 needed for relocation processing.) Shared libraries can
5663 function perfectly well when stripped, since the symbols for
5664 dynamic linking are in a separate part of the ELF object
5667 You might also want to use the options
5668 <tt>--remove-section=.comment</tt> and
5669 <tt>--remove-section=.note</tt> on both shared libraries
5670 and executables, and <tt>--strip-debug</tt> on static
5677 Note that under some circumstances it may be useful to
5678 install a shared library unstripped, for example when
5679 building a separate package to support debugging.
5683 Shared object files (often <file>.so</file> files) that are not
5684 public libraries, that is, they are not meant to be linked
5685 to by third party executables (binaries of other packages),
5686 should be installed in subdirectories of the
5687 <file>/usr/lib</file> directory. Such files are exempt from the
5688 rules that govern ordinary shared libraries, except that
5689 they must not be installed executable and should be
5692 A common example are the so-called ``plug-ins'',
5693 internal shared objects that are dynamically loaded by
5694 programs using <manref name="dlopen" section="3">.
5700 Packages containing shared libraries that may be linked to
5701 by other packages' binaries, but which for some
5702 <em>compelling</em> reason can not be installed in
5703 <file>/usr/lib</file> directory, may install the shared library
5704 files in subdirectories of the <file>/usr/lib</file> directory,
5705 in which case they should arrange to add that directory in
5706 <file>/etc/ld.so.conf</file> in the package's post-installation
5707 script, and remove it in the package's post-removal script.
5711 An ever increasing number of packages are using
5712 <prgn>libtool</prgn> to do their linking. The latest GNU
5713 libtools (>= 1.3a) can take advantage of the metadata in the
5714 installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5715 files). The main advantage of <prgn>libtool</prgn>'s
5716 <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5717 store and subsequently access metadata with respect to the
5718 libraries it builds. <prgn>libtool</prgn> will search for
5719 those files, which contain a lot of useful information about
5720 a library (such as library dependency information for static
5721 linking). Also, they're <em>essential</em> for programs
5722 using <tt>libltdl</tt>.<footnote>
5724 Although <prgn>libtool</prgn> is fully capable of
5725 linking against shared libraries which don't have
5726 <tt>.la</tt> files, as it is a mere shell script it can
5727 add considerably to the build time of a
5728 <prgn>libtool</prgn>-using package if that shell script
5729 has to derive all this information from first principles
5730 for each library every time it is linked. With the
5731 advent of <prgn>libtool</prgn> version 1.4 (and to a
5732 lesser extent <prgn>libtool</prgn> version 1.3), the
5733 <file>.la</file> files also store information about
5734 inter-library dependencies which cannot necessarily be
5735 derived after the <file>.la</file> file is deleted.
5741 Packages that use <prgn>libtool</prgn> to create shared
5742 libraries should include the <file>.la</file> files in the
5743 <tt>-dev</tt> package, unless the package relies on
5744 <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5745 the <tt>.la</tt> files must go in the run-time library
5750 You must make sure that you use only released versions of
5751 shared libraries to build your packages; otherwise other
5752 users will not be able to run your binaries
5753 properly. Producing source packages that depend on
5754 unreleased compilers is also usually a bad
5760 <heading>Shared libraries</heading>
5763 Packages involving shared libraries should be split up
5764 into several binary packages.</p>
5767 For a straightforward library which has a development
5768 environment and a runtime kit including just shared
5769 libraries you need to create two packages:
5770 <file><var>libraryname</var><var>soversion</var></file>, where
5771 <file><var>soversion</var></file> is the version number in the
5772 soname of the shared library<footnote>
5774 The soname is the shared object name: it's the thing
5775 that has to match exactly between building an executable
5776 and running it for the dynamic linker to be able run the
5777 program. For example, if the soname of the library is
5778 <file>libfoo.so.6</file>, the library package would be
5779 called <file>libfoo6</file>.
5782 and <tt><var>libraryname</var><var>soversion</var>-dev</tt>.
5783 Alternatively, if it would be confusing to directly append
5784 <var>soversion</var> to <var>libraryname</var> (e.g. because
5785 <var>libraryname</var> itself ends in a number), you may use
5786 <tt><var>libraryname</var>-<var>soversion</var></tt> and
5787 <tt><var>libraryname</var>-<var>soversion</var>-dev</tt>
5792 If you prefer only to support one development version at a
5793 time you may name the development package
5794 <file><var>libraryname</var>-dev</file>; otherwise you may need
5795 to use <prgn>dpkg</prgn>'s Conflicts mechanism (see <ref
5796 id="conflicts">) to ensure that the user only installs one
5797 development version at a time (as different development
5798 versions are likely to have the same header files in them,
5799 which would cause a filename clash if both were installed).
5800 Typically the development version should also have an exact
5801 version dependency on the runtime library, to make sure that
5802 compilation and linking happens correctly. The
5803 <tt>${Source-Version}</tt> substitution variable can be
5804 useful for this purpose.
5808 Packages which use the shared library should have a
5809 dependency on the name of the shared library package,
5810 <file><var>libraryname</var><var>soversion</var></file>. When
5811 the soname changes you can have both versions of the library
5812 installed while migrating from the old library to the new.
5816 If your package has some run-time support programs which use
5817 the shared library you must not put them in the shared
5818 library package. If you do that then you won't be able to
5819 install several versions of the shared library without
5820 getting filename clashes. Instead, either create a third
5821 package for the runtime binaries (this package might
5822 typically be named <tt><var>libraryname</var>-runtime</tt>;
5823 note the absence of the <var>soversion</var> in the package
5824 name), or if the development package is small you may
5825 include them in there.
5829 If you have several shared libraries built from the same
5830 source tree you may lump them all together into a single
5831 shared library package, provided that you change all of
5832 their sonames at once (so that you don't get filename
5833 clashes if you try to install different versions of the
5834 combined shared libraries package).
5838 Shared libraries should not be installed executable, since
5839 the dynamic linker does not require this and trying to
5840 execute a shared library usually results in a core dump.
5845 <heading>Scripts</heading>
5848 All command scripts, including the package maintainer
5849 scripts inside the package and used by <prgn>dpkg</prgn>,
5850 should have a <tt>#!</tt> line naming the shell to be used
5851 to interpret them.</p>
5854 In the case of Perl scripts this should be
5855 <tt>#!/usr/bin/perl</tt>.</p>
5858 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5859 should almost certainly start with <tt>set -e</tt> so that
5860 errors are detected. Every script should use
5861 <tt>set -e</tt> or check the exit status of <em>every</em>
5865 The standard shell interpreter <file>/bin/sh</file> can be a
5866 symbolic link to any POSIX compatible shell, if <tt>echo
5867 -n</tt> does not generate a newline.<footnote>
5869 Debian policy specifies POSIX behavior for
5870 <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5871 use in the Linux community (in particular including this
5872 policy, the Linux kernel source, many Debian scripts,
5873 etc.). This <tt>echo -n</tt> mechanism is valid but not
5874 required under POSIX, hence this explicit addition.
5875 Also, rumour has it that this shall be mandated under
5879 Thus, shell scripts specifying <file>/bin/sh</file> as
5880 interpreter should only use POSIX features. If a script
5881 requires non-POSIX features from the shell interpreter, the
5882 appropriate shell must be specified in the first line of the
5883 script (e.g., <tt>#!/bin/bash</tt>) and the package must
5884 depend on the package providing the shell (unless the shell
5885 package is marked `Essential', as in the case of
5890 You may wish to restrict your script to POSIX features when
5891 possible so that it may use <file>/bin/sh</file> as its
5892 interpreter. If your script works with <prgn>dash</prgn>
5893 (originally called <prgn>ash</prgn>), it's probably POSIX
5894 compliant, but if you are in doubt, use
5895 <file>/bin/bash</file>.
5899 Perl scripts should check for errors when making any
5900 system calls, including <tt>open</tt>, <tt>print</tt>,
5901 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5905 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5906 scripting languages. See <em>Csh Programming Considered
5907 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5908 can be found at <url
5909 id="http://language.perl.com/versus/csh.whynot">.<footnote>
5911 It can also be found on
5912 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5913 or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5914 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5917 If an upstream package comes with <prgn>csh</prgn> scripts
5918 then you must make sure that they start with
5919 <tt>#!/bin/csh</tt> and make your package depend on the
5920 <prgn>c-shell</prgn> virtual package.
5924 Any scripts which create files in world-writeable
5925 directories (e.g., in <file>/tmp</file>) must use a
5926 mechanism which will fail if a file with the same name
5930 The Debian base system provides the <prgn>tempfile</prgn>
5931 and <prgn>mktemp</prgn> utilities for use by scripts for
5932 this purpose.</p></sect>
5936 <heading>Symbolic links</heading>
5939 In general, symbolic links within a top-level directory
5940 should be relative, and symbolic links pointing from one
5941 top-level directory into another should be absolute. (A
5942 top-level directory is a sub-directory of the root
5943 directory <file>/</file>.)</p>
5946 In addition, symbolic links should be specified as short as
5947 possible, i.e., link targets like <file>foo/../bar</file> are
5951 Note that when creating a relative link using
5952 <prgn>ln</prgn> it is not necessary for the target of the
5953 link to exist relative to the working directory you're
5954 running <prgn>ln</prgn> from, nor is it necessary to change
5955 directory to the directory where the link is to be made.
5956 Simply include the string that should appear as the target
5957 of the link (this will be a pathname relative to the
5958 directory in which the link resides) as the first argument
5959 to <prgn>ln</prgn>.</p>
5962 For example, in your <prgn>Makefile</prgn> or
5963 <file>debian/rules</file>, you can do things like:
5964 <example compact="compact">
5965 ln -fs gcc $(prefix)/bin/cc
5966 ln -fs gcc debian/tmp/usr/bin/cc
5967 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5968 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5972 A symbolic link pointing to a compressed file should always
5973 have the same file extension as the referenced file. (For
5974 example, if a file <file>foo.gz</file> is referenced by a
5975 symbolic link, the filename of the link has to end with
5976 `<file>.gz</file>' too, as in <file>bar.gz</file>.)
5981 <heading>Device files</heading>
5984 Packages must not include device files in the package file
5988 If a package needs any special device files that are not
5989 included in the base system, it must call
5990 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
5991 after notifying the user<footnote>
5993 This notification could be done via a (low-priority)
5994 debconf message, or an echo (printf) statement.
6000 Packages must not remove any device files in the
6001 <prgn>postrm</prgn> or any other script. This is left to the
6002 system administrator.</p>
6005 Debian uses the serial devices
6006 <file>/dev/ttyS*</file>. Programs using the old
6007 <file>/dev/cu*</file> devices should be changed to use
6008 <file>/dev/ttyS*</file>.</p>
6011 <sect id="config-files">
6012 <heading>Configuration files</heading>
6014 <heading>Definitions</heading>
6017 <tag>configuration file</tag>
6020 A file that affects the operation of a program, or
6021 provides site- or host-specific information, or
6022 otherwise customizes the behavior of a program.
6023 Typically, configuration files are intended to be
6024 modified by the system administrator (if needed or
6025 desired) to conform to local policy or to provide
6026 more useful site-specific behavior.
6030 <tag><tt>conffile</tt></tag>
6033 A file listed in a package's <tt>conffiles</tt>
6034 file, and is treated specially by <prgn>dpkg</prgn>
6035 (see <ref id="configdetails">).
6042 The distinction between these two is important; they are
6043 not interchangeable concepts. Almost all
6044 <tt>conffile</tt>s are configuration files, but many
6045 configuration files are not <tt>conffiles</tt>.
6049 Note that a script that embeds configuration information
6050 (such as most of the files in <file>/etc/default</file> and
6051 <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6052 configuration file and should be treated as such.
6057 <heading>Location</heading>
6059 Any configuration files created or used by your package
6060 must reside in <file>/etc</file>. If there are several you
6061 should consider creating a subdirectory of <file>/etc</file>
6062 named after your package.</p>
6065 If your package creates or uses configuration files
6066 outside of <file>/etc</file>, and it is not feasible to modify
6067 the package to use the <file>/etc</file>, you should still put
6068 the files in <file>/etc</file> and create symbolic links to
6069 those files from the location that the package
6074 <heading>Behavior</heading>
6076 Configuration file handling must conform to the following
6078 <list compact="compact">
6081 local changes must be preserved during a package
6087 configuration files must be preserved when the
6088 package is removed, and only deleted when the
6096 The easy way to achieve this behavior is to make the
6097 configuration file a <tt>conffile</tt>. This is
6098 appropriate only if it is possible to distribute a default
6099 version that will work for most installations, although
6100 some system administrators may choose to modify it. This
6101 implies that the default version will be part of the
6102 package distribution, and must not be modified by the
6103 maintainer scripts during installation (or at any other
6108 In order to ensure that local changes are preserved
6109 correctly, no package may contain or make hard links to
6110 conffiles.<footnote>
6112 Rationale: There are two problems with hard links.
6113 The first is that some editors break the link while
6114 editing one of the files, so that the two files may
6115 unwittingly become unlinked and different. The second
6116 is that <prgn>dpkg</prgn> might break the hard link
6117 while upgrading <tt>conffile</tt>s.
6123 The other way to do it is via the maintainer scripts. In
6124 this case, the configuration file must not be listed as a
6125 <tt>conffile</tt> and must not be part of the package
6126 distribution. If the existence of a file is required for
6127 the package to be sensibly configured it is the
6128 responsibility of the package maintainer to provide
6129 maintainer scripts which correctly create, update and
6130 maintain the file and remove it on purge. (See <ref
6131 id="maintainerscripts"> for more information.) These
6132 scripts must be idempotent (i.e., must work correctly if
6133 <prgn>dpkg</prgn> needs to re-run them due to errors
6134 during installation or removal), must cope with all the
6135 variety of ways <prgn>dpkg</prgn> can call maintainer
6136 scripts, must not overwrite or otherwise mangle the user's
6137 configuration without asking, must not ask unnecessary
6138 questions (particularly during upgrades), and otherwise be
6143 The scripts are not required to configure every possible
6144 option for the package, but only those necessary to get
6145 the package running on a given system. Ideally the
6146 sysadmin should not have to do any configuration other
6147 than that done (semi-)automatically by the
6148 <prgn>postinst</prgn> script.
6152 A common practice is to create a script called
6153 <file><var>package</var>-configure</file> and have the
6154 package's <prgn>postinst</prgn> call it if and only if the
6155 configuration file does not already exist. In certain
6156 cases it is useful for there to be an example or template
6157 file which the maintainer scripts use. Such files should
6158 be in <file>/usr/share/<var>package</var></file> or
6159 <file>/usr/lib/<var>package</var></file> (depending on whether
6160 they are architecture-independent or not). There should
6161 be symbolic links to them from
6162 <file>/usr/share/doc/<var>package</var>/examples</file> if
6163 they are examples, and should be perfectly ordinary
6164 <prgn>dpkg</prgn>-handled files (<em>not</em>
6165 configuration files).
6169 These two styles of configuration file handling must
6170 not be mixed, for that way lies madness:
6171 <prgn>dpkg</prgn> will ask about overwriting the file
6172 every time the package is upgraded.
6177 <heading>Sharing configuration files</heading>
6179 Packages which specify the same file as a
6180 <tt>conffile</tt> must be tagged as <em>conflicting</em>
6181 with each other. (This is an instance of the general rule
6182 about not sharing files. Note that neither alternatives
6183 nor diversions are likely to be appropriate in this case;
6184 in particular, <prgn>dpkg</prgn> does not handle diverted
6185 <tt>conffile</tt>s well.)
6189 The maintainer scripts must not alter a <tt>conffile</tt>
6190 of <em>any</em> package, including the one the scripts
6195 If two or more packages use the same configuration file
6196 and it is reasonable for both to be installed at the same
6197 time, one of these packages must be defined as
6198 <em>owner</em> of the configuration file, i.e., it will be
6199 the package which handles that file as a configuration
6200 file. Other packages that use the configuration file must
6201 depend on the owning package if they require the
6202 configuration file to operate. If the other package will
6203 use the configuration file if present, but is capable of
6204 operating without it, no dependency need be declared.</p>
6207 If it is desirable for two or more related packages to
6208 share a configuration file <em>and</em> for all of the
6209 related packages to be able to modify that configuration
6210 file, then the following should be done:
6211 <enumlist compact="compact">
6214 One of the related packages (the "owning" package)
6215 will manage the configuration file with maintainer
6216 scripts as described in the previous section.
6221 The owning package should also provide a program
6222 that the other packages may use to modify the
6228 The related packages must use the provided program
6229 to make any desired modifications to the
6230 configuration file. They should either depend on
6231 the core package to guarantee that the configuration
6232 modifier program is available or accept gracefully
6233 that they cannot modify the configuration file if it
6234 is not. (This is in addition to the fact that the
6235 configuration file may not even be present in the
6243 Sometimes it's appropriate to create a new package which
6244 provides the basic infrastructure for the other packages
6245 and which manages the shared configuration files. (The
6246 <tt>sgml-base</tt> package is a good example.)
6251 <heading>User configuration files ("dotfiles")</heading>
6254 The files in <file>/etc/skel</file> will automatically be
6255 copied into new user accounts by <prgn>adduser</prgn>.
6256 No other program should reference the files in
6257 <file>/etc/skel</file>.
6261 Therefore, if a program needs a dotfile to exist in
6262 advance in <file>$HOME</file> to work sensibly, that dotfile
6263 should be installed in <file>/etc/skel</file> and treated as a
6268 However, programs that require dotfiles in order to
6269 operate sensibly (dotfiles that they do not create
6270 themselves automatically, that is) are a bad thing.
6271 Furthermore, programs should be configured by the Debian
6272 default installation to behave as closely to the upstream
6273 default behaviour as possible.
6277 Therefore, if a program in a Debian package needs to be
6278 configured in some way in order to operate sensibly, that
6279 should be done using a site-wide configuration file placed
6280 in <file>/etc</file>. Only if the program doesn't support a
6281 site-wide default configuration and the package maintainer
6282 doesn't have time to add it may a default per-user file be
6283 placed in <file>/etc/skel</file>.
6287 <file>/etc/skel</file> should be as empty as we can make it.
6288 This is particularly true because there is no easy (or
6289 necessarily desirable) mechanism for ensuring that the
6290 appropriate dotfiles are copied into the accounts of
6291 existing users when a package is installed.
6297 <heading>Log files</heading>
6299 Log files should usually be named
6300 <file>/var/log/<var>package</var>.log</file>. If you have many
6301 log files, or need a separate directory for permission
6302 reasons (<file>/var/log</file> is writable only by
6303 <file>root</file>), you should usually create a directory named
6304 <file>/var/log/<var>package</var></file> and place your log
6309 Log files must be rotated occasionally so that they don't
6310 grow indefinitely; the best way to do this is to drop a log
6311 rotation configuration file into the directory
6312 <file>/etc/logrotate.d</file> and use the facilities provided by
6313 logrotate.<footnote>
6315 The traditional approach to log files has been to set up
6316 <em>ad hoc</em> log rotation schemes using simple shell
6317 scripts and cron. While this approach is highly
6318 customizable, it requires quite a lot of sysadmin work.
6319 Even though the original Debian system helped a little
6320 by automatically installing a system which can be used
6321 as a template, this was deemed not enough.
6325 The use of <prgn>logrotate</prgn>, a program developed
6326 by Red Hat, is better, as it centralizes log management.
6327 It has both a configuration file
6328 (<file>/etc/logrotate.conf</file>) and a directory where
6329 packages can drop their individual log rotation
6330 configurations (<file>/etc/logrotate.d</file>).
6333 Here is a good example for a logrotate config
6334 file (for more information see <manref name="logrotate"
6336 <example compact="compact">
6342 /etc/init.d/foo force-reload
6346 This rotates all files under <file>/var/log/foo</file>, saves 12
6347 compressed generations, and forces the daemon to reload its
6348 configuration information after the log rotation.
6352 Log files should be removed when the package is
6353 purged (but not when it is only removed). This should be
6354 done by the <prgn>postrm</prgn> script when it is called
6355 with the argument <tt>purge</tt> (see <ref
6356 id="removedetails">).
6361 <heading>Permissions and owners</heading>
6364 The rules in this section are guidelines for general use.
6365 If necessary you may deviate from the details below.
6366 However, if you do so you must make sure that what is done
6367 is secure and you should try to be as consistent as possible
6368 with the rest of the system. You should probably also
6369 discuss it on <prgn>debian-devel</prgn> first.
6373 Files should be owned by <tt>root.root</tt>, and made
6374 writable only by the owner and universally readable (and
6375 executable, if appropriate), that is mode 644 or 755.
6379 Directories should be mode 755 or (for group-writability)
6380 mode 2775. The ownership of the directory should be
6381 consistent with its mode: if a directory is mode 2775, it
6382 should be owned by the group that needs write access to
6387 Setuid and setgid executables should be mode 4755 or 2755
6388 respectively, and owned by the appropriate user or group.
6389 They should not be made unreadable (modes like 4711 or
6390 2711 or even 4111); doing so achieves no extra security,
6391 because anyone can find the binary in the freely available
6392 Debian package; it is merely inconvenient. For the same
6393 reason you should not restrict read or execute permissions
6394 on non-set-id executables.
6398 Some setuid programs need to be restricted to particular
6399 sets of users, using file permissions. In this case they
6400 should be owned by the uid to which they are set-id, and by
6401 the group which should be allowed to execute them. They
6402 should have mode 4754; again there is no point in making
6403 them unreadable to those users who must not be allowed to
6408 It is possible to arrange that the system administrator can
6409 reconfigure the package to correspond to their local
6410 security policy by changing the permissions on a binary:
6411 they can do this by using <prgn>dpkg-statoverride</prgn>, as
6412 described below.<footnote>
6414 Ordinary files installed by <prgn>dpkg</prgn> (as
6415 opposed to <tt>conffile</tt>s and other similar objects)
6416 normally have their permissions reset to the distributed
6417 permissions when the package is reinstalled. However,
6418 the use of <prgn>dpkg-statoverride</prgn> overrides this
6419 default behaviour. If you use this method, you should
6420 remember to describe <prgn>dpkg-statoverride</prgn> in
6421 the package documentation; being a relatively new
6422 addition to Debian, it is probably not yet well-known.
6425 Another method you should consider is to create a group for
6426 people allowed to use the program(s) and make any setuid
6427 executables executable only by that group.
6431 If you need to create a new user or group for your package
6432 there are two possibilities. Firstly, you may need to
6433 make some files in the binary package be owned by this
6434 user or group, or you may need to compile the user or
6435 group id (rather than just the name) into the binary
6436 (though this latter should be avoided if possible, as in
6437 this case you need a statically allocated id).</p>
6440 If you need a statically allocated id, you must ask for a
6441 user or group id from the <tt>base-passwd</tt> maintainer,
6442 and must not release the package until you have been
6443 allocated one. Once you have been allocated one you must
6444 either make the package depend on a version of the
6445 <tt>base-passwd</tt> package with the id present in
6446 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6447 your package to create the user or group itself with the
6448 correct id (using <tt>adduser</tt>) in its
6449 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
6450 the <prgn>postinst</prgn> is to be preferred if it is
6451 possible, otherwise a pre-dependency will be needed on the
6452 <tt>adduser</tt> package.)
6456 On the other hand, the program might be able to determine
6457 the uid or gid from the user or group name at runtime, so
6458 that a dynamically allocated id can be used. In this case
6459 you should choose an appropriate user or group name,
6460 discussing this on <prgn>debian-devel</prgn> and checking
6461 with the base system maintainer that it is unique and that
6462 they do not wish you to use a statically allocated id
6463 instead. When this has been checked you must arrange for
6464 your package to create the user or group if necessary using
6465 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6466 <prgn>postinst</prgn> script (again, the latter is to be
6467 preferred if it is possible).
6471 Note that changing the numeric value of an id associated
6472 with a name is very difficult, and involves searching the
6473 file system for all appropriate files. You need to think
6474 carefully whether a static or dynamic id is required, since
6475 changing your mind later will cause problems.
6478 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6480 This section is not intended as policy, but as a
6481 description of the use of <prgn>dpkg-statoverride</prgn>.
6485 <prgn>dpkg-statoverride</prgn> is a replacement for the
6486 deprecated <tt>suidmanager</tt> package. Packages which
6487 previously used <tt>suidmanager</tt> should have a
6488 <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6489 <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6490 and <tt>suidunregister</tt> should now be simply removed
6491 from the maintainer scripts.
6495 If a system administrator wishes to have a file (or
6496 directory or other such thing) installed with owner and
6497 permissions different from those in the distributed Debian
6498 package, he can use the <prgn>dpkg-statoverride</prgn>
6499 program to instruct <prgn>dpkg</prgn> to use the different
6500 settings every time the file is installed. Thus the
6501 package maintainer should distribute the files with their
6502 normal permissions, and leave it for the system
6503 administrator to make any desired changes. For example, a
6504 daemon which is normally required to be setuid root, but
6505 in certain situations could be used without being setuid,
6506 should be installed setuid in the <tt>.deb</tt>. Then the
6507 local system administrator can change this if they wish.
6508 If there are two standard ways of doing it, the package
6509 maintainer can use <tt>debconf</tt> to find out the
6510 preference, and call <prgn>dpkg-statoverride</prgn> in the
6511 maintainer script if necessary to accommodate the system
6512 administrator's choice.
6516 Given the above, <prgn>dpkg-statoverride</prgn> is
6517 essentially a tool for system administrators and would not
6518 normally be needed in the maintainer scripts. There is
6519 one type of situation, though, where calls to
6520 <prgn>dpkg-statoverride</prgn> would be needed in the
6521 maintainer scripts, and that involves packages which use
6522 dynamically allocated user or group ids. In such a
6523 situation, something like the following idiom can be very
6524 helpful in the package's <prgn>postinst</prgn>, where
6525 <tt>sysuser</tt> is a dynamically allocated id:
6527 for i in /usr/bin/foo /usr/sbin/bar
6529 if ! dpkg-statoverride --list $i >/dev/null
6531 dpkg-statoverride --update --add sysuser root 4755 $i
6535 The corresponding <tt>dpkg-statoverride --remove</tt>
6536 calls can then be made unconditionally when the package is
6543 <chapt id="customized-programs">
6544 <heading>Customized programs</heading>
6546 <sect id="arch-spec">
6547 <heading>Architecture specification strings</heading>
6550 If a program needs to specify an <em>architecture specification
6551 string</em> in some place, the following format should be
6552 used: <var>arch</var>-<var>os</var><footnote>
6554 The following architectures and operating systems are
6555 currently recognised by <prgn>dpkg-archictecture</prgn>.
6556 The architecture, <tt><var>arch</var></tt>, is one of
6557 the following: <tt>alpha</tt>, <tt>arm</tt>,
6558 <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6559 <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6560 <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6561 <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>. The
6562 operating system, <tt><var>os</var></tt>, is one of:
6563 <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6564 <tt>openbsd</tt>. Use of <tt>gnu</tt> in this string is
6565 reserved for the GNU/Hurd operating system.
6571 Note that we don't want to use
6572 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6573 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6574 since this would make our programs incompatible with other
6575 Linux distributions. We also don't use something like
6576 <tt><var>arch</var>-unknown-linux</tt>, since the
6577 <tt>unknown</tt> does not look very good.
6582 <heading>Daemons</heading>
6585 The configuration files <file>/etc/services</file>,
6586 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6587 by the <prgn>netbase</prgn> package and must not be modified
6592 If a package requires a new entry in one of these files, the
6593 maintainer should get in contact with the
6594 <prgn>netbase</prgn> maintainer, who will add the entries
6595 and release a new version of the <prgn>netbase</prgn>
6600 The configuration file <file>/etc/inetd.conf</file> must not be
6601 modified by the package's scripts except via the
6602 <prgn>update-inetd</prgn> script or the
6603 <file>DebianNet.pm</file> Perl module. See their documentation
6604 for details on how to add entries.
6608 If a package wants to install an example entry into
6609 <file>/etc/inetd.conf</file>, the entry must be preceded with
6610 exactly one hash character (<tt>#</tt>). Such lines are
6611 treated as `commented out by user' by the
6612 <prgn>update-inetd</prgn> script and are not changed or
6613 activated during package updates.
6618 <heading>Using pseudo-ttys and modifying wtmp, utmp and
6622 Some programs need to create pseudo-ttys. This should be done
6623 using Unix98 ptys if the C library supports it. The resulting
6624 program must not be installed setuid root, unless that
6625 is required for other functionality.
6629 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6630 <file>/var/log/lastlog</file> must be installed writeable by
6631 group <tt>utmp</tt>. Programs which need to modify those
6632 files must be installed setgid <tt>utmp</tt>.
6637 <heading>Editors and pagers</heading>
6640 Some programs have the ability to launch an editor or pager
6641 program to edit or display a text document. Since there are
6642 lots of different editors and pagers available in the Debian
6643 distribution, the system administrator and each user should
6644 have the possibility to choose his/her preferred editor and
6649 In addition, every program should choose a good default
6650 editor/pager if none is selected by the user or system
6655 Thus, every program that launches an editor or pager must
6656 use the EDITOR or PAGER environment variable to determine
6657 the editor or pager the user wishes to use. If these
6658 variables are not set, the programs <file>/usr/bin/editor</file>
6659 and <file>/usr/bin/pager</file> should be used, respectively.
6663 These two files are managed through the <prgn>dpkg</prgn>
6664 `alternatives' mechanism. Thus every package providing an
6665 editor or pager must call the
6666 <prgn>update-alternatives</prgn> script to register these
6671 If it is very hard to adapt a program to make use of the
6672 EDITOR or PAGER variables, that program may be configured to
6673 use <file>/usr/bin/sensible-editor</file> and
6674 <file>/usr/bin/sensible-pager</file> as the editor or pager
6675 program respectively. These are two scripts provided in the
6676 Debian base system that check the EDITOR and PAGER variables
6677 and launch the appropriate program, and fall back to
6678 <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6679 variable is not set.
6683 A program may also use the VISUAL environment variable to
6684 determine the user's choice of editor. If it exists, it
6685 should take precedence over EDITOR. This is in fact what
6686 <file>/usr/bin/sensible-editor</file> does.
6690 It is not required for a package to depend on
6691 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6692 package to provide such virtual packages.<footnote>
6694 The Debian base system already provides an editor and a
6701 <sect id="web-appl">
6702 <heading>Web servers and applications</heading>
6705 This section describes the locations and URLs that should
6706 be used by all web servers and web applications in the
6714 Cgi-bin executable files are installed in the
6716 <example compact="compact">
6717 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6719 and should be referred to as
6720 <example compact="compact">
6721 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6726 <item><p>Access to HTML documents</p>
6729 HTML documents for a package are stored in
6730 <file>/usr/share/doc/<var>package</var></file>
6731 and can be referred to as
6732 <example compact="compact">
6733 http://localhost/doc/<var>package</var>/<var>filename</var>
6737 The web server should restrict access to the document
6738 tree so that only clients on the same host can read
6739 the documents. If the web server does not support such
6740 access controls, then it should not provide access at
6741 all, or ask about providing access during installation.
6745 <item><p>Web Document Root</p>
6748 Web Applications should try to avoid storing files in
6749 the Web Document Root. Instead they should use the
6750 /usr/share/doc/<var>package</var> directory for
6751 documents and register the Web Application via the
6752 menu package. If access to the web document root is
6753 unavoidable then use
6754 <example compact="compact">
6757 as the Document Root. This might be just a symbolic
6758 link to the location where the system administrator
6759 has put the real document root.
6763 </enumlist></p></sect>
6766 <sect id="mail-transport-agents">
6767 <heading>Mail transport, delivery and user agents</heading>
6770 Debian packages which process electronic mail, whether mail
6771 user agents (MUAs) or mail transport agents (MTAs), must
6772 ensure that they are compatible with the configuration
6773 decisions below. Failure to do this may result in lost
6774 mail, broken <tt>From:</tt> lines, and other serious brain
6779 The mail spool is <file>/var/mail</file> and the interface to
6780 send a mail message is <file>/usr/sbin/sendmail</file> (as per
6781 the FHS). On older systems, the mail spool may be
6782 physically located in <file>/var/spool/mail</file>, but all
6783 access to the mail spool should be via the
6784 <file>/var/mail</file> symlink. The mail spool is part of the
6785 base system and not part of the MTA package.
6789 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6790 programs (such as IMAP daemons) must lock the mailbox in an
6791 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6792 be combined with dot locking. To avoid deadlocks, a program
6793 should use <tt>fcntl()</tt> first and dot locking after
6794 this, or alternatively implement the two locking methods in
6795 a non blocking way<footnote>
6797 If it is not possible to establish both locks, the
6798 system shouldn't wait for the second lock to be
6799 established, but remove the first lock, wait a (random)
6800 time, and start over locking again.
6802 </footnote>. Using the functions <tt>maillock</tt> and
6803 <tt>mailunlock</tt> provided by the
6804 <tt>liblockfile*</tt><footnote>
6806 You will need to depend on <tt>liblockfile1
6807 (>>1.01)</tt> to use these functions.
6809 </footnote> packages is the recommended way to realize this.
6813 Mailboxes are generally mode 660
6814 <tt><var>user</var>.mail</tt> unless the system
6815 administrator has chosen otherwise. A MUA may remove a
6816 mailbox (unless it has nonstandard permissions) in which
6817 case the MTA or another MUA must recreate it if needed.
6818 Mailboxes must be writable by group mail.
6822 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6823 be setgid mail to do the locking mentioned above (and
6824 must obviously avoid accessing other users' mailboxes
6825 using this privilege).</p>
6828 <file>/etc/aliases</file> is the source file for the system mail
6829 aliases (e.g., postmaster, usenet, etc.), it is the one
6830 which the sysadmin and <prgn>postinst</prgn> scripts may
6831 edit. After <file>/etc/aliases</file> is edited the program or
6832 human editing it must call <prgn>newaliases</prgn>. All MTA
6833 packages must come with a <prgn>newaliases</prgn> program,
6834 even if it does nothing, but older MTA packages did not do
6835 this so programs should not fail if <prgn>newaliases</prgn>
6836 cannot be found. Note that because of this, all MTA
6837 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6838 <tt>Replaces: mail-transport-agent</tt> control file
6843 The convention of writing <tt>forward to
6844 <var>address</var></tt> in the mailbox itself is not
6845 supported. Use a <tt>.forward</tt> file instead.</p>
6848 The <prgn>rmail</prgn> program used by UUCP
6849 for incoming mail should be <file>/usr/sbin/rmail</file>.
6850 Likewise, <prgn>rsmtp</prgn>, for receiving
6851 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6855 If your package needs to know what hostname to use on (for
6856 example) outgoing news and mail messages which are generated
6857 locally, you should use the file <file>/etc/mailname</file>. It
6858 will contain the portion after the username and <tt>@</tt>
6859 (at) sign for email addresses of users on the machine
6860 (followed by a newline).
6864 Such package should check for the existence of this file
6865 when it is being configured. If it exists, it should be
6866 used without comment, although an MTA's configuration script
6867 may wish to prompt the user even if it finds that this file
6868 exists. If the file does not exist, the package should
6869 prompt the user for the value (preferably using
6870 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6871 as well as using it in the package's configuration. The
6872 prompt should make it clear that the name will not just be
6873 used by that package. For example, in this situation the
6874 <tt>inn</tt> package could say something like:
6875 <example compact="compact">
6876 Please enter the `mail name' of your system. This is the
6877 hostname portion of the address to be shown on outgoing
6878 news and mail messages. The default is
6879 <var>syshostname</var>, your system's host name. Mail
6880 name [`<var>syshostname</var>']:
6882 where <var>syshostname</var> is the output of <tt>hostname
6888 <heading>News system configuration</heading>
6891 All the configuration files related to the NNTP (news)
6892 servers and clients should be located under
6893 <file>/etc/news</file>.</p>
6896 There are some configuration issues that apply to a number
6897 of news clients and server packages on the machine. These
6901 <tag><file>/etc/news/organization</file></tag>
6902 <item><p>A string which should appear as the
6903 organization header for all messages posted
6904 by NNTP clients on the machine</p></item>
6906 <tag><file>/etc/news/server</file></tag>
6907 <item><p>Contains the FQDN of the upstream NNTP
6908 server, or localhost if the local machine is
6909 an NNTP server.</p></item>
6912 Other global files may be added as required for cross-package news
6913 configuration.</p></sect>
6917 <heading>Programs for the X Window System</heading>
6920 <heading>Providing X support and package priorities</heading>
6923 Programs that can be configured with support for the X
6924 Window System must be configured to do so and must declare
6925 any package dependencies necessary to satisfy their
6926 runtime requirements when using the X Window System. If
6927 such a package is of higher priority than the X packages
6928 on which it depends, it is required that either the
6929 X-specific components be split into a separate package, or
6930 that an alternative version of the package, which includes
6931 X support, be provided, or that the package's priority be
6937 <heading>Packages providing an X server</heading>
6940 Packages that provide an X server that, directly or
6941 indirectly, communicates with real input and display
6942 hardware should declare in their control data that they
6943 provide the virtual package <tt>xserver</tt>.<footnote>
6945 This implements current practice, and provides an
6946 actual policy for usage of the <tt>xserver</tt>
6947 virtual package which appears in the virtual packages
6948 list. In a nutshell, X servers that interface
6949 directly with the display and input hardware or via
6950 another subsystem (e.g., GGI) should provide
6951 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
6952 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
6959 <heading>Packages providing a terminal emulator</heading>
6962 Packages that provide a terminal emulator for the X Window
6963 System which meet the criteria listed below should declare
6964 in their control data that they provide the virtual
6965 package <tt>x-terminal-emulator</tt>. They should also
6966 register themselves as an alternative for
6967 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
6972 To be an <tt>x-terminal-emulator</tt>, a program must:
6973 <list compact="compact">
6975 Be able to emulate a DEC VT100 terminal, or a
6976 compatible terminal.
6980 Support the command-line option <tt>-e
6981 <var>command</var></tt>, which creates a new
6982 terminal window<footnote>
6984 "New terminal window" does not necessarily mean
6985 a new top-level X window directly parented by
6986 the window manager; it could, if the terminal
6987 emulator application were so coded, be a new
6988 "view" in a multiple-document interface (MDI).
6991 and runs the specified <var>command</var>.
6995 Support the command-line option <tt>-T
6996 <var>title</var></tt>, which creates a new terminal
6997 window with the window title <var>title</var>.
7004 <heading>Packages providing a window manager</heading>
7007 Packages that provide a window manager should declare in
7008 their control data that they provide the virtual package
7009 <tt>x-window-manager</tt>. They should also register
7010 themselves as an alternative for
7011 <file>/usr/bin/x-window-manager</file>, with a priority
7012 calculated as follows:
7013 <list compact="compact">
7014 <item><p>Start with a priority of 20.</p></item>
7018 If the window manager supports the Debian menu
7019 system, add 20 points if this support is available
7020 in the package's default configuration (i.e., no
7021 configuration files belonging to the system or user
7022 have to be edited to activate the feature); if
7023 configuration files must be modified, add only 10
7029 If the window manager complies with <url
7030 id="http://www.freedesktop.org/standards/wm-spec.html"
7031 name="The Window Manager Specification Project">,
7032 written by the <url id="http://www.freedesktop.org"
7033 name="Free Desktop Group">, add 20 points.
7039 If the window manager permits the X session to be
7040 restarted using a <em>different</em> window manager
7041 (without killing the X server) in its default
7042 configuration, add 10 points; otherwise add none.
7050 <heading>Packages providing fonts</heading>
7053 Packages that provide fonts for the X Window
7056 For the purposes of Debian Policy, a "font for the X
7057 Window System" is one which is accessed via X protocol
7058 requests. Fonts for the Linux console, for PostScript
7059 renderers, or any other purpose, do not fit this
7060 definition. Any tool which makes such fonts available
7061 to the X Window System, however, must abide by this
7065 must do a number of things to ensure that they are both
7066 available without modification of the X or font server
7067 configuration, and that they do not corrupt files used by
7068 other font packages to register information about
7073 Fonts of any type supported by the X Window System
7074 must be in a separate binary package from any
7075 executables, libraries, or documentation (except
7076 that specific to the fonts shipped, such as their
7077 license information). If one or more of the fonts
7078 so packaged are necessary for proper operation of
7079 the package with which they are associated the font
7080 package may be Recommended; if the fonts merely
7081 provide an enhancement, a Suggests relationship may
7082 be used. Packages must not Depend on font
7085 This is because the X server may retrieve fonts
7086 from the local filesystem or over the network
7087 from an X font server; the Debian package system
7088 is empowered to deal only with the local
7097 BDF fonts must be converted to PCF fonts with the
7098 <prgn>bdftopcf</prgn> utility (available in the
7099 <tt>xutils</tt> package, <tt>gzip</tt>ped, and
7100 placed in a directory that corresponds to their
7102 <list compact="compact">
7104 100 dpi fonts must be placed in
7105 <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7109 75 dpi fonts must be placed in
7110 <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7114 Character-cell fonts, cursor fonts, and other
7115 low-resolution fonts must be placed in
7116 <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7123 Speedo fonts must be placed in
7124 <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7128 Type 1 fonts must be placed in
7129 <file>/usr/X11R6/lib/X11/fonts/Type1/</file>. If font
7130 metric files are available, they must be placed here
7136 Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7137 other than those listed above must be neither
7138 created nor used. (The <file>PEX</file>, <file>CID</file>,
7139 and <file>cyrillic</file> directories are excepted for
7140 historical reasons, but installation of files into
7141 these directories remains discouraged.)
7147 Font packages may, instead of placing files directly
7148 in the X font directories listed above, provide
7149 symbolic links in that font directory pointing to
7150 the files' actual location in the filesystem. Such
7151 a location must comply with the FHS.
7157 Font packages should not contain both 75dpi and
7158 100dpi versions of a font. If both are available,
7159 they should be provided in separate binary packages
7160 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7161 the names of the packages containing the
7162 corresponding fonts.
7168 Fonts destined for the <file>misc</file> subdirectory
7169 should not be included in the same package as 75dpi
7170 or 100dpi fonts; instead, they should be provided in
7171 a separate package with <tt>-misc</tt> appended to
7178 Font packages must not provide the files
7179 <file>fonts.dir</file>, <file>fonts.alias</file>, or
7180 <file>fonts.scale</file> in a font directory:
7183 <file>fonts.dir</file> files must not be provided at all.
7188 <file>fonts.alias</file> and <file>fonts.scale</file>
7189 files, if needed, should be provided in the
7191 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7192 where <var>fontdir</var> is the name of the
7194 <file>/usr/X11R6/lib/X11/fonts/</file> where the
7195 package's corresponding fonts are stored
7196 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7197 <var>package</var> is the name of the package
7198 that provides these fonts, and
7199 <var>extension</var> is either <tt>scale</tt>
7200 or <tt>alias</tt>, whichever corresponds to
7210 Font packages must declare a dependency on
7211 <tt>xutils (>> 4.0.3)</tt> in their control
7218 Font packages that provide one or more
7219 <file>fonts.scale</file> files as described above must
7220 invoke <prgn>update-fonts-scale</prgn> on each
7221 directory into which they installed fonts
7222 <em>before</em> invoking
7223 <prgn>update-fonts-dir</prgn> on that directory.
7224 This invocation must occur in both the
7225 <prgn>postinst</prgn> (for all arguments) and
7226 <prgn>postrm</prgn> (for all arguments except
7227 <tt>upgrade</tt>) scripts.
7233 Font packages that provide one or more
7234 <file>fonts.alias</file> files as described above must
7235 invoke <prgn>update-fonts-alias</prgn> on each
7236 directory into which they installed fonts. This
7237 invocation must occur in both the
7238 <prgn>postinst</prgn> (for all arguments) and
7239 <prgn>postrm</prgn> (for all arguments except
7240 <tt>upgrade</tt>) scripts.
7246 Font packages must invoke
7247 <prgn>update-fonts-dir</prgn> on each directory into
7248 which they installed fonts. This invocation must
7249 occur in both the <prgn>postinst</prgn> (for all
7250 arguments) and <prgn>postrm</prgn> (for all
7251 arguments except <tt>upgrade</tt>) scripts.
7257 Font packages must not provide alias names for the
7258 fonts they include which collide with alias names
7259 already in use by fonts already packaged.
7265 Font packages must not provide fonts with the same
7266 XLFD registry name as another font already packaged.
7274 <heading>Application defaults files</heading>
7277 Application defaults files must be installed in the
7278 directory <file>/etc/X11/app-defaults/</file> (use of a
7279 localized subdirectory of <file>/etc/X11/</file> as described
7280 in the <em>X Toolkit Intrinsics - C Language
7281 Interface</em> manual is also permitted). They must be
7282 registered as <tt>conffile</tt>s or handled as
7283 configuration files. Packages must not provide the
7284 directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7288 Customization of programs' X resources may also be
7289 supported with the provision of a file with the same name
7290 as that of the package placed in the
7291 <file>/etc/X11/Xresources/</file> directory, which must
7292 registered as a <tt>conffile</tt> or handled as a
7293 configuration file.<footnote>
7295 Note that this mechanism is not the same as using
7296 app-defaults; app-defaults are tied to the client
7297 binary on the local filesystem, whereas X resources
7298 are stored in the X server and affect all connecting
7302 <em>Important:</em> packages that install files into the
7303 <file>/etc/X11/Xresources/</file> directory must conflict with
7304 <tt>xbase (<< 3.3.2.3a-2)</tt>; if this is not done
7305 it is possible for the installing package to destroy a
7306 previously-existing <file>/etc/X11/Xresources</file> file
7307 which had been customized by the system administrator.
7312 <heading>Installation directory issues</heading>
7315 Packages using the X Window System should not be
7316 configured to install files under the <file>/usr/X11R6/</file>
7317 directory unless they use <prgn>imake</prgn>. The
7318 <file>/usr/X11R6/</file> directory hierarchy should be
7319 regarded as deprecated for all packages except the X
7320 Window System itself, and those which use the
7321 <prgn>imake</prgn> program it provides, in which case the
7322 packages may transition out of the <file>/usr/X11R6/</file>
7323 directory at the maintainer's discretion.<footnote>
7325 <prgn>Imake</prgn>-using programs are exempt because,
7326 as long as they are written correctly, the pathnames
7327 they use to locate resources and install themselves
7328 are derived wholly from the X Window System
7329 configuration. Thus, in the event that the X Window
7330 System moves to <file>/usr/X11R7/</file>,
7331 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7332 that is required for these programs is a recompile
7333 against the corresponding X Window System library
7334 development packages.
7337 Programs that use GNU <prgn>autoconf</prgn> and
7338 <prgn>automake</prgn> are usually easily configured at
7339 compile time to use <file>/usr/</file> instead of
7340 <file>/usr/X11R6/</file>, and this should be done whenever
7341 possible. Configuration files for window managers and
7342 display managers should be placed in a subdirectory of
7343 <file>/etc/X11/</file> corresponding to the package name due
7344 to these programs' tight integration with the mechanisms
7345 of the X Window System. Application-level programs should
7346 use the <file>/etc/</file> directory unless otherwise mandated
7347 by policy. The installation of files into subdirectories
7348 of <file>/usr/X11R6/include/X11/</file> and
7349 <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7350 package maintainers should determine if subdirectories of
7351 <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7352 instead. (The use of symbolic links from the
7353 <file>X11R6</file> directories to other FHS-compliant
7354 locations is encouraged if the program is not easily
7355 configured to look elsewhere for its files.) Packages
7356 must not provide or install files into the directories
7357 <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7358 <file>/usr/lib/X11/</file>. Files within a package should,
7359 however, make reference to these directories, rather than
7360 their <tt>X11R6</tt>-named counterparts
7361 <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7362 and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7363 referred to have not been moved to other FHS-compliant
7369 <heading>The OSF/Motif and OpenMotif libraries</heading>
7372 <em>Programs that require the non-DFSG-compliant OSF/Motif or
7373 OpenMotif libraries</em><footnote>
7375 OSF/Motif and OpenMotif are collectively referred to as
7376 "Motif" in this policy document.
7379 should be compiled against and tested with LessTif (a free
7380 re-implementation of Motif) instead. If the maintainer
7381 judges that the program or programs do not work
7382 sufficiently well with LessTif to be distributed and
7383 supported, but do so when compiled against Motif, then two
7384 versions of the package should be created; one linked
7385 statically against Motif and with <tt>-smotif</tt>
7386 appended to the package name, and one linked dynamically
7387 against Motif and with <tt>-dmotif</tt> appended to the
7388 package name. Both Motif-linked versions are dependent
7389 upon non-DFSG-compliant software and thus cannot be
7390 uploaded to the <em>main</em> distribution; if the
7391 software is itself DFSG-compliant it may be uploaded to
7392 the <em>contrib</em> distribution. While known existing
7393 versions of Motif permit unlimited redistribution of
7394 binaries linked against the library (whether statically or
7395 dynamically), it is the package maintainer's
7396 responsibility to determine whether this is permitted by
7397 the license of the copy of Motif in his or her possession.
7403 <heading>Perl programs and modules</heading>
7405 Perl programs and modules should follow the current Perl
7406 policy as defined in the file found on
7407 <ftpsite>ftp.debian.org</ftpsite> in
7408 <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>
7409 or your local mirror. In addition, it is included in the
7410 <tt>debian-policy</tt> package.
7415 <heading>Emacs lisp programs</heading>
7418 Please refer to the `Debian Emacs Policy' (documented in
7419 <file>debian-emacs-policy.gz</file> of the
7420 <prgn>emacsen-common</prgn> package) for details of how to
7421 package emacs lisp programs.
7426 <heading>Games</heading>
7429 The permissions on <file>/var/games</file> are mode 755, owner
7430 <tt>root</tt> and group <tt>root</tt>.
7434 Each game decides on its own security policy.</p>
7437 Games which require protected, privileged access to
7438 high-score files, savegames, etc., may be made
7439 set-<em>group</em>-id (mode 2755) and owned by
7440 <tt>root.games</tt>, and use files and directories with
7441 appropriate permissions (770 <tt>root.games</tt>, for
7442 example). They must not be made
7443 set-<em>user</em>-id, as this causes security problems. (If
7444 an attacker can subvert any set-user-id game they can
7445 overwrite the executable of any other, causing other players
7446 of these games to run a Trojan horse program. With a
7447 set-group-id game the attacker only gets access to less
7448 important game data, and if they can get at the other
7449 players' accounts at all it will take considerably more
7453 Some packages, for example some fortune cookie programs, are
7454 configured by the upstream authors to install with their
7455 data files or other static information made unreadable so
7456 that they can only be accessed through set-id programs
7457 provided. You should not do this in a Debian package: anyone can
7458 download the <file>.deb</file> file and read the data from it,
7459 so there is no point making the files unreadable. Not
7460 making the files unreadable also means that you don't have
7461 to make so many programs set-id, which reduces the risk of a
7465 As described in the FHS, binaries of games should be
7466 installed in the directory <file>/usr/games</file>. This also
7467 applies to games that use the X Window System. Manual pages
7468 for games (X and non-X games) should be installed in
7469 <file>/usr/share/man/man6</file>.</p>
7473 <chapt id="docs"><heading>Documentation</heading>
7477 <heading>Manual pages</heading>
7480 You should install manual pages in <prgn>nroff</prgn> source
7481 form, in appropriate places under <file>/usr/share/man</file>. You
7482 should only use sections 1 to 9 (see the FHS for more
7483 details). You must not install a preformatted `cat
7487 Each program, utility, and function should have an
7488 associated manpage included in the same package. It is
7489 suggested that all configuration files also have a manual
7490 page included as well.
7494 If no manual page is available for a particular program,
7495 utility, function or configuration file and this is reported
7496 as a bug to the Debian Bug Tracking System, a symbolic link
7497 from the requested manual page to the <manref
7498 name="undocumented" section="7"> manual page may be
7499 provided. This symbolic link can be created from
7500 <file>debian/rules</file> like this:
7501 <example compact="compact">
7502 ln -s ../man7/undocumented.7.gz \
7503 debian/tmp/usr/share/man/man[1-9]/<var>requested_manpage</var>.[1-9].gz
7505 This manpage claims that the lack of a manpage has been
7506 reported as a bug, so you may only do this if it really has
7507 (you can report it yourself, if you like). Do not close the
7508 bug report until a proper manpage is available.</p>
7511 You may forward a complaint about a missing manpage to the
7512 upstream authors, and mark the bug as forwarded in the
7513 Debian bug tracking system. Even though the GNU Project do
7514 not in general consider the lack of a manpage to be a bug,
7515 we do; if they tell you that they don't consider it a bug
7516 you should leave the bug in our bug tracking system open
7520 Manual pages should be installed compressed using <tt>gzip
7524 If one manpage needs to be accessible via several names it
7525 is better to use a symbolic link than the <file>.so</file>
7526 feature, but there is no need to fiddle with the relevant
7527 parts of the upstream source to change from <file>.so</file> to
7528 symlinks: don't do it unless it's easy. You should not
7529 create hard links in the manual page directories, nor put
7530 absolute filenames in <file>.so</file> directives. The filename
7531 in a <file>.so</file> in a manpage should be relative to the
7532 base of the manpage tree (usually
7533 <file>/usr/share/man</file>). If you do not create any links
7534 (whether symlinks, hard links, or <tt>.so</tt> directives)
7535 in the filesystem to the alternate names of the manpage,
7536 then you should not rely on <prgn>man</prgn> finding your
7537 manpage under those names based solely on the information in
7538 the manpage's header.<footnote>
7540 Supporting this in <prgn>man</prgn> often requires
7541 unreasonable processing time to find a manual page or to
7542 report that none exists, and moves knowledge into man's
7543 database that would be better left in the filesystem.
7544 This support is therefore deprecated and will cease to
7545 be present in the future.
7552 <heading>Info documents</heading>
7555 Info documents should be installed in <file>/usr/share/info</file>.
7556 They should be compressed with <tt>gzip -9</tt>.</p>
7559 Your package should call <prgn>install-info</prgn> to update
7560 the Info <file>dir</file> file in its <prgn>postinst</prgn>
7561 script when called with a <tt>configure</tt> argument, for
7563 <example compact="compact">
7564 install-info --quiet --section Development Development \
7565 /usr/share/info/foobar.info
7569 It is a good idea to specify a section for the location of
7570 your program; this is done with the <tt>--section</tt>
7571 switch. To determine which section to use, you should look
7572 at <file>/usr/share/info/dir</file> on your system and choose the most
7573 relevant (or create a new section if none of the current
7574 sections are relevant). Note that the <tt>--section</tt>
7575 flag takes two arguments; the first is a regular expression
7576 to match (case-insensitively) against an existing section,
7577 the second is used when creating a new one.</p>
7580 You should remove the entries in the <prgn>prerm</prgn>
7581 script when called with a <tt>remove</tt> argument:
7582 <example compact="compact">
7583 install-info --quiet --remove /usr/share/info/foobar.info
7587 If <prgn>install-info</prgn> cannot find a description entry
7588 in the Info file you must supply one. See <manref
7589 name="install-info" section="8"> for details.</p>
7593 <heading>Additional documentation</heading>
7596 Any additional documentation that comes with the package may
7597 be installed at the discretion of the package maintainer.
7598 Text documentation should be installed in the directory
7599 <file>/usr/share/doc/<var>package</var></file>, where
7600 <var>package</var> is the name of the package, and
7601 compressed with <tt>gzip -9</tt> unless it is small.</p>
7604 If a package comes with large amounts of documentation which
7605 many users of the package will not require you should create
7606 a separate binary package to contain it, so that it does not
7607 take up disk space on the machines of users who do not need
7608 or want it installed.</p>
7611 It is often a good idea to put text information files
7612 (<file>README</file>s, changelogs, and so forth) that come with
7613 the source package in <file>/usr/share/doc/<var>package</var></file>
7614 in the binary package. However, you don't need to install
7615 the instructions for building and installing the package, of
7619 Files in <file>/usr/share/doc</file> should not be referenced by
7620 any program, and the system administrator should be able to
7621 delete them without causing any programs to break. Any files
7622 that are referenced by programs but are also useful as
7623 standalone documentation should be installed under
7624 <file>/usr/share/<var>package</var>/</file> with symbolic links
7625 from <file>/usr/share/doc/<var>package</var>/</file>.
7631 <heading>Accessing the documentation</heading>
7634 Former Debian releases placed all additional documentation
7635 in <file>/usr/doc/<var>package</var></file>. This has now
7636 changed to <file>/usr/share/doc/<var>package</var></file>,
7637 and packages must not put documentation in the directory
7638 <file>/usr/doc/<var>package</var></file>. <footnote>
7639 <p>At this phase of the transition, we no longer require a
7640 symbolic link in <file>/usr/doc/</file>. At a later point,
7641 policy shall change to make the symbolic links a bug.</p>
7647 <heading>Preferred documentation formats</heading>
7650 The unification of Debian documentation is being carried out
7654 If your package comes with extensive documentation in a
7655 markup format that can be converted to various other formats
7656 you should if possible ship HTML versions in a binary
7657 package, in the directory
7658 <file>/usr/share/doc/<var>appropriate-package</var></file> or
7659 its subdirectories.<footnote>
7661 The rationale: The important thing here is that HTML
7662 docs should be available in <em>some</em> package, not
7663 necessarily in the main binary package.
7669 Other formats such as PostScript may be provided at the
7670 package maintainer's discretion.
7674 <sect id="copyrightfile">
7675 <heading>Copyright information</heading>
7678 Every package must be accompanied by a verbatim copy of its
7679 copyright and distribution license in the file
7680 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7681 file must neither be compressed nor be a symbolic link.
7685 In addition, the copyright file must say where the upstream
7686 sources (if any) were obtained, and should explain briefly what
7687 modifications were made in the Debian version of the package
7688 compared to the upstream one. It should name the original
7689 authors of the package and the Debian maintainer(s) who were
7690 involved with its creation.</p>
7693 A copy of the file which will be installed in
7694 <file>/usr/share/doc/<var>package</var>/copyright</file> should
7695 be in <file>debian/copyright</file> in the source package.
7699 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7700 link to another directory in <file>/usr/share/doc</file> only if
7701 the two packages both come from the same source and the
7702 first package Depends on the second. These rules are
7703 important because copyrights must be extractable by
7708 Packages distributed under the UCB BSD license, the Artistic
7709 license, the GNU GPL, and the GNU LGPL should refer to the
7710 files <file>/usr/share/common-licenses/BSD</file>,
7711 <file>/usr/share/common-licenses/Artistic</file>,
7712 <file>/usr/share/common-licenses/GPL</file>, and
7713 <file>/usr/share/common-licenses/LGPL</file> respectively,
7714 rather than quoting them in the copyright file.
7718 You should not use the copyright file as a general <file>README</file>
7719 file. If your package has such a file it should be
7720 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7721 <file>README.Debian</file> or some other appropriate place.</p>
7725 <heading>Examples</heading>
7728 Any examples (configurations, source files, whatever),
7729 should be installed in a directory
7730 <file>/usr/share/doc/<var>package</var>/examples</file>. These
7731 files should not be referenced by any program: they're there
7732 for the benefit of the system administrator and users as
7733 documentation only. Architecture-specific example files
7734 should be installed in a directory
7735 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7737 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7738 latter directory itself may be a symbolic link to the
7743 <sect id="instchangelog">
7744 <heading>Changelog files</heading>
7747 Packages that are not Debian-native must contain a
7748 compressed copy of the <file>debian/changelog</file> file from
7749 the Debian source tree in
7750 <file>/usr/share/doc/<var>package</var></file> with the name
7751 <file>changelog.Debian.gz</file>. If an upstream changelog is
7752 available, it should be accessible as
7753 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7754 plain text. If the upstream changelog is distributed in
7755 HTML, it should be made available in that form as
7756 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7757 and a plain text <file>changelog.gz</file> should be generated
7758 from it using, for example, <tt>lynx -dump -nolist</tt>. If
7759 the upstream changelog files do not already conform to this
7760 naming convention, then this may be achieved either by
7761 renaming the files, or by adding a symbolic link, at the
7762 maintainer's discretion.<footnote>
7764 Rationale: People should not have to look in places for
7765 upstream changelogs merely because they are given
7766 different names or are distributed in HTML format.
7772 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7773 link to another directory in <file>/usr/share/doc</file> only if
7774 the two packages both come from the same source and the
7775 first package Depends on the second.
7780 All of these files should be installed compressed using
7781 <tt>gzip -9</tt>, as they will become large with time even
7782 if they start out small.
7786 If the package has only one changelog which is used both as
7787 the Debian changelog and the upstream one because there is
7788 no separate upstream maintainer then that changelog should
7789 usually be installed as
7790 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7791 there is a separate upstream maintainer, but no upstream
7792 changelog, then the Debian changelog should still be called
7793 <file>changelog.Debian.gz</file>.</p>
7797 <appendix id="pkg-scope">
7798 <heading>Introduction and scope of these appendices</heading>
7801 These appendices are taken essentially verbatim from the
7802 now-deprecated Packaging Manual, version 3.2.1.0. They are
7803 the chapters which are likely to be of use to package
7804 maintainers and which have not already been included in the
7805 policy document itself. Most of these sections are very likely
7806 not relevant to policy; they should be treated as
7807 documentation for the packaging system. Please note that these
7808 appendices are included for convenience, and for historical
7809 reasons: they used to be part of policy package, and they have
7810 not yet been incorporated into dpkg documentation. However,
7811 they still have value, and hence they are presented here.
7814 They have not yet been checked to ensure that they are
7815 compatible with the contents of policy, and if there are any
7816 contradictions, the version in the main policy document takes
7817 precedence. The remaining chapters of the old Packaging
7818 Manual have also not been read in detail to ensure that there
7819 are not parts which have been left out. Both of these will be
7824 <prgn>dpkg</prgn> is a suite of programs for creating binary
7825 package files and installing and removing them on Unix
7828 <prgn>dpkg</prgn> is targetted primarily at Debian
7829 GNU/Linux, but may work on or be ported to other
7836 The binary packages are designed for the management of
7837 installed executable programs (usually compiled binaries) and
7838 their associated data, though source code examples and
7839 documentation are provided as part of some packages.</p>
7842 This manual describes the technical aspects of creating Debian
7843 binary packages (<file>.deb</file> files). It documents the
7844 behaviour of the package management programs
7845 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7846 they interact with packages.</p>
7849 It also documents the interaction between
7850 <prgn>dselect</prgn>'s core and the access method scripts it
7851 uses to actually install the selected packages, and describes
7852 how to create a new access method.</p>
7855 This manual does not go into detail about the options and
7856 usage of the package building and installation tools. It
7857 should therefore be read in conjuction with those programs'
7862 The utility programs which are provided with <prgn>dpkg</prgn>
7863 for managing various system configuration and similar issues,
7864 such as <prgn>update-rc.d</prgn> and
7865 <prgn>install-info</prgn>, are not described in detail here -
7866 please see their manpages.
7870 It does <em>not</em> describe the policy requirements imposed
7871 on Debian packages, such as the permissions on files and
7872 directories, documentation requirements, upload procedure, and
7873 so on. You should see the Debian packaging policy manual for
7874 these details. (Many of them will probably turn out to be
7875 helpful even if you don't plan to upload your package and make
7876 it available as part of the distribution.)
7880 It is assumed that the reader is reasonably familiar with the
7881 <prgn>dpkg</prgn> System Administrators' manual.
7882 Unfortunately this manual does not yet exist.
7886 The Debian version of the FSF's GNU hello program is provided
7887 as an example for people wishing to create Debian
7888 packages. The Debian <prgn>debmake</prgn> package is
7889 recommended as a very helpful tool in creating and maintaining
7890 Debian packages. However, while the tools and examples are
7891 helpful, they do not replace the need to read and follow the
7892 Policy and Programmer's Manual.</p>
7895 <appendix id="pkg-binarypkg"><heading>Binary packages (from old
7900 The binary package has two main sections. The first part
7901 consists of various control information files and scripts used
7902 by <prgn>dpkg</prgn> when installing and removing. See <ref
7903 id="pkg-controlarea">.
7907 The second part is an archive containing the files and
7908 directories to be installed.
7912 In the future binary packages may also contain other
7913 components, such as checksums and digital signatures. The
7914 format for the archive is described in full in the
7915 <file>deb(5)</file> manpage.
7919 <sect id="pkg-bincreating"><heading>Creating package files -
7920 <prgn>dpkg-deb</prgn>
7924 All manipulation of binary package files is done by
7925 <prgn>dpkg-deb</prgn>; it's the only program that has
7926 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
7927 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
7928 will spot that the options requested are appropriate to
7929 <prgn>dpkg-deb</prgn> and invoke that instead with the same
7934 In order to create a binary package you must make a
7935 directory tree which contains all the files and directories
7936 you want to have in the filesystem data part of the package.
7937 In Debian-format source packages this directory is usually
7938 <file>debian/tmp</file>, relative to the top of the package's
7943 They should have the locations (relative to the root of the
7944 directory tree you're constructing) ownerships and
7945 permissions which you want them to have on the system when
7950 With current versions of <prgn>dpkg</prgn> the uid/username
7951 and gid/groupname mappings for the users and groups being
7952 used should be the same on the system where the package is
7953 built and the one where it is installed.
7957 You need to add one special directory to the root of the
7958 miniature filesystem tree you're creating:
7959 <prgn>DEBIAN</prgn>. It should contain the control
7960 information files, notably the binary package control file
7961 (see <ref id="pkg-controlfile">).
7965 The <prgn>DEBIAN</prgn> directory will not appear in the
7966 filesystem archive of the package, and so won't be installed
7967 by <prgn>dpkg</prgn> when the package is installed.
7971 When you've prepared the package, you should invoke:
7973 dpkg --build <var>directory</var>
7978 This will build the package in
7979 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
7980 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
7981 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
7986 See the manpage <manref name="dpkg-deb" section="8"> for details of how
7987 to examine the contents of this newly-created file. You may find the
7988 output of following commands enlightening:
7990 dpkg-deb --info <var>filename</var>.deb
7991 dpkg-deb --contents <var>filename</var>.deb
7992 dpkg --contents <var>filename</var>.deb
7994 To view the copyright file for a package you could use this command:
7996 dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8001 <sect id="pkg-controlarea">
8003 Package control information files
8007 The control information portion of a binary package is a
8008 collection of files with names known to <prgn>dpkg</prgn>.
8009 It will treat the contents of these files specially - some
8010 of them contain information used by <prgn>dpkg</prgn> when
8011 installing or removing the package; others are scripts which
8012 the package maintainer wants <prgn>dpkg</prgn> to run.
8016 It is possible to put other files in the package control
8017 area, but this is not generally a good idea (though they
8018 will largely be ignored).
8022 Here is a brief list of the control info files supported by
8023 <prgn>dpkg</prgn> and a summary of what they're used for.
8028 <tag><tt>control</tt>
8032 This is the key description file used by
8033 <prgn>dpkg</prgn>. It specifies the package's name
8034 and version, gives its description for the user,
8035 states its relationships with other packages, and so
8036 forth. See <ref id="pkg-controlfile">.
8040 It is usually generated automatically from information
8041 in the source package by the
8042 <prgn>dpkg-gencontrol</prgn> program, and with
8043 assistance from <prgn>dpkg-shlibdeps</prgn>. See <ref
8044 id="pkg-sourcetools">.</p>
8047 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8053 These are exectuable files (usually scripts) which
8054 <prgn>dpkg</prgn> runs during installation, upgrade
8055 and removal of packages. They allow the package to
8056 deal with matters which are particular to that package
8057 or require more complicated processing than that
8058 provided by <prgn>dpkg</prgn>. Details of when and
8059 how they are called are in <ref
8060 id="maintainerscripts">.
8064 It is very important to make these scripts
8068 That means that if it runs successfully or fails
8069 and then you call it again it doesn't bomb out,
8070 but just ensures that everything is the way it
8073 </footnote> This is so that if an error occurs, the
8074 user interrupts <prgn>dpkg</prgn> or some other
8075 unforeseen circumstance happens you don't leave the
8076 user with a badly-broken package.
8080 The maintainer scripts are guaranteed to run with a
8081 controlling terminal and can interact with the user.
8082 If they need to prompt for passwords, do full-screen
8083 interaction or something similar you should do these
8084 things to and from <file>/dev/tty</file>, since
8085 <prgn>dpkg</prgn> will at some point redirect scripts'
8086 standard input and output so that it can log the
8087 installation process. Likewise, because these scripts
8088 may be executed with standard output redirected into a
8089 pipe for logging purposes, Perl scripts should set
8090 unbuffered output by setting <tt>$|=1</tt> so that the
8091 output is printed immediately rather than being
8096 Each script should return a zero exit status for
8097 success, or a nonzero one for failure.</p>
8100 <tag><tt>conffiles</tt>
8105 This file contains a list of configuration files which
8106 are to be handled automatically by <prgn>dpkg</prgn>
8107 (see <ref id="pkg-conffiles">). Note that not necessarily
8108 every configuration file should be listed here.</p>
8111 <tag><tt>shlibs</tt>
8116 This file contains a list of the shared libraries
8117 supplied by the package, with dependency details for
8118 each. This is used by <prgn>dpkg-shlibdeps</prgn>
8119 when it determines what dependencies are required in a
8120 package control file. The <tt>shlibs</tt> file format
8121 is described on <ref id="shlibs">.
8127 <sect id="pkg-controlfile">
8129 The main control information file: <tt>control</tt>
8132 The most important control information file used by
8133 <prgn>dpkg</prgn> when it installs a package is
8134 <tt>control</tt>. It contains all the package's `vital
8139 The binary package control files of packages built from
8140 Debian sources are made by a special tool,
8141 <prgn>dpkg-gencontrol</prgn>, which reads
8142 <file>debian/control</file> and <file>debian/changelog</file> to
8143 find the information it needs. See <ref id="pkg-sourcepkg"> for
8148 The fields in binary package control files are:
8149 <list compact="compact">
8151 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8154 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8156 <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8160 This field should appear in all packages, though
8161 <prgn>dpkg</prgn> doesn't require it yet so that
8162 old packages can still be installed.
8168 <p><qref id="relationships"><tt>Depends</tt>,
8169 <tt>Provides</tt> et al.</qref></p>
8172 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8175 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8178 <p><qref id="pkg-f-classification"><tt>Section</tt>,
8179 <tt>Priority</tt></qref></p>
8182 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8185 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8189 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8195 A description of the syntax of control files and the purpose
8196 of these fields is available in <ref id="pkg-controlfields">.
8201 <heading>Time Stamps</heading>
8203 Maintainers are encouraged to preserve the modification
8204 times of the upstream source files in a package, as far as
8205 is reasonably possible.
8208 The rationale is that there is some information conveyed
8209 by knowing the age of the file, for example, you could
8210 recognize that some documentation is very old by looking
8211 at the modification time, so it would be nice if the
8212 modification time of the upstream source would be
8220 <appendix id="pkg-sourcepkg">
8221 <heading>Source packages (from old Packaging Manual) </heading>
8224 The Debian binary packages in the distribution are generated
8225 from Debian sources, which are in a special format to assist
8226 the easy and automatic building of binaries.
8230 There was a previous version of the Debian source format,
8231 which is now being phased out. Instructions for converting an
8232 old-style package are given in the Debian policy manual.
8235 <sect id="pkg-sourcetools">
8236 <heading>Tools for processing source packages</heading>
8239 Various tools are provided for manipulating source packages;
8240 they pack and unpack sources and help build of binary
8241 packages and help manage the distribution of new versions.
8245 They are introduced and typical uses described here; see
8246 <manref name="dpkg-source" section="1"> for full
8247 documentation about their arguments and operation.
8251 For examples of how to construct a Debian source package,
8252 and how to use those utilities that are used by Debian
8253 source packages, please see the <prgn>hello</prgn> example
8259 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8264 This program is frequently used by hand, and is also
8265 called from package-independent automated building scripts
8266 such as <prgn>dpkg-buildpackage</prgn>.
8270 To unpack a package it is typically invoked with
8272 dpkg-source -x <var>.../path/to/filename</var>.dsc
8277 with the <file><var>filename</var>.tar.gz</file> and
8278 <file><var>filename</var>.diff.gz</file> (if applicable) in
8279 the same directory. It unpacks into
8280 <file><var>package</var>-<var>version</var></file>, and if
8282 <file><var>package</var>-<var>version</var>.orig</file>, in
8283 the current directory.
8287 To create a packed source archive it is typically invoked:
8289 dpkg-source -b <var>package</var>-<var>version</var>
8294 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8295 <file>.diff.gz</file> (if appropriate) in the current
8296 directory. <prgn>dpkg-source</prgn> does not clean the
8297 source tree first - this must be done separately if it is
8302 See also <ref id="pkg-sourcearchives">.</p>
8308 <prgn>dpkg-buildpackage</prgn> - overall package-building
8313 <prgn>dpkg-buildpackage</prgn> is a script which invokes
8314 <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8315 targets <tt>clean</tt>, <tt>build</tt> and
8316 <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8317 <prgn>pgp</prgn> to build a signed source and binary
8322 It is usually invoked by hand from the top level of the
8323 built or unbuilt source directory. It may be invoked with
8324 no arguments; useful arguments include:
8325 <taglist compact="compact">
8326 <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8329 Do not PGP-sign the <tt>.changes</tt> file or the
8330 source package <tt>.dsc</tt> file, respectively.</p>
8332 <tag><tt>-p<var>pgp-command</var></tt></tag>
8335 Invoke <var>pgp-command</var> instead of finding
8336 <tt>pgp</tt> on the <prgn>PATH</prgn>.
8337 <var>pgp-command</var> must behave just like
8338 <prgn>pgp</prgn>.</p>
8340 <tag><tt>-r<var>root-command</var></tt></tag>
8343 When root privilege is required, invoke the command
8344 <var>root-command</var>. <var>root-command</var>
8345 should invoke its first argument as a command, from
8346 the <prgn>PATH</prgn> if necessary, and pass its
8347 second and subsequent arguments to the command it
8348 calls. If no <var>root-command</var> is supplied
8349 then <var>dpkg-buildpackage</var> will take no
8350 special action to gain root privilege, so that for
8351 most packages it will have to be invoked as root to
8354 <tag><tt>-b</tt>, <tt>-B</tt></tag>
8357 Two types of binary-only build and upload - see
8358 <manref name="dpkg-source" section="1">.
8367 <prgn>dpkg-gencontrol</prgn> - generates binary package
8372 This program is usually called from <file>debian/rules</file>
8373 (see <ref id="pkg-sourcetree">) in the top level of the source
8378 This is usually done just before the files and directories in the
8379 temporary directory tree where the package is being built have their
8380 permissions and ownerships set and the package is constructed using
8381 <prgn>dpkg-deb/</prgn>
8384 This is so that the control file which is produced has
8385 the right permissions
8391 <prgn>dpkg-gencontrol</prgn> must be called after all the
8392 files which are to go into the package have been placed in
8393 the temporary build directory, so that its calculation of
8394 the installed size of a package is correct.
8398 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8399 be run after <prgn>dpkg-shlibdeps</prgn> so that the
8400 variable substitutions created by
8401 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8406 For a package which generates only one binary package, and
8407 which builds it in <file>debian/tmp</file> relative to the top
8408 of the source package, it is usually sufficient to call
8409 <prgn>dpkg-gencontrol</prgn>.
8413 Sources which build several binaries will typically need
8416 dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8417 </example> The <tt>-P</tt> tells
8418 <prgn>dpkg-gencontrol</prgn> that the package is being
8419 built in a non-default directory, and the <tt>-p</tt>
8420 tells it which package's control file should be generated.
8424 <prgn>dpkg-gencontrol</prgn> also adds information to the
8425 list of files in <file>debian/files</file>, for the benefit of
8426 (for example) a future invocation of
8427 <prgn>dpkg-genchanges</prgn>.</p>
8432 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8437 This program is usually called from <file>debian/rules</file>
8438 just before <prgn>dpkg-gencontrol</prgn> (see <ref
8439 id="pkg-sourcetree">), in the top level of the source tree.
8443 Its arguments are executables.
8446 In a forthcoming dpkg version,
8447 <prgn>dpkg-shlibdeps</prgn> would be required to be
8448 called on shared libraries as well.
8451 They may be specified either in the locations in the
8452 source tree where they are created or in the locations
8453 in the temporary build tree where they are installed
8454 prior to binary package creation.
8456 </footnote> for which shared library dependencies should
8457 be included in the binary package's control file.
8461 If some of the found shared libraries should only
8462 warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8463 some warrant a <tt>Pre-Depends</tt>, this can be achieved
8464 by using the <tt>-d<var>dependency-field</var></tt> option
8465 before those executable(s). (Each <tt>-d</tt> option
8466 takes effect until the next <tt>-d</tt>.)
8470 <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8471 output control file to be modified. Instead by default it
8472 adds to the <file>debian/substvars</file> file variable
8473 settings like <tt>shlibs:Depends</tt>. These variable
8474 settings must be referenced in dependency fields in the
8475 appropriate per-binary-package sections of the source
8480 For example, the <prgn>procps</prgn> package generates two
8481 kinds of binaries, simple C binaries like <prgn>ps</prgn>
8482 which require a predependency and full-screen ncurses
8483 binaries like <prgn>top</prgn> which require only a
8484 recommendation. It can say in its <file>debian/rules</file>:
8486 dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8488 and then in its main control file <file>debian/control</file>:
8492 Pre-Depends: ${shlibs:Pre-Depends}
8493 Recommends: ${shlibs:Recommends}
8499 Sources which produce several binary packages with
8500 different shared library dependency requirements can use
8501 the <tt>-p<var>varnameprefix</var></tt> option to override
8502 the default <tt>shlibs:</tt> prefix (one invocation of
8503 <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8504 They can thus produce several sets of dependency
8505 variables, each of the form
8506 <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8507 which can be referred to in the appropriate parts of the
8508 binary package control files.
8515 <prgn>dpkg-distaddfile</prgn> - adds a file to
8516 <file>debian/files</file>
8520 Some packages' uploads need to include files other than
8521 the source and binary package files.
8525 <prgn>dpkg-distaddfile</prgn> adds a file to the
8526 <file>debian/files</file> file so that it will be included in
8527 the <file>.changes</file> file when
8528 <prgn>dpkg-genchanges</prgn> is run.
8532 It is usually invoked from the <tt>binary</tt> target of
8533 <file>debian/rules</file>:
8535 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8537 The <var>filename</var> is relative to the directory where
8538 <prgn>dpkg-genchanges</prgn> will expect to find it - this
8539 is usually the directory above the top level of the source
8540 tree. The <file>debian/rules</file> target should put the
8541 file there just before or just after calling
8542 <prgn>dpkg-distaddfile</prgn>.
8546 The <var>section</var> and <var>priority</var> are passed
8547 unchanged into the resulting <file>.changes</file> file. See
8548 <ref id="pkg-f-classification">.
8553 <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8558 This program is usually called by package-independent
8559 automatic building scripts such as
8560 <prgn>dpkg-buildpackage</prgn>, but it may also be called
8565 It is usually called in the top level of a built source
8566 tree, and when invoked with no arguments will print out a
8567 straightforward <file>.changes</file> file based on the
8568 information in the source package's changelog and control
8569 file and the binary and source packages which should have
8575 <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8580 This program is used internally by
8581 <prgn>dpkg-source</prgn> et al. It may also occasionally
8582 be useful in <file>debian/rules</file> and elsewhere. It
8583 parses a changelog, <file>debian/changelog</file> by default,
8584 and prints a control-file format representation of the
8585 information in it to standard output.
8589 <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8590 information about the build and host system
8594 This program can be used manually, but is also invoked by
8595 <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8596 to set environment or make variables which specify the build and
8597 host architecture for the package building process.
8602 <sect id="pkg-sourcetree"><heading>The Debianised source tree
8606 The source archive scheme described later is intended to
8607 allow a Debianised source tree with some associated control
8608 information to be reproduced and transported easily. The
8609 Debianised source tree is a version of the original program
8610 with certain files added for the benefit of the
8611 Debianisation process, and with any other changes required
8612 made to the rest of the source code and installation
8617 The extra files created for Debian are in the subdirectory
8618 <file>debian</file> of the top level of the Debianised source
8619 tree. They are described below.
8622 <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8627 This file is an executable makefile, and contains the
8628 package-specific recipies for compiling the package and
8629 building binary package(s) out of the source.
8633 It must start with the line <tt>#!/usr/bin/make -f</tt>,
8634 so that it can be invoked by saying its name rather than
8635 invoking <prgn>make</prgn> explicitly.
8639 Since an interactive <file>debian/rules</file> script makes it
8640 impossible to autocompile that package and also makes it
8641 hard for other people to reproduce the same binary
8642 package, all <strong>required targets</strong> have to be
8643 non-interactive. At a minimul, required targets are the
8644 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8645 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8646 <em>build</em>. It also follows that any target that these
8647 targets depend on must also be non-interactive.
8651 The targets which are required to be present are:
8653 <tag><tt>build</tt></tag>
8656 This should perform all non-interactive
8657 configuration and compilation of the package. If a
8658 package has an interactive pre-build configuration
8659 routine, the Debianised source package should be
8660 built after this has taken place, so that it can be
8661 built without rerunning the configuration.
8665 A package may also provide both of the targets
8666 <tt>build-arch</tt> and <tt>build-indep</tt>. The
8667 <tt>build-arch</tt> target, if provided, should
8668 perform all non-interactive configuration and
8669 compilation required for producing all
8670 architecture-dependant binary packages (those packages
8671 for which the body of the <tt>Architecture</tt> field
8672 in <tt>debian/control</tt> is not <tt>all</tt>).
8673 Similarly, the <tt>build-indep</tt> target, if
8674 provided, should perform all non-interactive
8675 configuration and compilation required for producing
8676 all architecture-independent binary packages (those
8677 packages for which the body of the
8678 <tt>Architecture</tt> field in <tt>debian/control</tt>
8679 is <tt>all</tt>). The <tt>build</tt> target should
8680 depend on those of the targets <tt>build-arch</tt> and
8681 <tt>build-indep</tt> that are provided in the rules
8686 If one or both of the targets <tt>build-arch</tt> and
8687 <tt>build-indep</tt> are not provided, then invoking
8688 <file>debian/rules</file> with one of the not-provided
8689 targets as arguments should produce a exit status code
8690 of 2. Usually this is provided automatically by make
8691 if the target is missing.
8695 For some packages, notably ones where the same
8696 source tree is compiled in different ways to produce
8697 two binary packages, the <tt>build</tt> target does
8698 not make much sense. For these packages it is good
8699 enough to provide two (or more) targets
8700 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8701 for each of the ways of building the package, and a
8702 <tt>build</tt> target that does nothing. The
8703 <tt>binary</tt> target will have to build the
8704 package in each of the possible ways and make the
8705 binary package out of each.
8709 The targets <tt>build</tt>, <tt>build-arch</tt>
8710 and <tt>build-indep</tt> target must not do
8711 anything that might require root privilege.
8715 The <tt>build</tt> target may need to run
8716 <tt>clean</tt> first - see below.
8720 When a package has a configuration routine that takes
8721 a long time, or when the makefiles are poorly
8722 designed, or when <tt>build</tt> needs to run
8723 <tt>clean</tt> first, it is a good idea to <tt>touch
8724 build</tt> when the build process is complete. This
8725 will ensure that if <tt>debian/rules build</tt> is run
8726 again it will not rebuild the whole program.
8730 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8731 <tt>binary-indep</tt>
8735 The <tt>binary</tt> target should be all that is
8736 necessary for the user to build the binary
8737 package. All these targets are required to be
8738 non-interactive. It is split into two parts:
8739 <tt>binary-arch</tt> builds the packages' output
8740 files which are specific to a particular
8741 architecture, and <tt>binary-indep</tt> builds
8742 those which are not.
8746 <tt>binary</tt> should usually be a target with
8747 no commands which simply depends on
8748 <prgn>binary-arch</prgn> and
8749 <prgn>binary-indep</prgn>.
8753 Both <prgn>binary-*</prgn> targets should depend on
8754 the <tt>build</tt> target, above, so that the
8755 package is built if it has not been already. It
8756 should then create the relevant binary package(s),
8757 using <prgn>dpkg-gencontrol</prgn> to make their
8758 control files and <prgn>dpkg-deb</prgn> to build
8759 them and place them in the parent of the top level
8764 If one of the <prgn>binary-*</prgn> targets has
8765 nothing to do (this will be always be the case if
8766 the source generates only a single binary package,
8767 whether architecture-dependent or not) it
8768 <em>must</em> still exist, but should always
8773 <ref id="pkg-binarypkg"> describes how to construct
8778 The <tt>binary</tt> targets must be invoked as
8783 <tag><tt>clean</tt></tag>
8787 This should undo any effects that the
8788 <tt>build</tt> and <tt>binary</tt> targets
8789 may have had, except that it should leave alone any
8790 output files created in the parent directory by a
8791 run of <tt>binary</tt>. This target is required
8792 to be non-interactive.
8796 If a <tt>build</tt> file is touched at the end
8797 of the <tt>build</tt> target, as suggested
8798 above, it must be removed as the first thing that
8799 <tt>clean</tt> does, so that running
8800 <tt>build</tt> again after an interrupted
8801 <tt>clean</tt> doesn't think that everything is
8806 The <tt>clean</tt> target must be invoked as
8807 root if <tt>binary</tt> has been invoked since
8808 the last <tt>clean</tt>, or if
8809 <tt>build</tt> has been invoked as root (since
8810 <tt>build</tt> may create directories, for
8815 <tag><tt>get-orig-source</tt> (optional)</tag>
8819 This target fetches the most recent version of the
8820 original source package from a canonical archive
8821 site (via FTP or WWW, for example), does any
8822 necessary rearrangement to turn it into the original
8823 source tarfile format described below, and leaves it
8824 in the current directory.
8828 This target may be invoked in any directory, and
8829 should take care to clean up any temporary files it
8834 This target is optional, but providing it if
8835 possible is a good idea.
8841 The <tt>build</tt>, <tt>binary</tt> and
8842 <tt>clean</tt> targets must be invoked with a current
8843 directory of the package's top-level directory.
8848 Additional targets may exist in <file>debian/rules</file>,
8849 either as published or undocumented interfaces or for the
8850 package's internal use.
8854 The architecture we build on and build for is determined by make
8855 variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8856 get the Debian architecture and the GNU style architecture
8857 specification string for the build machine as well as the host
8858 machine. Here is a list of supported make variables:
8859 <list compact="compact">
8861 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8864 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8865 specification string)</p>
8868 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8871 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8877 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
8878 the build machine or <tt>HOST</tt> for specification of the machine
8883 Backward compatibility can be provided in the rules file
8884 by setting the needed variables to suitable default
8885 values, please refer to the documentation of
8886 dpkg-architecture for details.
8890 It is important to understand that the <tt>DEB_*_ARCH</tt>
8891 string does only determine which Debian architecture we
8892 build on resp. for. It should not be used to get the CPU
8893 or System information, the GNU style variables should be
8899 <sect1><heading><file>debian/control</file>
8903 This file contains version-independent details about the
8904 source package and about the binary packages it creates.
8908 It is a series of sets of control fields, each
8909 syntactically similar to a binary package control file.
8910 The sets are separated by one or more blank lines. The
8911 first set is information about the source package in
8912 general; each subsequent set describes one binary package
8913 that the source tree builds.
8917 The syntax and semantics of the fields are described below
8918 in <ref id="pkg-controlfields">.
8922 The general (binary-package-independent) fields are:
8923 <list compact="compact">
8925 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
8928 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8932 <qref id="pkg-f-classification"><tt>Section</tt> and
8933 <tt>Priority</tt></qref>
8934 (classification, mandatory)
8939 <qref id="relationships"><tt>Build-Depends</tt> et
8940 al.</qref> (source package interrelationships)
8945 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
8951 The per-binary-package fields are:
8952 <list compact="compact">
8954 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8958 <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8962 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8966 <qref id="pkg-f-classification"><tt>Section</tt> and
8967 <tt>Priority</tt></qref> (classification)</p>
8970 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8974 <qref id="relationships"><tt>Depends</tt> et
8975 al.</qref> (binary package interrelationships)
8981 These fields are used by <prgn>dpkg-gencontrol</prgn> to
8982 generate control files for binary packages (see below), by
8983 <prgn>dpkg-genchanges</prgn> to generate the
8984 <tt>.changes</tt> file to accompany the upload, and by
8985 <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
8986 source control file as part of a source archive.
8990 The fields here may contain variable references - their
8991 values will be substituted by
8992 <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
8993 or <prgn>dpkg-source</prgn> when they generate output
8994 control files. See <ref id="pkg-srcsubstvars"> for details.
8997 <p> <sect2><heading>User-defined fields
9001 Additional user-defined fields may be added to the
9002 source package control file. Such fields will be
9003 ignored, and not copied to (for example) binary or
9004 source package control files or upload control files.
9008 If you wish to add additional unsupported fields to
9009 these output files you should use the mechanism
9014 Fields in the main source control information file with
9015 names starting <tt>X</tt>, followed by one or more of
9016 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9017 be copied to the output files. Only the part of the
9018 field name after the hyphen will be used in the output
9019 file. Where the letter <tt>B</tt> is used the field
9020 will appear in binary package control files, where the
9021 letter <tt>S</tt> is used in source package control
9022 files and where <tt>C</tt> is used in upload control
9023 (<tt>.changes</tt>) files.
9027 For example, if the main source information control file
9030 XBS-Comment: I stand between the candle and the star.
9032 then the binary and source package control files will contain the
9035 Comment: I stand between the candle and the star.
9042 <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9046 This file records the changes to the Debian-specific parts of the
9050 Though there is nothing stopping an author who is also
9051 the Debian maintainer from using it for all their
9052 changes, it will have to be renamed if the Debian and
9053 upstream maintainers become different
9060 It has a special format which allows the package building
9061 tools to discover which version of the package is being
9062 built and find out other release-specific information.
9066 That format is a series of entries like this:
9068 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9070 * <var>change details</var>
9071 <var>more change details</var>
9072 * <var>even more change details</var>
9074 -- <var>maintainer name and email address</var> <var>date</var>
9079 <var>package</var> and <var>version</var> are the source
9080 package name and version number.
9084 <var>distribution(s)</var> lists the distributions where
9085 this version should be installed when it is uploaded - it
9086 is copied to the <tt>Distribution</tt> field in the
9087 <tt>.changes</tt> file. See <ref id="pkg-f-Distribution">.
9091 <var>urgency</var> is the value for the <tt>Urgency</tt>
9092 field in the <file>.changes</file> file for the upload. See
9093 <ref id="pkg-f-Urgency">. It is not possible to specify an
9094 urgency containing commas; commas are used to separate
9095 <tt><var>keyword</var>=<var>value</var></tt> settings in
9096 the <prgn>dpkg</prgn> changelog format (though there is
9097 currently only one useful <var>keyword</var>,
9102 The change details may in fact be any series of lines
9103 starting with at least two spaces, but conventionally each
9104 change starts with an asterisk and a separating space and
9105 continuation lines are indented so as to bring them in
9106 line with the start of the text above. Blank lines may be
9107 used here to separate groups of changes, if desired.
9111 The maintainer name and email address should <em>not</em>
9112 necessarily be those of the usual package maintainer.
9113 They should be the details of the person doing
9114 <em>this</em> version. The information here will be
9115 copied to the <file>.changes</file> file, and then later used
9116 to send an acknowledgement when the upload has been
9121 The <var>date</var> should be in RFC822 format
9124 This is generated by the <prgn>822-date</prgn>
9127 </footnote>; it should include the timezone specified
9128 numerically, with the timezone name or abbreviation
9129 optionally present as a comment.
9133 The first `title' line with the package name should start
9134 at the left hand margin; the `trailer' line with the
9135 maintainer and date details should be preceded by exactly
9136 one space. The maintainer details and the date must be
9137 separated by exactly two spaces.
9141 An Emacs mode for editing this format is available: it is
9142 called <tt>debian-changelog-mode</tt>. You can have this
9143 mode selected automatically when you edit a Debian
9144 changelog by adding a local variables clause to the end of
9148 <sect2><heading>Defining alternative changelog formats
9152 It is possible to use a different format to the standard
9153 one, by providing a parser for the format you wish to
9158 In order to have <tt>dpkg-parsechangelog</tt> run your
9159 parser, you must include a line within the last 40 lines
9160 of your file matching the Perl regular expression:
9161 <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9162 parentheses should be the name of the format. For
9163 example, you might say:
9165 @@@ changelog-format: joebloggs @@@
9167 Changelog format names are non-empty strings of alphanumerics.
9171 If such a line exists then <tt>dpkg-parsechangelog</tt>
9172 will look for the parser as
9173 <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9175 <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9176 it is an error for it not to find it, or for it not to
9177 be an executable program. The default changelog format
9178 is <tt>dpkg</tt>, and a parser for it is provided with
9179 the <tt>dpkg</tt> package.
9183 The parser will be invoked with the changelog open on
9184 standard input at the start of the file. It should read
9185 the file (it may seek if it wishes) to determine the
9186 information required and return the parsed information
9187 to standard output in the form of a series of control
9188 fields in the standard format. By default it should
9189 return information about only the most recent version in
9190 the changelog; it should accept a
9191 <tt>-v<var>version</var></tt> option to return changes
9192 information from all versions present <em>strictly
9193 after</em> <var>version</var>, and it should then be an
9194 error for <var>version</var> not to be present in the
9200 <list compact="compact">
9202 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9205 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9209 <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9214 <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9218 <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9223 <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9227 <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9234 If several versions are being returned (due to the use
9235 of <tt>-v</tt>), the urgency value should be of the
9236 highest urgency code listed at the start of any of the
9237 versions requested followed by the concatenated
9238 (space-separated) comments from all the versions
9239 requested; the maintainer, version, distribution and
9240 date should always be from the most recent version.
9244 For the format of the <tt>Changes</tt> field see <ref
9245 id="pkg-f-Changes">.
9249 If the changelog format which is being parsed always or
9250 almost always leaves a blank line between individual
9251 change notes these blank lines should be stripped out,
9252 so as to make the resulting output compact.
9256 If the changelog format does not contain date or package
9257 name information this information should be omitted from
9258 the output. The parser should not attempt to synthesise
9259 it or find it from other sources.
9263 If the changelog does not have the expected format the
9264 parser should exit with a nonzero exit status, rather
9265 than trying to muddle through and possibly generating
9270 A changelog parser may not interact with the user at
9274 <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9275 and variable substitutions
9279 When <prgn>dpkg-gencontrol</prgn>,
9280 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9281 generate control files they do variable substitutions on
9282 their output just before writing it. Variable
9283 substitutions have the form
9284 <tt>${<var>variable-name</var>}</tt>. The optional file
9285 <file>debian/substvars</file> contains variable substitutions
9286 to be used; variables can also be set directly from
9287 <file>debian/rules</file> using the <tt>-V</tt> option to the
9288 source packaging commands, and certain predefined
9289 variables are available.
9293 The is usually generated and modified dynamically by
9294 <file>debian/rules</file> targets; in this case it must be
9295 removed by the <tt>clean</tt> target.
9299 See <manref name="dpkg-source" section="1"> for full
9300 details about source variable substitutions, including the
9301 format of <file>debian/substvars</file>.</p>
9304 <sect1><heading><file>debian/files</file>
9308 This file is not a permanent part of the source tree; it
9309 is used while building packages to record which files are
9310 being generated. <prgn>dpkg-genchanges</prgn> uses it
9311 when it generates a <file>.changes</file> file.
9315 It should not exist in a shipped source package, and so it
9316 (and any backup files or temporary files such as
9317 <file>files.new</file>
9320 <file>files.new</file> is used as a temporary file by
9321 <prgn>dpkg-gencontrol</prgn> and
9322 <prgn>dpkg-distaddfile</prgn> - they write a new
9323 version of <file>files</file> here before renaming it,
9324 to avoid leaving a corrupted copy if an error
9327 </footnote>) should be removed by the
9328 <tt>clean</tt> target. It may also be wise to
9329 ensure a fresh start by emptying or removing it at the
9330 start of the <tt>binary</tt> target.
9334 <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9335 for the <file>.deb</file> file that will be created by
9336 <prgn>dpkg-deb</prgn> from the control file that it
9337 generates, so for most packages all that needs to be done
9338 with this file is to delete it in <tt>clean</tt>.
9342 If a package upload includes files besides the source
9343 package and any binary packages whose control files were
9344 made with <prgn>dpkg-gencontrol</prgn> then they should be
9345 placed in the parent of the package's top-level directory
9346 and <prgn>dpkg-distaddfile</prgn> should be called to add
9347 the file to the list in <file>debian/files</file>.</p>
9350 <sect1><heading><file>debian/tmp</file>
9354 This is the canonical temporary location for the
9355 construction of binary packages by the <tt>binary</tt>
9356 target. The directory <file>tmp</file> serves as the root of
9357 the filesystem tree as it is being constructed (for
9358 example, by using the package's upstream makefiles install
9359 targets and redirecting the output there), and it also
9360 contains the <tt>DEBIAN</tt> subdirectory. See <ref
9361 id="pkg-bincreating">.
9365 If several binary packages are generated from the same
9366 source tree it is usual to use several
9367 <file>debian/tmp<var>something</var></file> directories, for
9368 example <file>tmp-a</file> or <file>tmp-doc</file>.
9372 Whatever <file>tmp</file> directories are created and used by
9373 <tt>binary</tt> must of course be removed by the
9374 <tt>clean</tt> target.</p></sect1>
9378 <sect id="pkg-sourcearchives"><heading>Source packages as archives
9382 As it exists on the FTP site, a Debian source package
9383 consists of three related files. You must have the right
9384 versions of all three to be able to use them.
9389 <tag>Debian source control file - <tt>.dsc</tt></tag>
9393 This file contains a series of fields, identified and
9394 separated just like the fields in the control file of
9395 a binary package. The fields are listed below; their
9396 syntax is described above, in <ref id="pkg-controlfields">.
9397 <list compact="compact">
9399 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9402 <p><qref id="versions"><tt>Version</tt></qref></p>
9405 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9408 <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9411 <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9415 <qref id="relationships"><tt>Build-Depends</tt> et
9416 al.</qref> (source package interrelationships)
9421 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9424 <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9429 The source package control file is generated by
9430 <prgn>dpkg-source</prgn> when it builds the source
9431 archive, from other files in the source package,
9432 described above. When unpacking it is checked against
9433 the files and directories in the other parts of the
9434 source package, as described below.</p>
9438 Original source archive -
9440 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9447 This is a compressed (with <tt>gzip -9</tt>)
9448 <prgn>tar</prgn> file containing the source code from
9449 the upstream authors of the program. The tarfile
9450 unpacks into a directory
9451 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9452 and does not contain files anywhere other than in
9453 there or in its subdirectories.</p>
9457 Debianisation diff -
9459 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9465 This is a unified context diff (<tt>diff -u</tt>)
9466 giving the changes which are required to turn the
9467 original source into the Debian source. These changes
9468 may only include editing and creating plain files.
9469 The permissions of files, the targets of symbolic
9470 links and the characteristics of special files or
9471 pipes may not be changed and no files may be removed
9476 All the directories in the diff must exist, except the
9477 <file>debian</file> subdirectory of the top of the source
9478 tree, which will be created by
9479 <prgn>dpkg-source</prgn> if necessary when unpacking.
9483 The <prgn>dpkg-source</prgn> program will
9484 automatically make the <file>debian/rules</file> file
9485 executable (see below).</p></item>
9490 If there is no original source code - for example, if the
9491 package is specially prepared for Debian or the Debian
9492 maintainer is the same as the upstream maintainer - the
9493 format is slightly different: then there is no diff, and the
9495 <file><var>package</var>_<var>version</var>.tar.gz</file> and
9496 contains a directory
9497 <file><var>package</var>-<var>version</var></file>.
9501 <sect><heading>Unpacking a Debian source package without
9502 <prgn>dpkg-source</prgn>
9506 <tt>dpkg-source -x</tt> is the recommended way to unpack a
9507 Debian source package. However, if it is not available it
9508 is possible to unpack a Debian source archive as follows:
9509 <enumlist compact="compact">
9512 Untar the tarfile, which will create a <file>.orig</file>
9516 <p>Rename the <file>.orig</file> directory to
9517 <file><var>package</var>-<var>version</var></file>.</p>
9521 Create the subdirectory <file>debian</file> at the top of
9522 the source tree.</p>
9524 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9526 <item><p>Untar the tarfile again if you want a copy of the original
9527 source code alongside the Debianised version.</p>
9532 It is not possible to generate a valid Debian source archive
9533 without using <prgn>dpkg-source</prgn>. In particular,
9534 attempting to use <prgn>diff</prgn> directly to generate the
9535 <file>.diff.gz</file> file will not work.
9538 <sect1><heading>Restrictions on objects in source packages
9542 The source package may not contain any hard links
9545 This is not currently detected when building source
9546 packages, but only when extracting
9552 Hard links may be permitted at some point in the
9553 future, but would require a fair amount of
9556 </footnote>, device special files, sockets or setuid or
9560 Setgid directories are allowed.
9566 The source packaging tools manage the changes between the
9567 original and Debianised source using <prgn>diff</prgn> and
9568 <prgn>patch</prgn>. Turning the original source tree as
9569 included in the <file>.orig.tar.gz</file> into the debianised
9570 source must not involve any changes which cannot be
9571 handled by these tools. Problematic changes which cause
9572 <prgn>dpkg-source</prgn> to halt with an error when
9573 building the source package are:
9574 <list compact="compact">
9575 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9577 <item><p>Changing the targets of symbolic links.</p>
9579 <item><p>Creating directories, other than <file>debian</file>.</p>
9581 <item><p>Changes to the contents of binary files.</p></item>
9582 </list> Changes which cause <prgn>dpkg-source</prgn> to
9583 print a warning but continue anyway are:
9584 <list compact="compact">
9587 Removing files, directories or symlinks.
9590 Renaming a file is not treated specially - it is
9591 seen as the removal of the old file (which
9592 generates a warning, but is otherwise ignored),
9593 and the creation of the new
9600 Changed text files which are missing the usual final
9601 newline (either in the original or the modified
9606 Changes which are not represented, but which are not detected by
9607 <prgn>dpkg-source</prgn>, are:
9608 <list compact="compact">
9609 <item><p>Changing the permissions of files (other than
9610 <file>debian/rules</file>) and directories.</p></item>
9615 The <file>debian</file> directory and <file>debian/rules</file>
9616 are handled specially by <prgn>dpkg-source</prgn> - before
9617 applying the changes it will create the <file>debian</file>
9618 directory, and afterwards it will make
9619 <file>debian/rules</file> world-exectuable.
9625 <appendix id="pkg-controlfields"><heading>Control files and their
9626 fields (from old Packaging Manual)
9630 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9631 data in a common format, known as control files. Binary and
9632 source packages have control data as do the <file>.changes</file>
9633 files which control the installation of uploaded files, and
9634 <prgn>dpkg</prgn>'s internal databases are in a similar
9638 <sect><heading>Syntax of control files
9642 A file consists of one or more paragraphs of fields. The
9643 paragraphs are separated by blank lines. Some control files
9644 only allow one paragraph; others allow several, in which
9645 case each paragraph often refers to a different package.
9649 Each paragraph is a series of fields and values; each field
9650 consists of a name, followed by a colon and the value. It
9651 ends at the end of the line. Horizontal whitespace (spaces
9652 and tabs) may occur before or after the value and is ignored
9653 there; it is conventional to put a single space after the
9658 Some fields' values may span several lines; in this case
9659 each continuation line <em>must</em> start with a space or
9660 tab. Any trailing spaces or tabs at the end of individual
9661 lines of a field value are ignored.
9665 Except where otherwise stated only a single line of data is
9666 allowed and whitespace is not significant in a field body.
9667 Whitespace may never appear inside names (of packages,
9668 architectures, files or anything else), version numbers or
9669 in between the characters of multi-character version
9674 Field names are not case-sensitive, but it is usual to
9675 capitalise the field names using mixed case as shown below.
9679 Blank lines, or lines consisting only of spaces and tabs,
9680 are not allowed within field values or between fields - that
9681 would mean a new paragraph.
9685 It is important to note that there are several fields which
9686 are optional as far as <prgn>dpkg</prgn> and the related
9687 tools are concerned, but which must appear in every Debian
9688 package, or whose omission may cause problems. When writing
9689 the control files for Debian packages you <em>must</em> read
9690 the Debian policy manual in conjuction with the details
9691 below and the list of fields for the particular file.</p>
9694 <sect><heading>List of fields
9697 <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9701 The name of the binary package. Package names consist of
9702 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9703 (plus, minus and full stop).
9706 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9707 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9708 and underscore) used to be legal and are still
9709 accepted when found in a package file, but may not be
9710 used in new packages
9716 They must be at least two characters and must start with
9717 an alphanumeric. In current versions of dpkg they are
9718 sort of case-sensitive<footnote><p>This is a
9719 bug.</p></footnote>; use lowercase package names unless
9720 the package you're building (or referring to, in other
9721 fields) is already using uppercase.</p>
9724 <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9728 This lists the source or binary package's version number -
9729 see <ref id="versions">.
9734 <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9738 This is the architecture string; it is a single word for
9739 the Debian architecture.
9743 <prgn>dpkg</prgn> will check the declared architecture of
9744 a binary package against its own compiled-in value before
9749 The special value <tt>all</tt> indicates that the package
9750 is architecture-independent.
9754 In the main <file>debian/control</file> file in the source
9755 package, or in the source package control file
9756 <file>.dsc</file>, a list of architectures (separated by
9757 spaces) is also allowed, as is the special value
9758 <tt>any</tt>. A list indicates that the source will build
9759 an architecture-dependent package, and will only work
9760 correctly on the listed architectures. <tt>any</tt>
9761 indicates that though the source package isn't dependent
9762 on any particular architecture and should compile fine on
9763 any one, the binary package(s) produced are not
9764 architecture-independent but will instead be specific to
9765 whatever the current build architecture is.
9769 In a <file>.changes</file> file the <tt>Architecture</tt>
9770 field lists the architecture(s) of the package(s)
9771 currently being uploaded. This will be a list; if the
9772 source for the package is being uploaded too the special
9773 entry <tt>source</tt> is also present.
9777 See <ref id="pkg-debianrules"> for information how to get the
9778 architecture for the build process.
9782 <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9786 The package maintainer's name and email address. The name
9787 should come first, then the email address inside angle
9788 brackets <tt><></tt> (in RFC822 format).
9792 If the maintainer's name contains a full stop then the
9793 whole field will not work directly as an email address due
9794 to a misfeature in the syntax specified in RFC822; a
9795 program using this field as an address must check for this
9796 and correct the problem if necessary (for example by
9797 putting the name in round brackets and moving it to the
9798 end, and bringing the email address forward).
9802 In a <file>.changes</file> file or parsed changelog data this
9803 contains the name and email address of the person
9804 responsible for the particular version in question - this
9805 may not be the package's usual maintainer.
9809 This field is usually optional in as far as the
9810 <prgn>dpkg</prgn> are concerned, but its absence when
9811 building packages usually generates a warning.</p>
9814 <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9818 This field identifies the source package name.
9822 In a main source control information or a
9823 <file>.changes</file> or <file>.dsc</file> file or parsed
9824 changelog data this may contain only the name of the
9829 In the control file of a binary package (or in a
9830 <file>Packages</file> file) it may be followed by a version
9831 number in parentheses.
9834 It is usual to leave a space after the package name if
9835 a version number is specified.
9837 </footnote> This version number may be omitted (and is, by
9838 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9839 the <tt>Version</tt> field of the binary package in
9840 question. The field itself may be omitted from a binary
9841 package control file when the source package has the same
9842 name and version as the binary package.
9846 <sect1><heading>Package interrelationship fields:
9847 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9848 <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9849 <tt>Provides</tt>, <tt>Replaces</tt>
9853 These fields describe the package's relationships with
9854 other packages. Their syntax and semantics are described
9855 in <ref id="relationships">.</p>
9858 <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9862 In a binary package <tt>Packages</tt> file or main source
9863 control file this field contains a description of the
9864 binary package, in a special format. See <ref
9865 id="descriptions"> for details.
9869 In a <file>.changes</file> file it contains a summary of the
9870 descriptions for the packages being uploaded. The part of
9871 the field before the first newline is empty; thereafter
9872 each line has the name of a binary package and the summary
9873 description line from that binary package. Each line is
9874 indented by one space.</p>
9877 <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
9881 This is a boolean field which may occur only in the
9882 control file of a binary package (or in the
9883 <file>Packages</file> file) or in a per-package fields
9884 paragraph of a main source control data file.
9888 If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
9889 <prgn>dselect</prgn> will refuse to remove the package
9890 (though it can be upgraded and/or replaced). The other
9891 possible value is <tt>no</tt>, which is the same as not
9892 having the field at all.</p>
9895 <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
9900 These two fields classify the package. The
9901 <tt>Priority</tt> represents how important that it is that
9902 the user have it installed; the <tt>Section</tt>
9903 represents an application area into which the package has
9908 When they appear in the <file>debian/control</file> file these
9909 fields give values for the section and priority subfields
9910 of the <tt>Files</tt> field of the <file>.changes</file> file,
9911 and give defaults for the section and priority of the
9916 The section and priority are represented, though not as
9917 separate fields, in the information for each file in the
9918 <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
9919 <file>.changes</file> file. The section value in a
9920 <file>.changes</file> file is used to decide where to install
9921 a package in the FTP archive.
9925 These fields are not used by by <prgn>dpkg</prgn> proper,
9926 but by <prgn>dselect</prgn> when it sorts packages and
9927 selects defaults. See the Debian policy manual for the
9928 priorities in use and the criteria for selecting the
9929 priority for a Debian package, and look at the Debian FTP
9930 archive for a list of currently in-use priorities.
9934 These fields may appear in binary package control files,
9935 in which case they provide a default value in case the
9936 <file>Packages</file> files are missing the information.
9937 <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
9938 the value from a <file>.deb</file> file if they have no other
9939 information; a value listed in a <file>Packages</file> file
9940 will always take precedence. By default
9941 <prgn>dpkg-gencontrol</prgn> does not include the section
9942 and priority in the control file of a binary package - use
9943 the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
9944 achieve this effect.</p>
9947 <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
9951 This field is a list of binary packages.
9955 When it appears in the <file>.dsc</file> file it is the list
9956 of binary packages which a source package can produce. It
9957 does not necessarily produce all of these binary packages
9958 for every architecture. The source control file doesn't
9959 contain details of which architectures are appropriate for
9960 which of the binary packages.
9964 When it appears in a <file>.changes</file> file it lists the
9965 names of the binary packages actually being uploaded.
9969 The syntax is a list of binary packages separated by
9973 A space after each comma is conventional.
9975 </footnote> Currently the packages must be separated using
9976 only spaces in the <file>.changes</file> file.</p>
9979 <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
9983 This field appears in the control files of binary
9984 packages, and in the <file>Packages</file> files. It gives
9985 the total amount of disk space required to install the
9990 The disk space is represented in kilobytes as a simple
9994 <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
9998 This field contains a list of files with information about
9999 each one. The exact information and syntax varies with
10000 the context. In all cases the the part of the field
10001 contents on the same line as the field name is empty. The
10002 remainder of the field is one line per file, each line
10003 being indented by one space and containing a number of
10004 sub-fields separated by spaces.
10008 In the <file>.dsc</file> (Debian source control) file each
10009 line contains the MD5 checksum, size and filename of the
10010 tarfile and (if applicable) diff file which make up the
10011 remainder of the source package.
10014 That is, the parts which are not the
10017 </footnote> The exact forms of the filenames are described
10018 in <ref id="pkg-sourcearchives">.
10022 In the <file>.changes</file> file this contains one line per
10023 file being uploaded. Each line contains the MD5 checksum,
10024 size, section and priority and the filename. The section
10025 and priority are the values of the corresponding fields in
10026 the main source control file - see <ref
10027 id="pkg-f-classification">. If no section or priority is
10028 specified then <tt>-</tt> should be used, though section
10029 and priority values must be specified for new packages to
10030 be installed properly.
10034 The special value <tt>byhand</tt> for the section in a
10035 <tt>.changes</tt> file indicates that the file in question
10036 is not an ordinary package file and must by installed by
10037 hand by the distribution maintainers. If the section is
10038 <tt>byhand</tt> the priority should be <tt>-</tt>.
10042 If a new Debian revision of a package is being shipped and
10043 no new original source archive is being distributed the
10044 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10045 entry for the original source archive
10046 <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10047 but the <file>.changes</file> file should leave it out. In
10048 this case the original source archive on the distribution
10049 site must match exactly, byte-for-byte, the original
10050 source archive which was used to generate the
10051 <file>.dsc</file> file and diff which are being uploaded.</p>
10056 id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10060 The most recent version of the standards (the
10061 <prgn>dpkg</prgn> programmers' and policy manuals and
10062 associated texts) with which the package complies. This
10063 is updated manually when editing the source package to
10064 conform to newer standards; it can sometimes be used to
10065 tell when a package needs attention.
10069 Its format is the same as that of a version number except
10070 that no epoch or Debian revision is allowed - see <ref
10071 id="versions">.</p>
10075 <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10079 In a <file>.changes</file> file or parsed changelog output
10080 this contains the (space-separated) name(s) of the
10081 distribution(s) where this version of the package should
10082 be or was installed. Distribution names follow the rules
10083 for package names. (See <ref id="pkg-f-Package">).
10087 Current distribution values are:
10089 <tag><em>stable</em></tag>
10092 This is the current `released' version of Debian
10093 GNU/Linux. A new version is released approximately
10094 every 3 months after the <em>development</em> code has
10095 been <em>frozen</em> for a month of testing. Once the
10096 distribution is <em>stable</em> only major bug fixes
10097 are allowed. When changes are made to this
10098 distribution, the release number is increased
10099 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10103 <tag><em>unstable</em></tag>
10106 This distribution value refers to the
10107 <em>developmental</em> part of the Debian distribution
10108 tree. New packages, new upstream versions of packages
10109 and bug fixes go into the <em>unstable</em> directory
10110 tree. Download from this distribution at your own
10114 <tag><em>contrib</em></tag>
10117 The packages with this distribution value do not meet
10118 the criteria for inclusion in the main Debian
10119 distribution as defined by the Policy Manual, but meet
10120 the criteria for the <em>contrib</em>
10121 Distribution. There is currently no distinction
10122 between stable and unstable packages in the
10123 <em>contrib</em> or <em>non-free</em>
10124 distributions. Use your best judgement in downloading
10125 from this Distribution.</p>
10128 <tag><em>non-free</em></tag>
10131 Like the packages in the <em>contrib</em> seciton,
10132 the packages in <em>non-free</em> do not meet the
10133 criteria for inclusion in the main Debian distribution
10134 as defined by the Policy Manual. Again, use your best
10135 judgement in downloading from this Distribution.</p>
10137 <tag><em>experimental</em></tag>
10140 The packages with this distribution value are deemed
10141 by their maintainers to be high risk. Oftentimes they
10142 represent early beta or developmental packages from
10143 various sources that the maintainers want people to
10144 try, but are not ready to be a part of the other parts
10145 of the Debian distribution tree. Download at your own
10149 <tag><em>frozen</em></tag>
10152 From time to time, (currently, every 3 months) the
10153 <em>unstable</em> distribution enters a state of
10154 `code-freeze' in anticipation of release as a
10155 <em>stable</em> version. During this period of testing
10156 (usually 4 weeks) only fixes for existing or
10157 newly-discovered bugs will be allowed.
10160 </taglist> You should list <em>all</em> distributions that
10161 the package should be installed into. Except in unusual
10162 circumstances, installations to <em>stable</em> should also
10163 go into <em>frozen</em> (if it exists) and
10164 <em>unstable</em>. Likewise, installations into
10165 <em>frozen</em> should also go into <em>unstable</em>.</p>
10168 <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10172 This is a description of how important it is to upgrade to
10173 this version from previous ones. It consists of a single
10174 keyword usually taking one of the values <tt>LOW</tt>,
10175 <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10176 commentary (separated by a space) which is usually in
10177 parentheses. For example:
10179 Urgency: LOW (HIGH for diversions users)
10184 This field appears in the <file>.changes</file> file and in
10185 parsed changelogs; its value appears as the value of the
10186 <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10187 changelog (see <ref id="pkg-dpkgchangelog">).
10191 Urgency keywords are not case-sensitive.</p>
10194 <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10198 In <tt>.changes</tt> files and parsed changelogs, this
10199 gives the date the package was built or last edited.</p>
10202 <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10206 This field occurs in <file>.changes</file> files, and
10207 specifies a format revision for the file. The format
10208 described here is version <tt>1.5</tt>. The syntax of the
10209 format value is the same as that of a package version
10210 number except that no epoch or Debian revision is allowed
10211 - see <ref id="versions">.</p>
10214 <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10218 In a <file>.changes</file> file or parsed changelog this field
10219 contains the human-readable changes data, describing the
10220 differences between the last version and the current one.
10224 There should be nothing in this field before the first
10225 newline; all the subsequent lines must be indented by at
10226 least one space; blank lines must be represented by a line
10227 consiting only of a space and a full stop.
10231 Each version's change information should be preceded by a
10232 `title' line giving at least the version, distribution(s)
10233 and urgency, in a human-readable way.
10237 If data from several versions is being returned the entry
10238 for the most recent version should be returned first, and
10239 entries should be separated by the representation of a
10240 blank line (the `title' line may also be followed by the
10241 representation of blank line).</p>
10244 <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10245 <tt>MSDOS-Filename</tt>
10249 These fields in <tt>Packages</tt> files give the
10250 filename(s) of (the parts of) a package in the
10251 distribution directories, relative to the root of the
10252 Debian hierarchy. If the package has been split into
10253 several parts the parts are all listed in order, separated
10257 <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10261 These fields in <file>Packages</file> files give the size (in
10262 bytes, expressed in decimal) and MD5 checksum of the
10263 file(s) which make(s) up a binary package in the
10264 distribution. If the package is split into several parts
10265 the values for the parts are listed in order, separated by
10269 <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10273 This field in <prgn>dpkg</prgn>'s status file records
10274 whether the user wants a package installed, removed or
10275 left alone, whether it is broken (requiring
10276 reinstallation) or not and what its current state on the
10277 system is. Each of these pieces of information is a
10281 <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10285 If a package is not installed or not configured, this
10286 field in <prgn>dpkg</prgn>'s status file records the last
10287 version of the package which was successfully
10291 <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10295 This field in <prgn>dpkg</prgn>'s status file contains
10296 information about the automatically-managed configuration
10297 files held by a package. This field should <em>not</em>
10298 appear anywhere in a package!</p>
10301 <sect1><heading>Obsolete fields
10305 These are still recognised by <prgn>dpkg</prgn> but should
10306 not appear anywhere any more.
10307 <taglist compact="compact">
10309 <tag><tt>Revision</tt></tag>
10310 <tag><tt>Package-Revision</tt></tag>
10311 <tag><tt>Package_Revision</tt></tag>
10314 The Debian revision part of the package version was
10315 at one point in a separate control file field. This
10316 field went through several names.</p>
10319 <tag><tt>Recommended</tt></tag>
10320 <item><p>Old name for <tt>Recommends</tt></p>
10323 <tag><tt>Optional</tt></tag>
10324 <item><p>Old name for <tt>Suggests</tt>.</p>
10326 <tag><tt>Class</tt></tag>
10327 <item><p>Old name for <tt>Priority</tt>.</p>
10335 <appendix id="pkg-conffiles"><heading>Configuration file handling
10336 (from old Packaging Manual)
10340 <prgn>dpkg</prgn> can do a certain amount of automatic
10341 handling of package configuration files.
10345 Whether this mechanism is appropriate depends on a number of
10346 factors, but basically there are two approaches to any
10347 particular configuration file.
10351 The easy method is to ship a best-effort configuration in the
10352 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10353 handle updates. If the user is unlikely to want to edit the
10354 file, but you need them to be able to without losing their
10355 changes, and a new package with a changed version of the file
10356 is only released infrequently, this is a good approach.
10360 The hard method is to build the configuration file from
10361 scratch in the <prgn>postinst</prgn> script, and to take the
10362 responsibility for fixing any mistakes made in earlier
10363 versions of the package automatically. This will be
10364 appropriate if the file is likely to need to be different on
10368 <sect><heading>Automatic handling of configuration files by
10373 A package may contain a control area file called
10374 <tt>conffiles</tt>. This file should be a list of filenames
10375 of configuration files needing automatic handling, separated
10376 by newlines. The filenames should be absolute pathnames,
10377 and the files referred to should actually exist in the
10382 When a package is upgraded <prgn>dpkg</prgn> will process
10383 the configuration files during the configuration stage,
10384 shortly before it runs the package's <prgn>postinst</prgn>
10389 For each file it checks to see whether the version of the
10390 file included in the package is the same as the one that was
10391 included in the last version of the package (the one that is
10392 being upgraded from); it also compares the version currently
10393 installed on the system with the one shipped with the last
10398 If neither the user nor the package maintainer has changed
10399 the file, it is left alone. If one or the other has changed
10400 their version, then the changed version is preferred - i.e.,
10401 if the user edits their file, but the package maintainer
10402 doesn't ship a different version, the user's changes will
10403 stay, silently, but if the maintainer ships a new version
10404 and the user hasn't edited it the new version will be
10405 installed (with an informative message). If both have
10406 changed their version the user is prompted about the problem
10407 and must resolve the differences themselves.
10411 The comparisons are done by calculating the MD5 message
10412 digests of the files, and storing the MD5 of the file as it
10413 was included in the most recent version of the package.
10417 When a package is installed for the first time
10418 <prgn>dpkg</prgn> will install the file that comes with it,
10419 unless that would mean overwriting a file already on the
10424 However, note that <prgn>dpkg</prgn> will <em>not</em>
10425 replace a conffile that was removed by the user (or by a
10426 script). This is necessary because with some programs a
10427 missing file produces an effect hard or impossible to
10428 achieve in another way, so that a missing file needs to be
10429 kept that way if the user did it.
10433 Note that a package should <em>not</em> modify a
10434 <prgn>dpkg</prgn>-handled conffile in its maintainer
10435 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
10436 the user confusing and possibly dangerous options for
10437 conffile update when the package is upgraded.</p>
10440 <sect><heading>Fully-featured maintainer script configuration
10445 For files which contain site-specific information such as
10446 the hostname and networking details and so forth, it is
10447 better to create the file in the package's
10448 <prgn>postinst</prgn> script.
10452 This will typically involve examining the state of the rest
10453 of the system to determine values and other information, and
10454 may involve prompting the user for some information which
10455 can't be obtained some other way.
10459 When using this method there are a couple of important
10460 issues which should be considered:
10464 If you discover a bug in the program which generates the
10465 configuration file, or if the format of the file changes
10466 from one version to the next, you will have to arrange for
10467 the postinst script to do something sensible - usually this
10468 will mean editing the installed configuration file to remove
10469 the problem or change the syntax. You will have to do this
10470 very carefully, since the user may have changed the file,
10471 perhaps to fix the very problem that your script is trying
10472 to deal with - you will have to detect these situations and
10473 deal with them correctly.
10477 If you do go down this route it's probably a good idea to
10478 make the program that generates the configuration file(s) a
10479 separate program in <file>/usr/sbin</file>, by convention called
10480 <file><var>package</var>config</file> and then run that if
10481 appropriate from the post-installation script. The
10482 <tt><var>package</var>config</tt> program should not
10483 unquestioningly overwrite an existing configuration - if its
10484 mode of operation is geared towards setting up a package for
10485 the first time (rather than any arbitrary reconfiguration
10486 later) you should have it check whether the configuration
10487 already exists, and require a <tt>--force</tt> flag to
10488 overwrite it.</p></sect>
10491 <appendix id="pkg-alternatives"><heading>Alternative versions of
10492 an interface - <prgn>update-alternatives</prgn> (from old
10497 When several packages all provide different versions of the
10498 same program or file it is useful to have the system select a
10499 default, but to allow the system administrator to change it
10500 and have their decisions respected.
10504 For example, there are several versions of the <prgn>vi</prgn>
10505 editor, and there is no reason to prevent all of them from
10506 being installed at once, each under their own name
10507 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10508 Nevertheless it is desirable to have the name <tt>vi</tt>
10509 refer to something, at least by default.
10513 If all the packages involved cooperate, this can be done with
10514 <prgn>update-alternatives</prgn>.
10518 Each package provides its own version under its own name, and
10519 calls <prgn>update-alternatives</prgn> in its postinst to
10520 register its version (and again in its prerm to deregister
10525 See the manpage <manref name="update-alternatives"
10526 section="8"> for details.
10530 If <prgn>update-alternatives</prgn> does not seem appropriate
10531 you may wish to consider using diversions instead.</p>
10534 <appendix id="pkg-diversions"><heading>Diversions - overriding a
10535 package's version of a file (from old Packaging Manual)
10539 It is possible to have <prgn>dpkg</prgn> not overwrite a file
10540 when it reinstalls the package it belongs to, and to have it
10541 put the file from the package somewhere else instead.
10545 This can be used locally to override a package's version of a
10546 file, or by one package to override another's version (or
10547 provide a wrapper for it).
10551 Before deciding to use a diversion, read <ref
10552 id="pkg-alternatives"> to see if you really want a diversion
10553 rather than several alternative versions of a program.
10557 There is a diversion list, which is read by <prgn>dpkg</prgn>,
10558 and updated by a special program <prgn>dpkg-divert</prgn>.
10559 Please see <manref name="dpkg-divert" section="8"> for full
10560 details of its operation.
10564 When a package wishes to divert a file from another, it should
10565 call <prgn>dpkg-divert</prgn> in its preinst to add the
10566 diversion and rename the existing file. For example,
10567 supposing that a <prgn>smailwrapper</prgn> package wishes to
10568 install a wrapper around <file>/usr/sbin/smail</file>:
10570 if [ install = "$1" ]; then
10571 dpkg-divert --package smailwrapper --add --rename \
10572 --divert /usr/sbin/smail.real /usr/sbin/smail
10574 </example> Testing <tt>$1</tt> is necessary so that the script
10575 doesn't try to add the diversion again when
10576 <prgn>smailwrapper</prgn> is upgraded. The <tt>--package
10577 smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10578 copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10579 get installed as the true version.
10583 The postrm has to do the reverse:
10585 if [ remove = "$1" ]; then
10586 dpkg-divert --package smailwrapper --remove --rename \
10587 --divert /usr/sbin/smail.real /usr/sbin/smail
10593 Do not attempt to divert a file which is vitally important for
10594 the system's operation - when using <prgn>dpkg-divert</prgn>
10595 there is a time, after it has been diverted but before
10596 <prgn>dpkg</prgn> has installed the new version, when the file
10597 does not exist.</p>