1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3 within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
10 <title>Debian Policy Manual</title>
11 <author><ref id="authors"></author>
12 <version>version &version;, &date;</version>
15 This manual describes the policy requirements for the Debian
16 GNU/Linux distribution. This includes the structure and
17 contents of the Debian archive and several design issues of
18 the operating system, as well as technical requirements that
19 each package must satisfy to be included in the distribution.
24 Copyright © 1996,1997,1998 Ian Jackson
25 and Christian Schwarz.
28 This manual is free software; you may redistribute it and/or
29 modify it under the terms of the GNU General Public License
30 as published by the Free Software Foundation; either version
31 2, or (at your option) any later version.
35 This is distributed in the hope that it will be useful, but
36 <em>without any warranty</em>; without even the implied
37 warranty of merchantability or fitness for a particular
38 purpose. See the GNU General Public License for more
43 A copy of the GNU General Public License is available as
44 <file>/usr/share/common-licenses/GPL</file> in the Debian GNU/Linux
45 distribution or on the World Wide Web at
46 <url id="http://www.gnu.org/copyleft/gpl.html"
47 name="the GNU General Public Licence">. You can also
48 obtain it by writing to the Free Software Foundation, Inc.,
49 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
57 <heading>About this manual</heading>
59 <heading>Scope</heading>
61 This manual describes the policy requirements for the Debian
62 GNU/Linux distribution. This includes the structure and
63 contents of the Debian archive and several design issues of the
64 operating system, as well as technical requirements that
65 each package must satisfy to be included in the
71 This manual also describes Debian policy as it relates to
72 creating Debian packages. It is not a tutorial on how to build
73 packages, nor is it exhaustive where it comes to describing
74 the behavior of the packaging system. Instead, this manual
75 attempts to define the interface to the package management
76 system that the developers have to be conversant with.<footnote>
78 Informally, the criteria used for inclusion is that the
79 material meet one of the following requirements:
80 <taglist compact="compact">
81 <tag>Standard interfaces</tag>
84 The material presented represents an interface to
85 the packaging system that is mandated for use, and
86 is used by, a significant number of packages, and
87 therefore should not be changed without peer
88 review. Package maintainers can then rely on this
89 interfaces not changing, and the package
90 management software authors need to ensure
91 compatibility with these interface
92 definitions. (Control file and changelog file
93 formats are examples.)
96 <tag>Chosen Convention</tag>
99 If there are a number of technically viable choices
100 that can be made, but one needs to select one of
101 these options for inter-operability. The version
102 number format is one example.
106 Please note that these are not mutually exclusive;
107 selected conventions often become parts of standard
114 The footnotes present in this manual are
115 merely informative, and are not part of Debian policy itself.
119 In this manual, the words <em>must</em>, <em>should</em> and
120 <em>may</em>, and the adjectives <em>required</em>,
121 <em>recommended</em> and <em>optional</em>, are used to
122 distinguish the significance of the various guidelines in
123 this policy document. Packages that do not conform to the
124 guidelines denoted by <em>must</em> (or <em>required</em>)
125 will generally not be considered acceptable for the Debian
126 distribution. Non-conformance with guidelines denoted by
127 <em>should</em> (or <em>recommended</em>) will generally be
128 considered a bug, but will not necessarily render a package
129 unsuitable for distribution. Guidelines denoted by
130 <em>may</em> (or <em>optional</em>) are truly optional and
131 adherence is left to the maintainer's discretion.
134 These classifications are roughly equivalent to the bug
135 severities <em>serious</em> (for <em>must</em> or
136 <em>required</em> directive violations), <em>minor</em>,
137 <em>normal</em> or <em>important</em>
138 (for <em>should</em> or <em>recommended</em> directive
139 violations) and <em>wishlist</em> (for <em>optional</em>
141 <p>Compare RFC 2119. Note, however, that these words are
142 used in a different way in this document.</p>
146 Much of the information presented in this manual will be
147 useful even when building a package which is to be
148 distributed in some other way or is intended for local use
154 <heading>New versions of this document</heading>
156 The current version of this document is always accessible
157 from the Debian FTP server <ftpsite>ftp.debian.org</ftpsite>
159 <ftppath>/debian/doc/package-developer/policy.txt.gz</ftppath>
160 (also available from the same directory are several other
161 formats: <file>policy.html.tar.gz</file>, <file>policy.pdf.gz</file>
162 and <file>policy.ps.gz</file>) or from the <url
163 id="http://www.debian.org/doc/debian-policy/" name="Debian
164 Policy Manual"> webpage.</p>
167 In addition, this manual is distributed via the Debian package
168 <file>debian-policy</file>.
172 The <tt>debian-policy</tt> package also includes the file
173 <file>upgrading-checklist.txt</file> which indicates policy
174 changes between versions of this document.
179 <heading>Authors and Maintainers</heading>
182 Originally called "Debian GNU/Linux Policy Manual", this
183 manual was initially written in 1996 by Ian Jackson.
184 It was revised on November 27th, 1996 by David A. Morris.
185 Christian Schwarz added new sections on March 15th, 1997,
186 and reworked/restructured it in April-July 1997.
187 Christoph Lameter contributed the "Web Standard".
188 Julian Gilbey largely restructured it in 2001.
192 Since September 1998, the responsibility for the contents of
193 this document lies on the debian-policy mailing list. Proposals
194 are discussed there and inserted into policy after a certain
195 consensus is established.
196 <!-- insert shameless policy-process plug here eventually -->
197 The actual editing is done by a group of maintainers that have
198 no editorial powers. These are the current maintainers:
201 <item>Julian Gilbey</item>
202 <item>Branden Robinson</item>
203 <item>Josip Rodin</item>
204 <item>Manoj Srivastava</item>
209 While the authors of this document have tried hard to avoid
210 typos and other errors, these do still occur. If you discover
211 an error in this manual or if you want to give any
212 comments, suggestions, or criticisms please send an email to
213 the Debian Policy List,
214 <email>debian-policy@lists.debian.org</email>, or submit a
215 bug report against the <tt>debian-policy</tt> package.
219 Please do not try to reach the individual authors or maintainers
220 of the Policy Manual regarding changes to the Policy.
226 <heading>The Debian Archive</heading>
228 The Debian GNU/Linux system is maintained and distributed as a
229 collection of <em>packages</em>. Since there are so many of
230 them (currently well over 6000), they are split into
231 <em>sections</em> and given <em>priorities</em> to simplify
232 the handling of them.
235 The effort of the Debian project is to build a free operating
236 system, but not every package we want to make accessible is
237 <em>free</em> in our sense (see the Debian Free Software
238 Guidelines, below), or may be imported/exported without
239 restrictions. Thus, the archive is split into the sections
240 <em>main</em>, <em>non-free</em>, <em>contrib</em>,
241 <em>non-US/main</em>, <em>non-US/non-free</em>, and
242 <em>non-US/contrib</em>. The sections are explained in detail
247 The <em>main</em> and the <em>non-US/main</em> sections
248 together form the <em>Debian GNU/Linux distribution</em>.
252 Packages in the other sections are not considered to be part
253 of the Debian distribution, although we support their use and
254 provide infrastructure for them (such as our bug-tracking
255 system and mailing lists). This Debian Policy Manual applies
256 to these packages as well.</p>
258 <sect id="pkgcopyright">
259 <heading>Package copyright and sections</heading>
261 The aims of this section are:
263 <list compact="compact">
265 <p>to allow us to make as much software available as we
269 <p>to allow us to encourage everyone to write free
273 <p>to allow us to make it easy for people to produce
274 CD-ROMs of our system without violating any licenses,
275 import/export restrictions, or any other laws.</p>
280 <heading>The Debian Free Software Guidelines</heading>
282 The Debian Free Software Guidelines (DFSG) form our
283 definition of "free software". These are:
285 <tag>Free Redistribution
289 The license of a Debian component may not restrict any
290 party from selling or giving away the software as a
291 component of an aggregate software distribution
292 containing programs from several different
293 sources. The license may not require a royalty or
294 other fee for such sale.
301 The program must include source code, and must allow
302 distribution in source code as well as compiled form.
309 The license must allow modifications and derived
310 works, and must allow them to be distributed under the
311 same terms as the license of the original software.
314 <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.)
331 <tag>No Discrimination Against Persons or Groups
335 The license must not discriminate against any person
339 <tag>No Discrimination Against Fields of Endeavor
343 The license must not restrict anyone from making use
344 of the program in a specific field of endeavor. For
345 example, it may not restrict the program from being
346 used in a business, or from being used for genetic
350 <tag>Distribution of License
354 The rights attached to the program must apply to all
355 to whom the program is redistributed without the need
356 for execution of an additional license by those
360 <tag>License Must Not Be Specific to Debian
364 The rights attached to the program must not depend on
365 the program's being part of a Debian system. If the
366 program is extracted from Debian and used or
367 distributed without Debian but otherwise within the
368 terms of the program's license, all parties to whom
369 the program is redistributed must have the same
370 rights as those that are granted in conjunction with
374 <tag>License Must Not Contaminate Other Software
378 The license must not place restrictions on other
379 software that is distributed along with the licensed
380 software. For example, the license must not insist
381 that all other programs distributed on the same medium
382 must be free software.
385 <tag>Example Licenses
389 The "GPL," "BSD," and "Artistic" licenses are examples of
390 licenses that we consider <em>free</em>.
397 <heading>The main section</heading>
399 Every package in <em>main</em> and <em>non-US/main</em>
400 must comply with the DFSG (Debian Free Software
404 In addition, the packages in <em>main</em>
405 <list compact="compact">
408 must not require a package outside of <em>main</em>
409 for compilation or execution (thus, the package must
410 not declare a "Depends", "Recommends", or
411 "Build-Depends" relationship on a non-<em>main</em>
417 must not be so buggy that we refuse to support them,
423 must meet all policy requirements presented in this
430 Similarly, the packages in <em>non-US/main</em>
431 <list compact="compact">
434 must not require a package outside of <em>main</em>
435 or <em>non-US/main</em> for compilation or
441 must not be so buggy that we refuse to support them,
446 must meet all policy requirements presented in this
454 <heading>The contrib section</heading>
456 Every package in <em>contrib</em> and
457 <em>non-US/contrib</em> must comply with the DFSG.
461 In addition, the packages in <em>contrib</em> and
462 <em>non-US/contrib</em>
463 <list compact="compact">
466 must not be so buggy that we refuse to support them,
472 must meet all policy requirements presented in this
480 Furthermore, packages in <em>contrib</em> must not require
481 a package in a <em>non-US</em> section for compilation or
486 Examples of packages which would be included in
487 <em>contrib</em> or <em>non-US/contrib</em> are:
488 <list compact="compact">
491 free packages which require <em>contrib</em>,
492 <em>non-free</em> packages or packages which are not
493 in our archive at all for compilation or execution,
499 wrapper packages or other sorts of free accessories for
507 <heading>The non-free section</heading>
509 Packages must be placed in <em>non-free</em> or
510 <em>non-US/non-free</em> if they are not compliant with
511 the DFSG or are encumbered by patents or other legal
512 issues that make their distribution problematic.
515 In addition, the packages in <em>non-free</em> and
516 <em>non-US/non-free</em>
517 <list compact="compact">
520 must not be so buggy that we refuse to support them,
526 must meet all policy requirements presented in this
527 manual that it is possible for them to meet.<footnote>
529 It is possible that there are policy
530 requirements which the package is unable to
531 meet, for example, if the source is
532 unavailable. These situations will need to be
533 handled on a case-by-case basis.
543 <heading>The non-US sections</heading>
545 Non-free programs with cryptographic program code need to
546 be stored on the <em>non-us</em> server because of export
547 restrictions of the U.S.
550 Programs which use patented algorithms that have a
551 restrictied license also need to be stored on "non-us",
552 since that is located in a country where it is not allowed
553 to patent algorithms.
556 A package depends on another package which is distributed
557 via the non-us server has to be stored on the non-us
562 <heading>Further copyright considerations</heading>
564 Every package must be accompanied by a verbatim copy of
565 its copyright and distribution license in the file
566 <file>/usr/share/doc/<var>package</var>/copyright</file>
567 (see <ref id="copyrightfile"> for further details).
570 We reserve the right to restrict files from being included
571 anywhere in our archives if
572 <list compact="compact">
575 their use or distribution would break a law,
580 there is an ethical conflict in their distribution or
586 we would have to sign a license for them, or
591 their distribution would conflict with other project
599 Programs whose authors encourage the user to make
600 donations are fine for the main distribution, provided
601 that the authors do not claim that not donating is
602 immoral, unethical, illegal or something similar; in such
603 a case they must go in <em>non-free</em>.</p>
606 Packages whose copyright permission notices (or patent
607 problems) do not even allow redistribution of binaries
608 only, and where no special permission has been obtained,
609 must not be placed on the Debian FTP site and its mirrors
613 Note that under international copyright law (this applies
614 in the United States, too), <em>no</em> distribution or
615 modification of a work is allowed without an explicit
616 notice saying so. Therefore a program without a copyright
617 notice <em>is</em> copyrighted and you may not do anything
618 to it without risking being sued! Likewise if a program
619 has a copyright notice but no statement saying what is
620 permitted then nothing is permitted.</p>
623 Many authors are unaware of the problems that restrictive
624 copyrights (or lack of copyright notices) can cause for
625 the users of their supposedly-free software. It is often
626 worthwhile contacting such authors diplomatically to ask
627 them to modify their license terms. However, this can be a
628 politically difficult thing to do and you should ask for
629 advice on the <tt>debian-legal</tt> mailing list first, as
634 When in doubt about a copyright, send mail to
635 <email>debian-legal@lists.debian.org</email>. Be prepared
636 to provide us with the copyright statement. Software
637 covered by the GPL, public domain software and BSD-like
638 copyrights are safe; be wary of the phrases "commercial
639 use prohibited" and "distribution restricted".
643 <heading>Subsections</heading>
646 The packages in the sections <em>main</em>,
647 <em>contrib</em> and <em>non-free</em> are grouped further
648 into <em>subsections</em> to simplify handling.
652 The section and subsection for each package should be
653 specified in the package's <tt>Section</tt> control
654 record. However, the maintainer of the Debian archive
655 may override this selection to ensure the consistency of
656 the Debian distribution. The <tt>Section</tt> field
657 should be of the form:
658 <list compact="compact">
661 <em>subsection</em> if the package is in the
662 <em>main</em> section,
667 <em>section/subsection</em> if the package is in
668 the <em>contrib</em> or <em>non-free</em> section,
674 <tt>non-US</tt>, <tt>non-US/contrib</tt> or
675 <tt>non-US/non-free</tt> if the package is in
676 <em>non-US/main</em>, <em>non-US/contrib</em> or
677 <em>non-US/non-free</em> respectively.
684 The Debian archive maintainers provide the authoritative
685 list of subsections. At present, they are:
686 <em>admin</em>, <em>base</em>, <em>comm</em>,
687 <em>contrib</em>, <em>devel</em>, <em>doc</em>,
688 <em>editors</em>, <em>electronics</em>, <em>games</em>,
689 <em>graphics</em>, <em>hamradio</em>,
690 <em>interpreters</em>, <em>libs</em>, <em>mail</em>,
691 <em>math</em>, <em>misc</em>, <em>net</em>, <em>news</em>,
692 <em>non-US</em>, <em>non-free</em>, <em>oldlibs</em>,
693 <em>otherosfs</em>, <em>science</em>, <em>shells</em>,
694 <em>sound</em>, <em>tex</em>, <em>text</em>,
695 <em>utils</em>, <em>web</em>, <em>x11</em>.
699 <heading>Priorities</heading>
702 Each package should have a <em>priority</em> value, which is
703 included in the package's <em>control record</em>. This
704 information is used by the Debian package management tools
705 to separate high-priority packages from less-important
709 The following <em>priority levels</em> are recognised by the
710 Debian package management tools.
712 <tag><tt>required</tt></tag>
715 Packages which are necessary for the proper
716 functioning of the system. You must not remove these
717 packages or your system may become totally broken and
718 you may not even be able to use <prgn>dpkg</prgn> to
719 put things back. Systems with only the
720 <tt>required</tt> packages are probably unusable, but
721 they do have enough functionality to allow the
722 sysadmin to boot and install more software.</p>
724 <tag><tt>important</tt></tag>
727 Important programs, including those which one would
728 expect to find on any Unix-like system. If the
729 expectation is that an experienced Unix person who
730 found it missing would say "What on earth is going on,
731 where is <prgn>foo</prgn>?", it must be an
732 <tt>important</tt> package.<footnote>
734 This is an important criterion because we are
735 trying to produce, amongst other things, a free
739 Other packages without which the system will not run
740 well or be usable must also have priority
741 <tt>important</tt>. This does
742 <em>not</em> include Emacs, the X Window System, TeX
743 or any other large applications. The
744 <tt>important</tt> packages are just a bare minimum of
745 commonly-expected and necessary tools.</p>
747 <tag><tt>standard</tt></tag>
750 These packages provide a reasonably small but not too
751 limited character-mode system. This is what will be
752 installed by default if the user doesn't select anything
753 else. It doesn't include many large applications.</p>
755 <tag><tt>optional</tt></tag>
758 (In a sense everything that isn't required is
759 optional, but that's not what is meant here.) This is
760 all the software that you might reasonably want to
761 install if you didn't know what it was and don't have
762 specialized requirements. This is a much larger system
763 and includes the X Window System, a full TeX
764 distribution, and many applications. Note that
765 optional packages should not conflict with each other.
768 <tag><tt>extra</tt></tag>
771 This contains all packages that conflict with others
772 with required, important, standard or optional
773 priorities, or are only likely to be useful if you
774 already know what they are or have specialised
781 Packages must not depend on packages with lower priority
782 values (excluding build-time dependencies). In order to
783 ensure this, the priorities of one or more packages may need
789 <heading>Binary packages</heading>
792 The Debian GNU/Linux distribution is based on the Debian
793 package management system, called <prgn>dpkg</prgn>. Thus,
794 all packages in the Debian distribution must be provided
795 in the <tt>.deb</tt> file format.</p>
799 <heading>The package name</heading>
802 Every package must have a name that's unique within the Debian
806 Package names must consist of lower case letters
807 (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus (<tt>+</tt>)
808 and minus (<tt>-</tt>) signs, and periods (<tt>.</tt>).
809 They must be at least two characters long and must start
810 with an alphanumeric character.
814 The package name is part of the file name of the
815 <tt>.deb</tt> file and is included in the control field
821 <heading>The maintainer of a package</heading>
823 Every package must have a Debian maintainer (the
824 maintainer may be one person or a group of people
825 reachable from a common email address, such as a mailing
826 list). The maintainer is responsible for ensuring that
827 the package is placed in the appropriate distributions.
831 The maintainer must be specified in the
832 <tt>Maintainer</tt> control field with their correct name
833 and a working email address. If one person maintains
834 several packages, he/she should try to avoid having
835 different forms of their name and email address in
836 the <tt>Maintainer</tt> fields of those packages.
840 If the maintainer of a package quits from the Debian
841 project, "Debian QA Group"
842 <email>packages@qa.debian.org</email> takes over the
843 maintainership of the package until someone else
844 volunteers for that task. These packages are called
845 <em>orphaned packages</em>.<footnote>
847 The detailed procedure for doing this gracefully can
848 be found in the Debian Developer's Reference, either
849 in the <tt>developers-reference</tt> package, or on
850 the Debian FTP server
851 <ftpsite>ftp.debian.org</ftpsite> as
852 <ftppath>/debian/doc/package-developer/developers-reference.txt.gz</ftppath>
854 id="http://www.debian.org/doc/packaging-manuals/developers-reference/"
855 name="Debian Developer's Reference"> webpage.
863 <heading>The description of a package</heading>
866 Every Debian package must have an extended description
867 stored in the appropriate field of the control record.</p>
870 The description should be written so that it gives the
871 system administrator enough information to decide whether
872 to install the package. This description should not just
873 be copied verbatim from the program's documentation.
874 Instructions for configuring or using the package should
875 not be included (that is what installation scripts,
876 manual pages, info files, etc., are for). Copyright
877 statements and other administrivia should not be included
878 either (that is what the copyright file is for).
882 Please refer to <ref id="descriptions"> for more information.
889 <heading>Dependencies</heading>
892 Every package must specify the dependency information
893 about other packages that are required for the first to
897 For example, a dependency entry must be provided for any
898 shared libraries required by a dynamically-linked executable
899 binary in a package.</p>
902 Packages are not required to declare any dependencies they
903 have on other packages which are marked <tt>Essential</tt>
904 (see below), and should not do so unless they depend on a
905 particular version of that package.</p>
908 Sometimes, a package requires another package to be installed
909 <em>and</em> configured before it can be installed. In this
910 case, you must specify a <tt>Pre-Depends</tt> entry for
914 You should not specify a <tt>Pre-Depends</tt> entry for a
915 package before this has been discussed on the
916 <tt>debian-devel</tt> mailing list and a consensus about
917 doing that has been reached.</p></sect1>
920 <sect1 id="virtual_pkg_sect">
921 <heading>Virtual packages</heading>
924 Sometimes, there are several packages which offer
925 more-or-less the same functionality. In this case, it's
926 useful to define a <em>virtual package</em> whose name
927 describes that common functionality. (The virtual
928 packages only exist logically, not physically; that's why
929 they are called <em>virtual</em>.) The packages with this
930 particular function will then <em>provide</em> the virtual
931 package. Thus, any other package requiring that function
932 can simply depend on the virtual package without having to
933 specify all possible packages individually.</p>
936 All packages should use virtual package names where
937 appropriate, and arrange to create new ones if necessary.
938 They should not use virtual package names (except privately,
939 amongst a cooperating group of packages) unless they have
940 been agreed upon and appear in the list of virtual package
941 names. (See also <ref id="virtual">)</p>
944 The latest version of the authoritative list of virtual
945 package names can be found on
946 <ftpsite>ftp.debian.org</ftpsite> in
947 <ftppath>/debian/doc/package-developer/virtual-package-names-list.txt</ftppath>
948 or your local mirror. In addition, it is included in the
949 <tt>debian-policy</tt> package. The procedure for updating
950 the list is described at the top of the file.</p></sect1>
954 <heading>Base system</heading>
957 The <tt>base system</tt> is a minimum subset of the Debian
958 GNU/Linux system that is installed before everything else
959 on a new system. Thus, only very few packages are allowed
960 to go into the <tt>base</tt> section to keep the required
961 disk usage very small.</p>
964 Most of these packages will have the priority value
965 <tt>required</tt> or at least <tt>important</tt>, and many
966 of them will be tagged <tt>essential</tt> (see below).</p>
973 <heading>Essential packages</heading>
976 Some packages are tagged <tt>essential</tt>. (They have
977 <tt>Essential: yes</tt> in their package control record.)
978 This flag is used for packages that are <em>essential</em>
982 Since these packages cannot be easily removed (one has to
983 specify an extra <em>force option</em> to
984 <prgn>dpkg</prgn> to do so), this flag must not be used
985 unless absolutely necessary. A shared library package
986 must not be tagged <tt>essential</tt>; dependencies will
987 prevent its premature removal, and we need to be able to
988 remove it when it has been superseded.
992 Since dpkg will not prevent upgrading of other packages
993 while an <tt>essential</tt> package is in an unconfigured
994 state, all <tt>essential</tt> packages must supply all of
995 their core functionality even when unconfigured. If the
996 package cannot satisfy this requirement it must not be
997 tagged as essential, and any packages depending on this
998 package must instead have explicit dependency fields as
1003 You must not tag any packages <tt>essential</tt> before
1004 this has been discussed on the <tt>debian-devel</tt>
1005 mailing list and a consensus about doing that has been
1010 <heading>Tasks</heading>
1013 The Debian install process allows the user to choose from
1014 a number of common tasks which a Debian system can be used to
1015 perform. Selecting a task with <prgn>tasksel</prgn> causes
1016 a set of packages that are useful in performing that task to be
1021 This set of packages is all available packages which have the
1022 name of the selected task in the <tt>Task</tt> field of their
1023 control file. The format of this field is a list of tasks,
1024 separated by commas.
1028 You should not tag any packages as belonging to a task
1029 before this has been discussed on the
1030 <em>debian-devel</em> mailing list and a consensus about
1031 doing that has been reached.
1035 For third parties (and historical reasons), tasksel also
1036 supports constructing tasks based on <em>task
1037 packages</em>. These are packages whose names begin with
1038 <em>task-</em>. Task packages should not be included in the
1043 <sect1 id="maintscripts">
1044 <heading>Maintainer Scripts</heading>
1047 The package installation scripts should avoid producing
1048 output which it is unnecessary for the user to see and
1049 should rely on <prgn>dpkg</prgn> to stave off boredom on
1050 the part of a user installing many packages. This means,
1051 amongst other things, using the <tt>--quiet</tt> option on
1052 <prgn>install-info</prgn>.</p>
1055 Errors which occur during the execution of an installation
1056 script must be checked and the installation must not
1057 continue after an error.
1061 Note that in general <ref id="scripts"> applies to package
1062 maintainer scripts, too.
1066 You should not use <prgn>dpkg-divert</prgn> on a file
1067 belonging to another package without consulting the
1068 maintainer of that package first.
1072 All packages which supply an instance of a common command
1073 name (or, in general, filename) should generally use
1074 <prgn>update-alternatives</prgn>, so that they may be
1075 installed together. If <prgn>update-alternatives</prgn>
1076 is not used, then each package must use
1077 <tt>Conflicts</tt> to ensure that other packages are
1078 de-installed. (In this case, it may be appropriate to
1079 specify a conflict against earlier versions of something
1080 that previously did not use
1081 <prgn>update-alternatives</prgn>; this is an exception to
1082 the usual rule that versioned conflicts should be
1088 <heading>Prompting in maintainer scripts</heading>
1090 Package maintainer scripts may prompt the user if
1091 necessary. Prompting may be accomplished by hand, or by
1092 communicating with a program, such as
1093 <prgn>debconf</prgn>, which conforms to the Debian
1094 Configuration management specification, version 2 or
1095 higher. These are included in the
1096 <file>debconf_specification</file> files in the
1097 <package>debian-policy</package> package.
1098 You may also find this file on the FTP site
1099 <ftpsite>ftp.debian.org</ftpsite> in
1100 <ftppath>/debian/doc/package-developer/debconf_specification.txt.gz</ftppath>
1101 or on your local mirror.<footnote>
1103 4% of Debian packages [see <url
1104 id="http://kitenet.net/programs/debconf/stats/"
1105 name="Debconf stats">] currently use
1106 <package>debconf</package> to prompt the user at
1107 install time, and this number is growing daily. The
1108 benefits of using debconf are briefly explained at
1110 id="http://kitenet.net/doc/debconf-doc/introduction.html"
1111 name="Debconf introduction">; they include
1112 preconfiguration, (mostly) noninteractive
1113 installation, elimination of redundant prompting,
1114 consistency of user interface, etc.
1117 With this increasing number of packages using
1118 <package>debconf</package>, plus the existance of a
1119 nascent second implementation of the Debian
1120 configuration management system
1121 (<package>cdebconf</package>), and the stabilization
1122 of the protocol these things use, the time has
1123 finally come to reflect the use of these things in
1130 Packages which use the Debian Configuration management
1131 specification may contain an additional
1132 <prgn>config</prgn> script and a <tt>templates</tt>
1133 file in their control archive. The <prgn>config</prgn>
1134 script might be run before the <prgn>preinst</prgn>
1135 script, and before the package is unpacked or any of its
1136 dependencies or pre-dependancies are satisfied.
1137 Therefore it must work using only the tools present in
1138 <em>essential</em> packages.<footnote>
1140 <package>Debconf</package> or another tool that
1141 implements the Debian Configuration management
1142 specification will also be installed, and any
1143 versioned dependencies on it will be satisfied
1144 before preconfiguration begins.
1150 Packages should try to minimize the amount of prompting
1151 they need to do, and they should ensure that the user
1152 will only ever be asked each question once. This means
1153 that packages should try to use appropriate shared
1154 configuration files (such as <file>/etc/papersize</file> and
1155 <file>/etc/news/server</file>), and shared
1156 <package>debconf</package> variables rather than each
1157 prompting for their own list of required pieces of
1162 It also means that an upgrade should not ask the same
1163 questions again, unless the user has used <tt>dpkg
1164 --purge</tt> to remove the package's configuration. The
1165 answers to configuration questions should be stored in an
1166 appropriate place in <file>/etc</file> so that the user can
1167 modify them, and how this has been done should be
1171 If a package has a vitally important piece of
1172 information to pass to the user (such as "don't run me
1173 as I am, you must edit the following configuration files
1174 first or you risk your system emitting badly-formatted
1175 messages"), it should display this in the
1176 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1177 prompt the user to hit return to acknowledge the
1178 message. Copyright messages do not count as vitally
1179 important (they belong in
1180 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1181 neither do instructions on how to use a program (these
1182 should be in on-line documentation, where all the users
1186 Any necessary prompting should almost always be confined
1187 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1188 script. If it is done in the <prgn>postinst</prgn>, it
1189 should be protected with a conditional so that
1190 unnecessary prompting doesn't happen if a package's
1191 installation fails and the <prgn>postinst</prgn> is
1192 called with <tt>abort-upgrade</tt>,
1193 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.</p>
1198 <heading>Source packages</heading>
1200 <sect1 id="standardsversion">
1201 <heading>Standards conformance</heading>
1204 In the source package's <tt>Standards-Version</tt> control
1205 field, you should specify the most recent version number
1206 of this policy document with which your package complied
1207 when it was last updated. The current version number is
1212 This information may be used to file bug reports
1213 automatically if your package becomes too much out of
1218 The version number has four components: major and minor
1219 version number and major and minor patch level. When the
1220 standards change in a way that requires every package to
1221 change the major number will be changed. Significant
1222 changes that will require work in many packages will be
1223 signaled by a change to the minor number. The major patch
1224 level will be changed for any change to the meaning of the
1225 standards, however small; the minor patch level will be
1226 changed when only cosmetic, typographical or other edits
1227 are made which neither change the meaning of the document
1228 nor affect the contents of packages.</p>
1231 Thus only the first three components of the policy version
1232 are significant in the <em>Standards-Version</em> control
1233 field, and so either these three components or the all
1234 four components may be specified.<footnote>
1236 In the past, people specified the full version number
1237 in the Standards-Version field, for example "2.3.0.0".
1238 Since minor patch-level changes don"t introduce new
1239 policy, it was thought it would be better to relax
1240 policy and only require the first 3 components to be
1241 specified, in this example "2.3.0". All four
1242 components may still be used if someone wishes to do
1249 You should regularly, and especially if your package has
1250 become out of date, check for the newest Policy Manual
1251 available and update your package, if necessary. When your
1252 package complies with the new standards you should update the
1253 <tt>Standards-Version</tt> source package field and
1254 release it.<footnote>
1256 See the file <file>upgrading-checklist</file> for
1257 information about policy which has changed between
1258 different versions of this document.
1266 <heading>Package relationships</heading>
1269 Source packages should specify which binary packages they
1270 require to be installed or not to be installed in order to
1271 build correctly. For example, if building a package
1272 requires a certain compiler, then the compiler should be
1273 specified as a build-time dependency.
1277 It is not necessary to explicitly specify build-time
1278 relationships on a minimal set of packages that are always
1279 needed to compile, link and put in a Debian package a
1280 standard "Hello World!" program written in C or C++. The
1281 required packages are called <em>build-essential</em>, and
1282 an informational list can be found in
1283 <file>/usr/share/doc/build-essential/list</file> (which is
1284 contained in the <tt>build-essential</tt>
1287 <list compact="compact">
1289 <p>This allows maintaining the list separately
1290 from the policy documents (the list does not
1291 need the kind of control that the policy
1297 Having a separate package allows one to install
1298 the build-essential packages on a machine, as
1299 well as allowing other packages such as tasks to
1300 require installation of the build-essential
1301 packages using the depends relation.
1306 The separate package allows bug reports against
1307 the list to be categorized separately from
1308 the policy management process in the BTS.
1318 When specifying the set of build-time dependencies, one
1319 should list only those packages explicitly required by the
1320 build. It is not necessary to list packages which are
1321 required merely because some other package in the list of
1322 build-time dependencies depends on them.<footnote>
1324 The reason for this is that dependencies change, and
1325 you should list all those packages, and <em>only</em>
1326 those packages that <em>you</em> need directly. What
1327 others need is their business. For example, if you
1328 only link against <file>libimlib</file>, you will need to
1329 build-depend on <package>libimlib2-dev</package> but
1330 not against any <tt>libjpeg*</tt> packages, even
1331 though <tt>libimlib2-dev</tt> currently depends on
1332 them: installation of <package>libimlib2-dev</package>
1333 will automatically ensure that all of its run-time
1334 dependencies are satisfied.
1340 If build-time dependencies are specified, it must be
1341 possible to build the package and produce working binaries
1342 on a system with only essential and build-essential
1343 packages installed and also those required to satisfy the
1344 build-time relationships (including any implied
1345 relationships). In particular, this means that version
1346 clauses should be used rigorously in build-time
1347 relationships so that one cannot produce bad or
1348 inconsistently configured packages when the relationships
1349 are properly satisfied.
1353 <heading>Changes to the upstream sources</heading>
1356 If changes to the source code are made that are not
1357 specific to the needs of the Debian system, they should be
1358 sent to the upstream authors in whatever form they prefer
1359 so as to be included in the upstream version of the
1363 If you need to configure the package differently for
1364 Debian or for Linux, and the upstream source doesn't
1365 provide a way to do so, you should add such configuration
1366 facilities (for example, a new <prgn>autoconf</prgn> test
1367 or <tt>#define</tt>) and send the patch to the upstream
1368 authors, with the default set to the way they originally
1369 had it. You can then easily override the default in your
1370 <file>debian/rules</file> or wherever is appropriate.</p>
1373 You should make sure that the <prgn>configure</prgn> utility
1374 detects the correct architecture specification string
1375 (refer to <ref id="arch-spec"> for details).</p>
1378 If you need to edit a <prgn>Makefile</prgn> where
1379 GNU-style <prgn>configure</prgn> scripts are used, you
1380 should edit the <file>.in</file> files rather than editing the
1381 <prgn>Makefile</prgn> directly. This allows the user to
1382 reconfigure the package if necessary. You should
1383 <em>not</em> configure the package and edit the generated
1384 <prgn>Makefile</prgn>! This makes it impossible for
1385 someone else to later reconfigure the package.</p>
1388 You should document your changes and updates to the source
1389 package properly in the <file>debian/changelog</file> file.
1390 For more information, please see <ref id="changelogs">.
1396 <heading>Error trapping in makefiles</heading>
1399 When <prgn>make</prgn> invokes a command in a makefile
1400 (including your package's upstream makefiles and
1401 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1402 means that <prgn>sh</prgn>'s usual bad error handling
1403 properties apply: if you include a miniature script as one
1404 of the commands in your makefile you'll find that if you
1405 don't do anything about it then errors are not detected
1406 and <prgn>make</prgn> will blithely continue after
1410 Every time you put more than one shell command (this
1411 includes using a loop) in a makefile command you
1412 must make sure that errors are trapped. For
1413 simple compound commands, such as changing directory and
1414 then running a program, using <tt>&&</tt> rather
1415 than semicolon as a command separator is sufficient. For
1416 more complex commands including most loops and
1417 conditionals you should include a separate <tt>set -e</tt>
1418 command at the start of every makefile command that's
1419 actually one of these miniature shell scripts.</p></sect1>
1423 <heading>Obsolete constructs and libraries</heading>
1426 The include file <tt><varargs.h></tt> is
1427 provided to support end-users compiling very old software;
1428 the library <tt>libtermcap</tt> is provided to support the
1429 execution of software which has been linked against it
1430 (either old programs or those such as Netscape which are
1431 only available in binary form).</p>
1434 Debian packages should be patched to use
1435 <tt><stdarg.h></tt> and <tt>ncurses</tt>
1442 <chapt id="controlfields"><heading>Control files and their fields</heading>
1445 Many of the tools in the package management suite manipulate
1446 data represented in a common format, known as <em>control
1447 data</em>. The data is often stored in <em>control
1448 files</em>. Binary and source packages have control files,
1449 and the <file>.changes</file> files which control the installation
1450 of uploaded files are also in control file format.
1451 <prgn>dpkg</prgn>'s internal databases are in a similar
1455 <sect id="controlsyntax"><heading>Syntax of control files</heading>
1458 A control file consists of one or more paragraphs of fields.
1459 The paragraphs are separated by blank lines. Some control
1460 files allow only one paragraph; others allow several, in
1461 which case each paragraph usually refers to a different
1462 package. (For example, in source packages, the first
1463 paragraph refers to the source package, and later paragraphs
1464 refer to binary packages generated from the source.)
1468 Each paragraph consists of a series of data fields; each
1469 field consists of the field name, followed by a colon and
1470 then the data/value associated with that field. It ends at
1471 the end of the line. Horizontal whitespace (spaces and
1472 tabs) may occur immediately before or after the value and is
1473 ignored there; it is conventional to put a single space
1474 after the colon. For example, a field might be:
1475 <example compact="compact">
1478 the field name is <tt>Package</tt> and the field value
1483 Some fields' values may span several lines; in this case
1484 each continuation line <em>must</em> start with a space or
1485 tab. Any trailing spaces or tabs at the end of individual
1486 lines of a field value are ignored.
1490 Except where otherwise stated only a single line of data is
1491 allowed and whitespace is not significant in a field body.
1492 Whitespace must not appear inside names (of packages,
1493 architectures, files or anything else) or version numbers,
1494 or between the characters of multi-character version
1499 Field names are not case-sensitive, but it is usual to
1500 capitalize the field names using mixed case as shown below.
1504 Blank lines, or lines consisting only of spaces and tabs,
1505 are not allowed within field values or between fields - that
1506 would mean a new paragraph.
1511 <sect><heading>List of fields</heading>
1513 This list here is not supposed to be exhaustive. Most fields
1514 are dealt with elsewhere in this document.
1516 <sect1 id="f-Package"><heading><tt>Package</tt>
1520 The name of the binary package. Package names consist of
1521 lower case letters (<tt>a-z</tt>), digits (<tt>0-9</tt>),
1522 plus (<tt>+</tt>) and minus (<tt>-</tt>) signs, and
1523 periods (<tt>.</tt>).
1527 They must be at least two characters long and must start
1528 with an alphanumeric character. The use of lowercase
1529 package names is required unless the package you're
1530 building (or referring to, in other fields) is already
1531 using uppercase characters.</p>
1534 <sect1 id="f-Version"><heading><tt>Version</tt>
1538 This lists the source or binary package's version number -
1539 see <ref id="versions">.
1545 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1549 The most recent version of the standards (the policy
1550 manual and associated texts) with which the package
1551 complies. This is updated manually when editing the
1552 source package to conform to newer standards; it can
1553 sometimes be used to tell when a package needs attention.
1554 Its format is described above; see
1555 <ref id="standardsversion">.
1560 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1564 In a <file>.changes</file> file or parsed changelog output
1565 this contains the (space-separated) name(s) of the
1566 distribution(s) where this version of the package should
1567 be installed. Valid distributions are determined by the
1568 archive maintainers.<footnote>
1569 Current distribution names are:
1570 <taglist compact="compact">
1571 <tag><em>stable</em></tag>
1574 This is the current "released" version of Debian
1575 GNU/Linux. Once the distribution is
1576 <em>stable</em> only security fixes and other
1577 major bug fixes are allowed. When changes are
1578 made to this distribution, the release number is
1579 increased (for example: 2.2r1 becomes 2.2r2 then
1584 <tag><em>unstable</em></tag>
1587 This distribution value refers to the
1588 <em>developmental</em> part of the Debian
1589 distribution tree. New packages, new upstream
1590 versions of packages and bug fixes go into the
1591 <em>unstable</em> directory tree. Download from
1592 this distribution at your own risk.
1596 <tag><em>testing</em></tag>
1599 This distribution value refers to the
1600 <em>testing</em> part of the Debian distribution
1601 tree. It receives its packages from the
1602 unstable distribution after a short time lag to
1603 ensure that there are no major issues with the
1604 unstable packages. It is less prone to breakage
1605 than unstable, but still risky. It is not
1606 possible to upload packages directly to
1611 <tag><em>frozen</em></tag>
1614 From time to time, the <em>testing</em>
1615 distribution enters a state of "code-freeze" in
1616 anticipation of release as a <em>stable</em>
1617 version. During this period of testing only
1618 fixes for existing or newly-discovered bugs will
1619 be allowed. The exact details of this stage are
1620 determined by the Release Manager.
1624 <tag><em>experimental</em></tag>
1627 The packages with this distribution value are
1628 deemed by their maintainers to be high
1629 risk. Oftentimes they represent early beta or
1630 developmental packages from various sources that
1631 the maintainers want people to try, but are not
1632 ready to be a part of the other parts of the
1633 Debian distribution tree. Download at your own
1639 You should list <em>all</em> distributions that the
1640 package should be installed into.
1649 <chapt id="versions"><heading>Version numbering</heading>
1652 Every package has a version number recorded in its
1653 <tt>Version</tt> control file field.
1657 The package management system imposes an ordering on version
1658 numbers, so that it can tell whether packages are being up- or
1659 downgraded and so that package system front end applications
1660 can tell whether a package it finds available is newer than
1661 the one installed on the system. The version number format
1662 has the most significant parts (as far as comparison is
1663 concerned) at the beginning.
1667 The version number format is:
1668 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
1672 The three components here are:
1674 <tag><var>epoch</var></tag>
1677 This is a single (generally small) unsigned integer. It
1678 may be omitted, in which case zero is assumed. If it is
1679 omitted then the <var>upstream_version</var> may not
1684 It is provided to allow mistakes in the version numbers
1685 of older versions of a package, and also a package's
1686 previous version numbering schemes, to be left behind.
1690 <tag><var>upstream_version</var></tag>
1693 This is the main part of the version number. It is
1694 usually the version number of the original ("upstream")
1695 package from which the <file>.deb</file> file has been made,
1696 if this is applicable. Usually this will be in the same
1697 format as that specified by the upstream author(s);
1698 however, it may need to be reformatted to fit into the
1699 package management system's format and comparison
1704 The comparison behavior of the package management system
1705 with respect to the <var>upstream_version</var> is
1706 described below. The <var>upstream_version</var>
1707 portion of the version number is mandatory.
1711 The <var>upstream_version</var> may contain only
1712 alphanumerics<footnote>
1713 <p>Alphanumerics are <tt>A-Za-z0-9</tt> only.</p>
1715 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
1716 <tt>:</tt> (full stop, plus, hyphen, colon) and should
1717 start with a digit. If there is no
1718 <var>debian_revision</var> then hyphens are not allowed;
1719 if there is no <var>epoch</var> then colons are not
1723 <tag><var>debian_revision</var></tag>
1726 This part of the version number specifies the version of
1727 the Debian package based on the upstream version. It
1728 may contain only alphanumerics and the characters
1729 <tt>+</tt> and <tt>.</tt> (plus and full stop) and is
1730 compared in the same way as the
1731 <var>upstream_version</var> is.
1735 It is optional; if it isn't present then the
1736 <var>upstream_version</var> may not contain a hyphen.
1737 This format represents the case where a piece of
1738 software was written specifically to be turned into a
1739 Debian package, and so there is only one "debianization"
1740 of it and therefore no revision indication is required.
1744 It is conventional to restart the
1745 <var>debian_revision</var> at <tt>1</tt> each time the
1746 <var>upstream_version</var> is increased.
1750 The package management system will break the version
1751 number apart at the last hyphen in the string (if there
1752 is one) to determine the <var>upstream_version</var> and
1753 <var>debian_revision</var>. The absence of a
1754 <var>debian_revision</var> compares earlier than the
1755 presence of one (but note that the
1756 <var>debian_revision</var> is the least significant part
1757 of the version number).
1764 The <var>upstream_version</var> and <var>debian_revision</var>
1765 parts are compared by the package management system using the
1770 The strings are compared from left to right.
1774 First the initial part of each string consisting entirely of
1775 non-digit characters is determined. These two parts (one of
1776 which may be empty) are compared lexically. If a difference
1777 is found it is returned. The lexical comparison is a
1778 comparison of ASCII values modified so that all the letters
1779 sort earlier than all the non-letters.
1783 Then the initial part of the remainder of each string which
1784 consists entirely of digit characters is determined. The
1785 numerical values of these two parts are compared, and any
1786 difference found is returned as the result of the comparison.
1787 For these purposes an empty string (which can only occur at
1788 the end of one or both version strings being compared) counts
1793 These two steps (comparing and removing initial non-digit
1794 strings and initial digit strings) are repeated until a
1795 difference is found or both strings are exhausted.
1799 Note that the purpose of epochs is to allow us to leave behind
1800 mistakes in version numbering, and to cope with situations
1801 where the version numbering scheme changes. It is
1802 <em>not</em> intended to cope with version numbers containing
1803 strings of letters which the package management system cannot
1804 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
1805 silly orderings (the author of this manual has heard of a
1806 package whose versions went <tt>1.1</tt>, <tt>1.2</tt>,
1807 <tt>1.3</tt>, <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>,
1808 <tt>2</tt> and so forth).
1812 If an upstream package has problematic version numbers they
1813 should be converted to a sane form for use in the
1814 <tt>Version</tt> field.
1818 <heading>Version numbers based on dates</heading>
1820 In general, Debian packages should use the same version
1821 numbers as the upstream sources.</p>
1824 However, in some cases where the upstream version number is
1825 based on a date (e.g., a development "snapshot" release) the
1826 package management system cannot handle these version
1827 numbers without epochs. For example, dpkg will consider
1828 "96May01" to be greater than "96Dec24".</p>
1831 To prevent having to use epochs for every new upstream
1832 version, the version number should be changed to the
1833 following format in such cases: "19960501", "19961224". It
1834 is up to the maintainer whether he/she wants to bother the
1835 upstream maintainer to change the version numbers upstream,
1839 Note that other version formats based on dates which are
1840 parsed correctly by the package management system should
1841 <em>not</em> be changed.</p>
1844 Native Debian packages (i.e., packages which have been
1845 written especially for Debian) whose version numbers include
1846 dates should always use the "YYYYMMDD" format.</p>
1850 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1852 <sect id="timestamps"><heading>Time Stamps</heading>
1854 Maintainers should preserve the modification times of the
1855 upstream source files in a package, as far as is reasonably
1858 The rationale is that there is some information conveyed
1859 by knowing the age of the file, for example, you could
1860 recognize that some documentation is very old by looking
1861 at the modification time, so it would be nice if the
1862 modification time of the upstream source would be
1869 <sect id="debianrules"><heading><file>debian/rules</file> - the
1870 main building script</heading>
1873 This file must be an executable makefile, and contains the
1874 package-specific recipes for compiling the package and
1875 building binary package(s) from the source.
1879 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1880 so that it can be invoked by saying its name rather than
1881 invoking <prgn>make</prgn> explicitly.
1885 Since an interactive <file>debian/rules</file> script makes it
1886 impossible to auto-compile that package and also makes it
1887 hard for other people to reproduce the same binary
1888 package, all <em>required targets</em> MUST be
1889 non-interactive. At a minimum, required targets are the
1890 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1891 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>,
1892 <em>binary-indep</em>, and <em>build</em>. It also follows
1893 that any target that these targets depend on must also be
1898 The required and optional targets are as follows:
1900 <tag><tt>build</tt>, <tt>build-arch</tt> (optional),
1901 <tt>build-indep</tt> (optional)</tag>
1904 The <tt>build</tt> target should perform all
1905 non-interactive configuration and compilation of the
1906 package. If a package has an interactive pre-build
1907 configuration routine, the Debianized source package
1908 must either be built after this has taken place (so
1909 that the binary package can be built without rerunning
1910 the configuration) or the configuration routine
1911 modified to become non-interactive. (The latter is
1912 preferable if there are architecture-specific features
1913 detected by the configuration routine.)
1917 For some packages, notably ones where the same
1918 source tree is compiled in different ways to produce
1919 two binary packages, the <tt>build</tt> target
1920 does not make much sense. For these packages it is
1921 good enough to provide two (or more) targets
1922 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1923 for each of the ways of building the package, and a
1924 <tt>build</tt> target that does nothing. The
1925 <tt>binary</tt> target will have to build the
1926 package in each of the possible ways and make the
1927 binary package out of each.
1931 The <tt>build</tt> target must not do anything
1932 that might require root privilege.
1936 The <tt>build</tt> target may need to run the
1937 <tt>clean</tt> target first - see below.
1941 When a package has a configuration and build routine
1942 which takes a long time, or when the makefiles are
1943 poorly designed, or when <tt>build</tt> needs to
1944 run <tt>clean</tt> first, it is a good idea to
1945 <tt>touch build</tt> when the build process is
1946 complete. This will ensure that if <tt>debian/rules
1947 build</tt> is run again it will not rebuild the whole
1950 Another common way to do this is for <tt>build</tt>
1951 to depend on <prgn>build-stamp</prgn> and to do
1952 nothing else, and for the <prgn>build-stamp</prgn>
1953 target to do the building and to <tt>touch
1954 build-stamp</tt> on completion. This is
1955 especially useful if the build routine creates a
1956 file or directory called <tt>build</tt>; in such a
1957 case, <tt>build</tt> will need to be listed as
1958 a phony target (i.e., as a dependency of the
1959 <tt>.PHONY</tt> target). See the documentation of
1960 <prgn>make</prgn> for more information on phony
1967 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1968 <tt>binary-indep</tt>
1972 The <tt>binary</tt> target must be all that is
1973 necessary for the user to build the binary package(s)
1974 produced from this source package. All of these
1975 targets are required to be non-interactive. It is
1976 split into two parts: <prgn>binary-arch</prgn> builds
1977 the binary packages which are specific to a particular
1978 architecture, and <tt>binary-indep</tt> builds
1979 those which are not.
1982 <tt>binary</tt> may be (and commonly is) a target with
1983 no commands which simply depends on
1984 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
1987 Both <tt>binary-*</tt> targets should depend on the
1988 <tt>build</tt> target, or on the appropriate
1989 <tt>build-arch</tt> or <tt>build-indep</tt> target, if
1990 provided, so that the package is built if it has not
1991 been already. It should then create the relevant
1992 binary package(s), using <prgn>dpkg-gencontrol</prgn> to
1993 make their control files and <prgn>dpkg-deb</prgn> to
1994 build them and place them in the parent of the top
1999 Both the <tt>binary-arch</tt> and
2000 <tt>binary-indep</tt> targets <em>must</em> exist.
2001 If one of them has nothing to do (which will always be
2002 the case if the source generates only a single binary
2003 package, whether architecture-dependent or not), it
2004 must still exist and must always succeed.
2008 The <tt>binary</tt> targets must be invoked as
2011 The <prgn>fakeroot</prgn> package often allows one
2012 to build a package correctly even without being
2019 <tag><tt>clean</tt></tag>
2022 This must undo any effects that the <tt>build</tt>
2023 and <tt>binary</tt> targets may have had, except
2024 that it should leave alone any output files created in
2025 the parent directory by a run of a <tt>binary</tt>
2026 target. This target must be non-interactive.
2030 If a <tt>build</tt> file is touched at the end of
2031 the <tt>build</tt> target, as suggested above, it
2032 should be removed as the first action that
2033 <tt>clean</tt> performs, so that running
2034 <tt>build</tt> again after an interrupted
2035 <tt>clean</tt> doesn't think that everything is
2040 The <tt>clean</tt> target may need to be
2041 invoked as root if <tt>binary</tt> has been
2042 invoked since the last <tt>clean</tt>, or if
2043 <tt>build</tt> has been invoked as root (since
2044 <tt>build</tt> may create directories, for
2049 <tag><tt>get-orig-source</tt> (optional)</tag>
2052 This target fetches the most recent version of the
2053 original source package from a canonical archive site
2054 (via FTP or WWW, for example), does any necessary
2055 rearrangement to turn it into the original source
2056 tar file format described below, and leaves it in the
2061 This target may be invoked in any directory, and
2062 should take care to clean up any temporary files it
2067 This target is optional, but providing it if
2068 possible is a good idea.
2074 The <tt>build</tt>, <tt>binary</tt> and
2075 <tt>clean</tt> targets must be invoked with the current
2076 directory being the package's top-level directory.
2081 Additional targets may exist in <file>debian/rules</file>,
2082 either as published or undocumented interfaces or for the
2083 package's internal use.
2087 The architectures we build on and build for are determined
2088 by <prgn>make</prgn> variables using the utility
2089 <prgn>dpkg-architecture</prgn>. You can determine the
2090 Debian architecture and the GNU style architecture
2091 specification string for the build machine (the machine type
2092 we are building on) as well as for the host machine (the
2093 machine type we are building for). Here is a list of
2094 supported <prgn>make</prgn> variables:
2095 <list compact="compact">
2097 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
2100 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2101 specification string)</p>
2104 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of
2105 <tt>DEB_*_GNU_TYPE</tt>)</p>
2108 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2109 <tt>DEB_*_GNU_TYPE</tt>)</p>
2111 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2112 the build machine or <tt>HOST</tt> for specification of the
2117 Backward compatibility can be provided in the rules file
2118 by setting the needed variables to suitable default
2119 values; please refer to the documentation of
2120 <prgn>dpkg-architecture</prgn> for details.
2124 It is important to understand that the <tt>DEB_*_ARCH</tt>
2125 string only determines which Debian architecture we are
2126 building on or for. It should not be used to get the CPU
2127 or system information; the GNU style variables should be
2132 <sect id="dpkgchangelog"><heading><file>debian/changelog</file>
2136 This file records the changes to the Debian-specific parts of the
2139 Though there is nothing stopping an author who is also
2140 the Debian maintainer from using it for all their
2141 changes, it will have to be renamed if the Debian and
2142 upstream maintainers become different people. In such a
2143 case, however, it might be better to maintain the
2144 package as a non-native package.
2150 It has a special format which allows the package building
2151 tools to discover which version of the package is being
2152 built and find out other release-specific information.
2156 That format is a series of entries like this:
2157 <example compact="compact">
2158 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
2160 <p>[optional blank line(s), stripped]</p>
2162 * <var>change details</var>
2163 <var>more change details</var>
2165 <p>[blank line(s), included in output of dpkg-parsechangelog]</p>
2167 * <var>even more change details</var>
2169 <p>[optional blank line(s), stripped]</p>
2171 -- <var>maintainer name</var> <<var>email
2172 address</var>><var>[two spaces]</var> <var>date</var>
2177 <var>package</var> and <var>version</var> are the source
2178 package name and version number.
2182 <var>distribution(s)</var> lists the distributions where
2183 this version should be installed when it is uploaded - it
2184 is copied to the <tt>Distribution</tt> field in the
2185 <file>.changes</file> file. See <ref id="f-Distribution">.
2189 <var>urgency</var> is the value for the <tt>Urgency</tt>
2190 field in the <file>.changes</file> file for the upload. It is
2191 not possible to specify an urgency containing commas; commas
2192 are used to separate
2193 <tt><var>keyword</var>=<var>value</var></tt> settings in the
2194 <prgn>dpkg</prgn> changelog format (though there is
2195 currently only one useful <var>keyword</var>,
2196 <tt>urgency</tt>).<footnote>
2198 Recognised urgency values are <tt>low</tt>,
2199 <tt>medium</tt>, <tt>high</tt> and <tt>emergency</tt>.
2200 They have an effect on how quickly a package will be
2201 considered for inclusion into the <tt>testing</tt>
2202 distribution, and give an indication of the importance
2203 of any fixes included in this upload.
2209 The change details may in fact be any series of lines
2210 starting with at least two spaces, but conventionally each
2211 change starts with an asterisk and a separating space and
2212 continuation lines are indented so as to bring them in
2213 line with the start of the text above. Blank lines may be
2214 used here to separate groups of changes, if desired.
2218 If this upload resolves bugs recorded in the Bug Tracking
2219 System (BTS), they may be automatically closed on the
2220 inclusion of this package into the Debian archive by
2221 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
2222 in the change details.<footnote>
2224 To be precise, the string should match the following
2225 Perl regular expression:
2227 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
2229 Then all of the bug numbers listed will be closed by the
2230 archive maintenance script (<prgn>katie</prgn>), or in
2231 the case of an NMU, marked as fixed.
2237 The maintainer name and email address used in the changelog
2238 should be the details of the person uploading <em>this</em>
2239 version. They are <em>not</em> necessarily those of the
2240 usual package maintainer. The information here will be
2241 copied to the <tt>Changed-By</tt> field in the
2242 <tt>.changes</tt> file, and then later used to send an
2243 acknowledgement when the upload has been installed.
2247 The <var>date</var> should be in RFC822 format<footnote>
2249 This is generated by the <prgn>822-date</prgn>
2252 </footnote>; it should include the time zone specified
2253 numerically, with the time zone name or abbreviation
2254 optionally present as a comment in parentheses.
2258 The first "title" line with the package name should start
2259 at the left hand margin; the "trailer" line with the
2260 maintainer and date details should be preceded by exactly
2261 one space. The maintainer details and the date must be
2262 separated by exactly two spaces.
2265 <sect1><heading>Defining alternative changelog formats</heading>
2268 It is possible to use a different format to the standard
2269 one, by providing a parser for the format you wish to
2273 A changelog parser must not interact with the user at
2279 <sect id="srcsubstvars"><heading><file>debian/substvars</file>
2280 and variable substitutions </heading>
2283 When <prgn>dpkg-gencontrol</prgn>,
2284 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2285 generate control files they perform variable substitutions
2286 on their output just before writing it. Variable
2287 substitutions have the form <tt>${<var>variable</var>}</tt>.
2288 The optional file <file>debian/substvars</file> contains
2289 variable substitutions to be used; variables can also be set
2290 directly from <file>debian/rules</file> using the <tt>-V</tt>
2291 option to the source packaging commands, and certain
2292 predefined variables are also available.
2296 The <file>debian/substvars</file> file is usually generated and
2297 modified dynamically by <file>debian/rules</file> targets; in
2298 this case it must be removed by the <tt>clean</tt>
2303 See <manref name="dpkg-source" section="1"> for full
2304 details about source variable substitutions, including the
2305 format of <file>debian/substvars</file>.</p>
2308 <sect id="debianfiles"><heading><file>debian/files</file>
2312 This file is not a permanent part of the source tree; it
2313 is used while building packages to record which files are
2314 being generated. <prgn>dpkg-genchanges</prgn> uses it
2315 when it generates a <file>.changes</file> file.
2319 It should not exist in a shipped source package, and so it
2320 (and any backup files or temporary files such as
2321 <file>files.new</file><footnote>
2323 <file>files.new</file> is used as a temporary file by
2324 <prgn>dpkg-gencontrol</prgn> and
2325 <prgn>dpkg-distaddfile</prgn> - they write a new
2326 version of <tt>files</tt> here before renaming it,
2327 to avoid leaving a corrupted copy if an error
2330 </footnote>) should be removed by the
2331 <tt>clean</tt> target. It may also be wise to
2332 ensure a fresh start by emptying or removing it at the
2333 start of the <tt>binary</tt> target.
2337 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2338 package, it adds an entry to <file>debian/files</file> for the
2339 <file>.deb</file> file that will be created when <tt>dpkg-deb
2340 --build</tt> is run for that binary package. So for most
2341 packages all that needs to be done with this file is to
2342 delete it in the <tt>clean</tt> target.
2346 If a package upload includes files besides the source
2347 package and any binary packages whose control files were
2348 made with <prgn>dpkg-gencontrol</prgn> then they should be
2349 placed in the parent of the package's top-level directory
2350 and <prgn>dpkg-distaddfile</prgn> should be called to add
2351 the file to the list in <file>debian/files</file>.</p>
2354 <sect id="restrictions"><heading>Restrictions on objects in source packages
2358 The source package may not contain any hard links<footnote>
2360 This is not currently detected when building source
2361 packages, but only when extracting
2365 Hard links may be permitted at some point in the
2366 future, but would require a fair amount of
2369 </footnote>, device special files, sockets or setuid or
2370 setgid files.<footnote>
2372 Setgid directories are allowed.
2378 <sect id="descriptions"><heading>Descriptions of packages - the
2379 <tt>Description</tt> field</heading>
2382 The "Description" control file field consists of two parts,
2383 the synopsis or the short description, and the long description.
2384 The field's format is as follows:
2388 Description: <single line synopsis>
2389 <extended description over several lines>
2393 The description is intended to describe the program to a user
2394 who has never met it before so that they know whether they
2395 want to install it. It should also give information about the
2396 significant dependencies and conflicts between this package
2397 and others, so that the user knows why these dependencies and
2398 conflicts have been declared.
2402 Put important information first, both in the synopsis and
2403 extended description. Sometimes only the first part of the
2404 synopsis or of the description will be displayed. You can
2405 assume that there will usually be a way to see the whole
2406 extended description.
2409 <sect1 id="synopsis"><heading>The single line synopsis</heading>
2412 The single line synopsis should be kept brief - certainly
2413 under 80 characters.
2417 Do not include the package name in the synopsis line. The
2418 display software knows how to display this already, and you
2419 do not need to state it. Remember that in many situations
2420 the user may only see the synopsis line - make it as
2421 informative as you can.
2426 <sect1 id="extendeddesc"><heading>The extended description</heading>
2429 Do not try to continue the single line synopsis into the
2430 extended description. This will not work correctly when
2431 the full description is displayed, and makes no sense
2432 where only the summary (the single line synopsis) is
2437 The extended description should describe what the package
2438 does and how it relates to the rest of the system (in terms
2439 of, for example, which subsystem it is which part of).
2443 The description field needs to make sense to anyone, even
2444 people who have no idea about any of the things the
2445 package deals with.<footnote>
2446 The blurb that comes with a program in its
2447 announcements and/or <prgn>README</prgn> files is
2448 rarely suitable for use in a description. It is
2449 usually aimed at people who are already in the
2450 community where the package is used.
2455 The lines in the extended description can have these formats:
2461 Those starting with a single space are part of a paragraph.
2462 Successive lines of this form will be word-wrapped when
2463 displayed. The leading space will usually be stripped off.
2467 Those starting with two or more spaces. These will be
2468 displayed verbatim. If the display cannot be panned
2469 horizontally, the displaying program will linewrap them "hard"
2470 (i.e., without taking account of word breaks). If it can they
2471 will be allowed to trail off to the right. None, one or two
2472 initial spaces may be deleted, but the number of spaces
2473 deleted from each line will be the same (so that you can have
2474 indenting work correctly, for example).
2478 Those containing a single space followed by a single full stop
2479 character. These are rendered as blank lines. This is the
2480 <em>only</em> way to get a blank line<footnote>
2481 Completely empty lines will not be rendered as blank lines.
2482 Instead, they will cause the parser to think you're starting
2483 a whole new record in the control file, and will therefore
2484 likely abort with an error.
2489 Those containing a space, a full stop and some more characters.
2490 These are for future expansion. Do not use them.
2496 Do not use tab characters. Their effect is not predictable.
2506 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2507 and installation procedure
2510 <sect><heading>Introduction to package maintainer scripts
2514 It is possible to supply scripts as part of a package which
2515 the package management system will run for you when your
2516 package is installed, upgraded or removed.
2520 These scripts are the files <prgn>preinst</prgn>,
2521 <prgn>postinst</prgn>, <prgn>prerm</prgn> and <prgn>postrm</prgn> in the
2522 control area of the package. They must be proper executable
2523 files; if they are scripts (which is recommended), they must
2524 start with the usual <tt>#!</tt> convention. They should be
2525 readable and executable by anyone, and not world-writable.
2529 The package management system looks at the exit status from
2530 these scripts. It is important that they exit with a
2531 non-zero status if there is an error, so that the package
2532 management system can stop its processing. For shell
2533 scripts this means that you <em>almost always</em> need to
2534 use <tt>set -e</tt> (this is usually true when writing shell
2535 scripts, in fact). It is also important, of course, that
2536 they don't exit with a non-zero status if everything went
2541 When a package is upgraded a combination of the scripts from
2542 the old and new packages is called during the upgrade
2543 procedure. If your scripts are going to be at all
2544 complicated you need to be aware of this, and may need to
2545 check the arguments to your scripts.
2549 Broadly speaking the <prgn>preinst</prgn> is called before
2550 (a particular version of) a package is installed, and the
2551 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2552 before (a version of) a package is removed and the
2553 <prgn>postrm</prgn> afterwards.
2557 Programs called from maintainer scripts should not normally
2558 have a path prepended to them. Before installation is
2559 started, the package management system checks to see if the
2560 programs <prgn>ldconfig</prgn>,
2561 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2562 and <prgn>update-rc.d</prgn> can be found via the
2563 <tt>PATH</tt> environment variable. Those programs, and any
2564 other program that one would expect to be on the
2565 <tt>PATH</tt>, should thus be invoked without an absolute
2566 pathname. Maintainer scripts should also not reset the
2567 <tt>PATH</tt>, though they might choose to modify it by
2568 prepending or appending package-specific directories. These
2569 considerations really apply to all shell scripts.</p>
2573 <heading>Maintainer scripts Idempotency</heading>
2576 It is necessary for the error recovery procedures that the
2577 scripts be idempotent. This means that if it is run
2578 successfully, and then it is called again, it doesn't bomb
2579 out or cause any harm, but just ensures that everything is
2580 the way it ought to be. If the first call failed, or
2581 aborted half way through for some reason, the second call
2582 should merely do the things that were left undone the first
2583 time, if any, and exit with a success status if everything
2586 This is so that if an error occurs, the user interrupts
2587 <prgn>dpkg</prgn> or some other unforeseen circumstance
2588 happens you don't leave the user with a badly-broken
2589 package when <prgn>dpkg</prgn> attempts to repeat the
2597 <heading>Controlling terminal for maintainer scripts</heading>
2600 The maintainer scripts are guaranteed to run with a
2601 controlling terminal and can interact with the user.
2602 If they need to prompt for passwords, do full-screen
2603 interaction or something similar you should do these
2604 things to and from <file>/dev/tty</file>, since
2605 <prgn>dpkg</prgn> will at some point redirect scripts'
2606 standard input and output so that it can log the
2607 installation process. Likewise, because these scripts
2608 may be executed with standard output redirected into a
2609 pipe for logging purposes, Perl scripts should set
2610 unbuffered output by setting <tt>$|=1</tt> so that the
2611 output is printed immediately rather than being
2616 Each script should return a zero exit status for
2617 success, or a nonzero one for failure.
2621 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2626 <list compact="compact">
2628 <p><var>new-preinst</var> <tt>install</tt></p>
2631 <p><var>new-preinst</var> <tt>install</tt>
2632 <var>old-version</var></p>
2635 <p><var>new-preinst</var> <tt>upgrade</tt>
2636 <var>old-version</var></p>
2639 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2640 <var>new-version</var>
2646 <list compact="compact">
2648 <p><var>postinst</var> <tt>configure</tt>
2649 <var>most-recently-configured-version</var></p>
2652 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2653 <var>new-version</var></p>
2656 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2657 <tt>in-favour</tt> <var>package</var>
2658 <var>new-version</var></p>
2662 <var>deconfigured's-postinst</var>
2663 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2664 <var>failed-install-package</var> <var>version</var>
2665 <tt>removing</tt> <var>conflicting-package</var>
2672 <list compact="compact">
2674 <p><var>prerm</var> <tt>remove</tt></p>
2677 <p><var>old-prerm</var> <tt>upgrade</tt>
2678 <var>new-version</var></p>
2681 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2682 <var>old-version</var></p>
2685 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2686 <tt>in-favour</tt> <var>package</var>
2687 <var>new-version</var></p>
2691 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2692 <tt>in-favour</tt> <var>package-being-installed</var>
2693 <var>version</var> <tt>removing</tt>
2694 <var>conflicting-package</var>
2701 <list compact="compact">
2703 <p><var>postrm</var> <tt>remove</tt></p>
2706 <p><var>postrm</var> <tt>purge</tt></p>
2710 <var>old-postrm</var> <tt>upgrade</tt>
2711 <var>new-version</var></p>
2714 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2715 <var>old-version</var></p>
2718 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2721 <p><var>new-postrm</var> <tt>abort-install</tt>
2722 <var>old-version</var></p>
2725 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2726 <var>old-version</var></p>
2730 <var>disappearer's-postrm</var> <tt>disappear</tt>
2731 <var>overwriter</var>
2732 <var>overwriter-version</var></p></item>
2737 <sect id="unpackphase"><heading>Details of unpack phase of
2738 installation or upgrade
2742 The procedure on installation/upgrade/overwrite/disappear
2743 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2744 stage of <tt>dpkg --install</tt>) is as follows. In each
2745 case, if a major error occurs (unless listed below) the
2746 actions are, in general, run backwards - this means that the
2747 maintainer scripts are run with different arguments in
2748 reverse order. These are the "error unwind" calls listed
2756 <p>If a version of the package is already
2758 <example compact="compact">
2759 <var>old-prerm</var> upgrade <var>new-version</var>
2764 If the script runs but exits with a non-zero
2765 exit status, <prgn>dpkg</prgn> will attempt:
2766 <example compact="compact">
2767 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2769 Error unwind, for both the above cases:
2770 <example compact="compact">
2771 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2779 <p>If a "conflicting" package is being removed at the same time:
2783 If any packages depended on that conflicting
2784 package and <tt>--auto-deconfigure</tt> is
2785 specified, call, for each such package:
2786 <example compact="compact">
2787 <var>deconfigured's-prerm</var> deconfigure \
2788 in-favour <var>package-being-installed</var> <var>version</var> \
2789 removing <var>conflicting-package</var> <var>version</var>
2792 <example compact="compact">
2793 <var>deconfigured's-postinst</var> abort-deconfigure \
2794 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2795 removing <var>conflicting-package</var> <var>version</var>
2797 The deconfigured packages are marked as
2798 requiring configuration, so that if
2799 <tt>--install</tt> is used they will be
2800 configured again if possible.</p>
2803 <p>To prepare for removal of the conflicting package, call:
2804 <example compact="compact">
2805 <var>conflictor's-prerm</var> remove \
2806 in-favour <var>package</var> <var>new-version</var>
2809 <example compact="compact">
2810 <var>conflictor's-postinst</var> abort-remove \
2811 in-favour <var>package</var> <var>new-version</var>
2822 <p>If the package is being upgraded, call:
2823 <example compact="compact">
2824 <var>new-preinst</var> upgrade <var>old-version</var>
2829 Otherwise, if the package had some configuration
2830 files from a previous version installed (i.e., it
2831 is in the "configuration files only" state):
2832 <example compact="compact">
2833 <var>new-preinst</var> install <var>old-version</var>
2837 <p>Otherwise (i.e., the package was completely purged):
2838 <example compact="compact">
2839 <var>new-preinst</var> install
2841 Error unwind actions, respectively:
2842 <example compact="compact">
2843 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2844 <var>new-postrm</var> abort-install <var>old-version</var>
2845 <var>new-postrm</var> abort-install
2854 The new package's files are unpacked, overwriting any
2855 that may be on the system already, for example any
2856 from the old version of the same package or from
2857 another package. Backups of the old files are kept
2858 temporarily, and if anything goes wrong the package
2859 management system will attempt to put them back as
2860 part of the error unwind.
2864 It is an error for a package to contains files which
2865 are on the system in another package, unless
2866 <tt>Replaces</tt> is used (see <ref id="replaces">).
2868 The following paragraph is not currently the case:
2869 Currently the <tt>- - force-overwrite</tt> flag is
2870 enabled, downgrading it to a warning, but this may not
2876 It is a more serious error for a package to contain a
2877 plain file or other kind of non-directory where another
2878 package has a directory (again, unless
2879 <tt>Replaces</tt> is used). This error can be
2880 overridden if desired using
2881 <tt>--force-overwrite-dir</tt>, but this is not
2886 Packages which overwrite each other's files produce
2887 behavior which, though deterministic, is hard for the
2888 system administrator to understand. It can easily
2889 lead to "missing" programs if, for example, a package
2890 is installed which overwrites a file from another
2891 package, and is then removed again.<footnote>
2893 Part of the problem is due to what is arguably a
2894 bug in <prgn>dpkg</prgn>.
2900 A directory will never be replaced by a symbolic link
2901 to a directory or vice versa; instead, the existing
2902 state (symlink or not) will be left alone and
2903 <prgn>dpkg</prgn> will follow the symlink if there is
2911 <p>If the package is being upgraded, call
2912 <example compact="compact">
2913 <var>old-postrm</var> upgrade <var>new-version</var>
2918 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2919 <example compact="compact">
2920 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2922 Error unwind, for both cases:
2923 <example compact="compact">
2924 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2931 This is the point of no return - if
2932 <prgn>dpkg</prgn> gets this far, it won't back off
2933 past this point if an error occurs. This will
2934 leave the package in a fairly bad state, which
2935 will require a successful re-installation to clear
2936 up, but it's when <prgn>dpkg</prgn> starts doing
2937 things that are irreversible.
2942 Any files which were in the old version of the package
2943 but not in the new are removed.</p>
2946 <p>The new file list replaces the old.</p>
2949 <p>The new maintainer scripts replace the old.</p>
2953 <p>Any packages all of whose files have been overwritten during the
2954 installation, and which aren't required for
2955 dependencies, are considered to have been removed.
2956 For each such package
2959 <p><prgn>dpkg</prgn> calls:
2960 <example compact="compact">
2961 <var>disappearer's-postrm</var> disappear \
2962 <var>overwriter</var> <var>overwriter-version</var>
2967 <p>The package's maintainer scripts are removed.
2972 It is noted in the status database as being in a
2973 sane state, namely not installed (any conffiles
2974 it may have are ignored, rather than being
2975 removed by <prgn>dpkg</prgn>). Note that
2976 disappearing packages do not have their prerm
2977 called, because <prgn>dpkg</prgn> doesn't know
2978 in advance that the package is going to
2987 Any files in the package we're unpacking that are also
2988 listed in the file lists of other packages are removed
2989 from those lists. (This will lobotomize the file list
2990 of the "conflicting" package if there is one.)
2995 The backup files made during installation, above, are
3002 The new package's status is now sane, and recorded as
3007 Here is another point of no return - if the
3008 conflicting package's removal fails we do not unwind
3009 the rest of the installation; the conflicting package
3010 is left in a half-removed limbo.
3016 If there was a conflicting package we go and do the
3017 removal actions (described below), starting with the
3018 removal of the conflicting package's files (any that
3019 are also in the package being installed have already
3020 been removed from the conflicting package's file list,
3021 and so do not get removed now).
3028 <sect id="configdetails"><heading>Details of configuration</heading>
3031 When we configure a package (this happens with <tt>dpkg
3032 --install</tt> and <tt>dpkg --configure</tt>), we first
3033 update any <tt>conffile</tt>s and then call:
3034 <example compact="compact">
3035 <var>postinst</var> configure <var>most-recently-configured-version</var>
3040 No attempt is made to unwind after errors during
3045 If there is no most recently configured version
3046 <prgn>dpkg</prgn> will pass a null argument; older versions
3047 of dpkg may pass <tt><unknown></tt> (including the
3048 angle brackets) in this case. Even older ones do not pass a
3049 second argument at all, under any circumstances.
3053 <sect id="removedetails"><heading>Details of removal and/or
3054 configuration purging</heading>
3060 <example compact="compact">
3061 <var>prerm</var> remove
3067 The package's files are removed (except <tt>conffile</tt>s).
3072 <example compact="compact">
3073 <var>postrm</var> remove
3079 All the maintainer scripts except the <prgn>postrm</prgn>
3084 If we aren't purging the package we stop here. Note
3085 that packages which have no <prgn>postrm</prgn> and no
3086 <tt>conffile</tt>s are automatically purged when
3087 removed, as there is no difference except for the
3088 <prgn>dpkg</prgn> status.</p>
3092 The <tt>conffile</tt>s and any backup files
3093 (<tt>~</tt>-files, <tt>#*#</tt> files,
3094 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
3099 <example compact="compact">
3100 <var>postrm</var> purge
3105 <p>The package's file list is removed.</p>
3108 No attempt is made to unwind after errors during
3115 <chapt id="relationships"><heading>Declaring relationships between
3119 Packages can declare in their control file that they have
3120 certain relationships to other packages - for example, that
3121 they may not be installed at the same time as certain other
3122 packages, and/or that they depend on the presence of others,
3123 or that they should overwrite files in certain other packages
3128 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3129 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3130 <tt>Conflicts</tt>, <tt>Provides</tt> and <tt>Replaces</tt>
3131 control file fields.
3135 Source packages may declare relationships to binary packages,
3136 saying that they require certain binary packages to be
3137 installed or absent at the time of building the package.
3141 This is done using the <tt>Build-Depends</tt>,
3142 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt> and
3143 <tt>Build-Conflicts-Indep</tt> control file fields.
3146 <sect id="depsyntax"><heading>Syntax of relationship fields
3150 These fields all have a uniform syntax. They are a list of
3151 package names separated by commas.
3155 In the <tt>Depends</tt>, <tt>Recommends</tt>,
3156 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
3157 <tt>Build-Depends</tt> and <tt>Build-Depends-Indep</tt>
3158 control file fields of the package, which declare
3159 dependencies on other packages, the package names listed may
3160 also include lists of alternative package names, separated
3161 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
3162 if any one of the alternative packages is installed, that
3163 part of the dependency is considered to be satisfied.
3167 All of the fields except for <tt>Provides</tt> may restrict
3168 their applicability to particular versions of each named
3169 package. This is done in parentheses after each individual
3170 package name; the parentheses should contain a relation from
3171 the list below followed by a version number, in the format
3172 described in <ref id="versions">.
3176 The relations allowed are <tt><<</tt>, <tt><=</tt>,
3177 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
3178 strictly earlier, earlier or equal, exactly equal, later or
3179 equal and strictly later, respectively. The deprecated
3180 forms <tt><</tt> and <tt>></tt> were used to mean
3181 earlier/later or equal, rather than strictly earlier/later,
3182 so they should not appear in new packages (though
3183 <prgn>dpkg</prgn> still supports them).
3187 Whitespace may appear at any point in the version
3188 specification subject to the rules in <ref
3189 id="controlsyntax">, and must appear where it's necessary to
3190 disambiguate; it is not otherwise significant. For
3191 consistency and in case of future changes to
3192 <prgn>dpkg</prgn> it is recommended that a single space be
3193 used after a version relationship and before a version
3194 number; it is also conventional to put a single space after
3195 each comma, on either side of each vertical bar, and before
3196 each open parenthesis.
3200 For example, a list of dependencies might appear as:
3201 <example compact="compact">
3204 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
3209 All fields that specify build-time relationships
3210 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3211 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
3212 may be restricted to a certain set of architectures. This
3213 is indicated in brackets after each individual package name and
3214 the optional version specification. The brackets enclose a
3215 list of Debian architecture names separated by whitespace.
3216 Exclamation marks may be prepended to each of the names.
3217 (It is not permitted for some names to be prepended with
3218 exclamation marks and others not.) If the current Debian
3219 host architecture is not in this list and there are no
3220 exclamation marks in the list, or it is in the list with a
3221 prepended exclamation mark, the package name and the
3222 associated version specification are ignored completely for
3223 the purposes of defining the relationships.
3228 <example compact="compact">
3230 Build-Depends-Indep: texinfo
3231 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
3232 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
3237 Note that the binary package relationship fields such as
3238 <tt>Depends</tt> appear in one of the binary package
3239 sections of the control file, whereas the build-time
3240 relationships such as <tt>Build-Depends</tt> appear in the
3241 source package section of the control file (which is the
3247 <heading>Binary Dependencies - <tt>Depends</tt>,
3248 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3249 <tt>Pre-Depends</tt>
3253 These five fields are used to declare a dependency
3254 relationship by one package on another. Except for
3255 <tt>Enhances</tt>, they appear in the depending (binary)
3256 package's control file. (<tt>Enhances</tt> appears in the
3257 recommending package's control file.)
3261 A <tt>Depends</tt> field takes effect <em>only</em> when a
3262 package is to be configured. It does not prevent a package
3263 being on the system in an unconfigured state while its
3264 dependencies are unsatisfied, and it is possible to replace
3265 a package whose dependencies are satisfied and which is
3266 properly installed with a different version whose
3267 dependencies are not and cannot be satisfied; when this is
3268 done the depending package will be left unconfigured (since
3269 attempts to configure it will give errors) and will not
3270 function properly. If it is necessary, a
3271 <tt>Pre-Depends</tt> field can be used, which has a partial
3272 effect even when a package is being unpacked, as explained
3273 in detail below. (The other three dependency fields,
3274 <tt>Recommends</tt>, <tt>Suggests</tt> and
3275 <tt>Enhances</tt>, are only used by the various front-ends
3276 to <prgn>dpkg</prgn> such as <prgn>dselect</prgn>.)
3280 For this reason packages in an installation run are usually
3281 all unpacked first and all configured later; this gives
3282 later versions of packages with dependencies on later
3283 versions of other packages the opportunity to have their
3284 dependencies satisfied.
3288 The <tt>Depends</tt> field thus allows package maintainers
3289 to impose an order in which packages should be configured.
3293 The meaning of the five dependency fields is as follows:
3295 <tag><tt>Depends</tt></tag>
3298 This declares an absolute dependency. A package will
3299 not be configured unless all of the packages listed in
3300 its <tt>Depends</tt> field have been correctly
3305 The <tt>Depends</tt> field should be used if the
3306 depended-on package is required for the depending
3307 package to provide a significant amount of
3311 The <tt>Depends</tt> field should also be used if the
3312 <prgn>postinst</prgn>, <prgn>prerm</prgn> or
3313 <prgn>postrm</prgn> scripts require the package to be
3314 present in order to run. Note, however, that the
3315 <prgn>postrm</prgn> cannot rely on any non-essential
3316 packages to be present during the <tt>purge</tt>
3320 <tag><tt>Recommends</tt></tag>
3322 <p>This declares a strong, but not absolute, dependency.
3326 The <tt>Recommends</tt> field should list packages
3327 that would be found together with this one in all but
3328 unusual installations.</p>
3331 <tag><tt>Suggests</tt></tag>
3334 This is used to declare that one package may be more
3335 useful with one or more others. Using this field
3336 tells the packaging system and the user that the
3337 listed packages are related to this one and can
3338 perhaps enhance its usefulness, but that installing
3339 this one without them is perfectly reasonable.
3343 <tag><tt>Enhances</tt></tag>
3346 This field is similar to Suggests but works in the
3347 opposite direction. It is used to declare that a
3348 package can enhance the functionality of another
3353 <tag><tt>Pre-Depends</tt></tag>
3356 This field is like <tt>Depends</tt>, except that it
3357 also forces <prgn>dpkg</prgn> to complete installation
3358 of the packages named before even starting the
3359 installation of the package which declares the
3360 pre-dependency, as follows:
3364 When a package declaring a pre-dependency is about to
3365 be <em>unpacked</em> the pre-dependency can be
3366 satisfied if the depended-on package is either fully
3367 configured, <em>or even if</em> the depended-on
3368 package(s) are only unpacked or half-configured,
3369 provided that they have been configured correctly at
3370 some point in the past (and not removed or partially
3371 removed since). In this case, both the
3372 previously-configured and currently unpacked or
3373 half-configured versions must satisfy any version
3374 clause in the <tt>Pre-Depends</tt> field.
3378 When the package declaring a pre-dependency is about
3379 to be <em>configured</em>, the pre-dependency will be
3380 treated as a normal <tt>Depends</tt>, that is, it will
3381 be considered satisfied only if the depended-on
3382 package has been correctly configured.
3386 <tt>Pre-Depends</tt> should be used sparingly,
3387 preferably only by packages whose premature upgrade or
3388 installation would hamper the ability of the system to
3389 continue with any upgrade that might be in progress.
3393 <tt>Pre-Depends</tt> are also required if the
3394 <prgn>preinst</prgn> script depends on the named
3395 package. It is best to avoid this situation if
3401 When selecting which level of dependency to use you should
3402 consider how important the depended-on package is to the
3403 functionality of the one declaring the dependency. Some
3404 packages are composed of components of varying degrees of
3405 importance. Such a package should list using
3406 <tt>Depends</tt> the package(s) which are required by the
3407 more important components. The other components'
3408 requirements may be mentioned as Suggestions or
3409 Recommendations, as appropriate to the components' relative
3414 <sect id="conflicts"><heading>Conflicting binary packages -
3415 <tt>Conflicts</tt></heading>
3418 When one binary package declares a conflict with another
3419 using a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will
3420 refuse to allow them to be installed on the system at the
3425 If one package is to be installed, the other must be removed
3426 first - if the package being installed is marked as
3427 replacing (see <ref id="replaces">) the one on the system,
3428 or the one on the system is marked as deselected, or both
3429 packages are marked <tt>Essential</tt>, then
3430 <prgn>dpkg</prgn> will automatically remove the package
3431 which is causing the conflict, otherwise it will halt the
3432 installation of the new package with an error. This
3433 mechanism is specifically designed to produce an error when
3434 the installed package is <tt>Essential</tt>, but the new
3439 A package will not cause a conflict merely because its
3440 configuration files are still installed; it must be at least
3445 A special exception is made for packages which declare a
3446 conflict with their own package name, or with a virtual
3447 package which they provide (see below): this does not
3448 prevent their installation, and allows a package to conflict
3449 with others providing a replacement for it. You use this
3450 feature when you want the package in question to be the only
3451 package providing some feature.
3455 A <tt>Conflicts</tt> entry should almost never have an
3456 "earlier than" version clause. This would prevent
3457 <prgn>dpkg</prgn> from upgrading or installing the package
3458 which declared such a conflict until the upgrade or removal
3459 of the conflicted-with package had been completed.
3463 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3467 As well as the names of actual ("concrete") packages, the
3468 package relationship fields <tt>Depends</tt>,
3469 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
3470 <tt>Pre-Depends</tt>, <tt>Conflicts</tt>,
3471 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3472 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>
3473 may mention "virtual packages".
3477 A <em>virtual package</em> is one which appears in the
3478 <tt>Provides</tt> control file field of another package.
3479 The effect is as if the package(s) which provide a
3480 particular virtual package name had been listed by name
3481 everywhere the virtual package name appears. (See also <ref
3482 id="virtual_pkg_sect">)
3486 If there are both concrete and virtual packages of the same
3487 name, then the dependency may be satisfied (or the conflict
3488 caused) by either the concrete package with the name in
3489 question or any other concrete package which provides the
3490 virtual package with the name in question. This is so that,
3491 for example, supposing we have
3492 <example compact="compact">
3496 and someone else releases an enhanced version of the
3497 <tt>bar</tt> package (for example, a non-US variant), they
3499 <example compact="compact">
3503 and the <tt>bar-plus</tt> package will now also satisfy the
3504 dependency for the <tt>foo</tt> package.
3508 If a dependency or a conflict has a version number attached
3509 then only real packages will be considered to see whether
3510 the relationship is satisfied (or the prohibition violated,
3511 for a conflict) - it is assumed that a real package which
3512 provides the virtual package is not of the "right" version.
3513 So, a <tt>Provides</tt> field may not contain version
3514 numbers, and the version number of the concrete package
3515 which provides a particular virtual package will not be
3516 looked at when considering a dependency on or conflict with
3517 the virtual package name.
3521 It is likely that the ability will be added in a future
3522 release of <prgn>dpkg</prgn> to specify a version number for
3523 each virtual package it provides. This feature is not yet
3524 present, however, and is expected to be used only
3529 If you want to specify which of a set of real packages
3530 should be the default to satisfy a particular dependency on
3531 a virtual package, you should list the real package as an
3532 alternative before the virtual one.
3537 <sect id="replaces"><heading>Overwriting files and replacing
3538 packages - <tt>Replaces</tt></heading>
3541 The <tt>Replaces</tt> control file field has two distinct
3542 purposes, which come into play in different situations.
3545 <sect1><heading>Overwriting files in other packages</heading>
3548 Firstly, as mentioned before, it is usually an error for a
3549 package to contain files which are on the system in
3554 However, if the overwriting package declares that it
3555 <tt>Replaces</tt> the one containing the file being
3556 overwritten, then <prgn>dpkg</prgn> will replace the file
3557 from the old package with that from the new. The file
3558 will no longer be listed as "owned" by the old package.
3562 If a package is completely replaced in this way, so that
3563 <prgn>dpkg</prgn> does not know of any files it still
3564 contains, it is considered to have "disappeared". It will
3565 be marked as not wanted on the system (selected for
3566 removal) and not installed. Any <tt>conffile</tt>s
3567 details noted for the package will be ignored, as they
3568 will have been taken over by the overwriting package. The
3569 package's <prgn>postrm</prgn> script will be run with a
3570 special argument to allow the package to do any final
3571 cleanup required. See <ref id="mscriptsinstact">.
3575 If an installed package, <tt>foo</tt> say, declares that
3576 it replaces another, <tt>bar</tt>, and an attempt is made
3577 to install <tt>bar</tt>, <prgn>dpkg</prgn> will discard
3578 files in the <tt>bar</tt> package which would overwrite
3579 those already present in <tt>foo</tt>. This is so that
3580 you can install an older version of a package without
3585 For this usage of <tt>Replaces</tt>, virtual packages (see
3586 <ref id="virtual">) are not considered when looking at a
3587 <tt>Replaces</tt> field - the packages declared as being
3588 replaced must be mentioned by their real names.
3592 Furthermore, this usage of <tt>Replaces</tt> only takes
3593 effect when both packages are at least partially on the
3594 system at once, so that it can only happen if they do not
3595 conflict or if the conflict has been overridden.
3600 <sect1><heading>Replacing whole packages, forcing their
3604 Secondly, <tt>Replaces</tt> allows the packaging system to
3605 resolve which package should be removed when there is a
3606 conflict - see <ref id="conflicts">. This usage only
3607 takes effect when the two packages <em>do</em> conflict,
3608 so that the two usages of this field do not interfere with
3613 In this situation, the package declared as being replaced
3614 can be a virtual package, so for example, all mail
3615 transport agents (MTAs) would have the following fields in
3616 their control files:
3617 <example compact="compact">
3618 Provides: mail-transport-agent
3619 Conflicts: mail-transport-agent
3620 Replaces: mail-transport-agent
3622 ensuring that only one MTA can be installed at any one
3627 <sect><heading>Relationships between source and binary packages -
3628 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3629 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3633 A source package may declare a dependency or a conflict on a
3634 binary package, indicating which packages are required to be
3635 present on the system in order to build the binary packages
3636 from the source package. This is done with the control file
3637 fields <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3638 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>.
3639 The dependencies and conflicts they define must be satisfied
3640 (as defined earlier for binary packages) in order to invoke
3641 the targets in <tt>debian/rules</tt>, as follows:<footnote>
3643 If you make "build-arch" or "binary-arch", you need
3644 Build-Depends. If you make "build-indep" or
3645 "binary-indep", you need Build-Depends and
3646 Build-Depends-Indep. If you make "build" or "binary",
3650 There is no Build-Depends-Arch; the autobuilders will
3651 only need the Build-Depends if they know how to build
3652 only build-arch and binary-arch. Anyone building the
3653 build-indep/binary-indep targets is basically assumed to
3654 be building the whole package and so installs all build
3658 The purpose of the original split, I recall, was so that
3659 the autobuilders wouldn't need to install extra packages
3660 needed only for the binary-indep targets. But without a
3661 build-arch/build-indep split, this didn't work, since
3662 most of the work is done in the build target, not in the
3668 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3671 The <tt>Build-Depends</tt> and
3672 <tt>Build-Conflicts</tt> fields must be satisfied when
3673 any of the following targets is invoked:
3674 <tt>build</tt>, <tt>clean</tt>, <tt>binary</tt>,
3675 <tt>binary-arch</tt>, <tt>build-arch</tt>,
3676 <tt>build-indep</tt> and <tt>binary-indep</tt>.
3679 <tag><tt>Build-Depends-Indep</tt>,
3680 <tt>Build-Conflicts-Indep</tt></tag>
3683 The <tt>Build-Depends-Indep</tt> and
3684 <tt>Build-Conflicts-Indep</tt> fields must be
3685 satisfied when any of the following targets is
3686 invoked: <tt>build</tt>, <tt>clean</tt>,
3687 <tt>build-indep</tt>, <tt>binary</tt> and
3688 <tt>binary-indep</tt>.
3699 <chapt id="conffiles"><heading>Configuration file handling
3703 This chapter has been superseded by <ref id="config-files">.
3707 <chapt id="sharedlibs"><heading>Shared libraries</heading>
3710 Packages containing shared libraries must be constructed with
3711 a little care to make sure that the shared library is always
3712 available. This is especially important for packages whose
3713 shared libraries are vitally important, such as the C library
3714 (currently <tt>libc6</tt>).
3718 Firstly, the package should install the shared libraries under
3719 their normal names. For example, the <tt>libgdbmg1</tt>
3720 package should install <tt>libgdbm.so.1.7.3</tt> as
3721 <file>/usr/lib/libgdbm.so.1.7.3</file>. The files should not be
3722 renamed or re-linked by any <prgn>prerm</prgn> or
3723 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
3724 of renaming things safely without affecting running programs,
3725 and attempts to interfere with this are likely to lead to
3730 Secondly, the package should include the symbolic link that
3731 <prgn>ldconfig</prgn> would create for the shared libraries.
3732 For example, the <prgn>libgdbmg1</prgn> package should include
3733 a symbolic link from <file>/usr/lib/libgdbm.so.1</file> to
3734 <file>libgdbm.so.1.7.3</file>. This is needed so that the dynamic
3735 linker (for example <prgn>ld.so</prgn> or
3736 <prgn>ld-linux.so.*</prgn>) can find the library between the
3737 time that <prgn>dpkg</prgn> installs it and the time that
3738 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
3741 The package management system requires the library to be
3742 placed before the symbolic link pointing to it in the
3743 <file>.deb</file> file. This is so that when
3744 <prgn>dpkg</prgn> comes to install the symlink
3745 (overwriting the previous symlink pointing at an older
3746 version of the library), the new shared library is already
3747 in place. In the past, this was achieved by creating the
3748 library in the temporary packaging directory before
3749 creating the symlink. Unfortunately, this was not always
3750 effective, since the building of the tar file in the
3751 <file>.deb</file> depended on the behavior of the underlying
3752 file system. Some file systems (such as reiserfs) reorder
3753 the files so that the order of creation is forgotten.
3754 Starting with release <tt>1.7.0</tt>, <prgn>dpkg</prgn>
3755 will reorder the files itself as necessary when building a
3756 package. Thus it is no longer important to concern
3757 oneself with the order of file creation.
3763 Thirdly, the associated development package should contain a
3764 symlink for the shared library without a version number. For
3765 example, the <tt>libgdbmg1-dev</tt> package should include a
3766 symlink from <tt>/usr/lib/libgdbm.so</tt> to
3767 <file>libgdbm.so.1.7.3</file>. This symlink is needed by the
3768 linker (<prgn>ld</prgn>) when compiling packages, as it will
3769 only look for <file>libgdbm.so</file> when compiling dynamically.
3773 Any package installing shared libraries in one of the default
3774 library directories of the dynamic linker (which are currently
3775 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
3776 listed in <file>/etc/ld.so.conf</file><footnote>
3779 <list compact="compact">
3780 <item><p>/usr/X11R6/lib/Xaw3d</p></item>
3781 <item><p>/usr/local/lib</p></item>
3782 <item><p>/usr/lib/libc5-compat</p></item>
3783 <item><p>/lib/libc5-compat</p></item>
3784 <item><p>/usr/X11R6/lib</p></item>
3788 must use <prgn>ldconfig</prgn> to update the shared library
3789 system. The package must call <prgn>ldconfig</prgn> in the
3790 <prgn>postinst</prgn> script if the first argument is
3791 <tt>configure</tt>; the <prgn>postinst</prgn> script may
3792 optionally invoke <prgn>ldconfig</prgn> at other times. The
3793 package should call <prgn>ldconfig</prgn> in the
3794 <prgn>postrm</prgn> script if the first argument is
3795 <tt>remove</tt>. The maintainer scripts must not invoke
3796 <prgn>ldconfig</prgn> under any circumstances other than those
3797 described in this paragraph.<footnote>
3798 <p>During install or upgrade, the preinst is called before
3799 the new files are installed, so calling "ldconfig" is
3800 pointless. The preinst of an existing package can also be
3801 called if an upgrade fails. However, this happens during
3802 the critical time when a shared libs may exist on-disk
3803 under a temporary name. Thus, it is dangerous and
3804 forbidden by current policy to call "ldconfig" at this
3807 <p>When a package is installed or upgraded, "postinst
3808 configure" runs after the new files are safely on-disk.
3809 Since it is perfectly safe to invoke ldconfig
3810 unconditionally in a postinst, it is OK for a package to
3811 simply put ldconfig in its postinst without checking the
3812 argument. The postinst can also be called to recover from
3813 a failed upgrade. This happens before any new files are
3814 unpacked, so there is no reason to call "ldconfig" at this
3817 <p>For a package that is being removed, prerm is
3818 called with all the files intact, so calling ldconfig is
3819 useless. The other calls to "prerm" happen in the case of
3820 upgrade at a time when all the files of the old package
3821 are on-disk, so again calling "ldconfig" is pointless.
3823 <p>postrm, on the other hand, is called with the "remove"
3824 argument just after the files are removed, so this is the
3825 proper time to call "ldconfig" to notify the system of the
3826 fact shared libraries from the package are removed.
3827 The postrm can be called at several other times. At the
3828 time of "postrm purge", "postrm abort-install", or "postrm
3829 abort-upgrade", calling "ldconfig" is useless because the
3830 shared lib files are not on-disk. However, when "postrm"
3831 is invoked with arguments "upgrade", "failed-upgrade", or
3832 "disappear", a shared lib may exist on-disk under a
3839 <heading>Handling shared library dependencies - the
3840 <tt>shlibs</tt> system</heading>
3843 If a package contains a binary or library which links to a
3844 shared library, we must ensure that when the package is
3845 installed on the system, all of the libraries needed are
3846 also installed. This requirement led to the creation of the
3847 <tt>shlibs</tt> system, which is very simple in its design:
3848 any package which <em>provides</em> a shared library also
3849 provides information on the package dependencies required to
3850 ensure the presence of this library, and any package which
3851 <em>uses</em> a shared library uses this information to
3852 determine the dependencies it requires. The files which
3853 contain the mapping from shared libraries to the necessary
3854 dependency information are called <file>shlibs</file> files.
3858 Thus, when a package is built which contains any shared
3859 libraries, it must provide a <file>shlibs</file> file for other
3860 packages to use, and when a package is built which contains
3861 any shared libraries or compiled binaries, it must run
3862 <prgn>dpkg-shlibdeps</prgn> on these to determine the
3863 libraries used and hence the dependencies needed by this
3866 In the past, the shared libraries linked to were
3867 determined by calling <prgn>ldd</prgn>, but now
3868 <prgn>objdump</prgn> is used to do this. The only
3869 change this makes to package building is that
3870 <prgn>dpkg-shlibdeps</prgn> must also be run on shared
3871 libraries, whereas in the past this was unnecessary.
3872 The rest of this footnote explains the advantage that
3877 We say that a binary <tt>foo</tt> <em>directly</em> uses
3878 a library <tt>libbar</tt> if it is explicitly linked
3879 with that library (that is, it uses the flag
3880 <tt>-lbar</tt> during the linking stage). Other
3881 libraries that are needed by <tt>libbar</tt> are linked
3882 <em>indirectly</em> to <tt>foo</tt>, and the dynamic
3883 linker will load them automatically when it loads
3884 <tt>libbar</tt>. A package should depend on
3885 the libraries it directly uses, and the dependencies for
3886 those libraries should automatically pull in the other
3891 Unfortunately, the <prgn>ldd</prgn> program shows both
3892 the directly and indirectly used libraries, meaning that
3893 the dependencies determined included both direct and
3894 indirect dependencies. The use of <prgn>objdump</prgn>
3895 avoids this problem by determining only the directly
3900 A good example of where this helps is the following. We
3901 could update <tt>libimlib</tt> with a new version that
3902 supports a new graphics format called dgf (but retaining
3903 the same major version number). If we used the old
3904 <prgn>ldd</prgn> method, every package that uses
3905 <tt>libimlib</tt> would need to be recompiled so it
3906 would also depend on <tt>libdgf</tt> or it wouldn't run
3907 due to missing symbols. However with the new system,
3908 packages using <tt>libimlib</tt> can rely on
3909 <tt>libimlib</tt> itself having the dependency on
3910 <tt>libdgf</tt> and so they would not need rebuilding.
3916 In the following sections, we will first describe where the
3917 various <tt>shlibs</tt> files are to be found, then how to
3918 use <prgn>dpkg-shlibdeps</prgn>, and finally the
3919 <tt>shlibs</tt> file format and how to create them if your
3920 package contains a shared library.
3924 <sect><heading>The <tt>shlibs</tt> files present on the system
3928 There are several places where <tt>shlibs</tt> files are
3929 found. The following list gives them in the order in which
3930 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
3931 one which gives the required information is used.)
3937 <p><file>debian/shlibs.local</file></p>
3939 This lists overrides for this package. Its use is
3940 described below (see <ref id="shlibslocal">).
3945 <p><file>/etc/dpkg/shlibs.override</file></p>
3947 This lists global overrides. This list is normally
3948 empty. It is maintained by the local system
3954 <p><file>DEBIAN/shlibs</file> files in the "build directory"</p>
3956 When packages are being built, any
3957 <file>debian/shlibs</file> files are copied into the
3958 control file area of the temporary build directory and
3959 given the name <file>shlibs</file>. These files give
3960 details of any shared libraries included in the
3963 An example may help here. Let us say that the
3964 source package <tt>foo</tt> generates two binary
3965 packages, <tt>libfoo2</tt> and
3966 <tt>foo-runtime</tt>. When building the binary
3967 packages, the two packages are created in the
3968 directories <file>debian/libfoo2</file> and
3969 <file>debian/foo-runtime</file> respectively.
3970 (<file>debian/tmp</file> could be used instead of one
3971 of these.) Since <tt>libfoo2</tt> provides the
3972 <tt>libfoo</tt> shared library, it will require a
3973 <tt>shlibs</tt> file, which will be installed in
3974 <file>debian/libfoo2/DEBIAN/shlibs</file>, eventually
3976 <file>/var/lib/dpkg/info/libfoo2.shlibs</file>. Then
3977 when <prgn>dpkg-shlibdeps</prgn> is run on the
3979 <file>debian/foo-runtime/usr/bin/foo-prog</file>, it
3981 <file>debian/libfoo2/DEBIAN/shlibs</file> file to
3982 determine whether <tt>foo-prog</tt>'s library
3983 dependencies are satisfied by any of the libraries
3984 provided by <tt>libfoo2</tt>. For this reason,
3985 <prgn>dpkg-shlibdeps</prgn> must only be run once
3986 all of the individual binary packages'
3987 <tt>shlibs</tt> files have been installed into the
3995 <p><file>/var/lib/dpkg/info/*.shlibs</file></p>
3997 These are the <file>shlibs</file> files corresponding to
3998 all of the packages installed on the system, and are
3999 maintained by the relevant package maintainers.
4004 <p><file>/etc/dpkg/shlibs.default</file></p>
4006 This file lists any shared libraries whose packages
4007 have failed to provide correct <file>shlibs</file> files.
4008 It was used when the <file>shlibs</file> setup was first
4009 introduced, but it is now normally empty. It is
4010 maintained by the <tt>dpkg</tt> maintainer.
4018 <heading>How to use <prgn>dpkg-shlibdeps</prgn> and the
4019 <file>shlibs</file> files</heading>
4022 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
4023 <file>debian/rules</file> file. If your package contains only
4024 compiled binaries and libraries (but no scripts), you can
4025 use a command such as:
4026 <example compact="compact">
4027 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/* \
4028 debian/tmp/usr/lib/*
4030 Otherwise, you will need to explicitly list the compiled
4031 binaries and libraries.<footnote>
4033 If you are using <tt>debhelper</tt>, the
4034 <prgn>dh_shlibdeps</prgn> program will do this work for
4035 you. It will also correctly handle multi-binary
4042 This command puts the dependency information into the
4043 <file>debian/substvars</file> file, which is then used by
4044 <prgn>dpkg-gencontrol</prgn>. You will need to place a
4045 <tt>${shlib:Depends}</tt> variable in the <tt>Depends</tt>
4046 field in the control file for this to work.
4050 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
4051 done. If it does complain you might need to create your own
4052 <file>debian/shlibs.local</file> file, as explained below (see
4053 <ref id="shlibslocal">).
4057 If you have multiple binary packages, you will need to call
4058 <prgn>dpkg-shlibdeps</prgn> on each one which contains
4059 compiled libraries or binaries. In such a case, you will
4060 need to use the <tt>-T</tt> option to the <tt>dpkg</tt>
4061 utilities to specify a different <file>substvars</file> file.
4062 For more details on this and other options, see <manref
4063 name="dpkg-shlibdeps" section="1">.
4067 <sect id="shlibs"><heading>The <file>shlibs</file> File Format
4071 Each <file>shlibs</file> file has the same format. Lines
4072 beginning with <tt>#</tt> are considered to be comments and
4073 are ignored. Each line is of the form:
4074 <example compact="compact">
4075 <var>library-name</var> <var>soname-version-number</var> <var>dependencies ...</var>
4080 We will explain this by reference to the example of the
4081 <tt>zlib1g</tt> package, which (at the time of writing)
4082 installs the shared library <file>/usr/lib/libz.so.1.1.3</file>.
4086 <var>library-name</var> is the name of the shared library,
4087 in this case <tt>libz</tt>. (This must match the name part
4088 of the soname, see below.)
4092 <var>soname-version-number</var> is the version part of the
4093 soname of the library. The soname is the thing that must
4094 exactly match for the library to be recognized by the
4095 dynamic linker, and is usually of the form
4096 <tt><var>name</var>.so.<var>major-version</var></tt>, in our
4097 example, <tt>libz.so.1</tt>.<footnote>
4099 This can be determined using the command
4100 <example compact="compact">
4101 objdump -p /usr/lib/libz.so.1.1.3 | grep SONAME
4105 The version part is the part which comes after
4106 <tt>.so.</tt>, so in our case, it is <tt>1</tt>.
4110 <var>dependencies</var> has the same syntax as a dependency
4111 field in a binary package control file. It should give
4112 details of which packages are required to satisfy a binary
4113 built against the version of the library contained in the
4114 package. See <ref id="depsyntax"> for details.
4118 In our example, if the first version of the <tt>zlib1g</tt>
4119 package which contained a minor number of at least
4120 <tt>1.3</tt> was <var>1:1.1.3-1</var>, then the
4121 <tt>shlibs</tt> entry for this library could say:
4122 <example compact="compact">
4123 libz 1 zlib1g (>= 1:1.1.3)
4125 The version-specific dependency is to avoid warnings from
4126 the dynamic linker about using older shared libraries with
4132 <heading>Providing a <file>shlibs</file> file</heading>
4135 If your package provides a shared library, you should create
4136 a <file>shlibs</file> file following the format described above.
4137 It is usual to call this file <file>debian/shlibs</file> (but if
4138 you have multiple binary packages, you might want to call it
4139 <file>debian/shlibs.<var>package</var></file> instead). Then
4140 let <file>debian/rules</file> install it in the control area:
4141 <example compact="compact">
4142 install -m644 debian/shlibs debian/tmp/DEBIAN
4144 or, in the case of a multi-binary package:
4145 <example compact="compact">
4146 install -m644 debian/shlibs.<var>package</var> debian/<var>package</var>/DEBIAN/shlibs
4148 An alternative way of doing this is to create the
4149 <file>shlibs</file> file in the control area directly from
4150 <file>debian/rules</file> without using a <file>debian/shlibs</file>
4151 file at all,<footnote>
4153 This is what <prgn>dh_makeshlibs</prgn> in the
4154 <tt>debhelper</tt> suite does.
4157 since the <file>debian/shlibs</file> file itself is ignored by
4158 <prgn>dpkg-shlibdeps</prgn>.
4162 As <prgn>dpkg-shlibdeps</prgn> reads the
4163 <file>DEBIAN/shlibs</file> files in all of the binary packages
4164 being built from this source package, all of the
4165 <file>DEBIAN/shlibs</file> files should be installed before
4166 <prgn>dpkg-shlibdeps</prgn> is called on any of the binary
4171 <sect id="shlibslocal">
4172 <heading>Writing the <file>debian/shlibs.local</file> file</heading>
4175 This file is intended only as a <em>temporary</em> fix if
4176 your binaries or libraries depend on a library whose package
4177 does not yet provide a correct <file>shlibs</file> file.
4181 We will assume that you are trying to package a binary
4182 <tt>foo</tt>. When you try running
4183 <prgn>dpkg-shlibdeps</prgn> you get the following error
4184 message (<tt>-O</tt> displays the dependency information on
4185 <tt>stdout</tt> instead of writing it to
4186 <tt>debian/substvars</tt>, and the lines have been wrapped
4187 for ease of reading):
4188 <example compact="compact">
4189 $ dpkg-shlibdeps -O debian/tmp/usr/bin/foo
4190 dpkg-shlibdeps: warning: unable to find dependency
4191 information for shared library libbar (soname 1,
4192 path /usr/lib/libbar.so.1, dependency field Depends)
4193 shlibs:Depends=libc6 (>= 2.2.2-2)
4195 You can then run <prgn>ldd</prgn> on the binary to find the
4196 full location of the library concerned:
4197 <example compact="compact">
4199 libbar.so.1 => /usr/lib/libbar.so.1 (0x4001e000)
4200 libc.so.6 => /lib/libc.so.6 (0x40032000)
4201 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
4203 So the <prgn>foo</prgn> binary depends on the
4204 <prgn>libbar</prgn> shared library, but no package seems to
4205 provide a <file>*.shlibs</file> file handling
4206 <file>libbar.so.1</file> in <file>/var/lib/dpkg/info/</file>. Let's
4207 determine the package responsible:
4208 <example compact="compact">
4209 $ dpkg -S /usr/lib/libbar.so.1
4210 bar1: /usr/lib/libbar.so.1
4211 $ dpkg -s bar1 | grep Version
4214 This tells us that the <tt>bar1</tt> package, version 1.0-1,
4215 is the one we are using. Now we can file a bug against the
4216 <tt>bar1</tt> package and create our own
4217 <file>debian/shlibs.local</file> to locally fix the problem.
4218 Including the following line into your
4219 <file>debian/shlibs.local</file> file:
4220 <example compact="compact">
4221 libbar 1 bar1 (>= 1.0-1)
4223 should allow the package build to work.
4227 As soon as the maintainer of <tt>bar1</tt> provides a
4228 correct <file>shlibs</file> file, you should remove this line
4229 from your <file>debian/shlibs.local</file> file. (You should
4230 probably also then have a versioned <tt>Build-Depends</tt>
4231 on <tt>bar1</tt> to help ensure that others do not have the
4232 same problem building your package.)
4237 <chapt id="opersys"><heading>The Operating System</heading>
4240 <heading>Filesystem hierarchy</heading>
4244 <heading>Filesystem Structure</heading>
4247 The location of all installed files and directories must
4248 comply with the Filesystem Hierarchy Standard (FHS),
4249 version 2.1, except where doing so would violate other
4250 terms of Debian Policy. The version of this document
4251 referred here can be found in the <tt>debian-policy</tt>
4253 <url id="http://www.debian.org/doc/packaging-manuals/fhs/"
4254 name="FHS (Debian copy)"> alongside this manual (or, if
4255 you have the <package>debian-policy</package> installed,
4257 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
4258 (local copy)">). The
4259 latest version, which may be a more recent version, may
4261 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
4262 Specific questions about following the standard may be
4263 asked on the <tt>debian-devel</tt> mailing list, or
4264 referred to the FHS mailing list (see the
4265 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
4271 <heading>Site-specific programs</heading>
4274 As mandated by the FHS, packages must not place any
4275 files in <file>/usr/local</file>, either by putting them in
4276 the file system archive to be unpacked by <prgn>dpkg</prgn>
4277 or by manipulating them in their maintainer scripts.
4281 However, the package may create empty directories below
4282 <file>/usr/local</file> so that the system administrator knows
4283 where to place site-specific files. These directories
4284 should be removed on package removal if they are
4289 Note, that this applies only to directories <em>below</em>
4290 <file>/usr/local</file>, not <em>in</em> <file>/usr/local</file>.
4291 Packages must not create sub-directories in the directory
4292 <file>/usr/local</file> itself, except those listed in FHS,
4293 section 4.5. However, you may create directories below
4294 them as you wish. You must not remove any of the
4295 directories listed in 4.5, even if you created them.
4299 Since <file>/usr/local</file> can be mounted read-only from a
4300 remote server, these directories must be created and
4301 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
4302 maintainer scripts and not be included in the
4303 <file>.deb</file> archive. These scripts must not fail if
4304 either of these operations fail.
4308 For example, the <tt>emacsen-common</tt> package could
4309 contain something like
4310 <example compact="compact">
4311 if [ ! -e /usr/local/share/emacs ]
4313 if mkdir /usr/local/share/emacs 2>/dev/null
4315 chown root:staff /usr/local/share/emacs
4316 chmod 2775 /usr/local/share/emacs
4320 in its <prgn>postinst</prgn> script, and
4321 <example compact="compact">
4322 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
4323 rmdir /usr/local/share/emacs 2>/dev/null || true
4325 in the <prgn>prerm</prgn> script. (Note that this form is
4326 used to ensure that if the script is interrupted, the
4327 directory <file>/usr/local/share/emacs</file> will still be
4332 If you do create a directory in <file>/usr/local</file> for
4333 local additions to a package, you should ensure that
4334 settings in <file>/usr/local</file> take precedence over the
4335 equivalents in <file>/usr</file>.
4339 However, because <file>/usr/local</file> and its contents are
4340 for exclusive use of the local administrator, a package
4341 must not rely on the presence or absence of files or
4342 directories in <file>/usr/local</file> for normal operation.
4346 The <file>/usr/local</file> directory itself and all the
4347 subdirectories created by the package should (by default) have
4348 permissions 2775 (group-writable and set-group-id) and be
4349 owned by <tt>root.staff</tt>.
4354 <heading>The system-wide mail directory</heading>
4356 The system-wide mail directory is <file>/var/mail</file>. This
4357 directory is part of the base system and should not owned
4358 by any particular mail agents. The use of the old
4359 location <file>/var/spool/mail</file> is deprecated, even
4360 though the spool may still be physically located there.
4361 To maintain partial upgrade compatibility for systems
4362 which have <file>/var/spool/mail</file> as their physical mail
4363 spool, packages using <file>/var/mail</file> must depend on
4364 either <package>libc6</package> (>= 2.1.3-13), or on
4365 <package>base-files</package> (>= 2.2.0), or on later
4366 versions of either one of these packages.
4372 <heading>Users and groups</heading>
4375 <heading>Introduction</heading>
4377 The Debian system can be configured to use either plain or
4382 Some user ids (UIDs) and group ids (GIDs) are reserved
4383 globally for use by certain packages. Because some
4384 packages need to include files which are owned by these
4385 users or groups, or need the ids compiled into binaries,
4386 these ids must be used on any Debian system only for the
4387 purpose for which they are allocated. This is a serious
4388 restriction, and we should avoid getting in the way of
4389 local administration policies. In particular, many sites
4390 allocate users and/or local system groups starting at 100.
4394 Apart from this we should have dynamically allocated ids,
4395 which should by default be arranged in some sensible
4396 order, but the behavior should be configurable.
4400 Packages other than <tt>base-passwd</tt> must not modify
4401 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
4402 <file>/etc/group</file> or <file>/etc/gshadow</file>.
4407 <heading>UID and GID classes</heading>
4409 The UID and GID numbers are divided into classes as
4415 Globally allocated by the Debian project, the same
4416 on every Debian system. These ids will appear in
4417 the <file>passwd</file> and <file>group</file> files of all
4418 Debian systems, new ids in this range being added
4419 automatically as the <tt>base-passwd</tt> package is
4424 Packages which need a single statically allocated
4425 uid or gid should use one of these; their
4426 maintainers should ask the <tt>base-passwd</tt>
4434 Dynamically allocated system users and groups.
4435 Packages which need a user or group, but can have
4436 this user or group allocated dynamically and
4437 differently on each system, should use <tt>adduser
4438 --system</tt> to create the group and/or user.
4439 <prgn>adduser</prgn> will check for the existence of
4440 the user or group, and if necessary choose an unused
4441 id based on the ranges specified in
4442 <file>adduser.conf</file>.
4446 <tag>1000-29999:</tag>
4449 Dynamically allocated user accounts. By default
4450 <prgn>adduser</prgn> will choose UIDs and GIDs for
4451 user accounts in this range, though
4452 <file>adduser.conf</file> may be used to modify this
4457 <tag>30000-59999:</tag>
4462 <tag>60000-64999:</tag>
4465 Globally allocated by the Debian project, but only
4466 created on demand. The ids are allocated centrally
4467 and statically, but the actual accounts are only
4468 created on users' systems on demand.
4472 These ids are for packages which are obscure or
4473 which require many statically-allocated ids. These
4474 packages should check for and create the accounts in
4475 <file>/etc/passwd</file> or <file>/etc/group</file> (using
4476 <prgn>adduser</prgn> if it has this facility) if
4477 necessary. Packages which are likely to require
4478 further allocations should have a "hole" left after
4479 them in the allocation, to give them room to
4484 <tag>65000-65533:</tag>
4492 User <tt>nobody</tt>. The corresponding gid refers
4493 to the group <tt>nogroup</tt>.
4500 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
4501 not</em> be used, because it is the error return
4510 <sect id="sysvinit">
4511 <heading>System run levels and <file>init.d</file> scripts</heading>
4513 <sect1 id="/etc/init.d">
4514 <heading>Introduction</heading>
4517 The <file>/etc/init.d</file> directory contains the scripts
4518 executed by <prgn>init</prgn> at boot time and when the
4519 init state (or "runlevel") is changed (see <manref
4520 name="init" section="8">).
4524 There are at least two different, yet functionally
4525 equivalent, ways of handling these scripts. For the sake
4526 of simplicity, this document describes only the symbolic
4527 link method. However, it must not be assumed by maintainer
4528 scripts that this method is being used, and any automated
4529 manipulation of the various runlevel behaviours by
4530 maintainer scripts must be performed using
4531 <prgn>update-rc.d</prgn> as described below and not by
4532 manually installing or removing symlinks. For information
4533 on the implementation details of the other method,
4534 implemented in the <tt>file-rc</tt> package, please refer
4535 to the documentation of that package.
4539 These scripts are referenced by symbolic links in the
4540 <file>/etc/rc<var>n</var>.d</file> directories. When changing
4541 runlevels, <prgn>init</prgn> looks in the directory
4542 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
4543 execute, where <tt><var>n</var></tt> is the runlevel that
4544 is being changed to, or <tt>S</tt> for the boot-up
4549 The names of the links all have the form
4550 <file>S<var>mm</var><var>script</var></file> or
4551 <file>K<var>mm</var><var>script</var></file> where
4552 <var>mm</var> is a two-digit number and <var>script</var>
4553 is the name of the script (this should be the same as the
4554 name of the actual script in <file>/etc/init.d</file>).
4558 When <prgn>init</prgn> changes runlevel first the targets
4559 of the links whose names start with a <tt>K</tt> are
4560 executed, each with the single argument <tt>stop</tt>,
4561 followed by the scripts prefixed with an <tt>S</tt>, each
4562 with the single argument <tt>start</tt>. (The links are
4563 those in the <file>/etc/rc<var>n</var>.d</file> directory
4564 corresponding to the new runlevel.) The <tt>K</tt> links
4565 are responsible for killing services and the <tt>S</tt>
4566 link for starting services upon entering the runlevel.
4570 For example, if we are changing from runlevel 2 to
4571 runlevel 3, init will first execute all of the <tt>K</tt>
4572 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
4573 all of the <tt>S</tt> prefixed scripts in that directory.
4574 The links starting with <tt>K</tt> will cause the
4575 referred-to file to be executed with an argument of
4576 <tt>stop</tt>, and the <tt>S</tt> links with an argument
4581 The two-digit number <var>mm</var> is used to determine
4582 the order in which to run the scripts: low-numbered links
4583 have their scripts run first. For example, the
4584 <tt>K20</tt> scripts will be executed before the
4585 <tt>K30</tt> scripts. This is used when a certain service
4586 must be started before another. For example, the name
4587 server <prgn>bind</prgn> might need to be started before
4588 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
4589 can set up its access lists. In this case, the script
4590 that starts <prgn>bind</prgn> would have a lower number
4591 than the script that starts <prgn>inn</prgn> so that it
4593 <example compact="compact">
4600 The two runlevels 0 (halt) and 6 (reboot) are slightly
4601 different. In these runlevels, the links with an
4602 <tt>S</tt> prefix are still called after those with a
4603 <tt>K</tt> prefix, but they too are called with the single
4604 argument <tt>stop</tt>.
4608 Also, if the script name ends <tt>.sh</tt>, the script
4609 will be sourced in runlevel <tt>S</tt> rather that being
4610 run in a forked subprocess, but will be explicitly run by
4611 <prgn>sh</prgn> in all other runlevels.
4616 <heading>Writing the scripts</heading>
4619 Packages that include daemons for system services should
4620 place scripts in <file>/etc/init.d</file> to start or stop
4621 services at boot time or during a change of runlevel.
4622 These scripts should be named
4623 <file>/etc/init.d/<var>package</var></file>, and they should
4624 accept one argument, saying what to do:
4627 <tag><tt>start</tt></tag>
4628 <item><p>start the service,</p></item>
4630 <tag><tt>stop</tt></tag>
4631 <item><p>stop the service,</p></item>
4633 <tag><tt>restart</tt></tag>
4634 <item><p>stop and restart the service,</p></item>
4636 <tag><tt>reload</tt></tag>
4637 <item><p>cause the configuration of the service to be
4638 reloaded without actually stopping and restarting
4639 the service,</p></item>
4641 <tag><tt>force-reload</tt></tag>
4642 <item><p>cause the configuration to be reloaded if the
4643 service supports this, otherwise restart the
4647 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
4648 <tt>force-reload</tt> options should be supported by all
4649 scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
4650 option is optional.</p>
4653 The <file>init.d</file> scripts should ensure that they will
4654 behave sensibly if invoked with <tt>start</tt> when the
4655 service is already running, or with <tt>stop</tt> when it
4656 isn't, and that they don't kill unfortunately-named user
4657 processes. The best way to achieve this is usually to use
4658 <prgn>start-stop-daemon</prgn>.</p>
4661 If a service reloads its configuration automatically (as
4662 in the case of <prgn>cron</prgn>, for example), the
4663 <tt>reload</tt> option of the <file>init.d</file> script
4664 should behave as if the configuration has been reloaded
4668 The <file>/etc/init.d</file> scripts must be treated as
4669 configuration files, either (if they are present in the
4670 package, that is, in the .deb file) by marking them as
4671 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
4672 by managing them correctly in the maintainer scripts (see
4673 <ref id="config-files">). This is important since we want
4674 to give the local system administrator the chance to adapt
4675 the scripts to the local system, e.g., to disable a
4676 service without de-installing the package, or to specify
4677 some special command line options when starting a service,
4678 while making sure her changes aren't lost during the next
4683 These scripts should not fail obscurely when the
4684 configuration files remain but the package has been
4685 removed, as configuration files remain on the system after
4686 the package has been removed. Only when <prgn>dpkg</prgn>
4687 is executed with the <tt>--purge</tt> option will
4688 configuration files be removed. In particular, as the
4689 <file>/etc/init.d/<var>package</var></file> script itself is
4690 usually a <tt>conffile</tt>, it will remain on the system
4691 if the package is removed but not purged. Therefore, you
4692 should include a <tt>test</tt> statement at the top of the
4694 <example compact="compact">
4695 test -f <var>program-executed-later-in-script</var> || exit 0
4700 Often there are some variables in the <file>init.d</file>
4701 scripts whose values control the behaviour of the scripts,
4702 and which a system administrator is likely to want to
4703 change. As the scripts themselves are frequently
4704 <tt>conffile</tt>s, modifying them requires that the
4705 administrator merge in their changes each time the package
4706 is upgraded and the <tt>conffile</tt> changes. To ease
4707 the burden on the system administrator, such configurable
4708 values should not be placed directly in the script.
4709 Instead, they should be placed in a file in
4710 <file>/etc/default</file>, which typically will have the same
4711 base name as the <file>init.d</file> script. This extra file
4712 should be sourced by the script when the script runs. It
4713 must contain only variable settings and comments in POSIX
4714 <prgn>sh</prgn> format. It may either be a
4715 <tt>conffile</tt> or a configuration file maintained by
4716 the package maintainer scripts. See <ref id="config-files">
4721 To ensure that vital configurable values are always
4722 available, the <file>init.d</file> script should set default
4723 values for each of the shell variables it uses, either
4724 before sourcing the <file>/etc/default/</file> file or
4725 afterwards using something like the <tt>:
4726 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
4727 script must behave sensibly and not fail if the
4728 <file>/etc/default</file> file is deleted.
4733 <heading>Interfacing with the initscript system</heading>
4736 Maintainers should use the abstraction layer provided by
4737 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
4738 programs to deal with initscripts in their packages'
4739 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
4740 and <prgn>postrm</prgn>.
4743 Directly managing the /etc/rc?.d links and directly
4744 invoking the <file>/etc/init.d/</file> initscripts should
4745 be done only by packages providing the initscript
4746 subsystem (such as <prgn>sysvinit</prgn> and
4747 <prgn>file-rc</prgn>).
4752 <heading>Managing the links</heading>
4755 The program <prgn>update-rc.d</prgn> is provided for
4756 package maintainers to arrange for the proper creation and
4757 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
4758 or their functional equivalent if another method is being
4759 used. This may be used by maintainers in their packages'
4760 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.</p>
4763 You must not include any <file>/etc/rc<var>n</var>.d</file>
4764 symbolic links in the actual archive or manually create or
4765 remove the symbolic links in maintainer scripts; you must
4766 use the <prgn>update-rc.d</prgn> program instead. (The
4767 former will fail if an alternative method of maintaining
4768 runlevel information is being used.) You must not include
4769 the <file>/etc/rc<var>n</var>.d</file> directories themselves
4770 in the archive either. (Only the <tt>sysvinit</tt>
4775 By default <prgn>update-rc.d</prgn> will start services in
4776 each of the multi-user state runlevels (2, 3, 4, and 5)
4777 and stop them in the halt runlevel (0), the single-user
4778 runlevel (1) and the reboot runlevel (6). The system
4779 administrator will have the opportunity to customize
4780 runlevels by simply adding, moving, or removing the
4781 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
4782 symbolic links are being used, or by modifying
4783 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
4788 To get the default behavior for your package, put in your
4789 <prgn>postinst</prgn> script
4790 <example compact="compact">
4791 update-rc.d <var>package</var> defaults
4793 and in your <prgn>postrm</prgn>
4794 <example compact="compact">
4795 if [ "$1" = purge ]; then
4796 update-rc.d <var>package</var> remove
4798 </example>. Note that if your package changes runlevels
4799 or priority, you may have to remove and recreate the links,
4800 since otherwise the old links may persist. Refer to the
4801 documentation of <prgn>update-rc.d</prgn></p>
4804 This will use a default sequence number of 20. If it does
4805 not matter when or in which order the <file>init.d</file>
4806 script is run, use this default. If it does, then you
4807 should talk to the maintainer of the <prgn>sysvinit</prgn>
4808 package or post to <tt>debian-devel</tt>, and they will
4809 help you choose a number.
4813 For more information about using <tt>update-rc.d</tt>,
4814 please consult its manpage <manref name="update-rc.d"
4820 <heading>Running initscripts</heading>
4822 The program <prgn>invoke-rc.d</prgn> is provided to make
4823 it easier for package maintainers to properly invoke an
4824 initscript, obeying runlevel and other locally-defined
4825 constraints that might limit a package's right to start,
4826 stop and otherwise manage services. This program may be
4827 used by maintainers in their packages' scripts.
4830 The use of <prgn>invoke-rc.d</prgn> to invoke the
4831 <file>/etc/init.d/*</file> initscripts is strongly
4832 recommended<footnote>
4834 In the future, the use of invoke-rc.d to invoke
4835 initscripts shall be made mandatory. Maintainers are
4836 advised to switch to invoke-rc.d as soon as
4838 </footnote>, instead of calling them directly.
4842 By default, <prgn>invoke-rc.d</prgn> will pass any
4843 action requests (start, stop, reload, restart...) to the
4844 <file>/etc/init.d</file> script, filtering out requests
4845 to start or restart a service out of its intended
4849 Most packages will simply need to change:
4850 <example compact="compact">/etc/init.d/<package>
4851 <action></example> in their <prgn>postinst</prgn>
4852 and <prgn>prerm</prgn> scripts to:
4853 <example compact="compact">
4854 if [ -x /usr/sbin/invoke-rc.d ] ; then
4855 invoke-rc.d <var>package</var> <action>
4857 /etc/init.d/<var>package</var> <action>
4861 A package should register its initscript services using
4862 <prgn>update-rc.d</prgn> before it tries to invoke them
4863 using <prgn>invoke-rc.d</prgn>. Invocation of
4864 unregistered services may fail.
4867 For more information about using
4868 <prgn>invoke-rc.d</prgn>, please consult its manpage
4869 <manref name="invoke-rc.d" section="8">.
4876 <heading>Boot-time initialization</heading>
4879 There used to be another directory, <file>/etc/rc.boot</file>,
4880 which contained scripts which were run once per machine
4881 boot. This has been deprecated in favour of links from
4882 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
4883 described in <ref id="/etc/init.d">. Packages must not
4884 place files in <file>/etc/rc.boot</file>.</p>
4887 <heading>Example</heading>
4890 The <prgn>bind</prgn> DNS (nameserver) package wants to
4891 make sure that the nameserver is running in multiuser
4892 runlevels, and is properly shut down with the system. It
4893 puts a script in <file>/etc/init.d</file>, naming the script
4894 appropriately <tt>bind</tt>. As you can see, the script
4895 interprets the argument <tt>reload</tt> to send the
4896 nameserver a <tt>HUP</tt> signal (causing it to reload its
4897 configuration); this way the system administrator can say
4898 <file>/etc/init.d/bind reload</file> to reload the name
4899 server. The script has one configurable value, which can
4900 be used to pass parameters to the named program at
4901 startup; this value is read from
4902 <file>/etc/default/bind</file> (see below).
4906 <example compact="compact">
4909 # Original version by Robert Leslie
4910 # <rob@mars.org>, edited by iwj and cs
4912 test -x /usr/sbin/named || exit 0
4914 # Source defaults file.
4916 if [ -f /etc/default/bind ]; then
4923 echo -n "Starting domain name service: named"
4924 start-stop-daemon --start --quiet --exec /usr/sbin/named \
4929 echo -n "Stopping domain name service: named"
4930 start-stop-daemon --stop --quiet \
4931 --pidfile /var/run/named.pid --exec /usr/sbin/named
4935 echo -n "Restarting domain name service: named"
4936 start-stop-daemon --stop --quiet \
4937 --pidfile /var/run/named.pid --exec /usr/sbin/named
4938 start-stop-daemon --start --verbose --exec /usr/sbin/named \
4942 force-reload|reload)
4943 echo -n "Reloading configuration of domain name service: named"
4944 start-stop-daemon --stop --signal 1 --quiet \
4945 --pidfile /var/run/named.pid --exec /usr/sbin/named
4949 echo "Usage: /etc/init.d/bind " \
4950 " {start|stop|restart|reload|force-reload}" >&2
4960 Complementing the above init script is a configuration
4961 file <file>/etc/default/bind</file>, which contains
4962 configurable parameters used by the script. This would be
4963 created by the <prgn>postinst</prgn> script if it was not
4964 already present, and removed on purge by the
4965 <prgn>postrm</prgn> script.
4966 <example compact="compact">
4967 # Specified parameters to pass to named. See named(8).
4968 # You may uncomment the following line, and edit to taste.
4974 Another example on which you can base your
4975 <file>/etc/init.d</file> scripts is found in
4976 <file>/etc/init.d/skeleton</file>.
4980 If this package is happy with the default setup from
4981 <prgn>update-rc.d</prgn>, namely an ordering number of 20
4982 and having named running in all runlevels, it can say in
4983 its <prgn>postinst</prgn>:
4984 <example compact="compact">
4985 update-rc.d bind defaults >/dev/null
4987 And in its <prgn>postrm</prgn>, to remove the links when the
4989 <example compact="compact">
4990 if [ "$1" = purge ]; then
4991 update-rc.d bind remove >/dev/null
4999 <heading>Console messages from <file>init.d</file> scripts</heading>
5002 This section describes the formats to be used for messages
5003 written to standard output by the <file>/etc/init.d</file>
5004 scripts. The intent is to improve the consistency of
5005 Debian's startup and shutdown look and feel. For this
5006 reason, please look very carefully at the details. We want
5007 the messages to have the same format in terms of wording,
5008 spaces, punctuation and case of letters.
5012 Here is a list of overall rules that you should use when you
5013 create output messages. They can be useful if you have a
5014 non-standard message that is not covered specifically in the
5022 Every message should fit in one line (fewer than 80
5023 characters), start with a capital letter and end with
5024 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
5030 If you want to express that the computer is working on
5031 something (that is, performing a specific task, not
5032 starting or stopping a program), we use an "ellipsis"
5033 (three dots: <tt>...</tt>). Note that we don't insert
5034 spaces before or after the dots. If the task has been
5035 completed we write <tt>done.</tt> and a line feed.
5041 Design your messages as if the computer is telling you
5042 what he is doing (let him be polite :-), but don't
5043 mention "him" directly. For example, if you think of
5045 <example compact="compact">
5046 I'm starting network daemons: nfsd mountd.
5049 <example compact="compact">
5050 Starting network daemons: nfsd mountd.
5058 There are standard message formats for the following
5059 situations. They should be used by the <tt>init.d</tt>
5066 <p>When daemons are started</p>
5069 If your script starts one or more daemons, the output
5070 should look like this (a single line, no leading
5072 <example compact="compact">
5073 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
5075 The <var>description</var> should describe the
5076 subsystem the daemon or set of daemons are part of,
5077 while <var>daemon-1</var> up to <var>daemon-n</var>
5078 denote each daemon's name (typically the file name of
5083 For example, the output of <file>/etc/init.d/lpd</file>
5085 <example compact="compact">
5086 Starting printer spooler: lpd.
5091 This can be achieved by saying
5092 <example compact="compact">
5093 echo -n "Starting printer spooler: lpd"
5094 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
5097 in the script. If you have more than one daemon to
5098 start, you should do the following:
5099 <example compact="compact">
5100 echo -n "Starting remote file system services:"
5101 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
5102 echo -n " mountd"; start-stop-daemon --start --quiet mountd
5103 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
5106 This makes it possible for the user to see what takes
5107 so long and when the final daemon has been started.
5108 You should be careful where to put spaces: in the
5109 example above the system administrator can easily
5110 comment out a line if he don't wants to start a
5111 specific daemon, while the displayed message still
5117 <p>When a system parameter is being set</p>
5120 If you have to set up different system parameters
5121 during the system boot, you should use this format:
5122 <example compact="compact">
5123 Setting <var>parameter</var> to "<var>value</var>".
5128 You can use a statement such as the following to get
5130 <example compact="compact">
5131 echo "Setting DNS domainname to \"$domainname\"."
5136 Note that the same symbol (<tt>"</tt>) is used for the left
5137 and right quotation marks. A grave accent (<tt>`</tt>) is
5138 not a quote character; neither is an apostrophe
5144 <p>When a daemon is stopped or restarted</p>
5147 When you stop or restart a daemon, you should issue a
5148 message identical to the startup message, except that
5149 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
5150 or <tt>Restarting</tt> respectively.
5154 For example, stopping the printer daemon will like
5156 <example compact="compact">
5157 Stopping printer spooler: lpd.
5163 <p>When something is executed</p>
5166 There are several examples where you have to run a
5167 program at system startup or shutdown to perform a
5168 specific task, for example, setting the system's clock
5169 using <prgn>netdate</prgn> or killing all processes
5170 when the system shuts down. Your message should look
5172 <example compact="compact">
5173 Doing something very useful...done.
5175 You should print the <tt>done.</tt> immediately after
5176 the job has been completed, so that the user is
5177 informed why she has to wait. You can get this
5179 <example compact="compact">
5180 echo -n "Doing something very useful..."
5189 <p>When the configuration is reloaded</p>
5192 When a daemon is forced to reload its configuration
5193 files you should use the following format:
5194 <example compact="compact">
5195 Reloading <var>description</var> configuration...done.
5197 where <var>description</var> is the same as in the
5198 daemon starting message.
5206 <heading>Cron jobs</heading>
5209 Packages must not modify the configuration file
5210 <file>/etc/crontab</file>, and they must not modify the files in
5211 <file>/var/spool/cron/crontabs</file>.</p>
5214 If a package wants to install a job that has to be executed
5215 via cron, it should place a file with the name of the
5216 package in one or more of the following directories:
5217 <example compact="compact">
5222 As these directory names imply, the files within them are
5223 executed on a daily, weekly, or monthly basis,
5224 respectively. The exact times are listed in
5225 <file>/etc/crontab</file>.</p>
5228 All files installed in any of these directories must be
5229 scripts (e.g., shell scripts or Perl scripts) so that they
5230 can easily be modified by the local system administrator.
5231 In addition, they should be treated as configuration
5236 If a certain job has to be executed more frequently than
5237 daily, the package should install a file
5238 <file>/etc/cron.d/<var>package</var></file>. This file uses the
5239 same syntax as <file>/etc/crontab</file> and is processed by
5240 <prgn>cron</prgn> automatically. The file must also be
5241 treated as a configuration file. (Note that entries in the
5242 <file>/etc/cron.d</file> directory are not handled by
5243 <prgn>anacron</prgn>. Thus, you should only use this
5244 directory for jobs which may be skipped if the system is not
5248 The scripts or crontab entries in these directories should
5249 check if all necessary programs are installed before they
5250 try to execute them. Otherwise, problems will arise when a
5251 package was removed but not purged since configuration files
5252 are kept on the system in this situation.</p>
5256 <heading>Menus</heading>
5259 Menu entries should follow the current menu policy found in
5260 the <tt>menu-policy</tt> files in the <tt>debian-policy</tt>
5261 package. It may also be found on the Debian FTP site
5262 <ftpsite>ftp.debian.org</ftpsite> as the file
5263 <ftppath>/debian/doc/package-developer/menu-policy.txt.gz</ftppath>,
5264 or in the equivalent location on your local mirror.
5268 The Debian <tt>menu</tt> package provides a standard
5269 interface between packages providing applications and
5270 documents, and <em>menu programs</em> (either X window
5271 managers or text-based menu programs such as
5272 <prgn>pdmenu</prgn>).
5276 All packages that provide applications that need not be
5277 passed any special command line arguments for normal
5278 operation should register a menu entry for those
5279 applications, so that users of the <tt>menu</tt> package
5280 will automatically get menu entries in their window
5281 managers, as well in shells like <tt>pdmenu</tt>.</p>
5284 Please also refer to the <em>Debian Menu System</em>
5285 documentation that comes with the <tt>menu</tt> package for
5286 information about how to register your applications and web
5292 <heading>Multimedia handlers</heading>
5295 Packages which provide the ability to view/show/play,
5296 compose, edit or print MIME types should register themselves
5297 as such following the current MIME support policy found in
5298 the <tt>mime-policy</tt> files in the <tt>debian-policy</tt>
5299 package. It may also be found on the Debian FTP site
5300 <ftpsite>ftp.debian.org</ftpsite> as the file
5301 <ftppath>/debian/doc/package-developer/mime-policy.txt.gz</ftppath>,
5302 or in the equivalent location on your local mirror.
5306 MIME (Multipurpose Internet Mail Extensions, RFCs 2045-2049)
5307 is a mechanism for encoding files and data streams and
5308 providing meta-information about them, in particular their
5309 type (e.g. audio or video) and format (e.g. PNG, HTML,
5314 Registration of MIME type handlers allows programs like mail
5315 user agents and web browsers to to invoke these handlers to
5316 view, edit or display MIME types they don't support
5322 <heading>Keyboard configuration</heading>
5325 To achieve a consistent keyboard configuration so that all
5326 applications interpret a keyboard event the same way, all
5327 programs in the Debian distribution must be configured to
5328 comply with the following guidelines.
5332 The following keys must have the specified interpretations:
5335 <tag><tt><--</tt></tag>
5336 <item><p>delete the character to the left of the cursor</p></item>
5338 <tag><tt>Delete</tt></tag>
5339 <item><p>delete the character to the right of the cursor</p></item>
5341 <tag><tt>Control+H</tt></tag>
5342 <item><p>emacs: the help prefix</p></item>
5345 The interpretation of any keyboard events should be
5346 independent of the terminal that is used, be it a virtual
5347 console, an X terminal emulator, an rlogin/telnet session,
5352 The following list explains how the different programs
5353 should be set up to achieve this:
5358 <item><p><tt><--</tt> generates <tt>KB_BackSpace</tt>
5361 <item><p><tt>Delete</tt> generates <tt>KB_Delete</tt> in
5366 X translations are set up to make
5367 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
5368 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
5369 is the vt220 escape code for the "delete character"
5370 key). This must be done by loading the X resources
5371 using <prgn>xrdb</prgn> on all local X displays, not
5372 using the application defaults, so that the
5373 translation resources used correspond to the
5374 <prgn>xmodmap</prgn> settings.</p></item>
5378 The Linux console is configured to make
5379 <tt><--</tt> generate DEL, and <tt>Delete</tt>
5380 generate <tt>ESC [ 3 ~</tt>.</p></item>
5384 X applications are configured so that <tt><</tt>
5385 deletes left, and <tt>Delete</tt> deletes right. Motif
5386 applications already work like this.</p></item>
5388 <item><p>Terminals should have <tt>stty erase ^?</tt> .</p></item>
5392 The <tt>xterm</tt> terminfo entry should have <tt>ESC
5393 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
5394 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.</p></item>
5398 Emacs is programmed to map <tt>KB_Backspace</tt> or
5399 the <tt>stty erase</tt> character to
5400 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
5401 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
5402 <tt>^H</tt> to <tt>help</tt> as always.</p></item>
5406 Other applications use the <tt>stty erase</tt>
5407 character and <tt>kdch1</tt> for the two delete keys,
5408 with ASCII DEL being "delete previous character" and
5409 <tt>kdch1</tt> being "delete character under
5416 This will solve the problem except for the following
5424 Some terminals have a <tt><--</tt> key that cannot
5425 be made to produce anything except <tt>^H</tt>. On
5426 these terminals Emacs help will be unavailable on
5427 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
5428 character takes precedence in Emacs, and has been set
5429 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
5430 available) can be used instead.</p></item>
5434 Some operating systems use <tt>^H</tt> for <tt>stty
5435 erase</tt>. However, modern telnet versions and all
5436 rlogin versions propagate <tt>stty</tt> settings, and
5437 almost all UNIX versions honour <tt>stty erase</tt>.
5438 Where the <tt>stty</tt> settings are not propagated
5439 correctly, things can be made to work by using
5440 <tt>stty</tt> manually.</p></item>
5444 Some systems (including previous Debian versions) use
5445 <prgn>xmodmap</prgn> to arrange for both
5446 <tt><--</tt> and <tt>Delete</tt> to generate
5447 <tt>KB_Delete</tt>. We can change the behavior of
5448 their X clients using the same X resources that we use
5449 to do it for our own clients, or configure our clients
5450 using their resources when things are the other way
5451 around. On displays configured like this
5452 <tt>Delete</tt> will not work, but <tt><--</tt>
5457 Some operating systems have different <tt>kdch1</tt>
5458 settings in their <tt>terminfo</tt> database for
5459 <tt>xterm</tt> and others. On these systems the
5460 <tt>Delete</tt> key will not work correctly when you
5461 log in from a system conforming to our policy, but
5462 <tt><--</tt> will.</p></item>
5468 <heading>Environment variables</heading>
5471 A program must not depend on environment variables to get
5472 reasonable defaults. (That's because these environment
5473 variables would have to be set in a system-wide
5474 configuration file like <file>/etc/profile</file>, which is not
5475 supported by all shells.)</p>
5478 If a program usually depends on environment variables for its
5479 configuration, the program should be changed to fall back to
5480 a reasonable default configuration if these environment
5481 variables are not present. If this cannot be done easily
5482 (e.g., if the source code of a non-free program is not
5483 available), the program must be replaced by a small
5484 "wrapper" shell script which sets the environment variables
5485 if they are not already defined, and calls the original program.</p>
5488 Here is an example of a wrapper script for this purpose:
5490 <example compact="compact">
5492 BAR=${BAR:-/var/lib/fubar}
5494 exec /usr/lib/foo/foo "$@"
5499 Furthermore, as <file>/etc/profile</file> is a configuration
5500 file of the <prgn>base-files</prgn> package, other packages must not
5501 put any environment variables or other commands into that
5507 <heading>Files</heading>
5510 <heading>Binaries</heading>
5513 Two different packages must not install programs with
5514 different functionality but with the same filenames. (The
5515 case of two programs having the same functionality but
5516 different implementations is handled via "alternatives" or
5517 the "Conflicts" mechanism. See <ref id="maintscripts"> and
5518 <ref id="conflicts"> respectively.) If this case happens,
5519 one of the programs must be renamed. The maintainers should
5520 report this to the <tt>debian-devel</tt> mailing list and
5521 try to find a consensus about which program will have to be
5522 renamed. If a consensus cannot be reached, <em>both</em>
5523 programs must be renamed.
5527 By default, when a package is being built, any binaries
5528 created should include debugging information, as well as
5529 being compiled with optimization. You should also turn on
5530 as many reasonable compilation warnings as possible; this
5531 makes life easier for porters, who can then look at build
5532 logs for possible problems. For the C programming language,
5533 this means the following compilation parameters should be
5535 <example compact="compact">
5537 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
5539 install -s # (or use strip on the files in debian/tmp)
5544 Note that by default all installed binaries should be stripped,
5545 either by using the <tt>-s</tt> flag to
5546 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
5547 the binaries after they have been copied into
5548 <file>debian/tmp</file> but before the tree is made into a
5552 Although binaries in the build tree should be compiled with
5553 debugging information by default, it can often be difficult
5554 to debug programs if they are also subjected to compiler
5555 optimization. For this reason, it is recommended to support
5556 the standardized environment
5557 variable <tt>DEB_BUILD_OPTIONS</tt>. This variable can
5558 contain several flags to change how a package is compiled
5566 The presence of this string means that the package
5567 should be complied with a minimum of optimization.
5568 For C programs, it is best to add <tt>-O0</tt>
5569 to <tt>CFLAGS</tt> (although this is usually the
5570 default). Some programs might fail to build or run at
5571 this level of optimization; it may be necessary to
5572 use <tt>-O1</tt>, for example.
5578 This string means that the debugging symbols should
5579 not be stripped from the binary during installation,
5580 so that debugging information may be included in the package.
5586 The following makefile snippet is an example of how one may
5587 implement the build options; you will probably have to
5588 massage this example in order to make it work for your
5590 <example compact="compact">
5593 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
5594 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
5595 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
5596 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
5598 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5603 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
5604 INSTALL_PROGRAM += -s
5610 It is up to the package maintainer to decide what
5611 compilation options are best for the package. Certain
5612 binaries (such as computationally-intensive programs) will
5613 function better with certain flags (<tt>-O3</tt>, for
5614 example); feel free to use them. Please use good judgment
5615 here. Don't use flags for the sake of it; only use them
5616 if there is good reason to do so. Feel free to override
5617 the upstream author's ideas about which compilation
5618 options are best: they are often inappropriate for our
5625 <heading>Libraries</heading>
5627 In general, libraries must have a shared version in the
5628 library package and a static version in the development
5629 package. The shared version must be compiled with
5630 <tt>-fPIC</tt>, and the static version must not be. In
5631 other words, each source unit ( <tt>*.c</tt>, for example,
5632 for C files) will need to be compiled twice.
5635 In some cases, it is acceptable for a library to be
5636 available in static form only; these cases include:
5639 <p>libraries for languages whose shared library support
5640 is immature or unstable</p>
5644 libraries whose interfaces are in flux or under
5645 development (commonly the case when the library's
5646 major version number is zero, or where the ABI breaks
5652 libraries which are explicitly intended to be
5653 available only in static form by their upstream
5657 If a library is available only in static form, then it must follow
5658 the conventions for a development package.
5661 All libraries must have a shared version in the
5662 <tt>lib*</tt> package and a static version in the
5663 <tt>lib*-dev</tt> package. The shared version must be
5664 compiled with <tt>-fPIC</tt>, and the static version must
5665 not be. In other words, each <tt>*.c</tt> file will need to
5666 be compiled twice.</p>
5669 You must specify the gcc option <tt>-D_REENTRANT</tt>
5670 when building a library (either static or shared) to make
5671 the library compatible with LinuxThreads.</p>
5674 Note that all installed shared libraries should be
5676 <example compact="compact">
5677 strip --strip-unneeded <var>your-lib</var>
5679 (The option <tt>--strip-unneeded</tt> makes
5680 <prgn>strip</prgn> remove only the symbols which aren't
5681 needed for relocation processing.) Shared libraries can
5682 function perfectly well when stripped, since the symbols for
5683 dynamic linking are in a separate part of the ELF object
5686 You might also want to use the options
5687 <tt>--remove-section=.comment</tt> and
5688 <tt>--remove-section=.note</tt> on both shared libraries
5689 and executables, and <tt>--strip-debug</tt> on static
5696 Note that under some circumstances it may be useful to
5697 install a shared library unstripped, for example when
5698 building a separate package to support debugging.
5702 Shared object files (often <file>.so</file> files) that are not
5703 public libraries, that is, they are not meant to be linked
5704 to by third party executables (binaries of other packages),
5705 should be installed in subdirectories of the
5706 <file>/usr/lib</file> directory. Such files are exempt from the
5707 rules that govern ordinary shared libraries, except that
5708 they must not be installed executable and should be
5711 A common example are the so-called "plug-ins",
5712 internal shared objects that are dynamically loaded by
5713 programs using <manref name="dlopen" section="3">.
5719 Packages containing shared libraries that may be linked to
5720 by other packages' binaries, but which for some
5721 <em>compelling</em> reason can not be installed in
5722 <file>/usr/lib</file> directory, may install the shared library
5723 files in subdirectories of the <file>/usr/lib</file> directory,
5724 in which case they should arrange to add that directory in
5725 <file>/etc/ld.so.conf</file> in the package's post-installation
5726 script, and remove it in the package's post-removal script.
5730 An ever increasing number of packages are using
5731 <prgn>libtool</prgn> to do their linking. The latest GNU
5732 libtools (>= 1.3a) can take advantage of the metadata in the
5733 installed <prgn>libtool</prgn> archive files (<file>*.la</file>
5734 files). The main advantage of <prgn>libtool</prgn>'s
5735 <file>.la</file> files is that it allows <prgn>libtool</prgn> to
5736 store and subsequently access metadata with respect to the
5737 libraries it builds. <prgn>libtool</prgn> will search for
5738 those files, which contain a lot of useful information about
5739 a library (such as library dependency information for static
5740 linking). Also, they're <em>essential</em> for programs
5741 using <tt>libltdl</tt>.<footnote>
5743 Although <prgn>libtool</prgn> is fully capable of
5744 linking against shared libraries which don't have
5745 <tt>.la</tt> files, as it is a mere shell script it can
5746 add considerably to the build time of a
5747 <prgn>libtool</prgn>-using package if that shell script
5748 has to derive all this information from first principles
5749 for each library every time it is linked. With the
5750 advent of <prgn>libtool</prgn> version 1.4 (and to a
5751 lesser extent <prgn>libtool</prgn> version 1.3), the
5752 <file>.la</file> files also store information about
5753 inter-library dependencies which cannot necessarily be
5754 derived after the <file>.la</file> file is deleted.
5760 Packages that use <prgn>libtool</prgn> to create shared
5761 libraries should include the <file>.la</file> files in the
5762 <tt>-dev</tt> package, unless the package relies on
5763 <tt>libtool</tt>'s <tt>libltdl</tt> library, in which case
5764 the <tt>.la</tt> files must go in the run-time library
5769 You must make sure that you use only released versions of
5770 shared libraries to build your packages; otherwise other
5771 users will not be able to run your binaries
5772 properly. Producing source packages that depend on
5773 unreleased compilers is also usually a bad
5779 <heading>Shared libraries</heading>
5782 Packages involving shared libraries should be split up
5783 into several binary packages.</p>
5786 For a straightforward library which has a development
5787 environment and a runtime kit including just shared
5788 libraries you need to create two packages:
5789 <file><var>libraryname</var><var>soversion</var></file>, where
5790 <file><var>soversion</var></file> is the version number in the
5791 soname of the shared library<footnote>
5793 The soname is the shared object name: it's the thing
5794 that has to match exactly between building an executable
5795 and running it for the dynamic linker to be able run the
5796 program. For example, if the soname of the library is
5797 <file>libfoo.so.6</file>, the library package would be
5798 called <file>libfoo6</file>.
5801 and <tt><var>libraryname</var><var>soversion</var>-dev</tt>.
5802 Alternatively, if it would be confusing to directly append
5803 <var>soversion</var> to <var>libraryname</var> (e.g. because
5804 <var>libraryname</var> itself ends in a number), you may use
5805 <tt><var>libraryname</var>-<var>soversion</var></tt> and
5806 <tt><var>libraryname</var>-<var>soversion</var>-dev</tt>
5811 If you prefer only to support one development version at a
5812 time you may name the development package
5813 <file><var>libraryname</var>-dev</file>; otherwise you may need
5814 to use <prgn>dpkg</prgn>'s Conflicts mechanism (see <ref
5815 id="conflicts">) to ensure that the user only installs one
5816 development version at a time (as different development
5817 versions are likely to have the same header files in them,
5818 which would cause a filename clash if both were installed).
5819 Typically the development version should also have an exact
5820 version dependency on the runtime library, to make sure that
5821 compilation and linking happens correctly. The
5822 <tt>${Source-Version}</tt> substitution variable can be
5823 useful for this purpose.
5827 Packages which use the shared library should have a
5828 dependency on the name of the shared library package,
5829 <file><var>libraryname</var><var>soversion</var></file>. When
5830 the soname changes you can have both versions of the library
5831 installed while migrating from the old library to the new.
5835 If your package has some run-time support programs which use
5836 the shared library you must not put them in the shared
5837 library package. If you do that then you won't be able to
5838 install several versions of the shared library without
5839 getting filename clashes. Instead, either create a third
5840 package for the runtime binaries (this package might
5841 typically be named <tt><var>libraryname</var>-runtime</tt>;
5842 note the absence of the <var>soversion</var> in the package
5843 name), or if the development package is small you may
5844 include them in there.
5848 If you have several shared libraries built from the same
5849 source tree you may lump them all together into a single
5850 shared library package, provided that you change all of
5851 their sonames at once (so that you don't get filename
5852 clashes if you try to install different versions of the
5853 combined shared libraries package).
5857 Shared libraries should not be installed executable, since
5858 the dynamic linker does not require this and trying to
5859 execute a shared library usually results in a core dump.
5864 <heading>Scripts</heading>
5867 All command scripts, including the package maintainer
5868 scripts inside the package and used by <prgn>dpkg</prgn>,
5869 should have a <tt>#!</tt> line naming the shell to be used
5870 to interpret them.</p>
5873 In the case of Perl scripts this should be
5874 <tt>#!/usr/bin/perl</tt>.</p>
5877 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
5878 should almost certainly start with <tt>set -e</tt> so that
5879 errors are detected. Every script should use
5880 <tt>set -e</tt> or check the exit status of <em>every</em>
5884 The standard shell interpreter <file>/bin/sh</file> can be a
5885 symbolic link to any POSIX compatible shell, if <tt>echo
5886 -n</tt> does not generate a newline.<footnote>
5888 Debian policy specifies POSIX behavior for
5889 <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
5890 use in the Linux community (in particular including this
5891 policy, the Linux kernel source, many Debian scripts,
5892 etc.). This <tt>echo -n</tt> mechanism is valid but not
5893 required under POSIX, hence this explicit addition.
5894 Also, rumour has it that this shall be mandated under
5898 Thus, shell scripts specifying <file>/bin/sh</file> as
5899 interpreter should only use POSIX features. If a script
5900 requires non-POSIX features from the shell interpreter, the
5901 appropriate shell must be specified in the first line of the
5902 script (e.g., <tt>#!/bin/bash</tt>) and the package must
5903 depend on the package providing the shell (unless the shell
5904 package is marked "Essential", as in the case of
5909 You may wish to restrict your script to POSIX features when
5910 possible so that it may use <file>/bin/sh</file> as its
5911 interpreter. If your script works with <prgn>dash</prgn>
5912 (originally called <prgn>ash</prgn>), it's probably POSIX
5913 compliant, but if you are in doubt, use
5914 <file>/bin/bash</file>.
5918 Perl scripts should check for errors when making any
5919 system calls, including <tt>open</tt>, <tt>print</tt>,
5920 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
5924 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
5925 scripting languages. See <em>Csh Programming Considered
5926 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
5927 can be found at <url
5928 id="http://language.perl.com/versus/csh.whynot">.<footnote>
5930 It can also be found on
5931 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
5932 or on the ftp site <ftpsite>ftp.cpan.org</ftpsite> as
5933 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
5936 If an upstream package comes with <prgn>csh</prgn> scripts
5937 then you must make sure that they start with
5938 <tt>#!/bin/csh</tt> and make your package depend on the
5939 <prgn>c-shell</prgn> virtual package.
5943 Any scripts which create files in world-writeable
5944 directories (e.g., in <file>/tmp</file>) must use a
5945 mechanism which will fail if a file with the same name
5949 The Debian base system provides the <prgn>tempfile</prgn>
5950 and <prgn>mktemp</prgn> utilities for use by scripts for
5951 this purpose.</p></sect>
5955 <heading>Symbolic links</heading>
5958 In general, symbolic links within a top-level directory
5959 should be relative, and symbolic links pointing from one
5960 top-level directory into another should be absolute. (A
5961 top-level directory is a sub-directory of the root
5962 directory <file>/</file>.)</p>
5965 In addition, symbolic links should be specified as short as
5966 possible, i.e., link targets like <file>foo/../bar</file> are
5970 Note that when creating a relative link using
5971 <prgn>ln</prgn> it is not necessary for the target of the
5972 link to exist relative to the working directory you're
5973 running <prgn>ln</prgn> from, nor is it necessary to change
5974 directory to the directory where the link is to be made.
5975 Simply include the string that should appear as the target
5976 of the link (this will be a pathname relative to the
5977 directory in which the link resides) as the first argument
5978 to <prgn>ln</prgn>.</p>
5981 For example, in your <prgn>Makefile</prgn> or
5982 <file>debian/rules</file>, you can do things like:
5983 <example compact="compact">
5984 ln -fs gcc $(prefix)/bin/cc
5985 ln -fs gcc debian/tmp/usr/bin/cc
5986 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5987 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5991 A symbolic link pointing to a compressed file should always
5992 have the same file extension as the referenced file. (For
5993 example, if a file <file>foo.gz</file> is referenced by a
5994 symbolic link, the filename of the link has to end with
5995 "<file>.gz</file>" too, as in <file>bar.gz</file>.)
6000 <heading>Device files</heading>
6003 Packages must not include device files in the package file
6007 If a package needs any special device files that are not
6008 included in the base system, it must call
6009 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
6010 after notifying the user<footnote>
6012 This notification could be done via a (low-priority)
6013 debconf message, or an echo (printf) statement.
6019 Packages must not remove any device files in the
6020 <prgn>postrm</prgn> or any other script. This is left to the
6021 system administrator.</p>
6024 Debian uses the serial devices
6025 <file>/dev/ttyS*</file>. Programs using the old
6026 <file>/dev/cu*</file> devices should be changed to use
6027 <file>/dev/ttyS*</file>.</p>
6030 <sect id="config-files">
6031 <heading>Configuration files</heading>
6033 <heading>Definitions</heading>
6036 <tag>configuration file</tag>
6039 A file that affects the operation of a program, or
6040 provides site- or host-specific information, or
6041 otherwise customizes the behavior of a program.
6042 Typically, configuration files are intended to be
6043 modified by the system administrator (if needed or
6044 desired) to conform to local policy or to provide
6045 more useful site-specific behavior.
6049 <tag><tt>conffile</tt></tag>
6052 A file listed in a package's <tt>conffiles</tt>
6053 file, and is treated specially by <prgn>dpkg</prgn>
6054 (see <ref id="configdetails">).
6061 The distinction between these two is important; they are
6062 not interchangeable concepts. Almost all
6063 <tt>conffile</tt>s are configuration files, but many
6064 configuration files are not <tt>conffiles</tt>.
6068 Note that a script that embeds configuration information
6069 (such as most of the files in <file>/etc/default</file> and
6070 <file>/etc/cron.{daily,weekly,monthly}</file>) is de-facto a
6071 configuration file and should be treated as such.
6076 <heading>Location</heading>
6078 Any configuration files created or used by your package
6079 must reside in <file>/etc</file>. If there are several you
6080 should consider creating a subdirectory of <file>/etc</file>
6081 named after your package.</p>
6084 If your package creates or uses configuration files
6085 outside of <file>/etc</file>, and it is not feasible to modify
6086 the package to use the <file>/etc</file>, you should still put
6087 the files in <file>/etc</file> and create symbolic links to
6088 those files from the location that the package
6093 <heading>Behavior</heading>
6095 Configuration file handling must conform to the following
6097 <list compact="compact">
6100 local changes must be preserved during a package
6106 configuration files must be preserved when the
6107 package is removed, and only deleted when the
6115 The easy way to achieve this behavior is to make the
6116 configuration file a <tt>conffile</tt>. This is
6117 appropriate only if it is possible to distribute a default
6118 version that will work for most installations, although
6119 some system administrators may choose to modify it. This
6120 implies that the default version will be part of the
6121 package distribution, and must not be modified by the
6122 maintainer scripts during installation (or at any other
6127 In order to ensure that local changes are preserved
6128 correctly, no package may contain or make hard links to
6129 conffiles.<footnote>
6131 Rationale: There are two problems with hard links.
6132 The first is that some editors break the link while
6133 editing one of the files, so that the two files may
6134 unwittingly become unlinked and different. The second
6135 is that <prgn>dpkg</prgn> might break the hard link
6136 while upgrading <tt>conffile</tt>s.
6142 The other way to do it is via the maintainer scripts. In
6143 this case, the configuration file must not be listed as a
6144 <tt>conffile</tt> and must not be part of the package
6145 distribution. If the existence of a file is required for
6146 the package to be sensibly configured it is the
6147 responsibility of the package maintainer to provide
6148 maintainer scripts which correctly create, update and
6149 maintain the file and remove it on purge. (See <ref
6150 id="maintainerscripts"> for more information.) These
6151 scripts must be idempotent (i.e., must work correctly if
6152 <prgn>dpkg</prgn> needs to re-run them due to errors
6153 during installation or removal), must cope with all the
6154 variety of ways <prgn>dpkg</prgn> can call maintainer
6155 scripts, must not overwrite or otherwise mangle the user's
6156 configuration without asking, must not ask unnecessary
6157 questions (particularly during upgrades), and otherwise be
6162 The scripts are not required to configure every possible
6163 option for the package, but only those necessary to get
6164 the package running on a given system. Ideally the
6165 sysadmin should not have to do any configuration other
6166 than that done (semi-)automatically by the
6167 <prgn>postinst</prgn> script.
6171 A common practice is to create a script called
6172 <file><var>package</var>-configure</file> and have the
6173 package's <prgn>postinst</prgn> call it if and only if the
6174 configuration file does not already exist. In certain
6175 cases it is useful for there to be an example or template
6176 file which the maintainer scripts use. Such files should
6177 be in <file>/usr/share/<var>package</var></file> or
6178 <file>/usr/lib/<var>package</var></file> (depending on whether
6179 they are architecture-independent or not). There should
6180 be symbolic links to them from
6181 <file>/usr/share/doc/<var>package</var>/examples</file> if
6182 they are examples, and should be perfectly ordinary
6183 <prgn>dpkg</prgn>-handled files (<em>not</em>
6184 configuration files).
6188 These two styles of configuration file handling must
6189 not be mixed, for that way lies madness:
6190 <prgn>dpkg</prgn> will ask about overwriting the file
6191 every time the package is upgraded.
6196 <heading>Sharing configuration files</heading>
6198 Packages which specify the same file as a
6199 <tt>conffile</tt> must be tagged as <em>conflicting</em>
6200 with each other. (This is an instance of the general rule
6201 about not sharing files. Note that neither alternatives
6202 nor diversions are likely to be appropriate in this case;
6203 in particular, <prgn>dpkg</prgn> does not handle diverted
6204 <tt>conffile</tt>s well.)
6208 The maintainer scripts must not alter a <tt>conffile</tt>
6209 of <em>any</em> package, including the one the scripts
6214 If two or more packages use the same configuration file
6215 and it is reasonable for both to be installed at the same
6216 time, one of these packages must be defined as
6217 <em>owner</em> of the configuration file, i.e., it will be
6218 the package which handles that file as a configuration
6219 file. Other packages that use the configuration file must
6220 depend on the owning package if they require the
6221 configuration file to operate. If the other package will
6222 use the configuration file if present, but is capable of
6223 operating without it, no dependency need be declared.</p>
6226 If it is desirable for two or more related packages to
6227 share a configuration file <em>and</em> for all of the
6228 related packages to be able to modify that configuration
6229 file, then the following should be done:
6230 <enumlist compact="compact">
6233 One of the related packages (the "owning" package)
6234 will manage the configuration file with maintainer
6235 scripts as described in the previous section.
6240 The owning package should also provide a program
6241 that the other packages may use to modify the
6247 The related packages must use the provided program
6248 to make any desired modifications to the
6249 configuration file. They should either depend on
6250 the core package to guarantee that the configuration
6251 modifier program is available or accept gracefully
6252 that they cannot modify the configuration file if it
6253 is not. (This is in addition to the fact that the
6254 configuration file may not even be present in the
6262 Sometimes it's appropriate to create a new package which
6263 provides the basic infrastructure for the other packages
6264 and which manages the shared configuration files. (The
6265 <tt>sgml-base</tt> package is a good example.)
6270 <heading>User configuration files ("dotfiles")</heading>
6273 The files in <file>/etc/skel</file> will automatically be
6274 copied into new user accounts by <prgn>adduser</prgn>.
6275 No other program should reference the files in
6276 <file>/etc/skel</file>.
6280 Therefore, if a program needs a dotfile to exist in
6281 advance in <file>$HOME</file> to work sensibly, that dotfile
6282 should be installed in <file>/etc/skel</file> and treated as a
6287 However, programs that require dotfiles in order to
6288 operate sensibly (dotfiles that they do not create
6289 themselves automatically, that is) are a bad thing.
6290 Furthermore, programs should be configured by the Debian
6291 default installation to behave as closely to the upstream
6292 default behaviour as possible.
6296 Therefore, if a program in a Debian package needs to be
6297 configured in some way in order to operate sensibly, that
6298 should be done using a site-wide configuration file placed
6299 in <file>/etc</file>. Only if the program doesn't support a
6300 site-wide default configuration and the package maintainer
6301 doesn't have time to add it may a default per-user file be
6302 placed in <file>/etc/skel</file>.
6306 <file>/etc/skel</file> should be as empty as we can make it.
6307 This is particularly true because there is no easy (or
6308 necessarily desirable) mechanism for ensuring that the
6309 appropriate dotfiles are copied into the accounts of
6310 existing users when a package is installed.
6316 <heading>Log files</heading>
6318 Log files should usually be named
6319 <file>/var/log/<var>package</var>.log</file>. If you have many
6320 log files, or need a separate directory for permission
6321 reasons (<file>/var/log</file> is writable only by
6322 <file>root</file>), you should usually create a directory named
6323 <file>/var/log/<var>package</var></file> and place your log
6328 Log files must be rotated occasionally so that they don't
6329 grow indefinitely; the best way to do this is to drop a log
6330 rotation configuration file into the directory
6331 <file>/etc/logrotate.d</file> and use the facilities provided by
6332 logrotate.<footnote>
6334 The traditional approach to log files has been to set up
6335 <em>ad hoc</em> log rotation schemes using simple shell
6336 scripts and cron. While this approach is highly
6337 customizable, it requires quite a lot of sysadmin work.
6338 Even though the original Debian system helped a little
6339 by automatically installing a system which can be used
6340 as a template, this was deemed not enough.
6344 The use of <prgn>logrotate</prgn>, a program developed
6345 by Red Hat, is better, as it centralizes log management.
6346 It has both a configuration file
6347 (<file>/etc/logrotate.conf</file>) and a directory where
6348 packages can drop their individual log rotation
6349 configurations (<file>/etc/logrotate.d</file>).
6352 Here is a good example for a logrotate config
6353 file (for more information see <manref name="logrotate"
6355 <example compact="compact">
6361 /etc/init.d/foo force-reload
6365 This rotates all files under <file>/var/log/foo</file>, saves 12
6366 compressed generations, and forces the daemon to reload its
6367 configuration information after the log rotation.
6371 Log files should be removed when the package is
6372 purged (but not when it is only removed). This should be
6373 done by the <prgn>postrm</prgn> script when it is called
6374 with the argument <tt>purge</tt> (see <ref
6375 id="removedetails">).
6380 <heading>Permissions and owners</heading>
6383 The rules in this section are guidelines for general use.
6384 If necessary you may deviate from the details below.
6385 However, if you do so you must make sure that what is done
6386 is secure and you should try to be as consistent as possible
6387 with the rest of the system. You should probably also
6388 discuss it on <prgn>debian-devel</prgn> first.
6392 Files should be owned by <tt>root.root</tt>, and made
6393 writable only by the owner and universally readable (and
6394 executable, if appropriate), that is mode 644 or 755.
6398 Directories should be mode 755 or (for group-writability)
6399 mode 2775. The ownership of the directory should be
6400 consistent with its mode: if a directory is mode 2775, it
6401 should be owned by the group that needs write access to
6406 Setuid and setgid executables should be mode 4755 or 2755
6407 respectively, and owned by the appropriate user or group.
6408 They should not be made unreadable (modes like 4711 or
6409 2711 or even 4111); doing so achieves no extra security,
6410 because anyone can find the binary in the freely available
6411 Debian package; it is merely inconvenient. For the same
6412 reason you should not restrict read or execute permissions
6413 on non-set-id executables.
6417 Some setuid programs need to be restricted to particular
6418 sets of users, using file permissions. In this case they
6419 should be owned by the uid to which they are set-id, and by
6420 the group which should be allowed to execute them. They
6421 should have mode 4754; again there is no point in making
6422 them unreadable to those users who must not be allowed to
6427 It is possible to arrange that the system administrator can
6428 reconfigure the package to correspond to their local
6429 security policy by changing the permissions on a binary:
6430 they can do this by using <prgn>dpkg-statoverride</prgn>, as
6431 described below.<footnote>
6433 Ordinary files installed by <prgn>dpkg</prgn> (as
6434 opposed to <tt>conffile</tt>s and other similar objects)
6435 normally have their permissions reset to the distributed
6436 permissions when the package is reinstalled. However,
6437 the use of <prgn>dpkg-statoverride</prgn> overrides this
6438 default behaviour. If you use this method, you should
6439 remember to describe <prgn>dpkg-statoverride</prgn> in
6440 the package documentation; being a relatively new
6441 addition to Debian, it is probably not yet well-known.
6444 Another method you should consider is to create a group for
6445 people allowed to use the program(s) and make any setuid
6446 executables executable only by that group.
6450 If you need to create a new user or group for your package
6451 there are two possibilities. Firstly, you may need to
6452 make some files in the binary package be owned by this
6453 user or group, or you may need to compile the user or
6454 group id (rather than just the name) into the binary
6455 (though this latter should be avoided if possible, as in
6456 this case you need a statically allocated id).</p>
6459 If you need a statically allocated id, you must ask for a
6460 user or group id from the <tt>base-passwd</tt> maintainer,
6461 and must not release the package until you have been
6462 allocated one. Once you have been allocated one you must
6463 either make the package depend on a version of the
6464 <tt>base-passwd</tt> package with the id present in
6465 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
6466 your package to create the user or group itself with the
6467 correct id (using <tt>adduser</tt>) in its
6468 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
6469 the <prgn>postinst</prgn> is to be preferred if it is
6470 possible, otherwise a pre-dependency will be needed on the
6471 <tt>adduser</tt> package.)
6475 On the other hand, the program might be able to determine
6476 the uid or gid from the user or group name at runtime, so
6477 that a dynamically allocated id can be used. In this case
6478 you should choose an appropriate user or group name,
6479 discussing this on <prgn>debian-devel</prgn> and checking
6480 with the <package/base-passwd/ maintainer that it is unique and that
6481 they do not wish you to use a statically allocated id
6482 instead. When this has been checked you must arrange for
6483 your package to create the user or group if necessary using
6484 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
6485 <prgn>postinst</prgn> script (again, the latter is to be
6486 preferred if it is possible).
6490 Note that changing the numeric value of an id associated
6491 with a name is very difficult, and involves searching the
6492 file system for all appropriate files. You need to think
6493 carefully whether a static or dynamic id is required, since
6494 changing your mind later will cause problems.
6497 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
6499 This section is not intended as policy, but as a
6500 description of the use of <prgn>dpkg-statoverride</prgn>.
6504 <prgn>dpkg-statoverride</prgn> is a replacement for the
6505 deprecated <tt>suidmanager</tt> package. Packages which
6506 previously used <tt>suidmanager</tt> should have a
6507 <tt>Conflicts: suidmanager (<< 0.50)</tt> entry (or even
6508 <tt>(<< 0.52)</tt>), and calls to <tt>suidregister</tt>
6509 and <tt>suidunregister</tt> should now be simply removed
6510 from the maintainer scripts.
6514 If a system administrator wishes to have a file (or
6515 directory or other such thing) installed with owner and
6516 permissions different from those in the distributed Debian
6517 package, he can use the <prgn>dpkg-statoverride</prgn>
6518 program to instruct <prgn>dpkg</prgn> to use the different
6519 settings every time the file is installed. Thus the
6520 package maintainer should distribute the files with their
6521 normal permissions, and leave it for the system
6522 administrator to make any desired changes. For example, a
6523 daemon which is normally required to be setuid root, but
6524 in certain situations could be used without being setuid,
6525 should be installed setuid in the <tt>.deb</tt>. Then the
6526 local system administrator can change this if they wish.
6527 If there are two standard ways of doing it, the package
6528 maintainer can use <tt>debconf</tt> to find out the
6529 preference, and call <prgn>dpkg-statoverride</prgn> in the
6530 maintainer script if necessary to accommodate the system
6531 administrator's choice.
6535 Given the above, <prgn>dpkg-statoverride</prgn> is
6536 essentially a tool for system administrators and would not
6537 normally be needed in the maintainer scripts. There is
6538 one type of situation, though, where calls to
6539 <prgn>dpkg-statoverride</prgn> would be needed in the
6540 maintainer scripts, and that involves packages which use
6541 dynamically allocated user or group ids. In such a
6542 situation, something like the following idiom can be very
6543 helpful in the package's <prgn>postinst</prgn>, where
6544 <tt>sysuser</tt> is a dynamically allocated id:
6546 for i in /usr/bin/foo /usr/sbin/bar
6548 if ! dpkg-statoverride --list $i >/dev/null
6550 dpkg-statoverride --update --add sysuser root 4755 $i
6554 The corresponding <tt>dpkg-statoverride --remove</tt>
6555 calls can then be made unconditionally when the package is
6562 <chapt id="customized-programs">
6563 <heading>Customized programs</heading>
6565 <sect id="arch-spec">
6566 <heading>Architecture specification strings</heading>
6569 If a program needs to specify an <em>architecture specification
6570 string</em> in some place, the following format should be
6571 used: <var>arch</var>-<var>os</var><footnote>
6573 The following architectures and operating systems are
6574 currently recognised by <prgn>dpkg-archictecture</prgn>.
6575 The architecture, <tt><var>arch</var></tt>, is one of
6576 the following: <tt>alpha</tt>, <tt>arm</tt>,
6577 <tt>hppa</tt>, <tt>i386</tt>, <tt>ia64</tt>,
6578 <tt>m68k</tt>, <tt>mips</tt>, <tt>mipsel</tt>,
6579 <tt>powerpc</tt>, <tt>s390</tt>, <tt>sh</tt>,
6580 <tt>sheb</tt>, <tt>sparc</tt> and <tt>sparc64</tt>. The
6581 operating system, <tt><var>os</var></tt>, is one of:
6582 <tt>linux</tt>, <tt>gnu</tt>, <tt>freebsd</tt> and
6583 <tt>openbsd</tt>. Use of <tt>gnu</tt> in this string is
6584 reserved for the GNU/Hurd operating system.
6590 Note that we don't want to use
6591 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
6592 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
6593 since this would make our programs incompatible with other
6594 Linux distributions. We also don't use something like
6595 <tt><var>arch</var>-unknown-linux</tt>, since the
6596 <tt>unknown</tt> does not look very good.
6601 <heading>Daemons</heading>
6604 The configuration files <file>/etc/services</file>,
6605 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
6606 by the <prgn>netbase</prgn> package and must not be modified
6611 If a package requires a new entry in one of these files, the
6612 maintainer should get in contact with the
6613 <prgn>netbase</prgn> maintainer, who will add the entries
6614 and release a new version of the <prgn>netbase</prgn>
6619 The configuration file <file>/etc/inetd.conf</file> must not be
6620 modified by the package's scripts except via the
6621 <prgn>update-inetd</prgn> script or the
6622 <file>DebianNet.pm</file> Perl module. See their documentation
6623 for details on how to add entries.
6627 If a package wants to install an example entry into
6628 <file>/etc/inetd.conf</file>, the entry must be preceded with
6629 exactly one hash character (<tt>#</tt>). Such lines are
6630 treated as "commented out by user" by the
6631 <prgn>update-inetd</prgn> script and are not changed or
6632 activated during package updates.
6637 <heading>Using pseudo-ttys and modifying wtmp, utmp and
6641 Some programs need to create pseudo-ttys. This should be done
6642 using Unix98 ptys if the C library supports it. The resulting
6643 program must not be installed setuid root, unless that
6644 is required for other functionality.
6648 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
6649 <file>/var/log/lastlog</file> must be installed writeable by
6650 group <tt>utmp</tt>. Programs which need to modify those
6651 files must be installed setgid <tt>utmp</tt>.
6656 <heading>Editors and pagers</heading>
6659 Some programs have the ability to launch an editor or pager
6660 program to edit or display a text document. Since there are
6661 lots of different editors and pagers available in the Debian
6662 distribution, the system administrator and each user should
6663 have the possibility to choose his/her preferred editor and
6668 In addition, every program should choose a good default
6669 editor/pager if none is selected by the user or system
6674 Thus, every program that launches an editor or pager must
6675 use the EDITOR or PAGER environment variable to determine
6676 the editor or pager the user wishes to use. If these
6677 variables are not set, the programs <file>/usr/bin/editor</file>
6678 and <file>/usr/bin/pager</file> should be used, respectively.
6682 These two files are managed through the <prgn>dpkg</prgn>
6683 "alternatives" mechanism. Thus every package providing an
6684 editor or pager must call the
6685 <prgn>update-alternatives</prgn> script to register these
6690 If it is very hard to adapt a program to make use of the
6691 EDITOR or PAGER variables, that program may be configured to
6692 use <file>/usr/bin/sensible-editor</file> and
6693 <file>/usr/bin/sensible-pager</file> as the editor or pager
6694 program respectively. These are two scripts provided in the
6695 Debian base system that check the EDITOR and PAGER variables
6696 and launch the appropriate program, and fall back to
6697 <file>/usr/bin/editor</file> and <file>/usr/bin/pager</file> if the
6698 variable is not set.
6702 A program may also use the VISUAL environment variable to
6703 determine the user's choice of editor. If it exists, it
6704 should take precedence over EDITOR. This is in fact what
6705 <file>/usr/bin/sensible-editor</file> does.
6709 It is not required for a package to depend on
6710 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
6711 package to provide such virtual packages.<footnote>
6713 The Debian base system already provides an editor and a
6720 <sect id="web-appl">
6721 <heading>Web servers and applications</heading>
6724 This section describes the locations and URLs that should
6725 be used by all web servers and web applications in the
6733 Cgi-bin executable files are installed in the
6735 <example compact="compact">
6736 /usr/lib/cgi-bin/<var>cgi-bin-name</var>
6738 and should be referred to as
6739 <example compact="compact">
6740 http://localhost/cgi-bin/<var>cgi-bin-name</var>
6745 <item><p>Access to HTML documents</p>
6748 HTML documents for a package are stored in
6749 <file>/usr/share/doc/<var>package</var></file>
6750 and can be referred to as
6751 <example compact="compact">
6752 http://localhost/doc/<var>package</var>/<var>filename</var>
6756 The web server should restrict access to the document
6757 tree so that only clients on the same host can read
6758 the documents. If the web server does not support such
6759 access controls, then it should not provide access at
6760 all, or ask about providing access during installation.
6764 <item><p>Web Document Root</p>
6767 Web Applications should try to avoid storing files in
6768 the Web Document Root. Instead they should use the
6769 /usr/share/doc/<var>package</var> directory for
6770 documents and register the Web Application via the
6771 menu package. If access to the web document root is
6772 unavoidable then use
6773 <example compact="compact">
6776 as the Document Root. This might be just a symbolic
6777 link to the location where the system administrator
6778 has put the real document root.
6782 </enumlist></p></sect>
6785 <sect id="mail-transport-agents">
6786 <heading>Mail transport, delivery and user agents</heading>
6789 Debian packages which process electronic mail, whether mail
6790 user agents (MUAs) or mail transport agents (MTAs), must
6791 ensure that they are compatible with the configuration
6792 decisions below. Failure to do this may result in lost
6793 mail, broken <tt>From:</tt> lines, and other serious brain
6798 The mail spool is <file>/var/mail</file> and the interface to
6799 send a mail message is <file>/usr/sbin/sendmail</file> (as per
6800 the FHS). On older systems, the mail spool may be
6801 physically located in <file>/var/spool/mail</file>, but all
6802 access to the mail spool should be via the
6803 <file>/var/mail</file> symlink. The mail spool is part of the
6804 base system and not part of the MTA package.
6808 All Debian MUAs, MTAs, MDAs and other mailbox accessing
6809 programs (such as IMAP daemons) must lock the mailbox in an
6810 NFS-safe way. This means that <tt>fcntl()</tt> locking must
6811 be combined with dot locking. To avoid deadlocks, a program
6812 should use <tt>fcntl()</tt> first and dot locking after
6813 this, or alternatively implement the two locking methods in
6814 a non blocking way<footnote>
6816 If it is not possible to establish both locks, the
6817 system shouldn't wait for the second lock to be
6818 established, but remove the first lock, wait a (random)
6819 time, and start over locking again.
6821 </footnote>. Using the functions <tt>maillock</tt> and
6822 <tt>mailunlock</tt> provided by the
6823 <tt>liblockfile*</tt><footnote>
6825 You will need to depend on <tt>liblockfile1
6826 (>>1.01)</tt> to use these functions.
6828 </footnote> packages is the recommended way to realize this.
6832 Mailboxes are generally mode 660
6833 <tt><var>user</var>.mail</tt> unless the system
6834 administrator has chosen otherwise. A MUA may remove a
6835 mailbox (unless it has nonstandard permissions) in which
6836 case the MTA or another MUA must recreate it if needed.
6837 Mailboxes must be writable by group mail.
6841 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
6842 be setgid mail to do the locking mentioned above (and
6843 must obviously avoid accessing other users' mailboxes
6844 using this privilege).</p>
6847 <file>/etc/aliases</file> is the source file for the system mail
6848 aliases (e.g., postmaster, usenet, etc.), it is the one
6849 which the sysadmin and <prgn>postinst</prgn> scripts may
6850 edit. After <file>/etc/aliases</file> is edited the program or
6851 human editing it must call <prgn>newaliases</prgn>. All MTA
6852 packages must come with a <prgn>newaliases</prgn> program,
6853 even if it does nothing, but older MTA packages did not do
6854 this so programs should not fail if <prgn>newaliases</prgn>
6855 cannot be found. Note that because of this, all MTA
6856 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
6857 <tt>Replaces: mail-transport-agent</tt> control file
6862 The convention of writing <tt>forward to
6863 <var>address</var></tt> in the mailbox itself is not
6864 supported. Use a <tt>.forward</tt> file instead.</p>
6867 The <prgn>rmail</prgn> program used by UUCP
6868 for incoming mail should be <file>/usr/sbin/rmail</file>.
6869 Likewise, <prgn>rsmtp</prgn>, for receiving
6870 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
6874 If your package needs to know what hostname to use on (for
6875 example) outgoing news and mail messages which are generated
6876 locally, you should use the file <file>/etc/mailname</file>. It
6877 will contain the portion after the username and <tt>@</tt>
6878 (at) sign for email addresses of users on the machine
6879 (followed by a newline).
6883 Such package should check for the existence of this file
6884 when it is being configured. If it exists, it should be
6885 used without comment, although an MTA's configuration script
6886 may wish to prompt the user even if it finds that this file
6887 exists. If the file does not exist, the package should
6888 prompt the user for the value (preferably using
6889 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
6890 as well as using it in the package's configuration. The
6891 prompt should make it clear that the name will not just be
6892 used by that package. For example, in this situation the
6893 <tt>inn</tt> package could say something like:
6894 <example compact="compact">
6895 Please enter the "mail name" of your system. This is the
6896 hostname portion of the address to be shown on outgoing
6897 news and mail messages. The default is
6898 <var>syshostname</var>, your system's host name. Mail
6899 name ["<var>syshostname</var>"]:
6901 where <var>syshostname</var> is the output of <tt>hostname
6907 <heading>News system configuration</heading>
6910 All the configuration files related to the NNTP (news)
6911 servers and clients should be located under
6912 <file>/etc/news</file>.</p>
6915 There are some configuration issues that apply to a number
6916 of news clients and server packages on the machine. These
6920 <tag><file>/etc/news/organization</file></tag>
6921 <item><p>A string which should appear as the
6922 organization header for all messages posted
6923 by NNTP clients on the machine</p></item>
6925 <tag><file>/etc/news/server</file></tag>
6926 <item><p>Contains the FQDN of the upstream NNTP
6927 server, or localhost if the local machine is
6928 an NNTP server.</p></item>
6931 Other global files may be added as required for cross-package news
6932 configuration.</p></sect>
6936 <heading>Programs for the X Window System</heading>
6939 <heading>Providing X support and package priorities</heading>
6942 Programs that can be configured with support for the X
6943 Window System must be configured to do so and must declare
6944 any package dependencies necessary to satisfy their
6945 runtime requirements when using the X Window System. If
6946 such a package is of higher priority than the X packages
6947 on which it depends, it is required that either the
6948 X-specific components be split into a separate package, or
6949 that an alternative version of the package, which includes
6950 X support, be provided, or that the package's priority be
6956 <heading>Packages providing an X server</heading>
6959 Packages that provide an X server that, directly or
6960 indirectly, communicates with real input and display
6961 hardware should declare in their control data that they
6962 provide the virtual package <tt>xserver</tt>.<footnote>
6964 This implements current practice, and provides an
6965 actual policy for usage of the <tt>xserver</tt>
6966 virtual package which appears in the virtual packages
6967 list. In a nutshell, X servers that interface
6968 directly with the display and input hardware or via
6969 another subsystem (e.g., GGI) should provide
6970 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
6971 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
6978 <heading>Packages providing a terminal emulator</heading>
6981 Packages that provide a terminal emulator for the X Window
6982 System which meet the criteria listed below should declare
6983 in their control data that they provide the virtual
6984 package <tt>x-terminal-emulator</tt>. They should also
6985 register themselves as an alternative for
6986 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
6991 To be an <tt>x-terminal-emulator</tt>, a program must:
6992 <list compact="compact">
6994 Be able to emulate a DEC VT100 terminal, or a
6995 compatible terminal.
6999 Support the command-line option <tt>-e
7000 <var>command</var></tt>, which creates a new
7001 terminal window<footnote>
7003 "New terminal window" does not necessarily mean
7004 a new top-level X window directly parented by
7005 the window manager; it could, if the terminal
7006 emulator application were so coded, be a new
7007 "view" in a multiple-document interface (MDI).
7010 and runs the specified <var>command</var>.
7014 Support the command-line option <tt>-T
7015 <var>title</var></tt>, which creates a new terminal
7016 window with the window title <var>title</var>.
7023 <heading>Packages providing a window manager</heading>
7026 Packages that provide a window manager should declare in
7027 their control data that they provide the virtual package
7028 <tt>x-window-manager</tt>. They should also register
7029 themselves as an alternative for
7030 <file>/usr/bin/x-window-manager</file>, with a priority
7031 calculated as follows:
7032 <list compact="compact">
7033 <item><p>Start with a priority of 20.</p></item>
7037 If the window manager supports the Debian menu
7038 system, add 20 points if this support is available
7039 in the package's default configuration (i.e., no
7040 configuration files belonging to the system or user
7041 have to be edited to activate the feature); if
7042 configuration files must be modified, add only 10
7048 If the window manager complies with <url
7049 id="http://www.freedesktop.org/standards/wm-spec.html"
7050 name="The Window Manager Specification Project">,
7051 written by the <url id="http://www.freedesktop.org"
7052 name="Free Desktop Group">, add 20 points.
7058 If the window manager permits the X session to be
7059 restarted using a <em>different</em> window manager
7060 (without killing the X server) in its default
7061 configuration, add 10 points; otherwise add none.
7069 <heading>Packages providing fonts</heading>
7072 Packages that provide fonts for the X Window
7075 For the purposes of Debian Policy, a "font for the X
7076 Window System" is one which is accessed via X protocol
7077 requests. Fonts for the Linux console, for PostScript
7078 renderers, or any other purpose, do not fit this
7079 definition. Any tool which makes such fonts available
7080 to the X Window System, however, must abide by this
7084 must do a number of things to ensure that they are both
7085 available without modification of the X or font server
7086 configuration, and that they do not corrupt files used by
7087 other font packages to register information about
7092 Fonts of any type supported by the X Window System
7093 must be in a separate binary package from any
7094 executables, libraries, or documentation (except
7095 that specific to the fonts shipped, such as their
7096 license information). If one or more of the fonts
7097 so packaged are necessary for proper operation of
7098 the package with which they are associated the font
7099 package may be Recommended; if the fonts merely
7100 provide an enhancement, a Suggests relationship may
7101 be used. Packages must not Depend on font
7104 This is because the X server may retrieve fonts
7105 from the local filesystem or over the network
7106 from an X font server; the Debian package system
7107 is empowered to deal only with the local
7116 BDF fonts must be converted to PCF fonts with the
7117 <prgn>bdftopcf</prgn> utility (available in the
7118 <tt>xutils</tt> package, <prgn>gzip</prgn>ped, and
7119 placed in a directory that corresponds to their
7121 <list compact="compact">
7123 100 dpi fonts must be placed in
7124 <file>/usr/X11R6/lib/X11/fonts/100dpi/</file>.
7128 75 dpi fonts must be placed in
7129 <file>/usr/X11R6/lib/X11/fonts/75dpi/</file>.
7133 Character-cell fonts, cursor fonts, and other
7134 low-resolution fonts must be placed in
7135 <file>/usr/X11R6/lib/X11/fonts/misc/</file>.
7142 Speedo fonts must be placed in
7143 <file>/usr/X11R6/lib/X11/fonts/Speedo/</file>.
7147 Type 1 fonts must be placed in
7148 <file>/usr/X11R6/lib/X11/fonts/Type1/</file>. If font
7149 metric files are available, they must be placed here
7155 Subdirectories of <file>/usr/X11R6/lib/X11/fonts/</file>
7156 other than those listed above must be neither
7157 created nor used. (The <file>PEX</file>, <file>CID</file>,
7158 and <file>cyrillic</file> directories are excepted for
7159 historical reasons, but installation of files into
7160 these directories remains discouraged.)
7166 Font packages may, instead of placing files directly
7167 in the X font directories listed above, provide
7168 symbolic links in that font directory pointing to
7169 the files' actual location in the filesystem. Such
7170 a location must comply with the FHS.
7176 Font packages should not contain both 75dpi and
7177 100dpi versions of a font. If both are available,
7178 they should be provided in separate binary packages
7179 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
7180 the names of the packages containing the
7181 corresponding fonts.
7187 Fonts destined for the <file>misc</file> subdirectory
7188 should not be included in the same package as 75dpi
7189 or 100dpi fonts; instead, they should be provided in
7190 a separate package with <tt>-misc</tt> appended to
7197 Font packages must not provide the files
7198 <file>fonts.dir</file>, <file>fonts.alias</file>, or
7199 <file>fonts.scale</file> in a font directory:
7202 <file>fonts.dir</file> files must not be provided at all.
7207 <file>fonts.alias</file> and <file>fonts.scale</file>
7208 files, if needed, should be provided in the
7210 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
7211 where <var>fontdir</var> is the name of the
7213 <file>/usr/X11R6/lib/X11/fonts/</file> where the
7214 package's corresponding fonts are stored
7215 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
7216 <var>package</var> is the name of the package
7217 that provides these fonts, and
7218 <var>extension</var> is either <tt>scale</tt>
7219 or <tt>alias</tt>, whichever corresponds to
7229 Font packages must declare a dependency on
7230 <tt>xutils (>> 4.0.3)</tt> in their control
7237 Font packages that provide one or more
7238 <file>fonts.scale</file> files as described above must
7239 invoke <prgn>update-fonts-scale</prgn> on each
7240 directory into which they installed fonts
7241 <em>before</em> invoking
7242 <prgn>update-fonts-dir</prgn> on that directory.
7243 This invocation must occur in both the
7244 <prgn>postinst</prgn> (for all arguments) and
7245 <prgn>postrm</prgn> (for all arguments except
7246 <tt>upgrade</tt>) scripts.
7252 Font packages that provide one or more
7253 <file>fonts.alias</file> files as described above must
7254 invoke <prgn>update-fonts-alias</prgn> on each
7255 directory into which they installed fonts. This
7256 invocation must occur in both the
7257 <prgn>postinst</prgn> (for all arguments) and
7258 <prgn>postrm</prgn> (for all arguments except
7259 <tt>upgrade</tt>) scripts.
7265 Font packages must invoke
7266 <prgn>update-fonts-dir</prgn> on each directory into
7267 which they installed fonts. This invocation must
7268 occur in both the <prgn>postinst</prgn> (for all
7269 arguments) and <prgn>postrm</prgn> (for all
7270 arguments except <tt>upgrade</tt>) scripts.
7276 Font packages must not provide alias names for the
7277 fonts they include which collide with alias names
7278 already in use by fonts already packaged.
7284 Font packages must not provide fonts with the same
7285 XLFD registry name as another font already packaged.
7293 <heading>Application defaults files</heading>
7296 Application defaults files must be installed in the
7297 directory <file>/etc/X11/app-defaults/</file> (use of a
7298 localized subdirectory of <file>/etc/X11/</file> as described
7299 in the <em>X Toolkit Intrinsics - C Language
7300 Interface</em> manual is also permitted). They must be
7301 registered as <tt>conffile</tt>s or handled as
7302 configuration files. Packages must not provide the
7303 directory <file>/usr/X11R6/lib/X11/app-defaults/</file>.
7307 Customization of programs' X resources may also be
7308 supported with the provision of a file with the same name
7309 as that of the package placed in the
7310 <file>/etc/X11/Xresources/</file> directory, which must
7311 registered as a <tt>conffile</tt> or handled as a
7312 configuration file.<footnote>
7314 Note that this mechanism is not the same as using
7315 app-defaults; app-defaults are tied to the client
7316 binary on the local filesystem, whereas X resources
7317 are stored in the X server and affect all connecting
7321 <em>Important:</em> packages that install files into the
7322 <file>/etc/X11/Xresources/</file> directory must conflict with
7323 <tt>xbase (<< 3.3.2.3a-2)</tt>; if this is not done
7324 it is possible for the installing package to destroy a
7325 previously-existing <file>/etc/X11/Xresources</file> file
7326 which had been customized by the system administrator.
7331 <heading>Installation directory issues</heading>
7334 Packages using the X Window System should not be
7335 configured to install files under the <file>/usr/X11R6/</file>
7336 directory unless they use <prgn>imake</prgn>. The
7337 <file>/usr/X11R6/</file> directory hierarchy should be
7338 regarded as deprecated for all packages except the X
7339 Window System itself, and those which use the
7340 <prgn>imake</prgn> program it provides, in which case the
7341 packages may transition out of the <file>/usr/X11R6/</file>
7342 directory at the maintainer's discretion.<footnote>
7344 <prgn>Imake</prgn>-using programs are exempt because,
7345 as long as they are written correctly, the pathnames
7346 they use to locate resources and install themselves
7347 are derived wholly from the X Window System
7348 configuration. Thus, in the event that the X Window
7349 System moves to <file>/usr/X11R7/</file>,
7350 <file>/usr/X12/</file>, or just plain <file>/usr/</file>, all
7351 that is required for these programs is a recompile
7352 against the corresponding X Window System library
7353 development packages.
7356 Programs that use GNU <prgn>autoconf</prgn> and
7357 <prgn>automake</prgn> are usually easily configured at
7358 compile time to use <file>/usr/</file> instead of
7359 <file>/usr/X11R6/</file>, and this should be done whenever
7360 possible. Configuration files for window managers and
7361 display managers should be placed in a subdirectory of
7362 <file>/etc/X11/</file> corresponding to the package name due
7363 to these programs' tight integration with the mechanisms
7364 of the X Window System. Application-level programs should
7365 use the <file>/etc/</file> directory unless otherwise mandated
7366 by policy. The installation of files into subdirectories
7367 of <file>/usr/X11R6/include/X11/</file> and
7368 <file>/usr/X11R6/lib/X11/</file> is permitted but discouraged;
7369 package maintainers should determine if subdirectories of
7370 <file>/usr/lib/</file> and <file>/usr/share/</file> can be used
7371 instead. (The use of symbolic links from the
7372 <file>X11R6</file> directories to other FHS-compliant
7373 locations is encouraged if the program is not easily
7374 configured to look elsewhere for its files.) Packages
7375 must not provide or install files into the directories
7376 <file>/usr/bin/X11/</file>, <file>/usr/include/X11/</file> or
7377 <file>/usr/lib/X11/</file>. Files within a package should,
7378 however, make reference to these directories, rather than
7379 their <tt>X11R6</tt>-named counterparts
7380 <file>/usr/X11R6/bin/</file>, <file>/usr/X11R6/include/X11/</file>
7381 and <file>/usr/X11R6/lib/X11/</file>, if the resources being
7382 referred to have not been moved to other FHS-compliant
7388 <heading>The OSF/Motif and OpenMotif libraries</heading>
7391 <em>Programs that require the non-DFSG-compliant OSF/Motif or
7392 OpenMotif libraries</em><footnote>
7394 OSF/Motif and OpenMotif are collectively referred to as
7395 "Motif" in this policy document.
7398 should be compiled against and tested with LessTif (a free
7399 re-implementation of Motif) instead. If the maintainer
7400 judges that the program or programs do not work
7401 sufficiently well with LessTif to be distributed and
7402 supported, but do so when compiled against Motif, then two
7403 versions of the package should be created; one linked
7404 statically against Motif and with <tt>-smotif</tt>
7405 appended to the package name, and one linked dynamically
7406 against Motif and with <tt>-dmotif</tt> appended to the
7407 package name. Both Motif-linked versions are dependent
7408 upon non-DFSG-compliant software and thus cannot be
7409 uploaded to the <em>main</em> distribution; if the
7410 software is itself DFSG-compliant it may be uploaded to
7411 the <em>contrib</em> distribution. While known existing
7412 versions of Motif permit unlimited redistribution of
7413 binaries linked against the library (whether statically or
7414 dynamically), it is the package maintainer's
7415 responsibility to determine whether this is permitted by
7416 the license of the copy of Motif in his or her possession.
7422 <heading>Perl programs and modules</heading>
7424 Perl programs and modules should follow the current Perl
7425 policy as defined in the file found on
7426 <ftpsite>ftp.debian.org</ftpsite> in
7427 <ftppath>/debian/doc/package-developer/perl-policy.txt.gz</ftppath>
7428 or your local mirror. In addition, it is included in the
7429 <tt>debian-policy</tt> package.
7434 <heading>Emacs lisp programs</heading>
7437 Please refer to the "Debian Emacs Policy" (documented in
7438 <file>debian-emacs-policy.gz</file> of the
7439 <prgn>emacsen-common</prgn> package) for details of how to
7440 package emacs lisp programs.
7445 <heading>Games</heading>
7448 The permissions on <file>/var/games</file> are mode 755, owner
7449 <tt>root</tt> and group <tt>root</tt>.
7453 Each game decides on its own security policy.</p>
7456 Games which require protected, privileged access to
7457 high-score files, savegames, etc., may be made
7458 set-<em>group</em>-id (mode 2755) and owned by
7459 <tt>root.games</tt>, and use files and directories with
7460 appropriate permissions (770 <tt>root.games</tt>, for
7461 example). They must not be made
7462 set-<em>user</em>-id, as this causes security problems. (If
7463 an attacker can subvert any set-user-id game they can
7464 overwrite the executable of any other, causing other players
7465 of these games to run a Trojan horse program. With a
7466 set-group-id game the attacker only gets access to less
7467 important game data, and if they can get at the other
7468 players' accounts at all it will take considerably more
7472 Some packages, for example some fortune cookie programs, are
7473 configured by the upstream authors to install with their
7474 data files or other static information made unreadable so
7475 that they can only be accessed through set-id programs
7476 provided. You should not do this in a Debian package: anyone can
7477 download the <file>.deb</file> file and read the data from it,
7478 so there is no point making the files unreadable. Not
7479 making the files unreadable also means that you don't have
7480 to make so many programs set-id, which reduces the risk of a
7484 As described in the FHS, binaries of games should be
7485 installed in the directory <file>/usr/games</file>. This also
7486 applies to games that use the X Window System. Manual pages
7487 for games (X and non-X games) should be installed in
7488 <file>/usr/share/man/man6</file>.</p>
7492 <chapt id="docs"><heading>Documentation</heading>
7496 <heading>Manual pages</heading>
7499 You should install manual pages in <prgn>nroff</prgn> source
7500 form, in appropriate places under <file>/usr/share/man</file>. You
7501 should only use sections 1 to 9 (see the FHS for more
7502 details). You must not install a preformatted "cat
7506 Each program, utility, and function should have an
7507 associated manpage included in the same package. It is
7508 suggested that all configuration files also have a manual
7509 page included as well.
7513 There should be a manual page at for every program at the
7514 very least, and possibly one for every configuration file,
7515 protocol, utility, and function. If no manual page is
7516 available, this is considered as a bug and should be
7517 reported to the Debian Bug Tracking System (the maintainer
7518 of the package is allowed to write this bug report
7519 themselves, if they so desire). Do not close the bug report
7520 until a proper manpage is available.<footnote>
7522 It is not very hard to write a man page. See the
7523 <url id="http://www.schweikhardt.net/man_page_howto.html"
7524 name="Man-Page-HOWTO">,
7525 <manref name="man" section="7">, the examples
7526 created by <prgn>debmake</prgn> or <prgn>dh_make</prgn>,
7527 the helper programs <prgn>help2man</prgn>, or the
7528 directory <file>/usr/share/doc/man-db/examples</file>.
7534 You may forward a complaint about a missing manpage to the
7535 upstream authors, and mark the bug as forwarded in the
7536 Debian bug tracking system. Even though the GNU Project do
7537 not in general consider the lack of a manpage to be a bug,
7538 we do; if they tell you that they don't consider it a bug
7539 you should leave the bug in our bug tracking system open
7544 Manual pages should be installed compressed using <tt>gzip -9</tt>.
7548 If one manpage needs to be accessible via several names it
7549 is better to use a symbolic link than the <file>.so</file>
7550 feature, but there is no need to fiddle with the relevant
7551 parts of the upstream source to change from <file>.so</file> to
7552 symlinks: don't do it unless it's easy. You should not
7553 create hard links in the manual page directories, nor put
7554 absolute filenames in <file>.so</file> directives. The filename
7555 in a <file>.so</file> in a manpage should be relative to the
7556 base of the manpage tree (usually
7557 <file>/usr/share/man</file>). If you do not create any links
7558 (whether symlinks, hard links, or <tt>.so</tt> directives)
7559 in the filesystem to the alternate names of the manpage,
7560 then you should not rely on <prgn>man</prgn> finding your
7561 manpage under those names based solely on the information in
7562 the manpage's header.<footnote>
7564 Supporting this in <prgn>man</prgn> often requires
7565 unreasonable processing time to find a manual page or to
7566 report that none exists, and moves knowledge into man's
7567 database that would be better left in the filesystem.
7568 This support is therefore deprecated and will cease to
7569 be present in the future.
7576 <heading>Info documents</heading>
7579 Info documents should be installed in <file>/usr/share/info</file>.
7580 They should be compressed with <tt>gzip -9</tt>.
7584 Your package should call <prgn>install-info</prgn> to update
7585 the Info <file>dir</file> file in its <prgn>postinst</prgn>
7586 script when called with a <tt>configure</tt> argument, for
7588 <example compact="compact">
7589 install-info --quiet --section Development Development \
7590 /usr/share/info/foobar.info
7594 It is a good idea to specify a section for the location of
7595 your program; this is done with the <tt>--section</tt>
7596 switch. To determine which section to use, you should look
7597 at <file>/usr/share/info/dir</file> on your system and choose the most
7598 relevant (or create a new section if none of the current
7599 sections are relevant). Note that the <tt>--section</tt>
7600 flag takes two arguments; the first is a regular expression
7601 to match (case-insensitively) against an existing section,
7602 the second is used when creating a new one.</p>
7605 You should remove the entries in the <prgn>prerm</prgn>
7606 script when called with a <tt>remove</tt> argument:
7607 <example compact="compact">
7608 install-info --quiet --remove /usr/share/info/foobar.info
7612 If <prgn>install-info</prgn> cannot find a description entry
7613 in the Info file you must supply one. See <manref
7614 name="install-info" section="8"> for details.</p>
7618 <heading>Additional documentation</heading>
7621 Any additional documentation that comes with the package may
7622 be installed at the discretion of the package maintainer.
7623 Text documentation should be installed in the directory
7624 <file>/usr/share/doc/<var>package</var></file>, where
7625 <var>package</var> is the name of the package, and
7626 compressed with <tt>gzip -9</tt> unless it is small.
7630 If a package comes with large amounts of documentation which
7631 many users of the package will not require you should create
7632 a separate binary package to contain it, so that it does not
7633 take up disk space on the machines of users who do not need
7634 or want it installed.</p>
7637 It is often a good idea to put text information files
7638 (<file>README</file>s, changelogs, and so forth) that come with
7639 the source package in <file>/usr/share/doc/<var>package</var></file>
7640 in the binary package. However, you don't need to install
7641 the instructions for building and installing the package, of
7645 Packages must not require the existance of any files in
7646 <file>/usr/share/doc/</file> in order to function
7649 The system administrator should be able to
7650 delete files in <file>/usr/share/doc/</file> without causing
7651 any programs to break.
7654 Any files that are referenced by programs but are also
7655 useful as standalone documentation should be installed under
7656 <file>/usr/share/<var>package</var>/</file> with symbolic links from
7657 <file>/usr/share/doc/<var>package</var></file>.
7661 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7662 link to another directory in <file>/usr/share/doc</file> only if
7663 the two packages both come from the same source and the
7664 first package Depends on the second.
7668 Former Debian releases placed all additional documentation
7669 in <file>/usr/doc/<var>package</var></file>. This has been
7670 changed to <file>/usr/share/doc/<var>package</var></file>,
7671 and packages must not put documentation in the directory
7672 <file>/usr/doc/<var>package</var></file>. <footnote>
7673 <p>At this phase of the transition, we no longer require a
7674 symbolic link in <file>/usr/doc/</file>. At a later point,
7675 policy shall change to make the symbolic links a bug.</p>
7681 <heading>Preferred documentation formats</heading>
7684 The unification of Debian documentation is being carried out
7688 If your package comes with extensive documentation in a
7689 markup format that can be converted to various other formats
7690 you should if possible ship HTML versions in a binary
7691 package, in the directory
7692 <file>/usr/share/doc/<var>appropriate-package</var></file> or
7693 its subdirectories.<footnote>
7695 The rationale: The important thing here is that HTML
7696 docs should be available in <em>some</em> package, not
7697 necessarily in the main binary package.
7703 Other formats such as PostScript may be provided at the
7704 package maintainer's discretion.
7708 <sect id="copyrightfile">
7709 <heading>Copyright information</heading>
7712 Every package must be accompanied by a verbatim copy of its
7713 copyright and distribution license in the file
7714 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
7715 file must neither be compressed nor be a symbolic link.
7719 In addition, the copyright file must say where the upstream
7720 sources (if any) were obtained. It should name the original
7721 authors of the package and the Debian maintainer(s) who were
7722 involved with its creation.</p>
7725 A copy of the file which will be installed in
7726 <file>/usr/share/doc/<var>package</var>/copyright</file> should
7727 be in <file>debian/copyright</file> in the source package.
7731 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
7732 link to another directory in <file>/usr/share/doc</file> only if
7733 the two packages both come from the same source and the
7734 first package Depends on the second. These rules are
7735 important because copyrights must be extractable by
7740 Packages distributed under the UCB BSD license, the Artistic
7741 license, the GNU GPL, and the GNU LGPL should refer to the
7742 files <file>/usr/share/common-licenses/BSD</file>,
7743 <file>/usr/share/common-licenses/Artistic</file>,
7744 <file>/usr/share/common-licenses/GPL</file>, and
7745 <file>/usr/share/common-licenses/LGPL</file> respectively,
7746 rather than quoting them in the copyright file.
7750 You should not use the copyright file as a general <file>README</file>
7751 file. If your package has such a file it should be
7752 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
7753 <file>README.Debian</file> or some other appropriate place.</p>
7757 <heading>Examples</heading>
7760 Any examples (configurations, source files, whatever),
7761 should be installed in a directory
7762 <file>/usr/share/doc/<var>package</var>/examples</file>. These
7763 files should not be referenced by any program: they're there
7764 for the benefit of the system administrator and users as
7765 documentation only. Architecture-specific example files
7766 should be installed in a directory
7767 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
7769 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
7770 latter directory itself may be a symbolic link to the
7775 <sect id="changelogs">
7776 <heading>Changelog files</heading>
7779 The Debian changelog file (<file>debian/changelog</file>) should
7780 explain briefly what modifications were made in the Debian version
7781 of the package compared to the upstream one. Other changes and
7782 updates to the package should also be documented in this file.
7786 Mistakes in changelogs are usually best rectified by
7787 making a new changelog entry rather than "rewriting history"
7788 by editing old changelog entries.
7792 The format of the <file>debian/changelog</file> file is described
7793 in <ref id="dpkgchangelog">. In non-experimental packages you must
7794 use a format for <file>debian/changelog</file> which is supported
7795 by the most recent released version of <prgn>dpkg</prgn>.<footnote>
7797 If you wish to use an alternative format, you may do so as
7798 long as you include a parser for it in your source package.
7799 The parser must have an API compatible with that expected by
7800 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-gencontrol</prgn>.
7801 If there is general interest in the new format, you should
7802 contact the <package>dpkg</package> maintainer to have the
7803 parser script for it included in the <prgn>dpkg</prgn>
7804 package. (You will need to agree that the parser and its
7805 manpage may be distributed under the GNU GPL, just as the rest
7806 of <prgn>dpkg</prgn> is.)
7812 Packages that are not Debian-native must contain a
7813 compressed copy of the <file>debian/changelog</file> file from
7814 the Debian source tree in
7815 <file>/usr/share/doc/<var>package</var></file> with the name
7816 <file>changelog.Debian.gz</file>.
7820 If an upstream changelog is available, it should be accessible as
7821 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
7822 plain text. If the upstream changelog is distributed in
7823 HTML, it should be made available in that form as
7824 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
7825 and a plain text <file>changelog.gz</file> should be generated
7826 from it using, for example, <tt>lynx -dump -nolist</tt>. If
7827 the upstream changelog files do not already conform to this
7828 naming convention, then this may be achieved either by
7829 renaming the files, or by adding a symbolic link, at the
7830 maintainer's discretion.<footnote>
7832 Rationale: People should not have to look in places for
7833 upstream changelogs merely because they are given
7834 different names or are distributed in HTML format.
7840 All of these files should be installed compressed using
7841 <tt>gzip -9</tt>, as they will become large with time even
7842 if they start out small.
7846 If the package has only one changelog which is used both as
7847 the Debian changelog and the upstream one because there is
7848 no separate upstream maintainer then that changelog should
7849 usually be installed as
7850 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
7851 there is a separate upstream maintainer, but no upstream
7852 changelog, then the Debian changelog should still be called
7853 <file>changelog.Debian.gz</file>.</p>
7858 <appendix id="pkg-scope">
7859 <heading>Introduction and scope of these appendices</heading>
7862 These appendices are taken essentially verbatim from the
7863 now-deprecated Packaging Manual, version 3.2.1.0. They are
7864 the chapters which are likely to be of use to package
7865 maintainers and which have not already been included in the
7866 policy document itself. Most of these sections are very likely
7867 not relevant to policy; they should be treated as
7868 documentation for the packaging system. Please note that these
7869 appendices are included for convenience, and for historical
7870 reasons: they used to be part of policy package, and they have
7871 not yet been incorporated into dpkg documentation. However,
7872 they still have value, and hence they are presented here.
7875 They have not yet been checked to ensure that they are
7876 compatible with the contents of policy, and if there are any
7877 contradictions, the version in the main policy document takes
7878 precedence. The remaining chapters of the old Packaging
7879 Manual have also not been read in detail to ensure that there
7880 are not parts which have been left out. Both of these will be
7885 <prgn>dpkg</prgn> is a suite of programs for creating binary
7886 package files and installing and removing them on Unix
7889 <prgn>dpkg</prgn> is targetted primarily at Debian
7890 GNU/Linux, but may work on or be ported to other
7897 The binary packages are designed for the management of
7898 installed executable programs (usually compiled binaries) and
7899 their associated data, though source code examples and
7900 documentation are provided as part of some packages.</p>
7903 This manual describes the technical aspects of creating Debian
7904 binary packages (<file>.deb</file> files). It documents the
7905 behaviour of the package management programs
7906 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
7907 they interact with packages.</p>
7910 It also documents the interaction between
7911 <prgn>dselect</prgn>'s core and the access method scripts it
7912 uses to actually install the selected packages, and describes
7913 how to create a new access method.</p>
7916 This manual does not go into detail about the options and
7917 usage of the package building and installation tools. It
7918 should therefore be read in conjuction with those programs'
7923 The utility programs which are provided with <prgn>dpkg</prgn>
7924 for managing various system configuration and similar issues,
7925 such as <prgn>update-rc.d</prgn> and
7926 <prgn>install-info</prgn>, are not described in detail here -
7927 please see their manpages.
7931 It does <em>not</em> describe the policy requirements imposed
7932 on Debian packages, such as the permissions on files and
7933 directories, documentation requirements, upload procedure, and
7934 so on. You should see the Debian packaging policy manual for
7935 these details. (Many of them will probably turn out to be
7936 helpful even if you don't plan to upload your package and make
7937 it available as part of the distribution.)
7941 It is assumed that the reader is reasonably familiar with the
7942 <prgn>dpkg</prgn> System Administrators' manual.
7943 Unfortunately this manual does not yet exist.
7947 The Debian version of the FSF's GNU hello program is provided
7948 as an example for people wishing to create Debian
7949 packages. The Debian <prgn>debmake</prgn> package is
7950 recommended as a very helpful tool in creating and maintaining
7951 Debian packages. However, while the tools and examples are
7952 helpful, they do not replace the need to read and follow the
7953 Policy and Programmer's Manual.</p>
7956 <appendix id="pkg-binarypkg"><heading>Binary packages (from old
7961 The binary package has two main sections. The first part
7962 consists of various control information files and scripts used
7963 by <prgn>dpkg</prgn> when installing and removing. See <ref
7964 id="pkg-controlarea">.
7968 The second part is an archive containing the files and
7969 directories to be installed.
7973 In the future binary packages may also contain other
7974 components, such as checksums and digital signatures. The
7975 format for the archive is described in full in the
7976 <file>deb(5)</file> manpage.
7980 <sect id="pkg-bincreating"><heading>Creating package files -
7981 <prgn>dpkg-deb</prgn>
7985 All manipulation of binary package files is done by
7986 <prgn>dpkg-deb</prgn>; it's the only program that has
7987 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
7988 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
7989 will spot that the options requested are appropriate to
7990 <prgn>dpkg-deb</prgn> and invoke that instead with the same
7995 In order to create a binary package you must make a
7996 directory tree which contains all the files and directories
7997 you want to have in the filesystem data part of the package.
7998 In Debian-format source packages this directory is usually
7999 <file>debian/tmp</file>, relative to the top of the package's
8004 They should have the locations (relative to the root of the
8005 directory tree you're constructing) ownerships and
8006 permissions which you want them to have on the system when
8011 With current versions of <prgn>dpkg</prgn> the uid/username
8012 and gid/groupname mappings for the users and groups being
8013 used should be the same on the system where the package is
8014 built and the one where it is installed.
8018 You need to add one special directory to the root of the
8019 miniature filesystem tree you're creating:
8020 <prgn>DEBIAN</prgn>. It should contain the control
8021 information files, notably the binary package control file
8022 (see <ref id="pkg-controlfile">).
8026 The <prgn>DEBIAN</prgn> directory will not appear in the
8027 filesystem archive of the package, and so won't be installed
8028 by <prgn>dpkg</prgn> when the package is installed.
8032 When you've prepared the package, you should invoke:
8034 dpkg --build <var>directory</var>
8039 This will build the package in
8040 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
8041 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
8042 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
8047 See the manpage <manref name="dpkg-deb" section="8"> for details of how
8048 to examine the contents of this newly-created file. You may find the
8049 output of following commands enlightening:
8051 dpkg-deb --info <var>filename</var>.deb
8052 dpkg-deb --contents <var>filename</var>.deb
8053 dpkg --contents <var>filename</var>.deb
8055 To view the copyright file for a package you could use this command:
8057 dpkg --fsys-tarfile <var>filename</var>.deb | tar xof usr/share/doc/<var>\*</var>copyright | less
8062 <sect id="pkg-controlarea">
8064 Package control information files
8068 The control information portion of a binary package is a
8069 collection of files with names known to <prgn>dpkg</prgn>.
8070 It will treat the contents of these files specially - some
8071 of them contain information used by <prgn>dpkg</prgn> when
8072 installing or removing the package; others are scripts which
8073 the package maintainer wants <prgn>dpkg</prgn> to run.
8077 It is possible to put other files in the package control
8078 area, but this is not generally a good idea (though they
8079 will largely be ignored).
8083 Here is a brief list of the control info files supported by
8084 <prgn>dpkg</prgn> and a summary of what they're used for.
8089 <tag><tt>control</tt>
8093 This is the key description file used by
8094 <prgn>dpkg</prgn>. It specifies the package's name
8095 and version, gives its description for the user,
8096 states its relationships with other packages, and so
8097 forth. See <ref id="pkg-controlfile">.
8101 It is usually generated automatically from information
8102 in the source package by the
8103 <prgn>dpkg-gencontrol</prgn> program, and with
8104 assistance from <prgn>dpkg-shlibdeps</prgn>. See <ref
8105 id="pkg-sourcetools">.</p>
8108 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
8114 These are exectuable files (usually scripts) which
8115 <prgn>dpkg</prgn> runs during installation, upgrade
8116 and removal of packages. They allow the package to
8117 deal with matters which are particular to that package
8118 or require more complicated processing than that
8119 provided by <prgn>dpkg</prgn>. Details of when and
8120 how they are called are in <ref
8121 id="maintainerscripts">.
8125 It is very important to make these scripts
8129 That means that if it runs successfully or fails
8130 and then you call it again it doesn't bomb out,
8131 but just ensures that everything is the way it
8134 </footnote> This is so that if an error occurs, the
8135 user interrupts <prgn>dpkg</prgn> or some other
8136 unforeseen circumstance happens you don't leave the
8137 user with a badly-broken package.
8141 The maintainer scripts are guaranteed to run with a
8142 controlling terminal and can interact with the user.
8143 If they need to prompt for passwords, do full-screen
8144 interaction or something similar you should do these
8145 things to and from <file>/dev/tty</file>, since
8146 <prgn>dpkg</prgn> will at some point redirect scripts'
8147 standard input and output so that it can log the
8148 installation process. Likewise, because these scripts
8149 may be executed with standard output redirected into a
8150 pipe for logging purposes, Perl scripts should set
8151 unbuffered output by setting <tt>$|=1</tt> so that the
8152 output is printed immediately rather than being
8157 Each script should return a zero exit status for
8158 success, or a nonzero one for failure.</p>
8161 <tag><tt>conffiles</tt>
8166 This file contains a list of configuration files which
8167 are to be handled automatically by <prgn>dpkg</prgn>
8168 (see <ref id="pkg-conffiles">). Note that not necessarily
8169 every configuration file should be listed here.</p>
8172 <tag><tt>shlibs</tt>
8177 This file contains a list of the shared libraries
8178 supplied by the package, with dependency details for
8179 each. This is used by <prgn>dpkg-shlibdeps</prgn>
8180 when it determines what dependencies are required in a
8181 package control file. The <tt>shlibs</tt> file format
8182 is described on <ref id="shlibs">.
8188 <sect id="pkg-controlfile">
8190 The main control information file: <tt>control</tt>
8193 The most important control information file used by
8194 <prgn>dpkg</prgn> when it installs a package is
8195 <tt>control</tt>. It contains all the package"s "vital
8200 The binary package control files of packages built from
8201 Debian sources are made by a special tool,
8202 <prgn>dpkg-gencontrol</prgn>, which reads
8203 <file>debian/control</file> and <file>debian/changelog</file> to
8204 find the information it needs. See <ref id="pkg-sourcepkg"> for
8209 The fields in binary package control files are:
8210 <list compact="compact">
8212 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
8215 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
8217 <item><p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
8221 This field should appear in all packages, though
8222 <prgn>dpkg</prgn> doesn't require it yet so that
8223 old packages can still be installed.
8229 <p><qref id="relationships"><tt>Depends</tt>,
8230 <tt>Provides</tt> et al.</qref></p>
8233 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
8236 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8239 <p><qref id="pkg-f-classification"><tt>Section</tt>,
8240 <tt>Priority</tt></qref></p>
8243 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
8246 <p><qref id="descriptions"><tt>Description</tt></qref></p>
8250 <qref id="pkg-f-Installed-Size"><tt>Installed-Size</tt></qref>
8256 A description of the syntax of control files and the purpose
8257 of these fields is available in <ref id="pkg-controlfields">.
8262 <heading>Time Stamps</heading>
8264 Maintainers are encouraged to preserve the modification
8265 times of the upstream source files in a package, as far as
8266 is reasonably possible.
8269 The rationale is that there is some information conveyed
8270 by knowing the age of the file, for example, you could
8271 recognize that some documentation is very old by looking
8272 at the modification time, so it would be nice if the
8273 modification time of the upstream source would be
8281 <appendix id="pkg-sourcepkg">
8282 <heading>Source packages (from old Packaging Manual) </heading>
8285 The Debian binary packages in the distribution are generated
8286 from Debian sources, which are in a special format to assist
8287 the easy and automatic building of binaries.
8291 There was a previous version of the Debian source format,
8292 which is now being phased out. Instructions for converting an
8293 old-style package are given in the Debian policy manual.
8296 <sect id="pkg-sourcetools">
8297 <heading>Tools for processing source packages</heading>
8300 Various tools are provided for manipulating source packages;
8301 they pack and unpack sources and help build of binary
8302 packages and help manage the distribution of new versions.
8306 They are introduced and typical uses described here; see
8307 <manref name="dpkg-source" section="1"> for full
8308 documentation about their arguments and operation.
8312 For examples of how to construct a Debian source package,
8313 and how to use those utilities that are used by Debian
8314 source packages, please see the <prgn>hello</prgn> example
8320 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
8325 This program is frequently used by hand, and is also
8326 called from package-independent automated building scripts
8327 such as <prgn>dpkg-buildpackage</prgn>.
8331 To unpack a package it is typically invoked with
8333 dpkg-source -x <var>.../path/to/filename</var>.dsc
8338 with the <file><var>filename</var>.tar.gz</file> and
8339 <file><var>filename</var>.diff.gz</file> (if applicable) in
8340 the same directory. It unpacks into
8341 <file><var>package</var>-<var>version</var></file>, and if
8343 <file><var>package</var>-<var>version</var>.orig</file>, in
8344 the current directory.
8348 To create a packed source archive it is typically invoked:
8350 dpkg-source -b <var>package</var>-<var>version</var>
8355 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
8356 <file>.diff.gz</file> (if appropriate) in the current
8357 directory. <prgn>dpkg-source</prgn> does not clean the
8358 source tree first - this must be done separately if it is
8363 See also <ref id="pkg-sourcearchives">.</p>
8369 <prgn>dpkg-buildpackage</prgn> - overall package-building
8374 <prgn>dpkg-buildpackage</prgn> is a script which invokes
8375 <prgn>dpkg-source</prgn>, the <file>debian/rules</file>
8376 targets <tt>clean</tt>, <tt>build</tt> and
8377 <tt>binary</tt>, <prgn>dpkg-genchanges</prgn> and
8378 <prgn>pgp</prgn> to build a signed source and binary
8383 It is usually invoked by hand from the top level of the
8384 built or unbuilt source directory. It may be invoked with
8385 no arguments; useful arguments include:
8386 <taglist compact="compact">
8387 <tag><tt>-uc</tt>, <tt>-us</tt></tag>
8390 Do not PGP-sign the <tt>.changes</tt> file or the
8391 source package <tt>.dsc</tt> file, respectively.</p>
8393 <tag><tt>-p<var>pgp-command</var></tt></tag>
8396 Invoke <var>pgp-command</var> instead of finding
8397 <tt>pgp</tt> on the <prgn>PATH</prgn>.
8398 <var>pgp-command</var> must behave just like
8399 <prgn>pgp</prgn>.</p>
8401 <tag><tt>-r<var>root-command</var></tt></tag>
8404 When root privilege is required, invoke the command
8405 <var>root-command</var>. <var>root-command</var>
8406 should invoke its first argument as a command, from
8407 the <prgn>PATH</prgn> if necessary, and pass its
8408 second and subsequent arguments to the command it
8409 calls. If no <var>root-command</var> is supplied
8410 then <var>dpkg-buildpackage</var> will take no
8411 special action to gain root privilege, so that for
8412 most packages it will have to be invoked as root to
8415 <tag><tt>-b</tt>, <tt>-B</tt></tag>
8418 Two types of binary-only build and upload - see
8419 <manref name="dpkg-source" section="1">.
8428 <prgn>dpkg-gencontrol</prgn> - generates binary package
8433 This program is usually called from <file>debian/rules</file>
8434 (see <ref id="pkg-sourcetree">) in the top level of the source
8439 This is usually done just before the files and directories in the
8440 temporary directory tree where the package is being built have their
8441 permissions and ownerships set and the package is constructed using
8442 <prgn>dpkg-deb/</prgn>
8445 This is so that the control file which is produced has
8446 the right permissions
8452 <prgn>dpkg-gencontrol</prgn> must be called after all the
8453 files which are to go into the package have been placed in
8454 the temporary build directory, so that its calculation of
8455 the installed size of a package is correct.
8459 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
8460 be run after <prgn>dpkg-shlibdeps</prgn> so that the
8461 variable substitutions created by
8462 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
8467 For a package which generates only one binary package, and
8468 which builds it in <file>debian/tmp</file> relative to the top
8469 of the source package, it is usually sufficient to call
8470 <prgn>dpkg-gencontrol</prgn>.
8474 Sources which build several binaries will typically need
8477 dpkg-gencontrol -Pdebian/tmp-<var>pkg</var> -p<var>package</var>
8478 </example> The <tt>-P</tt> tells
8479 <prgn>dpkg-gencontrol</prgn> that the package is being
8480 built in a non-default directory, and the <tt>-p</tt>
8481 tells it which package's control file should be generated.
8485 <prgn>dpkg-gencontrol</prgn> also adds information to the
8486 list of files in <file>debian/files</file>, for the benefit of
8487 (for example) a future invocation of
8488 <prgn>dpkg-genchanges</prgn>.</p>
8493 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
8498 This program is usually called from <file>debian/rules</file>
8499 just before <prgn>dpkg-gencontrol</prgn> (see <ref
8500 id="pkg-sourcetree">), in the top level of the source tree.
8504 Its arguments are executables.
8507 In a forthcoming dpkg version,
8508 <prgn>dpkg-shlibdeps</prgn> would be required to be
8509 called on shared libraries as well.
8512 They may be specified either in the locations in the
8513 source tree where they are created or in the locations
8514 in the temporary build tree where they are installed
8515 prior to binary package creation.
8517 </footnote> for which shared library dependencies should
8518 be included in the binary package's control file.
8522 If some of the found shared libraries should only
8523 warrant a <tt>Recommends</tt> or <tt>Suggests</tt>, or if
8524 some warrant a <tt>Pre-Depends</tt>, this can be achieved
8525 by using the <tt>-d<var>dependency-field</var></tt> option
8526 before those executable(s). (Each <tt>-d</tt> option
8527 takes effect until the next <tt>-d</tt>.)
8531 <prgn>dpkg-shlibdeps</prgn> does not directly cause the
8532 output control file to be modified. Instead by default it
8533 adds to the <file>debian/substvars</file> file variable
8534 settings like <tt>shlibs:Depends</tt>. These variable
8535 settings must be referenced in dependency fields in the
8536 appropriate per-binary-package sections of the source
8541 For example, the <prgn>procps</prgn> package generates two
8542 kinds of binaries, simple C binaries like <prgn>ps</prgn>
8543 which require a predependency and full-screen ncurses
8544 binaries like <prgn>top</prgn> which require only a
8545 recommendation. It can say in its <file>debian/rules</file>:
8547 dpkg-shlibdeps -dPre-Depends ps -dRecommends top
8549 and then in its main control file <file>debian/control</file>:
8553 Pre-Depends: ${shlibs:Pre-Depends}
8554 Recommends: ${shlibs:Recommends}
8560 Sources which produce several binary packages with
8561 different shared library dependency requirements can use
8562 the <tt>-p<var>varnameprefix</var></tt> option to override
8563 the default <tt>shlibs:</tt> prefix (one invocation of
8564 <prgn>dpkg-shlibdeps</prgn> per setting of this option).
8565 They can thus produce several sets of dependency
8566 variables, each of the form
8567 <tt><var>varnameprefix</var>:<var>dependencyfield</var></tt>,
8568 which can be referred to in the appropriate parts of the
8569 binary package control files.
8576 <prgn>dpkg-distaddfile</prgn> - adds a file to
8577 <file>debian/files</file>
8581 Some packages' uploads need to include files other than
8582 the source and binary package files.
8586 <prgn>dpkg-distaddfile</prgn> adds a file to the
8587 <file>debian/files</file> file so that it will be included in
8588 the <file>.changes</file> file when
8589 <prgn>dpkg-genchanges</prgn> is run.
8593 It is usually invoked from the <tt>binary</tt> target of
8594 <file>debian/rules</file>:
8596 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
8598 The <var>filename</var> is relative to the directory where
8599 <prgn>dpkg-genchanges</prgn> will expect to find it - this
8600 is usually the directory above the top level of the source
8601 tree. The <file>debian/rules</file> target should put the
8602 file there just before or just after calling
8603 <prgn>dpkg-distaddfile</prgn>.
8607 The <var>section</var> and <var>priority</var> are passed
8608 unchanged into the resulting <file>.changes</file> file. See
8609 <ref id="pkg-f-classification">.
8614 <sect1><heading><prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file> upload
8619 This program is usually called by package-independent
8620 automatic building scripts such as
8621 <prgn>dpkg-buildpackage</prgn>, but it may also be called
8626 It is usually called in the top level of a built source
8627 tree, and when invoked with no arguments will print out a
8628 straightforward <file>.changes</file> file based on the
8629 information in the source package's changelog and control
8630 file and the binary and source packages which should have
8636 <sect1><heading><prgn>dpkg-parsechangelog</prgn> - produces parsed representation of
8641 This program is used internally by
8642 <prgn>dpkg-source</prgn> et al. It may also occasionally
8643 be useful in <file>debian/rules</file> and elsewhere. It
8644 parses a changelog, <file>debian/changelog</file> by default,
8645 and prints a control-file format representation of the
8646 information in it to standard output.
8650 <sect1 id="pkg-dpkgarch"><heading><prgn>dpkg-architecture</prgn> -
8651 information about the build and host system
8655 This program can be used manually, but is also invoked by
8656 <tt>dpkg-buildpackage</tt> or <file>debian/rules</file> to set
8657 to set environment or make variables which specify the build and
8658 host architecture for the package building process.
8663 <sect id="pkg-sourcetree"><heading>The Debianised source tree
8667 The source archive scheme described later is intended to
8668 allow a Debianised source tree with some associated control
8669 information to be reproduced and transported easily. The
8670 Debianised source tree is a version of the original program
8671 with certain files added for the benefit of the
8672 Debianisation process, and with any other changes required
8673 made to the rest of the source code and installation
8678 The extra files created for Debian are in the subdirectory
8679 <file>debian</file> of the top level of the Debianised source
8680 tree. They are described below.
8683 <sect1 id="pkg-debianrules"><heading><file>debian/rules</file> - the main building
8688 This file is an executable makefile, and contains the
8689 package-specific recipies for compiling the package and
8690 building binary package(s) out of the source.
8694 It must start with the line <tt>#!/usr/bin/make -f</tt>,
8695 so that it can be invoked by saying its name rather than
8696 invoking <prgn>make</prgn> explicitly.
8700 Since an interactive <file>debian/rules</file> script makes it
8701 impossible to autocompile that package and also makes it
8702 hard for other people to reproduce the same binary
8703 package, all <strong>required targets</strong> have to be
8704 non-interactive. At a minimul, required targets are the
8705 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
8706 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
8707 <em>build</em>. It also follows that any target that these
8708 targets depend on must also be non-interactive.
8712 The targets which are required to be present are:
8714 <tag><tt>build</tt></tag>
8717 This should perform all non-interactive
8718 configuration and compilation of the package. If a
8719 package has an interactive pre-build configuration
8720 routine, the Debianised source package should be
8721 built after this has taken place, so that it can be
8722 built without rerunning the configuration.
8726 A package may also provide both of the targets
8727 <tt>build-arch</tt> and <tt>build-indep</tt>. The
8728 <tt>build-arch</tt> target, if provided, should
8729 perform all non-interactive configuration and
8730 compilation required for producing all
8731 architecture-dependant binary packages (those packages
8732 for which the body of the <tt>Architecture</tt> field
8733 in <tt>debian/control</tt> is not <tt>all</tt>).
8734 Similarly, the <tt>build-indep</tt> target, if
8735 provided, should perform all non-interactive
8736 configuration and compilation required for producing
8737 all architecture-independent binary packages (those
8738 packages for which the body of the
8739 <tt>Architecture</tt> field in <tt>debian/control</tt>
8740 is <tt>all</tt>). The <tt>build</tt> target should
8741 depend on those of the targets <tt>build-arch</tt> and
8742 <tt>build-indep</tt> that are provided in the rules
8747 If one or both of the targets <tt>build-arch</tt> and
8748 <tt>build-indep</tt> are not provided, then invoking
8749 <file>debian/rules</file> with one of the not-provided
8750 targets as arguments should produce a exit status code
8751 of 2. Usually this is provided automatically by make
8752 if the target is missing.
8756 For some packages, notably ones where the same
8757 source tree is compiled in different ways to produce
8758 two binary packages, the <tt>build</tt> target does
8759 not make much sense. For these packages it is good
8760 enough to provide two (or more) targets
8761 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
8762 for each of the ways of building the package, and a
8763 <tt>build</tt> target that does nothing. The
8764 <tt>binary</tt> target will have to build the
8765 package in each of the possible ways and make the
8766 binary package out of each.
8770 The targets <tt>build</tt>, <tt>build-arch</tt>
8771 and <tt>build-indep</tt> target must not do
8772 anything that might require root privilege.
8776 The <tt>build</tt> target may need to run
8777 <tt>clean</tt> first - see below.
8781 When a package has a configuration routine that takes
8782 a long time, or when the makefiles are poorly
8783 designed, or when <tt>build</tt> needs to run
8784 <tt>clean</tt> first, it is a good idea to <tt>touch
8785 build</tt> when the build process is complete. This
8786 will ensure that if <tt>debian/rules build</tt> is run
8787 again it will not rebuild the whole program.
8791 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
8792 <tt>binary-indep</tt>
8796 The <tt>binary</tt> target should be all that is
8797 necessary for the user to build the binary
8798 package. All these targets are required to be
8799 non-interactive. It is split into two parts:
8800 <tt>binary-arch</tt> builds the packages' output
8801 files which are specific to a particular
8802 architecture, and <tt>binary-indep</tt> builds
8803 those which are not.
8807 <tt>binary</tt> should usually be a target with
8808 no commands which simply depends on
8809 <prgn>binary-arch</prgn> and
8810 <prgn>binary-indep</prgn>.
8814 Both <prgn>binary-*</prgn> targets should depend on
8815 the <tt>build</tt> target, above, so that the
8816 package is built if it has not been already. It
8817 should then create the relevant binary package(s),
8818 using <prgn>dpkg-gencontrol</prgn> to make their
8819 control files and <prgn>dpkg-deb</prgn> to build
8820 them and place them in the parent of the top level
8825 If one of the <prgn>binary-*</prgn> targets has
8826 nothing to do (this will be always be the case if
8827 the source generates only a single binary package,
8828 whether architecture-dependent or not) it
8829 <em>must</em> still exist, but should always
8834 <ref id="pkg-binarypkg"> describes how to construct
8839 The <tt>binary</tt> targets must be invoked as
8844 <tag><tt>clean</tt></tag>
8848 This should undo any effects that the
8849 <tt>build</tt> and <tt>binary</tt> targets
8850 may have had, except that it should leave alone any
8851 output files created in the parent directory by a
8852 run of <tt>binary</tt>. This target is required
8853 to be non-interactive.
8857 If a <tt>build</tt> file is touched at the end
8858 of the <tt>build</tt> target, as suggested
8859 above, it must be removed as the first thing that
8860 <tt>clean</tt> does, so that running
8861 <tt>build</tt> again after an interrupted
8862 <tt>clean</tt> doesn't think that everything is
8867 The <tt>clean</tt> target must be invoked as
8868 root if <tt>binary</tt> has been invoked since
8869 the last <tt>clean</tt>, or if
8870 <tt>build</tt> has been invoked as root (since
8871 <tt>build</tt> may create directories, for
8876 <tag><tt>get-orig-source</tt> (optional)</tag>
8880 This target fetches the most recent version of the
8881 original source package from a canonical archive
8882 site (via FTP or WWW, for example), does any
8883 necessary rearrangement to turn it into the original
8884 source tarfile format described below, and leaves it
8885 in the current directory.
8889 This target may be invoked in any directory, and
8890 should take care to clean up any temporary files it
8895 This target is optional, but providing it if
8896 possible is a good idea.
8902 The <tt>build</tt>, <tt>binary</tt> and
8903 <tt>clean</tt> targets must be invoked with a current
8904 directory of the package's top-level directory.
8909 Additional targets may exist in <file>debian/rules</file>,
8910 either as published or undocumented interfaces or for the
8911 package's internal use.
8915 The architecture we build on and build for is determined by make
8916 variables via dpkg-architecture (see <ref id="pkg-dpkgarch">). You can
8917 get the Debian architecture and the GNU style architecture
8918 specification string for the build machine as well as the host
8919 machine. Here is a list of supported make variables:
8920 <list compact="compact">
8922 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
8925 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
8926 specification string)</p>
8929 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
8932 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
8938 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
8939 the build machine or <tt>HOST</tt> for specification of the machine
8944 Backward compatibility can be provided in the rules file
8945 by setting the needed variables to suitable default
8946 values, please refer to the documentation of
8947 dpkg-architecture for details.
8951 It is important to understand that the <tt>DEB_*_ARCH</tt>
8952 string does only determine which Debian architecture we
8953 build on resp. for. It should not be used to get the CPU
8954 or System information, the GNU style variables should be
8960 <sect1><heading><file>debian/control</file>
8964 This file contains version-independent details about the
8965 source package and about the binary packages it creates.
8969 It is a series of sets of control fields, each
8970 syntactically similar to a binary package control file.
8971 The sets are separated by one or more blank lines. The
8972 first set is information about the source package in
8973 general; each subsequent set describes one binary package
8974 that the source tree builds.
8978 The syntax and semantics of the fields are described below
8979 in <ref id="pkg-controlfields">.
8983 The general (binary-package-independent) fields are:
8984 <list compact="compact">
8986 <p><qref id="pkg-f-Source"><tt>Source</tt></qref> (mandatory)</p>
8989 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
8993 <qref id="pkg-f-classification"><tt>Section</tt> and
8994 <tt>Priority</tt></qref>
8995 (classification, mandatory)
9000 <qref id="relationships"><tt>Build-Depends</tt> et
9001 al.</qref> (source package interrelationships)
9006 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref>
9012 The per-binary-package fields are:
9013 <list compact="compact">
9015 <p><qref id="pkg-f-Package"><tt>Package</tt></qref> (mandatory)</p>
9019 <qref id="pkg-f-Architecture"><tt>Architecture</tt></qref>
9023 <p><qref id="descriptions"><tt>Description</tt></qref></p>
9027 <qref id="pkg-f-classification"><tt>Section</tt> and
9028 <tt>Priority</tt></qref> (classification)</p>
9031 <p><qref id="pkg-f-Essential"><tt>Essential</tt></qref></p>
9035 <qref id="relationships"><tt>Depends</tt> et
9036 al.</qref> (binary package interrelationships)
9042 These fields are used by <prgn>dpkg-gencontrol</prgn> to
9043 generate control files for binary packages (see below), by
9044 <prgn>dpkg-genchanges</prgn> to generate the
9045 <tt>.changes</tt> file to accompany the upload, and by
9046 <prgn>dpkg-source</prgn> when it creates the <file>.dsc</file>
9047 source control file as part of a source archive.
9051 The fields here may contain variable references - their
9052 values will be substituted by
9053 <prgn>dpkg-gencontrol</prgn>, <prgn>dpkg-genchanges</prgn>
9054 or <prgn>dpkg-source</prgn> when they generate output
9055 control files. See <ref id="pkg-srcsubstvars"> for details.
9058 <p> <sect2><heading>User-defined fields
9062 Additional user-defined fields may be added to the
9063 source package control file. Such fields will be
9064 ignored, and not copied to (for example) binary or
9065 source package control files or upload control files.
9069 If you wish to add additional unsupported fields to
9070 these output files you should use the mechanism
9075 Fields in the main source control information file with
9076 names starting <tt>X</tt>, followed by one or more of
9077 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
9078 be copied to the output files. Only the part of the
9079 field name after the hyphen will be used in the output
9080 file. Where the letter <tt>B</tt> is used the field
9081 will appear in binary package control files, where the
9082 letter <tt>S</tt> is used in source package control
9083 files and where <tt>C</tt> is used in upload control
9084 (<tt>.changes</tt>) files.
9088 For example, if the main source information control file
9091 XBS-Comment: I stand between the candle and the star.
9093 then the binary and source package control files will contain the
9096 Comment: I stand between the candle and the star.
9103 <sect1 id="pkg-dpkgchangelog"><heading><file>debian/changelog</file>
9107 This file records the changes to the Debian-specific parts of the
9111 Though there is nothing stopping an author who is also
9112 the Debian maintainer from using it for all their
9113 changes, it will have to be renamed if the Debian and
9114 upstream maintainers become different
9121 It has a special format which allows the package building
9122 tools to discover which version of the package is being
9123 built and find out other release-specific information.
9127 That format is a series of entries like this:
9129 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
9131 * <var>change details</var>
9132 <var>more change details</var>
9133 * <var>even more change details</var>
9135 -- <var>maintainer name and email address</var> <var>date</var>
9140 <var>package</var> and <var>version</var> are the source
9141 package name and version number.
9145 <var>distribution(s)</var> lists the distributions where
9146 this version should be installed when it is uploaded - it
9147 is copied to the <tt>Distribution</tt> field in the
9148 <tt>.changes</tt> file. See <ref id="pkg-f-Distribution">.
9152 <var>urgency</var> is the value for the <tt>Urgency</tt>
9153 field in the <file>.changes</file> file for the upload. See
9154 <ref id="pkg-f-Urgency">. It is not possible to specify an
9155 urgency containing commas; commas are used to separate
9156 <tt><var>keyword</var>=<var>value</var></tt> settings in
9157 the <prgn>dpkg</prgn> changelog format (though there is
9158 currently only one useful <var>keyword</var>,
9163 The change details may in fact be any series of lines
9164 starting with at least two spaces, but conventionally each
9165 change starts with an asterisk and a separating space and
9166 continuation lines are indented so as to bring them in
9167 line with the start of the text above. Blank lines may be
9168 used here to separate groups of changes, if desired.
9172 The maintainer name and email address should <em>not</em>
9173 necessarily be those of the usual package maintainer.
9174 They should be the details of the person doing
9175 <em>this</em> version. The information here will be
9176 copied to the <file>.changes</file> file, and then later used
9177 to send an acknowledgement when the upload has been
9182 The <var>date</var> should be in RFC822 format
9185 This is generated by the <prgn>822-date</prgn>
9188 </footnote>; it should include the timezone specified
9189 numerically, with the timezone name or abbreviation
9190 optionally present as a comment.
9194 The first "title" line with the package name should start
9195 at the left hand margin; the "trailer" line with the
9196 maintainer and date details should be preceded by exactly
9197 one space. The maintainer details and the date must be
9198 separated by exactly two spaces.
9202 An Emacs mode for editing this format is available: it is
9203 called <tt>debian-changelog-mode</tt>. You can have this
9204 mode selected automatically when you edit a Debian
9205 changelog by adding a local variables clause to the end of
9209 <sect2><heading>Defining alternative changelog formats
9213 It is possible to use a different format to the standard
9214 one, by providing a parser for the format you wish to
9219 In order to have <tt>dpkg-parsechangelog</tt> run your
9220 parser, you must include a line within the last 40 lines
9221 of your file matching the Perl regular expression:
9222 <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt> The part in
9223 parentheses should be the name of the format. For
9224 example, you might say:
9226 @@@ changelog-format: joebloggs @@@
9228 Changelog format names are non-empty strings of alphanumerics.
9232 If such a line exists then <tt>dpkg-parsechangelog</tt>
9233 will look for the parser as
9234 <file>/usr/lib/dpkg/parsechangelog/<var>format-name</var></file>
9236 <file>/usr/local/lib/dpkg/parsechangelog/<var>format-name</var></file>;
9237 it is an error for it not to find it, or for it not to
9238 be an executable program. The default changelog format
9239 is <tt>dpkg</tt>, and a parser for it is provided with
9240 the <tt>dpkg</tt> package.
9244 The parser will be invoked with the changelog open on
9245 standard input at the start of the file. It should read
9246 the file (it may seek if it wishes) to determine the
9247 information required and return the parsed information
9248 to standard output in the form of a series of control
9249 fields in the standard format. By default it should
9250 return information about only the most recent version in
9251 the changelog; it should accept a
9252 <tt>-v<var>version</var></tt> option to return changes
9253 information from all versions present <em>strictly
9254 after</em> <var>version</var>, and it should then be an
9255 error for <var>version</var> not to be present in the
9261 <list compact="compact">
9263 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9266 <p><qref id="versions"><tt>Version</tt></qref> (mandatory)</p>
9270 <qref id="pkg-f-Distribution"><tt>Distribution</tt></qref>
9275 <p><qref id="pkg-f-Urgency"><tt>Urgency</tt></qref> (mandatory)</p>
9279 <qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref>
9284 <p><qref id="pkg-f-Date"><tt>Date</tt></qref></p>
9288 <qref id="pkg-f-Changes"><tt>Changes</tt></qref>
9295 If several versions are being returned (due to the use
9296 of <tt>-v</tt>), the urgency value should be of the
9297 highest urgency code listed at the start of any of the
9298 versions requested followed by the concatenated
9299 (space-separated) comments from all the versions
9300 requested; the maintainer, version, distribution and
9301 date should always be from the most recent version.
9305 For the format of the <tt>Changes</tt> field see <ref
9306 id="pkg-f-Changes">.
9310 If the changelog format which is being parsed always or
9311 almost always leaves a blank line between individual
9312 change notes these blank lines should be stripped out,
9313 so as to make the resulting output compact.
9317 If the changelog format does not contain date or package
9318 name information this information should be omitted from
9319 the output. The parser should not attempt to synthesise
9320 it or find it from other sources.
9324 If the changelog does not have the expected format the
9325 parser should exit with a nonzero exit status, rather
9326 than trying to muddle through and possibly generating
9331 A changelog parser may not interact with the user at
9335 <sect1 id="pkg-srcsubstvars"><heading><file>debian/substvars</file>
9336 and variable substitutions
9340 When <prgn>dpkg-gencontrol</prgn>,
9341 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
9342 generate control files they do variable substitutions on
9343 their output just before writing it. Variable
9344 substitutions have the form
9345 <tt>${<var>variable-name</var>}</tt>. The optional file
9346 <file>debian/substvars</file> contains variable substitutions
9347 to be used; variables can also be set directly from
9348 <file>debian/rules</file> using the <tt>-V</tt> option to the
9349 source packaging commands, and certain predefined
9350 variables are available.
9354 The is usually generated and modified dynamically by
9355 <file>debian/rules</file> targets; in this case it must be
9356 removed by the <tt>clean</tt> target.
9360 See <manref name="dpkg-source" section="1"> for full
9361 details about source variable substitutions, including the
9362 format of <file>debian/substvars</file>.</p>
9365 <sect1><heading><file>debian/files</file>
9369 This file is not a permanent part of the source tree; it
9370 is used while building packages to record which files are
9371 being generated. <prgn>dpkg-genchanges</prgn> uses it
9372 when it generates a <file>.changes</file> file.
9376 It should not exist in a shipped source package, and so it
9377 (and any backup files or temporary files such as
9378 <file>files.new</file>
9381 <file>files.new</file> is used as a temporary file by
9382 <prgn>dpkg-gencontrol</prgn> and
9383 <prgn>dpkg-distaddfile</prgn> - they write a new
9384 version of <file>files</file> here before renaming it,
9385 to avoid leaving a corrupted copy if an error
9388 </footnote>) should be removed by the
9389 <tt>clean</tt> target. It may also be wise to
9390 ensure a fresh start by emptying or removing it at the
9391 start of the <tt>binary</tt> target.
9395 <prgn>dpkg-gencontrol</prgn> adds an entry to this file
9396 for the <file>.deb</file> file that will be created by
9397 <prgn>dpkg-deb</prgn> from the control file that it
9398 generates, so for most packages all that needs to be done
9399 with this file is to delete it in <tt>clean</tt>.
9403 If a package upload includes files besides the source
9404 package and any binary packages whose control files were
9405 made with <prgn>dpkg-gencontrol</prgn> then they should be
9406 placed in the parent of the package's top-level directory
9407 and <prgn>dpkg-distaddfile</prgn> should be called to add
9408 the file to the list in <file>debian/files</file>.</p>
9411 <sect1><heading><file>debian/tmp</file>
9415 This is the canonical temporary location for the
9416 construction of binary packages by the <tt>binary</tt>
9417 target. The directory <file>tmp</file> serves as the root of
9418 the filesystem tree as it is being constructed (for
9419 example, by using the package's upstream makefiles install
9420 targets and redirecting the output there), and it also
9421 contains the <tt>DEBIAN</tt> subdirectory. See <ref
9422 id="pkg-bincreating">.
9426 If several binary packages are generated from the same
9427 source tree it is usual to use several
9428 <file>debian/tmp<var>something</var></file> directories, for
9429 example <file>tmp-a</file> or <file>tmp-doc</file>.
9433 Whatever <file>tmp</file> directories are created and used by
9434 <tt>binary</tt> must of course be removed by the
9435 <tt>clean</tt> target.</p></sect1>
9439 <sect id="pkg-sourcearchives"><heading>Source packages as archives
9443 As it exists on the FTP site, a Debian source package
9444 consists of three related files. You must have the right
9445 versions of all three to be able to use them.
9450 <tag>Debian source control file - <tt>.dsc</tt></tag>
9454 This file contains a series of fields, identified and
9455 separated just like the fields in the control file of
9456 a binary package. The fields are listed below; their
9457 syntax is described above, in <ref id="pkg-controlfields">.
9458 <list compact="compact">
9460 <p><qref id="pkg-f-Source"><tt>Source</tt></qref></p>
9463 <p><qref id="versions"><tt>Version</tt></qref></p>
9466 <p><qref id="pkg-f-Maintainer"><tt>Maintainer</tt></qref></p>
9469 <p><qref id="pkg-f-Binary"><tt>Binary</tt></qref></p>
9472 <p><qref id="pkg-f-Architecture"><tt>Architecture</tt></qref></p>
9476 <qref id="relationships"><tt>Build-Depends</tt> et
9477 al.</qref> (source package interrelationships)
9482 <qref id="pkg-f-Standards-Version"><tt>Standards-Version</tt></qref></p>
9485 <p><qref id="pkg-f-Files"><tt>Files</tt></qref></p>
9490 The source package control file is generated by
9491 <prgn>dpkg-source</prgn> when it builds the source
9492 archive, from other files in the source package,
9493 described above. When unpacking it is checked against
9494 the files and directories in the other parts of the
9495 source package, as described below.</p>
9499 Original source archive -
9501 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
9508 This is a compressed (with <tt>gzip -9</tt>)
9509 <prgn>tar</prgn> file containing the source code from
9510 the upstream authors of the program. The tarfile
9511 unpacks into a directory
9512 <file><var>package</var>-<var>upstream-version</var>.orig</file>,
9513 and does not contain files anywhere other than in
9514 there or in its subdirectories.</p>
9518 Debianisation diff -
9520 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
9526 This is a unified context diff (<tt>diff -u</tt>)
9527 giving the changes which are required to turn the
9528 original source into the Debian source. These changes
9529 may only include editing and creating plain files.
9530 The permissions of files, the targets of symbolic
9531 links and the characteristics of special files or
9532 pipes may not be changed and no files may be removed
9537 All the directories in the diff must exist, except the
9538 <file>debian</file> subdirectory of the top of the source
9539 tree, which will be created by
9540 <prgn>dpkg-source</prgn> if necessary when unpacking.
9544 The <prgn>dpkg-source</prgn> program will
9545 automatically make the <file>debian/rules</file> file
9546 executable (see below).</p></item>
9551 If there is no original source code - for example, if the
9552 package is specially prepared for Debian or the Debian
9553 maintainer is the same as the upstream maintainer - the
9554 format is slightly different: then there is no diff, and the
9556 <file><var>package</var>_<var>version</var>.tar.gz</file> and
9557 contains a directory
9558 <file><var>package</var>-<var>version</var></file>.
9562 <sect><heading>Unpacking a Debian source package without
9563 <prgn>dpkg-source</prgn>
9567 <tt>dpkg-source -x</tt> is the recommended way to unpack a
9568 Debian source package. However, if it is not available it
9569 is possible to unpack a Debian source archive as follows:
9570 <enumlist compact="compact">
9573 Untar the tarfile, which will create a <file>.orig</file>
9577 <p>Rename the <file>.orig</file> directory to
9578 <file><var>package</var>-<var>version</var></file>.</p>
9582 Create the subdirectory <file>debian</file> at the top of
9583 the source tree.</p>
9585 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
9587 <item><p>Untar the tarfile again if you want a copy of the original
9588 source code alongside the Debianised version.</p>
9593 It is not possible to generate a valid Debian source archive
9594 without using <prgn>dpkg-source</prgn>. In particular,
9595 attempting to use <prgn>diff</prgn> directly to generate the
9596 <file>.diff.gz</file> file will not work.
9599 <sect1><heading>Restrictions on objects in source packages
9603 The source package may not contain any hard links
9606 This is not currently detected when building source
9607 packages, but only when extracting
9613 Hard links may be permitted at some point in the
9614 future, but would require a fair amount of
9617 </footnote>, device special files, sockets or setuid or
9621 Setgid directories are allowed.
9627 The source packaging tools manage the changes between the
9628 original and Debianised source using <prgn>diff</prgn> and
9629 <prgn>patch</prgn>. Turning the original source tree as
9630 included in the <file>.orig.tar.gz</file> into the debianised
9631 source must not involve any changes which cannot be
9632 handled by these tools. Problematic changes which cause
9633 <prgn>dpkg-source</prgn> to halt with an error when
9634 building the source package are:
9635 <list compact="compact">
9636 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
9638 <item><p>Changing the targets of symbolic links.</p>
9640 <item><p>Creating directories, other than <file>debian</file>.</p>
9642 <item><p>Changes to the contents of binary files.</p></item>
9643 </list> Changes which cause <prgn>dpkg-source</prgn> to
9644 print a warning but continue anyway are:
9645 <list compact="compact">
9648 Removing files, directories or symlinks.
9651 Renaming a file is not treated specially - it is
9652 seen as the removal of the old file (which
9653 generates a warning, but is otherwise ignored),
9654 and the creation of the new
9661 Changed text files which are missing the usual final
9662 newline (either in the original or the modified
9667 Changes which are not represented, but which are not detected by
9668 <prgn>dpkg-source</prgn>, are:
9669 <list compact="compact">
9670 <item><p>Changing the permissions of files (other than
9671 <file>debian/rules</file>) and directories.</p></item>
9676 The <file>debian</file> directory and <file>debian/rules</file>
9677 are handled specially by <prgn>dpkg-source</prgn> - before
9678 applying the changes it will create the <file>debian</file>
9679 directory, and afterwards it will make
9680 <file>debian/rules</file> world-exectuable.
9686 <appendix id="pkg-controlfields"><heading>Control files and their
9687 fields (from old Packaging Manual)
9691 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
9692 data in a common format, known as control files. Binary and
9693 source packages have control data as do the <file>.changes</file>
9694 files which control the installation of uploaded files, and
9695 <prgn>dpkg</prgn>'s internal databases are in a similar
9699 <sect><heading>Syntax of control files
9703 A file consists of one or more paragraphs of fields. The
9704 paragraphs are separated by blank lines. Some control files
9705 only allow one paragraph; others allow several, in which
9706 case each paragraph often refers to a different package.
9710 Each paragraph is a series of fields and values; each field
9711 consists of a name, followed by a colon and the value. It
9712 ends at the end of the line. Horizontal whitespace (spaces
9713 and tabs) may occur before or after the value and is ignored
9714 there; it is conventional to put a single space after the
9719 Some fields' values may span several lines; in this case
9720 each continuation line <em>must</em> start with a space or
9721 tab. Any trailing spaces or tabs at the end of individual
9722 lines of a field value are ignored.
9726 Except where otherwise stated only a single line of data is
9727 allowed and whitespace is not significant in a field body.
9728 Whitespace may never appear inside names (of packages,
9729 architectures, files or anything else), version numbers or
9730 in between the characters of multi-character version
9735 Field names are not case-sensitive, but it is usual to
9736 capitalise the field names using mixed case as shown below.
9740 Blank lines, or lines consisting only of spaces and tabs,
9741 are not allowed within field values or between fields - that
9742 would mean a new paragraph.
9746 It is important to note that there are several fields which
9747 are optional as far as <prgn>dpkg</prgn> and the related
9748 tools are concerned, but which must appear in every Debian
9749 package, or whose omission may cause problems. When writing
9750 the control files for Debian packages you <em>must</em> read
9751 the Debian policy manual in conjuction with the details
9752 below and the list of fields for the particular file.</p>
9755 <sect><heading>List of fields
9758 <sect1 id="pkg-f-Package"><heading><tt>Package</tt>
9762 The name of the binary package. Package names consist of
9763 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
9764 (plus, minus and full stop).
9767 The characters <tt>@</tt> <tt>:</tt> <tt>=</tt>
9768 <tt>%</tt> <tt>_</tt> (at, colon, equals, percent
9769 and underscore) used to be legal and are still
9770 accepted when found in a package file, but may not be
9771 used in new packages
9777 They must be at least two characters and must start with
9778 an alphanumeric. In current versions of dpkg they are
9779 sort of case-sensitive<footnote><p>This is a
9780 bug.</p></footnote>; use lowercase package names unless
9781 the package you're building (or referring to, in other
9782 fields) is already using uppercase.</p>
9785 <sect1 id="pkg-f-Version"><heading><tt>Version</tt>
9789 This lists the source or binary package's version number -
9790 see <ref id="versions">.
9795 <sect1 id="pkg-f-Architecture"><heading><tt>Architecture</tt>
9799 This is the architecture string; it is a single word for
9800 the Debian architecture.
9804 <prgn>dpkg</prgn> will check the declared architecture of
9805 a binary package against its own compiled-in value before
9810 The special value <tt>all</tt> indicates that the package
9811 is architecture-independent.
9815 In the main <file>debian/control</file> file in the source
9816 package, or in the source package control file
9817 <file>.dsc</file>, a list of architectures (separated by
9818 spaces) is also allowed, as is the special value
9819 <tt>any</tt>. A list indicates that the source will build
9820 an architecture-dependent package, and will only work
9821 correctly on the listed architectures. <tt>any</tt>
9822 indicates that though the source package isn't dependent
9823 on any particular architecture and should compile fine on
9824 any one, the binary package(s) produced are not
9825 architecture-independent but will instead be specific to
9826 whatever the current build architecture is.
9830 In a <file>.changes</file> file the <tt>Architecture</tt>
9831 field lists the architecture(s) of the package(s)
9832 currently being uploaded. This will be a list; if the
9833 source for the package is being uploaded too the special
9834 entry <tt>source</tt> is also present.
9838 See <ref id="pkg-debianrules"> for information how to get the
9839 architecture for the build process.
9843 <sect1 id="pkg-f-Maintainer"><heading><tt>Maintainer</tt>
9847 The package maintainer's name and email address. The name
9848 should come first, then the email address inside angle
9849 brackets <tt><></tt> (in RFC822 format).
9853 If the maintainer's name contains a full stop then the
9854 whole field will not work directly as an email address due
9855 to a misfeature in the syntax specified in RFC822; a
9856 program using this field as an address must check for this
9857 and correct the problem if necessary (for example by
9858 putting the name in round brackets and moving it to the
9859 end, and bringing the email address forward).
9863 In a <file>.changes</file> file or parsed changelog data this
9864 contains the name and email address of the person
9865 responsible for the particular version in question - this
9866 may not be the package's usual maintainer.
9870 This field is usually optional in as far as the
9871 <prgn>dpkg</prgn> are concerned, but its absence when
9872 building packages usually generates a warning.</p>
9875 <sect1 id="pkg-f-Source"><heading><tt>Source</tt>
9879 This field identifies the source package name.
9883 In a main source control information or a
9884 <file>.changes</file> or <file>.dsc</file> file or parsed
9885 changelog data this may contain only the name of the
9890 In the control file of a binary package (or in a
9891 <file>Packages</file> file) it may be followed by a version
9892 number in parentheses.
9895 It is usual to leave a space after the package name if
9896 a version number is specified.
9898 </footnote> This version number may be omitted (and is, by
9899 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
9900 the <tt>Version</tt> field of the binary package in
9901 question. The field itself may be omitted from a binary
9902 package control file when the source package has the same
9903 name and version as the binary package.
9907 <sect1><heading>Package interrelationship fields:
9908 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
9909 <tt>Recommends</tt> <tt>Suggests</tt>, <tt>Conflicts</tt>,
9910 <tt>Provides</tt>, <tt>Replaces</tt>
9914 These fields describe the package's relationships with
9915 other packages. Their syntax and semantics are described
9916 in <ref id="relationships">.</p>
9919 <sect1 id="pkg-f-Description"><heading><tt>Description</tt>
9923 In a binary package <tt>Packages</tt> file or main source
9924 control file this field contains a description of the
9925 binary package, in a special format. See <ref
9926 id="descriptions"> for details.
9930 In a <file>.changes</file> file it contains a summary of the
9931 descriptions for the packages being uploaded. The part of
9932 the field before the first newline is empty; thereafter
9933 each line has the name of a binary package and the summary
9934 description line from that binary package. Each line is
9935 indented by one space.</p>
9938 <sect1 id="pkg-f-Essential"><heading><tt>Essential</tt>
9942 This is a boolean field which may occur only in the
9943 control file of a binary package (or in the
9944 <file>Packages</file> file) or in a per-package fields
9945 paragraph of a main source control data file.
9949 If set to <tt>yes</tt> then <prgn>dpkg</prgn> and
9950 <prgn>dselect</prgn> will refuse to remove the package
9951 (though it can be upgraded and/or replaced). The other
9952 possible value is <tt>no</tt>, which is the same as not
9953 having the field at all.</p>
9956 <sect1 id="pkg-f-classification"><heading><tt>Section</tt> and
9961 These two fields classify the package. The
9962 <tt>Priority</tt> represents how important that it is that
9963 the user have it installed; the <tt>Section</tt>
9964 represents an application area into which the package has
9969 When they appear in the <file>debian/control</file> file these
9970 fields give values for the section and priority subfields
9971 of the <tt>Files</tt> field of the <file>.changes</file> file,
9972 and give defaults for the section and priority of the
9977 The section and priority are represented, though not as
9978 separate fields, in the information for each file in the
9979 <qref id="pkg-f-Files"><tt>-File</tt></qref>field of a
9980 <file>.changes</file> file. The section value in a
9981 <file>.changes</file> file is used to decide where to install
9982 a package in the FTP archive.
9986 These fields are not used by by <prgn>dpkg</prgn> proper,
9987 but by <prgn>dselect</prgn> when it sorts packages and
9988 selects defaults. See the Debian policy manual for the
9989 priorities in use and the criteria for selecting the
9990 priority for a Debian package, and look at the Debian FTP
9991 archive for a list of currently in-use priorities.
9995 These fields may appear in binary package control files,
9996 in which case they provide a default value in case the
9997 <file>Packages</file> files are missing the information.
9998 <prgn>dpkg</prgn> and <prgn>dselect</prgn> will only use
9999 the value from a <file>.deb</file> file if they have no other
10000 information; a value listed in a <file>Packages</file> file
10001 will always take precedence. By default
10002 <prgn>dpkg-gencontrol</prgn> does not include the section
10003 and priority in the control file of a binary package - use
10004 the <tt>-isp</tt>, <tt>-is</tt> or <tt>-ip</tt> options to
10005 achieve this effect.</p>
10008 <sect1 id="pkg-f-Binary"><heading><tt>Binary</tt>
10012 This field is a list of binary packages.
10016 When it appears in the <file>.dsc</file> file it is the list
10017 of binary packages which a source package can produce. It
10018 does not necessarily produce all of these binary packages
10019 for every architecture. The source control file doesn't
10020 contain details of which architectures are appropriate for
10021 which of the binary packages.
10025 When it appears in a <file>.changes</file> file it lists the
10026 names of the binary packages actually being uploaded.
10030 The syntax is a list of binary packages separated by
10034 A space after each comma is conventional.
10036 </footnote> Currently the packages must be separated using
10037 only spaces in the <file>.changes</file> file.</p>
10040 <sect1 id="pkg-f-Installed-Size"><heading><tt>Installed-Size</tt>
10044 This field appears in the control files of binary
10045 packages, and in the <file>Packages</file> files. It gives
10046 the total amount of disk space required to install the
10051 The disk space is represented in kilobytes as a simple
10052 decimal number.</p>
10055 <sect1 id="pkg-f-Files"><heading><tt>Files</tt>
10059 This field contains a list of files with information about
10060 each one. The exact information and syntax varies with
10061 the context. In all cases the the part of the field
10062 contents on the same line as the field name is empty. The
10063 remainder of the field is one line per file, each line
10064 being indented by one space and containing a number of
10065 sub-fields separated by spaces.
10069 In the <file>.dsc</file> (Debian source control) file each
10070 line contains the MD5 checksum, size and filename of the
10071 tarfile and (if applicable) diff file which make up the
10072 remainder of the source package.
10075 That is, the parts which are not the
10078 </footnote> The exact forms of the filenames are described
10079 in <ref id="pkg-sourcearchives">.
10083 In the <file>.changes</file> file this contains one line per
10084 file being uploaded. Each line contains the MD5 checksum,
10085 size, section and priority and the filename. The section
10086 and priority are the values of the corresponding fields in
10087 the main source control file - see <ref
10088 id="pkg-f-classification">. If no section or priority is
10089 specified then <tt>-</tt> should be used, though section
10090 and priority values must be specified for new packages to
10091 be installed properly.
10095 The special value <tt>byhand</tt> for the section in a
10096 <tt>.changes</tt> file indicates that the file in question
10097 is not an ordinary package file and must by installed by
10098 hand by the distribution maintainers. If the section is
10099 <tt>byhand</tt> the priority should be <tt>-</tt>.
10103 If a new Debian revision of a package is being shipped and
10104 no new original source archive is being distributed the
10105 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
10106 entry for the original source archive
10107 <file><var>package</var>-<var>upstream-version</var>.orig.tar.gz</file>,
10108 but the <file>.changes</file> file should leave it out. In
10109 this case the original source archive on the distribution
10110 site must match exactly, byte-for-byte, the original
10111 source archive which was used to generate the
10112 <file>.dsc</file> file and diff which are being uploaded.</p>
10117 id="pkg-f-Standards-Version"><heading><tt>Standards-Version</tt>
10121 The most recent version of the standards (the
10122 <prgn>dpkg</prgn> programmers' and policy manuals and
10123 associated texts) with which the package complies. This
10124 is updated manually when editing the source package to
10125 conform to newer standards; it can sometimes be used to
10126 tell when a package needs attention.
10130 Its format is the same as that of a version number except
10131 that no epoch or Debian revision is allowed - see <ref
10132 id="versions">.</p>
10136 <sect1 id="pkg-f-Distribution"><heading><tt>Distribution</tt>
10140 In a <file>.changes</file> file or parsed changelog output
10141 this contains the (space-separated) name(s) of the
10142 distribution(s) where this version of the package should
10143 be or was installed. Distribution names follow the rules
10144 for package names. (See <ref id="pkg-f-Package">).
10148 Current distribution values are:
10150 <tag><em>stable</em></tag>
10153 This is the current "released" version of Debian
10154 GNU/Linux. A new version is released approximately
10155 every 3 months after the <em>development</em> code has
10156 been <em>frozen</em> for a month of testing. Once the
10157 distribution is <em>stable</em> only major bug fixes
10158 are allowed. When changes are made to this
10159 distribution, the release number is increased
10160 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
10164 <tag><em>unstable</em></tag>
10167 This distribution value refers to the
10168 <em>developmental</em> part of the Debian distribution
10169 tree. New packages, new upstream versions of packages
10170 and bug fixes go into the <em>unstable</em> directory
10171 tree. Download from this distribution at your own
10175 <tag><em>contrib</em></tag>
10178 The packages with this distribution value do not meet
10179 the criteria for inclusion in the main Debian
10180 distribution as defined by the Policy Manual, but meet
10181 the criteria for the <em>contrib</em>
10182 Distribution. There is currently no distinction
10183 between stable and unstable packages in the
10184 <em>contrib</em> or <em>non-free</em>
10185 distributions. Use your best judgement in downloading
10186 from this Distribution.</p>
10189 <tag><em>non-free</em></tag>
10192 Like the packages in the <em>contrib</em> seciton,
10193 the packages in <em>non-free</em> do not meet the
10194 criteria for inclusion in the main Debian distribution
10195 as defined by the Policy Manual. Again, use your best
10196 judgement in downloading from this Distribution.</p>
10198 <tag><em>experimental</em></tag>
10201 The packages with this distribution value are deemed
10202 by their maintainers to be high risk. Oftentimes they
10203 represent early beta or developmental packages from
10204 various sources that the maintainers want people to
10205 try, but are not ready to be a part of the other parts
10206 of the Debian distribution tree. Download at your own
10210 <tag><em>frozen</em></tag>
10213 From time to time, (currently, every 3 months) the
10214 <em>unstable</em> distribution enters a state of
10215 "code-freeze" in anticipation of release as a
10216 <em>stable</em> version. During this period of testing
10217 (usually 4 weeks) only fixes for existing or
10218 newly-discovered bugs will be allowed.
10221 </taglist> You should list <em>all</em> distributions that
10222 the package should be installed into. Except in unusual
10223 circumstances, installations to <em>stable</em> should also
10224 go into <em>frozen</em> (if it exists) and
10225 <em>unstable</em>. Likewise, installations into
10226 <em>frozen</em> should also go into <em>unstable</em>.</p>
10229 <sect1 id="pkg-f-Urgency"><heading><tt>Urgency</tt>
10233 This is a description of how important it is to upgrade to
10234 this version from previous ones. It consists of a single
10235 keyword usually taking one of the values <tt>LOW</tt>,
10236 <tt>MEDIUM</tt> or <tt>HIGH</tt>) followed by an optional
10237 commentary (separated by a space) which is usually in
10238 parentheses. For example:
10240 Urgency: LOW (HIGH for diversions users)
10245 This field appears in the <file>.changes</file> file and in
10246 parsed changelogs; its value appears as the value of the
10247 <tt>urgency</tt> attribute in a <prgn>dpkg</prgn>-style
10248 changelog (see <ref id="pkg-dpkgchangelog">).
10252 Urgency keywords are not case-sensitive.</p>
10255 <sect1 id="pkg-f-Date"><heading><tt>Date</tt>
10259 In <tt>.changes</tt> files and parsed changelogs, this
10260 gives the date the package was built or last edited.</p>
10263 <sect1 id="pkg-f-Format"><heading><tt>Format</tt>
10267 This field occurs in <file>.changes</file> files, and
10268 specifies a format revision for the file. The format
10269 described here is version <tt>1.5</tt>. The syntax of the
10270 format value is the same as that of a package version
10271 number except that no epoch or Debian revision is allowed
10272 - see <ref id="versions">.</p>
10275 <sect1 id="pkg-f-Changes"><heading><tt>Changes</tt>
10279 In a <file>.changes</file> file or parsed changelog this field
10280 contains the human-readable changes data, describing the
10281 differences between the last version and the current one.
10285 There should be nothing in this field before the first
10286 newline; all the subsequent lines must be indented by at
10287 least one space; blank lines must be represented by a line
10288 consiting only of a space and a full stop.
10292 Each version's change information should be preceded by a
10293 "title" line giving at least the version, distribution(s)
10294 and urgency, in a human-readable way.
10298 If data from several versions is being returned the entry
10299 for the most recent version should be returned first, and
10300 entries should be separated by the representation of a
10301 blank line (the "title" line may also be followed by the
10302 representation of blank line).</p>
10305 <sect1 id="pkg-f-Filename"><heading><tt>Filename</tt> and
10306 <tt>MSDOS-Filename</tt>
10310 These fields in <tt>Packages</tt> files give the
10311 filename(s) of (the parts of) a package in the
10312 distribution directories, relative to the root of the
10313 Debian hierarchy. If the package has been split into
10314 several parts the parts are all listed in order, separated
10318 <sect1 id="pkg-f-Size"><heading><tt>Size</tt> and <tt>MD5sum</tt>
10322 These fields in <file>Packages</file> files give the size (in
10323 bytes, expressed in decimal) and MD5 checksum of the
10324 file(s) which make(s) up a binary package in the
10325 distribution. If the package is split into several parts
10326 the values for the parts are listed in order, separated by
10330 <sect1 id="pkg-f-Status"><heading><tt>Status</tt>
10334 This field in <prgn>dpkg</prgn>'s status file records
10335 whether the user wants a package installed, removed or
10336 left alone, whether it is broken (requiring
10337 reinstallation) or not and what its current state on the
10338 system is. Each of these pieces of information is a
10342 <sect1 id="pkg-f-Config-Version"><heading><tt>Config-Version</tt>
10346 If a package is not installed or not configured, this
10347 field in <prgn>dpkg</prgn>'s status file records the last
10348 version of the package which was successfully
10352 <sect1 id="pkg-f-Conffiles"><heading><tt>Conffiles</tt>
10356 This field in <prgn>dpkg</prgn>'s status file contains
10357 information about the automatically-managed configuration
10358 files held by a package. This field should <em>not</em>
10359 appear anywhere in a package!</p>
10362 <sect1><heading>Obsolete fields
10366 These are still recognised by <prgn>dpkg</prgn> but should
10367 not appear anywhere any more.
10368 <taglist compact="compact">
10370 <tag><tt>Revision</tt></tag>
10371 <tag><tt>Package-Revision</tt></tag>
10372 <tag><tt>Package_Revision</tt></tag>
10375 The Debian revision part of the package version was
10376 at one point in a separate control file field. This
10377 field went through several names.</p>
10380 <tag><tt>Recommended</tt></tag>
10381 <item><p>Old name for <tt>Recommends</tt></p>
10384 <tag><tt>Optional</tt></tag>
10385 <item><p>Old name for <tt>Suggests</tt>.</p>
10387 <tag><tt>Class</tt></tag>
10388 <item><p>Old name for <tt>Priority</tt>.</p>
10396 <appendix id="pkg-conffiles"><heading>Configuration file handling
10397 (from old Packaging Manual)
10401 <prgn>dpkg</prgn> can do a certain amount of automatic
10402 handling of package configuration files.
10406 Whether this mechanism is appropriate depends on a number of
10407 factors, but basically there are two approaches to any
10408 particular configuration file.
10412 The easy method is to ship a best-effort configuration in the
10413 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
10414 handle updates. If the user is unlikely to want to edit the
10415 file, but you need them to be able to without losing their
10416 changes, and a new package with a changed version of the file
10417 is only released infrequently, this is a good approach.
10421 The hard method is to build the configuration file from
10422 scratch in the <prgn>postinst</prgn> script, and to take the
10423 responsibility for fixing any mistakes made in earlier
10424 versions of the package automatically. This will be
10425 appropriate if the file is likely to need to be different on
10429 <sect><heading>Automatic handling of configuration files by
10434 A package may contain a control area file called
10435 <tt>conffiles</tt>. This file should be a list of filenames
10436 of configuration files needing automatic handling, separated
10437 by newlines. The filenames should be absolute pathnames,
10438 and the files referred to should actually exist in the
10443 When a package is upgraded <prgn>dpkg</prgn> will process
10444 the configuration files during the configuration stage,
10445 shortly before it runs the package's <prgn>postinst</prgn>
10450 For each file it checks to see whether the version of the
10451 file included in the package is the same as the one that was
10452 included in the last version of the package (the one that is
10453 being upgraded from); it also compares the version currently
10454 installed on the system with the one shipped with the last
10459 If neither the user nor the package maintainer has changed
10460 the file, it is left alone. If one or the other has changed
10461 their version, then the changed version is preferred - i.e.,
10462 if the user edits their file, but the package maintainer
10463 doesn't ship a different version, the user's changes will
10464 stay, silently, but if the maintainer ships a new version
10465 and the user hasn't edited it the new version will be
10466 installed (with an informative message). If both have
10467 changed their version the user is prompted about the problem
10468 and must resolve the differences themselves.
10472 The comparisons are done by calculating the MD5 message
10473 digests of the files, and storing the MD5 of the file as it
10474 was included in the most recent version of the package.
10478 When a package is installed for the first time
10479 <prgn>dpkg</prgn> will install the file that comes with it,
10480 unless that would mean overwriting a file already on the
10485 However, note that <prgn>dpkg</prgn> will <em>not</em>
10486 replace a conffile that was removed by the user (or by a
10487 script). This is necessary because with some programs a
10488 missing file produces an effect hard or impossible to
10489 achieve in another way, so that a missing file needs to be
10490 kept that way if the user did it.
10494 Note that a package should <em>not</em> modify a
10495 <prgn>dpkg</prgn>-handled conffile in its maintainer
10496 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
10497 the user confusing and possibly dangerous options for
10498 conffile update when the package is upgraded.</p>
10501 <sect><heading>Fully-featured maintainer script configuration
10506 For files which contain site-specific information such as
10507 the hostname and networking details and so forth, it is
10508 better to create the file in the package's
10509 <prgn>postinst</prgn> script.
10513 This will typically involve examining the state of the rest
10514 of the system to determine values and other information, and
10515 may involve prompting the user for some information which
10516 can't be obtained some other way.
10520 When using this method there are a couple of important
10521 issues which should be considered:
10525 If you discover a bug in the program which generates the
10526 configuration file, or if the format of the file changes
10527 from one version to the next, you will have to arrange for
10528 the postinst script to do something sensible - usually this
10529 will mean editing the installed configuration file to remove
10530 the problem or change the syntax. You will have to do this
10531 very carefully, since the user may have changed the file,
10532 perhaps to fix the very problem that your script is trying
10533 to deal with - you will have to detect these situations and
10534 deal with them correctly.
10538 If you do go down this route it's probably a good idea to
10539 make the program that generates the configuration file(s) a
10540 separate program in <file>/usr/sbin</file>, by convention called
10541 <file><var>package</var>config</file> and then run that if
10542 appropriate from the post-installation script. The
10543 <tt><var>package</var>config</tt> program should not
10544 unquestioningly overwrite an existing configuration - if its
10545 mode of operation is geared towards setting up a package for
10546 the first time (rather than any arbitrary reconfiguration
10547 later) you should have it check whether the configuration
10548 already exists, and require a <tt>--force</tt> flag to
10549 overwrite it.</p></sect>
10552 <appendix id="pkg-alternatives"><heading>Alternative versions of
10553 an interface - <prgn>update-alternatives</prgn> (from old
10558 When several packages all provide different versions of the
10559 same program or file it is useful to have the system select a
10560 default, but to allow the system administrator to change it
10561 and have their decisions respected.
10565 For example, there are several versions of the <prgn>vi</prgn>
10566 editor, and there is no reason to prevent all of them from
10567 being installed at once, each under their own name
10568 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
10569 Nevertheless it is desirable to have the name <tt>vi</tt>
10570 refer to something, at least by default.
10574 If all the packages involved cooperate, this can be done with
10575 <prgn>update-alternatives</prgn>.
10579 Each package provides its own version under its own name, and
10580 calls <prgn>update-alternatives</prgn> in its postinst to
10581 register its version (and again in its prerm to deregister
10586 See the manpage <manref name="update-alternatives"
10587 section="8"> for details.
10591 If <prgn>update-alternatives</prgn> does not seem appropriate
10592 you may wish to consider using diversions instead.</p>
10595 <appendix id="pkg-diversions"><heading>Diversions - overriding a
10596 package's version of a file (from old Packaging Manual)
10600 It is possible to have <prgn>dpkg</prgn> not overwrite a file
10601 when it reinstalls the package it belongs to, and to have it
10602 put the file from the package somewhere else instead.
10606 This can be used locally to override a package's version of a
10607 file, or by one package to override another's version (or
10608 provide a wrapper for it).
10612 Before deciding to use a diversion, read <ref
10613 id="pkg-alternatives"> to see if you really want a diversion
10614 rather than several alternative versions of a program.
10618 There is a diversion list, which is read by <prgn>dpkg</prgn>,
10619 and updated by a special program <prgn>dpkg-divert</prgn>.
10620 Please see <manref name="dpkg-divert" section="8"> for full
10621 details of its operation.
10625 When a package wishes to divert a file from another, it should
10626 call <prgn>dpkg-divert</prgn> in its preinst to add the
10627 diversion and rename the existing file. For example,
10628 supposing that a <prgn>smailwrapper</prgn> package wishes to
10629 install a wrapper around <file>/usr/sbin/smail</file>:
10631 if [ install = "$1" ]; then
10632 dpkg-divert --package smailwrapper --add --rename \
10633 --divert /usr/sbin/smail.real /usr/sbin/smail
10635 </example> Testing <tt>$1</tt> is necessary so that the script
10636 doesn't try to add the diversion again when
10637 <prgn>smailwrapper</prgn> is upgraded. The <tt>--package
10638 smailwrapper</tt> ensures that <prgn>smailwrapper</prgn>'s
10639 copy of <file>/usr/sbin/smail</file> can bypass the diversion and
10640 get installed as the true version.
10644 The postrm has to do the reverse:
10646 if [ remove = "$1" ]; then
10647 dpkg-divert --package smailwrapper --remove --rename \
10648 --divert /usr/sbin/smail.real /usr/sbin/smail
10654 Do not attempt to divert a file which is vitally important for
10655 the system's operation - when using <prgn>dpkg-divert</prgn>
10656 there is a time, after it has been diverted but before
10657 <prgn>dpkg</prgn> has installed the new version, when the file
10658 does not exist.</p>
10663 <!-- vim:set ai et sts=2 sw=2 tw=76: -->