1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3 within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
10 <title>Debian Policy Manual</title>
11 <author><ref id="authors"></author>
12 <version>version &version;, &date;</version>
15 This manual describes the policy requirements for the Debian
16 GNU/Linux distribution. This includes the structure and
17 contents of the Debian archive and several design issues of
18 the operating system, as well as technical requirements that
19 each package must satisfy to be included in the distribution.
24 Copyright © 1996,1997,1998 Ian Jackson
25 and Christian Schwarz.
28 This manual is free software; you may redistribute it and/or
29 modify it under the terms of the GNU General Public License
30 as published by the Free Software Foundation; either version
31 2, or (at your option) any later version.
35 This is distributed in the hope that it will be useful, but
36 <em>without any warranty</em>; without even the implied
37 warranty of merchantability or fitness for a particular
38 purpose. See the GNU General Public License for more
43 A copy of the GNU General Public License is available as
44 <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
45 distribution or on the World Wide Web at
46 <url id="http://www.gnu.org/copyleft/gpl.html"
47 name="the GNU General Public Licence">. You can also
48 obtain it by writing to the Free Software Foundation, Inc.,
49 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
57 <heading>About this manual</heading>
59 <heading>Scope</heading>
61 This manual describes the policy requirements for the Debian
62 GNU/Linux distribution. This includes the structure and
63 contents of the Debian archive and several design issues of the
64 operating system, as well as technical requirements that
65 each package must satisfy to be included in the
70 This manual also describes Debian policy as it relates to
71 creating Debian packages. It is not a tutorial on how to build
72 packages, nor is it exhaustive where it comes to describing
73 the behavior of the packaging system. Instead, this manual
74 attempts to define the interface to the package management
75 system that the developers have to be conversant with.<footnote>
77 Informally, the criteria used for inclusion is that the
78 material meet one of the following requirements:
79 <taglist compact="compact">
80 <tag>Standard interfaces</tag>
83 The material presented represents an interface to
84 the packaging system that is mandated for use, and
85 is used by, a significant number of packages, and
86 therefore should not be changed without peer
87 review. Package maintainers can then rely on this
88 interfaces not changing, and the package
89 management software authors need to ensure
90 compatibility with these interface
91 definitions. (Control file and changelog file
92 formats are examples.)
95 <tag>Chosen Convention</tag>
98 If there are a number of technically viable choices
99 that can be made, but one needs to select one of
100 these options for inter-operability. The version
101 number format is one example.
105 Please note that these are not mutually exclusive;
106 selected conventions often become parts of standard
113 The footnotes present in this manual are
114 merely informative, and are not part of Debian policy itself.
118 The appendices to this manual are not necessarily normative,
119 either. Please see <ref id="pkg-scope"> for more information.
123 In the normative part of this manual,
124 the words <em>must</em>, <em>should</em> and
125 <em>may</em>, and the adjectives <em>required</em>,
126 <em>recommended</em> and <em>optional</em>, are used to
127 distinguish the significance of the various guidelines in
128 this policy document. Packages that do not conform to the
129 guidelines denoted by <em>must</em> (or <em>required</em>)
130 will generally not be considered acceptable for the Debian
131 distribution. Non-conformance with guidelines denoted by
132 <em>should</em> (or <em>recommended</em>) will generally be
133 considered a bug, but will not necessarily render a package
134 unsuitable for distribution. Guidelines denoted by
135 <em>may</em> (or <em>optional</em>) are truly optional and
136 adherence is left to the maintainer's discretion.
139 These classifications are roughly equivalent to the bug
140 severities <em>serious</em> (for <em>must</em> or
141 <em>required</em> directive violations), <em>minor</em>,
142 <em>normal</em> or <em>important</em>
143 (for <em>should</em> or <em>recommended</em> directive
144 violations) and <em>wishlist</em> (for <em>optional</em>
146 <p>Compare RFC 2119. Note, however, that these words are
147 used in a different way in this document.</p>
151 Much of the information presented in this manual will be
152 useful even when building a package which is to be
153 distributed in some other way or is intended for local use
159 <heading>New versions of this document</heading>
161 The current version of this document is always accessible
162 from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
164 <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
165 (also available from the same directory are several other
166 formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
167 and <file>policy.ps.gz</file>) or from the <url
168 id="http://www.debian.org/doc/debian-policy/" name="Debian
169 Policy Manual"> webpage.</p>
172 In addition, this manual is distributed via the Debian package
173 <file>debian-policy</file>.
177 The <tt>debian-policy</tt> package also includes the file
178 <file>upgrading-checklist.txt</file> which indicates policy
179 changes between versions of this document.
184 <heading>Authors and Maintainers</heading>
187 Originally called "Debian GNU/Linux Policy Manual", this
188 manual was initially written in 1996 by Ian Jackson.
189 It was revised on November 27th, 1996 by David A. Morris.
190 Christian Schwarz added new sections on March 15th, 1997,
191 and reworked/restructured it in April-July 1997.
192 Christoph Lameter contributed the "Web Standard".
193 Julian Gilbey largely restructured it in 2001.
197 Since September 1998, the responsibility for the contents of
198 this document lies on the debian-policy mailing list. Proposals
199 are discussed there and inserted into policy after a certain
200 consensus is established.
201 <!-- insert shameless policy-process plug here eventually -->
202 The actual editing is done by a group of maintainers that have
203 no editorial powers. These are the current maintainers:
206 <item>Julian Gilbey</item>
207 <item>Branden Robinson</item>
208 <item>Josip Rodin</item>
209 <item>Manoj Srivastava</item>
214 While the authors of this document have tried hard to avoid
215 typos and other errors, these do still occur. If you discover
216 an error in this manual or if you want to give any
217 comments, suggestions, or criticisms please send an email to
218 the Debian Policy List,
219 <email>debian-policy@lists.debian.org</email>, or submit a
220 bug report against the <tt>debian-policy</tt> package.
224 Please do not try to reach the individual authors or maintainers
225 of the Policy Manual regarding changes to the Policy.
231 <heading>The Debian Archive</heading>
233 The Debian GNU/Linux system is maintained and distributed as a
234 collection of <em>packages</em>. Since there are so many of
235 them (currently well over 6000), they are split into
236 <em>sections</em> and given <em>priorities</em> to simplify
237 the handling of them.
240 The effort of the Debian project is to build a free operating
241 system, but not every package we want to make accessible is
242 <em>free</em> in our sense (see the Debian Free Software
243 Guidelines, below), or may be imported/exported without
244 restrictions. Thus, the archive is split into the sections
245 <em>main</em>, <em>non-free</em>, <em>contrib</em>,
246 <em>non-US/main</em>, <em>non-US/non-free</em>, and
247 <em>non-US/contrib</em>. The sections are explained in detail
252 The <em>main</em> and the <em>non-US/main</em> sections
253 together form the <em>Debian GNU/Linux distribution</em>.
257 Packages in the other sections are not considered to be part
258 of the Debian distribution, although we support their use and
259 provide infrastructure for them (such as our bug-tracking
260 system and mailing lists). This Debian Policy Manual applies
261 to these packages as well.</p>
263 <sect id="pkgcopyright">
264 <heading>Package copyright and sections</heading>
266 The aims of this section are:
268 <list compact="compact">
270 <p>to allow us to make as much software available as we
274 <p>to allow us to encourage everyone to write free
278 <p>to allow us to make it easy for people to produce
279 CD-ROMs of our system without violating any licenses,
280 import/export restrictions, or any other laws.</p>
285 <heading>The Debian Free Software Guidelines</heading>
287 The Debian Free Software Guidelines (DFSG) form our
288 definition of "free software". These are:
290 <tag>Free Redistribution
294 The license of a Debian component may not restrict any
295 party from selling or giving away the software as a
296 component of an aggregate software distribution
297 containing programs from several different
298 sources. The license may not require a royalty or
299 other fee for such sale.
306 The program must include source code, and must allow
307 distribution in source code as well as compiled form.
314 The license must allow modifications and derived
315 works, and must allow them to be distributed under the
316 same terms as the license of the original software.
319 <tag>Integrity of The Author's Source Code
323 The license may restrict source-code from being
324 distributed in modified form <em>only</em> if the
325 license allows the distribution of "patch files"
326 with the source code for the purpose of modifying the
327 program at build time. The license must explicitly
328 permit distribution of software built from modified
329 source code. The license may require derived works to
330 carry a different name or version number from the
331 original software. (This is a compromise. The Debian
332 Project encourages all authors to not restrict any
333 files, source or binary, from being modified.)
336 <tag>No Discrimination Against Persons or Groups
340 The license must not discriminate against any person
344 <tag>No Discrimination Against Fields of Endeavor
348 The license must not restrict anyone from making use
349 of the program in a specific field of endeavor. For
350 example, it may not restrict the program from being
351 used in a business, or from being used for genetic
355 <tag>Distribution of License
359 The rights attached to the program must apply to all
360 to whom the program is redistributed without the need
361 for execution of an additional license by those
365 <tag>License Must Not Be Specific to Debian
369 The rights attached to the program must not depend on
370 the program's being part of a Debian system. If the
371 program is extracted from Debian and used or
372 distributed without Debian but otherwise within the
373 terms of the program's license, all parties to whom
374 the program is redistributed must have the same
375 rights as those that are granted in conjunction with
379 <tag>License Must Not Contaminate Other Software
383 The license must not place restrictions on other
384 software that is distributed along with the licensed
385 software. For example, the license must not insist
386 that all other programs distributed on the same medium
387 must be free software.
390 <tag>Example Licenses
394 The "GPL," "BSD," and "Artistic" licenses are examples of
395 licenses that we consider <em>free</em>.
402 <heading>The main section</heading>
404 Every package in <em>main</em> and <em>non-US/main</em>
405 must comply with the DFSG (Debian Free Software
409 In addition, the packages in <em>main</em>
410 <list compact="compact">
413 must not require a package outside of <em>main</em>
414 for compilation or execution (thus, the package must
415 not declare a "Depends", "Recommends", or
416 "Build-Depends" relationship on a non-<em>main</em>
422 must not be so buggy that we refuse to support them,
428 must meet all policy requirements presented in this
435 Similarly, the packages in <em>non-US/main</em>
436 <list compact="compact">
439 must not require a package outside of <em>main</em>
440 or <em>non-US/main</em> for compilation or
446 must not be so buggy that we refuse to support them,
451 must meet all policy requirements presented in this
459 <heading>The contrib section</heading>
461 Every package in <em>contrib</em> and
462 <em>non-US/contrib</em> must comply with the DFSG.
466 In addition, the packages in <em>contrib</em> and
467 <em>non-US/contrib</em>
468 <list compact="compact">
471 must not be so buggy that we refuse to support them,
477 must meet all policy requirements presented in this
485 Furthermore, packages in <em>contrib</em> must not require
486 a package in a <em>non-US</em> section for compilation or
491 Examples of packages which would be included in
492 <em>contrib</em> or <em>non-US/contrib</em> are:
493 <list compact="compact">
496 free packages which require <em>contrib</em>,
497 <em>non-free</em> packages or packages which are not
498 in our archive at all for compilation or execution,
504 wrapper packages or other sorts of free accessories for
512 <heading>The non-free section</heading>
514 Packages must be placed in <em>non-free</em> or
515 <em>non-US/non-free</em> if they are not compliant with
516 the DFSG or are encumbered by patents or other legal
517 issues that make their distribution problematic.
520 In addition, the packages in <em>non-free</em> and
521 <em>non-US/non-free</em>
522 <list compact="compact">
525 must not be so buggy that we refuse to support them,
531 must meet all policy requirements presented in this
532 manual that it is possible for them to meet.<footnote>
534 It is possible that there are policy
535 requirements which the package is unable to
536 meet, for example, if the source is
537 unavailable. These situations will need to be
538 handled on a case-by-case basis.
548 <heading>The non-US sections</heading>
550 Non-free programs with cryptographic program code need to
551 be stored on the <em>non-us</em> server because of export
552 restrictions of the U.S.
555 Programs which use patented algorithms that have a
556 restrictied license also need to be stored on "non-us",
557 since that is located in a country where it is not allowed
558 to patent algorithms.
561 A package depends on another package which is distributed
562 via the non-us server has to be stored on the non-us
567 <heading>Further copyright considerations</heading>
569 Every package must be accompanied by a verbatim copy of
570 its copyright and distribution license in the file
571 <file>/usr/share/doc/<var>package</var>/copyright</file>
572 (see <ref id="copyrightfile"> for further details).
575 We reserve the right to restrict files from being included
576 anywhere in our archives if
577 <list compact="compact">
580 their use or distribution would break a law,
585 there is an ethical conflict in their distribution or
591 we would have to sign a license for them, or
596 their distribution would conflict with other project
604 Programs whose authors encourage the user to make
605 donations are fine for the main distribution, provided
606 that the authors do not claim that not donating is
607 immoral, unethical, illegal or something similar; in such
608 a case they must go in <em>non-free</em>.</p>
611 Packages whose copyright permission notices (or patent
612 problems) do not even allow redistribution of binaries
613 only, and where no special permission has been obtained,
614 must not be placed on the Debian FTP site and its mirrors
618 Note that under international copyright law (this applies
619 in the United States, too), <em>no</em> distribution or
620 modification of a work is allowed without an explicit
621 notice saying so. Therefore a program without a copyright
622 notice <em>is</em> copyrighted and you may not do anything
623 to it without risking being sued! Likewise if a program
624 has a copyright notice but no statement saying what is
625 permitted then nothing is permitted.</p>
628 Many authors are unaware of the problems that restrictive
629 copyrights (or lack of copyright notices) can cause for
630 the users of their supposedly-free software. It is often
631 worthwhile contacting such authors diplomatically to ask
632 them to modify their license terms. However, this can be a
633 politically difficult thing to do and you should ask for
634 advice on the <tt>debian-legal</tt> mailing list first, as
639 When in doubt about a copyright, send mail to
640 <email>debian-legal@lists.debian.org</email>. Be prepared
641 to provide us with the copyright statement. Software
642 covered by the GPL, public domain software and BSD-like
643 copyrights are safe; be wary of the phrases "commercial
644 use prohibited" and "distribution restricted".
648 <heading>Subsections</heading>
651 The packages in the sections <em>main</em>,
652 <em>contrib</em> and <em>non-free</em> are grouped further
653 into <em>subsections</em> to simplify handling.
657 The section and subsection for each package should be
658 specified in the package's <tt>Section</tt> control
659 record. However, the maintainer of the Debian archive
660 may override this selection to ensure the consistency of
661 the Debian distribution. The <tt>Section</tt> field
662 should be of the form:
663 <list compact="compact">
666 <em>subsection</em> if the package is in the
667 <em>main</em> section,
672 <em>section/subsection</em> if the package is in
673 the <em>contrib</em> or <em>non-free</em> section,
679 <tt>non-US</tt>, <tt>non-US/contrib</tt> or
680 <tt>non-US/non-free</tt> if the package is in
681 <em>non-US/main</em>, <em>non-US/contrib</em> or
682 <em>non-US/non-free</em> respectively.
689 The Debian archive maintainers provide the authoritative
690 list of subsections. At present, they are:
691 <em>admin</em>, <em>base</em>, <em>comm</em>,
692 <em>contrib</em>, <em>devel</em>, <em>doc</em>,
693 <em>editors</em>, <em>electronics</em>, <em>games</em>,
694 <em>graphics</em>, <em>hamradio</em>,
695 <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
696 <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
697 <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
698 <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
699 <em>sound</em>, <em>tex</em>, <em>text</em>,
700 <em>utils</em>, <em>web</em>, <em>x11</em>.
704 <heading>Priorities</heading>
707 Each package should have a <em>priority</em> value, which is
708 included in the package's <em>control record</em>. This
709 information is used by the Debian package management tools
710 to separate high-priority packages from less-important
714 The following <em>priority levels</em> are recognised by the
715 Debian package management tools.
717 <tag><tt>required</tt></tag>
720 Packages which are necessary for the proper
721 functioning of the system. You must not remove these
722 packages or your system may become totally broken and
723 you may not even be able to use <prgn>dpkg</prgn> to
724 put things back. Systems with only the
725 <tt>required</tt> packages are probably unusable, but
726 they do have enough functionality to allow the
727 sysadmin to boot and install more software.</p>
729 <tag><tt>important</tt></tag>
732 Important programs, including those which one would
733 expect to find on any Unix-like system. If the
734 expectation is that an experienced Unix person who
735 found it missing would say "What on earth is going on,
736 where is <prgn>foo</prgn>?", it must be an
737 <tt>important</tt> package.<footnote>
739 This is an important criterion because we are
740 trying to produce, amongst other things, a free
744 Other packages without which the system will not run
745 well or be usable must also have priority
746 <tt>important</tt>. This does
747 <em>not</em> include Emacs, the X Window System, TeX
748 or any other large applications. The
749 <tt>important</tt> packages are just a bare minimum of
750 commonly-expected and necessary tools.</p>
752 <tag><tt>standard</tt></tag>
755 These packages provide a reasonably small but not too
756 limited character-mode system. This is what will be
757 installed by default if the user doesn't select anything
758 else. It doesn't include many large applications.</p>
760 <tag><tt>optional</tt></tag>
763 (In a sense everything that isn't required is
764 optional, but that's not what is meant here.) This is
765 all the software that you might reasonably want to
766 install if you didn't know what it was and don't have
767 specialized requirements. This is a much larger system
768 and includes the X Window System, a full TeX
769 distribution, and many applications. Note that
770 optional packages should not conflict with each other.
773 <tag><tt>extra</tt></tag>
776 This contains all packages that conflict with others
777 with required, important, standard or optional
778 priorities, or are only likely to be useful if you
779 already know what they are or have specialised
786 Packages must not depend on packages with lower priority
787 values (excluding build-time dependencies). In order to
788 ensure this, the priorities of one or more packages may need
794 <heading>Binary packages</heading>
797 The Debian GNU/Linux distribution is based on the Debian
798 package management system, called <prgn>dpkg</prgn>. Thus,
799 all packages in the Debian distribution must be provided
800 in the <tt>.deb</tt> file format.</p>
804 <heading>The package name</heading>
807 Every package must have a name that's unique within the Debian
811 Package names must consist of lower case letters
812 (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
813 and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
814 They must be at least two characters long and must start
815 with an alphanumeric character.
819 The package name is part of the file name of the
820 <tt>.deb</tt> file and is included in the control field
826 <heading>The maintainer of a package</heading>
828 Every package must have a Debian maintainer (the
829 maintainer may be one person or a group of people
830 reachable from a common email address, such as a mailing
831 list). The maintainer is responsible for ensuring that
832 the package is placed in the appropriate distributions.
836 The maintainer must be specified in the
837 <tt>Maintainer</tt> control field with their correct name
838 and a working email address. If one person maintains
839 several packages, he/she should try to avoid having
840 different forms of their name and email address in
841 the <tt>Maintainer</tt> fields of those packages.
845 If the maintainer of a package quits from the Debian
846 project, "Debian QA Group"
847 <email>packages@qa.debian.org</email> takes over the
848 maintainership of the package until someone else
849 volunteers for that task. These packages are called
850 <em>orphaned packages</em>.<footnote>
852 The detailed procedure for doing this gracefully can
853 be found in the Debian Developer's Reference, either
854 in the <tt>developers-reference</tt> package, or on
855 the Debian FTP server
856 <ftpsite>ftp.debian.org</ftpsite> as
857 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
859 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
860 name="Debian Developer's Reference"> webpage.
868 <heading>The description of a package</heading>
871 Every Debian package must have an extended description
872 stored in the appropriate field of the control record.</p>
875 The description should be written so that it gives the
876 system administrator enough information to decide whether
877 to install the package. This description should not just
878 be copied verbatim from the program's documentation.
879 Instructions for configuring or using the package should
880 not be included (that is what installation scripts,
881 manual pages, info files, etc., are for). Copyright
882 statements and other administrivia should not be included
883 either (that is what the copyright file is for).
887 Please refer to <ref id="descriptions"> for more information.
894 <heading>Dependencies</heading>
897 Every package must specify the dependency information
898 about other packages that are required for the first to
902 For example, a dependency entry must be provided for any
903 shared libraries required by a dynamically-linked executable
904 binary in a package.</p>
907 Packages are not required to declare any dependencies they
908 have on other packages which are marked <tt>Essential</tt>
909 (see below), and should not do so unless they depend on a
910 particular version of that package.</p>
913 Sometimes, a package requires another package to be installed
914 <em>and</em> configured before it can be installed. In this
915 case, you must specify a <tt>Pre-Depends</tt> entry for
919 You should not specify a <tt>Pre-Depends</tt> entry for a
920 package before this has been discussed on the
921 <tt>debian-devel</tt> mailing list and a consensus about
922 doing that has been reached.</p></sect1>
925 <sect1 id="virtual_pkg_sect">
926 <heading>Virtual packages</heading>
929 Sometimes, there are several packages which offer
930 more-or-less the same functionality. In this case, it's
931 useful to define a <em>virtual package</em> whose name
932 describes that common functionality. (The virtual
933 packages only exist logically, not physically; that's why
934 they are called <em>virtual</em>.) The packages with this
935 particular function will then <em>provide</em> the virtual
936 package. Thus, any other package requiring that function
937 can simply depend on the virtual package without having to
938 specify all possible packages individually.</p>
941 All packages should use virtual package names where
942 appropriate, and arrange to create new ones if necessary.
943 They should not use virtual package names (except privately,
944 amongst a cooperating group of packages) unless they have
945 been agreed upon and appear in the list of virtual package
946 names. (See also <ref id="virtual">)</p>
949 The latest version of the authoritative list of virtual
950 package names can be found on
951 <ftpsite>ftp.debian.org</ftpsite> in
952 <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
953 or your local mirror. In addition, it is included in the
954 <tt>debian-policy</tt> package. The procedure for updating
955 the list is described at the top of the file.</p></sect1>
959 <heading>Base system</heading>
962 The <tt>base system</tt> is a minimum subset of the Debian
963 GNU/Linux system that is installed before everything else
964 on a new system. Thus, only very few packages are allowed
965 to go into the <tt>base</tt> section to keep the required
966 disk usage very small.</p>
969 Most of these packages will have the priority value
970 <tt>required</tt> or at least <tt>important</tt>, and many
971 of them will be tagged <tt>essential</tt> (see below).</p>
978 <heading>Essential packages</heading>
981 Some packages are tagged <tt>essential</tt>. (They have
982 <tt>Essential: yes</tt> in their package control record.)
983 This flag is used for packages that are <em>essential</em>
987 Since these packages cannot be easily removed (one has to
988 specify an extra <em>force option</em> to
989 <prgn>dpkg</prgn> to do so), this flag must not be used
990 unless absolutely necessary. A shared library package
991 must not be tagged <tt>essential</tt>; dependencies will
992 prevent its premature removal, and we need to be able to
993 remove it when it has been superseded.
997 Since dpkg will not prevent upgrading of other packages
998 while an <tt>essential</tt> package is in an unconfigured
999 state, all <tt>essential</tt> packages must supply all of
1000 their core functionality even when unconfigured. If the
1001 package cannot satisfy this requirement it must not be
1002 tagged as essential, and any packages depending on this
1003 package must instead have explicit dependency fields as
1008 You must not tag any packages <tt>essential</tt> before
1009 this has been discussed on the <tt>debian-devel</tt>
1010 mailing list and a consensus about doing that has been
1015 <heading>Tasks</heading>
1018 The Debian install process allows the user to choose from
1019 a number of common tasks which a Debian system can be used to
1020 perform. Selecting a task with <prgn>tasksel</prgn> causes
1021 a set of packages that are useful in performing that task to be
1026 This set of packages is all available packages which have the
1027 name of the selected task in the <tt>Task</tt> field of their
1028 control file. The format of this field is a list of tasks,
1029 separated by commas.
1033 You should not tag any packages as belonging to a task
1034 before this has been discussed on the
1035 <em>debian-devel</em> mailing list and a consensus about
1036 doing that has been reached.
1040 For third parties (and historical reasons), tasksel also
1041 supports constructing tasks based on <em>task
1042 packages</em>. These are packages whose names begin with
1043 <em>task-</em>. Task packages should not be included in the
1048 <sect1 id="maintscripts">
1049 <heading>Maintainer Scripts</heading>
1052 The package installation scripts should avoid producing
1053 output which it is unnecessary for the user to see and
1054 should rely on <prgn>dpkg</prgn> to stave off boredom on
1055 the part of a user installing many packages. This means,
1056 amongst other things, using the <tt>--quiet</tt> option on
1057 <prgn>install-info</prgn>.</p>
1060 Errors which occur during the execution of an installation
1061 script must be checked and the installation must not
1062 continue after an error.
1066 Note that in general <ref id="scripts"> applies to package
1067 maintainer scripts, too.
1071 You should not use <prgn>dpkg-divert</prgn> on a file
1072 belonging to another package without consulting the
1073 maintainer of that package first.
1077 All packages which supply an instance of a common command
1078 name (or, in general, filename) should generally use
1079 <prgn>update-alternatives</prgn>, so that they may be
1080 installed together. If <prgn>update-alternatives</prgn>
1081 is not used, then each package must use
1082 <tt>Conflicts</tt> to ensure that other packages are
1083 de-installed. (In this case, it may be appropriate to
1084 specify a conflict against earlier versions of something
1085 that previously did not use
1086 <prgn>update-alternatives</prgn>; this is an exception to
1087 the usual rule that versioned conflicts should be
1093 <heading>Prompting in maintainer scripts</heading>
1095 Package maintainer scripts may prompt the user if
1096 necessary. Prompting may be accomplished by hand, or by
1097 communicating with a program, such as
1098 <prgn>debconf</prgn>, which conforms to the Debian
1099 Configuration management specification, version 2 or
1100 higher. These are included in the
1101 <file>debconf_specification</file> files in the
1102 <package>debian-policy</package> package.
1103 You may also find this file on the FTP site
1104 <ftpsite>ftp.debian.org</ftpsite> in
1105 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1106 or on your local mirror.<footnote>
1108 4% of Debian packages [see <url
1109 id="http://kitenet.net/programs/debconf/stats/"
1110 name="Debconf stats">] currently use
1111 <package>debconf</package> to prompt the user at
1112 install time, and this number is growing daily. The
1113 benefits of using debconf are briefly explained at
1115 id="http://kitenet.net/doc/debconf-doc/introduction.html"
1116 name="Debconf introduction">; they include
1117 preconfiguration, (mostly) noninteractive
1118 installation, elimination of redundant prompting,
1119 consistency of user interface, etc.
1122 With this increasing number of packages using
1123 <package>debconf</package>, plus the existance of a
1124 nascent second implementation of the Debian
1125 configuration management system
1126 (<package>cdebconf</package>), and the stabilization
1127 of the protocol these things use, the time has
1128 finally come to reflect the use of these things in
1135 Packages which use the Debian Configuration management
1136 specification may contain an additional
1137 <prgn>config</prgn> script and a <tt>templates</tt>
1138 file in their control archive. The <prgn>config</prgn>
1139 script might be run before the <prgn>preinst</prgn>
1140 script, and before the package is unpacked or any of its
1141 dependencies or pre-dependancies are satisfied.
1142 Therefore it must work using only the tools present in
1143 <em>essential</em> packages.<footnote>
1145 <package>Debconf</package> or another tool that
1146 implements the Debian Configuration management
1147 specification will also be installed, and any
1148 versioned dependencies on it will be satisfied
1149 before preconfiguration begins.
1155 Packages should try to minimize the amount of prompting
1156 they need to do, and they should ensure that the user
1157 will only ever be asked each question once. This means
1158 that packages should try to use appropriate shared
1159 configuration files (such as <file>/etc/papersize</file> and
1160 <file>/etc/news/server</file>), and shared
1161 <package>debconf</package> variables rather than each
1162 prompting for their own list of required pieces of
1167 It also means that an upgrade should not ask the same
1168 questions again, unless the user has used <tt>dpkg
1169 --purge</tt> to remove the package's configuration. The
1170 answers to configuration questions should be stored in an
1171 appropriate place in <file>/etc</file> so that the user can
1172 modify them, and how this has been done should be
1176 If a package has a vitally important piece of
1177 information to pass to the user (such as "don't run me
1178 as I am, you must edit the following configuration files
1179 first or you risk your system emitting badly-formatted
1180 messages"), it should display this in the
1181 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1182 prompt the user to hit return to acknowledge the
1183 message. Copyright messages do not count as vitally
1184 important (they belong in
1185 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1186 neither do instructions on how to use a program (these
1187 should be in on-line documentation, where all the users
1191 Any necessary prompting should almost always be confined
1192 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1193 script. If it is done in the <prgn>postinst</prgn>, it
1194 should be protected with a conditional so that
1195 unnecessary prompting doesn't happen if a package's
1196 installation fails and the <prgn>postinst</prgn> is
1197 called with <tt>abort-upgrade</tt>,
1198 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1203 <heading>Source packages</heading>
1205 <sect1 id="standardsversion">
1206 <heading>Standards conformance</heading>
1209 In the source package's <tt>Standards-Version</tt> control
1210 field, you should specify the most recent version number
1211 of this policy document with which your package complied
1212 when it was last updated. The current version number is
1217 This information may be used to file bug reports
1218 automatically if your package becomes too much out of
1223 The version number has four components: major and minor
1224 version number and major and minor patch level. When the
1225 standards change in a way that requires every package to
1226 change the major number will be changed. Significant
1227 changes that will require work in many packages will be
1228 signaled by a change to the minor number. The major patch
1229 level will be changed for any change to the meaning of the
1230 standards, however small; the minor patch level will be
1231 changed when only cosmetic, typographical or other edits
1232 are made which neither change the meaning of the document
1233 nor affect the contents of packages.</p>
1236 Thus only the first three components of the policy version
1237 are significant in the <em>Standards-Version</em> control
1238 field, and so either these three components or the all
1239 four components may be specified.<footnote>
1241 In the past, people specified the full version number
1242 in the Standards-Version field, for example "2.3.0.0".
1243 Since minor patch-level changes don"t introduce new
1244 policy, it was thought it would be better to relax
1245 policy and only require the first 3 components to be
1246 specified, in this example "2.3.0". All four
1247 components may still be used if someone wishes to do
1254 You should regularly, and especially if your package has
1255 become out of date, check for the newest Policy Manual
1256 available and update your package, if necessary. When your
1257 package complies with the new standards you should update the
1258 <tt>Standards-Version</tt> source package field and
1259 release it.<footnote>
1261 See the file <file>upgrading-checklist</file> for
1262 information about policy which has changed between
1263 different versions of this document.
1270 <sect1 id="pkg-relations">
1271 <heading>Package relationships</heading>
1274 Source packages should specify which binary packages they
1275 require to be installed or not to be installed in order to
1276 build correctly. For example, if building a package
1277 requires a certain compiler, then the compiler should be
1278 specified as a build-time dependency.
1282 It is not necessary to explicitly specify build-time
1283 relationships on a minimal set of packages that are always
1284 needed to compile, link and put in a Debian package a
1285 standard "Hello World!" program written in C or C++. The
1286 required packages are called <em>build-essential</em>, and
1287 an informational list can be found in
1288 <file>/usr/share/doc/build-essential/list</file> (which is
1289 contained in the <tt>build-essential</tt>
1292 <list compact="compact">
1294 <p>This allows maintaining the list separately
1295 from the policy documents (the list does not
1296 need the kind of control that the policy
1302 Having a separate package allows one to install
1303 the build-essential packages on a machine, as
1304 well as allowing other packages such as tasks to
1305 require installation of the build-essential
1306 packages using the depends relation.
1311 The separate package allows bug reports against
1312 the list to be categorized separately from
1313 the policy management process in the BTS.
1323 When specifying the set of build-time dependencies, one
1324 should list only those packages explicitly required by the
1325 build. It is not necessary to list packages which are
1326 required merely because some other package in the list of
1327 build-time dependencies depends on them.<footnote>
1329 The reason for this is that dependencies change, and
1330 you should list all those packages, and <em>only</em>
1331 those packages that <em>you</em> need directly. What
1332 others need is their business. For example, if you
1333 only link against <file>libimlib</file>, you will need to
1334 build-depend on <package>libimlib2-dev</package> but
1335 not against any <tt>libjpeg*</tt> packages, even
1336 though <tt>libimlib2-dev</tt> currently depends on
1337 them: installation of <package>libimlib2-dev</package>
1338 will automatically ensure that all of its run-time
1339 dependencies are satisfied.
1345 If build-time dependencies are specified, it must be
1346 possible to build the package and produce working binaries
1347 on a system with only essential and build-essential
1348 packages installed and also those required to satisfy the
1349 build-time relationships (including any implied
1350 relationships). In particular, this means that version
1351 clauses should be used rigorously in build-time
1352 relationships so that one cannot produce bad or
1353 inconsistently configured packages when the relationships
1354 are properly satisfied.
1358 <ref id="relationships"> explains the technical details.
1362 <heading>Changes to the upstream sources</heading>
1365 If changes to the source code are made that are not
1366 specific to the needs of the Debian system, they should be
1367 sent to the upstream authors in whatever form they prefer
1368 so as to be included in the upstream version of the
1372 If you need to configure the package differently for
1373 Debian or for Linux, and the upstream source doesn't
1374 provide a way to do so, you should add such configuration
1375 facilities (for example, a new <prgn>autoconf</prgn> test
1376 or <tt>#define</tt>) and send the patch to the upstream
1377 authors, with the default set to the way they originally
1378 had it. You can then easily override the default in your
1379 <file>debian/rules</file> or wherever is appropriate.</p>
1382 You should make sure that the <prgn>configure</prgn> utility
1383 detects the correct architecture specification string
1384 (refer to <ref id="arch-spec"> for details).</p>
1387 If you need to edit a <prgn>Makefile</prgn> where
1388 GNU-style <prgn>configure</prgn> scripts are used, you
1389 should edit the <file>.in</file> files rather than editing the
1390 <prgn>Makefile</prgn> directly. This allows the user to
1391 reconfigure the package if necessary. You should
1392 <em>not</em> configure the package and edit the generated
1393 <prgn>Makefile</prgn>! This makes it impossible for
1394 someone else to later reconfigure the package.</p>
1397 You should document your changes and updates to the source
1398 package properly in the <file>debian/changelog</file> file.
1399 For more information, please see <ref id="changelogs">.
1405 <heading>Error trapping in makefiles</heading>
1408 When <prgn>make</prgn> invokes a command in a makefile
1409 (including your package's upstream makefiles and
1410 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1411 means that <prgn>sh</prgn>'s usual bad error handling
1412 properties apply: if you include a miniature script as one
1413 of the commands in your makefile you'll find that if you
1414 don't do anything about it then errors are not detected
1415 and <prgn>make</prgn> will blithely continue after
1419 Every time you put more than one shell command (this
1420 includes using a loop) in a makefile command you
1421 must make sure that errors are trapped. For
1422 simple compound commands, such as changing directory and
1423 then running a program, using <tt>&&</tt> rather
1424 than semicolon as a command separator is sufficient. For
1425 more complex commands including most loops and
1426 conditionals you should include a separate <tt>set -e</tt>
1427 command at the start of every makefile command that's
1428 actually one of these miniature shell scripts.</p></sect1>
1432 <heading>Obsolete constructs and libraries</heading>
1435 The include file <tt><varargs.h></tt> is
1436 provided to support end-users compiling very old software;
1437 the library <tt>libtermcap</tt> is provided to support the
1438 execution of software which has been linked against it
1439 (either old programs or those such as Netscape which are
1440 only available in binary form).</p>
1443 Debian packages should be patched to use
1444 <tt><stdarg.h></tt> and <tt>ncurses</tt>
1451 <chapt id="controlfields"><heading>Control files and their fields</heading>
1454 Many of the tools in the package management suite manipulate
1455 data represented in a common format, known as <em>control
1456 data</em>. The data is often stored in <em>control
1457 files</em>. Binary and source packages have control files,
1458 and the <file>.changes</file> files which control the installation
1459 of uploaded files are also in control file format.
1460 <prgn>dpkg</prgn>'s internal databases are in a similar
1464 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1467 A control file consists of one or more paragraphs of fields.
1468 The paragraphs are separated by blank lines. Some control
1469 files allow only one paragraph; others allow several, in
1470 which case each paragraph usually refers to a different
1471 package. (For example, in source packages, the first
1472 paragraph refers to the source package, and later paragraphs
1473 refer to binary packages generated from the source.)
1477 Each paragraph consists of a series of data fields; each
1478 field consists of the field name, followed by a colon and
1479 then the data/value associated with that field. It ends at
1480 the end of the line. Horizontal whitespace (spaces and
1481 tabs) may occur immediately before or after the value and is
1482 ignored there; it is conventional to put a single space
1483 after the colon. For example, a field might be:
1484 <example compact="compact">
1487 the field name is <tt>Package</tt> and the field value
1492 Some fields' values may span several lines; in this case
1493 each continuation line <em>must</em> start with a space or
1494 tab. Any trailing spaces or tabs at the end of individual
1495 lines of a field value are ignored.
1499 Except where otherwise stated only a single line of data is
1500 allowed and whitespace is not significant in a field body.
1501 Whitespace must not appear inside names (of packages,
1502 architectures, files or anything else) or version numbers,
1503 or between the characters of multi-character version
1508 Field names are not case-sensitive, but it is usual to
1509 capitalize the field names using mixed case as shown below.
1513 Blank lines, or lines consisting only of spaces and tabs,
1514 are not allowed within field values or between fields - that
1515 would mean a new paragraph.
1520 <sect><heading>List of fields</heading>
1522 This list here is not supposed to be exhaustive. Most fields
1523 are dealt with elsewhere in this document.
1525 <sect1 id="f-Package"><heading><tt>Package</tt>
1529 The name of the binary package. Package names consist of
1530 lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1531 plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1532 periods (<tt>.</tt>).
1536 They must be at least two characters long and must start
1537 with an alphanumeric character. The use of lowercase
1538 package names is required unless the package you're
1539 building (or referring to, in other fields) is already
1540 using uppercase characters.</p>
1543 <sect1 id="f-Version"><heading><tt>Version</tt>
1547 This lists the source or binary package's version number -
1548 see <ref id="versions">.
1554 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1558 The most recent version of the standards (the policy
1559 manual and associated texts) with which the package
1560 complies. This is updated manually when editing the
1561 source package to conform to newer standards; it can
1562 sometimes be used to tell when a package needs attention.
1563 Its format is described above; see
1564 <ref id="standardsversion">.
1569 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1573 In a <file>.changes</file> file or parsed changelog output
1574 this contains the (space-separated) name(s) of the
1575 distribution(s) where this version of the package should
1576 be installed. Valid distributions are determined by the
1577 archive maintainers.<footnote>
1578 Current distribution names are:
1579 <taglist compact="compact">
1580 <tag><em>stable</em></tag>
1583 This is the current "released" version of Debian
1584 GNU/Linux. Once the distribution is
1585 <em>stable</em> only security fixes and other
1586 major bug fixes are allowed. When changes are
1587 made to this distribution, the release number is
1588 increased (for example: 2.2r1 becomes 2.2r2 then
1593 <tag><em>unstable</em></tag>
1596 This distribution value refers to the
1597 <em>developmental</em> part of the Debian
1598 distribution tree. New packages, new upstream
1599 versions of packages and bug fixes go into the
1600 <em>unstable</em> directory tree. Download from
1601 this distribution at your own risk.
1605 <tag><em>testing</em></tag>
1608 This distribution value refers to the
1609 <em>testing</em> part of the Debian distribution
1610 tree. It receives its packages from the
1611 unstable distribution after a short time lag to
1612 ensure that there are no major issues with the
1613 unstable packages. It is less prone to breakage
1614 than unstable, but still risky. It is not
1615 possible to upload packages directly to
1620 <tag><em>frozen</em></tag>
1623 From time to time, the <em>testing</em>
1624 distribution enters a state of "code-freeze" in
1625 anticipation of release as a <em>stable</em>
1626 version. During this period of testing only
1627 fixes for existing or newly-discovered bugs will
1628 be allowed. The exact details of this stage are
1629 determined by the Release Manager.
1633 <tag><em>experimental</em></tag>
1636 The packages with this distribution value are
1637 deemed by their maintainers to be high
1638 risk. Oftentimes they represent early beta or
1639 developmental packages from various sources that
1640 the maintainers want people to try, but are not
1641 ready to be a part of the other parts of the
1642 Debian distribution tree. Download at your own
1648 You should list <em>all</em> distributions that the
1649 package should be installed into.
1658 <chapt id="versions"><heading>Version numbering</heading>
1661 Every package has a version number recorded in its
1662 <tt>Version</tt> control file field.
1666 The package management system imposes an ordering on version
1667 numbers, so that it can tell whether packages are being up- or
1668 downgraded and so that package system front end applications
1669 can tell whether a package it finds available is newer than
1670 the one installed on the system. The version number format
1671 has the most significant parts (as far as comparison is
1672 concerned) at the beginning.
1676 The version number format is:
1677 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1681 The three components here are:
1683 <tag><var>epoch</var></tag>
1686 This is a single (generally small) unsigned integer. It
1687 may be omitted, in which case zero is assumed. If it is
1688 omitted then the <var>upstream_version</var> may not
1693 It is provided to allow mistakes in the version numbers
1694 of older versions of a package, and also a package's
1695 previous version numbering schemes, to be left behind.
1699 <tag><var>upstream_version</var></tag>
1702 This is the main part of the version number. It is
1703 usually the version number of the original ("upstream")
1704 package from which the <file>.deb</file> file has been made,
1705 if this is applicable. Usually this will be in the same
1706 format as that specified by the upstream author(s);
1707 however, it may need to be reformatted to fit into the
1708 package management system's format and comparison
1713 The comparison behavior of the package management system
1714 with respect to the <var>upstream_version</var> is
1715 described below. The <var>upstream_version</var>
1716 portion of the version number is mandatory.
1720 The <var>upstream_version</var> may contain only
1721 alphanumerics<footnote>
1722 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1724 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1725 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1726 start with a digit. If there is no
1727 <var>debian_revision</var> then hyphens are not allowed;
1728 if there is no <var>epoch</var> then colons are not
1732 <tag><var>debian_revision</var></tag>
1735 This part of the version number specifies the version of
1736 the Debian package based on the upstream version. It
1737 may contain only alphanumerics and the characters
1738 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1739 compared in the same way as the
1740 <var>upstream_version</var> is.
1744 It is optional; if it isn't present then the
1745 <var>upstream_version</var> may not contain a hyphen.
1746 This format represents the case where a piece of
1747 software was written specifically to be turned into a
1748 Debian package, and so there is only one "debianization"
1749 of it and therefore no revision indication is required.
1753 It is conventional to restart the
1754 <var>debian_revision</var> at <tt>1</tt> each time the
1755 <var>upstream_version</var> is increased.
1759 The package management system will break the version
1760 number apart at the last hyphen in the string (if there
1761 is one) to determine the <var>upstream_version</var> and
1762 <var>debian_revision</var>. The absence of a
1763 <var>debian_revision</var> compares earlier than the
1764 presence of one (but note that the
1765 <var>debian_revision</var> is the least significant part
1766 of the version number).
1773 The <var>upstream_version</var> and <var>debian_revision</var>
1774 parts are compared by the package management system using the
1779 The strings are compared from left to right.
1783 First the initial part of each string consisting entirely of
1784 non-digit characters is determined. These two parts (one of
1785 which may be empty) are compared lexically. If a difference
1786 is found it is returned. The lexical comparison is a
1787 comparison of ASCII values modified so that all the letters
1788 sort earlier than all the non-letters.
1792 Then the initial part of the remainder of each string which
1793 consists entirely of digit characters is determined. The
1794 numerical values of these two parts are compared, and any
1795 difference found is returned as the result of the comparison.
1796 For these purposes an empty string (which can only occur at
1797 the end of one or both version strings being compared) counts
1802 These two steps (comparing and removing initial non-digit
1803 strings and initial digit strings) are repeated until a
1804 difference is found or both strings are exhausted.
1808 Note that the purpose of epochs is to allow us to leave behind
1809 mistakes in version numbering, and to cope with situations
1810 where the version numbering scheme changes. It is
1811 <em>not</em> intended to cope with version numbers containing
1812 strings of letters which the package management system cannot
1813 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1814 silly orderings (the author of this manual has heard of a
1815 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1816 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1817 <tt>2</tt> and so forth).
1821 If an upstream package has problematic version numbers they
1822 should be converted to a sane form for use in the
1823 <tt>Version</tt> field.
1827 <heading>Version numbers based on dates</heading>
1829 In general, Debian packages should use the same version
1830 numbers as the upstream sources.</p>
1833 However, in some cases where the upstream version number is
1834 based on a date (e.g., a development "snapshot" release) the
1835 package management system cannot handle these version
1836 numbers without epochs. For example, dpkg will consider
1837 "96May01" to be greater than "96Dec24".</p>
1840 To prevent having to use epochs for every new upstream
1841 version, the version number should be changed to the
1842 following format in such cases: "19960501", "19961224". It
1843 is up to the maintainer whether he/she wants to bother the
1844 upstream maintainer to change the version numbers upstream,
1848 Note that other version formats based on dates which are
1849 parsed correctly by the package management system should
1850 <em>not</em> be changed.</p>
1853 Native Debian packages (i.e., packages which have been
1854 written especially for Debian) whose version numbers include
1855 dates should always use the "YYYYMMDD" format.</p>
1859 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1861 <sect id="timestamps"><heading>Time Stamps</heading>
1863 Maintainers should preserve the modification times of the
1864 upstream source files in a package, as far as is reasonably
1867 The rationale is that there is some information conveyed
1868 by knowing the age of the file, for example, you could
1869 recognize that some documentation is very old by looking
1870 at the modification time, so it would be nice if the
1871 modification time of the upstream source would be
1878 <sect id="debianrules"><heading><file>debian/rules</file> - the
1879 main building script</heading>
1882 This file must be an executable makefile, and contains the
1883 package-specific recipes for compiling the package and
1884 building binary package(s) from the source.
1888 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1889 so that it can be invoked by saying its name rather than
1890 invoking <prgn>make</prgn> explicitly.
1894 Since an interactive <file>debian/rules</file> script makes it
1895 impossible to auto-compile that package and also makes it
1896 hard for other people to reproduce the same binary
1897 package, all <em>required targets</em> MUST be
1898 non-interactive. At a minimum, required targets are the
1899 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1900 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1901 <em>binary-indep</em>, and <em>build</em>. It also follows
1902 that any target that these targets depend on must also be
1907 The required and optional targets are as follows:
1909 <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1910 <tt>build-indep</tt> (optional)</tag>
1913 The <tt>build</tt> target should perform all
1914 non-interactive configuration and compilation of the
1915 package. If a package has an interactive pre-build
1916 configuration routine, the Debianized source package
1917 must either be built after this has taken place (so
1918 that the binary package can be built without rerunning
1919 the configuration) or the configuration routine
1920 modified to become non-interactive. (The latter is
1921 preferable if there are architecture-specific features
1922 detected by the configuration routine.)
1926 For some packages, notably ones where the same
1927 source tree is compiled in different ways to produce
1928 two binary packages, the <tt>build</tt> target
1929 does not make much sense. For these packages it is
1930 good enough to provide two (or more) targets
1931 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1932 for each of the ways of building the package, and a
1933 <tt>build</tt> target that does nothing. The
1934 <tt>binary</tt> target will have to build the
1935 package in each of the possible ways and make the
1936 binary package out of each.
1940 The <tt>build</tt> target must not do anything
1941 that might require root privilege.
1945 The <tt>build</tt> target may need to run the
1946 <tt>clean</tt> target first - see below.
1950 When a package has a configuration and build routine
1951 which takes a long time, or when the makefiles are
1952 poorly designed, or when <tt>build</tt> needs to
1953 run <tt>clean</tt> first, it is a good idea to
1954 <tt>touch build</tt> when the build process is
1955 complete. This will ensure that if <tt>debian/rules
1956 build</tt> is run again it will not rebuild the whole
1959 Another common way to do this is for <tt>build</tt>
1960 to depend on <prgn>build-stamp</prgn> and to do
1961 nothing else, and for the <prgn>build-stamp</prgn>
1962 target to do the building and to <tt>touch
1963 build-stamp</tt> on completion. This is
1964 especially useful if the build routine creates a
1965 file or directory called <tt>build</tt>; in such a
1966 case, <tt>build</tt> will need to be listed as
1967 a phony target (i.e., as a dependency of the
1968 <tt>.PHONY</tt> target). See the documentation of
1969 <prgn>make</prgn> for more information on phony
1976 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1977 <tt>binary-indep</tt>
1981 The <tt>binary</tt> target must be all that is
1982 necessary for the user to build the binary package(s)
1983 produced from this source package. All of these
1984 targets are required to be non-interactive. It is
1985 split into two parts: <prgn>binary-arch</prgn> builds
1986 the binary packages which are specific to a particular
1987 architecture, and <tt>binary-indep</tt> builds
1988 those which are not.
1991 <tt>binary</tt> may be (and commonly is) a target with
1992 no commands which simply depends on
1993 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
1996 Both <tt>binary-*</tt> targets should depend on the
1997 <tt>build</tt> target, or on the appropriate
1998 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
1999 provided, so that the package is built if it has not
2000 been already. It should then create the relevant
2001 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
2002 make their control files and <prgn>dpkg-deb</prgn> to
2003 build them and place them in the parent of the top
2008 Both the <tt>binary-arch</tt> and
2009 <tt>binary-indep</tt> targets <em>must</em> exist.
2010 If one of them has nothing to do (which will always be
2011 the case if the source generates only a single binary
2012 package, whether architecture-dependent or not), it
2013 must still exist and must always succeed.
2017 The <tt>binary</tt> targets must be invoked as
2020 The <prgn>fakeroot</prgn> package often allows one
2021 to build a package correctly even without being
2028 <tag><tt>clean</tt></tag>
2031 This must undo any effects that the <tt>build</tt>
2032 and <tt>binary</tt> targets may have had, except
2033 that it should leave alone any output files created in
2034 the parent directory by a run of a <tt>binary</tt>
2035 target. This target must be non-interactive.
2039 If a <tt>build</tt> file is touched at the end of
2040 the <tt>build</tt> target, as suggested above, it
2041 should be removed as the first action that
2042 <tt>clean</tt> performs, so that running
2043 <tt>build</tt> again after an interrupted
2044 <tt>clean</tt> doesn't think that everything is
2049 The <tt>clean</tt> target may need to be
2050 invoked as root if <tt>binary</tt> has been
2051 invoked since the last <tt>clean</tt>, or if
2052 <tt>build</tt> has been invoked as root (since
2053 <tt>build</tt> may create directories, for
2058 <tag><tt>get-orig-source</tt> (optional)</tag>
2061 This target fetches the most recent version of the
2062 original source package from a canonical archive site
2063 (via FTP or WWW, for example), does any necessary
2064 rearrangement to turn it into the original source
2065 tar file format described below, and leaves it in the
2070 This target may be invoked in any directory, and
2071 should take care to clean up any temporary files it
2076 This target is optional, but providing it if
2077 possible is a good idea.
2083 The <tt>build</tt>, <tt>binary</tt> and
2084 <tt>clean</tt> targets must be invoked with the current
2085 directory being the package's top-level directory.
2090 Additional targets may exist in <file>debian/rules</file>,
2091 either as published or undocumented interfaces or for the
2092 package's internal use.
2096 The architectures we build on and build for are determined
2097 by <prgn>make</prgn> variables using the utility
2098 <prgn>dpkg-architecture</prgn>. You can determine the
2099 Debian architecture and the GNU style architecture
2100 specification string for the build machine (the machine type
2101 we are building on) as well as for the host machine (the
2102 machine type we are building for). Here is a list of
2103 supported <prgn>make</prgn> variables:
2104 <list compact="compact">
2106 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2109 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2110 specification string)</p>
2113 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2114 <tt>DEB_*_GNU_TYPE</tt>)</p>
2117 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2118 <tt>DEB_*_GNU_TYPE</tt>)</p>
2120 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2121 the build machine or <tt>HOST</tt> for specification of the
2126 Backward compatibility can be provided in the rules file
2127 by setting the needed variables to suitable default
2128 values; please refer to the documentation of
2129 <prgn>dpkg-architecture</prgn> for details.
2133 It is important to understand that the <tt>DEB_*_ARCH</tt>
2134 string only determines which Debian architecture we are
2135 building on or for. It should not be used to get the CPU
2136 or system information; the GNU style variables should be
2141 <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2145 This file records the changes to the Debian-specific parts of the
2148 Though there is nothing stopping an author who is also
2149 the Debian maintainer from using it for all their
2150 changes, it will have to be renamed if the Debian and
2151 upstream maintainers become different people. In such a
2152 case, however, it might be better to maintain the
2153 package as a non-native package.
2159 It has a special format which allows the package building
2160 tools to discover which version of the package is being
2161 built and find out other release-specific information.
2165 That format is a series of entries like this:
2166 <example compact="compact">
2167 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2169 <p>[optional blank line(s), stripped]</p>
2171 * <var>change details</var>
2172 <var>more change details</var>
2174 <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2176 * <var>even more change details</var>
2178 <p>[optional blank line(s), stripped]</p>
2180 -- <var>maintainer name</var> <<var>email
2181 address</var>><var>[two spaces]</var> <var>date</var>
2186 <var>package</var> and <var>version</var> are the source
2187 package name and version number.
2191 <var>distribution(s)</var> lists the distributions where
2192 this version should be installed when it is uploaded - it
2193 is copied to the <tt>Distribution</tt> field in the
2194 <file>.changes</file> file. See <ref id="f-Distribution">.
2198 <var>urgency</var> is the value for the <tt>Urgency</tt>
2199 field in the <file>.changes</file> file for the upload. It is
2200 not possible to specify an urgency containing commas; commas
2201 are used to separate
2202 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2203 <prgn>dpkg</prgn> changelog format (though there is
2204 currently only one useful <var>keyword</var>,
2205 <tt>urgency</tt>).<footnote>
2207 Recognised urgency values are <tt>low</tt>,
2208 <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2209 They have an effect on how quickly a package will be
2210 considered for inclusion into the <tt>testing</tt>
2211 distribution, and give an indication of the importance
2212 of any fixes included in this upload.
2218 The change details may in fact be any series of lines
2219 starting with at least two spaces, but conventionally each
2220 change starts with an asterisk and a separating space and
2221 continuation lines are indented so as to bring them in
2222 line with the start of the text above. Blank lines may be
2223 used here to separate groups of changes, if desired.
2227 If this upload resolves bugs recorded in the Bug Tracking
2228 System (BTS), they may be automatically closed on the
2229 inclusion of this package into the Debian archive by
2230 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2231 in the change details.<footnote>
2233 To be precise, the string should match the following
2234 Perl regular expression:
2236 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2238 Then all of the bug numbers listed will be closed by the
2239 archive maintenance script (<prgn>katie</prgn>), or in
2240 the case of an NMU, marked as fixed.
2246 The maintainer name and email address used in the changelog
2247 should be the details of the person uploading <em>this</em>
2248 version. They are <em>not</em> necessarily those of the
2249 usual package maintainer. The information here will be
2250 copied to the <tt>Changed-By</tt> field in the
2251 <tt>.changes</tt> file, and then later used to send an
2252 acknowledgement when the upload has been installed.
2256 The <var>date</var> should be in RFC822 format<footnote>
2258 This is generated by the <prgn>822-date</prgn>
2261 </footnote>; it should include the time zone specified
2262 numerically, with the time zone name or abbreviation
2263 optionally present as a comment in parentheses.
2267 The first "title" line with the package name should start
2268 at the left hand margin; the "trailer" line with the
2269 maintainer and date details should be preceded by exactly
2270 one space. The maintainer details and the date must be
2271 separated by exactly two spaces.
2274 <sect1><heading>Defining alternative changelog formats</heading>
2277 It is possible to use a different format to the standard
2278 one, by providing a parser for the format you wish to
2282 A changelog parser must not interact with the user at
2288 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
2290 <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2291 and variable substitutions </heading>
2294 When <prgn>dpkg-gencontrol</prgn>,
2295 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2296 generate control files they perform variable substitutions
2297 on their output just before writing it. Variable
2298 substitutions have the form <tt>${<var>variable</var>}</tt>.
2299 The optional file <file>debian/substvars</file> contains
2300 variable substitutions to be used; variables can also be set
2301 directly from <file>debian/rules</file> using the <tt>-V</tt>
2302 option to the source packaging commands, and certain
2303 predefined variables are also available.
2307 The <file>debian/substvars</file> file is usually generated and
2308 modified dynamically by <file>debian/rules</file> targets, in
2309 which case it must be removed by the <tt>clean</tt> target.
2313 See <manref name="dpkg-source" section="1"> for full
2314 details about source variable substitutions, including the
2315 format of <file>debian/substvars</file>.</p>
2318 <sect id="debianfiles"><heading><file>debian/files</file>
2322 This file is not a permanent part of the source tree; it
2323 is used while building packages to record which files are
2324 being generated. <prgn>dpkg-genchanges</prgn> uses it
2325 when it generates a <file>.changes</file> file.
2329 It should not exist in a shipped source package, and so it
2330 (and any backup files or temporary files such as
2331 <file>files.new</file><footnote>
2333 <file>files.new</file> is used as a temporary file by
2334 <prgn>dpkg-gencontrol</prgn> and
2335 <prgn>dpkg-distaddfile</prgn> - they write a new
2336 version of <tt>files</tt> here before renaming it,
2337 to avoid leaving a corrupted copy if an error
2340 </footnote>) should be removed by the
2341 <tt>clean</tt> target. It may also be wise to
2342 ensure a fresh start by emptying or removing it at the
2343 start of the <tt>binary</tt> target.
2347 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2348 package, it adds an entry to <file>debian/files</file> for the
2349 <file>.deb</file> file that will be created when <tt>dpkg-deb
2350 --build</tt> is run for that binary package. So for most
2351 packages all that needs to be done with this file is to
2352 delete it in the <tt>clean</tt> target.
2356 If a package upload includes files besides the source
2357 package and any binary packages whose control files were
2358 made with <prgn>dpkg-gencontrol</prgn> then they should be
2359 placed in the parent of the package's top-level directory
2360 and <prgn>dpkg-distaddfile</prgn> should be called to add
2361 the file to the list in <file>debian/files</file>.</p>
2364 <sect id="restrictions"><heading>Restrictions on objects in source packages
2368 The source package may not contain any hard links<footnote>
2370 This is not currently detected when building source
2371 packages, but only when extracting
2375 Hard links may be permitted at some point in the
2376 future, but would require a fair amount of
2379 </footnote>, device special files, sockets or setuid or
2380 setgid files.<footnote>
2382 Setgid directories are allowed.
2388 <sect id="descriptions"><heading>Descriptions of packages - the
2389 <tt>Description</tt> field</heading>
2392 The "Description" control file field consists of two parts,
2393 the synopsis or the short description, and the long description.
2394 The field's format is as follows:
2398 Description: <single line synopsis>
2399 <extended description over several lines>
2403 The description is intended to describe the program to a user
2404 who has never met it before so that they know whether they
2405 want to install it. It should also give information about the
2406 significant dependencies and conflicts between this package
2407 and others, so that the user knows why these dependencies and
2408 conflicts have been declared.
2412 Put important information first, both in the synopsis and
2413 extended description. Sometimes only the first part of the
2414 synopsis or of the description will be displayed. You can
2415 assume that there will usually be a way to see the whole
2416 extended description.
2419 <sect1 id="synopsis"><heading>The single line synopsis</heading>
2422 The single line synopsis should be kept brief - certainly
2423 under 80 characters.
2427 Do not include the package name in the synopsis line. The
2428 display software knows how to display this already, and you
2429 do not need to state it. Remember that in many situations
2430 the user may only see the synopsis line - make it as
2431 informative as you can.
2436 <sect1 id="extendeddesc"><heading>The extended description</heading>
2439 Do not try to continue the single line synopsis into the
2440 extended description. This will not work correctly when
2441 the full description is displayed, and makes no sense
2442 where only the summary (the single line synopsis) is
2447 The extended description should describe what the package
2448 does and how it relates to the rest of the system (in terms
2449 of, for example, which subsystem it is which part of).
2453 The description field needs to make sense to anyone, even
2454 people who have no idea about any of the things the
2455 package deals with.<footnote>
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.
2465 The lines in the extended description can have these formats:
2471 Those starting with a single space are part of a paragraph.
2472 Successive lines of this form will be word-wrapped when
2473 displayed. The leading space will usually be stripped off.
2477 Those starting with two or more spaces. These will be
2478 displayed verbatim. If the display cannot be panned
2479 horizontally, the displaying program will linewrap them "hard"
2480 (i.e., without taking account of word breaks). If it can they
2481 will be allowed to trail off to the right. None, one or two
2482 initial spaces may be deleted, but the number of spaces
2483 deleted from each line will be the same (so that you can have
2484 indenting work correctly, for example).
2488 Those containing a single space followed by a single full stop
2489 character. These are rendered as blank lines. This is the
2490 <em>only</em> way to get a blank line<footnote>
2491 Completely empty lines will not be rendered as blank lines.
2492 Instead, they will cause the parser to think you're starting
2493 a whole new record in the control file, and will therefore
2494 likely abort with an error.
2499 Those containing a space, a full stop and some more characters.
2500 These are for future expansion. Do not use them.
2506 Do not use tab characters. Their effect is not predictable.
2516 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2517 and installation procedure
2520 <sect><heading>Introduction to package maintainer scripts
2524 It is possible to supply scripts as part of a package which
2525 the package management system will run for you when your
2526 package is installed, upgraded or removed.
2530 These scripts are the files <prgn>preinst</prgn>,
2531 <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2532 control area of the package. They must be proper executable
2533 files; if they are scripts (which is recommended), they must
2534 start with the usual <tt>#!</tt> convention. They should be
2535 readable and executable by anyone, and not world-writable.
2539 The package management system looks at the exit status from
2540 these scripts. It is important that they exit with a
2541 non-zero status if there is an error, so that the package
2542 management system can stop its processing. For shell
2543 scripts this means that you <em>almost always</em> need to
2544 use <tt>set -e</tt> (this is usually true when writing shell
2545 scripts, in fact). It is also important, of course, that
2546 they don't exit with a non-zero status if everything went
2551 When a package is upgraded a combination of the scripts from
2552 the old and new packages is called during the upgrade
2553 procedure. If your scripts are going to be at all
2554 complicated you need to be aware of this, and may need to
2555 check the arguments to your scripts.
2559 Broadly speaking the <prgn>preinst</prgn> is called before
2560 (a particular version of) a package is installed, and the
2561 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2562 before (a version of) a package is removed and the
2563 <prgn>postrm</prgn> afterwards.
2567 Programs called from maintainer scripts should not normally
2568 have a path prepended to them. Before installation is
2569 started, the package management system checks to see if the
2570 programs <prgn>ldconfig</prgn>,
2571 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2572 and <prgn>update-rc.d</prgn> can be found via the
2573 <tt>PATH</tt> environment variable. Those programs, and any
2574 other program that one would expect to be on the
2575 <tt>PATH</tt>, should thus be invoked without an absolute
2576 pathname. Maintainer scripts should also not reset the
2577 <tt>PATH</tt>, though they might choose to modify it by
2578 prepending or appending package-specific directories. These
2579 considerations really apply to all shell scripts.</p>
2583 <heading>Maintainer scripts Idempotency</heading>
2586 It is necessary for the error recovery procedures that the
2587 scripts be idempotent. This means that if it is run
2588 successfully, and then it is called again, it doesn't bomb
2589 out or cause any harm, but just ensures that everything is
2590 the way it ought to be. If the first call failed, or
2591 aborted half way through for some reason, the second call
2592 should merely do the things that were left undone the first
2593 time, if any, and exit with a success status if everything
2596 This is so that if an error occurs, the user interrupts
2597 <prgn>dpkg</prgn> or some other unforeseen circumstance
2598 happens you don't leave the user with a badly-broken
2599 package when <prgn>dpkg</prgn> attempts to repeat the
2607 <heading>Controlling terminal for maintainer scripts</heading>
2610 The maintainer scripts are guaranteed to run with a
2611 controlling terminal and can interact with the user.
2612 If they need to prompt for passwords, do full-screen
2613 interaction or something similar you should do these
2614 things to and from <file>/dev/tty</file>, since
2615 <prgn>dpkg</prgn> will at some point redirect scripts'
2616 standard input and output so that it can log the
2617 installation process. Likewise, because these scripts
2618 may be executed with standard output redirected into a
2619 pipe for logging purposes, Perl scripts should set
2620 unbuffered output by setting <tt>$|=1</tt> so that the
2621 output is printed immediately rather than being
2626 Each script should return a zero exit status for
2627 success, or a nonzero one for failure.
2631 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2636 <list compact="compact">
2638 <p><var>new-preinst</var> <tt>install</tt></p>
2641 <p><var>new-preinst</var> <tt>install</tt>
2642 <var>old-version</var></p>
2645 <p><var>new-preinst</var> <tt>upgrade</tt>
2646 <var>old-version</var></p>
2649 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2650 <var>new-version</var>
2656 <list compact="compact">
2658 <p><var>postinst</var> <tt>configure</tt>
2659 <var>most-recently-configured-version</var></p>
2662 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2663 <var>new-version</var></p>
2666 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2667 <tt>in-favour</tt> <var>package</var>
2668 <var>new-version</var></p>
2672 <var>deconfigured's-postinst</var>
2673 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2674 <var>failed-install-package</var> <var>version</var>
2675 <tt>removing</tt> <var>conflicting-package</var>
2682 <list compact="compact">
2684 <p><var>prerm</var> <tt>remove</tt></p>
2687 <p><var>old-prerm</var> <tt>upgrade</tt>
2688 <var>new-version</var></p>
2691 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2692 <var>old-version</var></p>
2695 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2696 <tt>in-favour</tt> <var>package</var>
2697 <var>new-version</var></p>
2701 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2702 <tt>in-favour</tt> <var>package-being-installed</var>
2703 <var>version</var> <tt>removing</tt>
2704 <var>conflicting-package</var>
2711 <list compact="compact">
2713 <p><var>postrm</var> <tt>remove</tt></p>
2716 <p><var>postrm</var> <tt>purge</tt></p>
2720 <var>old-postrm</var> <tt>upgrade</tt>
2721 <var>new-version</var></p>
2724 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2725 <var>old-version</var></p>
2728 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2731 <p><var>new-postrm</var> <tt>abort-install</tt>
2732 <var>old-version</var></p>
2735 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2736 <var>old-version</var></p>
2740 <var>disappearer's-postrm</var> <tt>disappear</tt>
2741 <var>overwriter</var>
2742 <var>overwriter-version</var></p></item>
2747 <sect id="unpackphase"><heading>Details of unpack phase of
2748 installation or upgrade
2752 The procedure on installation/upgrade/overwrite/disappear
2753 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2754 stage of <tt>dpkg --install</tt>) is as follows. In each
2755 case, if a major error occurs (unless listed below) the
2756 actions are, in general, run backwards - this means that the
2757 maintainer scripts are run with different arguments in
2758 reverse order. These are the "error unwind" calls listed
2766 <p>If a version of the package is already
2768 <example compact="compact">
2769 <var>old-prerm</var> upgrade <var>new-version</var>
2774 If the script runs but exits with a non-zero
2775 exit status, <prgn>dpkg</prgn> will attempt:
2776 <example compact="compact">
2777 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2779 Error unwind, for both the above cases:
2780 <example compact="compact">
2781 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2789 <p>If a "conflicting" package is being removed at the same time:
2793 If any packages depended on that conflicting
2794 package and <tt>--auto-deconfigure</tt> is
2795 specified, call, for each such package:
2796 <example compact="compact">
2797 <var>deconfigured's-prerm</var> deconfigure \
2798 in-favour <var>package-being-installed</var> <var>version</var> \
2799 removing <var>conflicting-package</var> <var>version</var>
2802 <example compact="compact">
2803 <var>deconfigured's-postinst</var> abort-deconfigure \
2804 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2805 removing <var>conflicting-package</var> <var>version</var>
2807 The deconfigured packages are marked as
2808 requiring configuration, so that if
2809 <tt>--install</tt> is used they will be
2810 configured again if possible.</p>
2813 <p>To prepare for removal of the conflicting package, call:
2814 <example compact="compact">
2815 <var>conflictor's-prerm</var> remove \
2816 in-favour <var>package</var> <var>new-version</var>
2819 <example compact="compact">
2820 <var>conflictor's-postinst</var> abort-remove \
2821 in-favour <var>package</var> <var>new-version</var>
2832 <p>If the package is being upgraded, call:
2833 <example compact="compact">
2834 <var>new-preinst</var> upgrade <var>old-version</var>
2839 Otherwise, if the package had some configuration
2840 files from a previous version installed (i.e., it
2841 is in the "configuration files only" state):
2842 <example compact="compact">
2843 <var>new-preinst</var> install <var>old-version</var>
2847 <p>Otherwise (i.e., the package was completely purged):
2848 <example compact="compact">
2849 <var>new-preinst</var> install
2851 Error unwind actions, respectively:
2852 <example compact="compact">
2853 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2854 <var>new-postrm</var> abort-install <var>old-version</var>
2855 <var>new-postrm</var> abort-install
2864 The new package's files are unpacked, overwriting any
2865 that may be on the system already, for example any
2866 from the old version of the same package or from
2867 another package. Backups of the old files are kept
2868 temporarily, and if anything goes wrong the package
2869 management system will attempt to put them back as
2870 part of the error unwind.
2874 It is an error for a package to contains files which
2875 are on the system in another package, unless
2876 <tt>Replaces</tt> is used (see <ref id="replaces">).
2878 The following paragraph is not currently the case:
2879 Currently the <tt>- - force-overwrite</tt> flag is
2880 enabled, downgrading it to a warning, but this may not
2886 It is a more serious error for a package to contain a
2887 plain file or other kind of non-directory where another
2888 package has a directory (again, unless
2889 <tt>Replaces</tt> is used). This error can be
2890 overridden if desired using
2891 <tt>--force-overwrite-dir</tt>, but this is not
2896 Packages which overwrite each other's files produce
2897 behavior which, though deterministic, is hard for the
2898 system administrator to understand. It can easily
2899 lead to "missing" programs if, for example, a package
2900 is installed which overwrites a file from another
2901 package, and is then removed again.<footnote>
2903 Part of the problem is due to what is arguably a
2904 bug in <prgn>dpkg</prgn>.
2910 A directory will never be replaced by a symbolic link
2911 to a directory or vice versa; instead, the existing
2912 state (symlink or not) will be left alone and
2913 <prgn>dpkg</prgn> will follow the symlink if there is
2921 <p>If the package is being upgraded, call
2922 <example compact="compact">
2923 <var>old-postrm</var> upgrade <var>new-version</var>
2928 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2929 <example compact="compact">
2930 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2932 Error unwind, for both cases:
2933 <example compact="compact">
2934 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2941 This is the point of no return - if
2942 <prgn>dpkg</prgn> gets this far, it won't back off
2943 past this point if an error occurs. This will
2944 leave the package in a fairly bad state, which
2945 will require a successful re-installation to clear
2946 up, but it's when <prgn>dpkg</prgn> starts doing
2947 things that are irreversible.
2952 Any files which were in the old version of the package
2953 but not in the new are removed.</p>
2956 <p>The new file list replaces the old.</p>
2959 <p>The new maintainer scripts replace the old.</p>
2963 <p>Any packages all of whose files have been overwritten during the
2964 installation, and which aren't required for
2965 dependencies, are considered to have been removed.
2966 For each such package
2969 <p><prgn>dpkg</prgn> calls:
2970 <example compact="compact">
2971 <var>disappearer's-postrm</var> disappear \
2972 <var>overwriter</var> <var>overwriter-version</var>
2977 <p>The package's maintainer scripts are removed.
2982 It is noted in the status database as being in a
2983 sane state, namely not installed (any conffiles
2984 it may have are ignored, rather than being
2985 removed by <prgn>dpkg</prgn>). Note that
2986 disappearing packages do not have their prerm
2987 called, because <prgn>dpkg</prgn> doesn't know
2988 in advance that the package is going to
2997 Any files in the package we're unpacking that are also
2998 listed in the file lists of other packages are removed
2999 from those lists. (This will lobotomize the file list
3000 of the "conflicting" package if there is one.)
3005 The backup files made during installation, above, are
3012 The new package's status is now sane, and recorded as
3017 Here is another point of no return - if the
3018 conflicting package's removal fails we do not unwind
3019 the rest of the installation; the conflicting package
3020 is left in a half-removed limbo.
3026 If there was a conflicting package we go and do the
3027 removal actions (described below), starting with the
3028 removal of the conflicting package's files (any that
3029 are also in the package being installed have already
3030 been removed from the conflicting package's file list,
3031 and so do not get removed now).
3038 <sect id="configdetails"><heading>Details of configuration</heading>
3041 When we configure a package (this happens with <tt>dpkg
3042 --install</tt> and <tt>dpkg --configure</tt>), we first
3043 update any <tt>conffile</tt>s and then call:
3044 <example compact="compact">
3045 <var>postinst</var> configure <var>most-recently-configured-version</var>
3050 No attempt is made to unwind after errors during
3055 If there is no most recently configured version
3056 <prgn>dpkg</prgn> will pass a null argument; older versions
3057 of dpkg may pass <tt><unknown></tt> (including the
3058 angle brackets) in this case. Even older ones do not pass a
3059 second argument at all, under any circumstances.
3063 <sect id="removedetails"><heading>Details of removal and/or
3064 configuration purging</heading>
3070 <example compact="compact">
3071 <var>prerm</var> remove
3077 The package's files are removed (except <tt>conffile</tt>s).
3082 <example compact="compact">
3083 <var>postrm</var> remove
3089 All the maintainer scripts except the <prgn>postrm</prgn>
3094 If we aren't purging the package we stop here. Note
3095 that packages which have no <prgn>postrm</prgn> and no
3096 <tt>conffile</tt>s are automatically purged when
3097 removed, as there is no difference except for the
3098 <prgn>dpkg</prgn> status.</p>
3102 The <tt>conffile</tt>s and any backup files
3103 (<tt>~</tt>-files, <tt>#*#</tt> files,
3104 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3109 <example compact="compact">
3110 <var>postrm</var> purge
3115 <p>The package's file list is removed.</p>
3118 No attempt is made to unwind after errors during
3125 <chapt id="relationships"><heading>Declaring relationships between
3128 <sect id="depsyntax"><heading>Syntax of relationship fields
3132 These fields all have a uniform syntax. They are a list of
3133 package names separated by commas.
3137 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3138 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3139 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3140 control file fields of the package, which declare
3141 dependencies on other packages, the package names listed may
3142 also include lists of alternative package names, separated
3143 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3144 if any one of the alternative packages is installed, that
3145 part of the dependency is considered to be satisfied.
3149 All of the fields except for <tt>Provides</tt> may restrict
3150 their applicability to particular versions of each named
3151 package. This is done in parentheses after each individual
3152 package name; the parentheses should contain a relation from
3153 the list below followed by a version number, in the format
3154 described in <ref id="versions">.
3158 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3159 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3160 strictly earlier, earlier or equal, exactly equal, later or
3161 equal and strictly later, respectively. The deprecated
3162 forms <tt><</tt> and <tt>></tt> were used to mean
3163 earlier/later or equal, rather than strictly earlier/later,
3164 so they should not appear in new packages (though
3165 <prgn>dpkg</prgn> still supports them).
3169 Whitespace may appear at any point in the version
3170 specification subject to the rules in <ref
3171 id="controlsyntax">, and must appear where it's necessary to
3172 disambiguate; it is not otherwise significant. For
3173 consistency and in case of future changes to
3174 <prgn>dpkg</prgn> it is recommended that a single space be
3175 used after a version relationship and before a version
3176 number; it is also conventional to put a single space after
3177 each comma, on either side of each vertical bar, and before
3178 each open parenthesis.
3182 For example, a list of dependencies might appear as:
3183 <example compact="compact">
3186 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3191 All fields that specify build-time relationships
3192 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3193 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3194 may be restricted to a certain set of architectures. This
3195 is indicated in brackets after each individual package name and
3196 the optional version specification. The brackets enclose a
3197 list of Debian architecture names separated by whitespace.
3198 Exclamation marks may be prepended to each of the names.
3199 (It is not permitted for some names to be prepended with
3200 exclamation marks and others not.) If the current Debian
3201 host architecture is not in this list and there are no
3202 exclamation marks in the list, or it is in the list with a
3203 prepended exclamation mark, the package name and the
3204 associated version specification are ignored completely for
3205 the purposes of defining the relationships.
3210 <example compact="compact">
3212 Build-Depends-Indep: texinfo
3213 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3214 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3219 Note that the binary package relationship fields such as
3220 <tt>Depends</tt> appear in one of the binary package
3221 sections of the control file, whereas the build-time
3222 relationships such as <tt>Build-Depends</tt> appear in the
3223 source package section of the control file (which is the
3229 <heading>Binary Dependencies - <tt>Depends</tt>,
3230 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3231 <tt>Pre-Depends</tt>
3235 Packages can declare in their control file that they have
3236 certain relationships to other packages - for example, that
3237 they may not be installed at the same time as certain other
3238 packages, and/or that they depend on the presence of others.
3242 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3243 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt> and
3244 <tt>Conflicts</tt> control file fields.
3248 These six fields are used to declare a dependency
3249 relationship by one package on another. Except for
3250 <tt>Enhances</tt>, they appear in the depending (binary)
3251 package's control file. (<tt>Enhances</tt> appears in the
3252 recommending package's control file.)
3256 A <tt>Depends</tt> field takes effect <em>only</em> when a
3257 package is to be configured. It does not prevent a package
3258 being on the system in an unconfigured state while its
3259 dependencies are unsatisfied, and it is possible to replace
3260 a package whose dependencies are satisfied and which is
3261 properly installed with a different version whose
3262 dependencies are not and cannot be satisfied; when this is
3263 done the depending package will be left unconfigured (since
3264 attempts to configure it will give errors) and will not
3265 function properly. If it is necessary, a
3266 <tt>Pre-Depends</tt> field can be used, which has a partial
3267 effect even when a package is being unpacked, as explained
3268 in detail below. (The other three dependency fields,
3269 <tt>Recommends</tt>, <tt>Suggests</tt> and
3270 <tt>Enhances</tt>, are only used by the various front-ends
3271 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3275 For this reason packages in an installation run are usually
3276 all unpacked first and all configured later; this gives
3277 later versions of packages with dependencies on later
3278 versions of other packages the opportunity to have their
3279 dependencies satisfied.
3283 The <tt>Depends</tt> field thus allows package maintainers
3284 to impose an order in which packages should be configured.
3288 The meaning of the five dependency fields is as follows:
3290 <tag><tt>Depends</tt></tag>
3293 This declares an absolute dependency. A package will
3294 not be configured unless all of the packages listed in
3295 its <tt>Depends</tt> field have been correctly
3300 The <tt>Depends</tt> field should be used if the
3301 depended-on package is required for the depending
3302 package to provide a significant amount of
3306 The <tt>Depends</tt> field should also be used if the
3307 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3308 <prgn>postrm</prgn> scripts require the package to be
3309 present in order to run. Note, however, that the
3310 <prgn>postrm</prgn> cannot rely on any non-essential
3311 packages to be present during the <tt>purge</tt>
3315 <tag><tt>Recommends</tt></tag>
3317 <p>This declares a strong, but not absolute, dependency.
3321 The <tt>Recommends</tt> field should list packages
3322 that would be found together with this one in all but
3323 unusual installations.</p>
3326 <tag><tt>Suggests</tt></tag>
3329 This is used to declare that one package may be more
3330 useful with one or more others. Using this field
3331 tells the packaging system and the user that the
3332 listed packages are related to this one and can
3333 perhaps enhance its usefulness, but that installing
3334 this one without them is perfectly reasonable.
3338 <tag><tt>Enhances</tt></tag>
3341 This field is similar to Suggests but works in the
3342 opposite direction. It is used to declare that a
3343 package can enhance the functionality of another
3348 <tag><tt>Pre-Depends</tt></tag>
3351 This field is like <tt>Depends</tt>, except that it
3352 also forces <prgn>dpkg</prgn> to complete installation
3353 of the packages named before even starting the
3354 installation of the package which declares the
3355 pre-dependency, as follows:
3359 When a package declaring a pre-dependency is about to
3360 be <em>unpacked</em> the pre-dependency can be
3361 satisfied if the depended-on package is either fully
3362 configured, <em>or even if</em> the depended-on
3363 package(s) are only unpacked or half-configured,
3364 provided that they have been configured correctly at
3365 some point in the past (and not removed or partially
3366 removed since). In this case, both the
3367 previously-configured and currently unpacked or
3368 half-configured versions must satisfy any version
3369 clause in the <tt>Pre-Depends</tt> field.
3373 When the package declaring a pre-dependency is about
3374 to be <em>configured</em>, the pre-dependency will be
3375 treated as a normal <tt>Depends</tt>, that is, it will
3376 be considered satisfied only if the depended-on
3377 package has been correctly configured.
3381 <tt>Pre-Depends</tt> should be used sparingly,
3382 preferably only by packages whose premature upgrade or
3383 installation would hamper the ability of the system to
3384 continue with any upgrade that might be in progress.
3388 <tt>Pre-Depends</tt> are also required if the
3389 <prgn>preinst</prgn> script depends on the named
3390 package. It is best to avoid this situation if
3396 When selecting which level of dependency to use you should
3397 consider how important the depended-on package is to the
3398 functionality of the one declaring the dependency. Some
3399 packages are composed of components of varying degrees of
3400 importance. Such a package should list using
3401 <tt>Depends</tt> the package(s) which are required by the
3402 more important components. The other components'
3403 requirements may be mentioned as Suggestions or
3404 Recommendations, as appropriate to the components' relative
3409 <sect id="conflicts"><heading>Conflicting binary packages -
3410 <tt>Conflicts</tt></heading>
3413 When one binary package declares a conflict with another
3414 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3415 refuse to allow them to be installed on the system at the
3420 If one package is to be installed, the other must be removed
3421 first - if the package being installed is marked as
3422 replacing (see <ref id="replaces">) the one on the system,
3423 or the one on the system is marked as deselected, or both
3424 packages are marked <tt>Essential</tt>, then
3425 <prgn>dpkg</prgn> will automatically remove the package
3426 which is causing the conflict, otherwise it will halt the
3427 installation of the new package with an error. This
3428 mechanism is specifically designed to produce an error when
3429 the installed package is <tt>Essential</tt>, but the new
3434 A package will not cause a conflict merely because its
3435 configuration files are still installed; it must be at least
3440 A special exception is made for packages which declare a
3441 conflict with their own package name, or with a virtual
3442 package which they provide (see below): this does not
3443 prevent their installation, and allows a package to conflict
3444 with others providing a replacement for it. You use this
3445 feature when you want the package in question to be the only
3446 package providing some feature.
3450 A <tt>Conflicts</tt> entry should almost never have an
3451 "earlier than" version clause. This would prevent
3452 <prgn>dpkg</prgn> from upgrading or installing the package
3453 which declared such a conflict until the upgrade or removal
3454 of the conflicted-with package had been completed.
3458 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3462 As well as the names of actual ("concrete") packages, the
3463 package relationship fields <tt>Depends</tt>,
3464 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3465 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3466 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3467 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3468 may mention "virtual packages".
3472 A <em>virtual package</em> is one which appears in the
3473 <tt>Provides</tt> control file field of another package.
3474 The effect is as if the package(s) which provide a
3475 particular virtual package name had been listed by name
3476 everywhere the virtual package name appears. (See also <ref
3477 id="virtual_pkg_sect">)
3481 If there are both concrete and virtual packages of the same
3482 name, then the dependency may be satisfied (or the conflict
3483 caused) by either the concrete package with the name in
3484 question or any other concrete package which provides the
3485 virtual package with the name in question. This is so that,
3486 for example, supposing we have
3487 <example compact="compact">
3491 and someone else releases an enhanced version of the
3492 <tt>bar</tt> package (for example, a non-US variant), they
3494 <example compact="compact">
3498 and the <tt>bar-plus</tt> package will now also satisfy the
3499 dependency for the <tt>foo</tt> package.
3503 If a dependency or a conflict has a version number attached
3504 then only real packages will be considered to see whether
3505 the relationship is satisfied (or the prohibition violated,
3506 for a conflict) - it is assumed that a real package which
3507 provides the virtual package is not of the "right" version.
3508 So, a <tt>Provides</tt> field may not contain version
3509 numbers, and the version number of the concrete package
3510 which provides a particular virtual package will not be
3511 looked at when considering a dependency on or conflict with
3512 the virtual package name.
3516 It is likely that the ability will be added in a future
3517 release of <prgn>dpkg</prgn> to specify a version number for
3518 each virtual package it provides. This feature is not yet
3519 present, however, and is expected to be used only
3524 If you want to specify which of a set of real packages
3525 should be the default to satisfy a particular dependency on
3526 a virtual package, you should list the real package as an
3527 alternative before the virtual one.
3532 <sect id="replaces"><heading>Overwriting files and replacing
3533 packages - <tt>Replaces</tt></heading>
3536 Packages can declare in their control file that they should
3537 overwrite files in certain other packages, or completely
3538 replace other packages. The <tt>Replaces</tt> control file
3539 field has these two distinct purposes.
3542 <sect1><heading>Overwriting files in other packages</heading>
3545 Firstly, as mentioned before, it is usually an error for a
3546 package to contain files which are on the system in
3551 However, if the overwriting package declares that it
3552 <tt>Replaces</tt> the one containing the file being
3553 overwritten, then <prgn>dpkg</prgn> will replace the file
3554 from the old package with that from the new. The file
3555 will no longer be listed as "owned" by the old package.
3559 If a package is completely replaced in this way, so that
3560 <prgn>dpkg</prgn> does not know of any files it still
3561 contains, it is considered to have "disappeared". It will
3562 be marked as not wanted on the system (selected for
3563 removal) and not installed. Any <tt>conffile</tt>s
3564 details noted for the package will be ignored, as they
3565 will have been taken over by the overwriting package. The
3566 package's <prgn>postrm</prgn> script will be run with a
3567 special argument to allow the package to do any final
3568 cleanup required. See <ref id="mscriptsinstact">.
3572 If an installed package, <tt>foo</tt> say, declares that
3573 it replaces another, <tt>bar</tt>, and an attempt is made
3574 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3575 files in the <tt>bar</tt> package which would overwrite
3576 those already present in <tt>foo</tt>. This is so that
3577 you can install an older version of a package without
3582 For this usage of <tt>Replaces</tt>, virtual packages (see
3583 <ref id="virtual">) are not considered when looking at a
3584 <tt>Replaces</tt> field - the packages declared as being
3585 replaced must be mentioned by their real names.
3589 Furthermore, this usage of <tt>Replaces</tt> only takes
3590 effect when both packages are at least partially on the
3591 system at once, so that it can only happen if they do not
3592 conflict or if the conflict has been overridden.
3597 <sect1><heading>Replacing whole packages, forcing their
3601 Secondly, <tt>Replaces</tt> allows the packaging system to
3602 resolve which package should be removed when there is a
3603 conflict - see <ref id="conflicts">. This usage only
3604 takes effect when the two packages <em>do</em> conflict,
3605 so that the two usages of this field do not interfere with
3610 In this situation, the package declared as being replaced
3611 can be a virtual package, so for example, all mail
3612 transport agents (MTAs) would have the following fields in
3613 their control files:
3614 <example compact="compact">
3615 Provides: mail-transport-agent
3616 Conflicts: mail-transport-agent
3617 Replaces: mail-transport-agent
3619 ensuring that only one MTA can be installed at any one
3624 <sect><heading>Relationships between source and binary packages -
3625 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3626 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3630 Source packages that require certain binary packages to be
3631 installed or absent at the time of building the package
3632 can declare relationships to those binary packages.
3636 This is done using the <tt>Build-Depends</tt>,
3637 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3638 <tt>Build-Conflicts-Indep</tt> control file fields.
3642 Build-dependencies on "build-essential" binary packages can be
3643 omitted. Please see <ref id="pkg-relations"> for more information.
3647 The dependencies and conflicts they define must be satisfied
3648 (as defined earlier for binary packages) in order to invoke
3649 the targets in <tt>debian/rules</tt>, as follows:<footnote>
3651 If you make "build-arch" or "binary-arch", you need
3652 Build-Depends. If you make "build-indep" or
3653 "binary-indep", you need Build-Depends and
3654 Build-Depends-Indep. If you make "build" or "binary",
3658 There is no Build-Depends-Arch; the autobuilders will
3659 only need the Build-Depends if they know how to build
3660 only build-arch and binary-arch. Anyone building the
3661 build-indep/binary-indep targets is basically assumed to
3662 be building the whole package and so installs all build
3666 The purpose of the original split, I recall, was so that
3667 the autobuilders wouldn't need to install extra packages
3668 needed only for the binary-indep targets. But without a
3669 build-arch/build-indep split, this didn't work, since
3670 most of the work is done in the build target, not in the
3676 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3679 The <tt>Build-Depends</tt> and
3680 <tt>Build-Conflicts</tt> fields must be satisfied when
3681 any of the following targets is invoked:
3682 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
3683 <tt>binary-arch</tt>, <tt>build-arch</tt>,
3684 <tt>build-indep</tt> and <tt>binary-indep</tt>.
3687 <tag><tt>Build-Depends-Indep</tt>,
3688 <tt>Build-Conflicts-Indep</tt></tag>
3691 The <tt>Build-Depends-Indep</tt> and
3692 <tt>Build-Conflicts-Indep</tt> fields must be
3693 satisfied when any of the following targets is
3694 invoked: <tt>build</tt>, <tt>clean</tt>,
3695 <tt>build-indep</tt>, <tt>binary</tt> and
3696 <tt>binary-indep</tt>.
3707 <chapt id="conffiles"><heading>Configuration file handling
3711 This chapter has been superseded by <ref id="config-files">.
3715 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3718 Packages containing shared libraries must be constructed with
3719 a little care to make sure that the shared library is always
3720 available. This is especially important for packages whose
3721 shared libraries are vitally important, such as the C library
3722 (currently <tt>libc6</tt>).
3726 Packages involving shared libraries should be split up into
3727 several binary packages. This section mostly deals with how
3728 this separation is to be accomplished; rules for files within
3729 the shared library packages are in <ref id="libraries"> instead.
3732 <sect id="sharedlibs-runtime">
3733 <heading>Run-time shared libraries</heading>
3736 The run-time shared library needs to be placed in a package called
3737 <package><var>libraryname</var><var>soversion</var></package>, where
3738 <file><var>soversion</var></file> is the version number in the
3739 soname of the shared library<footnote>
3741 The soname is the shared object name: it's the thing
3742 that has to match exactly between building an executable
3743 and running it for the dynamic linker to be able run the
3744 program. For example, if the soname of the library is
3745 <file>libfoo.so.6</file>, the library package would be
3746 called <file>libfoo6</file>.
3749 Alternatively, if it would be confusing to directly append
3750 <var>soversion</var> to <var>libraryname</var> (e.g. because
3751 <var>libraryname</var> itself ends in a number), you may use
3752 <package><var>libraryname</var>-<var>soversion</var></package> and
3753 <package><var>libraryname</var>-<var>soversion</var>-dev</package>
3758 If you have several shared libraries built from the same
3759 source tree you may lump them all together into a single
3760 shared library package, provided that you change all of
3761 their sonames at once (so that you don't get filename
3762 clashes if you try to install different versions of the
3763 combined shared libraries package).
3767 The package should install the shared libraries under
3768 their normal names. For example, the <package>libgdbmg1</package>
3769 package should install <file>libgdbm.so.1.7.3</file> as
3770 <file>/usr/lib/libgdbm.so.1.7.3</file>. The files should not be
3771 renamed or re-linked by any <prgn>prerm</prgn> or
3772 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3773 of renaming things safely without affecting running programs,
3774 and attempts to interfere with this are likely to lead to
3779 Shared libraries should not be installed executable, since
3780 the dynamic linker does not require this and trying to
3781 execute a shared library usually results in a core dump.
3785 The run-time library package should include the symbolic link that
3786 <prgn>ldconfig</prgn> would create for the shared libraries.
3787 For example, the <package>libgdbmg1</package> package should include
3788 a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3789 <file>libgdbm.so.1.7.3</file>. This is needed so that the dynamic
3790 linker (for example <prgn>ld.so</prgn> or
3791 <prgn>ld-linux.so.*</prgn>) can find the library between the
3792 time that <prgn>dpkg</prgn> installs it and the time that
3793 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3796 The package management system requires the library to be
3797 placed before the symbolic link pointing to it in the
3798 <file>.deb</file> file. This is so that when
3799 <prgn>dpkg</prgn> comes to install the symlink
3800 (overwriting the previous symlink pointing at an older
3801 version of the library), the new shared library is already
3802 in place. In the past, this was achieved by creating the
3803 library in the temporary packaging directory before
3804 creating the symlink. Unfortunately, this was not always
3805 effective, since the building of the tar file in the
3806 <file>.deb</file> depended on the behavior of the underlying
3807 file system. Some file systems (such as reiserfs) reorder
3808 the files so that the order of creation is forgotten.
3809 Since version 1.7.0, <prgn>dpkg</prgn>
3810 reorders the files itself as necessary when building a
3811 package. Thus it is no longer important to concern
3812 oneself with the order of file creation.
3817 <sect1 id="ldconfig">
3818 <heading><tt>ldconfig</tt></heading>
3821 Any package installing shared libraries in one of the default
3822 library directories of the dynamic linker (which are currently
3823 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3824 listed in <file>/etc/ld.so.conf</file><footnote>
3827 <list compact="compact">
3828 <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3829 <item><p>/usr/local/lib</p></item>
3830 <item><p>/usr/lib/libc5-compat</p></item>
3831 <item><p>/lib/libc5-compat</p></item>
3832 <item><p>/usr/X11R6/lib</p></item>
3836 must use <prgn>ldconfig</prgn> to update the shared library
3841 The package must call <prgn>ldconfig</prgn> in the
3842 <prgn>postinst</prgn> script if the first argument is
3843 <tt>configure</tt>; the <prgn>postinst</prgn> script may
3844 optionally invoke <prgn>ldconfig</prgn> at other times. The
3845 package should call <prgn>ldconfig</prgn> in the
3846 <prgn>postrm</prgn> script if the first argument is
3847 <tt>remove</tt>. The maintainer scripts must not invoke
3848 <prgn>ldconfig</prgn> under any circumstances other than those
3849 described in this paragraph.<footnote>
3850 <p>During install or upgrade, the preinst is called before
3851 the new files are installed, so calling "ldconfig" is
3852 pointless. The preinst of an existing package can also be
3853 called if an upgrade fails. However, this happens during
3854 the critical time when a shared libs may exist on-disk
3855 under a temporary name. Thus, it is dangerous and
3856 forbidden by current policy to call "ldconfig" at this
3859 <p>When a package is installed or upgraded, "postinst
3860 configure" runs after the new files are safely on-disk.
3861 Since it is perfectly safe to invoke ldconfig
3862 unconditionally in a postinst, it is OK for a package to
3863 simply put ldconfig in its postinst without checking the
3864 argument. The postinst can also be called to recover from
3865 a failed upgrade. This happens before any new files are
3866 unpacked, so there is no reason to call "ldconfig" at this
3869 <p>For a package that is being removed, prerm is
3870 called with all the files intact, so calling ldconfig is
3871 useless. The other calls to "prerm" happen in the case of
3872 upgrade at a time when all the files of the old package
3873 are on-disk, so again calling "ldconfig" is pointless.
3875 <p>postrm, on the other hand, is called with the "remove"
3876 argument just after the files are removed, so this is the
3877 proper time to call "ldconfig" to notify the system of the
3878 fact shared libraries from the package are removed.
3879 The postrm can be called at several other times. At the
3880 time of "postrm purge", "postrm abort-install", or "postrm
3881 abort-upgrade", calling "ldconfig" is useless because the
3882 shared lib files are not on-disk. However, when "postrm"
3883 is invoked with arguments "upgrade", "failed-upgrade", or
3884 "disappear", a shared lib may exist on-disk under a
3893 <sect id="sharedlibs-runtime-progs">
3894 <heading>Run-time support programs</heading>
3897 If your package has some run-time support programs which use
3898 the shared library you must not put them in the shared
3899 library package. If you do that then you won't be able to
3900 install several versions of the shared library without
3901 getting filename clashes.
3905 Instead, either create another package for the runtime binaries
3906 (this package might typically be named
3907 <package><var>libraryname</var>-runtime</package>; note the absence
3908 of the <var>soversion</var> in the package name), or if the
3909 development package is small, include them in there.
3913 <sect id="sharedlibs-static">
3914 <heading>Static libraries</heading>
3917 The static library (<file><var>libraryname.a</var></file>)
3918 is usually provided in addition to the shared version.
3919 It is placed into the development package (see below).
3923 In some cases, it is acceptable for a library to be
3924 available in static form only; these cases include:
3926 <item>libraries for languages whose shared library support
3927 is immature or unstable</item>
3928 <item>libraries whose interfaces are in flux or under
3929 development (commonly the case when the library's
3930 major version number is zero, or where the ABI breaks
3931 across patchlevels)</item>
3932 <item>libraries which are explicitly intended to be
3933 available only in static form by their upstream
3938 <sect id="sharedlibs-dev">
3939 <heading>Development files</heading>
3942 The development files associated to a shared library need to be
3943 placed in a package called
3944 <package><var>libraryname</var><var>soversion</var>-dev</package>,
3945 or if you prefer only to support one development version at a
3946 time, <package><var>libraryname</var>-dev</package>.
3950 In case several development versions of a library exist, you may
3951 need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
3952 <ref id="conflicts">) to ensure that the user only installs one
3953 development version at a time (as different development versions are
3954 likely to have the same header files in them, which would cause a
3955 filename clash if both were installed).
3959 The development package should contain a symlink for the associated
3960 shared library without a version number. For example, the
3961 <package>libgdbmg1-dev</package> package should include a symlink
3962 from <file>/usr/lib/libgdbm.so</file> to
3963 <file>libgdbm.so.1.7.3</file>. This symlink is needed by the linker
3964 (<prgn>ld</prgn>) when compiling packages, as it will only look for
3965 <file>libgdbm.so</file> when compiling dynamically.
3969 <sect id="sharedlibs-intradeps">
3970 <heading>Dependencies between the packages of the same library</heading>
3973 Typically the development version should have an exact
3974 version dependency on the runtime library, to make sure that
3975 compilation and linking happens correctly. The
3976 <tt>${Source-Version}</tt> substitution variable can be
3977 useful for this purpose.
3981 <sect id="sharedlibs-shlibdeps">
3982 <heading>Dependencies between the library and other packages -
3983 the <tt>shlibs</tt> system</heading>
3986 If a package contains a binary or library which links to a
3987 shared library, we must ensure that when the package is
3988 installed on the system, all of the libraries needed are
3989 also installed. This requirement led to the creation of the
3990 <tt>shlibs</tt> system, which is very simple in its design:
3991 any package which <em>provides</em> a shared library also
3992 provides information on the package dependencies required to
3993 ensure the presence of this library, and any package which
3994 <em>uses</em> a shared library uses this information to
3995 determine the dependencies it requires. The files which
3996 contain the mapping from shared libraries to the necessary
3997 dependency information are called <file>shlibs</file> files.
4001 Thus, when a package is built which contains any shared
4002 libraries, it must provide a <file>shlibs</file> file for other
4003 packages to use, and when a package is built which contains
4004 any shared libraries or compiled binaries, it must run
4005 <prgn>dpkg-shlibdeps</prgn> on these to determine the
4006 libraries used and hence the dependencies needed by this
4009 In the past, the shared libraries linked to were
4010 determined by calling <prgn>ldd</prgn>, but now
4011 <prgn>objdump</prgn> is used to do this. The only
4012 change this makes to package building is that
4013 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
4014 libraries, whereas in the past this was unnecessary.
4015 The rest of this footnote explains the advantage that
4020 We say that a binary <tt>foo</tt> <em>directly</em> uses
4021 a library <tt>libbar</tt> if it is explicitly linked
4022 with that library (that is, it uses the flag
4023 <tt>-lbar</tt> during the linking stage). Other
4024 libraries that are needed by <tt>libbar</tt> are linked
4025 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
4026 linker will load them automatically when it loads
4027 <tt>libbar</tt>. A package should depend on
4028 the libraries it directly uses, and the dependencies for
4029 those libraries should automatically pull in the other
4034 Unfortunately, the <prgn>ldd</prgn> program shows both
4035 the directly and indirectly used libraries, meaning that
4036 the dependencies determined included both direct and
4037 indirect dependencies. The use of <prgn>objdump</prgn>
4038 avoids this problem by determining only the directly
4043 A good example of where this helps is the following. We
4044 could update <tt>libimlib</tt> with a new version that
4045 supports a new graphics format called dgf (but retaining
4046 the same major version number). If we used the old
4047 <prgn>ldd</prgn> method, every package that uses
4048 <tt>libimlib</tt> would need to be recompiled so it
4049 would also depend on <tt>libdgf</tt> or it wouldn't run
4050 due to missing symbols. However with the new system,
4051 packages using <tt>libimlib</tt> can rely on
4052 <tt>libimlib</tt> itself having the dependency on
4053 <tt>libdgf</tt> and so they would not need rebuilding.
4059 In the following sections, we will first describe where the
4060 various <tt>shlibs</tt> files are to be found, then how to
4061 use <prgn>dpkg-shlibdeps</prgn>, and finally the
4062 <tt>shlibs</tt> file format and how to create them if your
4063 package contains a shared library.
4067 <heading>The <tt>shlibs</tt> files present on the system</heading>
4070 There are several places where <tt>shlibs</tt> files are
4071 found. The following list gives them in the order in which
4072 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
4073 one which gives the required information is used.)
4079 <p><file>debian/shlibs.local</file></p>
4081 This lists overrides for this package. Its use is
4082 described below (see <ref id="shlibslocal">).
4087 <p><file>/etc/dpkg/shlibs.override</file></p>
4089 This lists global overrides. This list is normally
4090 empty. It is maintained by the local system
4096 <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
4098 When packages are being built, any
4099 <file>debian/shlibs</file> files are copied into the
4100 control file area of the temporary build directory and
4101 given the name <file>shlibs</file>. These files give
4102 details of any shared libraries included in the
4105 An example may help here. Let us say that the
4106 source package <tt>foo</tt> generates two binary
4107 packages, <tt>libfoo2</tt> and
4108 <tt>foo-runtime</tt>. When building the binary
4109 packages, the two packages are created in the
4110 directories <file>debian/libfoo2</file> and
4111 <file>debian/foo-runtime</file> respectively.
4112 (<file>debian/tmp</file> could be used instead of one
4113 of these.) Since <tt>libfoo2</tt> provides the
4114 <tt>libfoo</tt> shared library, it will require a
4115 <tt>shlibs</tt> file, which will be installed in
4116 <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
4118 <file>/var/lib/dpkg/info/libfoo2.shlibs</file>. Then
4119 when <prgn>dpkg-shlibdeps</prgn> is run on the
4121 <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
4123 <file>debian/libfoo2/DEBIAN/shlibs</file> file to
4124 determine whether <tt>foo-prog</tt>'s library
4125 dependencies are satisfied by any of the libraries
4126 provided by <tt>libfoo2</tt>. For this reason,
4127 <prgn>dpkg-shlibdeps</prgn> must only be run once
4128 all of the individual binary packages'
4129 <tt>shlibs</tt> files have been installed into the
4137 <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
4139 These are the <file>shlibs</file> files corresponding to
4140 all of the packages installed on the system, and are
4141 maintained by the relevant package maintainers.
4146 <p><file>/etc/dpkg/shlibs.default</file></p>
4148 This file lists any shared libraries whose packages
4149 have failed to provide correct <file>shlibs</file> files.
4150 It was used when the <file>shlibs</file> setup was first
4151 introduced, but it is now normally empty. It is
4152 maintained by the <tt>dpkg</tt> maintainer.
4160 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4161 <file>shlibs</file> files</heading>
4164 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4165 <file>debian/rules</file> file. If your package contains only
4166 compiled binaries and libraries (but no scripts), you can
4167 use a command such as:
4168 <example compact="compact">
4169 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4170 debian/tmp/usr/lib/*
4172 Otherwise, you will need to explicitly list the compiled
4173 binaries and libraries.<footnote>
4175 If you are using <tt>debhelper</tt>, the
4176 <prgn>dh_shlibdeps</prgn> program will do this work for
4177 you. It will also correctly handle multi-binary
4184 This command puts the dependency information into the
4185 <file>debian/substvars</file> file, which is then used by
4186 <prgn>dpkg-gencontrol</prgn>. You will need to place a
4187 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4188 field in the control file for this to work.
4192 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4193 done. If it does complain you might need to create your own
4194 <file>debian/shlibs.local</file> file, as explained below (see
4195 <ref id="shlibslocal">).
4199 If you have multiple binary packages, you will need to call
4200 <prgn>dpkg-shlibdeps</prgn> on each one which contains
4201 compiled libraries or binaries. In such a case, you will
4202 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4203 utilities to specify a different <file>substvars</file> file.
4204 For more details on this and other options, see <manref
4205 name="dpkg-shlibdeps" section="1">.
4210 <heading>The <file>shlibs</file> File Format</heading>
4213 Each <file>shlibs</file> file has the same format. Lines
4214 beginning with <tt>#</tt> are considered to be comments and
4215 are ignored. Each line is of the form:
4216 <example compact="compact">
4217 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4222 We will explain this by reference to the example of the
4223 <tt>zlib1g</tt> package, which (at the time of writing)
4224 installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4228 <var>library-name</var> is the name of the shared library,
4229 in this case <tt>libz</tt>. (This must match the name part
4230 of the soname, see below.)
4234 <var>soname-version-number</var> is the version part of the
4235 soname of the library. The soname is the thing that must
4236 exactly match for the library to be recognized by the
4237 dynamic linker, and is usually of the form
4238 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4239 example, <tt>libz.so.1</tt>.<footnote>
4241 This can be determined using the command
4242 <example compact="compact">
4243 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4247 The version part is the part which comes after
4248 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4252 <var>dependencies</var> has the same syntax as a dependency
4253 field in a binary package control file. It should give
4254 details of which packages are required to satisfy a binary
4255 built against the version of the library contained in the
4256 package. See <ref id="depsyntax"> for details.
4260 In our example, if the first version of the <tt>zlib1g</tt>
4261 package which contained a minor number of at least
4262 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4263 <tt>shlibs</tt> entry for this library could say:
4264 <example compact="compact">
4265 libz 1 zlib1g (>= 1:1.1.3)
4267 The version-specific dependency is to avoid warnings from
4268 the dynamic linker about using older shared libraries with
4274 <heading>Providing a <file>shlibs</file> file</heading>
4277 If your package provides a shared library, you should create
4278 a <file>shlibs</file> file following the format described above.
4279 It is usual to call this file <file>debian/shlibs</file> (but if
4280 you have multiple binary packages, you might want to call it
4281 <file>debian/shlibs.<var>package</var></file> instead). Then
4282 let <file>debian/rules</file> install it in the control area:
4283 <example compact="compact">
4284 install -m644 debian/shlibs debian/tmp/DEBIAN
4286 or, in the case of a multi-binary package:
4287 <example compact="compact">
4288 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4290 An alternative way of doing this is to create the
4291 <file>shlibs</file> file in the control area directly from
4292 <file>debian/rules</file> without using a <file>debian/shlibs</file>
4293 file at all,<footnote>
4295 This is what <prgn>dh_makeshlibs</prgn> in the
4296 <tt>debhelper</tt> suite does.
4299 since the <file>debian/shlibs</file> file itself is ignored by
4300 <prgn>dpkg-shlibdeps</prgn>.
4304 As <prgn>dpkg-shlibdeps</prgn> reads the
4305 <file>DEBIAN/shlibs</file> files in all of the binary packages
4306 being built from this source package, all of the
4307 <file>DEBIAN/shlibs</file> files should be installed before
4308 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4313 <sect1 id="shlibslocal">
4314 <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4317 This file is intended only as a <em>temporary</em> fix if
4318 your binaries or libraries depend on a library whose package
4319 does not yet provide a correct <file>shlibs</file> file.
4323 We will assume that you are trying to package a binary
4324 <tt>foo</tt>. When you try running
4325 <prgn>dpkg-shlibdeps</prgn> you get the following error
4326 message (<tt>-O</tt> displays the dependency information on
4327 <tt>stdout</tt> instead of writing it to
4328 <tt>debian/substvars</tt>, and the lines have been wrapped
4329 for ease of reading):
4330 <example compact="compact">
4331 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4332 dpkg-shlibdeps: warning: unable to find dependency
4333 information for shared library libbar (soname 1,
4334 path /usr/lib/libbar.so.1, dependency field Depends)
4335 shlibs:Depends=libc6 (>= 2.2.2-2)
4337 You can then run <prgn>ldd</prgn> on the binary to find the
4338 full location of the library concerned:
4339 <example compact="compact">
4341 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4342 libc.so.6 => /lib/libc.so.6 (0x40032000)
4343 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4345 So the <prgn>foo</prgn> binary depends on the
4346 <prgn>libbar</prgn> shared library, but no package seems to
4347 provide a <file>*.shlibs</file> file handling
4348 <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>. Let's
4349 determine the package responsible:
4350 <example compact="compact">
4351 $ dpkg -S /usr/lib/libbar.so.1
4352 bar1: /usr/lib/libbar.so.1
4353 $ dpkg -s bar1 | grep Version
4356 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4357 is the one we are using. Now we can file a bug against the
4358 <tt>bar1</tt> package and create our own
4359 <file>debian/shlibs.local</file> to locally fix the problem.
4360 Including the following line into your
4361 <file>debian/shlibs.local</file> file:
4362 <example compact="compact">
4363 libbar 1 bar1 (>= 1.0-1)
4365 should allow the package build to work.
4369 As soon as the maintainer of <tt>bar1</tt> provides a
4370 correct <file>shlibs</file> file, you should remove this line
4371 from your <file>debian/shlibs.local</file> file. (You should
4372 probably also then have a versioned <tt>Build-Depends</tt>
4373 on <tt>bar1</tt> to help ensure that others do not have the
4374 same problem building your package.)
4382 <chapt id="opersys"><heading>The Operating System</heading>
4385 <heading>Filesystem hierarchy</heading>
4389 <heading>Filesystem Structure</heading>
4392 The location of all installed files and directories must
4393 comply with the Filesystem Hierarchy Standard (FHS),
4394 version 2.1, except where doing so would violate other
4395 terms of Debian Policy. The version of this document
4396 referred here can be found in the <tt>debian-policy</tt>
4398 <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4399 name="FHS (Debian copy)"> alongside this manual (or, if
4400 you have the <package>debian-policy</package> installed,
4402 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4403 (local copy)">). The
4404 latest version, which may be a more recent version, may
4406 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4407 Specific questions about following the standard may be
4408 asked on the <tt>debian-devel</tt> mailing list, or
4409 referred to the FHS mailing list (see the
4410 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4416 <heading>Site-specific programs</heading>
4419 As mandated by the FHS, packages must not place any
4420 files in <file>/usr/local</file>, either by putting them in
4421 the file system archive to be unpacked by <prgn>dpkg</prgn>
4422 or by manipulating them in their maintainer scripts.
4426 However, the package may create empty directories below
4427 <file>/usr/local</file> so that the system administrator knows
4428 where to place site-specific files. These directories
4429 should be removed on package removal if they are
4434 Note, that this applies only to directories <em>below</em>
4435 <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4436 Packages must not create sub-directories in the directory
4437 <file>/usr/local</file> itself, except those listed in FHS,
4438 section 4.5. However, you may create directories below
4439 them as you wish. You must not remove any of the
4440 directories listed in 4.5, even if you created them.
4444 Since <file>/usr/local</file> can be mounted read-only from a
4445 remote server, these directories must be created and
4446 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4447 maintainer scripts and not be included in the
4448 <file>.deb</file> archive. These scripts must not fail if
4449 either of these operations fail.
4453 For example, the <tt>emacsen-common</tt> package could
4454 contain something like
4455 <example compact="compact">
4456 if [ ! -e /usr/local/share/emacs ]
4458 if mkdir /usr/local/share/emacs 2>/dev/null
4460 chown root:staff /usr/local/share/emacs
4461 chmod 2775 /usr/local/share/emacs
4465 in its <prgn>postinst</prgn> script, and
4466 <example compact="compact">
4467 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4468 rmdir /usr/local/share/emacs 2>/dev/null || true
4470 in the <prgn>prerm</prgn> script. (Note that this form is
4471 used to ensure that if the script is interrupted, the
4472 directory <file>/usr/local/share/emacs</file> will still be
4477 If you do create a directory in <file>/usr/local</file> for
4478 local additions to a package, you should ensure that
4479 settings in <file>/usr/local</file> take precedence over the
4480 equivalents in <file>/usr</file>.
4484 However, because <file>/usr/local</file> and its contents are
4485 for exclusive use of the local administrator, a package
4486 must not rely on the presence or absence of files or
4487 directories in <file>/usr/local</file> for normal operation.
4491 The <file>/usr/local</file> directory itself and all the
4492 subdirectories created by the package should (by default) have
4493 permissions 2775 (group-writable and set-group-id) and be
4494 owned by <tt>root.staff</tt>.
4499 <heading>The system-wide mail directory</heading>
4501 The system-wide mail directory is <file>/var/mail</file>. This
4502 directory is part of the base system and should not owned
4503 by any particular mail agents. The use of the old
4504 location <file>/var/spool/mail</file> is deprecated, even
4505 though the spool may still be physically located there.
4506 To maintain partial upgrade compatibility for systems
4507 which have <file>/var/spool/mail</file> as their physical mail
4508 spool, packages using <file>/var/mail</file> must depend on
4509 either <package>libc6</package> (>= 2.1.3-13), or on
4510 <package>base-files</package> (>= 2.2.0), or on later
4511 versions of either one of these packages.
4517 <heading>Users and groups</heading>
4520 <heading>Introduction</heading>
4522 The Debian system can be configured to use either plain or
4527 Some user ids (UIDs) and group ids (GIDs) are reserved
4528 globally for use by certain packages. Because some
4529 packages need to include files which are owned by these
4530 users or groups, or need the ids compiled into binaries,
4531 these ids must be used on any Debian system only for the
4532 purpose for which they are allocated. This is a serious
4533 restriction, and we should avoid getting in the way of
4534 local administration policies. In particular, many sites
4535 allocate users and/or local system groups starting at 100.
4539 Apart from this we should have dynamically allocated ids,
4540 which should by default be arranged in some sensible
4541 order, but the behavior should be configurable.
4545 Packages other than <tt>base-passwd</tt> must not modify
4546 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4547 <file>/etc/group</file> or <file>/etc/gshadow</file>.
4552 <heading>UID and GID classes</heading>
4554 The UID and GID numbers are divided into classes as
4560 Globally allocated by the Debian project, the same
4561 on every Debian system. These ids will appear in
4562 the <file>passwd</file> and <file>group</file> files of all
4563 Debian systems, new ids in this range being added
4564 automatically as the <tt>base-passwd</tt> package is
4569 Packages which need a single statically allocated
4570 uid or gid should use one of these; their
4571 maintainers should ask the <tt>base-passwd</tt>
4579 Dynamically allocated system users and groups.
4580 Packages which need a user or group, but can have
4581 this user or group allocated dynamically and
4582 differently on each system, should use <tt>adduser
4583 --system</tt> to create the group and/or user.
4584 <prgn>adduser</prgn> will check for the existence of
4585 the user or group, and if necessary choose an unused
4586 id based on the ranges specified in
4587 <file>adduser.conf</file>.
4591 <tag>1000-29999:</tag>
4594 Dynamically allocated user accounts. By default
4595 <prgn>adduser</prgn> will choose UIDs and GIDs for
4596 user accounts in this range, though
4597 <file>adduser.conf</file> may be used to modify this
4602 <tag>30000-59999:</tag>
4607 <tag>60000-64999:</tag>
4610 Globally allocated by the Debian project, but only
4611 created on demand. The ids are allocated centrally
4612 and statically, but the actual accounts are only
4613 created on users' systems on demand.
4617 These ids are for packages which are obscure or
4618 which require many statically-allocated ids. These
4619 packages should check for and create the accounts in
4620 <file>/etc/passwd</file> or <file>/etc/group</file> (using
4621 <prgn>adduser</prgn> if it has this facility) if
4622 necessary. Packages which are likely to require
4623 further allocations should have a "hole" left after
4624 them in the allocation, to give them room to
4629 <tag>65000-65533:</tag>
4637 User <tt>nobody</tt>. The corresponding gid refers
4638 to the group <tt>nogroup</tt>.
4645 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4646 not</em> be used, because it is the error return
4655 <sect id="sysvinit">
4656 <heading>System run levels and <file>init.d</file> scripts</heading>
4658 <sect1 id="/etc/init.d">
4659 <heading>Introduction</heading>
4662 The <file>/etc/init.d</file> directory contains the scripts
4663 executed by <prgn>init</prgn> at boot time and when the
4664 init state (or "runlevel") is changed (see <manref
4665 name="init" section="8">).
4669 There are at least two different, yet functionally
4670 equivalent, ways of handling these scripts. For the sake
4671 of simplicity, this document describes only the symbolic
4672 link method. However, it must not be assumed by maintainer
4673 scripts that this method is being used, and any automated
4674 manipulation of the various runlevel behaviours by
4675 maintainer scripts must be performed using
4676 <prgn>update-rc.d</prgn> as described below and not by
4677 manually installing or removing symlinks. For information
4678 on the implementation details of the other method,
4679 implemented in the <tt>file-rc</tt> package, please refer
4680 to the documentation of that package.
4684 These scripts are referenced by symbolic links in the
4685 <file>/etc/rc<var>n</var>.d</file> directories. When changing
4686 runlevels, <prgn>init</prgn> looks in the directory
4687 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4688 execute, where <tt><var>n</var></tt> is the runlevel that
4689 is being changed to, or <tt>S</tt> for the boot-up
4694 The names of the links all have the form
4695 <file>S<var>mm</var><var>script</var></file> or
4696 <file>K<var>mm</var><var>script</var></file> where
4697 <var>mm</var> is a two-digit number and <var>script</var>
4698 is the name of the script (this should be the same as the
4699 name of the actual script in <file>/etc/init.d</file>).
4703 When <prgn>init</prgn> changes runlevel first the targets
4704 of the links whose names start with a <tt>K</tt> are
4705 executed, each with the single argument <tt>stop</tt>,
4706 followed by the scripts prefixed with an <tt>S</tt>, each
4707 with the single argument <tt>start</tt>. (The links are
4708 those in the <file>/etc/rc<var>n</var>.d</file> directory
4709 corresponding to the new runlevel.) The <tt>K</tt> links
4710 are responsible for killing services and the <tt>S</tt>
4711 link for starting services upon entering the runlevel.
4715 For example, if we are changing from runlevel 2 to
4716 runlevel 3, init will first execute all of the <tt>K</tt>
4717 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4718 all of the <tt>S</tt> prefixed scripts in that directory.
4719 The links starting with <tt>K</tt> will cause the
4720 referred-to file to be executed with an argument of
4721 <tt>stop</tt>, and the <tt>S</tt> links with an argument
4726 The two-digit number <var>mm</var> is used to determine
4727 the order in which to run the scripts: low-numbered links
4728 have their scripts run first. For example, the
4729 <tt>K20</tt> scripts will be executed before the
4730 <tt>K30</tt> scripts. This is used when a certain service
4731 must be started before another. For example, the name
4732 server <prgn>bind</prgn> might need to be started before
4733 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4734 can set up its access lists. In this case, the script
4735 that starts <prgn>bind</prgn> would have a lower number
4736 than the script that starts <prgn>inn</prgn> so that it
4738 <example compact="compact">
4745 The two runlevels 0 (halt) and 6 (reboot) are slightly
4746 different. In these runlevels, the links with an
4747 <tt>S</tt> prefix are still called after those with a
4748 <tt>K</tt> prefix, but they too are called with the single
4749 argument <tt>stop</tt>.
4753 Also, if the script name ends <tt>.sh</tt>, the script
4754 will be sourced in runlevel <tt>S</tt> rather that being
4755 run in a forked subprocess, but will be explicitly run by
4756 <prgn>sh</prgn> in all other runlevels.
4761 <heading>Writing the scripts</heading>
4764 Packages that include daemons for system services should
4765 place scripts in <file>/etc/init.d</file> to start or stop
4766 services at boot time or during a change of runlevel.
4767 These scripts should be named
4768 <file>/etc/init.d/<var>package</var></file>, and they should
4769 accept one argument, saying what to do:
4772 <tag><tt>start</tt></tag>
4773 <item><p>start the service,</p></item>
4775 <tag><tt>stop</tt></tag>
4776 <item><p>stop the service,</p></item>
4778 <tag><tt>restart</tt></tag>
4779 <item><p>stop and restart the service if it's already
4780 running, otherwise start the service</p></item>
4782 <tag><tt>reload</tt></tag>
4783 <item><p>cause the configuration of the service to be
4784 reloaded without actually stopping and restarting
4785 the service,</p></item>
4787 <tag><tt>force-reload</tt></tag>
4788 <item><p>cause the configuration to be reloaded if the
4789 service supports this, otherwise restart the
4793 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4794 <tt>force-reload</tt> options should be supported by all
4795 scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4796 option is optional.</p>
4799 The <file>init.d</file> scripts should ensure that they will
4800 behave sensibly if invoked with <tt>start</tt> when the
4801 service is already running, or with <tt>stop</tt> when it
4802 isn't, and that they don't kill unfortunately-named user
4803 processes. The best way to achieve this is usually to use
4804 <prgn>start-stop-daemon</prgn>.</p>
4807 If a service reloads its configuration automatically (as
4808 in the case of <prgn>cron</prgn>, for example), the
4809 <tt>reload</tt> option of the <file>init.d</file> script
4810 should behave as if the configuration has been reloaded
4814 The <file>/etc/init.d</file> scripts must be treated as
4815 configuration files, either (if they are present in the
4816 package, that is, in the .deb file) by marking them as
4817 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4818 by managing them correctly in the maintainer scripts (see
4819 <ref id="config-files">). This is important since we want
4820 to give the local system administrator the chance to adapt
4821 the scripts to the local system, e.g., to disable a
4822 service without de-installing the package, or to specify
4823 some special command line options when starting a service,
4824 while making sure her changes aren't lost during the next
4829 These scripts should not fail obscurely when the
4830 configuration files remain but the package has been
4831 removed, as configuration files remain on the system after
4832 the package has been removed. Only when <prgn>dpkg</prgn>
4833 is executed with the <tt>--purge</tt> option will
4834 configuration files be removed. In particular, as the
4835 <file>/etc/init.d/<var>package</var></file> script itself is
4836 usually a <tt>conffile</tt>, it will remain on the system
4837 if the package is removed but not purged. Therefore, you
4838 should include a <tt>test</tt> statement at the top of the
4840 <example compact="compact">
4841 test -f <var>program-executed-later-in-script</var> || exit 0
4846 Often there are some variables in the <file>init.d</file>
4847 scripts whose values control the behaviour of the scripts,
4848 and which a system administrator is likely to want to
4849 change. As the scripts themselves are frequently
4850 <tt>conffile</tt>s, modifying them requires that the
4851 administrator merge in their changes each time the package
4852 is upgraded and the <tt>conffile</tt> changes. To ease
4853 the burden on the system administrator, such configurable
4854 values should not be placed directly in the script.
4855 Instead, they should be placed in a file in
4856 <file>/etc/default</file>, which typically will have the same
4857 base name as the <file>init.d</file> script. This extra file
4858 should be sourced by the script when the script runs. It
4859 must contain only variable settings and comments in POSIX
4860 <prgn>sh</prgn> format. It may either be a
4861 <tt>conffile</tt> or a configuration file maintained by
4862 the package maintainer scripts. See <ref id="config-files">
4867 To ensure that vital configurable values are always
4868 available, the <file>init.d</file> script should set default
4869 values for each of the shell variables it uses, either
4870 before sourcing the <file>/etc/default/</file> file or
4871 afterwards using something like the <tt>:
4872 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
4873 script must behave sensibly and not fail if the
4874 <file>/etc/default</file> file is deleted.
4879 <heading>Interfacing with the initscript system</heading>
4882 Maintainers should use the abstraction layer provided by
4883 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4884 programs to deal with initscripts in their packages'
4885 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4886 and <prgn>postrm</prgn>.
4889 Directly managing the /etc/rc?.d links and directly
4890 invoking the <file>/etc/init.d/</file> initscripts should
4891 be done only by packages providing the initscript
4892 subsystem (such as <prgn>sysvinit</prgn> and
4893 <prgn>file-rc</prgn>).
4898 <heading>Managing the links</heading>
4901 The program <prgn>update-rc.d</prgn> is provided for
4902 package maintainers to arrange for the proper creation and
4903 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4904 or their functional equivalent if another method is being
4905 used. This may be used by maintainers in their packages'
4906 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4909 You must not include any <file>/etc/rc<var>n</var>.d</file>
4910 symbolic links in the actual archive or manually create or
4911 remove the symbolic links in maintainer scripts; you must
4912 use the <prgn>update-rc.d</prgn> program instead. (The
4913 former will fail if an alternative method of maintaining
4914 runlevel information is being used.) You must not include
4915 the <file>/etc/rc<var>n</var>.d</file> directories themselves
4916 in the archive either. (Only the <tt>sysvinit</tt>
4921 By default <prgn>update-rc.d</prgn> will start services in
4922 each of the multi-user state runlevels (2, 3, 4, and 5)
4923 and stop them in the halt runlevel (0), the single-user
4924 runlevel (1) and the reboot runlevel (6). The system
4925 administrator will have the opportunity to customize
4926 runlevels by simply adding, moving, or removing the
4927 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4928 symbolic links are being used, or by modifying
4929 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4934 To get the default behavior for your package, put in your
4935 <prgn>postinst</prgn> script
4936 <example compact="compact">
4937 update-rc.d <var>package</var> defaults
4939 and in your <prgn>postrm</prgn>
4940 <example compact="compact">
4941 if [ "$1" = purge ]; then
4942 update-rc.d <var>package</var> remove
4944 </example>. Note that if your package changes runlevels
4945 or priority, you may have to remove and recreate the links,
4946 since otherwise the old links may persist. Refer to the
4947 documentation of <prgn>update-rc.d</prgn></p>
4950 This will use a default sequence number of 20. If it does
4951 not matter when or in which order the <file>init.d</file>
4952 script is run, use this default. If it does, then you
4953 should talk to the maintainer of the <prgn>sysvinit</prgn>
4954 package or post to <tt>debian-devel</tt>, and they will
4955 help you choose a number.
4959 For more information about using <tt>update-rc.d</tt>,
4960 please consult its manpage <manref name="update-rc.d"
4966 <heading>Running initscripts</heading>
4968 The program <prgn>invoke-rc.d</prgn> is provided to make
4969 it easier for package maintainers to properly invoke an
4970 initscript, obeying runlevel and other locally-defined
4971 constraints that might limit a package's right to start,
4972 stop and otherwise manage services. This program may be
4973 used by maintainers in their packages' scripts.
4976 The use of <prgn>invoke-rc.d</prgn> to invoke the
4977 <file>/etc/init.d/*</file> initscripts is strongly
4978 recommended<footnote>
4980 In the future, the use of invoke-rc.d to invoke
4981 initscripts shall be made mandatory. Maintainers are
4982 advised to switch to invoke-rc.d as soon as
4984 </footnote>, instead of calling them directly.
4988 By default, <prgn>invoke-rc.d</prgn> will pass any
4989 action requests (start, stop, reload, restart...) to the
4990 <file>/etc/init.d</file> script, filtering out requests
4991 to start or restart a service out of its intended
4995 Most packages will simply need to change:
4996 <example compact="compact">/etc/init.d/<package>
4997 <action></example> in their <prgn>postinst</prgn>
4998 and <prgn>prerm</prgn> scripts to:
4999 <example compact="compact">
5000 if [ -x /usr/sbin/invoke-rc.d ] ; then
5001 invoke-rc.d <var>package</var> <action>
5003 /etc/init.d/<var>package</var> <action>
5007 A package should register its initscript services using
5008 <prgn>update-rc.d</prgn> before it tries to invoke them
5009 using <prgn>invoke-rc.d</prgn>. Invocation of
5010 unregistered services may fail.
5013 For more information about using
5014 <prgn>invoke-rc.d</prgn>, please consult its manpage
5015 <manref name="invoke-rc.d" section="8">.
5022 <heading>Boot-time initialization</heading>
5025 There used to be another directory, <file>/etc/rc.boot</file>,
5026 which contained scripts which were run once per machine
5027 boot. This has been deprecated in favour of links from
5028 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
5029 described in <ref id="/etc/init.d">. Packages must not
5030 place files in <file>/etc/rc.boot</file>.</p>
5033 <heading>Example</heading>
5036 The <prgn>bind</prgn> DNS (nameserver) package wants to
5037 make sure that the nameserver is running in multiuser
5038 runlevels, and is properly shut down with the system. It
5039 puts a script in <file>/etc/init.d</file>, naming the script
5040 appropriately <tt>bind</tt>. As you can see, the script
5041 interprets the argument <tt>reload</tt> to send the
5042 nameserver a <tt>HUP</tt> signal (causing it to reload its
5043 configuration); this way the system administrator can say
5044 <tt>/etc/init.d/bind reload</tt> to reload the name
5045 server. The script has one configurable value, which can
5046 be used to pass parameters to the named program at
5047 startup; this value is read from
5048 <file>/etc/default/bind</file> (see below).
5052 <example compact="compact">
5055 # Original version by Robert Leslie
5056 # <rob@mars.org>, edited by iwj and cs
5058 test -x /usr/sbin/named || exit 0
5060 # Source defaults file.
5062 if [ -f /etc/default/bind ]; then
5069 echo -n "Starting domain name service: named"
5070 start-stop-daemon --start --quiet --exec /usr/sbin/named \
5075 echo -n "Stopping domain name service: named"
5076 start-stop-daemon --stop --quiet \
5077 --pidfile /var/run/named.pid --exec /usr/sbin/named
5081 echo -n "Restarting domain name service: named"
5082 start-stop-daemon --stop --quiet \
5083 --pidfile /var/run/named.pid --exec /usr/sbin/named
5084 start-stop-daemon --start --verbose --exec /usr/sbin/named \
5088 force-reload|reload)
5089 echo -n "Reloading configuration of domain name service: named"
5090 start-stop-daemon --stop --signal 1 --quiet \
5091 --pidfile /var/run/named.pid --exec /usr/sbin/named
5095 echo "Usage: /etc/init.d/bind " \
5096 " {start|stop|restart|reload|force-reload}" >&2
5106 Complementing the above init script is a configuration
5107 file <file>/etc/default/bind</file>, which contains
5108 configurable parameters used by the script. This would be
5109 created by the <prgn>postinst</prgn> script if it was not
5110 already present, and removed on purge by the
5111 <prgn>postrm</prgn> script.
5112 <example compact="compact">
5113 # Specified parameters to pass to named. See named(8).
5114 # You may uncomment the following line, and edit to taste.
5120 Another example on which you can base your
5121 <file>/etc/init.d</file> scripts is found in
5122 <file>/etc/init.d/skeleton</file>.
5126 If this package is happy with the default setup from
5127 <prgn>update-rc.d</prgn>, namely an ordering number of 20
5128 and having named running in all runlevels, it can say in
5129 its <prgn>postinst</prgn>:
5130 <example compact="compact">
5131 update-rc.d bind defaults >/dev/null
5133 And in its <prgn>postrm</prgn>, to remove the links when the
5135 <example compact="compact">
5136 if [ "$1" = purge ]; then
5137 update-rc.d bind remove >/dev/null
5145 <heading>Console messages from <file>init.d</file> scripts</heading>
5148 This section describes the formats to be used for messages
5149 written to standard output by the <file>/etc/init.d</file>
5150 scripts. The intent is to improve the consistency of
5151 Debian's startup and shutdown look and feel. For this
5152 reason, please look very carefully at the details. We want
5153 the messages to have the same format in terms of wording,
5154 spaces, punctuation and case of letters.
5158 Here is a list of overall rules that you should use when you
5159 create output messages. They can be useful if you have a
5160 non-standard message that is not covered specifically in the
5168 Every message should fit in one line (fewer than 80
5169 characters), start with a capital letter and end with
5170 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5176 If you want to express that the computer is working on
5177 something (that is, performing a specific task, not
5178 starting or stopping a program), we use an "ellipsis"
5179 (three dots: <tt>...</tt>). Note that we don't insert
5180 spaces before or after the dots. If the task has been
5181 completed we write <tt>done.</tt> and a line feed.
5187 Design your messages as if the computer is telling you
5188 what he is doing (let him be polite :-), but don't
5189 mention "him" directly. For example, if you think of
5191 <example compact="compact">
5192 I'm starting network daemons: nfsd mountd.
5195 <example compact="compact">
5196 Starting network daemons: nfsd mountd.
5204 There are standard message formats for the following
5205 situations. They should be used by the <tt>init.d</tt>
5212 <p>When daemons are started</p>
5215 If your script starts one or more daemons, the output
5216 should look like this (a single line, no leading
5218 <example compact="compact">
5219 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5221 The <var>description</var> should describe the
5222 subsystem the daemon or set of daemons are part of,
5223 while <var>daemon-1</var> up to <var>daemon-n</var>
5224 denote each daemon's name (typically the file name of
5229 For example, the output of <file>/etc/init.d/lpd</file>
5231 <example compact="compact">
5232 Starting printer spooler: lpd.
5237 This can be achieved by saying
5238 <example compact="compact">
5239 echo -n "Starting printer spooler: lpd"
5240 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5243 in the script. If you have more than one daemon to
5244 start, you should do the following:
5245 <example compact="compact">
5246 echo -n "Starting remote file system services:"
5247 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5248 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5249 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5252 This makes it possible for the user to see what takes
5253 so long and when the final daemon has been started.
5254 You should be careful where to put spaces: in the
5255 example above the system administrator can easily
5256 comment out a line if he don't wants to start a
5257 specific daemon, while the displayed message still
5263 <p>When a system parameter is being set</p>
5266 If you have to set up different system parameters
5267 during the system boot, you should use this format:
5268 <example compact="compact">
5269 Setting <var>parameter</var> to "<var>value</var>".
5274 You can use a statement such as the following to get
5276 <example compact="compact">
5277 echo "Setting DNS domainname to \"$domainname\"."
5282 Note that the same symbol (<tt>"</tt>) is used for the left
5283 and right quotation marks. A grave accent (<tt>`</tt>) is
5284 not a quote character; neither is an apostrophe
5290 <p>When a daemon is stopped or restarted</p>
5293 When you stop or restart a daemon, you should issue a
5294 message identical to the startup message, except that
5295 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5296 or <tt>Restarting</tt> respectively.
5300 For example, stopping the printer daemon will like
5302 <example compact="compact">
5303 Stopping printer spooler: lpd.
5309 <p>When something is executed</p>
5312 There are several examples where you have to run a
5313 program at system startup or shutdown to perform a
5314 specific task, for example, setting the system's clock
5315 using <prgn>netdate</prgn> or killing all processes
5316 when the system shuts down. Your message should look
5318 <example compact="compact">
5319 Doing something very useful...done.
5321 You should print the <tt>done.</tt> immediately after
5322 the job has been completed, so that the user is
5323 informed why she has to wait. You can get this
5325 <example compact="compact">
5326 echo -n "Doing something very useful..."
5335 <p>When the configuration is reloaded</p>
5338 When a daemon is forced to reload its configuration
5339 files you should use the following format:
5340 <example compact="compact">
5341 Reloading <var>description</var> configuration...done.
5343 where <var>description</var> is the same as in the
5344 daemon starting message.
5352 <heading>Cron jobs</heading>
5355 Packages must not modify the configuration file
5356 <file>/etc/crontab</file>, and they must not modify the files in
5357 <file>/var/spool/cron/crontabs</file>.</p>
5360 If a package wants to install a job that has to be executed
5361 via cron, it should place a file with the name of the
5362 package in one or more of the following directories:
5363 <example compact="compact">
5368 As these directory names imply, the files within them are
5369 executed on a daily, weekly, or monthly basis,
5370 respectively. The exact times are listed in
5371 <file>/etc/crontab</file>.</p>
5374 All files installed in any of these directories must be
5375 scripts (e.g., shell scripts or Perl scripts) so that they
5376 can easily be modified by the local system administrator.
5377 In addition, they should be treated as configuration
5382 If a certain job has to be executed more frequently than
5383 daily, the package should install a file
5384 <file>/etc/cron.d/<var>package</var></file>. This file uses the
5385 same syntax as <file>/etc/crontab</file> and is processed by
5386 <prgn>cron</prgn> automatically. The file must also be
5387 treated as a configuration file. (Note that entries in the
5388 <file>/etc/cron.d</file> directory are not handled by
5389 <prgn>anacron</prgn>. Thus, you should only use this
5390 directory for jobs which may be skipped if the system is not
5394 The scripts or crontab entries in these directories should
5395 check if all necessary programs are installed before they
5396 try to execute them. Otherwise, problems will arise when a
5397 package was removed but not purged since configuration files
5398 are kept on the system in this situation.</p>
5402 <heading>Menus</heading>
5405 Menu entries should follow the current menu policy found in
5406 the <tt>menu-policy</tt> files in the <tt>debian-policy</tt>
5407 package. It may also be found on the Debian FTP site
5408 <ftpsite>ftp.debian.org</ftpsite> as the file
5409 <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>,
5410 or in the equivalent location on your local mirror.
5414 The Debian <tt>menu</tt> package provides a standard
5415 interface between packages providing applications and
5416 documents, and <em>menu programs</em> (either X window
5417 managers or text-based menu programs such as
5418 <prgn>pdmenu</prgn>).
5422 All packages that provide applications that need not be
5423 passed any special command line arguments for normal
5424 operation should register a menu entry for those
5425 applications, so that users of the <tt>menu</tt> package
5426 will automatically get menu entries in their window
5427 managers, as well in shells like <tt>pdmenu</tt>.</p>
5430 Please also refer to the <em>Debian Menu System</em>
5431 documentation that comes with the <tt>menu</tt> package for
5432 information about how to register your applications and web
5438 <heading>Multimedia handlers</heading>
5441 Packages which provide the ability to view/show/play,
5442 compose, edit or print MIME types should register themselves
5443 as such following the current MIME support policy found in
5444 the <tt>mime-policy</tt> files in the <tt>debian-policy</tt>
5445 package. It may also be found on the Debian FTP site
5446 <ftpsite>ftp.debian.org</ftpsite> as the file
5447 <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>,
5448 or in the equivalent location on your local mirror.
5452 MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5453 is a mechanism for encoding files and data streams and
5454 providing meta-information about them, in particular their
5455 type (e.g. audio or video) and format (e.g. PNG, HTML,
5460 Registration of MIME type handlers allows programs like mail
5461 user agents and web browsers to to invoke these handlers to
5462 view, edit or display MIME types they don't support
5468 <heading>Keyboard configuration</heading>
5471 To achieve a consistent keyboard configuration so that all
5472 applications interpret a keyboard event the same way, all
5473 programs in the Debian distribution must be configured to
5474 comply with the following guidelines.
5478 The following keys must have the specified interpretations:
5481 <tag><tt><--</tt></tag>
5482 <item><p>delete the character to the left of the cursor</p></item>
5484 <tag><tt>Delete</tt></tag>
5485 <item><p>delete the character to the right of the cursor</p></item>
5487 <tag><tt>Control+H</tt></tag>
5488 <item><p>emacs: the help prefix</p></item>
5491 The interpretation of any keyboard events should be
5492 independent of the terminal that is used, be it a virtual
5493 console, an X terminal emulator, an rlogin/telnet session,
5498 The following list explains how the different programs
5499 should be set up to achieve this:
5504 <item><p><tt><--</tt> generates <tt>KB_BackSpace</tt>
5507 <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5512 X translations are set up to make
5513 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5514 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5515 is the vt220 escape code for the "delete character"
5516 key). This must be done by loading the X resources
5517 using <prgn>xrdb</prgn> on all local X displays, not
5518 using the application defaults, so that the
5519 translation resources used correspond to the
5520 <prgn>xmodmap</prgn> settings.</p></item>
5524 The Linux console is configured to make
5525 <tt><--</tt> generate DEL, and <tt>Delete</tt>
5526 generate <tt>ESC [ 3 ~</tt>.</p></item>
5530 X applications are configured so that <tt><</tt>
5531 deletes left, and <tt>Delete</tt> deletes right. Motif
5532 applications already work like this.</p></item>
5534 <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5538 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5539 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5540 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5544 Emacs is programmed to map <tt>KB_Backspace</tt> or
5545 the <tt>stty erase</tt> character to
5546 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5547 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5548 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5552 Other applications use the <tt>stty erase</tt>
5553 character and <tt>kdch1</tt> for the two delete keys,
5554 with ASCII DEL being "delete previous character" and
5555 <tt>kdch1</tt> being "delete character under
5562 This will solve the problem except for the following
5570 Some terminals have a <tt><--</tt> key that cannot
5571 be made to produce anything except <tt>^H</tt>. On
5572 these terminals Emacs help will be unavailable on
5573 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5574 character takes precedence in Emacs, and has been set
5575 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
5576 available) can be used instead.</p></item>
5580 Some operating systems use <tt>^H</tt> for <tt>stty
5581 erase</tt>. However, modern telnet versions and all
5582 rlogin versions propagate <tt>stty</tt> settings, and
5583 almost all UNIX versions honour <tt>stty erase</tt>.
5584 Where the <tt>stty</tt> settings are not propagated
5585 correctly, things can be made to work by using
5586 <tt>stty</tt> manually.</p></item>
5590 Some systems (including previous Debian versions) use
5591 <prgn>xmodmap</prgn> to arrange for both
5592 <tt><--</tt> and <tt>Delete</tt> to generate
5593 <tt>KB_Delete</tt>. We can change the behavior of
5594 their X clients using the same X resources that we use
5595 to do it for our own clients, or configure our clients
5596 using their resources when things are the other way
5597 around. On displays configured like this
5598 <tt>Delete</tt> will not work, but <tt><--</tt>
5603 Some operating systems have different <tt>kdch1</tt>
5604 settings in their <tt>terminfo</tt> database for
5605 <tt>xterm</tt> and others. On these systems the
5606 <tt>Delete</tt> key will not work correctly when you
5607 log in from a system conforming to our policy, but
5608 <tt><--</tt> will.</p></item>
5614 <heading>Environment variables</heading>
5617 A program must not depend on environment variables to get
5618 reasonable defaults. (That's because these environment
5619 variables would have to be set in a system-wide
5620 configuration file like <file>/etc/profile</file>, which is not
5621 supported by all shells.)</p>
5624 If a program usually depends on environment variables for its
5625 configuration, the program should be changed to fall back to
5626 a reasonable default configuration if these environment
5627 variables are not present. If this cannot be done easily
5628 (e.g., if the source code of a non-free program is not
5629 available), the program must be replaced by a small
5630 "wrapper" shell script which sets the environment variables
5631 if they are not already defined, and calls the original program.</p>
5634 Here is an example of a wrapper script for this purpose:
5636 <example compact="compact">
5638 BAR=${BAR:-/var/lib/fubar}
5640 exec /usr/lib/foo/foo "$@"
5645 Furthermore, as <file>/etc/profile</file> is a configuration
5646 file of the <prgn>base-files</prgn> package, other packages must not
5647 put any environment variables or other commands into that
5653 <heading>Files</heading>
5656 <heading>Binaries</heading>
5659 Two different packages must not install programs with
5660 different functionality but with the same filenames. (The
5661 case of two programs having the same functionality but
5662 different implementations is handled via "alternatives" or
5663 the "Conflicts" mechanism. See <ref id="maintscripts"> and
5664 <ref id="conflicts"> respectively.) If this case happens,
5665 one of the programs must be renamed. The maintainers should
5666 report this to the <tt>debian-devel</tt> mailing list and
5667 try to find a consensus about which program will have to be
5668 renamed. If a consensus cannot be reached, <em>both</em>
5669 programs must be renamed.
5673 By default, when a package is being built, any binaries
5674 created should include debugging information, as well as
5675 being compiled with optimization. You should also turn on
5676 as many reasonable compilation warnings as possible; this
5677 makes life easier for porters, who can then look at build
5678 logs for possible problems. For the C programming language,
5679 this means the following compilation parameters should be
5681 <example compact="compact">
5683 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5685 install -s # (or use strip on the files in debian/tmp)
5690 Note that by default all installed binaries should be stripped,
5691 either by using the <tt>-s</tt> flag to
5692 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5693 the binaries after they have been copied into
5694 <file>debian/tmp</file> but before the tree is made into a
5698 Although binaries in the build tree should be compiled with
5699 debugging information by default, it can often be difficult
5700 to debug programs if they are also subjected to compiler
5701 optimization. For this reason, it is recommended to support
5702 the standardized environment
5703 variable <tt>DEB_BUILD_OPTIONS</tt>. This variable can
5704 contain several flags to change how a package is compiled
5712 The presence of this string means that the package
5713 should be complied with a minimum of optimization.
5714 For C programs, it is best to add <tt>-O0</tt>
5715 to <tt>CFLAGS</tt> (although this is usually the
5716 default). Some programs might fail to build or run at
5717 this level of optimization; it may be necessary to
5718 use <tt>-O1</tt>, for example.
5724 This string means that the debugging symbols should
5725 not be stripped from the binary during installation,
5726 so that debugging information may be included in the package.
5732 The following makefile snippet is an example of how one may
5733 implement the build options; you will probably have to
5734 massage this example in order to make it work for your
5736 <example compact="compact">
5739 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5740 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5741 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5742 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5744 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5749 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5750 INSTALL_PROGRAM += -s
5756 It is up to the package maintainer to decide what
5757 compilation options are best for the package. Certain
5758 binaries (such as computationally-intensive programs) will
5759 function better with certain flags (<tt>-O3</tt>, for
5760 example); feel free to use them. Please use good judgment
5761 here. Don't use flags for the sake of it; only use them
5762 if there is good reason to do so. Feel free to override
5763 the upstream author's ideas about which compilation
5764 options are best: they are often inappropriate for our
5770 <sect id="libraries">
5771 <heading>Libraries</heading>
5774 The shared version of a library must be compiled with
5775 <tt>-fPIC</tt>, and the static version must not be. In other
5776 words, each source unit (<tt>*.c</tt>, for example, for C files)
5777 will need to be compiled twice.
5782 You must specify the gcc option <tt>-D_REENTRANT</tt>
5783 when building a library (either static or shared) to make
5784 the library compatible with LinuxThreads.
5788 All installed shared libraries should be stripped with
5789 <example compact="compact">
5790 strip --strip-unneeded <var>your-lib</var>
5792 (The option <tt>--strip-unneeded</tt> makes
5793 <prgn>strip</prgn> remove only the symbols which aren't
5794 needed for relocation processing.) Shared libraries can
5795 function perfectly well when stripped, since the symbols for
5796 dynamic linking are in a separate part of the ELF object
5799 You might also want to use the options
5800 <tt>--remove-section=.comment</tt> and
5801 <tt>--remove-section=.note</tt> on both shared libraries
5802 and executables, and <tt>--strip-debug</tt> on static
5809 Note that under some circumstances it may be useful to
5810 install a shared library unstripped, for example when
5811 building a separate package to support debugging.
5815 Shared object files (often <file>.so</file> files) that are not
5816 public libraries, that is, they are not meant to be linked
5817 to by third party executables (binaries of other packages),
5818 should be installed in subdirectories of the
5819 <file>/usr/lib</file> directory. Such files are exempt from the
5820 rules that govern ordinary shared libraries, except that
5821 they must not be installed executable and should be
5824 A common example are the so-called "plug-ins",
5825 internal shared objects that are dynamically loaded by
5826 programs using <manref name="dlopen" section="3">.
5832 Packages containing shared libraries that may be linked to
5833 by other packages' binaries, but which for some
5834 <em>compelling</em> reason can not be installed in
5835 <file>/usr/lib</file> directory, may install the shared library
5836 files in subdirectories of the <file>/usr/lib</file> directory,
5837 in which case they should arrange to add that directory in
5838 <file>/etc/ld.so.conf</file> in the package's post-installation
5839 script, and remove it in the package's post-removal script.
5843 An ever increasing number of packages are using
5844 <prgn>libtool</prgn> to do their linking. The latest GNU
5845 libtools (>= 1.3a) can take advantage of the metadata in the
5846 installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5847 files). The main advantage of <prgn>libtool</prgn>'s
5848 <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5849 store and subsequently access metadata with respect to the
5850 libraries it builds. <prgn>libtool</prgn> will search for
5851 those files, which contain a lot of useful information about
5852 a library (such as library dependency information for static
5853 linking). Also, they're <em>essential</em> for programs
5854 using <tt>libltdl</tt>.<footnote>
5856 Although <prgn>libtool</prgn> is fully capable of
5857 linking against shared libraries which don't have
5858 <tt>.la</tt> files, as it is a mere shell script it can
5859 add considerably to the build time of a
5860 <prgn>libtool</prgn>-using package if that shell script
5861 has to derive all this information from first principles
5862 for each library every time it is linked. With the
5863 advent of <prgn>libtool</prgn> version 1.4 (and to a
5864 lesser extent <prgn>libtool</prgn> version 1.3), the
5865 <file>.la</file> files also store information about
5866 inter-library dependencies which cannot necessarily be
5867 derived after the <file>.la</file> file is deleted.
5873 Packages that use <prgn>libtool</prgn> to create shared
5874 libraries should include the <file>.la</file> files in the
5875 <tt>-dev</tt> package, unless the package relies on
5876 <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5877 the <tt>.la</tt> files must go in the run-time library
5882 You must make sure that you use only released versions of
5883 shared libraries to build your packages; otherwise other
5884 users will not be able to run your binaries
5885 properly. Producing source packages that depend on
5886 unreleased compilers is also usually a bad
5893 <heading>Shared libraries</heading>
5895 This section has moved to <ref id="sharedlibs">.
5901 <heading>Scripts</heading>
5904 All command scripts, including the package maintainer
5905 scripts inside the package and used by <prgn>dpkg</prgn>,
5906 should have a <tt>#!</tt> line naming the shell to be used
5907 to interpret them.</p>
5910 In the case of Perl scripts this should be
5911 <tt>#!/usr/bin/perl</tt>.</p>
5914 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5915 should almost certainly start with <tt>set -e</tt> so that
5916 errors are detected. Every script should use
5917 <tt>set -e</tt> or check the exit status of <em>every</em>
5921 The standard shell interpreter <file>/bin/sh</file> can be a
5922 symbolic link to any POSIX compatible shell, if <tt>echo
5923 -n</tt> does not generate a newline.<footnote>
5925 Debian policy specifies POSIX behavior for
5926 <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5927 use in the Linux community (in particular including this
5928 policy, the Linux kernel source, many Debian scripts,
5929 etc.). This <tt>echo -n</tt> mechanism is valid but not
5930 required under POSIX, hence this explicit addition.
5931 Also, rumour has it that this shall be mandated under
5935 Thus, shell scripts specifying <file>/bin/sh</file> as
5936 interpreter should only use POSIX features. If a script
5937 requires non-POSIX features from the shell interpreter, the
5938 appropriate shell must be specified in the first line of the
5939 script (e.g., <tt>#!/bin/bash</tt>) and the package must
5940 depend on the package providing the shell (unless the shell
5941 package is marked "Essential", as in the case of
5946 You may wish to restrict your script to POSIX features when
5947 possible so that it may use <file>/bin/sh</file> as its
5948 interpreter. If your script works with <prgn>dash</prgn>
5949 (originally called <prgn>ash</prgn>), it's probably POSIX
5950 compliant, but if you are in doubt, use
5951 <file>/bin/bash</file>.
5955 Perl scripts should check for errors when making any
5956 system calls, including <tt>open</tt>, <tt>print</tt>,
5957 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5961 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5962 scripting languages. See <em>Csh Programming Considered
5963 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5964 can be found at <url
5965 id="http://language.perl.com/versus/csh.whynot">.<footnote>
5967 It can also be found on
5968 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5969 or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5970 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5973 If an upstream package comes with <prgn>csh</prgn> scripts
5974 then you must make sure that they start with
5975 <tt>#!/bin/csh</tt> and make your package depend on the
5976 <prgn>c-shell</prgn> virtual package.
5980 Any scripts which create files in world-writeable
5981 directories (e.g., in <file>/tmp</file>) must use a
5982 mechanism which will fail if a file with the same name
5986 The Debian base system provides the <prgn>tempfile</prgn>
5987 and <prgn>mktemp</prgn> utilities for use by scripts for
5988 this purpose.</p></sect>
5992 <heading>Symbolic links</heading>
5995 In general, symbolic links within a top-level directory
5996 should be relative, and symbolic links pointing from one
5997 top-level directory into another should be absolute. (A
5998 top-level directory is a sub-directory of the root
5999 directory <file>/</file>.)</p>
6002 In addition, symbolic links should be specified as short as
6003 possible, i.e., link targets like <file>foo/../bar</file> are
6007 Note that when creating a relative link using
6008 <prgn>ln</prgn> it is not necessary for the target of the
6009 link to exist relative to the working directory you're
6010 running <prgn>ln</prgn> from, nor is it necessary to change
6011 directory to the directory where the link is to be made.
6012 Simply include the string that should appear as the target
6013 of the link (this will be a pathname relative to the
6014 directory in which the link resides) as the first argument
6015 to <prgn>ln</prgn>.</p>
6018 For example, in your <prgn>Makefile</prgn> or
6019 <file>debian/rules</file>, you can do things like:
6020 <example compact="compact">
6021 ln -fs gcc $(prefix)/bin/cc
6022 ln -fs gcc debian/tmp/usr/bin/cc
6023 ln -fs ../sbin/sendmail $(prefix)/bin/runq
6024 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
6028 A symbolic link pointing to a compressed file should always
6029 have the same file extension as the referenced file. (For
6030 example, if a file <file>foo.gz</file> is referenced by a
6031 symbolic link, the filename of the link has to end with
6032 "<file>.gz</file>" too, as in <file>bar.gz</file>.)
6037 <heading>Device files</heading>
6040 Packages must not include device files in the package file
6044 If a package needs any special device files that are not
6045 included in the base system, it must call
6046 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
6047 after notifying the user<footnote>
6049 This notification could be done via a (low-priority)
6050 debconf message, or an echo (printf) statement.
6056 Packages must not remove any device files in the
6057 <prgn>postrm</prgn> or any other script. This is left to the
6058 system administrator.</p>
6061 Debian uses the serial devices
6062 <file>/dev/ttyS*</file>. Programs using the old
6063 <file>/dev/cu*</file> devices should be changed to use
6064 <file>/dev/ttyS*</file>.</p>
6067 <sect id="config-files">
6068 <heading>Configuration files</heading>
6070 <heading>Definitions</heading>
6073 <tag>configuration file</tag>
6076 A file that affects the operation of a program, or
6077 provides site- or host-specific information, or
6078 otherwise customizes the behavior of a program.
6079 Typically, configuration files are intended to be
6080 modified by the system administrator (if needed or
6081 desired) to conform to local policy or to provide
6082 more useful site-specific behavior.
6086 <tag><tt>conffile</tt></tag>
6089 A file listed in a package's <tt>conffiles</tt>
6090 file, and is treated specially by <prgn>dpkg</prgn>
6091 (see <ref id="configdetails">).
6098 The distinction between these two is important; they are
6099 not interchangeable concepts. Almost all
6100 <tt>conffile</tt>s are configuration files, but many
6101 configuration files are not <tt>conffiles</tt>.
6105 Note that a script that embeds configuration information
6106 (such as most of the files in <file>/etc/default</file> and
6107 <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6108 configuration file and should be treated as such.
6113 <heading>Location</heading>
6115 Any configuration files created or used by your package
6116 must reside in <file>/etc</file>. If there are several,
6117 consider creating a subdirectory of <file>/etc</file>
6118 named after your package.</p>
6121 If your package creates or uses configuration files
6122 outside of <file>/etc</file>, and it is not feasible to modify
6123 the package to use <file>/etc</file> directly, put the files
6124 in <file>/etc</file> and create symbolic links to those files
6125 from the location that the package requires.</p>
6129 <heading>Behavior</heading>
6131 Configuration file handling must conform to the following
6133 <list compact="compact">
6136 local changes must be preserved during a package
6142 configuration files must be preserved when the
6143 package is removed, and only deleted when the
6151 The easy way to achieve this behavior is to make the
6152 configuration file a <tt>conffile</tt>. This is
6153 appropriate only if it is possible to distribute a default
6154 version that will work for most installations, although
6155 some system administrators may choose to modify it. This
6156 implies that the default version will be part of the
6157 package distribution, and must not be modified by the
6158 maintainer scripts during installation (or at any other
6163 In order to ensure that local changes are preserved
6164 correctly, no package may contain or make hard links to
6165 conffiles.<footnote>
6167 Rationale: There are two problems with hard links.
6168 The first is that some editors break the link while
6169 editing one of the files, so that the two files may
6170 unwittingly become unlinked and different. The second
6171 is that <prgn>dpkg</prgn> might break the hard link
6172 while upgrading <tt>conffile</tt>s.
6178 The other way to do it is via the maintainer scripts. In
6179 this case, the configuration file must not be listed as a
6180 <tt>conffile</tt> and must not be part of the package
6181 distribution. If the existence of a file is required for
6182 the package to be sensibly configured it is the
6183 responsibility of the package maintainer to provide
6184 maintainer scripts which correctly create, update and
6185 maintain the file and remove it on purge. (See <ref
6186 id="maintainerscripts"> for more information.) These
6187 scripts must be idempotent (i.e., must work correctly if
6188 <prgn>dpkg</prgn> needs to re-run them due to errors
6189 during installation or removal), must cope with all the
6190 variety of ways <prgn>dpkg</prgn> can call maintainer
6191 scripts, must not overwrite or otherwise mangle the user's
6192 configuration without asking, must not ask unnecessary
6193 questions (particularly during upgrades), and otherwise be
6198 The scripts are not required to configure every possible
6199 option for the package, but only those necessary to get
6200 the package running on a given system. Ideally the
6201 sysadmin should not have to do any configuration other
6202 than that done (semi-)automatically by the
6203 <prgn>postinst</prgn> script.
6207 A common practice is to create a script called
6208 <file><var>package</var>-configure</file> and have the
6209 package's <prgn>postinst</prgn> call it if and only if the
6210 configuration file does not already exist. In certain
6211 cases it is useful for there to be an example or template
6212 file which the maintainer scripts use. Such files should
6213 be in <file>/usr/share/<var>package</var></file> or
6214 <file>/usr/lib/<var>package</var></file> (depending on whether
6215 they are architecture-independent or not). There should
6216 be symbolic links to them from
6217 <file>/usr/share/doc/<var>package</var>/examples</file> if
6218 they are examples, and should be perfectly ordinary
6219 <prgn>dpkg</prgn>-handled files (<em>not</em>
6220 configuration files).
6224 These two styles of configuration file handling must
6225 not be mixed, for that way lies madness:
6226 <prgn>dpkg</prgn> will ask about overwriting the file
6227 every time the package is upgraded.
6232 <heading>Sharing configuration files</heading>
6234 Packages which specify the same file as a
6235 <tt>conffile</tt> must be tagged as <em>conflicting</em>
6236 with each other. (This is an instance of the general rule
6237 about not sharing files. Note that neither alternatives
6238 nor diversions are likely to be appropriate in this case;
6239 in particular, <prgn>dpkg</prgn> does not handle diverted
6240 <tt>conffile</tt>s well.)
6244 The maintainer scripts must not alter a <tt>conffile</tt>
6245 of <em>any</em> package, including the one the scripts
6250 If two or more packages use the same configuration file
6251 and it is reasonable for both to be installed at the same
6252 time, one of these packages must be defined as
6253 <em>owner</em> of the configuration file, i.e., it will be
6254 the package which handles that file as a configuration
6255 file. Other packages that use the configuration file must
6256 depend on the owning package if they require the
6257 configuration file to operate. If the other package will
6258 use the configuration file if present, but is capable of
6259 operating without it, no dependency need be declared.</p>
6262 If it is desirable for two or more related packages to
6263 share a configuration file <em>and</em> for all of the
6264 related packages to be able to modify that configuration
6265 file, then the following should be done:
6266 <enumlist compact="compact">
6269 One of the related packages (the "owning" package)
6270 will manage the configuration file with maintainer
6271 scripts as described in the previous section.
6276 The owning package should also provide a program
6277 that the other packages may use to modify the
6283 The related packages must use the provided program
6284 to make any desired modifications to the
6285 configuration file. They should either depend on
6286 the core package to guarantee that the configuration
6287 modifier program is available or accept gracefully
6288 that they cannot modify the configuration file if it
6289 is not. (This is in addition to the fact that the
6290 configuration file may not even be present in the
6298 Sometimes it's appropriate to create a new package which
6299 provides the basic infrastructure for the other packages
6300 and which manages the shared configuration files. (The
6301 <tt>sgml-base</tt> package is a good example.)
6306 <heading>User configuration files ("dotfiles")</heading>
6309 The files in <file>/etc/skel</file> will automatically be
6310 copied into new user accounts by <prgn>adduser</prgn>.
6311 No other program should reference the files in
6312 <file>/etc/skel</file>.
6316 Therefore, if a program needs a dotfile to exist in
6317 advance in <file>$HOME</file> to work sensibly, that dotfile
6318 should be installed in <file>/etc/skel</file> and treated as a
6323 However, programs that require dotfiles in order to
6324 operate sensibly are a bad thing, unless they do create
6325 the dotfiles themselves automatically.
6329 Furthermore, programs should be configured by the Debian
6330 default installation to behave as closely to the upstream
6331 default behaviour as possible.
6335 Therefore, if a program in a Debian package needs to be
6336 configured in some way in order to operate sensibly, that
6337 should be done using a site-wide configuration file placed
6338 in <file>/etc</file>. Only if the program doesn't support a
6339 site-wide default configuration and the package maintainer
6340 doesn't have time to add it may a default per-user file be
6341 placed in <file>/etc/skel</file>.
6345 <file>/etc/skel</file> should be as empty as we can make it.
6346 This is particularly true because there is no easy (or
6347 necessarily desirable) mechanism for ensuring that the
6348 appropriate dotfiles are copied into the accounts of
6349 existing users when a package is installed.
6355 <heading>Log files</heading>
6357 Log files should usually be named
6358 <file>/var/log/<var>package</var>.log</file>. If you have many
6359 log files, or need a separate directory for permission
6360 reasons (<file>/var/log</file> is writable only by
6361 <file>root</file>), you should usually create a directory named
6362 <file>/var/log/<var>package</var></file> and place your log
6367 Log files must be rotated occasionally so that they don't
6368 grow indefinitely; the best way to do this is to drop a log
6369 rotation configuration file into the directory
6370 <file>/etc/logrotate.d</file> and use the facilities provided by
6371 logrotate.<footnote>
6373 The traditional approach to log files has been to set up
6374 <em>ad hoc</em> log rotation schemes using simple shell
6375 scripts and cron. While this approach is highly
6376 customizable, it requires quite a lot of sysadmin work.
6377 Even though the original Debian system helped a little
6378 by automatically installing a system which can be used
6379 as a template, this was deemed not enough.
6383 The use of <prgn>logrotate</prgn>, a program developed
6384 by Red Hat, is better, as it centralizes log management.
6385 It has both a configuration file
6386 (<file>/etc/logrotate.conf</file>) and a directory where
6387 packages can drop their individual log rotation
6388 configurations (<file>/etc/logrotate.d</file>).
6391 Here is a good example for a logrotate config
6392 file (for more information see <manref name="logrotate"
6394 <example compact="compact">
6400 /etc/init.d/foo force-reload
6404 This rotates all files under <file>/var/log/foo</file>, saves 12
6405 compressed generations, and forces the daemon to reload its
6406 configuration information after the log rotation.
6410 Log files should be removed when the package is
6411 purged (but not when it is only removed). This should be
6412 done by the <prgn>postrm</prgn> script when it is called
6413 with the argument <tt>purge</tt> (see <ref
6414 id="removedetails">).
6419 <heading>Permissions and owners</heading>
6422 The rules in this section are guidelines for general use.
6423 If necessary you may deviate from the details below.
6424 However, if you do so you must make sure that what is done
6425 is secure and you should try to be as consistent as possible
6426 with the rest of the system. You should probably also
6427 discuss it on <prgn>debian-devel</prgn> first.
6431 Files should be owned by <tt>root.root</tt>, and made
6432 writable only by the owner and universally readable (and
6433 executable, if appropriate), that is mode 644 or 755.
6437 Directories should be mode 755 or (for group-writability)
6438 mode 2775. The ownership of the directory should be
6439 consistent with its mode: if a directory is mode 2775, it
6440 should be owned by the group that needs write access to
6445 Setuid and setgid executables should be mode 4755 or 2755
6446 respectively, and owned by the appropriate user or group.
6447 They should not be made unreadable (modes like 4711 or
6448 2711 or even 4111); doing so achieves no extra security,
6449 because anyone can find the binary in the freely available
6450 Debian package; it is merely inconvenient. For the same
6451 reason you should not restrict read or execute permissions
6452 on non-set-id executables.
6456 Some setuid programs need to be restricted to particular
6457 sets of users, using file permissions. In this case they
6458 should be owned by the uid to which they are set-id, and by
6459 the group which should be allowed to execute them. They
6460 should have mode 4754; again there is no point in making
6461 them unreadable to those users who must not be allowed to
6466 It is possible to arrange that the system administrator can
6467 reconfigure the package to correspond to their local
6468 security policy by changing the permissions on a binary:
6469 they can do this by using <prgn>dpkg-statoverride</prgn>, as
6470 described below.<footnote>
6472 Ordinary files installed by <prgn>dpkg</prgn> (as
6473 opposed to <tt>conffile</tt>s and other similar objects)
6474 normally have their permissions reset to the distributed
6475 permissions when the package is reinstalled. However,
6476 the use of <prgn>dpkg-statoverride</prgn> overrides this
6477 default behaviour. If you use this method, you should
6478 remember to describe <prgn>dpkg-statoverride</prgn> in
6479 the package documentation; being a relatively new
6480 addition to Debian, it is probably not yet well-known.
6483 Another method you should consider is to create a group for
6484 people allowed to use the program(s) and make any setuid
6485 executables executable only by that group.
6489 If you need to create a new user or group for your package
6490 there are two possibilities. Firstly, you may need to
6491 make some files in the binary package be owned by this
6492 user or group, or you may need to compile the user or
6493 group id (rather than just the name) into the binary
6494 (though this latter should be avoided if possible, as in
6495 this case you need a statically allocated id).</p>
6498 If you need a statically allocated id, you must ask for a
6499 user or group id from the <tt>base-passwd</tt> maintainer,
6500 and must not release the package until you have been
6501 allocated one. Once you have been allocated one you must
6502 either make the package depend on a version of the
6503 <tt>base-passwd</tt> package with the id present in
6504 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6505 your package to create the user or group itself with the
6506 correct id (using <tt>adduser</tt>) in its
6507 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
6508 the <prgn>postinst</prgn> is to be preferred if it is
6509 possible, otherwise a pre-dependency will be needed on the
6510 <tt>adduser</tt> package.)
6514 On the other hand, the program might be able to determine
6515 the uid or gid from the user or group name at runtime, so
6516 that a dynamically allocated id can be used. In this case
6517 you should choose an appropriate user or group name,
6518 discussing this on <prgn>debian-devel</prgn> and checking
6519 with the <package/base-passwd/ maintainer that it is unique and that
6520 they do not wish you to use a statically allocated id
6521 instead. When this has been checked you must arrange for
6522 your package to create the user or group if necessary using
6523 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6524 <prgn>postinst</prgn> script (again, the latter is to be
6525 preferred if it is possible).
6529 Note that changing the numeric value of an id associated
6530 with a name is very difficult, and involves searching the
6531 file system for all appropriate files. You need to think
6532 carefully whether a static or dynamic id is required, since
6533 changing your mind later will cause problems.
6536 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6538 This section is not intended as policy, but as a
6539 description of the use of <prgn>dpkg-statoverride</prgn>.
6543 <prgn>dpkg-statoverride</prgn> is a replacement for the
6544 deprecated <tt>suidmanager</tt> package. Packages which
6545 previously used <tt>suidmanager</tt> should have a
6546 <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6547 <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6548 and <tt>suidunregister</tt> should now be simply removed
6549 from the maintainer scripts.
6553 If a system administrator wishes to have a file (or
6554 directory or other such thing) installed with owner and
6555 permissions different from those in the distributed Debian
6556 package, he can use the <prgn>dpkg-statoverride</prgn>
6557 program to instruct <prgn>dpkg</prgn> to use the different
6558 settings every time the file is installed. Thus the
6559 package maintainer should distribute the files with their
6560 normal permissions, and leave it for the system
6561 administrator to make any desired changes. For example, a
6562 daemon which is normally required to be setuid root, but
6563 in certain situations could be used without being setuid,
6564 should be installed setuid in the <tt>.deb</tt>. Then the
6565 local system administrator can change this if they wish.
6566 If there are two standard ways of doing it, the package
6567 maintainer can use <tt>debconf</tt> to find out the
6568 preference, and call <prgn>dpkg-statoverride</prgn> in the
6569 maintainer script if necessary to accommodate the system
6570 administrator's choice.
6574 Given the above, <prgn>dpkg-statoverride</prgn> is
6575 essentially a tool for system administrators and would not
6576 normally be needed in the maintainer scripts. There is
6577 one type of situation, though, where calls to
6578 <prgn>dpkg-statoverride</prgn> would be needed in the
6579 maintainer scripts, and that involves packages which use
6580 dynamically allocated user or group ids. In such a
6581 situation, something like the following idiom can be very
6582 helpful in the package's <prgn>postinst</prgn>, where
6583 <tt>sysuser</tt> is a dynamically allocated id:
6585 for i in /usr/bin/foo /usr/sbin/bar
6587 if ! dpkg-statoverride --list $i >/dev/null
6589 dpkg-statoverride --update --add sysuser root 4755 $i
6593 The corresponding <tt>dpkg-statoverride --remove</tt>
6594 calls can then be made unconditionally when the package is
6601 <chapt id="customized-programs">
6602 <heading>Customized programs</heading>
6604 <sect id="arch-spec">
6605 <heading>Architecture specification strings</heading>
6608 If a program needs to specify an <em>architecture specification
6609 string</em> in some place, the following format should be
6610 used: <var>arch</var>-<var>os</var><footnote>
6612 The following architectures and operating systems are
6613 currently recognised by <prgn>dpkg-archictecture</prgn>.
6614 The architecture, <tt><var>arch</var></tt>, is one of
6615 the following: <tt>alpha</tt>, <tt>arm</tt>,
6616 <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6617 <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6618 <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6619 <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>. The
6620 operating system, <tt><var>os</var></tt>, is one of:
6621 <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6622 <tt>openbsd</tt>. Use of <tt>gnu</tt> in this string is
6623 reserved for the GNU/Hurd operating system.
6629 Note that we don't want to use
6630 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6631 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6632 since this would make our programs incompatible with other
6633 Linux distributions. We also don't use something like
6634 <tt><var>arch</var>-unknown-linux</tt>, since the
6635 <tt>unknown</tt> does not look very good.
6640 <heading>Daemons</heading>
6643 The configuration files <file>/etc/services</file>,
6644 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6645 by the <prgn>netbase</prgn> package and must not be modified
6650 If a package requires a new entry in one of these files, the
6651 maintainer should get in contact with the
6652 <prgn>netbase</prgn> maintainer, who will add the entries
6653 and release a new version of the <prgn>netbase</prgn>
6658 The configuration file <file>/etc/inetd.conf</file> must not be
6659 modified by the package's scripts except via the
6660 <prgn>update-inetd</prgn> script or the
6661 <file>DebianNet.pm</file> Perl module. See their documentation
6662 for details on how to add entries.
6666 If a package wants to install an example entry into
6667 <file>/etc/inetd.conf</file>, the entry must be preceded with
6668 exactly one hash character (<tt>#</tt>). Such lines are
6669 treated as "commented out by user" by the
6670 <prgn>update-inetd</prgn> script and are not changed or
6671 activated during package updates.
6676 <heading>Using pseudo-ttys and modifying wtmp, utmp and
6680 Some programs need to create pseudo-ttys. This should be done
6681 using Unix98 ptys if the C library supports it. The resulting
6682 program must not be installed setuid root, unless that
6683 is required for other functionality.
6687 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6688 <file>/var/log/lastlog</file> must be installed writeable by
6689 group <tt>utmp</tt>. Programs which need to modify those
6690 files must be installed setgid <tt>utmp</tt>.
6695 <heading>Editors and pagers</heading>
6698 Some programs have the ability to launch an editor or pager
6699 program to edit or display a text document. Since there are
6700 lots of different editors and pagers available in the Debian
6701 distribution, the system administrator and each user should
6702 have the possibility to choose his/her preferred editor and
6707 In addition, every program should choose a good default
6708 editor/pager if none is selected by the user or system
6713 Thus, every program that launches an editor or pager must
6714 use the EDITOR or PAGER environment variable to determine
6715 the editor or pager the user wishes to use. If these
6716 variables are not set, the programs <file>/usr/bin/editor</file>
6717 and <file>/usr/bin/pager</file> should be used, respectively.
6721 These two files are managed through the <prgn>dpkg</prgn>
6722 "alternatives" mechanism. Thus every package providing an
6723 editor or pager must call the
6724 <prgn>update-alternatives</prgn> script to register these
6729 If it is very hard to adapt a program to make use of the
6730 EDITOR or PAGER variables, that program may be configured to
6731 use <file>/usr/bin/sensible-editor</file> and
6732 <file>/usr/bin/sensible-pager</file> as the editor or pager
6733 program respectively. These are two scripts provided in the
6734 Debian base system that check the EDITOR and PAGER variables
6735 and launch the appropriate program, and fall back to
6736 <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6737 variable is not set.
6741 A program may also use the VISUAL environment variable to
6742 determine the user's choice of editor. If it exists, it
6743 should take precedence over EDITOR. This is in fact what
6744 <file>/usr/bin/sensible-editor</file> does.
6748 It is not required for a package to depend on
6749 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6750 package to provide such virtual packages.<footnote>
6752 The Debian base system already provides an editor and a
6759 <sect id="web-appl">
6760 <heading>Web servers and applications</heading>
6763 This section describes the locations and URLs that should
6764 be used by all web servers and web applications in the
6772 Cgi-bin executable files are installed in the
6774 <example compact="compact">
6775 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6777 and should be referred to as
6778 <example compact="compact">
6779 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6784 <item><p>Access to HTML documents</p>
6787 HTML documents for a package are stored in
6788 <file>/usr/share/doc/<var>package</var></file>
6789 and can be referred to as
6790 <example compact="compact">
6791 http://localhost/doc/<var>package</var>/<var>filename</var>
6795 The web server should restrict access to the document
6796 tree so that only clients on the same host can read
6797 the documents. If the web server does not support such
6798 access controls, then it should not provide access at
6799 all, or ask about providing access during installation.
6803 <item><p>Web Document Root</p>
6806 Web Applications should try to avoid storing files in
6807 the Web Document Root. Instead they should use the
6808 /usr/share/doc/<var>package</var> directory for
6809 documents and register the Web Application via the
6810 menu package. If access to the web document root is
6811 unavoidable then use
6812 <example compact="compact">
6815 as the Document Root. This might be just a symbolic
6816 link to the location where the system administrator
6817 has put the real document root.
6821 </enumlist></p></sect>
6824 <sect id="mail-transport-agents">
6825 <heading>Mail transport, delivery and user agents</heading>
6828 Debian packages which process electronic mail, whether mail
6829 user agents (MUAs) or mail transport agents (MTAs), must
6830 ensure that they are compatible with the configuration
6831 decisions below. Failure to do this may result in lost
6832 mail, broken <tt>From:</tt> lines, and other serious brain
6837 The mail spool is <file>/var/mail</file> and the interface to
6838 send a mail message is <file>/usr/sbin/sendmail</file> (as per
6839 the FHS). On older systems, the mail spool may be
6840 physically located in <file>/var/spool/mail</file>, but all
6841 access to the mail spool should be via the
6842 <file>/var/mail</file> symlink. The mail spool is part of the
6843 base system and not part of the MTA package.
6847 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6848 programs (such as IMAP daemons) must lock the mailbox in an
6849 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6850 be combined with dot locking. To avoid deadlocks, a program
6851 should use <tt>fcntl()</tt> first and dot locking after
6852 this, or alternatively implement the two locking methods in
6853 a non blocking way<footnote>
6855 If it is not possible to establish both locks, the
6856 system shouldn't wait for the second lock to be
6857 established, but remove the first lock, wait a (random)
6858 time, and start over locking again.
6860 </footnote>. Using the functions <tt>maillock</tt> and
6861 <tt>mailunlock</tt> provided by the
6862 <tt>liblockfile*</tt><footnote>
6864 You will need to depend on <tt>liblockfile1
6865 (>>1.01)</tt> to use these functions.
6867 </footnote> packages is the recommended way to realize this.
6871 Mailboxes are generally mode 660
6872 <tt><var>user</var>.mail</tt> unless the system
6873 administrator has chosen otherwise. A MUA may remove a
6874 mailbox (unless it has nonstandard permissions) in which
6875 case the MTA or another MUA must recreate it if needed.
6876 Mailboxes must be writable by group mail.
6880 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6881 be setgid mail to do the locking mentioned above (and
6882 must obviously avoid accessing other users' mailboxes
6883 using this privilege).</p>
6886 <file>/etc/aliases</file> is the source file for the system mail
6887 aliases (e.g., postmaster, usenet, etc.), it is the one
6888 which the sysadmin and <prgn>postinst</prgn> scripts may
6889 edit. After <file>/etc/aliases</file> is edited the program or
6890 human editing it must call <prgn>newaliases</prgn>. All MTA
6891 packages must come with a <prgn>newaliases</prgn> program,
6892 even if it does nothing, but older MTA packages did not do
6893 this so programs should not fail if <prgn>newaliases</prgn>
6894 cannot be found. Note that because of this, all MTA
6895 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6896 <tt>Replaces: mail-transport-agent</tt> control file
6901 The convention of writing <tt>forward to
6902 <var>address</var></tt> in the mailbox itself is not
6903 supported. Use a <tt>.forward</tt> file instead.</p>
6906 The <prgn>rmail</prgn> program used by UUCP
6907 for incoming mail should be <file>/usr/sbin/rmail</file>.
6908 Likewise, <prgn>rsmtp</prgn>, for receiving
6909 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6913 If your package needs to know what hostname to use on (for
6914 example) outgoing news and mail messages which are generated
6915 locally, you should use the file <file>/etc/mailname</file>. It
6916 will contain the portion after the username and <tt>@</tt>
6917 (at) sign for email addresses of users on the machine
6918 (followed by a newline).
6922 Such package should check for the existence of this file
6923 when it is being configured. If it exists, it should be
6924 used without comment, although an MTA's configuration script
6925 may wish to prompt the user even if it finds that this file
6926 exists. If the file does not exist, the package should
6927 prompt the user for the value (preferably using
6928 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6929 as well as using it in the package's configuration. The
6930 prompt should make it clear that the name will not just be
6931 used by that package. For example, in this situation the
6932 <tt>inn</tt> package could say something like:
6933 <example compact="compact">
6934 Please enter the "mail name" of your system. This is the
6935 hostname portion of the address to be shown on outgoing
6936 news and mail messages. The default is
6937 <var>syshostname</var>, your system's host name. Mail
6938 name ["<var>syshostname</var>"]:
6940 where <var>syshostname</var> is the output of <tt>hostname
6946 <heading>News system configuration</heading>
6949 All the configuration files related to the NNTP (news)
6950 servers and clients should be located under
6951 <file>/etc/news</file>.</p>
6954 There are some configuration issues that apply to a number
6955 of news clients and server packages on the machine. These
6959 <tag><file>/etc/news/organization</file></tag>
6960 <item><p>A string which should appear as the
6961 organization header for all messages posted
6962 by NNTP clients on the machine</p></item>
6964 <tag><file>/etc/news/server</file></tag>
6965 <item><p>Contains the FQDN of the upstream NNTP
6966 server, or localhost if the local machine is
6967 an NNTP server.</p></item>
6970 Other global files may be added as required for cross-package news
6971 configuration.</p></sect>
6975 <heading>Programs for the X Window System</heading>
6978 <heading>Providing X support and package priorities</heading>
6981 Programs that can be configured with support for the X
6982 Window System must be configured to do so and must declare
6983 any package dependencies necessary to satisfy their
6984 runtime requirements when using the X Window System. If
6985 such a package is of higher priority than the X packages
6986 on which it depends, it is required that either the
6987 X-specific components be split into a separate package, or
6988 that an alternative version of the package, which includes
6989 X support, be provided, or that the package's priority be
6995 <heading>Packages providing an X server</heading>
6998 Packages that provide an X server that, directly or
6999 indirectly, communicates with real input and display
7000 hardware should declare in their control data that they
7001 provide the virtual package <tt>xserver</tt>.<footnote>
7003 This implements current practice, and provides an
7004 actual policy for usage of the <tt>xserver</tt>
7005 virtual package which appears in the virtual packages
7006 list. In a nutshell, X servers that interface
7007 directly with the display and input hardware or via
7008 another subsystem (e.g., GGI) should provide
7009 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
7010 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
7017 <heading>Packages providing a terminal emulator</heading>
7020 Packages that provide a terminal emulator for the X Window
7021 System which meet the criteria listed below should declare
7022 in their control data that they provide the virtual
7023 package <tt>x-terminal-emulator</tt>. They should also
7024 register themselves as an alternative for
7025 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
7030 To be an <tt>x-terminal-emulator</tt>, a program must:
7031 <list compact="compact">
7033 Be able to emulate a DEC VT100 terminal, or a
7034 compatible terminal.
7038 Support the command-line option <tt>-e
7039 <var>command</var></tt>, which creates a new
7040 terminal window<footnote>
7042 "New terminal window" does not necessarily mean
7043 a new top-level X window directly parented by
7044 the window manager; it could, if the terminal
7045 emulator application were so coded, be a new
7046 "view" in a multiple-document interface (MDI).
7049 and runs the specified <var>command</var>.
7053 Support the command-line option <tt>-T
7054 <var>title</var></tt>, which creates a new terminal
7055 window with the window title <var>title</var>.
7062 <heading>Packages providing a window manager</heading>
7065 Packages that provide a window manager should declare in
7066 their control data that they provide the virtual package
7067 <tt>x-window-manager</tt>. They should also register
7068 themselves as an alternative for
7069 <file>/usr/bin/x-window-manager</file>, with a priority
7070 calculated as follows:
7071 <list compact="compact">
7072 <item><p>Start with a priority of 20.</p></item>
7076 If the window manager supports the Debian menu
7077 system, add 20 points if this support is available
7078 in the package's default configuration (i.e., no
7079 configuration files belonging to the system or user
7080 have to be edited to activate the feature); if
7081 configuration files must be modified, add only 10
7087 If the window manager complies with <url
7088 id="http://www.freedesktop.org/standards/wm-spec.html"
7089 name="The Window Manager Specification Project">,
7090 written by the <url id="http://www.freedesktop.org"
7091 name="Free Desktop Group">, add 20 points.
7097 If the window manager permits the X session to be
7098 restarted using a <em>different</em> window manager
7099 (without killing the X server) in its default
7100 configuration, add 10 points; otherwise add none.
7108 <heading>Packages providing fonts</heading>
7111 Packages that provide fonts for the X Window
7114 For the purposes of Debian Policy, a "font for the X
7115 Window System" is one which is accessed via X protocol
7116 requests. Fonts for the Linux console, for PostScript
7117 renderers, or any other purpose, do not fit this
7118 definition. Any tool which makes such fonts available
7119 to the X Window System, however, must abide by this
7123 must do a number of things to ensure that they are both
7124 available without modification of the X or font server
7125 configuration, and that they do not corrupt files used by
7126 other font packages to register information about
7131 Fonts of any type supported by the X Window System
7132 must be in a separate binary package from any
7133 executables, libraries, or documentation (except
7134 that specific to the fonts shipped, such as their
7135 license information). If one or more of the fonts
7136 so packaged are necessary for proper operation of
7137 the package with which they are associated the font
7138 package may be Recommended; if the fonts merely
7139 provide an enhancement, a Suggests relationship may
7140 be used. Packages must not Depend on font
7143 This is because the X server may retrieve fonts
7144 from the local filesystem or over the network
7145 from an X font server; the Debian package system
7146 is empowered to deal only with the local
7155 BDF fonts must be converted to PCF fonts with the
7156 <prgn>bdftopcf</prgn> utility (available in the
7157 <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7158 placed in a directory that corresponds to their
7160 <list compact="compact">
7162 100 dpi fonts must be placed in
7163 <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7167 75 dpi fonts must be placed in
7168 <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7172 Character-cell fonts, cursor fonts, and other
7173 low-resolution fonts must be placed in
7174 <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7181 Speedo fonts must be placed in
7182 <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7186 Type 1 fonts must be placed in
7187 <file>/usr/X11R6/lib/X11/fonts/Type1/</file>. If font
7188 metric files are available, they must be placed here
7194 Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7195 other than those listed above must be neither
7196 created nor used. (The <file>PEX</file>, <file>CID</file>,
7197 and <file>cyrillic</file> directories are excepted for
7198 historical reasons, but installation of files into
7199 these directories remains discouraged.)
7205 Font packages may, instead of placing files directly
7206 in the X font directories listed above, provide
7207 symbolic links in that font directory pointing to
7208 the files' actual location in the filesystem. Such
7209 a location must comply with the FHS.
7215 Font packages should not contain both 75dpi and
7216 100dpi versions of a font. If both are available,
7217 they should be provided in separate binary packages
7218 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7219 the names of the packages containing the
7220 corresponding fonts.
7226 Fonts destined for the <file>misc</file> subdirectory
7227 should not be included in the same package as 75dpi
7228 or 100dpi fonts; instead, they should be provided in
7229 a separate package with <tt>-misc</tt> appended to
7236 Font packages must not provide the files
7237 <file>fonts.dir</file>, <file>fonts.alias</file>, or
7238 <file>fonts.scale</file> in a font directory:
7241 <file>fonts.dir</file> files must not be provided at all.
7246 <file>fonts.alias</file> and <file>fonts.scale</file>
7247 files, if needed, should be provided in the
7249 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7250 where <var>fontdir</var> is the name of the
7252 <file>/usr/X11R6/lib/X11/fonts/</file> where the
7253 package's corresponding fonts are stored
7254 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7255 <var>package</var> is the name of the package
7256 that provides these fonts, and
7257 <var>extension</var> is either <tt>scale</tt>
7258 or <tt>alias</tt>, whichever corresponds to
7268 Font packages must declare a dependency on
7269 <tt>xutils (>> 4.0.3)</tt> in their control
7276 Font packages that provide one or more
7277 <file>fonts.scale</file> files as described above must
7278 invoke <prgn>update-fonts-scale</prgn> on each
7279 directory into which they installed fonts
7280 <em>before</em> invoking
7281 <prgn>update-fonts-dir</prgn> on that directory.
7282 This invocation must occur in both the
7283 <prgn>postinst</prgn> (for all arguments) and
7284 <prgn>postrm</prgn> (for all arguments except
7285 <tt>upgrade</tt>) scripts.
7291 Font packages that provide one or more
7292 <file>fonts.alias</file> files as described above must
7293 invoke <prgn>update-fonts-alias</prgn> on each
7294 directory into which they installed fonts. This
7295 invocation must occur in both the
7296 <prgn>postinst</prgn> (for all arguments) and
7297 <prgn>postrm</prgn> (for all arguments except
7298 <tt>upgrade</tt>) scripts.
7304 Font packages must invoke
7305 <prgn>update-fonts-dir</prgn> on each directory into
7306 which they installed fonts. This invocation must
7307 occur in both the <prgn>postinst</prgn> (for all
7308 arguments) and <prgn>postrm</prgn> (for all
7309 arguments except <tt>upgrade</tt>) scripts.
7315 Font packages must not provide alias names for the
7316 fonts they include which collide with alias names
7317 already in use by fonts already packaged.
7323 Font packages must not provide fonts with the same
7324 XLFD registry name as another font already packaged.
7332 <heading>Application defaults files</heading>
7335 Application defaults files must be installed in the
7336 directory <file>/etc/X11/app-defaults/</file> (use of a
7337 localized subdirectory of <file>/etc/X11/</file> as described
7338 in the <em>X Toolkit Intrinsics - C Language
7339 Interface</em> manual is also permitted). They must be
7340 registered as <tt>conffile</tt>s or handled as
7341 configuration files. Packages must not provide the
7342 directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7346 Customization of programs' X resources may also be
7347 supported with the provision of a file with the same name
7348 as that of the package placed in the
7349 <file>/etc/X11/Xresources/</file> directory, which must
7350 registered as a <tt>conffile</tt> or handled as a
7351 configuration file.<footnote>
7353 Note that this mechanism is not the same as using
7354 app-defaults; app-defaults are tied to the client
7355 binary on the local filesystem, whereas X resources
7356 are stored in the X server and affect all connecting
7360 <em>Important:</em> packages that install files into the
7361 <file>/etc/X11/Xresources/</file> directory must conflict with
7362 <tt>xbase (<< 3.3.2.3a-2)</tt>; if this is not done
7363 it is possible for the installing package to destroy a
7364 previously-existing <file>/etc/X11/Xresources</file> file
7365 which had been customized by the system administrator.
7370 <heading>Installation directory issues</heading>
7373 Packages using the X Window System should not be
7374 configured to install files under the <file>/usr/X11R6/</file>
7375 directory unless they use <prgn>imake</prgn>. The
7376 <file>/usr/X11R6/</file> directory hierarchy should be
7377 regarded as deprecated for all packages except the X
7378 Window System itself, and those which use the
7379 <prgn>imake</prgn> program it provides, in which case the
7380 packages may transition out of the <file>/usr/X11R6/</file>
7381 directory at the maintainer's discretion.<footnote>
7383 <prgn>Imake</prgn>-using programs are exempt because,
7384 as long as they are written correctly, the pathnames
7385 they use to locate resources and install themselves
7386 are derived wholly from the X Window System
7387 configuration. Thus, in the event that the X Window
7388 System moves to <file>/usr/X11R7/</file>,
7389 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7390 that is required for these programs is a recompile
7391 against the corresponding X Window System library
7392 development packages.
7395 Programs that use GNU <prgn>autoconf</prgn> and
7396 <prgn>automake</prgn> are usually easily configured at
7397 compile time to use <file>/usr/</file> instead of
7398 <file>/usr/X11R6/</file>, and this should be done whenever
7399 possible. Configuration files for window managers and
7400 display managers should be placed in a subdirectory of
7401 <file>/etc/X11/</file> corresponding to the package name due
7402 to these programs' tight integration with the mechanisms
7403 of the X Window System. Application-level programs should
7404 use the <file>/etc/</file> directory unless otherwise mandated
7405 by policy. The installation of files into subdirectories
7406 of <file>/usr/X11R6/include/X11/</file> and
7407 <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7408 package maintainers should determine if subdirectories of
7409 <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7410 instead. (The use of symbolic links from the
7411 <file>X11R6</file> directories to other FHS-compliant
7412 locations is encouraged if the program is not easily
7413 configured to look elsewhere for its files.) Packages
7414 must not provide or install files into the directories
7415 <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7416 <file>/usr/lib/X11/</file>. Files within a package should,
7417 however, make reference to these directories, rather than
7418 their <tt>X11R6</tt>-named counterparts
7419 <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7420 and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7421 referred to have not been moved to other FHS-compliant
7427 <heading>The OSF/Motif and OpenMotif libraries</heading>
7430 <em>Programs that require the non-DFSG-compliant OSF/Motif or
7431 OpenMotif libraries</em><footnote>
7433 OSF/Motif and OpenMotif are collectively referred to as
7434 "Motif" in this policy document.
7437 should be compiled against and tested with LessTif (a free
7438 re-implementation of Motif) instead. If the maintainer
7439 judges that the program or programs do not work
7440 sufficiently well with LessTif to be distributed and
7441 supported, but do so when compiled against Motif, then two
7442 versions of the package should be created; one linked
7443 statically against Motif and with <tt>-smotif</tt>
7444 appended to the package name, and one linked dynamically
7445 against Motif and with <tt>-dmotif</tt> appended to the
7446 package name. Both Motif-linked versions are dependent
7447 upon non-DFSG-compliant software and thus cannot be
7448 uploaded to the <em>main</em> distribution; if the
7449 software is itself DFSG-compliant it may be uploaded to
7450 the <em>contrib</em> distribution. While known existing
7451 versions of Motif permit unlimited redistribution of
7452 binaries linked against the library (whether statically or
7453 dynamically), it is the package maintainer's
7454 responsibility to determine whether this is permitted by
7455 the license of the copy of Motif in his or her possession.
7461 <heading>Perl programs and modules</heading>
7463 Perl programs and modules should follow the current Perl
7464 policy as defined in the file found on
7465 <ftpsite>ftp.debian.org</ftpsite> in
7466 <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>
7467 or your local mirror. In addition, it is included in the
7468 <tt>debian-policy</tt> package.
7473 <heading>Emacs lisp programs</heading>
7476 Please refer to the "Debian Emacs Policy" (documented in
7477 <file>debian-emacs-policy.gz</file> of the
7478 <prgn>emacsen-common</prgn> package) for details of how to
7479 package emacs lisp programs.
7484 <heading>Games</heading>
7487 The permissions on <file>/var/games</file> are mode 755, owner
7488 <tt>root</tt> and group <tt>root</tt>.
7492 Each game decides on its own security policy.</p>
7495 Games which require protected, privileged access to
7496 high-score files, savegames, etc., may be made
7497 set-<em>group</em>-id (mode 2755) and owned by
7498 <tt>root.games</tt>, and use files and directories with
7499 appropriate permissions (770 <tt>root.games</tt>, for
7500 example). They must not be made
7501 set-<em>user</em>-id, as this causes security problems. (If
7502 an attacker can subvert any set-user-id game they can
7503 overwrite the executable of any other, causing other players
7504 of these games to run a Trojan horse program. With a
7505 set-group-id game the attacker only gets access to less
7506 important game data, and if they can get at the other
7507 players' accounts at all it will take considerably more
7511 Some packages, for example some fortune cookie programs, are
7512 configured by the upstream authors to install with their
7513 data files or other static information made unreadable so
7514 that they can only be accessed through set-id programs
7515 provided. You should not do this in a Debian package: anyone can
7516 download the <file>.deb</file> file and read the data from it,
7517 so there is no point making the files unreadable. Not
7518 making the files unreadable also means that you don't have
7519 to make so many programs set-id, which reduces the risk of a
7523 As described in the FHS, binaries of games should be
7524 installed in the directory <file>/usr/games</file>. This also
7525 applies to games that use the X Window System. Manual pages
7526 for games (X and non-X games) should be installed in
7527 <file>/usr/share/man/man6</file>.</p>
7531 <chapt id="docs"><heading>Documentation</heading>
7535 <heading>Manual pages</heading>
7538 You should install manual pages in <prgn>nroff</prgn> source
7539 form, in appropriate places under <file>/usr/share/man</file>.
7540 You should only use sections 1 to 9 (see the FHS for more
7541 details). You must not install a preformatted "cat page".
7545 Each program, utility, and function should have an
7546 associated manual page included in the same package. It is
7547 suggested that all configuration files also have a manual
7548 page included as well. Manual pages for protocols and other
7549 auxiliary things are optional.
7553 If no manual page is available, this is considered as a bug
7554 and should be reported to the Debian Bug Tracking System (the
7555 maintainer of the package is allowed to write this bug report
7556 themselves, if they so desire). Do not close the bug report
7557 until a proper manpage is available.<footnote>
7559 It is not very hard to write a man page. See the
7560 <url id="http://www.schweikhardt.net/man_page_howto.html"
7561 name="Man-Page-HOWTO">,
7562 <manref name="man" section="7">, the examples
7563 created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7564 the helper programs <prgn>help2man</prgn>, or the
7565 directory <file>/usr/share/doc/man-db/examples</file>.
7571 You may forward a complaint about a missing manpage to the
7572 upstream authors, and mark the bug as forwarded in the
7573 Debian bug tracking system. Even though the GNU Project do
7574 not in general consider the lack of a manpage to be a bug,
7575 we do; if they tell you that they don't consider it a bug
7576 you should leave the bug in our bug tracking system open
7581 Manual pages should be installed compressed using <tt>gzip -9</tt>.
7585 If one manpage needs to be accessible via several names it
7586 is better to use a symbolic link than the <file>.so</file>
7587 feature, but there is no need to fiddle with the relevant
7588 parts of the upstream source to change from <file>.so</file> to
7589 symlinks: don't do it unless it's easy. You should not
7590 create hard links in the manual page directories, nor put
7591 absolute filenames in <file>.so</file> directives. The filename
7592 in a <file>.so</file> in a manpage should be relative to the
7593 base of the manpage tree (usually
7594 <file>/usr/share/man</file>). If you do not create any links
7595 (whether symlinks, hard links, or <tt>.so</tt> directives)
7596 in the filesystem to the alternate names of the manpage,
7597 then you should not rely on <prgn>man</prgn> finding your
7598 manpage under those names based solely on the information in
7599 the manpage's header.<footnote>
7601 Supporting this in <prgn>man</prgn> often requires
7602 unreasonable processing time to find a manual page or to
7603 report that none exists, and moves knowledge into man's
7604 database that would be better left in the filesystem.
7605 This support is therefore deprecated and will cease to
7606 be present in the future.
7613 <heading>Info documents</heading>
7616 Info documents should be installed in <file>/usr/share/info</file>.
7617 They should be compressed with <tt>gzip -9</tt>.
7621 Your package should call <prgn>install-info</prgn> to update
7622 the Info <file>dir</file> file in its <prgn>postinst</prgn>
7623 script when called with a <tt>configure</tt> argument, for
7625 <example compact="compact">
7626 install-info --quiet --section Development Development \
7627 /usr/share/info/foobar.info
7631 It is a good idea to specify a section for the location of
7632 your program; this is done with the <tt>--section</tt>
7633 switch. To determine which section to use, you should look
7634 at <file>/usr/share/info/dir</file> on your system and choose the most
7635 relevant (or create a new section if none of the current
7636 sections are relevant). Note that the <tt>--section</tt>
7637 flag takes two arguments; the first is a regular expression
7638 to match (case-insensitively) against an existing section,
7639 the second is used when creating a new one.</p>
7642 You should remove the entries in the <prgn>prerm</prgn>
7643 script when called with a <tt>remove</tt> argument:
7644 <example compact="compact">
7645 install-info --quiet --remove /usr/share/info/foobar.info
7649 If <prgn>install-info</prgn> cannot find a description entry
7650 in the Info file you must supply one. See <manref
7651 name="install-info" section="8"> for details.</p>
7655 <heading>Additional documentation</heading>
7658 Any additional documentation that comes with the package may
7659 be installed at the discretion of the package maintainer.
7660 Text documentation should be installed in the directory
7661 <file>/usr/share/doc/<var>package</var></file>, where
7662 <var>package</var> is the name of the package, and
7663 compressed with <tt>gzip -9</tt> unless it is small.
7667 If a package comes with large amounts of documentation which
7668 many users of the package will not require you should create
7669 a separate binary package to contain it, so that it does not
7670 take up disk space on the machines of users who do not need
7671 or want it installed.</p>
7674 It is often a good idea to put text information files
7675 (<file>README</file>s, changelogs, and so forth) that come with
7676 the source package in <file>/usr/share/doc/<var>package</var></file>
7677 in the binary package. However, you don't need to install
7678 the instructions for building and installing the package, of
7682 Packages must not require the existance of any files in
7683 <file>/usr/share/doc/</file> in order to function
7686 The system administrator should be able to
7687 delete files in <file>/usr/share/doc/</file> without causing
7688 any programs to break.
7691 Any files that are referenced by programs but are also
7692 useful as standalone documentation should be installed under
7693 <file>/usr/share/<var>package</var>/</file> with symbolic links from
7694 <file>/usr/share/doc/<var>package</var></file>.
7698 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7699 link to another directory in <file>/usr/share/doc</file> only if
7700 the two packages both come from the same source and the
7701 first package Depends on the second.
7705 Former Debian releases placed all additional documentation
7706 in <file>/usr/doc/<var>package</var></file>. This has been
7707 changed to <file>/usr/share/doc/<var>package</var></file>,
7708 and packages must not put documentation in the directory
7709 <file>/usr/doc/<var>package</var></file>. <footnote>
7710 <p>At this phase of the transition, we no longer require a
7711 symbolic link in <file>/usr/doc/</file>. At a later point,
7712 policy shall change to make the symbolic links a bug.</p>
7718 <heading>Preferred documentation formats</heading>
7721 The unification of Debian documentation is being carried out
7725 If your package comes with extensive documentation in a
7726 markup format that can be converted to various other formats
7727 you should if possible ship HTML versions in a binary
7728 package, in the directory
7729 <file>/usr/share/doc/<var>appropriate-package</var></file> or
7730 its subdirectories.<footnote>
7732 The rationale: The important thing here is that HTML
7733 docs should be available in <em>some</em> package, not
7734 necessarily in the main binary package.
7740 Other formats such as PostScript may be provided at the
7741 package maintainer's discretion.
7745 <sect id="copyrightfile">
7746 <heading>Copyright information</heading>
7749 Every package must be accompanied by a verbatim copy of its
7750 copyright and distribution license in the file
7751 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7752 file must neither be compressed nor be a symbolic link.
7756 In addition, the copyright file must say where the upstream
7757 sources (if any) were obtained. It should name the original
7758 authors of the package and the Debian maintainer(s) who were
7759 involved with its creation.</p>
7762 A copy of the file which will be installed in
7763 <file>/usr/share/doc/<var>package</var>/copyright</file> should
7764 be in <file>debian/copyright</file> in the source package.
7768 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7769 link to another directory in <file>/usr/share/doc</file> only if
7770 the two packages both come from the same source and the
7771 first package Depends on the second. These rules are
7772 important because copyrights must be extractable by
7777 Packages distributed under the UCB BSD license, the Artistic
7778 license, the GNU GPL, and the GNU LGPL should refer to the
7779 files <file>/usr/share/common-licenses/BSD</file>,
7780 <file>/usr/share/common-licenses/Artistic</file>,
7781 <file>/usr/share/common-licenses/GPL</file>, and
7782 <file>/usr/share/common-licenses/LGPL</file> respectively,
7783 rather than quoting them in the copyright file.
7787 You should not use the copyright file as a general <file>README</file>
7788 file. If your package has such a file it should be
7789 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7790 <file>README.Debian</file> or some other appropriate place.</p>
7794 <heading>Examples</heading>
7797 Any examples (configurations, source files, whatever),
7798 should be installed in a directory
7799 <file>/usr/share/doc/<var>package</var>/examples</file>. These
7800 files should not be referenced by any program: they're there
7801 for the benefit of the system administrator and users as
7802 documentation only. Architecture-specific example files
7803 should be installed in a directory
7804 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7806 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7807 latter directory itself may be a symbolic link to the
7812 If the purpose of a package is to provide examples, then the
7813 example files may be installed into
7814 <file>/usr/share/doc/<var>package</var></file>.
7818 <sect id="changelogs">
7819 <heading>Changelog files</heading>
7822 The Debian changelog file (<file>debian/changelog</file>) should
7823 explain briefly what modifications were made in the Debian version
7824 of the package compared to the upstream one. Other changes and
7825 updates to the package should also be documented in this file.
7829 Mistakes in changelogs are usually best rectified by
7830 making a new changelog entry rather than "rewriting history"
7831 by editing old changelog entries.
7835 The format of the <file>debian/changelog</file> file is described
7836 in <ref id="dpkgchangelog">. In non-experimental packages you must
7837 use a format for <file>debian/changelog</file> which is supported
7838 by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7840 If you wish to use an alternative format, you may do so as
7841 long as you include a parser for it in your source package.
7842 The parser must have an API compatible with that expected by
7843 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7844 If there is general interest in the new format, you should
7845 contact the <package>dpkg</package> maintainer to have the
7846 parser script for it included in the <prgn>dpkg</prgn>
7847 package. (You will need to agree that the parser and its
7848 manpage may be distributed under the GNU GPL, just as the rest
7849 of <prgn>dpkg</prgn> is.)
7855 Packages that are not Debian-native must contain a
7856 compressed copy of the <file>debian/changelog</file> file from
7857 the Debian source tree in
7858 <file>/usr/share/doc/<var>package</var></file> with the name
7859 <file>changelog.Debian.gz</file>.
7863 If an upstream changelog is available, it should be accessible as
7864 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7865 plain text. If the upstream changelog is distributed in
7866 HTML, it should be made available in that form as
7867 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7868 and a plain text <file>changelog.gz</file> should be generated
7869 from it using, for example, <tt>lynx -dump -nolist</tt>. If
7870 the upstream changelog files do not already conform to this
7871 naming convention, then this may be achieved either by
7872 renaming the files, or by adding a symbolic link, at the
7873 maintainer's discretion.<footnote>
7875 Rationale: People should not have to look in places for
7876 upstream changelogs merely because they are given
7877 different names or are distributed in HTML format.
7883 All of these files should be installed compressed using
7884 <tt>gzip -9</tt>, as they will become large with time even
7885 if they start out small.
7889 If the package has only one changelog which is used both as
7890 the Debian changelog and the upstream one because there is
7891 no separate upstream maintainer then that changelog should
7892 usually be installed as
7893 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7894 there is a separate upstream maintainer, but no upstream
7895 changelog, then the Debian changelog should still be called
7896 <file>changelog.Debian.gz</file>.</p>
7901 <appendix id="pkg-scope">
7902 <heading>Introduction and scope of these appendices</heading>
7905 These appendices are taken essentially verbatim from the
7906 now-deprecated Packaging Manual, version 3.2.1.0. They are
7907 the chapters which are likely to be of use to package
7908 maintainers and which have not already been included in the
7909 policy document itself. Most of these sections are very likely
7910 not relevant to policy; they should be treated as
7911 documentation for the packaging system. Please note that these
7912 appendices are included for convenience, and for historical
7913 reasons: they used to be part of policy package, and they have
7914 not yet been incorporated into dpkg documentation. However,
7915 they still have value, and hence they are presented here.
7918 They have not yet been checked to ensure that they are
7919 compatible with the contents of policy, and if there are any
7920 contradictions, the version in the main policy document takes
7921 precedence. The remaining chapters of the old Packaging
7922 Manual have also not been read in detail to ensure that there
7923 are not parts which have been left out. Both of these will be
7928 <prgn>dpkg</prgn> is a suite of programs for creating binary
7929 package files and installing and removing them on Unix
7932 <prgn>dpkg</prgn> is targetted primarily at Debian
7933 GNU/Linux, but may work on or be ported to other
7940 The binary packages are designed for the management of
7941 installed executable programs (usually compiled binaries) and
7942 their associated data, though source code examples and
7943 documentation are provided as part of some packages.</p>
7946 This manual describes the technical aspects of creating Debian
7947 binary packages (<file>.deb</file> files). It documents the
7948 behaviour of the package management programs
7949 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7950 they interact with packages.</p>
7953 It also documents the interaction between
7954 <prgn>dselect</prgn>'s core and the access method scripts it
7955 uses to actually install the selected packages, and describes
7956 how to create a new access method.</p>
7959 This manual does not go into detail about the options and
7960 usage of the package building and installation tools. It
7961 should therefore be read in conjuction with those programs'
7966 The utility programs which are provided with <prgn>dpkg</prgn>
7967 for managing various system configuration and similar issues,
7968 such as <prgn>update-rc.d</prgn> and
7969 <prgn>install-info</prgn>, are not described in detail here -
7970 please see their manpages.
7974 It is assumed that the reader is reasonably familiar with the
7975 <prgn>dpkg</prgn> System Administrators' manual.
7976 Unfortunately this manual does not yet exist.
7980 The Debian version of the FSF's GNU hello program is provided
7981 as an example for people wishing to create Debian
7982 packages. The Debian <prgn>debmake</prgn> package is
7983 recommended as a very helpful tool in creating and maintaining
7984 Debian packages. However, while the tools and examples are
7985 helpful, they do not replace the need to read and follow the
7986 Policy and Programmer's Manual.</p>
7989 <appendix id="pkg-binarypkg"><heading>Binary packages (from old
7994 The binary package has two main sections. The first part
7995 consists of various control information files and scripts used
7996 by <prgn>dpkg</prgn> when installing and removing. See <ref
7997 id="pkg-controlarea">.
8001 The second part is an archive containing the files and
8002 directories to be installed.
8006 In the future binary packages may also contain other
8007 components, such as checksums and digital signatures. The
8008 format for the archive is described in full in the
8009 <file>deb(5)</file> manpage.
8013 <sect id="pkg-bincreating"><heading>Creating package files -
8014 <prgn>dpkg-deb</prgn>
8018 All manipulation of binary package files is done by
8019 <prgn>dpkg-deb</prgn>; it's the only program that has
8020 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
8021 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
8022 will spot that the options requested are appropriate to
8023 <prgn>dpkg-deb</prgn> and invoke that instead with the same
8028 In order to create a binary package you must make a
8029 directory tree which contains all the files and directories
8030 you want to have in the filesystem data part of the package.
8031 In Debian-format source packages this directory is usually
8032 <file>debian/tmp</file>, relative to the top of the package's
8037 They should have the locations (relative to the root of the
8038 directory tree you're constructing) ownerships and
8039 permissions which you want them to have on the system when
8044 With current versions of <prgn>dpkg</prgn> the uid/username
8045 and gid/groupname mappings for the users and groups being
8046 used should be the same on the system where the package is
8047 built and the one where it is installed.
8051 You need to add one special directory to the root of the
8052 miniature filesystem tree you're creating:
8053 <prgn>DEBIAN</prgn>. It should contain the control
8054 information files, notably the binary package control file
8055 (see <ref id="pkg-controlfile">).
8059 The <prgn>DEBIAN</prgn> directory will not appear in the
8060 filesystem archive of the package, and so won't be installed
8061 by <prgn>dpkg</prgn> when the package is installed.
8065 When you've prepared the package, you should invoke:
8067 dpkg --build <var>directory</var>
8072 This will build the package in
8073 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
8074 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8075 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8080 See the manpage <manref name="dpkg-deb" section="8"> for details of how
8081 to examine the contents of this newly-created file. You may find the
8082 output of following commands enlightening:
8084 dpkg-deb --info <var>filename</var>.deb
8085 dpkg-deb --contents <var>filename</var>.deb
8086 dpkg --contents <var>filename</var>.deb
8088 To view the copyright file for a package you could use this command:
8090 dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8095 <sect id="pkg-controlarea">
8097 Package control information files
8101 The control information portion of a binary package is a
8102 collection of files with names known to <prgn>dpkg</prgn>.
8103 It will treat the contents of these files specially - some
8104 of them contain information used by <prgn>dpkg</prgn> when
8105 installing or removing the package; others are scripts which
8106 the package maintainer wants <prgn>dpkg</prgn> to run.
8110 It is possible to put other files in the package control
8111 area, but this is not generally a good idea (though they
8112 will largely be ignored).
8116 Here is a brief list of the control info files supported by
8117 <prgn>dpkg</prgn> and a summary of what they're used for.
8122 <tag><tt>control</tt>
8126 This is the key description file used by
8127 <prgn>dpkg</prgn>. It specifies the package's name
8128 and version, gives its description for the user,
8129 states its relationships with other packages, and so
8130 forth. See <ref id="pkg-controlfile">.
8134 It is usually generated automatically from information
8135 in the source package by the
8136 <prgn>dpkg-gencontrol</prgn> program, and with
8137 assistance from <prgn>dpkg-shlibdeps</prgn>. See <ref
8138 id="pkg-sourcetools">.</p>
8141 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8147 These are exectuable files (usually scripts) which
8148 <prgn>dpkg</prgn> runs during installation, upgrade
8149 and removal of packages. They allow the package to
8150 deal with matters which are particular to that package
8151 or require more complicated processing than that
8152 provided by <prgn>dpkg</prgn>. Details of when and
8153 how they are called are in <ref
8154 id="maintainerscripts">.
8158 It is very important to make these scripts
8162 That means that if it runs successfully or fails
8163 and then you call it again it doesn't bomb out,
8164 but just ensures that everything is the way it
8167 </footnote> This is so that if an error occurs, the
8168 user interrupts <prgn>dpkg</prgn> or some other
8169 unforeseen circumstance happens you don't leave the
8170 user with a badly-broken package.
8174 The maintainer scripts are guaranteed to run with a
8175 controlling terminal and can interact with the user.
8176 If they need to prompt for passwords, do full-screen
8177 interaction or something similar you should do these
8178 things to and from <file>/dev/tty</file>, since
8179 <prgn>dpkg</prgn> will at some point redirect scripts'
8180 standard input and output so that it can log the
8181 installation process. Likewise, because these scripts
8182 may be executed with standard output redirected into a
8183 pipe for logging purposes, Perl scripts should set
8184 unbuffered output by setting <tt>$|=1</tt> so that the
8185 output is printed immediately rather than being
8190 Each script should return a zero exit status for
8191 success, or a nonzero one for failure.</p>
8194 <tag><tt>conffiles</tt>
8199 This file contains a list of configuration files which
8200 are to be handled automatically by <prgn>dpkg</prgn>
8201 (see <ref id="pkg-conffiles">). Note that not necessarily
8202 every configuration file should be listed here.</p>
8205 <tag><tt>shlibs</tt>
8210 This file contains a list of the shared libraries
8211 supplied by the package, with dependency details for
8212 each. This is used by <prgn>dpkg-shlibdeps</prgn>
8213 when it determines what dependencies are required in a
8214 package control file. The <tt>shlibs</tt> file format
8215 is described on <ref id="shlibs">.
8221 <sect id="pkg-controlfile">
8223 The main control information file: <tt>control</tt>
8226 The most important control information file used by
8227 <prgn>dpkg</prgn> when it installs a package is
8228 <tt>control</tt>. It contains all the package"s "vital
8233 The binary package control files of packages built from
8234 Debian sources are made by a special tool,
8235 <prgn>dpkg-gencontrol</prgn>, which reads
8236 <file>debian/control</file> and <file>debian/changelog</file> to
8237 find the information it needs. See <ref id="pkg-sourcepkg"> for
8242 The fields in binary package control files are:
8243 <list compact="compact">
8245 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8248 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8250 <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8254 This field should appear in all packages, though
8255 <prgn>dpkg</prgn> doesn't require it yet so that
8256 old packages can still be installed.
8262 <p><qref id="relationships"><tt>Depends</tt>,
8263 <tt>Provides</tt> et al.</qref></p>
8266 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8269 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8272 <p><qref id="pkg-f-classification"><tt>Section</tt>,
8273 <tt>Priority</tt></qref></p>
8276 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8279 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8283 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8289 A description of the syntax of control files and the purpose
8290 of these fields is available in <ref id="pkg-controlfields">.
8295 <heading>Time Stamps</heading>
8297 Maintainers are encouraged to preserve the modification
8298 times of the upstream source files in a package, as far as
8299 is reasonably possible.
8302 The rationale is that there is some information conveyed
8303 by knowing the age of the file, for example, you could
8304 recognize that some documentation is very old by looking
8305 at the modification time, so it would be nice if the
8306 modification time of the upstream source would be
8314 <appendix id="pkg-sourcepkg">
8315 <heading>Source packages (from old Packaging Manual) </heading>
8318 The Debian binary packages in the distribution are generated
8319 from Debian sources, which are in a special format to assist
8320 the easy and automatic building of binaries.
8323 <sect id="pkg-sourcetools">
8324 <heading>Tools for processing source packages</heading>
8327 Various tools are provided for manipulating source packages;
8328 they pack and unpack sources and help build of binary
8329 packages and help manage the distribution of new versions.
8333 They are introduced and typical uses described here; see
8334 <manref name="dpkg-source" section="1"> for full
8335 documentation about their arguments and operation.
8339 For examples of how to construct a Debian source package,
8340 and how to use those utilities that are used by Debian
8341 source packages, please see the <prgn>hello</prgn> example
8347 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8352 This program is frequently used by hand, and is also
8353 called from package-independent automated building scripts
8354 such as <prgn>dpkg-buildpackage</prgn>.
8358 To unpack a package it is typically invoked with
8360 dpkg-source -x <var>.../path/to/filename</var>.dsc
8365 with the <file><var>filename</var>.tar.gz</file> and
8366 <file><var>filename</var>.diff.gz</file> (if applicable) in
8367 the same directory. It unpacks into
8368 <file><var>package</var>-<var>version</var></file>, and if
8370 <file><var>package</var>-<var>version</var>.orig</file>, in
8371 the current directory.
8375 To create a packed source archive it is typically invoked:
8377 dpkg-source -b <var>package</var>-<var>version</var>
8382 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8383 <file>.diff.gz</file> (if appropriate) in the current
8384 directory. <prgn>dpkg-source</prgn> does not clean the
8385 source tree first - this must be done separately if it is
8390 See also <ref id="pkg-sourcearchives">.</p>
8396 <prgn>dpkg-buildpackage</prgn> - overall package-building
8401 <prgn>dpkg-buildpackage</prgn> is a script which invokes
8402 <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8403 targets <tt>clean</tt>, <tt>build</tt> and
8404 <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8405 <prgn>pgp</prgn> to build a signed source and binary
8410 It is usually invoked by hand from the top level of the
8411 built or unbuilt source directory. It may be invoked with
8412 no arguments; useful arguments include:
8413 <taglist compact="compact">
8414 <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8417 Do not PGP-sign the <tt>.changes</tt> file or the
8418 source package <tt>.dsc</tt> file, respectively.</p>
8420 <tag><tt>-p<var>pgp-command</var></tt></tag>
8423 Invoke <var>pgp-command</var> instead of finding
8424 <tt>pgp</tt> on the <prgn>PATH</prgn>.
8425 <var>pgp-command</var> must behave just like
8426 <prgn>pgp</prgn>.</p>
8428 <tag><tt>-r<var>root-command</var></tt></tag>
8431 When root privilege is required, invoke the command
8432 <var>root-command</var>. <var>root-command</var>
8433 should invoke its first argument as a command, from
8434 the <prgn>PATH</prgn> if necessary, and pass its
8435 second and subsequent arguments to the command it
8436 calls. If no <var>root-command</var> is supplied
8437 then <var>dpkg-buildpackage</var> will take no
8438 special action to gain root privilege, so that for
8439 most packages it will have to be invoked as root to
8442 <tag><tt>-b</tt>, <tt>-B</tt></tag>
8445 Two types of binary-only build and upload - see
8446 <manref name="dpkg-source" section="1">.
8455 <prgn>dpkg-gencontrol</prgn> - generates binary package
8460 This program is usually called from <file>debian/rules</file>
8461 (see <ref id="pkg-sourcetree">) in the top level of the source
8466 This is usually done just before the files and directories in the
8467 temporary directory tree where the package is being built have their
8468 permissions and ownerships set and the package is constructed using
8469 <prgn>dpkg-deb/</prgn>
8472 This is so that the control file which is produced has
8473 the right permissions
8479 <prgn>dpkg-gencontrol</prgn> must be called after all the
8480 files which are to go into the package have been placed in
8481 the temporary build directory, so that its calculation of
8482 the installed size of a package is correct.
8486 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8487 be run after <prgn>dpkg-shlibdeps</prgn> so that the
8488 variable substitutions created by
8489 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8494 For a package which generates only one binary package, and
8495 which builds it in <file>debian/tmp</file> relative to the top
8496 of the source package, it is usually sufficient to call
8497 <prgn>dpkg-gencontrol</prgn>.
8501 Sources which build several binaries will typically need
8504 dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8505 </example> The <tt>-P</tt> tells
8506 <prgn>dpkg-gencontrol</prgn> that the package is being
8507 built in a non-default directory, and the <tt>-p</tt>
8508 tells it which package's control file should be generated.
8512 <prgn>dpkg-gencontrol</prgn> also adds information to the
8513 list of files in <file>debian/files</file>, for the benefit of
8514 (for example) a future invocation of
8515 <prgn>dpkg-genchanges</prgn>.</p>
8520 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8525 This program is usually called from <file>debian/rules</file>
8526 just before <prgn>dpkg-gencontrol</prgn> (see <ref
8527 id="pkg-sourcetree">), in the top level of the source tree.
8531 Its arguments are executables.
8534 In a forthcoming dpkg version,
8535 <prgn>dpkg-shlibdeps</prgn> would be required to be
8536 called on shared libraries as well.
8539 They may be specified either in the locations in the
8540 source tree where they are created or in the locations
8541 in the temporary build tree where they are installed
8542 prior to binary package creation.
8544 </footnote> for which shared library dependencies should
8545 be included in the binary package's control file.
8549 If some of the found shared libraries should only
8550 warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8551 some warrant a <tt>Pre-Depends</tt>, this can be achieved
8552 by using the <tt>-d<var>dependency-field</var></tt> option
8553 before those executable(s). (Each <tt>-d</tt> option
8554 takes effect until the next <tt>-d</tt>.)
8558 <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8559 output control file to be modified. Instead by default it
8560 adds to the <file>debian/substvars</file> file variable
8561 settings like <tt>shlibs:Depends</tt>. These variable
8562 settings must be referenced in dependency fields in the
8563 appropriate per-binary-package sections of the source
8568 For example, the <prgn>procps</prgn> package generates two
8569 kinds of binaries, simple C binaries like <prgn>ps</prgn>
8570 which require a predependency and full-screen ncurses
8571 binaries like <prgn>top</prgn> which require only a
8572 recommendation. It can say in its <file>debian/rules</file>:
8574 dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8576 and then in its main control file <file>debian/control</file>:
8580 Pre-Depends: ${shlibs:Pre-Depends}
8581 Recommends: ${shlibs:Recommends}
8587 Sources which produce several binary packages with
8588 different shared library dependency requirements can use
8589 the <tt>-p<var>varnameprefix</var></tt> option to override
8590 the default <tt>shlibs:</tt> prefix (one invocation of
8591 <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8592 They can thus produce several sets of dependency
8593 variables, each of the form
8594 <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8595 which can be referred to in the appropriate parts of the
8596 binary package control files.
8603 <prgn>dpkg-distaddfile</prgn> - adds a file to
8604 <file>debian/files</file>
8608 Some packages' uploads need to include files other than
8609 the source and binary package files.
8613 <prgn>dpkg-distaddfile</prgn> adds a file to the
8614 <file>debian/files</file> file so that it will be included in
8615 the <file>.changes</file> file when
8616 <prgn>dpkg-genchanges</prgn> is run.
8620 It is usually invoked from the <tt>binary</tt> target of
8621 <file>debian/rules</file>:
8623 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8625 The <var>filename</var> is relative to the directory where
8626 <prgn>dpkg-genchanges</prgn> will expect to find it - this
8627 is usually the directory above the top level of the source
8628 tree. The <file>debian/rules</file> target should put the
8629 file there just before or just after calling
8630 <prgn>dpkg-distaddfile</prgn>.
8634 The <var>section</var> and <var>priority</var> are passed
8635 unchanged into the resulting <file>.changes</file> file. See
8636 <ref id="pkg-f-classification">.
8641 <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8646 This program is usually called by package-independent
8647 automatic building scripts such as
8648 <prgn>dpkg-buildpackage</prgn>, but it may also be called
8653 It is usually called in the top level of a built source
8654 tree, and when invoked with no arguments will print out a
8655 straightforward <file>.changes</file> file based on the
8656 information in the source package's changelog and control
8657 file and the binary and source packages which should have
8663 <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8668 This program is used internally by
8669 <prgn>dpkg-source</prgn> et al. It may also occasionally
8670 be useful in <file>debian/rules</file> and elsewhere. It
8671 parses a changelog, <file>debian/changelog</file> by default,
8672 and prints a control-file format representation of the
8673 information in it to standard output.
8677 <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8678 information about the build and host system
8682 This program can be used manually, but is also invoked by
8683 <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8684 to set environment or make variables which specify the build and
8685 host architecture for the package building process.
8690 <sect id="pkg-sourcetree"><heading>The Debianised source tree
8694 The source archive scheme described later is intended to
8695 allow a Debianised source tree with some associated control
8696 information to be reproduced and transported easily. The
8697 Debianised source tree is a version of the original program
8698 with certain files added for the benefit of the
8699 Debianisation process, and with any other changes required
8700 made to the rest of the source code and installation
8705 The extra files created for Debian are in the subdirectory
8706 <file>debian</file> of the top level of the Debianised source
8707 tree. They are described below.
8710 <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8715 This file is an executable makefile, and contains the
8716 package-specific recipies for compiling the package and
8717 building binary package(s) out of the source.
8721 It must start with the line <tt>#!/usr/bin/make -f</tt>,
8722 so that it can be invoked by saying its name rather than
8723 invoking <prgn>make</prgn> explicitly.
8727 Since an interactive <file>debian/rules</file> script makes it
8728 impossible to autocompile that package and also makes it
8729 hard for other people to reproduce the same binary
8730 package, all <strong>required targets</strong> have to be
8731 non-interactive. At a minimul, required targets are the
8732 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8733 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8734 <em>build</em>. It also follows that any target that these
8735 targets depend on must also be non-interactive.
8739 The targets which are required to be present are:
8741 <tag><tt>build</tt></tag>
8744 This should perform all non-interactive
8745 configuration and compilation of the package. If a
8746 package has an interactive pre-build configuration
8747 routine, the Debianised source package should be
8748 built after this has taken place, so that it can be
8749 built without rerunning the configuration.
8753 A package may also provide both of the targets
8754 <tt>build-arch</tt> and <tt>build-indep</tt>. The
8755 <tt>build-arch</tt> target, if provided, should
8756 perform all non-interactive configuration and
8757 compilation required for producing all
8758 architecture-dependant binary packages (those packages
8759 for which the body of the <tt>Architecture</tt> field
8760 in <tt>debian/control</tt> is not <tt>all</tt>).
8761 Similarly, the <tt>build-indep</tt> target, if
8762 provided, should perform all non-interactive
8763 configuration and compilation required for producing
8764 all architecture-independent binary packages (those
8765 packages for which the body of the
8766 <tt>Architecture</tt> field in <tt>debian/control</tt>
8767 is <tt>all</tt>). The <tt>build</tt> target should
8768 depend on those of the targets <tt>build-arch</tt> and
8769 <tt>build-indep</tt> that are provided in the rules
8774 If one or both of the targets <tt>build-arch</tt> and
8775 <tt>build-indep</tt> are not provided, then invoking
8776 <file>debian/rules</file> with one of the not-provided
8777 targets as arguments should produce a exit status code
8778 of 2. Usually this is provided automatically by make
8779 if the target is missing.
8783 For some packages, notably ones where the same
8784 source tree is compiled in different ways to produce
8785 two binary packages, the <tt>build</tt> target does
8786 not make much sense. For these packages it is good
8787 enough to provide two (or more) targets
8788 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8789 for each of the ways of building the package, and a
8790 <tt>build</tt> target that does nothing. The
8791 <tt>binary</tt> target will have to build the
8792 package in each of the possible ways and make the
8793 binary package out of each.
8797 The targets <tt>build</tt>, <tt>build-arch</tt>
8798 and <tt>build-indep</tt> target must not do
8799 anything that might require root privilege.
8803 The <tt>build</tt> target may need to run
8804 <tt>clean</tt> first - see below.
8808 When a package has a configuration routine that takes
8809 a long time, or when the makefiles are poorly
8810 designed, or when <tt>build</tt> needs to run
8811 <tt>clean</tt> first, it is a good idea to <tt>touch
8812 build</tt> when the build process is complete. This
8813 will ensure that if <tt>debian/rules build</tt> is run
8814 again it will not rebuild the whole program.
8818 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8819 <tt>binary-indep</tt>
8823 The <tt>binary</tt> target should be all that is
8824 necessary for the user to build the binary
8825 package. All these targets are required to be
8826 non-interactive. It is split into two parts:
8827 <tt>binary-arch</tt> builds the packages' output
8828 files which are specific to a particular
8829 architecture, and <tt>binary-indep</tt> builds
8830 those which are not.
8834 <tt>binary</tt> should usually be a target with
8835 no commands which simply depends on
8836 <prgn>binary-arch</prgn> and
8837 <prgn>binary-indep</prgn>.
8841 Both <prgn>binary-*</prgn> targets should depend on
8842 the <tt>build</tt> target, above, so that the
8843 package is built if it has not been already. It
8844 should then create the relevant binary package(s),
8845 using <prgn>dpkg-gencontrol</prgn> to make their
8846 control files and <prgn>dpkg-deb</prgn> to build
8847 them and place them in the parent of the top level
8852 If one of the <prgn>binary-*</prgn> targets has
8853 nothing to do (this will be always be the case if
8854 the source generates only a single binary package,
8855 whether architecture-dependent or not) it
8856 <em>must</em> still exist, but should always
8861 <ref id="pkg-binarypkg"> describes how to construct
8866 The <tt>binary</tt> targets must be invoked as
8871 <tag><tt>clean</tt></tag>
8875 This should undo any effects that the
8876 <tt>build</tt> and <tt>binary</tt> targets
8877 may have had, except that it should leave alone any
8878 output files created in the parent directory by a
8879 run of <tt>binary</tt>. This target is required
8880 to be non-interactive.
8884 If a <tt>build</tt> file is touched at the end
8885 of the <tt>build</tt> target, as suggested
8886 above, it must be removed as the first thing that
8887 <tt>clean</tt> does, so that running
8888 <tt>build</tt> again after an interrupted
8889 <tt>clean</tt> doesn't think that everything is
8894 The <tt>clean</tt> target must be invoked as
8895 root if <tt>binary</tt> has been invoked since
8896 the last <tt>clean</tt>, or if
8897 <tt>build</tt> has been invoked as root (since
8898 <tt>build</tt> may create directories, for
8903 <tag><tt>get-orig-source</tt> (optional)</tag>
8907 This target fetches the most recent version of the
8908 original source package from a canonical archive
8909 site (via FTP or WWW, for example), does any
8910 necessary rearrangement to turn it into the original
8911 source tarfile format described below, and leaves it
8912 in the current directory.
8916 This target may be invoked in any directory, and
8917 should take care to clean up any temporary files it
8922 This target is optional, but providing it if
8923 possible is a good idea.
8929 The <tt>build</tt>, <tt>binary</tt> and
8930 <tt>clean</tt> targets must be invoked with a current
8931 directory of the package's top-level directory.
8936 Additional targets may exist in <file>debian/rules</file>,
8937 either as published or undocumented interfaces or for the
8938 package's internal use.
8942 The architecture we build on and build for is determined by make
8943 variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8944 get the Debian architecture and the GNU style architecture
8945 specification string for the build machine as well as the host
8946 machine. Here is a list of supported make variables:
8947 <list compact="compact">
8949 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8952 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8953 specification string)</p>
8956 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8959 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8965 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
8966 the build machine or <tt>HOST</tt> for specification of the machine
8971 Backward compatibility can be provided in the rules file
8972 by setting the needed variables to suitable default
8973 values, please refer to the documentation of
8974 dpkg-architecture for details.
8978 It is important to understand that the <tt>DEB_*_ARCH</tt>
8979 string does only determine which Debian architecture we
8980 build on resp. for. It should not be used to get the CPU
8981 or System information, the GNU style variables should be
8987 <sect1><heading><file>debian/control</file>
8991 This file contains version-independent details about the
8992 source package and about the binary packages it creates.
8996 It is a series of sets of control fields, each
8997 syntactically similar to a binary package control file.
8998 The sets are separated by one or more blank lines. The
8999 first set is information about the source package in
9000 general; each subsequent set describes one binary package
9001 that the source tree builds.
9005 The syntax and semantics of the fields are described below
9006 in <ref id="pkg-controlfields">.
9010 The general (binary-package-independent) fields are:
9011 <list compact="compact">
9013 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
9016 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9020 <qref id="pkg-f-classification"><tt>Section</tt> and
9021 <tt>Priority</tt></qref>
9022 (classification, mandatory)
9027 <qref id="relationships"><tt>Build-Depends</tt> et
9028 al.</qref> (source package interrelationships)
9033 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
9039 The per-binary-package fields are:
9040 <list compact="compact">
9042 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
9046 <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
9050 <p><qref id="descriptions"><tt>Description</tt></qref></p>
9054 <qref id="pkg-f-classification"><tt>Section</tt> and
9055 <tt>Priority</tt></qref> (classification)</p>
9058 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
9062 <qref id="relationships"><tt>Depends</tt> et
9063 al.</qref> (binary package interrelationships)
9069 These fields are used by <prgn>dpkg-gencontrol</prgn> to
9070 generate control files for binary packages (see below), by
9071 <prgn>dpkg-genchanges</prgn> to generate the
9072 <tt>.changes</tt> file to accompany the upload, and by
9073 <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9074 source control file as part of a source archive.
9078 The fields here may contain variable references - their
9079 values will be substituted by
9080 <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9081 or <prgn>dpkg-source</prgn> when they generate output
9082 control files. See <ref id="pkg-srcsubstvars"> for details.
9085 <p> <sect2><heading>User-defined fields
9089 Additional user-defined fields may be added to the
9090 source package control file. Such fields will be
9091 ignored, and not copied to (for example) binary or
9092 source package control files or upload control files.
9096 If you wish to add additional unsupported fields to
9097 these output files you should use the mechanism
9102 Fields in the main source control information file with
9103 names starting <tt>X</tt>, followed by one or more of
9104 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9105 be copied to the output files. Only the part of the
9106 field name after the hyphen will be used in the output
9107 file. Where the letter <tt>B</tt> is used the field
9108 will appear in binary package control files, where the
9109 letter <tt>S</tt> is used in source package control
9110 files and where <tt>C</tt> is used in upload control
9111 (<tt>.changes</tt>) files.
9115 For example, if the main source information control file
9118 XBS-Comment: I stand between the candle and the star.
9120 then the binary and source package control files will contain the
9123 Comment: I stand between the candle and the star.
9130 <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9134 This file records the changes to the Debian-specific parts of the
9138 Though there is nothing stopping an author who is also
9139 the Debian maintainer from using it for all their
9140 changes, it will have to be renamed if the Debian and
9141 upstream maintainers become different
9148 It has a special format which allows the package building
9149 tools to discover which version of the package is being
9150 built and find out other release-specific information.
9154 That format is a series of entries like this:
9156 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9158 * <var>change details</var>
9159 <var>more change details</var>
9160 * <var>even more change details</var>
9162 -- <var>maintainer name and email address</var> <var>date</var>
9167 <var>package</var> and <var>version</var> are the source
9168 package name and version number.
9172 <var>distribution(s)</var> lists the distributions where
9173 this version should be installed when it is uploaded - it
9174 is copied to the <tt>Distribution</tt> field in the
9175 <tt>.changes</tt> file. See <ref id="pkg-f-Distribution">.
9179 <var>urgency</var> is the value for the <tt>Urgency</tt>
9180 field in the <file>.changes</file> file for the upload. See
9181 <ref id="pkg-f-Urgency">. It is not possible to specify an
9182 urgency containing commas; commas are used to separate
9183 <tt><var>keyword</var>=<var>value</var></tt> settings in
9184 the <prgn>dpkg</prgn> changelog format (though there is
9185 currently only one useful <var>keyword</var>,
9190 The change details may in fact be any series of lines
9191 starting with at least two spaces, but conventionally each
9192 change starts with an asterisk and a separating space and
9193 continuation lines are indented so as to bring them in
9194 line with the start of the text above. Blank lines may be
9195 used here to separate groups of changes, if desired.
9199 The maintainer name and email address should <em>not</em>
9200 necessarily be those of the usual package maintainer.
9201 They should be the details of the person doing
9202 <em>this</em> version. The information here will be
9203 copied to the <file>.changes</file> file, and then later used
9204 to send an acknowledgement when the upload has been
9209 The <var>date</var> should be in RFC822 format
9212 This is generated by the <prgn>822-date</prgn>
9215 </footnote>; it should include the timezone specified
9216 numerically, with the timezone name or abbreviation
9217 optionally present as a comment.
9221 The first "title" line with the package name should start
9222 at the left hand margin; the "trailer" line with the
9223 maintainer and date details should be preceded by exactly
9224 one space. The maintainer details and the date must be
9225 separated by exactly two spaces.
9229 An Emacs mode for editing this format is available: it is
9230 called <tt>debian-changelog-mode</tt>. You can have this
9231 mode selected automatically when you edit a Debian
9232 changelog by adding a local variables clause to the end of
9236 <sect2><heading>Defining alternative changelog formats
9240 It is possible to use a different format to the standard
9241 one, by providing a parser for the format you wish to
9246 In order to have <tt>dpkg-parsechangelog</tt> run your
9247 parser, you must include a line within the last 40 lines
9248 of your file matching the Perl regular expression:
9249 <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9250 parentheses should be the name of the format. For
9251 example, you might say:
9253 @@@ changelog-format: joebloggs @@@
9255 Changelog format names are non-empty strings of alphanumerics.
9259 If such a line exists then <tt>dpkg-parsechangelog</tt>
9260 will look for the parser as
9261 <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9263 <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9264 it is an error for it not to find it, or for it not to
9265 be an executable program. The default changelog format
9266 is <tt>dpkg</tt>, and a parser for it is provided with
9267 the <tt>dpkg</tt> package.
9271 The parser will be invoked with the changelog open on
9272 standard input at the start of the file. It should read
9273 the file (it may seek if it wishes) to determine the
9274 information required and return the parsed information
9275 to standard output in the form of a series of control
9276 fields in the standard format. By default it should
9277 return information about only the most recent version in
9278 the changelog; it should accept a
9279 <tt>-v<var>version</var></tt> option to return changes
9280 information from all versions present <em>strictly
9281 after</em> <var>version</var>, and it should then be an
9282 error for <var>version</var> not to be present in the
9288 <list compact="compact">
9290 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9293 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9297 <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9302 <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9306 <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9311 <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9315 <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9322 If several versions are being returned (due to the use
9323 of <tt>-v</tt>), the urgency value should be of the
9324 highest urgency code listed at the start of any of the
9325 versions requested followed by the concatenated
9326 (space-separated) comments from all the versions
9327 requested; the maintainer, version, distribution and
9328 date should always be from the most recent version.
9332 For the format of the <tt>Changes</tt> field see <ref
9333 id="pkg-f-Changes">.
9337 If the changelog format which is being parsed always or
9338 almost always leaves a blank line between individual
9339 change notes these blank lines should be stripped out,
9340 so as to make the resulting output compact.
9344 If the changelog format does not contain date or package
9345 name information this information should be omitted from
9346 the output. The parser should not attempt to synthesise
9347 it or find it from other sources.
9351 If the changelog does not have the expected format the
9352 parser should exit with a nonzero exit status, rather
9353 than trying to muddle through and possibly generating
9358 A changelog parser may not interact with the user at
9362 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
9364 <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9365 and variable substitutions
9369 When <prgn>dpkg-gencontrol</prgn>,
9370 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9371 generate control files they do variable substitutions on
9372 their output just before writing it. Variable
9373 substitutions have the form
9374 <tt>${<var>variable-name</var>}</tt>. The optional file
9375 <file>debian/substvars</file> contains variable substitutions
9376 to be used; variables can also be set directly from
9377 <file>debian/rules</file> using the <tt>-V</tt> option to the
9378 source packaging commands, and certain predefined
9379 variables are available.
9383 This file is usually generated and modified dynamically by
9384 <file>debian/rules</file> targets, in which case it must be
9385 removed by the <tt>clean</tt> target.
9389 See <manref name="dpkg-source" section="1"> for full
9390 details about source variable substitutions, including the
9391 format of <file>debian/substvars</file>.</p>
9394 <sect1><heading><file>debian/files</file>
9398 This file is not a permanent part of the source tree; it
9399 is used while building packages to record which files are
9400 being generated. <prgn>dpkg-genchanges</prgn> uses it
9401 when it generates a <file>.changes</file> file.
9405 It should not exist in a shipped source package, and so it
9406 (and any backup files or temporary files such as
9407 <file>files.new</file>
9410 <file>files.new</file> is used as a temporary file by
9411 <prgn>dpkg-gencontrol</prgn> and
9412 <prgn>dpkg-distaddfile</prgn> - they write a new
9413 version of <file>files</file> here before renaming it,
9414 to avoid leaving a corrupted copy if an error
9417 </footnote>) should be removed by the
9418 <tt>clean</tt> target. It may also be wise to
9419 ensure a fresh start by emptying or removing it at the
9420 start of the <tt>binary</tt> target.
9424 <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9425 for the <file>.deb</file> file that will be created by
9426 <prgn>dpkg-deb</prgn> from the control file that it
9427 generates, so for most packages all that needs to be done
9428 with this file is to delete it in <tt>clean</tt>.
9432 If a package upload includes files besides the source
9433 package and any binary packages whose control files were
9434 made with <prgn>dpkg-gencontrol</prgn> then they should be
9435 placed in the parent of the package's top-level directory
9436 and <prgn>dpkg-distaddfile</prgn> should be called to add
9437 the file to the list in <file>debian/files</file>.</p>
9440 <sect1><heading><file>debian/tmp</file>
9444 This is the canonical temporary location for the
9445 construction of binary packages by the <tt>binary</tt>
9446 target. The directory <file>tmp</file> serves as the root of
9447 the filesystem tree as it is being constructed (for
9448 example, by using the package's upstream makefiles install
9449 targets and redirecting the output there), and it also
9450 contains the <tt>DEBIAN</tt> subdirectory. See <ref
9451 id="pkg-bincreating">.
9455 If several binary packages are generated from the same
9456 source tree it is usual to use several
9457 <file>debian/tmp<var>something</var></file> directories, for
9458 example <file>tmp-a</file> or <file>tmp-doc</file>.
9462 Whatever <file>tmp</file> directories are created and used by
9463 <tt>binary</tt> must of course be removed by the
9464 <tt>clean</tt> target.</p></sect1>
9468 <sect id="pkg-sourcearchives"><heading>Source packages as archives
9472 As it exists on the FTP site, a Debian source package
9473 consists of three related files. You must have the right
9474 versions of all three to be able to use them.
9479 <tag>Debian source control file - <tt>.dsc</tt></tag>
9483 This file contains a series of fields, identified and
9484 separated just like the fields in the control file of
9485 a binary package. The fields are listed below; their
9486 syntax is described above, in <ref id="pkg-controlfields">.
9487 <list compact="compact">
9489 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9492 <p><qref id="versions"><tt>Version</tt></qref></p>
9495 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9498 <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9501 <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9505 <qref id="relationships"><tt>Build-Depends</tt> et
9506 al.</qref> (source package interrelationships)
9511 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9514 <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9519 The source package control file is generated by
9520 <prgn>dpkg-source</prgn> when it builds the source
9521 archive, from other files in the source package,
9522 described above. When unpacking it is checked against
9523 the files and directories in the other parts of the
9524 source package, as described below.</p>
9528 Original source archive -
9530 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9537 This is a compressed (with <tt>gzip -9</tt>)
9538 <prgn>tar</prgn> file containing the source code from
9539 the upstream authors of the program. The tarfile
9540 unpacks into a directory
9541 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9542 and does not contain files anywhere other than in
9543 there or in its subdirectories.</p>
9547 Debianisation diff -
9549 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9555 This is a unified context diff (<tt>diff -u</tt>)
9556 giving the changes which are required to turn the
9557 original source into the Debian source. These changes
9558 may only include editing and creating plain files.
9559 The permissions of files, the targets of symbolic
9560 links and the characteristics of special files or
9561 pipes may not be changed and no files may be removed
9566 All the directories in the diff must exist, except the
9567 <file>debian</file> subdirectory of the top of the source
9568 tree, which will be created by
9569 <prgn>dpkg-source</prgn> if necessary when unpacking.
9573 The <prgn>dpkg-source</prgn> program will
9574 automatically make the <file>debian/rules</file> file
9575 executable (see below).</p></item>
9580 If there is no original source code - for example, if the
9581 package is specially prepared for Debian or the Debian
9582 maintainer is the same as the upstream maintainer - the
9583 format is slightly different: then there is no diff, and the
9585 <file><var>package</var>_<var>version</var>.tar.gz</file> and
9586 contains a directory
9587 <file><var>package</var>-<var>version</var></file>.
9591 <sect><heading>Unpacking a Debian source package without
9592 <prgn>dpkg-source</prgn>
9596 <tt>dpkg-source -x</tt> is the recommended way to unpack a
9597 Debian source package. However, if it is not available it
9598 is possible to unpack a Debian source archive as follows:
9599 <enumlist compact="compact">
9602 Untar the tarfile, which will create a <file>.orig</file>
9606 <p>Rename the <file>.orig</file> directory to
9607 <file><var>package</var>-<var>version</var></file>.</p>
9611 Create the subdirectory <file>debian</file> at the top of
9612 the source tree.</p>
9614 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9616 <item><p>Untar the tarfile again if you want a copy of the original
9617 source code alongside the Debianised version.</p>
9622 It is not possible to generate a valid Debian source archive
9623 without using <prgn>dpkg-source</prgn>. In particular,
9624 attempting to use <prgn>diff</prgn> directly to generate the
9625 <file>.diff.gz</file> file will not work.
9628 <sect1><heading>Restrictions on objects in source packages
9632 The source package may not contain any hard links
9635 This is not currently detected when building source
9636 packages, but only when extracting
9642 Hard links may be permitted at some point in the
9643 future, but would require a fair amount of
9646 </footnote>, device special files, sockets or setuid or
9650 Setgid directories are allowed.
9656 The source packaging tools manage the changes between the
9657 original and Debianised source using <prgn>diff</prgn> and
9658 <prgn>patch</prgn>. Turning the original source tree as
9659 included in the <file>.orig.tar.gz</file> into the debianised
9660 source must not involve any changes which cannot be
9661 handled by these tools. Problematic changes which cause
9662 <prgn>dpkg-source</prgn> to halt with an error when
9663 building the source package are:
9664 <list compact="compact">
9665 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9667 <item><p>Changing the targets of symbolic links.</p>
9669 <item><p>Creating directories, other than <file>debian</file>.</p>
9671 <item><p>Changes to the contents of binary files.</p></item>
9672 </list> Changes which cause <prgn>dpkg-source</prgn> to
9673 print a warning but continue anyway are:
9674 <list compact="compact">
9677 Removing files, directories or symlinks.
9680 Renaming a file is not treated specially - it is
9681 seen as the removal of the old file (which
9682 generates a warning, but is otherwise ignored),
9683 and the creation of the new
9690 Changed text files which are missing the usual final
9691 newline (either in the original or the modified
9696 Changes which are not represented, but which are not detected by
9697 <prgn>dpkg-source</prgn>, are:
9698 <list compact="compact">
9699 <item><p>Changing the permissions of files (other than
9700 <file>debian/rules</file>) and directories.</p></item>
9705 The <file>debian</file> directory and <file>debian/rules</file>
9706 are handled specially by <prgn>dpkg-source</prgn> - before
9707 applying the changes it will create the <file>debian</file>
9708 directory, and afterwards it will make
9709 <file>debian/rules</file> world-exectuable.
9715 <appendix id="pkg-controlfields"><heading>Control files and their
9716 fields (from old Packaging Manual)
9720 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9721 data in a common format, known as control files. Binary and
9722 source packages have control data as do the <file>.changes</file>
9723 files which control the installation of uploaded files, and
9724 <prgn>dpkg</prgn>'s internal databases are in a similar
9728 <sect><heading>Syntax of control files
9732 A file consists of one or more paragraphs of fields. The
9733 paragraphs are separated by blank lines. Some control files
9734 only allow one paragraph; others allow several, in which
9735 case each paragraph often refers to a different package.
9739 Each paragraph is a series of fields and values; each field
9740 consists of a name, followed by a colon and the value. It
9741 ends at the end of the line. Horizontal whitespace (spaces
9742 and tabs) may occur before or after the value and is ignored
9743 there; it is conventional to put a single space after the
9748 Some fields' values may span several lines; in this case
9749 each continuation line <em>must</em> start with a space or
9750 tab. Any trailing spaces or tabs at the end of individual
9751 lines of a field value are ignored.
9755 Except where otherwise stated only a single line of data is
9756 allowed and whitespace is not significant in a field body.
9757 Whitespace may never appear inside names (of packages,
9758 architectures, files or anything else), version numbers or
9759 in between the characters of multi-character version
9764 Field names are not case-sensitive, but it is usual to
9765 capitalise the field names using mixed case as shown below.
9769 Blank lines, or lines consisting only of spaces and tabs,
9770 are not allowed within field values or between fields - that
9771 would mean a new paragraph.
9775 It is important to note that there are several fields which
9776 are optional as far as <prgn>dpkg</prgn> and the related
9777 tools are concerned, but which must appear in every Debian
9778 package, or whose omission may cause problems.
9782 <sect><heading>List of fields
9785 <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9789 The name of the binary package. Package names consist of
9790 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9791 (plus, minus and full stop).
9794 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9795 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9796 and underscore) used to be legal and are still
9797 accepted when found in a package file, but may not be
9798 used in new packages
9804 They must be at least two characters and must start with
9805 an alphanumeric. In current versions of dpkg they are
9806 sort of case-sensitive<footnote><p>This is a
9807 bug.</p></footnote>; use lowercase package names unless
9808 the package you're building (or referring to, in other
9809 fields) is already using uppercase.</p>
9812 <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9816 This lists the source or binary package's version number -
9817 see <ref id="versions">.
9822 <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9826 This is the architecture string; it is a single word for
9827 the Debian architecture.
9831 <prgn>dpkg</prgn> will check the declared architecture of
9832 a binary package against its own compiled-in value before
9837 The special value <tt>all</tt> indicates that the package
9838 is architecture-independent.
9842 In the main <file>debian/control</file> file in the source
9843 package, or in the source package control file
9844 <file>.dsc</file>, a list of architectures (separated by
9845 spaces) is also allowed, as is the special value
9846 <tt>any</tt>. A list indicates that the source will build
9847 an architecture-dependent package, and will only work
9848 correctly on the listed architectures. <tt>any</tt>
9849 indicates that though the source package isn't dependent
9850 on any particular architecture and should compile fine on
9851 any one, the binary package(s) produced are not
9852 architecture-independent but will instead be specific to
9853 whatever the current build architecture is.
9857 In a <file>.changes</file> file the <tt>Architecture</tt>
9858 field lists the architecture(s) of the package(s)
9859 currently being uploaded. This will be a list; if the
9860 source for the package is being uploaded too the special
9861 entry <tt>source</tt> is also present.
9865 See <ref id="pkg-debianrules"> for information how to get the
9866 architecture for the build process.
9870 <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9874 The package maintainer's name and email address. The name
9875 should come first, then the email address inside angle
9876 brackets <tt><></tt> (in RFC822 format).
9880 If the maintainer's name contains a full stop then the
9881 whole field will not work directly as an email address due
9882 to a misfeature in the syntax specified in RFC822; a
9883 program using this field as an address must check for this
9884 and correct the problem if necessary (for example by
9885 putting the name in round brackets and moving it to the
9886 end, and bringing the email address forward).
9890 In a <file>.changes</file> file or parsed changelog data this
9891 contains the name and email address of the person
9892 responsible for the particular version in question - this
9893 may not be the package's usual maintainer.
9897 This field is usually optional in as far as the
9898 <prgn>dpkg</prgn> are concerned, but its absence when
9899 building packages usually generates a warning.</p>
9902 <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9906 This field identifies the source package name.
9910 In a main source control information or a
9911 <file>.changes</file> or <file>.dsc</file> file or parsed
9912 changelog data this may contain only the name of the
9917 In the control file of a binary package (or in a
9918 <file>Packages</file> file) it may be followed by a version
9919 number in parentheses.
9922 It is usual to leave a space after the package name if
9923 a version number is specified.
9925 </footnote> This version number may be omitted (and is, by
9926 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9927 the <tt>Version</tt> field of the binary package in
9928 question. The field itself may be omitted from a binary
9929 package control file when the source package has the same
9930 name and version as the binary package.
9934 <sect1><heading>Package interrelationship fields:
9935 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9936 <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9937 <tt>Provides</tt>, <tt>Replaces</tt>
9941 These fields describe the package's relationships with
9942 other packages. Their syntax and semantics are described
9943 in <ref id="relationships">.</p>
9946 <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9950 In a binary package <tt>Packages</tt> file or main source
9951 control file this field contains a description of the
9952 binary package, in a special format. See <ref
9953 id="descriptions"> for details.
9957 In a <file>.changes</file> file it contains a summary of the
9958 descriptions for the packages being uploaded. The part of
9959 the field before the first newline is empty; thereafter
9960 each line has the name of a binary package and the summary
9961 description line from that binary package. Each line is
9962 indented by one space.</p>
9965 <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
9969 This is a boolean field which may occur only in the
9970 control file of a binary package (or in the
9971 <file>Packages</file> file) or in a per-package fields
9972 paragraph of a main source control data file.
9976 If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
9977 <prgn>dselect</prgn> will refuse to remove the package
9978 (though it can be upgraded and/or replaced). The other
9979 possible value is <tt>no</tt>, which is the same as not
9980 having the field at all.</p>
9983 <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
9988 These two fields classify the package. The
9989 <tt>Priority</tt> represents how important that it is that
9990 the user have it installed; the <tt>Section</tt>
9991 represents an application area into which the package has
9996 When they appear in the <file>debian/control</file> file these
9997 fields give values for the section and priority subfields
9998 of the <tt>Files</tt> field of the <file>.changes</file> file,
9999 and give defaults for the section and priority of the
10004 The section and priority are represented, though not as
10005 separate fields, in the information for each file in the
10006 <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
10007 <file>.changes</file> file. The section value in a
10008 <file>.changes</file> file is used to decide where to install
10009 a package in the FTP archive.
10013 These fields are not used by by <prgn>dpkg</prgn> proper,
10014 but by <prgn>dselect</prgn> when it sorts packages and
10019 These fields can appear in binary package control files,
10020 in which case they provide a default value in case the
10021 <file>Packages</file> files are missing the information.
10022 <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
10023 the value from a <file>.deb</file> file if they have no other
10024 information; a value listed in a <file>Packages</file> file
10025 will always take precedence. By default
10026 <prgn>dpkg-gencontrol</prgn> does not include the section
10027 and priority in the control file of a binary package - use
10028 the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
10029 achieve this effect.</p>
10032 <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
10036 This field is a list of binary packages.
10040 When it appears in the <file>.dsc</file> file it is the list
10041 of binary packages which a source package can produce. It
10042 does not necessarily produce all of these binary packages
10043 for every architecture. The source control file doesn't
10044 contain details of which architectures are appropriate for
10045 which of the binary packages.
10049 When it appears in a <file>.changes</file> file it lists the
10050 names of the binary packages actually being uploaded.
10054 The syntax is a list of binary packages separated by
10058 A space after each comma is conventional.
10060 </footnote> Currently the packages must be separated using
10061 only spaces in the <file>.changes</file> file.</p>
10064 <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10068 This field appears in the control files of binary
10069 packages, and in the <file>Packages</file> files. It gives
10070 the total amount of disk space required to install the
10075 The disk space is represented in kilobytes as a simple
10076 decimal number.</p>
10079 <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10083 This field contains a list of files with information about
10084 each one. The exact information and syntax varies with
10085 the context. In all cases the part of the field
10086 contents on the same line as the field name is empty. The
10087 remainder of the field is one line per file, each line
10088 being indented by one space and containing a number of
10089 sub-fields separated by spaces.
10093 In the <file>.dsc</file> (Debian source control) file each
10094 line contains the MD5 checksum, size and filename of the
10095 tarfile and (if applicable) diff file which make up the
10096 remainder of the source package.
10099 That is, the parts which are not the
10102 </footnote> The exact forms of the filenames are described
10103 in <ref id="pkg-sourcearchives">.
10107 In the <file>.changes</file> file this contains one line per
10108 file being uploaded. Each line contains the MD5 checksum,
10109 size, section and priority and the filename. The section
10110 and priority are the values of the corresponding fields in
10111 the main source control file - see <ref
10112 id="pkg-f-classification">. If no section or priority is
10113 specified then <tt>-</tt> should be used, though section
10114 and priority values must be specified for new packages to
10115 be installed properly.
10119 The special value <tt>byhand</tt> for the section in a
10120 <tt>.changes</tt> file indicates that the file in question
10121 is not an ordinary package file and must by installed by
10122 hand by the distribution maintainers. If the section is
10123 <tt>byhand</tt> the priority should be <tt>-</tt>.
10127 If a new Debian revision of a package is being shipped and
10128 no new original source archive is being distributed the
10129 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10130 entry for the original source archive
10131 <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10132 but the <file>.changes</file> file should leave it out. In
10133 this case the original source archive on the distribution
10134 site must match exactly, byte-for-byte, the original
10135 source archive which was used to generate the
10136 <file>.dsc</file> file and diff which are being uploaded.</p>
10141 id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10145 The most recent version of the standards (the Debian Policy
10146 and associated texts) with which the package complies. This
10147 is updated manually when editing the source package to
10148 conform to newer standards; it can sometimes be used to
10149 tell when a package needs attention.
10153 Its format is the same as that of a version number except
10154 that no epoch or Debian revision is allowed - see <ref
10155 id="versions">.</p>
10159 <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10163 In a <file>.changes</file> file or parsed changelog output
10164 this contains the (space-separated) name(s) of the
10165 distribution(s) where this version of the package should
10166 be or was installed. Distribution names follow the rules
10167 for package names. (See <ref id="pkg-f-Package">).
10171 Current distribution values are:
10173 <tag><em>stable</em></tag>
10176 This is the current "released" version of Debian
10177 GNU/Linux. A new version is released approximately
10178 every 3 months after the <em>development</em> code has
10179 been <em>frozen</em> for a month of testing. Once the
10180 distribution is <em>stable</em> only major bug fixes
10181 are allowed. When changes are made to this
10182 distribution, the release number is increased
10183 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10187 <tag><em>unstable</em></tag>
10190 This distribution value refers to the
10191 <em>developmental</em> part of the Debian distribution
10192 tree. New packages, new upstream versions of packages
10193 and bug fixes go into the <em>unstable</em> directory
10194 tree. Download from this distribution at your own
10198 <tag><em>contrib</em></tag>
10201 The packages with this distribution value do not meet
10202 the criteria for inclusion in the main Debian
10203 distribution as defined by the Policy Manual, but meet
10204 the criteria for the <em>contrib</em>
10205 Distribution. There is currently no distinction
10206 between stable and unstable packages in the
10207 <em>contrib</em> or <em>non-free</em>
10208 distributions. Use your best judgement in downloading
10209 from this Distribution.</p>
10212 <tag><em>non-free</em></tag>
10215 Like the packages in the <em>contrib</em> seciton,
10216 the packages in <em>non-free</em> do not meet the
10217 criteria for inclusion in the main Debian distribution
10218 as defined by the Policy Manual. Again, use your best
10219 judgement in downloading from this Distribution.</p>
10221 <tag><em>experimental</em></tag>
10224 The packages with this distribution value are deemed
10225 by their maintainers to be high risk. Oftentimes they
10226 represent early beta or developmental packages from
10227 various sources that the maintainers want people to
10228 try, but are not ready to be a part of the other parts
10229 of the Debian distribution tree. Download at your own
10233 <tag><em>frozen</em></tag>
10236 From time to time, (currently, every 3 months) the
10237 <em>unstable</em> distribution enters a state of
10238 "code-freeze" in anticipation of release as a
10239 <em>stable</em> version. During this period of testing
10240 (usually 4 weeks) only fixes for existing or
10241 newly-discovered bugs will be allowed.
10244 </taglist> You should list <em>all</em> distributions that
10245 the package should be installed into. Except in unusual
10246 circumstances, installations to <em>stable</em> should also
10247 go into <em>frozen</em> (if it exists) and
10248 <em>unstable</em>. Likewise, installations into
10249 <em>frozen</em> should also go into <em>unstable</em>.</p>
10252 <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10256 This is a description of how important it is to upgrade to
10257 this version from previous ones. It consists of a single
10258 keyword usually taking one of the values <tt>LOW</tt>,
10259 <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10260 commentary (separated by a space) which is usually in
10261 parentheses. For example:
10263 Urgency: LOW (HIGH for diversions users)
10268 This field appears in the <file>.changes</file> file and in
10269 parsed changelogs; its value appears as the value of the
10270 <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10271 changelog (see <ref id="pkg-dpkgchangelog">).
10275 Urgency keywords are not case-sensitive.</p>
10278 <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10282 In <tt>.changes</tt> files and parsed changelogs, this
10283 gives the date the package was built or last edited.</p>
10286 <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10290 This field occurs in <file>.changes</file> files, and
10291 specifies a format revision for the file. The format
10292 described here is version <tt>1.5</tt>. The syntax of the
10293 format value is the same as that of a package version
10294 number except that no epoch or Debian revision is allowed
10295 - see <ref id="versions">.</p>
10298 <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10302 In a <file>.changes</file> file or parsed changelog this field
10303 contains the human-readable changes data, describing the
10304 differences between the last version and the current one.
10308 There should be nothing in this field before the first
10309 newline; all the subsequent lines must be indented by at
10310 least one space; blank lines must be represented by a line
10311 consiting only of a space and a full stop.
10315 Each version's change information should be preceded by a
10316 "title" line giving at least the version, distribution(s)
10317 and urgency, in a human-readable way.
10321 If data from several versions is being returned the entry
10322 for the most recent version should be returned first, and
10323 entries should be separated by the representation of a
10324 blank line (the "title" line may also be followed by the
10325 representation of blank line).</p>
10328 <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10329 <tt>MSDOS-Filename</tt>
10333 These fields in <tt>Packages</tt> files give the
10334 filename(s) of (the parts of) a package in the
10335 distribution directories, relative to the root of the
10336 Debian hierarchy. If the package has been split into
10337 several parts the parts are all listed in order, separated
10341 <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10345 These fields in <file>Packages</file> files give the size (in
10346 bytes, expressed in decimal) and MD5 checksum of the
10347 file(s) which make(s) up a binary package in the
10348 distribution. If the package is split into several parts
10349 the values for the parts are listed in order, separated by
10353 <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10357 This field in <prgn>dpkg</prgn>'s status file records
10358 whether the user wants a package installed, removed or
10359 left alone, whether it is broken (requiring
10360 reinstallation) or not and what its current state on the
10361 system is. Each of these pieces of information is a
10365 <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10369 If a package is not installed or not configured, this
10370 field in <prgn>dpkg</prgn>'s status file records the last
10371 version of the package which was successfully
10375 <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10379 This field in <prgn>dpkg</prgn>'s status file contains
10380 information about the automatically-managed configuration
10381 files held by a package. This field should <em>not</em>
10382 appear anywhere in a package!</p>
10385 <sect1><heading>Obsolete fields
10389 These are still recognised by <prgn>dpkg</prgn> but should
10390 not appear anywhere any more.
10391 <taglist compact="compact">
10393 <tag><tt>Revision</tt></tag>
10394 <tag><tt>Package-Revision</tt></tag>
10395 <tag><tt>Package_Revision</tt></tag>
10398 The Debian revision part of the package version was
10399 at one point in a separate control file field. This
10400 field went through several names.</p>
10403 <tag><tt>Recommended</tt></tag>
10404 <item><p>Old name for <tt>Recommends</tt></p>
10407 <tag><tt>Optional</tt></tag>
10408 <item><p>Old name for <tt>Suggests</tt>.</p>
10410 <tag><tt>Class</tt></tag>
10411 <item><p>Old name for <tt>Priority</tt>.</p>
10419 <appendix id="pkg-conffiles"><heading>Configuration file handling
10420 (from old Packaging Manual)
10424 <prgn>dpkg</prgn> can do a certain amount of automatic
10425 handling of package configuration files.
10429 Whether this mechanism is appropriate depends on a number of
10430 factors, but basically there are two approaches to any
10431 particular configuration file.
10435 The easy method is to ship a best-effort configuration in the
10436 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10437 handle updates. If the user is unlikely to want to edit the
10438 file, but you need them to be able to without losing their
10439 changes, and a new package with a changed version of the file
10440 is only released infrequently, this is a good approach.
10444 The hard method is to build the configuration file from
10445 scratch in the <prgn>postinst</prgn> script, and to take the
10446 responsibility for fixing any mistakes made in earlier
10447 versions of the package automatically. This will be
10448 appropriate if the file is likely to need to be different on
10452 <sect><heading>Automatic handling of configuration files by
10457 A package may contain a control area file called
10458 <tt>conffiles</tt>. This file should be a list of filenames
10459 of configuration files needing automatic handling, separated
10460 by newlines. The filenames should be absolute pathnames,
10461 and the files referred to should actually exist in the
10466 When a package is upgraded <prgn>dpkg</prgn> will process
10467 the configuration files during the configuration stage,
10468 shortly before it runs the package's <prgn>postinst</prgn>
10473 For each file it checks to see whether the version of the
10474 file included in the package is the same as the one that was
10475 included in the last version of the package (the one that is
10476 being upgraded from); it also compares the version currently
10477 installed on the system with the one shipped with the last
10482 If neither the user nor the package maintainer has changed
10483 the file, it is left alone. If one or the other has changed
10484 their version, then the changed version is preferred - i.e.,
10485 if the user edits their file, but the package maintainer
10486 doesn't ship a different version, the user's changes will
10487 stay, silently, but if the maintainer ships a new version
10488 and the user hasn't edited it the new version will be
10489 installed (with an informative message). If both have
10490 changed their version the user is prompted about the problem
10491 and must resolve the differences themselves.
10495 The comparisons are done by calculating the MD5 message
10496 digests of the files, and storing the MD5 of the file as it
10497 was included in the most recent version of the package.
10501 When a package is installed for the first time
10502 <prgn>dpkg</prgn> will install the file that comes with it,
10503 unless that would mean overwriting a file already on the
10508 However, note that <prgn>dpkg</prgn> will <em>not</em>
10509 replace a conffile that was removed by the user (or by a
10510 script). This is necessary because with some programs a
10511 missing file produces an effect hard or impossible to
10512 achieve in another way, so that a missing file needs to be
10513 kept that way if the user did it.
10517 Note that a package should <em>not</em> modify a
10518 <prgn>dpkg</prgn>-handled conffile in its maintainer
10519 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
10520 the user confusing and possibly dangerous options for
10521 conffile update when the package is upgraded.</p>
10524 <sect><heading>Fully-featured maintainer script configuration
10529 For files which contain site-specific information such as
10530 the hostname and networking details and so forth, it is
10531 better to create the file in the package's
10532 <prgn>postinst</prgn> script.
10536 This will typically involve examining the state of the rest
10537 of the system to determine values and other information, and
10538 may involve prompting the user for some information which
10539 can't be obtained some other way.
10543 When using this method there are a couple of important
10544 issues which should be considered:
10548 If you discover a bug in the program which generates the
10549 configuration file, or if the format of the file changes
10550 from one version to the next, you will have to arrange for
10551 the postinst script to do something sensible - usually this
10552 will mean editing the installed configuration file to remove
10553 the problem or change the syntax. You will have to do this
10554 very carefully, since the user may have changed the file,
10555 perhaps to fix the very problem that your script is trying
10556 to deal with - you will have to detect these situations and
10557 deal with them correctly.
10561 If you do go down this route it's probably a good idea to
10562 make the program that generates the configuration file(s) a
10563 separate program in <file>/usr/sbin</file>, by convention called
10564 <file><var>package</var>config</file> and then run that if
10565 appropriate from the post-installation script. The
10566 <tt><var>package</var>config</tt> program should not
10567 unquestioningly overwrite an existing configuration - if its
10568 mode of operation is geared towards setting up a package for
10569 the first time (rather than any arbitrary reconfiguration
10570 later) you should have it check whether the configuration
10571 already exists, and require a <tt>--force</tt> flag to
10572 overwrite it.</p></sect>
10575 <appendix id="pkg-alternatives"><heading>Alternative versions of
10576 an interface - <prgn>update-alternatives</prgn> (from old
10581 When several packages all provide different versions of the
10582 same program or file it is useful to have the system select a
10583 default, but to allow the system administrator to change it
10584 and have their decisions respected.
10588 For example, there are several versions of the <prgn>vi</prgn>
10589 editor, and there is no reason to prevent all of them from
10590 being installed at once, each under their own name
10591 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10592 Nevertheless it is desirable to have the name <tt>vi</tt>
10593 refer to something, at least by default.
10597 If all the packages involved cooperate, this can be done with
10598 <prgn>update-alternatives</prgn>.
10602 Each package provides its own version under its own name, and
10603 calls <prgn>update-alternatives</prgn> in its postinst to
10604 register its version (and again in its prerm to deregister
10609 See the manpage <manref name="update-alternatives"
10610 section="8"> for details.
10614 If <prgn>update-alternatives</prgn> does not seem appropriate
10615 you may wish to consider using diversions instead.</p>
10618 <appendix id="pkg-diversions"><heading>Diversions - overriding a
10619 package's version of a file (from old Packaging Manual)
10623 It is possible to have <prgn>dpkg</prgn> not overwrite a file
10624 when it reinstalls the package it belongs to, and to have it
10625 put the file from the package somewhere else instead.
10629 This can be used locally to override a package's version of a
10630 file, or by one package to override another's version (or
10631 provide a wrapper for it).
10635 Before deciding to use a diversion, read <ref
10636 id="pkg-alternatives"> to see if you really want a diversion
10637 rather than several alternative versions of a program.
10641 There is a diversion list, which is read by <prgn>dpkg</prgn>,
10642 and updated by a special program <prgn>dpkg-divert</prgn>.
10643 Please see <manref name="dpkg-divert" section="8"> for full
10644 details of its operation.
10648 When a package wishes to divert a file from another, it should
10649 call <prgn>dpkg-divert</prgn> in its preinst to add the
10650 diversion and rename the existing file. For example,
10651 supposing that a <prgn>smailwrapper</prgn> package wishes to
10652 install a wrapper around <file>/usr/sbin/smail</file>:
10654 if [ install = "$1" ]; then
10655 dpkg-divert --package smailwrapper --add --rename \
10656 --divert /usr/sbin/smail.real /usr/sbin/smail
10658 </example> Testing <tt>$1</tt> is necessary so that the script
10659 doesn't try to add the diversion again when
10660 <prgn>smailwrapper</prgn> is upgraded. The <tt>--package
10661 smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10662 copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10663 get installed as the true version.
10667 The postrm has to do the reverse:
10669 if [ remove = "$1" ]; then
10670 dpkg-divert --package smailwrapper --remove --rename \
10671 --divert /usr/sbin/smail.real /usr/sbin/smail
10677 Do not attempt to divert a file which is vitally important for
10678 the system's operation - when using <prgn>dpkg-divert</prgn>
10679 there is a time, after it has been diverted but before
10680 <prgn>dpkg</prgn> has installed the new version, when the file
10681 does not exist.</p>
10686 <!-- vim:set ai et sts=2 sw=2 tw=76: -->