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.
121 Informally, the criteria used for inclusion is that the
122 material meet one of the following requirements:
123 <taglist compact="compact">
124 <tag>Standard interfaces</tag>
127 The material presented represents an interface to
128 the packaging system that is mandated for use, and
129 is used by, a significant number of packages, and
130 therefore should not be changed without peer
131 review. Package maintainers can then rely on this
132 interfaces not changing, and the package
133 management software authors need to ensure
134 compatibility with these interface
135 definitions. (Control file and changelog file
136 formats are examples.)
139 <tag>Chosen Convention</tag>
142 If there are a number of technically viable choices
143 that can be made, but one needs to select one of
144 these options for inter-operability. The version
145 number format is one example.
149 Please note that these are not mutually exclusive;
150 selected conventions often become parts of standard
157 The footnotes present in this manual are
158 merely informative, and are not part of Debian policy itself.
163 In this manual, the words <em>must</em>, <em>should</em> and
164 <em>may</em>, and the adjectives <em>required</em>,
165 <em>recommended</em> and <em>optional</em>, are used to
166 distinguish the significance of the various guidelines in
167 this policy document. Packages that do not conform to the
168 guidelines denoted by <em>must</em> (or <em>required</em>)
169 will generally not be considered acceptable for the Debian
170 distribution. Non-conformance with guidelines denoted by
171 <em>should</em> (or <em>recommended</em>) will generally be
172 considered a bug, but will not necessarily render a package
173 unsuitable for distribution. Guidelines denoted by
174 <em>may</em> (or <em>optional</em>) are truly optional and
175 adherence is left to the maintainer's discretion.
178 These classifications are roughly equivalent to the bug
179 severities <em>serious</em> (for <em>must</em> or
180 <em>required</em> directive violations), <em>minor</em>,
181 <em>normal</em> or <em>important</em>
182 (for <em>should</em> or <em>recommended</em> directive
183 violations) and <em>wishlist</em> (for <em>optional</em>
185 <p>Compare RFC 2119. Note, however, that these words are
186 used in a different way in this document.</p>
190 Much of the information presented in this manual will be
191 useful even when building a package which is to be
192 distributed in some other way or is intended for local use
197 <heading>New versions of this document</heading>
199 The current version of this document is always accessible
200 from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
202 <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
203 (also available from the same directory are several other
204 formats: <tt>policy.html.tar.gz</tt>, <tt>policy.pdf.gz</tt>
205 and <tt>policy.ps.gz</tt>) or from the <url
206 id="http://www.debian.org/doc/debian-policy/" name="Debian
207 Policy Manual"> webpage.</p>
210 In addition, this manual is distributed via the Debian package
211 <tt>debian-policy</tt>.
215 The <tt>debian-policy</tt> package also includes the file
216 <tt>upgrading-checklist.txt</tt> which indicates policy
217 changes between versions of this document.
221 <heading>Feedback</heading>
224 As the Debian GNU/Linux system is continuously evolving this
228 While the authors of this document have tried hard to avoid
229 typos and other errors, these do still occur. If you discover
230 an error in this manual or if you want to give any
231 comments, suggestions, or criticisms please send an email to
232 the Debian Policy List,
233 <email>debian-policy@lists.debian.org</email>, or submit a
234 bug report against the <tt>debian-policy</tt> package.
240 <heading>The Debian Archive</heading>
242 The Debian GNU/Linux system is maintained and distributed as a
243 collection of <em>packages</em>. Since there are so many of
244 them (currently well over 6000), they are split into
245 <em>sections</em> and given <em>priorities</em> to simplify
246 the handling of them.
249 The effort of the Debian project is to build a free operating
250 system, but not every package we want to make accessible is
251 <em>free</em> in our sense (see the Debian Free Software
252 Guidelines, below), or may be imported/exported without
253 restrictions. Thus, the archive is split into the sections
254 <em>main</em>, <em>non-free</em>, <em>contrib</em>,
255 <em>non-US/main</em>, <em>non-US/non-free</em>, and
256 <em>non-US/contrib</em>. The sections are explained in detail
261 The <em>main</em> and the <em>non-US/main</em> sections
262 together form the <em>Debian GNU/Linux distribution</em>.
266 Packages in the other sections are not considered to be part
267 of the Debian distribution, although we support their use and
268 provide infrastructure for them (such as our bug-tracking
269 system and mailing lists). This Debian Policy Manual applies
270 to these packages as well.</p>
272 <sect id="pkgcopyright">
273 <heading>Package copyright and sections</heading>
275 The aims of this section are:
277 <list compact="compact">
279 <p>to allow us to make as much software available as we
283 <p>to allow us to encourage everyone to write free
287 <p>to allow us to make it easy for people to produce
288 CD-ROMs of our system without violating any licenses,
289 import/export restrictions, or any other laws.</p>
294 <heading>The Debian Free Software Guidelines</heading>
296 The Debian Free Software Guidelines (DFSG) form our
297 definition of `free software'. These are:
299 <tag>Free Redistribution
303 The license of a Debian component may not restrict any
304 party from selling or giving away the software as a
305 component of an aggregate software distribution
306 containing programs from several different
307 sources. The license may not require a royalty or
308 other fee for such sale.
315 The program must include source code, and must allow
316 distribution in source code as well as compiled form.
323 The license must allow modifications and derived
324 works, and must allow them to be distributed under the
325 same terms as the license of the original software.
328 <tag>Integrity of The Author's Source Code
332 The license may restrict source-code from being
333 distributed in modified form <em>only</em> if the
334 license allows the distribution of ``patch files''
335 with the source code for the purpose of modifying the
336 program at build time. The license must explicitly
337 permit distribution of software built from modified
338 source code. The license may require derived works to
339 carry a different name or version number from the
340 original software. (This is a compromise. The Debian
341 Project encourages all authors to not restrict any
342 files, source or binary, from being modified.)
345 <tag>No Discrimination Against Persons or Groups
349 The license must not discriminate against any person
353 <tag>No Discrimination Against Fields of Endeavor
357 The license must not restrict anyone from making use
358 of the program in a specific field of endeavor. For
359 example, it may not restrict the program from being
360 used in a business, or from being used for genetic
364 <tag>Distribution of License
368 The rights attached to the program must apply to all
369 to whom the program is redistributed without the need
370 for execution of an additional license by those
374 <tag>License Must Not Be Specific to Debian
378 The rights attached to the program must not depend on
379 the program's being part of a Debian system. If the
380 program is extracted from Debian and used or
381 distributed without Debian but otherwise within the
382 terms of the program's license, all parties to whom
383 the program is redistributed must have the same
384 rights as those that are granted in conjunction with
388 <tag>License Must Not Contaminate Other Software
392 The license must not place restrictions on other
393 software that is distributed along with the licensed
394 software. For example, the license must not insist
395 that all other programs distributed on the same medium
396 must be free software.
399 <tag>Example Licenses
403 The ``GPL,'' ``BSD,'' and ``Artistic'' licenses are
404 examples of licenses that we consider <em>free</em>.
411 <heading>The main section</heading>
413 Every package in <em>main</em> and <em>non-US/main</em>
414 must comply with the DFSG (Debian Free Software
418 In addition, the packages in <em>main</em>
419 <list compact="compact">
422 must not require a package outside of <em>main</em>
423 for compilation or execution (thus, the package must
424 not declare a "Depends", "Recommends", or
425 "Build-Depends" relationship on a non-<em>main</em>
431 must not be so buggy that we refuse to support them,
437 must meet all policy requirements presented in this
444 Similarly, the packages in <em>non-US/main</em>
445 <list compact="compact">
448 must not require a package outside of <em>main</em>
449 or <em>non-US/main</em> for compilation or
455 must not be so buggy that we refuse to support them,
460 must meet all policy requirements presented in this
468 <heading>The contrib section</heading>
470 Every package in <em>contrib</em> and
471 <em>non-US/contrib</em> must comply with the DFSG.
475 In addition, the packages in <em>contrib</em> and
476 <em>non-US/contrib</em>
477 <list compact="compact">
480 must not be so buggy that we refuse to support them,
486 must meet all policy requirements presented in this
494 Furthermore, packages in <em>contrib</em> must not require
495 a package in a <em>non-US</em> section for compilation or
500 Examples of packages which would be included in
501 <em>contrib</em> or <em>non-US/contrib</em> are:
502 <list compact="compact">
505 free packages which require <em>contrib</em>,
506 <em>non-free</em> packages or packages which are not
507 in our archive at all for compilation or execution,
513 wrapper packages or other sorts of free accessories for
521 <heading>The non-free section</heading>
523 Packages must be placed in <em>non-free</em> or
524 <em>non-US/non-free</em> if they are not compliant with
525 the DFSG or are encumbered by patents or other legal
526 issues that make their distribution problematic.
529 In addition, the packages in <em>non-free</em> and
530 <em>non-US/non-free</em>
531 <list compact="compact">
534 must not be so buggy that we refuse to support them,
540 must meet all policy requirements presented in this
541 manual that it is possible for them to meet.
544 It is possible that there are policy
545 requirements which the package is unable to
546 meet, for example, if the source is
547 unavailable. These situations will need to be
548 handled on a case-by-case basis.
558 <heading>The non-US sections</heading>
560 Some programs with cryptographic program code need to be
561 stored on the <em>non-US</em> server because of United
562 States export restrictions. Such programs must be
563 distributed in the appropriate <em>non-US</em> section,
564 either <em>non-US/main</em>, <em>non-US/contrib</em> or
565 <em>non-US/non-free</em>.
568 This applies only to packages which contain cryptographic
569 code. A package containing a program with an interface to
570 a cryptographic program or a program that's dynamically
571 linked against a cryptographic library should not be
572 distributed via the <em>non-US</em> server if it is
573 capable of running without the cryptographic library or
578 <heading>Further copyright considerations</heading>
580 Every package must be accompanied by a verbatim copy of
581 its copyright and distribution license in the file
582 <tt>/usr/share/doc/<em><package></em>/copyright</tt>
583 (see <ref id="copyrightfile"> for further details).
586 We reserve the right to restrict files from being included
587 anywhere in our archives if
588 <list compact="compact">
591 their use or distribution would break a law,
596 there is an ethical conflict in their distribution or
602 we would have to sign a license for them, or
607 their distribution would conflict with other project
615 Programs whose authors encourage the user to make
616 donations are fine for the main distribution, provided
617 that the authors do not claim that not donating is
618 immoral, unethical, illegal or something similar; in such
619 a case they must go in <em>non-free</em>.</p>
622 Packages whose copyright permission notices (or patent
623 problems) do not even allow redistribution of binaries
624 only, and where no special permission has been obtained,
625 must not be placed on the Debian FTP site and its mirrors
629 Note that under international copyright law (this applies
630 in the United States, too), <em>no</em> distribution or
631 modification of a work is allowed without an explicit
632 notice saying so. Therefore a program without a copyright
633 notice <em>is</em> copyrighted and you may not do anything
634 to it without risking being sued! Likewise if a program
635 has a copyright notice but no statement saying what is
636 permitted then nothing is permitted.</p>
639 Many authors are unaware of the problems that restrictive
640 copyrights (or lack of copyright notices) can cause for
641 the users of their supposedly-free software. It is often
642 worthwhile contacting such authors diplomatically to ask
643 them to modify their license terms. However, this can be a
644 politically difficult thing to do and you should ask for
645 advice on the <tt>debian-legal</tt> mailing list first, as
650 When in doubt about a copyright, send mail to
651 <email>debian-legal@lists.debian.org</email>. Be prepared
652 to provide us with the copyright statement. Software
653 covered by the GPL, public domain software and BSD-like
654 copyrights are safe; be wary of the phrases `commercial
655 use prohibited' and `distribution restricted'.
659 <heading>Subsections</heading>
662 The packages in the sections <em>main</em>,
663 <em>contrib</em> and <em>non-free</em> are grouped further
664 into <em>subsections</em> to simplify handling.
668 The section and subsection for each package should be
669 specified in the package's <tt>Section</tt> control
670 record. However, the maintainer of the Debian archive
671 may override this selection to ensure the consistency of
672 the Debian distribution. The <tt>Section</tt> field
673 should be of the form:
674 <list compact="compact">
677 <em>subsection</em> if the package is in the
678 <em>main</em> section,
683 <em>section/subsection</em> if the package is in
684 the <em>contrib</em> or <em>non-free</em> section,
690 <tt>non-US</tt>, <tt>non-US/contrib</tt> or
691 <tt>non-US/non-free</tt> if the package is in
692 <em>non-US/main</em>, <em>non-US/contrib</em> or
693 <em>non-US/non-free</em> respectively.
700 The Debian archive maintainers provide the authoritative
701 list of subsections. At present, they are:
702 <em>admin</em>, <em>base</em>, <em>comm</em>,
703 <em>contrib</em>, <em>devel</em>, <em>doc</em>,
704 <em>editors</em>, <em>electronics</em>, <em>games</em>,
705 <em>graphics</em>, <em>hamradio</em>,
706 <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
707 <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
708 <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
709 <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
710 <em>sound</em>, <em>tex</em>, <em>text</em>,
711 <em>utils</em>, <em>web</em>, <em>x11</em>.
715 <heading>Priorities</heading>
718 Each package should have a <em>priority</em> value, which is
719 included in the package's <em>control record</em>. This
720 information is used by the Debian package management tools
721 to separate high-priority packages from less-important
725 The following <em>priority levels</em> are recognised by the
726 Debian package management tools.
728 <tag><tt>required</tt></tag>
731 Packages which are necessary for the proper
732 functioning of the system. You must not remove these
733 packages or your system may become totally broken and
734 you may not even be able to use <prgn>dpkg</prgn> to
735 put things back. Systems with only the
736 <tt>required</tt> packages are probably unusable, but
737 they do have enough functionality to allow the
738 sysadmin to boot and install more software.</p>
740 <tag><tt>important</tt></tag>
743 Important programs, including those which one would
744 expect to find on any Unix-like system. If the
745 expectation is that an experienced Unix person who
746 found it missing would say `What on earth is going on,
747 where is <prgn>foo</prgn>?', it must be an
748 <tt>important</tt> package.
751 This is an important criterion because we are
752 trying to produce, amongst other things, a free
756 Other packages without which the system will not run
757 well or be usable must also have priority
758 <tt>important</tt>. This does
759 <em>not</em> include Emacs, the X Window System, TeX
760 or any other large applications. The
761 <tt>important</tt> packages are just a bare minimum of
762 commonly-expected and necessary tools.</p>
764 <tag><tt>standard</tt></tag>
767 These packages provide a reasonably small but not too
768 limited character-mode system. This is what will be
769 installed by default if the user doesn't select anything
770 else. It doesn't include many large applications, but
771 it does include Emacs (this is more of a piece of
772 infrastructure than an application) and a reasonable
773 subset of TeX and LaTeX.</p>
775 <tag><tt>optional</tt></tag>
778 (In a sense everything that isn't required is
779 optional, but that's not what is meant here.) This is
780 all the software that you might reasonably want to
781 install if you didn't know what it was and don't have
782 specialized requirements. This is a much larger system
783 and includes the X Window System, a full TeX
784 distribution, and many applications. Note that
785 optional packages should not conflict with each other.
788 <tag><tt>extra</tt></tag>
791 This contains all packages that conflict with others
792 with required, important, standard or optional
793 priorities, or are only likely to be useful if you
794 already know what they are or have specialised
801 Packages must not depend on packages with lower priority
802 values (excluding build-time dependencies). In order to
803 ensure this, the priorities of one or more packages may need
809 <heading>Binary packages</heading>
812 The Debian GNU/Linux distribution is based on the Debian
813 package management system, called <prgn>dpkg</prgn>. Thus,
814 all packages in the Debian distribution must be provided
815 in the <tt>.deb</tt> file format.</p>
819 <heading>The package name</heading>
822 Every package must have a name that's unique within the Debian
826 Package names must consist of lower case letters
827 (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
828 and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
829 They must be at least two characters long and must contain
834 The package name is part of the file name of the
835 <tt>.deb</tt> file and is included in the control field
841 <heading>The maintainer of a package</heading>
843 Every package must have a Debian maintainer (the
844 maintainer may be one person or a group of people
845 reachable from a common email address, such as a mailing
846 list). The maintainer is responsible for ensuring that
847 the package is placed in the appropriate distributions.
851 The maintainer must be specified in the
852 <tt>Maintainer</tt> control field with their correct name
853 and a working email address. If one person maintains
854 several packages, he/she should try to avoid having
855 different forms of their name and email address in
856 the <tt>Maintainer</tt> fields of those packages.
860 If the maintainer of a package quits from the Debian
861 project, "Debian QA Group"
862 <email>packages@qa.debian.org</email> takes over the
863 maintainership of the package until someone else
864 volunteers for that task. These packages are called
865 <em>orphaned packages</em>.
868 The detailed procedure for doing this gracefully can
869 be found in the Debian Developer's Reference, either
870 in the <tt>developers-reference</tt> package, or on
871 the Debian FTP server
872 <ftpsite>ftp.debian.org</ftpsite> as
873 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
875 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
876 name="Debian Developer's Reference"> webpage.
884 <heading>The description of a package</heading>
887 Every Debian package must have an extended description
888 stored in the appropriate field of the control record.</p>
891 The description should be written so that it gives the
892 system administrator enough information to decide whether
893 to install the package. This description should not just
894 be copied verbatim from the program's documentation.
895 Instructions for configuring or using the package should
896 not be included (that is what installation scripts,
897 manual pages, info files, etc., are for). Copyright
898 statements and other administrivia should not be included
899 either (that is what the copyright file is for).
905 <heading>Dependencies</heading>
908 Every package must specify the dependency information
909 about other packages that are required for the first to
913 For example, a dependency entry must be provided for any
914 shared libraries required by a dynamically-linked executable
915 binary in a package.</p>
918 Packages are not required to declare any dependencies they
919 have on other packages which are marked <tt>Essential</tt>
920 (see below), and should not do so unless they depend on a
921 particular version of that package.</p>
924 Sometimes, a package requires another package to be installed
925 <em>and</em> configured before it can be installed. In this
926 case, you must specify a <tt>Pre-Depends</tt> entry for
930 You should not specify a <tt>Pre-Depends</tt> entry for a
931 package before this has been discussed on the
932 <tt>debian-devel</tt> mailing list and a consensus about
933 doing that has been reached.</p></sect1>
937 <heading>Virtual packages</heading>
940 Sometimes, there are several packages which offer
941 more-or-less the same functionality. In this case, it's
942 useful to define a <em>virtual package</em> whose name
943 describes that common functionality. (The virtual
944 packages only exist logically, not physically; that's why
945 they are called <em>virtual</em>.) The packages with this
946 particular function will then <em>provide</em> the virtual
947 package. Thus, any other package requiring that function
948 can simply depend on the virtual package without having to
949 specify all possible packages individually.</p>
952 All packages should use virtual package names where
953 appropriate, and arrange to create new ones if necessary.
954 They should not use virtual package names (except privately,
955 amongst a cooperating group of packages) unless they have
956 been agreed upon and appear in the list of virtual package
960 The latest version of the authoritative list of virtual
961 package names can be found on
962 <ftpsite>ftp.debian.org</ftpsite> in
963 <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
964 or your local mirror. In addition, it is included in the
965 <tt>debian-policy</tt> package. The procedure for updating
966 the list is described at the top of the file.</p></sect1>
970 <heading>Base packages</heading>
973 The packages included in the <tt>base</tt> section have a
974 special function. They form a minimum subset of the Debian
975 GNU/Linux system that is installed before everything else
976 on a new system. Thus, only very few packages are allowed
977 to go into the <tt>base</tt> section to keep the required
978 disk usage very small.</p>
981 Most of these packages will have the priority value
982 <tt>required</tt> or at least <tt>important</tt>, and many
983 of them will be tagged <tt>essential</tt> (see below).</p>
986 You must not place any packages into the <tt>base</tt>
987 section before this has been discussed on the
988 <tt>debian-devel</tt> mailing list and a consensus about
989 doing that has been reached.</p></sect1>
993 <heading>Essential packages</heading>
996 Some packages are tagged <tt>essential</tt>. (They have
997 <tt>Essential: yes</tt> in their package control record.)
998 This flag is used for packages that are <em>essential</em>
1002 Since these packages cannot be easily removed (one has to
1003 specify an extra <em>force option</em> to
1004 <prgn>dpkg</prgn> to do so), this flag must not be used
1005 unless absolutely necessary. A shared library package
1006 must not be tagged <tt>essential</tt>; dependencies will
1007 prevent its premature removal, and we need to be able to
1008 remove it when it has been superseded.
1012 Since dpkg will not prevent upgrading of other packages
1013 while an <tt>essential</tt> package is in an unconfigured
1014 state, all <tt>essential</tt> packages must supply all of
1015 their core functionality even when unconfigured. If the
1016 package cannot satisfy this requirement it must not be
1017 tagged as essential, and any packages depending on this
1018 package must instead have explicit dependency fields as
1023 You must not tag any packages <tt>essential</tt> before
1024 this has been discussed on the <tt>debian-devel</tt>
1025 mailing list and a consensus about doing that has been
1031 <heading>Maintainer scripts</heading>
1034 The package installation scripts should avoid producing
1035 output which it is unnecessary for the user to see and
1036 should rely on <prgn>dpkg</prgn> to stave off boredom on
1037 the part of a user installing many packages. This means,
1038 amongst other things, using the <tt>--quiet</tt> option on
1039 <prgn>install-info</prgn>.</p>
1042 Errors which occur during the execution of an installation
1043 script must be checked and the installation must not
1044 continue after an error.
1048 Note that in general <ref id="scripts"> applies to package
1049 maintainer scripts, too.
1053 You should not use <tt>dpkg-divert</tt> on a file
1054 belonging to another package without consulting the
1055 maintainer of that package first.
1058 All packages which supply an instance of a common command
1059 name (or, in general, filename) should generally use
1060 <prgn>update-alternatives</prgn>, so that they may be
1061 installed together. If <prgn>update-alternatives</prgn>
1062 is not used, then each package must use
1063 <var>Conflicts</var> to ensure that other packages are
1064 de-installed. (In this case, it may be appropriate to
1065 specify a conflict against earlier versions of something
1066 that previously did not use
1067 <prgn>update-alternatives</prgn>; this is an exception to
1068 the usual rule that versioned conflicts should be
1074 <heading>Prompting in maintainer scripts</heading>
1076 Package maintainer scripts may prompt the user if
1077 necessary. Prompting may be accomplished by hand, or by
1078 communicating with a program, such as
1079 <prgn>debconf</prgn>, which conforms to the Debian
1080 Configuration management specification, version 2 or
1081 higher. These are included in the
1082 <file>debconf_specification</file> files in the
1083 <package>debian-policy</package> package.
1084 You may also find this file on the FTP site
1085 <ftpsite>ftp.debian.org</ftpsite> in
1086 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1087 or on your local mirror.
1090 2.5% of Debian packages [see <url
1091 id="http://kitenet.net/programs/debconf/stats/">]
1092 currently use <package>debconf</package> to prompt
1093 the user at install time, and this number is growing
1094 daily. The benefits of using debconf are briefly
1096 id="http://kitenet.net/doc/debconf-doc/introduction.html">;
1097 they include preconfiguration, (mostly)
1098 noninteractive installation, elimination of
1099 redundant prompting, consistency of user interface,
1103 With this increasing number of packages using
1104 <package>debconf</package>, plus the existance of a
1105 nascent second implementation of the Debian
1106 configuration management system
1107 (<package>cdebconf</package>), and the stabalization
1108 of the protocol these things use, the time has
1109 finally come to reflect the use of these things in
1116 Packages which use the Debian Configuration management
1117 specification may contain an additional
1118 <file>config</file> script and a <file>templates</file>
1119 file in their control archive. The <prgn>config</prgn>
1120 script might be run before the <prgn>preinst</prgn>
1121 script, and before the package is unpacked or any of its
1122 dependancies or pre-dependancies are satisfied.
1123 Therefore it must work using only the tools present in
1124 <em>essential</em> packages.
1127 <package>Debconf</package> or another tool that
1128 implements the Debian Configuration management
1129 specification will also be installed, and any
1130 versioned dependencies on it will be satisfied
1131 before preconfiguration begins.
1137 Packages should try to minimize the amount of prompting
1138 they need to do, and they should ensure that the user
1139 will only ever be asked each question once. This means
1140 that packages should try to use appropriate shared
1141 configuration files (such as <tt>/etc/papersize</tt> and
1142 <tt>/etc/news/server</tt>), and shared
1143 <package>debconf</package> variables rather than each
1144 prompting for their own list of required pieces of
1149 It also means that an upgrade should not ask the same
1150 questions again, unless the user has used <tt>dpkg
1151 --purge</tt> to remove the package's configuration. The
1152 answers to configuration questions should be stored in an
1153 appropriate place in <tt>/etc</tt> so that the user can
1154 modify them, and how this has been done should be
1158 If a package has a vitally important piece of
1159 information to pass to the user (such as "don't run me
1160 as I am, you must edit the following configuration files
1161 first or you risk your system emitting badly-formatted
1162 messages"), it should display this in the
1163 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1164 prompt the user to hit return to acknowledge the
1165 message. Copyright messages do not count as vitally
1166 important (they belong in
1167 <tt>/usr/share/doc/<var>package</var>/copyright</tt>);
1168 neither do instructions on how to use a program (these
1169 should be in on-line documentation, where all the users
1173 Any necessary prompting should almost always be confined
1174 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1175 script. If it is done in the <prgn>postinst</prgn>, it
1176 should be protected with a conditional so that unnecessary
1177 prompting doesn't happen if a package's installation fails
1178 and the <prgn>postinst</prgn> is called with
1179 <tt>abort-upgrade</tt>, <tt>abort-remove</tt> or
1180 <tt>abort-deconfigure</tt>.</p>
1185 <heading>Source packages</heading>
1187 <sect1 id="standardsversion">
1188 <heading>Standards conformance</heading>
1191 In the source package's <tt>Standards-Version</tt> control
1192 field, you must specify the most recent version number of
1193 this policy document with which your package complies.
1194 The current version number is &version;.
1198 This information may be used to file bug reports
1199 automatically if your package becomes too much out of
1204 The version number has four components: major and minor
1205 version number and major and minor patch level. When the
1206 standards change in a way that requires every package to
1207 change the major number will be changed. Significant
1208 changes that will require work in many packages will be
1209 signaled by a change to the minor number. The major patch
1210 level will be changed for any change to the meaning of the
1211 standards, however small; the minor patch level will be
1212 changed when only cosmetic, typographical or other edits
1213 are made which neither change the meaning of the document
1214 nor affect the contents of packages.</p>
1217 Thus only the first three components of the policy version
1218 are significant in the <em>Standards-Version</em> control
1219 field, and so either these three components or the all
1220 four components may be specified.
1223 In the past, people specified the full version number
1224 in the Standards-Version field, for example `2.3.0.0'.
1225 Since minor patch-level changes don't introduce new
1226 policy, it was thought it would be better to relax
1227 policy and only require the first 3 components to be
1228 specified, in this example `2.3.0'. All four
1229 components may still be used if someone wishes to do
1236 You should regularly, and especially if your package has
1237 become out of date, check for the newest Policy Manual
1238 available and update your package, if necessary. When your
1239 package complies with the new standards you should update the
1240 <tt>Standards-Version</tt> source package field and
1244 See the file <tt>upgrading-checklist</tt> for
1245 information about policy which has changed between
1246 different versions of this document.
1254 <heading>Package relationships</heading>
1257 Source packages should specify which binary packages they
1258 require to be installed or not to be installed in order to
1259 build correctly. For example, if building a package
1260 requires a certain compiler, then the compiler should be
1261 specified as a build-time dependency.
1265 It is not necessary to explicitly specify build-time
1266 relationships on a minimal set of packages that are always
1267 needed to compile, link and put in a Debian package a
1268 standard "Hello World!" program written in C or C++. The
1269 required packages are called <em>build-essential</em>, and
1270 an informational list can be found in
1271 <tt>/usr/share/doc/build-essential/list</tt> (which is
1272 contained in the <tt>build-essential</tt>
1276 <list compact="compact">
1278 <p>This allows maintaining the list separately
1279 from the policy documents (the list does not
1280 need the kind of control that the policy
1286 Having a separate package allows one to install
1287 the build-essential packages on a machine, as
1288 well as allowing other packages such as task
1289 packages to require installation of the
1290 build-essential packages using the depends
1296 The separate package allows bug reports against
1297 the list to be categorized separately from
1298 the policy management process in the BTS.
1308 When specifying the set of build-time dependencies, one
1309 should list only those packages explicitly required by the
1310 build. It is not necessary to list packages which are
1311 required merely because some other package in the list of
1312 build-time dependencies depends on them.
1315 The reason for this is that dependencies change, and
1316 you should list all those packages, and <em>only</em>
1317 those packages that <em>you</em> need directly. What
1318 others need is their business. For example, if you
1319 only link against <tt>libimlib</tt>, you will need to
1320 build-depend on <package>libimlib2-dev</package> but
1321 not against any <tt>libjpeg*</tt> packages, even
1322 though <tt>libimlib2-dev</tt> currently depends on
1323 them: installation of <package>libimlib2-dev</package>
1324 will automatically ensure that all of its run-time
1325 dependencies are satisfied.
1331 If build-time dependencies are specified, it must be
1332 possible to build the package and produce working binaries
1333 on a system with only essential and build-essential
1334 packages installed and also those required to satisfy the
1335 build-time relationships (including any implied
1336 relationships). In particular, this means that version
1337 clauses should be used rigorously in build-time
1338 relationships so that one cannot produce bad or
1339 inconsistently configured packages when the relationships
1340 are properly satisfied.
1344 <heading>Changes to the upstream sources</heading>
1347 If changes to the source code are made that are not
1348 specific to the needs of the Debian system, they should be
1349 sent to the upstream authors in whatever form they prefer
1350 so as to be included in the upstream version of the
1354 If you need to configure the package differently for
1355 Debian or for Linux, and the upstream source doesn't
1356 provide a way to do so, you should add such configuration
1357 facilities (for example, a new <prgn>autoconf</prgn> test
1358 or <tt>#define</tt>) and send the patch to the upstream
1359 authors, with the default set to the way they originally
1360 had it. You can then easily override the default in your
1361 <tt>debian/rules</tt> or wherever is appropriate.</p>
1364 You should make sure that the <prgn>configure</prgn> utility
1365 detects the correct architecture specification string
1366 (refer to <ref id="arch-spec"> for details).</p>
1369 If you need to edit a <prgn>Makefile</prgn> where
1370 GNU-style <prgn>configure</prgn> scripts are used, you
1371 should edit the <tt>.in</tt> files rather than editing the
1372 <prgn>Makefile</prgn> directly. This allows the user to
1373 reconfigure the package if necessary. You should
1374 <em>not</em> configure the package and edit the generated
1375 <prgn>Makefile</prgn>! This makes it impossible for
1376 someone else to later reconfigure the package.</p></sect1>
1380 <heading>Documenting your changes</heading>
1383 You should document your changes and updates to the source
1384 package properly in the <tt>debian/changelog</tt> file. (Note
1385 that mistakes in changelogs are usually best rectified by
1386 making a new changelog entry rather than "rewriting history"
1387 by editing old changelog entries.)</p>
1390 In non-experimental packages you must use a format for
1391 <tt>debian/changelog</tt> which is supported by the most
1392 recent released version of <prgn>dpkg</prgn>.
1395 If you wish to use an alternative format, you may do
1396 so as long as you include a parser for it in your
1397 source package. The parser must have an API
1398 compatible with that expected by
1399 <prgn>dpkg-genchanges</prgn> and
1400 <prgn>dpkg-gencontrol</prgn>. If there is general
1401 interest in the new format, you should contact the
1402 <package>dpkg</package> maintainer to have the parser
1403 script for it included in the <prgn>dpkg</prgn>
1404 package. (You will need to agree that the parser and
1405 its manpage may be distributed under the GNU GPL, just
1406 as the rest of `dpkg' is.)
1414 <heading>Error trapping in makefiles</heading>
1417 When <prgn>make</prgn> invokes a command in a makefile
1418 (including your package's upstream makefiles and
1419 <tt>debian/rules</tt>), it does so using <tt>sh</tt>. This
1420 means that <tt>sh</tt>'s usual bad error handling
1421 properties apply: if you include a miniature script as one
1422 of the commands in your makefile you'll find that if you
1423 don't do anything about it then errors are not detected
1424 and <prgn>make</prgn> will blithely continue after
1428 Every time you put more than one shell command (this
1429 includes using a loop) in a makefile command you
1430 must make sure that errors are trapped. For
1431 simple compound commands, such as changing directory and
1432 then running a program, using <tt>&&</tt> rather
1433 than semicolon as a command separator is sufficient. For
1434 more complex commands including most loops and
1435 conditionals you should include a separate <tt>set -e</tt>
1436 command at the start of every makefile command that's
1437 actually one of these miniature shell scripts.</p></sect1>
1441 <heading>Obsolete constructs and libraries</heading>
1444 The include file <prgn><varargs.h></prgn> is
1445 provided to support end-users compiling very old software;
1446 the library <tt>libtermcap</tt> is provided to support the
1447 execution of software which has been linked against it
1448 (either old programs or those such as Netscape which are
1449 only available in binary form).</p>
1452 Debian packages should be patched to use
1453 <prgn><stdarg.h></prgn> and <tt>ncurses</tt>
1460 <chapt id="controlfields"><heading>Control files and their fields</heading>
1463 Many of the tools in the package management suite manipulate
1464 data represented in a common format, known as <em>control
1465 data</em>. The data is often stored in <em>control
1466 files</em>. Binary and source packages have control files,
1467 and the <tt>.changes</tt> files which control the installation
1468 of uploaded files are also in control file format.
1469 <prgn>Dpkg</prgn>'s internal databases are in a similar
1473 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1476 A control file consists of one or more paragraphs of fields.
1477 The paragraphs are separated by blank lines. Some control
1478 files allow only one paragraph; others allow several, in
1479 which case each paragraph usually refers to a different
1480 package. (For example, in source packages, the first
1481 paragraph refers to the source package, and later paragraphs
1482 refer to binary packages generated from the source.)
1486 Each paragraph consists of a series of data fields; each
1487 field consists of the field name, followed by a colon and
1488 then the data/value associated with that field. It ends at
1489 the end of the line. Horizontal whitespace (spaces and
1490 tabs) may occur immediately before or after the value and is
1491 ignored there; it is conventional to put a single space
1492 after the colon. For example, a field might be:
1493 <example compact="compact">
1496 the field name is <tt>Package</tt> and the field value
1501 Some fields' values may span several lines; in this case
1502 each continuation line <em>must</em> start with a space or
1503 tab. Any trailing spaces or tabs at the end of individual
1504 lines of a field value are ignored.
1508 Except where otherwise stated only a single line of data is
1509 allowed and whitespace is not significant in a field body.
1510 Whitespace must not appear inside names (of packages,
1511 architectures, files or anything else) or version numbers,
1512 or between the characters of multi-character version
1517 Field names are not case-sensitive, but it is usual to
1518 capitalize the field names using mixed case as shown below.
1522 Blank lines, or lines consisting only of spaces and tabs,
1523 are not allowed within field values or between fields - that
1524 would mean a new paragraph.
1529 <sect><heading>List of fields</heading>
1531 This list here is not supposed to be exhaustive. Most fields
1532 are dealt with elsewhere in this document.
1534 <sect1 id="f-Package"><heading><tt>Package</tt>
1538 The name of the binary package. Package names consist of
1539 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
1540 (plus, minus and full stop).
1544 They must be at least two characters long and must start
1545 with an alphanumeric character and not be all digits. The
1546 use of lowercase package names is strongly recommended
1547 unless the package you're building (or referring to, in
1548 other fields) is already using uppercase.</p>
1551 <sect1 id="f-Version"><heading><tt>Version</tt>
1555 This lists the source or binary package's version number -
1556 see <ref id="versions">.
1562 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1566 The most recent version of the standards (the policy
1567 manual and associated texts) with which the package
1568 complies. This is updated manually when editing the
1569 source package to conform to newer standards; it can
1570 sometimes be used to tell when a package needs attention.
1571 Its format is described above; see
1572 <ref id="standardsversion">.
1577 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1581 In a <tt>.changes</tt> file or parsed changelog output
1582 this contains the (space-separated) name(s) of the
1583 distribution(s) where this version of the package should
1584 be installed. Valid distributions are determined by the
1585 archive maintainers.
1587 Current distribution names are:
1588 <taglist compact="compact">
1589 <tag><em>stable</em></tag>
1592 This is the current `released' version of Debian
1593 GNU/Linux. Once the distribution is
1594 <em>stable</em> only security fixes and other
1595 major bug fixes are allowed. When changes are
1596 made to this distribution, the release number is
1597 increased (for example: 2.2r1 becomes 2.2r2 then
1602 <tag><em>unstable</em></tag>
1605 This distribution value refers to the
1606 <em>developmental</em> part of the Debian
1607 distribution tree. New packages, new upstream
1608 versions of packages and bug fixes go into the
1609 <em>unstable</em> directory tree. Download from
1610 this distribution at your own risk.
1614 <tag><em>testing</em></tag>
1617 This distribution value refers to the
1618 <em>testing</em> part of the Debian distribution
1619 tree. It receives its packages from the
1620 unstable distribution after a short time lag to
1621 ensure that there are no major issues with the
1622 unstable packages. It is less prone to breakage
1623 than unstable, but still risky. It is not
1624 possible to upload packages directly to
1629 <tag><em>frozen</em></tag>
1632 From time to time, the <em>frozen</em>
1633 distribution enters a state of `code-freeze' in
1634 anticipation of release as a <em>stable</em>
1635 version. During this period of testing only
1636 fixes for existing or newly-discovered bugs will
1637 be allowed. The exact details of this stage are
1638 determined by the Release Manager.
1642 <tag><em>experimental</em></tag>
1645 The packages with this distribution value are
1646 deemed by their maintainers to be high
1647 risk. Oftentimes they represent early beta or
1648 developmental packages from various sources that
1649 the maintainers want people to try, but are not
1650 ready to be a part of the other parts of the
1651 Debian distribution tree. Download at your own
1657 You should list <em>all</em> distributions that the
1658 package should be installed into.
1667 <chapt id="versions"><heading>Version numbering</heading>
1670 Every package has a version number recorded in its
1671 <tt>Version</tt> control file field.
1675 The package management system imposes an ordering on version
1676 numbers, so that it can tell whether packages are being up- or
1677 downgraded and so that package system front end applications
1678 can tell whether a package it finds available is newer than
1679 the one installed on the system. The version number format
1680 has the most significant parts (as far as comparison is
1681 concerned) at the beginning.
1685 The version number format is:
1686 <example compact="compact">
1687 &lsqb<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1692 The three components here are:
1694 <tag><var>epoch</var></tag>
1698 This is a single (generally small) unsigned integer. It
1699 may be omitted, in which case zero is assumed. If it is
1700 omitted then the <var>upstream_version</var> may not
1705 It is provided to allow mistakes in the version numbers
1706 of older versions of a package, and also a package's
1707 previous version numbering schemes, to be left behind.
1712 <tag><var>upstream_version</var></tag>
1716 This is the main part of the version number. It is
1717 usually the version number of the original (`upstream')
1718 package from which the <tt>.deb</tt> file has been made,
1719 if this is applicable. Usually this will be in the same
1720 format as that specified by the upstream author(s);
1721 however, it may need to be reformatted to fit into the
1722 package management system's format and comparison
1727 The comparison behavior of the package management system
1728 with respect to the <var>upstream_version</var> is
1729 described below. The <var>upstream_version</var>
1730 portion of the version number is mandatory.
1734 The <var>upstream_version</var> may contain only
1737 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1739 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1740 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1741 start with a digit. If there is no
1742 <var>debian_revision</var> then hyphens are not allowed;
1743 if there is no <var>epoch</var> then colons are not
1747 <tag><var>debian_revision</var></tag>
1751 This part of the version number specifies the version of
1752 the Debian package based on the upstream version. It
1753 may contain only alphanumerics and the characters
1754 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1755 compared in the same way as the
1756 <var>upstream_version</var> is.
1760 It is optional; if it isn't present then the
1761 <var>upstream_version</var> may not contain a hyphen.
1762 This format represents the case where a piece of
1763 software was written specifically to be turned into a
1764 Debian package, and so there is only one `debianization'
1765 of it and therefore no revision indication is required.
1769 It is conventional to restart the
1770 <var>debian_revision</var> at <tt>1</tt> each time the
1771 <var>upstream_version</var> is increased.
1775 The package management system will break the version
1776 number apart at the last hyphen in the string (if there
1777 is one) to determine the <var>upstream_version</var> and
1778 <var>debian_revision</var>. The absence of a
1779 <var>debian_revision</var> compares earlier than the
1780 presence of one (but note that the
1781 <var>debian_revision</var> is the least significant part
1782 of the version number).
1789 The <var>upstream_version</var> and <var>debian_revision</var>
1790 parts are compared by the package management system using the
1795 The strings are compared from left to right.
1799 First the initial part of each string consisting entirely of
1800 non-digit characters is determined. These two parts (one of
1801 which may be empty) are compared lexically. If a difference
1802 is found it is returned. The lexical comparison is a
1803 comparison of ASCII values modified so that all the letters
1804 sort earlier than all the non-letters.
1808 Then the initial part of the remainder of each string which
1809 consists entirely of digit characters is determined. The
1810 numerical values of these two parts are compared, and any
1811 difference found is returned as the result of the comparison.
1812 For these purposes an empty string (which can only occur at
1813 the end of one or both version strings being compared) counts
1818 These two steps (comparing and removing initial non-digit
1819 strings and initial digit strings) are repeated until a
1820 difference is found or both strings are exhausted.
1824 Note that the purpose of epochs is to allow us to leave behind
1825 mistakes in version numbering, and to cope with situations
1826 where the version numbering scheme changes. It is
1827 <em>not</em> intended to cope with version numbers containing
1828 strings of letters which the package management system cannot
1829 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1830 silly orderings (the author of this manual has heard of a
1831 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1832 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1833 <tt>2</tt> and so forth).
1837 If an upstream package has problematic version numbers they
1838 should be converted to a sane form for use in the
1839 <tt>Version</tt> field.
1843 <heading>Version numbers based on dates</heading>
1845 In general, Debian packages should use the same version
1846 numbers as the upstream sources.</p>
1849 However, in some cases where the upstream version number is
1850 based on a date (e.g., a development `snapshot' release) the
1851 package management system cannot handle these version
1852 numbers without epochs. For example, dpkg will consider
1853 `96May01' to be greater than `96Dec24'.</p>
1856 To prevent having to use epochs for every new upstream
1857 version, the version number should be changed to the
1858 following format in such cases: `19960501', `19961224'. It
1859 is up to the maintainer whether he/she wants to bother the
1860 upstream maintainer to change the version numbers upstream,
1864 Note that other version formats based on dates which are
1865 parsed correctly by the package management system should
1866 <em>not</em> be changed.</p>
1869 Native Debian packages (i.e., packages which have been
1870 written especially for Debian) whose version numbers include
1871 dates should always use the `YYYYMMDD' format.</p>
1875 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1877 <sect id="timestamps"><heading>Time Stamps</heading>
1879 Maintainers should preserve the modification times of the
1880 upstream source files in a package, as far as is reasonably
1884 The rationale is that there is some information conveyed
1885 by knowing the age of the file, for example, you could
1886 recognize that some documentation is very old by looking
1887 at the modification time, so it would be nice if the
1888 modification time of the upstream source would be
1895 <sect id="debianrules"><heading><tt>debian/rules</tt> - the
1896 main building script</heading>
1899 This file must be an executable makefile, and contains the
1900 package-specific recipes for compiling the package and
1901 building binary package(s) from the source.
1905 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1906 so that it can be invoked by saying its name rather than
1907 invoking <prgn>make</prgn> explicitly.
1911 Since an interactive <tt>debian/rules</tt> script makes it
1912 impossible to auto-compile that package and also makes it
1913 hard for other people to reproduce the same binary
1914 package, all <em>required targets</em> MUST be
1915 non-interactive. At a minimum, required targets are the
1916 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1917 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1918 <em>binary-indep</em>, and <em>build</em>. It also follows
1919 that any target that these targets depend on must also be
1924 The required and optional targets are as follows:
1926 <tag><tt>build</tt></tag>
1929 This should perform all non-interactive configuration
1930 and compilation of the package. If a package has an
1931 interactive pre-build configuration routine, the
1932 Debianized source package must either be built after
1933 this has taken place (so that the binary package can
1934 be built without rerunning the configuration) or the
1935 configuration routine modified to become
1936 non-interactive. (The latter is preferable if there
1937 are architecture-specific features detected by the
1938 configuration routine.)
1942 For some packages, notably ones where the same
1943 source tree is compiled in different ways to produce
1944 two binary packages, the <prgn>build</prgn> target
1945 does not make much sense. For these packages it is
1946 good enough to provide two (or more) targets
1947 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1948 for each of the ways of building the package, and a
1949 <prgn>build</prgn> target that does nothing. The
1950 <prgn>binary</prgn> target will have to build the
1951 package in each of the possible ways and make the
1952 binary package out of each.
1956 The <prgn>build</prgn> target must not do anything
1957 that might require root privilege.
1961 The <prgn>build</prgn> target may need to run the
1962 <prgn>clean</prgn> target first - see below.
1966 When a package has a configuration and build routine
1967 which takes a long time, or when the makefiles are
1968 poorly designed, or when <prgn>build</prgn> needs to
1969 run <prgn>clean</prgn> first, it is a good idea to
1970 <tt>touch build</tt> when the build process is
1971 complete. This will ensure that if <tt>debian/rules
1972 build</tt> is run again it will not rebuild the whole
1976 Another common way to do this is for <prgn>build</prgn>
1977 to depend on <prgn>build-stamp</prgn> and to do
1978 nothing else, and for the <prgn>build-stamp</prgn>
1979 target to do the building and to <tt>touch
1980 build-stamp</tt> on completion. This is
1981 especially useful if the build routine creates a
1982 file or directory called <tt>build</tt>; in such a
1983 case, <prgn>build</prgn> will need to be listed as
1984 a phony target (i.e., as a dependency of the
1985 <tt>.PHONY</tt> target). See the documentation of
1986 <prgn>make</prgn> for more information on phony
1993 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1994 <tt>binary-indep</tt>
1998 The <prgn>binary</prgn> target must be all that is
1999 necessary for the user to build the binary package(s)
2000 produced from this source package. All of these
2001 targets are required to be non-interactive. It is
2002 split into two parts: <prgn>binary-arch</prgn> builds
2003 the binary packages which are specific to a particular
2004 architecture, and <prgn>binary-indep</prgn> builds
2005 those which are not.
2009 <prgn>binary</prgn> may be (and commonly is) a target
2010 with no commands which simply depends on
2011 <prgn>binary-arch</prgn> and
2012 <prgn>binary-indep</prgn>.
2016 Each <prgn>binary-*</prgn> target should depend on
2017 the <prgn>build</prgn> target, above, so that the
2018 package is built if it has not been already. It
2019 should then create the relevant binary package(s),
2020 using <prgn>dpkg-gencontrol</prgn> to make their
2021 control files and <prgn>dpkg-deb</prgn> to build
2022 them and place them in the parent of the top level
2027 Both the <prgn>binary-arch</prgn> and
2028 <prgn>binary-indep</prgn> targets <em>must</em> exist.
2029 If one of them has nothing to do (which will always be
2030 the case if the source generates only a single binary
2031 package, whether architecture-dependent or not), it
2032 must still exist and must always succeed.
2036 The <prgn>binary</prgn> targets must be invoked as
2040 The <prgn>fakeroot</prgn> package often allows one
2041 to build a package correctly even without being
2048 <tag><tt>clean</tt></tag>
2052 This must undo any effects that the <prgn>build</prgn>
2053 and <prgn>binary</prgn> targets may have had, except
2054 that it should leave alone any output files created in
2055 the parent directory by a run of a <prgn>binary</prgn>
2056 target. This target must be non-interactive.
2060 If a <prgn>build</prgn> file is touched at the end of
2061 the <prgn>build</prgn> target, as suggested above, it
2062 should be removed as the first action that
2063 <prgn>clean</prgn> performs, so that running
2064 <prgn>build</prgn> again after an interrupted
2065 <prgn>clean</prgn> doesn't think that everything is
2070 The <prgn>clean</prgn> target may need to be
2071 invoked as root if <prgn>binary</prgn> has been
2072 invoked since the last <prgn>clean</prgn>, or if
2073 <prgn>build</prgn> has been invoked as root (since
2074 <prgn>build</prgn> may create directories, for
2079 <tag><tt>get-orig-source</tt> (optional)</tag>
2083 This target fetches the most recent version of the
2084 original source package from a canonical archive site
2085 (via FTP or WWW, for example), does any necessary
2086 rearrangement to turn it into the original source
2087 tar file format described below, and leaves it in the
2092 This target may be invoked in any directory, and
2093 should take care to clean up any temporary files it
2098 This target is optional, but providing it if
2099 possible is a good idea.
2105 The <prgn>build</prgn>, <prgn>binary</prgn> and
2106 <prgn>clean</prgn> targets must be invoked with the current
2107 directory being the package's top-level directory.
2112 Additional targets may exist in <tt>debian/rules</tt>,
2113 either as published or undocumented interfaces or for the
2114 package's internal use.
2118 The architectures we build on and build for are determined
2119 by <prgn>make</prgn> variables using the utility
2120 <prgn>dpkg-architecture</prgn>. You can determine the
2121 Debian architecture and the GNU style architecture
2122 specification string for the build machine (the machine type
2123 we are building on) as well as for the host machine (the
2124 machine type we are building for). Here is a list of
2125 supported <prgn>make</prgn> variables:
2126 <list compact="compact">
2128 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2131 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2132 specification string)</p>
2135 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2136 <tt>DEB_*_GNU_TYPE</tt>)</p>
2139 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2140 <tt>DEB_*_GNU_TYPE</tt>)</p>
2142 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2143 the build machine or <tt>HOST</tt> for specification of the
2148 Backward compatibility can be provided in the rules file
2149 by setting the needed variables to suitable default
2150 values; please refer to the documentation of
2151 <prgn>dpkg-architecture</prgn> for details.
2155 It is important to understand that the <tt>DEB_*_ARCH</tt>
2156 string only determines which Debian architecture we are
2157 building on or for. It should not be used to get the CPU
2158 or system information; the GNU style variables should be
2163 <sect id="dpkgchangelog"><heading><tt>debian/changelog</tt>
2167 This file records the changes to the Debian-specific parts of the
2171 Though there is nothing stopping an author who is also
2172 the Debian maintainer from using it for all their
2173 changes, it will have to be renamed if the Debian and
2174 upstream maintainers become different people. In such a
2175 case, however, it might be better to maintain the
2176 package as a non-native package.
2182 It has a special format which allows the package building
2183 tools to discover which version of the package is being
2184 built and find out other release-specific information.
2188 That format is a series of entries like this:
2189 <example compact="compact">
2190 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2192 * <var>change details</var>
2193 <var>more change details</var>
2194 * <var>even more change details</var>
2196 -- <var>maintainer name</var> <<var>email address</var>> <var>date</var>
2201 <var>package</var> and <var>version</var> are the source
2202 package name and version number.
2206 <var>distribution(s)</var> lists the distributions where
2207 this version should be installed when it is uploaded - it
2208 is copied to the <tt>Distribution</tt> field in the
2209 <tt>.changes</tt> file. See <ref id="f-Distribution">.
2213 <var>urgency</var> is the value for the <tt>Urgency</tt>
2214 field in the <tt>.changes</tt> file for the upload. It is
2215 not possible to specify an urgency containing commas; commas
2216 are used to separate
2217 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2218 <prgn>dpkg</prgn> changelog format (though there is
2219 currently only one useful <var>keyword</var>,
2223 Usual urgency values are <tt>low</tt>, <tt>medium</tt>,
2224 <tt>high</tt> and <tt>critical</tt>. They have an
2225 effect on how quickly a package will be considered for
2226 inclusion into the <tt>testing</tt> distribution, and
2227 give an indication of the importance of any fixes
2228 included in this upload.
2234 The change details may in fact be any series of lines
2235 starting with at least two spaces, but conventionally each
2236 change starts with an asterisk and a separating space and
2237 continuation lines are indented so as to bring them in
2238 line with the start of the text above. Blank lines may be
2239 used here to separate groups of changes, if desired.
2243 If this upload resolves bugs recorded in the Bug Tracking
2244 System (BTS), they may be automatically closed on the
2245 inclusion of this package into the Debian archive by
2246 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2247 in the change details.
2250 To be precise, the string should match the following
2251 Perl regular expression:
2253 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2255 Then all of the bug numbers listed will be closed by the
2256 archive maintenance script (<prgn>katie</prgn>), or in
2257 the case of an NMU, marked as fixed.
2263 The maintainer name and email address used in the changelog
2264 should be the details of the person uploading <em>this</em>
2265 version. They are <em>not</em> necessarily those of the
2266 usual package maintainer. The information here will be
2267 copied to the <tt>Changed-By</tt> field in the
2268 <tt>.changes</tt> file, and then later used to send an
2269 acknowledgement when the upload has been installed.
2273 The <var>date</var> should be in RFC822 format
2276 This is generated by the <prgn>822-date</prgn>
2279 </footnote>; it should include the time zone specified
2280 numerically, with the time zone name or abbreviation
2281 optionally present as a comment in parentheses.
2285 The first `title' line with the package name should start
2286 at the left hand margin; the `trailer' line with the
2287 maintainer and date details should be preceded by exactly
2288 one space. The maintainer details and the date must be
2289 separated by exactly two spaces.
2292 <sect1><heading>Defining alternative changelog formats</heading>
2295 It is possible to use a different format to the standard
2296 one, by providing a parser for the format you wish to
2300 A changelog parser must not interact with the user at
2306 <sect id="srcsubstvars"><heading><tt>debian/substvars</tt>
2307 and variable substitutions </heading>
2310 When <prgn>dpkg-gencontrol</prgn>,
2311 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2312 generate control files they perform variable substitutions
2313 on their output just before writing it. Variable
2314 substitutions have the form
2315 <tt>${<var>variable-name</var>}</tt>. The optional file
2316 <tt>debian/substvars</tt> contains variable substitutions to
2317 be used; variables can also be set directly from
2318 <tt>debian/rules</tt> using the <tt>-V</tt> option to the
2319 source packaging commands, and certain predefined variables
2324 The <tt>debian/substvars</tt> file is usually generated and
2325 modified dynamically by <tt>debian/rules</tt> targets; in
2326 this case it must be removed by the <prgn>clean</prgn>
2331 See <manref name="dpkg-source" section="1"> for full
2332 details about source variable substitutions, including the
2333 format of <tt>debian/substvars</tt>.</p>
2336 <sect id="debianfiles"><heading><tt>debian/files</tt>
2340 This file is not a permanent part of the source tree; it
2341 is used while building packages to record which files are
2342 being generated. <prgn>dpkg-genchanges</prgn> uses it
2343 when it generates a <tt>.changes</tt> file.
2347 It should not exist in a shipped source package, and so it
2348 (and any backup files or temporary files such as
2352 <tt>files.new</tt> is used as a temporary file by
2353 <prgn>dpkg-gencontrol</prgn> and
2354 <prgn>dpkg-distaddfile</prgn> - they write a new
2355 version of <tt>files</tt> here before renaming it,
2356 to avoid leaving a corrupted copy if an error
2359 </footnote>) should be removed by the
2360 <prgn>clean</prgn> target. It may also be wise to
2361 ensure a fresh start by emptying or removing it at the
2362 start of the <prgn>binary</prgn> target.
2366 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2367 package, it adds an entry to <tt>debian/files</tt> for the
2368 <tt>.deb</tt> file that will be created when <tt>dpkg-deb
2369 --build</tt> is run for that binary package. So for most
2370 packages all that needs to be done with this file is to
2371 delete it in the <prgn>clean</prgn> target.
2375 If a package upload includes files besides the source
2376 package and any binary packages whose control files were
2377 made with <prgn>dpkg-gencontrol</prgn> then they should be
2378 placed in the parent of the package's top-level directory
2379 and <prgn>dpkg-distaddfile</prgn> should be called to add
2380 the file to the list in <tt>debian/files</tt>.</p>
2383 <sect id="restrictions"><heading>Restrictions on objects in source packages
2387 The source package may not contain any hard links
2390 This is not currently detected when building source
2391 packages, but only when extracting
2395 Hard links may be permitted at some point in the
2396 future, but would require a fair amount of
2399 </footnote>, device special files, sockets or setuid or
2403 Setgid directories are allowed.
2408 <sect id="descriptions"><heading>Descriptions of packages - the
2409 <tt>Description</tt> field </heading>
2412 The description is intended to describe the program to a user
2413 who has never met it before so that they know whether they
2414 want to install it. It should also give information about the
2415 significant dependencies and conflicts between this package
2416 and others, so that the user knows why these dependencies and
2417 conflicts have been declared.
2420 <sect1><heading>Notes about writing descriptions
2424 The single line synopsis should be kept brief - certainly
2425 under 80 characters.
2429 Do not include the package name in the synopsis line. The
2430 display software knows how to display this already, and you
2431 do not need to state it. Remember that in many situations
2432 the user may only see the synopsis line - make it as
2433 informative as you can.
2437 Do not try to continue the single line synopsis into the
2438 extended description. This will not work correctly when
2439 the full description is displayed, and makes no sense
2440 where only the summary (the single line synopsis) is
2445 The extended description should describe what the package
2446 does and how it relates to the rest of the system (in terms
2447 of, for example, which subsystem it is which part of).
2451 The description field needs to make sense to anyone, even
2452 people who have no idea about any of the things the
2456 The blurb that comes with a program in its
2457 announcements and/or <prgn>README</prgn> files is
2458 rarely suitable for use in a description. It is
2459 usually aimed at people who are already in the
2460 community where the package is used.
2466 Put important information first, both in the synopsis and
2467 extended description. Sometimes only the first part of the
2468 synopsis or of the description will be displayed. You can
2469 assume that there will usually be a way to see the whole
2470 extended description.
2474 You may include information about dependencies and so forth
2475 in the extended description, if you wish.
2479 Do not use tab characters. Their effect is not predictable.
2487 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2488 and installation procedure
2491 <sect><heading>Introduction to package maintainer scripts
2495 It is possible to supply scripts as part of a package which
2496 the package management system will run for you when your
2497 package is installed, upgraded or removed.
2501 These scripts are the files <tt>preinst</tt>,
2502 <tt>postinst</tt>, <tt>prerm</tt> and <tt>postrm</tt> in the
2503 control area of the package. They must be proper executable
2504 files; if they are scripts (which is recommended), they must
2505 start with the usual <tt>#!</tt> convention. They should be
2506 readable and executable by anyone, and not world-writable.
2510 The package management system looks at the exit status from
2511 these scripts. It is important that they exit with a
2512 non-zero status if there is an error, so that the package
2513 management system can stop its processing. For shell
2514 scripts this means that you <em>almost always</em> need to
2515 use <tt>set -e</tt> (this is usually true when writing shell
2516 scripts, in fact). It is also important, of course, that
2517 they don't exit with a non-zero status if everything went
2522 When a package is upgraded a combination of the scripts from
2523 the old and new packages is called during the upgrade
2524 procedure. If your scripts are going to be at all
2525 complicated you need to be aware of this, and may need to
2526 check the arguments to your scripts.
2530 Broadly speaking the <prgn>preinst</prgn> is called before
2531 (a particular version of) a package is installed, and the
2532 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2533 before (a version of) a package is removed and the
2534 <prgn>postrm</prgn> afterwards.
2538 Programs called from maintainer scripts should not normally
2539 have a path prepended to them. Before installation is
2540 started, the package management system checks to see if the
2541 programs <prgn>ldconfig</prgn>,
2542 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2543 and <prgn>update-rc.d</prgn> can be found via the
2544 <tt>PATH</tt> environment variable. Those programs, and any
2545 other program that one would expect to be on the
2546 <tt>PATH</tt>, should thus be invoked without an absolute
2547 pathname. Maintainer scripts should also not reset the
2548 <tt>PATH</tt>, though they might choose to modify it by
2549 prepending or appending package-specific directories. These
2550 considerations really apply to all shell scripts.</p>
2554 <heading>Maintainer scripts Idempotency</heading>
2557 It is necessary for the error recovery procedures that the
2558 scripts be idempotent. This means that if it is run
2559 successfully, and then it is called again, it doesn't bomb
2560 out or cause any harm, but just ensures that everything is
2561 the way it ought to be. If the first call failed, or
2562 aborted half way through for some reason, the second call
2563 should merely do the things that were left undone the first
2564 time, if any, and exit with a success status if everything
2568 This is so that if an error occurs, the user interrupts
2569 <prgn>dpkg</prgn> or some other unforeseen circumstance
2570 happens you don't leave the user with a badly-broken
2571 package when <prgn>dpkg</prgn> attempts to repeat the
2579 <heading>Controlling terminal for maintainer scripts</heading>
2582 The maintainer scripts are guaranteed to run with a
2583 controlling terminal and can interact with the user.
2584 If they need to prompt for passwords, do full-screen
2585 interaction or something similar you should do these
2586 things to and from <tt>/dev/tty</tt>, since
2587 <prgn>dpkg</prgn> will at some point redirect scripts'
2588 standard input and output so that it can log the
2589 installation process. Likewise, because these scripts
2590 may be executed with standard output redirected into a
2591 pipe for logging purposes, Perl scripts should set
2592 unbuffered output by setting <tt>$|=1</tt> so that the
2593 output is printed immediately rather than being
2598 Each script should return a zero exit status for
2599 success, or a nonzero one for failure.
2603 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2608 <list compact="compact">
2610 <p><var>new-preinst</var> <tt>install</tt></p>
2613 <p><var>new-preinst</var> <tt>install</tt>
2614 <var>old-version</var></p>
2617 <p><var>new-preinst</var> <tt>upgrade</tt>
2618 <var>old-version</var></p>
2621 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2622 <var>new-version</var>
2628 <list compact="compact">
2630 <p><var>postinst</var> <tt>configure</tt>
2631 <var>most-recently-configured-version</var></p>
2634 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2635 <var>new-version</var></p>
2638 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2639 <tt>in-favour</tt> <var>package</var>
2640 <var>new-version</var></p>
2644 <var>deconfigured's-postinst</var>
2645 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2646 <var>failed-install-package</var> <var>version</var>
2647 <tt>removing</tt> <var>conflicting-package</var>
2654 <list compact="compact">
2656 <p><var>prerm</var> <tt>remove</tt></p>
2659 <p><var>old-prerm</var> <tt>upgrade</tt>
2660 <var>new-version</var></p>
2663 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2664 <var>old-version</var></p>
2667 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2668 <tt>in-favour</tt> <var>package</var>
2669 <var>new-version</var></p>
2673 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2674 <tt>in-favour</tt> <var>package-being-installed</var>
2675 <var>version</var> <tt>removing</tt>
2676 <var>conflicting-package</var>
2683 <list compact="compact">
2685 <p><var>postrm</var> <tt>remove</tt></p>
2688 <p><var>postrm</var> <tt>purge</tt></p>
2692 <var>old-postrm</var> <tt>upgrade</tt>
2693 <var>new-version</var></p>
2696 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2697 <var>old-version</var></p>
2700 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2703 <p><var>new-postrm</var> <tt>abort-install</tt>
2704 <var>old-version</var></p>
2707 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2708 <var>old-version</var></p>
2712 <var>disappearer's-postrm</var> <tt>disappear</tt>
2713 <var>overwriter</var>
2714 <var>overwriter-version</var></p></item>
2719 <sect id="unpackphase"><heading>Details of unpack phase of
2720 installation or upgrade
2724 The procedure on installation/upgrade/overwrite/disappear
2725 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2726 stage of <tt>dpkg --install</tt>) is as follows. In each
2727 case, if a major error occurs (unless listed below) the
2728 actions are, in general, run backwards - this means that the
2729 maintainer scripts are run with different arguments in
2730 reverse order. These are the `error unwind' calls listed
2738 <p>If a version of the package is already
2740 <example compact="compact">
2741 <var>old-prerm</var> upgrade <var>new-version</var>
2746 If the script runs but exits with a non-zero
2747 exit status, <prgn>dpkg</prgn> will attempt:
2748 <example compact="compact">
2749 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2751 Error unwind, for both the above cases:
2752 <example compact="compact">
2753 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2761 <p>If a `conflicting' package is being removed at the same time:
2765 If any packages depended on that conflicting
2766 package and <tt>--auto-deconfigure</tt> is
2767 specified, call, for each such package:
2768 <example compact="compact">
2769 <var>deconfigured's-prerm</var> deconfigure \
2770 in-favour <var>package-being-installed</var> <var>version</var> \
2771 removing <var>conflicting-package</var> <var>version</var>
2774 <example compact="compact">
2775 <var>deconfigured's-postinst</var> abort-deconfigure \
2776 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2777 removing <var>conflicting-package</var> <var>version</var>
2779 The deconfigured packages are marked as
2780 requiring configuration, so that if
2781 <tt>--install</tt> is used they will be
2782 configured again if possible.</p>
2785 <p>To prepare for removal of the conflicting package, call:
2786 <example compact="compact">
2787 <var>conflictor's-prerm</var> remove \
2788 in-favour <var>package</var> <var>new-version</var>
2791 <example compact="compact">
2792 <var>conflictor's-postinst</var> abort-remove \
2793 in-favour <var>package</var> <var>new-version</var>
2804 <p>If the package is being upgraded, call:
2805 <example compact="compact">
2806 <var>new-preinst</var> upgrade <var>old-version</var>
2811 Otherwise, if the package had some configuration
2812 files from a previous version installed (i.e., it
2813 is in the `configuration files only' state):
2814 <example compact="compact">
2815 <var>new-preinst</var> install <var>old-version</var>
2819 <p>Otherwise (i.e., the package was completely purged):
2820 <example compact="compact">
2821 <var>new-preinst</var> install
2823 Error unwind actions, respectively:
2824 <example compact="compact">
2825 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2826 <var>new-postrm</var> abort-install <var>old-version</var>
2827 <var>new-postrm</var> abort-install
2837 The new package's files are unpacked, overwriting any
2838 that may be on the system already, for example any
2839 from the old version of the same package or from
2840 another package. Backups of the old files are kept
2841 temporarily, and if anything goes wrong the package
2842 management system will attempt to put them back as
2843 part of the error unwind.
2847 It is an error for a package to contains files which
2848 are on the system in another package, unless
2849 <tt>Replaces</tt> is used (see <ref id="replaces">).
2851 The following paragraph is not currently the case:
2852 Currently the <tt>- - force-overwrite</tt> flag is
2853 enabled, downgrading it to a warning, but this may not
2859 It is a more serious error for a package to contain a
2860 plain file or other kind of non-directory where another
2861 package has a directory (again, unless
2862 <tt>Replaces</tt> is used). This error can be
2863 overridden if desired using
2864 <tt>--force-overwrite-dir</tt>, but this is not
2869 Packages which overwrite each other's files produce
2870 behavior which, though deterministic, is hard for the
2871 system administrator to understand. It can easily
2872 lead to `missing' programs if, for example, a package
2873 is installed which overwrites a file from another
2874 package, and is then removed again.
2877 Part of the problem is due to what is arguably a
2878 bug in <prgn>dpkg</prgn>.
2884 A directory will never be replaced by a symbolic link
2885 to a directory or vice versa; instead, the existing
2886 state (symlink or not) will be left alone and
2887 <prgn>dpkg</prgn> will follow the symlink if there is
2895 <p>If the package is being upgraded, call
2896 <example compact="compact">
2897 <var>old-postrm</var> upgrade <var>new-version</var>
2901 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2902 <example compact="compact">
2903 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2905 Error unwind, for both cases:
2906 <example compact="compact">
2907 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2913 This is the point of no return - if
2914 <prgn>dpkg</prgn> gets this far, it won't back off
2915 past this point if an error occurs. This will
2916 leave the package in a fairly bad state, which
2917 will require a successful re-installation to clear
2918 up, but it's when <prgn>dpkg</prgn> starts doing
2919 things that are irreversible.
2924 Any files which were in the old version of the package
2925 but not in the new are removed.</p>
2928 <p>The new file list replaces the old.</p>
2931 <p>The new maintainer scripts replace the old.</p>
2935 <p>Any packages all of whose files have been overwritten during the
2936 installation, and which aren't required for
2937 dependencies, are considered to have been removed.
2938 For each such package
2941 <p><prgn>dpkg</prgn> calls:
2942 <example compact="compact">
2943 <var>disappearer's-postrm</var> disappear \
2944 <var>overwriter</var> <var>overwriter-version</var>
2949 <p>The package's maintainer scripts are removed.
2954 It is noted in the status database as being in a
2955 sane state, namely not installed (any conffiles
2956 it may have are ignored, rather than being
2957 removed by <prgn>dpkg</prgn>). Note that
2958 disappearing packages do not have their prerm
2959 called, because <prgn>dpkg</prgn> doesn't know
2960 in advance that the package is going to
2969 Any files in the package we're unpacking that are also
2970 listed in the file lists of other packages are removed
2971 from those lists. (This will lobotomize the file list
2972 of the `conflicting' package if there is one.)
2977 The backup files made during installation, above, are
2984 The new package's status is now sane, and recorded as
2989 Here is another point of no return - if the
2990 conflicting package's removal fails we do not unwind
2991 the rest of the installation; the conflicting package
2992 is left in a half-removed limbo.
2998 If there was a conflicting package we go and do the
2999 removal actions (described below), starting with the
3000 removal of the conflicting package's files (any that
3001 are also in the package being installed have already
3002 been removed from the conflicting package's file list,
3003 and so do not get removed now).
3010 <sect><heading>Details of configuration</heading>
3013 When we configure a package (this happens with <tt>dpkg
3014 --install</tt>, or with <tt>--configure</tt>), we first
3015 update any <tt>conffile</tt>s and then call:
3016 <example compact="compact">
3017 <var>postinst</var> configure <var>most-recently-configured-version</var>
3022 No attempt is made to unwind after errors during
3027 If there is no most recently configured version
3028 <prgn>dpkg</prgn> will pass a null argument; older versions
3029 of dpkg may pass <tt><unknown></tt> (including the
3030 angle brackets) in this case. Even older ones do not pass a
3031 second argument at all, under any circumstances.
3035 <sect><heading>Details of removal and/or configuration purging
3042 <example compact="compact">
3043 <var>prerm</var> remove
3049 The package's files are removed (except <tt>conffile</tt>s).
3054 <example compact="compact">
3055 <var>postrm</var> remove
3061 All the maintainer scripts except the <tt>postrm</tt>
3066 If we aren't purging the package we stop here. Note
3067 that packages which have no <tt>postrm</tt> and no
3068 <tt>conffile</tt>s are automatically purged when
3069 removed, as there is no difference except for the
3070 <prgn>dpkg</prgn> status.</p>
3074 The conffiles and any backup files (<tt>~</tt>-files,
3075 <tt>#*#</tt> files, <tt>%</tt>-files,
3076 <tt>.dpkg-{old,new,tmp}</tt>, etc.) are removed.</p>
3080 <example compact="compact">
3081 <var>postrm</var> purge
3086 <p>The package's file list is removed.</p>
3089 No attempt is made to unwind after errors during
3096 <chapt id="relationships"><heading>Declaring relationships between
3100 Packages can declare in their control file that they have
3101 certain relationships to other packages - for example, that
3102 they may not be installed at the same time as certain other
3103 packages, and/or that they depend on the presence of others,
3104 or that they should overwrite files in certain other packages
3109 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3110 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3111 <tt>Conflicts</tt>, <tt>Provides</tt> and <tt>Replaces</tt>
3112 control file fields.
3116 Source packages may declare relationships to binary packages,
3117 saying that they require certain binary packages to be
3118 installed or absent at the time of building the package.
3122 This is done using the <tt>Build-Depends</tt>,
3123 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3124 <tt>Build-Conflicts-Indep</tt> control file fields.
3127 <sect id="depsyntax"><heading>Syntax of relationship fields
3131 These fields all have a uniform syntax. They are a list of
3132 package names separated by commas.
3136 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3137 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3138 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3139 control file fields of the package, which declare
3140 dependencies on other packages, the package names listed may
3141 also include lists of alternative package names, separated
3142 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3143 if any one of the alternative packages is installed, that
3144 part of the dependency is considered to be satisfied.
3148 All of the fields except for <tt>Provides</tt> may restrict
3149 their applicability to particular versions of each named
3150 package. This is done in parentheses after each individual
3151 package name; the parentheses should contain a relation from
3152 the list below followed by a version number, in the format
3153 described in <ref id="versions">.
3157 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3158 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3159 strictly earlier, earlier or equal, exactly equal, later or
3160 equal and strictly later, respectively. The deprecated
3161 forms <tt><</tt> and <tt>></tt> were used to mean
3162 earlier/later or equal, rather than strictly earlier/later,
3163 so they should not appear in new packages (though
3164 <prgn>dpkg</prgn> still supports them).
3168 Whitespace may appear at any point in the version
3169 specification subject to the rules in <ref
3170 id="controlsyntax">, and must appear where it's necessary to
3171 disambiguate; it is not otherwise significant. For
3172 consistency and in case of future changes to
3173 <prgn>dpkg</prgn> it is recommended that a single space be
3174 used after a version relationship and before a version
3175 number; it is also conventional to put a single space after
3176 each comma, on either side of each vertical bar, and before
3177 each open parenthesis.
3181 For example, a list of dependencies might appear as:
3182 <example compact="compact">
3185 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3190 All fields that specify build-time relationships
3191 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3192 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3193 may be restricted to a certain set of architectures. This
3194 is indicated in brackets after each individual package name and
3195 the optional version specification. The brackets enclose a
3196 list of Debian architecture names separated by whitespace.
3197 Exclamation marks may be prepended to each of the names.
3198 (It is not permitted for some names to be prepended with
3199 exclamation marks and others not.) If the current Debian
3200 host architecture is not in this list and there are no
3201 exclamation marks in the list, or it is in the list with a
3202 prepended exclamation mark, the package name and the
3203 associated version specification are ignored completely for
3204 the purposes of defining the relationships.
3209 <example compact="compact">
3211 Build-Depends-Indep: texinfo
3212 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3213 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3219 <heading>Binary Dependencies - <tt>Depends</tt>,
3220 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3221 <tt>Pre-Depends</tt>
3225 These five fields are used to declare a dependency
3226 relationship by one package on another. They appear in the
3227 depending package's control file.
3231 A <tt>Depends</tt> field takes effect <em>only</em> when a
3232 package is to be configured. It does not prevent a package
3233 being on the system in an unconfigured state while its
3234 dependencies are unsatisfied, and it is possible to replace
3235 a package whose dependencies are satisfied and which is
3236 properly installed with a different version whose
3237 dependencies are not and cannot be satisfied; when this is
3238 done the depending package will be left unconfigured (since
3239 attempts to configure it will give errors) and will not
3240 function properly. If it is necessary, a
3241 <tt>Pre-Depends</tt> field can be used, which has a partial
3242 effect even when a package is being unpacked, as explained
3243 in detail below. (The other three dependency fields,
3244 <tt>Recommends</tt>, <tt>Suggests</tt> and
3245 <tt>Enhances</tt>, are only used by the various front-ends
3246 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3250 For this reason packages in an installation run are usually
3251 all unpacked first and all configured later; this gives
3252 later versions of packages with dependencies on later
3253 versions of other packages the opportunity to have their
3254 dependencies satisfied.
3258 The <tt>Depends</tt> field thus allows package maintainers
3259 to impose an order in which packages should be configured.
3263 The meaning of the five dependency fields is as follows:
3265 <tag><tt>Depends</tt></tag>
3269 This declares an absolute dependency. A package will
3270 not be configured unless all of the packages listed in
3271 its <tt>Depends</tt> field have been correctly
3276 The <tt>Depends</tt> field should be used if the
3277 depended-on package is required for the depending
3278 package to provide a significant amount of
3282 The <tt>Depends</tt> field should also be used if the
3283 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3284 <prgn>postrm</prgn> scripts require the package to be
3285 present in order to run. Note, however, that the
3286 <prgn>postrm</prgn> cannot rely on any non-essential
3287 packages to be present during the <tt>purge</tt>
3291 <tag><tt>Recommends</tt></tag>
3293 <p>This declares a strong, but not absolute, dependency.
3297 The <tt>Recommends</tt> field should list packages
3298 that would be found together with this one in all but
3299 unusual installations.</p>
3302 <tag><tt>Suggests</tt></tag>
3306 This is used to declare that one package may be more
3307 useful with one or more others. Using this field
3308 tells the packaging system and the user that the
3309 listed packages are related to this one and can
3310 perhaps enhance its usefulness, but that installing
3311 this one without them is perfectly reasonable.
3315 <tag><tt>Enhances</tt></tag>
3318 This field is similar to Suggests but works in the
3319 opposite direction. It is used to declare that a
3320 package can enhance the functionality of another
3325 <tag><tt>Pre-Depends</tt></tag>
3329 This field is like <tt>Depends</tt>, except that it
3330 also forces <prgn>dpkg</prgn> to complete installation
3331 of the packages named before even starting the
3332 installation of the package which declares the
3333 pre-dependency, as follows:
3337 When a package declaring a pre-dependency is about to
3338 be <em>unpacked</em> the pre-dependency can be
3339 satisfied if the depended-on package is either fully
3340 configured, <em>or even if</em> the depended-on
3341 package(s) are only unpacked or half-configured,
3342 provided that they have been configured correctly at
3343 some point in the past (and not removed or partially
3344 removed since). In this case, both the
3345 previously-configured and currently unpacked or
3346 half-configured versions must satisfy any version
3347 clause in the <tt>Pre-Depends</tt> field.
3351 When the package declaring a pre-dependency is about
3352 to be <em>configured</em>, the pre-dependency will be
3353 treated as a normal <tt>Depends</tt>, that is, it will
3354 be considered satisfied only if the depended-on
3355 package has been correctly configured.
3359 <tt>Pre-Depends</tt> should be used sparingly,
3360 preferably only by packages whose premature upgrade or
3361 installation would hamper the ability of the system to
3362 continue with any upgrade that might be in progress.
3366 <tt>Pre-Depends</tt> are also required if the
3367 <prgn>preinst</prgn> script depends on the named
3368 package. It is best to avoid this situation if
3374 When selecting which level of dependency to use you should
3375 consider how important the depended-on package is to the
3376 functionality of the one declaring the dependency. Some
3377 packages are composed of components of varying degrees of
3378 importance. Such a package should list using
3379 <tt>Depends</tt> the package(s) which are required by the
3380 more important components. The other components'
3381 requirements may be mentioned as Suggestions or
3382 Recommendations, as appropriate to the components' relative
3387 <sect id="conflicts"><heading>Conflicting binary packages -
3388 <tt>Conflicts</tt></heading>
3391 When one binary package declares a conflict with another
3392 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3393 refuse to allow them to be installed on the system at the
3398 If one package is to be installed, the other must be removed
3399 first - if the package being installed is marked as
3400 replacing (see <ref id="replaces">) the one on the system,
3401 or the one on the system is marked as deselected, or both
3402 packages are marked <tt>Essential</tt>, then
3403 <prgn>dpkg</prgn> will automatically remove the package
3404 which is causing the conflict, otherwise it will halt the
3405 installation of the new package with an error. This
3406 mechanism is specifically designed to produce an error when
3407 the installed package is <tt>Essential</tt>, but the new
3412 A package will not cause a conflict merely because its
3413 configuration files are still installed; it must be at least
3418 A special exception is made for packages which declare a
3419 conflict with their own package name, or with a virtual
3420 package which they provide (see below): this does not
3421 prevent their installation, and allows a package to conflict
3422 with others providing a replacement for it. You use this
3423 feature when you want the package in question to be the only
3424 package providing some feature.
3428 A <tt>Conflicts</tt> entry should almost never have an
3429 `earlier than' version clause. This would prevent
3430 <prgn>dpkg</prgn> from upgrading or installing the package
3431 which declared such a conflict until the upgrade or removal
3432 of the conflicted-with package had been completed.
3436 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3440 As well as the names of actual (`concrete') packages, the
3441 package relationship fields <tt>Depends</tt>,
3442 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3443 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3444 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3445 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3446 may mention `virtual packages'.
3450 A <em>virtual package</em> is one which appears in the
3451 <tt>Provides</tt> control file field of another package.
3452 The effect is as if the package(s) which provide a
3453 particular virtual package name had been listed by name
3454 everywhere the virtual package name appears.
3458 If there are both a real and a virtual package of the same
3459 name then the dependency may be satisfied (or the conflict
3460 caused) by either the real package or any of the virtual
3461 packages which provide it. This is so that, for example,
3463 <example compact="compact">
3467 and someone else releases an enhanced version of the
3468 <tt>bar</tt> package (for example, a non-US variant), they
3470 <example compact="compact">
3474 and the <tt>bar-plus</tt> package will now also satisfy the
3475 dependency for the <tt>foo</tt> package.
3479 If a dependency or a conflict has a version number attached
3480 then only real packages will be considered to see whether
3481 the relationship is satisfied (or the prohibition violated,
3482 for a conflict) - it is assumed that a real package which
3483 provides the virtual package is not of the `right' version.
3484 So, a <tt>Provides</tt> field may not contain version
3485 numbers, and the version number of the concrete package
3486 which provides a particular virtual package will not be
3487 looked at when considering a dependency on or conflict with
3488 the virtual package name.
3492 It is likely that the ability will be added in a future
3493 release of <prgn>dpkg</prgn> to specify a version number for
3494 each virtual package it provides. This feature is not yet
3495 present, however, and is expected to be used only
3500 If you want to specify which of a set of real packages
3501 should be the default to satisfy a particular dependency on
3502 a virtual package, you should list the real package as an
3503 alternative before the virtual one.
3508 <sect id="replaces"><heading>Overwriting files and replacing
3509 packages - <tt>Replaces</tt></heading>
3512 The <tt>Replaces</tt> control file field has two distinct
3513 purposes, which come into play in different situations.
3516 <sect1><heading>Overwriting files in other packages</heading>
3519 Firstly, as mentioned before, it is usually an error for a
3520 package to contain files which are on the system in
3525 However, if the overwriting package declares that it
3526 <tt>Replaces</tt> the one containing the file being
3527 overwritten, then <prgn>dpkg</prgn> will replace the file
3528 from the old package with that from the new. The file
3529 will no longer be listed as `owned' by the old package.
3533 If a package is completely replaced in this way, so that
3534 <prgn>dpkg</prgn> does not know of any files it still
3535 contains, it is considered to have `disappeared'. It will
3536 be marked as not wanted on the system (selected for
3537 removal) and not installed. Any <tt>conffile</tt>s
3538 details noted for the package will be ignored, as they
3539 will have been taken over by the overwriting package. The
3540 package's <prgn>postrm</prgn> script will be run with a
3541 special argument to allow the package to do any final
3542 cleanup required. See <ref id="mscriptsinstact">.
3546 If an installed package, <tt>foo</tt> say, declares that
3547 it replaces another, <tt>bar</tt>, and an attempt is made
3548 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3549 files in the <tt>bar</tt> package which would overwrite
3550 those already present in <tt>foo</tt>. This is so that
3551 you can install an older version of a package without
3556 For this usage of <tt>Replaces</tt>, virtual packages (see
3557 <ref id="virtual">) are not considered when looking at a
3558 <tt>Replaces</tt> field - the packages declared as being
3559 replaced must be mentioned by their real names.
3563 Furthermore, this usage of <tt>Replaces</tt> only takes
3564 effect when both packages are at least partially on the
3565 system at once, so that it can only happen if they do not
3566 conflict or if the conflict has been overridden.
3571 <sect1><heading>Replacing whole packages, forcing their
3575 Secondly, <tt>Replaces</tt> allows the packaging system to
3576 resolve which package should be removed when there is a
3577 conflict - see <ref id="conflicts">. This usage only
3578 takes effect when the two packages <em>do</em> conflict,
3579 so that the two usages of this field do not interfere with
3584 In this situation, the package declared as being replaced
3585 can be a virtual package, so for example, all mail
3586 transport agents (MTAs) would have the following fields in
3587 their control files:
3588 <example compact="compact">
3589 Provides: mail-transport-agent
3590 Conflicts: mail-transport-agent
3591 Replaces: mail-transport-agent
3593 ensuring that only one MTA can be installed at any one
3598 <sect><heading>Relationships between source and binary packages -
3599 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3600 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3604 A source package may declare a dependency or a conflict on a
3605 binary package, indicating which packages are required to be
3606 present on the system in order to build the binary packages
3607 from the source package. This is done with the control file
3608 fields <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3609 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>.
3610 The dependencies and conflicts they define must be satisfied
3611 (as defined earlier for binary packages) in order to invoke
3612 the targets in <tt>debian/rules</tt>, as follows:
3615 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3618 The <tt>Build-Depends</tt> and
3619 <tt>Build-Conflicts</tt> fields must be satisfied when
3620 any of the following targets is invoked:
3621 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>
3622 and <tt>binary-indep</tt>.
3625 <tag><tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt></tag>
3628 The <tt>Build-Depends-Indep</tt> and
3629 <tt>Build-Conflicts-Indep</tt> fields must be
3630 satisfied when any of the following targets is
3631 invoked: <tt>binary</tt> and <tt>binary-indep</tt>.
3642 <chapt id="conffiles"><heading>Configuration file handling
3646 This chapter has been superseded by <ref id="config files">.
3650 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3653 Packages containing shared libraries must be constructed with
3654 a little care to make sure that the shared library is always
3655 available. This is especially important for packages whose
3656 shared libraries are vitally important, such as the C library
3657 (currently <tt>libc6</tt>).
3661 Firstly, the package should install the shared libraries under
3662 their normal names. For example, the <tt>libgdbmg1</tt>
3663 package should install <tt>libgdbm.so.1.7.3</tt> as
3664 <tt>/usr/lib/libgdbm.so.1.7.3</tt>. The files should not be
3665 renamed or re-linked by any <prgn>prerm</prgn> or
3666 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3667 of renaming things safely without affecting running programs,
3668 and attempts to interfere with this are likely to lead to
3673 Secondly, the package should include the symbolic link that
3674 <prgn>ldconfig</prgn> would create for the shared libraries.
3675 For example, the <prgn>libgdbmg1</prgn> package should include
3676 a symbolic link from <tt>/usr/lib/libgdbm.so.1</tt> to
3677 <tt>libgdbm.so.1.7.3</tt>. This is needed so that the dynamic
3678 linker (for example <prgn>ld.so</prgn> or
3679 <prgn>ld-linux.so.*</prgn>) can find the library between the
3680 time that <prgn>dpkg</prgn> installs it and the time that
3681 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3685 The package management system requires the library to be
3686 placed before the symbolic link pointing to it in the
3687 <tt>.deb</tt> file. This is so that when
3688 <prgn>dpkg</prgn> comes to install the symlink
3689 (overwriting the previous symlink pointing at an older
3690 version of the library), the new shared library is already
3691 in place. In the past, this was achieved by creating the
3692 library in the temporary packaging directory before
3693 creating the symlink. Unfortunately, this was not always
3694 effective, since the building of the tar file in the
3695 <tt>.deb</tt> depended on the behavior of the underlying
3696 file system. Some file systems (such as reiserfs) reorder
3697 the files so that the order of creation is forgotten.
3698 Starting with release <tt>1.7.0</tt>, <prgn>dpkg</prgn>
3699 will reorder the files itself as necessary when building a
3700 package. Thus it is no longer important to concern
3701 oneself with the order of file creation.
3707 Thirdly, the associated development package should contain a
3708 symlink for the shared library without a version number. For
3709 example, the <tt>libgdbmg1-dev</tt> package should include a
3710 symlink from <tt>/usr/lib/libgdbm.so</tt> to
3711 <tt>libgdbm.so.1.7.3</tt>. This symlink is needed by the
3712 linker (<prgn>ld</prgn>) when compiling packages, as it will
3713 only look for <tt>libgdbm.so</tt> when compiling dynamically.
3717 Any package installing shared libraries in one of the default
3718 library directories of the dynamic linker (which are currently
3719 <tt>/usr/lib</tt> and <tt>/lib</tt>) or a directory that is
3720 listed in <tt>/etc/ld.so.conf</tt>
3724 <list compact="compact">
3725 <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3726 <item><p>/usr/local/lib</p></item>
3727 <item><p>/usr/lib/libc5-compat</p></item>
3728 <item><p>/lib/libc5-compat</p></item>
3729 <item><p>/usr/X11R6/lib</p></item>
3733 must call <prgn>ldconfig</prgn> in its <prgn>postinst</prgn>
3734 script if and only if the first argument is <tt>configure</tt>
3735 and should call it in the <prgn>postrm</prgn> script if the
3736 first argument is <tt>remove</tt>.
3740 However, <prgn>postrm</prgn> and <prgn>preinst</prgn> scripts
3741 <em>must not</em> call <prgn>ldconfig</prgn> in the case where
3742 the package is being upgraded (see <ref id="unpackphase"> for
3743 details), as <prgn>ldconfig</prgn> will see the temporary
3744 names that <prgn>dpkg</prgn> uses for the files while it is
3745 installing them and will make the shared library links point
3746 to them, just before <prgn>dpkg</prgn> continues the
3747 installation and renames the temporary files!
3751 <heading>Handling shared library dependencies - the
3752 <tt>shlibs</tt> system</heading>
3755 If a package contains a binary or library which links to a
3756 shared library, we must ensure that when the package is
3757 installed on the system, all of the libraries needed are
3758 also installed. This requirement led to the creation of the
3759 <tt>shlibs</tt> system, which is very simple in its design:
3760 any package which <em>provides</em> a shared library also
3761 provides information on the package dependencies required to
3762 ensure the presence of this library, and any package which
3763 <em>uses</em> a shared library uses this information to
3764 determine the dependencies it requires. The files which
3765 contain the mapping from shared libraries to the necessary
3766 dependency information are called <tt>shlibs</tt> files.
3770 Thus, when a package is built which contains any shared
3771 libraries, it must provide a <tt>shlibs</tt> file for other
3772 packages to use, and when a package is built which contains
3773 any shared libraries or compiled binaries, it must run
3774 <prgn>dpkg-shlibdeps</prgn> on these to determine the
3775 libraries used and hence the dependencies needed by this
3779 In the past, the shared libraries linked to were
3780 determined by calling <prgn>ldd</prgn>, but now
3781 <prgn>objdump</prgn> to do this. The only change this
3782 makes to package building is that
3783 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
3784 libraries, whereas in the past this was unnecessary.
3785 The rest of this footnote explains the advantage that
3790 We say that a binary <tt>foo</tt> <em>directly</em> uses
3791 a library <tt>libbar</tt> if it is explicitly linked
3792 with that library (that is, it uses the flag
3793 <tt>-lbar</tt> during the linking stage). Other
3794 libraries that are needed by <tt>libbar</tt> are linked
3795 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
3796 linker will load them automatically when it loads
3797 <tt>libbar</tt>. A package should needs to depend on
3798 the libraries it directly uses, and the dependencies for
3799 those libraries should automatically pull in the other
3804 Unfortunately, the <prgn>ldd</prgn> program shows both
3805 the directly and indirectly used libraries, meaning that
3806 the dependencies determined included both direct and
3807 indirect dependencies. The use of <prgn>objdump</prgn>
3808 avoids this problem by determining only the directly
3813 A good example of where this helps is the following. We
3814 could update <tt>libimlib</tt> with a new version that
3815 supports a new graphics format called dgf (but retaining
3816 the same major version number). If we used the old
3817 <prgn>ldd</prgn> method, every package that uses
3818 <tt>libimlib</tt> would need to be recompiled so it
3819 would also depend on <tt>libdgf</tt> or it wouldn't run
3820 due to missing symbols. However with the new system,
3821 packages using <tt>libimlib</tt> can rely on
3822 <tt>libimlib</tt> itself having the dependency on
3823 <tt>libdgf</tt> and so they would not need rebuilding.
3829 In the following sections, we will first describe where the
3830 various <tt>shlibs</tt> files are to be found, then how to
3831 use <prgn>dpkg-shlibdeps</prgn>, and finally the
3832 <tt>shlibs</tt> file format and how to create them if your
3833 package contains a shared library.
3837 <sect><heading>The <tt>shlibs</tt> files present on the system
3841 There are several places where <tt>shlibs</tt> files are
3842 found. The following list gives them in the order in which
3843 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
3844 one which gives the required information is used.)
3850 <p><tt>debian/shlibs.local</tt></p>
3852 This lists overrides for this package. Its use is
3853 described below (see <ref id="shlibslocal">).
3858 <p><tt>/etc/dpkg/shlibs.override</tt></p>
3860 This lists global overrides. This list is normally
3861 empty. It is maintained by the local system
3867 <p><tt>DEBIAN/shlibs</tt> files in the `build directory'</p>
3869 When packages are being built, any
3870 <tt>debian/shlibs</tt> files are copied into the
3871 control file area of the temporary build directory and
3872 given the name <tt>shlibs</tt>. These files give
3873 details of any shared libraries included in the
3877 An example may help here. Let us say that the
3878 source package <tt>foo</tt> generates two binary
3879 packages, <tt>libfoo2</tt> and
3880 <tt>foo-runtime</tt>. When building the binary
3881 packages, the two packages are created in the
3882 directories <tt>debian/libfoo2</tt> and
3883 <tt>debian/foo-runtime</tt> respectively.
3884 (<tt>debian/tmp</tt> could be used instead of one
3885 of these.) Since <tt>libfoo2</tt> provides the
3886 <tt>libfoo</tt> shared library, it will require a
3887 <tt>shlibs</tt> file, which will be installed in
3888 <tt>debian/libfoo2/DEBIAN/shlibs</tt>, eventually
3890 <tt>/var/lib/dpkg/info/libfoo2.shlibs</tt>. Then
3891 when <prgn>dpkg-shlibdeps</prgn> is run on the
3893 <tt>debian/foo-runtime/usr/bin/foo-prog</tt>, it
3895 <tt>debian/libfoo2/DEBIAN/shlibs</tt> file to
3896 determine whether <tt>foo-prog</tt>'s library
3897 dependencies are satisfied by any of the libraries
3898 provided by <tt>libfoo2</tt>. For this reason,
3899 <prgn>dpkg-shlibdeps</prgn> must only be run once
3900 all of the individual binary packages'
3901 <tt>shlibs</tt> files have been installed into the
3909 <p><tt>/var/lib/dpkg/info/*.shlibs</tt></p>
3911 These are the <tt>shlibs</tt> files corresponding to
3912 all of the packages installed on the system, and are
3913 maintained by the relevant package maintainers.
3918 <p><tt>/etc/dpkg/shlibs.default</tt></p>
3920 This file lists any shared libraries whose packages
3921 have failed to provide correct <tt>shlibs</tt> files.
3922 It was used when the <tt>shlibs</tt> setup was first
3923 introduced, but it is now normally empty. It is
3924 maintained by the <tt>dpkg</tt> maintainer.
3932 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
3933 <tt>shlibs</tt> files</heading>
3936 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
3937 <tt>debian/rules</tt> file. If your package contains only
3938 compiled binaries and libraries (but no scripts), you can
3939 use a command such as:
3940 <example compact="compact">
3941 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
3942 debian/tmp/usr/lib/*
3944 Otherwise, you will need to explicitly list the compiled
3945 binaries and libraries.
3948 If you are using <tt>debhelper</tt>, the
3949 <prgn>dh_shlibdeps</prgn> program will do this work for
3950 you. It will also correctly handle multi-binary
3957 This command puts the dependency information into the
3958 <tt>debian/substvars</tt> file, which is then used by
3959 <prgn>dpkg-gencontrol</prgn>. You will need to place a
3960 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
3961 field in the control file for this to work.
3965 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
3966 done. If it does complain you might need to create your own
3967 <tt>debian/shlibs.local</tt> file, as explained below (see
3968 <ref id="shlibslocal">).
3972 If you have multiple binary packages, you will need to call
3973 <prgn>dpkg-shlibdeps</prgn> on each one which contains
3974 compiled libraries or binaries. In such a case, you will
3975 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
3976 utilities to specify a different <tt>substvars</tt> file.
3977 For more details on this and other options, see <manref
3978 name="dpkg-shlibdeps" section="1">.
3982 <sect id="shlibs"><heading>The <tt>shlibs</tt> File Format
3986 Each <tt>shlibs</tt> file has the same format. Lines
3987 beginning with <tt>#</tt> are considered to be commments and
3988 are ignored. Each line is of the form:
3989 <example compact="compact">
3990 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
3995 We will explain this by reference to the example of the
3996 <tt>zlib1g</tt> package, which (at the time of writing)
3997 installs the shared library <tt>/usr/lib/libz.so.1.1.3</tt>.
4001 <var>library-name</var> is the name of the shared library,
4002 in this case <tt>libz</tt>. (This must match the name part
4003 of the soname, see below.)
4007 <var>soname-version-number</var> is the version part of the
4008 soname of the library. The soname is the thing that must
4009 exactly match for the library to be recognized by the
4010 dynamic linker, and is usually of the form
4011 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4012 example, <tt>libz.so.1</tt>.
4015 This can be determined using the command
4016 <example compact="compact">
4017 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4021 The version part is the part which comes after
4022 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4026 <var>dependencies</var> has the same syntax as a dependency
4027 field in a binary package control file. It should give
4028 details of which packages are required to satisfy a binary
4029 built against the version of the library contained in the
4030 package. See <ref id="depsyntax"> for details.
4034 In our example, if the first version of the <tt>zlib1g</tt>
4035 package which contained a minor number of at least
4036 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4037 <tt>shlibs</tt> entry for this library could say:
4038 <example compact="compact">
4039 libz 1 zlib1g (>= 1:1.1.3)
4041 The version-specific dependency is to avoid warnings from
4042 the dynamic linker about using older shared libraries with
4048 <heading>Providing a <tt>shlibs</tt> file</heading>
4051 If your package provides a shared library, you should create
4052 a <tt>shlibs</tt> file following the format described above.
4053 It is usual to call this file <tt>debian/shlibs</tt> (but if
4054 you have multiple binary packages, you might want to call it
4055 <tt>debian/shlibs.<var>package</var></tt> instead). Then
4056 let <tt>debian/rules</tt> install it in the control area:
4057 <example compact="compact">
4058 install -m644 debian/shlibs debian/tmp/DEBIAN
4060 or, in the case of a multi-binary package:
4061 <example compact="compact">
4062 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4064 An alternative way of doing this is to create the
4065 <tt>shlibs</tt> file in the control area directly from
4066 <tt>debian/rules</tt> without using a <tt>debian/shlibs</tt>
4070 This is what <prgn>dh_makeshlibs</prgn> in the
4071 <tt>debhelper</tt> suite does.
4074 since the <tt>debian/shlibs</tt> file itself is ignored by
4075 <prgn>dpkg-shlibdeps</prgn>.
4079 As <prgn>dpkg-shlibdeps</prgn> reads the
4080 <tt>DEBIAN/shlibs</tt> files in all of the binary packages
4081 being built from this source package, all of the
4082 <tt>DEBIAN/shlibs</tt> files should be installed before
4083 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4088 <sect id="shlibslocal">
4089 <heading>Writing the <tt>debian/shlibs.local</tt> file</heading>
4092 This file is intended only as a <em>temporary</em> fix if
4093 your binaries or libraries depend on a library whose package
4094 does not yet provide a correct <tt>shlibs</tt> file.
4098 We will assume that you are trying to package a binary
4099 <tt>foo</tt>. When you try running
4100 <prgn>dpkg-shlibdeps</prgn> you get the following error
4101 message (<tt>-O</tt> displays the dependency information on
4102 <tt>stdout</tt> instead of writing it to
4103 <tt>debian/substvars</tt>, and the lines have been wrapped
4104 for ease of reading):
4105 <example compact="compact">
4106 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4107 dpkg-shlibdeps: warning: unable to find dependency
4108 information for shared library libbar (soname 1,
4109 path /usr/lib/libbar.so.1, dependency field Depends)
4110 shlibs:Depends=libc6 (>= 2.2.2-2)
4112 You can then run <prgn>ldd</prgn> on the binary to find the
4113 full location of the library concerned:
4114 <example compact="compact">
4116 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4117 libc.so.6 => /lib/libc.so.6 (0x40032000)
4118 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4120 So the <prgn>foo</prgn> binary depends on the
4121 <prgn>libbar</prgn> shared library, but no package seems to
4122 provide a <tt>*.shlibs</tt> file handling
4123 <tt>libbar.so.1</tt> in <tt>/var/lib/dpkg/info/</tt>. Let's
4124 determine the package responsible:
4125 <example compact="compact">
4126 $ dpkg -S /usr/lib/libbar.so.1
4127 bar1: /usr/lib/libbar.so.1
4128 $ dpkg -s bar1 | grep Version
4131 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4132 is the one we are using. Now we can file a bug against the
4133 <tt>bar1</tt> package and create our own
4134 <tt>debian/shlibs.local</tt> to locally fix the problem.
4135 Including the following line into your
4136 <tt>debian/shlibs.local</tt> file:
4137 <example compact="compact">
4138 libbar 1 bar1 (>= 1.0-1)
4140 should allow the package build to work.
4144 As soon as the maintainer of <tt>bar1</tt> provides a
4145 correct <tt>shlibs</tt> file, you should remove this line
4146 from your <tt>debian/shlibs.local</tt> file. (You should
4147 probably also then have a versioned <tt>Build-Depends</tt>
4148 on <tt>bar1</tt> to help ensure that others do not have the
4149 same problem building your package.)
4154 <chapt><heading>The Operating System</heading>
4157 <heading>File system hierarchy</heading>
4161 <heading>Linux File system Structure</heading>
4164 The location of all installed files and directories must
4165 comply with the Linux File system Hierarchy Standard
4166 (FHS). The latest version of this document can be found
4167 alongside this manual or on
4168 <url id="http://www.pathname.com/fhs/">.
4169 Specific questions about following the standard may be
4170 asked on <prgn>debian-devel</prgn>, or referred to Daniel
4171 Quinlan, the FHS coordinator, at
4172 <email>quinlan@pathname.com</email>.</p></sect1>
4176 <heading>Site-specific programs</heading>
4179 As mandated by the FHS, packages must not place any
4180 files in <tt>/usr/local</tt>, either by putting them in
4181 the file system archive to be unpacked by <prgn>dpkg</prgn>
4182 or by manipulating them in their maintainer scripts.</p>
4185 However, the package may create empty directories below
4186 <tt>/usr/local</tt> so that the system administrator knows
4187 where to place site-specific files. These directories
4188 should be removed on package removal if they are
4192 Note, that this applies only to directories <em>below</em>
4193 <tt>/usr/local</tt>, not <em>in</em>
4194 <tt>/usr/local</tt>. Packages must not create sub-directories
4195 in the directory <tt>/usr/local</tt> itself, except those listed in
4196 FHS, section 4.5. However, you may create directories
4197 below them as you wish. You must not remove any of the
4198 directories listed in 4.5, even if you created them.</p>
4201 Since <tt>/usr/local</tt> can be mounted read-only from a
4202 remote server, these directories must be created and
4203 removed by the <tt>postinst</tt> and <tt>prerm</tt>
4204 maintainer scripts. These scripts must not fail if either
4205 of these operations fail. (In the future, it will be
4206 possible to tell <prgn>dpkg</prgn> not to unpack files
4207 matching certain patterns, so that the directories can be
4208 included in the <tt>.deb</tt> packages and system
4209 administrators who do not wish these directories in
4210 /usr/local do not need to have them.)</p>
4213 For example, the <prgn>emacs</prgn> package will contain
4214 <example compact="compact">
4215 mkdir -p /usr/local/lib/emacs/site-lisp || true
4217 in the <tt>postinst</tt> script, and
4218 <example compact="compact">
4219 rmdir /usr/local/lib/emacs/site-lisp || true
4220 rmdir /usr/local/lib/emacs || true
4222 in the <tt>prerm</tt> script.</p>
4225 If you do create a directory in <tt>/usr/local</tt> for
4226 local additions to a package, you should ensure that
4227 settings in <tt>/usr/local</tt> take precedence over the
4228 equivalents in <tt>/usr</tt>.</p>
4231 However, because '/usr/local' and its contents are for
4232 exclusive use of the local administrator, a package must
4233 not rely on the presence or absence of files or
4234 directories in '/usr/local' for normal operation.</p>
4237 The <tt>/usr/local</tt> directory itself and all the
4238 subdirectories created by the package should (by default) have
4239 permissions 2775 (group-writable and set-group-id) and be
4240 owned by <tt>root.staff</tt>.</p>
4243 <heading>The system-wide mail directory</heading>
4245 The system-wide mail directory is <tt>/var/mail</tt>. This
4246 directory is part of the base system and should not owned
4247 by any particular mail agents. The use of the old
4248 location <tt>/var/spool/mail</tt> is deprecated, even
4249 though the spool may still be physically located there.
4250 To maintain partial upgrade compatibility for systems
4251 which have <tt>/var/spool/mail</tt> as their physical mail
4252 spool, packages using <tt>/var/mail</tt> must depend on
4253 either <package>libc6</package> (>= 2.1.3-13), or on
4254 <package>base-files</package> (>= 2.2.0), or on later
4255 versions of either one of these packages.
4264 <heading>Users and groups</heading>
4267 The Debian system can be configured to use either plain or
4268 shadow passwords.</p>
4271 Some user ids (UIDs) and group ids (GIDs) are reserved
4272 globally for use by certain packages. Because some packages
4273 need to include files which are owned by these users or
4274 groups, or need the ids compiled into binaries, these ids
4275 must be used on any Debian system only for the purpose for
4276 which they are allocated. This is a serious restriction, and
4277 we should avoid getting in the way of local administration
4278 policies. In particular, many sites allocate users and/or
4279 local system groups starting at 100.</p>
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.</p>
4287 Packages other than <tt>base-passwd</tt> must not modify
4288 <tt>/etc/passwd</tt>, <tt>/etc/shadow</tt>,
4289 <tt>/etc/group</tt> or <tt>/etc/gshadow</tt>.</p>
4292 The UID and GID ranges are as follows:
4297 Globally allocated by the Debian project, the
4298 same on every Debian system. These ids will appear in
4299 the <tt>passwd</tt> and <tt>group</tt> files of all
4300 Debian systems, new ids in this range being added
4301 automatically as the <tt>base-passwd</tt> package is
4305 Packages which need a single statically allocated uid
4306 or gid should use one of these; their maintainers
4307 should ask the <tt>base-passwd</tt> maintainer for
4314 Dynamically allocated system users and groups.
4315 Packages which need a user or group, but can have this
4316 user or group allocated dynamically and differently on
4317 each system, should use `<tt>adduser --system</tt>' to
4318 create the group and/or user. <prgn>adduser</prgn>
4319 will check for the existence of the user or group, and
4320 if necessary choose an unused id based on the ranges
4321 specified in <tt>adduser.conf</tt>.</p></item>
4324 <tag>1000-29999:</tag>
4327 Dynamically allocated user accounts. By default
4328 <prgn>adduser</prgn> will choose UIDs and GIDs for
4329 user accounts in this range, though
4330 <tt>adduser.conf</tt> may be used to modify this
4334 <tag>30000-59999:</tag>
4336 <p>Reserved.</p></item>
4339 <tag>60000-64999:</tag>
4342 Globally allocated by the Debian project, but only
4343 created on demand. The ids are allocated centrally and
4344 statically, but the actual accounts are only created
4345 on users' systems on demand.</p>
4348 These ids are for packages which are obscure or which
4349 require many statically-allocated ids. These packages
4350 should check for and create the accounts in
4351 <tt>/etc/passwd</tt> or <tt>/etc/group</tt> (using
4352 <prgn>adduser</prgn> if it has this facility) if
4353 necessary. Packages which are likely to require
4354 further allocations should have a `hole' left after
4355 them in the allocation, to give them room to
4359 <tag>65000-65533:</tag>
4361 <p>Reserved.</p></item>
4366 <p>User `<tt>nobody</tt>.' The corresponding gid refers
4367 to the group `<tt>nogroup</tt>.'</p></item>
4373 <tt>(uid_t)(-1) == (gid_t)(-1)</tt>. NOT TO BE USED,
4374 because it is the error return sentinel value.</p>
4379 <sect id="sysvinit">
4380 <heading>System run levels</heading>
4383 <sect1 id="/etc/init.d">
4384 <heading>Introduction</heading>
4387 The <tt>/etc/init.d</tt> directory contains the scripts
4388 executed by <prgn>init</prgn> at boot time and when init
4389 state (or `runlevel') is changed (see <manref name="init"
4393 There are at least two different, yet functionally
4394 equivalent, ways of handling these scripts. For the sake
4395 of simplicity, this document describes only the symbolic
4396 link method. However, it must not be assumed by maintainer
4397 scripts that this method is being used, and any automated
4398 manipulation of the various runlevel behaviours by
4399 maintainer scripts must be performed using `update-rc.d'
4400 as described below and not by manually installing or
4401 removing symlinks. For information on the
4402 implementation details of the other method, implemented in
4403 the <tt>file-rc</tt> package, please refer to the
4404 documentation of that package.</p>
4407 These scripts are referenced by symbolic links in
4408 the <tt>/etc/rc<var>n</var>.d</tt> directories. When
4409 changing runlevels, <prgn>init</prgn> looks in the
4410 directory <tt>/etc/rc<var>n</var>.d</tt> for the scripts
4411 it should execute, where <var>n</var> is the runlevel that
4412 is being changed to, or `S' for the boot-up scripts.</p>
4415 The names of the links all have the form
4416 <tt>S<var>mm</var><var>script</var></tt> or
4417 <tt>K<var>mm</var><var>script</var></tt> where
4418 <var>mm</var> is a two-digit number and <var>script</var>
4419 is the name of the script (this should be the same as the
4420 name of the actual script in <tt>/etc/init.d</tt>.</p>
4423 When <prgn>init</prgn> changes runlevel first the targets
4424 of the links whose names starting with a <tt>K</tt> are
4425 executed, each with the single argument <tt>stop</tt>,
4426 followed by the scripts prefixed with an <tt>S</tt>, each
4427 with the single argument <tt>start</tt>. The <tt>K</tt>
4428 links are responsible for killing services and the
4429 <tt>S</tt> link for starting services upon entering the
4433 For example, if we are changing from runlevel 2 to
4434 runlevel 3, init will first execute all of the <tt>K</tt>
4435 prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
4436 all of the <tt>S</tt> prefixed scripts. The links
4437 starting with <tt>K</tt> will cause the referred-to file
4438 to be executed with an argument of <tt>stop</tt>, and the
4439 <tt>S</tt> links with an argument of <tt>start</tt>.</p>
4442 The two-digit number <var>mm</var> is used to decide which
4443 order to start and stop things in: low-numbered links have
4444 their scripts run first. For example, the <tt>K20</tt>
4445 scripts will be executed before the <tt>K30</tt> scripts.
4446 This is used when a certain service must be started before
4447 another. For example, the name server <prgn>bind</prgn>
4448 might need to be started before the news server
4449 <prgn>inn</prgn> so that <prgn>inn</prgn> can set up its
4450 access lists. In this case, the script that starts
4451 <prgn>bind</prgn> would have a lower number than the
4452 script that starts <prgn>inn</prgn> so that it runs first:
4453 <example compact="compact">
4461 <heading>Writing the scripts</heading>
4464 Packages that include daemons for system services should
4465 place scripts in <tt>/etc/init.d</tt> to start or stop
4466 services at boot time or during a change of runlevel.
4467 These scripts should be named
4468 <tt>/etc/init.d/<var>package</var></tt>, and they should
4469 accept one argument, saying what to do:
4472 <tag><tt>start</tt></tag>
4473 <item><p>start the service,</p></item>
4475 <tag><tt>stop</tt></tag>
4476 <item><p>stop the service,</p></item>
4478 <tag><tt>restart</tt></tag>
4479 <item><p>stop and restart the service,</p></item>
4481 <tag><tt>reload</tt></tag>
4482 <item><p>cause the configuration of the service to be
4483 reloaded without actually stopping and restarting
4484 the service,</p></item>
4486 <tag><tt>force-reload</tt></tag> <item><p>cause the
4487 configuration to be reloaded if the service supports
4488 this, otherwise restart the service.</p></item>
4491 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4492 <tt>force-reload</tt> options should be supported by all
4493 scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
4494 option is optional.</p>
4497 The <tt>init.d</tt> scripts should ensure that they will
4498 behave sensibly if invoked with <tt>start</tt> when the
4499 service is already running, or with <tt>stop</tt> when it
4500 isn't, and that they don't kill unfortunately-named user
4501 processes. The best way to achieve this is usually to use
4502 <prgn>start-stop-daemon</prgn>.</p>
4505 If a service reloads its configuration automatically (as
4506 in the case of <prgn>cron</prgn>, for example), the
4507 <tt>reload</tt> option of the <tt>init.d</tt> script
4508 should behave as if the configuration has been reloaded
4512 These scripts should not fail obscurely when the
4513 configuration files remain but the package has been
4514 removed, as configuration files remain on the system after
4515 the package has been removed. Only when <prgn>dpkg</prgn>
4516 is executed with the <tt>--purge</tt> option will
4517 configuration files be removed. In particular, the init
4518 script itself is usually a configuration file (see
4519 <ref id="init.d notes">), and will remain on the system if
4520 the package is removed but not purged. Therefore, you
4521 should include a <tt>test</tt> statement at the top of the
4523 <example compact="compact">
4524 test -f <var>program-executed-later-in-script</var> || exit 0
4528 Often there are some values in the `<tt>init.d</tt>'
4529 scripts that a system administrator will frequently want
4530 to change. While the scripts are frequently conffiles,
4531 modifying them requires that the administrator merge in
4532 their changes each time the package is upgraded and the
4533 conffile changes. To ease the burden on the system
4534 administrator, such configurable values should not be
4535 placed directly in the script. Instead, they should be
4536 placed in a file in `<tt>/etc/default</tt>', which
4537 typically will have the same base name as the
4538 `<tt>init.d</tt>' script. This extra file can be sourced
4539 by the script when the script runs. It must contain only
4540 variable settings and comments.
4544 To ensure that vital configurable values are always
4545 available, the `<tt>init.d</tt>' script should set default
4546 values for each of the shell variables it uses before
4547 sourcing the <tt>/etc/default/</tt> file. Also, since the
4548 `<tt>/etc/default/</tt>' file is often a conffile, the
4549 `<tt>init.d</tt>' script must behave sensibly without
4550 failing if it is deleted.
4556 <heading>Managing the links</heading>
4559 The program <prgn>update-rc.d</prgn> is provided to make
4560 it easier for package maintainers to arrange for the
4561 proper creation and removal of
4562 <tt>/etc/rc<var>n</var>.d</tt> symbolic links, or their
4563 functional equivalent if another method is being used.
4564 This may be used by maintainers in their packages'
4565 <tt>postinst</tt> and <tt>postrm</tt> scripts.</p>
4568 You must use this script to make changes to
4569 <tt>/etc/rc<var>n</var>.d</tt> and <em>never</em> either
4570 include any <tt>/etc/rc<var>n</var>.d</tt> symbolic links
4571 in the actual archive or manually create or remove the
4572 symbolic links in maintainer scripts. (The latter will
4573 fail if an alternative method of maintaining runlevel
4574 information is being used.)</p>
4577 By default <prgn>update-rc.d</prgn> will start services in
4578 each of the multi-user state runlevels (2, 3, 4, and 5)
4579 and stop them in the halt runlevel (0), the single-user
4580 runlevel (1) and the reboot runlevel (6). The system
4581 administrator will have the opportunity to customize
4582 runlevels by either running <prgn>update-rc.d</prgn>, by
4583 simply adding, moving, or removing the symbolic links in
4584 <tt>/etc/rc<var>n</var>.d</tt> if symbolic links are being
4585 used, or by modifying <tt>/etc/runlevel.conf</tt> if the
4586 <tt>file-rc</tt> method is being used.</p>
4589 To get the default behavior for your package, put in your
4590 <tt>postinst</tt> script
4591 <example compact="compact">
4592 update-rc.d <var>package</var> defaults >/dev/null
4594 and in your <tt>postrm</tt>
4595 <example compact="compact">
4596 if [ purge = "$1" ]; then
4597 update-rc.d <var>package</var> remove >/dev/null
4602 This will use a default sequence number of 20. If it does
4603 not matter when or in which order the script is run, use
4604 this default. If it does, then you should talk to the
4605 maintainer of the <prgn>sysvinit</prgn> package or post to
4606 <tt>debian-devel</tt>, and they will help you choose a
4610 For more information about using <tt>update-rc.d</tt>,
4611 please consult its manpage <manref name="update-rc.d"
4612 section="8">.</p></sect1>
4616 <heading>Boot-time initialization</heading>
4619 There used to be another directory, <tt>/etc/rc.boot</tt>,
4620 which contained scripts which were run once per machine
4621 boot. This has been deprecated in favour of links from
4622 <tt>/etc/rcS.d</tt> to files in <tt>/etc/init.d</tt> as
4623 described in <ref id="/etc/init.d">. Packages must not
4624 place files in <tt>/etc/rc.boot</tt>.</p>
4626 <sect1 id="init.d notes">
4627 <heading>Notes</heading>
4630 <em>Do not</em> include the
4631 <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in the
4632 <tt>.deb</tt> file system archive! <em>This will cause
4633 problems!</em> You must create them with
4634 <prgn>update-rc.d</prgn>, as above.</p>
4637 <em>Do not</em> include the
4638 <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in
4639 <prgn>dpkg</prgn>'s conffiles list! <em>This will cause
4640 problems!</em> You should, however, treat the
4641 <tt>/etc/init.d</tt> scripts as configuration files,
4642 either by marking them as conffiles or managing them
4643 correctly in the maintainer scripts (see
4644 <ref id="config files">). (This is important since we want
4645 to give the local system administrator the chance to adapt
4646 the scripts to the local system, e.g., to disable a
4647 service without de-installing the package, or to specify
4648 some special command line options when starting a
4649 service, while making sure her changes aren't lost during
4650 the next package upgrade.)</p>
4654 <heading>Example</heading>
4657 The <prgn>bind</prgn> DNS (nameserver) package wants to
4658 make sure that the nameserver is running in multiuser
4659 runlevels, and is properly shut down with the system. It
4660 puts a script in <tt>/etc/init.d</tt>, naming the script
4661 appropriately <tt>bind</tt>. As you can see, the script
4662 interprets the argument <tt>reload</tt> to send the
4663 nameserver a <tt>HUP</tt> signal (causing it to reload its
4664 configuration); this way the user can say
4665 <tt>/etc/init.d/bind reload</tt> to reload the name
4666 server. The script has one configurable value, which can
4667 be used to pass parameters to the named program at
4672 <example compact="compact">
4675 # Original version by Robert Leslie
4676 # <rob@mars.org>, edited by iwj and cs
4678 test -x /usr/sbin/named || exit 0
4680 # Source defaults file.
4682 if [ -f /etc/default/bind ]; then
4689 echo -n "Starting domain name service: named"
4690 start-stop-daemon --start --quiet --exec /usr/sbin/named \
4695 echo -n "Stopping domain name service: named"
4696 start-stop-daemon --stop --quiet \
4697 --pidfile /var/run/named.pid --exec /usr/sbin/named
4701 echo -n "Restarting domain name service: named"
4702 start-stop-daemon --stop --quiet \
4703 --pidfile /var/run/named.pid --exec /usr/sbin/named
4704 start-stop-daemon --start --verbose --exec /usr/sbin/named \
4708 force-reload|reload)
4709 echo -n "Reloading configuration of domain name service: named"
4710 start-stop-daemon --stop --signal 1 --quiet \
4711 --pidfile /var/run/named.pid --exec /usr/sbin/named
4715 echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
4725 Complementing the above init script is a file
4726 '<tt>/etc/default/bind</tt>', which contains configurable
4727 parameters used by the script.
4730 <example compact="compact">
4731 # Specified parameters to pass to named. See named(8).
4732 # You may uncomment the following line, and edit to taste.
4738 Another example on which to base your <tt>/etc/init.d</tt>
4739 scripts is in <tt>/etc/init.d/skeleton</tt>.</p>
4742 If this package is happy with the default setup from
4743 <prgn>update-rc.d</prgn>, namely an ordering number of 20
4744 and having named running in all runlevels, it can say in
4745 its <tt>postinst</tt>:
4746 <example compact="compact">
4747 update-rc.d bind defaults >/dev/null
4749 And in its <tt>postrm</tt>, to remove the links when the
4751 <example compact="compact">
4752 if [ purge = "$1" ]; then
4753 update-rc.d bind remove >/dev/null
4759 <heading>Cron jobs</heading>
4762 Packages must not modify the configuration file
4763 <tt>/etc/crontab</tt>, and they must not modify the files in
4764 <tt>/var/spool/cron/crontabs</tt>.</p>
4767 If a package wants to install a job that has to be executed
4768 via cron, it should place a file with the name of the
4769 package in one of the following directories:
4770 <example compact="compact">
4775 As these directory names imply, the files within them are
4776 executed on a daily, weekly, or monthly basis,
4777 respectively. The exact times are listed in
4778 <tt>/etc/crontab</tt>.</p>
4781 All files installed in any of these directories must be
4782 scripts (shell scripts, Perl scripts, etc.) so that they can
4783 easily be modified by the local system administrator. In
4784 addition, they should be treated as configuration files.</p>
4787 If a certain job has to be executed more frequently than
4788 daily, the package should install a file
4789 <tt>/etc/cron.d/<var>package</var></tt>. This file uses
4790 the same syntax as <tt>/etc/crontab</tt> and is processed by
4791 <prgn>cron</prgn> automatically. The file must also be
4792 treated as a configuration file. (Note, that entries in the
4793 <tt>/etc/cron.d</tt> directory are not handled by
4794 <prgn>anacron</prgn>. Thus, you should only use this
4795 directory for jobs which may be skipped if the system is not
4799 The scripts or crontab entries in these directories should
4800 check if all necessary programs are installed before they
4801 try to execute them. Otherwise, problems will arise when a
4802 package was removed but not purged since configuration files
4803 are kept on the system in this situation.</p>
4807 <heading>Console messages</heading>
4810 This section describes different formats 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.</p>
4816 Please look very careful at the details. We want to get the
4817 messages to look exactly the same way concerning spaces,
4818 punctuation, and case of letters.</p>
4821 Here is a list of overall rules that you should use when you
4822 create output messages. They can be useful if you have a
4823 non-standard message that isn't covered in the sections
4830 Every message should cover one line, start with a
4831 capital letter and end with a period `.'.</p></item>
4836 If you want to express that the computer is working on
4837 something (performing a specific task, not starting or
4838 stopping a program), we use an ``ellipsis'', namely
4839 three dots `...'. Note that we don't insert spaces in
4840 front of or behind the dots. If the task has been
4841 completed we write `done.' and a line feed.</p></item>
4846 Design your messages as if the computer is telling you
4847 what he is doing (let him be polite :-) but don't
4848 mention ``him'' directly. For example, if you think
4850 <example compact="compact">
4851 I'm starting network daemons: nfsd mountd.
4854 <example compact="compact">
4855 Starting network daemons: nfsd mountd.
4863 The following formats should be used</p>
4868 <p>when daemons get started.</p>
4871 Use this format if your script starts one or more
4872 daemons. The output should look like this (a single
4873 line, no leading spaces):
4874 <example compact="compact">
4875 Starting <description>: <daemon-1> ... <daemon-n>.
4877 The <description> should describe the subsystem
4878 the daemon or set of daemons are part of, while
4879 <daemon-1> up to <daemon-n> denote each
4880 daemon's name (typically the file name of the
4884 For example, the output of /etc/init.d/lpd would look like:
4885 <example compact="compact">
4886 Starting printer spooler: lpd.
4890 This can be achieved by saying
4891 <example compact="compact">
4892 echo -n "Starting printer spooler: lpd"
4893 start-stop-daemon --start --quiet lpd
4896 in the script. If you have more than one daemon to
4897 start, you should do the following:
4898 <example compact="compact">
4899 echo -n "Starting remote file system services:"
4900 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
4901 echo -n " mountd"; start-stop-daemon --start --quiet mountd
4902 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
4905 This makes it possible for the user to see what takes
4906 so long and when the final daemon has been
4907 started. You should be careful where to put spaces: In the
4908 example above the system administrator can easily
4909 comment out a line if he don't wants to start a
4910 specific daemon, while the displayed message still
4916 <p>when something needs to be configured.</p>
4919 If you have to set up different parameters of the
4920 system upon boot up, you should use this format:
4921 <example compact="compact">
4922 Setting <parameter> to `<value>'.
4927 You can use the following echo statement to get the quotes right:
4928 <example compact="compact">
4929 echo "Setting DNS domainname to \`"value"'."
4934 Note that the left quotation mark (`) is different
4940 <p>when a daemon is stopped.</p>
4943 When you stop a daemon you should issue a message
4944 similar to the startup message, except that `Starting'
4945 is replaced with `Stopping'.</p>
4948 So stopping the printer daemon will like like this:
4949 <example compact="compact">
4950 Stopping printer spooler: lpd.
4951 </example></p></item>
4954 <p>when something is executed.</p>
4957 There are several examples where you have to run a
4958 program at system startup or shutdown to perform a
4959 specific task. For example, setting the system's clock
4960 via `netdate' or killing all processes when the system
4961 comes down. Your message should like this:
4962 <example compact="compact">
4963 Doing something very useful...done.
4965 You should print the `done.' right after the job has been completed,
4966 so that the user gets informed why he has to wait. You can get this
4968 <example compact="compact">
4969 echo -n "Doing something very useful..."
4978 <p>when the configuration is reloaded.</p>
4981 When a daemon is forced to reload its configuration
4982 files you should use the following format:
4983 <example compact="compact">
4984 Reloading <daemon's-name> configuration...done.
4990 <p>when none of the above rules apply.</p>
4993 If you have to print a message that doesn't fit into
4994 the styles described above, you can use something
4995 appropriate, but please have a look at the overall
5004 <heading>Menus</heading>
5007 Menu entries should follow the current menu policy as
5008 defined in the file <ftpsite>ftp.debian.org</ftpsite> in
5009 <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>
5010 or your local mirror. In addition, it is included in the
5011 <tt>debian-policy</tt> package.
5015 The Debian <tt>menu</tt> packages provides a unique
5016 interface between packages providing applications and
5017 documents, and <em>menu programs</em> (either X window
5018 managers or text-based menu programs as
5019 <prgn>pdmenu</prgn>).</p>
5022 All packages that provide applications that need not be
5023 passed any special command line arguments for normal
5024 operation should register a menu entry for those
5025 applications, so that users of the <tt>menu</tt> package
5026 will automatically get menu entries in their window
5027 managers, as well in shells like <tt>pdmenu</tt>.</p>
5030 Please refer to the <em>Debian Menu System</em> document
5031 that comes with the <tt>menu</tt> package for information
5032 about how to register your applications and web
5038 <heading>Multimedia handlers</heading>
5041 Packages which provide the ability to view/show/play,
5042 compose, edit or print MIME types should register themselves
5043 as such following the current MIME support policy as defined
5044 in the file found on <ftpsite>ftp.debian.org</ftpsite> in
5045 <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>
5046 or your local mirror. In addition, it is included in the
5047 <tt>debian-policy</tt> package.
5051 MIME (Multipurpose Internet Mail Extensions, RFC 1521) is a
5052 mechanism for encoding files and data streams and providing
5053 meta-information about them, in particular their type (e.g.
5054 audio or video) and format (e.g. PNG, HTML, MP3).
5058 Registration of MIME type handlers allows programs like mail
5059 user agents and web browsers to to invoke these handlers to
5060 view, edit or display MIME types they don't support
5066 <heading>Keyboard configuration</heading>
5069 To achieve a consistent keyboard configuration (i.e., all
5070 applications interpret a keyboard event the same way) all
5071 programs in the Debian distribution must be configured to
5072 comply with the following guidelines.</p>
5075 Here is a list that contains certain keys and their interpretation:
5078 <tag><tt><--</tt></tag>
5079 <item><p>delete the character to the left of the cursor</p></item>
5081 <tag><tt>Delete</tt></tag>
5082 <item><p>delete the character to the right of the cursor</p></item>
5084 <tag><tt>Control+H</tt></tag>
5085 <item><p>emacs: the help prefix</p></item>
5088 The interpretation of any keyboard events should be independent
5089 of the terminal that's used, be it a virtual console, an X
5090 terminal emulator, an rlogin/telnet session, etc.</p>
5093 The following list explains how the different programs
5094 should be set up to achieve this:</p>
5098 <item><p>`<tt><--</tt>' generates KB_Backspace in
5101 <item><p>`<tt>Delete</tt>' generates KB_Delete in X.</p></item>
5105 X translations are set up to make KB_Backspace
5106 generate ASCII DEL, and to make KB_Delete generate
5107 <tt>ESC [ 3 ~</tt> (this is the vt220 escape code for
5108 the `delete character' key). This must be done by
5109 loading the resources using xrdb on all local X
5110 displays, not using the application defaults, so that
5111 the translation resources used correspond to the
5112 xmodmap settings.</p></item>
5116 The Linux console is configured to make
5117 `<tt><--</tt>' generate DEL, and `Delete' generate
5118 <tt>ESC [ 3 ~</tt> (this is the case at the
5122 X applications are configured so that Backspace
5123 deletes left, and Delete deletes right. Motif
5124 applications already work like this.</p></item>
5126 <item><p>stty erase <tt>^?</tt> .</p></item>
5129 The `xterm' terminfo entry should have <tt>ESC [ 3
5130 ~</tt> for kdch1, just like TERM=linux and
5131 TERM=vt220.</p></item>
5134 Emacs is programmed to map KB_Backspace or the `stty
5135 erase' character to delete-backward-char, and
5136 KB_Delete or kdch1 to delete-forward-char, and
5137 <tt>^H</tt> to help as always.</p></item>
5140 Other applications use the `stty erase' character and
5141 kdch1 for the two delete keys, with ASCII DEL being
5142 `delete previous character' and kdch1 being `delete
5143 character under cursor'.</p></item>
5147 This will solve the problem except for:</p>
5152 Some terminals have a <tt><--</tt> key that cannot
5153 be made to produce anything except <tt>^H</tt>. On
5154 these terminals Emacs help will be unavailable on
5155 <tt>^H</tt> (assuming that the `stty erase' character
5156 takes precedence in Emacs, and has been set
5157 correctly). M-x help or F1 (if available) can be used
5161 Some operating systems use <tt>^H</tt> for stty erase.
5162 However, modern telnet versions and all rlogin
5163 versions propagate stty settings, and almost all UNIX
5164 versions honour stty erase. Where the stty settings
5165 are not propagated correctly things can be made to
5166 work by using stty manually.</p></item>
5169 Some systems (including previous Debian versions) use
5170 xmodmap to arrange for both <tt><--</tt> and Delete
5171 to generate KB_Delete. We can change the behavior
5172 of their X clients via the same X resources that we
5173 use to do it for our own, or have our clients be
5174 configured via their resources when things are the
5175 other way around. On displays configured like this
5176 Delete will not work, but <tt><--</tt>
5180 Some operating systems have different kdch1 settings
5181 in their terminfo for xterm and others. On these
5182 systems the Delete key will not work correctly when
5183 you log in from a system conforming to our policy, but
5184 <tt><--</tt> will.</p></item>
5191 <heading>Environment variables</heading>
5194 A program must not depend on environment variables to get
5195 reasonable defaults. (That's because these environment
5196 variables would have to be set in a system-wide
5197 configuration file like /etc/profile, which is not supported
5201 If a program usually depends on environment variables for its
5202 configuration, the program should be changed to fall back to
5203 a reasonable default configuration if these environment
5204 variables are not present. If this cannot be done easily
5205 (e.g., if the source code of a non-free program is not
5206 available), the program must be replaced by a small
5207 `wrapper' shell script which sets the environment variables
5208 if they are not already defined, and calls the original program.</p>
5211 Here is an example of a wrapper script for this purpose:
5213 <example compact="compact">
5215 BAR=${BAR:-/var/lib/fubar}
5217 exec /usr/lib/foo/foo "$@"
5221 Furthermore, as <tt>/etc/profile</tt> is a configuration
5222 file of the <prgn>base-files</prgn> package, other packages must not
5223 put any environment variables or other commands into that
5228 <heading>Files</heading>
5232 <heading>Binaries</heading>
5235 Two different packages must not install programs with
5236 different functionality but with the same filenames. (The
5237 case of two programs having the same functionality but
5238 different implementations is handled via `alternatives.')
5239 If this case happens, one of the programs must be
5240 renamed. The maintainers should report this to the
5241 developers' mailing and try to find a consensus about
5242 which package will have to be renamed. If a consensus can
5243 not be reached, <em>both</em> programs must be
5247 Generally the following compilation parameters should be used:
5248 <example compact="compact">
5250 CFLAGS = -O2 -Wall # sane warning options vary between programs
5252 install -s # (or use strip on the files in debian/tmp)
5256 Note that by default all installed binaries should be stripped,
5257 either by using the <tt>-s</tt> flag to
5258 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5259 the binaries after they have been copied into
5260 <tt>debian/tmp</tt> but before the tree is made into a
5264 The <tt>-N</tt> flag should not be used. On a.out systems
5265 it may have been useful for some very small binaries, but
5266 for ELF it has no good effect.</p>
5269 Debugging symbols are useful for error diagnosis,
5270 investigation of core dumps (which may be submitted by users
5271 in bug reports), or testing and developing the
5272 software. Therefore it is recommended to support building
5273 the package with debugging information through the following
5274 interface: If the environment variable
5275 <tt>DEB_BUILD_OPTIONS</tt> contains the string
5276 <tt>debug</tt>, compile the software with debugging
5277 information (usually this involves adding the <tt>-g</tt>
5278 flag to <tt>CFLAGS</tt>). This allows the generation of a
5279 build tree with debugging information. If the environment
5280 variable <tt>DEB_BUILD_OPTIONS</tt> contains the string
5281 <tt>nostrip</tt>, do not strip the files at installation
5282 time. This allows one to generate a package with debugging
5283 information included. The following makefile snippet is only
5284 an example of how one may test for either condition:
5287 Rationale: Building by default with -g causes more
5288 wasted CPU cycles since the information is stripped away
5289 anyway. The package can by default build without -g if
5290 it also provides a mechanism to easily be rebuilt with
5291 debugging information. This can be done by providing a
5292 "build-debug" make target, or allowing the user to
5293 specify "DEB_BUILD_OPTIONS=debug" in the environment while
5294 compiling that package.
5296 <p>Now this has several added benefits:
5297 <list compact="compact">
5300 It is actually easier to build debugging bins and
5301 libraries this way (no more editing debian/rules
5302 or similar) since it provides a documented way of
5303 getting this type of build.</p>
5307 There will be much less wasted CPU time for the
5308 autobuilders since not having debugging
5309 information (and hence also not having to strip
5310 it) will increase the speed of compiles. This
5311 skips an entire pass of the compiler.
5319 <example compact="compact">
5322 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5323 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5324 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5325 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5327 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
5330 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5331 INSTALL_PROGRAM += -s
5335 Please note that the above example is merely informative,
5336 and is not a policy mandate. You may have to massage this
5337 example in order to make it work for your package.
5342 It is up to the package maintainer to decide what
5343 compilation options are best for the package. Certain
5344 binaries (such as computationally-intensive programs) will
5345 function better with certain flags (<tt>-O3</tt>, for
5346 example); feel free to use them. Please use good judgment
5347 here. Don't use flags for the sake of it; only use them
5348 if there is good reason to do so. Feel free to override
5349 the upstream author's ideas about which compilation
5350 options are best: they are often inappropriate for our
5351 environment.</p></sect>
5355 <heading>Libraries</heading>
5358 All libraries must have a shared version in the lib
5359 package and a static version in the lib-dev package. The
5360 shared version must be compiled with <tt>-fPIC</tt>, and
5361 the static version must not be. In other words, each
5362 <tt>*.c</tt> file will need to be compiled twice.</p>
5365 You must specify the gcc option <tt>-D_REENTRANT</tt>
5366 when building a library (either static or shared) to make
5367 the library compatible with LinuxThreads.</p>
5370 Note that all installed shared libraries should be
5372 <example compact="compact">
5373 strip --strip-unneeded <your-lib>
5375 (The option <tt>--strip-unneeded</tt> makes
5376 <prgn>strip</prgn> remove only the symbols which aren't
5377 needed for relocation processing.) Shared libraries can
5378 function perfectly well when stripped, since the symbols for
5379 dynamic linking are in a separate part of the ELF object
5383 Note that under some circumstances it may be useful to
5384 install a shared library unstripped, for example when
5385 building a separate package to support debugging.
5389 An ever increasing number of packages are using libtool to
5390 do their linking. The latest GNU libtools (>= 1.3a) can take
5391 advantage of the metadata in the installed libtool archive
5392 files (`*.la'). The main advantage of libtool's .la files is
5393 that it allows libtool to store and subsequently access
5394 metadata with respect to the libraries it builds. libtool
5395 will search for those files, which contain a lot of useful
5396 information about a library (e.g. dependency libraries for
5397 static linking). Also, they're <em>essential</em> for
5398 programs using libltdl.
5402 Certainly libtool is fully capable of linking against shared
5403 libraries which don't have .la files, but being a mere shell
5404 script it can add considerably to the build time of a
5405 libtool using package if that shell-script has to derive all
5406 this information from first principles for each library every
5407 time it is linked. With the advent of libtool-1.4 (and to a
5408 lesser extent libtool-1.3), the .la files will also store
5409 information about inter-library dependencies which cannot
5410 necessarily be derived after the .la file is deleted.
5414 Packages that use libtool to create shared libraries should
5415 include the <em>.la</em> files in the <em>-dev</em>
5416 packages, with the exception that if the package relies on
5417 libtool's <em>libltdl</em> library, in which case the .la
5418 files must go in the run-time library package. This is a
5419 good idea in general, and especially for static linking
5424 You must make sure that you use only released versions of
5425 shared libraries to build your packages; otherwise other
5426 users will not be able to run your binaries
5427 properly. Producing source packages that depend on
5428 unreleased compilers is also usually a bad
5435 <heading>Shared libraries</heading>
5438 Packages involving shared libraries should be split up
5439 into several binary packages.</p>
5442 For a straightforward library which has a development
5443 environment and a runtime kit including just shared
5444 libraries you need to create two packages:
5445 <tt><var>libraryname</var><var>soname</var></tt>
5446 (<var>soname</var> is the shared object name of the shared
5447 library: it's the thing that has to match exactly between
5448 building an executable and running it for the dynamic
5449 linker to be able run the program; usually the
5450 <var>soname</var> is the major number of the library) and
5451 <tt><var>libraryname</var><var>soname</var>-dev</tt>.</p>
5454 If you prefer only to support one development version at a
5455 time you may name the development package
5456 <tt><var>libraryname</var>-dev</tt>; otherwise you may
5457 wish to use <prgn>dpkg</prgn>'s conflicts mechanism to
5458 ensure that the user only installs one development version
5459 at a time (after all, different development versions are
5460 likely to have the same header files in them, causing a
5461 filename clash if both are installed). Typically the
5462 development version should also have an exact version
5463 dependency on the runtime library, to make sure that
5464 compilation and linking happens correctly.</p>
5467 Packages which use the shared library should have a
5468 dependency on the name of the shared library package,
5469 <tt><var>libraryname</var><var>soname</var></tt>. When
5470 the <var>soname</var> changes you can have both versions
5471 of the library installed while moving from the old library
5475 If your package has some run-time support programs which
5476 use the shared library you must not put them in
5477 the shared library package. If you do that then you won't
5478 be able to install several versions of the shared library
5479 without getting filename clashes. Instead, either create
5480 a third package for the runtime binaries (this package
5481 might typically be named
5482 <tt><var>libraryname</var>-runtime</tt>; note the absence
5483 of the <var>soname</var> in the package name) or if the
5484 development package is small include them in there.</p>
5487 If you have several shared libraries built from the same
5488 source tree you may lump them all together into a single
5489 shared library package, provided that you change all their
5490 <var>soname</var>s at once (so that you don't get filename
5491 clashes if you try to install different versions of the
5492 combined shared libraries package).</p>
5495 You should follow the directions in the <em>Debian Packaging
5496 Manual</em> (or other documentation of the Debian
5497 packaging tools) for putting the shared library in its
5498 package, and you must include a <tt>shlibs</tt> control area
5499 file with details of the dependencies for packages which use
5503 Shared libraries should not be installed
5504 executable, since <prgn>ld.so</prgn> does not require this
5505 and trying to execute a shared library results in a core
5510 <heading>Scripts</heading>
5513 All command scripts, including the package maintainer
5514 scripts inside the package and used by <prgn>dpkg</prgn>,
5515 should have a <tt>#!</tt> line naming the shell to be used
5516 to interpret them.</p>
5519 In the case of Perl scripts this should be
5520 <tt>#!/usr/bin/perl</tt>.</p>
5523 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5524 should almost certainly start with <tt>set -e</tt> so that
5525 errors are detected. Every script should use
5526 <tt>set -e</tt> or check the exit status of <em>every</em>
5530 The standard shell interpreter `<tt>/bin/sh</tt>' can be a
5531 symbolic link to any POSIX compatible shell, if <tt>echo
5532 -n</tt> does not generate a newline.
5535 Debian policy specifies POSIX behavior for /bin/sh, but
5536 echo -n has widespread use in the Linux community
5537 (including especially debian policy, the linux kernel
5538 source, many debian scripts, etc.). This echo -n
5539 mechanism is valid but not required under POSIX, hence
5540 this explicit addition. Also, rumour has it that this
5541 shall be mandated under the LSB anyway.
5545 specifying `<tt>/bin/sh</tt>' as interpreter should only
5546 use POSIX features. If a script requires non-POSIX
5547 features from the shell interpreter, the appropriate shell
5548 must be specified in the first line of the script (e.g.,
5549 `<tt>#!/bin/bash</tt>') and the package must depend on the
5550 package providing the shell (unless the shell package is
5551 marked `Essential', e.g., in the case of
5556 You may wish to restrict your script to POSIX features when possible so
5557 that it may use <tt>/bin/sh</tt> as its interpreter. If
5558 your script works with <prgn>ash</prgn>, it's probably
5559 POSIX compliant, but if you are in doubt, use
5560 <tt>/bin/bash</tt>.</p>
5563 Perl scripts should check for errors when making any
5564 system calls, including <tt>open</tt>, <tt>print</tt>,
5565 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.</p>
5568 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided
5569 as scripting languages. See <em>Csh Programming
5570 Considered Harmful</em>, one of the <tt>comp.unix.*</tt>
5571 FAQs. It can be found on
5572 <url id="http://language.perl.com/versus/csh.whynot">, or
5573 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5574 or even on <ftpsite>ftp.cpan.org</ftpsite>
5575 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5576 If an upstream package comes with <prgn>csh</prgn> scripts
5577 then you must make sure that they start with
5578 <tt>#!/bin/csh</tt> and make your package depend on the
5579 <prgn>c-shell</prgn> virtual package.</p>
5582 Any scripts which create files in world-writeable
5583 directories (e.g., in <tt>/tmp</tt>) must use a
5584 mechanism which will fail if a file with the same name
5588 The Debian base distribution provides the
5589 <prgn>tempfile</prgn> and <prgn>mktemp</prgn> utilities
5590 for use by scripts for this purpose.</p></sect>
5594 <heading>Symbolic links</heading>
5597 In general, symbolic links within a top-level directory
5598 should be relative, and symbolic links pointing from one
5599 top-level directory into another should be absolute. (A
5600 top-level directory is a sub-directory of the root
5604 In addition, symbolic links should be specified as short
5605 as possible, i.e., link targets like `foo/../bar' are
5609 Note that when creating a relative link using
5610 <prgn>ln</prgn> it is not necessary for the target of the
5611 link to exist relative to the working directory you're
5612 running <prgn>ln</prgn> from; nor is it necessary to
5613 change directory to the directory where the link is to be
5614 made. Simply include the string that should appear as the
5615 target of the link (this will be a pathname relative to
5616 the directory in which the link resides) as the first
5617 argument to <prgn>ln</prgn>.</p>
5620 For example, in your <prgn>Makefile</prgn> or
5621 <tt>debian/rules</tt>, do things like:
5622 <example compact="compact">
5623 ln -fs gcc $(prefix)/bin/cc
5624 ln -fs gcc debian/tmp/usr/bin/cc
5625 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5626 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5630 A symbolic link pointing to a compressed file should
5631 always have the same file extension as the referenced
5632 file. (For example, if a file `<tt>foo.gz</tt>' is
5633 referenced by a symbolic link, the filename of the link
5634 has to end with `<tt>.gz</tt>' too, as in
5635 `bar.gz.')</p></sect>
5639 <heading>Device files</heading>
5642 Packages must not include device files in the package file
5646 If a package needs any special device files that are not
5647 included in the base system, it must call
5648 <prgn>MAKEDEV</prgn> in the <tt>postinst</tt> script,
5649 after asking the user for permission to do so.</p>
5652 Packages must not remove any device files in the
5653 <tt>postrm</tt> or any other script. This is left to the
5654 system administrator.</p>
5657 Debian uses the serial devices
5658 <tt>/dev/ttyS*</tt>. Programs using the old
5659 <tt>/dev/cu*</tt> devices should be changed to use
5660 <tt>/dev/ttyS*</tt>.</p>
5663 <sect id="config files">
5664 <heading>Configuration files</heading>
5666 <heading>Definitions</heading>
5669 <tag>configuration file</tag>
5671 A file that affects the operation of program, or
5672 provides site- or host-specific information, or
5673 otherwise customizes the behavior of program.
5674 Typically, configuration files are intended to be
5675 modified by the system administrator (if needed or
5676 desired) to conform to local policy or provide more
5677 useful site-specific behavior.</p>
5680 <tag><tt>conffile</tt></tag>
5682 A file listed in a package's <tt>conffiles</tt>
5683 file, and is treated specially by <prgn>dpkg</prgn>
5684 (see the <em>Debian Packaging Manual</em>).</p>
5690 The distinction between these two is important; they are
5691 not interchangeable concepts. Almost all
5692 <tt>conffiles</tt> are configuration files, but many
5693 configuration files are not <tt>conffiles</tt>.</p>
5696 Note that a script that embeds configuration information
5697 (such as most of the files in <tt>/etc/init.d</tt> and
5698 <tt>/etc/cron.{daily,weekly,monthly}</tt>) is de-facto a
5699 configuration file and should be treated as such.</p>
5703 <heading>Location</heading>
5705 Any configuration files created or used by your package
5706 must reside in <tt>/etc</tt>. If there are several you
5707 should consider creating a subdirectory of <tt>/etc</tt>
5708 named after your package.</p>
5711 If your package creates or uses configuration files
5712 outside of <tt>/etc</tt>, and it is not feasible to modify
5713 the package to use the <tt>/etc</tt>, you should still put
5714 the files in <tt>/etc</tt> and create symbolic links to
5715 those files from the location that the package
5720 <heading>Behavior</heading>
5722 Configuration file handling must conform to the following
5724 <list compact="compact">
5726 <p>local changes must be preserved during a package
5730 <p>configuration files must be preserved when the
5731 package is removed, and only deleted when the
5732 package is purged.</p>
5737 The easy way to achieve this behavior is to make the
5738 configuration file a <tt>conffile</tt>. This is
5739 appropriate only if it is possible to distribute a default
5740 version that will work for most installations, although
5741 some system administrators may choose to modify it. This
5742 implies that the default version will be part of the
5743 package distribution, and must not be modified by the
5744 maintainer scripts during installation (or at any other
5749 In order to ensure that local changes are preserved
5750 correctly, no package may contain or make hard links to
5754 Rationale: There are two problems with hard links.
5755 The first is that some editors break the link while
5756 editing one of the files, so that the two files may
5757 unwittingly become different. The second is that
5758 <prgn>dpkg</prgn> might break the hard link while
5759 upgrading <tt>conffile</tt>s.
5765 The other way to do it is via the maintainer scripts.
5766 In this case, the configuration file must not be listed as
5767 a <tt>conffile</tt> and must not be part of the package
5768 distribution. If the existence of a file is required for
5769 the package to be sensibly configured it is the
5770 responsibility of the package maintainer to write scripts
5771 which correctly create, update, maintain and
5772 remove-on-purge the file. These scripts must be idempotent
5773 (i.e., must work correctly if <prgn>dpkg</prgn> needs to
5774 re-run them due to errors during installation or removal),
5775 must cope with all the variety of ways <prgn>dpkg</prgn>
5776 can call maintainer scripts, must not overwrite or
5777 otherwise mangle the user's configuration without asking,
5778 must not ask unnecessary questions (particularly during
5779 upgrades), and otherwise be good citizens.</p>
5782 The scripts are not required to configure every possible option for
5783 the package, but only those necessary to get the package
5784 running on a given system. Ideally the sysadmin should not
5785 have to do any configuration other than that done
5786 (semi-)automatically by the <tt>postinst</tt> script.</p>
5789 A common practice is to create a script called
5790 <tt><var>package</var>-configure</tt> and have the
5791 package's <tt>postinst</tt> call it if and only if the
5792 configuration file does not already exist. In certain
5793 cases it is useful for there to be an example or template
5794 file which the maintainer scripts use. Such files should
5795 be in <tt>/usr/share/<package></tt> or
5796 <tt>/usr/lib/<package></tt> with a symbolic link
5797 from <tt>/usr/share/doc/<package>/examples</tt>
5798 if they are examples, and should be
5799 perfectly ordinary <prgn>dpkg</prgn>-handled files
5800 (<em>not</em> <tt>conffiles</tt>).
5804 These two styles of configuration file handling must
5805 not be mixed, for that way lies madness:
5806 <prgn>dpkg</prgn> will ask about overwriting the file
5807 every time the package is upgraded.</p>
5812 <heading>Sharing configuration files</heading>
5814 Packages which specify the same file as
5815 `<tt>conffile</tt>' must be tagged as <em>conflicting</em>
5820 The maintainer scripts must not alter the conffile of
5821 <em>any</em> package, including the one the scripts belong
5825 If two or more packages use the same configuration file
5826 and it is reasonable for both to be installed at the same
5827 time, one of these packages must be defined as
5828 <em>owner</em> of the configuration file, i.e., it will be
5829 the package to list that distributes the file and lists it
5830 as a <tt>conffile</tt>. Other packages that use the
5831 configuration file must depend on the owning package if
5832 they require the configuration file to operate. If the
5833 other package will use the configuration file if present,
5834 but is capable of operating without it, no dependency need
5838 If it is desirable for two or more related packages to
5839 share a configuration file <em>and</em> for all of the
5840 related packages to be able to modify that configuration
5841 file, then the following should be done:
5845 have one of the related packages (the "core"
5846 package) manage the configuration file with
5847 maintainer scripts as described in the previous
5851 the core package should also provide a program that
5852 the other packages may use to modify the
5853 configuration file.</p>
5857 the related packages must use the provided program
5858 to make any modifications to the configuration file.
5859 They should either depend on the core package to
5860 guarantee that the configuration modifier program is
5861 available or accept gracefully that they cannot
5862 modify the configuration file if it is not.</p>
5867 Sometimes it's appropriate to create a new package which
5868 provides the basic infrastructure for the other packages
5869 and which manages the shared configuration files. (Check
5870 out the <tt>sgml-base</tt> package as an example.)</p>
5874 <heading>User configuration files ("dotfiles")</heading>
5877 Files in <tt>/etc/skel</tt> will automatically be copied
5878 into new user accounts by <prgn>adduser</prgn>. They
5879 should not be referenced there by any program.</p>
5882 Therefore, if a program needs a dotfile to exist in
5883 advance in <tt>$HOME</tt> to work sensibly, that dotfile
5884 should be installed in <tt>/etc/skel</tt> (and listed in
5885 conffiles, if it is not generated and modified dynamically
5886 by the package's installation scripts).</p>
5889 However, programs that require dotfiles in order to
5890 operate sensibly (dotfiles that they do not create
5891 themselves automatically, that is) are a bad thing, and
5892 programs should be configured by the Debian default
5893 installation as close to normal as possible.</p>
5896 Therefore, if a program in a Debian package needs to be
5897 configured in some way in order to operate sensibly that
5898 configuration should be done in a site-wide global
5899 configuration file elsewhere in <tt>/etc</tt>. Only if the
5900 program doesn't support a site-wide default configuration
5901 and the package maintainer doesn't have time to add it
5902 may a default per-user file be placed in
5903 <tt>/etc/skel</tt>.</p>
5906 <tt>/etc/skel</tt> should be as empty as we can make it.
5907 This is particularly true because there is no easy
5908 mechanism for ensuring that the appropriate dotfiles are
5909 copied into the accounts of existing users when a package
5915 <heading>Log files</heading>
5917 The traditional approach to log files has been to set up ad
5918 hoc log rotation schemes using simple shell scripts and
5919 cron. While this approach is highly customizable, it
5920 requires quite a lot of sysadmin work. Even though the
5921 original Debian system helped a little by automatically
5922 installing a system which can be used as a template, this
5923 was deemed not enough.
5927 A better scheme is to use logrotate, a GPL'd program
5928 developed by Red Hat, which centralizes log management. It
5929 has both a configuration file (<tt>/etc/logrotate.conf</tt>)
5930 and a directory where packages can drop logrotation info
5931 (<tt>/etc/logrotate.d</tt>).
5935 Log files should usually be named
5936 <tt>/var/log/<var>package</var>.log</tt>. If you have many
5937 log files, or need a separate directory for permissions
5938 reasons (<tt>/var/log</tt> is writable only by
5939 <tt>root</tt>), you should usually create a directory named
5940 <tt>/var/log/<var>package</var></tt>.</p>
5943 Log files must be rotated occasionally so
5944 that they don't grow indefinitely; the best way to do this
5945 is to drop a script into the directory
5946 <tt>/etc/logrotate.d</tt> and use the facilities provided by
5947 logrotate. Here is a good example for a logrotate config
5948 file (for more information see <manref name="logrotate"
5950 <example compact="compact">
5956 /etc/init.d/foo force-reload
5960 Which rotates all files under `/var/log/foo', saves 12
5961 compressed generations, and sends a HUP signal at the end of
5967 Log files should be removed when the package is
5968 purged (but not when it is only removed), by checking the
5969 argument to the <tt>postrm</tt> script (see the <em>Debian
5970 Packaging Manual</em> for details).</p>
5975 <heading>Permissions and owners</heading>
5978 The rules in this section are guidelines for general use.
5979 If necessary you may deviate from the details below.
5980 However, if you do so you must make sure that what is done
5981 is secure and you should try to be as consistent as possible
5982 with the rest of the system. You should probably also
5983 discuss it on <prgn>debian-devel</prgn> first.</p>
5986 Files should be owned by <tt>root.root</tt>, and made
5987 writable only by the owner and universally readable (and
5988 executable, if appropriate).</p>
5991 Directories should be mode 755 or (for group-writability)
5992 mode 2775. The ownership of the directory should be
5993 consistent with its mode: if a directory is mode 2775, it
5994 should be owned by the group that needs write access to
5998 Setuid and setgid executables should be mode 4755 or 2755
5999 respectively, and owned by the appropriate user or group.
6000 They should not be made unreadable (modes like 4711 or
6001 2711 or even 4111); doing so achieves no extra security,
6002 because anyone can find the binary in the freely available
6003 Debian package, it is merely inconvenient. For the same
6004 reason you should not restrict read or execute permissions
6005 on non-set-id executables.</p>
6008 Some setuid programs need to be restricted to particular
6009 sets of users, using file permissions. In this case they
6010 should be owned by the uid to which they are set-id, and
6011 by the group which should be allowed to execute them.
6012 They should have mode 4754; there is no point in making
6013 them unreadable to those users who must not be allowed to
6017 You must not arrange that the system administrator can only
6018 reconfigure the package to correspond to their local
6019 security policy by changing the permissions on a binary.
6020 Ordinary files installed by <prgn>dpkg</prgn> (as opposed
6021 to conffiles and other similar objects) have their
6022 permissions reset to the distributed permissions when the
6023 package is reinstalled. Instead you should consider (for
6024 example) creating a group for people allowed to use the
6025 program(s) and making any setuid executables executable
6026 only by that group.</p>
6029 If you need to create a new user or group for your package
6030 there are two possibilities. Firstly, you may need to
6031 make some files in the binary package be owned by this
6032 user or group, or you may need to compile the user or
6033 group id (rather than just the name) into the binary
6034 (though this latter should be avoided if possible, as in
6035 this case you need a statically allocated id).</p>
6038 If you need a statically allocated id, you must ask for a
6039 user or group id from the base system
6040 maintainer, and must not release the package until you
6041 have been allocated one. Once you have been allocated one
6042 you must make the package depend on a version of the base
6043 system with the id present in <tt>/etc/passwd</tt> or
6044 <tt>/etc/group</tt>, or alternatively arrange for your
6045 package to create the user or group itself with the
6046 correct id (using <tt>adduser</tt>) in its pre- or
6047 post-installation script (the latter is to be preferred if
6048 it is possible).</p>
6051 On the other hand, the program might be able to determine the
6052 uid or gid from the group name at runtime, so that a
6053 dynamic id can be used. In this case you should choose an
6054 appropriate user or group name, discussing this on
6055 <prgn>debian-devel</prgn> and checking with the base
6056 system maintainer that it is unique and that they do not
6057 wish you to use a statically allocated id instead. When
6058 this has been checked you must arrange for your package to
6059 create the user or group if necessary using
6060 <prgn>adduser</prgn> in the pre- or post-installation
6061 script (again, the latter is to be preferred if it is
6065 Note that changing the numeric value of an id associated with a name
6066 is very difficult, and involves searching the file system for all
6067 appropriate files. You need to think carefully whether a static or
6068 dynamic id is required, since changing your mind later will cause
6073 <chapt id="customized-programs">
6074 <heading>Customized programs</heading>
6076 <sect id="arch-spec">
6077 <heading>Architecture specification strings</heading>
6080 If a program needs to specify an <em>architecture specification
6081 string</em> in some place, the following format should be used:
6082 <example compact="compact">
6083 <arch>-<os>
6085 where `<arch>' is one of the following: i386, alpha, arm, m68k,
6086 powerpc, sparc and `<os>' is one of: linux, gnu. Use
6087 of <em>gnu</em> in this string is reserved for the GNU/Hurd
6088 operating system.</p>
6090 Note, that we don't want to use `<arch>-debian-linux'
6091 to apply to the rule `architecture-vendor-os' since this
6092 would make our programs incompatible to other Linux
6093 distributions. Also note, that we don't use
6094 `<arch>-unknown-linux', since the `unknown' does not
6095 look very good.</p></sect>
6099 <heading>Daemons</heading>
6102 The configuration files <tt>/etc/services</tt>,
6103 <tt>/etc/protocols</tt>, and <tt>/etc/rpc</tt> are managed
6104 by the <prgn>netbase</prgn> package and may not be modified
6105 by other packages.</p>
6108 If a package requires a new entry in one of these files, the
6109 maintainer should get in contact with the
6110 <prgn>netbase</prgn> maintainer, who will add the entries
6111 and release a new version of the <prgn>netbase</prgn>
6115 The configuration file <tt>/etc/inetd.conf</tt> must not be
6116 modified by the package's scripts except via the
6117 <prgn>update-inetd</prgn> script or the
6118 <prgn>DebianNet.pm</prgn> Perl module.</p>
6121 If a package wants to install an example entry into
6122 <tt>/etc/inetd.conf</tt>, the entry must be preceded with
6123 exactly one hash character (<tt>#</tt>). Such lines are
6124 treated as `commented out by user' by the
6125 <prgn>update-inetd</prgn> script and are not changed or
6126 activated during a package updates.</p></sect>
6130 <heading>Using pseudo-ttys and modifying wtmp, utmp and lastlog</heading>
6133 Some programs need to create pseudo-ttys. This should be done
6134 using Unix98 ptys if the C library supports it. The resulting
6135 program must not be installed setuid root, unless that
6136 is required for other functionality.
6140 The files <tt>/var/run/utmp</tt>, <tt>/var/log/wtmp</tt> and
6141 <tt>/var/log/lastlog</tt> must be installed writeable by
6142 group utmp. Programs who need to modify those files must
6143 be installed setgid utmp.
6148 <heading>Editors and pagers</heading>
6151 Some programs have the ability to launch an editor or pager
6152 program to edit or display a text document. Since there are
6153 lots of different editors and pagers available in the Debian
6154 distribution, the system administrator and each user should
6155 have the possibility to choose his/her preferred editor and
6159 In addition, every program should choose a good default
6160 editor/pager if none is selected by the user or system
6164 Thus, every program that launches an editor or pager must
6165 use the EDITOR or PAGER environment variables to determine
6166 the editor/pager the user wants to get started. If these
6167 variables are not set, the programs <tt>/usr/bin/editor</tt>
6168 and <tt>/usr/bin/pager</tt> should be used, respectively.</p>
6171 These two files are managed through `alternatives.' That is,
6172 every package providing an editor or pager must call the
6173 <prgn>update-alternatives</prgn> script to register these
6177 If it is very hard to adapt a program to make us of the
6178 EDITOR and PAGER variables, that program may be configured
6179 to use <tt>/usr/bin/sensible-editor</tt> and
6180 <tt>/usr/bin/sensible-pager</tt> as editor or pager program,
6181 respectively. These are two scripts provided in the Debian
6182 base system that check the EDITOR and PAGER variables and
6183 launch the appropriate program or fall back to
6184 <tt>/usr/bin/editor</tt> and <tt>/usr/bin/pager</tt>,
6188 A program may also use the VISUAL environment variable to
6189 determine the user's choice of editor. If it exists, it
6190 should take precedence over EDITOR. This is in fact what
6191 <tt>/usr/bin/sensible-editor</tt> does.</p>
6194 It is not required for a package to depend on
6195 `editor' and `pager', nor is it required for a package to
6196 provide such virtual packages.
6199 The Debian base system already provides an editor and
6208 <sect id="web-appl">
6209 <heading>Web servers and applications</heading>
6212 This section describes the locations and URLs that should
6213 be used by all web servers and web application in the Debian
6219 <p>Cgi-bin executable files are installed in the
6221 <example compact="compact">
6222 /usr/lib/cgi-bin/<cgi-bin-name>
6224 and should be referred to as
6225 <example compact="compact">
6226 http://localhost/cgi-bin/<cgi-bin-name>
6231 <item><p>Access to html documents</p>
6234 Html documents for a package are stored in
6235 <tt>/usr/share/doc/<var>package</var></tt> but should
6236 be accessed via symlinks as
6237 <tt>/usr/doc/<var>package</var></tt><footnote> for
6238 backward compatibility, see <ref id="usrdoc"></footnote>
6239 and can be referred to as
6240 <example compact="compact">
6241 http://localhost/doc/<package>/<filename>
6246 <item><p>Web Document Root</p>
6249 Web Applications should try to avoid storing files in
6250 the Web Document Root. Instead they should use the
6251 /usr/share/doc/<package> directory for documents and
6252 register the Web Application via the menu package. If
6253 access to the web-root is unavoidable then use
6254 <example compact="compact">
6257 as the Document Root. This might be just a
6258 symbolic link to the location where the sysadmin has
6259 put the real document root.</p>
6262 </enumlist></p></sect>
6265 <sect id="mail-transport-agents">
6266 <heading>Mail transport, delivery and user agents</heading>
6269 Debian packages which process electronic mail, whether
6270 mail-user-agents (MUAs) or mail-transport-agents (MTAs),
6271 must make sure that they are compatible with the
6272 configuration decisions below. Failure to do this may
6273 result in lost mail, broken <tt>From:</tt> lines, and other
6274 serious brain damage!</p>
6277 The mail spool is <tt>/var/mail</tt> and the interface
6278 to send a mail message is <tt>/usr/sbin/sendmail</tt> (as
6279 per the FHS). On older systems, the mail spool may be
6280 physically located in /var/spool/mail, but all access to the
6281 mail spool should be via the /var/mail symlink. The mail
6282 spool is part of the base system and not part of the MTA
6287 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6288 programs (like IMAP daemons) must lock the mailbox in an
6289 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6290 be combined with dot locking. To avoid deadlocks, a
6291 program should use <tt>fcntl()</tt> first and dot locking
6292 after this or alternatively implement the two locking
6293 methods in a non blocking way<footnote>
6295 If it is not possible to establish both locks, the
6296 system shouldn't wait for the second lock to be
6297 established, but remove the first lock, wait a (random)
6298 time, and start over locking again.</p>
6299 </footnote>. Using the functions <tt>maillock</tt> and
6300 <tt>mailunlock</tt> provided by the
6301 <tt>liblockfile*</tt><footnote>
6303 <tt>liblockfile</tt> version >>1.01</p>
6304 </footnote> packages is the recommended way to realize this.
6308 Mailboxes are generally 660 <tt><var>user</var>.mail</tt>
6309 unless the user has chosen otherwise. A MUA may remove a
6310 mailbox (unless it has nonstandard permissions) in which
6311 case the MTA or another MUA must recreate it if needed.
6312 Mailboxes must be writable by group mail.</p>
6315 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6316 be setgid mail to do the locking mentioned above (and
6317 must obviously avoid accessing other users' mailboxes
6318 using this privilege).</p>
6321 <tt>/etc/aliases</tt> is the source file for the system mail
6322 aliases (e.g., postmaster, usenet, etc.), it is the one
6323 which the sysadmin and <tt>postinst</tt> scripts may edit.
6324 After <tt>/etc/aliases</tt> is edited the program or human
6325 editing it must call <prgn>newaliases</prgn>. All MTA
6326 packages must come with a <prgn>newaliases</prgn> program,
6327 even if it does nothing, but older MTA packages do not do
6328 this so programs should not fail if <prgn>newaliases</prgn>
6329 cannot be found.</p>
6332 The convention of writing <tt>forward to
6333 <var>address</var></tt> in the mailbox itself is not
6334 supported. Use a <tt>.forward</tt> file instead.</p>
6337 The <prgn>rmail</prgn> program used by UUCP
6338 for incoming mail should be <tt>/usr/sbin/rmail</tt>.
6339 Likewise, <prgn>rsmtp</prgn>, for receiving
6340 batch-SMTP-over-UUCP, should be <tt>/usr/sbin/rsmtp</tt> if it
6344 If you need to know what name to use (for example) on
6345 outgoing news and mail messages which are generated locally,
6346 you should use the file <tt>/etc/mailname</tt>. It will
6347 contain the portion after the username and <tt>@</tt> (at)
6348 sign for email addresses of users on the machine (followed
6352 A package should check for the existence of this file. If
6353 it exists it should use it without comment. (An MTA's
6354 prompting configuration script may wish to prompt the user
6355 even if it finds this file exists.) If it does not exist it
6356 should prompt the user for the value and store it in
6357 <tt>/etc/mailname</tt> as well as using it in the package's
6358 configuration. The prompt should make it clear that the
6359 name will not just be used by that package. For example, in
6360 this situation the INN package says:
6361 <example compact="compact">
6362 Please enter the `mail name' of your system. This is the
6363 hostname portion of the address to be shown on outgoing
6364 news and mail messages. The default is
6365 <var>syshostname</var>, your system's host name. Mail
6366 name [`<var>syshostname</var>']:
6368 where <var>syshostname</var> is the output of <tt>hostname
6374 <heading>News system configuration</heading>
6377 All the configuration files related to the NNTP (news)
6378 servers and clients should be located under
6379 <tt>/etc/news</tt>.</p>
6382 There are some configuration issues that apply to a number
6383 of news clients and server packages on the machine. These
6387 <tag>/etc/news/organization</tag>
6388 <item><p>A string which should appear as the
6389 organization header for all messages posted
6390 by NNTP clients on the machine</p></item>
6392 <tag>/etc/news/server</tag>
6393 <item><p>Contains the FQDN of the upstream NNTP
6394 server, or localhost if the local machine is
6395 an NNTP server.</p></item>
6398 Other global files may be added as required for cross-package news
6399 configuration.</p></sect>
6403 <heading>Programs for the X Window System</heading>
6406 <em>Programs that may be configured with support for the X Window
6407 System</em> must be configured to do so and must declare any
6408 package dependencies necessary to satisfy their runtime
6409 requirements when using the X Window System, unless the package
6410 in question is of standard or higher priority, in which case
6411 X-specific binaries may be split into a separate package, or
6412 alternative versions of the package with X support may be
6418 <em>Packages which provide an X server</em> that, directly or
6419 indirectly, communicates with real input and display hardware
6420 should declare in their control data that they provide the
6421 virtual package <tt>xserver</tt>.
6424 This implements current practice, and provides an actual
6425 policy for usage of the "xserver" virtual package which
6426 appears in the virtual packages list. In a nutshell, X
6427 servers that interface directly with the display and input
6428 hardware or via another subsystem (e.g., GGI) should provide
6429 xserver. Things like Xvfb, Xnest, and Xprt should not.
6435 <em>Packages that provide a terminal emulator</em> for the X
6436 Window System which support a terminal type with a terminfo
6437 description provided in the <tt>ncurses-base</tt> package
6438 should declare in their control data that they provide the
6439 virtual package <tt>x-terminal-emulator</tt>. They should
6440 also register themselves as an alternative for
6441 <tt>/usr/bin/x-terminal-emulator</tt>, with a priority of
6446 <em>Packages that provide window managers</em> should declare in
6447 their control data that they provide the virtual package
6448 <tt>x-window-manager</tt>. They should also register themselves as an
6449 alternative for <tt>/usr/bin/x-window-manager</tt>, with a priority
6450 calculated as follows:
6451 <list compact="compact">
6452 <item>Start with a priority of 20.</item>
6453 <item>If the window manager supports the Debian menu system,
6454 add 20 points if this support is available in the
6455 package's default configuration (i.e., no
6456 configuration files belonging to the system or user
6457 have to be edited to activate the feature); if
6458 configuration files must be modified, add only 10
6460 <item>If the window manager permits the X session to be
6461 restarted using a <em>different</em> window manager
6462 (without killing the X server) in its default
6463 configuration, add 10 points; otherwise add
6469 <em>Packages that provide fonts for the X Window System</em>
6470 must do a number of things to ensure that they are both
6471 available without modification of the X or font server
6472 configuration, and that they do not corrupt files used by
6473 other font packages to register information about themselves.
6476 Fonts of any type supported by the X Window System
6477 should be be in a separate binary package from any
6478 executables, libraries, or documentation (except that
6479 specific to the fonts shipped); if a program or
6480 library is <em>unusable</em> without one or more
6481 specific fonts, the package containing the program or
6482 library should declare a dependency on the package(s)
6483 containing the font(s) it requires.
6486 BDF fonts should be converted to PCF fonts with the
6487 <tt>bdftopcf</tt> utility (available in the
6488 <tt>xutils</tt> package), <tt>gzip</tt>ped, and
6489 placed in a directory that corresponds to their
6491 <list compact="compact">
6493 100 dpi fonts should be placed in
6494 <tt>/usr/X11R6/lib/X11/fonts/100dpi/</tt>.
6497 75 dpi fonts should be placed in
6498 <tt>/usr/X11R6/lib/X11/fonts/75dpi/</tt>.
6501 Character-cell fonts, cursor fonts, and other
6502 low-resolution fonts should be placed in
6503 <tt>/usr/X11R6/lib/X11/fonts/misc/</tt>.
6508 Speedo fonts should be placed in
6509 <tt>/usr/X11R6/lib/X11/fonts/Speedo/</tt>.
6512 Type 1 fonts should be placed in
6513 <tt>/usr/X11R6/lib/X11/fonts/Type1/</tt>. If font
6514 metric files are available, they may be placed here as
6518 Subdirectories of <tt>/usr/X11R6/lib/X11/fonts/</tt>
6519 other than those listed above should be neither created nor
6520 used. (The <tt>PEX</tt> and <tt>cyrillic</tt> directories are
6521 excepted for historical reasons, but installation of files into
6522 these directories remains discouraged.)
6525 Font packages may, instead of placing files directly in
6526 the X font directories listed above, provide symbolic links in
6527 the font directory which point to the files' actual location
6528 in the filesystem. Such a location should comply with the
6532 Font packages should not contain both 75dpi and 100dpi
6533 versions of a font. If both are available, they should be
6534 provided in separate binary packages with "-75dpi" or "-100dpi"
6535 appended to the names of the packages containing the
6536 corresponding fonts.
6539 Fonts destined for the <tt>misc</tt> subdirectory should
6540 not be included in the same package as 75dpi or 100dpi fonts;
6541 instead, they should be provided in a separate package with
6542 "-misc" appended to its name.
6545 Font packages <em>must not</em> provide the files
6546 <tt>fonts.dir</tt>, <tt>fonts.alias</tt>, or
6547 <tt>fonts.scale</tt> in a font directory.
6548 <list compact="compact">
6550 <tt>fonts.dir</tt> files must not be provided at
6554 <tt>fonts.alias</tt> and <tt>fonts.scale</tt>
6555 files, if needed, should be provided in the
6557 <tt>/etc/X11/fonts/<em>fontdir</em>/<em>package</em>.<em>extension</em></tt>,
6558 where <em>fontdir</em> is the name of the
6560 <tt>/usr/X11R6/lib/X11/fonts/</tt> where the
6561 package's corresponding fonts are stored (e.g.,
6562 <tt>75dpi</tt> or <tt>misc</tt>),
6563 <em>package</em> is the name of the package that
6564 provides these fonts, and <em>extension</em> is
6565 either <tt>scale</tt> or <tt>alias</tt>,
6566 whichever corresponds to the file
6572 Font packages must declare a dependency on
6573 <tt>xutils</tt> and, in the package
6574 post-installation and post-removal scripts, invoke the
6575 <tt>mkfontdir</tt> command on each directory into
6576 which they installed fonts.
6579 Font packages that provide one or more
6580 <tt>fonts.scale</tt> files as described above must declare a
6581 versioned dependency on <tt>xutils (>=
6582 4.0.2)</tt> and invoke <tt>update-fonts-scale</tt> on each
6583 directory into which they installed fonts
6584 <em>before</em> invoking <tt>mkfontdir</tt> on that
6585 directory. This invocation must occur in both the
6586 post-installation and post-removal scripts.
6589 Font packages that provide one or more
6590 <tt>fonts.alias</tt> files as described above must
6591 declare a versioned dependency on <tt>xutils
6592 (>= 4.0.2)</tt> and, in the package
6593 post-installation and post-removal scripts, invoke
6594 <tt>update-fonts-alias</tt> on each directory into
6595 which they installed fonts.
6598 Font packages must not provide alias names for the
6599 fonts they include which collide with alias names already in
6600 use by fonts already packaged.
6603 Font packages must not provide fonts with the same XLFD
6604 registry name as another font already packaged.
6610 <em>Application defaults</em> files must be installed in the
6611 directory <tt>/etc/X11/app-defaults/</tt> (use of a
6612 localized subdirectory of <tt>/etc/X11/</tt> as described in
6613 the <em>X Toolkit Intrinsics - C Language Interface</em>
6614 manual is also permitted). They must be registered as
6615 <em>conffile</em>s or handled as configuration files. For
6616 programs that are not linked against the X Toolkit (Xt)
6617 library, customization of programs' X resources may also be
6618 supported with the provision of a file with the same name as
6619 that of the package placed in the
6620 <tt>/etc/X11/Xresources/</tt> directory, which must
6621 registered as a <em>conffile</em> or handled as a
6622 configuration file. <em>Important:</em> packages that
6623 install files into the <tt>/etc/X11/Xresources/</tt>
6624 directory <em>must</em> declare a conflict with <tt>xbase
6625 (<< 3.3.2.3a-2)</tt>; if this is not done it is
6626 possible for the installing package to destroy a
6627 previously-existing <tt>/etc/X11/Xresources</tt> file which
6628 had been customized by the system administrator.
6632 <em>Packages using the X Window System should abide by the
6633 FHS standard whenever possible</em>; they should install
6634 binaries, libraries, manual pages, and other files in
6635 FHS-mandated locations wherever possible. This means that
6636 files must not be installed into <tt>/usr/X11R6/bin/</tt>,
6637 <tt>/usr/X11R6/lib/</tt>, or <tt>/usr/X11R6/man/</tt>
6638 unless this is necessary for the package to operate
6639 properly. Configuration files for window managers and
6640 display managers should be placed in a subdirectory of
6641 <tt>/etc/X11/</tt> corresponding to the package name due
6642 to these programs' tight integration with the mechanisms
6643 of the X Window System. Application-level programs should
6644 use the <tt>/etc/</tt> directory unless otherwise mandated
6645 by policy. The installation of files into subdirectories
6646 of <tt>/usr/X11R6/include/X11/</tt> and
6647 <tt>/usr/X11R6/lib/X11/</tt> is permitted but discouraged;
6648 package maintainers should determine if subdirectories of
6649 <tt>/usr/lib/</tt> and <tt>/usr/share/</tt> can be used
6650 instead (symlinks from the X11R6 directories to
6651 FHS-compliant locations is encouraged if the program is
6652 not easily configured to look elsewhere for its files).
6653 Packages must not provide or install files into the
6654 directories <tt>/usr/bin/X11/</tt>,
6655 <tt>/usr/include/X11/</tt>, or <tt>/usr/lib/X11/</tt>.
6656 Files within a package should, however, make reference to
6657 these directories, rather than their X11R6-named
6658 counterparts <tt>/usr/X11R6/bin/</tt>,
6659 <tt>/usr/X11R6/include/X11/</tt>, and
6660 <tt>/usr/X11R6/lib/X11/</tt>, if the resources being
6661 referred to have not been moved to FHS-compliant
6666 <em>Programs that require the non-DFSG-compliant OSF/Motif
6667 library</em> should be compiled against and tested with
6668 LessTif (a free re-implementation of Motif) instead. If the
6669 maintainer judges that the program or programs do not work
6670 sufficiently well with LessTif to be distributed and
6671 supported, but do so when compiled against Motif, then two
6672 versions of the package should be created; one linked
6673 statically against Motif and with <tt>-smotif</tt> appended
6674 to the package name, and one linked dynamically against
6675 Motif and with <tt>-dmotif</tt> appended to the package
6676 name. Both Motif-linked versions are dependent upon
6677 non-DFSG-compliant software and thus cannot be uploaded to
6678 the main distribution; if the software is itself
6679 DFSG-compliant it may be uploaded to the contrib
6680 distribution. While known existing versions of OSF/Motif
6681 permit unlimited redistribution of binaries linked against
6682 the library (whether statically or dynamically), it is the
6683 package maintainer's responsibility to determine whether
6684 this is permitted by the license of the copy of OSF/Motif in
6685 his or her possession.
6690 <heading>Perl programs and modules</heading>
6692 Perl programs and modules should follow the current Perl
6693 policy as defined in the file found on
6694 <ftpsite>ftp.debian.org</ftpsite> in
6695 <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>
6696 or your local mirror. In addition, it is included in the
6697 <tt>debian-policy</tt> package.
6702 <heading>Emacs lisp programs</heading>
6705 Please refer to the `Debian Emacs Policy' (documented in
6706 <tt>debian-emacs-policy.gz</tt> of the
6707 <prgn>emacsen-common</prgn> package) for details of how to
6708 package emacs lisp programs.</p></sect>
6712 <heading>Games</heading>
6715 The permissions on /var/games are 755
6716 <tt>root.root</tt>.</p>
6719 Each game decides on its own security policy.</p>
6722 Games which require protected, privileged access to
6723 high-score files, savegames, etc., may be made
6724 set-<em>group</em>-id (mode 2755) and owned by
6725 <tt>root.games</tt>, and use files and directories with
6726 appropriate permissions (770 <tt>root.games</tt>, for
6727 example). They must not be made
6728 set-<em>user</em>-id, as this causes security problems. (If
6729 an attacker can subvert any set-user-id game they can
6730 overwrite the executable of any other, causing other players
6731 of these games to run a Trojan horse program. With a
6732 set-group-id game the attacker only gets access to less
6733 important game data, and if they can get at the other
6734 players' accounts at all it will take considerably more
6738 Some packages, for example some fortune cookie programs, are
6739 configured by the upstream authors to install with their
6740 data files or other static information made unreadable so
6741 that they can only be accessed through set-id programs
6742 provided. You should not do this in a Debian package: anyone can
6743 download the <tt>.deb</tt> file and read the data from it,
6744 so there is no point making the files unreadable. Not
6745 making the files unreadable also means that you don't have
6746 to make so many programs set-id, which reduces the risk of a
6750 As described in the FHS, binaries of games should be
6751 installed in the directory <tt>/usr/games</tt>. This also
6752 applies to games that use the X Window System. Manual pages
6753 for games (X and non-X games) should be installed in
6754 <tt>/usr/share/man/man6</tt>.</p>
6758 <chapt><heading>Documentation</heading>
6762 <heading>Manual pages</heading>
6765 You should install manual pages in <prgn>nroff</prgn> source
6766 form, in appropriate places under <tt>/usr/share/man</tt>. You
6767 should only use sections 1 to 9 (see the FHS for more
6768 details). You must not install a preformatted `cat
6772 Each program, utility, and function should have an
6773 associated manpage included in the same package. It is
6774 suggested that all configuration files also have a manual
6775 page included as well.
6779 If no manual page is available for a particular program,
6780 utility, function or configuration file and this is reported as a bug on
6781 debian-bugs, a symbolic link from the requested manual page
6782 to the <manref name="undocumented" section="7"> manual page
6783 may be provided. This symbolic link can be created from
6784 <tt>debian/rules</tt> like this:
6785 <example compact="compact">
6786 ln -s ../man7/undocumented.7.gz \
6787 debian/tmp/usr/share/man/man[1-9]/the_requested_manpage.[1-9].gz
6789 This manpage claims that the lack of a manpage has been
6790 reported as a bug, so you may only do this if it really has
6791 (you can report it yourself, if you like). Do not close the
6792 bug report until a proper manpage is available.</p>
6795 You may forward a complaint about a missing manpage to the
6796 upstream authors, and mark the bug as forwarded in the
6797 Debian bug tracking system. Even though the GNU Project do
6798 not in general consider the lack of a manpage to be a bug,
6799 we do; if they tell you that they don't consider it a bug
6800 you should leave the bug in our bug tracking system open
6804 Manual pages should be installed compressed using <tt>gzip
6808 If one manpage needs to be accessible via several names it
6809 is better to use a symbolic link than the <tt>.so</tt>
6810 feature, but there is no need to fiddle with the relevant
6811 parts of the upstream source to change from <tt>.so</tt> to
6812 symlinks: don't do it unless it's easy. You should not create hard
6813 links in the manual page directories, nor put
6814 absolute filenames in <tt>.so</tt> directives. The filename
6815 in a <tt>.so</tt> in a manpage should be relative to the
6816 base of the manpage tree (usually
6817 <tt>/usr/share/man</tt>).</p></sect>
6821 <heading>Info documents</heading>
6824 Info documents should be installed in <tt>/usr/share/info</tt>.
6825 They should be compressed with <tt>gzip -9</tt>.</p>
6828 Your package should call <prgn>install-info</prgn> to update the Info
6830 file, in its post-installation script:
6831 <example compact="compact">
6832 install-info --quiet --section Development Development \
6833 /usr/share/info/foobar.info
6837 It is a good idea to specify a section for the location of
6838 your program; this is done with the <tt>--section</tt>
6839 switch. To determine which section to use, you should look
6840 at <tt>/usr/share/info/dir</tt> on your system and choose the most
6841 relevant (or create a new section if none of the current
6842 sections are relevant). Note that the <tt>--section</tt>
6843 flag takes two arguments; the first is a regular expression
6844 to match (case-insensitively) against an existing section,
6845 the second is used when creating a new one.</p>
6848 You should remove the entries in the pre-removal script:
6849 <example compact="compact">
6850 install-info --quiet --remove /usr/share/info/foobar.info
6854 If <prgn>install-info</prgn> cannot find a description entry
6855 in the Info file you must supply one. See <manref
6856 name="install-info" section="8"> for details.</p>
6860 <heading>Additional documentation</heading>
6863 Any additional documentation that comes with the package may
6864 be installed at the discretion of the package maintainer.
6865 Text documentation should be installed in a directory
6866 <tt>/usr/share/doc/<var>package</var></tt>, where
6867 <var>package</var> is the name of the package, and
6868 compressed with <tt>gzip -9</tt> unless it is small.</p>
6871 If a package comes with large amounts of documentation which
6872 many users of the package will not require you should create
6873 a separate binary package to contain it, so that it does not
6874 take up disk space on the machines of users who do not need
6875 or want it installed.</p>
6878 It is often a good idea to put text information files
6879 (<tt>README</tt>s, changelogs, and so forth) that come with
6880 the source package in <tt>/usr/share/doc/<var>package</var></tt>
6881 in the binary package. However, you don't need to install
6882 the instructions for building and installing the package, of
6886 Files in <tt>/usr/share/doc</tt> should not be referenced by
6887 any program, and the system administrator should be able to
6888 delete them without causing any programs to break. Any files
6889 that are referenced by programs but are also useful as
6890 standalone documentation should be installed under
6891 <tt>/usr/share/<package>/</tt> and symlinked in
6892 <tt>/usr/share/doc/<package>/</tt>.
6898 <heading>Accessing the documentation</heading>
6901 Former Debian releases placed all additional documentation
6902 in <tt>/usr/doc/<var>package</var></tt>. To realize a
6904 <tt>/usr/share/doc/<var>package</var></tt>, each package
6905 must maintain a symlink <tt>/usr/doc/<var>package</var></tt>
6906 that points to the new location of its documentation in
6907 <tt>/usr/share/doc/<var>package</var></tt><footnote>These
6908 symlinks will be removed in the future, but they have to be
6909 there for compatibility reasons until all packages have
6910 moved and the policy is changed accordingly.</footnote>.
6911 The symlink must be created when the package is installed;
6912 it cannot be contained in the package itself due to problems
6913 with <prgn>dpkg</prgn>. One reasonable way to accomplish
6914 this is to put the following in the package's
6915 <prgn>postinst</prgn>:
6916 <example compact="compact">
6917 if [ "$1" = "configure" ]; then
6918 if [ -d /usr/doc -a ! -e /usr/doc/#PACKAGE# \
6919 -a -d /usr/share/doc/#PACKAGE# ]; then
6920 ln -sf ../share/doc/#PACKAGE# /usr/doc/#PACKAGE#
6924 And the following in the package's <prgn>prerm</prgn>:
6925 <example compact="compact">
6926 if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \
6927 -a -L /usr/doc/#PACKAGE# ]; then
6928 rm -f /usr/doc/#PACKAGE#
6935 <heading>Preferred documentation formats</heading>
6938 The unification of Debian documentation is being carried out
6942 If your package comes with extensive documentation in a
6943 mark up format that can be converted to various other formats
6944 you should if possible ship HTML versions in a binary
6945 package, in the directory
6946 <tt>/usr/share/doc/<var>appropriate package</var></tt> or its
6949 <p>The rationale: The important thing here is that HTML
6950 docs should be available in <em>some</em> package, not
6951 necessarily in the main binary package, though. </p>
6956 Other formats such as PostScript may be provided at your
6960 <sect id="copyrightfile">
6961 <heading>Copyright information</heading>
6964 Every package must be accompanied by a verbatim copy of its
6965 copyright and distribution license in the file
6966 /usr/share/doc/<package>/copyright. This file must
6967 neither be compressed nor be a symbolic link.</p>
6970 In addition, the copyright file must say where the upstream
6971 sources (if any) were obtained, and should explain briefly what
6972 modifications were made in the Debian version of the package
6973 compared to the upstream one. It should name the original
6974 authors of the package and the Debian maintainer(s) who were
6975 involved with its creation.</p>
6978 A copy of the file which will be installed in
6979 <tt>/usr/share/doc/<var>package</var>/copyright</tt> should be
6980 in <tt>debian/copyright</tt>.</p>
6984 /usr/share/doc/<package> may be a symbolic link to a
6985 directory in /usr/share/doc only if two packages both come from
6986 the same source and the first package has a "Depends"
6987 relationship on the second. These rules are important
6988 because copyrights must be extractable by mechanical
6992 Packages distributed under the UCB BSD license, the Artistic
6993 license, the GNU GPL, and the GNU LGPL should refer to the
6994 files /usr/share/common-licenses/BSD,
6995 /usr/share/common-licenses/Artistic,
6996 /usr/share/common-licenses/GPL, and
6997 /usr/share/common-licenses/LGPL.
7000 Why "licenses" and not "copyright"? Because
7001 <tt>/usr/doc/copyright</tt> used to contain all the
7002 copyright files, plus the four common licenses GPL,
7003 LGPL, Artistic and BSD. Now individual copyright files
7004 for packages are no longer in a common directory. Once
7005 <tt>/usr/doc/copyright</tt> is almost empty it makes
7006 sense to rename "copyright" to "licenses"
7009 Why "common-licenses" and not "licenses"? Because if I
7010 put just "licenses" I'm sure I will receive a bug report
7011 saying "license foo is not included in the licenses
7012 directory. They are not all the licenses, just a few
7013 common ones. I could use /usr/share/doc/common-licenses
7014 but I think this is too long, and, after all, the GPL
7015 does not "document" anything, it is merely a license.
7021 You should not use the copyright file as a general <tt>README</tt>
7022 file. If your package has such a file it should be
7023 installed in <tt>/usr/share/doc/<var>package</var>/README</tt> or
7024 <tt>README.Debian</tt> or some other appropriate place.</p>
7028 <heading>Examples</heading>
7031 Any examples (configurations, source files, whatever),
7032 should be installed in a directory
7033 <tt>/usr/share/doc/<var>package</var>/examples</tt>. These
7034 files should not be referenced by any program: they're there
7035 for the benefit of the system administrator and users, as
7036 documentation only. Architecture-specific example files
7037 should be installed in a directory
7038 <tt>/usr/lib/<var>package</var>/examples</tt>, and files in
7039 <tt>/usr/share/doc/<var>package</var>/examples</tt> symlink
7040 to files in it. Or the latter directory may be a symlink to
7044 <sect id="instchangelog">
7045 <heading>Changelog files</heading>
7048 Packages that are not Debian-native must contain a copy of
7049 <tt>debian/changelog</tt> file from the Debian source tree
7050 in <tt>/usr/share/doc/<var>package</var></tt> as
7051 <tt>changelog.Debian.gz</tt>. If an upstream changelog is
7052 available, it should be accessible as
7053 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt> in
7054 plain text. If the upstream changelog is distributed in
7055 HTML, it should be made available in that form as
7056 <tt>/usr/share/doc/<var>package</var>/changelog.html.gz</tt>
7057 and the <tt>changelog.gz</tt> should be generated using, eg,
7058 <tt>lynx -dump -nolist</tt>. If the upstream changelog files
7059 do not already conform to this naming convention, then this
7060 may be achieved either by renaming the files, or adding a
7061 symbolic link, at the maintainer's discretion.
7064 Rationale: People should not have to look into two
7065 places for upstream changelogs merely because they are
7073 All these files should be installed compressed using <tt>gzip -9</tt>,
7074 as they will become large with time even if they start out
7079 If the package has only one changelog which is used both as
7080 the Debian changelog and the upstream one because there is
7081 no separate upstream maintainer then that changelog should
7082 usually be installed as
7083 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>; if
7084 there is a separate upstream maintainer, but no upstream
7085 changelog, then the Debian changelog should still be called
7086 <tt>changelog.Debian.gz</tt>.</p>