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><qref id="authors">The Debian Policy Mailing List</qref></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>
82 The material presented represents an interface to
83 the packaging system that is mandated for use, and
84 is used by, a significant number of packages, and
85 therefore should not be changed without peer
86 review. Package maintainers can then rely on this
87 interfaces not changing, and the package
88 management software authors need to ensure
89 compatibility with these interface
90 definitions. (Control file and changelog file
91 formats are examples.)
93 <tag>Chosen Convention</tag>
95 If there are a number of technically viable choices
96 that can be made, but one needs to select one of
97 these options for inter-operability. The version
98 number format is one example.
101 Please note that these are not mutually exclusive;
102 selected conventions often become parts of standard
109 The footnotes present in this manual are
110 merely informative, and are not part of Debian policy itself.
114 The appendices to this manual are not necessarily normative,
115 either. Please see <ref id="pkg-scope"> for more information.
119 In the normative part of this manual,
120 the words <em>must</em>, <em>should</em> and
121 <em>may</em>, and the adjectives <em>required</em>,
122 <em>recommended</em> and <em>optional</em>, are used to
123 distinguish the significance of the various guidelines in
124 this policy document. Packages that do not conform to the
125 guidelines denoted by <em>must</em> (or <em>required</em>)
126 will generally not be considered acceptable for the Debian
127 distribution. Non-conformance with guidelines denoted by
128 <em>should</em> (or <em>recommended</em>) will generally be
129 considered a bug, but will not necessarily render a package
130 unsuitable for distribution. Guidelines denoted by
131 <em>may</em> (or <em>optional</em>) are truly optional and
132 adherence is left to the maintainer's discretion.
135 These classifications are roughly equivalent to the bug
136 severities <em>serious</em> (for <em>must</em> or
137 <em>required</em> directive violations), <em>minor</em>,
138 <em>normal</em> or <em>important</em>
139 (for <em>should</em> or <em>recommended</em> directive
140 violations) and <em>wishlist</em> (for <em>optional</em>
142 <p>Compare RFC 2119. Note, however, that these words are
143 used in a different way in this document.</p>
147 Much of the information presented in this manual will be
148 useful even when building a package which is to be
149 distributed in some other way or is intended for local use
155 <heading>New versions of this document</heading>
158 This manual is distributed via the Debian package
159 <package>debian-policy</package>.
163 The current version of this document is also available from
164 the Debian web mirrors at
165 <tt><url name="/doc/debian-policy/"
166 id="http://www.debian.org/doc/debian-policy/"></tt>
167 and from the Debian archive mirrors at
168 <tt><url name="/doc/package-developer/policy.txt.gz"
169 id="http://ftp.debian.org/debian/doc/package-developer/policy.txt.gz"></tt>.
170 Also available from the same directory are several other
171 formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
172 and <file>policy.ps.gz</file>.
176 The <package>debian-policy</package> package also includes the file
177 <file>upgrading-checklist.txt</file> which indicates policy
178 changes between versions of this document.
183 <heading>Authors and Maintainers</heading>
186 Originally called "Debian GNU/Linux Policy Manual", this
187 manual was initially written in 1996 by Ian Jackson.
188 It was revised on November 27th, 1996 by David A. Morris.
189 Christian Schwarz added new sections on March 15th, 1997,
190 and reworked/restructured it in April-July 1997.
191 Christoph Lameter contributed the "Web Standard".
192 Julian Gilbey largely restructured it in 2001.
196 Since September 1998, the responsibility for the contents of
197 this document lies on the <url name="debian-policy mailing list"
198 id="mailto:debian-policy@lists.debian.org">. 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.
233 <heading>The Debian Archive</heading>
236 The Debian GNU/Linux system is maintained and distributed as a
237 collection of <em>packages</em>. Since there are so many of
238 them (currently well over 6000), they are split into
239 <em>sections</em> and given <em>priorities</em> to simplify
240 the handling of them.
244 The effort of the Debian project is to build a free operating
245 system, but not every package we want to make accessible is
246 <em>free</em> in our sense (see the Debian Free Software
247 Guidelines, below), or may be imported/exported without
248 restrictions. Thus, the archive is split into the sections
249 <em>main</em>, <em>non-free</em>, <em>contrib</em>,
250 <em>non-US/main</em>, <em>non-US/non-free</em>, and
251 <em>non-US/contrib</em>. The sections are explained in detail
256 The <em>main</em> and the <em>non-US/main</em> sections
257 together form the <em>Debian GNU/Linux distribution</em>.
261 Packages in the other sections are not considered to be part
262 of the Debian distribution, although we support their use and
263 provide infrastructure for them (such as our bug-tracking
264 system and mailing lists). This Debian Policy Manual applies
265 to these packages as well.</p>
267 <sect id="pkgcopyright">
268 <heading>Package copyright and sections</heading>
270 The aims of this section are:
272 <list compact="compact">
274 to allow us to make as much software available as we can,
277 to allow us to encourage everyone to write free software, and
280 to allow us to make it easy for people to produce
281 CD-ROMs of our system without violating any licenses,
282 import/export restrictions, or any other laws.
287 <heading>The Debian Free Software Guidelines</heading>
289 The Debian Free Software Guidelines (DFSG) form our
290 definition of "free software". These are:
292 <tag>Free Redistribution
295 The license of a Debian component may not restrict any
296 party from selling or giving away the software as a
297 component of an aggregate software distribution
298 containing programs from several different
299 sources. The license may not require a royalty or
300 other fee for such sale.
305 The program must include source code, and must allow
306 distribution in source code as well as compiled form.
311 The license must allow modifications and derived
312 works, and must allow them to be distributed under the
313 same terms as the license of the original software.
315 <tag>Integrity of The Author's Source Code
318 The license may restrict source-code from being
319 distributed in modified form <em>only</em> if the
320 license allows the distribution of "patch files"
321 with the source code for the purpose of modifying the
322 program at build time. The license must explicitly
323 permit distribution of software built from modified
324 source code. The license may require derived works to
325 carry a different name or version number from the
326 original software. (This is a compromise. The Debian
327 Project encourages all authors to not restrict any
328 files, source or binary, from being modified.)
330 <tag>No Discrimination Against Persons or Groups
333 The license must not discriminate against any person
336 <tag>No Discrimination Against Fields of Endeavor
339 The license must not restrict anyone from making use
340 of the program in a specific field of endeavor. For
341 example, it may not restrict the program from being
342 used in a business, or from being used for genetic
345 <tag>Distribution of License
348 The rights attached to the program must apply to all
349 to whom the program is redistributed without the need
350 for execution of an additional license by those
353 <tag>License Must Not Be Specific to Debian
356 The rights attached to the program must not depend on
357 the program's being part of a Debian system. If the
358 program is extracted from Debian and used or
359 distributed without Debian but otherwise within the
360 terms of the program's license, all parties to whom
361 the program is redistributed must have the same
362 rights as those that are granted in conjunction with
365 <tag>License Must Not Contaminate Other Software
368 The license must not place restrictions on other
369 software that is distributed along with the licensed
370 software. For example, the license must not insist
371 that all other programs distributed on the same medium
372 must be free software.
374 <tag>Example Licenses
377 The "GPL," "BSD," and "Artistic" licenses are examples of
378 licenses that we consider <em>free</em>.
384 <heading>The main section</heading>
386 Every package in <em>main</em> and <em>non-US/main</em>
387 must comply with the DFSG (Debian Free Software
392 In addition, the packages in <em>main</em>
393 <list compact="compact">
395 must not require a package outside of <em>main</em>
396 for compilation or execution (thus, the package must
397 not declare a "Depends", "Recommends", or
398 "Build-Depends" relationship on a non-<em>main</em>
402 must not be so buggy that we refuse to support them,
406 must meet all policy requirements presented in this
413 Similarly, the packages in <em>non-US/main</em>
414 <list compact="compact">
416 must not require a package outside of <em>main</em>
417 or <em>non-US/main</em> for compilation or
421 must not be so buggy that we refuse to support them,
424 must meet all policy requirements presented in this
433 <heading>The contrib section</heading>
436 Every package in <em>contrib</em> and
437 <em>non-US/contrib</em> must comply with the DFSG.
441 In addition, the packages in <em>contrib</em> and
442 <em>non-US/contrib</em>
443 <list compact="compact">
445 must not be so buggy that we refuse to support them,
449 must meet all policy requirements presented in this
456 Furthermore, packages in <em>contrib</em> must not require
457 a package in a <em>non-US</em> section for compilation or
462 Examples of packages which would be included in
463 <em>contrib</em> or <em>non-US/contrib</em> are:
464 <list compact="compact">
466 free packages which require <em>contrib</em>,
467 <em>non-free</em> packages or packages which are not
468 in our archive at all for compilation or execution,
472 wrapper packages or other sorts of free accessories for
479 <sect1 id="non-free">
480 <heading>The non-free section</heading>
483 Packages must be placed in <em>non-free</em> or
484 <em>non-US/non-free</em> if they are not compliant with
485 the DFSG or are encumbered by patents or other legal
486 issues that make their distribution problematic.
490 In addition, the packages in <em>non-free</em> and
491 <em>non-US/non-free</em>
492 <list compact="compact">
494 must not be so buggy that we refuse to support them,
498 must meet all policy requirements presented in this
499 manual that it is possible for them to meet.
501 It is possible that there are policy
502 requirements which the package is unable to
503 meet, for example, if the source is
504 unavailable. These situations will need to be
505 handled on a case-by-case basis.
513 <heading>The non-US sections</heading>
516 Non-free programs with cryptographic program code need to
517 be stored on the <em>non-us</em> server because of export
518 restrictions of the U.S.
522 Programs which use patented algorithms that have a
523 restrictied license also need to be stored on "non-us",
524 since that is located in a country where it is not allowed
525 to patent algorithms.
529 A package depends on another package which is distributed
530 via the non-us server has to be stored on the non-us
535 <heading>Further copyright considerations</heading>
537 Every package must be accompanied by a verbatim copy of
538 its copyright and distribution license in the file
539 <file>/usr/share/doc/<var>package</var>/copyright</file>
540 (see <ref id="copyrightfile"> for further details).
543 We reserve the right to restrict files from being included
544 anywhere in our archives if
545 <list compact="compact">
547 their use or distribution would break a law,
550 there is an ethical conflict in their distribution or
554 we would have to sign a license for them, or
557 their distribution would conflict with other project
564 Programs whose authors encourage the user to make
565 donations are fine for the main distribution, provided
566 that the authors do not claim that not donating is
567 immoral, unethical, illegal or something similar; in such
568 a case they must go in <em>non-free</em>.</p>
571 Packages whose copyright permission notices (or patent
572 problems) do not even allow redistribution of binaries
573 only, and where no special permission has been obtained,
574 must not be placed on the Debian FTP site and its mirrors
578 Note that under international copyright law (this applies
579 in the United States, too), <em>no</em> distribution or
580 modification of a work is allowed without an explicit
581 notice saying so. Therefore a program without a copyright
582 notice <em>is</em> copyrighted and you may not do anything
583 to it without risking being sued! Likewise if a program
584 has a copyright notice but no statement saying what is
585 permitted then nothing is permitted.</p>
588 Many authors are unaware of the problems that restrictive
589 copyrights (or lack of copyright notices) can cause for
590 the users of their supposedly-free software. It is often
591 worthwhile contacting such authors diplomatically to ask
592 them to modify their license terms. However, this can be a
593 politically difficult thing to do and you should ask for
594 advice on the <tt>debian-legal</tt> mailing list first, as
599 When in doubt about a copyright, send mail to
600 <email>debian-legal@lists.debian.org</email>. Be prepared
601 to provide us with the copyright statement. Software
602 covered by the GPL, public domain software and BSD-like
603 copyrights are safe; be wary of the phrases "commercial
604 use prohibited" and "distribution restricted".
608 <heading>Subsections</heading>
611 The packages in the sections <em>main</em>,
612 <em>contrib</em> and <em>non-free</em> are grouped further
613 into <em>subsections</em> to simplify handling.
617 The section and subsection for each package should be
618 specified in the package's <tt>Section</tt> control
619 record. However, the maintainer of the Debian archive
620 may override this selection to ensure the consistency of
621 the Debian distribution. The <tt>Section</tt> field
622 should be of the form:
623 <list compact="compact">
625 <em>subsection</em> if the package is in the
626 <em>main</em> section,
629 <em>section/subsection</em> if the package is in
630 the <em>contrib</em> or <em>non-free</em> section,
634 <tt>non-US</tt>, <tt>non-US/contrib</tt> or
635 <tt>non-US/non-free</tt> if the package is in
636 <em>non-US/main</em>, <em>non-US/contrib</em> or
637 <em>non-US/non-free</em> respectively.
643 The Debian archive maintainers provide the authoritative
644 list of subsections. At present, they are:
645 <em>admin</em>, <em>base</em>, <em>comm</em>,
646 <em>contrib</em>, <em>devel</em>, <em>doc</em>,
647 <em>editors</em>, <em>electronics</em>, <em>games</em>,
648 <em>graphics</em>, <em>hamradio</em>,
649 <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
650 <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
651 <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
652 <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
653 <em>sound</em>, <em>tex</em>, <em>text</em>,
654 <em>utils</em>, <em>web</em>, <em>x11</em>.
658 <heading>Priorities</heading>
661 Each package should have a <em>priority</em> value, which is
662 included in the package's <em>control record</em>. This
663 information is used by the Debian package management tools
664 to separate high-priority packages from less-important
668 The following <em>priority levels</em> are recognised by the
669 Debian package management tools.
671 <tag><tt>required</tt></tag>
673 Packages which are necessary for the proper
674 functioning of the system. You must not remove these
675 packages or your system may become totally broken and
676 you may not even be able to use <prgn>dpkg</prgn> to
677 put things back. Systems with only the
678 <tt>required</tt> packages are probably unusable, but
679 they do have enough functionality to allow the
680 sysadmin to boot and install more software.
682 <tag><tt>important</tt></tag>
684 Important programs, including those which one would
685 expect to find on any Unix-like system. If the
686 expectation is that an experienced Unix person who
687 found it missing would say "What on earth is going on,
688 where is <prgn>foo</prgn>?", it must be an
689 <tt>important</tt> package.<footnote>
690 This is an important criterion because we are
691 trying to produce, amongst other things, a free
694 Other packages without which the system will not run
695 well or be usable must also have priority
696 <tt>important</tt>. This does
697 <em>not</em> include Emacs, the X Window System, TeX
698 or any other large applications. The
699 <tt>important</tt> packages are just a bare minimum of
700 commonly-expected and necessary tools.
702 <tag><tt>standard</tt></tag>
704 These packages provide a reasonably small but not too
705 limited character-mode system. This is what will be
706 installed by default if the user doesn't select anything
707 else. It doesn't include many large applications.
709 <tag><tt>optional</tt></tag>
711 (In a sense everything that isn't required is
712 optional, but that's not what is meant here.) This is
713 all the software that you might reasonably want to
714 install if you didn't know what it was and don't have
715 specialized requirements. This is a much larger system
716 and includes the X Window System, a full TeX
717 distribution, and many applications. Note that
718 optional packages should not conflict with each other.
720 <tag><tt>extra</tt></tag>
722 This contains all packages that conflict with others
723 with required, important, standard or optional
724 priorities, or are only likely to be useful if you
725 already know what they are or have specialised
732 Packages must not depend on packages with lower priority
733 values (excluding build-time dependencies). In order to
734 ensure this, the priorities of one or more packages may need
740 <heading>Binary packages</heading>
743 The Debian GNU/Linux distribution is based on the Debian
744 package management system, called <prgn>dpkg</prgn>. Thus,
745 all packages in the Debian distribution must be provided
746 in the <tt>.deb</tt> file format.</p>
750 <heading>The package name</heading>
753 Every package must have a name that's unique within the Debian
757 Package names must consist only of lower case letters
758 (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
759 and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
760 They must be at least two characters long and must start
761 with an alphanumeric character.
765 The package name is part of the file name of the
766 <tt>.deb</tt> file and is included in the control field
772 <heading>The maintainer of a package</heading>
774 Every package must have a Debian maintainer (the
775 maintainer may be one person or a group of people
776 reachable from a common email address, such as a mailing
777 list). The maintainer is responsible for ensuring that
778 the package is placed in the appropriate distributions.
782 The maintainer must be specified in the
783 <tt>Maintainer</tt> control field with their correct name
784 and a working email address. If one person maintains
785 several packages, he/she should try to avoid having
786 different forms of their name and email address in
787 the <tt>Maintainer</tt> fields of those packages.
791 If the maintainer of a package quits from the Debian
792 project, "Debian QA Group"
793 <email>packages@qa.debian.org</email> takes over the
794 maintainership of the package until someone else
795 volunteers for that task. These packages are called
796 <em>orphaned packages</em>.<footnote>
798 The detailed procedure for doing this gracefully can
799 be found in the Debian Developer's Reference, either
800 in the <tt>developers-reference</tt> package, or on
801 the Debian FTP server
802 <ftpsite>ftp.debian.org</ftpsite> as
803 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
805 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
806 name="Debian Developer's Reference"> webpage.
814 <heading>The description of a package</heading>
817 Every Debian package must have an extended description
818 stored in the appropriate field of the control record.</p>
821 The description should be written so that it gives the
822 system administrator enough information to decide whether
823 to install the package. This description should not just
824 be copied verbatim from the program's documentation.
825 Instructions for configuring or using the package should
826 not be included (that is what installation scripts,
827 manual pages, info files, etc., are for). Copyright
828 statements and other administrivia should not be included
829 either (that is what the copyright file is for).
833 Please refer to <ref id="descriptions"> for more information.
840 <heading>Dependencies</heading>
843 Every package must specify the dependency information
844 about other packages that are required for the first to
848 For example, a dependency entry must be provided for any
849 shared libraries required by a dynamically-linked executable
850 binary in a package.</p>
853 Packages are not required to declare any dependencies they
854 have on other packages which are marked <tt>Essential</tt>
855 (see below), and should not do so unless they depend on a
856 particular version of that package.</p>
859 Sometimes, a package requires another package to be installed
860 <em>and</em> configured before it can be installed. In this
861 case, you must specify a <tt>Pre-Depends</tt> entry for
865 You should not specify a <tt>Pre-Depends</tt> entry for a
866 package before this has been discussed on the
867 <tt>debian-devel</tt> mailing list and a consensus about
868 doing that has been reached.</p></sect1>
871 <sect1 id="virtual_pkg">
872 <heading>Virtual packages</heading>
875 Sometimes, there are several packages which offer
876 more-or-less the same functionality. In this case, it's
877 useful to define a <em>virtual package</em> whose name
878 describes that common functionality. (The virtual
879 packages only exist logically, not physically; that's why
880 they are called <em>virtual</em>.) The packages with this
881 particular function will then <em>provide</em> the virtual
882 package. Thus, any other package requiring that function
883 can simply depend on the virtual package without having to
884 specify all possible packages individually.</p>
887 All packages should use virtual package names where
888 appropriate, and arrange to create new ones if necessary.
889 They should not use virtual package names (except privately,
890 amongst a cooperating group of packages) unless they have
891 been agreed upon and appear in the list of virtual package
892 names. (See also <ref id="virtual">)</p>
895 The latest version of the authoritative list of virtual
896 package names can be found in the <tt>debian-policy</tt> package.
897 It's also available from the Debian web mirrors at
898 <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
899 id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>
900 and from the Debian archive mirrors at
901 <tt><url name="/doc/package-developer/virtual-package-names-list.txt"
902 id="http://ftp.debian.org/debian/doc/package-developer/virtual-package-names-list.txt"></tt>.
906 The procedure for updating the list is described in the preface
913 <heading>Base system</heading>
916 The <tt>base system</tt> is a minimum subset of the Debian
917 GNU/Linux system that is installed before everything else
918 on a new system. Thus, only very few packages are allowed
919 to go into the <tt>base</tt> section to keep the required
920 disk usage very small.</p>
923 Most of these packages will have the priority value
924 <tt>required</tt> or at least <tt>important</tt>, and many
925 of them will be tagged <tt>essential</tt> (see below).</p>
932 <heading>Essential packages</heading>
935 Some packages are tagged <tt>essential</tt>. (They have
936 <tt>Essential: yes</tt> in their package control record.)
937 This flag is used for packages that are <em>essential</em>
941 Since these packages cannot be easily removed (one has to
942 specify an extra <em>force option</em> to
943 <prgn>dpkg</prgn> to do so), this flag must not be used
944 unless absolutely necessary. A shared library package
945 must not be tagged <tt>essential</tt>; dependencies will
946 prevent its premature removal, and we need to be able to
947 remove it when it has been superseded.
951 Since dpkg will not prevent upgrading of other packages
952 while an <tt>essential</tt> package is in an unconfigured
953 state, all <tt>essential</tt> packages must supply all of
954 their core functionality even when unconfigured. If the
955 package cannot satisfy this requirement it must not be
956 tagged as essential, and any packages depending on this
957 package must instead have explicit dependency fields as
962 You must not tag any packages <tt>essential</tt> before
963 this has been discussed on the <tt>debian-devel</tt>
964 mailing list and a consensus about doing that has been
969 <heading>Tasks</heading>
972 The Debian install process allows the user to choose from
973 a number of common tasks which a Debian system can be used to
974 perform. Selecting a task with <prgn>tasksel</prgn> causes
975 a set of packages that are useful in performing that task to be
980 This set of packages is all available packages which have the
981 name of the selected task in the <tt>Task</tt> field of their
982 control file. The format of this field is a list of tasks,
987 You should not tag any packages as belonging to a task
988 before this has been discussed on the
989 <em>debian-devel</em> mailing list and a consensus about
990 doing that has been reached.
994 For third parties (and historical reasons), tasksel also
995 supports constructing tasks based on <em>task
996 packages</em>. These are packages whose names begin with
997 <em>task-</em>. Task packages should not be included in the
1002 <sect1 id="maintscripts">
1003 <heading>Maintainer Scripts</heading>
1006 The package installation scripts should avoid producing
1007 output which it is unnecessary for the user to see and
1008 should rely on <prgn>dpkg</prgn> to stave off boredom on
1009 the part of a user installing many packages. This means,
1010 amongst other things, using the <tt>--quiet</tt> option on
1011 <prgn>install-info</prgn>.</p>
1014 Errors which occur during the execution of an installation
1015 script must be checked and the installation must not
1016 continue after an error.
1020 Note that in general <ref id="scripts"> applies to package
1021 maintainer scripts, too.
1025 You should not use <prgn>dpkg-divert</prgn> on a file
1026 belonging to another package without consulting the
1027 maintainer of that package first.
1031 All packages which supply an instance of a common command
1032 name (or, in general, filename) should generally use
1033 <prgn>update-alternatives</prgn>, so that they may be
1034 installed together. If <prgn>update-alternatives</prgn>
1035 is not used, then each package must use
1036 <tt>Conflicts</tt> to ensure that other packages are
1037 de-installed. (In this case, it may be appropriate to
1038 specify a conflict against earlier versions of something
1039 that previously did not use
1040 <prgn>update-alternatives</prgn>; this is an exception to
1041 the usual rule that versioned conflicts should be
1047 <heading>Prompting in maintainer scripts</heading>
1049 Package maintainer scripts may prompt the user if
1050 necessary. Prompting may be accomplished by
1052 <p>From the Jasrgon file: by hand 2. By extension,
1053 writing code which does something in an explicit or
1054 low-level way for which a presupplied library
1055 (<em>debconf, in this instance</em>) routine ought
1056 to have been available.</p>
1057 </footnote> (but this is deprecated), or by
1058 communicating though a program, which conforms to the
1059 Debian Configuration management specification, version 2
1060 or higher (such as <prgn>debconf</prgn>). Thiss
1061 specification is included in the
1062 <file>debconf_specification</file> files in the
1063 <package>debian-policy</package> package. You may also
1064 find this file on the FTP site
1065 <ftpsite>ftp.debian.org</ftpsite> in
1066 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1067 or on your local mirror.<footnote>
1069 6% of Debian packages [see <url
1070 id="http://auric.debian.org/%7Ejoeyh/debconf-stats/data/"
1071 name="Debconf stats">] currently use
1072 <package>debconf</package> to prompt the user at
1073 install time, and this number is growing daily. The
1074 benefits of using debconf are briefly explained at
1076 id="http://kitenet.net/doc/debconf-doc/introduction.html"
1077 name="Debconf introduction">; they include
1078 preconfiguration, (mostly) noninteractive
1079 installation, elimination of redundant prompting,
1080 consistency of user interface, etc.
1084 With this increasing number of packages using
1085 <package>debconf</package>, plus the existance of a
1086 nascent second implementation of the Debian
1087 configuration management system
1088 (<package>cdebconf</package>), and the stabilization
1089 of the protocol these things use, the time has
1090 finally come to reflect the use of these things in
1097 Packages which use the Debian Configuration management
1098 specification may contain an additional
1099 <prgn>config</prgn> script and a <tt>templates</tt>
1100 file in their control archive. The <prgn>config</prgn>
1101 script might be run before the <prgn>preinst</prgn>
1102 script, and before the package is unpacked or any of its
1103 dependencies or pre-dependancies are satisfied.
1104 Therefore it must work using only the tools present in
1105 <em>essential</em> packages.<footnote>
1107 <package>Debconf</package> or another tool that
1108 implements the Debian Configuration management
1109 specification will also be installed, and any
1110 versioned dependencies on it will be satisfied
1111 before preconfiguration begins.
1117 Packages should try to minimize the amount of prompting
1118 they need to do, and they should ensure that the user
1119 will only ever be asked each question once. This means
1120 that packages should try to use appropriate shared
1121 configuration files (such as <file>/etc/papersize</file> and
1122 <file>/etc/news/server</file>), and shared
1123 <package>debconf</package> variables rather than each
1124 prompting for their own list of required pieces of
1129 It also means that an upgrade should not ask the same
1130 questions again, unless the user has used <tt>dpkg
1131 --purge</tt> to remove the package's configuration. The
1132 answers to configuration questions should be stored in an
1133 appropriate place in <file>/etc</file> so that the user can
1134 modify them, and how this has been done should be
1138 If a package has a vitally important piece of
1139 information to pass to the user (such as "don't run me
1140 as I am, you must edit the following configuration files
1141 first or you risk your system emitting badly-formatted
1142 messages"), it should display this in the
1143 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1144 prompt the user to hit return to acknowledge the
1145 message. Copyright messages do not count as vitally
1146 important (they belong in
1147 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1148 neither do instructions on how to use a program (these
1149 should be in on-line documentation, where all the users
1153 Any necessary prompting should almost always be confined
1154 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1155 script. If it is done in the <prgn>postinst</prgn>, it
1156 should be protected with a conditional so that
1157 unnecessary prompting doesn't happen if a package's
1158 installation fails and the <prgn>postinst</prgn> is
1159 called with <tt>abort-upgrade</tt>,
1160 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1165 <heading>Source packages</heading>
1167 <sect1 id="standardsversion">
1168 <heading>Standards conformance</heading>
1171 In the source package's <tt>Standards-Version</tt> control
1172 field, you should specify the most recent version number
1173 of this policy document with which your package complied
1174 when it was last updated. The current version number is
1179 This information may be used to file bug reports
1180 automatically if your package becomes too much out of
1185 The version number has four components: major and minor
1186 version number and major and minor patch level. When the
1187 standards change in a way that requires every package to
1188 change the major number will be changed. Significant
1189 changes that will require work in many packages will be
1190 signaled by a change to the minor number. The major patch
1191 level will be changed for any change to the meaning of the
1192 standards, however small; the minor patch level will be
1193 changed when only cosmetic, typographical or other edits
1194 are made which neither change the meaning of the document
1195 nor affect the contents of packages.</p>
1198 Thus only the first three components of the policy version
1199 are significant in the <em>Standards-Version</em> control
1200 field, and so either these three components or the all
1201 four components may be specified.<footnote>
1203 In the past, people specified the full version number
1204 in the Standards-Version field, for example "2.3.0.0".
1205 Since minor patch-level changes don't introduce new
1206 policy, it was thought it would be better to relax
1207 policy and only require the first 3 components to be
1208 specified, in this example "2.3.0". All four
1209 components may still be used if someone wishes to do
1216 You should regularly, and especially if your package has
1217 become out of date, check for the newest Policy Manual
1218 available and update your package, if necessary. When your
1219 package complies with the new standards you should update the
1220 <tt>Standards-Version</tt> source package field and
1221 release it.<footnote>
1223 See the file <file>upgrading-checklist</file> for
1224 information about policy which has changed between
1225 different versions of this document.
1232 <sect1 id="pkg-relations">
1233 <heading>Package relationships</heading>
1236 Source packages should specify which binary packages they
1237 require to be installed or not to be installed in order to
1238 build correctly. For example, if building a package
1239 requires a certain compiler, then the compiler should be
1240 specified as a build-time dependency.
1244 It is not necessary to explicitly specify build-time
1245 relationships on a minimal set of packages that are always
1246 needed to compile, link and put in a Debian package a
1247 standard "Hello World!" program written in C or C++. The
1248 required packages are called <em>build-essential</em>, and
1249 an informational list can be found in
1250 <file>/usr/share/doc/build-essential/list</file> (which is
1251 contained in the <tt>build-essential</tt>
1254 <list compact="compact">
1256 This allows maintaining the list separately
1257 from the policy documents (the list does not
1258 need the kind of control that the policy
1262 Having a separate package allows one to install
1263 the build-essential packages on a machine, as
1264 well as allowing other packages such as tasks to
1265 require installation of the build-essential
1266 packages using the depends relation.
1269 The separate package allows bug reports against
1270 the list to be categorized separately from
1271 the policy management process in the BTS.
1280 When specifying the set of build-time dependencies, one
1281 should list only those packages explicitly required by the
1282 build. It is not necessary to list packages which are
1283 required merely because some other package in the list of
1284 build-time dependencies depends on them.<footnote>
1286 The reason for this is that dependencies change, and
1287 you should list all those packages, and <em>only</em>
1288 those packages that <em>you</em> need directly. What
1289 others need is their business. For example, if you
1290 only link against <file>libimlib</file>, you will need to
1291 build-depend on <package>libimlib2-dev</package> but
1292 not against any <tt>libjpeg*</tt> packages, even
1293 though <tt>libimlib2-dev</tt> currently depends on
1294 them: installation of <package>libimlib2-dev</package>
1295 will automatically ensure that all of its run-time
1296 dependencies are satisfied.
1302 If build-time dependencies are specified, it must be
1303 possible to build the package and produce working binaries
1304 on a system with only essential and build-essential
1305 packages installed and also those required to satisfy the
1306 build-time relationships (including any implied
1307 relationships). In particular, this means that version
1308 clauses should be used rigorously in build-time
1309 relationships so that one cannot produce bad or
1310 inconsistently configured packages when the relationships
1311 are properly satisfied.
1315 <ref id="relationships"> explains the technical details.
1319 <heading>Changes to the upstream sources</heading>
1322 If changes to the source code are made that are not
1323 specific to the needs of the Debian system, they should be
1324 sent to the upstream authors in whatever form they prefer
1325 so as to be included in the upstream version of the
1329 If you need to configure the package differently for
1330 Debian or for Linux, and the upstream source doesn't
1331 provide a way to do so, you should add such configuration
1332 facilities (for example, a new <prgn>autoconf</prgn> test
1333 or <tt>#define</tt>) and send the patch to the upstream
1334 authors, with the default set to the way they originally
1335 had it. You can then easily override the default in your
1336 <file>debian/rules</file> or wherever is appropriate.</p>
1339 You should make sure that the <prgn>configure</prgn> utility
1340 detects the correct architecture specification string
1341 (refer to <ref id="arch-spec"> for details).</p>
1344 If you need to edit a <prgn>Makefile</prgn> where
1345 GNU-style <prgn>configure</prgn> scripts are used, you
1346 should edit the <file>.in</file> files rather than editing the
1347 <prgn>Makefile</prgn> directly. This allows the user to
1348 reconfigure the package if necessary. You should
1349 <em>not</em> configure the package and edit the generated
1350 <prgn>Makefile</prgn>! This makes it impossible for
1351 someone else to later reconfigure the package.</p>
1354 You should document your changes and updates to the source
1355 package properly in the <file>debian/changelog</file> file.
1356 For more information, please see <ref id="changelogs">.
1362 <heading>Error trapping in makefiles</heading>
1365 When <prgn>make</prgn> invokes a command in a makefile
1366 (including your package's upstream makefiles and
1367 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1368 means that <prgn>sh</prgn>'s usual bad error handling
1369 properties apply: if you include a miniature script as one
1370 of the commands in your makefile you'll find that if you
1371 don't do anything about it then errors are not detected
1372 and <prgn>make</prgn> will blithely continue after
1376 Every time you put more than one shell command (this
1377 includes using a loop) in a makefile command you
1378 must make sure that errors are trapped. For
1379 simple compound commands, such as changing directory and
1380 then running a program, using <tt>&&</tt> rather
1381 than semicolon as a command separator is sufficient. For
1382 more complex commands including most loops and
1383 conditionals you should include a separate <tt>set -e</tt>
1384 command at the start of every makefile command that's
1385 actually one of these miniature shell scripts.</p></sect1>
1389 <heading>Obsolete constructs and libraries</heading>
1392 The include file <tt><varargs.h></tt> is
1393 provided to support end-users compiling very old software;
1394 the library <tt>libtermcap</tt> is provided to support the
1395 execution of software which has been linked against it
1396 (either old programs or those such as Netscape which are
1397 only available in binary form).</p>
1400 Debian packages should be patched to use
1401 <tt><stdarg.h></tt> and <tt>ncurses</tt>
1408 <chapt id="controlfields"><heading>Control files and their fields</heading>
1411 Many of the tools in the package management suite manipulate
1412 data represented in a common format, known as <em>control
1413 data</em>. The data is often stored in <em>control
1414 files</em>. Binary and source packages have control files,
1415 and the <file>.changes</file> files which control the installation
1416 of uploaded files are also in control file format.
1417 <prgn>dpkg</prgn>'s internal databases are in a similar
1421 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1424 A control file consists of one or more paragraphs of fields.
1425 The paragraphs are separated by blank lines. Some control
1426 files allow only one paragraph; others allow several, in
1427 which case each paragraph usually refers to a different
1428 package. (For example, in source packages, the first
1429 paragraph refers to the source package, and later paragraphs
1430 refer to binary packages generated from the source.)
1434 Each paragraph consists of a series of data fields; each
1435 field consists of the field name, followed by a colon and
1436 then the data/value associated with that field. It ends at
1437 the end of the line. Horizontal whitespace (spaces and
1438 tabs) may occur immediately before or after the value and is
1439 ignored there; it is conventional to put a single space
1440 after the colon. For example, a field might be:
1441 <example compact="compact">
1444 the field name is <tt>Package</tt> and the field value
1449 Some fields' values may span several lines; in this case
1450 each continuation line <em>must</em> start with a space or
1451 tab. Any trailing spaces or tabs at the end of individual
1452 lines of a field value are ignored.
1456 Except where otherwise stated only a single line of data is
1457 allowed and whitespace is not significant in a field body.
1458 Whitespace must not appear inside names (of packages,
1459 architectures, files or anything else) or version numbers,
1460 or between the characters of multi-character version
1465 Field names are not case-sensitive, but it is usual to
1466 capitalize the field names using mixed case as shown below.
1470 Blank lines, or lines consisting only of spaces and tabs,
1471 are not allowed within field values or between fields - that
1472 would mean a new paragraph.
1477 <sect><heading>List of fields</heading>
1479 This list here is not supposed to be exhaustive. Most fields
1480 are dealt with elsewhere in this document.
1482 <sect1 id="f-Package"><heading><tt>Package</tt>
1486 The name of the binary package. Package names consist of
1487 lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1488 plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1489 periods (<tt>.</tt>).
1493 They must be at least two characters long and must start
1494 with an alphanumeric character. The use of lowercase
1495 package names is required unless the package you're
1496 building (or referring to, in other fields) is already
1497 using uppercase characters.</p>
1500 <sect1 id="f-Version"><heading><tt>Version</tt>
1504 This lists the source or binary package's version number -
1505 see <ref id="versions">.
1511 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1515 The most recent version of the standards (the policy
1516 manual and associated texts) with which the package
1517 complies. This is updated manually when editing the
1518 source package to conform to newer standards; it can
1519 sometimes be used to tell when a package needs attention.
1520 Its format is described above; see
1521 <ref id="standardsversion">.
1526 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1530 In a <file>.changes</file> file or parsed changelog output
1531 this contains the (space-separated) name(s) of the
1532 distribution(s) where this version of the package should
1533 be installed. Valid distributions are determined by the
1534 archive maintainers.<footnote>
1535 Current distribution names are:
1536 <taglist compact="compact">
1537 <tag><em>stable</em></tag>
1539 This is the current "released" version of Debian
1540 GNU/Linux. Once the distribution is
1541 <em>stable</em> only security fixes and other
1542 major bug fixes are allowed. When changes are
1543 made to this distribution, the release number is
1544 increased (for example: 2.2r1 becomes 2.2r2 then
1548 <tag><em>unstable</em></tag>
1550 This distribution value refers to the
1551 <em>developmental</em> part of the Debian
1552 distribution tree. New packages, new upstream
1553 versions of packages and bug fixes go into the
1554 <em>unstable</em> directory tree. Download from
1555 this distribution at your own risk.
1558 <tag><em>testing</em></tag>
1560 This distribution value refers to the
1561 <em>testing</em> part of the Debian distribution
1562 tree. It receives its packages from the
1563 unstable distribution after a short time lag to
1564 ensure that there are no major issues with the
1565 unstable packages. It is less prone to breakage
1566 than unstable, but still risky. It is not
1567 possible to upload packages directly to
1571 <tag><em>frozen</em></tag>
1573 From time to time, the <em>testing</em>
1574 distribution enters a state of "code-freeze" in
1575 anticipation of release as a <em>stable</em>
1576 version. During this period of testing only
1577 fixes for existing or newly-discovered bugs will
1578 be allowed. The exact details of this stage are
1579 determined by the Release Manager.
1582 <tag><em>experimental</em></tag>
1584 The packages with this distribution value are
1585 deemed by their maintainers to be high
1586 risk. Oftentimes they represent early beta or
1587 developmental packages from various sources that
1588 the maintainers want people to try, but are not
1589 ready to be a part of the other parts of the
1590 Debian distribution tree. Download at your own
1595 You should list <em>all</em> distributions that the
1596 package should be installed into.
1606 <chapt id="versions"><heading>Version numbering</heading>
1609 Every package has a version number recorded in its
1610 <tt>Version</tt> control file field.
1614 The package management system imposes an ordering on version
1615 numbers, so that it can tell whether packages are being up- or
1616 downgraded and so that package system front end applications
1617 can tell whether a package it finds available is newer than
1618 the one installed on the system. The version number format
1619 has the most significant parts (as far as comparison is
1620 concerned) at the beginning.
1624 The version number format is:
1625 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1629 The three components here are:
1631 <tag><var>epoch</var></tag>
1634 This is a single (generally small) unsigned integer. It
1635 may be omitted, in which case zero is assumed. If it is
1636 omitted then the <var>upstream_version</var> may not
1641 It is provided to allow mistakes in the version numbers
1642 of older versions of a package, and also a package's
1643 previous version numbering schemes, to be left behind.
1647 <tag><var>upstream_version</var></tag>
1650 This is the main part of the version number. It is
1651 usually the version number of the original ("upstream")
1652 package from which the <file>.deb</file> file has been made,
1653 if this is applicable. Usually this will be in the same
1654 format as that specified by the upstream author(s);
1655 however, it may need to be reformatted to fit into the
1656 package management system's format and comparison
1661 The comparison behavior of the package management system
1662 with respect to the <var>upstream_version</var> is
1663 described below. The <var>upstream_version</var>
1664 portion of the version number is mandatory.
1668 The <var>upstream_version</var> may contain only
1669 alphanumerics<footnote>
1670 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1672 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1673 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1674 start with a digit. If there is no
1675 <var>debian_revision</var> then hyphens are not allowed;
1676 if there is no <var>epoch</var> then colons are not
1680 <tag><var>debian_revision</var></tag>
1683 This part of the version number specifies the version of
1684 the Debian package based on the upstream version. It
1685 may contain only alphanumerics and the characters
1686 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1687 compared in the same way as the
1688 <var>upstream_version</var> is.
1692 It is optional; if it isn't present then the
1693 <var>upstream_version</var> may not contain a hyphen.
1694 This format represents the case where a piece of
1695 software was written specifically to be turned into a
1696 Debian package, and so there is only one "debianization"
1697 of it and therefore no revision indication is required.
1701 It is conventional to restart the
1702 <var>debian_revision</var> at <tt>1</tt> each time the
1703 <var>upstream_version</var> is increased.
1707 The package management system will break the version
1708 number apart at the last hyphen in the string (if there
1709 is one) to determine the <var>upstream_version</var> and
1710 <var>debian_revision</var>. The absence of a
1711 <var>debian_revision</var> compares earlier than the
1712 presence of one (but note that the
1713 <var>debian_revision</var> is the least significant part
1714 of the version number).
1721 The <var>upstream_version</var> and <var>debian_revision</var>
1722 parts are compared by the package management system using the
1727 The strings are compared from left to right.
1731 First the initial part of each string consisting entirely of
1732 non-digit characters is determined. These two parts (one of
1733 which may be empty) are compared lexically. If a difference
1734 is found it is returned. The lexical comparison is a
1735 comparison of ASCII values modified so that all the letters
1736 sort earlier than all the non-letters.
1740 Then the initial part of the remainder of each string which
1741 consists entirely of digit characters is determined. The
1742 numerical values of these two parts are compared, and any
1743 difference found is returned as the result of the comparison.
1744 For these purposes an empty string (which can only occur at
1745 the end of one or both version strings being compared) counts
1750 These two steps (comparing and removing initial non-digit
1751 strings and initial digit strings) are repeated until a
1752 difference is found or both strings are exhausted.
1756 Note that the purpose of epochs is to allow us to leave behind
1757 mistakes in version numbering, and to cope with situations
1758 where the version numbering scheme changes. It is
1759 <em>not</em> intended to cope with version numbers containing
1760 strings of letters which the package management system cannot
1761 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1762 silly orderings (the author of this manual has heard of a
1763 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1764 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1765 <tt>2</tt> and so forth).
1769 If an upstream package has problematic version numbers they
1770 should be converted to a sane form for use in the
1771 <tt>Version</tt> field.
1775 <heading>Version numbers based on dates</heading>
1777 In general, Debian packages should use the same version
1778 numbers as the upstream sources.</p>
1781 However, in some cases where the upstream version number is
1782 based on a date (e.g., a development "snapshot" release) the
1783 package management system cannot handle these version
1784 numbers without epochs. For example, dpkg will consider
1785 "96May01" to be greater than "96Dec24".</p>
1788 To prevent having to use epochs for every new upstream
1789 version, the version number should be changed to the
1790 following format in such cases: "19960501", "19961224". It
1791 is up to the maintainer whether he/she wants to bother the
1792 upstream maintainer to change the version numbers upstream,
1796 Note that other version formats based on dates which are
1797 parsed correctly by the package management system should
1798 <em>not</em> be changed.</p>
1801 Native Debian packages (i.e., packages which have been
1802 written especially for Debian) whose version numbers include
1803 dates should always use the "YYYYMMDD" format.</p>
1807 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1809 <sect id="timestamps"><heading>Time Stamps</heading>
1811 Maintainers should preserve the modification times of the
1812 upstream source files in a package, as far as is reasonably
1815 The rationale is that there is some information conveyed
1816 by knowing the age of the file, for example, you could
1817 recognize that some documentation is very old by looking
1818 at the modification time, so it would be nice if the
1819 modification time of the upstream source would be
1826 <sect id="debianrules"><heading><file>debian/rules</file> - the
1827 main building script</heading>
1830 This file must be an executable makefile, and contains the
1831 package-specific recipes for compiling the package and
1832 building binary package(s) from the source.
1836 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1837 so that it can be invoked by saying its name rather than
1838 invoking <prgn>make</prgn> explicitly.
1842 Since an interactive <file>debian/rules</file> script makes it
1843 impossible to auto-compile that package and also makes it
1844 hard for other people to reproduce the same binary
1845 package, all <em>required targets</em> MUST be
1846 non-interactive. At a minimum, required targets are the
1847 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1848 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1849 <em>binary-indep</em>, and <em>build</em>. It also follows
1850 that any target that these targets depend on must also be
1855 The required and optional targets are as follows:
1857 <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1858 <tt>build-indep</tt> (optional)</tag>
1861 The <tt>build</tt> target should perform all
1862 non-interactive configuration and compilation of the
1863 package. If a package has an interactive pre-build
1864 configuration routine, the Debianized source package
1865 must either be built after this has taken place (so
1866 that the binary package can be built without rerunning
1867 the configuration) or the configuration routine
1868 modified to become non-interactive. (The latter is
1869 preferable if there are architecture-specific features
1870 detected by the configuration routine.)
1874 For some packages, notably ones where the same
1875 source tree is compiled in different ways to produce
1876 two binary packages, the <tt>build</tt> target
1877 does not make much sense. For these packages it is
1878 good enough to provide two (or more) targets
1879 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1880 for each of the ways of building the package, and a
1881 <tt>build</tt> target that does nothing. The
1882 <tt>binary</tt> target will have to build the
1883 package in each of the possible ways and make the
1884 binary package out of each.
1888 The <tt>build</tt> target must not do anything
1889 that might require root privilege.
1893 The <tt>build</tt> target may need to run the
1894 <tt>clean</tt> target first - see below.
1898 When a package has a configuration and build routine
1899 which takes a long time, or when the makefiles are
1900 poorly designed, or when <tt>build</tt> needs to
1901 run <tt>clean</tt> first, it is a good idea to
1902 <tt>touch build</tt> when the build process is
1903 complete. This will ensure that if <tt>debian/rules
1904 build</tt> is run again it will not rebuild the whole
1907 Another common way to do this is for <tt>build</tt>
1908 to depend on <prgn>build-stamp</prgn> and to do
1909 nothing else, and for the <prgn>build-stamp</prgn>
1910 target to do the building and to <tt>touch
1911 build-stamp</tt> on completion. This is
1912 especially useful if the build routine creates a
1913 file or directory called <tt>build</tt>; in such a
1914 case, <tt>build</tt> will need to be listed as
1915 a phony target (i.e., as a dependency of the
1916 <tt>.PHONY</tt> target). See the documentation of
1917 <prgn>make</prgn> for more information on phony
1924 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1925 <tt>binary-indep</tt>
1929 The <tt>binary</tt> target must be all that is
1930 necessary for the user to build the binary package(s)
1931 produced from this source package. All of these
1932 targets are required to be non-interactive. It is
1933 split into two parts: <prgn>binary-arch</prgn> builds
1934 the binary packages which are specific to a particular
1935 architecture, and <tt>binary-indep</tt> builds
1936 those which are not.
1939 <tt>binary</tt> may be (and commonly is) a target with
1940 no commands which simply depends on
1941 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
1944 Both <tt>binary-*</tt> targets should depend on the
1945 <tt>build</tt> target, or on the appropriate
1946 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
1947 provided, so that the package is built if it has not
1948 been already. It should then create the relevant
1949 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
1950 make their control files and <prgn>dpkg-deb</prgn> to
1951 build them and place them in the parent of the top
1956 Both the <tt>binary-arch</tt> and
1957 <tt>binary-indep</tt> targets <em>must</em> exist.
1958 If one of them has nothing to do (which will always be
1959 the case if the source generates only a single binary
1960 package, whether architecture-dependent or not), it
1961 must still exist and must always succeed.
1965 The <tt>binary</tt> targets must be invoked as
1968 The <prgn>fakeroot</prgn> package often allows one
1969 to build a package correctly even without being
1976 <tag><tt>clean</tt></tag>
1979 This must undo any effects that the <tt>build</tt>
1980 and <tt>binary</tt> targets may have had, except
1981 that it should leave alone any output files created in
1982 the parent directory by a run of a <tt>binary</tt>
1983 target. This target must be non-interactive.
1987 If a <tt>build</tt> file is touched at the end of
1988 the <tt>build</tt> target, as suggested above, it
1989 should be removed as the first action that
1990 <tt>clean</tt> performs, so that running
1991 <tt>build</tt> again after an interrupted
1992 <tt>clean</tt> doesn't think that everything is
1997 The <tt>clean</tt> target may need to be
1998 invoked as root if <tt>binary</tt> has been
1999 invoked since the last <tt>clean</tt>, or if
2000 <tt>build</tt> has been invoked as root (since
2001 <tt>build</tt> may create directories, for
2006 <tag><tt>get-orig-source</tt> (optional)</tag>
2009 This target fetches the most recent version of the
2010 original source package from a canonical archive site
2011 (via FTP or WWW, for example), does any necessary
2012 rearrangement to turn it into the original source
2013 tar file format described below, and leaves it in the
2018 This target may be invoked in any directory, and
2019 should take care to clean up any temporary files it
2024 This target is optional, but providing it if
2025 possible is a good idea.
2031 The <tt>build</tt>, <tt>binary</tt> and
2032 <tt>clean</tt> targets must be invoked with the current
2033 directory being the package's top-level directory.
2038 Additional targets may exist in <file>debian/rules</file>,
2039 either as published or undocumented interfaces or for the
2040 package's internal use.
2044 The architectures we build on and build for are determined
2045 by <prgn>make</prgn> variables using the utility
2046 <qref id="pkg-dpkgarch"><prgn>dpkg-architecture</prgn></qref>.
2047 You can determine the
2048 Debian architecture and the GNU style architecture
2049 specification string for the build machine (the machine type
2050 we are building on) as well as for the host machine (the
2051 machine type we are building for). Here is a list of
2052 supported <prgn>make</prgn> variables:
2053 <list compact="compact">
2055 <tt>DEB_*_ARCH</tt> (the Debian architecture)
2058 <tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2059 specification string)
2062 <tt>DEB_*_GNU_CPU</tt> (the CPU part of
2063 <tt>DEB_*_GNU_TYPE</tt>)
2066 <tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2067 <tt>DEB_*_GNU_TYPE</tt>)
2069 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2070 the build machine or <tt>HOST</tt> for specification of the
2075 Backward compatibility can be provided in the rules file
2076 by setting the needed variables to suitable default
2077 values; please refer to the documentation of
2078 <prgn>dpkg-architecture</prgn> for details.
2082 It is important to understand that the <tt>DEB_*_ARCH</tt>
2083 string only determines which Debian architecture we are
2084 building on or for. It should not be used to get the CPU
2085 or system information; the GNU style variables should be
2090 <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2094 This file records the changes to the Debian-specific parts of the
2097 Though there is nothing stopping an author who is also
2098 the Debian maintainer from using it for all their
2099 changes, it will have to be renamed if the Debian and
2100 upstream maintainers become different people. In such a
2101 case, however, it might be better to maintain the
2102 package as a non-native package.
2108 It has a special format which allows the package building
2109 tools to discover which version of the package is being
2110 built and find out other release-specific information.
2114 That format is a series of entries like this:
2115 <example compact="compact">
2116 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2118 <p>[optional blank line(s), stripped]</p>
2120 * <var>change details</var>
2121 <var>more change details</var>
2123 <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2125 * <var>even more change details</var>
2127 <p>[optional blank line(s), stripped]</p>
2129 -- <var>maintainer name</var> <<var>email
2130 address</var>><var>[two spaces]</var> <var>date</var>
2135 <var>package</var> and <var>version</var> are the source
2136 package name and version number.
2140 <var>distribution(s)</var> lists the distributions where
2141 this version should be installed when it is uploaded - it
2142 is copied to the <tt>Distribution</tt> field in the
2143 <file>.changes</file> file. See <ref id="f-Distribution">.
2147 <var>urgency</var> is the value for the <tt>Urgency</tt>
2148 field in the <file>.changes</file> file for the upload. It is
2149 not possible to specify an urgency containing commas; commas
2150 are used to separate
2151 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2152 <prgn>dpkg</prgn> changelog format (though there is
2153 currently only one useful <var>keyword</var>,
2154 <tt>urgency</tt>).<footnote>
2156 Recognised urgency values are <tt>low</tt>,
2157 <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2158 They have an effect on how quickly a package will be
2159 considered for inclusion into the <tt>testing</tt>
2160 distribution, and give an indication of the importance
2161 of any fixes included in this upload.
2167 The change details may in fact be any series of lines
2168 starting with at least two spaces, but conventionally each
2169 change starts with an asterisk and a separating space and
2170 continuation lines are indented so as to bring them in
2171 line with the start of the text above. Blank lines may be
2172 used here to separate groups of changes, if desired.
2176 If this upload resolves bugs recorded in the Bug Tracking
2177 System (BTS), they may be automatically closed on the
2178 inclusion of this package into the Debian archive by
2179 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2180 in the change details.<footnote>
2182 To be precise, the string should match the following
2183 Perl regular expression:
2185 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2187 Then all of the bug numbers listed will be closed by the
2188 archive maintenance script (<prgn>katie</prgn>), or in
2189 the case of an NMU, marked as fixed.
2195 The maintainer name and email address used in the changelog
2196 should be the details of the person uploading <em>this</em>
2197 version. They are <em>not</em> necessarily those of the
2198 usual package maintainer. The information here will be
2199 copied to the <tt>Changed-By</tt> field in the
2200 <tt>.changes</tt> file, and then later used to send an
2201 acknowledgement when the upload has been installed.
2205 The <var>date</var> should be in RFC822 format<footnote>
2207 This is generated by the <prgn>822-date</prgn>
2210 </footnote>; it should include the time zone specified
2211 numerically, with the time zone name or abbreviation
2212 optionally present as a comment in parentheses.
2216 The first "title" line with the package name should start
2217 at the left hand margin; the "trailer" line with the
2218 maintainer and date details should be preceded by exactly
2219 one space. The maintainer details and the date must be
2220 separated by exactly two spaces.
2223 <sect1><heading>Defining alternative changelog formats</heading>
2226 It is possible to use a different format to the standard
2227 one, by providing a parser for the format you wish to
2231 A changelog parser must not interact with the user at
2237 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
2239 <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2240 and variable substitutions </heading>
2243 When <prgn>dpkg-gencontrol</prgn>,
2244 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2245 generate control files they perform variable substitutions
2246 on their output just before writing it. Variable
2247 substitutions have the form <tt>${<var>variable</var>}</tt>.
2248 The optional file <file>debian/substvars</file> contains
2249 variable substitutions to be used; variables can also be set
2250 directly from <file>debian/rules</file> using the <tt>-V</tt>
2251 option to the source packaging commands, and certain
2252 predefined variables are also available.
2256 The <file>debian/substvars</file> file is usually generated and
2257 modified dynamically by <file>debian/rules</file> targets, in
2258 which case it must be removed by the <tt>clean</tt> target.
2262 See <manref name="dpkg-source" section="1"> for full
2263 details about source variable substitutions, including the
2264 format of <file>debian/substvars</file>.</p>
2267 <sect id="debianfiles"><heading><file>debian/files</file>
2271 This file is not a permanent part of the source tree; it
2272 is used while building packages to record which files are
2273 being generated. <prgn>dpkg-genchanges</prgn> uses it
2274 when it generates a <file>.changes</file> file.
2278 It should not exist in a shipped source package, and so it
2279 (and any backup files or temporary files such as
2280 <file>files.new</file><footnote>
2282 <file>files.new</file> is used as a temporary file by
2283 <prgn>dpkg-gencontrol</prgn> and
2284 <prgn>dpkg-distaddfile</prgn> - they write a new
2285 version of <tt>files</tt> here before renaming it,
2286 to avoid leaving a corrupted copy if an error
2289 </footnote>) should be removed by the
2290 <tt>clean</tt> target. It may also be wise to
2291 ensure a fresh start by emptying or removing it at the
2292 start of the <tt>binary</tt> target.
2296 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2297 package, it adds an entry to <file>debian/files</file> for the
2298 <file>.deb</file> file that will be created when <tt>dpkg-deb
2299 --build</tt> is run for that binary package. So for most
2300 packages all that needs to be done with this file is to
2301 delete it in the <tt>clean</tt> target.
2305 If a package upload includes files besides the source
2306 package and any binary packages whose control files were
2307 made with <prgn>dpkg-gencontrol</prgn> then they should be
2308 placed in the parent of the package's top-level directory
2309 and <prgn>dpkg-distaddfile</prgn> should be called to add
2310 the file to the list in <file>debian/files</file>.</p>
2313 <sect id="restrictions"><heading>Restrictions on objects in source packages
2317 The source package may not contain any hard links<footnote>
2319 This is not currently detected when building source
2320 packages, but only when extracting
2324 Hard links may be permitted at some point in the
2325 future, but would require a fair amount of
2328 </footnote>, device special files, sockets or setuid or
2329 setgid files.<footnote>
2331 Setgid directories are allowed.
2337 <sect id="descriptions"><heading>Descriptions of packages - the
2338 <tt>Description</tt> field</heading>
2341 The "Description" control file field consists of two parts,
2342 the synopsis or the short description, and the long description.
2343 The field's format is as follows:
2347 Description: <single line synopsis>
2348 <extended description over several lines>
2352 The description is intended to describe the program to a user
2353 who has never met it before so that they know whether they
2354 want to install it. It should also give information about the
2355 significant dependencies and conflicts between this package
2356 and others, so that the user knows why these dependencies and
2357 conflicts have been declared.
2361 Put important information first, both in the synopsis and
2362 extended description. Sometimes only the first part of the
2363 synopsis or of the description will be displayed. You can
2364 assume that there will usually be a way to see the whole
2365 extended description.
2368 <sect1 id="synopsis"><heading>The single line synopsis</heading>
2371 The single line synopsis should be kept brief - certainly
2372 under 80 characters.
2376 Do not include the package name in the synopsis line. The
2377 display software knows how to display this already, and you
2378 do not need to state it. Remember that in many situations
2379 the user may only see the synopsis line - make it as
2380 informative as you can.
2385 <sect1 id="extendeddesc"><heading>The extended description</heading>
2388 Do not try to continue the single line synopsis into the
2389 extended description. This will not work correctly when
2390 the full description is displayed, and makes no sense
2391 where only the summary (the single line synopsis) is
2396 The extended description should describe what the package
2397 does and how it relates to the rest of the system (in terms
2398 of, for example, which subsystem it is which part of).
2402 The description field needs to make sense to anyone, even
2403 people who have no idea about any of the things the
2404 package deals with.<footnote>
2405 The blurb that comes with a program in its
2406 announcements and/or <prgn>README</prgn> files is
2407 rarely suitable for use in a description. It is
2408 usually aimed at people who are already in the
2409 community where the package is used.
2414 The lines in the extended description can have these formats:
2420 Those starting with a single space are part of a paragraph.
2421 Successive lines of this form will be word-wrapped when
2422 displayed. The leading space will usually be stripped off.
2426 Those starting with two or more spaces. These will be
2427 displayed verbatim. If the display cannot be panned
2428 horizontally, the displaying program will linewrap them "hard"
2429 (i.e., without taking account of word breaks). If it can they
2430 will be allowed to trail off to the right. None, one or two
2431 initial spaces may be deleted, but the number of spaces
2432 deleted from each line will be the same (so that you can have
2433 indenting work correctly, for example).
2437 Those containing a single space followed by a single full stop
2438 character. These are rendered as blank lines. This is the
2439 <em>only</em> way to get a blank line<footnote>
2440 Completely empty lines will not be rendered as blank lines.
2441 Instead, they will cause the parser to think you're starting
2442 a whole new record in the control file, and will therefore
2443 likely abort with an error.
2448 Those containing a space, a full stop and some more characters.
2449 These are for future expansion. Do not use them.
2455 Do not use tab characters. Their effect is not predictable.
2465 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2466 and installation procedure
2469 <sect><heading>Introduction to package maintainer scripts
2473 It is possible to supply scripts as part of a package which
2474 the package management system will run for you when your
2475 package is installed, upgraded or removed.
2479 These scripts are the files <prgn>preinst</prgn>,
2480 <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2481 control area of the package. They must be proper executable
2482 files; if they are scripts (which is recommended), they must
2483 start with the usual <tt>#!</tt> convention. They should be
2484 readable and executable by anyone, and not world-writable.
2488 The package management system looks at the exit status from
2489 these scripts. It is important that they exit with a
2490 non-zero status if there is an error, so that the package
2491 management system can stop its processing. For shell
2492 scripts this means that you <em>almost always</em> need to
2493 use <tt>set -e</tt> (this is usually true when writing shell
2494 scripts, in fact). It is also important, of course, that
2495 they don't exit with a non-zero status if everything went
2500 When a package is upgraded a combination of the scripts from
2501 the old and new packages is called during the upgrade
2502 procedure. If your scripts are going to be at all
2503 complicated you need to be aware of this, and may need to
2504 check the arguments to your scripts.
2508 Broadly speaking the <prgn>preinst</prgn> is called before
2509 (a particular version of) a package is installed, and the
2510 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2511 before (a version of) a package is removed and the
2512 <prgn>postrm</prgn> afterwards.
2516 Programs called from maintainer scripts should not normally
2517 have a path prepended to them. Before installation is
2518 started, the package management system checks to see if the
2519 programs <prgn>ldconfig</prgn>,
2520 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2521 and <prgn>update-rc.d</prgn> can be found via the
2522 <tt>PATH</tt> environment variable. Those programs, and any
2523 other program that one would expect to be on the
2524 <tt>PATH</tt>, should thus be invoked without an absolute
2525 pathname. Maintainer scripts should also not reset the
2526 <tt>PATH</tt>, though they might choose to modify it by
2527 prepending or appending package-specific directories. These
2528 considerations really apply to all shell scripts.</p>
2532 <heading>Maintainer scripts Idempotency</heading>
2535 It is necessary for the error recovery procedures that the
2536 scripts be idempotent. This means that if it is run
2537 successfully, and then it is called again, it doesn't bomb
2538 out or cause any harm, but just ensures that everything is
2539 the way it ought to be. If the first call failed, or
2540 aborted half way through for some reason, the second call
2541 should merely do the things that were left undone the first
2542 time, if any, and exit with a success status if everything
2545 This is so that if an error occurs, the user interrupts
2546 <prgn>dpkg</prgn> or some other unforeseen circumstance
2547 happens you don't leave the user with a badly-broken
2548 package when <prgn>dpkg</prgn> attempts to repeat the
2556 <heading>Controlling terminal for maintainer scripts</heading>
2559 The maintainer scripts are guaranteed to run with a
2560 controlling terminal and can interact with the user.
2561 If they need to prompt for passwords, do full-screen
2562 interaction or something similar you should do these
2563 things to and from <file>/dev/tty</file>, since
2564 <prgn>dpkg</prgn> will at some point redirect scripts'
2565 standard input and output so that it can log the
2566 installation process. Likewise, because these scripts
2567 may be executed with standard output redirected into a
2568 pipe for logging purposes, Perl scripts should set
2569 unbuffered output by setting <tt>$|=1</tt> so that the
2570 output is printed immediately rather than being
2575 Each script should return a zero exit status for
2576 success, or a nonzero one for failure.
2580 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2585 <list compact="compact">
2587 <var>new-preinst</var> <tt>install</tt>
2590 <var>new-preinst</var> <tt>install</tt> <var>old-version</var>
2593 <var>new-preinst</var> <tt>upgrade</tt> <var>old-version</var>
2596 <var>old-preinst</var> <tt>abort-upgrade</tt>
2597 <var>new-version</var>
2602 <list compact="compact">
2604 <var>postinst</var> <tt>configure</tt>
2605 <var>most-recently-configured-version</var>
2608 <var>old-postinst</var> <tt>abort-upgrade</tt>
2609 <var>new-version</var>
2612 <var>conflictor's-postinst</var> <tt>abort-remove</tt>
2613 <tt>in-favour</tt> <var>package</var>
2614 <var>new-version</var>
2617 <var>deconfigured's-postinst</var>
2618 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2619 <var>failed-install-package</var> <var>version</var>
2620 <tt>removing</tt> <var>conflicting-package</var>
2626 <list compact="compact">
2628 <var>prerm</var> <tt>remove</tt>
2631 <var>old-prerm</var> <tt>upgrade</tt>
2632 <var>new-version</var>
2635 <var>new-prerm</var> <tt>failed-upgrade</tt>
2636 <var>old-version</var>
2639 <var>conflictor's-prerm</var> <tt>remove</tt>
2640 <tt>in-favour</tt> <var>package</var>
2641 <var>new-version</var>
2644 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2645 <tt>in-favour</tt> <var>package-being-installed</var>
2646 <var>version</var> <tt>removing</tt>
2647 <var>conflicting-package</var>
2653 <list compact="compact">
2655 <var>postrm</var> <tt>remove</tt>
2658 <var>postrm</var> <tt>purge</tt>
2661 <var>old-postrm</var> <tt>upgrade</tt>
2662 <var>new-version</var>
2665 <var>new-postrm</var> <tt>failed-upgrade</tt>
2666 <var>old-version</var>
2669 <var>new-postrm</var> <tt>abort-install</tt>
2672 <var>new-postrm</var> <tt>abort-install</tt>
2673 <var>old-version</var>
2676 <var>new-postrm</var> <tt>abort-upgrade</tt>
2677 <var>old-version</var>
2680 <var>disappearer's-postrm</var> <tt>disappear</tt>
2681 <var>overwriter</var>
2682 <var>overwriter-version</var>
2688 <sect id="unpackphase">
2689 <heading>Details of unpack phase of installation or upgrade</heading>
2692 The procedure on installation/upgrade/overwrite/disappear
2693 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2694 stage of <tt>dpkg --install</tt>) is as follows. In each
2695 case, if a major error occurs (unless listed below) the
2696 actions are, in general, run backwards - this means that the
2697 maintainer scripts are run with different arguments in
2698 reverse order. These are the "error unwind" calls listed
2705 If a version of the package is already installed, call
2706 <example compact="compact">
2707 <var>old-prerm</var> upgrade <var>new-version</var>
2711 If the script runs but exits with a non-zero
2712 exit status, <prgn>dpkg</prgn> will attempt:
2713 <example compact="compact">
2714 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2716 Error unwind, for both the above cases:
2717 <example compact="compact">
2718 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2725 If a "conflicting" package is being removed at the same time:
2728 If any packages depended on that conflicting
2729 package and <tt>--auto-deconfigure</tt> is
2730 specified, call, for each such package:
2731 <example compact="compact">
2732 <var>deconfigured's-prerm</var> deconfigure \
2733 in-favour <var>package-being-installed</var> <var>version</var> \
2734 removing <var>conflicting-package</var> <var>version</var>
2737 <example compact="compact">
2738 <var>deconfigured's-postinst</var> abort-deconfigure \
2739 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2740 removing <var>conflicting-package</var> <var>version</var>
2742 The deconfigured packages are marked as
2743 requiring configuration, so that if
2744 <tt>--install</tt> is used they will be
2745 configured again if possible.
2748 To prepare for removal of the conflicting package, call:
2749 <example compact="compact">
2750 <var>conflictor's-prerm</var> remove \
2751 in-favour <var>package</var> <var>new-version</var>
2754 <example compact="compact">
2755 <var>conflictor's-postinst</var> abort-remove \
2756 in-favour <var>package</var> <var>new-version</var>
2765 If the package is being upgraded, call:
2766 <example compact="compact">
2767 <var>new-preinst</var> upgrade <var>old-version</var>
2771 Otherwise, if the package had some configuration
2772 files from a previous version installed (i.e., it
2773 is in the "configuration files only" state):
2774 <example compact="compact">
2775 <var>new-preinst</var> install <var>old-version</var>
2779 Otherwise (i.e., the package was completely purged):
2780 <example compact="compact">
2781 <var>new-preinst</var> install
2783 Error unwind actions, respectively:
2784 <example compact="compact">
2785 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2786 <var>new-postrm</var> abort-install <var>old-version</var>
2787 <var>new-postrm</var> abort-install
2795 The new package's files are unpacked, overwriting any
2796 that may be on the system already, for example any
2797 from the old version of the same package or from
2798 another package. Backups of the old files are kept
2799 temporarily, and if anything goes wrong the package
2800 management system will attempt to put them back as
2801 part of the error unwind.
2805 It is an error for a package to contains files which
2806 are on the system in another package, unless
2807 <tt>Replaces</tt> is used (see <ref id="replaces">).
2809 The following paragraph is not currently the case:
2810 Currently the <tt>- - force-overwrite</tt> flag is
2811 enabled, downgrading it to a warning, but this may not
2817 It is a more serious error for a package to contain a
2818 plain file or other kind of non-directory where another
2819 package has a directory (again, unless
2820 <tt>Replaces</tt> is used). This error can be
2821 overridden if desired using
2822 <tt>--force-overwrite-dir</tt>, but this is not
2827 Packages which overwrite each other's files produce
2828 behavior which, though deterministic, is hard for the
2829 system administrator to understand. It can easily
2830 lead to "missing" programs if, for example, a package
2831 is installed which overwrites a file from another
2832 package, and is then removed again.<footnote>
2833 Part of the problem is due to what is arguably a
2834 bug in <prgn>dpkg</prgn>.
2839 A directory will never be replaced by a symbolic link
2840 to a directory or vice versa; instead, the existing
2841 state (symlink or not) will be left alone and
2842 <prgn>dpkg</prgn> will follow the symlink if there is
2851 If the package is being upgraded, call
2852 <example compact="compact">
2853 <var>old-postrm</var> upgrade <var>new-version</var>
2857 If this fails, <prgn>dpkg</prgn> will attempt:
2858 <example compact="compact">
2859 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2861 Error unwind, for both cases:
2862 <example compact="compact">
2863 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2870 This is the point of no return - if
2871 <prgn>dpkg</prgn> gets this far, it won't back off
2872 past this point if an error occurs. This will
2873 leave the package in a fairly bad state, which
2874 will require a successful re-installation to clear
2875 up, but it's when <prgn>dpkg</prgn> starts doing
2876 things that are irreversible.
2881 Any files which were in the old version of the package
2882 but not in the new are removed.
2886 The new file list replaces the old.
2890 The new maintainer scripts replace the old.
2894 Any packages all of whose files have been overwritten
2895 during the installation, and which aren't required for
2896 dependencies, are considered to have been removed.
2897 For each such package
2900 <prgn>dpkg</prgn> calls:
2901 <example compact="compact">
2902 <var>disappearer's-postrm</var> disappear \
2903 <var>overwriter</var> <var>overwriter-version</var>
2907 The package's maintainer scripts are removed.
2910 It is noted in the status database as being in a
2911 sane state, namely not installed (any conffiles
2912 it may have are ignored, rather than being
2913 removed by <prgn>dpkg</prgn>). Note that
2914 disappearing packages do not have their prerm
2915 called, because <prgn>dpkg</prgn> doesn't know
2916 in advance that the package is going to
2923 Any files in the package we're unpacking that are also
2924 listed in the file lists of other packages are removed
2925 from those lists. (This will lobotomize the file list
2926 of the "conflicting" package if there is one.)
2930 The backup files made during installation, above, are
2936 The new package's status is now sane, and recorded as
2941 Here is another point of no return - if the
2942 conflicting package's removal fails we do not unwind
2943 the rest of the installation; the conflicting package
2944 is left in a half-removed limbo.
2949 If there was a conflicting package we go and do the
2950 removal actions (described below), starting with the
2951 removal of the conflicting package's files (any that
2952 are also in the package being installed have already
2953 been removed from the conflicting package's file list,
2954 and so do not get removed now).
2960 <sect id="configdetails"><heading>Details of configuration</heading>
2963 When we configure a package (this happens with <tt>dpkg
2964 --install</tt> and <tt>dpkg --configure</tt>), we first
2965 update any <tt>conffile</tt>s and then call:
2966 <example compact="compact">
2967 <var>postinst</var> configure <var>most-recently-configured-version</var>
2972 No attempt is made to unwind after errors during
2977 If there is no most recently configured version
2978 <prgn>dpkg</prgn> will pass a null argument; older versions
2979 of dpkg may pass <tt><unknown></tt> (including the
2980 angle brackets) in this case. Even older ones do not pass a
2981 second argument at all, under any circumstances.
2985 <sect id="removedetails"><heading>Details of removal and/or
2986 configuration purging</heading>
2991 <example compact="compact">
2992 <var>prerm</var> remove
2996 The package's files are removed (except <tt>conffile</tt>s).
2999 <example compact="compact">
3000 <var>postrm</var> remove
3005 All the maintainer scripts except the <prgn>postrm</prgn>
3010 If we aren't purging the package we stop here. Note
3011 that packages which have no <prgn>postrm</prgn> and no
3012 <tt>conffile</tt>s are automatically purged when
3013 removed, as there is no difference except for the
3014 <prgn>dpkg</prgn> status.
3018 The <tt>conffile</tt>s and any backup files
3019 (<tt>~</tt>-files, <tt>#*#</tt> files,
3020 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3024 <example compact="compact">
3025 <var>postrm</var> purge
3029 The package's file list is removed.
3033 No attempt is made to unwind after errors during
3040 <chapt id="relationships">
3041 <heading>Declaring relationships between packages</heading>
3043 <sect id="depsyntax">
3044 <heading>Syntax of relationship fields</heading>
3047 These fields all have a uniform syntax. They are a list of
3048 package names separated by commas.
3052 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3053 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3054 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3055 control file fields of the package, which declare
3056 dependencies on other packages, the package names listed may
3057 also include lists of alternative package names, separated
3058 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3059 if any one of the alternative packages is installed, that
3060 part of the dependency is considered to be satisfied.
3064 All of the fields except for <tt>Provides</tt> may restrict
3065 their applicability to particular versions of each named
3066 package. This is done in parentheses after each individual
3067 package name; the parentheses should contain a relation from
3068 the list below followed by a version number, in the format
3069 described in <ref id="versions">.
3073 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3074 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3075 strictly earlier, earlier or equal, exactly equal, later or
3076 equal and strictly later, respectively. The deprecated
3077 forms <tt><</tt> and <tt>></tt> were used to mean
3078 earlier/later or equal, rather than strictly earlier/later,
3079 so they should not appear in new packages (though
3080 <prgn>dpkg</prgn> still supports them).
3084 Whitespace may appear at any point in the version
3085 specification subject to the rules in <ref
3086 id="controlsyntax">, and must appear where it's necessary to
3087 disambiguate; it is not otherwise significant. For
3088 consistency and in case of future changes to
3089 <prgn>dpkg</prgn> it is recommended that a single space be
3090 used after a version relationship and before a version
3091 number; it is also conventional to put a single space after
3092 each comma, on either side of each vertical bar, and before
3093 each open parenthesis.
3097 For example, a list of dependencies might appear as:
3098 <example compact="compact">
3101 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3106 All fields that specify build-time relationships
3107 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3108 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3109 may be restricted to a certain set of architectures. This
3110 is indicated in brackets after each individual package name and
3111 the optional version specification. The brackets enclose a
3112 list of Debian architecture names separated by whitespace.
3113 Exclamation marks may be prepended to each of the names.
3114 (It is not permitted for some names to be prepended with
3115 exclamation marks and others not.) If the current Debian
3116 host architecture is not in this list and there are no
3117 exclamation marks in the list, or it is in the list with a
3118 prepended exclamation mark, the package name and the
3119 associated version specification are ignored completely for
3120 the purposes of defining the relationships.
3125 <example compact="compact">
3127 Build-Depends-Indep: texinfo
3128 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3129 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3134 Note that the binary package relationship fields such as
3135 <tt>Depends</tt> appear in one of the binary package
3136 sections of the control file, whereas the build-time
3137 relationships such as <tt>Build-Depends</tt> appear in the
3138 source package section of the control file (which is the
3144 <heading>Binary Dependencies - <tt>Depends</tt>,
3145 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3146 <tt>Pre-Depends</tt>
3150 Packages can declare in their control file that they have
3151 certain relationships to other packages - for example, that
3152 they may not be installed at the same time as certain other
3153 packages, and/or that they depend on the presence of others.
3157 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3158 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt> and
3159 <tt>Conflicts</tt> control file fields.
3163 These six fields are used to declare a dependency
3164 relationship by one package on another. Except for
3165 <tt>Enhances</tt>, they appear in the depending (binary)
3166 package's control file. (<tt>Enhances</tt> appears in the
3167 recommending package's control file.)
3171 A <tt>Depends</tt> field takes effect <em>only</em> when a
3172 package is to be configured. It does not prevent a package
3173 being on the system in an unconfigured state while its
3174 dependencies are unsatisfied, and it is possible to replace
3175 a package whose dependencies are satisfied and which is
3176 properly installed with a different version whose
3177 dependencies are not and cannot be satisfied; when this is
3178 done the depending package will be left unconfigured (since
3179 attempts to configure it will give errors) and will not
3180 function properly. If it is necessary, a
3181 <tt>Pre-Depends</tt> field can be used, which has a partial
3182 effect even when a package is being unpacked, as explained
3183 in detail below. (The other three dependency fields,
3184 <tt>Recommends</tt>, <tt>Suggests</tt> and
3185 <tt>Enhances</tt>, are only used by the various front-ends
3186 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3190 For this reason packages in an installation run are usually
3191 all unpacked first and all configured later; this gives
3192 later versions of packages with dependencies on later
3193 versions of other packages the opportunity to have their
3194 dependencies satisfied.
3198 The <tt>Depends</tt> field thus allows package maintainers
3199 to impose an order in which packages should be configured.
3203 The meaning of the five dependency fields is as follows:
3205 <tag><tt>Depends</tt></tag>
3208 This declares an absolute dependency. A package will
3209 not be configured unless all of the packages listed in
3210 its <tt>Depends</tt> field have been correctly
3215 The <tt>Depends</tt> field should be used if the
3216 depended-on package is required for the depending
3217 package to provide a significant amount of
3222 The <tt>Depends</tt> field should also be used if the
3223 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3224 <prgn>postrm</prgn> scripts require the package to be
3225 present in order to run. Note, however, that the
3226 <prgn>postrm</prgn> cannot rely on any non-essential
3227 packages to be present during the <tt>purge</tt>
3231 <tag><tt>Recommends</tt></tag>
3234 This declares a strong, but not absolute, dependency.
3238 The <tt>Recommends</tt> field should list packages
3239 that would be found together with this one in all but
3240 unusual installations.
3244 <tag><tt>Suggests</tt></tag>
3246 This is used to declare that one package may be more
3247 useful with one or more others. Using this field
3248 tells the packaging system and the user that the
3249 listed packages are related to this one and can
3250 perhaps enhance its usefulness, but that installing
3251 this one without them is perfectly reasonable.
3254 <tag><tt>Enhances</tt></tag>
3256 This field is similar to Suggests but works in the
3257 opposite direction. It is used to declare that a
3258 package can enhance the functionality of another
3262 <tag><tt>Pre-Depends</tt></tag>
3265 This field is like <tt>Depends</tt>, except that it
3266 also forces <prgn>dpkg</prgn> to complete installation
3267 of the packages named before even starting the
3268 installation of the package which declares the
3269 pre-dependency, as follows:
3273 When a package declaring a pre-dependency is about to
3274 be <em>unpacked</em> the pre-dependency can be
3275 satisfied if the depended-on package is either fully
3276 configured, <em>or even if</em> the depended-on
3277 package(s) are only unpacked or half-configured,
3278 provided that they have been configured correctly at
3279 some point in the past (and not removed or partially
3280 removed since). In this case, both the
3281 previously-configured and currently unpacked or
3282 half-configured versions must satisfy any version
3283 clause in the <tt>Pre-Depends</tt> field.
3287 When the package declaring a pre-dependency is about
3288 to be <em>configured</em>, the pre-dependency will be
3289 treated as a normal <tt>Depends</tt>, that is, it will
3290 be considered satisfied only if the depended-on
3291 package has been correctly configured.
3295 <tt>Pre-Depends</tt> should be used sparingly,
3296 preferably only by packages whose premature upgrade or
3297 installation would hamper the ability of the system to
3298 continue with any upgrade that might be in progress.
3302 <tt>Pre-Depends</tt> are also required if the
3303 <prgn>preinst</prgn> script depends on the named
3304 package. It is best to avoid this situation if
3312 When selecting which level of dependency to use you should
3313 consider how important the depended-on package is to the
3314 functionality of the one declaring the dependency. Some
3315 packages are composed of components of varying degrees of
3316 importance. Such a package should list using
3317 <tt>Depends</tt> the package(s) which are required by the
3318 more important components. The other components'
3319 requirements may be mentioned as Suggestions or
3320 Recommendations, as appropriate to the components' relative
3325 <sect id="conflicts">
3326 <heading>Conflicting binary packages - <tt>Conflicts</tt></heading>
3329 When one binary package declares a conflict with another
3330 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3331 refuse to allow them to be installed on the system at the
3336 If one package is to be installed, the other must be removed
3337 first - if the package being installed is marked as
3338 replacing (see <ref id="replaces">) the one on the system,
3339 or the one on the system is marked as deselected, or both
3340 packages are marked <tt>Essential</tt>, then
3341 <prgn>dpkg</prgn> will automatically remove the package
3342 which is causing the conflict, otherwise it will halt the
3343 installation of the new package with an error. This
3344 mechanism is specifically designed to produce an error when
3345 the installed package is <tt>Essential</tt>, but the new
3350 A package will not cause a conflict merely because its
3351 configuration files are still installed; it must be at least
3356 A special exception is made for packages which declare a
3357 conflict with their own package name, or with a virtual
3358 package which they provide (see below): this does not
3359 prevent their installation, and allows a package to conflict
3360 with others providing a replacement for it. You use this
3361 feature when you want the package in question to be the only
3362 package providing some feature.
3366 A <tt>Conflicts</tt> entry should almost never have an
3367 "earlier than" version clause. This would prevent
3368 <prgn>dpkg</prgn> from upgrading or installing the package
3369 which declared such a conflict until the upgrade or removal
3370 of the conflicted-with package had been completed.
3374 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3378 As well as the names of actual ("concrete") packages, the
3379 package relationship fields <tt>Depends</tt>,
3380 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3381 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3382 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3383 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3384 may mention "virtual packages".
3388 A <em>virtual package</em> is one which appears in the
3389 <tt>Provides</tt> control file field of another package.
3390 The effect is as if the package(s) which provide a
3391 particular virtual package name had been listed by name
3392 everywhere the virtual package name appears. (See also <ref
3397 If there are both concrete and virtual packages of the same
3398 name, then the dependency may be satisfied (or the conflict
3399 caused) by either the concrete package with the name in
3400 question or any other concrete package which provides the
3401 virtual package with the name in question. This is so that,
3402 for example, supposing we have
3403 <example compact="compact">
3407 and someone else releases an enhanced version of the
3408 <tt>bar</tt> package (for example, a non-US variant), they
3410 <example compact="compact">
3414 and the <tt>bar-plus</tt> package will now also satisfy the
3415 dependency for the <tt>foo</tt> package.
3419 If a dependency or a conflict has a version number attached
3420 then only real packages will be considered to see whether
3421 the relationship is satisfied (or the prohibition violated,
3422 for a conflict) - it is assumed that a real package which
3423 provides the virtual package is not of the "right" version.
3424 So, a <tt>Provides</tt> field may not contain version
3425 numbers, and the version number of the concrete package
3426 which provides a particular virtual package will not be
3427 looked at when considering a dependency on or conflict with
3428 the virtual package name.
3432 It is likely that the ability will be added in a future
3433 release of <prgn>dpkg</prgn> to specify a version number for
3434 each virtual package it provides. This feature is not yet
3435 present, however, and is expected to be used only
3440 If you want to specify which of a set of real packages
3441 should be the default to satisfy a particular dependency on
3442 a virtual package, you should list the real package as an
3443 alternative before the virtual one.
3448 <sect id="replaces"><heading>Overwriting files and replacing
3449 packages - <tt>Replaces</tt></heading>
3452 Packages can declare in their control file that they should
3453 overwrite files in certain other packages, or completely
3454 replace other packages. The <tt>Replaces</tt> control file
3455 field has these two distinct purposes.
3458 <sect1><heading>Overwriting files in other packages</heading>
3461 Firstly, as mentioned before, it is usually an error for a
3462 package to contain files which are on the system in
3467 However, if the overwriting package declares that it
3468 <tt>Replaces</tt> the one containing the file being
3469 overwritten, then <prgn>dpkg</prgn> will replace the file
3470 from the old package with that from the new. The file
3471 will no longer be listed as "owned" by the old package.
3475 If a package is completely replaced in this way, so that
3476 <prgn>dpkg</prgn> does not know of any files it still
3477 contains, it is considered to have "disappeared". It will
3478 be marked as not wanted on the system (selected for
3479 removal) and not installed. Any <tt>conffile</tt>s
3480 details noted for the package will be ignored, as they
3481 will have been taken over by the overwriting package. The
3482 package's <prgn>postrm</prgn> script will be run with a
3483 special argument to allow the package to do any final
3484 cleanup required. See <ref id="mscriptsinstact">.
3488 If an installed package, <tt>foo</tt> say, declares that
3489 it replaces another, <tt>bar</tt>, and an attempt is made
3490 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3491 files in the <tt>bar</tt> package which would overwrite
3492 those already present in <tt>foo</tt>. This is so that
3493 you can install an older version of a package without
3498 For this usage of <tt>Replaces</tt>, virtual packages (see
3499 <ref id="virtual">) are not considered when looking at a
3500 <tt>Replaces</tt> field - the packages declared as being
3501 replaced must be mentioned by their real names.
3505 Furthermore, this usage of <tt>Replaces</tt> only takes
3506 effect when both packages are at least partially on the
3507 system at once, so that it can only happen if they do not
3508 conflict or if the conflict has been overridden.
3513 <sect1><heading>Replacing whole packages, forcing their
3517 Secondly, <tt>Replaces</tt> allows the packaging system to
3518 resolve which package should be removed when there is a
3519 conflict - see <ref id="conflicts">. This usage only
3520 takes effect when the two packages <em>do</em> conflict,
3521 so that the two usages of this field do not interfere with
3526 In this situation, the package declared as being replaced
3527 can be a virtual package, so for example, all mail
3528 transport agents (MTAs) would have the following fields in
3529 their control files:
3530 <example compact="compact">
3531 Provides: mail-transport-agent
3532 Conflicts: mail-transport-agent
3533 Replaces: mail-transport-agent
3535 ensuring that only one MTA can be installed at any one
3540 <sect><heading>Relationships between source and binary packages -
3541 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3542 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3546 Source packages that require certain binary packages to be
3547 installed or absent at the time of building the package
3548 can declare relationships to those binary packages.
3552 This is done using the <tt>Build-Depends</tt>,
3553 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3554 <tt>Build-Conflicts-Indep</tt> control file fields.
3558 Build-dependencies on "build-essential" binary packages can be
3559 omitted. Please see <ref id="pkg-relations"> for more information.
3563 The dependencies and conflicts they define must be satisfied
3564 (as defined earlier for binary packages) in order to invoke
3565 the targets in <tt>debian/rules</tt>, as follows:<footnote>
3567 If you make "build-arch" or "binary-arch", you need
3568 Build-Depends. If you make "build-indep" or
3569 "binary-indep", you need Build-Depends and
3570 Build-Depends-Indep. If you make "build" or "binary",
3574 There is no Build-Depends-Arch; the autobuilders will
3575 only need the Build-Depends if they know how to build
3576 only build-arch and binary-arch. Anyone building the
3577 build-indep/binary-indep targets is basically assumed to
3578 be building the whole package and so installs all build
3582 The purpose of the original split, I recall, was so that
3583 the autobuilders wouldn't need to install extra packages
3584 needed only for the binary-indep targets. But without a
3585 build-arch/build-indep split, this didn't work, since
3586 most of the work is done in the build target, not in the
3592 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3594 The <tt>Build-Depends</tt> and
3595 <tt>Build-Conflicts</tt> fields must be satisfied when
3596 any of the following targets is invoked:
3597 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
3598 <tt>binary-arch</tt>, <tt>build-arch</tt>,
3599 <tt>build-indep</tt> and <tt>binary-indep</tt>.
3601 <tag><tt>Build-Depends-Indep</tt>,
3602 <tt>Build-Conflicts-Indep</tt></tag>
3604 The <tt>Build-Depends-Indep</tt> and
3605 <tt>Build-Conflicts-Indep</tt> fields must be
3606 satisfied when any of the following targets is
3607 invoked: <tt>build</tt>, <tt>clean</tt>,
3608 <tt>build-indep</tt>, <tt>binary</tt> and
3609 <tt>binary-indep</tt>.
3620 <chapt id="conffiles">
3621 <heading>Configuration file handling</heading>
3624 This chapter has been superseded by <ref id="config-files">.
3629 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3632 Packages containing shared libraries must be constructed with
3633 a little care to make sure that the shared library is always
3634 available. This is especially important for packages whose
3635 shared libraries are vitally important, such as the C library
3636 (currently <tt>libc6</tt>).
3640 Packages involving shared libraries should be split up into
3641 several binary packages. This section mostly deals with how
3642 this separation is to be accomplished; rules for files within
3643 the shared library packages are in <ref id="libraries"> instead.
3646 <sect id="sharedlibs-runtime">
3647 <heading>Run-time shared libraries</heading>
3650 The run-time shared library needs to be placed in a package called
3651 <package><var>libraryname</var><var>soversion</var></package>, where
3652 <file><var>soversion</var></file> is the version number in the
3653 soname of the shared library<footnote>
3655 The soname is the shared object name: it's the thing
3656 that has to match exactly between building an executable
3657 and running it for the dynamic linker to be able run the
3658 program. For example, if the soname of the library is
3659 <file>libfoo.so.6</file>, the library package would be
3660 called <file>libfoo6</file>.
3663 Alternatively, if it would be confusing to directly append
3664 <var>soversion</var> to <var>libraryname</var> (e.g. because
3665 <var>libraryname</var> itself ends in a number), you may use
3666 <package><var>libraryname</var>-<var>soversion</var></package> and
3667 <package><var>libraryname</var>-<var>soversion</var>-dev</package>
3672 If you have several shared libraries built from the same
3673 source tree you may lump them all together into a single
3674 shared library package, provided that you change all of
3675 their sonames at once (so that you don't get filename
3676 clashes if you try to install different versions of the
3677 combined shared libraries package).
3681 The package should install the shared libraries under
3682 their normal names. For example, the <package>libgdbmg1</package>
3683 package should install <file>libgdbm.so.1.7.3</file> as
3684 <file>/usr/lib/libgdbm.so.1.7.3</file>. The files should not be
3685 renamed or re-linked by any <prgn>prerm</prgn> or
3686 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3687 of renaming things safely without affecting running programs,
3688 and attempts to interfere with this are likely to lead to
3693 Shared libraries should not be installed executable, since
3694 the dynamic linker does not require this and trying to
3695 execute a shared library usually results in a core dump.
3699 The run-time library package should include the symbolic link that
3700 <prgn>ldconfig</prgn> would create for the shared libraries.
3701 For example, the <package>libgdbmg1</package> package should include
3702 a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3703 <file>libgdbm.so.1.7.3</file>. This is needed so that the dynamic
3704 linker (for example <prgn>ld.so</prgn> or
3705 <prgn>ld-linux.so.*</prgn>) can find the library between the
3706 time that <prgn>dpkg</prgn> installs it and the time that
3707 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3710 The package management system requires the library to be
3711 placed before the symbolic link pointing to it in the
3712 <file>.deb</file> file. This is so that when
3713 <prgn>dpkg</prgn> comes to install the symlink
3714 (overwriting the previous symlink pointing at an older
3715 version of the library), the new shared library is already
3716 in place. In the past, this was achieved by creating the
3717 library in the temporary packaging directory before
3718 creating the symlink. Unfortunately, this was not always
3719 effective, since the building of the tar file in the
3720 <file>.deb</file> depended on the behavior of the underlying
3721 file system. Some file systems (such as reiserfs) reorder
3722 the files so that the order of creation is forgotten.
3723 Since version 1.7.0, <prgn>dpkg</prgn>
3724 reorders the files itself as necessary when building a
3725 package. Thus it is no longer important to concern
3726 oneself with the order of file creation.
3731 <sect1 id="ldconfig">
3732 <heading><tt>ldconfig</tt></heading>
3735 Any package installing shared libraries in one of the default
3736 library directories of the dynamic linker (which are currently
3737 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3738 listed in <file>/etc/ld.so.conf</file><footnote>
3740 <list compact="compact">
3741 <item>/usr/X11R6/lib/Xaw3d</item>
3742 <item>/usr/local/lib</item>
3743 <item>/usr/lib/libc5-compat</item>
3744 <item>/lib/libc5-compat</item>
3745 <item>/usr/X11R6/lib</item>
3748 must use <prgn>ldconfig</prgn> to update the shared library
3753 The package must call <prgn>ldconfig</prgn> in the
3754 <prgn>postinst</prgn> script if the first argument is
3755 <tt>configure</tt>; the <prgn>postinst</prgn> script may
3756 optionally invoke <prgn>ldconfig</prgn> at other times. The
3757 package should call <prgn>ldconfig</prgn> in the
3758 <prgn>postrm</prgn> script if the first argument is
3759 <tt>remove</tt>. The maintainer scripts must not invoke
3760 <prgn>ldconfig</prgn> under any circumstances other than those
3761 described in this paragraph.<footnote>
3763 During install or upgrade, the preinst is called before
3764 the new files are installed, so calling "ldconfig" is
3765 pointless. The preinst of an existing package can also be
3766 called if an upgrade fails. However, this happens during
3767 the critical time when a shared libs may exist on-disk
3768 under a temporary name. Thus, it is dangerous and
3769 forbidden by current policy to call "ldconfig" at this
3774 When a package is installed or upgraded, "postinst
3775 configure" runs after the new files are safely on-disk.
3776 Since it is perfectly safe to invoke ldconfig
3777 unconditionally in a postinst, it is OK for a package to
3778 simply put ldconfig in its postinst without checking the
3779 argument. The postinst can also be called to recover from
3780 a failed upgrade. This happens before any new files are
3781 unpacked, so there is no reason to call "ldconfig" at this
3786 For a package that is being removed, prerm is
3787 called with all the files intact, so calling ldconfig is
3788 useless. The other calls to "prerm" happen in the case of
3789 upgrade at a time when all the files of the old package
3790 are on-disk, so again calling "ldconfig" is pointless.
3794 postrm, on the other hand, is called with the "remove"
3795 argument just after the files are removed, so this is the
3796 proper time to call "ldconfig" to notify the system of the
3797 fact shared libraries from the package are removed.
3798 The postrm can be called at several other times. At the
3799 time of "postrm purge", "postrm abort-install", or "postrm
3800 abort-upgrade", calling "ldconfig" is useless because the
3801 shared lib files are not on-disk. However, when "postrm"
3802 is invoked with arguments "upgrade", "failed-upgrade", or
3803 "disappear", a shared lib may exist on-disk under a
3812 <sect id="sharedlibs-runtime-progs">
3813 <heading>Run-time support programs</heading>
3816 If your package has some run-time support programs which use
3817 the shared library you must not put them in the shared
3818 library package. If you do that then you won't be able to
3819 install several versions of the shared library without
3820 getting filename clashes.
3824 Instead, either create another package for the runtime binaries
3825 (this package might typically be named
3826 <package><var>libraryname</var>-runtime</package>; note the absence
3827 of the <var>soversion</var> in the package name), or if the
3828 development package is small, include them in there.
3832 <sect id="sharedlibs-static">
3833 <heading>Static libraries</heading>
3836 The static library (<file><var>libraryname.a</var></file>)
3837 is usually provided in addition to the shared version.
3838 It is placed into the development package (see below).
3842 In some cases, it is acceptable for a library to be
3843 available in static form only; these cases include:
3845 <item>libraries for languages whose shared library support
3846 is immature or unstable</item>
3847 <item>libraries whose interfaces are in flux or under
3848 development (commonly the case when the library's
3849 major version number is zero, or where the ABI breaks
3850 across patchlevels)</item>
3851 <item>libraries which are explicitly intended to be
3852 available only in static form by their upstream
3857 <sect id="sharedlibs-dev">
3858 <heading>Development files</heading>
3861 The development files associated to a shared library need to be
3862 placed in a package called
3863 <package><var>libraryname</var><var>soversion</var>-dev</package>,
3864 or if you prefer only to support one development version at a
3865 time, <package><var>libraryname</var>-dev</package>.
3869 In case several development versions of a library exist, you may
3870 need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
3871 <ref id="conflicts">) to ensure that the user only installs one
3872 development version at a time (as different development versions are
3873 likely to have the same header files in them, which would cause a
3874 filename clash if both were installed).
3878 The development package should contain a symlink for the associated
3879 shared library without a version number. For example, the
3880 <package>libgdbmg1-dev</package> package should include a symlink
3881 from <file>/usr/lib/libgdbm.so</file> to
3882 <file>libgdbm.so.1.7.3</file>. This symlink is needed by the linker
3883 (<prgn>ld</prgn>) when compiling packages, as it will only look for
3884 <file>libgdbm.so</file> when compiling dynamically.
3888 <sect id="sharedlibs-intradeps">
3889 <heading>Dependencies between the packages of the same library</heading>
3892 Typically the development version should have an exact
3893 version dependency on the runtime library, to make sure that
3894 compilation and linking happens correctly. The
3895 <tt>${Source-Version}</tt> substitution variable can be
3896 useful for this purpose.
3900 <sect id="sharedlibs-shlibdeps">
3901 <heading>Dependencies between the library and other packages -
3902 the <tt>shlibs</tt> system</heading>
3905 If a package contains a binary or library which links to a
3906 shared library, we must ensure that when the package is
3907 installed on the system, all of the libraries needed are
3908 also installed. This requirement led to the creation of the
3909 <tt>shlibs</tt> system, which is very simple in its design:
3910 any package which <em>provides</em> a shared library also
3911 provides information on the package dependencies required to
3912 ensure the presence of this library, and any package which
3913 <em>uses</em> a shared library uses this information to
3914 determine the dependencies it requires. The files which
3915 contain the mapping from shared libraries to the necessary
3916 dependency information are called <file>shlibs</file> files.
3920 Thus, when a package is built which contains any shared
3921 libraries, it must provide a <file>shlibs</file> file for other
3922 packages to use, and when a package is built which contains
3923 any shared libraries or compiled binaries, it must run
3924 <prgn>dpkg-shlibdeps</prgn> on these to determine the
3925 libraries used and hence the dependencies needed by this
3928 In the past, the shared libraries linked to were
3929 determined by calling <prgn>ldd</prgn>, but now
3930 <prgn>objdump</prgn> is used to do this. The only
3931 change this makes to package building is that
3932 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
3933 libraries, whereas in the past this was unnecessary.
3934 The rest of this footnote explains the advantage that
3939 We say that a binary <tt>foo</tt> <em>directly</em> uses
3940 a library <tt>libbar</tt> if it is explicitly linked
3941 with that library (that is, it uses the flag
3942 <tt>-lbar</tt> during the linking stage). Other
3943 libraries that are needed by <tt>libbar</tt> are linked
3944 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
3945 linker will load them automatically when it loads
3946 <tt>libbar</tt>. A package should depend on
3947 the libraries it directly uses, and the dependencies for
3948 those libraries should automatically pull in the other
3953 Unfortunately, the <prgn>ldd</prgn> program shows both
3954 the directly and indirectly used libraries, meaning that
3955 the dependencies determined included both direct and
3956 indirect dependencies. The use of <prgn>objdump</prgn>
3957 avoids this problem by determining only the directly
3962 A good example of where this helps is the following. We
3963 could update <tt>libimlib</tt> with a new version that
3964 supports a new graphics format called dgf (but retaining
3965 the same major version number). If we used the old
3966 <prgn>ldd</prgn> method, every package that uses
3967 <tt>libimlib</tt> would need to be recompiled so it
3968 would also depend on <tt>libdgf</tt> or it wouldn't run
3969 due to missing symbols. However with the new system,
3970 packages using <tt>libimlib</tt> can rely on
3971 <tt>libimlib</tt> itself having the dependency on
3972 <tt>libdgf</tt> and so they would not need rebuilding.
3978 In the following sections, we will first describe where the
3979 various <tt>shlibs</tt> files are to be found, then how to
3980 use <prgn>dpkg-shlibdeps</prgn>, and finally the
3981 <tt>shlibs</tt> file format and how to create them if your
3982 package contains a shared library.
3986 <heading>The <tt>shlibs</tt> files present on the system</heading>
3989 There are several places where <tt>shlibs</tt> files are
3990 found. The following list gives them in the order in which
3991 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
3992 one which gives the required information is used.)
3998 <p><file>debian/shlibs.local</file></p>
4001 This lists overrides for this package. Its use is
4002 described below (see <ref id="shlibslocal">).
4007 <p><file>/etc/dpkg/shlibs.override</file></p>
4010 This lists global overrides. This list is normally
4011 empty. It is maintained by the local system
4017 <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
4020 When packages are being built, any
4021 <file>debian/shlibs</file> files are copied into the
4022 control file area of the temporary build directory and
4023 given the name <file>shlibs</file>. These files give
4024 details of any shared libraries included in the
4027 An example may help here. Let us say that the
4028 source package <tt>foo</tt> generates two binary
4029 packages, <tt>libfoo2</tt> and
4030 <tt>foo-runtime</tt>. When building the binary
4031 packages, the two packages are created in the
4032 directories <file>debian/libfoo2</file> and
4033 <file>debian/foo-runtime</file> respectively.
4034 (<file>debian/tmp</file> could be used instead of one
4035 of these.) Since <tt>libfoo2</tt> provides the
4036 <tt>libfoo</tt> shared library, it will require a
4037 <tt>shlibs</tt> file, which will be installed in
4038 <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
4040 <file>/var/lib/dpkg/info/libfoo2.shlibs</file>. Then
4041 when <prgn>dpkg-shlibdeps</prgn> is run on the
4043 <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
4045 <file>debian/libfoo2/DEBIAN/shlibs</file> file to
4046 determine whether <tt>foo-prog</tt>'s library
4047 dependencies are satisfied by any of the libraries
4048 provided by <tt>libfoo2</tt>. For this reason,
4049 <prgn>dpkg-shlibdeps</prgn> must only be run once
4050 all of the individual binary packages'
4051 <tt>shlibs</tt> files have been installed into the
4059 <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
4062 These are the <file>shlibs</file> files corresponding to
4063 all of the packages installed on the system, and are
4064 maintained by the relevant package maintainers.
4069 <p><file>/etc/dpkg/shlibs.default</file></p>
4072 This file lists any shared libraries whose packages
4073 have failed to provide correct <file>shlibs</file> files.
4074 It was used when the <file>shlibs</file> setup was first
4075 introduced, but it is now normally empty. It is
4076 maintained by the <tt>dpkg</tt> maintainer.
4084 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4085 <file>shlibs</file> files</heading>
4088 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4089 <file>debian/rules</file> file. If your package contains only
4090 compiled binaries and libraries (but no scripts), you can
4091 use a command such as:
4092 <example compact="compact">
4093 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4094 debian/tmp/usr/lib/*
4096 Otherwise, you will need to explicitly list the compiled
4097 binaries and libraries.<footnote>
4099 If you are using <tt>debhelper</tt>, the
4100 <prgn>dh_shlibdeps</prgn> program will do this work for
4101 you. It will also correctly handle multi-binary
4108 This command puts the dependency information into the
4109 <file>debian/substvars</file> file, which is then used by
4110 <prgn>dpkg-gencontrol</prgn>. You will need to place a
4111 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4112 field in the control file for this to work.
4116 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4117 done. If it does complain you might need to create your own
4118 <file>debian/shlibs.local</file> file, as explained below (see
4119 <ref id="shlibslocal">).
4123 If you have multiple binary packages, you will need to call
4124 <prgn>dpkg-shlibdeps</prgn> on each one which contains
4125 compiled libraries or binaries. In such a case, you will
4126 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4127 utilities to specify a different <file>substvars</file> file.
4128 For more details on this and other options, see <manref
4129 name="dpkg-shlibdeps" section="1">.
4134 <heading>The <file>shlibs</file> File Format</heading>
4137 Each <file>shlibs</file> file has the same format. Lines
4138 beginning with <tt>#</tt> are considered to be comments and
4139 are ignored. Each line is of the form:
4140 <example compact="compact">
4141 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4146 We will explain this by reference to the example of the
4147 <tt>zlib1g</tt> package, which (at the time of writing)
4148 installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4152 <var>library-name</var> is the name of the shared library,
4153 in this case <tt>libz</tt>. (This must match the name part
4154 of the soname, see below.)
4158 <var>soname-version-number</var> is the version part of the
4159 soname of the library. The soname is the thing that must
4160 exactly match for the library to be recognized by the
4161 dynamic linker, and is usually of the form
4162 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4163 example, <tt>libz.so.1</tt>.<footnote>
4165 This can be determined using the command
4166 <example compact="compact">
4167 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4171 The version part is the part which comes after
4172 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4176 <var>dependencies</var> has the same syntax as a dependency
4177 field in a binary package control file. It should give
4178 details of which packages are required to satisfy a binary
4179 built against the version of the library contained in the
4180 package. See <ref id="depsyntax"> for details.
4184 In our example, if the first version of the <tt>zlib1g</tt>
4185 package which contained a minor number of at least
4186 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4187 <tt>shlibs</tt> entry for this library could say:
4188 <example compact="compact">
4189 libz 1 zlib1g (>= 1:1.1.3)
4191 The version-specific dependency is to avoid warnings from
4192 the dynamic linker about using older shared libraries with
4198 <heading>Providing a <file>shlibs</file> file</heading>
4201 If your package provides a shared library, you should create
4202 a <file>shlibs</file> file following the format described above.
4203 It is usual to call this file <file>debian/shlibs</file> (but if
4204 you have multiple binary packages, you might want to call it
4205 <file>debian/shlibs.<var>package</var></file> instead). Then
4206 let <file>debian/rules</file> install it in the control area:
4207 <example compact="compact">
4208 install -m644 debian/shlibs debian/tmp/DEBIAN
4210 or, in the case of a multi-binary package:
4211 <example compact="compact">
4212 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4214 An alternative way of doing this is to create the
4215 <file>shlibs</file> file in the control area directly from
4216 <file>debian/rules</file> without using a <file>debian/shlibs</file>
4217 file at all,<footnote>
4219 This is what <prgn>dh_makeshlibs</prgn> in the
4220 <tt>debhelper</tt> suite does.
4223 since the <file>debian/shlibs</file> file itself is ignored by
4224 <prgn>dpkg-shlibdeps</prgn>.
4228 As <prgn>dpkg-shlibdeps</prgn> reads the
4229 <file>DEBIAN/shlibs</file> files in all of the binary packages
4230 being built from this source package, all of the
4231 <file>DEBIAN/shlibs</file> files should be installed before
4232 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4237 <sect1 id="shlibslocal">
4238 <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4241 This file is intended only as a <em>temporary</em> fix if
4242 your binaries or libraries depend on a library whose package
4243 does not yet provide a correct <file>shlibs</file> file.
4247 We will assume that you are trying to package a binary
4248 <tt>foo</tt>. When you try running
4249 <prgn>dpkg-shlibdeps</prgn> you get the following error
4250 message (<tt>-O</tt> displays the dependency information on
4251 <tt>stdout</tt> instead of writing it to
4252 <tt>debian/substvars</tt>, and the lines have been wrapped
4253 for ease of reading):
4254 <example compact="compact">
4255 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4256 dpkg-shlibdeps: warning: unable to find dependency
4257 information for shared library libbar (soname 1,
4258 path /usr/lib/libbar.so.1, dependency field Depends)
4259 shlibs:Depends=libc6 (>= 2.2.2-2)
4261 You can then run <prgn>ldd</prgn> on the binary to find the
4262 full location of the library concerned:
4263 <example compact="compact">
4265 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4266 libc.so.6 => /lib/libc.so.6 (0x40032000)
4267 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4269 So the <prgn>foo</prgn> binary depends on the
4270 <prgn>libbar</prgn> shared library, but no package seems to
4271 provide a <file>*.shlibs</file> file handling
4272 <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>. Let's
4273 determine the package responsible:
4274 <example compact="compact">
4275 $ dpkg -S /usr/lib/libbar.so.1
4276 bar1: /usr/lib/libbar.so.1
4277 $ dpkg -s bar1 | grep Version
4280 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4281 is the one we are using. Now we can file a bug against the
4282 <tt>bar1</tt> package and create our own
4283 <file>debian/shlibs.local</file> to locally fix the problem.
4284 Including the following line into your
4285 <file>debian/shlibs.local</file> file:
4286 <example compact="compact">
4287 libbar 1 bar1 (>= 1.0-1)
4289 should allow the package build to work.
4293 As soon as the maintainer of <tt>bar1</tt> provides a
4294 correct <file>shlibs</file> file, you should remove this line
4295 from your <file>debian/shlibs.local</file> file. (You should
4296 probably also then have a versioned <tt>Build-Depends</tt>
4297 on <tt>bar1</tt> to help ensure that others do not have the
4298 same problem building your package.)
4306 <chapt id="opersys"><heading>The Operating System</heading>
4309 <heading>Filesystem hierarchy</heading>
4313 <heading>Filesystem Structure</heading>
4316 The location of all installed files and directories must
4317 comply with the Filesystem Hierarchy Standard (FHS),
4318 version 2.1, except where doing so would violate other
4319 terms of Debian Policy. The version of this document
4320 referred here can be found in the <tt>debian-policy</tt>
4322 <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4323 name="FHS (Debian copy)"> alongside this manual (or, if
4324 you have the <package>debian-policy</package> installed,
4326 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4327 (local copy)">). The
4328 latest version, which may be a more recent version, may
4330 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4331 Specific questions about following the standard may be
4332 asked on the <tt>debian-devel</tt> mailing list, or
4333 referred to the FHS mailing list (see the
4334 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4340 <heading>Site-specific programs</heading>
4343 As mandated by the FHS, packages must not place any
4344 files in <file>/usr/local</file>, either by putting them in
4345 the file system archive to be unpacked by <prgn>dpkg</prgn>
4346 or by manipulating them in their maintainer scripts.
4350 However, the package may create empty directories below
4351 <file>/usr/local</file> so that the system administrator knows
4352 where to place site-specific files. These directories
4353 should be removed on package removal if they are
4358 Note, that this applies only to directories <em>below</em>
4359 <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4360 Packages must not create sub-directories in the directory
4361 <file>/usr/local</file> itself, except those listed in FHS,
4362 section 4.5. However, you may create directories below
4363 them as you wish. You must not remove any of the
4364 directories listed in 4.5, even if you created them.
4368 Since <file>/usr/local</file> can be mounted read-only from a
4369 remote server, these directories must be created and
4370 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4371 maintainer scripts and not be included in the
4372 <file>.deb</file> archive. These scripts must not fail if
4373 either of these operations fail.
4377 For example, the <tt>emacsen-common</tt> package could
4378 contain something like
4379 <example compact="compact">
4380 if [ ! -e /usr/local/share/emacs ]
4382 if mkdir /usr/local/share/emacs 2>/dev/null
4384 chown root:staff /usr/local/share/emacs
4385 chmod 2775 /usr/local/share/emacs
4389 in its <prgn>postinst</prgn> script, and
4390 <example compact="compact">
4391 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4392 rmdir /usr/local/share/emacs 2>/dev/null || true
4394 in the <prgn>prerm</prgn> script. (Note that this form is
4395 used to ensure that if the script is interrupted, the
4396 directory <file>/usr/local/share/emacs</file> will still be
4401 If you do create a directory in <file>/usr/local</file> for
4402 local additions to a package, you should ensure that
4403 settings in <file>/usr/local</file> take precedence over the
4404 equivalents in <file>/usr</file>.
4408 However, because <file>/usr/local</file> and its contents are
4409 for exclusive use of the local administrator, a package
4410 must not rely on the presence or absence of files or
4411 directories in <file>/usr/local</file> for normal operation.
4415 The <file>/usr/local</file> directory itself and all the
4416 subdirectories created by the package should (by default) have
4417 permissions 2775 (group-writable and set-group-id) and be
4418 owned by <tt>root.staff</tt>.
4423 <heading>The system-wide mail directory</heading>
4425 The system-wide mail directory is <file>/var/mail</file>. This
4426 directory is part of the base system and should not owned
4427 by any particular mail agents. The use of the old
4428 location <file>/var/spool/mail</file> is deprecated, even
4429 though the spool may still be physically located there.
4430 To maintain partial upgrade compatibility for systems
4431 which have <file>/var/spool/mail</file> as their physical mail
4432 spool, packages using <file>/var/mail</file> must depend on
4433 either <package>libc6</package> (>= 2.1.3-13), or on
4434 <package>base-files</package> (>= 2.2.0), or on later
4435 versions of either one of these packages.
4441 <heading>Users and groups</heading>
4444 <heading>Introduction</heading>
4446 The Debian system can be configured to use either plain or
4451 Some user ids (UIDs) and group ids (GIDs) are reserved
4452 globally for use by certain packages. Because some
4453 packages need to include files which are owned by these
4454 users or groups, or need the ids compiled into binaries,
4455 these ids must be used on any Debian system only for the
4456 purpose for which they are allocated. This is a serious
4457 restriction, and we should avoid getting in the way of
4458 local administration policies. In particular, many sites
4459 allocate users and/or local system groups starting at 100.
4463 Apart from this we should have dynamically allocated ids,
4464 which should by default be arranged in some sensible
4465 order, but the behavior should be configurable.
4469 Packages other than <tt>base-passwd</tt> must not modify
4470 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4471 <file>/etc/group</file> or <file>/etc/gshadow</file>.
4476 <heading>UID and GID classes</heading>
4478 The UID and GID numbers are divided into classes as
4484 Globally allocated by the Debian project, the same
4485 on every Debian system. These ids will appear in
4486 the <file>passwd</file> and <file>group</file> files of all
4487 Debian systems, new ids in this range being added
4488 automatically as the <tt>base-passwd</tt> package is
4493 Packages which need a single statically allocated
4494 uid or gid should use one of these; their
4495 maintainers should ask the <tt>base-passwd</tt>
4503 Dynamically allocated system users and groups.
4504 Packages which need a user or group, but can have
4505 this user or group allocated dynamically and
4506 differently on each system, should use <tt>adduser
4507 --system</tt> to create the group and/or user.
4508 <prgn>adduser</prgn> will check for the existence of
4509 the user or group, and if necessary choose an unused
4510 id based on the ranges specified in
4511 <file>adduser.conf</file>.
4515 <tag>1000-29999:</tag>
4518 Dynamically allocated user accounts. By default
4519 <prgn>adduser</prgn> will choose UIDs and GIDs for
4520 user accounts in this range, though
4521 <file>adduser.conf</file> may be used to modify this
4526 <tag>30000-59999:</tag>
4531 <tag>60000-64999:</tag>
4534 Globally allocated by the Debian project, but only
4535 created on demand. The ids are allocated centrally
4536 and statically, but the actual accounts are only
4537 created on users' systems on demand.
4541 These ids are for packages which are obscure or
4542 which require many statically-allocated ids. These
4543 packages should check for and create the accounts in
4544 <file>/etc/passwd</file> or <file>/etc/group</file> (using
4545 <prgn>adduser</prgn> if it has this facility) if
4546 necessary. Packages which are likely to require
4547 further allocations should have a "hole" left after
4548 them in the allocation, to give them room to
4553 <tag>65000-65533:</tag>
4561 User <tt>nobody</tt>. The corresponding gid refers
4562 to the group <tt>nogroup</tt>.
4569 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4570 not</em> be used, because it is the error return
4579 <sect id="sysvinit">
4580 <heading>System run levels and <file>init.d</file> scripts</heading>
4582 <sect1 id="/etc/init.d">
4583 <heading>Introduction</heading>
4586 The <file>/etc/init.d</file> directory contains the scripts
4587 executed by <prgn>init</prgn> at boot time and when the
4588 init state (or "runlevel") is changed (see <manref
4589 name="init" section="8">).
4593 There are at least two different, yet functionally
4594 equivalent, ways of handling these scripts. For the sake
4595 of simplicity, this document describes only the symbolic
4596 link method. However, it must not be assumed by maintainer
4597 scripts that this method is being used, and any automated
4598 manipulation of the various runlevel behaviours by
4599 maintainer scripts must be performed using
4600 <prgn>update-rc.d</prgn> as described below and not by
4601 manually installing or removing symlinks. For information
4602 on the implementation details of the other method,
4603 implemented in the <tt>file-rc</tt> package, please refer
4604 to the documentation of that package.
4608 These scripts are referenced by symbolic links in the
4609 <file>/etc/rc<var>n</var>.d</file> directories. When changing
4610 runlevels, <prgn>init</prgn> looks in the directory
4611 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4612 execute, where <tt><var>n</var></tt> is the runlevel that
4613 is being changed to, or <tt>S</tt> for the boot-up
4618 The names of the links all have the form
4619 <file>S<var>mm</var><var>script</var></file> or
4620 <file>K<var>mm</var><var>script</var></file> where
4621 <var>mm</var> is a two-digit number and <var>script</var>
4622 is the name of the script (this should be the same as the
4623 name of the actual script in <file>/etc/init.d</file>).
4627 When <prgn>init</prgn> changes runlevel first the targets
4628 of the links whose names start with a <tt>K</tt> are
4629 executed, each with the single argument <tt>stop</tt>,
4630 followed by the scripts prefixed with an <tt>S</tt>, each
4631 with the single argument <tt>start</tt>. (The links are
4632 those in the <file>/etc/rc<var>n</var>.d</file> directory
4633 corresponding to the new runlevel.) The <tt>K</tt> links
4634 are responsible for killing services and the <tt>S</tt>
4635 link for starting services upon entering the runlevel.
4639 For example, if we are changing from runlevel 2 to
4640 runlevel 3, init will first execute all of the <tt>K</tt>
4641 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4642 all of the <tt>S</tt> prefixed scripts in that directory.
4643 The links starting with <tt>K</tt> will cause the
4644 referred-to file to be executed with an argument of
4645 <tt>stop</tt>, and the <tt>S</tt> links with an argument
4650 The two-digit number <var>mm</var> is used to determine
4651 the order in which to run the scripts: low-numbered links
4652 have their scripts run first. For example, the
4653 <tt>K20</tt> scripts will be executed before the
4654 <tt>K30</tt> scripts. This is used when a certain service
4655 must be started before another. For example, the name
4656 server <prgn>bind</prgn> might need to be started before
4657 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4658 can set up its access lists. In this case, the script
4659 that starts <prgn>bind</prgn> would have a lower number
4660 than the script that starts <prgn>inn</prgn> so that it
4662 <example compact="compact">
4669 The two runlevels 0 (halt) and 6 (reboot) are slightly
4670 different. In these runlevels, the links with an
4671 <tt>S</tt> prefix are still called after those with a
4672 <tt>K</tt> prefix, but they too are called with the single
4673 argument <tt>stop</tt>.
4677 Also, if the script name ends <tt>.sh</tt>, the script
4678 will be sourced in runlevel <tt>S</tt> rather that being
4679 run in a forked subprocess, but will be explicitly run by
4680 <prgn>sh</prgn> in all other runlevels.
4685 <heading>Writing the scripts</heading>
4688 Packages that include daemons for system services should
4689 place scripts in <file>/etc/init.d</file> to start or stop
4690 services at boot time or during a change of runlevel.
4691 These scripts should be named
4692 <file>/etc/init.d/<var>package</var></file>, and they should
4693 accept one argument, saying what to do:
4696 <tag><tt>start</tt></tag>
4697 <item>start the service,</item>
4699 <tag><tt>stop</tt></tag>
4700 <item>stop the service,</item>
4702 <tag><tt>restart</tt></tag>
4703 <item>stop and restart the service if it's already running,
4704 otherwise start the service</item>
4706 <tag><tt>reload</tt></tag>
4707 <item><p>cause the configuration of the service to be
4708 reloaded without actually stopping and restarting
4711 <tag><tt>force-reload</tt></tag>
4712 <item>cause the configuration to be reloaded if the
4713 service supports this, otherwise restart the
4717 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4718 <tt>force-reload</tt> options should be supported by all
4719 scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4724 The <file>init.d</file> scripts should ensure that they will
4725 behave sensibly if invoked with <tt>start</tt> when the
4726 service is already running, or with <tt>stop</tt> when it
4727 isn't, and that they don't kill unfortunately-named user
4728 processes. The best way to achieve this is usually to use
4729 <prgn>start-stop-daemon</prgn>.
4733 If a service reloads its configuration automatically (as
4734 in the case of <prgn>cron</prgn>, for example), the
4735 <tt>reload</tt> option of the <file>init.d</file> script
4736 should behave as if the configuration has been reloaded
4741 The <file>/etc/init.d</file> scripts must be treated as
4742 configuration files, either (if they are present in the
4743 package, that is, in the .deb file) by marking them as
4744 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4745 by managing them correctly in the maintainer scripts (see
4746 <ref id="config-files">). This is important since we want
4747 to give the local system administrator the chance to adapt
4748 the scripts to the local system, e.g., to disable a
4749 service without de-installing the package, or to specify
4750 some special command line options when starting a service,
4751 while making sure her changes aren't lost during the next
4756 These scripts should not fail obscurely when the
4757 configuration files remain but the package has been
4758 removed, as configuration files remain on the system after
4759 the package has been removed. Only when <prgn>dpkg</prgn>
4760 is executed with the <tt>--purge</tt> option will
4761 configuration files be removed. In particular, as the
4762 <file>/etc/init.d/<var>package</var></file> script itself is
4763 usually a <tt>conffile</tt>, it will remain on the system
4764 if the package is removed but not purged. Therefore, you
4765 should include a <tt>test</tt> statement at the top of the
4767 <example compact="compact">
4768 test -f <var>program-executed-later-in-script</var> || exit 0
4773 Often there are some variables in the <file>init.d</file>
4774 scripts whose values control the behaviour of the scripts,
4775 and which a system administrator is likely to want to
4776 change. As the scripts themselves are frequently
4777 <tt>conffile</tt>s, modifying them requires that the
4778 administrator merge in their changes each time the package
4779 is upgraded and the <tt>conffile</tt> changes. To ease
4780 the burden on the system administrator, such configurable
4781 values should not be placed directly in the script.
4782 Instead, they should be placed in a file in
4783 <file>/etc/default</file>, which typically will have the same
4784 base name as the <file>init.d</file> script. This extra file
4785 should be sourced by the script when the script runs. It
4786 must contain only variable settings and comments in POSIX
4787 <prgn>sh</prgn> format. It may either be a
4788 <tt>conffile</tt> or a configuration file maintained by
4789 the package maintainer scripts. See <ref id="config-files">
4794 To ensure that vital configurable values are always
4795 available, the <file>init.d</file> script should set default
4796 values for each of the shell variables it uses, either
4797 before sourcing the <file>/etc/default/</file> file or
4798 afterwards using something like the <tt>:
4799 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
4800 script must behave sensibly and not fail if the
4801 <file>/etc/default</file> file is deleted.
4806 <heading>Interfacing with the initscript system</heading>
4809 Maintainers should use the abstraction layer provided by
4810 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4811 programs to deal with initscripts in their packages'
4812 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4813 and <prgn>postrm</prgn>.
4817 Directly managing the /etc/rc?.d links and directly
4818 invoking the <file>/etc/init.d/</file> initscripts should
4819 be done only by packages providing the initscript
4820 subsystem (such as <prgn>sysvinit</prgn> and
4821 <prgn>file-rc</prgn>).
4825 <heading>Managing the links</heading>
4828 The program <prgn>update-rc.d</prgn> is provided for
4829 package maintainers to arrange for the proper creation and
4830 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4831 or their functional equivalent if another method is being
4832 used. This may be used by maintainers in their packages'
4833 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.
4837 You must not include any <file>/etc/rc<var>n</var>.d</file>
4838 symbolic links in the actual archive or manually create or
4839 remove the symbolic links in maintainer scripts; you must
4840 use the <prgn>update-rc.d</prgn> program instead. (The
4841 former will fail if an alternative method of maintaining
4842 runlevel information is being used.) You must not include
4843 the <file>/etc/rc<var>n</var>.d</file> directories themselves
4844 in the archive either. (Only the <tt>sysvinit</tt>
4849 By default <prgn>update-rc.d</prgn> will start services in
4850 each of the multi-user state runlevels (2, 3, 4, and 5)
4851 and stop them in the halt runlevel (0), the single-user
4852 runlevel (1) and the reboot runlevel (6). The system
4853 administrator will have the opportunity to customize
4854 runlevels by simply adding, moving, or removing the
4855 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4856 symbolic links are being used, or by modifying
4857 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4862 To get the default behavior for your package, put in your
4863 <prgn>postinst</prgn> script
4864 <example compact="compact">
4865 update-rc.d <var>package</var> defaults
4867 and in your <prgn>postrm</prgn>
4868 <example compact="compact">
4869 if [ "$1" = purge ]; then
4870 update-rc.d <var>package</var> remove
4872 </example>. Note that if your package changes runlevels
4873 or priority, you may have to remove and recreate the links,
4874 since otherwise the old links may persist. Refer to the
4875 documentation of <prgn>update-rc.d</prgn>.
4879 This will use a default sequence number of 20. If it does
4880 not matter when or in which order the <file>init.d</file>
4881 script is run, use this default. If it does, then you
4882 should talk to the maintainer of the <prgn>sysvinit</prgn>
4883 package or post to <tt>debian-devel</tt>, and they will
4884 help you choose a number.
4888 For more information about using <tt>update-rc.d</tt>,
4889 please consult its manpage <manref name="update-rc.d"
4895 <heading>Running initscripts</heading>
4897 The program <prgn>invoke-rc.d</prgn> is provided to make
4898 it easier for package maintainers to properly invoke an
4899 initscript, obeying runlevel and other locally-defined
4900 constraints that might limit a package's right to start,
4901 stop and otherwise manage services. This program may be
4902 used by maintainers in their packages' scripts.
4906 The use of <prgn>invoke-rc.d</prgn> to invoke the
4907 <file>/etc/init.d/*</file> initscripts is strongly
4908 recommended<footnote>
4909 In the future, the use of invoke-rc.d to invoke
4910 initscripts shall be made mandatory. Maintainers are
4911 advised to switch to invoke-rc.d as soon as
4913 </footnote>, instead of calling them directly.
4917 By default, <prgn>invoke-rc.d</prgn> will pass any
4918 action requests (start, stop, reload, restart...) to the
4919 <file>/etc/init.d</file> script, filtering out requests
4920 to start or restart a service out of its intended
4925 Most packages will simply need to change:
4926 <example compact="compact">/etc/init.d/<package>
4927 <action></example> in their <prgn>postinst</prgn>
4928 and <prgn>prerm</prgn> scripts to:
4929 <example compact="compact">
4930 if [ -x /usr/sbin/invoke-rc.d ] ; then
4931 invoke-rc.d <var>package</var> <action>
4933 /etc/init.d/<var>package</var> <action>
4939 A package should register its initscript services using
4940 <prgn>update-rc.d</prgn> before it tries to invoke them
4941 using <prgn>invoke-rc.d</prgn>. Invocation of
4942 unregistered services may fail.
4946 For more information about using
4947 <prgn>invoke-rc.d</prgn>, please consult its manpage
4948 <manref name="invoke-rc.d" section="8">.
4954 <heading>Boot-time initialization</heading>
4957 There used to be another directory, <file>/etc/rc.boot</file>,
4958 which contained scripts which were run once per machine
4959 boot. This has been deprecated in favour of links from
4960 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
4961 described in <ref id="/etc/init.d">. Packages must not
4962 place files in <file>/etc/rc.boot</file>.
4967 <heading>Example</heading>
4970 The <prgn>bind</prgn> DNS (nameserver) package wants to
4971 make sure that the nameserver is running in multiuser
4972 runlevels, and is properly shut down with the system. It
4973 puts a script in <file>/etc/init.d</file>, naming the script
4974 appropriately <tt>bind</tt>. As you can see, the script
4975 interprets the argument <tt>reload</tt> to send the
4976 nameserver a <tt>HUP</tt> signal (causing it to reload its
4977 configuration); this way the system administrator can say
4978 <tt>/etc/init.d/bind reload</tt> to reload the name
4979 server. The script has one configurable value, which can
4980 be used to pass parameters to the named program at
4981 startup; this value is read from
4982 <file>/etc/default/bind</file> (see below).
4986 <example compact="compact">
4989 # Original version by Robert Leslie
4990 # <rob@mars.org>, edited by iwj and cs
4992 test -x /usr/sbin/named || exit 0
4994 # Source defaults file.
4996 if [ -f /etc/default/bind ]; then
5003 echo -n "Starting domain name service: named"
5004 start-stop-daemon --start --quiet --exec /usr/sbin/named \
5009 echo -n "Stopping domain name service: named"
5010 start-stop-daemon --stop --quiet \
5011 --pidfile /var/run/named.pid --exec /usr/sbin/named
5015 echo -n "Restarting domain name service: named"
5016 start-stop-daemon --stop --quiet \
5017 --pidfile /var/run/named.pid --exec /usr/sbin/named
5018 start-stop-daemon --start --verbose --exec /usr/sbin/named \
5022 force-reload|reload)
5023 echo -n "Reloading configuration of domain name service: named"
5024 start-stop-daemon --stop --signal 1 --quiet \
5025 --pidfile /var/run/named.pid --exec /usr/sbin/named
5029 echo "Usage: /etc/init.d/bind " \
5030 " {start|stop|restart|reload|force-reload}" >&2
5040 Complementing the above init script is a configuration
5041 file <file>/etc/default/bind</file>, which contains
5042 configurable parameters used by the script. This would be
5043 created by the <prgn>postinst</prgn> script if it was not
5044 already present, and removed on purge by the
5045 <prgn>postrm</prgn> script.
5046 <example compact="compact">
5047 # Specified parameters to pass to named. See named(8).
5048 # You may uncomment the following line, and edit to taste.
5054 Another example on which you can base your
5055 <file>/etc/init.d</file> scripts is found in
5056 <file>/etc/init.d/skeleton</file>.
5060 If this package is happy with the default setup from
5061 <prgn>update-rc.d</prgn>, namely an ordering number of 20
5062 and having named running in all runlevels, it can say in
5063 its <prgn>postinst</prgn>:
5064 <example compact="compact">
5065 update-rc.d bind defaults >/dev/null
5067 And in its <prgn>postrm</prgn>, to remove the links when the
5069 <example compact="compact">
5070 if [ "$1" = purge ]; then
5071 update-rc.d bind remove >/dev/null
5079 <heading>Console messages from <file>init.d</file> scripts</heading>
5082 This section describes the formats to be used for messages
5083 written to standard output by the <file>/etc/init.d</file>
5084 scripts. The intent is to improve the consistency of
5085 Debian's startup and shutdown look and feel. For this
5086 reason, please look very carefully at the details. We want
5087 the messages to have the same format in terms of wording,
5088 spaces, punctuation and case of letters.
5092 Here is a list of overall rules that you should use when you
5093 create output messages. They can be useful if you have a
5094 non-standard message that is not covered specifically in the
5101 Every message should fit in one line (fewer than 80
5102 characters), start with a capital letter and end with
5103 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5107 If you want to express that the computer is working on
5108 something (that is, performing a specific task, not
5109 starting or stopping a program), we use an "ellipsis"
5110 (three dots: <tt>...</tt>). Note that we don't insert
5111 spaces before or after the dots. If the task has been
5112 completed we write <tt>done.</tt> and a line feed.
5116 Design your messages as if the computer is telling you
5117 what he is doing (let him be polite :-), but don't
5118 mention "him" directly. For example, if you think of
5120 <example compact="compact">
5121 I'm starting network daemons: nfsd mountd.
5124 <example compact="compact">
5125 Starting network daemons: nfsd mountd.
5132 There are standard message formats for the following
5133 situations. They should be used by the <tt>init.d</tt>
5140 <p>When daemons are started</p>
5143 If your script starts one or more daemons, the output
5144 should look like this (a single line, no leading
5146 <example compact="compact">
5147 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5149 The <var>description</var> should describe the
5150 subsystem the daemon or set of daemons are part of,
5151 while <var>daemon-1</var> up to <var>daemon-n</var>
5152 denote each daemon's name (typically the file name of
5157 For example, the output of <file>/etc/init.d/lpd</file>
5159 <example compact="compact">
5160 Starting printer spooler: lpd.
5165 This can be achieved by saying
5166 <example compact="compact">
5167 echo -n "Starting printer spooler: lpd"
5168 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5171 in the script. If you have more than one daemon to
5172 start, you should do the following:
5173 <example compact="compact">
5174 echo -n "Starting remote file system services:"
5175 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5176 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5177 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5180 This makes it possible for the user to see what takes
5181 so long and when the final daemon has been started.
5182 You should be careful where to put spaces: in the
5183 example above the system administrator can easily
5184 comment out a line if he don't wants to start a
5185 specific daemon, while the displayed message still
5191 <p>When a system parameter is being set</p>
5194 If you have to set up different system parameters
5195 during the system boot, you should use this format:
5196 <example compact="compact">
5197 Setting <var>parameter</var> to "<var>value</var>".
5202 You can use a statement such as the following to get
5204 <example compact="compact">
5205 echo "Setting DNS domainname to \"$domainname\"."
5210 Note that the same symbol (<tt>"</tt>) is used for the left
5211 and right quotation marks. A grave accent (<tt>`</tt>) is
5212 not a quote character; neither is an apostrophe
5218 <p>When a daemon is stopped or restarted</p>
5221 When you stop or restart a daemon, you should issue a
5222 message identical to the startup message, except that
5223 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5224 or <tt>Restarting</tt> respectively.
5228 For example, stopping the printer daemon will like
5230 <example compact="compact">
5231 Stopping printer spooler: lpd.
5237 <p>When something is executed</p>
5240 There are several examples where you have to run a
5241 program at system startup or shutdown to perform a
5242 specific task, for example, setting the system's clock
5243 using <prgn>netdate</prgn> or killing all processes
5244 when the system shuts down. Your message should look
5246 <example compact="compact">
5247 Doing something very useful...done.
5249 You should print the <tt>done.</tt> immediately after
5250 the job has been completed, so that the user is
5251 informed why she has to wait. You can get this
5253 <example compact="compact">
5254 echo -n "Doing something very useful..."
5263 <p>When the configuration is reloaded</p>
5266 When a daemon is forced to reload its configuration
5267 files you should use the following format:
5268 <example compact="compact">
5269 Reloading <var>description</var> configuration...done.
5271 where <var>description</var> is the same as in the
5272 daemon starting message.
5280 <heading>Cron jobs</heading>
5283 Packages must not modify the configuration file
5284 <file>/etc/crontab</file>, and they must not modify the files in
5285 <file>/var/spool/cron/crontabs</file>.</p>
5288 If a package wants to install a job that has to be executed
5289 via cron, it should place a file with the name of the
5290 package in one or more of the following directories:
5291 <example compact="compact">
5296 As these directory names imply, the files within them are
5297 executed on a daily, weekly, or monthly basis,
5298 respectively. The exact times are listed in
5299 <file>/etc/crontab</file>.</p>
5302 All files installed in any of these directories must be
5303 scripts (e.g., shell scripts or Perl scripts) so that they
5304 can easily be modified by the local system administrator.
5305 In addition, they should be treated as configuration
5310 If a certain job has to be executed more frequently than
5311 daily, the package should install a file
5312 <file>/etc/cron.d/<var>package</var></file>. This file uses the
5313 same syntax as <file>/etc/crontab</file> and is processed by
5314 <prgn>cron</prgn> automatically. The file must also be
5315 treated as a configuration file. (Note that entries in the
5316 <file>/etc/cron.d</file> directory are not handled by
5317 <prgn>anacron</prgn>. Thus, you should only use this
5318 directory for jobs which may be skipped if the system is not
5322 The scripts or crontab entries in these directories should
5323 check if all necessary programs are installed before they
5324 try to execute them. Otherwise, problems will arise when a
5325 package was removed but not purged since configuration files
5326 are kept on the system in this situation.</p>
5330 <heading>Menus</heading>
5333 The Debian <tt>menu</tt> package provides a standard
5334 interface between packages providing applications and
5335 documents, and <em>menu programs</em> (either X window
5336 managers or text-based menu programs such as
5337 <prgn>pdmenu</prgn>).
5341 All packages that provide applications that need not be
5342 passed any special command line arguments for normal
5343 operation should register a menu entry for those
5344 applications, so that users of the <tt>menu</tt> package
5345 will automatically get menu entries in their window
5346 managers, as well in shells like <tt>pdmenu</tt>.
5350 Menu entries should follow the current menu policy.
5354 The menu policy can be found in the <tt>menu-policy</tt>
5355 files in the <tt>debian-policy</tt> package.
5356 They are also available from the Debian web mirrors at
5357 <tt><url name="/doc/packaging-manuals/menu-policy/"
5358 id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>
5359 and from the Debian archive mirrors at
5360 <tt><url name="/doc/package-developer/menu-policy.txt.gz"
5361 id="http://ftp.debian.org/debian/doc/package-developer/menu-policy.txt.gz"></tt>.
5365 Please also refer to the <em>Debian Menu System</em>
5366 documentation that comes with the <tt>menu</tt> package for
5367 information about how to register your applications and web
5373 <heading>Multimedia handlers</heading>
5376 MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5377 is a mechanism for encoding files and data streams and
5378 providing meta-information about them, in particular their
5379 type (e.g. audio or video) and format (e.g. PNG, HTML,
5384 Registration of MIME type handlers allows programs like mail
5385 user agents and web browsers to to invoke these handlers to
5386 view, edit or display MIME types they don't support
5391 Packages which provide the ability to view/show/play,
5392 compose, edit or print MIME types should register themselves
5393 as such following the current MIME support policy.
5397 The MIME support policy can be found in the <tt>mime-policy</tt>
5398 files in the <tt>debian-policy</tt> package.
5399 They are also available from the Debian web mirrors at
5400 <tt><url name="/doc/packaging-manuals/mime-policy/"
5401 id="http://www.debian.org/doc/packaging-manuals/mime-policy/"></tt>
5402 and from the Debian archive mirrors at
5403 <tt><url name="/doc/package-developer/mime-policy.txt.gz"
5404 id="http://ftp.debian.org/debian/doc/package-developer/mime-policy.txt.gz"></tt>.
5410 <heading>Keyboard configuration</heading>
5413 To achieve a consistent keyboard configuration so that all
5414 applications interpret a keyboard event the same way, all
5415 programs in the Debian distribution must be configured to
5416 comply with the following guidelines.
5420 The following keys must have the specified interpretations:
5423 <tag><tt><--</tt></tag>
5424 <item>delete the character to the left of the cursor</item>
5426 <tag><tt>Delete</tt></tag>
5427 <item>delete the character to the right of the cursor</item>
5429 <tag><tt>Control+H</tt></tag>
5430 <item>emacs: the help prefix</item>
5433 The interpretation of any keyboard events should be
5434 independent of the terminal that is used, be it a virtual
5435 console, an X terminal emulator, an rlogin/telnet session,
5440 The following list explains how the different programs
5441 should be set up to achieve this:
5447 <tt><--</tt> generates <tt>KB_BackSpace</tt> in X.
5451 <tt>Delete</tt> generates <tt>KB_Delete</tt> in X.
5455 X translations are set up to make
5456 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5457 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5458 is the vt220 escape code for the "delete character"
5459 key). This must be done by loading the X resources
5460 using <prgn>xrdb</prgn> on all local X displays, not
5461 using the application defaults, so that the
5462 translation resources used correspond to the
5463 <prgn>xmodmap</prgn> settings.
5467 The Linux console is configured to make
5468 <tt><--</tt> generate DEL, and <tt>Delete</tt>
5469 generate <tt>ESC [ 3 ~</tt>.
5473 X applications are configured so that <tt><</tt>
5474 deletes left, and <tt>Delete</tt> deletes right. Motif
5475 applications already work like this.
5479 Terminals should have <tt>stty erase ^?</tt> .
5483 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5484 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5485 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.
5489 Emacs is programmed to map <tt>KB_Backspace</tt> or
5490 the <tt>stty erase</tt> character to
5491 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5492 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5493 <tt>^H</tt> to <tt>help</tt> as always.
5497 Other applications use the <tt>stty erase</tt>
5498 character and <tt>kdch1</tt> for the two delete keys,
5499 with ASCII DEL being "delete previous character" and
5500 <tt>kdch1</tt> being "delete character under
5508 This will solve the problem except for the following
5515 Some terminals have a <tt><--</tt> key that cannot
5516 be made to produce anything except <tt>^H</tt>. On
5517 these terminals Emacs help will be unavailable on
5518 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5519 character takes precedence in Emacs, and has been set
5520 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
5521 available) can be used instead.
5525 Some operating systems use <tt>^H</tt> for <tt>stty
5526 erase</tt>. However, modern telnet versions and all
5527 rlogin versions propagate <tt>stty</tt> settings, and
5528 almost all UNIX versions honour <tt>stty erase</tt>.
5529 Where the <tt>stty</tt> settings are not propagated
5530 correctly, things can be made to work by using
5531 <tt>stty</tt> manually.
5535 Some systems (including previous Debian versions) use
5536 <prgn>xmodmap</prgn> to arrange for both
5537 <tt><--</tt> and <tt>Delete</tt> to generate
5538 <tt>KB_Delete</tt>. We can change the behavior of
5539 their X clients using the same X resources that we use
5540 to do it for our own clients, or configure our clients
5541 using their resources when things are the other way
5542 around. On displays configured like this
5543 <tt>Delete</tt> will not work, but <tt><--</tt>
5548 Some operating systems have different <tt>kdch1</tt>
5549 settings in their <tt>terminfo</tt> database for
5550 <tt>xterm</tt> and others. On these systems the
5551 <tt>Delete</tt> key will not work correctly when you
5552 log in from a system conforming to our policy, but
5553 <tt><--</tt> will.
5560 <heading>Environment variables</heading>
5563 A program must not depend on environment variables to get
5564 reasonable defaults. (That's because these environment
5565 variables would have to be set in a system-wide
5566 configuration file like <file>/etc/profile</file>, which is not
5567 supported by all shells.)
5571 If a program usually depends on environment variables for its
5572 configuration, the program should be changed to fall back to
5573 a reasonable default configuration if these environment
5574 variables are not present. If this cannot be done easily
5575 (e.g., if the source code of a non-free program is not
5576 available), the program must be replaced by a small
5577 "wrapper" shell script which sets the environment variables
5578 if they are not already defined, and calls the original program.
5582 Here is an example of a wrapper script for this purpose:
5584 <example compact="compact">
5586 BAR=${BAR:-/var/lib/fubar}
5588 exec /usr/lib/foo/foo "$@"
5593 Furthermore, as <file>/etc/profile</file> is a configuration
5594 file of the <prgn>base-files</prgn> package, other packages must not
5595 put any environment variables or other commands into that
5604 <heading>Files</heading>
5607 <heading>Binaries</heading>
5610 Two different packages must not install programs with
5611 different functionality but with the same filenames. (The
5612 case of two programs having the same functionality but
5613 different implementations is handled via "alternatives" or
5614 the "Conflicts" mechanism. See <ref id="maintscripts"> and
5615 <ref id="conflicts"> respectively.) If this case happens,
5616 one of the programs must be renamed. The maintainers should
5617 report this to the <tt>debian-devel</tt> mailing list and
5618 try to find a consensus about which program will have to be
5619 renamed. If a consensus cannot be reached, <em>both</em>
5620 programs must be renamed.
5624 By default, when a package is being built, any binaries
5625 created should include debugging information, as well as
5626 being compiled with optimization. You should also turn on
5627 as many reasonable compilation warnings as possible; this
5628 makes life easier for porters, who can then look at build
5629 logs for possible problems. For the C programming language,
5630 this means the following compilation parameters should be
5632 <example compact="compact">
5634 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5636 install -s # (or use strip on the files in debian/tmp)
5641 Note that by default all installed binaries should be stripped,
5642 either by using the <tt>-s</tt> flag to
5643 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5644 the binaries after they have been copied into
5645 <file>debian/tmp</file> but before the tree is made into a
5650 Although binaries in the build tree should be compiled with
5651 debugging information by default, it can often be difficult
5652 to debug programs if they are also subjected to compiler
5653 optimization. For this reason, it is recommended to support
5654 the standardized environment
5655 variable <tt>DEB_BUILD_OPTIONS</tt>. This variable can
5656 contain several flags to change how a package is compiled
5664 The presence of this string means that the package
5665 should be complied with a minimum of optimization.
5666 For C programs, it is best to add <tt>-O0</tt>
5667 to <tt>CFLAGS</tt> (although this is usually the
5668 default). Some programs might fail to build or run at
5669 this level of optimization; it may be necessary to
5670 use <tt>-O1</tt>, for example.
5674 This string means that the debugging symbols should
5675 not be stripped from the binary during installation,
5676 so that debugging information may be included in the package.
5682 The following makefile snippet is an example of how one may
5683 implement the build options; you will probably have to
5684 massage this example in order to make it work for your
5686 <example compact="compact">
5689 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5690 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5691 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5692 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5694 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5699 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5700 INSTALL_PROGRAM += -s
5706 It is up to the package maintainer to decide what
5707 compilation options are best for the package. Certain
5708 binaries (such as computationally-intensive programs) will
5709 function better with certain flags (<tt>-O3</tt>, for
5710 example); feel free to use them. Please use good judgment
5711 here. Don't use flags for the sake of it; only use them
5712 if there is good reason to do so. Feel free to override
5713 the upstream author's ideas about which compilation
5714 options are best: they are often inappropriate for our
5720 <sect id="libraries">
5721 <heading>Libraries</heading>
5724 The shared version of a library must be compiled with
5725 <tt>-fPIC</tt>, and the static version must not be. In other
5726 words, each source unit (<tt>*.c</tt>, for example, for C files)
5727 will need to be compiled twice.
5731 You must specify the gcc option <tt>-D_REENTRANT</tt>
5732 when building a library (either static or shared) to make
5733 the library compatible with LinuxThreads.
5737 All installed shared libraries should be stripped with
5738 <example compact="compact">
5739 strip --strip-unneeded <var>your-lib</var>
5741 (The option <tt>--strip-unneeded</tt> makes
5742 <prgn>strip</prgn> remove only the symbols which aren't
5743 needed for relocation processing.) Shared libraries can
5744 function perfectly well when stripped, since the symbols for
5745 dynamic linking are in a separate part of the ELF object
5747 You might also want to use the options
5748 <tt>--remove-section=.comment</tt> and
5749 <tt>--remove-section=.note</tt> on both shared libraries
5750 and executables, and <tt>--strip-debug</tt> on static
5756 Note that under some circumstances it may be useful to
5757 install a shared library unstripped, for example when
5758 building a separate package to support debugging.
5762 Shared object files (often <file>.so</file> files) that are not
5763 public libraries, that is, they are not meant to be linked
5764 to by third party executables (binaries of other packages),
5765 should be installed in subdirectories of the
5766 <file>/usr/lib</file> directory. Such files are exempt from the
5767 rules that govern ordinary shared libraries, except that
5768 they must not be installed executable and should be
5770 A common example are the so-called "plug-ins",
5771 internal shared objects that are dynamically loaded by
5772 programs using <manref name="dlopen" section="3">.
5777 Packages containing shared libraries that may be linked to
5778 by other packages' binaries, but which for some
5779 <em>compelling</em> reason can not be installed in
5780 <file>/usr/lib</file> directory, may install the shared library
5781 files in subdirectories of the <file>/usr/lib</file> directory,
5782 in which case they should arrange to add that directory in
5783 <file>/etc/ld.so.conf</file> in the package's post-installation
5784 script, and remove it in the package's post-removal script.
5788 An ever increasing number of packages are using
5789 <prgn>libtool</prgn> to do their linking. The latest GNU
5790 libtools (>= 1.3a) can take advantage of the metadata in the
5791 installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5792 files). The main advantage of <prgn>libtool</prgn>'s
5793 <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5794 store and subsequently access metadata with respect to the
5795 libraries it builds. <prgn>libtool</prgn> will search for
5796 those files, which contain a lot of useful information about
5797 a library (such as library dependency information for static
5798 linking). Also, they're <em>essential</em> for programs
5799 using <tt>libltdl</tt>.<footnote>
5800 Although <prgn>libtool</prgn> is fully capable of
5801 linking against shared libraries which don't have
5802 <tt>.la</tt> files, as it is a mere shell script it can
5803 add considerably to the build time of a
5804 <prgn>libtool</prgn>-using package if that shell script
5805 has to derive all this information from first principles
5806 for each library every time it is linked. With the
5807 advent of <prgn>libtool</prgn> version 1.4 (and to a
5808 lesser extent <prgn>libtool</prgn> version 1.3), the
5809 <file>.la</file> files also store information about
5810 inter-library dependencies which cannot necessarily be
5811 derived after the <file>.la</file> file is deleted.
5816 Packages that use <prgn>libtool</prgn> to create shared
5817 libraries should include the <file>.la</file> files in the
5818 <tt>-dev</tt> package, unless the package relies on
5819 <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5820 the <tt>.la</tt> files must go in the run-time library
5825 You must make sure that you use only released versions of
5826 shared libraries to build your packages; otherwise other
5827 users will not be able to run your binaries
5828 properly. Producing source packages that depend on
5829 unreleased compilers is also usually a bad
5836 <heading>Shared libraries</heading>
5838 This section has moved to <ref id="sharedlibs">.
5844 <heading>Scripts</heading>
5847 All command scripts, including the package maintainer
5848 scripts inside the package and used by <prgn>dpkg</prgn>,
5849 should have a <tt>#!</tt> line naming the shell to be used
5854 In the case of Perl scripts this should be
5855 <tt>#!/usr/bin/perl</tt>.
5859 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5860 should almost certainly start with <tt>set -e</tt> so that
5861 errors are detected. Every script should use
5862 <tt>set -e</tt> or check the exit status of <em>every</em>
5867 The standard shell interpreter <file>/bin/sh</file> can be a
5868 symbolic link to any POSIX compatible shell, if <tt>echo
5869 -n</tt> does not generate a newline.<footnote>
5870 Debian policy specifies POSIX behavior for
5871 <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5872 use in the Linux community (in particular including this
5873 policy, the Linux kernel source, many Debian scripts,
5874 etc.). This <tt>echo -n</tt> mechanism is valid but not
5875 required under POSIX, hence this explicit addition.
5876 Also, rumour has it that this shall be mandated under
5879 Thus, shell scripts specifying <file>/bin/sh</file> as
5880 interpreter should only use POSIX features. If a script
5881 requires non-POSIX features from the shell interpreter, the
5882 appropriate shell must be specified in the first line of the
5883 script (e.g., <tt>#!/bin/bash</tt>) and the package must
5884 depend on the package providing the shell (unless the shell
5885 package is marked "Essential", as in the case of
5890 You may wish to restrict your script to POSIX features when
5891 possible so that it may use <file>/bin/sh</file> as its
5892 interpreter. If your script works with <prgn>dash</prgn>
5893 (originally called <prgn>ash</prgn>), it's probably POSIX
5894 compliant, but if you are in doubt, use
5895 <file>/bin/bash</file>.
5899 Perl scripts should check for errors when making any
5900 system calls, including <tt>open</tt>, <tt>print</tt>,
5901 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5905 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5906 scripting languages. See <em>Csh Programming Considered
5907 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5908 can be found at <url
5909 id="http://language.perl.com/versus/csh.whynot">.<footnote>
5910 It can also be found on
5911 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5912 or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5913 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5915 If an upstream package comes with <prgn>csh</prgn> scripts
5916 then you must make sure that they start with
5917 <tt>#!/bin/csh</tt> and make your package depend on the
5918 <prgn>c-shell</prgn> virtual package.
5922 Any scripts which create files in world-writeable
5923 directories (e.g., in <file>/tmp</file>) must use a
5924 mechanism which will fail if a file with the same name
5929 The Debian base system provides the <prgn>tempfile</prgn>
5930 and <prgn>mktemp</prgn> utilities for use by scripts for
5937 <heading>Symbolic links</heading>
5940 In general, symbolic links within a top-level directory
5941 should be relative, and symbolic links pointing from one
5942 top-level directory into another should be absolute. (A
5943 top-level directory is a sub-directory of the root
5944 directory <file>/</file>.)
5948 In addition, symbolic links should be specified as short as
5949 possible, i.e., link targets like <file>foo/../bar</file> are
5954 Note that when creating a relative link using
5955 <prgn>ln</prgn> it is not necessary for the target of the
5956 link to exist relative to the working directory you're
5957 running <prgn>ln</prgn> from, nor is it necessary to change
5958 directory to the directory where the link is to be made.
5959 Simply include the string that should appear as the target
5960 of the link (this will be a pathname relative to the
5961 directory in which the link resides) as the first argument
5966 For example, in your <prgn>Makefile</prgn> or
5967 <file>debian/rules</file>, you can do things like:
5968 <example compact="compact">
5969 ln -fs gcc $(prefix)/bin/cc
5970 ln -fs gcc debian/tmp/usr/bin/cc
5971 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5972 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5977 A symbolic link pointing to a compressed file should always
5978 have the same file extension as the referenced file. (For
5979 example, if a file <file>foo.gz</file> is referenced by a
5980 symbolic link, the filename of the link has to end with
5981 "<file>.gz</file>" too, as in <file>bar.gz</file>.)
5986 <heading>Device files</heading>
5989 Packages must not include device files in the package file
5994 If a package needs any special device files that are not
5995 included in the base system, it must call
5996 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
5997 after notifying the user<footnote>
5998 This notification could be done via a (low-priority)
5999 debconf message, or an echo (printf) statement.
6004 Packages must not remove any device files in the
6005 <prgn>postrm</prgn> or any other script. This is left to the
6006 system administrator.
6010 Debian uses the serial devices
6011 <file>/dev/ttyS*</file>. Programs using the old
6012 <file>/dev/cu*</file> devices should be changed to use
6013 <file>/dev/ttyS*</file>.
6017 <sect id="config-files">
6018 <heading>Configuration files</heading>
6021 <heading>Definitions</heading>
6025 <tag>configuration file</tag>
6027 A file that affects the operation of a program, or
6028 provides site- or host-specific information, or
6029 otherwise customizes the behavior of a program.
6030 Typically, configuration files are intended to be
6031 modified by the system administrator (if needed or
6032 desired) to conform to local policy or to provide
6033 more useful site-specific behavior.
6036 <tag><tt>conffile</tt></tag>
6038 A file listed in a package's <tt>conffiles</tt>
6039 file, and is treated specially by <prgn>dpkg</prgn>
6040 (see <ref id="configdetails">).
6046 The distinction between these two is important; they are
6047 not interchangeable concepts. Almost all
6048 <tt>conffile</tt>s are configuration files, but many
6049 configuration files are not <tt>conffiles</tt>.
6053 Note that a script that embeds configuration information
6054 (such as most of the files in <file>/etc/default</file> and
6055 <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6056 configuration file and should be treated as such.
6061 <heading>Location</heading>
6064 Any configuration files created or used by your package
6065 must reside in <file>/etc</file>. If there are several,
6066 consider creating a subdirectory of <file>/etc</file>
6067 named after your package.
6071 If your package creates or uses configuration files
6072 outside of <file>/etc</file>, and it is not feasible to modify
6073 the package to use <file>/etc</file> directly, put the files
6074 in <file>/etc</file> and create symbolic links to those files
6075 from the location that the package requires.
6080 <heading>Behavior</heading>
6083 Configuration file handling must conform to the following
6085 <list compact="compact">
6087 local changes must be preserved during a package
6091 configuration files must be preserved when the
6092 package is removed, and only deleted when the
6099 The easy way to achieve this behavior is to make the
6100 configuration file a <tt>conffile</tt>. This is
6101 appropriate only if it is possible to distribute a default
6102 version that will work for most installations, although
6103 some system administrators may choose to modify it. This
6104 implies that the default version will be part of the
6105 package distribution, and must not be modified by the
6106 maintainer scripts during installation (or at any other
6111 In order to ensure that local changes are preserved
6112 correctly, no package may contain or make hard links to
6113 conffiles.<footnote>
6114 Rationale: There are two problems with hard links.
6115 The first is that some editors break the link while
6116 editing one of the files, so that the two files may
6117 unwittingly become unlinked and different. The second
6118 is that <prgn>dpkg</prgn> might break the hard link
6119 while upgrading <tt>conffile</tt>s.
6124 The other way to do it is via the maintainer scripts. In
6125 this case, the configuration file must not be listed as a
6126 <tt>conffile</tt> and must not be part of the package
6127 distribution. If the existence of a file is required for
6128 the package to be sensibly configured it is the
6129 responsibility of the package maintainer to provide
6130 maintainer scripts which correctly create, update and
6131 maintain the file and remove it on purge. (See <ref
6132 id="maintainerscripts"> for more information.) These
6133 scripts must be idempotent (i.e., must work correctly if
6134 <prgn>dpkg</prgn> needs to re-run them due to errors
6135 during installation or removal), must cope with all the
6136 variety of ways <prgn>dpkg</prgn> can call maintainer
6137 scripts, must not overwrite or otherwise mangle the user's
6138 configuration without asking, must not ask unnecessary
6139 questions (particularly during upgrades), and otherwise be
6144 The scripts are not required to configure every possible
6145 option for the package, but only those necessary to get
6146 the package running on a given system. Ideally the
6147 sysadmin should not have to do any configuration other
6148 than that done (semi-)automatically by the
6149 <prgn>postinst</prgn> script.
6153 A common practice is to create a script called
6154 <file><var>package</var>-configure</file> and have the
6155 package's <prgn>postinst</prgn> call it if and only if the
6156 configuration file does not already exist. In certain
6157 cases it is useful for there to be an example or template
6158 file which the maintainer scripts use. Such files should
6159 be in <file>/usr/share/<var>package</var></file> or
6160 <file>/usr/lib/<var>package</var></file> (depending on whether
6161 they are architecture-independent or not). There should
6162 be symbolic links to them from
6163 <file>/usr/share/doc/<var>package</var>/examples</file> if
6164 they are examples, and should be perfectly ordinary
6165 <prgn>dpkg</prgn>-handled files (<em>not</em>
6166 configuration files).
6170 These two styles of configuration file handling must
6171 not be mixed, for that way lies madness:
6172 <prgn>dpkg</prgn> will ask about overwriting the file
6173 every time the package is upgraded.
6178 <heading>Sharing configuration files</heading>
6181 Packages which specify the same file as a
6182 <tt>conffile</tt> must be tagged as <em>conflicting</em>
6183 with each other. (This is an instance of the general rule
6184 about not sharing files. Note that neither alternatives
6185 nor diversions are likely to be appropriate in this case;
6186 in particular, <prgn>dpkg</prgn> does not handle diverted
6187 <tt>conffile</tt>s well.)
6191 The maintainer scripts must not alter a <tt>conffile</tt>
6192 of <em>any</em> package, including the one the scripts
6197 If two or more packages use the same configuration file
6198 and it is reasonable for both to be installed at the same
6199 time, one of these packages must be defined as
6200 <em>owner</em> of the configuration file, i.e., it will be
6201 the package which handles that file as a configuration
6202 file. Other packages that use the configuration file must
6203 depend on the owning package if they require the
6204 configuration file to operate. If the other package will
6205 use the configuration file if present, but is capable of
6206 operating without it, no dependency need be declared.
6210 If it is desirable for two or more related packages to
6211 share a configuration file <em>and</em> for all of the
6212 related packages to be able to modify that configuration
6213 file, then the following should be done:
6214 <enumlist compact="compact">
6216 One of the related packages (the "owning" package)
6217 will manage the configuration file with maintainer
6218 scripts as described in the previous section.
6221 The owning package should also provide a program
6222 that the other packages may use to modify the
6226 The related packages must use the provided program
6227 to make any desired modifications to the
6228 configuration file. They should either depend on
6229 the core package to guarantee that the configuration
6230 modifier program is available or accept gracefully
6231 that they cannot modify the configuration file if it
6232 is not. (This is in addition to the fact that the
6233 configuration file may not even be present in the
6240 Sometimes it's appropriate to create a new package which
6241 provides the basic infrastructure for the other packages
6242 and which manages the shared configuration files. (The
6243 <tt>sgml-base</tt> package is a good example.)
6248 <heading>User configuration files ("dotfiles")</heading>
6251 The files in <file>/etc/skel</file> will automatically be
6252 copied into new user accounts by <prgn>adduser</prgn>.
6253 No other program should reference the files in
6254 <file>/etc/skel</file>.
6258 Therefore, if a program needs a dotfile to exist in
6259 advance in <file>$HOME</file> to work sensibly, that dotfile
6260 should be installed in <file>/etc/skel</file> and treated as a
6265 However, programs that require dotfiles in order to
6266 operate sensibly are a bad thing, unless they do create
6267 the dotfiles themselves automatically.
6271 Furthermore, programs should be configured by the Debian
6272 default installation to behave as closely to the upstream
6273 default behaviour as possible.
6277 Therefore, if a program in a Debian package needs to be
6278 configured in some way in order to operate sensibly, that
6279 should be done using a site-wide configuration file placed
6280 in <file>/etc</file>. Only if the program doesn't support a
6281 site-wide default configuration and the package maintainer
6282 doesn't have time to add it may a default per-user file be
6283 placed in <file>/etc/skel</file>.
6287 <file>/etc/skel</file> should be as empty as we can make it.
6288 This is particularly true because there is no easy (or
6289 necessarily desirable) mechanism for ensuring that the
6290 appropriate dotfiles are copied into the accounts of
6291 existing users when a package is installed.
6297 <heading>Log files</heading>
6299 Log files should usually be named
6300 <file>/var/log/<var>package</var>.log</file>. If you have many
6301 log files, or need a separate directory for permission
6302 reasons (<file>/var/log</file> is writable only by
6303 <file>root</file>), you should usually create a directory named
6304 <file>/var/log/<var>package</var></file> and place your log
6309 Log files must be rotated occasionally so that they don't
6310 grow indefinitely; the best way to do this is to drop a log
6311 rotation configuration file into the directory
6312 <file>/etc/logrotate.d</file> and use the facilities provided by
6313 logrotate.<footnote>
6315 The traditional approach to log files has been to set up
6316 <em>ad hoc</em> log rotation schemes using simple shell
6317 scripts and cron. While this approach is highly
6318 customizable, it requires quite a lot of sysadmin work.
6319 Even though the original Debian system helped a little
6320 by automatically installing a system which can be used
6321 as a template, this was deemed not enough.
6325 The use of <prgn>logrotate</prgn>, a program developed
6326 by Red Hat, is better, as it centralizes log management.
6327 It has both a configuration file
6328 (<file>/etc/logrotate.conf</file>) and a directory where
6329 packages can drop their individual log rotation
6330 configurations (<file>/etc/logrotate.d</file>).
6333 Here is a good example for a logrotate config
6334 file (for more information see <manref name="logrotate"
6336 <example compact="compact">
6337 /var/log/foo/*.log {
6342 /etc/init.d/foo force-reload
6346 This rotates all files under <file>/var/log/foo</file>, saves 12
6347 compressed generations, and forces the daemon to reload its
6348 configuration information after the log rotation.
6352 Log files should be removed when the package is
6353 purged (but not when it is only removed). This should be
6354 done by the <prgn>postrm</prgn> script when it is called
6355 with the argument <tt>purge</tt> (see <ref
6356 id="removedetails">).
6361 <heading>Permissions and owners</heading>
6364 The rules in this section are guidelines for general use.
6365 If necessary you may deviate from the details below.
6366 However, if you do so you must make sure that what is done
6367 is secure and you should try to be as consistent as possible
6368 with the rest of the system. You should probably also
6369 discuss it on <prgn>debian-devel</prgn> first.
6373 Files should be owned by <tt>root.root</tt>, and made
6374 writable only by the owner and universally readable (and
6375 executable, if appropriate), that is mode 644 or 755.
6379 Directories should be mode 755 or (for group-writability)
6380 mode 2775. The ownership of the directory should be
6381 consistent with its mode: if a directory is mode 2775, it
6382 should be owned by the group that needs write access to
6387 Setuid and setgid executables should be mode 4755 or 2755
6388 respectively, and owned by the appropriate user or group.
6389 They should not be made unreadable (modes like 4711 or
6390 2711 or even 4111); doing so achieves no extra security,
6391 because anyone can find the binary in the freely available
6392 Debian package; it is merely inconvenient. For the same
6393 reason you should not restrict read or execute permissions
6394 on non-set-id executables.
6398 Some setuid programs need to be restricted to particular
6399 sets of users, using file permissions. In this case they
6400 should be owned by the uid to which they are set-id, and by
6401 the group which should be allowed to execute them. They
6402 should have mode 4754; again there is no point in making
6403 them unreadable to those users who must not be allowed to
6408 It is possible to arrange that the system administrator can
6409 reconfigure the package to correspond to their local
6410 security policy by changing the permissions on a binary:
6411 they can do this by using <prgn>dpkg-statoverride</prgn>, as
6412 described below.<footnote>
6414 Ordinary files installed by <prgn>dpkg</prgn> (as
6415 opposed to <tt>conffile</tt>s and other similar objects)
6416 normally have their permissions reset to the distributed
6417 permissions when the package is reinstalled. However,
6418 the use of <prgn>dpkg-statoverride</prgn> overrides this
6419 default behaviour. If you use this method, you should
6420 remember to describe <prgn>dpkg-statoverride</prgn> in
6421 the package documentation; being a relatively new
6422 addition to Debian, it is probably not yet well-known.
6425 Another method you should consider is to create a group for
6426 people allowed to use the program(s) and make any setuid
6427 executables executable only by that group.
6431 If you need to create a new user or group for your package
6432 there are two possibilities. Firstly, you may need to
6433 make some files in the binary package be owned by this
6434 user or group, or you may need to compile the user or
6435 group id (rather than just the name) into the binary
6436 (though this latter should be avoided if possible, as in
6437 this case you need a statically allocated id).</p>
6440 If you need a statically allocated id, you must ask for a
6441 user or group id from the <tt>base-passwd</tt> maintainer,
6442 and must not release the package until you have been
6443 allocated one. Once you have been allocated one you must
6444 either make the package depend on a version of the
6445 <tt>base-passwd</tt> package with the id present in
6446 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6447 your package to create the user or group itself with the
6448 correct id (using <tt>adduser</tt>) in its
6449 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
6450 the <prgn>postinst</prgn> is to be preferred if it is
6451 possible, otherwise a pre-dependency will be needed on the
6452 <tt>adduser</tt> package.)
6456 On the other hand, the program might be able to determine
6457 the uid or gid from the user or group name at runtime, so
6458 that a dynamically allocated id can be used. In this case
6459 you should choose an appropriate user or group name,
6460 discussing this on <prgn>debian-devel</prgn> and checking
6461 with the <package/base-passwd/ maintainer that it is unique and that
6462 they do not wish you to use a statically allocated id
6463 instead. When this has been checked you must arrange for
6464 your package to create the user or group if necessary using
6465 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6466 <prgn>postinst</prgn> script (again, the latter is to be
6467 preferred if it is possible).
6471 Note that changing the numeric value of an id associated
6472 with a name is very difficult, and involves searching the
6473 file system for all appropriate files. You need to think
6474 carefully whether a static or dynamic id is required, since
6475 changing your mind later will cause problems.
6478 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6480 This section is not intended as policy, but as a
6481 description of the use of <prgn>dpkg-statoverride</prgn>.
6485 <prgn>dpkg-statoverride</prgn> is a replacement for the
6486 deprecated <tt>suidmanager</tt> package. Packages which
6487 previously used <tt>suidmanager</tt> should have a
6488 <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6489 <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6490 and <tt>suidunregister</tt> should now be simply removed
6491 from the maintainer scripts.
6495 If a system administrator wishes to have a file (or
6496 directory or other such thing) installed with owner and
6497 permissions different from those in the distributed Debian
6498 package, he can use the <prgn>dpkg-statoverride</prgn>
6499 program to instruct <prgn>dpkg</prgn> to use the different
6500 settings every time the file is installed. Thus the
6501 package maintainer should distribute the files with their
6502 normal permissions, and leave it for the system
6503 administrator to make any desired changes. For example, a
6504 daemon which is normally required to be setuid root, but
6505 in certain situations could be used without being setuid,
6506 should be installed setuid in the <tt>.deb</tt>. Then the
6507 local system administrator can change this if they wish.
6508 If there are two standard ways of doing it, the package
6509 maintainer can use <tt>debconf</tt> to find out the
6510 preference, and call <prgn>dpkg-statoverride</prgn> in the
6511 maintainer script if necessary to accommodate the system
6512 administrator's choice.
6516 Given the above, <prgn>dpkg-statoverride</prgn> is
6517 essentially a tool for system administrators and would not
6518 normally be needed in the maintainer scripts. There is
6519 one type of situation, though, where calls to
6520 <prgn>dpkg-statoverride</prgn> would be needed in the
6521 maintainer scripts, and that involves packages which use
6522 dynamically allocated user or group ids. In such a
6523 situation, something like the following idiom can be very
6524 helpful in the package's <prgn>postinst</prgn>, where
6525 <tt>sysuser</tt> is a dynamically allocated id:
6527 for i in /usr/bin/foo /usr/sbin/bar
6529 if ! dpkg-statoverride --list $i >/dev/null
6531 dpkg-statoverride --update --add sysuser root 4755 $i
6535 The corresponding <tt>dpkg-statoverride --remove</tt>
6536 calls can then be made unconditionally when the package is
6543 <chapt id="customized-programs">
6544 <heading>Customized programs</heading>
6546 <sect id="arch-spec">
6547 <heading>Architecture specification strings</heading>
6550 If a program needs to specify an <em>architecture specification
6551 string</em> in some place, the following format should be
6552 used: <var>arch</var>-<var>os</var><footnote>
6554 The following architectures and operating systems are
6555 currently recognised by <prgn>dpkg-archictecture</prgn>.
6556 The architecture, <tt><var>arch</var></tt>, is one of
6557 the following: <tt>alpha</tt>, <tt>arm</tt>,
6558 <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6559 <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6560 <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6561 <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>. The
6562 operating system, <tt><var>os</var></tt>, is one of:
6563 <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6564 <tt>openbsd</tt>. Use of <tt>gnu</tt> in this string is
6565 reserved for the GNU/Hurd operating system.
6571 Note that we don't want to use
6572 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6573 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6574 since this would make our programs incompatible with other
6575 Linux distributions. We also don't use something like
6576 <tt><var>arch</var>-unknown-linux</tt>, since the
6577 <tt>unknown</tt> does not look very good.
6582 <heading>Daemons</heading>
6585 The configuration files <file>/etc/services</file>,
6586 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6587 by the <prgn>netbase</prgn> package and must not be modified
6592 If a package requires a new entry in one of these files, the
6593 maintainer should get in contact with the
6594 <prgn>netbase</prgn> maintainer, who will add the entries
6595 and release a new version of the <prgn>netbase</prgn>
6600 The configuration file <file>/etc/inetd.conf</file> must not be
6601 modified by the package's scripts except via the
6602 <prgn>update-inetd</prgn> script or the
6603 <file>DebianNet.pm</file> Perl module. See their documentation
6604 for details on how to add entries.
6608 If a package wants to install an example entry into
6609 <file>/etc/inetd.conf</file>, the entry must be preceded with
6610 exactly one hash character (<tt>#</tt>). Such lines are
6611 treated as "commented out by user" by the
6612 <prgn>update-inetd</prgn> script and are not changed or
6613 activated during package updates.
6618 <heading>Using pseudo-ttys and modifying wtmp, utmp and
6622 Some programs need to create pseudo-ttys. This should be done
6623 using Unix98 ptys if the C library supports it. The resulting
6624 program must not be installed setuid root, unless that
6625 is required for other functionality.
6629 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6630 <file>/var/log/lastlog</file> must be installed writeable by
6631 group <tt>utmp</tt>. Programs which need to modify those
6632 files must be installed setgid <tt>utmp</tt>.
6637 <heading>Editors and pagers</heading>
6640 Some programs have the ability to launch an editor or pager
6641 program to edit or display a text document. Since there are
6642 lots of different editors and pagers available in the Debian
6643 distribution, the system administrator and each user should
6644 have the possibility to choose his/her preferred editor and
6649 In addition, every program should choose a good default
6650 editor/pager if none is selected by the user or system
6655 Thus, every program that launches an editor or pager must
6656 use the EDITOR or PAGER environment variable to determine
6657 the editor or pager the user wishes to use. If these
6658 variables are not set, the programs <file>/usr/bin/editor</file>
6659 and <file>/usr/bin/pager</file> should be used, respectively.
6663 These two files are managed through the <prgn>dpkg</prgn>
6664 "alternatives" mechanism. Thus every package providing an
6665 editor or pager must call the
6666 <prgn>update-alternatives</prgn> script to register these
6671 If it is very hard to adapt a program to make use of the
6672 EDITOR or PAGER variables, that program may be configured to
6673 use <file>/usr/bin/sensible-editor</file> and
6674 <file>/usr/bin/sensible-pager</file> as the editor or pager
6675 program respectively. These are two scripts provided in the
6676 Debian base system that check the EDITOR and PAGER variables
6677 and launch the appropriate program, and fall back to
6678 <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6679 variable is not set.
6683 A program may also use the VISUAL environment variable to
6684 determine the user's choice of editor. If it exists, it
6685 should take precedence over EDITOR. This is in fact what
6686 <file>/usr/bin/sensible-editor</file> does.
6690 It is not required for a package to depend on
6691 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6692 package to provide such virtual packages.<footnote>
6694 The Debian base system already provides an editor and a
6701 <sect id="web-appl">
6702 <heading>Web servers and applications</heading>
6705 This section describes the locations and URLs that should
6706 be used by all web servers and web applications in the
6713 Cgi-bin executable files are installed in the
6715 <example compact="compact">
6716 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6718 and should be referred to as
6719 <example compact="compact">
6720 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6725 <p>Access to HTML documents</p>
6728 HTML documents for a package are stored in
6729 <file>/usr/share/doc/<var>package</var></file>
6730 and can be referred to as
6731 <example compact="compact">
6732 http://localhost/doc/<var>package</var>/<var>filename</var>
6737 The web server should restrict access to the document
6738 tree so that only clients on the same host can read
6739 the documents. If the web server does not support such
6740 access controls, then it should not provide access at
6741 all, or ask about providing access during installation.
6746 <p>Web Document Root</p>
6749 Web Applications should try to avoid storing files in
6750 the Web Document Root. Instead they should use the
6751 /usr/share/doc/<var>package</var> directory for
6752 documents and register the Web Application via the
6753 menu package. If access to the web document root is
6754 unavoidable then use
6755 <example compact="compact">
6758 as the Document Root. This might be just a symbolic
6759 link to the location where the system administrator
6760 has put the real document root.
6768 <sect id="mail-transport-agents">
6769 <heading>Mail transport, delivery and user agents</heading>
6772 Debian packages which process electronic mail, whether mail
6773 user agents (MUAs) or mail transport agents (MTAs), must
6774 ensure that they are compatible with the configuration
6775 decisions below. Failure to do this may result in lost
6776 mail, broken <tt>From:</tt> lines, and other serious brain
6781 The mail spool is <file>/var/mail</file> and the interface to
6782 send a mail message is <file>/usr/sbin/sendmail</file> (as per
6783 the FHS). On older systems, the mail spool may be
6784 physically located in <file>/var/spool/mail</file>, but all
6785 access to the mail spool should be via the
6786 <file>/var/mail</file> symlink. The mail spool is part of the
6787 base system and not part of the MTA package.
6791 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6792 programs (such as IMAP daemons) must lock the mailbox in an
6793 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6794 be combined with dot locking. To avoid deadlocks, a program
6795 should use <tt>fcntl()</tt> first and dot locking after
6796 this, or alternatively implement the two locking methods in
6797 a non blocking way<footnote>
6799 If it is not possible to establish both locks, the
6800 system shouldn't wait for the second lock to be
6801 established, but remove the first lock, wait a (random)
6802 time, and start over locking again.
6804 </footnote>. Using the functions <tt>maillock</tt> and
6805 <tt>mailunlock</tt> provided by the
6806 <tt>liblockfile*</tt><footnote>
6808 You will need to depend on <tt>liblockfile1
6809 (>>1.01)</tt> to use these functions.
6811 </footnote> packages is the recommended way to realize this.
6815 Mailboxes are generally mode 660
6816 <tt><var>user</var>.mail</tt> unless the system
6817 administrator has chosen otherwise. A MUA may remove a
6818 mailbox (unless it has nonstandard permissions) in which
6819 case the MTA or another MUA must recreate it if needed.
6820 Mailboxes must be writable by group mail.
6824 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6825 be setgid mail to do the locking mentioned above (and
6826 must obviously avoid accessing other users' mailboxes
6827 using this privilege).</p>
6830 <file>/etc/aliases</file> is the source file for the system mail
6831 aliases (e.g., postmaster, usenet, etc.), it is the one
6832 which the sysadmin and <prgn>postinst</prgn> scripts may
6833 edit. After <file>/etc/aliases</file> is edited the program or
6834 human editing it must call <prgn>newaliases</prgn>. All MTA
6835 packages must come with a <prgn>newaliases</prgn> program,
6836 even if it does nothing, but older MTA packages did not do
6837 this so programs should not fail if <prgn>newaliases</prgn>
6838 cannot be found. Note that because of this, all MTA
6839 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6840 <tt>Replaces: mail-transport-agent</tt> control file
6845 The convention of writing <tt>forward to
6846 <var>address</var></tt> in the mailbox itself is not
6847 supported. Use a <tt>.forward</tt> file instead.</p>
6850 The <prgn>rmail</prgn> program used by UUCP
6851 for incoming mail should be <file>/usr/sbin/rmail</file>.
6852 Likewise, <prgn>rsmtp</prgn>, for receiving
6853 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6857 If your package needs to know what hostname to use on (for
6858 example) outgoing news and mail messages which are generated
6859 locally, you should use the file <file>/etc/mailname</file>. It
6860 will contain the portion after the username and <tt>@</tt>
6861 (at) sign for email addresses of users on the machine
6862 (followed by a newline).
6866 Such package should check for the existence of this file
6867 when it is being configured. If it exists, it should be
6868 used without comment, although an MTA's configuration script
6869 may wish to prompt the user even if it finds that this file
6870 exists. If the file does not exist, the package should
6871 prompt the user for the value (preferably using
6872 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6873 as well as using it in the package's configuration. The
6874 prompt should make it clear that the name will not just be
6875 used by that package. For example, in this situation the
6876 <tt>inn</tt> package could say something like:
6877 <example compact="compact">
6878 Please enter the "mail name" of your system. This is the
6879 hostname portion of the address to be shown on outgoing
6880 news and mail messages. The default is
6881 <var>syshostname</var>, your system's host name. Mail
6882 name ["<var>syshostname</var>"]:
6884 where <var>syshostname</var> is the output of <tt>hostname
6890 <heading>News system configuration</heading>
6893 All the configuration files related to the NNTP (news)
6894 servers and clients should be located under
6895 <file>/etc/news</file>.</p>
6898 There are some configuration issues that apply to a number
6899 of news clients and server packages on the machine. These
6903 <tag><file>/etc/news/organization</file></tag>
6905 A string which should appear as the
6906 organization header for all messages posted
6907 by NNTP clients on the machine
6910 <tag><file>/etc/news/server</file></tag>
6912 Contains the FQDN of the upstream NNTP
6913 server, or localhost if the local machine is
6918 Other global files may be added as required for cross-package news
6925 <heading>Programs for the X Window System</heading>
6928 <heading>Providing X support and package priorities</heading>
6931 Programs that can be configured with support for the X
6932 Window System must be configured to do so and must declare
6933 any package dependencies necessary to satisfy their
6934 runtime requirements when using the X Window System. If
6935 such a package is of higher priority than the X packages
6936 on which it depends, it is required that either the
6937 X-specific components be split into a separate package, or
6938 that an alternative version of the package, which includes
6939 X support, be provided, or that the package's priority be
6945 <heading>Packages providing an X server</heading>
6948 Packages that provide an X server that, directly or
6949 indirectly, communicates with real input and display
6950 hardware should declare in their control data that they
6951 provide the virtual package <tt>xserver</tt>.<footnote>
6952 This implements current practice, and provides an
6953 actual policy for usage of the <tt>xserver</tt>
6954 virtual package which appears in the virtual packages
6955 list. In a nutshell, X servers that interface
6956 directly with the display and input hardware or via
6957 another subsystem (e.g., GGI) should provide
6958 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
6959 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
6965 <heading>Packages providing a terminal emulator</heading>
6968 Packages that provide a terminal emulator for the X Window
6969 System which meet the criteria listed below should declare
6970 in their control data that they provide the virtual
6971 package <tt>x-terminal-emulator</tt>. They should also
6972 register themselves as an alternative for
6973 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
6978 To be an <tt>x-terminal-emulator</tt>, a program must:
6979 <list compact="compact">
6981 Be able to emulate a DEC VT100 terminal, or a
6982 compatible terminal.
6986 Support the command-line option <tt>-e
6987 <var>command</var></tt>, which creates a new
6988 terminal window<footnote>
6989 "New terminal window" does not necessarily mean
6990 a new top-level X window directly parented by
6991 the window manager; it could, if the terminal
6992 emulator application were so coded, be a new
6993 "view" in a multiple-document interface (MDI).
6995 and runs the specified <var>command</var>,
6996 interpreting the entirity of the rest of the command
6997 line as a command to pass straight to exec, in the
6998 manner that <tt>xterm</tt> does.
7002 Support the command-line option <tt>-T
7003 <var>title</var></tt>, which creates a new terminal
7004 window with the window title <var>title</var>.
7011 <heading>Packages providing a window manager</heading>
7014 Packages that provide a window manager should declare in
7015 their control data that they provide the virtual package
7016 <tt>x-window-manager</tt>. They should also register
7017 themselves as an alternative for
7018 <file>/usr/bin/x-window-manager</file>, with a priority
7019 calculated as follows:
7020 <list compact="compact">
7022 Start with a priority of 20.
7026 If the window manager supports the Debian menu
7027 system, add 20 points if this support is available
7028 in the package's default configuration (i.e., no
7029 configuration files belonging to the system or user
7030 have to be edited to activate the feature); if
7031 configuration files must be modified, add only 10
7036 If the window manager complies with <url
7037 id="http://www.freedesktop.org/standards/wm-spec.html"
7038 name="The Window Manager Specification Project">,
7039 written by the <url id="http://www.freedesktop.org"
7040 name="Free Desktop Group">, add 40 points.
7044 If the window manager permits the X session to be
7045 restarted using a <em>different</em> window manager
7046 (without killing the X server) in its default
7047 configuration, add 10 points; otherwise add none.
7054 <heading>Packages providing fonts</heading>
7057 Packages that provide fonts for the X Window
7059 For the purposes of Debian Policy, a "font for the X
7060 Window System" is one which is accessed via X protocol
7061 requests. Fonts for the Linux console, for PostScript
7062 renderers, or any other purpose, do not fit this
7063 definition. Any tool which makes such fonts available
7064 to the X Window System, however, must abide by this
7067 must do a number of things to ensure that they are both
7068 available without modification of the X or font server
7069 configuration, and that they do not corrupt files used by
7070 other font packages to register information about
7074 Fonts of any type supported by the X Window System
7075 must be in a separate binary package from any
7076 executables, libraries, or documentation (except
7077 that specific to the fonts shipped, such as their
7078 license information). If one or more of the fonts
7079 so packaged are necessary for proper operation of
7080 the package with which they are associated the font
7081 package may be Recommended; if the fonts merely
7082 provide an enhancement, a Suggests relationship may
7083 be used. Packages must not Depend on font
7085 This is because the X server may retrieve fonts
7086 from the local filesystem or over the network
7087 from an X font server; the Debian package system
7088 is empowered to deal only with the local
7094 BDF fonts must be converted to PCF fonts with the
7095 <prgn>bdftopcf</prgn> utility (available in the
7096 <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7097 placed in a directory that corresponds to their
7099 <list compact="compact">
7101 100 dpi fonts must be placed in
7102 <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7106 75 dpi fonts must be placed in
7107 <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7111 Character-cell fonts, cursor fonts, and other
7112 low-resolution fonts must be placed in
7113 <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7119 Speedo fonts must be placed in
7120 <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7124 Type 1 fonts must be placed in
7125 <file>/usr/X11R6/lib/X11/fonts/Type1/</file>. If font
7126 metric files are available, they must be placed here
7131 Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7132 other than those listed above must be neither
7133 created nor used. (The <file>PEX</file>, <file>CID</file>,
7134 and <file>cyrillic</file> directories are excepted for
7135 historical reasons, but installation of files into
7136 these directories remains discouraged.)
7140 Font packages may, instead of placing files directly
7141 in the X font directories listed above, provide
7142 symbolic links in that font directory pointing to
7143 the files' actual location in the filesystem. Such
7144 a location must comply with the FHS.
7148 Font packages should not contain both 75dpi and
7149 100dpi versions of a font. If both are available,
7150 they should be provided in separate binary packages
7151 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7152 the names of the packages containing the
7153 corresponding fonts.
7157 Fonts destined for the <file>misc</file> subdirectory
7158 should not be included in the same package as 75dpi
7159 or 100dpi fonts; instead, they should be provided in
7160 a separate package with <tt>-misc</tt> appended to
7165 Font packages must not provide the files
7166 <file>fonts.dir</file>, <file>fonts.alias</file>, or
7167 <file>fonts.scale</file> in a font directory:
7170 <file>fonts.dir</file> files must not be provided at all.
7174 <file>fonts.alias</file> and <file>fonts.scale</file>
7175 files, if needed, should be provided in the
7177 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7178 where <var>fontdir</var> is the name of the
7180 <file>/usr/X11R6/lib/X11/fonts/</file> where the
7181 package's corresponding fonts are stored
7182 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7183 <var>package</var> is the name of the package
7184 that provides these fonts, and
7185 <var>extension</var> is either <tt>scale</tt>
7186 or <tt>alias</tt>, whichever corresponds to
7193 Font packages must declare a dependency on
7194 <tt>xutils (>> 4.0.3)</tt> in their control
7199 Font packages that provide one or more
7200 <file>fonts.scale</file> files as described above must
7201 invoke <prgn>update-fonts-scale</prgn> on each
7202 directory into which they installed fonts
7203 <em>before</em> invoking
7204 <prgn>update-fonts-dir</prgn> on that directory.
7205 This invocation must occur in both the
7206 <prgn>postinst</prgn> (for all arguments) and
7207 <prgn>postrm</prgn> (for all arguments except
7208 <tt>upgrade</tt>) scripts.
7212 Font packages that provide one or more
7213 <file>fonts.alias</file> files as described above must
7214 invoke <prgn>update-fonts-alias</prgn> on each
7215 directory into which they installed fonts. This
7216 invocation must occur in both the
7217 <prgn>postinst</prgn> (for all arguments) and
7218 <prgn>postrm</prgn> (for all arguments except
7219 <tt>upgrade</tt>) scripts.
7223 Font packages must invoke
7224 <prgn>update-fonts-dir</prgn> on each directory into
7225 which they installed fonts. This invocation must
7226 occur in both the <prgn>postinst</prgn> (for all
7227 arguments) and <prgn>postrm</prgn> (for all
7228 arguments except <tt>upgrade</tt>) scripts.
7232 Font packages must not provide alias names for the
7233 fonts they include which collide with alias names
7234 already in use by fonts already packaged.
7238 Font packages must not provide fonts with the same
7239 XLFD registry name as another font already packaged.
7246 <heading>Application defaults files</heading>
7249 Application defaults files must be installed in the
7250 directory <file>/etc/X11/app-defaults/</file> (use of a
7251 localized subdirectory of <file>/etc/X11/</file> as described
7252 in the <em>X Toolkit Intrinsics - C Language
7253 Interface</em> manual is also permitted). They must be
7254 registered as <tt>conffile</tt>s or handled as
7255 configuration files. Packages must not provide the
7256 directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7260 Customization of programs' X resources may also be
7261 supported with the provision of a file with the same name
7262 as that of the package placed in the
7263 <file>/etc/X11/Xresources/</file> directory, which must
7264 registered as a <tt>conffile</tt> or handled as a
7265 configuration file.<footnote>
7266 Note that this mechanism is not the same as using
7267 app-defaults; app-defaults are tied to the client
7268 binary on the local filesystem, whereas X resources
7269 are stored in the X server and affect all connecting
7272 <em>Important:</em> packages that install files into the
7273 <file>/etc/X11/Xresources/</file> directory must conflict with
7274 <tt>xbase (<< 3.3.2.3a-2)</tt>; if this is not done
7275 it is possible for the installing package to destroy a
7276 previously-existing <file>/etc/X11/Xresources</file> file
7277 which had been customized by the system administrator.
7282 <heading>Installation directory issues</heading>
7285 Packages using the X Window System should not be
7286 configured to install files under the <file>/usr/X11R6/</file>
7287 directory unless they use <prgn>imake</prgn>. The
7288 <file>/usr/X11R6/</file> directory hierarchy should be
7289 regarded as deprecated for all packages except the X
7290 Window System itself, and those which use the
7291 <prgn>imake</prgn> program it provides, in which case the
7292 packages may transition out of the <file>/usr/X11R6/</file>
7293 directory at the maintainer's discretion.<footnote>
7294 <prgn>Imake</prgn>-using programs are exempt because,
7295 as long as they are written correctly, the pathnames
7296 they use to locate resources and install themselves
7297 are derived wholly from the X Window System
7298 configuration. Thus, in the event that the X Window
7299 System moves to <file>/usr/X11R7/</file>,
7300 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7301 that is required for these programs is a recompile
7302 against the corresponding X Window System library
7303 development packages.
7308 Programs that use GNU <prgn>autoconf</prgn> and
7309 <prgn>automake</prgn> are usually easily configured at
7310 compile time to use <file>/usr/</file> instead of
7311 <file>/usr/X11R6/</file>, and this should be done whenever
7312 possible. Configuration files for window managers and
7313 display managers should be placed in a subdirectory of
7314 <file>/etc/X11/</file> corresponding to the package name due
7315 to these programs' tight integration with the mechanisms
7316 of the X Window System. Application-level programs should
7317 use the <file>/etc/</file> directory unless otherwise mandated
7322 The installation of files into subdirectories
7323 of <file>/usr/X11R6/include/X11/</file> and
7324 <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7325 package maintainers should determine if subdirectories of
7326 <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7327 instead. (The use of symbolic links from the
7328 <file>X11R6</file> directories to other FHS-compliant
7329 locations is encouraged if the program is not easily
7330 configured to look elsewhere for its files.)
7334 Packages must not provide or install files into the directories
7335 <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7336 <file>/usr/lib/X11/</file>. Files within a package should,
7337 however, make reference to these directories, rather than
7338 their <tt>X11R6</tt>-named counterparts
7339 <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7340 and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7341 referred to have not been moved to other FHS-compliant
7347 <heading>The OSF/Motif and OpenMotif libraries</heading>
7350 <em>Programs that require the non-DFSG-compliant OSF/Motif or
7351 OpenMotif libraries</em><footnote>
7352 OSF/Motif and OpenMotif are collectively referred to as
7353 "Motif" in this policy document.
7355 should be compiled against and tested with LessTif (a free
7356 re-implementation of Motif) instead. If the maintainer
7357 judges that the program or programs do not work
7358 sufficiently well with LessTif to be distributed and
7359 supported, but do so when compiled against Motif, then two
7360 versions of the package should be created; one linked
7361 statically against Motif and with <tt>-smotif</tt>
7362 appended to the package name, and one linked dynamically
7363 against Motif and with <tt>-dmotif</tt> appended to the
7367 Both Motif-linked versions are dependent
7368 upon non-DFSG-compliant software and thus cannot be
7369 uploaded to the <em>main</em> distribution; if the
7370 software is itself DFSG-compliant it may be uploaded to
7371 the <em>contrib</em> distribution. While known existing
7372 versions of Motif permit unlimited redistribution of
7373 binaries linked against the library (whether statically or
7374 dynamically), it is the package maintainer's
7375 responsibility to determine whether this is permitted by
7376 the license of the copy of Motif in his or her possession.
7382 <heading>Perl programs and modules</heading>
7385 Perl programs and modules should follow the current Perl policy.
7389 The Perl policy can be found in the <tt>perl-policy</tt>
7390 files in the <tt>debian-policy</tt> package.
7391 They are also available from the Debian web mirrors at
7392 <tt><url name="/doc/packaging-manuals/perl-policy/"
7393 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>
7394 and from the Debian archive mirrors at
7395 <tt><url name="/doc/package-developer/perl-policy.txt.gz"
7396 id="http://ftp.debian.org/debian/doc/package-developer/perl-policy.txt.gz"></tt>.
7401 <heading>Emacs lisp programs</heading>
7404 Please refer to the "Debian Emacs Policy" for details of how to
7405 package emacs lisp programs.
7409 The Emacs policy is available in
7410 <file>debian-emacs-policy.gz</file> of the
7411 <package>emacsen-common</package> package.
7412 It is also available from the Debian web mirrors at
7413 <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
7414 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
7419 <heading>Games</heading>
7422 The permissions on <file>/var/games</file> are mode 755, owner
7423 <tt>root</tt> and group <tt>root</tt>.
7427 Each game decides on its own security policy.</p>
7430 Games which require protected, privileged access to
7431 high-score files, savegames, etc., may be made
7432 set-<em>group</em>-id (mode 2755) and owned by
7433 <tt>root.games</tt>, and use files and directories with
7434 appropriate permissions (770 <tt>root.games</tt>, for
7435 example). They must not be made
7436 set-<em>user</em>-id, as this causes security problems. (If
7437 an attacker can subvert any set-user-id game they can
7438 overwrite the executable of any other, causing other players
7439 of these games to run a Trojan horse program. With a
7440 set-group-id game the attacker only gets access to less
7441 important game data, and if they can get at the other
7442 players' accounts at all it will take considerably more
7446 Some packages, for example some fortune cookie programs, are
7447 configured by the upstream authors to install with their
7448 data files or other static information made unreadable so
7449 that they can only be accessed through set-id programs
7450 provided. You should not do this in a Debian package: anyone can
7451 download the <file>.deb</file> file and read the data from it,
7452 so there is no point making the files unreadable. Not
7453 making the files unreadable also means that you don't have
7454 to make so many programs set-id, which reduces the risk of a
7458 As described in the FHS, binaries of games should be
7459 installed in the directory <file>/usr/games</file>. This also
7460 applies to games that use the X Window System. Manual pages
7461 for games (X and non-X games) should be installed in
7462 <file>/usr/share/man/man6</file>.</p>
7466 <chapt id="docs"><heading>Documentation</heading>
7470 <heading>Manual pages</heading>
7473 You should install manual pages in <prgn>nroff</prgn> source
7474 form, in appropriate places under <file>/usr/share/man</file>.
7475 You should only use sections 1 to 9 (see the FHS for more
7476 details). You must not install a preformatted "cat page".
7480 Each program, utility, and function should have an
7481 associated manual page included in the same package. It is
7482 suggested that all configuration files also have a manual
7483 page included as well. Manual pages for protocols and other
7484 auxiliary things are optional.
7488 If no manual page is available, this is considered as a bug
7489 and should be reported to the Debian Bug Tracking System (the
7490 maintainer of the package is allowed to write this bug report
7491 themselves, if they so desire). Do not close the bug report
7492 until a proper manpage is available.<footnote>
7494 It is not very hard to write a man page. See the
7495 <url id="http://www.schweikhardt.net/man_page_howto.html"
7496 name="Man-Page-HOWTO">,
7497 <manref name="man" section="7">, the examples
7498 created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7499 the helper programs <prgn>help2man</prgn>, or the
7500 directory <file>/usr/share/doc/man-db/examples</file>.
7506 You may forward a complaint about a missing manpage to the
7507 upstream authors, and mark the bug as forwarded in the
7508 Debian bug tracking system. Even though the GNU Project do
7509 not in general consider the lack of a manpage to be a bug,
7510 we do; if they tell you that they don't consider it a bug
7511 you should leave the bug in our bug tracking system open
7516 Manual pages should be installed compressed using <tt>gzip -9</tt>.
7520 If one manpage needs to be accessible via several names it
7521 is better to use a symbolic link than the <file>.so</file>
7522 feature, but there is no need to fiddle with the relevant
7523 parts of the upstream source to change from <file>.so</file> to
7524 symlinks: don't do it unless it's easy. You should not
7525 create hard links in the manual page directories, nor put
7526 absolute filenames in <file>.so</file> directives. The filename
7527 in a <file>.so</file> in a manpage should be relative to the
7528 base of the manpage tree (usually
7529 <file>/usr/share/man</file>). If you do not create any links
7530 (whether symlinks, hard links, or <tt>.so</tt> directives)
7531 in the filesystem to the alternate names of the manpage,
7532 then you should not rely on <prgn>man</prgn> finding your
7533 manpage under those names based solely on the information in
7534 the manpage's header.<footnote>
7536 Supporting this in <prgn>man</prgn> often requires
7537 unreasonable processing time to find a manual page or to
7538 report that none exists, and moves knowledge into man's
7539 database that would be better left in the filesystem.
7540 This support is therefore deprecated and will cease to
7541 be present in the future.
7548 <heading>Info documents</heading>
7551 Info documents should be installed in <file>/usr/share/info</file>.
7552 They should be compressed with <tt>gzip -9</tt>.
7556 Your package should call <prgn>install-info</prgn> to update
7557 the Info <file>dir</file> file in its <prgn>postinst</prgn>
7558 script when called with a <tt>configure</tt> argument, for
7560 <example compact="compact">
7561 install-info --quiet --section Development Development \
7562 /usr/share/info/foobar.info
7566 It is a good idea to specify a section for the location of
7567 your program; this is done with the <tt>--section</tt>
7568 switch. To determine which section to use, you should look
7569 at <file>/usr/share/info/dir</file> on your system and choose the most
7570 relevant (or create a new section if none of the current
7571 sections are relevant). Note that the <tt>--section</tt>
7572 flag takes two arguments; the first is a regular expression
7573 to match (case-insensitively) against an existing section,
7574 the second is used when creating a new one.</p>
7577 You should remove the entries in the <prgn>prerm</prgn>
7578 script when called with a <tt>remove</tt> argument:
7579 <example compact="compact">
7580 install-info --quiet --remove /usr/share/info/foobar.info
7584 If <prgn>install-info</prgn> cannot find a description entry
7585 in the Info file you must supply one. See <manref
7586 name="install-info" section="8"> for details.</p>
7590 <heading>Additional documentation</heading>
7593 Any additional documentation that comes with the package may
7594 be installed at the discretion of the package maintainer.
7595 Text documentation should be installed in the directory
7596 <file>/usr/share/doc/<var>package</var></file>, where
7597 <var>package</var> is the name of the package, and
7598 compressed with <tt>gzip -9</tt> unless it is small.
7602 If a package comes with large amounts of documentation which
7603 many users of the package will not require you should create
7604 a separate binary package to contain it, so that it does not
7605 take up disk space on the machines of users who do not need
7606 or want it installed.</p>
7609 It is often a good idea to put text information files
7610 (<file>README</file>s, changelogs, and so forth) that come with
7611 the source package in <file>/usr/share/doc/<var>package</var></file>
7612 in the binary package. However, you don't need to install
7613 the instructions for building and installing the package, of
7617 Packages must not require the existance of any files in
7618 <file>/usr/share/doc/</file> in order to function
7621 The system administrator should be able to
7622 delete files in <file>/usr/share/doc/</file> without causing
7623 any programs to break.
7626 Any files that are referenced by programs but are also
7627 useful as standalone documentation should be installed under
7628 <file>/usr/share/<var>package</var>/</file> with symbolic links from
7629 <file>/usr/share/doc/<var>package</var></file>.
7633 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7634 link to another directory in <file>/usr/share/doc</file> only if
7635 the two packages both come from the same source and the
7636 first package Depends on the second.
7640 Former Debian releases placed all additional documentation
7641 in <file>/usr/doc/<var>package</var></file>. This has been
7642 changed to <file>/usr/share/doc/<var>package</var></file>,
7643 and packages must not put documentation in the directory
7644 <file>/usr/doc/<var>package</var></file>. <footnote>
7645 <p>At this phase of the transition, we no longer require a
7646 symbolic link in <file>/usr/doc/</file>. At a later point,
7647 policy shall change to make the symbolic links a bug.</p>
7653 <heading>Preferred documentation formats</heading>
7656 The unification of Debian documentation is being carried out
7660 If your package comes with extensive documentation in a
7661 markup format that can be converted to various other formats
7662 you should if possible ship HTML versions in a binary
7663 package, in the directory
7664 <file>/usr/share/doc/<var>appropriate-package</var></file> or
7665 its subdirectories.<footnote>
7667 The rationale: The important thing here is that HTML
7668 docs should be available in <em>some</em> package, not
7669 necessarily in the main binary package.
7675 Other formats such as PostScript may be provided at the
7676 package maintainer's discretion.
7680 <sect id="copyrightfile">
7681 <heading>Copyright information</heading>
7684 Every package must be accompanied by a verbatim copy of its
7685 copyright and distribution license in the file
7686 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7687 file must neither be compressed nor be a symbolic link.
7691 In addition, the copyright file must say where the upstream
7692 sources (if any) were obtained. It should name the original
7693 authors of the package and the Debian maintainer(s) who were
7694 involved with its creation.</p>
7697 A copy of the file which will be installed in
7698 <file>/usr/share/doc/<var>package</var>/copyright</file> should
7699 be in <file>debian/copyright</file> in the source package.
7703 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7704 link to another directory in <file>/usr/share/doc</file> only if
7705 the two packages both come from the same source and the
7706 first package Depends on the second. These rules are
7707 important because copyrights must be extractable by
7712 Packages distributed under the UCB BSD license, the Artistic
7713 license, the GNU GPL, and the GNU LGPL should refer to the
7714 files <file>/usr/share/common-licenses/BSD</file>,
7715 <file>/usr/share/common-licenses/Artistic</file>,
7716 <file>/usr/share/common-licenses/GPL</file>, and
7717 <file>/usr/share/common-licenses/LGPL</file> respectively,
7718 rather than quoting them in the copyright file.
7722 You should not use the copyright file as a general <file>README</file>
7723 file. If your package has such a file it should be
7724 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7725 <file>README.Debian</file> or some other appropriate place.</p>
7729 <heading>Examples</heading>
7732 Any examples (configurations, source files, whatever),
7733 should be installed in a directory
7734 <file>/usr/share/doc/<var>package</var>/examples</file>. These
7735 files should not be referenced by any program: they're there
7736 for the benefit of the system administrator and users as
7737 documentation only. Architecture-specific example files
7738 should be installed in a directory
7739 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7741 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7742 latter directory itself may be a symbolic link to the
7747 If the purpose of a package is to provide examples, then the
7748 example files may be installed into
7749 <file>/usr/share/doc/<var>package</var></file>.
7753 <sect id="changelogs">
7754 <heading>Changelog files</heading>
7757 The Debian changelog file (<file>debian/changelog</file>) should
7758 explain briefly what modifications were made in the Debian version
7759 of the package compared to the upstream one. Other changes and
7760 updates to the package should also be documented in this file.
7764 Mistakes in changelogs are usually best rectified by
7765 making a new changelog entry rather than "rewriting history"
7766 by editing old changelog entries.
7770 The format of the <file>debian/changelog</file> file is described
7771 in <ref id="dpkgchangelog">. In non-experimental packages you must
7772 use a format for <file>debian/changelog</file> which is supported
7773 by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7775 If you wish to use an alternative format, you may do so as
7776 long as you include a parser for it in your source package.
7777 The parser must have an API compatible with that expected by
7778 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7779 If there is general interest in the new format, you should
7780 contact the <package>dpkg</package> maintainer to have the
7781 parser script for it included in the <prgn>dpkg</prgn>
7782 package. (You will need to agree that the parser and its
7783 manpage may be distributed under the GNU GPL, just as the rest
7784 of <prgn>dpkg</prgn> is.)
7790 Packages that are not Debian-native must contain a
7791 compressed copy of the <file>debian/changelog</file> file from
7792 the Debian source tree in
7793 <file>/usr/share/doc/<var>package</var></file> with the name
7794 <file>changelog.Debian.gz</file>.
7798 If an upstream changelog is available, it should be accessible as
7799 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7800 plain text. If the upstream changelog is distributed in
7801 HTML, it should be made available in that form as
7802 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7803 and a plain text <file>changelog.gz</file> should be generated
7804 from it using, for example, <tt>lynx -dump -nolist</tt>. If
7805 the upstream changelog files do not already conform to this
7806 naming convention, then this may be achieved either by
7807 renaming the files, or by adding a symbolic link, at the
7808 maintainer's discretion.<footnote>
7810 Rationale: People should not have to look in places for
7811 upstream changelogs merely because they are given
7812 different names or are distributed in HTML format.
7818 All of these files should be installed compressed using
7819 <tt>gzip -9</tt>, as they will become large with time even
7820 if they start out small.
7824 If the package has only one changelog which is used both as
7825 the Debian changelog and the upstream one because there is
7826 no separate upstream maintainer then that changelog should
7827 usually be installed as
7828 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7829 there is a separate upstream maintainer, but no upstream
7830 changelog, then the Debian changelog should still be called
7831 <file>changelog.Debian.gz</file>.</p>
7836 <appendix id="pkg-scope">
7837 <heading>Introduction and scope of these appendices</heading>
7840 These appendices are taken essentially verbatim from the
7841 now-deprecated Packaging Manual, version 3.2.1.0. They are
7842 the chapters which are likely to be of use to package
7843 maintainers and which have not already been included in the
7844 policy document itself. Most of these sections are very likely
7845 not relevant to policy; they should be treated as
7846 documentation for the packaging system. Please note that these
7847 appendices are included for convenience, and for historical
7848 reasons: they used to be part of policy package, and they have
7849 not yet been incorporated into dpkg documentation. However,
7850 they still have value, and hence they are presented here.
7853 They have not yet been checked to ensure that they are
7854 compatible with the contents of policy, and if there are any
7855 contradictions, the version in the main policy document takes
7856 precedence. The remaining chapters of the old Packaging
7857 Manual have also not been read in detail to ensure that there
7858 are not parts which have been left out. Both of these will be
7863 <prgn>dpkg</prgn> is a suite of programs for creating binary
7864 package files and installing and removing them on Unix
7867 <prgn>dpkg</prgn> is targetted primarily at Debian
7868 GNU/Linux, but may work on or be ported to other
7875 The binary packages are designed for the management of
7876 installed executable programs (usually compiled binaries) and
7877 their associated data, though source code examples and
7878 documentation are provided as part of some packages.</p>
7881 This manual describes the technical aspects of creating Debian
7882 binary packages (<file>.deb</file> files). It documents the
7883 behaviour of the package management programs
7884 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7885 they interact with packages.</p>
7888 It also documents the interaction between
7889 <prgn>dselect</prgn>'s core and the access method scripts it
7890 uses to actually install the selected packages, and describes
7891 how to create a new access method.</p>
7894 This manual does not go into detail about the options and
7895 usage of the package building and installation tools. It
7896 should therefore be read in conjuction with those programs'
7901 The utility programs which are provided with <prgn>dpkg</prgn>
7902 for managing various system configuration and similar issues,
7903 such as <prgn>update-rc.d</prgn> and
7904 <prgn>install-info</prgn>, are not described in detail here -
7905 please see their manpages.
7909 It is assumed that the reader is reasonably familiar with the
7910 <prgn>dpkg</prgn> System Administrators' manual.
7911 Unfortunately this manual does not yet exist.
7915 The Debian version of the FSF's GNU hello program is provided
7916 as an example for people wishing to create Debian
7917 packages. The Debian <prgn>debmake</prgn> package is
7918 recommended as a very helpful tool in creating and maintaining
7919 Debian packages. However, while the tools and examples are
7920 helpful, they do not replace the need to read and follow the
7921 Policy and Programmer's Manual.</p>
7924 <appendix id="pkg-binarypkg"><heading>Binary packages (from old
7929 The binary package has two main sections. The first part
7930 consists of various control information files and scripts used
7931 by <prgn>dpkg</prgn> when installing and removing. See <ref
7932 id="pkg-controlarea">.
7936 The second part is an archive containing the files and
7937 directories to be installed.
7941 In the future binary packages may also contain other
7942 components, such as checksums and digital signatures. The
7943 format for the archive is described in full in the
7944 <file>deb(5)</file> manpage.
7948 <sect id="pkg-bincreating"><heading>Creating package files -
7949 <prgn>dpkg-deb</prgn>
7953 All manipulation of binary package files is done by
7954 <prgn>dpkg-deb</prgn>; it's the only program that has
7955 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
7956 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
7957 will spot that the options requested are appropriate to
7958 <prgn>dpkg-deb</prgn> and invoke that instead with the same
7963 In order to create a binary package you must make a
7964 directory tree which contains all the files and directories
7965 you want to have in the filesystem data part of the package.
7966 In Debian-format source packages this directory is usually
7967 <file>debian/tmp</file>, relative to the top of the package's
7972 They should have the locations (relative to the root of the
7973 directory tree you're constructing) ownerships and
7974 permissions which you want them to have on the system when
7979 With current versions of <prgn>dpkg</prgn> the uid/username
7980 and gid/groupname mappings for the users and groups being
7981 used should be the same on the system where the package is
7982 built and the one where it is installed.
7986 You need to add one special directory to the root of the
7987 miniature filesystem tree you're creating:
7988 <prgn>DEBIAN</prgn>. It should contain the control
7989 information files, notably the binary package control file
7990 (see <ref id="pkg-controlfile">).
7994 The <prgn>DEBIAN</prgn> directory will not appear in the
7995 filesystem archive of the package, and so won't be installed
7996 by <prgn>dpkg</prgn> when the package is installed.
8000 When you've prepared the package, you should invoke:
8002 dpkg --build <var>directory</var>
8007 This will build the package in
8008 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
8009 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8010 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8015 See the manpage <manref name="dpkg-deb" section="8"> for details of how
8016 to examine the contents of this newly-created file. You may find the
8017 output of following commands enlightening:
8019 dpkg-deb --info <var>filename</var>.deb
8020 dpkg-deb --contents <var>filename</var>.deb
8021 dpkg --contents <var>filename</var>.deb
8023 To view the copyright file for a package you could use this command:
8025 dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8030 <sect id="pkg-controlarea">
8032 Package control information files
8036 The control information portion of a binary package is a
8037 collection of files with names known to <prgn>dpkg</prgn>.
8038 It will treat the contents of these files specially - some
8039 of them contain information used by <prgn>dpkg</prgn> when
8040 installing or removing the package; others are scripts which
8041 the package maintainer wants <prgn>dpkg</prgn> to run.
8045 It is possible to put other files in the package control
8046 area, but this is not generally a good idea (though they
8047 will largely be ignored).
8051 Here is a brief list of the control info files supported by
8052 <prgn>dpkg</prgn> and a summary of what they're used for.
8057 <tag><tt>control</tt>
8061 This is the key description file used by
8062 <prgn>dpkg</prgn>. It specifies the package's name
8063 and version, gives its description for the user,
8064 states its relationships with other packages, and so
8065 forth. See <ref id="pkg-controlfile">.
8069 It is usually generated automatically from information
8070 in the source package by the
8071 <prgn>dpkg-gencontrol</prgn> program, and with
8072 assistance from <prgn>dpkg-shlibdeps</prgn>. See <ref
8073 id="pkg-sourcetools">.</p>
8076 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8082 These are exectuable files (usually scripts) which
8083 <prgn>dpkg</prgn> runs during installation, upgrade
8084 and removal of packages. They allow the package to
8085 deal with matters which are particular to that package
8086 or require more complicated processing than that
8087 provided by <prgn>dpkg</prgn>. Details of when and
8088 how they are called are in <ref
8089 id="maintainerscripts">.
8093 It is very important to make these scripts
8097 That means that if it runs successfully or fails
8098 and then you call it again it doesn't bomb out,
8099 but just ensures that everything is the way it
8102 </footnote> This is so that if an error occurs, the
8103 user interrupts <prgn>dpkg</prgn> or some other
8104 unforeseen circumstance happens you don't leave the
8105 user with a badly-broken package.
8109 The maintainer scripts are guaranteed to run with a
8110 controlling terminal and can interact with the user.
8111 If they need to prompt for passwords, do full-screen
8112 interaction or something similar you should do these
8113 things to and from <file>/dev/tty</file>, since
8114 <prgn>dpkg</prgn> will at some point redirect scripts'
8115 standard input and output so that it can log the
8116 installation process. Likewise, because these scripts
8117 may be executed with standard output redirected into a
8118 pipe for logging purposes, Perl scripts should set
8119 unbuffered output by setting <tt>$|=1</tt> so that the
8120 output is printed immediately rather than being
8125 Each script should return a zero exit status for
8126 success, or a nonzero one for failure.</p>
8129 <tag><tt>conffiles</tt>
8134 This file contains a list of configuration files which
8135 are to be handled automatically by <prgn>dpkg</prgn>
8136 (see <ref id="pkg-conffiles">). Note that not necessarily
8137 every configuration file should be listed here.</p>
8140 <tag><tt>shlibs</tt>
8145 This file contains a list of the shared libraries
8146 supplied by the package, with dependency details for
8147 each. This is used by <prgn>dpkg-shlibdeps</prgn>
8148 when it determines what dependencies are required in a
8149 package control file. The <tt>shlibs</tt> file format
8150 is described on <ref id="shlibs">.
8156 <sect id="pkg-controlfile">
8158 The main control information file: <tt>control</tt>
8161 The most important control information file used by
8162 <prgn>dpkg</prgn> when it installs a package is
8163 <tt>control</tt>. It contains all the package"s "vital
8168 The binary package control files of packages built from
8169 Debian sources are made by a special tool,
8170 <prgn>dpkg-gencontrol</prgn>, which reads
8171 <file>debian/control</file> and <file>debian/changelog</file> to
8172 find the information it needs. See <ref id="pkg-sourcepkg"> for
8177 The fields in binary package control files are:
8178 <list compact="compact">
8180 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8183 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8185 <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8189 This field should appear in all packages, though
8190 <prgn>dpkg</prgn> doesn't require it yet so that
8191 old packages can still be installed.
8197 <p><qref id="relationships"><tt>Depends</tt>,
8198 <tt>Provides</tt> et al.</qref></p>
8201 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8204 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8207 <p><qref id="pkg-f-classification"><tt>Section</tt>,
8208 <tt>Priority</tt></qref></p>
8211 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8214 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8218 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8224 A description of the syntax of control files and the purpose
8225 of these fields is available in <ref id="pkg-controlfields">.
8230 <heading>Time Stamps</heading>
8232 Maintainers are encouraged to preserve the modification
8233 times of the upstream source files in a package, as far as
8234 is reasonably possible.
8237 The rationale is that there is some information conveyed
8238 by knowing the age of the file, for example, you could
8239 recognize that some documentation is very old by looking
8240 at the modification time, so it would be nice if the
8241 modification time of the upstream source would be
8249 <appendix id="pkg-sourcepkg">
8250 <heading>Source packages (from old Packaging Manual) </heading>
8253 The Debian binary packages in the distribution are generated
8254 from Debian sources, which are in a special format to assist
8255 the easy and automatic building of binaries.
8258 <sect id="pkg-sourcetools">
8259 <heading>Tools for processing source packages</heading>
8262 Various tools are provided for manipulating source packages;
8263 they pack and unpack sources and help build of binary
8264 packages and help manage the distribution of new versions.
8268 They are introduced and typical uses described here; see
8269 <manref name="dpkg-source" section="1"> for full
8270 documentation about their arguments and operation.
8274 For examples of how to construct a Debian source package,
8275 and how to use those utilities that are used by Debian
8276 source packages, please see the <prgn>hello</prgn> example
8282 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8287 This program is frequently used by hand, and is also
8288 called from package-independent automated building scripts
8289 such as <prgn>dpkg-buildpackage</prgn>.
8293 To unpack a package it is typically invoked with
8295 dpkg-source -x <var>.../path/to/filename</var>.dsc
8300 with the <file><var>filename</var>.tar.gz</file> and
8301 <file><var>filename</var>.diff.gz</file> (if applicable) in
8302 the same directory. It unpacks into
8303 <file><var>package</var>-<var>version</var></file>, and if
8305 <file><var>package</var>-<var>version</var>.orig</file>, in
8306 the current directory.
8310 To create a packed source archive it is typically invoked:
8312 dpkg-source -b <var>package</var>-<var>version</var>
8317 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8318 <file>.diff.gz</file> (if appropriate) in the current
8319 directory. <prgn>dpkg-source</prgn> does not clean the
8320 source tree first - this must be done separately if it is
8325 See also <ref id="pkg-sourcearchives">.</p>
8331 <prgn>dpkg-buildpackage</prgn> - overall package-building
8336 <prgn>dpkg-buildpackage</prgn> is a script which invokes
8337 <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8338 targets <tt>clean</tt>, <tt>build</tt> and
8339 <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8340 <prgn>pgp</prgn> to build a signed source and binary
8345 It is usually invoked by hand from the top level of the
8346 built or unbuilt source directory. It may be invoked with
8347 no arguments; useful arguments include:
8348 <taglist compact="compact">
8349 <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8352 Do not PGP-sign the <tt>.changes</tt> file or the
8353 source package <tt>.dsc</tt> file, respectively.</p>
8355 <tag><tt>-p<var>pgp-command</var></tt></tag>
8358 Invoke <var>pgp-command</var> instead of finding
8359 <tt>pgp</tt> on the <prgn>PATH</prgn>.
8360 <var>pgp-command</var> must behave just like
8361 <prgn>pgp</prgn>.</p>
8363 <tag><tt>-r<var>root-command</var></tt></tag>
8366 When root privilege is required, invoke the command
8367 <var>root-command</var>. <var>root-command</var>
8368 should invoke its first argument as a command, from
8369 the <prgn>PATH</prgn> if necessary, and pass its
8370 second and subsequent arguments to the command it
8371 calls. If no <var>root-command</var> is supplied
8372 then <var>dpkg-buildpackage</var> will take no
8373 special action to gain root privilege, so that for
8374 most packages it will have to be invoked as root to
8377 <tag><tt>-b</tt>, <tt>-B</tt></tag>
8380 Two types of binary-only build and upload - see
8381 <manref name="dpkg-source" section="1">.
8390 <prgn>dpkg-gencontrol</prgn> - generates binary package
8395 This program is usually called from <file>debian/rules</file>
8396 (see <ref id="pkg-sourcetree">) in the top level of the source
8401 This is usually done just before the files and directories in the
8402 temporary directory tree where the package is being built have their
8403 permissions and ownerships set and the package is constructed using
8404 <prgn>dpkg-deb/</prgn>
8407 This is so that the control file which is produced has
8408 the right permissions
8414 <prgn>dpkg-gencontrol</prgn> must be called after all the
8415 files which are to go into the package have been placed in
8416 the temporary build directory, so that its calculation of
8417 the installed size of a package is correct.
8421 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8422 be run after <prgn>dpkg-shlibdeps</prgn> so that the
8423 variable substitutions created by
8424 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8429 For a package which generates only one binary package, and
8430 which builds it in <file>debian/tmp</file> relative to the top
8431 of the source package, it is usually sufficient to call
8432 <prgn>dpkg-gencontrol</prgn>.
8436 Sources which build several binaries will typically need
8439 dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8440 </example> The <tt>-P</tt> tells
8441 <prgn>dpkg-gencontrol</prgn> that the package is being
8442 built in a non-default directory, and the <tt>-p</tt>
8443 tells it which package's control file should be generated.
8447 <prgn>dpkg-gencontrol</prgn> also adds information to the
8448 list of files in <file>debian/files</file>, for the benefit of
8449 (for example) a future invocation of
8450 <prgn>dpkg-genchanges</prgn>.</p>
8455 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8460 This program is usually called from <file>debian/rules</file>
8461 just before <prgn>dpkg-gencontrol</prgn> (see <ref
8462 id="pkg-sourcetree">), in the top level of the source tree.
8466 Its arguments are executables.
8469 In a forthcoming dpkg version,
8470 <prgn>dpkg-shlibdeps</prgn> would be required to be
8471 called on shared libraries as well.
8474 They may be specified either in the locations in the
8475 source tree where they are created or in the locations
8476 in the temporary build tree where they are installed
8477 prior to binary package creation.
8479 </footnote> for which shared library dependencies should
8480 be included in the binary package's control file.
8484 If some of the found shared libraries should only
8485 warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8486 some warrant a <tt>Pre-Depends</tt>, this can be achieved
8487 by using the <tt>-d<var>dependency-field</var></tt> option
8488 before those executable(s). (Each <tt>-d</tt> option
8489 takes effect until the next <tt>-d</tt>.)
8493 <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8494 output control file to be modified. Instead by default it
8495 adds to the <file>debian/substvars</file> file variable
8496 settings like <tt>shlibs:Depends</tt>. These variable
8497 settings must be referenced in dependency fields in the
8498 appropriate per-binary-package sections of the source
8503 For example, the <prgn>procps</prgn> package generates two
8504 kinds of binaries, simple C binaries like <prgn>ps</prgn>
8505 which require a predependency and full-screen ncurses
8506 binaries like <prgn>top</prgn> which require only a
8507 recommendation. It can say in its <file>debian/rules</file>:
8509 dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8511 and then in its main control file <file>debian/control</file>:
8515 Pre-Depends: ${shlibs:Pre-Depends}
8516 Recommends: ${shlibs:Recommends}
8522 Sources which produce several binary packages with
8523 different shared library dependency requirements can use
8524 the <tt>-p<var>varnameprefix</var></tt> option to override
8525 the default <tt>shlibs:</tt> prefix (one invocation of
8526 <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8527 They can thus produce several sets of dependency
8528 variables, each of the form
8529 <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8530 which can be referred to in the appropriate parts of the
8531 binary package control files.
8538 <prgn>dpkg-distaddfile</prgn> - adds a file to
8539 <file>debian/files</file>
8543 Some packages' uploads need to include files other than
8544 the source and binary package files.
8548 <prgn>dpkg-distaddfile</prgn> adds a file to the
8549 <file>debian/files</file> file so that it will be included in
8550 the <file>.changes</file> file when
8551 <prgn>dpkg-genchanges</prgn> is run.
8555 It is usually invoked from the <tt>binary</tt> target of
8556 <file>debian/rules</file>:
8558 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8560 The <var>filename</var> is relative to the directory where
8561 <prgn>dpkg-genchanges</prgn> will expect to find it - this
8562 is usually the directory above the top level of the source
8563 tree. The <file>debian/rules</file> target should put the
8564 file there just before or just after calling
8565 <prgn>dpkg-distaddfile</prgn>.
8569 The <var>section</var> and <var>priority</var> are passed
8570 unchanged into the resulting <file>.changes</file> file. See
8571 <ref id="pkg-f-classification">.
8576 <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8581 This program is usually called by package-independent
8582 automatic building scripts such as
8583 <prgn>dpkg-buildpackage</prgn>, but it may also be called
8588 It is usually called in the top level of a built source
8589 tree, and when invoked with no arguments will print out a
8590 straightforward <file>.changes</file> file based on the
8591 information in the source package's changelog and control
8592 file and the binary and source packages which should have
8598 <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8603 This program is used internally by
8604 <prgn>dpkg-source</prgn> et al. It may also occasionally
8605 be useful in <file>debian/rules</file> and elsewhere. It
8606 parses a changelog, <file>debian/changelog</file> by default,
8607 and prints a control-file format representation of the
8608 information in it to standard output.
8612 <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8613 information about the build and host system
8617 This program can be used manually, but is also invoked by
8618 <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8619 to set environment or make variables which specify the build and
8620 host architecture for the package building process.
8625 <sect id="pkg-sourcetree"><heading>The Debianised source tree
8629 The source archive scheme described later is intended to
8630 allow a Debianised source tree with some associated control
8631 information to be reproduced and transported easily. The
8632 Debianised source tree is a version of the original program
8633 with certain files added for the benefit of the
8634 Debianisation process, and with any other changes required
8635 made to the rest of the source code and installation
8640 The extra files created for Debian are in the subdirectory
8641 <file>debian</file> of the top level of the Debianised source
8642 tree. They are described below.
8645 <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8650 This file is an executable makefile, and contains the
8651 package-specific recipies for compiling the package and
8652 building binary package(s) out of the source.
8656 It must start with the line <tt>#!/usr/bin/make -f</tt>,
8657 so that it can be invoked by saying its name rather than
8658 invoking <prgn>make</prgn> explicitly.
8662 Since an interactive <file>debian/rules</file> script makes it
8663 impossible to autocompile that package and also makes it
8664 hard for other people to reproduce the same binary
8665 package, all <strong>required targets</strong> have to be
8666 non-interactive. At a minimul, required targets are the
8667 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8668 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8669 <em>build</em>. It also follows that any target that these
8670 targets depend on must also be non-interactive.
8674 The targets which are required to be present are:
8676 <tag><tt>build</tt></tag>
8679 This should perform all non-interactive
8680 configuration and compilation of the package. If a
8681 package has an interactive pre-build configuration
8682 routine, the Debianised source package should be
8683 built after this has taken place, so that it can be
8684 built without rerunning the configuration.
8688 A package may also provide both of the targets
8689 <tt>build-arch</tt> and <tt>build-indep</tt>. The
8690 <tt>build-arch</tt> target, if provided, should
8691 perform all non-interactive configuration and
8692 compilation required for producing all
8693 architecture-dependant binary packages (those packages
8694 for which the body of the <tt>Architecture</tt> field
8695 in <tt>debian/control</tt> is not <tt>all</tt>).
8696 Similarly, the <tt>build-indep</tt> target, if
8697 provided, should perform all non-interactive
8698 configuration and compilation required for producing
8699 all architecture-independent binary packages (those
8700 packages for which the body of the
8701 <tt>Architecture</tt> field in <tt>debian/control</tt>
8702 is <tt>all</tt>). The <tt>build</tt> target should
8703 depend on those of the targets <tt>build-arch</tt> and
8704 <tt>build-indep</tt> that are provided in the rules
8709 If one or both of the targets <tt>build-arch</tt> and
8710 <tt>build-indep</tt> are not provided, then invoking
8711 <file>debian/rules</file> with one of the not-provided
8712 targets as arguments should produce a exit status code
8713 of 2. Usually this is provided automatically by make
8714 if the target is missing.
8718 For some packages, notably ones where the same
8719 source tree is compiled in different ways to produce
8720 two binary packages, the <tt>build</tt> target does
8721 not make much sense. For these packages it is good
8722 enough to provide two (or more) targets
8723 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8724 for each of the ways of building the package, and a
8725 <tt>build</tt> target that does nothing. The
8726 <tt>binary</tt> target will have to build the
8727 package in each of the possible ways and make the
8728 binary package out of each.
8732 The targets <tt>build</tt>, <tt>build-arch</tt>
8733 and <tt>build-indep</tt> target must not do
8734 anything that might require root privilege.
8738 The <tt>build</tt> target may need to run
8739 <tt>clean</tt> first - see below.
8743 When a package has a configuration routine that takes
8744 a long time, or when the makefiles are poorly
8745 designed, or when <tt>build</tt> needs to run
8746 <tt>clean</tt> first, it is a good idea to <tt>touch
8747 build</tt> when the build process is complete. This
8748 will ensure that if <tt>debian/rules build</tt> is run
8749 again it will not rebuild the whole program.
8753 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8754 <tt>binary-indep</tt>
8758 The <tt>binary</tt> target should be all that is
8759 necessary for the user to build the binary
8760 package. All these targets are required to be
8761 non-interactive. It is split into two parts:
8762 <tt>binary-arch</tt> builds the packages' output
8763 files which are specific to a particular
8764 architecture, and <tt>binary-indep</tt> builds
8765 those which are not.
8769 <tt>binary</tt> should usually be a target with
8770 no commands which simply depends on
8771 <prgn>binary-arch</prgn> and
8772 <prgn>binary-indep</prgn>.
8776 Both <prgn>binary-*</prgn> targets should depend on
8777 the <tt>build</tt> target, above, so that the
8778 package is built if it has not been already. It
8779 should then create the relevant binary package(s),
8780 using <prgn>dpkg-gencontrol</prgn> to make their
8781 control files and <prgn>dpkg-deb</prgn> to build
8782 them and place them in the parent of the top level
8787 If one of the <prgn>binary-*</prgn> targets has
8788 nothing to do (this will be always be the case if
8789 the source generates only a single binary package,
8790 whether architecture-dependent or not) it
8791 <em>must</em> still exist, but should always
8796 <ref id="pkg-binarypkg"> describes how to construct
8801 The <tt>binary</tt> targets must be invoked as
8806 <tag><tt>clean</tt></tag>
8810 This should undo any effects that the
8811 <tt>build</tt> and <tt>binary</tt> targets
8812 may have had, except that it should leave alone any
8813 output files created in the parent directory by a
8814 run of <tt>binary</tt>. This target is required
8815 to be non-interactive.
8819 If a <tt>build</tt> file is touched at the end
8820 of the <tt>build</tt> target, as suggested
8821 above, it must be removed as the first thing that
8822 <tt>clean</tt> does, so that running
8823 <tt>build</tt> again after an interrupted
8824 <tt>clean</tt> doesn't think that everything is
8829 The <tt>clean</tt> target must be invoked as
8830 root if <tt>binary</tt> has been invoked since
8831 the last <tt>clean</tt>, or if
8832 <tt>build</tt> has been invoked as root (since
8833 <tt>build</tt> may create directories, for
8838 <tag><tt>get-orig-source</tt> (optional)</tag>
8842 This target fetches the most recent version of the
8843 original source package from a canonical archive
8844 site (via FTP or WWW, for example), does any
8845 necessary rearrangement to turn it into the original
8846 source tarfile format described below, and leaves it
8847 in the current directory.
8851 This target may be invoked in any directory, and
8852 should take care to clean up any temporary files it
8857 This target is optional, but providing it if
8858 possible is a good idea.
8864 The <tt>build</tt>, <tt>binary</tt> and
8865 <tt>clean</tt> targets must be invoked with a current
8866 directory of the package's top-level directory.
8871 Additional targets may exist in <file>debian/rules</file>,
8872 either as published or undocumented interfaces or for the
8873 package's internal use.
8877 The architecture we build on and build for is determined by make
8878 variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8879 get the Debian architecture and the GNU style architecture
8880 specification string for the build machine as well as the host
8881 machine. Here is a list of supported make variables:
8882 <list compact="compact">
8884 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8887 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8888 specification string)</p>
8891 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8894 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8900 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
8901 the build machine or <tt>HOST</tt> for specification of the machine
8906 Backward compatibility can be provided in the rules file
8907 by setting the needed variables to suitable default
8908 values, please refer to the documentation of
8909 dpkg-architecture for details.
8913 It is important to understand that the <tt>DEB_*_ARCH</tt>
8914 string does only determine which Debian architecture we
8915 build on resp. for. It should not be used to get the CPU
8916 or System information, the GNU style variables should be
8922 <sect1><heading><file>debian/control</file>
8926 This file contains version-independent details about the
8927 source package and about the binary packages it creates.
8931 It is a series of sets of control fields, each
8932 syntactically similar to a binary package control file.
8933 The sets are separated by one or more blank lines. The
8934 first set is information about the source package in
8935 general; each subsequent set describes one binary package
8936 that the source tree builds.
8940 The syntax and semantics of the fields are described below
8941 in <ref id="pkg-controlfields">.
8945 The general (binary-package-independent) fields are:
8946 <list compact="compact">
8948 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
8951 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8955 <qref id="pkg-f-classification"><tt>Section</tt> and
8956 <tt>Priority</tt></qref>
8957 (classification, mandatory)
8962 <qref id="relationships"><tt>Build-Depends</tt> et
8963 al.</qref> (source package interrelationships)
8968 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
8974 The per-binary-package fields are:
8975 <list compact="compact">
8977 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8981 <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8985 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8989 <qref id="pkg-f-classification"><tt>Section</tt> and
8990 <tt>Priority</tt></qref> (classification)</p>
8993 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8997 <qref id="relationships"><tt>Depends</tt> et
8998 al.</qref> (binary package interrelationships)
9004 These fields are used by <prgn>dpkg-gencontrol</prgn> to
9005 generate control files for binary packages (see below), by
9006 <prgn>dpkg-genchanges</prgn> to generate the
9007 <tt>.changes</tt> file to accompany the upload, and by
9008 <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9009 source control file as part of a source archive.
9013 The fields here may contain variable references - their
9014 values will be substituted by
9015 <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9016 or <prgn>dpkg-source</prgn> when they generate output
9017 control files. See <ref id="pkg-srcsubstvars"> for details.
9020 <p> <sect2><heading>User-defined fields
9024 Additional user-defined fields may be added to the
9025 source package control file. Such fields will be
9026 ignored, and not copied to (for example) binary or
9027 source package control files or upload control files.
9031 If you wish to add additional unsupported fields to
9032 these output files you should use the mechanism
9037 Fields in the main source control information file with
9038 names starting <tt>X</tt>, followed by one or more of
9039 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9040 be copied to the output files. Only the part of the
9041 field name after the hyphen will be used in the output
9042 file. Where the letter <tt>B</tt> is used the field
9043 will appear in binary package control files, where the
9044 letter <tt>S</tt> is used in source package control
9045 files and where <tt>C</tt> is used in upload control
9046 (<tt>.changes</tt>) files.
9050 For example, if the main source information control file
9053 XBS-Comment: I stand between the candle and the star.
9055 then the binary and source package control files will contain the
9058 Comment: I stand between the candle and the star.
9065 <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9069 This file records the changes to the Debian-specific parts of the
9073 Though there is nothing stopping an author who is also
9074 the Debian maintainer from using it for all their
9075 changes, it will have to be renamed if the Debian and
9076 upstream maintainers become different
9083 It has a special format which allows the package building
9084 tools to discover which version of the package is being
9085 built and find out other release-specific information.
9089 That format is a series of entries like this:
9091 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9093 * <var>change details</var>
9094 <var>more change details</var>
9095 * <var>even more change details</var>
9097 -- <var>maintainer name and email address</var> <var>date</var>
9102 <var>package</var> and <var>version</var> are the source
9103 package name and version number.
9107 <var>distribution(s)</var> lists the distributions where
9108 this version should be installed when it is uploaded - it
9109 is copied to the <tt>Distribution</tt> field in the
9110 <tt>.changes</tt> file. See <ref id="pkg-f-Distribution">.
9114 <var>urgency</var> is the value for the <tt>Urgency</tt>
9115 field in the <file>.changes</file> file for the upload. See
9116 <ref id="pkg-f-Urgency">. It is not possible to specify an
9117 urgency containing commas; commas are used to separate
9118 <tt><var>keyword</var>=<var>value</var></tt> settings in
9119 the <prgn>dpkg</prgn> changelog format (though there is
9120 currently only one useful <var>keyword</var>,
9125 The change details may in fact be any series of lines
9126 starting with at least two spaces, but conventionally each
9127 change starts with an asterisk and a separating space and
9128 continuation lines are indented so as to bring them in
9129 line with the start of the text above. Blank lines may be
9130 used here to separate groups of changes, if desired.
9134 The maintainer name and email address should <em>not</em>
9135 necessarily be those of the usual package maintainer.
9136 They should be the details of the person doing
9137 <em>this</em> version. The information here will be
9138 copied to the <file>.changes</file> file, and then later used
9139 to send an acknowledgement when the upload has been
9144 The <var>date</var> should be in RFC822 format
9147 This is generated by the <prgn>822-date</prgn>
9150 </footnote>; it should include the timezone specified
9151 numerically, with the timezone name or abbreviation
9152 optionally present as a comment.
9156 The first "title" line with the package name should start
9157 at the left hand margin; the "trailer" line with the
9158 maintainer and date details should be preceded by exactly
9159 one space. The maintainer details and the date must be
9160 separated by exactly two spaces.
9164 An Emacs mode for editing this format is available: it is
9165 called <tt>debian-changelog-mode</tt>. You can have this
9166 mode selected automatically when you edit a Debian
9167 changelog by adding a local variables clause to the end of
9171 <sect2><heading>Defining alternative changelog formats
9175 It is possible to use a different format to the standard
9176 one, by providing a parser for the format you wish to
9181 In order to have <tt>dpkg-parsechangelog</tt> run your
9182 parser, you must include a line within the last 40 lines
9183 of your file matching the Perl regular expression:
9184 <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9185 parentheses should be the name of the format. For
9186 example, you might say:
9188 @@@ changelog-format: joebloggs @@@
9190 Changelog format names are non-empty strings of alphanumerics.
9194 If such a line exists then <tt>dpkg-parsechangelog</tt>
9195 will look for the parser as
9196 <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9198 <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9199 it is an error for it not to find it, or for it not to
9200 be an executable program. The default changelog format
9201 is <tt>dpkg</tt>, and a parser for it is provided with
9202 the <tt>dpkg</tt> package.
9206 The parser will be invoked with the changelog open on
9207 standard input at the start of the file. It should read
9208 the file (it may seek if it wishes) to determine the
9209 information required and return the parsed information
9210 to standard output in the form of a series of control
9211 fields in the standard format. By default it should
9212 return information about only the most recent version in
9213 the changelog; it should accept a
9214 <tt>-v<var>version</var></tt> option to return changes
9215 information from all versions present <em>strictly
9216 after</em> <var>version</var>, and it should then be an
9217 error for <var>version</var> not to be present in the
9223 <list compact="compact">
9225 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9228 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9232 <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9237 <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9241 <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9246 <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9250 <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9257 If several versions are being returned (due to the use
9258 of <tt>-v</tt>), the urgency value should be of the
9259 highest urgency code listed at the start of any of the
9260 versions requested followed by the concatenated
9261 (space-separated) comments from all the versions
9262 requested; the maintainer, version, distribution and
9263 date should always be from the most recent version.
9267 For the format of the <tt>Changes</tt> field see <ref
9268 id="pkg-f-Changes">.
9272 If the changelog format which is being parsed always or
9273 almost always leaves a blank line between individual
9274 change notes these blank lines should be stripped out,
9275 so as to make the resulting output compact.
9279 If the changelog format does not contain date or package
9280 name information this information should be omitted from
9281 the output. The parser should not attempt to synthesise
9282 it or find it from other sources.
9286 If the changelog does not have the expected format the
9287 parser should exit with a nonzero exit status, rather
9288 than trying to muddle through and possibly generating
9293 A changelog parser may not interact with the user at
9297 <!-- FIXME: section pkg-srcsubstvars is the same as srcsubstvars -->
9299 <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9300 and variable substitutions
9304 When <prgn>dpkg-gencontrol</prgn>,
9305 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9306 generate control files they do variable substitutions on
9307 their output just before writing it. Variable
9308 substitutions have the form
9309 <tt>${<var>variable-name</var>}</tt>. The optional file
9310 <file>debian/substvars</file> contains variable substitutions
9311 to be used; variables can also be set directly from
9312 <file>debian/rules</file> using the <tt>-V</tt> option to the
9313 source packaging commands, and certain predefined
9314 variables are available.
9318 This file is usually generated and modified dynamically by
9319 <file>debian/rules</file> targets, in which case it must be
9320 removed by the <tt>clean</tt> target.
9324 See <manref name="dpkg-source" section="1"> for full
9325 details about source variable substitutions, including the
9326 format of <file>debian/substvars</file>.</p>
9329 <sect1><heading><file>debian/files</file>
9333 This file is not a permanent part of the source tree; it
9334 is used while building packages to record which files are
9335 being generated. <prgn>dpkg-genchanges</prgn> uses it
9336 when it generates a <file>.changes</file> file.
9340 It should not exist in a shipped source package, and so it
9341 (and any backup files or temporary files such as
9342 <file>files.new</file>
9345 <file>files.new</file> is used as a temporary file by
9346 <prgn>dpkg-gencontrol</prgn> and
9347 <prgn>dpkg-distaddfile</prgn> - they write a new
9348 version of <file>files</file> here before renaming it,
9349 to avoid leaving a corrupted copy if an error
9352 </footnote>) should be removed by the
9353 <tt>clean</tt> target. It may also be wise to
9354 ensure a fresh start by emptying or removing it at the
9355 start of the <tt>binary</tt> target.
9359 <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9360 for the <file>.deb</file> file that will be created by
9361 <prgn>dpkg-deb</prgn> from the control file that it
9362 generates, so for most packages all that needs to be done
9363 with this file is to delete it in <tt>clean</tt>.
9367 If a package upload includes files besides the source
9368 package and any binary packages whose control files were
9369 made with <prgn>dpkg-gencontrol</prgn> then they should be
9370 placed in the parent of the package's top-level directory
9371 and <prgn>dpkg-distaddfile</prgn> should be called to add
9372 the file to the list in <file>debian/files</file>.</p>
9375 <sect1><heading><file>debian/tmp</file>
9379 This is the canonical temporary location for the
9380 construction of binary packages by the <tt>binary</tt>
9381 target. The directory <file>tmp</file> serves as the root of
9382 the filesystem tree as it is being constructed (for
9383 example, by using the package's upstream makefiles install
9384 targets and redirecting the output there), and it also
9385 contains the <tt>DEBIAN</tt> subdirectory. See <ref
9386 id="pkg-bincreating">.
9390 If several binary packages are generated from the same
9391 source tree it is usual to use several
9392 <file>debian/tmp<var>something</var></file> directories, for
9393 example <file>tmp-a</file> or <file>tmp-doc</file>.
9397 Whatever <file>tmp</file> directories are created and used by
9398 <tt>binary</tt> must of course be removed by the
9399 <tt>clean</tt> target.</p></sect1>
9403 <sect id="pkg-sourcearchives"><heading>Source packages as archives
9407 As it exists on the FTP site, a Debian source package
9408 consists of three related files. You must have the right
9409 versions of all three to be able to use them.
9414 <tag>Debian source control file - <tt>.dsc</tt></tag>
9418 This file contains a series of fields, identified and
9419 separated just like the fields in the control file of
9420 a binary package. The fields are listed below; their
9421 syntax is described above, in <ref id="pkg-controlfields">.
9422 <list compact="compact">
9424 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9427 <p><qref id="versions"><tt>Version</tt></qref></p>
9430 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9433 <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9436 <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9440 <qref id="relationships"><tt>Build-Depends</tt> et
9441 al.</qref> (source package interrelationships)
9446 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9449 <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9454 The source package control file is generated by
9455 <prgn>dpkg-source</prgn> when it builds the source
9456 archive, from other files in the source package,
9457 described above. When unpacking it is checked against
9458 the files and directories in the other parts of the
9459 source package, as described below.</p>
9463 Original source archive -
9465 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9472 This is a compressed (with <tt>gzip -9</tt>)
9473 <prgn>tar</prgn> file containing the source code from
9474 the upstream authors of the program. The tarfile
9475 unpacks into a directory
9476 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9477 and does not contain files anywhere other than in
9478 there or in its subdirectories.</p>
9482 Debianisation diff -
9484 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9490 This is a unified context diff (<tt>diff -u</tt>)
9491 giving the changes which are required to turn the
9492 original source into the Debian source. These changes
9493 may only include editing and creating plain files.
9494 The permissions of files, the targets of symbolic
9495 links and the characteristics of special files or
9496 pipes may not be changed and no files may be removed
9501 All the directories in the diff must exist, except the
9502 <file>debian</file> subdirectory of the top of the source
9503 tree, which will be created by
9504 <prgn>dpkg-source</prgn> if necessary when unpacking.
9508 The <prgn>dpkg-source</prgn> program will
9509 automatically make the <file>debian/rules</file> file
9510 executable (see below).</p></item>
9515 If there is no original source code - for example, if the
9516 package is specially prepared for Debian or the Debian
9517 maintainer is the same as the upstream maintainer - the
9518 format is slightly different: then there is no diff, and the
9520 <file><var>package</var>_<var>version</var>.tar.gz</file> and
9521 contains a directory
9522 <file><var>package</var>-<var>version</var></file>.
9526 <sect><heading>Unpacking a Debian source package without
9527 <prgn>dpkg-source</prgn>
9531 <tt>dpkg-source -x</tt> is the recommended way to unpack a
9532 Debian source package. However, if it is not available it
9533 is possible to unpack a Debian source archive as follows:
9534 <enumlist compact="compact">
9537 Untar the tarfile, which will create a <file>.orig</file>
9541 <p>Rename the <file>.orig</file> directory to
9542 <file><var>package</var>-<var>version</var></file>.</p>
9546 Create the subdirectory <file>debian</file> at the top of
9547 the source tree.</p>
9549 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9551 <item><p>Untar the tarfile again if you want a copy of the original
9552 source code alongside the Debianised version.</p>
9557 It is not possible to generate a valid Debian source archive
9558 without using <prgn>dpkg-source</prgn>. In particular,
9559 attempting to use <prgn>diff</prgn> directly to generate the
9560 <file>.diff.gz</file> file will not work.
9563 <sect1><heading>Restrictions on objects in source packages
9567 The source package may not contain any hard links
9570 This is not currently detected when building source
9571 packages, but only when extracting
9577 Hard links may be permitted at some point in the
9578 future, but would require a fair amount of
9581 </footnote>, device special files, sockets or setuid or
9585 Setgid directories are allowed.
9591 The source packaging tools manage the changes between the
9592 original and Debianised source using <prgn>diff</prgn> and
9593 <prgn>patch</prgn>. Turning the original source tree as
9594 included in the <file>.orig.tar.gz</file> into the debianised
9595 source must not involve any changes which cannot be
9596 handled by these tools. Problematic changes which cause
9597 <prgn>dpkg-source</prgn> to halt with an error when
9598 building the source package are:
9599 <list compact="compact">
9600 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9602 <item><p>Changing the targets of symbolic links.</p>
9604 <item><p>Creating directories, other than <file>debian</file>.</p>
9606 <item><p>Changes to the contents of binary files.</p></item>
9607 </list> Changes which cause <prgn>dpkg-source</prgn> to
9608 print a warning but continue anyway are:
9609 <list compact="compact">
9612 Removing files, directories or symlinks.
9615 Renaming a file is not treated specially - it is
9616 seen as the removal of the old file (which
9617 generates a warning, but is otherwise ignored),
9618 and the creation of the new
9625 Changed text files which are missing the usual final
9626 newline (either in the original or the modified
9631 Changes which are not represented, but which are not detected by
9632 <prgn>dpkg-source</prgn>, are:
9633 <list compact="compact">
9634 <item><p>Changing the permissions of files (other than
9635 <file>debian/rules</file>) and directories.</p></item>
9640 The <file>debian</file> directory and <file>debian/rules</file>
9641 are handled specially by <prgn>dpkg-source</prgn> - before
9642 applying the changes it will create the <file>debian</file>
9643 directory, and afterwards it will make
9644 <file>debian/rules</file> world-exectuable.
9650 <appendix id="pkg-controlfields"><heading>Control files and their
9651 fields (from old Packaging Manual)
9655 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9656 data in a common format, known as control files. Binary and
9657 source packages have control data as do the <file>.changes</file>
9658 files which control the installation of uploaded files, and
9659 <prgn>dpkg</prgn>'s internal databases are in a similar
9663 <sect><heading>Syntax of control files
9667 A file consists of one or more paragraphs of fields. The
9668 paragraphs are separated by blank lines. Some control files
9669 only allow one paragraph; others allow several, in which
9670 case each paragraph often refers to a different package.
9674 Each paragraph is a series of fields and values; each field
9675 consists of a name, followed by a colon and the value. It
9676 ends at the end of the line. Horizontal whitespace (spaces
9677 and tabs) may occur before or after the value and is ignored
9678 there; it is conventional to put a single space after the
9683 Some fields' values may span several lines; in this case
9684 each continuation line <em>must</em> start with a space or
9685 tab. Any trailing spaces or tabs at the end of individual
9686 lines of a field value are ignored.
9690 Except where otherwise stated only a single line of data is
9691 allowed and whitespace is not significant in a field body.
9692 Whitespace may never appear inside names (of packages,
9693 architectures, files or anything else), version numbers or
9694 in between the characters of multi-character version
9699 Field names are not case-sensitive, but it is usual to
9700 capitalise the field names using mixed case as shown below.
9704 Blank lines, or lines consisting only of spaces and tabs,
9705 are not allowed within field values or between fields - that
9706 would mean a new paragraph.
9710 It is important to note that there are several fields which
9711 are optional as far as <prgn>dpkg</prgn> and the related
9712 tools are concerned, but which must appear in every Debian
9713 package, or whose omission may cause problems.
9717 <sect><heading>List of fields
9720 <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9724 The name of the binary package. Package names consist of
9725 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9726 (plus, minus and full stop).
9729 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9730 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9731 and underscore) used to be legal and are still
9732 accepted when found in a package file, but may not be
9733 used in new packages
9739 They must be at least two characters and must start with
9740 an alphanumeric. In current versions of dpkg they are
9741 sort of case-sensitive<footnote><p>This is a
9742 bug.</p></footnote>; use lowercase package names unless
9743 the package you're building (or referring to, in other
9744 fields) is already using uppercase.</p>
9747 <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9751 This lists the source or binary package's version number -
9752 see <ref id="versions">.
9757 <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9761 This is the architecture string; it is a single word for
9762 the Debian architecture.
9766 <prgn>dpkg</prgn> will check the declared architecture of
9767 a binary package against its own compiled-in value before
9772 The special value <tt>all</tt> indicates that the package
9773 is architecture-independent.
9777 In the main <file>debian/control</file> file in the source
9778 package, or in the source package control file
9779 <file>.dsc</file>, a list of architectures (separated by
9780 spaces) is also allowed, as is the special value
9781 <tt>any</tt>. A list indicates that the source will build
9782 an architecture-dependent package, and will only work
9783 correctly on the listed architectures. <tt>any</tt>
9784 indicates that though the source package isn't dependent
9785 on any particular architecture and should compile fine on
9786 any one, the binary package(s) produced are not
9787 architecture-independent but will instead be specific to
9788 whatever the current build architecture is.
9792 In a <file>.changes</file> file the <tt>Architecture</tt>
9793 field lists the architecture(s) of the package(s)
9794 currently being uploaded. This will be a list; if the
9795 source for the package is being uploaded too the special
9796 entry <tt>source</tt> is also present.
9800 See <ref id="pkg-debianrules"> for information how to get the
9801 architecture for the build process.
9805 <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9809 The package maintainer's name and email address. The name
9810 should come first, then the email address inside angle
9811 brackets <tt><></tt> (in RFC822 format).
9815 If the maintainer's name contains a full stop then the
9816 whole field will not work directly as an email address due
9817 to a misfeature in the syntax specified in RFC822; a
9818 program using this field as an address must check for this
9819 and correct the problem if necessary (for example by
9820 putting the name in round brackets and moving it to the
9821 end, and bringing the email address forward).
9825 In a <file>.changes</file> file or parsed changelog data this
9826 contains the name and email address of the person
9827 responsible for the particular version in question - this
9828 may not be the package's usual maintainer.
9832 This field is usually optional in as far as the
9833 <prgn>dpkg</prgn> are concerned, but its absence when
9834 building packages usually generates a warning.</p>
9837 <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9841 This field identifies the source package name.
9845 In a main source control information or a
9846 <file>.changes</file> or <file>.dsc</file> file or parsed
9847 changelog data this may contain only the name of the
9852 In the control file of a binary package (or in a
9853 <file>Packages</file> file) it may be followed by a version
9854 number in parentheses.
9857 It is usual to leave a space after the package name if
9858 a version number is specified.
9860 </footnote> This version number may be omitted (and is, by
9861 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9862 the <tt>Version</tt> field of the binary package in
9863 question. The field itself may be omitted from a binary
9864 package control file when the source package has the same
9865 name and version as the binary package.
9869 <sect1><heading>Package interrelationship fields:
9870 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9871 <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9872 <tt>Provides</tt>, <tt>Replaces</tt>
9876 These fields describe the package's relationships with
9877 other packages. Their syntax and semantics are described
9878 in <ref id="relationships">.</p>
9881 <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9885 In a binary package <tt>Packages</tt> file or main source
9886 control file this field contains a description of the
9887 binary package, in a special format. See <ref
9888 id="descriptions"> for details.
9892 In a <file>.changes</file> file it contains a summary of the
9893 descriptions for the packages being uploaded. The part of
9894 the field before the first newline is empty; thereafter
9895 each line has the name of a binary package and the summary
9896 description line from that binary package. Each line is
9897 indented by one space.</p>
9900 <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
9904 This is a boolean field which may occur only in the
9905 control file of a binary package (or in the
9906 <file>Packages</file> file) or in a per-package fields
9907 paragraph of a main source control data file.
9911 If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
9912 <prgn>dselect</prgn> will refuse to remove the package
9913 (though it can be upgraded and/or replaced). The other
9914 possible value is <tt>no</tt>, which is the same as not
9915 having the field at all.</p>
9918 <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
9923 These two fields classify the package. The
9924 <tt>Priority</tt> represents how important that it is that
9925 the user have it installed; the <tt>Section</tt>
9926 represents an application area into which the package has
9931 When they appear in the <file>debian/control</file> file these
9932 fields give values for the section and priority subfields
9933 of the <tt>Files</tt> field of the <file>.changes</file> file,
9934 and give defaults for the section and priority of the
9939 The section and priority are represented, though not as
9940 separate fields, in the information for each file in the
9941 <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
9942 <file>.changes</file> file. The section value in a
9943 <file>.changes</file> file is used to decide where to install
9944 a package in the FTP archive.
9948 These fields are not used by by <prgn>dpkg</prgn> proper,
9949 but by <prgn>dselect</prgn> when it sorts packages and
9954 These fields can appear in binary package control files,
9955 in which case they provide a default value in case the
9956 <file>Packages</file> files are missing the information.
9957 <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
9958 the value from a <file>.deb</file> file if they have no other
9959 information; a value listed in a <file>Packages</file> file
9960 will always take precedence. By default
9961 <prgn>dpkg-gencontrol</prgn> does not include the section
9962 and priority in the control file of a binary package - use
9963 the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
9964 achieve this effect.</p>
9967 <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
9971 This field is a list of binary packages.
9975 When it appears in the <file>.dsc</file> file it is the list
9976 of binary packages which a source package can produce. It
9977 does not necessarily produce all of these binary packages
9978 for every architecture. The source control file doesn't
9979 contain details of which architectures are appropriate for
9980 which of the binary packages.
9984 When it appears in a <file>.changes</file> file it lists the
9985 names of the binary packages actually being uploaded.
9989 The syntax is a list of binary packages separated by
9993 A space after each comma is conventional.
9995 </footnote> Currently the packages must be separated using
9996 only spaces in the <file>.changes</file> file.</p>
9999 <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10003 This field appears in the control files of binary
10004 packages, and in the <file>Packages</file> files. It gives
10005 the total amount of disk space required to install the
10010 The disk space is represented in kilobytes as a simple
10011 decimal number.</p>
10014 <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10018 This field contains a list of files with information about
10019 each one. The exact information and syntax varies with
10020 the context. In all cases the part of the field
10021 contents on the same line as the field name is empty. The
10022 remainder of the field is one line per file, each line
10023 being indented by one space and containing a number of
10024 sub-fields separated by spaces.
10028 In the <file>.dsc</file> (Debian source control) file each
10029 line contains the MD5 checksum, size and filename of the
10030 tarfile and (if applicable) diff file which make up the
10031 remainder of the source package.
10034 That is, the parts which are not the
10037 </footnote> The exact forms of the filenames are described
10038 in <ref id="pkg-sourcearchives">.
10042 In the <file>.changes</file> file this contains one line per
10043 file being uploaded. Each line contains the MD5 checksum,
10044 size, section and priority and the filename. The section
10045 and priority are the values of the corresponding fields in
10046 the main source control file - see <ref
10047 id="pkg-f-classification">. If no section or priority is
10048 specified then <tt>-</tt> should be used, though section
10049 and priority values must be specified for new packages to
10050 be installed properly.
10054 The special value <tt>byhand</tt> for the section in a
10055 <tt>.changes</tt> file indicates that the file in question
10056 is not an ordinary package file and must by installed by
10057 hand by the distribution maintainers. If the section is
10058 <tt>byhand</tt> the priority should be <tt>-</tt>.
10062 If a new Debian revision of a package is being shipped and
10063 no new original source archive is being distributed the
10064 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10065 entry for the original source archive
10066 <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10067 but the <file>.changes</file> file should leave it out. In
10068 this case the original source archive on the distribution
10069 site must match exactly, byte-for-byte, the original
10070 source archive which was used to generate the
10071 <file>.dsc</file> file and diff which are being uploaded.</p>
10076 id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10080 The most recent version of the standards (the Debian Policy
10081 and associated texts) with which the package complies. This
10082 is updated manually when editing the source package to
10083 conform to newer standards; it can sometimes be used to
10084 tell when a package needs attention.
10088 Its format is the same as that of a version number except
10089 that no epoch or Debian revision is allowed - see <ref
10090 id="versions">.</p>
10094 <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10098 In a <file>.changes</file> file or parsed changelog output
10099 this contains the (space-separated) name(s) of the
10100 distribution(s) where this version of the package should
10101 be or was installed. Distribution names follow the rules
10102 for package names. (See <ref id="pkg-f-Package">).
10106 Current distribution values are:
10108 <tag><em>stable</em></tag>
10111 This is the current "released" version of Debian
10112 GNU/Linux. A new version is released approximately
10113 every 3 months after the <em>development</em> code has
10114 been <em>frozen</em> for a month of testing. Once the
10115 distribution is <em>stable</em> only major bug fixes
10116 are allowed. When changes are made to this
10117 distribution, the release number is increased
10118 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10122 <tag><em>unstable</em></tag>
10125 This distribution value refers to the
10126 <em>developmental</em> part of the Debian distribution
10127 tree. New packages, new upstream versions of packages
10128 and bug fixes go into the <em>unstable</em> directory
10129 tree. Download from this distribution at your own
10133 <tag><em>contrib</em></tag>
10136 The packages with this distribution value do not meet
10137 the criteria for inclusion in the main Debian
10138 distribution as defined by the Policy Manual, but meet
10139 the criteria for the <em>contrib</em>
10140 Distribution. There is currently no distinction
10141 between stable and unstable packages in the
10142 <em>contrib</em> or <em>non-free</em>
10143 distributions. Use your best judgement in downloading
10144 from this Distribution.</p>
10147 <tag><em>non-free</em></tag>
10150 Like the packages in the <em>contrib</em> seciton,
10151 the packages in <em>non-free</em> do not meet the
10152 criteria for inclusion in the main Debian distribution
10153 as defined by the Policy Manual. Again, use your best
10154 judgement in downloading from this Distribution.</p>
10156 <tag><em>experimental</em></tag>
10159 The packages with this distribution value are deemed
10160 by their maintainers to be high risk. Oftentimes they
10161 represent early beta or developmental packages from
10162 various sources that the maintainers want people to
10163 try, but are not ready to be a part of the other parts
10164 of the Debian distribution tree. Download at your own
10168 <tag><em>frozen</em></tag>
10171 From time to time, (currently, every 3 months) the
10172 <em>unstable</em> distribution enters a state of
10173 "code-freeze" in anticipation of release as a
10174 <em>stable</em> version. During this period of testing
10175 (usually 4 weeks) only fixes for existing or
10176 newly-discovered bugs will be allowed.
10179 </taglist> You should list <em>all</em> distributions that
10180 the package should be installed into. Except in unusual
10181 circumstances, installations to <em>stable</em> should also
10182 go into <em>frozen</em> (if it exists) and
10183 <em>unstable</em>. Likewise, installations into
10184 <em>frozen</em> should also go into <em>unstable</em>.</p>
10187 <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10191 This is a description of how important it is to upgrade to
10192 this version from previous ones. It consists of a single
10193 keyword usually taking one of the values <tt>LOW</tt>,
10194 <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10195 commentary (separated by a space) which is usually in
10196 parentheses. For example:
10198 Urgency: LOW (HIGH for diversions users)
10203 This field appears in the <file>.changes</file> file and in
10204 parsed changelogs; its value appears as the value of the
10205 <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10206 changelog (see <ref id="pkg-dpkgchangelog">).
10210 Urgency keywords are not case-sensitive.</p>
10213 <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10217 In <tt>.changes</tt> files and parsed changelogs, this
10218 gives the date the package was built or last edited.</p>
10221 <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10225 This field occurs in <file>.changes</file> files, and
10226 specifies a format revision for the file. The format
10227 described here is version <tt>1.5</tt>. The syntax of the
10228 format value is the same as that of a package version
10229 number except that no epoch or Debian revision is allowed
10230 - see <ref id="versions">.</p>
10233 <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10237 In a <file>.changes</file> file or parsed changelog this field
10238 contains the human-readable changes data, describing the
10239 differences between the last version and the current one.
10243 There should be nothing in this field before the first
10244 newline; all the subsequent lines must be indented by at
10245 least one space; blank lines must be represented by a line
10246 consiting only of a space and a full stop.
10250 Each version's change information should be preceded by a
10251 "title" line giving at least the version, distribution(s)
10252 and urgency, in a human-readable way.
10256 If data from several versions is being returned the entry
10257 for the most recent version should be returned first, and
10258 entries should be separated by the representation of a
10259 blank line (the "title" line may also be followed by the
10260 representation of blank line).</p>
10263 <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10264 <tt>MSDOS-Filename</tt>
10268 These fields in <tt>Packages</tt> files give the
10269 filename(s) of (the parts of) a package in the
10270 distribution directories, relative to the root of the
10271 Debian hierarchy. If the package has been split into
10272 several parts the parts are all listed in order, separated
10277 <sect1 id="pkg-f-Size">
10278 <heading><tt>Size</tt> and <tt>MD5sum</tt></heading>
10281 These fields in <file>Packages</file> files give the size (in
10282 bytes, expressed in decimal) and MD5 checksum of the
10283 file(s) which make(s) up a binary package in the
10284 distribution. If the package is split into several parts
10285 the values for the parts are listed in order, separated by
10290 <sect1 id="pkg-f-Status">
10291 <heading><tt>Status</tt></heading>
10294 This field in <prgn>dpkg</prgn>'s status file records
10295 whether the user wants a package installed, removed or
10296 left alone, whether it is broken (requiring
10297 reinstallation) or not and what its current state on the
10298 system is. Each of these pieces of information is a
10303 <sect1 id="pkg-f-Config-Version">
10304 <heading><tt>Config-Version</tt></heading>
10307 If a package is not installed or not configured, this
10308 field in <prgn>dpkg</prgn>'s status file records the last
10309 version of the package which was successfully
10314 <sect1 id="pkg-f-Conffiles">
10315 <heading><tt>Conffiles</tt></heading>
10318 This field in <prgn>dpkg</prgn>'s status file contains
10319 information about the automatically-managed configuration
10320 files held by a package. This field should <em>not</em>
10321 appear anywhere in a package!
10326 <heading>Obsolete fields</heading>
10329 These are still recognised by <prgn>dpkg</prgn> but should
10330 not appear anywhere any more.
10332 <taglist compact="compact">
10334 <tag><tt>Revision</tt></tag>
10335 <tag><tt>Package-Revision</tt></tag>
10336 <tag><tt>Package_Revision</tt></tag>
10338 The Debian revision part of the package version was
10339 at one point in a separate control file field. This
10340 field went through several names.
10343 <tag><tt>Recommended</tt></tag>
10344 <item>Old name for <tt>Recommends</tt>.</item>
10346 <tag><tt>Optional</tt></tag>
10347 <item>Old name for <tt>Suggests</tt>.</item>
10349 <tag><tt>Class</tt></tag>
10350 <item>Old name for <tt>Priority</tt>.</item>
10359 <appendix id="pkg-conffiles">
10360 <heading>Configuration file handling (from old Packaging Manual)</heading>
10363 <prgn>dpkg</prgn> can do a certain amount of automatic
10364 handling of package configuration files.
10368 Whether this mechanism is appropriate depends on a number of
10369 factors, but basically there are two approaches to any
10370 particular configuration file.
10374 The easy method is to ship a best-effort configuration in the
10375 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10376 handle updates. If the user is unlikely to want to edit the
10377 file, but you need them to be able to without losing their
10378 changes, and a new package with a changed version of the file
10379 is only released infrequently, this is a good approach.
10383 The hard method is to build the configuration file from
10384 scratch in the <prgn>postinst</prgn> script, and to take the
10385 responsibility for fixing any mistakes made in earlier
10386 versions of the package automatically. This will be
10387 appropriate if the file is likely to need to be different on
10391 <sect><heading>Automatic handling of configuration files by
10396 A package may contain a control area file called
10397 <tt>conffiles</tt>. This file should be a list of filenames
10398 of configuration files needing automatic handling, separated
10399 by newlines. The filenames should be absolute pathnames,
10400 and the files referred to should actually exist in the
10405 When a package is upgraded <prgn>dpkg</prgn> will process
10406 the configuration files during the configuration stage,
10407 shortly before it runs the package's <prgn>postinst</prgn>
10412 For each file it checks to see whether the version of the
10413 file included in the package is the same as the one that was
10414 included in the last version of the package (the one that is
10415 being upgraded from); it also compares the version currently
10416 installed on the system with the one shipped with the last
10421 If neither the user nor the package maintainer has changed
10422 the file, it is left alone. If one or the other has changed
10423 their version, then the changed version is preferred - i.e.,
10424 if the user edits their file, but the package maintainer
10425 doesn't ship a different version, the user's changes will
10426 stay, silently, but if the maintainer ships a new version
10427 and the user hasn't edited it the new version will be
10428 installed (with an informative message). If both have
10429 changed their version the user is prompted about the problem
10430 and must resolve the differences themselves.
10434 The comparisons are done by calculating the MD5 message
10435 digests of the files, and storing the MD5 of the file as it
10436 was included in the most recent version of the package.
10440 When a package is installed for the first time
10441 <prgn>dpkg</prgn> will install the file that comes with it,
10442 unless that would mean overwriting a file already on the
10447 However, note that <prgn>dpkg</prgn> will <em>not</em>
10448 replace a conffile that was removed by the user (or by a
10449 script). This is necessary because with some programs a
10450 missing file produces an effect hard or impossible to
10451 achieve in another way, so that a missing file needs to be
10452 kept that way if the user did it.
10456 Note that a package should <em>not</em> modify a
10457 <prgn>dpkg</prgn>-handled conffile in its maintainer
10458 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
10459 the user confusing and possibly dangerous options for
10460 conffile update when the package is upgraded.</p>
10463 <sect><heading>Fully-featured maintainer script configuration
10468 For files which contain site-specific information such as
10469 the hostname and networking details and so forth, it is
10470 better to create the file in the package's
10471 <prgn>postinst</prgn> script.
10475 This will typically involve examining the state of the rest
10476 of the system to determine values and other information, and
10477 may involve prompting the user for some information which
10478 can't be obtained some other way.
10482 When using this method there are a couple of important
10483 issues which should be considered:
10487 If you discover a bug in the program which generates the
10488 configuration file, or if the format of the file changes
10489 from one version to the next, you will have to arrange for
10490 the postinst script to do something sensible - usually this
10491 will mean editing the installed configuration file to remove
10492 the problem or change the syntax. You will have to do this
10493 very carefully, since the user may have changed the file,
10494 perhaps to fix the very problem that your script is trying
10495 to deal with - you will have to detect these situations and
10496 deal with them correctly.
10500 If you do go down this route it's probably a good idea to
10501 make the program that generates the configuration file(s) a
10502 separate program in <file>/usr/sbin</file>, by convention called
10503 <file><var>package</var>config</file> and then run that if
10504 appropriate from the post-installation script. The
10505 <tt><var>package</var>config</tt> program should not
10506 unquestioningly overwrite an existing configuration - if its
10507 mode of operation is geared towards setting up a package for
10508 the first time (rather than any arbitrary reconfiguration
10509 later) you should have it check whether the configuration
10510 already exists, and require a <tt>--force</tt> flag to
10511 overwrite it.</p></sect>
10514 <appendix id="pkg-alternatives"><heading>Alternative versions of
10515 an interface - <prgn>update-alternatives</prgn> (from old
10520 When several packages all provide different versions of the
10521 same program or file it is useful to have the system select a
10522 default, but to allow the system administrator to change it
10523 and have their decisions respected.
10527 For example, there are several versions of the <prgn>vi</prgn>
10528 editor, and there is no reason to prevent all of them from
10529 being installed at once, each under their own name
10530 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10531 Nevertheless it is desirable to have the name <tt>vi</tt>
10532 refer to something, at least by default.
10536 If all the packages involved cooperate, this can be done with
10537 <prgn>update-alternatives</prgn>.
10541 Each package provides its own version under its own name, and
10542 calls <prgn>update-alternatives</prgn> in its postinst to
10543 register its version (and again in its prerm to deregister
10548 See the manpage <manref name="update-alternatives"
10549 section="8"> for details.
10553 If <prgn>update-alternatives</prgn> does not seem appropriate
10554 you may wish to consider using diversions instead.</p>
10557 <appendix id="pkg-diversions"><heading>Diversions - overriding a
10558 package's version of a file (from old Packaging Manual)
10562 It is possible to have <prgn>dpkg</prgn> not overwrite a file
10563 when it reinstalls the package it belongs to, and to have it
10564 put the file from the package somewhere else instead.
10568 This can be used locally to override a package's version of a
10569 file, or by one package to override another's version (or
10570 provide a wrapper for it).
10574 Before deciding to use a diversion, read <ref
10575 id="pkg-alternatives"> to see if you really want a diversion
10576 rather than several alternative versions of a program.
10580 There is a diversion list, which is read by <prgn>dpkg</prgn>,
10581 and updated by a special program <prgn>dpkg-divert</prgn>.
10582 Please see <manref name="dpkg-divert" section="8"> for full
10583 details of its operation.
10587 When a package wishes to divert a file from another, it should
10588 call <prgn>dpkg-divert</prgn> in its preinst to add the
10589 diversion and rename the existing file. For example,
10590 supposing that a <prgn>smailwrapper</prgn> package wishes to
10591 install a wrapper around <file>/usr/sbin/smail</file>:
10593 if [ install = "$1" ]; then
10594 dpkg-divert --package smailwrapper --add --rename \
10595 --divert /usr/sbin/smail.real /usr/sbin/smail
10597 </example> Testing <tt>$1</tt> is necessary so that the script
10598 doesn't try to add the diversion again when
10599 <prgn>smailwrapper</prgn> is upgraded. The <tt>--package
10600 smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10601 copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10602 get installed as the true version.
10606 The postrm has to do the reverse:
10608 if [ remove = "$1" ]; then
10609 dpkg-divert --package smailwrapper --remove --rename \
10610 --divert /usr/sbin/smail.real /usr/sbin/smail
10616 Do not attempt to divert a file which is vitally important for
10617 the system's operation - when using <prgn>dpkg-divert</prgn>
10618 there is a time, after it has been diverted but before
10619 <prgn>dpkg</prgn> has installed the new version, when the file
10620 does not exist.</p>
10625 <!-- vim:set ai et sts=2 sw=2 tw=76: -->