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 the
48 operating system, as well as technical requirements that each
49 package must satisfy to be included in the distribution. The
50 policy package itself is maintained by a group of maintainers
51 that have no editorial powers. At the moment, the list of
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 <tt>/usr/share/common-licenses/GPL</tt> 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: <tt>policy.html.tar.gz</tt>, <tt>policy.pdf.gz</tt>
204 and <tt>policy.ps.gz</tt>) 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 <tt>debian-policy</tt>.
214 The <tt>debian-policy</tt> package also includes the file
215 <tt>upgrading-checklist.txt</tt> 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 Some programs with cryptographic program code need to be
559 stored on the <em>non-US</em> server because of United
560 States export restrictions. Such programs must be
561 distributed in the appropriate <em>non-US</em> section,
562 either <em>non-US/main</em>, <em>non-US/contrib</em> or
563 <em>non-US/non-free</em>.
566 This applies only to packages which contain cryptographic
567 code. A package containing a program with an interface to
568 a cryptographic program or a program that's dynamically
569 linked against a cryptographic library should not be
570 distributed via the <em>non-US</em> server if it is
571 capable of running without the cryptographic library or
576 <heading>Further copyright considerations</heading>
578 Every package must be accompanied by a verbatim copy of
579 its copyright and distribution license in the file
580 <tt>/usr/share/doc/<var>package</var>/copyright</tt>
581 (see <ref id="copyrightfile"> for further details).
584 We reserve the right to restrict files from being included
585 anywhere in our archives if
586 <list compact="compact">
589 their use or distribution would break a law,
594 there is an ethical conflict in their distribution or
600 we would have to sign a license for them, or
605 their distribution would conflict with other project
613 Programs whose authors encourage the user to make
614 donations are fine for the main distribution, provided
615 that the authors do not claim that not donating is
616 immoral, unethical, illegal or something similar; in such
617 a case they must go in <em>non-free</em>.</p>
620 Packages whose copyright permission notices (or patent
621 problems) do not even allow redistribution of binaries
622 only, and where no special permission has been obtained,
623 must not be placed on the Debian FTP site and its mirrors
627 Note that under international copyright law (this applies
628 in the United States, too), <em>no</em> distribution or
629 modification of a work is allowed without an explicit
630 notice saying so. Therefore a program without a copyright
631 notice <em>is</em> copyrighted and you may not do anything
632 to it without risking being sued! Likewise if a program
633 has a copyright notice but no statement saying what is
634 permitted then nothing is permitted.</p>
637 Many authors are unaware of the problems that restrictive
638 copyrights (or lack of copyright notices) can cause for
639 the users of their supposedly-free software. It is often
640 worthwhile contacting such authors diplomatically to ask
641 them to modify their license terms. However, this can be a
642 politically difficult thing to do and you should ask for
643 advice on the <tt>debian-legal</tt> mailing list first, as
648 When in doubt about a copyright, send mail to
649 <email>debian-legal@lists.debian.org</email>. Be prepared
650 to provide us with the copyright statement. Software
651 covered by the GPL, public domain software and BSD-like
652 copyrights are safe; be wary of the phrases `commercial
653 use prohibited' and `distribution restricted'.
657 <heading>Subsections</heading>
660 The packages in the sections <em>main</em>,
661 <em>contrib</em> and <em>non-free</em> are grouped further
662 into <em>subsections</em> to simplify handling.
666 The section and subsection for each package should be
667 specified in the package's <tt>Section</tt> control
668 record. However, the maintainer of the Debian archive
669 may override this selection to ensure the consistency of
670 the Debian distribution. The <tt>Section</tt> field
671 should be of the form:
672 <list compact="compact">
675 <em>subsection</em> if the package is in the
676 <em>main</em> section,
681 <em>section/subsection</em> if the package is in
682 the <em>contrib</em> or <em>non-free</em> section,
688 <tt>non-US</tt>, <tt>non-US/contrib</tt> or
689 <tt>non-US/non-free</tt> if the package is in
690 <em>non-US/main</em>, <em>non-US/contrib</em> or
691 <em>non-US/non-free</em> respectively.
698 The Debian archive maintainers provide the authoritative
699 list of subsections. At present, they are:
700 <em>admin</em>, <em>base</em>, <em>comm</em>,
701 <em>contrib</em>, <em>devel</em>, <em>doc</em>,
702 <em>editors</em>, <em>electronics</em>, <em>games</em>,
703 <em>graphics</em>, <em>hamradio</em>,
704 <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
705 <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
706 <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
707 <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
708 <em>sound</em>, <em>tex</em>, <em>text</em>,
709 <em>utils</em>, <em>web</em>, <em>x11</em>.
713 <heading>Priorities</heading>
716 Each package should have a <em>priority</em> value, which is
717 included in the package's <em>control record</em>. This
718 information is used by the Debian package management tools
719 to separate high-priority packages from less-important
723 The following <em>priority levels</em> are recognised by the
724 Debian package management tools.
726 <tag><tt>required</tt></tag>
729 Packages which are necessary for the proper
730 functioning of the system. You must not remove these
731 packages or your system may become totally broken and
732 you may not even be able to use <prgn>dpkg</prgn> to
733 put things back. Systems with only the
734 <tt>required</tt> packages are probably unusable, but
735 they do have enough functionality to allow the
736 sysadmin to boot and install more software.</p>
738 <tag><tt>important</tt></tag>
741 Important programs, including those which one would
742 expect to find on any Unix-like system. If the
743 expectation is that an experienced Unix person who
744 found it missing would say `What on earth is going on,
745 where is <prgn>foo</prgn>?', it must be an
746 <tt>important</tt> package.<footnote>
748 This is an important criterion because we are
749 trying to produce, amongst other things, a free
753 Other packages without which the system will not run
754 well or be usable must also have priority
755 <tt>important</tt>. This does
756 <em>not</em> include Emacs, the X Window System, TeX
757 or any other large applications. The
758 <tt>important</tt> packages are just a bare minimum of
759 commonly-expected and necessary tools.</p>
761 <tag><tt>standard</tt></tag>
764 These packages provide a reasonably small but not too
765 limited character-mode system. This is what will be
766 installed by default if the user doesn't select anything
767 else. It doesn't include many large applications, but
768 it does include Emacs (this is more of a piece of
769 infrastructure than an application) and a reasonable
770 subset of TeX and LaTeX.</p>
772 <tag><tt>optional</tt></tag>
775 (In a sense everything that isn't required is
776 optional, but that's not what is meant here.) This is
777 all the software that you might reasonably want to
778 install if you didn't know what it was and don't have
779 specialized requirements. This is a much larger system
780 and includes the X Window System, a full TeX
781 distribution, and many applications. Note that
782 optional packages should not conflict with each other.
785 <tag><tt>extra</tt></tag>
788 This contains all packages that conflict with others
789 with required, important, standard or optional
790 priorities, or are only likely to be useful if you
791 already know what they are or have specialised
798 Packages must not depend on packages with lower priority
799 values (excluding build-time dependencies). In order to
800 ensure this, the priorities of one or more packages may need
806 <heading>Binary packages</heading>
809 The Debian GNU/Linux distribution is based on the Debian
810 package management system, called <prgn>dpkg</prgn>. Thus,
811 all packages in the Debian distribution must be provided
812 in the <tt>.deb</tt> file format.</p>
816 <heading>The package name</heading>
819 Every package must have a name that's unique within the Debian
823 Package names must consist of lower case letters
824 (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
825 and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
826 They must be at least two characters long and must contain
831 The package name is part of the file name of the
832 <tt>.deb</tt> file and is included in the control field
838 <heading>The maintainer of a package</heading>
840 Every package must have a Debian maintainer (the
841 maintainer may be one person or a group of people
842 reachable from a common email address, such as a mailing
843 list). The maintainer is responsible for ensuring that
844 the package is placed in the appropriate distributions.
848 The maintainer must be specified in the
849 <tt>Maintainer</tt> control field with their correct name
850 and a working email address. If one person maintains
851 several packages, he/she should try to avoid having
852 different forms of their name and email address in
853 the <tt>Maintainer</tt> fields of those packages.
857 If the maintainer of a package quits from the Debian
858 project, "Debian QA Group"
859 <email>packages@qa.debian.org</email> takes over the
860 maintainership of the package until someone else
861 volunteers for that task. These packages are called
862 <em>orphaned packages</em>.<footnote>
864 The detailed procedure for doing this gracefully can
865 be found in the Debian Developer's Reference, either
866 in the <tt>developers-reference</tt> package, or on
867 the Debian FTP server
868 <ftpsite>ftp.debian.org</ftpsite> as
869 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
871 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
872 name="Debian Developer's Reference"> webpage.
880 <heading>The description of a package</heading>
883 Every Debian package must have an extended description
884 stored in the appropriate field of the control record.</p>
887 The description should be written so that it gives the
888 system administrator enough information to decide whether
889 to install the package. This description should not just
890 be copied verbatim from the program's documentation.
891 Instructions for configuring or using the package should
892 not be included (that is what installation scripts,
893 manual pages, info files, etc., are for). Copyright
894 statements and other administrivia should not be included
895 either (that is what the copyright file is for).
901 <heading>Dependencies</heading>
904 Every package must specify the dependency information
905 about other packages that are required for the first to
909 For example, a dependency entry must be provided for any
910 shared libraries required by a dynamically-linked executable
911 binary in a package.</p>
914 Packages are not required to declare any dependencies they
915 have on other packages which are marked <tt>Essential</tt>
916 (see below), and should not do so unless they depend on a
917 particular version of that package.</p>
920 Sometimes, a package requires another package to be installed
921 <em>and</em> configured before it can be installed. In this
922 case, you must specify a <tt>Pre-Depends</tt> entry for
926 You should not specify a <tt>Pre-Depends</tt> entry for a
927 package before this has been discussed on the
928 <tt>debian-devel</tt> mailing list and a consensus about
929 doing that has been reached.</p></sect1>
933 <heading>Virtual packages</heading>
936 Sometimes, there are several packages which offer
937 more-or-less the same functionality. In this case, it's
938 useful to define a <em>virtual package</em> whose name
939 describes that common functionality. (The virtual
940 packages only exist logically, not physically; that's why
941 they are called <em>virtual</em>.) The packages with this
942 particular function will then <em>provide</em> the virtual
943 package. Thus, any other package requiring that function
944 can simply depend on the virtual package without having to
945 specify all possible packages individually.</p>
948 All packages should use virtual package names where
949 appropriate, and arrange to create new ones if necessary.
950 They should not use virtual package names (except privately,
951 amongst a cooperating group of packages) unless they have
952 been agreed upon and appear in the list of virtual package
956 The latest version of the authoritative list of virtual
957 package names can be found on
958 <ftpsite>ftp.debian.org</ftpsite> in
959 <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
960 or your local mirror. In addition, it is included in the
961 <tt>debian-policy</tt> package. The procedure for updating
962 the list is described at the top of the file.</p></sect1>
966 <heading>Base packages</heading>
969 The packages included in the <tt>base</tt> section have a
970 special function. They form a minimum subset of the Debian
971 GNU/Linux system that is installed before everything else
972 on a new system. Thus, only very few packages are allowed
973 to go into the <tt>base</tt> section to keep the required
974 disk usage very small.</p>
977 Most of these packages will have the priority value
978 <tt>required</tt> or at least <tt>important</tt>, and many
979 of them will be tagged <tt>essential</tt> (see below).</p>
982 You must not place any packages into the <tt>base</tt>
983 section before this has been discussed on the
984 <tt>debian-devel</tt> mailing list and a consensus about
985 doing that has been reached.</p></sect1>
989 <heading>Essential packages</heading>
992 Some packages are tagged <tt>essential</tt>. (They have
993 <tt>Essential: yes</tt> in their package control record.)
994 This flag is used for packages that are <em>essential</em>
998 Since these packages cannot be easily removed (one has to
999 specify an extra <em>force option</em> to
1000 <prgn>dpkg</prgn> to do so), this flag must not be used
1001 unless absolutely necessary. A shared library package
1002 must not be tagged <tt>essential</tt>; dependencies will
1003 prevent its premature removal, and we need to be able to
1004 remove it when it has been superseded.
1008 Since dpkg will not prevent upgrading of other packages
1009 while an <tt>essential</tt> package is in an unconfigured
1010 state, all <tt>essential</tt> packages must supply all of
1011 their core functionality even when unconfigured. If the
1012 package cannot satisfy this requirement it must not be
1013 tagged as essential, and any packages depending on this
1014 package must instead have explicit dependency fields as
1019 You must not tag any packages <tt>essential</tt> before
1020 this has been discussed on the <tt>debian-devel</tt>
1021 mailing list and a consensus about doing that has been
1026 <sect1 id="maintscripts">
1027 <heading>Maintainer scripts</heading>
1030 The package installation scripts should avoid producing
1031 output which it is unnecessary for the user to see and
1032 should rely on <prgn>dpkg</prgn> to stave off boredom on
1033 the part of a user installing many packages. This means,
1034 amongst other things, using the <tt>--quiet</tt> option on
1035 <prgn>install-info</prgn>.</p>
1038 Errors which occur during the execution of an installation
1039 script must be checked and the installation must not
1040 continue after an error.
1044 Note that in general <ref id="scripts"> applies to package
1045 maintainer scripts, too.
1049 You should not use <tt>dpkg-divert</tt> on a file
1050 belonging to another package without consulting the
1051 maintainer of that package first.
1055 All packages which supply an instance of a common command
1056 name (or, in general, filename) should generally use
1057 <prgn>update-alternatives</prgn>, so that they may be
1058 installed together. If <prgn>update-alternatives</prgn>
1059 is not used, then each package must use
1060 <tt>Conflicts</tt> to ensure that other packages are
1061 de-installed. (In this case, it may be appropriate to
1062 specify a conflict against earlier versions of something
1063 that previously did not use
1064 <prgn>update-alternatives</prgn>; this is an exception to
1065 the usual rule that versioned conflicts should be
1071 <heading>Prompting in maintainer scripts</heading>
1073 Package maintainer scripts may prompt the user if
1074 necessary. Prompting may be accomplished by hand, or by
1075 communicating with a program, such as
1076 <prgn>debconf</prgn>, which conforms to the Debian
1077 Configuration management specification, version 2 or
1078 higher. These are included in the
1079 <file>debconf_specification</file> files in the
1080 <package>debian-policy</package> package.
1081 You may also find this file on the FTP site
1082 <ftpsite>ftp.debian.org</ftpsite> in
1083 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1084 or on your local mirror.<footnote>
1086 2.5% of Debian packages [see <url
1087 id="http://kitenet.net/programs/debconf/stats/"
1088 name="Debconf stats">] currently use
1089 <package>debconf</package> to prompt the user at
1090 install time, and this number is growing daily. The
1091 benefits of using debconf are briefly explained at
1093 id="http://kitenet.net/doc/debconf-doc/introduction.html"
1094 name="Debconf introduction">; they include
1095 preconfiguration, (mostly) noninteractive
1096 installation, elimination of redundant prompting,
1097 consistency of user interface, etc.
1100 With this increasing number of packages using
1101 <package>debconf</package>, plus the existance of a
1102 nascent second implementation of the Debian
1103 configuration management system
1104 (<package>cdebconf</package>), and the stabalization
1105 of the protocol these things use, the time has
1106 finally come to reflect the use of these things in
1113 Packages which use the Debian Configuration management
1114 specification may contain an additional
1115 <file>config</file> script and a <file>templates</file>
1116 file in their control archive. The <prgn>config</prgn>
1117 script might be run before the <prgn>preinst</prgn>
1118 script, and before the package is unpacked or any of its
1119 dependancies or pre-dependancies are satisfied.
1120 Therefore it must work using only the tools present in
1121 <em>essential</em> packages.<footnote>
1123 <package>Debconf</package> or another tool that
1124 implements the Debian Configuration management
1125 specification will also be installed, and any
1126 versioned dependencies on it will be satisfied
1127 before preconfiguration begins.
1133 Packages should try to minimize the amount of prompting
1134 they need to do, and they should ensure that the user
1135 will only ever be asked each question once. This means
1136 that packages should try to use appropriate shared
1137 configuration files (such as <tt>/etc/papersize</tt> and
1138 <tt>/etc/news/server</tt>), and shared
1139 <package>debconf</package> variables rather than each
1140 prompting for their own list of required pieces of
1145 It also means that an upgrade should not ask the same
1146 questions again, unless the user has used <tt>dpkg
1147 --purge</tt> to remove the package's configuration. The
1148 answers to configuration questions should be stored in an
1149 appropriate place in <tt>/etc</tt> so that the user can
1150 modify them, and how this has been done should be
1154 If a package has a vitally important piece of
1155 information to pass to the user (such as "don't run me
1156 as I am, you must edit the following configuration files
1157 first or you risk your system emitting badly-formatted
1158 messages"), it should display this in the
1159 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1160 prompt the user to hit return to acknowledge the
1161 message. Copyright messages do not count as vitally
1162 important (they belong in
1163 <tt>/usr/share/doc/<var>package</var>/copyright</tt>);
1164 neither do instructions on how to use a program (these
1165 should be in on-line documentation, where all the users
1169 Any necessary prompting should almost always be confined
1170 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1171 script. If it is done in the <prgn>postinst</prgn>, it
1172 should be protected with a conditional so that
1173 unnecessary prompting doesn't happen if a package's
1174 installation fails and the <prgn>postinst</prgn> is
1175 called with <tt>abort-upgrade</tt>,
1176 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1181 <heading>Source packages</heading>
1183 <sect1 id="standardsversion">
1184 <heading>Standards conformance</heading>
1187 In the source package's <tt>Standards-Version</tt> control
1188 field, you should specify the most recent version number
1189 of this policy document with which your package complied
1190 when it was last updated. The current version number is
1195 This information may be used to file bug reports
1196 automatically if your package becomes too much out of
1201 The version number has four components: major and minor
1202 version number and major and minor patch level. When the
1203 standards change in a way that requires every package to
1204 change the major number will be changed. Significant
1205 changes that will require work in many packages will be
1206 signaled by a change to the minor number. The major patch
1207 level will be changed for any change to the meaning of the
1208 standards, however small; the minor patch level will be
1209 changed when only cosmetic, typographical or other edits
1210 are made which neither change the meaning of the document
1211 nor affect the contents of packages.</p>
1214 Thus only the first three components of the policy version
1215 are significant in the <em>Standards-Version</em> control
1216 field, and so either these three components or the all
1217 four components may be specified.<footnote>
1219 In the past, people specified the full version number
1220 in the Standards-Version field, for example `2.3.0.0'.
1221 Since minor patch-level changes don't introduce new
1222 policy, it was thought it would be better to relax
1223 policy and only require the first 3 components to be
1224 specified, in this example `2.3.0'. All four
1225 components may still be used if someone wishes to do
1232 You should regularly, and especially if your package has
1233 become out of date, check for the newest Policy Manual
1234 available and update your package, if necessary. When your
1235 package complies with the new standards you should update the
1236 <tt>Standards-Version</tt> source package field and
1237 release it.<footnote>
1239 See the file <tt>upgrading-checklist</tt> for
1240 information about policy which has changed between
1241 different versions of this document.
1249 <heading>Package relationships</heading>
1252 Source packages should specify which binary packages they
1253 require to be installed or not to be installed in order to
1254 build correctly. For example, if building a package
1255 requires a certain compiler, then the compiler should be
1256 specified as a build-time dependency.
1260 It is not necessary to explicitly specify build-time
1261 relationships on a minimal set of packages that are always
1262 needed to compile, link and put in a Debian package a
1263 standard "Hello World!" program written in C or C++. The
1264 required packages are called <em>build-essential</em>, and
1265 an informational list can be found in
1266 <tt>/usr/share/doc/build-essential/list</tt> (which is
1267 contained in the <tt>build-essential</tt>
1270 <list compact="compact">
1272 <p>This allows maintaining the list separately
1273 from the policy documents (the list does not
1274 need the kind of control that the policy
1280 Having a separate package allows one to install
1281 the build-essential packages on a machine, as
1282 well as allowing other packages such as task
1283 packages to require installation of the
1284 build-essential packages using the depends
1290 The separate package allows bug reports against
1291 the list to be categorized separately from
1292 the policy management process in the BTS.
1302 When specifying the set of build-time dependencies, one
1303 should list only those packages explicitly required by the
1304 build. It is not necessary to list packages which are
1305 required merely because some other package in the list of
1306 build-time dependencies depends on them.<footnote>
1308 The reason for this is that dependencies change, and
1309 you should list all those packages, and <em>only</em>
1310 those packages that <em>you</em> need directly. What
1311 others need is their business. For example, if you
1312 only link against <tt>libimlib</tt>, you will need to
1313 build-depend on <package>libimlib2-dev</package> but
1314 not against any <tt>libjpeg*</tt> packages, even
1315 though <tt>libimlib2-dev</tt> currently depends on
1316 them: installation of <package>libimlib2-dev</package>
1317 will automatically ensure that all of its run-time
1318 dependencies are satisfied.
1324 If build-time dependencies are specified, it must be
1325 possible to build the package and produce working binaries
1326 on a system with only essential and build-essential
1327 packages installed and also those required to satisfy the
1328 build-time relationships (including any implied
1329 relationships). In particular, this means that version
1330 clauses should be used rigorously in build-time
1331 relationships so that one cannot produce bad or
1332 inconsistently configured packages when the relationships
1333 are properly satisfied.
1337 <heading>Changes to the upstream sources</heading>
1340 If changes to the source code are made that are not
1341 specific to the needs of the Debian system, they should be
1342 sent to the upstream authors in whatever form they prefer
1343 so as to be included in the upstream version of the
1347 If you need to configure the package differently for
1348 Debian or for Linux, and the upstream source doesn't
1349 provide a way to do so, you should add such configuration
1350 facilities (for example, a new <prgn>autoconf</prgn> test
1351 or <tt>#define</tt>) and send the patch to the upstream
1352 authors, with the default set to the way they originally
1353 had it. You can then easily override the default in your
1354 <tt>debian/rules</tt> or wherever is appropriate.</p>
1357 You should make sure that the <prgn>configure</prgn> utility
1358 detects the correct architecture specification string
1359 (refer to <ref id="arch-spec"> for details).</p>
1362 If you need to edit a <prgn>Makefile</prgn> where
1363 GNU-style <prgn>configure</prgn> scripts are used, you
1364 should edit the <tt>.in</tt> files rather than editing the
1365 <prgn>Makefile</prgn> directly. This allows the user to
1366 reconfigure the package if necessary. You should
1367 <em>not</em> configure the package and edit the generated
1368 <prgn>Makefile</prgn>! This makes it impossible for
1369 someone else to later reconfigure the package.</p></sect1>
1373 <heading>Documenting your changes</heading>
1376 You should document your changes and updates to the source
1377 package properly in the <tt>debian/changelog</tt> file. (Note
1378 that mistakes in changelogs are usually best rectified by
1379 making a new changelog entry rather than "rewriting history"
1380 by editing old changelog entries.)</p>
1383 In non-experimental packages you must use a format for
1384 <tt>debian/changelog</tt> which is supported by the most
1385 recent released version of <prgn>dpkg</prgn>.<footnote>
1387 If you wish to use an alternative format, you may do
1388 so as long as you include a parser for it in your
1389 source package. The parser must have an API
1390 compatible with that expected by
1391 <prgn>dpkg-genchanges</prgn> and
1392 <prgn>dpkg-gencontrol</prgn>. If there is general
1393 interest in the new format, you should contact the
1394 <package>dpkg</package> maintainer to have the parser
1395 script for it included in the <prgn>dpkg</prgn>
1396 package. (You will need to agree that the parser and
1397 its manpage may be distributed under the GNU GPL, just
1398 as the rest of `dpkg' is.)
1406 <heading>Error trapping in makefiles</heading>
1409 When <prgn>make</prgn> invokes a command in a makefile
1410 (including your package's upstream makefiles and
1411 <tt>debian/rules</tt>), it does so using <tt>sh</tt>. This
1412 means that <tt>sh</tt>'s usual bad error handling
1413 properties apply: if you include a miniature script as one
1414 of the commands in your makefile you'll find that if you
1415 don't do anything about it then errors are not detected
1416 and <prgn>make</prgn> will blithely continue after
1420 Every time you put more than one shell command (this
1421 includes using a loop) in a makefile command you
1422 must make sure that errors are trapped. For
1423 simple compound commands, such as changing directory and
1424 then running a program, using <tt>&&</tt> rather
1425 than semicolon as a command separator is sufficient. For
1426 more complex commands including most loops and
1427 conditionals you should include a separate <tt>set -e</tt>
1428 command at the start of every makefile command that's
1429 actually one of these miniature shell scripts.</p></sect1>
1433 <heading>Obsolete constructs and libraries</heading>
1436 The include file <tt><varargs.h></tt> is
1437 provided to support end-users compiling very old software;
1438 the library <tt>libtermcap</tt> is provided to support the
1439 execution of software which has been linked against it
1440 (either old programs or those such as Netscape which are
1441 only available in binary form).</p>
1444 Debian packages should be patched to use
1445 <tt><stdarg.h></tt> and <tt>ncurses</tt>
1452 <chapt id="controlfields"><heading>Control files and their fields</heading>
1455 Many of the tools in the package management suite manipulate
1456 data represented in a common format, known as <em>control
1457 data</em>. The data is often stored in <em>control
1458 files</em>. Binary and source packages have control files,
1459 and the <tt>.changes</tt> files which control the installation
1460 of uploaded files are also in control file format.
1461 <prgn>Dpkg</prgn>'s internal databases are in a similar
1465 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1468 A control file consists of one or more paragraphs of fields.
1469 The paragraphs are separated by blank lines. Some control
1470 files allow only one paragraph; others allow several, in
1471 which case each paragraph usually refers to a different
1472 package. (For example, in source packages, the first
1473 paragraph refers to the source package, and later paragraphs
1474 refer to binary packages generated from the source.)
1478 Each paragraph consists of a series of data fields; each
1479 field consists of the field name, followed by a colon and
1480 then the data/value associated with that field. It ends at
1481 the end of the line. Horizontal whitespace (spaces and
1482 tabs) may occur immediately before or after the value and is
1483 ignored there; it is conventional to put a single space
1484 after the colon. For example, a field might be:
1485 <example compact="compact">
1488 the field name is <tt>Package</tt> and the field value
1493 Some fields' values may span several lines; in this case
1494 each continuation line <em>must</em> start with a space or
1495 tab. Any trailing spaces or tabs at the end of individual
1496 lines of a field value are ignored.
1500 Except where otherwise stated only a single line of data is
1501 allowed and whitespace is not significant in a field body.
1502 Whitespace must not appear inside names (of packages,
1503 architectures, files or anything else) or version numbers,
1504 or between the characters of multi-character version
1509 Field names are not case-sensitive, but it is usual to
1510 capitalize the field names using mixed case as shown below.
1514 Blank lines, or lines consisting only of spaces and tabs,
1515 are not allowed within field values or between fields - that
1516 would mean a new paragraph.
1521 <sect><heading>List of fields</heading>
1523 This list here is not supposed to be exhaustive. Most fields
1524 are dealt with elsewhere in this document.
1526 <sect1 id="f-Package"><heading><tt>Package</tt>
1530 The name of the binary package. Package names consist of
1531 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
1532 (plus, minus and full stop).
1536 They must be at least two characters long and must start
1537 with an alphanumeric character and not be all digits. The
1538 use of lowercase package names is strongly recommended
1539 unless the package you're building (or referring to, in
1540 other fields) is already using uppercase.</p>
1543 <sect1 id="f-Version"><heading><tt>Version</tt>
1547 This lists the source or binary package's version number -
1548 see <ref id="versions">.
1554 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1558 The most recent version of the standards (the policy
1559 manual and associated texts) with which the package
1560 complies. This is updated manually when editing the
1561 source package to conform to newer standards; it can
1562 sometimes be used to tell when a package needs attention.
1563 Its format is described above; see
1564 <ref id="standardsversion">.
1569 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1573 In a <tt>.changes</tt> file or parsed changelog output
1574 this contains the (space-separated) name(s) of the
1575 distribution(s) where this version of the package should
1576 be installed. Valid distributions are determined by the
1577 archive maintainers.<footnote>
1578 Current distribution names are:
1579 <taglist compact="compact">
1580 <tag><em>stable</em></tag>
1583 This is the current `released' version of Debian
1584 GNU/Linux. Once the distribution is
1585 <em>stable</em> only security fixes and other
1586 major bug fixes are allowed. When changes are
1587 made to this distribution, the release number is
1588 increased (for example: 2.2r1 becomes 2.2r2 then
1593 <tag><em>unstable</em></tag>
1596 This distribution value refers to the
1597 <em>developmental</em> part of the Debian
1598 distribution tree. New packages, new upstream
1599 versions of packages and bug fixes go into the
1600 <em>unstable</em> directory tree. Download from
1601 this distribution at your own risk.
1605 <tag><em>testing</em></tag>
1608 This distribution value refers to the
1609 <em>testing</em> part of the Debian distribution
1610 tree. It receives its packages from the
1611 unstable distribution after a short time lag to
1612 ensure that there are no major issues with the
1613 unstable packages. It is less prone to breakage
1614 than unstable, but still risky. It is not
1615 possible to upload packages directly to
1620 <tag><em>frozen</em></tag>
1623 From time to time, the <em>testing</em>
1624 distribution enters a state of `code-freeze' in
1625 anticipation of release as a <em>stable</em>
1626 version. During this period of testing only
1627 fixes for existing or newly-discovered bugs will
1628 be allowed. The exact details of this stage are
1629 determined by the Release Manager.
1633 <tag><em>experimental</em></tag>
1636 The packages with this distribution value are
1637 deemed by their maintainers to be high
1638 risk. Oftentimes they represent early beta or
1639 developmental packages from various sources that
1640 the maintainers want people to try, but are not
1641 ready to be a part of the other parts of the
1642 Debian distribution tree. Download at your own
1648 You should list <em>all</em> distributions that the
1649 package should be installed into.
1658 <chapt id="versions"><heading>Version numbering</heading>
1661 Every package has a version number recorded in its
1662 <tt>Version</tt> control file field.
1666 The package management system imposes an ordering on version
1667 numbers, so that it can tell whether packages are being up- or
1668 downgraded and so that package system front end applications
1669 can tell whether a package it finds available is newer than
1670 the one installed on the system. The version number format
1671 has the most significant parts (as far as comparison is
1672 concerned) at the beginning.
1676 The version number format is:
1677 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1681 The three components here are:
1683 <tag><var>epoch</var></tag>
1686 This is a single (generally small) unsigned integer. It
1687 may be omitted, in which case zero is assumed. If it is
1688 omitted then the <var>upstream_version</var> may not
1693 It is provided to allow mistakes in the version numbers
1694 of older versions of a package, and also a package's
1695 previous version numbering schemes, to be left behind.
1699 <tag><var>upstream_version</var></tag>
1702 This is the main part of the version number. It is
1703 usually the version number of the original (`upstream')
1704 package from which the <tt>.deb</tt> file has been made,
1705 if this is applicable. Usually this will be in the same
1706 format as that specified by the upstream author(s);
1707 however, it may need to be reformatted to fit into the
1708 package management system's format and comparison
1713 The comparison behavior of the package management system
1714 with respect to the <var>upstream_version</var> is
1715 described below. The <var>upstream_version</var>
1716 portion of the version number is mandatory.
1720 The <var>upstream_version</var> may contain only
1721 alphanumerics<footnote>
1722 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1724 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1725 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1726 start with a digit. If there is no
1727 <var>debian_revision</var> then hyphens are not allowed;
1728 if there is no <var>epoch</var> then colons are not
1732 <tag><var>debian_revision</var></tag>
1735 This part of the version number specifies the version of
1736 the Debian package based on the upstream version. It
1737 may contain only alphanumerics and the characters
1738 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1739 compared in the same way as the
1740 <var>upstream_version</var> is.
1744 It is optional; if it isn't present then the
1745 <var>upstream_version</var> may not contain a hyphen.
1746 This format represents the case where a piece of
1747 software was written specifically to be turned into a
1748 Debian package, and so there is only one `debianization'
1749 of it and therefore no revision indication is required.
1753 It is conventional to restart the
1754 <var>debian_revision</var> at <tt>1</tt> each time the
1755 <var>upstream_version</var> is increased.
1759 The package management system will break the version
1760 number apart at the last hyphen in the string (if there
1761 is one) to determine the <var>upstream_version</var> and
1762 <var>debian_revision</var>. The absence of a
1763 <var>debian_revision</var> compares earlier than the
1764 presence of one (but note that the
1765 <var>debian_revision</var> is the least significant part
1766 of the version number).
1773 The <var>upstream_version</var> and <var>debian_revision</var>
1774 parts are compared by the package management system using the
1779 The strings are compared from left to right.
1783 First the initial part of each string consisting entirely of
1784 non-digit characters is determined. These two parts (one of
1785 which may be empty) are compared lexically. If a difference
1786 is found it is returned. The lexical comparison is a
1787 comparison of ASCII values modified so that all the letters
1788 sort earlier than all the non-letters.
1792 Then the initial part of the remainder of each string which
1793 consists entirely of digit characters is determined. The
1794 numerical values of these two parts are compared, and any
1795 difference found is returned as the result of the comparison.
1796 For these purposes an empty string (which can only occur at
1797 the end of one or both version strings being compared) counts
1802 These two steps (comparing and removing initial non-digit
1803 strings and initial digit strings) are repeated until a
1804 difference is found or both strings are exhausted.
1808 Note that the purpose of epochs is to allow us to leave behind
1809 mistakes in version numbering, and to cope with situations
1810 where the version numbering scheme changes. It is
1811 <em>not</em> intended to cope with version numbers containing
1812 strings of letters which the package management system cannot
1813 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1814 silly orderings (the author of this manual has heard of a
1815 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1816 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1817 <tt>2</tt> and so forth).
1821 If an upstream package has problematic version numbers they
1822 should be converted to a sane form for use in the
1823 <tt>Version</tt> field.
1827 <heading>Version numbers based on dates</heading>
1829 In general, Debian packages should use the same version
1830 numbers as the upstream sources.</p>
1833 However, in some cases where the upstream version number is
1834 based on a date (e.g., a development `snapshot' release) the
1835 package management system cannot handle these version
1836 numbers without epochs. For example, dpkg will consider
1837 `96May01' to be greater than `96Dec24'.</p>
1840 To prevent having to use epochs for every new upstream
1841 version, the version number should be changed to the
1842 following format in such cases: `19960501', `19961224'. It
1843 is up to the maintainer whether he/she wants to bother the
1844 upstream maintainer to change the version numbers upstream,
1848 Note that other version formats based on dates which are
1849 parsed correctly by the package management system should
1850 <em>not</em> be changed.</p>
1853 Native Debian packages (i.e., packages which have been
1854 written especially for Debian) whose version numbers include
1855 dates should always use the `YYYYMMDD' format.</p>
1859 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1861 <sect id="timestamps"><heading>Time Stamps</heading>
1863 Maintainers should preserve the modification times of the
1864 upstream source files in a package, as far as is reasonably
1867 The rationale is that there is some information conveyed
1868 by knowing the age of the file, for example, you could
1869 recognize that some documentation is very old by looking
1870 at the modification time, so it would be nice if the
1871 modification time of the upstream source would be
1878 <sect id="debianrules"><heading><tt>debian/rules</tt> - the
1879 main building script</heading>
1882 This file must be an executable makefile, and contains the
1883 package-specific recipes for compiling the package and
1884 building binary package(s) from the source.
1888 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1889 so that it can be invoked by saying its name rather than
1890 invoking <prgn>make</prgn> explicitly.
1894 Since an interactive <tt>debian/rules</tt> script makes it
1895 impossible to auto-compile that package and also makes it
1896 hard for other people to reproduce the same binary
1897 package, all <em>required targets</em> MUST be
1898 non-interactive. At a minimum, required targets are the
1899 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1900 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1901 <em>binary-indep</em>, and <em>build</em>. It also follows
1902 that any target that these targets depend on must also be
1907 The required and optional targets are as follows:
1909 <tag><tt>build</tt></tag>
1912 This should perform all non-interactive configuration
1913 and compilation of the package. If a package has an
1914 interactive pre-build configuration routine, the
1915 Debianized source package must either be built after
1916 this has taken place (so that the binary package can
1917 be built without rerunning the configuration) or the
1918 configuration routine modified to become
1919 non-interactive. (The latter is preferable if there
1920 are architecture-specific features detected by the
1921 configuration routine.)
1925 For some packages, notably ones where the same
1926 source tree is compiled in different ways to produce
1927 two binary packages, the <prgn>build</prgn> target
1928 does not make much sense. For these packages it is
1929 good enough to provide two (or more) targets
1930 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1931 for each of the ways of building the package, and a
1932 <prgn>build</prgn> target that does nothing. The
1933 <prgn>binary</prgn> target will have to build the
1934 package in each of the possible ways and make the
1935 binary package out of each.
1939 The <prgn>build</prgn> target must not do anything
1940 that might require root privilege.
1944 The <prgn>build</prgn> target may need to run the
1945 <prgn>clean</prgn> target first - see below.
1949 When a package has a configuration and build routine
1950 which takes a long time, or when the makefiles are
1951 poorly designed, or when <prgn>build</prgn> needs to
1952 run <prgn>clean</prgn> first, it is a good idea to
1953 <tt>touch build</tt> when the build process is
1954 complete. This will ensure that if <tt>debian/rules
1955 build</tt> is run again it will not rebuild the whole
1958 Another common way to do this is for <prgn>build</prgn>
1959 to depend on <prgn>build-stamp</prgn> and to do
1960 nothing else, and for the <prgn>build-stamp</prgn>
1961 target to do the building and to <tt>touch
1962 build-stamp</tt> on completion. This is
1963 especially useful if the build routine creates a
1964 file or directory called <tt>build</tt>; in such a
1965 case, <prgn>build</prgn> will need to be listed as
1966 a phony target (i.e., as a dependency of the
1967 <tt>.PHONY</tt> target). See the documentation of
1968 <prgn>make</prgn> for more information on phony
1975 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1976 <tt>binary-indep</tt>
1980 The <prgn>binary</prgn> target must be all that is
1981 necessary for the user to build the binary package(s)
1982 produced from this source package. All of these
1983 targets are required to be non-interactive. It is
1984 split into two parts: <prgn>binary-arch</prgn> builds
1985 the binary packages which are specific to a particular
1986 architecture, and <prgn>binary-indep</prgn> builds
1987 those which are not.
1991 <prgn>binary</prgn> may be (and commonly is) a target
1992 with no commands which simply depends on
1993 <prgn>binary-arch</prgn> and
1994 <prgn>binary-indep</prgn>.
1998 Each <prgn>binary-*</prgn> target should depend on
1999 the <prgn>build</prgn> target, above, so that the
2000 package is built if it has not been already. It
2001 should then create the relevant binary package(s),
2002 using <prgn>dpkg-gencontrol</prgn> to make their
2003 control files and <prgn>dpkg-deb</prgn> to build
2004 them and place them in the parent of the top level
2009 Both the <prgn>binary-arch</prgn> and
2010 <prgn>binary-indep</prgn> targets <em>must</em> exist.
2011 If one of them has nothing to do (which will always be
2012 the case if the source generates only a single binary
2013 package, whether architecture-dependent or not), it
2014 must still exist and must always succeed.
2018 The <prgn>binary</prgn> targets must be invoked as
2021 The <prgn>fakeroot</prgn> package often allows one
2022 to build a package correctly even without being
2029 <tag><tt>clean</tt></tag>
2032 This must undo any effects that the <prgn>build</prgn>
2033 and <prgn>binary</prgn> targets may have had, except
2034 that it should leave alone any output files created in
2035 the parent directory by a run of a <prgn>binary</prgn>
2036 target. This target must be non-interactive.
2040 If a <prgn>build</prgn> file is touched at the end of
2041 the <prgn>build</prgn> target, as suggested above, it
2042 should be removed as the first action that
2043 <prgn>clean</prgn> performs, so that running
2044 <prgn>build</prgn> again after an interrupted
2045 <prgn>clean</prgn> doesn't think that everything is
2050 The <prgn>clean</prgn> target may need to be
2051 invoked as root if <prgn>binary</prgn> has been
2052 invoked since the last <prgn>clean</prgn>, or if
2053 <prgn>build</prgn> has been invoked as root (since
2054 <prgn>build</prgn> may create directories, for
2059 <tag><tt>get-orig-source</tt> (optional)</tag>
2062 This target fetches the most recent version of the
2063 original source package from a canonical archive site
2064 (via FTP or WWW, for example), does any necessary
2065 rearrangement to turn it into the original source
2066 tar file format described below, and leaves it in the
2071 This target may be invoked in any directory, and
2072 should take care to clean up any temporary files it
2077 This target is optional, but providing it if
2078 possible is a good idea.
2084 The <prgn>build</prgn>, <prgn>binary</prgn> and
2085 <prgn>clean</prgn> targets must be invoked with the current
2086 directory being the package's top-level directory.
2091 Additional targets may exist in <tt>debian/rules</tt>,
2092 either as published or undocumented interfaces or for the
2093 package's internal use.
2097 The architectures we build on and build for are determined
2098 by <prgn>make</prgn> variables using the utility
2099 <prgn>dpkg-architecture</prgn>. You can determine the
2100 Debian architecture and the GNU style architecture
2101 specification string for the build machine (the machine type
2102 we are building on) as well as for the host machine (the
2103 machine type we are building for). Here is a list of
2104 supported <prgn>make</prgn> variables:
2105 <list compact="compact">
2107 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2110 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2111 specification string)</p>
2114 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2115 <tt>DEB_*_GNU_TYPE</tt>)</p>
2118 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2119 <tt>DEB_*_GNU_TYPE</tt>)</p>
2121 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2122 the build machine or <tt>HOST</tt> for specification of the
2127 Backward compatibility can be provided in the rules file
2128 by setting the needed variables to suitable default
2129 values; please refer to the documentation of
2130 <prgn>dpkg-architecture</prgn> for details.
2134 It is important to understand that the <tt>DEB_*_ARCH</tt>
2135 string only determines which Debian architecture we are
2136 building on or for. It should not be used to get the CPU
2137 or system information; the GNU style variables should be
2142 <sect id="dpkgchangelog"><heading><tt>debian/changelog</tt>
2146 This file records the changes to the Debian-specific parts of the
2149 Though there is nothing stopping an author who is also
2150 the Debian maintainer from using it for all their
2151 changes, it will have to be renamed if the Debian and
2152 upstream maintainers become different people. In such a
2153 case, however, it might be better to maintain the
2154 package as a non-native package.
2160 It has a special format which allows the package building
2161 tools to discover which version of the package is being
2162 built and find out other release-specific information.
2166 That format is a series of entries like this:
2167 <example compact="compact">
2168 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2170 * <var>change details</var>
2171 <var>more change details</var>
2172 * <var>even more change details</var>
2174 -- <var>maintainer name</var> <<var>email address</var>> <var>date</var>
2179 <var>package</var> and <var>version</var> are the source
2180 package name and version number.
2184 <var>distribution(s)</var> lists the distributions where
2185 this version should be installed when it is uploaded - it
2186 is copied to the <tt>Distribution</tt> field in the
2187 <tt>.changes</tt> file. See <ref id="f-Distribution">.
2191 <var>urgency</var> is the value for the <tt>Urgency</tt>
2192 field in the <tt>.changes</tt> file for the upload. It is
2193 not possible to specify an urgency containing commas; commas
2194 are used to separate
2195 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2196 <prgn>dpkg</prgn> changelog format (though there is
2197 currently only one useful <var>keyword</var>,
2198 <tt>urgency</tt>).<footnote>
2200 Usual urgency values are <tt>low</tt>, <tt>medium</tt>,
2201 <tt>high</tt> and <tt>critical</tt>. They have an
2202 effect on how quickly a package will be considered for
2203 inclusion into the <tt>testing</tt> distribution, and
2204 give an indication of the importance of any fixes
2205 included in this upload.
2211 The change details may in fact be any series of lines
2212 starting with at least two spaces, but conventionally each
2213 change starts with an asterisk and a separating space and
2214 continuation lines are indented so as to bring them in
2215 line with the start of the text above. Blank lines may be
2216 used here to separate groups of changes, if desired.
2220 If this upload resolves bugs recorded in the Bug Tracking
2221 System (BTS), they may be automatically closed on the
2222 inclusion of this package into the Debian archive by
2223 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2224 in the change details.<footnote>
2226 To be precise, the string should match the following
2227 Perl regular expression:
2229 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2231 Then all of the bug numbers listed will be closed by the
2232 archive maintenance script (<prgn>katie</prgn>), or in
2233 the case of an NMU, marked as fixed.
2239 The maintainer name and email address used in the changelog
2240 should be the details of the person uploading <em>this</em>
2241 version. They are <em>not</em> necessarily those of the
2242 usual package maintainer. The information here will be
2243 copied to the <tt>Changed-By</tt> field in the
2244 <tt>.changes</tt> file, and then later used to send an
2245 acknowledgement when the upload has been installed.
2249 The <var>date</var> should be in RFC822 format<footnote>
2251 This is generated by the <prgn>822-date</prgn>
2254 </footnote>; it should include the time zone specified
2255 numerically, with the time zone name or abbreviation
2256 optionally present as a comment in parentheses.
2260 The first `title' line with the package name should start
2261 at the left hand margin; the `trailer' line with the
2262 maintainer and date details should be preceded by exactly
2263 one space. The maintainer details and the date must be
2264 separated by exactly two spaces.
2267 <sect1><heading>Defining alternative changelog formats</heading>
2270 It is possible to use a different format to the standard
2271 one, by providing a parser for the format you wish to
2275 A changelog parser must not interact with the user at
2281 <sect id="srcsubstvars"><heading><tt>debian/substvars</tt>
2282 and variable substitutions </heading>
2285 When <prgn>dpkg-gencontrol</prgn>,
2286 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2287 generate control files they perform variable substitutions
2288 on their output just before writing it. Variable
2289 substitutions have the form <tt>${<var>variable</var>}</tt>.
2290 The optional file <tt>debian/substvars</tt> contains
2291 variable substitutions to be used; variables can also be set
2292 directly from <tt>debian/rules</tt> using the <tt>-V</tt>
2293 option to the source packaging commands, and certain
2294 predefined variables are also available.
2298 The <tt>debian/substvars</tt> file is usually generated and
2299 modified dynamically by <tt>debian/rules</tt> targets; in
2300 this case it must be removed by the <prgn>clean</prgn>
2305 See <manref name="dpkg-source" section="1"> for full
2306 details about source variable substitutions, including the
2307 format of <tt>debian/substvars</tt>.</p>
2310 <sect id="debianfiles"><heading><tt>debian/files</tt>
2314 This file is not a permanent part of the source tree; it
2315 is used while building packages to record which files are
2316 being generated. <prgn>dpkg-genchanges</prgn> uses it
2317 when it generates a <tt>.changes</tt> file.
2321 It should not exist in a shipped source package, and so it
2322 (and any backup files or temporary files such as
2323 <tt>files.new</tt><footnote>
2325 <tt>files.new</tt> is used as a temporary file by
2326 <prgn>dpkg-gencontrol</prgn> and
2327 <prgn>dpkg-distaddfile</prgn> - they write a new
2328 version of <tt>files</tt> here before renaming it,
2329 to avoid leaving a corrupted copy if an error
2332 </footnote>) should be removed by the
2333 <prgn>clean</prgn> target. It may also be wise to
2334 ensure a fresh start by emptying or removing it at the
2335 start of the <prgn>binary</prgn> target.
2339 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2340 package, it adds an entry to <tt>debian/files</tt> for the
2341 <tt>.deb</tt> file that will be created when <tt>dpkg-deb
2342 --build</tt> is run for that binary package. So for most
2343 packages all that needs to be done with this file is to
2344 delete it in the <prgn>clean</prgn> target.
2348 If a package upload includes files besides the source
2349 package and any binary packages whose control files were
2350 made with <prgn>dpkg-gencontrol</prgn> then they should be
2351 placed in the parent of the package's top-level directory
2352 and <prgn>dpkg-distaddfile</prgn> should be called to add
2353 the file to the list in <tt>debian/files</tt>.</p>
2356 <sect id="restrictions"><heading>Restrictions on objects in source packages
2360 The source package may not contain any hard links<footnote>
2362 This is not currently detected when building source
2363 packages, but only when extracting
2367 Hard links may be permitted at some point in the
2368 future, but would require a fair amount of
2371 </footnote>, device special files, sockets or setuid or
2372 setgid files.<footnote>
2374 Setgid directories are allowed.
2379 <sect id="descriptions"><heading>Descriptions of packages - the
2380 <tt>Description</tt> field </heading>
2383 The description is intended to describe the program to a user
2384 who has never met it before so that they know whether they
2385 want to install it. It should also give information about the
2386 significant dependencies and conflicts between this package
2387 and others, so that the user knows why these dependencies and
2388 conflicts have been declared.
2391 <sect1><heading>Notes about writing descriptions
2395 The single line synopsis should be kept brief - certainly
2396 under 80 characters.
2400 Do not include the package name in the synopsis line. The
2401 display software knows how to display this already, and you
2402 do not need to state it. Remember that in many situations
2403 the user may only see the synopsis line - make it as
2404 informative as you can.
2408 Do not try to continue the single line synopsis into the
2409 extended description. This will not work correctly when
2410 the full description is displayed, and makes no sense
2411 where only the summary (the single line synopsis) is
2416 The extended description should describe what the package
2417 does and how it relates to the rest of the system (in terms
2418 of, for example, which subsystem it is which part of).
2422 The description field needs to make sense to anyone, even
2423 people who have no idea about any of the things the
2424 package deals with.<footnote>
2426 The blurb that comes with a program in its
2427 announcements and/or <prgn>README</prgn> files is
2428 rarely suitable for use in a description. It is
2429 usually aimed at people who are already in the
2430 community where the package is used.
2436 Put important information first, both in the synopsis and
2437 extended description. Sometimes only the first part of the
2438 synopsis or of the description will be displayed. You can
2439 assume that there will usually be a way to see the whole
2440 extended description.
2444 You may include information about dependencies and so forth
2445 in the extended description, if you wish.
2449 Do not use tab characters. Their effect is not predictable.
2457 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2458 and installation procedure
2461 <sect><heading>Introduction to package maintainer scripts
2465 It is possible to supply scripts as part of a package which
2466 the package management system will run for you when your
2467 package is installed, upgraded or removed.
2471 These scripts are the files <prgn>preinst</prgn>,
2472 <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2473 control area of the package. They must be proper executable
2474 files; if they are scripts (which is recommended), they must
2475 start with the usual <tt>#!</tt> convention. They should be
2476 readable and executable by anyone, and not world-writable.
2480 The package management system looks at the exit status from
2481 these scripts. It is important that they exit with a
2482 non-zero status if there is an error, so that the package
2483 management system can stop its processing. For shell
2484 scripts this means that you <em>almost always</em> need to
2485 use <tt>set -e</tt> (this is usually true when writing shell
2486 scripts, in fact). It is also important, of course, that
2487 they don't exit with a non-zero status if everything went
2492 When a package is upgraded a combination of the scripts from
2493 the old and new packages is called during the upgrade
2494 procedure. If your scripts are going to be at all
2495 complicated you need to be aware of this, and may need to
2496 check the arguments to your scripts.
2500 Broadly speaking the <prgn>preinst</prgn> is called before
2501 (a particular version of) a package is installed, and the
2502 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2503 before (a version of) a package is removed and the
2504 <prgn>postrm</prgn> afterwards.
2508 Programs called from maintainer scripts should not normally
2509 have a path prepended to them. Before installation is
2510 started, the package management system checks to see if the
2511 programs <prgn>ldconfig</prgn>,
2512 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2513 and <prgn>update-rc.d</prgn> can be found via the
2514 <tt>PATH</tt> environment variable. Those programs, and any
2515 other program that one would expect to be on the
2516 <tt>PATH</tt>, should thus be invoked without an absolute
2517 pathname. Maintainer scripts should also not reset the
2518 <tt>PATH</tt>, though they might choose to modify it by
2519 prepending or appending package-specific directories. These
2520 considerations really apply to all shell scripts.</p>
2524 <heading>Maintainer scripts Idempotency</heading>
2527 It is necessary for the error recovery procedures that the
2528 scripts be idempotent. This means that if it is run
2529 successfully, and then it is called again, it doesn't bomb
2530 out or cause any harm, but just ensures that everything is
2531 the way it ought to be. If the first call failed, or
2532 aborted half way through for some reason, the second call
2533 should merely do the things that were left undone the first
2534 time, if any, and exit with a success status if everything
2537 This is so that if an error occurs, the user interrupts
2538 <prgn>dpkg</prgn> or some other unforeseen circumstance
2539 happens you don't leave the user with a badly-broken
2540 package when <prgn>dpkg</prgn> attempts to repeat the
2548 <heading>Controlling terminal for maintainer scripts</heading>
2551 The maintainer scripts are guaranteed to run with a
2552 controlling terminal and can interact with the user.
2553 If they need to prompt for passwords, do full-screen
2554 interaction or something similar you should do these
2555 things to and from <tt>/dev/tty</tt>, since
2556 <prgn>dpkg</prgn> will at some point redirect scripts'
2557 standard input and output so that it can log the
2558 installation process. Likewise, because these scripts
2559 may be executed with standard output redirected into a
2560 pipe for logging purposes, Perl scripts should set
2561 unbuffered output by setting <tt>$|=1</tt> so that the
2562 output is printed immediately rather than being
2567 Each script should return a zero exit status for
2568 success, or a nonzero one for failure.
2572 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2577 <list compact="compact">
2579 <p><var>new-preinst</var> <tt>install</tt></p>
2582 <p><var>new-preinst</var> <tt>install</tt>
2583 <var>old-version</var></p>
2586 <p><var>new-preinst</var> <tt>upgrade</tt>
2587 <var>old-version</var></p>
2590 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2591 <var>new-version</var>
2597 <list compact="compact">
2599 <p><var>postinst</var> <tt>configure</tt>
2600 <var>most-recently-configured-version</var></p>
2603 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2604 <var>new-version</var></p>
2607 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2608 <tt>in-favour</tt> <var>package</var>
2609 <var>new-version</var></p>
2613 <var>deconfigured's-postinst</var>
2614 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2615 <var>failed-install-package</var> <var>version</var>
2616 <tt>removing</tt> <var>conflicting-package</var>
2623 <list compact="compact">
2625 <p><var>prerm</var> <tt>remove</tt></p>
2628 <p><var>old-prerm</var> <tt>upgrade</tt>
2629 <var>new-version</var></p>
2632 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2633 <var>old-version</var></p>
2636 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2637 <tt>in-favour</tt> <var>package</var>
2638 <var>new-version</var></p>
2642 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2643 <tt>in-favour</tt> <var>package-being-installed</var>
2644 <var>version</var> <tt>removing</tt>
2645 <var>conflicting-package</var>
2652 <list compact="compact">
2654 <p><var>postrm</var> <tt>remove</tt></p>
2657 <p><var>postrm</var> <tt>purge</tt></p>
2661 <var>old-postrm</var> <tt>upgrade</tt>
2662 <var>new-version</var></p>
2665 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2666 <var>old-version</var></p>
2669 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2672 <p><var>new-postrm</var> <tt>abort-install</tt>
2673 <var>old-version</var></p>
2676 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2677 <var>old-version</var></p>
2681 <var>disappearer's-postrm</var> <tt>disappear</tt>
2682 <var>overwriter</var>
2683 <var>overwriter-version</var></p></item>
2688 <sect id="unpackphase"><heading>Details of unpack phase of
2689 installation or upgrade
2693 The procedure on installation/upgrade/overwrite/disappear
2694 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2695 stage of <tt>dpkg --install</tt>) is as follows. In each
2696 case, if a major error occurs (unless listed below) the
2697 actions are, in general, run backwards - this means that the
2698 maintainer scripts are run with different arguments in
2699 reverse order. These are the `error unwind' calls listed
2707 <p>If a version of the package is already
2709 <example compact="compact">
2710 <var>old-prerm</var> upgrade <var>new-version</var>
2715 If the script runs but exits with a non-zero
2716 exit status, <prgn>dpkg</prgn> will attempt:
2717 <example compact="compact">
2718 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2720 Error unwind, for both the above cases:
2721 <example compact="compact">
2722 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2730 <p>If a `conflicting' package is being removed at the same time:
2734 If any packages depended on that conflicting
2735 package and <tt>--auto-deconfigure</tt> is
2736 specified, call, for each such package:
2737 <example compact="compact">
2738 <var>deconfigured's-prerm</var> deconfigure \
2739 in-favour <var>package-being-installed</var> <var>version</var> \
2740 removing <var>conflicting-package</var> <var>version</var>
2743 <example compact="compact">
2744 <var>deconfigured's-postinst</var> abort-deconfigure \
2745 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2746 removing <var>conflicting-package</var> <var>version</var>
2748 The deconfigured packages are marked as
2749 requiring configuration, so that if
2750 <tt>--install</tt> is used they will be
2751 configured again if possible.</p>
2754 <p>To prepare for removal of the conflicting package, call:
2755 <example compact="compact">
2756 <var>conflictor's-prerm</var> remove \
2757 in-favour <var>package</var> <var>new-version</var>
2760 <example compact="compact">
2761 <var>conflictor's-postinst</var> abort-remove \
2762 in-favour <var>package</var> <var>new-version</var>
2773 <p>If the package is being upgraded, call:
2774 <example compact="compact">
2775 <var>new-preinst</var> upgrade <var>old-version</var>
2780 Otherwise, if the package had some configuration
2781 files from a previous version installed (i.e., it
2782 is in the `configuration files only' state):
2783 <example compact="compact">
2784 <var>new-preinst</var> install <var>old-version</var>
2788 <p>Otherwise (i.e., the package was completely purged):
2789 <example compact="compact">
2790 <var>new-preinst</var> install
2792 Error unwind actions, respectively:
2793 <example compact="compact">
2794 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2795 <var>new-postrm</var> abort-install <var>old-version</var>
2796 <var>new-postrm</var> abort-install
2805 The new package's files are unpacked, overwriting any
2806 that may be on the system already, for example any
2807 from the old version of the same package or from
2808 another package. Backups of the old files are kept
2809 temporarily, and if anything goes wrong the package
2810 management system will attempt to put them back as
2811 part of the error unwind.
2815 It is an error for a package to contains files which
2816 are on the system in another package, unless
2817 <tt>Replaces</tt> is used (see <ref id="replaces">).
2819 The following paragraph is not currently the case:
2820 Currently the <tt>- - force-overwrite</tt> flag is
2821 enabled, downgrading it to a warning, but this may not
2827 It is a more serious error for a package to contain a
2828 plain file or other kind of non-directory where another
2829 package has a directory (again, unless
2830 <tt>Replaces</tt> is used). This error can be
2831 overridden if desired using
2832 <tt>--force-overwrite-dir</tt>, but this is not
2837 Packages which overwrite each other's files produce
2838 behavior which, though deterministic, is hard for the
2839 system administrator to understand. It can easily
2840 lead to `missing' programs if, for example, a package
2841 is installed which overwrites a file from another
2842 package, and is then removed again.<footnote>
2844 Part of the problem is due to what is arguably a
2845 bug in <prgn>dpkg</prgn>.
2851 A directory will never be replaced by a symbolic link
2852 to a directory or vice versa; instead, the existing
2853 state (symlink or not) will be left alone and
2854 <prgn>dpkg</prgn> will follow the symlink if there is
2862 <p>If the package is being upgraded, call
2863 <example compact="compact">
2864 <var>old-postrm</var> upgrade <var>new-version</var>
2869 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2870 <example compact="compact">
2871 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2873 Error unwind, for both cases:
2874 <example compact="compact">
2875 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2882 This is the point of no return - if
2883 <prgn>dpkg</prgn> gets this far, it won't back off
2884 past this point if an error occurs. This will
2885 leave the package in a fairly bad state, which
2886 will require a successful re-installation to clear
2887 up, but it's when <prgn>dpkg</prgn> starts doing
2888 things that are irreversible.
2893 Any files which were in the old version of the package
2894 but not in the new are removed.</p>
2897 <p>The new file list replaces the old.</p>
2900 <p>The new maintainer scripts replace the old.</p>
2904 <p>Any packages all of whose files have been overwritten during the
2905 installation, and which aren't required for
2906 dependencies, are considered to have been removed.
2907 For each such package
2910 <p><prgn>dpkg</prgn> calls:
2911 <example compact="compact">
2912 <var>disappearer's-postrm</var> disappear \
2913 <var>overwriter</var> <var>overwriter-version</var>
2918 <p>The package's maintainer scripts are removed.
2923 It is noted in the status database as being in a
2924 sane state, namely not installed (any conffiles
2925 it may have are ignored, rather than being
2926 removed by <prgn>dpkg</prgn>). Note that
2927 disappearing packages do not have their prerm
2928 called, because <prgn>dpkg</prgn> doesn't know
2929 in advance that the package is going to
2938 Any files in the package we're unpacking that are also
2939 listed in the file lists of other packages are removed
2940 from those lists. (This will lobotomize the file list
2941 of the `conflicting' package if there is one.)
2946 The backup files made during installation, above, are
2953 The new package's status is now sane, and recorded as
2958 Here is another point of no return - if the
2959 conflicting package's removal fails we do not unwind
2960 the rest of the installation; the conflicting package
2961 is left in a half-removed limbo.
2967 If there was a conflicting package we go and do the
2968 removal actions (described below), starting with the
2969 removal of the conflicting package's files (any that
2970 are also in the package being installed have already
2971 been removed from the conflicting package's file list,
2972 and so do not get removed now).
2979 <sect id="configdetails"><heading>Details of configuration</heading>
2982 When we configure a package (this happens with <tt>dpkg
2983 --install</tt> and <tt>dpkg --configure</tt>), we first
2984 update any <tt>conffile</tt>s and then call:
2985 <example compact="compact">
2986 <var>postinst</var> configure <var>most-recently-configured-version</var>
2991 No attempt is made to unwind after errors during
2996 If there is no most recently configured version
2997 <prgn>dpkg</prgn> will pass a null argument; older versions
2998 of dpkg may pass <tt><unknown></tt> (including the
2999 angle brackets) in this case. Even older ones do not pass a
3000 second argument at all, under any circumstances.
3004 <sect id="removedetails"><heading>Details of removal and/or
3005 configuration purging</heading>
3011 <example compact="compact">
3012 <var>prerm</var> remove
3018 The package's files are removed (except <tt>conffile</tt>s).
3023 <example compact="compact">
3024 <var>postrm</var> remove
3030 All the maintainer scripts except the <prgn>postrm</prgn>
3035 If we aren't purging the package we stop here. Note
3036 that packages which have no <prgn>postrm</prgn> and no
3037 <tt>conffile</tt>s are automatically purged when
3038 removed, as there is no difference except for the
3039 <prgn>dpkg</prgn> status.</p>
3043 The <tt>conffile</tt>s and any backup files
3044 (<tt>~</tt>-files, <tt>#*#</tt> files,
3045 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3050 <example compact="compact">
3051 <var>postrm</var> purge
3056 <p>The package's file list is removed.</p>
3059 No attempt is made to unwind after errors during
3066 <chapt id="relationships"><heading>Declaring relationships between
3070 Packages can declare in their control file that they have
3071 certain relationships to other packages - for example, that
3072 they may not be installed at the same time as certain other
3073 packages, and/or that they depend on the presence of others,
3074 or that they should overwrite files in certain other packages
3079 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3080 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3081 <tt>Conflicts</tt>, <tt>Provides</tt> and <tt>Replaces</tt>
3082 control file fields.
3086 Source packages may declare relationships to binary packages,
3087 saying that they require certain binary packages to be
3088 installed or absent at the time of building the package.
3092 This is done using the <tt>Build-Depends</tt>,
3093 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3094 <tt>Build-Conflicts-Indep</tt> control file fields.
3097 <sect id="depsyntax"><heading>Syntax of relationship fields
3101 These fields all have a uniform syntax. They are a list of
3102 package names separated by commas.
3106 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3107 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3108 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3109 control file fields of the package, which declare
3110 dependencies on other packages, the package names listed may
3111 also include lists of alternative package names, separated
3112 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3113 if any one of the alternative packages is installed, that
3114 part of the dependency is considered to be satisfied.
3118 All of the fields except for <tt>Provides</tt> may restrict
3119 their applicability to particular versions of each named
3120 package. This is done in parentheses after each individual
3121 package name; the parentheses should contain a relation from
3122 the list below followed by a version number, in the format
3123 described in <ref id="versions">.
3127 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3128 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3129 strictly earlier, earlier or equal, exactly equal, later or
3130 equal and strictly later, respectively. The deprecated
3131 forms <tt><</tt> and <tt>></tt> were used to mean
3132 earlier/later or equal, rather than strictly earlier/later,
3133 so they should not appear in new packages (though
3134 <prgn>dpkg</prgn> still supports them).
3138 Whitespace may appear at any point in the version
3139 specification subject to the rules in <ref
3140 id="controlsyntax">, and must appear where it's necessary to
3141 disambiguate; it is not otherwise significant. For
3142 consistency and in case of future changes to
3143 <prgn>dpkg</prgn> it is recommended that a single space be
3144 used after a version relationship and before a version
3145 number; it is also conventional to put a single space after
3146 each comma, on either side of each vertical bar, and before
3147 each open parenthesis.
3151 For example, a list of dependencies might appear as:
3152 <example compact="compact">
3155 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3160 All fields that specify build-time relationships
3161 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3162 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3163 may be restricted to a certain set of architectures. This
3164 is indicated in brackets after each individual package name and
3165 the optional version specification. The brackets enclose a
3166 list of Debian architecture names separated by whitespace.
3167 Exclamation marks may be prepended to each of the names.
3168 (It is not permitted for some names to be prepended with
3169 exclamation marks and others not.) If the current Debian
3170 host architecture is not in this list and there are no
3171 exclamation marks in the list, or it is in the list with a
3172 prepended exclamation mark, the package name and the
3173 associated version specification are ignored completely for
3174 the purposes of defining the relationships.
3179 <example compact="compact">
3181 Build-Depends-Indep: texinfo
3182 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3183 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3188 Note that the binary package relationship fields such as
3189 <tt>Depends</tt> appear in one of the binary package
3190 sections of the control file, whereas the build-time
3191 relationships such as <tt>Build-Depends</tt> appear in the
3192 source package section of the control file (which is the
3198 <heading>Binary Dependencies - <tt>Depends</tt>,
3199 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3200 <tt>Pre-Depends</tt>
3204 These five fields are used to declare a dependency
3205 relationship by one package on another. Except for
3206 <tt>Enhances</tt>, they appear in the depending (binary)
3207 package's control file. (<tt>Enhances</tt> appears in the
3208 recommending package's control file.)
3212 A <tt>Depends</tt> field takes effect <em>only</em> when a
3213 package is to be configured. It does not prevent a package
3214 being on the system in an unconfigured state while its
3215 dependencies are unsatisfied, and it is possible to replace
3216 a package whose dependencies are satisfied and which is
3217 properly installed with a different version whose
3218 dependencies are not and cannot be satisfied; when this is
3219 done the depending package will be left unconfigured (since
3220 attempts to configure it will give errors) and will not
3221 function properly. If it is necessary, a
3222 <tt>Pre-Depends</tt> field can be used, which has a partial
3223 effect even when a package is being unpacked, as explained
3224 in detail below. (The other three dependency fields,
3225 <tt>Recommends</tt>, <tt>Suggests</tt> and
3226 <tt>Enhances</tt>, are only used by the various front-ends
3227 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3231 For this reason packages in an installation run are usually
3232 all unpacked first and all configured later; this gives
3233 later versions of packages with dependencies on later
3234 versions of other packages the opportunity to have their
3235 dependencies satisfied.
3239 The <tt>Depends</tt> field thus allows package maintainers
3240 to impose an order in which packages should be configured.
3244 The meaning of the five dependency fields is as follows:
3246 <tag><tt>Depends</tt></tag>
3249 This declares an absolute dependency. A package will
3250 not be configured unless all of the packages listed in
3251 its <tt>Depends</tt> field have been correctly
3256 The <tt>Depends</tt> field should be used if the
3257 depended-on package is required for the depending
3258 package to provide a significant amount of
3262 The <tt>Depends</tt> field should also be used if the
3263 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3264 <prgn>postrm</prgn> scripts require the package to be
3265 present in order to run. Note, however, that the
3266 <prgn>postrm</prgn> cannot rely on any non-essential
3267 packages to be present during the <tt>purge</tt>
3271 <tag><tt>Recommends</tt></tag>
3273 <p>This declares a strong, but not absolute, dependency.
3277 The <tt>Recommends</tt> field should list packages
3278 that would be found together with this one in all but
3279 unusual installations.</p>
3282 <tag><tt>Suggests</tt></tag>
3285 This is used to declare that one package may be more
3286 useful with one or more others. Using this field
3287 tells the packaging system and the user that the
3288 listed packages are related to this one and can
3289 perhaps enhance its usefulness, but that installing
3290 this one without them is perfectly reasonable.
3294 <tag><tt>Enhances</tt></tag>
3297 This field is similar to Suggests but works in the
3298 opposite direction. It is used to declare that a
3299 package can enhance the functionality of another
3304 <tag><tt>Pre-Depends</tt></tag>
3307 This field is like <tt>Depends</tt>, except that it
3308 also forces <prgn>dpkg</prgn> to complete installation
3309 of the packages named before even starting the
3310 installation of the package which declares the
3311 pre-dependency, as follows:
3315 When a package declaring a pre-dependency is about to
3316 be <em>unpacked</em> the pre-dependency can be
3317 satisfied if the depended-on package is either fully
3318 configured, <em>or even if</em> the depended-on
3319 package(s) are only unpacked or half-configured,
3320 provided that they have been configured correctly at
3321 some point in the past (and not removed or partially
3322 removed since). In this case, both the
3323 previously-configured and currently unpacked or
3324 half-configured versions must satisfy any version
3325 clause in the <tt>Pre-Depends</tt> field.
3329 When the package declaring a pre-dependency is about
3330 to be <em>configured</em>, the pre-dependency will be
3331 treated as a normal <tt>Depends</tt>, that is, it will
3332 be considered satisfied only if the depended-on
3333 package has been correctly configured.
3337 <tt>Pre-Depends</tt> should be used sparingly,
3338 preferably only by packages whose premature upgrade or
3339 installation would hamper the ability of the system to
3340 continue with any upgrade that might be in progress.
3344 <tt>Pre-Depends</tt> are also required if the
3345 <prgn>preinst</prgn> script depends on the named
3346 package. It is best to avoid this situation if
3352 When selecting which level of dependency to use you should
3353 consider how important the depended-on package is to the
3354 functionality of the one declaring the dependency. Some
3355 packages are composed of components of varying degrees of
3356 importance. Such a package should list using
3357 <tt>Depends</tt> the package(s) which are required by the
3358 more important components. The other components'
3359 requirements may be mentioned as Suggestions or
3360 Recommendations, as appropriate to the components' relative
3365 <sect id="conflicts"><heading>Conflicting binary packages -
3366 <tt>Conflicts</tt></heading>
3369 When one binary package declares a conflict with another
3370 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3371 refuse to allow them to be installed on the system at the
3376 If one package is to be installed, the other must be removed
3377 first - if the package being installed is marked as
3378 replacing (see <ref id="replaces">) the one on the system,
3379 or the one on the system is marked as deselected, or both
3380 packages are marked <tt>Essential</tt>, then
3381 <prgn>dpkg</prgn> will automatically remove the package
3382 which is causing the conflict, otherwise it will halt the
3383 installation of the new package with an error. This
3384 mechanism is specifically designed to produce an error when
3385 the installed package is <tt>Essential</tt>, but the new
3390 A package will not cause a conflict merely because its
3391 configuration files are still installed; it must be at least
3396 A special exception is made for packages which declare a
3397 conflict with their own package name, or with a virtual
3398 package which they provide (see below): this does not
3399 prevent their installation, and allows a package to conflict
3400 with others providing a replacement for it. You use this
3401 feature when you want the package in question to be the only
3402 package providing some feature.
3406 A <tt>Conflicts</tt> entry should almost never have an
3407 `earlier than' version clause. This would prevent
3408 <prgn>dpkg</prgn> from upgrading or installing the package
3409 which declared such a conflict until the upgrade or removal
3410 of the conflicted-with package had been completed.
3414 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3418 As well as the names of actual (`concrete') packages, the
3419 package relationship fields <tt>Depends</tt>,
3420 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3421 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3422 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3423 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3424 may mention `virtual packages'.
3428 A <em>virtual package</em> is one which appears in the
3429 <tt>Provides</tt> control file field of another package.
3430 The effect is as if the package(s) which provide a
3431 particular virtual package name had been listed by name
3432 everywhere the virtual package name appears.
3436 If there are both a real and a virtual package of the same
3437 name then the dependency may be satisfied (or the conflict
3438 caused) by either the real package or any of the virtual
3439 packages which provide it. This is so that, for example,
3441 <example compact="compact">
3445 and someone else releases an enhanced version of the
3446 <tt>bar</tt> package (for example, a non-US variant), they
3448 <example compact="compact">
3452 and the <tt>bar-plus</tt> package will now also satisfy the
3453 dependency for the <tt>foo</tt> package.
3457 If a dependency or a conflict has a version number attached
3458 then only real packages will be considered to see whether
3459 the relationship is satisfied (or the prohibition violated,
3460 for a conflict) - it is assumed that a real package which
3461 provides the virtual package is not of the `right' version.
3462 So, a <tt>Provides</tt> field may not contain version
3463 numbers, and the version number of the concrete package
3464 which provides a particular virtual package will not be
3465 looked at when considering a dependency on or conflict with
3466 the virtual package name.
3470 It is likely that the ability will be added in a future
3471 release of <prgn>dpkg</prgn> to specify a version number for
3472 each virtual package it provides. This feature is not yet
3473 present, however, and is expected to be used only
3478 If you want to specify which of a set of real packages
3479 should be the default to satisfy a particular dependency on
3480 a virtual package, you should list the real package as an
3481 alternative before the virtual one.
3486 <sect id="replaces"><heading>Overwriting files and replacing
3487 packages - <tt>Replaces</tt></heading>
3490 The <tt>Replaces</tt> control file field has two distinct
3491 purposes, which come into play in different situations.
3494 <sect1><heading>Overwriting files in other packages</heading>
3497 Firstly, as mentioned before, it is usually an error for a
3498 package to contain files which are on the system in
3503 However, if the overwriting package declares that it
3504 <tt>Replaces</tt> the one containing the file being
3505 overwritten, then <prgn>dpkg</prgn> will replace the file
3506 from the old package with that from the new. The file
3507 will no longer be listed as `owned' by the old package.
3511 If a package is completely replaced in this way, so that
3512 <prgn>dpkg</prgn> does not know of any files it still
3513 contains, it is considered to have `disappeared'. It will
3514 be marked as not wanted on the system (selected for
3515 removal) and not installed. Any <tt>conffile</tt>s
3516 details noted for the package will be ignored, as they
3517 will have been taken over by the overwriting package. The
3518 package's <prgn>postrm</prgn> script will be run with a
3519 special argument to allow the package to do any final
3520 cleanup required. See <ref id="mscriptsinstact">.
3524 If an installed package, <tt>foo</tt> say, declares that
3525 it replaces another, <tt>bar</tt>, and an attempt is made
3526 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3527 files in the <tt>bar</tt> package which would overwrite
3528 those already present in <tt>foo</tt>. This is so that
3529 you can install an older version of a package without
3534 For this usage of <tt>Replaces</tt>, virtual packages (see
3535 <ref id="virtual">) are not considered when looking at a
3536 <tt>Replaces</tt> field - the packages declared as being
3537 replaced must be mentioned by their real names.
3541 Furthermore, this usage of <tt>Replaces</tt> only takes
3542 effect when both packages are at least partially on the
3543 system at once, so that it can only happen if they do not
3544 conflict or if the conflict has been overridden.
3549 <sect1><heading>Replacing whole packages, forcing their
3553 Secondly, <tt>Replaces</tt> allows the packaging system to
3554 resolve which package should be removed when there is a
3555 conflict - see <ref id="conflicts">. This usage only
3556 takes effect when the two packages <em>do</em> conflict,
3557 so that the two usages of this field do not interfere with
3562 In this situation, the package declared as being replaced
3563 can be a virtual package, so for example, all mail
3564 transport agents (MTAs) would have the following fields in
3565 their control files:
3566 <example compact="compact">
3567 Provides: mail-transport-agent
3568 Conflicts: mail-transport-agent
3569 Replaces: mail-transport-agent
3571 ensuring that only one MTA can be installed at any one
3576 <sect><heading>Relationships between source and binary packages -
3577 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3578 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3582 A source package may declare a dependency or a conflict on a
3583 binary package, indicating which packages are required to be
3584 present on the system in order to build the binary packages
3585 from the source package. This is done with the control file
3586 fields <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3587 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>.
3588 The dependencies and conflicts they define must be satisfied
3589 (as defined earlier for binary packages) in order to invoke
3590 the targets in <tt>debian/rules</tt>, as follows:
3593 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3596 The <tt>Build-Depends</tt> and
3597 <tt>Build-Conflicts</tt> fields must be satisfied when
3598 any of the following targets is invoked:
3599 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>
3600 and <tt>binary-indep</tt>.
3603 <tag><tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt></tag>
3606 The <tt>Build-Depends-Indep</tt> and
3607 <tt>Build-Conflicts-Indep</tt> fields must be
3608 satisfied when any of the following targets is
3609 invoked: <tt>binary</tt> and <tt>binary-indep</tt>.
3620 <chapt id="conffiles"><heading>Configuration file handling
3624 This chapter has been superseded by <ref id="config files">.
3628 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3631 Packages containing shared libraries must be constructed with
3632 a little care to make sure that the shared library is always
3633 available. This is especially important for packages whose
3634 shared libraries are vitally important, such as the C library
3635 (currently <tt>libc6</tt>).
3639 Firstly, the package should install the shared libraries under
3640 their normal names. For example, the <tt>libgdbmg1</tt>
3641 package should install <tt>libgdbm.so.1.7.3</tt> as
3642 <tt>/usr/lib/libgdbm.so.1.7.3</tt>. The files should not be
3643 renamed or re-linked by any <prgn>prerm</prgn> or
3644 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3645 of renaming things safely without affecting running programs,
3646 and attempts to interfere with this are likely to lead to
3651 Secondly, the package should include the symbolic link that
3652 <prgn>ldconfig</prgn> would create for the shared libraries.
3653 For example, the <prgn>libgdbmg1</prgn> package should include
3654 a symbolic link from <tt>/usr/lib/libgdbm.so.1</tt> to
3655 <tt>libgdbm.so.1.7.3</tt>. This is needed so that the dynamic
3656 linker (for example <prgn>ld.so</prgn> or
3657 <prgn>ld-linux.so.*</prgn>) can find the library between the
3658 time that <prgn>dpkg</prgn> installs it and the time that
3659 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3662 The package management system requires the library to be
3663 placed before the symbolic link pointing to it in the
3664 <tt>.deb</tt> file. This is so that when
3665 <prgn>dpkg</prgn> comes to install the symlink
3666 (overwriting the previous symlink pointing at an older
3667 version of the library), the new shared library is already
3668 in place. In the past, this was achieved by creating the
3669 library in the temporary packaging directory before
3670 creating the symlink. Unfortunately, this was not always
3671 effective, since the building of the tar file in the
3672 <tt>.deb</tt> depended on the behavior of the underlying
3673 file system. Some file systems (such as reiserfs) reorder
3674 the files so that the order of creation is forgotten.
3675 Starting with release <tt>1.7.0</tt>, <prgn>dpkg</prgn>
3676 will reorder the files itself as necessary when building a
3677 package. Thus it is no longer important to concern
3678 oneself with the order of file creation.
3684 Thirdly, the associated development package should contain a
3685 symlink for the shared library without a version number. For
3686 example, the <tt>libgdbmg1-dev</tt> package should include a
3687 symlink from <tt>/usr/lib/libgdbm.so</tt> to
3688 <tt>libgdbm.so.1.7.3</tt>. This symlink is needed by the
3689 linker (<prgn>ld</prgn>) when compiling packages, as it will
3690 only look for <tt>libgdbm.so</tt> when compiling dynamically.
3694 Any package installing shared libraries in one of the default
3695 library directories of the dynamic linker (which are currently
3696 <tt>/usr/lib</tt> and <tt>/lib</tt>) or a directory that is
3697 listed in <tt>/etc/ld.so.conf</tt><footnote>
3700 <list compact="compact">
3701 <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3702 <item><p>/usr/local/lib</p></item>
3703 <item><p>/usr/lib/libc5-compat</p></item>
3704 <item><p>/lib/libc5-compat</p></item>
3705 <item><p>/usr/X11R6/lib</p></item>
3709 must call <prgn>ldconfig</prgn> in its <prgn>postinst</prgn>
3710 script if the first argument is <tt>configure</tt> and should
3711 call it in the <prgn>postrm</prgn> script if the first
3712 argument is <tt>remove</tt>.
3716 However, <prgn>postrm</prgn> and <prgn>preinst</prgn> scripts
3717 <em>must not</em> call <prgn>ldconfig</prgn> in the case where
3718 the package is being upgraded (see <ref id="unpackphase"> for
3719 details), as <prgn>ldconfig</prgn> will see the temporary
3720 names that <prgn>dpkg</prgn> uses for the files while it is
3721 installing them and will make the shared library links point
3722 to them, just before <prgn>dpkg</prgn> continues the
3723 installation and renames the temporary files!
3727 <heading>Handling shared library dependencies - the
3728 <tt>shlibs</tt> system</heading>
3731 If a package contains a binary or library which links to a
3732 shared library, we must ensure that when the package is
3733 installed on the system, all of the libraries needed are
3734 also installed. This requirement led to the creation of the
3735 <tt>shlibs</tt> system, which is very simple in its design:
3736 any package which <em>provides</em> a shared library also
3737 provides information on the package dependencies required to
3738 ensure the presence of this library, and any package which
3739 <em>uses</em> a shared library uses this information to
3740 determine the dependencies it requires. The files which
3741 contain the mapping from shared libraries to the necessary
3742 dependency information are called <tt>shlibs</tt> files.
3746 Thus, when a package is built which contains any shared
3747 libraries, it must provide a <tt>shlibs</tt> file for other
3748 packages to use, and when a package is built which contains
3749 any shared libraries or compiled binaries, it must run
3750 <prgn>dpkg-shlibdeps</prgn> on these to determine the
3751 libraries used and hence the dependencies needed by this
3754 In the past, the shared libraries linked to were
3755 determined by calling <prgn>ldd</prgn>, but now
3756 <prgn>objdump</prgn> to do this. The only change this
3757 makes to package building is that
3758 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
3759 libraries, whereas in the past this was unnecessary.
3760 The rest of this footnote explains the advantage that
3765 We say that a binary <tt>foo</tt> <em>directly</em> uses
3766 a library <tt>libbar</tt> if it is explicitly linked
3767 with that library (that is, it uses the flag
3768 <tt>-lbar</tt> during the linking stage). Other
3769 libraries that are needed by <tt>libbar</tt> are linked
3770 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
3771 linker will load them automatically when it loads
3772 <tt>libbar</tt>. A package should needs to depend on
3773 the libraries it directly uses, and the dependencies for
3774 those libraries should automatically pull in the other
3779 Unfortunately, the <prgn>ldd</prgn> program shows both
3780 the directly and indirectly used libraries, meaning that
3781 the dependencies determined included both direct and
3782 indirect dependencies. The use of <prgn>objdump</prgn>
3783 avoids this problem by determining only the directly
3788 A good example of where this helps is the following. We
3789 could update <tt>libimlib</tt> with a new version that
3790 supports a new graphics format called dgf (but retaining
3791 the same major version number). If we used the old
3792 <prgn>ldd</prgn> method, every package that uses
3793 <tt>libimlib</tt> would need to be recompiled so it
3794 would also depend on <tt>libdgf</tt> or it wouldn't run
3795 due to missing symbols. However with the new system,
3796 packages using <tt>libimlib</tt> can rely on
3797 <tt>libimlib</tt> itself having the dependency on
3798 <tt>libdgf</tt> and so they would not need rebuilding.
3804 In the following sections, we will first describe where the
3805 various <tt>shlibs</tt> files are to be found, then how to
3806 use <prgn>dpkg-shlibdeps</prgn>, and finally the
3807 <tt>shlibs</tt> file format and how to create them if your
3808 package contains a shared library.
3812 <sect><heading>The <tt>shlibs</tt> files present on the system
3816 There are several places where <tt>shlibs</tt> files are
3817 found. The following list gives them in the order in which
3818 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
3819 one which gives the required information is used.)
3825 <p><tt>debian/shlibs.local</tt></p>
3827 This lists overrides for this package. Its use is
3828 described below (see <ref id="shlibslocal">).
3833 <p><tt>/etc/dpkg/shlibs.override</tt></p>
3835 This lists global overrides. This list is normally
3836 empty. It is maintained by the local system
3842 <p><tt>DEBIAN/shlibs</tt> files in the `build directory'</p>
3844 When packages are being built, any
3845 <tt>debian/shlibs</tt> files are copied into the
3846 control file area of the temporary build directory and
3847 given the name <tt>shlibs</tt>. These files give
3848 details of any shared libraries included in the
3851 An example may help here. Let us say that the
3852 source package <tt>foo</tt> generates two binary
3853 packages, <tt>libfoo2</tt> and
3854 <tt>foo-runtime</tt>. When building the binary
3855 packages, the two packages are created in the
3856 directories <tt>debian/libfoo2</tt> and
3857 <tt>debian/foo-runtime</tt> respectively.
3858 (<tt>debian/tmp</tt> could be used instead of one
3859 of these.) Since <tt>libfoo2</tt> provides the
3860 <tt>libfoo</tt> shared library, it will require a
3861 <tt>shlibs</tt> file, which will be installed in
3862 <tt>debian/libfoo2/DEBIAN/shlibs</tt>, eventually
3864 <tt>/var/lib/dpkg/info/libfoo2.shlibs</tt>. Then
3865 when <prgn>dpkg-shlibdeps</prgn> is run on the
3867 <tt>debian/foo-runtime/usr/bin/foo-prog</tt>, it
3869 <tt>debian/libfoo2/DEBIAN/shlibs</tt> file to
3870 determine whether <tt>foo-prog</tt>'s library
3871 dependencies are satisfied by any of the libraries
3872 provided by <tt>libfoo2</tt>. For this reason,
3873 <prgn>dpkg-shlibdeps</prgn> must only be run once
3874 all of the individual binary packages'
3875 <tt>shlibs</tt> files have been installed into the
3883 <p><tt>/var/lib/dpkg/info/*.shlibs</tt></p>
3885 These are the <tt>shlibs</tt> files corresponding to
3886 all of the packages installed on the system, and are
3887 maintained by the relevant package maintainers.
3892 <p><tt>/etc/dpkg/shlibs.default</tt></p>
3894 This file lists any shared libraries whose packages
3895 have failed to provide correct <tt>shlibs</tt> files.
3896 It was used when the <tt>shlibs</tt> setup was first
3897 introduced, but it is now normally empty. It is
3898 maintained by the <tt>dpkg</tt> maintainer.
3906 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
3907 <tt>shlibs</tt> files</heading>
3910 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
3911 <tt>debian/rules</tt> file. If your package contains only
3912 compiled binaries and libraries (but no scripts), you can
3913 use a command such as:
3914 <example compact="compact">
3915 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
3916 debian/tmp/usr/lib/*
3918 Otherwise, you will need to explicitly list the compiled
3919 binaries and libraries.<footnote>
3921 If you are using <tt>debhelper</tt>, the
3922 <prgn>dh_shlibdeps</prgn> program will do this work for
3923 you. It will also correctly handle multi-binary
3930 This command puts the dependency information into the
3931 <tt>debian/substvars</tt> file, which is then used by
3932 <prgn>dpkg-gencontrol</prgn>. You will need to place a
3933 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
3934 field in the control file for this to work.
3938 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
3939 done. If it does complain you might need to create your own
3940 <tt>debian/shlibs.local</tt> file, as explained below (see
3941 <ref id="shlibslocal">).
3945 If you have multiple binary packages, you will need to call
3946 <prgn>dpkg-shlibdeps</prgn> on each one which contains
3947 compiled libraries or binaries. In such a case, you will
3948 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
3949 utilities to specify a different <tt>substvars</tt> file.
3950 For more details on this and other options, see <manref
3951 name="dpkg-shlibdeps" section="1">.
3955 <sect id="shlibs"><heading>The <tt>shlibs</tt> File Format
3959 Each <tt>shlibs</tt> file has the same format. Lines
3960 beginning with <tt>#</tt> are considered to be commments and
3961 are ignored. Each line is of the form:
3962 <example compact="compact">
3963 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
3968 We will explain this by reference to the example of the
3969 <tt>zlib1g</tt> package, which (at the time of writing)
3970 installs the shared library <tt>/usr/lib/libz.so.1.1.3</tt>.
3974 <var>library-name</var> is the name of the shared library,
3975 in this case <tt>libz</tt>. (This must match the name part
3976 of the soname, see below.)
3980 <var>soname-version-number</var> is the version part of the
3981 soname of the library. The soname is the thing that must
3982 exactly match for the library to be recognized by the
3983 dynamic linker, and is usually of the form
3984 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
3985 example, <tt>libz.so.1</tt>.<footnote>
3987 This can be determined using the command
3988 <example compact="compact">
3989 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
3993 The version part is the part which comes after
3994 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
3998 <var>dependencies</var> has the same syntax as a dependency
3999 field in a binary package control file. It should give
4000 details of which packages are required to satisfy a binary
4001 built against the version of the library contained in the
4002 package. See <ref id="depsyntax"> for details.
4006 In our example, if the first version of the <tt>zlib1g</tt>
4007 package which contained a minor number of at least
4008 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4009 <tt>shlibs</tt> entry for this library could say:
4010 <example compact="compact">
4011 libz 1 zlib1g (>= 1:1.1.3)
4013 The version-specific dependency is to avoid warnings from
4014 the dynamic linker about using older shared libraries with
4020 <heading>Providing a <tt>shlibs</tt> file</heading>
4023 If your package provides a shared library, you should create
4024 a <tt>shlibs</tt> file following the format described above.
4025 It is usual to call this file <tt>debian/shlibs</tt> (but if
4026 you have multiple binary packages, you might want to call it
4027 <tt>debian/shlibs.<var>package</var></tt> instead). Then
4028 let <tt>debian/rules</tt> install it in the control area:
4029 <example compact="compact">
4030 install -m644 debian/shlibs debian/tmp/DEBIAN
4032 or, in the case of a multi-binary package:
4033 <example compact="compact">
4034 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4036 An alternative way of doing this is to create the
4037 <tt>shlibs</tt> file in the control area directly from
4038 <tt>debian/rules</tt> without using a <tt>debian/shlibs</tt>
4039 file at all,<footnote>
4041 This is what <prgn>dh_makeshlibs</prgn> in the
4042 <tt>debhelper</tt> suite does.
4045 since the <tt>debian/shlibs</tt> file itself is ignored by
4046 <prgn>dpkg-shlibdeps</prgn>.
4050 As <prgn>dpkg-shlibdeps</prgn> reads the
4051 <tt>DEBIAN/shlibs</tt> files in all of the binary packages
4052 being built from this source package, all of the
4053 <tt>DEBIAN/shlibs</tt> files should be installed before
4054 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4059 <sect id="shlibslocal">
4060 <heading>Writing the <tt>debian/shlibs.local</tt> file</heading>
4063 This file is intended only as a <em>temporary</em> fix if
4064 your binaries or libraries depend on a library whose package
4065 does not yet provide a correct <tt>shlibs</tt> file.
4069 We will assume that you are trying to package a binary
4070 <tt>foo</tt>. When you try running
4071 <prgn>dpkg-shlibdeps</prgn> you get the following error
4072 message (<tt>-O</tt> displays the dependency information on
4073 <tt>stdout</tt> instead of writing it to
4074 <tt>debian/substvars</tt>, and the lines have been wrapped
4075 for ease of reading):
4076 <example compact="compact">
4077 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4078 dpkg-shlibdeps: warning: unable to find dependency
4079 information for shared library libbar (soname 1,
4080 path /usr/lib/libbar.so.1, dependency field Depends)
4081 shlibs:Depends=libc6 (>= 2.2.2-2)
4083 You can then run <prgn>ldd</prgn> on the binary to find the
4084 full location of the library concerned:
4085 <example compact="compact">
4087 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4088 libc.so.6 => /lib/libc.so.6 (0x40032000)
4089 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4091 So the <prgn>foo</prgn> binary depends on the
4092 <prgn>libbar</prgn> shared library, but no package seems to
4093 provide a <tt>*.shlibs</tt> file handling
4094 <tt>libbar.so.1</tt> in <tt>/var/lib/dpkg/info/</tt>. Let's
4095 determine the package responsible:
4096 <example compact="compact">
4097 $ dpkg -S /usr/lib/libbar.so.1
4098 bar1: /usr/lib/libbar.so.1
4099 $ dpkg -s bar1 | grep Version
4102 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4103 is the one we are using. Now we can file a bug against the
4104 <tt>bar1</tt> package and create our own
4105 <tt>debian/shlibs.local</tt> to locally fix the problem.
4106 Including the following line into your
4107 <tt>debian/shlibs.local</tt> file:
4108 <example compact="compact">
4109 libbar 1 bar1 (>= 1.0-1)
4111 should allow the package build to work.
4115 As soon as the maintainer of <tt>bar1</tt> provides a
4116 correct <tt>shlibs</tt> file, you should remove this line
4117 from your <tt>debian/shlibs.local</tt> file. (You should
4118 probably also then have a versioned <tt>Build-Depends</tt>
4119 on <tt>bar1</tt> to help ensure that others do not have the
4120 same problem building your package.)
4125 <chapt id="opersys"><heading>The Operating System</heading>
4128 <heading>Filesystem hierarchy</heading>
4132 <heading>Filesystem Structure</heading>
4135 The location of all installed files and directories must
4136 comply with the Filesystem Hierarchy Standard (FHS),
4137 version 2.1. This can be found in the
4138 <tt>debian-policy</tt> package or on <url
4139 id="http://www.debian.org/doc/packaging-manuals/fhs"
4140 name="FHS (Debian copy)"> alongside this manual or on <url
4141 id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4142 Specific questions about following the standard may be
4143 asked on the <tt>debian-devel</tt> mailing list, or
4144 referred to Daniel Quinlan, the FHS coordinator, at
4145 <email>quinlan@pathname.com</email>.
4150 <heading>Site-specific programs</heading>
4153 As mandated by the FHS, packages must not place any
4154 files in <tt>/usr/local</tt>, either by putting them in
4155 the file system archive to be unpacked by <prgn>dpkg</prgn>
4156 or by manipulating them in their maintainer scripts.
4160 However, the package may create empty directories below
4161 <tt>/usr/local</tt> so that the system administrator knows
4162 where to place site-specific files. These directories
4163 should be removed on package removal if they are
4168 Note, that this applies only to directories <em>below</em>
4169 <tt>/usr/local</tt>, not <em>in</em> <tt>/usr/local</tt>.
4170 Packages must not create sub-directories in the directory
4171 <tt>/usr/local</tt> itself, except those listed in FHS,
4172 section 4.5. However, you may create directories below
4173 them as you wish. You must not remove any of the
4174 directories listed in 4.5, even if you created them.
4178 Since <tt>/usr/local</tt> can be mounted read-only from a
4179 remote server, these directories must be created and
4180 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4181 maintainer scripts and not be included in the
4182 <tt>.deb</tt> archive. These scripts must not fail if
4183 either of these operations fail.<footnote>
4185 In the future, it may be possible to tell
4186 <prgn>dpkg</prgn> not to unpack files matching certain
4187 patterns, so that the directories can be included in
4188 the <tt>.deb</tt> packages and system administrators
4189 who do not wish these directories in
4190 <tt>/usr/local</tt> do not need to have them.)
4196 For example, the <tt>emacsen-common</tt> package could
4197 contain something like
4198 <example compact="compact">
4199 if [ ! -e /usr/local/share/emacs ]
4201 if mkdir /usr/local/share/emacs 2>/dev/null
4203 chown root:staff /usr/local/share/emacs
4204 chmod 2775 /usr/local/share/emacs
4208 in its <prgn>postinst</prgn> script, and
4209 <example compact="compact">
4210 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4211 rmdir /usr/local/share/emacs 2>/dev/null || true
4213 in the <prgn>prerm</prgn> script. (Note that this form is
4214 used to ensure that if the script is interrupted, the
4215 directory <tt>/usr/local/share/emacs</tt> will still be
4220 If you do create a directory in <tt>/usr/local</tt> for
4221 local additions to a package, you should ensure that
4222 settings in <tt>/usr/local</tt> take precedence over the
4223 equivalents in <tt>/usr</tt>.
4227 However, because <tt>/usr/local</tt> and its contents are
4228 for exclusive use of the local administrator, a package
4229 must not rely on the presence or absence of files or
4230 directories in <tt>/usr/local</tt> for normal operation.
4234 The <tt>/usr/local</tt> directory itself and all the
4235 subdirectories created by the package should (by default) have
4236 permissions 2775 (group-writable and set-group-id) and be
4237 owned by <tt>root.staff</tt>.
4242 <heading>The system-wide mail directory</heading>
4244 The system-wide mail directory is <tt>/var/mail</tt>. This
4245 directory is part of the base system and should not owned
4246 by any particular mail agents. The use of the old
4247 location <tt>/var/spool/mail</tt> is deprecated, even
4248 though the spool may still be physically located there.
4249 To maintain partial upgrade compatibility for systems
4250 which have <tt>/var/spool/mail</tt> as their physical mail
4251 spool, packages using <tt>/var/mail</tt> must depend on
4252 either <package>libc6</package> (>= 2.1.3-13), or on
4253 <package>base-files</package> (>= 2.2.0), or on later
4254 versions of either one of these packages.
4260 <heading>Users and groups</heading>
4263 <heading>Introduction</heading>
4265 The Debian system can be configured to use either plain or
4270 Some user ids (UIDs) and group ids (GIDs) are reserved
4271 globally for use by certain packages. Because some
4272 packages need to include files which are owned by these
4273 users or groups, or need the ids compiled into binaries,
4274 these ids must be used on any Debian system only for the
4275 purpose for which they are allocated. This is a serious
4276 restriction, and we should avoid getting in the way of
4277 local administration policies. In particular, many sites
4278 allocate users and/or local system groups starting at 100.
4282 Apart from this we should have dynamically allocated ids,
4283 which should by default be arranged in some sensible
4284 order, but the behavior should be configurable.
4288 Packages other than <tt>base-passwd</tt> must not modify
4289 <tt>/etc/passwd</tt>, <tt>/etc/shadow</tt>,
4290 <tt>/etc/group</tt> or <tt>/etc/gshadow</tt>.
4295 <heading>UID and GID classes</heading>
4297 The UID and GID numbers are divided into classes as
4303 Globally allocated by the Debian project, the same
4304 on every Debian system. These ids will appear in
4305 the <tt>passwd</tt> and <tt>group</tt> files of all
4306 Debian systems, new ids in this range being added
4307 automatically as the <tt>base-passwd</tt> package is
4312 Packages which need a single statically allocated
4313 uid or gid should use one of these; their
4314 maintainers should ask the <tt>base-passwd</tt>
4322 Dynamically allocated system users and groups.
4323 Packages which need a user or group, but can have
4324 this user or group allocated dynamically and
4325 differently on each system, should use <tt>adduser
4326 --system</tt> to create the group and/or user.
4327 <prgn>adduser</prgn> will check for the existence of
4328 the user or group, and if necessary choose an unused
4329 id based on the ranges specified in
4330 <tt>adduser.conf</tt>.
4334 <tag>1000-29999:</tag>
4337 Dynamically allocated user accounts. By default
4338 <prgn>adduser</prgn> will choose UIDs and GIDs for
4339 user accounts in this range, though
4340 <tt>adduser.conf</tt> may be used to modify this
4345 <tag>30000-59999:</tag>
4350 <tag>60000-64999:</tag>
4353 Globally allocated by the Debian project, but only
4354 created on demand. The ids are allocated centrally
4355 and statically, but the actual accounts are only
4356 created on users' systems on demand.
4360 These ids are for packages which are obscure or
4361 which require many statically-allocated ids. These
4362 packages should check for and create the accounts in
4363 <tt>/etc/passwd</tt> or <tt>/etc/group</tt> (using
4364 <prgn>adduser</prgn> if it has this facility) if
4365 necessary. Packages which are likely to require
4366 further allocations should have a `hole' left after
4367 them in the allocation, to give them room to
4372 <tag>65000-65533:</tag>
4380 User <tt>nobody</tt>. The corresponding gid refers
4381 to the group <tt>nogroup</tt>.
4388 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4389 not</em> be used, because it is the error return
4398 <sect id="sysvinit">
4399 <heading>System run levels and <tt>init.d</tt> scripts</heading>
4401 <sect1 id="/etc/init.d">
4402 <heading>Introduction</heading>
4405 The <tt>/etc/init.d</tt> directory contains the scripts
4406 executed by <prgn>init</prgn> at boot time and when the
4407 init state (or `runlevel') is changed (see <manref
4408 name="init" section="8">).
4412 There are at least two different, yet functionally
4413 equivalent, ways of handling these scripts. For the sake
4414 of simplicity, this document describes only the symbolic
4415 link method. However, it must not be assumed by maintainer
4416 scripts that this method is being used, and any automated
4417 manipulation of the various runlevel behaviours by
4418 maintainer scripts must be performed using
4419 <prgn>update-rc.d</prgn> as described below and not by
4420 manually installing or removing symlinks. For information
4421 on the implementation details of the other method,
4422 implemented in the <tt>file-rc</tt> package, please refer
4423 to the documentation of that package.
4427 These scripts are referenced by symbolic links in the
4428 <tt>/etc/rc<var>n</var>.d</tt> directories. When changing
4429 runlevels, <prgn>init</prgn> looks in the directory
4430 <tt>/etc/rc<var>n</var>.d</tt> for the scripts it should
4431 execute, where <tt><var>n</var></tt> is the runlevel that
4432 is being changed to, or <tt>S</tt> for the boot-up
4437 The names of the links all have the form
4438 <tt>S<var>mm</var><var>script</var></tt> or
4439 <tt>K<var>mm</var><var>script</var></tt> where
4440 <var>mm</var> is a two-digit number and <var>script</var>
4441 is the name of the script (this should be the same as the
4442 name of the actual script in <tt>/etc/init.d</tt>).
4446 When <prgn>init</prgn> changes runlevel first the targets
4447 of the links whose names start with a <tt>K</tt> are
4448 executed, each with the single argument <tt>stop</tt>,
4449 followed by the scripts prefixed with an <tt>S</tt>, each
4450 with the single argument <tt>start</tt>. (The links are
4451 those in the <tt>/etc/rc<var>n</var>.d</tt> directory
4452 corresponding to the new runlevel.) The <tt>K</tt> links
4453 are responsible for killing services and the <tt>S</tt>
4454 link for starting services upon entering the runlevel.
4458 For example, if we are changing from runlevel 2 to
4459 runlevel 3, init will first execute all of the <tt>K</tt>
4460 prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
4461 all of the <tt>S</tt> prefixed scripts in that directory.
4462 The links starting with <tt>K</tt> will cause the
4463 referred-to file to be executed with an argument of
4464 <tt>stop</tt>, and the <tt>S</tt> links with an argument
4469 The two-digit number <var>mm</var> is used to determine
4470 the order in which to run the scripts: low-numbered links
4471 have their scripts run first. For example, the
4472 <tt>K20</tt> scripts will be executed before the
4473 <tt>K30</tt> scripts. This is used when a certain service
4474 must be started before another. For example, the name
4475 server <prgn>bind</prgn> might need to be started before
4476 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4477 can set up its access lists. In this case, the script
4478 that starts <prgn>bind</prgn> would have a lower number
4479 than the script that starts <prgn>inn</prgn> so that it
4481 <example compact="compact">
4488 The two runlevels 0 (halt) and 6 (reboot) are slightly
4489 different. In these runlevels, the links with an
4490 <tt>S</tt> prefix are still called after those with a
4491 <tt>K</tt> prefix, but they too are called with the single
4492 argument <tt>stop</tt>.
4496 Also, if the script name ends <tt>.sh</tt>, the script
4497 will be sourced in runlevel <tt>S</tt> rather that being
4498 run in a forked subprocess, but will be explicitly run by
4499 <prgn>sh</prgn> in all other runlevels.
4504 <heading>Writing the scripts</heading>
4507 Packages that include daemons for system services should
4508 place scripts in <tt>/etc/init.d</tt> to start or stop
4509 services at boot time or during a change of runlevel.
4510 These scripts should be named
4511 <tt>/etc/init.d/<var>package</var></tt>, and they should
4512 accept one argument, saying what to do:
4515 <tag><tt>start</tt></tag>
4516 <item><p>start the service,</p></item>
4518 <tag><tt>stop</tt></tag>
4519 <item><p>stop the service,</p></item>
4521 <tag><tt>restart</tt></tag>
4522 <item><p>stop and restart the service,</p></item>
4524 <tag><tt>reload</tt></tag>
4525 <item><p>cause the configuration of the service to be
4526 reloaded without actually stopping and restarting
4527 the service,</p></item>
4529 <tag><tt>force-reload</tt></tag>
4530 <item><p>cause the configuration to be reloaded if the
4531 service supports this, otherwise restart the
4535 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4536 <tt>force-reload</tt> options should be supported by all
4537 scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
4538 option is optional.</p>
4541 The <tt>init.d</tt> scripts should ensure that they will
4542 behave sensibly if invoked with <tt>start</tt> when the
4543 service is already running, or with <tt>stop</tt> when it
4544 isn't, and that they don't kill unfortunately-named user
4545 processes. The best way to achieve this is usually to use
4546 <prgn>start-stop-daemon</prgn>.</p>
4549 If a service reloads its configuration automatically (as
4550 in the case of <prgn>cron</prgn>, for example), the
4551 <tt>reload</tt> option of the <tt>init.d</tt> script
4552 should behave as if the configuration has been reloaded
4556 The <tt>/etc/init.d</tt> scripts should be treated as
4557 configuration files, either by marking them as
4558 <tt>conffile</tt>s or managing them correctly in the
4559 maintainer scripts (see <ref id="config files">). This is
4560 important since we want to give the local system
4561 administrator the chance to adapt the scripts to the local
4562 system, e.g., to disable a service without de-installing
4563 the package, or to specify some special command line
4564 options when starting a service, while making sure her
4565 changes aren't lost during the next package upgrade.
4569 These scripts should not fail obscurely when the
4570 configuration files remain but the package has been
4571 removed, as configuration files remain on the system after
4572 the package has been removed. Only when <prgn>dpkg</prgn>
4573 is executed with the <tt>--purge</tt> option will
4574 configuration files be removed. In particular, as the
4575 <tt>/etc/init.d/<var>package</var></tt> script itself is
4576 usually a <tt>conffile</tt>, it will remain on the system
4577 if the package is removed but not purged. Therefore, you
4578 should include a <tt>test</tt> statement at the top of the
4580 <example compact="compact">
4581 test -f <var>program-executed-later-in-script</var> || exit 0
4586 Often there are some variables in the <tt>init.d</tt>
4587 scripts whose values control the bahaviour of the scripts,
4588 and which a system administrator is likely to want to
4589 change. As the scripts themselves are frequently
4590 <tt>conffile</tt>s, modifying them requires that the
4591 administrator merge in their changes each time the package
4592 is upgraded and the <tt>conffile changes</tt>. To ease
4593 the burden on the system administrator, such configurable
4594 values should not be placed directly in the script.
4595 Instead, they should be placed in a file in
4596 <tt>/etc/default</tt>, which typically will have thesame
4597 base name as the <tt>init.d</tt> script. This extra file
4598 should be sourced by the script when the script runs. It
4599 must contain only variable settings and comments in POSIX
4600 <prgn>sh</prgn> format. It should not be a
4601 <tt>conffile</tt>, but a configuration file maintained by
4602 the package maintainer scripts. See <ref id="config files">
4607 To ensure that vital configurable values are always
4608 available, the <tt>init.d</tt> script should set default
4609 values for each of the shell variables it uses, either
4610 before sourcing the <tt>/etc/default/</tt> file or
4611 afterwards using something like the <tt>:
4612 ${VAR:=default}</tt> syntax. Also, the <tt>init.d</tt>
4613 script must behave sensibly and not fail if the
4614 <tt>/etc/default</tt> file is deleted.
4619 <heading>Managing the links</heading>
4622 The program <prgn>update-rc.d</prgn> is provided for
4623 package maintainers to arrange for the proper creation and
4624 removal of <tt>/etc/rc<var>n</var>.d</tt> symbolic links,
4625 or their functional equivalent if another method is being
4626 used. This may be used by maintainers in their packages'
4627 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4630 You must not include any <tt>/etc/rc<var>n</var>.d</tt>
4631 symbolic links in the actual archive or manually create or
4632 remove the symbolic links in maintainer scripts; you must
4633 use the <prgn>update-rc.d</prgn> program instead. (The
4634 former will fail if an alternative method of maintaining
4635 runlevel information is being used.) You must not include
4636 the <tt>/etc/rc<var>n</var>.d</tt> directories themselves
4637 in the archive either. (Only the <tt>sysvinit</tt>
4642 By default <prgn>update-rc.d</prgn> will start services in
4643 each of the multi-user state runlevels (2, 3, 4, and 5)
4644 and stop them in the halt runlevel (0), the single-user
4645 runlevel (1) and the reboot runlevel (6). The system
4646 administrator will have the opportunity to customize
4647 runlevels by simply adding, moving, or removing the
4648 symbolic links in <tt>/etc/rc<var>n</var>.d</tt> if
4649 symbolic links are being used, or by modifying
4650 <tt>/etc/runlevel.conf</tt> if the <tt>file-rc</tt> method
4655 To get the default behavior for your package, put in your
4656 <prgn>postinst</prgn> script
4657 <example compact="compact">
4658 update-rc.d <var>package</var> defaults >/dev/null
4660 and in your <prgn>postrm</prgn>
4661 <example compact="compact">
4662 if [ "$1" = purge ]; then
4663 update-rc.d <var>package</var> remove >/dev/null
4668 This will use a default sequence number of 20. If it does
4669 not matter when or in which order the <tt>init.d</tt>
4670 script is run, use this default. If it does, then you
4671 should talk to the maintainer of the <prgn>sysvinit</prgn>
4672 package or post to <tt>debian-devel</tt>, and they will
4673 help you choose a number.
4677 For more information about using <tt>update-rc.d</tt>,
4678 please consult its manpage <manref name="update-rc.d"
4685 <heading>Boot-time initialization</heading>
4688 There used to be another directory, <tt>/etc/rc.boot</tt>,
4689 which contained scripts which were run once per machine
4690 boot. This has been deprecated in favour of links from
4691 <tt>/etc/rcS.d</tt> to files in <tt>/etc/init.d</tt> as
4692 described in <ref id="/etc/init.d">. Packages must not
4693 place files in <tt>/etc/rc.boot</tt>.</p>
4696 <heading>Example</heading>
4699 The <prgn>bind</prgn> DNS (nameserver) package wants to
4700 make sure that the nameserver is running in multiuser
4701 runlevels, and is properly shut down with the system. It
4702 puts a script in <tt>/etc/init.d</tt>, naming the script
4703 appropriately <tt>bind</tt>. As you can see, the script
4704 interprets the argument <tt>reload</tt> to send the
4705 nameserver a <tt>HUP</tt> signal (causing it to reload its
4706 configuration); this way the system administrator can say
4707 <tt>/etc/init.d/bind reload</tt> to reload the name
4708 server. The script has one configurable value, which can
4709 be used to pass parameters to the named program at
4710 startup; this value is read from
4711 <tt>/etc/default/bind</tt> (see below).
4715 <example compact="compact">
4718 # Original version by Robert Leslie
4719 # <rob@mars.org>, edited by iwj and cs
4721 test -x /usr/sbin/named || exit 0
4723 # Source defaults file.
4725 if [ -f /etc/default/bind ]; then
4732 echo -n "Starting domain name service: named"
4733 start-stop-daemon --start --quiet --exec /usr/sbin/named \
4738 echo -n "Stopping domain name service: named"
4739 start-stop-daemon --stop --quiet \
4740 --pidfile /var/run/named.pid --exec /usr/sbin/named
4744 echo -n "Restarting domain name service: named"
4745 start-stop-daemon --stop --quiet \
4746 --pidfile /var/run/named.pid --exec /usr/sbin/named
4747 start-stop-daemon --start --verbose --exec /usr/sbin/named \
4751 force-reload|reload)
4752 echo -n "Reloading configuration of domain name service: named"
4753 start-stop-daemon --stop --signal 1 --quiet \
4754 --pidfile /var/run/named.pid --exec /usr/sbin/named
4758 echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
4768 Complementing the above init script is a configuration
4769 file <tt>/etc/default/bind</tt>, which contains
4770 configurable parameters used by the script. This would be
4771 created by the <prgn>postinst</prgn> script if it was not
4772 already present, and removed on purge by the
4773 <prgn>postrm</prgn> script.
4774 <example compact="compact">
4775 # Specified parameters to pass to named. See named(8).
4776 # You may uncomment the following line, and edit to taste.
4782 Another example on which you can base your
4783 <tt>/etc/init.d</tt> scripts is found in
4784 <tt>/etc/init.d/skeleton</tt>.
4788 If this package is happy with the default setup from
4789 <prgn>update-rc.d</prgn>, namely an ordering number of 20
4790 and having named running in all runlevels, it can say in
4791 its <prgn>postinst</prgn>:
4792 <example compact="compact">
4793 update-rc.d bind defaults >/dev/null
4795 And in its <prgn>postrm</prgn>, to remove the links when the
4797 <example compact="compact">
4798 if [ "$1" = purge ]; then
4799 update-rc.d bind remove >/dev/null
4807 <heading>Console messages from <tt>init.d</tt> scripts</heading>
4810 This section describes the formats to be used for messages
4811 written to standard output by the <tt>/etc/init.d</tt>
4812 scripts. The intent is to improve the consistency of
4813 Debian's startup and shutdown look and feel. For this
4814 reason, please look very carefully at the details. We want
4815 the messages to have the same format in terms of wording,
4816 spaces, punctuation and case of letters.
4820 Here is a list of overall rules that you should use when you
4821 create output messages. They can be useful if you have a
4822 non-standard message that is not covered specifically in the
4830 Every message should fit in one line (fewer than 80
4831 characters), start with a capital letter and end with
4832 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
4838 If you want to express that the computer is working on
4839 something (that is, performing a specific task, not
4840 starting or stopping a program), we use an "ellipsis"
4841 (three dots: <tt>...</tt>). Note that we don't insert
4842 spaces before or after the dots. If the task has been
4843 completed we write <tt>done.</tt> and a line feed.
4849 Design your messages as if the computer is telling you
4850 what he is doing (let him be polite :-), but don't
4851 mention "him" directly. For example, if you think of
4853 <example compact="compact">
4854 I'm starting network daemons: nfsd mountd.
4857 <example compact="compact">
4858 Starting network daemons: nfsd mountd.
4866 There are standard message formats for the following
4867 situations. They should be used by the <tt>init.d</tt>
4874 <p>When daemons are started</p>
4877 If your script starts one or more daemons, the output
4878 should look like this (a single line, no leading
4880 <example compact="compact">
4881 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
4883 The <var>description</var> should describe the
4884 subsystem the daemon or set of daemons are part of,
4885 while <var>daemon-1</var> up to <var>daemon-n</var>
4886 denote each daemon's name (typically the file name of
4891 For example, the output of <tt>/etc/init.d/lpd</tt>
4893 <example compact="compact">
4894 Starting printer spooler: lpd.
4899 This can be achieved by saying
4900 <example compact="compact">
4901 echo -n "Starting printer spooler: lpd"
4902 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
4905 in the script. If you have more than one daemon to
4906 start, you should do the following:
4907 <example compact="compact">
4908 echo -n "Starting remote file system services:"
4909 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
4910 echo -n " mountd"; start-stop-daemon --start --quiet mountd
4911 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
4914 This makes it possible for the user to see what takes
4915 so long and when the final daemon has been started.
4916 You should be careful where to put spaces: in the
4917 example above the system administrator can easily
4918 comment out a line if he don't wants to start a
4919 specific daemon, while the displayed message still
4925 <p>When a system parameter is being set</p>
4928 If you have to set up different system parameters
4929 during the system boot, you should use this format:
4930 <example compact="compact">
4931 Setting <var>parameter</var> to `<var>value</var>'.
4936 You can use a statement such as the following to get
4938 <example compact="compact">
4939 echo "Setting DNS domainname to \`$domainname'."
4944 Note that the left quotation mark (<tt>`</tt>) is
4945 different from the right one (<tt>'</tt>).
4950 <p>When a daemon is stopped or restarted</p>
4953 When you stop or restart a daemon, you should issue a
4954 message identical to the startup message, except that
4955 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
4956 or <tt>Restarting</tt> respectively.
4960 For example, stopping the printer daemon will like
4962 <example compact="compact">
4963 Stopping printer spooler: lpd.
4969 <p>When something is executed</p>
4972 There are several examples where you have to run a
4973 program at system startup or shutdown to perform a
4974 specific task, for example, setting the system's clock
4975 using <prgn>netdate</prgn> or killing all processes
4976 when the system shuts down. Your message should look
4978 <example compact="compact">
4979 Doing something very useful...done.
4981 You should print the <tt>done.</tt> immediately after
4982 the job has been completed, so that the user is
4983 informed why she has to wait. You can get this
4985 <example compact="compact">
4986 echo -n "Doing something very useful..."
4995 <p>When the configuration is reloaded</p>
4998 When a daemon is forced to reload its configuration
4999 files you should use the following format:
5000 <example compact="compact">
5001 Reloading <var>description</var> configuration...done.
5003 where <var>description</var> is the same as in the
5004 daemon starting message.
5012 <heading>Cron jobs</heading>
5015 Packages must not modify the configuration file
5016 <tt>/etc/crontab</tt>, and they must not modify the files in
5017 <tt>/var/spool/cron/crontabs</tt>.</p>
5020 If a package wants to install a job that has to be executed
5021 via cron, it should place a file with the name of the
5022 package in one or more of the following directories:
5023 <example compact="compact">
5028 As these directory names imply, the files within them are
5029 executed on a daily, weekly, or monthly basis,
5030 respectively. The exact times are listed in
5031 <tt>/etc/crontab</tt>.</p>
5034 All files installed in any of these directories must be
5035 scripts (e.g., shell scripts or Perl scripts) so that they
5036 can easily be modified by the local system administrator.
5037 In addition, they should be treated as configuration
5042 If a certain job has to be executed more frequently than
5043 daily, the package should install a file
5044 <tt>/etc/cron.d/<var>package</var></tt>. This file uses the
5045 same syntax as <tt>/etc/crontab</tt> and is processed by
5046 <prgn>cron</prgn> automatically. The file must also be
5047 treated as a configuration file. (Note that entries in the
5048 <tt>/etc/cron.d</tt> directory are not handled by
5049 <prgn>anacron</prgn>. Thus, you should only use this
5050 directory for jobs which may be skipped if the system is not
5054 The scripts or crontab entries in these directories should
5055 check if all necessary programs are installed before they
5056 try to execute them. Otherwise, problems will arise when a
5057 package was removed but not purged since configuration files
5058 are kept on the system in this situation.</p>
5062 <heading>Menus</heading>
5065 Menu entries should follow the current menu policy found in
5066 the <tt>menu-policy</tt> files in the <tt>debian-policy</tt>
5067 package. It may also be found on the Debian FTP site
5068 <ftpsite>ftp.debian.org</ftpsite> as the file
5069 <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>,
5070 or in the equivalent location on your local mirror.
5074 The Debian <tt>menu</tt> package provides a standard
5075 interface between packages providing applications and
5076 documents, and <em>menu programs</em> (either X window
5077 managers or text-based menu programs such as
5078 <prgn>pdmenu</prgn>).
5082 All packages that provide applications that need not be
5083 passed any special command line arguments for normal
5084 operation should register a menu entry for those
5085 applications, so that users of the <tt>menu</tt> package
5086 will automatically get menu entries in their window
5087 managers, as well in shells like <tt>pdmenu</tt>.</p>
5090 Please also refer to the <em>Debian Menu System</em>
5091 documentation that comes with the <tt>menu</tt> package for
5092 information about how to register your applications and web
5098 <heading>Multimedia handlers</heading>
5101 Packages which provide the ability to view/show/play,
5102 compose, edit or print MIME types should register themselves
5103 as such following the current MIME support policy found in
5104 the <tt>mime-policy</tt> files in the <tt>debian-policy</tt>
5105 package. It may also be found on the Debian FTP site
5106 <ftpsite>ftp.debian.org</ftpsite> as the file
5107 <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>,
5108 or in the equivalent location on your local mirror.
5112 MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5113 is a mechanism for encoding files and data streams and
5114 providing meta-information about them, in particular their
5115 type (e.g. audio or video) and format (e.g. PNG, HTML,
5120 Registration of MIME type handlers allows programs like mail
5121 user agents and web browsers to to invoke these handlers to
5122 view, edit or display MIME types they don't support
5128 <heading>Keyboard configuration</heading>
5131 To achieve a consistent keyboard configuration so that all
5132 applications interpret a keyboard event the same way, all
5133 programs in the Debian distribution must be configured to
5134 comply with the following guidelines.
5138 The following keys must have the specified interpretations:
5141 <tag><tt><--</tt></tag>
5142 <item><p>delete the character to the left of the cursor</p></item>
5144 <tag><tt>Delete</tt></tag>
5145 <item><p>delete the character to the right of the cursor</p></item>
5147 <tag><tt>Control+H</tt></tag>
5148 <item><p>emacs: the help prefix</p></item>
5151 The interpretation of any keyboard events should be
5152 independent of the terminal that is used, be it a virtual
5153 console, an X terminal emulator, an rlogin/telnet session,
5158 The following list explains how the different programs
5159 should be set up to achieve this:
5164 <item><p><tt><--</tt> generates <tt>KB_Backspace</tt>
5167 <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5172 X translations are set up to make
5173 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5174 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5175 is the vt220 escape code for the `delete character'
5176 key). This must be done by loading the X resources
5177 using <prgn>xrdb</prgn> on all local X displays, not
5178 using the application defaults, so that the
5179 translation resources used correspond to the
5180 <prgn>xmodmap</prgn> settings.</p></item>
5184 The Linux console is configured to make
5185 <tt><--</tt> generate DEL, and <tt>Delete</tt>
5186 generate <tt>ESC [ 3 ~</tt>.</p></item>
5190 X applications are configured so that <tt><</tt>
5191 deletes left, and <tt>Delete</tt> deletes right. Motif
5192 applications already work like this.</p></item>
5194 <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5198 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5199 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5200 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5204 Emacs is programmed to map <tt>KB_Backspace</tt> or
5205 the <tt>stty erase</tt> character to
5206 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5207 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5208 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5212 Other applications use the <tt>stty erase</tt>
5213 character and <tt>kdch1</tt> for the two delete keys,
5214 with ASCII DEL being `delete previous character' and
5215 <tt>kdch1</tt> being `delete character under
5222 This will solve the problem except for the following
5230 Some terminals have a <tt><--</tt> key that cannot
5231 be made to produce anything except <tt>^H</tt>. On
5232 these terminals Emacs help will be unavailable on
5233 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5234 character takes precedence in Emacs, and has been set
5235 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
5236 available) can be used instead.</p></item>
5240 Some operating systems use <tt>^H</tt> for <tt>stty
5241 erase</tt>. However, modern telnet versions and all
5242 rlogin versions propagate <tt>stty</tt> settings, and
5243 almost all UNIX versions honour <tt>stty erase</tt>.
5244 Where the <tt>stty</tt> settings are not propagated
5245 correctly, things can be made to work by using
5246 <tt>stty</tt> manually.</p></item>
5250 Some systems (including previous Debian versions) use
5251 <prgn>xmodmap</prgn> to arrange for both
5252 <tt><--</tt> and <tt>Delete</tt> to generate
5253 <tt>KB_Delete</tt>. We can change the behavior of
5254 their X clients using the same X resources that we use
5255 to do it for our own clients, or configure our clients
5256 using their resources when things are the other way
5257 around. On displays configured like this
5258 <tt>Delete</tt> will not work, but <tt><--</tt>
5263 Some operating systems have different <tt>kdch1</tt>
5264 settings in their <tt>terminfo</tt> database for
5265 <tt>xterm</tt> and others. On these systems the
5266 <tt>Delete</tt> key will not work correctly when you
5267 log in from a system conforming to our policy, but
5268 <tt><--</tt> will.</p></item>
5274 <heading>Environment variables</heading>
5277 A program must not depend on environment variables to get
5278 reasonable defaults. (That's because these environment
5279 variables would have to be set in a system-wide
5280 configuration file like <tt>/etc/profile</tt>, which is not
5281 supported by all shells.)</p>
5284 If a program usually depends on environment variables for its
5285 configuration, the program should be changed to fall back to
5286 a reasonable default configuration if these environment
5287 variables are not present. If this cannot be done easily
5288 (e.g., if the source code of a non-free program is not
5289 available), the program must be replaced by a small
5290 `wrapper' shell script which sets the environment variables
5291 if they are not already defined, and calls the original program.</p>
5294 Here is an example of a wrapper script for this purpose:
5296 <example compact="compact">
5298 BAR=${BAR:-/var/lib/fubar}
5300 exec /usr/lib/foo/foo "$@"
5305 Furthermore, as <tt>/etc/profile</tt> is a configuration
5306 file of the <prgn>base-files</prgn> package, other packages must not
5307 put any environment variables or other commands into that
5313 <heading>Files</heading>
5316 <heading>Binaries</heading>
5319 Two different packages must not install programs with
5320 different functionality but with the same filenames. (The
5321 case of two programs having the same functionality but
5322 different implementations is handled via `alternatives' or
5323 the `Conflicts' mechanism. See <ref id="maintscripts"> and
5324 <ref id="conflicts"> respectively.) If this case happens,
5325 one of the programs must be renamed. The maintainers should
5326 report this to the <tt>debian-devel</tt> mailing list and
5327 try to find a consensus about which program will have to be
5328 renamed. If a consensus cannot be reached, <em>both</em>
5329 programs must be renamed.
5333 Generally the following compilation parameters should be used:
5334 <example compact="compact">
5336 CFLAGS = -O2 -Wall # sane warning options vary between programs
5338 install -s # (or use strip on the files in debian/tmp)
5342 Note that by default all installed binaries should be stripped,
5343 either by using the <tt>-s</tt> flag to
5344 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5345 the binaries after they have been copied into
5346 <tt>debian/tmp</tt> but before the tree is made into a
5350 The <tt>-N</tt> flag should not be used. On <tt>a.out</tt>
5351 systems it may have been useful for some very small
5352 binaries, but for ELF it has no good effect.</p>
5355 Debugging symbols are useful for error diagnosis,
5356 investigation of core dumps (which may be submitted by users
5357 in bug reports), or testing and developing the software.
5358 Therefore it is recommended to support building the package
5359 with debugging information through the following interface:
5360 If the environment variable <tt>DEB_BUILD_OPTIONS</tt>
5361 contains the string <tt>debug</tt>, compile the software
5362 with debugging information (usually this involves adding the
5363 <tt>-g</tt> flag to <tt>CFLAGS</tt>). This allows the
5364 generation of a build tree with debugging information. If
5365 the environment variable <tt>DEB_BUILD_OPTIONS</tt> contains
5366 the string <tt>nostrip</tt>, do not strip the files at
5367 installation time. This allows one to generate a package
5368 with debugging information included.<footnote>
5370 Rationale: Using <tt>-g</tt> by default causes wasted
5371 CPU cycles since the information is stripped away
5372 anyway; this can have a significant impact on the
5373 efficiency of the autobuilders. Having a standard way
5374 to build a debugging variant also makes it easier to
5375 build debugging bins and libraries since it provides a
5376 documented way of getting this type of build; one does
5377 not have to manually edit <tt>debian/rules</tt> or
5381 The following makefile snippet is an example of how one may
5382 test for either condition; you will probably have to massage
5383 this example in order to make it work for your package.
5384 <example compact="compact">
5387 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5388 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5389 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5390 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5392 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
5395 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5396 INSTALL_PROGRAM += -s
5402 It is up to the package maintainer to decide what
5403 compilation options are best for the package. Certain
5404 binaries (such as computationally-intensive programs) will
5405 function better with certain flags (<tt>-O3</tt>, for
5406 example); feel free to use them. Please use good judgment
5407 here. Don't use flags for the sake of it; only use them
5408 if there is good reason to do so. Feel free to override
5409 the upstream author's ideas about which compilation
5410 options are best: they are often inappropriate for our
5411 environment.</p></sect>
5415 <heading>Libraries</heading>
5418 All libraries must have a shared version in the
5419 <tt>lib*</tt> package and a static version in the
5420 <tt>lib*-dev</tt> package. The shared version must be
5421 compiled with <tt>-fPIC</tt>, and the static version must
5422 not be. In other words, each <tt>*.c</tt> file will need to
5423 be compiled twice.</p>
5426 You must specify the gcc option <tt>-D_REENTRANT</tt>
5427 when building a library (either static or shared) to make
5428 the library compatible with LinuxThreads.</p>
5431 Note that all installed shared libraries should be
5433 <example compact="compact">
5434 strip --strip-unneeded <var>your-lib</var>
5436 (The option <tt>--strip-unneeded</tt> makes
5437 <prgn>strip</prgn> remove only the symbols which aren't
5438 needed for relocation processing.) Shared libraries can
5439 function perfectly well when stripped, since the symbols for
5440 dynamic linking are in a separate part of the ELF object
5443 You might also want to use the options
5444 <tt>--remove-section=.comment</tt> and
5445 <tt>--remove-section=.note</tt> on both shared libraries
5446 and executables, and <tt>--strip-debug</tt> on static
5453 Note that under some circumstances it may be useful to
5454 install a shared library unstripped, for example when
5455 building a separate package to support debugging.
5459 An ever increasing number of packages are using
5460 <prgn>libtool</prgn> to do their linking. The latest GNU
5461 libtools (>= 1.3a) can take advantage of the metadata in the
5462 installed <prgn>libtool</prgn> archive files (<tt>*.la</tt>
5463 files). The main advantage of <prgn>libtool</prgn>'s
5464 <tt>.la</tt> files is that it allows <prgn>libtool</prgn> to
5465 store and subsequently access metadata with respect to the
5466 libraries it builds. <prgn>libtool</prgn> will search for
5467 those files, which contain a lot of useful information about
5468 a library (such as library dependency information for static
5469 linking). Also, they're <em>essential</em> for programs
5470 using <tt>libltdl</tt>.<footnote>
5472 Although <prgn>libtool</prgn> is fully capable of
5473 linking against shared libraries which don't have
5474 <tt>.la</tt> files, as it is a mere shell script it can
5475 add considerably to the build time of a
5476 <prgn>libtool</prgn>-using package if that shell script
5477 has to derive all this information from first principles
5478 for each library every time it is linked. With the
5479 advent of <prgn>libtool</prgn> version 1.4 (and to a
5480 lesser extent <prgn>libtool</prgn> version 1.3), the
5481 <tt>.la</tt> files also store information about
5482 inter-library dependencies which cannot necessarily be
5483 derived after the <tt>.la</tt> file is deleted.
5489 Packages that use <prgn>libtool</prgn> to create shared
5490 libraries should include the <tt>.la</tt> files in the
5491 <tt>-dev</tt> package, unless the package relies on
5492 <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5493 the <tt>.la</tt> files must go in the run-time library
5498 You must make sure that you use only released versions of
5499 shared libraries to build your packages; otherwise other
5500 users will not be able to run your binaries
5501 properly. Producing source packages that depend on
5502 unreleased compilers is also usually a bad
5508 <heading>Shared libraries</heading>
5511 Packages involving shared libraries should be split up
5512 into several binary packages.</p>
5515 For a straightforward library which has a development
5516 environment and a runtime kit including just shared
5517 libraries you need to create two packages:
5518 <tt><var>libraryname</var><var>soversion</var></tt>, where
5519 <tt><var>soversion</var></tt> is the version number in the
5520 soname of the shared library<footnote>
5522 The soname is the shared object name: it's the thing
5523 that has to match exactly between building an executable
5524 and running it for the dynamic linker to be able run the
5525 program. For example, if the soname of the library is
5526 <tt>libfoo.so.6</tt>, the library package would be
5527 called <tt>libfoo6</tt>.
5530 and <tt><var>libraryname</var><var>soversion</var>-dev</tt>.
5534 If you prefer only to support one development version at a
5535 time you may name the development package
5536 <tt><var>libraryname</var>-dev</tt>; otherwise you may need
5537 to use <prgn>dpkg</prgn>'s Conflicts mechanism (see <ref
5538 id="conflicts">) to ensure that the user only installs one
5539 development version at a time (as different development
5540 versions are likely to have the same header files in them,
5541 which would cause a filename clash if both were installed).
5542 Typically the development version should also have an exact
5543 version dependency on the runtime library, to make sure that
5544 compilation and linking happens correctly. The
5545 <tt>${Source-Version}</tt> substitution variable can be
5546 useful for this purpose.
5550 Packages which use the shared library should have a
5551 dependency on the name of the shared library package,
5552 <tt><var>libraryname</var><var>soversion</var></tt>. When
5553 the soname changes you can have both versions of the library
5554 installed while migrating from the old library to the new.
5558 If your package has some run-time support programs which use
5559 the shared library you must not put them in the shared
5560 library package. If you do that then you won't be able to
5561 install several versions of the shared library without
5562 getting filename clashes. Instead, either create a third
5563 package for the runtime binaries (this package might
5564 typically be named <tt><var>libraryname</var>-runtime</tt>;
5565 note the absence of the <var>soversion</var> in the package
5566 name), or if the development package is small you may
5567 include them in there.
5571 If you have several shared libraries built from the same
5572 source tree you may lump them all together into a single
5573 shared library package, provided that you change all of
5574 their sonames at once (so that you don't get filename
5575 clashes if you try to install different versions of the
5576 combined shared libraries package).
5580 Shared libraries should not be installed executable, since
5581 the dynamic linker does not require this and trying to
5582 execute a shared library usually results in a core dump.
5587 <heading>Scripts</heading>
5590 All command scripts, including the package maintainer
5591 scripts inside the package and used by <prgn>dpkg</prgn>,
5592 should have a <tt>#!</tt> line naming the shell to be used
5593 to interpret them.</p>
5596 In the case of Perl scripts this should be
5597 <tt>#!/usr/bin/perl</tt>.</p>
5600 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5601 should almost certainly start with <tt>set -e</tt> so that
5602 errors are detected. Every script should use
5603 <tt>set -e</tt> or check the exit status of <em>every</em>
5607 The standard shell interpreter <tt>/bin/sh</tt> can be a
5608 symbolic link to any POSIX compatible shell, if <tt>echo
5609 -n</tt> does not generate a newline.<footnote>
5611 Debian policy specifies POSIX behavior for
5612 <tt>/bin/sh</tt>, but <tt>echo -n</tt> has widespread
5613 use in the Linux community (in particular including this
5614 policy, the Linux kernel source, many Debian scripts,
5615 etc.). This <tt>echo -n</tt> mechanism is valid but not
5616 required under POSIX, hence this explicit addition.
5617 Also, rumour has it that this shall be mandated under
5621 Thus, shell scripts specifying <tt>/bin/sh</tt> as
5622 interpreter should only use POSIX features. If a script
5623 requires non-POSIX features from the shell interpreter, the
5624 appropriate shell must be specified in the first line of the
5625 script (e.g., <tt>#!/bin/bash</tt>) and the package must
5626 depend on the package providing the shell (unless the shell
5627 package is marked `Essential', as in the case of
5632 You may wish to restrict your script to POSIX features when
5633 possible so that it may use <tt>/bin/sh</tt> as its
5634 interpreter. If your script works with <prgn>ash</prgn>,
5635 it's probably POSIX compliant, but if you are in doubt, use
5640 Perl scripts should check for errors when making any
5641 system calls, including <tt>open</tt>, <tt>print</tt>,
5642 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5646 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5647 scripting languages. See <em>Csh Programming Considered
5648 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5649 can be found at <url
5650 id="http://language.perl.com/versus/csh.whynot">.<footnote>
5652 It can also be found on
5653 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5654 or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5655 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5658 If an upstream package comes with <prgn>csh</prgn> scripts
5659 then you must make sure that they start with
5660 <tt>#!/bin/csh</tt> and make your package depend on the
5661 <prgn>c-shell</prgn> virtual package.
5665 Any scripts which create files in world-writeable
5666 directories (e.g., in <tt>/tmp</tt>) must use a
5667 mechanism which will fail if a file with the same name
5671 The Debian base distribution provides the
5672 <prgn>tempfile</prgn> and <prgn>mktemp</prgn> utilities
5673 for use by scripts for this purpose.</p></sect>
5677 <heading>Symbolic links</heading>
5680 In general, symbolic links within a top-level directory
5681 should be relative, and symbolic links pointing from one
5682 top-level directory into another should be absolute. (A
5683 top-level directory is a sub-directory of the root
5684 directory <tt>/</tt>.)</p>
5687 In addition, symbolic links should be specified as short as
5688 possible, i.e., link targets like <tt>foo/../bar</tt> are
5692 Note that when creating a relative link using
5693 <prgn>ln</prgn> it is not necessary for the target of the
5694 link to exist relative to the working directory you're
5695 running <prgn>ln</prgn> from, nor is it necessary to change
5696 directory to the directory where the link is to be made.
5697 Simply include the string that should appear as the target
5698 of the link (this will be a pathname relative to the
5699 directory in which the link resides) as the first argument
5700 to <prgn>ln</prgn>.</p>
5703 For example, in your <prgn>Makefile</prgn> or
5704 <tt>debian/rules</tt>, you can do things like:
5705 <example compact="compact">
5706 ln -fs gcc $(prefix)/bin/cc
5707 ln -fs gcc debian/tmp/usr/bin/cc
5708 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5709 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5713 A symbolic link pointing to a compressed file should always
5714 have the same file extension as the referenced file. (For
5715 example, if a file <tt>foo.gz</tt> is referenced by a
5716 symbolic link, the filename of the link has to end with
5717 `<tt>.gz</tt>' too, as in <tt>bar.gz</tt>.)
5722 <heading>Device files</heading>
5725 Packages must not include device files in the package file
5729 If a package needs any special device files that are not
5730 included in the base system, it must call
5731 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
5732 after asking the user for permission to do so.</p>
5735 Packages must not remove any device files in the
5736 <prgn>postrm</prgn> or any other script. This is left to the
5737 system administrator.</p>
5740 Debian uses the serial devices
5741 <tt>/dev/ttyS*</tt>. Programs using the old
5742 <tt>/dev/cu*</tt> devices should be changed to use
5743 <tt>/dev/ttyS*</tt>.</p>
5746 <sect id="config files">
5747 <heading>Configuration files</heading>
5749 <heading>Definitions</heading>
5752 <tag>configuration file</tag>
5755 A file that affects the operation of a program, or
5756 provides site- or host-specific information, or
5757 otherwise customizes the behavior of a program.
5758 Typically, configuration files are intended to be
5759 modified by the system administrator (if needed or
5760 desired) to conform to local policy or to provide
5761 more useful site-specific behavior.
5765 <tag><tt>conffile</tt></tag>
5768 A file listed in a package's <tt>conffiles</tt>
5769 file, and is treated specially by <prgn>dpkg</prgn>
5770 (see <ref id="configdetails">).
5777 The distinction between these two is important; they are
5778 not interchangeable concepts. Almost all
5779 <tt>conffile</tt>s are configuration files, but many
5780 configuration files are not <tt>conffiles</tt>.
5784 Note that a script that embeds configuration information
5785 (such as most of the files in <tt>/etc/default</tt> and
5786 <tt>/etc/cron.{daily,weekly,monthly}</tt>) is de-facto a
5787 configuration file and should be treated as such.
5792 <heading>Location</heading>
5794 Any configuration files created or used by your package
5795 must reside in <tt>/etc</tt>. If there are several you
5796 should consider creating a subdirectory of <tt>/etc</tt>
5797 named after your package.</p>
5800 If your package creates or uses configuration files
5801 outside of <tt>/etc</tt>, and it is not feasible to modify
5802 the package to use the <tt>/etc</tt>, you should still put
5803 the files in <tt>/etc</tt> and create symbolic links to
5804 those files from the location that the package
5809 <heading>Behavior</heading>
5811 Configuration file handling must conform to the following
5813 <list compact="compact">
5816 local changes must be preserved during a package
5822 configuration files must be preserved when the
5823 package is removed, and only deleted when the
5831 The easy way to achieve this behavior is to make the
5832 configuration file a <tt>conffile</tt>. This is
5833 appropriate only if it is possible to distribute a default
5834 version that will work for most installations, although
5835 some system administrators may choose to modify it. This
5836 implies that the default version will be part of the
5837 package distribution, and must not be modified by the
5838 maintainer scripts during installation (or at any other
5843 In order to ensure that local changes are preserved
5844 correctly, no package may contain or make hard links to
5845 conffiles.<footnote>
5847 Rationale: There are two problems with hard links.
5848 The first is that some editors break the link while
5849 editing one of the files, so that the two files may
5850 unwittingly become unlinked and different. The second
5851 is that <prgn>dpkg</prgn> might break the hard link
5852 while upgrading <tt>conffile</tt>s.
5858 The other way to do it is via the maintainer scripts. In
5859 this case, the configuration file must not be listed as a
5860 <tt>conffile</tt> and must not be part of the package
5861 distribution. If the existence of a file is required for
5862 the package to be sensibly configured it is the
5863 responsibility of the package maintainer to provide
5864 maintainer scripts which correctly create, update and
5865 maintain the file and remove it on purge. (See <ref
5866 id="maintainerscripts"> for more information.) These
5867 scripts must be idempotent (i.e., must work correctly if
5868 <prgn>dpkg</prgn> needs to re-run them due to errors
5869 during installation or removal), must cope with all the
5870 variety of ways <prgn>dpkg</prgn> can call maintainer
5871 scripts, must not overwrite or otherwise mangle the user's
5872 configuration without asking, must not ask unnecessary
5873 questions (particularly during upgrades), and otherwise be
5878 The scripts are not required to configure every possible
5879 option for the package, but only those necessary to get
5880 the package running on a given system. Ideally the
5881 sysadmin should not have to do any configuration other
5882 than that done (semi-)automatically by the
5883 <prgn>postinst</prgn> script.
5887 A common practice is to create a script called
5888 <tt><var>package</var>-configure</tt> and have the
5889 package's <prgn>postinst</prgn> call it if and only if the
5890 configuration file does not already exist. In certain
5891 cases it is useful for there to be an example or template
5892 file which the maintainer scripts use. Such files should
5893 be in <tt>/usr/share/<var>package</var></tt> or
5894 <tt>/usr/lib/<var>package</var></tt> (depending on whether
5895 they are architecture-independent or not). There should
5896 be symbolic links to them from
5897 <tt>/usr/share/doc/<var>package</var>/examples</tt> if
5898 they are examples, and should be perfectly ordinary
5899 <prgn>dpkg</prgn>-handled files (<em>not</em>
5900 <tt>conffiles</tt>).
5904 These two styles of configuration file handling must
5905 not be mixed, for that way lies madness:
5906 <prgn>dpkg</prgn> will ask about overwriting the file
5907 every time the package is upgraded.
5912 <heading>Sharing configuration files</heading>
5914 Packages which specify the same file as a
5915 <tt>conffile</tt> must be tagged as <em>conflicting</em>
5916 with each other. (This is an instance of the general rule
5917 about not sharing files. Note that neither alternatives
5918 nor diversions are likely to be appropriate in this case.)
5922 The maintainer scripts must not alter a <tt>conffile</tt>
5923 of <em>any</em> package, including the one the scripts
5928 If two or more packages use the same configuration file
5929 and it is reasonable for both to be installed at the same
5930 time, one of these packages must be defined as
5931 <em>owner</em> of the configuration file, i.e., it will be
5932 the package which handles that file as a configuration
5933 file. Other packages that use the configuration file must
5934 depend on the owning package if they require the
5935 configuration file to operate. If the other package will
5936 use the configuration file if present, but is capable of
5937 operating without it, no dependency need be declared.</p>
5940 If it is desirable for two or more related packages to
5941 share a configuration file <em>and</em> for all of the
5942 related packages to be able to modify that configuration
5943 file, then the following should be done:
5944 <enumlist compact="compact">
5947 One of the related packages (the "owning" package)
5948 will manage the configuration file with maintainer
5949 scripts as described in the previous section.
5954 The owning package should also provide a program
5955 that the other packages may use to modify the
5961 The related packages must use the provided program
5962 to make any desired modifications to the
5963 configuration file. They should either depend on
5964 the core package to guarantee that the configuration
5965 modifier program is available or accept gracefully
5966 that they cannot modify the configuration file if it
5967 is not. (This is in addition to the fact that the
5968 configuration file may not even be present in the
5976 Sometimes it's appropriate to create a new package which
5977 provides the basic infrastructure for the other packages
5978 and which manages the shared configuration files. (The
5979 <tt>sgml-base</tt> package is a good example.)
5984 <heading>User configuration files ("dotfiles")</heading>
5987 The files in <tt>/etc/skel</tt> will automatically be
5988 copied into new user accounts by <prgn>adduser</prgn>.
5989 No other program should reference the files in
5994 Therefore, if a program needs a dotfile to exist in
5995 advance in <tt>$HOME</tt> to work sensibly, that dotfile
5996 should be installed in <tt>/etc/skel</tt> and treated as a
6001 However, programs that require dotfiles in order to
6002 operate sensibly (dotfiles that they do not create
6003 themselves automatically, that is) are a bad thing.
6004 Furthermore, programs should be configured by the Debian
6005 default installation as behave as closely to the upstream
6006 default behaviour as possible.
6010 Therefore, if a program in a Debian package needs to be
6011 configured in some way in order to operate sensibly, that
6012 should be done using a site-wide configuration file placed
6013 in <tt>/etc</tt>. Only if the program doesn't support a
6014 site-wide default configuration and the package maintainer
6015 doesn't have time to add it may a default per-user file be
6016 placed in <tt>/etc/skel</tt>.
6020 <tt>/etc/skel</tt> should be as empty as we can make it.
6021 This is particularly true because there is no easy (or
6022 necessarily desirable) mechanism for ensuring that the
6023 appropriate dotfiles are copied into the accounts of
6024 existing users when a package is installed.
6030 <heading>Log files</heading>
6032 Log files should usually be named
6033 <tt>/var/log/<var>package</var>.log</tt>. If you have many
6034 log files, or need a separate directory for permission
6035 reasons (<tt>/var/log</tt> is writable only by
6036 <tt>root</tt>), you should usually create a directory named
6037 <tt>/var/log/<var>package</var></tt> and place your log
6042 Log files must be rotated occasionally so that they don't
6043 grow indefinitely; the best way to do this is to drop a log
6044 rotation configuration file into the directory
6045 <tt>/etc/logrotate.d</tt> and use the facilities provided by
6046 logrotate.<footnote>
6048 The traditional approach to log files has been to set up
6049 <em>ad hoc</em> log rotation schemes using simple shell
6050 scripts and cron. While this approach is highly
6051 customizable, it requires quite a lot of sysadmin work.
6052 Even though the original Debian system helped a little
6053 by automatically installing a system which can be used
6054 as a template, this was deemed not enough.
6058 The use of <prgn>logrotate</prgn>, a program developed
6059 by Red Hat, is better, as it centralizes log management.
6060 It has both a configuration file
6061 (<tt>/etc/logrotate.conf</tt>) and a directory where
6062 packages can drop their individual log rotation
6063 configurations (<tt>/etc/logrotate.d</tt>).
6066 Here is a good example for a logrotate config
6067 file (for more information see <manref name="logrotate"
6069 <example compact="compact">
6075 /etc/init.d/foo force-reload
6079 This rotates all files under <tt>/var/log/foo</tt>, saves 12
6080 compressed generations, and forces the daemon to reload its
6081 configuration information after the log rotation.
6085 Log files should be removed when the package is
6086 purged (but not when it is only removed). This should be
6087 done by the <prgn>postrm</prgn> script when it is called
6088 with the argument <tt>purge</tt> (see <ref
6089 id="removedetails">).
6094 <heading>Permissions and owners</heading>
6097 The rules in this section are guidelines for general use.
6098 If necessary you may deviate from the details below.
6099 However, if you do so you must make sure that what is done
6100 is secure and you should try to be as consistent as possible
6101 with the rest of the system. You should probably also
6102 discuss it on <prgn>debian-devel</prgn> first.
6106 Files should be owned by <tt>root.root</tt>, and made
6107 writable only by the owner and universally readable (and
6108 executable, if appropriate), that is mode 644 or 755.
6112 Directories should be mode 755 or (for group-writability)
6113 mode 2775. The ownership of the directory should be
6114 consistent with its mode: if a directory is mode 2775, it
6115 should be owned by the group that needs write access to
6120 Setuid and setgid executables should be mode 4755 or 2755
6121 respectively, and owned by the appropriate user or group.
6122 They should not be made unreadable (modes like 4711 or
6123 2711 or even 4111); doing so achieves no extra security,
6124 because anyone can find the binary in the freely available
6125 Debian package; it is merely inconvenient. For the same
6126 reason you should not restrict read or execute permissions
6127 on non-set-id executables.
6131 Some setuid programs need to be restricted to particular
6132 sets of users, using file permissions. In this case they
6133 should be owned by the uid to which they are set-id, and by
6134 the group which should be allowed to execute them. They
6135 should have mode 4754; again there is no point in making
6136 them unreadable to those users who must not be allowed to
6141 It is possible to arrange that the system administrator can
6142 reconfigure the package to correspond to their local
6143 security policy by changing the permissions on a binary:
6144 they can do this by using <prgn>dpkg-statoverride</prgn>, as
6145 described below.<footnote>
6147 Ordinary files installed by <prgn>dpkg</prgn> (as
6148 opposed to <tt>conffile</tt>s and other similar objects)
6149 normally have their permissions reset to the distributed
6150 permissions when the package is reinstalled. However,
6151 the use of <prgn>dpkg-statoverride</prgn> overrides this
6152 default behaviour. If you use this method, you should
6153 remember to describe <prgn>dpkg-statoverride</prgn> in
6154 the package documentation; being a relatively new
6155 addition to Debian, it is probably not yet well-known.
6158 Another method you should consider is to create a group for
6159 people allowed to use the program(s) and make any setuid
6160 executables executable only by that group.
6164 If you need to create a new user or group for your package
6165 there are two possibilities. Firstly, you may need to
6166 make some files in the binary package be owned by this
6167 user or group, or you may need to compile the user or
6168 group id (rather than just the name) into the binary
6169 (though this latter should be avoided if possible, as in
6170 this case you need a statically allocated id).</p>
6173 If you need a statically allocated id, you must ask for a
6174 user or group id from the <tt>base-passwd</tt> maintainer,
6175 and must not release the package until you have been
6176 allocated one. Once you have been allocated one you must
6177 either make the package depend on a version of the
6178 <tt>base-passwd</tt> package with the id present in
6179 <tt>/etc/passwd</tt> or <tt>/etc/group</tt>, or arrange for
6180 your package to create the user or group itself with the
6181 correct id (using <tt>adduser</tt>) in its
6182 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
6183 the <prgn>postinst</prgn> is to be preferred if it is
6184 possible, otherwise a pre-dependency will be needed on the
6185 <tt>adduser</tt> package.)
6189 On the other hand, the program might be able to determine
6190 the uid or gid from the user or group name at runtime, so
6191 that a dynamically allocated id can be used. In this case
6192 you should choose an appropriate user or group name,
6193 discussing this on <prgn>debian-devel</prgn> and checking
6194 with the base system maintainer that it is unique and that
6195 they do not wish you to use a statically allocated id
6196 instead. When this has been checked you must arrange for
6197 your package to create the user or group if necessary using
6198 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6199 <prgn>postinst</prgn> script (again, the latter is to be
6200 preferred if it is possible).
6204 Note that changing the numeric value of an id associated
6205 with a name is very difficult, and involves searching the
6206 file system for all appropriate files. You need to think
6207 carefully whether a static or dynamic id is required, since
6208 changing your mind later will cause problems.
6211 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6213 This section is not intended as policy, but as a
6214 description of the use of <prgn>dpkg-statoverride</prgn>.
6218 <prgn>dpkg-statoverride</prgn> is a replacement for the
6219 deprecated <tt>suidmanager</tt> package. Packages which
6220 previously used <tt>suidmanager</tt> should have a
6221 <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6222 <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6223 and <tt>suidunregister</tt> should now be simply removed
6224 from the maintainer scripts.
6228 If a system administrator wishes to have a file (or
6229 directory or other such thing) installed with owner and
6230 permissions different from those in the distributed Debian
6231 package, he can use the <prgn>dpkg-statoverride</prgn>
6232 program to instruct <prgn>dpkg</prgn> to use the different
6233 settings every time the file is installed. Thus the
6234 package maintainer should distribute the files with their
6235 normal permissions, and leave it for the system
6236 administrator to make any desired changes. For example, a
6237 daemon which is normally required to be setuid root, but
6238 in certain situations could be used without being setuid,
6239 should be installed setuid in the <tt>.deb</tt>. Then the
6240 local system administrator can change this if they wish.
6241 If there are two standard ways of doing it, the package
6242 maintainer can use <tt>debconf</tt> to find out the
6243 preference, and call <prgn>dpkg-statoverride</prgn> in the
6244 maintainer script if necessary to accommodate the system
6245 administrator's choice.
6249 Given the above, <prgn>dpkg-statoverride</prgn> is
6250 essentially a tool for system administrators and would not
6251 normally be needed in the maintainer scripts. There is
6252 one type of situation, though, where calls to
6253 <prgn>dpkg-statoverride</prgn> would be needed in the
6254 maintainer scripts, and that involves packages which use
6255 dynamically allocated user or group ids. In such a
6256 situation, something like the following idiom can be very
6257 helpful in the package's <prgn>postinst</prgn>, where
6258 <tt>sysuser</tt> is a dynamically allocated id:
6260 for i in /usr/bin/foo /usr/sbin/bar
6262 if ! dpkg-statoverride --list $i >/dev/null
6264 dpkg-statoverride --update --add sysuser root 4755 $i
6268 The corresponding <tt>dpkg-statoverride --remove</tt>
6269 calls can then be made unconditionally when the package is
6276 <chapt id="customized-programs">
6277 <heading>Customized programs</heading>
6279 <sect id="arch-spec">
6280 <heading>Architecture specification strings</heading>
6283 If a program needs to specify an <em>architecture specification
6284 string</em> in some place, the following format should be used:
6285 <example compact="compact">
6286 <var>arch</var>-<var>os</var>
6287 </example><footnote>
6289 The following architectures and operating systems are
6290 currently recognised by <prgn>dpkg-archictecture</prgn>.
6291 The architecture, <tt><var>arch</var></tt>, is one of
6292 the following: <tt>alpha</tt>, <tt>arm</tt>,
6293 <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6294 <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6295 <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6296 <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>. The
6297 operating system, <tt><var>os</var></tt>, is one of:
6298 <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6299 <tt>openbsd</tt>. Use of <tt>gnu</tt> in this string is
6300 reserved for the GNU/Hurd operating system.
6306 Note that we don't want to use
6307 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6308 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6309 since this would make our programs incompatible with other
6310 Linux distributions. We also don't use something like
6311 <tt><var>arch</var>-unknown-linux</tt>, since the
6312 <tt>unknown</tt> does not look very good.
6317 <heading>Daemons</heading>
6320 The configuration files <tt>/etc/services</tt>,
6321 <tt>/etc/protocols</tt>, and <tt>/etc/rpc</tt> are managed
6322 by the <prgn>netbase</prgn> package and must not be modified
6327 If a package requires a new entry in one of these files, the
6328 maintainer should get in contact with the
6329 <prgn>netbase</prgn> maintainer, who will add the entries
6330 and release a new version of the <prgn>netbase</prgn>
6335 The configuration file <tt>/etc/inetd.conf</tt> must not be
6336 modified by the package's scripts except via the
6337 <prgn>update-inetd</prgn> script or the
6338 <tt>DebianNet.pm</tt> Perl module. See their documentation
6339 for details on how to add entries.
6343 If a package wants to install an example entry into
6344 <tt>/etc/inetd.conf</tt>, the entry must be preceded with
6345 exactly one hash character (<tt>#</tt>). Such lines are
6346 treated as `commented out by user' by the
6347 <prgn>update-inetd</prgn> script and are not changed or
6348 activated during package updates.
6353 <heading>Using pseudo-ttys and modifying wtmp, utmp and
6357 Some programs need to create pseudo-ttys. This should be done
6358 using Unix98 ptys if the C library supports it. The resulting
6359 program must not be installed setuid root, unless that
6360 is required for other functionality.
6364 The files <tt>/var/run/utmp</tt>, <tt>/var/log/wtmp</tt> and
6365 <tt>/var/log/lastlog</tt> must be installed writeable by
6366 group <tt>utmp</tt>. Programs which need to modify those
6367 files must be installed setgid <tt>utmp</tt>.
6372 <heading>Editors and pagers</heading>
6375 Some programs have the ability to launch an editor or pager
6376 program to edit or display a text document. Since there are
6377 lots of different editors and pagers available in the Debian
6378 distribution, the system administrator and each user should
6379 have the possibility to choose his/her preferred editor and
6384 In addition, every program should choose a good default
6385 editor/pager if none is selected by the user or system
6390 Thus, every program that launches an editor or pager must
6391 use the EDITOR or PAGER environment variable to determine
6392 the editor or pager the user wishes to use. If these
6393 variables are not set, the programs <tt>/usr/bin/editor</tt>
6394 and <tt>/usr/bin/pager</tt> should be used, respectively.
6398 These two files are managed through the <prgn>dpkg</prgn>
6399 `alternatives' mechanism. Thus every package providing an
6400 editor or pager must call the
6401 <prgn>update-alternatives</prgn> script to register these
6406 If it is very hard to adapt a program to make use of the
6407 EDITOR or PAGER variables, that program may be configured to
6408 use <tt>/usr/bin/sensible-editor</tt> and
6409 <tt>/usr/bin/sensible-pager</tt> as the editor or pager
6410 program respectively. These are two scripts provided in the
6411 Debian base system that check the EDITOR and PAGER variables
6412 and launch the appropriate program, and fall back to
6413 <tt>/usr/bin/editor</tt> and <tt>/usr/bin/pager</tt> if the
6414 variable is not set.
6418 A program may also use the VISUAL environment variable to
6419 determine the user's choice of editor. If it exists, it
6420 should take precedence over EDITOR. This is in fact what
6421 <tt>/usr/bin/sensible-editor</tt> does.
6425 It is not required for a package to depend on
6426 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6427 package to provide such virtual packages.<footnote>
6429 The Debian base system already provides an editor and a
6436 <sect id="web-appl">
6437 <heading>Web servers and applications</heading>
6440 This section describes the locations and URLs that should
6441 be used by all web servers and web applications in the
6449 Cgi-bin executable files are installed in the
6451 <example compact="compact">
6452 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6454 and should be referred to as
6455 <example compact="compact">
6456 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6461 <item><p>Access to HTML documents</p>
6464 HTML documents for a package are stored in
6465 <tt>/usr/share/doc/<var>package</var></tt> but should
6466 be accessed via symlinks as
6467 <tt>/usr/doc/<var>package</var></tt><footnote>
6469 for backward compatibility; see <ref
6473 and can be referred to as
6474 <example compact="compact">
6475 http://localhost/doc/<var>package</var>/<var>filename</var>
6480 <item><p>Web Document Root</p>
6483 Web Applications should try to avoid storing files in
6484 the Web Document Root. Instead they should use the
6485 /usr/share/doc/<var>package</var> directory for
6486 documents and register the Web Application via the
6487 menu package. If access to the web document root is
6488 unavoidable then use
6489 <example compact="compact">
6492 as the Document Root. This might be just a symbolic
6493 link to the location where the system administrator
6494 has put the real document root.
6498 </enumlist></p></sect>
6501 <sect id="mail-transport-agents">
6502 <heading>Mail transport, delivery and user agents</heading>
6505 Debian packages which process electronic mail, whether mail
6506 user agents (MUAs) or mail transport agents (MTAs), must
6507 ensure that they are compatible with the configuration
6508 decisions below. Failure to do this may result in lost
6509 mail, broken <tt>From:</tt> lines, and other serious brain
6514 The mail spool is <tt>/var/mail</tt> and the interface to
6515 send a mail message is <tt>/usr/sbin/sendmail</tt> (as per
6516 the FHS). On older systems, the mail spool may be
6517 physically located in <tt>/var/spool/mail</tt>, but all
6518 access to the mail spool should be via the
6519 <tt>/var/mail</tt> symlink. The mail spool is part of the
6520 base system and not part of the MTA package.
6524 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6525 programs (such as IMAP daemons) must lock the mailbox in an
6526 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6527 be combined with dot locking. To avoid deadlocks, a program
6528 should use <tt>fcntl()</tt> first and dot locking after
6529 this, or alternatively implement the two locking methods in
6530 a non blocking way<footnote>
6532 If it is not possible to establish both locks, the
6533 system shouldn't wait for the second lock to be
6534 established, but remove the first lock, wait a (random)
6535 time, and start over locking again.
6537 </footnote>. Using the functions <tt>maillock</tt> and
6538 <tt>mailunlock</tt> provided by the
6539 <tt>liblockfile*</tt><footnote>
6541 You will need to depend on <tt>liblockfile1
6542 (>>1.01)</tt> to use these functions.
6544 </footnote> packages is the recommended way to realize this.
6548 Mailboxes are generally mode 660
6549 <tt><var>user</var>.mail</tt> unless the system
6550 administrator has chosen otherwise. A MUA may remove a
6551 mailbox (unless it has nonstandard permissions) in which
6552 case the MTA or another MUA must recreate it if needed.
6553 Mailboxes must be writable by group mail.
6557 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6558 be setgid mail to do the locking mentioned above (and
6559 must obviously avoid accessing other users' mailboxes
6560 using this privilege).</p>
6563 <tt>/etc/aliases</tt> is the source file for the system mail
6564 aliases (e.g., postmaster, usenet, etc.), it is the one
6565 which the sysadmin and <prgn>postinst</prgn> scripts may
6566 edit. After <tt>/etc/aliases</tt> is edited the program or
6567 human editing it must call <prgn>newaliases</prgn>. All MTA
6568 packages must come with a <prgn>newaliases</prgn> program,
6569 even if it does nothing, but older MTA packages did not do
6570 this so programs should not fail if <prgn>newaliases</prgn>
6571 cannot be found. Note that because of this, all MTA
6572 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6573 <tt>Replaces: mail-transport-agent</tt> control file
6578 The convention of writing <tt>forward to
6579 <var>address</var></tt> in the mailbox itself is not
6580 supported. Use a <tt>.forward</tt> file instead.</p>
6583 The <prgn>rmail</prgn> program used by UUCP
6584 for incoming mail should be <tt>/usr/sbin/rmail</tt>.
6585 Likewise, <prgn>rsmtp</prgn>, for receiving
6586 batch-SMTP-over-UUCP, should be <tt>/usr/sbin/rsmtp</tt> if it
6590 If your package needs to know what hostname to use on (for
6591 example) outgoing news and mail messages which are generated
6592 locally, you should use the file <tt>/etc/mailname</tt>. It
6593 will contain the portion after the username and <tt>@</tt>
6594 (at) sign for email addresses of users on the machine
6595 (followed by a newline).
6599 Such package should check for the existence of this file
6600 when it is being configured. If it exists, it should be
6601 used without comment, although an MTA's configuration script
6602 may wish to prompt the user even if it finds that this file
6603 exists. If the file does not exist, the package should
6604 prompt the user for the value (preferably using
6605 <prgn>debconf</prgn>) and store it in <tt>/etc/mailname</tt>
6606 as well as using it in the package's configuration. The
6607 prompt should make it clear that the name will not just be
6608 used by that package. For example, in this situation the
6609 <tt>inn</tt> package could say something like:
6610 <example compact="compact">
6611 Please enter the `mail name' of your system. This is the
6612 hostname portion of the address to be shown on outgoing
6613 news and mail messages. The default is
6614 <var>syshostname</var>, your system's host name. Mail
6615 name [`<var>syshostname</var>']:
6617 where <var>syshostname</var> is the output of <tt>hostname
6623 <heading>News system configuration</heading>
6626 All the configuration files related to the NNTP (news)
6627 servers and clients should be located under
6628 <tt>/etc/news</tt>.</p>
6631 There are some configuration issues that apply to a number
6632 of news clients and server packages on the machine. These
6636 <tag><tt>/etc/news/organization</tt></tag>
6637 <item><p>A string which should appear as the
6638 organization header for all messages posted
6639 by NNTP clients on the machine</p></item>
6641 <tag><tt>/etc/news/server</tt></tag>
6642 <item><p>Contains the FQDN of the upstream NNTP
6643 server, or localhost if the local machine is
6644 an NNTP server.</p></item>
6647 Other global files may be added as required for cross-package news
6648 configuration.</p></sect>
6652 <heading>Programs for the X Window System</heading>
6655 <heading>Providing X support and package priorities</heading>
6658 Programs that can be configured with support for the X
6659 Window System must be configured to do so and must declare
6660 any package dependencies necessary to satisfy their
6661 runtime requirements when using the X Window System. If
6662 such a package is of higher priority than the X packages
6663 on which it depends, it is required that either the
6664 X-specific components be split into a separate package, or
6665 that an alternative version of the package, which includes
6666 X support, be provided, or that the package's priority be
6672 <heading>Packages providing an X server</heading>
6675 Packages that provide an X server that, directly or
6676 indirectly, communicates with real input and display
6677 hardware should declare in their control data that they
6678 provide the virtual package <tt>xserver</tt>.<footnote>
6680 This implements current practice, and provides an
6681 actual policy for usage of the <tt>xserver</tt>
6682 virtual package which appears in the virtual packages
6683 list. In a nutshell, X servers that interface
6684 directly with the display and input hardware or via
6685 another subsystem (e.g., GGI) should provide
6686 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
6687 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
6694 <heading>Packages providing a terminal emulator</heading>
6697 Packages that provide a terminal emulator for the X Window
6698 System which meet the criteria listed below should declare
6699 in their control data that they provide the virtual
6700 package <tt>x-terminal-emulator</tt>. They should also
6701 register themselves as an alternative for
6702 <tt>/usr/bin/x-terminal-emulator</tt>, with a priority of
6707 To be an <tt>x-terminal-emulator</tt>, a program must:
6708 <list compact="compact">
6710 Be able to emulate a DEC VT100 terminal, or a
6711 compatible terminal.
6715 Support the command-line option <tt>-e
6716 <var>command</var></tt>, which creates a new
6717 terminal window<footnote>
6719 "New terminal window" does not necessarily mean
6720 a new top-level X window directly parented by
6721 the window manager; it could, if the terminal
6722 emulator application were so coded, be a new
6723 "view" in a multiple-document interface (MDI).
6726 and runs the specified <var>command</var>.
6730 Support the command-line option <tt>-T
6731 <var>title</var></tt>, which creates a new terminal
6732 window with the window title <var>title</var>.
6739 <heading>Packages providing a window manager</heading>
6742 Packages that provide a window manager should declare in
6743 their control data that they provide the virtual package
6744 <tt>x-window-manager</tt>. They should also register
6745 themselves as an alternative for
6746 <tt>/usr/bin/x-window-manager</tt>, with a priority
6747 calculated as follows:
6748 <list compact="compact">
6749 <item><p>Start with a priority of 20.</p></item>
6753 If the window manager supports the Debian menu
6754 system, add 20 points if this support is available
6755 in the package's default configuration (i.e., no
6756 configuration files belonging to the system or user
6757 have to be edited to activate the feature); if
6758 configuration files must be modified, add only 10
6765 If the window manager permits the X session to be
6766 restarted using a <em>different</em> window manager
6767 (without killing the X server) in its default
6768 configuration, add 10 points; otherwise add none.
6776 <heading>Packages providing fonts</heading>
6779 Packages that provide fonts for the X Window
6782 For the purposes of Debian Policy, a "font for the X
6783 Window System" is one which is accessed via X protocol
6784 requests. Fonts for the Linux console, for PostScript
6785 renderers, or any other purpose, do not fit this
6786 definition. Any tool which makes such fonts available
6787 to the X Window System, however, must abide by this
6791 must do a number of things to ensure that they are both
6792 available without modification of the X or font server
6793 configuration, and that they do not corrupt files used by
6794 other font packages to register information about
6799 Fonts of any type supported by the X Window System
6800 must be be in a separate binary package from any
6801 executables, libraries, or documentation (except
6802 that specific to the fonts shipped, such as their
6803 license information). If one or more of the fonts
6804 so packaged are necessary for proper operation of
6805 the package with which they are associated the font
6806 package may be Recommended; if the fonts merely
6807 provide an enhancement, a Suggests relationship may
6808 be used. Packages must not Depend on font
6811 This is because the X server may retrieve fonts
6812 from the local filesystem or over the network
6813 from an X font server; the Debian package system
6814 is empowered to deal only with the local
6823 BDF fonts must be converted to PCF fonts with the
6824 <prgn>bdftopcf</prgn> utility (available in the
6825 <tt>xutils</tt> package, <tt>gzip</tt>ped, and
6826 placed in a directory that corresponds to their
6828 <list compact="compact">
6830 100 dpi fonts must be placed in
6831 <tt>/usr/X11R6/lib/X11/fonts/100dpi/</tt>.
6835 75 dpi fonts must be placed in
6836 <tt>/usr/X11R6/lib/X11/fonts/75dpi/</tt>.
6840 Character-cell fonts, cursor fonts, and other
6841 low-resolution fonts must be placed in
6842 <tt>/usr/X11R6/lib/X11/fonts/misc/</tt>.
6849 Speedo fonts must be placed in
6850 <tt>/usr/X11R6/lib/X11/fonts/Speedo/</tt>.
6854 Type 1 fonts must be placed in
6855 <tt>/usr/X11R6/lib/X11/fonts/Type1/</tt>. If font
6856 metric files are available, they must be placed here
6862 Subdirectories of <tt>/usr/X11R6/lib/X11/fonts/</tt>
6863 other than those listed above must be neither
6864 created nor used. (The <tt>PEX</tt>, <tt>CID</tt>,
6865 and <tt>cyrillic</tt> directories are excepted for
6866 historical reasons, but installation of files into
6867 these directories remains discouraged.)
6873 Font packages may, instead of placing files directly
6874 in the X font directories listed above, provide
6875 symbolic links in the font directory which point to
6876 the files' actual location in the filesystem. Such
6877 a location must comply with the FHS.
6883 Font packages should not contain both 75dpi and
6884 100dpi versions of a font. If both are available,
6885 they should be provided in separate binary packages
6886 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
6887 the names of the packages containing the
6888 corresponding fonts.
6894 Fonts destined for the <tt>misc</tt> subdirectory
6895 should not be included in the same package as 75dpi
6896 or 100dpi fonts; instead, they should be provided in
6897 a separate package with <tt>-misc</tt> appended to
6904 Font packages must not provide the files
6905 <tt>fonts.dir</tt>, <tt>fonts.alias</tt>, or
6906 <tt>fonts.scale</tt> in a font directory:
6909 <tt>fonts.dir</tt> files must not be provided at all.
6914 <tt>fonts.alias</tt> and <tt>fonts.scale</tt>
6915 files, if needed, should be provided in the
6917 <tt>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></tt>,
6918 where <var>fontdir</var> is the name of the
6920 <tt>/usr/X11R6/lib/X11/fonts/</tt> where the
6921 package's corresponding fonts are stored
6922 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
6923 <var>package</var> is the name of the package
6924 that provides these fonts, and
6925 <var>extension</var> is either <tt>scale</tt>
6926 or <tt>alias</tt>, whichever corresponds to
6936 Font packages must declare a dependency on
6937 <tt>xutils (>> 4.0.3)</tt> in their control
6944 Font packages that provide one or more
6945 <tt>fonts.scale</tt> files as described above must
6946 invoke <prgn>update-fonts-scale</prgn> on each
6947 directory into which they installed fonts
6948 <em>before</em> invoking
6949 <prgn>update-fonts-dir</prgn> on that directory.
6950 This invocation must occur in both the
6951 <prgn>postinst</prgn> (for all arguments) and
6952 <prgn>postrm</prgn> (for all arguments except
6953 <tt>upgrade</tt>) scripts.
6959 Font packages that provide one or more
6960 <tt>fonts.alias</tt> files as described above must
6961 invoke <prgn>update-fonts-alias</prgn> on each
6962 directory into which they installed fonts. This
6963 invocation must occur in both the
6964 <prgn>postinst</prgn> (for all arguments) and
6965 <prgn>postrm</prgn> (for all arguments except
6966 <tt>upgrade</tt>) scripts.
6972 Font packages must invoke
6973 <prgn>update-fonts-dir</prgn> on each directory into
6974 which they installed fonts. This invocation must
6975 occur in both the <prgn>postinst</prgn> (for all
6976 arguments) and <prgn>postrm</prgn> (for all
6977 arguments except <tt>upgrade</tt>) scripts.
6983 Font packages must not provide alias names for the
6984 fonts they include which collide with alias names
6985 already in use by fonts already packaged.
6991 Font packages must not provide fonts with the same
6992 XLFD registry name as another font already packaged.
7000 <heading>Application defaults files</heading>
7003 Application defaults files must be installed in the
7004 directory <tt>/etc/X11/app-defaults/</tt> (use of a
7005 localized subdirectory of <tt>/etc/X11/</tt> as described
7006 in the <em>X Toolkit Intrinsics - C Language
7007 Interface</em> manual is also permitted). They must be
7008 registered as <tt>conffile</tt>s or handled as
7009 configuration files. Packages must not provide the
7010 directory <tt>/usr/X11R6/lib/X11/app-defaults/</tt>.
7014 Customization of programs' X resources may also be
7015 supported with the provision of a file with the same name
7016 as that of the package placed in the
7017 <tt>/etc/X11/Xresources/</tt> directory, which must
7018 registered as a <tt>conffile</tt> or handled as a
7019 configuration file.<footnote>
7021 Note that this mechanism is not the same as using
7022 app-defaults; app-defaults are tied to the client
7023 binary on the local filesystem, whereas X resources
7024 are stored in the X server and affect all connecting
7028 <em>Important:</em> packages that install files into the
7029 <tt>/etc/X11/Xresources/</tt> directory must conflict with
7030 <tt>xbase (<< 3.3.2.3a-2)</tt>; if this is not done
7031 it is possible for the installing package to destroy a
7032 previously-existing <tt>/etc/X11/Xresources</tt> file
7033 which had been customized by the system administrator.
7038 <heading>Installation directory issues</heading>
7041 Packages using the X Window System should not be
7042 configured to install files under the <tt>/usr/X11R6/</tt>
7043 directory unless they use <prgn>imake</prgn>. The
7044 <tt>/usr/X11R6/</tt> directory hierarchy should be
7045 regarded as deprecated for all packages except the X
7046 Window System itself, and those which use the
7047 <prgn>imake</prgn> program it provides, in which case the
7048 packages may transition out of the <tt>/usr/X11R6/</tt>
7049 directory at the maintainer's discretion.<footnote>
7051 <prgn>Imake</prgn>-using programs are exempt because,
7052 as long as they are written correctly, the pathnames
7053 they use to locate resources and install themselves
7054 are derived wholly from the X Window System
7055 configuration. Thus, in the event that the X Window
7056 System moves to <tt>/usr/X11R7/</tt>,
7057 <tt>/usr/X12/</tt>, or just plain <tt>/usr/</tt>, all
7058 that is required for these programs is a recompile
7059 against the corresponding X Window System library
7060 development packages.
7063 Programs that use GNU <prgn>autoconf</prgn> and
7064 <prgn>automake</prgn> are usually easily configured at
7065 compile time to use <tt>/usr/</tt> instead of
7066 <tt>/usr/X11R6/</tt>, and this should be done whenever
7067 possible. Configuration files for window managers and
7068 display managers should be placed in a subdirectory of
7069 <tt>/etc/X11/</tt> corresponding to the package name due
7070 to these programs' tight integration with the mechanisms
7071 of the X Window System. Application-level programs should
7072 use the <tt>/etc/</tt> directory unless otherwise mandated
7073 by policy. The installation of files into subdirectories
7074 of <tt>/usr/X11R6/include/X11/</tt> and
7075 <tt>/usr/X11R6/lib/X11/</tt> is permitted but discouraged;
7076 package maintainers should determine if subdirectories of
7077 <tt>/usr/lib/</tt> and <tt>/usr/share/</tt> can be used
7078 instead. (The use of symbolic links from the
7079 <tt>X11R6</tt> directories to other FHS-compliant
7080 locations is encouraged if the program is not easily
7081 configured to look elsewhere for its files.) Packages
7082 must not provide or install files into the directories
7083 <tt>/usr/bin/X11/</tt>, <tt>/usr/include/X11/</tt> or
7084 <tt>/usr/lib/X11/</tt>. Files within a package should,
7085 however, make reference to these directories, rather than
7086 their <tt>X11R6</tt>-named counterparts
7087 <tt>/usr/X11R6/bin/</tt>, <tt>/usr/X11R6/include/X11/</tt>
7088 and <tt>/usr/X11R6/lib/X11/</tt>, if the resources being
7089 referred to have not been moved to other FHS-compliant
7095 <heading>The OSF/Motif and OpenMotif libraries</heading>
7098 <em>Programs that require the non-DFSG-compliant OSF/Motif or
7099 OpenMotif libraries</em><footnote>
7101 OSF/Motif and OpenMotif are collectively referred to as
7102 "Motif" in this policy document.
7105 should be compiled against and tested with LessTif (a free
7106 re-implementation of Motif) instead. If the maintainer
7107 judges that the program or programs do not work
7108 sufficiently well with LessTif to be distributed and
7109 supported, but do so when compiled against Motif, then two
7110 versions of the package should be created; one linked
7111 statically against Motif and with <tt>-smotif</tt>
7112 appended to the package name, and one linked dynamically
7113 against Motif and with <tt>-dmotif</tt> appended to the
7114 package name. Both Motif-linked versions are dependent
7115 upon non-DFSG-compliant software and thus cannot be
7116 uploaded to the <em>main</em> distribution; if the
7117 software is itself DFSG-compliant it may be uploaded to
7118 the <em>contrib</em> distribution. While known existing
7119 versions of Motif permit unlimited redistribution of
7120 binaries linked against the library (whether statically or
7121 dynamically), it is the package maintainer's
7122 responsibility to determine whether this is permitted by
7123 the license of the copy of Motif in his or her possession.
7129 <heading>Perl programs and modules</heading>
7131 Perl programs and modules should follow the current Perl
7132 policy as defined in the file found on
7133 <ftpsite>ftp.debian.org</ftpsite> in
7134 <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>
7135 or your local mirror. In addition, it is included in the
7136 <tt>debian-policy</tt> package.
7141 <heading>Emacs lisp programs</heading>
7144 Please refer to the `Debian Emacs Policy' (documented in
7145 <tt>debian-emacs-policy.gz</tt> of the
7146 <prgn>emacsen-common</prgn> package) for details of how to
7147 package emacs lisp programs.
7152 <heading>Games</heading>
7155 The permissions on <tt>/var/games</tt> are mode 755, owner
7156 <tt>root</tt> and group <tt>root</tt>.
7160 Each game decides on its own security policy.</p>
7163 Games which require protected, privileged access to
7164 high-score files, savegames, etc., may be made
7165 set-<em>group</em>-id (mode 2755) and owned by
7166 <tt>root.games</tt>, and use files and directories with
7167 appropriate permissions (770 <tt>root.games</tt>, for
7168 example). They must not be made
7169 set-<em>user</em>-id, as this causes security problems. (If
7170 an attacker can subvert any set-user-id game they can
7171 overwrite the executable of any other, causing other players
7172 of these games to run a Trojan horse program. With a
7173 set-group-id game the attacker only gets access to less
7174 important game data, and if they can get at the other
7175 players' accounts at all it will take considerably more
7179 Some packages, for example some fortune cookie programs, are
7180 configured by the upstream authors to install with their
7181 data files or other static information made unreadable so
7182 that they can only be accessed through set-id programs
7183 provided. You should not do this in a Debian package: anyone can
7184 download the <tt>.deb</tt> file and read the data from it,
7185 so there is no point making the files unreadable. Not
7186 making the files unreadable also means that you don't have
7187 to make so many programs set-id, which reduces the risk of a
7191 As described in the FHS, binaries of games should be
7192 installed in the directory <tt>/usr/games</tt>. This also
7193 applies to games that use the X Window System. Manual pages
7194 for games (X and non-X games) should be installed in
7195 <tt>/usr/share/man/man6</tt>.</p>
7199 <chapt id="docs"><heading>Documentation</heading>
7203 <heading>Manual pages</heading>
7206 You should install manual pages in <prgn>nroff</prgn> source
7207 form, in appropriate places under <tt>/usr/share/man</tt>. You
7208 should only use sections 1 to 9 (see the FHS for more
7209 details). You must not install a preformatted `cat
7213 Each program, utility, and function should have an
7214 associated manpage included in the same package. It is
7215 suggested that all configuration files also have a manual
7216 page included as well.
7220 If no manual page is available for a particular program,
7221 utility, function or configuration file and this is reported as a bug on
7222 debian-bugs, a symbolic link from the requested manual page
7223 to the <manref name="undocumented" section="7"> manual page
7224 may be provided. This symbolic link can be created from
7225 <tt>debian/rules</tt> like this:
7226 <example compact="compact">
7227 ln -s ../man7/undocumented.7.gz \
7228 debian/tmp/usr/share/man/man[1-9]/the_requested_manpage.[1-9].gz
7230 This manpage claims that the lack of a manpage has been
7231 reported as a bug, so you may only do this if it really has
7232 (you can report it yourself, if you like). Do not close the
7233 bug report until a proper manpage is available.</p>
7236 You may forward a complaint about a missing manpage to the
7237 upstream authors, and mark the bug as forwarded in the
7238 Debian bug tracking system. Even though the GNU Project do
7239 not in general consider the lack of a manpage to be a bug,
7240 we do; if they tell you that they don't consider it a bug
7241 you should leave the bug in our bug tracking system open
7245 Manual pages should be installed compressed using <tt>gzip
7249 If one manpage needs to be accessible via several names it
7250 is better to use a symbolic link than the <tt>.so</tt>
7251 feature, but there is no need to fiddle with the relevant
7252 parts of the upstream source to change from <tt>.so</tt> to
7253 symlinks: don't do it unless it's easy. You should not
7254 create hard links in the manual page directories, nor put
7255 absolute filenames in <tt>.so</tt> directives. The filename
7256 in a <tt>.so</tt> in a manpage should be relative to the
7257 base of the manpage tree (usually
7258 <tt>/usr/share/man</tt>). If you do not create any links
7259 (whether symlinks, hard links, or <tt>.so</tt> directives)
7260 in the filesystem to the alternate names of the manpage,
7261 then you should not rely on <prgn>man</prgn> finding your
7262 manpage under those names based solely on the information in
7263 the manpage's header.<footnote>
7265 Supporting this in <prgn>man</prgn> often requires
7266 unreasonable processing time to find a manual page or to
7267 report that none exists, and moves knowledge into man's
7268 database that would be better left in the filesystem.
7269 This support is therefore deprecated and will cease to
7270 be present in the future.
7277 <heading>Info documents</heading>
7280 Info documents should be installed in <tt>/usr/share/info</tt>.
7281 They should be compressed with <tt>gzip -9</tt>.</p>
7284 Your package should call <prgn>install-info</prgn> to update the Info
7286 file, in its <prgn>postinst</prgn> script:
7287 <example compact="compact">
7288 install-info --quiet --section Development Development \
7289 /usr/share/info/foobar.info
7293 It is a good idea to specify a section for the location of
7294 your program; this is done with the <tt>--section</tt>
7295 switch. To determine which section to use, you should look
7296 at <tt>/usr/share/info/dir</tt> on your system and choose the most
7297 relevant (or create a new section if none of the current
7298 sections are relevant). Note that the <tt>--section</tt>
7299 flag takes two arguments; the first is a regular expression
7300 to match (case-insensitively) against an existing section,
7301 the second is used when creating a new one.</p>
7304 You should remove the entries in the <prgn>prerm</prgn> script:
7305 <example compact="compact">
7306 install-info --quiet --remove /usr/share/info/foobar.info
7310 If <prgn>install-info</prgn> cannot find a description entry
7311 in the Info file you must supply one. See <manref
7312 name="install-info" section="8"> for details.</p>
7316 <heading>Additional documentation</heading>
7319 Any additional documentation that comes with the package may
7320 be installed at the discretion of the package maintainer.
7321 Text documentation should be installed in a directory
7322 <tt>/usr/share/doc/<var>package</var></tt>, where
7323 <var>package</var> is the name of the package, and
7324 compressed with <tt>gzip -9</tt> unless it is small.</p>
7327 If a package comes with large amounts of documentation which
7328 many users of the package will not require you should create
7329 a separate binary package to contain it, so that it does not
7330 take up disk space on the machines of users who do not need
7331 or want it installed.</p>
7334 It is often a good idea to put text information files
7335 (<tt>README</tt>s, changelogs, and so forth) that come with
7336 the source package in <tt>/usr/share/doc/<var>package</var></tt>
7337 in the binary package. However, you don't need to install
7338 the instructions for building and installing the package, of
7342 Files in <tt>/usr/share/doc</tt> should not be referenced by
7343 any program, and the system administrator should be able to
7344 delete them without causing any programs to break. Any files
7345 that are referenced by programs but are also useful as
7346 standalone documentation should be installed under
7347 <tt>/usr/share/<var>package</var>/</tt> and symlinked in
7348 <tt>/usr/share/doc/<var>package</var>/</tt>.
7354 <heading>Accessing the documentation</heading>
7357 Former Debian releases placed all additional documentation
7358 in <tt>/usr/doc/<var>package</var></tt>. To realize a
7360 <tt>/usr/share/doc/<var>package</var></tt>, each package
7361 must maintain a symlink <tt>/usr/doc/<var>package</var></tt>
7362 that points to the new location of its documentation in
7363 <tt>/usr/share/doc/<var>package</var></tt><footnote>These
7364 symlinks will be removed in the future, but they have to be
7365 there for compatibility reasons until all packages have
7366 moved and the policy is changed accordingly.</footnote>.
7367 The symlink must be created when the package is installed;
7368 it cannot be contained in the package itself due to problems
7369 with <prgn>dpkg</prgn>. One reasonable way to accomplish
7370 this is to put the following in the package's
7371 <prgn>postinst</prgn>:
7372 <example compact="compact">
7373 if [ "$1" = "configure" ]; then
7374 if [ -d /usr/doc -a ! -e /usr/doc/#PACKAGE# \
7375 -a -d /usr/share/doc/#PACKAGE# ]; then
7376 ln -sf ../share/doc/#PACKAGE# /usr/doc/#PACKAGE#
7380 And the following in the package's <prgn>prerm</prgn>:
7381 <example compact="compact">
7382 if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \
7383 -a -L /usr/doc/#PACKAGE# ]; then
7384 rm -f /usr/doc/#PACKAGE#
7391 <heading>Preferred documentation formats</heading>
7394 The unification of Debian documentation is being carried out
7398 If your package comes with extensive documentation in a
7399 mark up format that can be converted to various other formats
7400 you should if possible ship HTML versions in a binary
7401 package, in the directory
7402 <tt>/usr/share/doc/<var>appropriate package</var></tt> or its
7403 subdirectories.<footnote>
7404 <p>The rationale: The important thing here is that HTML
7405 docs should be available in <em>some</em> package, not
7406 necessarily in the main binary package, though. </p>
7411 Other formats such as PostScript may be provided at your
7415 <sect id="copyrightfile">
7416 <heading>Copyright information</heading>
7419 Every package must be accompanied by a verbatim copy of its
7420 copyright and distribution license in the file
7421 /usr/share/doc/<var>package</var>/copyright. This file must
7422 neither be compressed nor be a symbolic link.</p>
7425 In addition, the copyright file must say where the upstream
7426 sources (if any) were obtained, and should explain briefly what
7427 modifications were made in the Debian version of the package
7428 compared to the upstream one. It should name the original
7429 authors of the package and the Debian maintainer(s) who were
7430 involved with its creation.</p>
7433 A copy of the file which will be installed in
7434 <tt>/usr/share/doc/<var>package</var>/copyright</tt> should be
7435 in <tt>debian/copyright</tt>.</p>
7439 /usr/share/doc/<var>package</var> may be a symbolic link to a
7440 directory in /usr/share/doc only if two packages both come from
7441 the same source and the first package has a "Depends"
7442 relationship on the second. These rules are important
7443 because copyrights must be extractable by mechanical
7447 Packages distributed under the UCB BSD license, the Artistic
7448 license, the GNU GPL, and the GNU LGPL should refer to the
7449 files /usr/share/common-licenses/BSD,
7450 /usr/share/common-licenses/Artistic,
7451 /usr/share/common-licenses/GPL, and
7452 /usr/share/common-licenses/LGPL.<footnote>
7454 Why "licenses" and not "copyright"? Because
7455 <tt>/usr/doc/copyright</tt> used to contain all the
7456 copyright files, plus the four common licenses GPL,
7457 LGPL, Artistic and BSD. Now individual copyright files
7458 for packages are no longer in a common directory. Once
7459 <tt>/usr/doc/copyright</tt> is almost empty it makes
7460 sense to rename "copyright" to "licenses"
7463 Why "common-licenses" and not "licenses"? Because if I
7464 put just "licenses" I'm sure I will receive a bug report
7465 saying "license foo is not included in the licenses
7466 directory. They are not all the licenses, just a few
7467 common ones. I could use /usr/share/doc/common-licenses
7468 but I think this is too long, and, after all, the GPL
7469 does not "document" anything, it is merely a license.
7475 You should not use the copyright file as a general <tt>README</tt>
7476 file. If your package has such a file it should be
7477 installed in <tt>/usr/share/doc/<var>package</var>/README</tt> or
7478 <tt>README.Debian</tt> or some other appropriate place.</p>
7482 <heading>Examples</heading>
7485 Any examples (configurations, source files, whatever),
7486 should be installed in a directory
7487 <tt>/usr/share/doc/<var>package</var>/examples</tt>. These
7488 files should not be referenced by any program: they're there
7489 for the benefit of the system administrator and users, as
7490 documentation only. Architecture-specific example files
7491 should be installed in a directory
7492 <tt>/usr/lib/<var>package</var>/examples</tt>, and files in
7493 <tt>/usr/share/doc/<var>package</var>/examples</tt> symlink
7494 to files in it. Or the latter directory may be a symlink to
7498 <sect id="instchangelog">
7499 <heading>Changelog files</heading>
7502 Packages that are not Debian-native must contain a copy of
7503 <tt>debian/changelog</tt> file from the Debian source tree
7504 in <tt>/usr/share/doc/<var>package</var></tt> as
7505 <tt>changelog.Debian.gz</tt>. If an upstream changelog is
7506 available, it should be accessible as
7507 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt> in
7508 plain text. If the upstream changelog is distributed in
7509 HTML, it should be made available in that form as
7510 <tt>/usr/share/doc/<var>package</var>/changelog.html.gz</tt>
7511 and the <tt>changelog.gz</tt> should be generated using, eg,
7512 <tt>lynx -dump -nolist</tt>. If the upstream changelog files
7513 do not already conform to this naming convention, then this
7514 may be achieved either by renaming the files, or adding a
7515 symbolic link, at the maintainer's discretion.<footnote>
7517 Rationale: People should not have to look into two
7518 places for upstream changelogs merely because they are
7526 All these files should be installed compressed using <tt>gzip -9</tt>,
7527 as they will become large with time even if they start out
7532 If the package has only one changelog which is used both as
7533 the Debian changelog and the upstream one because there is
7534 no separate upstream maintainer then that changelog should
7535 usually be installed as
7536 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>; if
7537 there is a separate upstream maintainer, but no upstream
7538 changelog, then the Debian changelog should still be called
7539 <tt>changelog.Debian.gz</tt>.</p>