1 <!doctype debiandoc system [
2 <!-- include version information so we don't have to hard code it
3 within the document -->
4 <!entity % versiondata SYSTEM "version.ent"> %versiondata;
8 Debian GNU/Linux Policy Manual.
9 Copyright (C)1996,1997,1998 Ian Jackson and Christian Schwarz;
10 released under the terms of the GNU
11 General Public License, version 2 or (at your option) any later.
12 Initial version 1996, Ian Jackson, ijackson@gnu.ai.mit.edu
13 Revised November 27, 1996, David A. Morris, bweaver@debian.org
14 New sections March 15, 1997, Christian Schwarz, schwarz@debian.org
15 Reworked/Restructured April-July 1997, Christian Schwarz, schwarz@debian.org
16 Maintainer since 1997, Christian Schwarz, schwarz@debian.org
17 Christoph Lameter contributed the "Web Standard"
18 The debian-policy mailing list has taken responsibility for the
19 contents of this document since September 1998, with the package
20 maintainers responsible for packaging administrivia only.
25 <title>Debian Policy Manual</title>
27 <name>Ian Jackson </name>
28 <email>ijackson@gnu.ai.mit.edu</email>
31 <name>Christian Schwarz</name>
32 <email>schwarz@debian.org</email>
35 <name>revised: David A. Morris</name>
36 <email>bweaver@debian.org</email>
39 <name>The Debian Policy mailing List</name>
40 <email>debian-policy@lists.debian.org</email>
42 <version>version &version;, &date;</version>
45 This manual describes the policy requirements for the Debian
46 GNU/Linux distribution. This includes the structure and
47 contents of the Debian archive, several design issues of the
48 operating system, as well as technical requirements that each
49 package must satisfy to be included in the distribution. The
50 policy package itself is maintained by a group of maintainers
51 that have no editorial powers. At the moment, the list of
55 <p>Michael Alan Dorman <email>mdorman@debian.org</email></p>
58 <p>Richard Braakman <email>dark@xs4all.nl</email></p>
61 <p>Philip Hands <email>phil@hands.com</email></p>
64 <p>Julian Gilbey <email>J.D.Gilbey@qmw.ac.uk</email></p>
67 <p>Manoj Srivastava <email>srivasta@debian.org</email></p>
75 Copyright ©1996,1997,1998 Ian Jackson
76 and Christian Schwarz.
79 This manual is free software; you may redistribute it and/or
80 modify it under the terms of the GNU General Public License
81 as published by the Free Software Foundation; either version
82 2, or (at your option) any later version.
86 This is distributed in the hope that it will be useful, but
87 <em>without any warranty</em>; without even the implied
88 warranty of merchantability or fitness for a particular
89 purpose. See the GNU General Public License for more
94 A copy of the GNU General Public License is available as
95 <tt>/usr/share/common-licences/GPL</tt> in the Debian GNU/Linux
96 distribution or on the World Wide Web at
97 <url id="http://www.gnu.org/copyleft/gpl.html"
98 name="The GNU Public Licence">. You can also obtain it by writing to the
99 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
100 Boston, MA 02111-1307, USA.
108 <heading>About this manual</heading>
110 <heading>Scope</heading>
112 This manual describes the policy requirements for the Debian
113 GNU/Linux distribution. This includes the structure and
114 contents of the Debian archive, several design issues of the
115 operating system, as well as technical requirements that
116 each package must satisfy to be included in the
122 This manual also describes Debian policy as it relates to
123 creating Debian packages. It is not a tutorial on how to build
124 packages, nor is it exhaustive where it comes to describing
125 the behavior of the packaging system. Instead, this manual
126 attempts to define the interface to the package management
127 system that the developers have to be conversant with.
130 Informally, the criteria used for inclusion is that the
131 material meet one of the following requirements:
133 <tag>Standard interfaces</tag>
136 The material presented represents an interface to
137 the packaging system that is mandated for use, and
138 is used by, a significant number of packages, and
139 should not be changed without peer review. Package
140 maintainers can then rely on this interfaces not
141 changing, and the package management software
142 authors need to ensure compatibility with these
143 interface definitions. (control file and and
144 changelog file formats are one example)
147 <tag>Chosen Convention</tag>
150 If there are a number of technically viable choices
151 that can be made, but one needs to select one of
152 these options for inter-operability. The version
153 number format is one example.
157 Please note that these are not mutually exclusive;
158 selected conventions often become parts of standard
165 Please note that the footnotes present in this manual are
166 merely informative, and are not part of Debian policy itself.
171 In this manual, the words <em>must</em>, <em>should</em> and
172 <em>may</em>, and the adjectives <em>required</em>,
173 <em>recommended</em> and <em>optional</em>, are used to
174 distinguish the significance of the various guidelines in
175 this policy document. Packages that do not conform the the
176 guidelines denoted by <em>must</em> (or <em>required</em>)
177 will generally not be considered acceptable for the Debian
178 distribution. Non-conformance with guidelines denoted by
179 <em>should</em> (or <em>recommended</em>) will generally be
180 considered a bug, but will not necessarily render a package
181 unsuitable for distribution. Guidelines denoted by
182 <em>may</em> (or <em>optional</em>) are truly optional and
183 adherence is left to the maintainer's discretion.
186 These classifications are roughly equivalent to the bug
187 severities <em>important</em> (for <em>must</em> or
188 <em>required</em> directive violations), <em>normal</em>
189 (for <em>should</em> or <em>recommended</em> directive
190 violations) and <em>wishlist</em> (for <em>optional</em>
192 <p>Also see RFC 2119.</p>
196 Much of the information presented in this manual will be
197 useful even when building a package which is to be
198 distributed in some other way or is for local use.
202 <heading>New versions of this document</heading>
204 The current version of this document is always accessible from the
205 Debian FTP server <ftpsite>ftp.debian.org</ftpsite> at
206 <ftppath>/debian/doc/package-developer/debian-policy.html.tar.gz</ftppath>
207 or from the Debian WWW server at
208 <url id="http://www.debian.org/doc/debian-policy/"
209 name="The Debian Policy Manual">.</p>
212 In addition, this manual is distributed via the Debian package
213 <tt>debian-policy</tt>.
217 <heading>Feedback</heading>
220 As the Debian GNU/Linux system is continuously evolving this
221 manual is changed from time to time.
224 While the authors of this document tried hard not to include
225 any typos or other errors these still occur. If you discover
226 an error in this manual or if you want to tell us any
227 comments, suggestions, or critics please send an email to
228 the Debian Policy List,
229 <email>debian-policy@lists.debian.org</email>, or submit a
230 bug report against the <tt>debian-policy</tt> package.
235 <heading>The Debian Archive</heading>
237 The Debian GNU/Linux system is maintained and distributed as a
238 collection of <em>packages</em>. Since there are so many of them (over
239 5000) they are split into <em>sections</em> and <em>priorities</em> to
240 simplify handling of them.
243 The effort of the Debian project is to build a free operating
244 system, but not every package we want to make accessible is
245 <em>free</em> in our sense (see Debian Free Software
246 Guidelines, below), or may be imported/exported without
247 restrictions. Thus, the archive is split into the sections
248 <em>main</em>, <em>non-free</em>, <em>contrib</em>,
249 <em>non-US/main</em>, <em>non-US/non-free</em>, and
250 <em>non-US/contrib</em>.</p>
253 The <em>main</em> and the <em>non-US/main</em> sections form
254 the <em>Debian GNU/Linux distribution</em>.
258 Packages in the other sections are not considered as part of
259 the Debian distribution, though we support their use, and we
260 provide infrastructure for them (such as our bug-tracking
261 system and mailing lists). This Debian Policy Manual applies
262 to these packages as well.</p>
264 <sect id="pkgcopyright">
265 <heading>Package copyright and sections</heading>
267 The aims of this policy are:
269 <list compact="compact">
271 <p>We want to make as much software available as we
275 <p>We want to encourage everyone to write free software.</p>
278 <p> We want to make it easy for people to produce
279 CD-ROMs of our system without violating any licenses,
280 import/export restrictions, or any other laws.</p>
285 <heading>The Debian Free Software Guidelines</heading>
287 The Debian Free Software Guidelines (DFSG) is our
288 definition of `free' software.
290 <tag>Free Redistribution
294 The license of a Debian component may not restrict any
295 party from selling or giving away the software as a
296 component of an aggregate software distribution
297 containing programs from several different
298 sources. The license may not require a royalty or
299 other fee for such sale.
306 The program must include source code, and must allow
307 distribution in source code as well as compiled form.
314 The license must allow modifications and derived
315 works, and must allow them to be distributed under the
316 same terms as the license of the original software.
319 <tag>Integrity of The Author's Source Code
323 The license may restrict source-code from being
324 distributed in modified form <em>only</em> if the
325 license allows the distribution of ``patch files''
326 with the source code for the purpose of modifying the
327 program at build time. The license must explicitly
328 permit distribution of software built from modified
329 source code. The license may require derived works to
330 carry a different name or version number from the
331 original software. (This is a compromise. The Debian
332 group encourages all authors to not restrict any
333 files, source or binary, from being modified.)
336 <tag>No Discrimination Against Persons or Groups
340 The license must not discriminate against any person
344 <tag>No Discrimination Against Fields of Endeavor
348 The license must not restrict anyone from making use
349 of the program in a specific field of endeavor. For
350 example, it may not restrict the program from being
351 used in a business, or from being used for genetic
355 <tag>Distribution of License
359 The rights attached to the program must apply to all
360 to whom the program is redistributed without the need
361 for execution of an additional license by those
365 <tag>License Must Not Be Specific to Debian
369 The rights attached to the program must not depend on
370 the program's being part of a Debian system. If the
371 program is extracted from Debian and used or
372 distributed without Debian but otherwise within the
373 terms of the program's license, all parties to whom
374 the program is redistributed must have the same
375 rights as those that are granted in conjunction with
379 <tag>License Must Not Contaminate Other Software
383 The license must not place restrictions on other
384 software that is distributed along with the licensed
385 software. For example, the license must not insist
386 that all other programs distributed on the same medium
387 must be free software.
390 <tag>Example Licenses
394 The ``GPL,'' ``BSD,'' and ``Artistic'' licenses are
395 examples of licenses that we consider <em>free</em>.
402 <heading>The main section</heading>
404 Every package in "main" and "non-US/main" must comply with
405 the DFSG (Debian Free Software Guidelines).</p>
408 In addition, the packages in "main"
409 <list compact="compact">
412 must not require a package outside of "main" for
413 compilation or execution (thus, the package must not
414 declare a "Depends", "Recommends", or "Build-Depends"
415 relationship on a non-main package),
420 must not be so buggy that we refuse to support them,
425 must meet all policy requirements presented in this
432 Similarly, the packages in "non-US/main"
433 <list compact="compact">
436 must not require a package outside of "main" or
437 "non-US/main" for compilation or execution,
442 must not be so buggy that we refuse to support them,
447 must meet all policy requirements presented in this
455 <heading>The contrib section</heading>
457 Every package in "contrib" and "non-US/contrib" must
458 comply with the DFSG.
462 Examples of packages which would be included in "contrib"
463 or "non-US/contrib" are
464 <list compact="compact">
467 free packages which require "contrib", "non-free"
468 packages or packages which are not in our
469 archive at all for compilation or execution,
474 wrapper packages or other sorts of free accessories for
482 <heading>The non-free section and non-US/non-free </heading>
484 Packages must be placed in "non-free" or "non-US/non-free"
485 if they are not compliant with the DFSG or are encumbered
486 by patents or other legal issues that make their
487 distribution problematic.
491 <heading>The non-US sections</heading>
493 Some programs with cryptographic program code need to be stored
494 on the "non-US" server because of export restrictions of the
495 U.S. Such programs must be distributed in the appropriate
496 non-US section, either non-US/main, non-US/contrib or
497 non-US/non-free. </p>
499 This applies only to packages which contain cryptographic
500 code. A package containing a program with an interface to a
501 cryptographic program or a program that's dynamically linked
502 against a cryptographic library should not be distributed
503 via the non-us server if it is capable of running without the
504 cryptography library or program.
508 <heading>Further copyright considerations</heading>
510 Every package must be accompanied by a verbatim copy of its
511 copyright and distribution license in the file
512 /usr/share/doc/<package-name>/copyright (see
513 <ref id="copyrightfile"> for details).</p>
515 We reserve the right to restrict files from being included
516 anywhere in our archives if
517 <list compact="compact">
520 their use or distribution would break a law,
525 there is an ethical conflict in their distribution or
531 we would have to sign a license for them, or
536 their distribution would conflict with other project
544 Programs whose authors encourage the user to make donations
545 are fine for the main distribution, provided that the
546 authors do not claim that not donating is immoral,
547 unethical, illegal or something similar; otherwise they must
551 Packages whose copyright permission notices (or patent
552 problems) do not allow redistribution even of only binaries,
553 and where no special permission has been obtained, must not be
554 placed on the Debian FTP site and its mirrors at all.</p>
557 Note, that under international copyright law (this applies
558 in the United States, too) <em>no</em> distribution or
559 modification of a work is allowed without an explicit notice
560 saying so. Therefore a program without a copyright notice
561 <em>is</em> copyrighted and you may not do anything to it
562 without risking being sued! Likewise if a program has a
563 copyright notice but no statement saying what is permitted
564 then nothing is permitted.</p>
567 Many authors are unaware of the problems that restrictive
568 copyrights (or lack of copyright notices) can cause for the
569 users of their supposedly-free software. It is often
570 worthwhile contacting such authors diplomatically to ask
571 them to modify their license terms. However, this is a
572 politically difficult thing to do and you should ask for
573 advice on <tt>debian-legal</tt> first.</p>
576 When in doubt, send mail to
577 <email>debian-legal@lists.debian.org</email>. Be prepared
578 to provide us with the copyright statement. Software
579 covered by the GPL, public domain software and BSD-like
580 copyrights are safe; be wary of the phrases `commercial use
581 prohibited' and `distribution restricted'.</p>
584 <heading>Subsections</heading>
587 The packages in all the sections (<em>main</em>,
588 <em>contrib</em>, <em>non-US/main</em>, <em>non-free</em>,
589 <em>non-US/contrib</em>, and <em>non-US/non-free</em>) are
590 grouped further into <em>subsections</em> to simplify
594 The section for each package should be specified in the
595 package's <em>control record</em>. However, the maintainer of
596 the Debian archive may override this selection to assure the
597 consistency of the Debian distribution. </p>
600 Please check the current Debian distribution to see which
601 sections are available.</p>
604 <heading>Priorities</heading>
607 Each package should have a <em>priority</em> value,
608 which is included in the package's <em>control
609 record</em>. This information is used in the Debian package
610 management tool to separate high-priority packages from
611 less-important packages.</p>
614 The following <em>priority levels</em> are supported by the
615 Debian package management system, <prgn>dpkg</prgn>.
617 <tag><tt>required</tt></tag>
620 <tt>required</tt> packages are necessary for the
621 proper functioning of the system. You must not remove
622 these packages or your system may become totally
623 broken and you may not even be able to use
624 <prgn>dpkg</prgn> to put things back. Systems with
625 only the <tt>required</tt> packages are probably
626 unusable, but they do have enough functionality to
627 allow the sysadmin to boot and install more
630 <tag><tt>important</tt></tag>
633 Important programs, including those which one would
634 expect to find on any Unix-like system. If the
635 expectation is that an experienced Unix person who
636 found it missing would say `What the F*!@<+ is
637 going on, where is <prgn>foo</prgn>', it must be in
638 <tt>important</tt>. This is an important criterion
639 because we are trying to produce, amongst other
640 things, a free Unix. Other packages without which the
641 system will not run well or be usable must also be
642 here. This does <em>not</em> include Emacs, the X
643 Window System, TeX or any other large applications.
644 The <tt>important</tt> packages are just a bare
645 minimum of commonly-expected and necessary tools.</p>
647 <tag><tt>standard</tt></tag>
650 These packages provide a reasonably small but not too
651 limited character-mode system. This is what will
652 install by default if the user doesn't select anything
653 else. It doesn't include many large applications, but
654 it does include Emacs (this is more of a piece of
655 infrastructure than an application) and a reasonable
656 subset of TeX and LaTeX (if this is possible without
659 <tag><tt>optional</tt></tag>
662 (In a sense everything is optional that isn't
663 required, but that's not what is meant here.) This is
664 all the software that you might reasonably want to
665 install if you didn't know what it was or don't have
666 specialized requirements. This is a much larger system
667 and includes the X Window System, a full TeX distribution,
668 and many applications. Note that optional packages should
669 not conflict with each other.
672 <tag><tt>extra</tt></tag>
675 This contains all packages that conflict with others
676 with required, important, standard or optional
677 priorities, or are only likely to be useful if you
678 already know what they are or have specialised
685 Packages must not depend on packages with lower priority
686 values (excluding build-time dependencies). In order to
687 ensure this, the priorities of one or more packages must
693 <heading>Binary packages</heading>
696 The Debian GNU/Linux distribution is based on the Debian
697 package management system, called <prgn>dpkg</prgn>. Thus,
698 all packages in the Debian distribution must be provided
699 in the <tt>.deb</tt> file format.</p>
703 <heading>The package name</heading>
706 Every package must have a name that's unique within the Debian
710 Package names must only consist of lower case letters, digits (0-9),
711 plus (+) or minus (-) signs, and periods (.).</p>
714 The package name is part of the file name of the
715 <tt>.deb</tt> file and is included in the control field
721 <heading>The maintainer of a package</heading>
724 Every package should have exactly one maintainer at a
725 time. This person is responsible that the license of the
726 package's software complies with the policy of the
727 distribution this package is included in.</p>
730 The maintainer must be specified in the
731 <tt>Maintainer</tt> control field with the correct name
732 and a working email address for the Debian maintainer of
733 the package. If one person maintains several packages
734 he/she should try to avoid having different forms of their
735 name and email address in different <tt>Maintainer</tt>
739 If the maintainer of a package quits from the Debian
740 project the Debian QA Group
741 <email>debian-qa@lists.debian.org</email> takes over the
742 maintainership of the package until someone else
743 volunteers for that task. These packages are called
744 <em>orphaned packages</em>.
750 <heading>The description of a package</heading>
753 Every Debian package must have an extended description
754 stored in the appropriate field of the control record.</p>
757 The description should be written so that it tells the user
758 what they need to know to decide whether to install the
759 package. This description should not just be copied from
760 the blurb for the program. Instructions for configuring
761 or using the package should not be included -- that is what
762 installation scripts, manual pages, Info files, etc. are
763 for. Copyright statements and other administrivia should
764 not be included -- that is what the copyright file is
770 <heading>Dependencies</heading>
773 Every package must specify the dependency information
774 about other packages that are required for the first to
778 For example, a dependency entry must be provided for any
779 shared libraries required by a dynamically-linked executable
780 binary in a package.</p>
783 Packages are not required to declare any dependencies they
784 have on other packages which are marked <tt>Essential</tt>
785 (see below), and should not do so unless they depend on a
786 particular version of that package.</p>
789 Sometimes, a package requires another package to be installed
790 <em>and</em> configured before it can be installed. In this
791 case, you must specify a <tt>Pre-Depends</tt> entry for
795 You should not specify a <tt>Pre-Depends</tt> entry for a
796 package before this has been discussed on the
797 <tt>debian-devel</tt> mailing list and a consensus about
798 doing that has been reached.</p></sect1>
802 <heading>Virtual packages</heading>
805 Sometimes, there are several packages doing more-or-less
806 the same job. In this case, it's useful to define a
807 <em>virtual package</em> whose name describes the function
808 the packages have. (The virtual packages just exist
809 logically, not physically--that's why they are called
810 <em>virtual</em>.) The packages with this particular
811 function will then <em>provide</em> the virtual
812 package. Thus, any other package requiring that function
813 can simply depend on the virtual package without having to
814 specify all possible packages individually.</p>
817 All packages should use virtual package names where
818 appropriate, and arrange to create new ones if necessary.
819 They should not use virtual package names (except privately,
820 amongst a cooperating group of packages) unless they have
821 been agreed upon and appear in the list of virtual package
825 The latest version of the authoritative list of virtual
826 package names can be found on
827 <ftpsite>ftp.debian.org</ftpsite> in
828 <ftppath>/debian/doc/package-developer/virtual-package-names-list.text</ftppath>
829 or your local mirror. In addition, it is included in the
830 <tt>debian-policy</tt> package. The procedure for updating
831 the list is described at the top of the file.</p></sect1>
835 <heading>Base packages</heading>
838 The packages included in the <tt>base</tt> section have a
839 special function. They form a minimum subset of the Debian
840 GNU/Linux system that is installed before everything else
841 on a new system. Thus, only very few packages are allowed
842 to go into the <tt>base</tt> section to keep the required
843 disk usage very small.</p>
846 Most of these packages will have the priority value
847 <tt>required</tt> or at least <tt>important</tt>, and many
848 of them will be tagged <tt>essential</tt> (see below).</p>
851 You must not place any packages into the <tt>base</tt>
852 section before this has been discussed on the
853 <tt>debian-devel</tt> mailing list and a consensus about
854 doing that has been reached.</p></sect1>
858 <heading>Essential packages</heading>
861 Some packages are tagged <tt>essential</tt>. (They have
862 <tt>Essential: yes</tt> in their package control record.)
863 This flag is used for packages that are <em>essential</em>
867 Since these packages can not easily be removed (you'll
868 have to specify an extra <em>force option</em> to
869 <prgn>dpkg</prgn>) this flag must not be used unless
870 absolutely necessary. A shared library package must not
871 be tagged <tt>essential</tt>--the dependencies will
872 prevent its premature removal, and we need to be able to
873 remove it when it has been superseded.
877 Since dpkg will not prevent upgrading of other packages
878 while an <tt>essential</tt> package is in an unconfigured
879 state, all <tt>essential</tt> packages must supply all
880 their core functionality even when unconfigured. If the
881 package cannot satisfy this requirement it must not be
882 tagged as essential, and any packages depending on this
883 package must instead have explicit dependency fields as
888 You must not tag any packages <tt>essential</tt> before
889 this has been discussed on the <tt>debian-devel</tt>
890 mailing and a consensus about doing that has been
895 <heading>Maintainer scripts</heading>
898 The package installation scripts should avoid producing
899 output which it is unnecessary for the user to see and
900 should rely on <prgn>dpkg</prgn> to stave off boredom on
901 the part of a user installing many packages. This means,
902 amongst other things, using the <tt>--quiet</tt> option on
903 <prgn>install-info</prgn>.</p>
906 Packages should try to minimize the amount of prompting
907 they need to do, and they should ensure that the user will
908 only ever be asked each question once. This means that
909 packages should try to use appropriate shared
910 configuration files (such as <tt>/etc/papersize</tt> and
911 <tt>/etc/news/server</tt>), rather than each prompting for
912 their own list of required pieces of information.</p>
915 It also means that an upgrade should not ask the same
916 questions again, unless the user has used <tt>dpkg
917 --purge</tt> to remove the package's configuration. The
918 answers to configuration questions should be stored in an
919 appropriate place in <tt>/etc</tt> so that the user can
920 modify them, and how this has been done should be
924 If a package has a vitally important piece of information
925 to pass to the user (such as "don't run me as I am, you
926 must edit the following configuration files first or you
927 risk your system emitting badly-formatted messages"), it
928 should display this in the <prgn>postinst</prgn> script
929 and prompt the user to hit return to acknowledge the
930 message. Copyright messages do not count as vitally
931 important (they belong in
932 <tt>/usr/share/doc/<var>package</var>/copyright</tt>); neither
933 do instructions on how to use a program (these should be
934 in on line documentation, where all the users can see
938 Any necessary prompting should almost always be confined
939 to the post-installation script, and should be protected
940 with a conditional so that unnecessary prompting doesn't
941 happen if a package's installation fails and the
942 <prgn>postinst</prgn> is called with
943 <tt>abort-upgrade</tt>, <tt>abort-remove</tt> or
944 <tt>abort-deconfigure</tt>.</p>
947 Errors which occur during the execution of an installation
948 script should be checked and the installation should not
949 continue after an error.</p>
952 Note, that <ref id="scripts">, in general applies to
953 package maintainer scripts, too.</p>
956 You should not use <prgn>dpkg-divert</prgn> on a file
957 belonging to another package without consulting the maintainer
958 of that package first.</p>
961 All packages which supply an instance of a common command
962 name (or, in general, filename) should generally use
963 <prgn>update-alternatives</prgn>, so that they may be
964 installed together. If <prgn>update-alternatives</prgn>
965 is not used, then each package must use <tt>Conflicts</tt>
966 to ensure that other packages are de-installed. (In this
967 case, it may be appropriate to specify a conflict against
968 earlier versions of something that previously did not use
969 <prgn>update-alternatives</prgn> -- this is an exception to
970 the usual rule that this not allowed).
975 <heading>Source packages</heading>
978 <heading>Standards conformance</heading>
981 You should specify the most recent version of the
982 packaging standards with which your package complies in
983 the source package's <tt>Standards-Version</tt> field.</p>
986 This value will be used to file bug reports automatically
987 if your package becomes too much out of date.</p>
990 The value corresponds to a version of the Debian manuals,
991 as can be found on the title page or page headers and
992 footers (depending on the format).</p>
995 The version number has four components--major and minor
996 number and major and minor patch level. When the
997 standards change in a way that requires every package to
998 change the major number will be changed. Significant
999 changes that will require work in many packages will be
1000 signaled by a change to the minor number. The major patch
1001 level will be changed for any change to the meaning of the
1002 standards, however small; the minor patch level will be
1003 changed when only cosmetic, typographical or other edits
1004 which do not change the meaning are made, or changes which
1005 do not affect the contents of packages.</p>
1008 For package maintainers, only the first 3 digits of the
1009 manual version are significant in representing the
1010 <em>Standards-Version</em>, and either these 3 digits or
1011 the complete 4 digits may be specified.
1014 In the past, people specified 4 digits in the
1015 Standards-Version field, like `2.3.0.0'. Since any
1016 `patch-level changes' don't introduce new policy, it
1017 was thought it would be better to relax policy and
1018 only require that the first 3 digits are specified. (4
1019 digits may still be used if someone wants to do so.)
1025 You should regularly, and especially if your package has
1026 become out of date, check for the newest Policy Manual
1027 available and update your package, if necessary. When your
1028 package complies with the new standards you should update the
1029 <tt>Standards-Version</tt> source package field and
1030 release it.</p></sect1>
1034 <heading>Package relationships</heading>
1037 Source packages should specify which binary packages they
1038 require to be installed or not to be installed in order to
1039 build correctly. For example, if building a package
1040 requires a certain compiler, then the compiler should be
1041 specified as a build-time dependency.
1045 It is not necessary to explicitly specify build-time
1046 relationships on a minimal set of packages that are always
1047 needed to compile, link and put in a Debian package a
1048 standard "Hello World!" program written in C or C++. The
1049 required packages are called <em>build-essential</em>, and
1050 an informational list can be found in
1051 <tt>/usr/share/doc/build-essential/list</tt> (which is
1052 contained in the <tt>build-essential</tt>
1058 <p>This allows maintaining the list separately
1059 from the policy documents (the list does not
1060 need the kind of control that the policy
1066 Having a separate package allows one to nistall
1067 the build essential packages on a machine, as
1068 well as allowing other packages (think task
1069 packages) to bring in the build-essential
1070 packages using the depends relation
1075 The separate package allows bug reports against
1076 the package to be categorized separately from
1077 the policy management process that uses the BTS
1087 When specifying the set of build-time dependencies, one
1088 should list only those packages explicitly required by the
1089 build. It is not necessary to list packages which are
1090 required merely because some other package in the list of
1091 build-time dependencies depends on them. The reason is
1092 that dependencies change, and you should list only those
1093 <em>you</em> need. What others need is their business.
1097 If build-time dependencies are specified, it must be
1098 possible to build the package and produce working binaries
1099 on a system with the build-essential packages installed
1100 and satisfying the build-time relationships (including any
1101 implied relationships). This
1102 means in particular that version clauses should be used
1103 rigorously in build-time relationships so that one cannot
1104 produce bad or inconsistently configured packages when the
1105 relationships are properly satisfied.
1109 <heading>Changes to the upstream sources</heading>
1112 If changes to the source code are made that are generally
1113 applicable, they should be sent to the upstream authors
1114 in whatever form they prefer so as to be included in the
1115 upstream version of the package.</p>
1118 If you need to configure the package differently for
1119 Debian or for Linux, and the upstream source doesn't
1120 provide a way to configure it the way you need to, you
1121 should add such configuration facilities (for example, a new
1122 <prgn>autoconf</prgn> test or <tt>#define</tt>) and send
1123 the patch to the upstream authors, with the default set to
1124 the way they originally had it. You can then easily
1125 override the default in your <tt>debian/rules</tt> or
1126 wherever is appropriate.</p>
1129 You should make sure that the <prgn>configure</prgn> utility
1130 detects the correct architecture specification string
1131 (refer to <ref id="arch-spec"> for details).</p>
1134 If you need to edit a <prgn>Makefile</prgn> where
1135 GNU-style <prgn>configure</prgn> scripts are used, you
1136 should edit the <tt>.in</tt> files rather than editing the
1137 <prgn>Makefile</prgn> directly. This allows the user to
1138 reconfigure the package if necessary. You should
1139 <em>not</em> configure the package and edit the generated
1140 <prgn>Makefile</prgn>! This makes it impossible for
1141 someone else to later reconfigure the package.</p></sect1>
1145 <heading>Documenting your changes</heading>
1148 You should document your changes and updates to the source
1149 package properly in the <tt>debian/changelog</tt> file. (Note
1150 that mistakes in changelogs are usually best rectified by
1151 making a new changelog entry rather than "rewriting history"
1152 by editing old changelog entries)</p>
1155 A copy of the file which will be installed in
1156 <tt>/usr/share/doc/<var>package</var>/copyright</tt> should be
1157 in <tt>debian/copyright</tt>.</p>
1160 In non-experimental packages you must only use a format for
1161 <tt>debian/changelog</tt> which is supported by the most
1162 recent released version of <prgn>dpkg</prgn>. If your
1163 format is not supported and there is general support for
1164 it you should contact the <prgn>dpkg</prgn> maintainer to
1165 have the parser script for your format included in the
1166 <prgn>dpkg</prgn> package. (You will need to agree that
1167 the parser and its manpage may be distributed under the
1168 GNU GPL, just as the rest of <prgn>dpkg</prgn>
1173 <heading>Error trapping in makefiles</heading>
1176 When <prgn>make</prgn> invokes a command in a makefile
1177 (including your package's upstream makefiles and the
1178 <tt>debian/rules</tt>) it does so using <tt>sh</tt>. This
1179 means that <tt>sh</tt>'s usual bad error handling
1180 properties apply: if you include a miniature script as one
1181 of the commands in your makefile you'll find that if you
1182 don't do anything about it then errors are not detected
1183 and <prgn>make</prgn> will blithely continue after
1187 Every time you put more than one shell command (this
1188 includes using a loop) in a makefile command you
1189 must make sure that errors are trapped. For
1190 simple compound commands, such as changing directory and
1191 then running a program, using <tt>&&</tt> rather
1192 than semicolon as a command separator is sufficient. For
1193 more complex commands including most loops and
1194 conditionals you should include a separate <tt>set -e</tt>
1195 command at the start of every makefile command that's
1196 actually one of these miniature shell scripts.</p></sect1>
1200 <heading>Obsolete constructs and libraries</heading>
1203 The include file <prgn><varargs.h></prgn> is
1204 provided to support end-users compiling very old software;
1205 the library <tt>libtermcap</tt> is provided to support the
1206 execution of software which has been linked against it
1207 (either old programs or those such as Netscape which are
1208 only available in binary form).</p>
1211 Debian packages should be ported to include
1212 <prgn><stdarg.h></prgn> and <tt>ncurses</tt> when
1218 <chapt id="controlfields"><heading>Control files and their fields</heading>
1221 Many of the tools in the package management suite manipulate
1222 data in a common format, known as control files. Binary and
1223 source packages have control data as do the <tt>.changes</tt>
1224 files which control the installation of uploaded files, and
1225 <prgn>dpkg</prgn>'s internal databases are in a similar
1229 <sect><heading>Syntax of control files</heading>
1232 A file consists of one or more paragraphs of fields. The
1233 paragraphs are separated by blank lines. Some control files
1234 only allow one paragraph; others allow several, in which
1235 case each paragraph often refers to a different package.
1239 Each paragraph is a series of fields and values; each field
1240 consists of a name, followed by a colon and the value. It
1241 ends at the end of the line. Horizontal whitespace (spaces
1242 and tabs) may occur immediately before or after the value
1243 and is ignored there; it is conventional to put a single
1244 space after the colon.
1248 Some fields' values may span several lines; in this case
1249 each continuation line <em>must</em> start with a space or
1250 tab. Any trailing spaces or tabs at the end of individual
1251 lines of a field value are ignored.
1255 Except where otherwise stated only a single line of data is
1256 allowed and whitespace is not significant in a field body.
1257 Whitespace may never appear inside names (of packages,
1258 architectures, files or anything else), version numbers or
1259 in between the characters of multi-character version
1264 Field names are not case-sensitive, but it is usual to
1265 capitalize the field names using mixed case as shown below.
1269 Blank lines, or lines consisting only of spaces and tabs,
1270 are not allowed within field values or between fields - that
1271 would mean a new paragraph.
1275 It is important to note that there are several fields which
1276 are optional as far as <prgn>dpkg</prgn> and the related
1277 tools are concerned, but which must appear in every Debian
1278 package, or whose omission may cause problems. When writing
1279 the control files for Debian packages you <em>must</em> read
1280 the Debian policy manual in conjunction with the details
1281 below and the list of fields for the particular file.</p>
1284 <sect><heading>List of fields</heading>
1286 This list here is not supposed to be exhaustive. Typically
1287 only fields for whom policy exists are mentioned here.
1289 <sect1 id="f-Package"><heading><tt>Package</tt>
1293 The name of the binary package. Package names consist of
1294 the alphanumerics and <tt>+</tt> <tt>-</tt> <tt>.</tt>
1295 (plus, minus and full stop).
1299 They must be at least two characters long and must start
1300 with an alphanumeric character. The use lowercase package
1301 names is strongly recommended unless the package you're
1302 building (or referring to, in other fields) is already
1303 using uppercase.</p>
1306 <sect1 id="f-Version"><heading><tt>Version</tt>
1310 This lists the source or binary package's version number -
1311 see <ref id="versions">.
1317 id="f-Standards-Version"><heading><tt>Standards-Version</tt>
1321 The most recent version of the standards (the packaging
1322 and policy manuals and associated texts) with which the
1323 package complies. This is updated manually when editing
1324 the source package to conform to newer standards; it can
1325 sometimes be used to tell when a package needs attention.
1329 Its format is the same as that of a version number except
1330 that no epoch or Debian revision is allowed - see <ref
1335 <sect1 id="f-Distribution"><heading><tt>Distribution</tt>
1339 In a <tt>.changes</tt> file or parsed changelog output
1340 this contains the (space-separated) name(s) of the
1341 distribution(s) where this version of the package should
1342 be or was installed. Distribution names follow the rules
1343 for package names. (See <ref id="f-Package">).
1348 Current distribution values are:
1350 <tag><em>stable</em></tag>
1353 This is the current `released' version of Debian
1355 distribution is <em>stable</em> only major bug fixes
1356 are allowed. When changes are made to this
1357 distribution, the release number is increased
1358 (for example: 1.2r1 becomes 1.2r2 then 1.2r3, etc).
1362 <tag><em>unstable</em></tag>
1365 This distribution value refers to the
1366 <em>developmental</em> part of the Debian
1367 distribution tree. New packages, new upstream
1368 versions of packages and bug fixes go into the
1369 <em>unstable</em> directory tree. Download from
1370 this distribution at your own risk.
1374 <tag><em>frozen</em></tag>
1377 From time to time, the <em>unstable</em>
1378 distribution enters a state of `code-freeze' in
1379 anticipation of release as a <em>stable</em>
1380 version. During this period of testing only
1381 fixes for existing or newly-discovered bugs will
1386 <tag><em>experimental</em></tag>
1389 The packages with this distribution value are deemed
1390 by their maintainers to be high risk. Oftentimes they
1391 represent early beta or developmental packages from
1392 various sources that the maintainers want people to
1393 try, but are not ready to be a part of the other parts
1394 of the Debian distribution tree. Download at your own
1399 There are several sections in each
1400 distribution. Currently, these sections are:
1403 <tag><em>contrib</em></tag>
1406 The packages in this section do not meet the
1407 criteria for inclusion in the main Debian
1408 distribution as defined by the Policy Manual,
1409 but are otherwise free, as defined by the Debian
1410 free software guidelines.</p>
1413 <tag><em>non-free</em></tag>
1416 Packages in <em>non-free</em> do not meet the
1417 criteria of free software, as defined by the
1418 Debian free software guidelines. Again, use your
1419 best judgment in downloading from this
1423 </taglist> You should list <em>all</em> distributions that
1424 the package should be installed into. Except in unusual
1425 circumstances, installations to <em>stable</em> should also
1426 go into <em>frozen</em> (if it exists) and
1427 <em>unstable</em>. Likewise, installations into
1428 <em>frozen</em> should also go into <em>unstable</em>.
1437 <chapt id="versions"><heading>Version numbering </heading>
1440 Every package has a version number, in its <tt>Version</tt>
1445 The package management system imposes an ordering on version
1446 numbers, so that it can tell whether packages are being up- or
1447 downgraded and so that package system front end applications
1448 can tell whether a package it finds available is newer than
1449 the one installed on the system. The version number format
1450 has the most significant parts (as far as comparison is
1451 concerned) at the beginning.
1455 The version number format is:
1456 &lsqb<var>epoch</var><tt>:</tt>]<var>upstream-version</var>[<tt>-/<var>debian-revision</var>].</tt>
1460 The three components here are:
1462 <tag><var>epoch</var></tag>
1466 This is a single (generally small) unsigned integer. It
1467 may be omitted, in which case zero is assumed. If it is
1468 omitted then the <var>upstream-version</var> may not
1473 It is provided to allow mistakes in the version numbers
1474 of older versions of a package, and also a package's
1475 previous version numbering schemes, to be left behind.
1480 <tag><var>upstream-version</var></tag>
1484 This is the main part of the version. It is usually
1485 version number of the original (`upstream') package of
1486 which the <tt>.deb</tt> file has been made, if this is
1487 applicable. Usually this will be in the same format as
1488 that specified by the upstream author(s); however, it
1489 may need to be reformatted to fit into the package
1490 management system's format and comparison scheme.
1494 The comparison behavior of the package management system
1495 with respect to the <var>upstream-version</var> is
1496 described below. The <var>upstream-version</var>
1497 portion of the version number is mandatory.
1501 The <var>upstream-version</var> may contain only
1502 alphanumerics and the characters <tt>.</tt> <tt>+</tt>
1503 <tt>-</tt> <tt>:</tt> (full stop, plus, hyphen, colon)
1504 and should start with a digit. If there is no
1505 <var>debian-revision</var> then hyphens are not allowed;
1506 if there is no <var>epoch</var> then colons are not
1510 <tag><var>debian-revision</var></tag>
1514 This part of the version represents the version of the
1515 modifications that were made to the package to make it a
1516 Debian binary package. It is in the same format as the
1517 <var>upstream-version</var> and is compared in the same
1522 It is optional; if it isn't present then the
1523 <var>upstream-version</var> may not contain a hyphen.
1524 This format represents the case where a piece of
1525 software was written specifically to be turned into a
1526 Debian binary package, and so there is only one
1527 `debianization' of it and therefore no revision
1528 indication is required.
1532 It is conventional to restart the
1533 <var>debian-revision</var> at <tt>1</tt> each time the
1534 <var>upstream-version</var> is increased.
1538 The package management system will break the
1539 <var>upstream-version</var> and
1540 <var>debian-revision</var> apart at the last hyphen in
1541 the string. The absence of a <var>debian-revision</var>
1542 compares earlier than the presence of one (but note that
1543 the <var>debian-revision</var> is the least significant
1544 part of the version number).
1548 The <var>debian-revision</var> may contain only
1549 alphanumerics and the characters <tt>+</tt> and
1550 <tt>.</tt> (plus and full stop).
1554 The <var>upstream-version</var> and <var>debian-revision</var>
1555 parts are compared by the package management system using the
1560 The strings are compared from left to right.
1564 First the initial part of each string consisting entirely of
1565 non-digit characters is determined. These two parts (one of
1566 which may be empty) are compared lexically. If a difference
1567 is found it is returned. The lexical comparison is a
1568 comparison of ASCII values modified so that all the letters
1569 sort earlier than all the non-letters.
1573 Then the initial part of the remainder of each string which
1574 consists entirely of digit characters is determined. The
1575 numerical values of these two parts are compared, and any
1576 difference found is returned as the result of the comparison.
1577 For these purposes an empty string (which can only occur at
1578 the end of one or both version strings being compared) counts
1583 These two steps are repeated (chopping initial non-digit
1584 strings and initial digit strings off from the start) until a
1585 difference is found or both strings are exhausted.
1589 Note that the purpose of epochs is to allow us to leave behind
1590 mistakes in version numbering, and to cope with situations
1591 where the version numbering changes. It is <em>not</em> there
1592 to cope with version numbers containing strings of letters
1593 which the package management system cannot interpret (such as
1594 <tt>ALPHA</tt> or <tt>pre-</tt>), or with silly orderings (the
1595 author of this manual has heard of a package whose versions
1596 went <tt>1.1</tt>, <tt>1.2</tt>, <tt>1.3</tt>, <tt>1</tt>,
1597 <tt>2.1</tt>, <tt>2.2</tt>, <tt>2</tt> and so forth).
1601 If an upstream package has problematic version numbers they
1602 should be converted to a sane form for use in the
1603 <tt>Version</tt> field.
1607 <heading>Version numbers based on dates</heading>
1609 In general, Debian packages should use the same version
1610 numbers as the upstream sources.</p>
1613 However, in some cases where the upstream version number is
1614 based on a date (e.g., a development `snapshot' release) the
1615 package management system cannot handle these version
1616 numbers without epochs. For example, dpkg will consider
1617 `96May01' to be greater than `96Dec24'.</p>
1620 To prevent having to use epochs for every new upstream
1621 version, the version number should be changed to the
1622 following format in such cases: `19960501', `19961224'. It
1623 is up to the maintainer whether he/she wants to bother the
1624 upstream maintainer to change the version numbers upstream,
1628 Note, that other version formats based on dates which are
1629 parsed correctly by the package management system should
1630 <em>not</em> be changed.</p>
1633 Native Debian packages (i.e., packages which have been
1634 written especially for Debian) whose version numbers include
1635 dates should always use the `YYYYMMDD' format.</p>
1639 <chapt id="miscellaneous"><heading>Packaging Considerations</heading>
1641 <sect id="timestamps"><heading>Time Stamps</heading>
1643 Maintainers are encouraged to preserve the modification
1644 times of the upstream source files in a package, as far as
1645 is reasonably possible. Even though this is optional, this
1646 is still a good idea.
1649 The rationale is that there is some information conveyed
1650 by knowing the age of the file, for example, you could
1651 recognize that some documentation is very old by looking
1652 at the modification time, so it would be nice if the
1653 modification time of the upstream source would be
1660 <sect id="debianrules"><heading><tt>debian/rules</tt> - the
1661 main building script </heading>
1664 This file must be an executable makefile, and contains the
1665 package-specific recipes for compiling the package and
1666 building binary package(s) out of the source.
1670 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1671 so that it can be invoked by saying its name rather than
1672 invoking <prgn>make</prgn> explicitly.
1676 Since an interactive <tt>debian/rules</tt> script makes it
1677 impossible to auto-compile that package and also makes it
1678 hard for other people to reproduce the same binary
1679 package, all <strong>required targets</strong> MUST be
1680 non-interactive. At a minimum, required targets are the
1681 ones called by <prgn>dpkg-buildpackage</prgn>, namely,
1682 <em>clean</em>, <em>binary</em>, <em>binary-arch</em>, and
1683 <em>build</em>. It also follows that any target that these
1684 targets depend on must also be non-interactive.
1688 The targets which must be present are:
1690 <tag><tt>build</tt></tag>
1693 This should perform all non-interactive
1694 configuration and compilation of the package. If a
1695 package has an interactive pre-build configuration
1696 routine, the Debianised source package should be
1697 built after this has taken place, so that it can be
1698 built without rerunning the configuration.
1702 For some packages, notably ones where the same
1703 source tree is compiled in different ways to produce
1704 two binary packages, the <prgn>build</prgn> target
1705 does not make much sense. For these packages it is
1706 good enough to provide two (or more) targets
1707 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1708 for each of the ways of building the package, and a
1709 <prgn>build</prgn> target that does nothing. The
1710 <prgn>binary</prgn> target will have to build the
1711 package in each of the possible ways and make the
1712 binary package out of each.
1716 The <prgn>build</prgn> target must not do anything
1717 that might require root privilege.
1721 The <prgn>build</prgn> target may need to run
1722 <prgn>clean</prgn> first - see below.
1726 When a package has a configuration routine that
1727 takes a long time, or when the makefiles are poorly
1728 designed, or when <prgn>build</prgn> needs to run
1729 <prgn>clean</prgn> first, it is a good idea to
1730 <tt>touch build</tt> when the build process is
1731 complete. This will ensure that if <tt>debian/rules
1732 build</tt> is run again it will not rebuild the
1737 <tag><tt>binary</tt>, <tt>binary-arch</tt>,
1738 <tt>binary-indep</tt>
1742 The <prgn>binary</prgn> target must be all that is
1743 necessary for the user to build the binary
1744 package. All these targets are required to be
1745 non-interactive. It is split into two parts:
1746 <prgn>binary-arch</prgn> builds the packages' output
1747 files which are specific to a particular
1748 architecture, and <prgn>binary-indep</prgn> builds
1749 those which are not.
1753 <prgn>binary</prgn> may be (and commonly is) a target
1754 with no commands which simply depends on
1755 <prgn>binary-arch</prgn> and
1756 <prgn>binary-indep</prgn>.
1760 Both <prgn>binary-*</prgn> targets should depend on
1761 the <prgn>build</prgn> target, above, so that the
1762 package is built if it has not been already. It
1763 should then create the relevant binary package(s),
1764 using <prgn>dpkg-gencontrol</prgn> to make their
1765 control files and <prgn>dpkg-deb</prgn> to build
1766 them and place them in the parent of the top level
1771 If one of the <prgn>binary-*</prgn> targets has
1772 nothing to do (this will be always be the case if
1773 the source generates only a single binary package,
1774 whether architecture-dependent or not) it
1775 <em>must</em> still exist, and must always
1780 The <prgn>binary</prgn> targets must be invoked as
1785 <tag><tt>clean</tt></tag>
1789 This must undo any effects that the
1790 <prgn>build</prgn> and <prgn>binary</prgn> targets
1791 may have had, except that it should leave alone any
1792 output files created in the parent directory by a
1793 run of <prgn>binary</prgn>. This target must be
1798 If a <prgn>build</prgn> file is touched at the end
1799 of the <prgn>build</prgn> target, as suggested
1800 above, it should be removed as the first thing that
1801 <prgn>clean</prgn> does, so that running
1802 <prgn>build</prgn> again after an interrupted
1803 <prgn>clean</prgn> doesn't think that everything is
1808 The <prgn>clean</prgn> target may need to be
1809 invoked as root if <prgn>binary</prgn> has been
1810 invoked since the last <prgn>clean</prgn>, or if
1811 <prgn>build</prgn> has been invoked as root (since
1812 <prgn>build</prgn> may create directories, for
1817 <tag><tt>get-orig-source</tt> (optional)</tag>
1821 This target fetches the most recent version of the
1822 original source package from a canonical archive site
1823 (via FTP or WWW, for example), does any necessary
1824 rearrangement to turn it into the original source
1825 tar file format described below, and leaves it in the
1830 This target may be invoked in any directory, and
1831 should take care to clean up any temporary files it
1836 This target is optional, but providing it if
1837 possible is a good idea.
1843 The <prgn>build</prgn>, <prgn>binary</prgn> and
1844 <prgn>clean</prgn> targets must be invoked with a current
1845 directory of the package's top-level directory.
1850 Additional targets may exist in <tt>debian/rules</tt>,
1851 either as published or undocumented interfaces or for the
1852 package's internal use.
1856 The architecture we build on and build for is determined by
1857 make variables via dpkg-architecture. You can get the Debian
1858 architecture and the GNU style architecture specification
1859 string for the build machine as well as the host
1860 machine. Here is a list of supported make variables:
1861 <list compact="compact">
1863 <p><tt>DEB_*_ARCH</tt> (the Debian architecture)</p>
1866 <p><tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
1867 specification string)</p>
1870 <p><tt>DEB_*_GNU_CPU</tt> (the CPU part of DEB_*_GNU_TYPE)</p>
1873 <p><tt>DEB_*_GNU_SYSTEM</tt> (the System part of
1879 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
1880 the build machine or <tt>HOST</tt> for specification of the machine
1885 Backward compatibility can be provided in the rules file
1886 by setting the needed variables to suitable default
1887 values, please refer to the documentation of
1888 dpkg-architecture for details.
1892 It is important to understand that the <tt>DEB_*_ARCH</tt>
1893 string does only determine which Debian architecture we
1894 build on resp. for. It should not be used to get the CPU
1895 or System information, the GNU style variables should be
1900 <sect id="dpkgchangelog"><heading><tt>debian/changelog</tt>
1904 This file records the changes to the Debian-specific parts of the
1908 Though there is nothing stopping an author who is also
1909 the Debian maintainer from using it for all their
1910 changes, it will have to be renamed if the Debian and
1911 upstream maintainers become different
1918 It has a special format which allows the package building
1919 tools to discover which version of the package is being
1920 built and find out other release-specific information.
1924 That format is a series of entries like this:
1926 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
1928 * <var>change details</var>
1929 <var>more change details</var>
1930 * <var>even more change details</var>
1932 -- <var>maintainer name and email address</var> <var>date</var>
1937 <var>package</var> and <var>version</var> are the source
1938 package name and version number.
1942 <var>distribution(s)</var> lists the distributions where
1943 this version should be installed when it is uploaded - it
1944 is copied to the <tt>Distribution</tt> field in the
1945 <tt>.changes</tt> file. See <ref id="f-Distribution">.
1949 <var>urgency</var> is the value for the <tt>Urgency</tt>
1950 field in the <tt>.changes</tt> file for the upload. It is
1951 not possible to specify an urgency containing commas; commas
1952 are used to separate
1953 <tt><var>keyword</var>=<var>value</var></tt> settings in the
1954 <prgn>dpkg</prgn> changelog format (though there is
1955 currently only one useful <var>keyword</var>,
1960 The change details may in fact be any series of lines
1961 starting with at least two spaces, but conventionally each
1962 change starts with an asterisk and a separating space and
1963 continuation lines are indented so as to bring them in
1964 line with the start of the text above. Blank lines may be
1965 used here to separate groups of changes, if desired.
1969 The maintainer name and email address need <em>not</em>
1970 necessarily be those of the usual package maintainer.
1971 They should be the details of the person doing
1972 <em>this</em> version. The information here will be
1973 copied to the <tt>.changes</tt> file, and then later used
1974 to send an acknowledgement when the upload has been
1979 The <var>date</var> should be in RFC822 format
1982 This is generated by the <prgn>822-date</prgn>
1985 </footnote>; it should include the time zone specified
1986 numerically, with the time zone name or abbreviation
1987 optionally present as a comment.
1991 The first `title' line with the package name should start
1992 at the left hand margin; the `trailer' line with the
1993 maintainer and date details should be preceded by exactly
1994 one space. The maintainer details and the date must be
1995 separated by exactly two spaces.
1998 <sect1><heading>Defining alternative changelog formats</heading>
2001 It is possible to use a different format to the standard
2002 one, by providing a parser for the format you wish to
2006 A changelog parser must not interact with the user at
2012 <sect id="srcsubstvars"><heading><tt>debian/substvars</tt>
2013 and variable substitutions </heading>
2016 When <prgn>dpkg-gencontrol</prgn>,
2017 <prgn>dpkg-genchanges</prgn> and <prgn>dpkg-source</prgn>
2018 generate control files they do variable substitutions on
2019 their output just before writing it. Variable
2020 substitutions have the form
2021 <tt>${<var>variable-name</var>}</tt>. The optional file
2022 <tt>debian/substvars</tt> contains variable substitutions
2023 to be used; variables can also be set directly from
2024 <tt>debian/rules</tt> using the <tt>-V</tt> option to the
2025 source packaging commands, and certain predefined
2026 variables are available.
2030 The is usually generated and modified dynamically by
2031 <tt>debian/rules</tt> targets; in this case it must be
2032 removed by the <prgn>clean</prgn> target.
2036 See <manref name="dpkg-source" section="1"> for full
2037 details about source variable substitutions, including the
2038 format of <tt>debian/substvars</tt>.</p>
2041 <sect id="debianfiles"><heading><tt>debian/files</tt>
2045 This file is not a permanent part of the source tree; it
2046 is used while building packages to record which files are
2047 being generated. <prgn>dpkg-genchanges</prgn> uses it
2048 when it generates a <tt>.changes</tt> file.
2052 It should not exist in a shipped source package, and so it
2053 (and any backup files or temporary files such as
2057 <tt>files.new</tt> is used as a temporary file by
2058 <prgn>dpkg-gencontrol</prgn> and
2059 <prgn>dpkg-distaddfile</prgn> - they write a new
2060 version of <tt>files</tt> here before renaming it,
2061 to avoid leaving a corrupted copy if an error
2064 </footnote>) should be removed by the
2065 <prgn>clean</prgn> target. It may also be wise to
2066 ensure a fresh start by emptying or removing it at the
2067 start of the <prgn>binary</prgn> target.
2071 <prgn>dpkg-gencontrol</prgn> adds an entry to this file
2072 for the <tt>.deb</tt> file that will be created by
2073 <prgn>dpkg-deb</prgn> from the control file that it
2074 generates, so for most packages all that needs to be done
2075 with this file is to delete it in <prgn>clean</prgn>.
2079 If a package upload includes files besides the source
2080 package and any binary packages whose control files were
2081 made with <prgn>dpkg-gencontrol</prgn> then they should be
2082 placed in the parent of the package's top-level directory
2083 and <prgn>dpkg-distaddfile</prgn> should be called to add
2084 the file to the list in <tt>debian/files</tt>.</p>
2087 <sect id="restrictions"><heading>Restrictions on objects in source packages
2091 The source package may not contain any hard links
2094 This is not currently detected when building source
2095 packages, but only when extracting
2101 Hard links may be permitted at some point in the
2102 future, but would require a fair amount of
2105 </footnote>, device special files, sockets or setuid or
2109 Setgid directories are allowed.
2114 <sect id="descriptions"><heading>Descriptions of packages - the
2115 <tt>Description</tt> field </heading>
2118 The description is intended to describe the program to a user
2119 who has never met it before so that they know whether they
2120 want to install it. It should also give information about the
2121 significant dependencies and conflicts between this package
2122 and others, so that the user knows why these dependencies and
2123 conflicts have been declared.
2126 <sect1><heading>Notes about writing descriptions
2130 The single line synopsis should be kept brief - certainly
2131 under 80 characters.
2135 Do not include the package name in the synopsis line. The
2136 display software knows how to display this already, and you
2137 do not need to state it. Remember that in many situations
2138 the user may only see the synopsis line - make it as
2139 informative as you can.
2143 Do not try to continue the single line synopsis into the
2144 extended description. This will not work correctly when
2145 the full description is displayed, and makes no sense
2146 where only the summary (the single line synopsis) is
2151 The extended description should describe what the package
2152 does and how it relates to the rest of the system (in terms
2153 of, for example, which subsystem it is which part of).
2157 The description field needs to make sense to anyone, even
2158 people who have no idea about any of the things the
2162 The blurb that comes with a program in its
2163 announcements and/or <prgn>README</prgn> files is
2164 rarely suitable for use in a description. It is
2165 usually aimed at people who are already in the
2166 community where the package is used.
2172 Put important information first, both in the synopsis and
2173 extended description. Sometimes only the first part of the
2174 synopsis or of the description will be displayed. You can
2175 assume that there will usually be a way to see the whole
2176 extended description.
2180 You may include information about dependencies and so forth
2181 in the extended description, if you wish.
2185 Do not use tab characters. Their effect is not predictable.
2193 <chapt id="maintainerscripts"><heading>Package maintainer scripts
2194 and installation procedure
2197 <sect><heading>Introduction to package maintainer scripts
2201 It is possible to supply scripts as part of a package which
2202 the package management system will run for you when your
2203 package is installed, upgraded or removed.
2207 These scripts should be the files <tt>preinst</tt>,
2208 <tt>postinst</tt>, <tt>prerm</tt> and <tt>postrm</tt> in the
2209 control area of the package. They must be proper executable
2210 files; if they are scripts (which is recommended) they must
2211 start with the usual <tt>#!</tt> convention. They should be
2212 readable and executable to anyone, and not world-writable.
2216 the package management system looks at the exit status from
2217 these scripts. It is important that they exit with a
2218 non-zero status if there is an error, so that the package
2219 management system can stop its processing. For shell
2220 scripts this means that you <em>almost always</em> need to
2221 use <tt>set -e</tt> (this is usually true when writing shell
2222 scripts, in fact). It is also important, of course, that
2223 they don't exit with a non-zero status if everything went
2228 It is necessary for the error recovery procedures that the
2229 scripts be idempotent: i.e., invoking the same script several
2230 times in the same situation should do no harm. If the first
2231 call failed, or aborted half way through for some reason,
2232 the second call should merely do the things that were left
2233 undone the first time, if any, and exit with a success
2238 When a package is upgraded a combination of the scripts from
2239 the old and new packages is called in amongst the other
2240 steps of the upgrade procedure. If your scripts are going
2241 to be at all complicated you need to be aware of this, and
2242 may need to check the arguments to your scripts.
2246 Broadly speaking the <prgn></prgn> is called before
2247 (a particular version of) a package is installed, and the
2248 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
2249 before (a version of) a package is removed and the
2250 <prgn>postrm</prgn> afterwards.
2253 next paragraph by Guy Maor to close bug #2481
2256 <p> Programs called from maintainer scripts should not
2257 normally have a path prepended to them. Before installation
2258 is started the package management system checks to see if
2259 the programs <prgn>ldconfig</prgn>,
2260 <prgn>start-stop-daemon</prgn>, <prgn>install-info</prgn>,
2261 and <prgn>update-rc.d</prgn> can be found via the
2262 <tt>PATH</tt> environment variable. Those programs, and any
2263 other program that one would expect to on the <tt>PATH</tt>,
2264 should thus be invoked without an absolute
2265 pathname. Maintainer scripts should also not reset the
2266 <tt>PATH</tt>, though they might choose to modify it by pre-
2267 or appending package-specific directories. These
2268 considerations really apply to all shell scripts.</p>
2271 <heading>Maintainer scripts Idempotency</heading>
2274 It is very important to make maintainer scripts
2278 That means that if it runs successfully or fails
2279 and then you call it again it doesn't bomb out,
2280 but just ensures that everything is the way it
2283 </footnote> This is so that if an error occurs, the
2284 user interrupts <prgn>dpkg</prgn> or some other
2285 unforeseen circumstance happens you don't leave the
2286 user with a badly-broken package.
2290 <heading>Controlling terminal for maintainer scripts</heading>
2293 The maintainer scripts are guaranteed to run with a
2294 controlling terminal and can interact with the user.
2295 If they need to prompt for passwords, do full-screen
2296 interaction or something similar you should do these
2297 things to and from <tt>/dev/tty</tt>, since
2298 <prgn>dpkg</prgn> will at some point redirect scripts'
2299 standard input and output so that it can log the
2300 installation process. Likewise, because these scripts
2301 may be executed with standard output redirected into a
2302 pipe for logging purposes, Perl scripts should set
2303 unbuffered output by setting <tt>$|=1</tt> so that the
2304 output is printed immediately rather than being
2309 Each script should return a zero exit status for
2310 success, or a nonzero one for failure.
2314 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
2319 <list compact="compact">
2321 <p><var>new-preinst</var> <tt>install</tt></p>
2324 <p><var>new-preinst</var> <tt>install</tt>
2325 <var>old-version</var></p>
2328 <p><var>new-preinst</var> <tt>upgrade</tt>
2329 <var>old-version</var></p>
2332 <p><var>old-preinst</var> <tt>abort-upgrade</tt>
2333 <var>new-version</var>
2339 <list compact="compact">
2341 <p><var>postinst</var> <tt>configure</tt>
2342 <var>most-recently-configured-version</var></p>
2345 <p><var>old-postinst</var> <tt>abort-upgrade</tt>
2346 <var>new version</var></p>
2349 <p><var>conflictor's-postinst</var> <tt>abort-remove</tt>
2350 <tt>in-favour</tt> <var>package</var>
2351 <var>new-version</var></p>
2355 <var>deconfigured's-postinst</var>
2356 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
2357 <var>failed-install-package</var> <var>version</var>
2358 <tt>removing</tt> <var>conflicting-package</var>
2365 <list compact="compact">
2367 <p><var>prerm</var> <tt>remove</tt></p>
2370 <p><var>old-prerm</var> <tt>upgrade</tt>
2371 <var>new-version</var></p>
2374 <p><var>new-prerm</var> <tt>failed-upgrade</tt>
2375 <var>old-version</var></p>
2378 <p><var>conflictor's-prerm</var> <tt>remove</tt>
2379 <tt>in-favour</tt> <var>package</var>
2380 <var>new-version</var></p>
2384 <var>deconfigured's-prerm</var> <tt>deconfigure</tt>
2385 <tt>in-favour</tt> <var>package-being-installed</var>
2386 <var>version</var> <tt>removing</tt>
2387 <var>conflicting-package</var>
2394 <list compact="compact">
2396 <p><var>postrm</var> <tt>remove</tt></p>
2399 <p><var>postrm</var> <tt>purge</tt></p>
2403 <var>old-postrm</var> <tt>upgrade</tt>
2404 <var>new-version</var></p>
2407 <p><var>new-postrm</var> <tt>failed-upgrade</tt>
2408 <var>old-version</var></p>
2411 <p><var>new-postrm</var> <tt>abort-install</tt></p>
2414 <p><var>new-postrm</var> <tt>abort-install</tt>
2415 <var>old-version</var></p>
2418 <p><var>new-postrm</var> <tt>abort-upgrade</tt>
2419 <var>old-version</var></p>
2423 <var>disappearer's-postrm</var> <tt>disappear</tt>
2424 <var>overwriter</var>
2425 <var>overwriter-version</var></p></item>
2430 <sect id="unpackphase"><heading>Details of unpack phase of
2431 installation or upgrade
2435 The procedure on installation/upgrade/overwrite/disappear
2436 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
2438 --install</tt>) is as follows. In each case if an error occurs the
2439 actions in are general run backwards - this means that the maintainer
2440 scripts are run with different arguments in reverse order. These are
2441 the `error unwind' calls listed below.
2448 <p>If a version the package is already
2451 <var>old-prerm</var> upgrade <var>new-version</var>
2456 If this gives an error (i.e., a non-zero exit
2457 status), dpkg will attempt instead:
2459 <var>new-prerm</var> failed-upgrade <var>old-version</var>
2461 Error unwind, for both the above cases:
2463 <var>old-postinst</var> abort-upgrade <var>new-version</var>
2471 <p>If a `conflicting' package is being removed at the same time:
2475 If any packages depended on that conflicting
2476 package and <tt>--auto-deconfigure</tt> is
2477 specified, call, for each such package:
2479 <var>deconfigured's-prerm</var> deconfigure \
2480 in-favour <var>package-being-installed</var> <var>version</var> \
2481 removing <var>conflicting-package</var> <var>version</var>
2485 <var>deconfigured's-postinst</var> abort-deconfigure \
2486 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
2487 removing <var>conflicting-package</var> <var>version</var>
2489 The deconfigured packages are marked as
2490 requiring configuration, so that if
2491 <tt>--install</tt> is used they will be
2492 configured again if possible.</p>
2495 <p>To prepare for removal of the conflicting package, call:
2497 <var>conflictor's-prerm</var> remove in-favour <var>package</var> <var>new-version</var>
2501 <var>conflictor's-postinst</var> abort-remove \
2502 in-favour <var>package</var> <var>new-version</var>
2513 <p>If the package is being upgraded, call:
2515 <var>new-preinst</var> upgrade <var>old-version</var>
2520 Otherwise, if the package had some configuration
2521 files from a previous version installed (i.e., it
2522 is in the `configuration files only' state):
2524 <var>new-preinst</var> install <var>old-version</var>
2528 <p>Otherwise (i.e., the package was completely purged):
2530 <var>new-preinst</var> install
2532 Error unwind versions, respectively:
2534 <var>new-postrm</var> abort-upgrade <var>old-version</var>
2535 <var>new-postrm</var> abort-install <var>old-version</var>
2536 <var>new-postrm</var> abort-install
2546 The new package's files are unpacked, overwriting any
2547 that may be on the system already, for example any
2548 from the old version of the same package or from
2549 another package (backups of the old files are left
2550 around, and if anything goes wrong the package
2551 management system will attempt to put them back as
2552 part of the error unwind).
2556 It is an error for a package to contains files which
2557 are on the system in another package, unless
2558 <tt>Replaces</tt> is used (see <ref id="replaces">).
2559 Currently the <tt>--force-overwrite</tt> flag is
2560 enabled, downgrading it to a warning, but this may not
2565 It is a more serious error for a package to contain a
2566 plain file or other kind of non-directory where another
2567 package has a directory (again, unless
2568 <tt>Replaces</tt> is used). This error can be
2569 overridden if desired using
2570 <tt>--force-overwrite-dir</tt>, but this is not
2575 Packages which overwrite each other's files produce
2576 behavior which though deterministic is hard for the
2577 system administrator to understand. It can easily
2578 lead to `missing' programs if, for example, a package
2579 is installed which overwrites a file from another
2580 package, and is then removed again.
2583 Part of the problem is due to what is arguably a
2584 bug in <prgn>dpkg</prgn>.
2590 A directory will never be replaced by a symbolic links
2591 to a directory or vice versa; instead, the existing
2592 state (symlink or not) will be left alone and
2593 <prgn>dpkg</prgn> will follow the symlink if there is
2601 <p>If the package is being upgraded, call
2603 <var>old-postrm</var> upgrade <var>new-version</var>
2607 <p>If this fails, <prgn>dpkg</prgn> will attempt:
2609 <var>new-postrm</var> failed-upgrade <var>old-version</var>
2611 Error unwind, for both cases:
2613 <var>old-preinst</var> abort-upgrade <var>new-version</var>
2619 This is the point of no return - if
2620 <prgn>dpkg</prgn> gets this far, it won't back off
2621 past this point if an error occurs. This will
2622 leave the package in a fairly bad state, which
2623 will require a successful re-installation to clear
2624 up, but it's when <prgn>dpkg</prgn> starts doing
2625 things that are irreversible.
2630 Any files which were in the old version of the package
2631 but not in the new are removed.</p>
2634 <p>The new file list replaces the old.</p>
2637 <p>The new maintainer scripts replace the old.</p>
2641 <p>Any packages all of whose files have been overwritten during the
2642 installation, and which aren't required for
2643 dependencies, are considered to have been removed.
2644 For each such package,
2647 <p><prgn>dpkg</prgn> calls:
2649 <var>disappearer's-postrm</var> disappear \
2650 <var>overwriter</var> <var>overwriter-version</var>
2655 <p>The package's maintainer scripts are removed.
2660 It is noted in the status database as being in a
2661 sane state, namely not installed (any conffiles
2662 it may have are ignored, rather than being
2663 removed by <prgn>dpkg</prgn>). Note that
2664 disappearing packages do not have their prerm
2665 called, because <prgn>dpkg</prgn> doesn't know
2666 in advance that the package is going to
2675 Any files in the package we're unpacking that are also
2676 listed in the file lists of other packages are removed
2677 from those lists. (This will lobotomize the file list
2678 of the `conflicting' package if there is one.)
2683 The backup files made during installation, above, are
2690 The new package's status is now sane, and recorded as
2691 `unpacked'. Here is another point of no return - if
2692 the conflicting package's removal fails we do not
2693 unwind the rest of the installation; the conflicting
2694 package is left in a half-removed limbo.
2699 If there was a conflicting package we go and do the
2700 removal actions (described below), starting with the
2701 removal of the conflicting package's files (any that
2702 are also in the package being installed have already
2703 been removed from the conflicting package's file list,
2704 and so do not get removed now).
2711 <sect><heading>Details of configuration</heading>
2714 When we configure a package (this happens with <tt>dpkg
2715 --install</tt>, or with <tt>--configure</tt>), we first
2716 update the conffiles and then call:
2718 <var>postinst</var> configure <var>most-recently-configured-version</var>
2723 No attempt is made to unwind after errors during
2728 If there is no most recently configured version
2729 <prgn>dpkg</prgn> will pass a null argument; older versions
2730 of dpkg may pass <tt><unknown></tt> (including the
2731 angle brackets) in this case. Even older ones do not pass a
2732 second argument at all, under any circumstances.
2736 <sect><heading>Details of removal and/or configuration purging
2744 <var>prerm</var> remove
2750 The package's files are removed (except conffiles).
2755 <var>postrm</var> remove
2759 <p>All the maintainer scripts except the postrm are removed.
2763 If we aren't purging the package we stop here. Note
2764 that packages which have no postrm and no conffiles
2765 are automatically purged when removed, as there is no
2766 difference except for the <prgn>dpkg</prgn>
2771 The conffiles and any backup files (<tt>~</tt>-files,
2772 <tt>#*#</tt> files, <tt>%</tt>-files,
2773 <tt>.dpkg-{old,new,tmp}</tt>, etc.) are removed.</p>
2777 <var>postrm</var> purge
2781 <p>The package's file list is removed.</p>
2784 No attempt is made to unwind after errors during
2790 <chapt id="relationships"><heading>Declaring relationships between
2794 Packages can declare in their control file that they have
2795 certain relationships to other packages - for example, that
2796 they may not be installed at the same time as certain other
2797 packages, and/or that they depend on the presence of others,
2798 or that they should overwrite files in certain other packages
2803 This is done using the <tt>Depends</tt>, <tt>Recommends</tt>,
2804 <tt>Suggests</tt>, <tt>Conflicts</tt>, <tt>Provides</tt> and
2805 <tt>Replaces</tt> control file fields.
2809 Source packages may declare relationships to binary packages,
2810 saying that they require certain binary packages being
2811 installed or absent at the time of building the package.
2815 This is done using the <tt>Build-Depends</tt>,
2816 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts</tt>, and
2817 <tt>Build-Conflicts-Indep</tt> control file fields.
2820 <sect id="depsyntax"><heading>Syntax of relationship fields
2824 These fields all have a uniform syntax. They are a list of
2825 package names separated by commas.
2829 In <tt>Depends</tt>, <tt>Recommends</tt>, <tt>Suggests</tt>,
2830 <tt>Pre-Depends</tt>, <tt>Build-Depends</tt> and
2831 <tt>Build-Depends-Indep</tt>(the fields which declare
2832 dependencies of the package in which they occur on other
2833 packages) these package names may also be lists of
2834 alternative package names, separated by vertical bar symbols
2835 <tt>|</tt> (pipe symbols).
2839 All the fields except <tt>Provides</tt> may restrict their
2840 applicability to particular versions of each named package.
2841 This is done in parentheses after each individual package
2842 name; the parentheses should contain a relation from the
2843 list below followed by a version number, in the format
2844 described in <ref id="versions">.
2848 The relations allowed are <tt><<</tt>, <tt><=</tt>,
2849 <tt>=</tt>, <tt>>=</tt> and <tt>>></tt> for
2850 strictly earlier, earlier or equal, exactly equal, later or
2851 equal and strictly later, respectively. The forms
2852 <tt><</tt> and <tt>></tt> were used to mean
2853 earlier/later or equal, rather than strictly earlier/later,
2854 so they should not appear in new packages (though
2855 <prgn>dpkg</prgn> still supports them).
2859 Whitespace may appear at any point in the version
2860 specification, and must appear where it's necessary to
2861 disambiguate; it is not otherwise significant. For
2862 consistency and in case of future changes to
2863 <prgn>dpkg</prgn> it is recommended that a single space be
2864 used after a version relationship and before a version
2865 number; it is usual also to put a single space after each
2866 comma, on either side of each vertical bar, and before each
2875 Depends: libc5 (>= 5.2.18-4), mime-support, csh | tcsh
2880 All fields that specify build-time relationships
2881 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
2882 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt>)
2883 may be restricted to a certain set of architectures. This
2884 is done in brackets after each individual package name and
2885 the optional version specification. The brackets enclose a
2886 list of Debian architecture names separated by whitespace.
2887 An exclamation mark may be prepended to each name. If the
2888 current Debian host architecture is not in this list and
2889 there are no exclamation marks in the list, or it is in the
2890 list with a prepended exclamation mark, the package name and
2891 the associated version specification are ignored completely
2892 for the purposes of defining the relationships.
2899 Build-Depends-Indep: texinfo
2900 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
2901 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
2907 <heading>Binary Dependencies - <tt>Depends</tt>,
2908 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Pre-Depends</tt>
2912 These four fields are used to declare a dependency by one
2913 package on another. They appear in the depending package's
2918 All but <tt>Pre-Depends</tt> and <tt>Conflicts</tt>
2919 (discussed below) take effect <em>only</em> when a package
2920 is to be configured. They do not prevent a package being on
2921 the system in an unconfigured state while its dependencies
2922 are unsatisfied, and it is possible to replace a package
2923 whose dependencies are satisfied and which is properly
2924 installed with a different version whose dependencies are
2925 not and cannot be satisfied; when this is done the depending
2926 package will be left unconfigured (since attempts to
2927 configure it will give errors) and will not function
2932 For this reason packages in an installation run are usually
2933 all unpacked first and all configured later; this gives
2934 later versions of packages with dependencies on later
2935 versions of other packages the opportunity to have their
2936 dependencies satisfied.
2940 Thus <tt>Depends</tt> allows package maintainers to impose
2941 an order in which packages should be configured.
2943 <tag><tt>Depends</tt></tag>
2946 <p>This declares an absolute dependency.
2950 The <tt>Depends</tt> field should be used if the
2951 depended-on package is required for the depending
2952 package to provide a significant amount of
2956 <tag><tt>Recommends</tt></tag>
2958 <p>This declares a strong, but not absolute, dependency.
2962 The <tt>Recommends</tt> field should list packages
2963 that would be found together with this one in all but
2964 unusual installations.</p>
2967 <tag><tt>Suggests</tt></tag>
2971 This is used to declare that one package may be more
2972 useful with one or more others. Using this field
2973 tells the packaging system and the user that the
2974 listed packages are related to this one and can
2975 perhaps enhance its usefulness, but that installing
2976 this one without them is perfectly reasonable.
2981 <tag><tt>Pre-Depends</tt></tag>
2985 This field is like <tt>Depends</tt>, except that it
2986 also forces <prgn>dpkg</prgn> to complete installation
2987 of the packages named before even starting the
2988 installation of the package which declares the
2993 <tt>Pre-Depends</tt> should be used sparingly,
2994 preferably only by packages whose premature upgrade or
2995 installation would hamper the ability of the system to
2996 continue with any upgrade that might be in progress.
3000 When the package declaring it is being configured, a
3001 <tt>Pre-Dependency</tt> will be considered satisfied
3002 only if the depending package has been correctly
3003 configured, just as if an ordinary <tt>Depends</tt>
3008 However, when a package declaring a Pre-dependency is
3009 being unpacked the predependency can be satisfied even
3010 if the depended-on package(s) are only unpacked or
3011 half-configured, provided that they have been
3012 configured correctly at some point in the past (and
3013 not removed or partially removed since). In this case
3014 both the previously-configured and currently unpacked
3015 or half-configured versions must satisfy any version
3016 clause in the <tt>Pre-Depends</tt> field.
3022 When selecting which level of dependency to use you should
3023 consider how important the depended-on package is to the
3024 functionality of the one declaring the dependency. Some
3025 packages are composed of components of varying degrees of
3026 importance. Such a package should list using
3027 <tt>Depends</tt> the package(s) which are required by the
3028 more important components. The other components'
3029 requirements may be mentioned as Suggestions or
3030 Recommendations, as appropriate to the components' relative
3035 <sect id="conflicts"><heading>Alternative binary packages -
3036 <tt>Conflicts</tt> and <tt>Replaces</tt>
3040 When one binary package declares a conflict with another
3041 <prgn>dpkg</prgn> will refuse to allow them to be installed
3042 on the system at the same time.
3046 If one package is to be installed, the other must be removed
3047 first - if the package being installed is marked as
3048 replacing (<ref id="replaces">) the one on the system, or
3049 the one on the system is marked as deselected, or both
3050 packages are marked <tt>Essential</tt>, then
3051 <prgn>dpkg</prgn> will automatically remove the package
3052 which is causing the conflict, otherwise it will halt the
3053 installation of the new package with an error. This
3054 mechanism specifically doesn't work when the installed
3055 package is <tt>Essential</tt>, but the new package is not.
3060 A package will not cause a conflict merely because its
3061 configuration files are still installed; it must be at least
3066 A special exception is made for packages which declare a
3067 conflict with their own package name, or with a virtual
3068 package which they provide (see below): this does not
3069 prevent their installation, and allows a package to conflict
3070 with others providing a replacement for it. You use this
3071 feature when you want the package in question to be the only
3072 package providing something.
3076 A <tt>Conflicts</tt> entry should almost never have an
3077 `earlier than' version clause. This would prevent
3078 <prgn>dpkg</prgn> from upgrading or installing the package
3079 which declared such a conflict until the upgrade or removal
3080 of the conflicted-with package had been completed.
3084 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
3088 As well as the names of actual (`concrete') packages, the
3089 package relationship fields <tt>Depends</tt>,
3090 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3091 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Conflicts</tt>,
3092 <tt>Build-Conflicts</tt> and <tt>Build-Conflicts-Indep</tt> may
3093 mention virtual packages.
3097 A virtual package is one which appears in the
3098 <tt>Provides</tt> control file field of another package.
3099 The effect is as if the package(s) which provide a
3100 particular virtual package name had been listed by name
3101 everywhere the virtual package name appears.
3105 If there are both a real and a virtual package of the same
3106 name then the dependency may be satisfied (or the conflict
3107 caused) by either the real package or any of the virtual
3108 packages which provide it. This is so that, for example,
3114 and someone else releases an xemacs package they can say
3118 </example> and all will work in the interim (until a purely
3119 virtual package name is decided on and the <tt>emacs</tt>
3120 and <tt>vm</tt> packages are changed to use it).
3124 If a dependency or a conflict has a version number attached
3125 then only real packages will be considered to see whether
3126 the relationship is satisfied (or the prohibition violated,
3127 for a conflict) - it is assumed that a real package which
3128 provides virtual package is not of the `right' version. So,
3129 a <tt>Provides</tt> field may not contain version numbers,
3130 and the version number of the concrete package which
3131 provides a particular virtual package will not be looked at
3132 when considering a dependency on or conflict with the
3133 virtual package name.
3137 It is likely that the ability will be added in a future
3138 release of <prgn>dpkg</prgn> to specify a version number for
3139 each virtual package it provides. This feature is not yet
3140 present, however, and is expected to be used only
3145 If you want to specify which of a set of real packages should be the
3146 default to satisfy a particular dependency on a virtual package, you
3147 should list the real package as an alternative before the virtual.
3152 <sect id="replaces"><heading><tt>Replaces</tt> - overwriting
3153 files and replacing packages
3157 The <tt>Replaces</tt> control file field has two purposes,
3158 which come into play in different situations.
3162 Virtual packages (<ref id="virtual">) are not considered
3163 when looking at a <tt>Replaces</tt> field - the packages
3164 declared as being replaced must be mentioned by their real
3168 <sect1><heading>Overwriting files in other packages
3172 Firstly, as mentioned before, it is usually an error for a
3173 package to contains files which are on the system in
3174 another package, though currently the
3175 <tt>--force-overwrite</tt> flag is enabled by default,
3176 downgrading the error to a warning,
3180 If the overwriting package declares that it replaces the
3181 one containing the file being overwritten then
3182 <prgn>dpkg</prgn> will proceed, and replace the file from
3183 the old package with that from the new. The file will no
3184 longer be listed as `owned' by the old package.
3188 If a package is completely replaced in this way, so that
3189 <prgn>dpkg</prgn> does not know of any files it still
3190 contains, it is considered to have disappeared. It will
3191 be marked as not wanted on the system (selected for
3192 removal) and not installed. Any conffiles details noted
3193 in the package will be ignored, as they will have been
3194 taken over by the replacing package(s). The package's
3195 <prgn>postrm</prgn> script will be run to allow the
3196 package to do any final cleanup required. See <ref
3197 id="mscriptsinstact">.
3201 In the future <prgn>dpkg</prgn> will discard files which
3202 overwrite those from another package which declares that
3203 it replaces the one being installed (so that you can
3204 install an older version of a package without problems).
3208 This usage of <tt>Replaces</tt> only takes effect when
3209 both packages are at least partially on the system at
3210 once, so that it can only happen if they do not conflict
3211 or if the conflict has been overridden.</p>
3214 <sect1><heading>Replacing whole packages, forcing their
3219 Secondly, <tt>Replaces</tt> allows the packaging system to
3220 resolve which package should be removed when there is a
3221 conflict - see <ref id="conflicts">. This usage only
3222 takes effect when the two packages <em>do</em> conflict,
3223 so that the two effects do not interfere with each other.
3228 <sect><heading>Relationships between source and binary packages -
3229 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3230 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt>
3234 A source package may declare a dependency or a conflict on a
3235 binary package. This is done with the control file fields
3236 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
3237 <tt>Build-Conflicts</tt>, and <tt>Build-Conflicts-Indep</tt>. Their
3238 semantics is that the dependencies and conflicts they define
3239 must be satisfied (as defined earlier for binary packages),
3240 when one of the targets in <tt>debian/rules</tt> that the
3241 particular field applies to is invoked.
3244 <tag><tt>Build-Depends</tt>, <tt>Build-Conflicts</tt></tag>
3247 The <tt>Build-Depends</tt> and
3248 <tt>Build-Conflicts</tt> fields apply to the targets
3249 <tt>build</tt>, <tt>binary</tt>, <tt>binary-arch</tt>
3250 and <tt>binary-indep</tt>.
3253 <tag><tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt></tag>
3256 The <tt>Build-Depends-Indep</tt> and
3257 <tt>Build-Conflicts-Indep</tt> fields apply to the
3258 targets <tt>binary</tt> and <tt>binary-indep</tt>.
3269 <chapt id="conffiles"><heading>Configuration file handling
3273 <prgn>dpkg</prgn> can do a certain amount of automatic
3274 handling of package configuration files.
3278 Whether this mechanism is appropriate depends on a number of
3279 factors, but basically there are two approaches to any
3280 particular configuration file.
3284 The easy method is to ship a best-effort configuration in the
3285 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
3286 handle updates. If the user is unlikely to want to edit the
3287 file, but you need them to be able to without losing their
3288 changes, and a new package with a changed version of the file
3289 is only released infrequently, this is a good approach.
3293 The hard method is to build the configuration file from
3294 scratch in the <prgn>postinst</prgn> script, and to take the
3295 responsibility for fixing any mistakes made in earlier
3296 versions of the package automatically. This will be
3297 appropriate if the file is likely to need to be different on
3302 <chapt id="sharedlibs"><heading>Shared libraries
3306 Packages containing shared libraries must be constructed with
3307 a little care to make sure that the shared library is always
3308 available. This is especially important for packages whose
3309 shared libraries are vitally important, such as the libc.
3313 Firstly, your package should install the shared libraries
3314 under their normal names. For example, the
3315 <prgn>libgdbm1</prgn> package should install
3316 <tt>libgdbm.so.1.7.3</tt> as
3317 <tt>/usr/lib/libgdbm.so.1.7.3</tt>. The files should not be
3318 renamed or re-linked by any prerm or postrm scripts;
3319 <prgn>dpkg</prgn> will take care of renaming things safely
3320 without affecting running programs, and attempts to interfere
3321 with this are likely to lead to problems.
3325 Secondly, your package should include the symlink that
3326 <prgn>ldconfig</prgn> would create for the shared libraries.
3327 For example, the <prgn>libgdbm1</prgn> package should include
3328 a symlink from <tt>/usr/lib/libgdbm.so.1</tt> to
3329 <tt>libgdbm.so.1.7.3</tt>. This is needed so that
3330 <prgn>ld.so</prgn> can find the library in between the time
3331 <prgn>dpkg</prgn> installs it and <prgn>ldconfig</prgn> is run
3332 in the <prgn>postinst</prgn> script. Furthermore, older
3333 versions of the package management system required the library
3334 must be placed before the symlink pointing to it in the
3335 <tt>.deb</tt> file. This is so that by the time
3336 <prgn>dpkg</prgn> comes to install the symlink (overwriting
3337 the previous symlink pointing at an older version of the
3338 library) the new shared library is already in place.
3339 Unfortunately, this was not not always possible, since it
3340 highly depends on the behavior of the file system. Some
3341 file systems (such as reiserfs) will reorder the files so it
3342 doesn't matter in what order you create them. Starting with
3343 release <tt>1.7.0</tt> <prgn>dpkg</prgn> will reorder the
3344 files itself when building a package.
3348 next Paragraph added to close Bug #5299, Guy Maor
3352 Thirdly, the development package should contain a symlink for
3353 the shared library without a version number. For example, the
3354 <tt>libgdbm1-dev</tt> package should include a symlink from
3355 <tt>/usr/lib/libgdm.so</tt> to <tt>libgdm.so.1.7.3</tt>. This
3356 symlink is needed by <prgn>ld</prgn> when compiling packages
3357 as it will only look for <tt>libgdm.so</tt> and
3358 <tt>libgdm.a</tt> when compiling dynamically or statically,
3363 next paragraph changed by Christian Schwarz (see policy weekly #6)
3367 Any package installing shared libraries in a directory that's listed
3368 in <tt>/etc/ld.so.conf</tt> or in one of the default library
3369 directories of <prgn>ld.so</prgn> (currently, these are <tt>/usr/lib</tt>
3370 and <tt>/lib</tt>) must call <prgn>ldconfig</prgn> in its <prgn>postinst</prgn>
3371 script if and only if the first argument is `configure'. However, it
3372 is important not to call <prgn>ldconfig</prgn> in the postrm or preinst
3373 scripts in the case where the package is being upgraded (see <ref
3374 id="unpackphase">), as <prgn>ldconfig</prgn> will see the temporary names
3375 that <prgn>dpkg</prgn> uses for the files while it is
3376 installing them and will make the shared library links point
3377 to them, just before <prgn>dpkg</prgn> continues the
3378 installation and removes the links!
3382 moved from section 2.2 , DMorris
3385 <sect id="shlibs"><heading>The <tt>shlibs</tt> File Format
3389 This file is for use by <prgn>dpkg-shlibdeps</prgn> and is
3390 required when your package provides shared libraries.
3394 Each line is of the form:
3396 <var>library-name</var> <var>version-or-soname</var> <var>dependencies ...</var>
3401 <var>library-name</var> is the name of the shared library,
3402 for example <tt>libc5</tt>.
3406 <var>version-or-soname</var> is the soname of the library -
3407 i.e., the thing that must exactly match for the library to be
3408 recognized by <prgn>ld.so</prgn>. Usually this is major
3409 version number of the library.
3413 <var>dependencies</var> has the same syntax as a dependency
3414 field in a binary package control file. It should give
3415 details of which package(s) are required to satisfy a binary
3416 built against the version of the library contained in the
3417 package. See <ref id="depsyntax">.
3421 For example, if the package <tt>foo</tt> contains
3422 <tt>libfoo.so.1.2.3</tt>, where the soname of the library is
3423 <tt>libfoo.so.1</tt>, and the first version of the package
3424 which contained a minor number of at least <tt>2.3</tt> was
3425 <var>1.2.3-1</var>, then the package's <var>shlibs</var>
3428 libfoo 1 foo (>= 1.2.3-1)
3433 The version-specific dependency is to avoid warnings from
3434 <prgn>ld.so</prgn> about using older shared libraries with
3438 <sect><heading>Further Technical information on
3439 <tt>shlibs</tt></heading>
3443 following section mostly provided by Heiko Schlittermann
3447 <sect1><heading><em>What</em> are the <tt>shlibs</tt> files?
3451 The <tt>debian/shlibs</tt> file provides a way of checking
3452 for shared library dependencies on packaged binaries.
3453 They are intended to be used by package maintainers to
3454 make their lives easier.
3458 Other <tt>shlibs</tt> files that exist on a Debian system are
3460 <item> <p><tt>/etc/dpkg/shlibs.default</tt></p></item>
3461 <item> <p><tt>/etc/dpkg/shlibs.override</tt></p></item>
3462 <item> <p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
3463 <item> <p><tt>debian/shlibs.local</tt></p></item>
3465 These files are used by <prgn>dpkg-shlibdeps</prgn> when
3466 creating a binary package.</p>
3469 <sect1><heading><em>How</em> does <prgn>dpkg-shlibdeps</prgn>
3473 <prgn>dpkg-shlibdeps</prgn>
3474 determines the shared libraries directly
3477 Currently, it calls <prgn>ldd</prgn>, but in a
3478 forthcoming version it shall call <prgn>objdump</prgn>
3479 to to this. This however changes will need a couple of
3480 changes in the way that packages are build.
3483 Suppose a binary <tt>foo</tt> directly use a library
3484 <tt>libbar</tt> if it is linked with that
3485 library. Other libraries that are needed by
3486 <tt>libbar</tt> are linked indirectly to <tt>foo</tt>,
3487 and the dynamic linker will load the automatically
3488 when it loads <tt>libbar</tt>. Using <prgn>ldd</prgn>
3489 lists all the libraries, used directly and indirectly;
3490 but <prgn>objdump</prgn> only lists the directly
3491 linked libraries. A package only needs to depend on
3492 the libraries it is directly linked to, since the
3493 dependencies for those libraries should automatically
3494 pull in the other libraries.</p>
3497 This change does mean a change in the way packages are
3498 build though: currently dpkg-shlibdeps is only run on
3499 binaries. But since we will now depend on the
3500 libraries to depend on the libraries they need the
3501 packages containing those libraries will need to run
3502 dpkg-shlibdeps on the libraries.
3505 A good example where this would help us is the current
3506 mess with multiple version of the mesa library. With
3507 the ldd-based system every package that uses mesa need
3508 to add a dependency on svgalib|svgalib-dummy in order
3509 to handle the glide mesa variant. With an
3510 objdump-based system this isn't necessary anymore and
3511 would have saved everyone a lot of work.
3514 Another example: we could update libimlib with a new
3515 version that supports a new graphics format called
3516 dgf. If we use the old ldd method every package that
3517 uses libimlib would need to be recompiled so it would
3518 also depend on libdgf or it wouldn't run due to
3519 missing symbols. However with the new system packages
3520 using libimlib can depend on libimlib itself having
3521 the dependency on libgdh and wouldn't need to be
3525 used by the compiled binaries (and libraries, in a version
3526 of <prgn>dpkg-shlibdeps</prgn> coming soon) passed through
3527 on its command line.
3531 For each shared library, <prgn>dpkg-shlibdeps</prgn> needs to know
3532 <list compact="compact">
3533 <item><p>the package containing the library, and</p></item>
3534 <item><p>the library version number,</p></item>
3537 it scans the following files in this order.
3538 <enumlist compact="compact">
3539 <item><p><tt>debian/shlibs.local</tt></p></item>
3540 <item><p><tt>/etc/dpkg/shlibs.override</tt></p></item>
3541 <item><p><tt>/var/lib/dpkg/info/*.shlibs</tt></p></item>
3542 <item><p><tt>/etc/dpkg/shlibs.default</tt></p></item>
3546 <sect1><heading><em>Who</em> maintains the various
3547 <tt>shlibs</tt> files?
3551 <list compact="compact">
3553 <p><tt>/etc/dpkg/shlibs.default</tt> - the maintainer
3558 <tt>/var/lib/dpkg/info/<var>package</var>.shlibs</tt>
3559 - the maintainer of each package</p>
3563 <tt>/etc/dpkg/shlibs.override</tt> - the local
3564 system administrator</p>
3567 <p><tt>debian/shlibs.local</tt> - the maintainer of
3572 The <tt>shlibs.default</tt> file is managed by
3573 <prgn>dpkg</prgn>. The entries in <tt>shlibs.default</tt>
3574 that are provided by <prgn>dpkg</prgn> are just there to
3575 fix things until the shared library packages all have
3576 <tt>shlibs</tt> files.
3580 <sect1><heading><em>How</em> to use <prgn>dpkg-shlibdeps</prgn> and
3581 the <tt>shlibs</tt> files?
3584 <sect2><heading>If your package doesn't provide a shared
3589 Put a call to <prgn>dpkg-shlibdeps</prgn> into your
3590 <tt>debian/rules</tt> file. If your package contains
3591 only binaries (e.g. no scripts) use:
3593 dpkg-shlibdeps debian/tmp/usr/bin/* debian/tmp/usr/sbin/*
3595 If <prgn>dpkg-shlibdeps</prgn> doesn't complain, you're
3596 done. If it does complain you might need to create your
3597 own <tt>debian/shlibs.local</tt> file.</p>
3600 <sect2><heading>If your package provides a shared library
3604 Create a <tt>debian/shlibs</tt> file and let
3605 <tt>debian/rules</tt> install it in the control area:
3607 install -m644 debian/shlibs debian/tmp/DEBIAN
3609 If your package contains additional binaries see above.
3614 <sect1><heading><em>How</em> to write
3615 <tt>debian/shlibs.local</tt>
3619 This file is intended only as a <em>temporary</em> fix if
3620 your binaries depend on a library which doesn't provide
3621 its own <tt>/var/lib/dpkg/info/*.shlibs</tt> file yet.
3625 Let's assume you are packaging a binary <tt>foo</tt>. Your
3626 output in building the package might look like this.
3629 libbar.so.1 => /usr/X11R6/lib/libbar.so.1.0
3630 libc.so.5 => /lib/libc.so.5.2.18
3631 libX11.so.6 => /usr/X11R6/lib/libX11.so.6.0
3633 And when you ran <prgn>dpkg-shlibdeps</prgn>
3635 $ dpkg-shlibdeps -o foo
3636 dpkg-shlibdeps: warning: unable to find dependency information
3637 for shared library libbar
3638 (soname 1, path /usr/X11R6/lib/libbar.so.1.0, dependency field Depends)
3639 shlibs:Depends=elf-x11r6lib, libc5 (>= 5.2.18)
3641 The <prgn>foo</prgn> binary depends on the
3642 <prgn>libbar</prgn> shared library, but no package seems
3643 to provide a <tt>*.shlibs</tt> file in
3644 <tt></tt>var/lib/dpkg/info/. Let's determine the package
3650 $ dpkg -S /usr/X11R6/lib/libbar.so.1.0
3651 bar1: /usr/X11R6/lib/libbar.so.1.0
3652 $ dpkg -s bar1 | grep Version
3655 This tells us that the <prgn>bar1</prgn> package, version
3656 1.0-1 is the one we are using. Now we can create our own
3657 <tt>debian/shlibs.local</tt> to temporarily fix the above
3658 problem. Include the following line into your
3659 <tt>debian/shlibs.local</tt> file.
3661 libbar 1 bar1 (>= 1.0-1)
3663 Now your package build should work. As soon as the
3664 maintainer of <prgn>libbar1</prgn> provides a
3665 <tt>shlibs</tt> file, you can remove your
3666 <tt>debian/shlibs.local</tt> file.
3672 <chapt><heading>The Operating System</heading>
3676 <heading>File system hierarchy</heading>
3680 <heading>Linux File system Structure</heading>
3683 The location of all installed files and directories must
3684 comply with the Linux File system Hierarchy Standard
3685 (FHS). The latest version of this document can be found
3686 alongside this manual or on
3687 <url id="http://www.pathname.com/fhs/">.
3688 Specific questions about following the standard may be
3689 asked on <prgn>debian-devel</prgn>, or referred to Daniel
3690 Quinlan, the FHS coordinator, at
3691 <email>quinlan@pathname.com</email>.</p></sect1>
3695 <heading>Site-specific programs</heading>
3698 As mandated by the FHS, packages must not place any
3699 files in <tt>/usr/local</tt>, either by putting them in
3700 the file system archive to be unpacked by <prgn>dpkg</prgn>
3701 or by manipulating them in their maintainer scripts.</p>
3704 However, the package may create empty directories below
3705 <tt>/usr/local</tt> so that the system administrator knows
3706 where to place site-specific files. These directories
3707 should be removed on package removal if they are
3711 Note, that this applies only to directories <em>below</em>
3712 <tt>/usr/local</tt>, not <em>in</em>
3713 <tt>/usr/local</tt>. Packages must not create sub-directories
3714 in the directory <tt>/usr/local</tt> itself, except those listed in
3715 FHS, section 4.5. However, you may create directories
3716 below them as you wish. You must not remove any of the
3717 directories listed in 4.5, even if you created them.</p>
3720 Since <tt>/usr/local</tt> can be mounted read-only from a
3721 remote server, these directories must be created and
3722 removed by the <tt>postinst</tt> and <tt>prerm</tt>
3723 maintainer scripts. These scripts must not fail if either
3724 of these operations fail. (In the future, it will be
3725 possible to tell <prgn>dpkg</prgn> not to unpack files
3726 matching certain patterns, so that the directories can be
3727 included in the <tt>.deb</tt> packages and system
3728 administrators who do not wish these directories in
3729 /usr/local do not need to have them.)</p>
3732 For example, the <prgn>emacs</prgn> package will contain
3734 mkdir -p /usr/local/lib/emacs/site-lisp || true
3736 in the <tt>postinst</tt> script, and
3738 rmdir /usr/local/lib/emacs/site-lisp && \
3739 rmdir /usr/local/lib/emacs || \
3742 in the <tt>prerm</tt> script.</p>
3745 If you do create a directory in <tt>/usr/local</tt> for
3746 local additions to a package, you should ensure that
3747 settings in <tt>/usr/local</tt> take precedence over the
3748 equivalents in <tt>/usr</tt>.</p>
3751 However, because '/usr/local' and its contents are for
3752 exclusive use of the local administrator, a package must
3753 not rely on the presence or absence of files or
3754 directories in '/usr/local' for normal operation.</p>
3757 The <tt>/usr/local</tt> directory itself and all the
3758 subdirectories created by the package should (by default) have
3759 permissions 2775 (group-writable and set-group-id) and be
3760 owned by <tt>root.staff</tt>.</p>
3765 <heading>Users and groups</heading>
3768 The Debian system can be configured to use either plain or
3769 shadow passwords.</p>
3772 Some user ids (UIDs) and group ids (GIDs) are reserved
3773 globally for use by certain packages. Because some packages
3774 need to include files which are owned by these users or
3775 groups, or need the ids compiled into binaries, these ids
3776 must be used on any Debian system only for the purpose for
3777 which they are allocated. This is a serious restriction, and
3778 we should avoid getting in the way of local administration
3779 policies. In particular, many sites allocate users and/or
3780 local system groups starting at 100.</p>
3783 Apart from this we should have dynamically allocated ids,
3784 which should by default be arranged in some sensible
3785 order--but the behavior should be configurable.</p>
3788 Packages other than <tt>base-passwd</tt> must not modify
3789 <tt>/etc/passwd</tt>, <tt>/etc/shadow</tt>,
3790 <tt>/etc/group</tt> or <tt>/etc/gshadow</tt>.</p>
3793 The UID and GID ranges are as follows:
3798 Globally allocated by the Debian project, the
3799 same on every Debian system. These ids will appear in
3800 the <tt>passwd</tt> and <tt>group</tt> files of all
3801 Debian systems, new ids in this range being added
3802 automatically as the <tt>base-passwd</tt> package is
3806 Packages which need a single statically allocated uid
3807 or gid should use one of these; their maintainers
3808 should ask the <tt>base-passwd</tt> maintainer for
3815 Dynamically allocated system users and groups.
3816 Packages which need a user or group, but can have this
3817 user or group allocated dynamically and differently on
3818 each system, should use `<tt>adduser --system</tt>' to
3819 create the group and/or user. <prgn>adduser</prgn>
3820 will check for the existence of the user or group, and
3821 if necessary choose an unused id based on the ranged
3822 specified in <tt>adduser.conf</tt>.</p></item>
3825 <tag>1000-29999:</tag>
3828 Dynamically allocated user accounts. By default
3829 <prgn>adduser</prgn> will choose UIDs and GIDs for
3830 user accounts in this range, though
3831 <tt>adduser.conf</tt> may be used to modify this
3835 <tag>30000-59999:</tag>
3837 <p>Reserved.</p></item>
3840 <tag>60000-64999:</tag>
3843 Globally allocated by the Debian project, but only
3844 created on demand. The ids are allocated centrally and
3845 statically, but the actual accounts are only created
3846 on users' systems on demand.</p>
3849 These ids are for packages which are obscure or which
3850 require many statically-allocated ids. These packages
3851 should check for and create the accounts in
3852 <tt>/etc/passwd</tt> or <tt>/etc/group</tt> (using
3853 <prgn>adduser</prgn> if it has this facility) if
3854 necessary. Packages which are likely to require
3855 further allocations should have a `hole' left after
3856 them in the allocation, to give them room to
3860 <tag>65000-65533:</tag>
3862 <p>Reserved.</p></item>
3867 <p>User `<tt>nobody</tt>.'</p></item>
3873 <tt>(uid_t)(-1) == (gid_t)(-1)</tt>. NOT TO BE USED,
3874 because it is the error return sentinel value.</p>
3879 <sect id="sysvinit">
3880 <heading>System run levels</heading>
3883 <sect1 id="/etc/init.d">
3884 <heading>Introduction</heading>
3887 The <tt>/etc/init.d</tt> directory contains the scripts
3888 executed by <prgn>init</prgn> at boot time and when init
3889 state (or `runlevel') is changed (see <manref name="init"
3893 There are at least two different, yet functionally
3894 equivalent, ways of handling these scripts. For the sake
3895 of simplicity, this document describes only the symbolic
3896 link method. However, it must not be assumed that this
3897 method is being used, and any manipulation of the various
3898 runlevel behaviours must be performed using
3899 <prgn>update-rc.d</prgn> as described below and not by
3900 manually installing symlinks. For information on the
3901 implementation details of the other method, implemented in
3902 the <tt>file-rc</tt> package, please refer to the
3903 documentation of that package.</p>
3906 These scripts are referenced by symbolic links in
3907 the <tt>/etc/rc<var>n</var>.d</tt> directories. When
3908 changing runlevels, <prgn>init</prgn> looks in the
3909 directory <tt>/etc/rc<var>n</var>.d</tt> for the scripts
3910 it should execute, where <var>n</var> is the runlevel that
3911 is being changed to, or `S' for the boot-up scripts.</p>
3914 The names of the links all have the form
3915 <tt>S<var>mm</var><var>script</var></tt> or
3916 <tt>K<var>mm</var><var>script</var></tt> where
3917 <var>mm</var> is a two-digit number and <var>script</var>
3918 is the name of the script (this should be the same as the
3919 name of the actual script in <tt>/etc/init.d</tt>.</p>
3922 When <prgn>init</prgn> changes runlevel first the targets
3923 of the links whose names starting with a <tt>K</tt> are
3924 executed, each with the single argument <tt>stop</tt>,
3925 followed by the scripts prefixed with an <tt>S</tt>, each
3926 with the single argument <tt>start</tt>. The <tt>K</tt>
3927 links are responsible for killing services and the
3928 <tt>S</tt> link for starting services upon entering the
3932 For example, if we are changing from runlevel 2 to
3933 runlevel 3, init will first execute all of the <tt>K</tt>
3934 prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
3935 all of the <tt>S</tt> prefixed scripts. The links
3936 starting with <tt>K</tt> will cause the referred-to file
3937 to be executed with an argument of <tt>stop</tt>, and the
3938 <tt>S</tt> links with an argument of <tt>start</tt>.</p>
3941 The two-digit number <var>mm</var> is used to decide which
3942 order to start and stop things in--low-numbered links have
3943 their scripts run first. For example, the <tt>K20</tt>
3944 scripts will be executed before the <tt>K30</tt> scripts.
3945 This is used when a certain service must be started before
3946 another. For example, the name server <prgn>bind</prgn>
3947 might need to be started before the news server
3948 <prgn>inn</prgn> so that <prgn>inn</prgn> can set up its
3949 access lists. In this case, the script that starts
3950 <prgn>bind</prgn> would have a lower number than the
3951 script that starts <prgn>inn</prgn> so that it runs first:
3960 <heading>Writing the scripts</heading>
3963 Packages that include daemons for system services should
3964 place scripts in <tt>/etc/init.d</tt> to start or stop
3965 services at boot time or during a change of runlevel.
3966 These scripts should be named
3967 <tt>/etc/init.d/<var>package</var></tt>, and they should
3968 accept one argument, saying what to do:
3971 <tag><tt>start</tt></tag>
3972 <item><p>start the service,</p></item>
3974 <tag><tt>stop</tt></tag>
3975 <item><p>stop the service,</p></item>
3977 <tag><tt>restart</tt></tag>
3978 <item><p>stop and restart the service,</p></item>
3980 <tag><tt>reload</tt></tag>
3981 <item><p>cause the configuration of the service to be
3982 reloaded without actually stopping and restarting
3983 the service,</p></item>
3985 <tag><tt>force-reload</tt></tag> <item><p>cause the
3986 configuration to be reloaded if the service supports
3987 this, otherwise restart the service.</p></item>
3990 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
3991 <tt>force-reload</tt> options should be supported by all
3992 scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
3993 option is optional.</p>
3996 The <tt>init.d</tt> scripts should ensure that they will
3997 behave sensibly if invoked with <tt>start</tt> when the
3998 service is already running, or with <tt>stop</tt> when it
3999 isn't, and that they don't kill unfortunately-named user
4000 processes. The best way to achieve this is usually to use
4001 <prgn>start-stop-daemon</prgn>.</p>
4004 If a service reloads its configuration automatically (as
4005 in the case of <prgn>cron</prgn>, for example), the
4006 <tt>reload</tt> option of the <tt>init.d</tt> script
4007 should behave as if the configuration has been reloaded
4011 These scripts should not fail obscurely when the
4012 configuration files remain but the package has been
4013 removed, as configuration files remain on the system after
4014 the package has been removed. Only when <prgn>dpkg</prgn>
4015 is executed with the <tt>--purge</tt> option will
4016 configuration files be removed. In particular, the init
4017 script itself is usually a configuration file (see
4018 <ref id="init.d notes">), and will remain on the system if
4019 the package is removed but not purged. Therefore, you
4020 should include a <tt>test</tt> statement at the top of the
4023 test -f <var>program-executed-later-in-script</var> || exit 0
4028 <heading>Managing the links</heading>
4031 The program <prgn>update-rc.d</prgn> is provided to make
4032 it easier for package maintainers to arrange for the
4033 proper creation and removal of
4034 <tt>/etc/rc<var>n</var>.d</tt> symbolic links, or their
4035 functional equivalent if another method is being used.
4036 This may be used by maintainers in their packages'
4037 <tt>postinst</tt> and <tt>postrm</tt> scripts.</p>
4040 You must use this script to make changes to
4041 <tt>/etc/rc<var>n</var>.d</tt> and <em>never</em> either
4042 include any <tt>/etc/rc<var>n</var>.d</tt> symbolic links
4043 in the actual archive or manually create or remove the
4044 symbolic links in maintainer scripts. (The latter will
4045 fail if an alternative method of maintaining runlevel
4046 information is being used.)</p>
4049 By default <prgn>update-rc.d</prgn> will start services in
4050 each of the multi-user state runlevels (2, 3, 4, and 5)
4051 and stop them in the halt runlevel (0), the single-user
4052 runlevel (1) and the reboot runlevel (6). The system
4053 administrator will have the opportunity to customize
4054 runlevels by either running <prgn>update-rc.d</prgn>, by
4055 simply adding, moving, or removing the symbolic links in
4056 <tt>/etc/rc<var>n</var>.d</tt> if symbolic links are being
4057 used, or by modifying <tt>/etc/runlevel.conf</tt> if the
4058 <tt>file-rc</tt> method is being used.</p>
4061 To get the default behavior for your package, put in your
4062 <tt>postinst</tt> script
4064 update-rc.d <var>package</var> defaults >/dev/null
4066 and in your <tt>postrm</tt>
4068 if [ purge = "$1" ]; then
4069 update-rc.d <var>package</var> remove >/dev/null
4074 This will use a default sequence number of 20. If it does
4075 not matter when or in which order the script is run, use
4076 this default. If it does, then you should talk to the
4077 maintainer of the <prgn>sysvinit</prgn> package or post to
4078 <tt>debian-devel</tt>, and they will help you choose a
4082 For more information about using <tt>update-rc.d</tt>,
4083 please consult its manpage <manref name="update-rc.d"
4084 section="8">.</p></sect1>
4088 <heading>Boot-time initialization</heading>
4091 There used to be another directory, <tt>/etc/rc.boot</tt>,
4092 which contained scripts which were run once per machine
4093 boot. This has been deprecated in favour of links from
4094 <tt>/etc/rcS.d</tt> to files in <tt>/etc/init.d</tt> as
4095 described in <ref id="/etc/init.d">. Packages must not
4096 place files in <tt>/etc/rc.boot</tt>.</p>
4098 <sect1 id="init.d notes">
4099 <heading>Notes</heading>
4102 <em>Do not</em> include the
4103 <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in the
4104 <tt>.deb</tt> file system archive! <em>This will cause
4105 problems!</em> You must create them with
4106 <prgn>update-rc.d</prgn>, as above.</p>
4109 <em>Do not</em> include the
4110 <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in
4111 <prgn>dpkg</prgn>'s conffiles list! <em>This will cause
4112 problems!</em> You should, however, treat the
4113 <tt>/etc/init.d</tt> scripts as configuration files,
4114 either by marking them as conffiles or managing them
4115 correctly in the maintainer scripts (see
4116 <ref id="config files">). (This is important since we want
4117 to give the local system administrator the chance to adapt
4118 the scripts to the local system--e.g., to disable a
4119 service without de-installing the package, or to specify
4120 some special command line options when starting a
4121 service--while making sure her changes aren't lost during
4122 the next package upgrade.)</p>
4126 <heading>Example</heading>
4129 The <prgn>bind</prgn> DNS (nameserver) package wants to
4130 make sure that the nameserver is running in multiuser
4131 runlevels, and is properly shut down with the system. It
4132 puts a script in <tt>/etc/init.d</tt>, naming the script
4133 appropriately <tt>bind</tt>. As you can see, the script
4134 interprets the argument <tt>reload</tt> to send the
4135 nameserver a <tt>HUP</tt> signal (causing it to reload its
4136 configuration); this way the user can say
4137 <tt>/etc/init.d/bind reload</tt> to reload the name
4144 # Original version by Robert Leslie
4145 # <rob@mars.org>, edited by iwj and cs
4147 test -x /usr/sbin/named || exit 0
4151 echo -n "Starting domain name service: named"
4152 start-stop-daemon --start --quiet --exec /usr/sbin/named
4156 echo -n "Stopping domain name service: named"
4157 start-stop-daemon --stop --quiet \
4158 --pidfile /var/run/named.pid --exec /usr/sbin/named
4162 echo -n "Restarting domain name service: named"
4163 start-stop-daemon --stop --quiet \
4164 --pidfile /var/run/named.pid --exec /usr/sbin/named
4165 start-stop-daemon --start --verbose --exec /usr/sbin/named
4168 force-reload|reload)
4169 echo -n "Reloading configuration of domain name service: named"
4170 start-stop-daemon --stop --signal 1 --quiet \
4171 --pidfile /var/run/named.pid --exec /usr/sbin/named
4175 echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
4184 Another example on which to base your <tt>/etc/init.d</tt>
4185 scripts is in <tt>/etc/init.d/skeleton</tt>.</p>
4188 If this package is happy with the default setup from
4189 <prgn>update-rc.d</prgn>, namely an ordering number of 20
4190 and having named running in all runlevels, it can say in
4191 its <tt>postinst</tt>:
4193 update-rc.d bind defaults >/dev/null
4195 And in its <tt>postrm</tt>, to remove the links when the
4198 if [ purge = "$1" ]; then
4199 update-rc.d bind remove >/dev/null
4205 <heading>Cron jobs</heading>
4208 Packages must not modify the configuration file
4209 <tt>/etc/crontab</tt>, and they must not modify the files in
4210 <tt>/var/spool/cron/crontabs</tt>.</p>
4213 If a package wants to install a job that has to be executed
4214 via cron, it should place a file with the name if the
4215 package in one of the following directories:
4221 As these directory names imply, the files within them are
4222 executed on a daily, weekly, or monthly basis,
4223 respectively. The exact times are listed in
4224 <tt>/etc/crontab</tt>.</p>
4227 All files installed in any of these directories must be
4228 scripts (shell scripts, Perl scripts, etc.) so that they can
4229 easily be modified by the local system administrator. In
4230 addition, they should be treated as configuration files.</p>
4233 If a certain job has to be executed more frequently than
4234 daily, the package should install a file
4235 <tt>/etc/cron.d/<var>package-name</var></tt>. This file uses
4236 the same syntax as <tt>/etc/crontab</tt> and is processed by
4237 <prgn>cron</prgn> automatically. The file must also be
4238 treated as a configuration file. (Note, that entries in the
4239 <tt>/etc/cron.d</tt> directory are not handled by
4240 <prgn>anacron</prgn>. Thus, you should only use this
4241 directory for jobs which may be skipped if the system is not
4245 The scripts or crontab entries in these directories should
4246 check if all necessary programs are installed before they
4247 try to execute them. Otherwise, problems will arise when a
4248 package was removed but not purged since configuration files
4249 are kept on the system in this situation.</p>
4253 <heading>Console messages</heading>
4256 This section describes different formats for messages
4257 written to standard output by the <tt>/etc/init.d</tt>
4258 scripts. The intent is to improve the consistency of
4259 Debian's startup and shutdown look and feel.</p>
4262 Please look very careful at the details. We want to get the
4263 messages to look exactly the same way concerning spaces,
4264 punctuation, and case of letters.</p>
4267 Here is a list of overall rules that you should use when you
4268 create output messages. They can be useful if you have a
4269 non-standard message that isn't covered in the sections
4276 Every message should cover one line, start with a
4277 capital letter and end with a period `.'.</p></item>
4282 If you want to express that the computer is working on
4283 something (performing a specific task, not starting or
4284 stopping a program), we use an ``ellipsis'', namely
4285 three dots `...'. Note that we don't insert spaces in
4286 front of or behind the dots. If the task has been
4287 completed we write `done.' and a line feed.</p></item>
4292 Design your messages as if the computer is telling you
4293 what he is doing (let him be polite :-) but don't
4294 mention ``him'' directly. For example, if you think
4297 I'm starting network daemons: nfsd mountd.
4301 Starting network daemons: nfsd mountd.
4302 </example></p></item>
4306 The following formats should be used</p>
4311 <p>when daemons get started.</p>
4314 Use this format if your script starts one or more
4315 daemons. The output should look like this (a single
4316 line, no leading spaces):
4318 Starting <description>: <daemon-1> <daemon-2> <...> <daemon-n>.
4320 The <description> should describe the subsystem
4321 the daemon or set of daemons are part of, while
4322 <daemon-1> up to <daemon-n> denote each
4323 daemon's name (typically the file name of the
4327 For example, the output of /etc/init.d/lpd would look like:
4329 Starting printer spooler: lpd.
4333 This can be achieved by saying
4335 echo -n "Starting printer spooler: lpd"
4336 start-stop-daemon --start --quiet lpd
4339 in the script. If you have more than one daemon to
4340 start, you should do the following:
4342 echo -n "Starting remote file system services:"
4343 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
4344 echo -n " mountd"; start-stop-daemon --start --quiet mountd
4345 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
4348 This makes it possible for the user to see what takes
4349 so long and when the final daemon has been
4350 started. You should be careful where to put spaces: In the
4351 example above the system administrator can easily
4352 comment out a line if he don't wants to start a
4353 specific daemon, while the displayed message still
4354 looks good.</p></item>
4358 <p>when something needs to be configured.</p>
4361 If you have to set up different parameters of the
4362 system upon boot up, you should use this format:
4364 Setting <parameter> to `<value>'.
4368 You can use the following echo statement to get the quotes right:
4370 echo "Setting DNS domainname to \`"value"'."
4374 Note that the left quotation mark (`) is different
4375 from the right (').</p></item>
4378 <p>when a daemon is stopped.</p>
4381 When you stop a daemon you should issue a message
4382 similar to the startup message, except that `Starting'
4383 is replaced with `Stopping'.</p>
4386 So stopping the printer daemon will like like this:
4388 Stopping printer spooler: lpd.
4389 </example></p></item>
4392 <p>when something is executed.</p>
4395 There are several examples where you have to run a
4396 program at system startup or shutdown to perform a
4397 specific task. For example, setting the system's clock
4398 via `netdate' or killing all processes when the system
4399 comes down. Your message should like this:
4401 Doing something very useful...done.
4403 You should print the `done.' right after the job has been completed,
4404 so that the user gets informed why he has to wait. You can get this
4407 echo -n "Doing something very useful..."
4411 in your script.</p></item>
4414 <p>when the configuration is reloaded.</p>
4417 When a daemon is forced to reload its configuration
4418 files you should use the following format:
4420 Reloading <daemon's-name> configuration...done.
4421 </example></p></item>
4424 <p>when none of the above rules apply.</p>
4427 If you have to print a message that doesn't fit into
4428 the styles described above, you can use something
4429 appropriate, but please have a look at the overall
4430 rules listed above.</p></item>
4435 <heading>Menus</heading>
4438 Menu entries should follow the current menu policy as
4439 defined in the file <ftpsite>ftp.debian.org</ftpsite> in
4440 <ftppath>/debian/doc/package-developer/menu-policy.txt</ftppath>
4441 or your local mirror. In addition, it is included in the
4442 <tt>debian-policy</tt> package.
4446 The Debian <tt>menu</tt> packages provides a unique
4447 interface between packages providing applications and
4448 documents, and <em>menu programs</em> (either X window
4449 managers or text-based menu programs as
4450 <prgn>pdmenu</prgn>).</p>
4453 All packages that provide applications that need not be
4454 passed any special command line arguments for normal
4455 operation should register a menu entry for those
4456 applications, so that users of the <tt>menu</tt> package
4457 will automatically get menu entries in their window
4458 managers, as well in shells like <tt>pdmenu</tt>.</p>
4461 Please refer to the <em>Debian Menu System</em> document
4462 that comes with the <tt>menu</tt> package for information
4463 about how to register your applications and web
4469 <heading>Multimedia handlers</heading>
4472 Packages which provide the ability to view/show/play,
4473 compose, edit or print MIME types should register themselves
4474 as such following the current MIME support policy as defined
4475 in the file found on <ftpsite>ftp.debian.org</ftpsite> in
4476 <ftppath>/debian/doc/package-developer/mime_policy.txt</ftppath>
4477 or your local mirror. In addition, it is included in the
4478 <tt>debian-policy</tt> package.
4482 MIME (Multipurpose Internet Mail Extensions, RFC 1521) is a
4483 mechanism for encoding files and data streams and providing
4484 meta-information about them, in particular their type (e.g.
4485 audio or video) and format (e.g. PNG, HTML, MP3).
4489 Registration of MIME type handlers allows programs like mail
4490 user agents and web browsers to to invoke these handlers to
4491 view, edit or display MIME types they don't support
4497 <heading>Keyboard configuration</heading>
4500 To achieve a consistent keyboard configuration (i.e., all
4501 applications interpret a keyboard event the same way) all
4502 programs in the Debian distribution must be configured to
4503 comply with the following guidelines.</p>
4506 Here is a list that contains certain keys and their interpretation:
4509 <tag><tt><--</tt></tag>
4510 <item><p>delete the character to the left of the cursor</p></item>
4512 <tag><tt>Delete</tt></tag>
4513 <item><p>delete the character to the right of the cursor</p></item>
4515 <tag><tt>Control+H</tt></tag>
4516 <item><p>emacs: the help prefix</p></item>
4519 The interpretation of any keyboard events should be independent
4520 of the terminal that's used, be it a virtual console, an X
4521 terminal emulator, an rlogin/telnet session, etc.</p>
4524 The following list explains how the different programs
4525 should be set up to achieve this:</p>
4528 <list compact="compact">
4529 <item><p>`<tt><--</tt>' generates KB_Backspace in
4532 <item><p>`<tt>Delete</tt>' generates KB_Delete in X.</p></item>
4536 X translations are set up to make KB_Backspace
4537 generate ASCII DEL, and to make KB_Delete generate
4538 <tt>ESC [ 3 ~</tt> (this is the vt220 escape code for
4539 the `delete character' key). This must be done by
4540 loading the resources using xrdb on all local X
4541 displays, not using the application defaults, so that
4542 the translation resources used correspond to the
4543 xmodmap settings.</p></item>
4547 The Linux console is configured to make
4548 `<tt><--</tt>' generate DEL, and `Delete' generate
4549 <tt>ESC [ 3 ~</tt> (this is the case at the
4553 X applications are configured so that Backspace
4554 deletes left, and Delete deletes right. Motif
4555 applications already work like this.</p></item>
4557 <item><p>stty erase <tt>^?</tt> .</p></item>
4560 The `xterm' terminfo entry should have <tt>ESC [ 3
4561 ~</tt> for kdch1, just like TERM=linux and
4562 TERM=vt220.</p></item>
4565 Emacs is programmed to map KB_Backspace or the `stty
4566 erase' character to delete-backward-char, and
4567 KB_Delete or kdch1 to delete-forward-char, and
4568 <tt>^H</tt> to help as always.</p></item>
4571 Other applications use the `stty erase' character and
4572 kdch1 for the two delete keys, with ASCII DEL being
4573 `delete previous character' and kdch1 being `delete
4574 character under cursor'.</p></item>
4578 This will solve the problem except for:</p>
4581 <list compact="compact">
4583 Some terminals have a <tt><--</tt> key that cannot
4584 be made to produce anything except <tt>^H</tt>. On
4585 these terminals Emacs help will be unavailable on
4586 <tt>^H</tt> (assuming that the `stty erase' character
4587 takes precedence in Emacs, and has been set
4588 correctly). M-x help or F1 (if available) can be used
4592 Some operating systems use <tt>^H</tt> for stty erase.
4593 However, modern telnet versions and all rlogin
4594 versions propagate stty settings, and almost all UNIX
4595 versions honour stty erase. Where the stty settings
4596 are not propagated correctly things can be made to
4597 work by using stty manually.</p></item>
4600 Some systems (including previous Debian versions) use
4601 xmodmap to arrange for both <tt><--</tt> and Delete
4602 to generate KB_Delete. We can change the behavior
4603 of their X clients via the same X resources that we
4604 use to do it for our own, or have our clients be
4605 configured via their resources when things are the
4606 other way around. On displays configured like this
4607 Delete will not work, but <tt><--</tt>
4611 Some operating systems have different kdch1 settings
4612 in their terminfo for xterm and others. On these
4613 systems the Delete key will not work correctly when
4614 you log in from a system conforming to our policy, but
4615 <tt><--</tt> will.</p></item>
4622 <heading>Environment variables</heading>
4625 A program must not depend on environment variables to get
4626 reasonable defaults. (That's because these environment
4627 variables would have to be set in a system-wide
4628 configuration file like /etc/profile, which is not supported
4632 If a program usually depends on environment variables for its
4633 configuration, the program should be changed to fall back to
4634 a reasonable default configuration if these environment
4635 variables are not present. If this cannot be done easily
4636 (e.g., if the source code of a non-free program is not
4637 available), the program must be replaced by a small
4638 `wrapper' shell script which sets the environment variables
4639 if they are not already defined, and calls the original program.</p>
4642 Here is an example of a wrapper script for this purpose:
4646 BAR=${BAR:-/var/lib/fubar}
4648 exec /usr/lib/foo/foo "$@"
4652 Furthermore, as <tt>/etc/profile</tt> is a configuration
4653 file of the <prgn>base-files</prgn> package, other packages must not
4654 put any environment variables or other commands into that
4659 <heading>Files</heading>
4663 <heading>Binaries</heading>
4666 Two different packages must not install programs with
4667 different functionality but with the same filenames. (The
4668 case of two programs having the same functionality but
4669 different implementations is handled via `alternatives.')
4670 If this case happens, one of the programs must be
4671 renamed. The maintainers should report this to the
4672 developers' mailing and try to find a consensus about
4673 which package will have to be renamed. If a consensus can
4674 not be reached, <em>both</em> programs must be
4678 Generally the following compilation parameters should be used:
4681 CFLAGS = -O2 -Wall # sane warning options vary between programs
4683 install -s # (or use strip on the files in debian/tmp)
4687 Note that by default all installed binaries should be stripped,
4688 either by using the <tt>-s</tt> flag to
4689 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
4690 the binaries after they have been copied into
4691 <tt>debian/tmp</tt> but before the tree is made into a
4695 The <tt>-N</tt> flag should not be used. On a.out systems
4696 it may have been useful for some very small binaries, but
4697 for ELF it has no good effect.</p>
4700 Debugging symbols are useful for error diagnosis,
4701 investigation of core dumps (which may be submitted by users
4702 in bug reports), or testing and developing the
4703 software. Therefore it is recommended to support building
4704 the package with debugging information through the following
4705 interface: If the environment variable
4706 <tt>DEB_BUILD_OPTIONS</tt> contains the string
4707 <tt>debug</tt>, compile the software with debugging
4708 information (usually this involves adding the <tt>-g</tt>
4709 flag to <tt>CFLAGS</tt>). This allows the generation of a
4710 build tree with debugging information. If the environment
4711 variable <tt>DEB_BUILD_OPTIONS</tt> contains the string
4712 <tt>nostrip</tt>, do not strip the files at installation
4713 time. This allows one to generate a package with debugging
4714 information included. The following makefile snippet is only
4715 an example of how one may test for either condition:
4718 Rationale: Building by default with -g causes more
4719 wasted CPU cycles since the information is stripped away
4720 anyway. The package can by default build without -g if
4721 it also provides a mechanism to easily be rebuilt with
4722 debugging information. This can be done by providing a
4723 "build-debug" make target, or allowing the user to
4724 specify "DEB_BUILD_OPTIONS=debug" in the environment while
4725 compiling that package.
4727 <p>Now this has several added benefits:
4731 It is actually easier to build debugging bins and
4732 libraries this way (no more editing debian/rules
4733 or similar) since it provides a documented way of
4734 getting this type of build.</p>
4738 There will be much less wasted cpu time for the
4739 autobuilders since not having debugging
4740 information (and hence also not having to strip
4741 it) will increase the speed of compiles. This
4742 skips an entire pass of the compiler.
4753 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
4756 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
4762 It is up to the package maintainer to decide what
4763 compilation options are best for the package. Certain
4764 binaries (such as computationally-intensive programs) will
4765 function better with certain flags (<tt>-O3</tt>, for
4766 example); feel free to use them. Please use good judgment
4767 here. Don't use flags for the sake of it; only use them
4768 if there is good reason to do so. Feel free to override
4769 the upstream author's ideas about which compilation
4770 options are best--they are often inappropriate for our
4771 environment.</p></sect>
4775 <heading>Libraries</heading>
4778 All libraries must have a shared version in the lib
4779 package and a static version in the lib-dev package. The
4780 shared version must be compiled with <tt>-fPIC</tt>, and
4781 the static version must not be. In other words, each
4782 <tt>*.c</tt> file will need to be compiled twice.</p>
4785 You must specify the gcc option <tt>-D_REENTRANT</tt>
4786 when building a library (either static or shared) to make
4787 the library compatible with LinuxThreads.</p>
4790 Note that all installed shared libraries should be
4793 strip --strip-unneeded <your-lib>
4795 (The option `--strip-unneeded' makes <tt>strip</tt> remove
4796 only the symbols which aren't needed for relocation
4797 processing.) Shared libraries can function perfectly well
4798 when stripped, since the symbols for dynamic linking are
4799 in a separate part of the ELF object file.</p>
4802 Note that under some circumstances it may be useful to
4803 install a shared library unstripped, for example when
4804 building a separate package to support debugging.
4808 An ever increasing number of packages are using libtool to
4809 do their linking. The latest GNU libtools (>= 1.3a) can take
4810 advantage of the metadata in the installed libtool archive
4811 files (`*.la'). The main advantage of libtool's .la files is
4812 that it allows libtool to store and subsequently access
4813 metadata with respect to the libraries it builds. libtool
4814 will search for those files, which contain a lot of useful
4815 information about a library (e.g. dependency libraries for
4816 static linking). Also, they're <em>essential</em> for
4817 programs using libltdl.
4821 Certainly libtool is fully capable of linking against shared
4822 libraries which don't have .la files, but being a mere shell
4823 script it can add considerably to the build time of a
4824 libtool using package if that shell-script has to derive all
4825 this information from first principles for each library every
4826 time it is linked. With the advent of libtool-1.4 (and to a
4827 lesser extent libtool-1.3), the .la files will also store
4828 information about inter-library dependencies which cannot
4829 necessarily be derived after the .la file is deleted.
4833 Packages that use libtool to create shared libraries should
4834 include the <em>.la</em> files in the <em>-dev</em>
4835 packages, with the exception that if the package relies on
4836 libtool's <em>libltdl</em> library, in which case the .la
4837 files must go in the run-time library package. This is a
4838 good idea in general, and especially for static linking
4843 You must make sure that you use only released versions of
4844 shared libraries to build your packages; otherwise other
4845 users will not be able to run your binaries
4846 properly. Producing source packages that depend on
4847 unreleased compilers is also usually a bad
4854 <heading>Shared libraries</heading>
4857 Packages involving shared libraries should be split up
4858 into several binary packages.</p>
4861 For a straightforward library which has a development
4862 environment and a runtime kit including just shared
4863 libraries you need to create two packages:
4864 <tt><var>libraryname</var><var>soname</var></tt>
4865 (<var>soname</var> is the shared object name of the shared
4866 library--it's the thing that has to match exactly between
4867 building an executable and running it for the dynamic
4868 linker to be able run the program; usually the
4869 <var>soname</var> is the major number of the library) and
4870 <tt><var>libraryname</var><var>soname</var>-dev</tt>.</p>
4873 If you prefer only to support one development version at a
4874 time you may name the development package
4875 <tt><var>libraryname</var>-dev</tt>; otherwise you may
4876 wish to use <prgn>dpkg</prgn>'s conflicts mechanism to
4877 ensure that the user only installs one development version
4878 at a time (after all, different development versions are
4879 likely to have the same header files in them, causing a
4880 filename clash if both are installed). Typically the
4881 development version should also have an exact version
4882 dependency on the runtime library, to make sure that
4883 compilation and linking happens correctly.</p>
4886 Packages which use the shared library should have a
4887 dependency on the name of the shared library package,
4888 <tt><var>libraryname</var><var>soname</var></tt>. When
4889 the <var>soname</var> changes you can have both versions
4890 of the library installed while moving from the old library
4894 If your package has some run-time support programs which
4895 use the shared library you must not put them in
4896 the shared library package. If you do that then you won't
4897 be able to install several versions of the shared library
4898 without getting filename clashes. Instead, either create
4899 a third package for the runtime binaries (this package
4900 might typically be named
4901 <tt><var>libraryname</var>-runtime</tt>--note the absence
4902 of the <var>soname</var> in the package name) or if the
4903 development package is small include them in there.</p>
4906 If you have several shared libraries built from the same
4907 source tree you may lump them all together into a single
4908 shared library package, provided that you change all their
4909 <var>soname</var>s at once (so that you don't get filename
4910 clashes if you try to install different versions of the
4911 combined shared libraries package).</p>
4914 You should follow the directions in the <em>Debian Packaging
4915 Manual</em> for putting the shared library in its package,
4916 and you must include a <tt>shlibs</tt> control area
4917 file with details of the dependencies for packages which
4918 use the library.</p>
4921 Shared libraries should not be installed
4922 executable, since <prgn>ld.so</prgn> does not require this
4923 and trying to execute a shared library results in a core
4928 <heading>Scripts</heading>
4931 All command scripts, including the package maintainer
4932 scripts inside the package and used by <prgn>dpkg</prgn>,
4933 should have a <tt>#!</tt> line naming the shell to be used
4934 to interpret them.</p>
4937 In the case of Perl scripts this should be
4938 <tt>#!/usr/bin/perl</tt>.</p>
4941 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
4942 should almost certainly start with <tt>set -e</tt> so that
4943 errors are detected. Every script should use
4944 <tt>set -e</tt> or check the exit status of <em>every</em>
4948 The standard shell interpreter `<tt>/bin/sh</tt>' can be a
4949 symbolic link to any POSIX compatible shell, if <tt>echo
4950 -n</tt> does not generate a newline.
4953 Debian policy specifies POSIX behavior for /bin/sh, but
4954 echo -n has widespread use in the Linux community
4955 (including especially debian policy, the linux kernel
4956 source, many debian scripts, etc.). This echo -n
4957 mechanism is valid but not required under POSIX, hence
4958 this explicit addition. Also, rumour has it that this
4959 shall be mandated under the LSB anyway.
4963 specifying `<tt>/bin/sh</tt>' as interpreter should only
4964 use POSIX features. If a script requires non-POSIX
4965 features from the shell interpreter, the appropriate shell
4966 must be specified in the first line of the script (e.g.,
4967 `<tt>#!/bin/bash</tt>') and the package must depend on the
4968 package providing the shell (unless the shell package is
4969 marked `Essential', e.g., in the case of
4974 You may wish to restrict your script to POSIX features when possible so
4975 that it may use <tt>/bin/sh</tt> as its interpreter. If
4976 your script works with <prgn>ash</prgn>, it's probably
4977 POSIX compliant, but if you are in doubt, use
4978 <tt>/bin/bash</tt>.</p>
4981 Perl scripts should check for errors when making any
4982 system calls, including <tt>open</tt>, <tt>print</tt>,
4983 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.</p>
4986 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided
4987 as scripting languages. See <em>Csh Programming
4988 Considered Harmful</em>, one of the <tt>comp.unix.*</tt>
4989 FAQs. It can be found on
4990 <url id="http://language.perl.com/versus/csh.whynot">, or
4991 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
4992 or even on <ftpsite>ftp.cpan.org</ftpsite>
4993 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
4994 If an upstream package comes with <prgn>csh</prgn> scripts
4995 then you must make sure that they start with
4996 <tt>#!/bin/csh</tt> and make your package depend on the
4997 <prgn>c-shell</prgn> virtual package.</p>
5000 Any scripts which create files in world-writeable
5001 directories (e.g., in <tt>/tmp</tt>) must use a
5002 mechanism which will fail if a file with the same name
5006 The Debian base distribution provides the
5007 <prgn>tempfile</prgn> and <prgn>mktemp</prgn> utilities
5008 for use by scripts for this purpose.</p></sect>
5012 <heading>Symbolic links</heading>
5015 In general, symbolic links within a top-level directory
5016 should be relative, and symbolic links pointing from one
5017 top-level directory into another should be absolute. (A
5018 top-level directory is a sub-directory of the root
5022 In addition, symbolic links should be specified as short
5023 as possible, i.e., link targets like `foo/../bar' are
5027 Note that when creating a relative link using
5028 <prgn>ln</prgn> it is not necessary for the target of the
5029 link to exist relative to the working directory you're
5030 running <prgn>ln</prgn> from; nor is it necessary to
5031 change directory to the directory where the link is to be
5032 made. Simply include the string that should appear as the
5033 target of the link (this will be a pathname relative to
5034 the directory in which the link resides) as the first
5035 argument to <prgn>ln</prgn>.</p>
5038 For example, in your <prgn>Makefile</prgn> or
5039 <tt>debian/rules</tt>, do things like:
5041 ln -fs gcc $(prefix)/bin/cc
5042 ln -fs gcc debian/tmp/usr/bin/cc
5043 ln -fs ../sbin/sendmail $(prefix)/bin/runq
5044 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
5048 A symbolic link pointing to a compressed file should
5049 always have the same file extension as the referenced
5050 file. (For example, if a file `<tt>foo.gz</tt>' is
5051 referenced by a symbolic link, the filename of the link
5052 has to end with `<tt>.gz</tt>' too, as in
5053 `bar.gz.')</p></sect>
5057 <heading>Device files</heading>
5060 Packages must not include device files in the package file
5064 If a package needs any special device files that are not
5065 included in the base system, it must call
5066 <prgn>makedev</prgn> in the <tt>postinst</tt> script,
5067 after asking the user for permission to do so.</p>
5070 Packages must not remove any device files in the
5071 <tt>postrm</tt> or any other script. This is left to the
5072 system administrator.</p>
5075 Debian uses the serial devices
5076 <tt>/dev/ttyS*</tt>. Programs using the old
5077 <tt>/dev/cu*</tt> devices should be changed to use
5078 <tt>/dev/ttyS*</tt>.</p>
5081 <sect id="config files">
5082 <heading>Configuration files</heading>
5084 <heading>Definitions</heading>
5087 <tag>configuration file</tag>
5089 A file that affects the operation of program, or
5090 provides site- or host-specific information, or
5091 otherwise customizes the behavior of program.
5092 Typically, configuration files are intended to be
5093 modified by the system administrator (if needed or
5094 desired) to conform to local policy or provide more
5095 useful site-specific behavior.</p>
5098 <tag><tt>conffile</tt></tag>
5100 A file listed in a package's <tt>conffiles</tt>
5101 file, and is treated specially by <prgn>dpkg</prgn>
5102 (see the <em>Debian Packaging Manual</em>).</p>
5108 The distinction between these two is important; they are
5109 not interchangeable concepts. Almost all
5110 <tt>conffiles</tt> are configuration files, but many
5111 configuration files are not <tt>conffiles</tt>.</p>
5114 Note that a script that embeds configuration information
5115 (such as most of the files in <tt>/etc/init.d</tt> and
5116 <tt>/etc/cron.{daily,weekly,monthly}</tt>) is de-facto a
5117 configuration file and should be treated as such.</p>
5121 <heading>Location</heading>
5123 Any configuration files created or used by your package
5124 must reside in <tt>/etc</tt>. If there are several you
5125 should consider creating a subdirectory of <tt>/etc</tt>
5126 named after your package.</p>
5129 If your package creates or uses configuration files
5130 outside of <tt>/etc</tt>, and it is not feasible to modify
5131 the package to use the <tt>/etc</tt>, you should still put
5132 the files in <tt>/etc</tt> and create symbolic links to
5133 those files from the location that the package
5138 <heading>Behavior</heading>
5140 Configuration file handling must conform to the following
5144 <p>local changes must be preserved during a package
5148 <p>configuration files must be preserved when the
5149 package is removed, and only deleted when the
5150 package is purged.</p>
5155 The easy way to achieve this behavior is to make the
5156 configuration file a <tt>conffile</tt>. This is
5157 appropriate only if it is possible to distribute a default
5158 version that will work for most installations, although
5159 some system administrators may choose to modify it. This
5160 implies that the default version will be part of the
5161 package distribution, and must not be modified by the
5162 maintainer scripts during installation (or at any other
5167 In order to ensure that local changes are preserved
5168 correctly, no package may contain or make hard links to
5172 Rationale: There are two problems with hard links.
5173 The first is that some editors break the link while
5174 editing one of the files, so that the two files may
5175 unwittingly become different. The second is that
5176 <prgn>dpkg</prgn> might break the hard link while
5177 upgrading <tt>conffile</tt>s.
5182 The other way to do it is via the maintainer scripts.
5183 In this case, the configuration file must not be listed as
5184 a <tt>conffile</tt> and must not be part of the package
5185 distribution. If the existence of a file is required for
5186 the package to be sensibly configured it is the
5187 responsibility of the package maintainer to write scripts
5188 which correctly create, update, maintain and
5189 remove-on-purge the file. These scripts must be idempotent
5190 (i.e., must work correctly if <prgn>dpkg</prgn> needs to
5191 re-run them due to errors during installation or removal),
5192 must cope with all the variety of ways <prgn>dpkg</prgn>
5193 can call maintainer scripts, must not overwrite or
5194 otherwise mangle the user's configuration without asking,
5195 must not ask unnecessary questions (particularly during
5196 upgrades), and otherwise be good citizens.</p>
5199 The scripts are not required to configure every possible option for
5200 the package, but only those necessary to get the package
5201 running on a given system. Ideally the sysadmin should not
5202 have to do any configuration other than that done
5203 (semi-)automatically by the <tt>postinst</tt> script.</p>
5206 A common practice is to create a script called
5207 <tt><var>package</var>-configure</tt> and have the
5208 package's <tt>postinst</tt> call it if and only if the
5209 configuration file does not already exist. In certain
5210 cases it is useful for there to be an example or template
5211 file which the maintainer scripts use. Such files should
5212 be in <tt>/usr/share/doc</tt> if they are examples or
5213 <tt>/usr/lib</tt> if they are templates, and should be
5214 perfectly ordinary <prgn>dpkg</prgn>-handled files
5215 (<em>not</em> <tt>conffiles</tt>).</p>
5218 These two styles of configuration file handling must
5219 not be mixed, for that way lies madness:
5220 <prgn>dpkg</prgn> will ask about overwriting the file
5221 every time the package is upgraded.</p>
5226 <heading>Sharing configuration files</heading>
5228 Packages that are not tagged as <em>conflicting</em> with
5229 each other must not specify the same file as
5230 <tt>conffile</tt>.</p>
5233 The maintainer scripts must not alter the conffile of
5234 <em>any</em> package, including the one the scripts belong
5238 If two or more packages use the same configuration file
5239 and it is reasonable for both to be installed at the same
5240 time, one of these packages must be defined as
5241 <em>owner</em> of the configuration file, i.e., it will be
5242 the package to list that distributes the file and lists it
5243 as a <tt>conffile</tt>. Other packages that use the
5244 configuration file must depend on the owning package if
5245 they require the configuration file to operate. If the
5246 other package will use the configuration file if present,
5247 but is capable of operating without it, no dependency need
5251 If it is desirable for two or more related packages to
5252 share a configuration file <em>and</em> for all of the
5253 related packages to be able to modify that configuration
5254 file, then the following should be done:
5258 have one of the related packages (the "core"
5259 package) manage the configuration file with
5260 maintainer scripts as described in the previous
5264 the core package should also provide a program that
5265 the other packages may use to modify the
5266 configuration file.</p>
5270 the related packages must use the provided program
5271 to make any modifications to the configuration file.
5272 They should either depend on the core package to
5273 guarantee that the configuration modifier program is
5274 available or accept gracefully that they cannot
5275 modify the configuration file if it is not.</p>
5280 Sometimes it's appropriate to create a new package which
5281 provides the basic infrastructure for the other packages
5282 and which manages the shared configuration files. (Check
5283 out the <tt>sgml-base</tt> package as an example.)</p>
5287 <heading>User configuration files ("dotfiles")</heading>
5290 Files in <tt>/etc/skel</tt> will automatically be copied
5291 into new user accounts by <prgn>adduser</prgn>. They
5292 should not be referenced there by any program.</p>
5295 Therefore, if a program needs a dotfile to exist in
5296 advance in <tt>$HOME</tt> to work sensibly, that dotfile
5297 should be installed in <tt>/etc/skel</tt> (and listed in
5298 conffiles, if it is not generated and modified dynamically
5299 by the package's installation scripts).</p>
5302 However, programs that require dotfiles in order to
5303 operate sensibly (dotfiles that they do not create
5304 themselves automatically, that is) are a bad thing, and
5305 programs should be configured by the Debian default
5306 installation as close to normal as possible.</p>
5309 Therefore, if a program in a Debian package needs to be
5310 configured in some way in order to operate sensibly that
5311 configuration should be done in a site-wide global
5312 configuration file elsewhere in <tt>/etc</tt>. Only if the
5313 program doesn't support a site-wide default configuration
5314 and the package maintainer doesn't have time to add it
5315 may a default per-user file be placed in
5316 <tt>/etc/skel</tt>.</p>
5319 <tt>/etc/skel</tt> should be as empty as we can make it.
5320 This is particularly true because there is no easy
5321 mechanism for ensuring that the appropriate dotfiles are
5322 copied into the accounts of existing users when a package
5328 <heading>Log files</heading>
5330 The traditional approach to log files has been to set up ad
5331 hoc log rotation schemes using simple shell scripts and
5332 cron. While this approach is highly customizable, it
5333 requires quite a lot of sysadmin work. Even though the
5334 original Debian system helped a little by automatically
5335 installing a system which can be used as a template, this
5336 was deemed not enough.
5340 A better scheme is to use logrotate, a GPL'd program
5341 developed by Red Hat, which centralizes log management. It
5342 has both a configuration file (<tt>/etc/logrotate.conf</tt>)
5343 and a directory where packages can drop logrotation info
5344 (<tt>/etc/logrotate.d</tt>).
5348 Log files should usually be named
5349 <tt>/var/log/<var>package</var>.log</tt>. If you have many
5350 log files, or need a separate directory for permissions
5351 reasons (<tt>/var/log</tt> is writable only by
5352 <tt>root</tt>), you should usually create a directory named
5353 <tt>/var/log/<var>package</var></tt>.</p>
5356 Log files must be rotated occasionally so
5357 that they don't grow indefinitely; the best way to do this
5358 is to drop a script into the directory
5359 <tt>/etc/logrotate.d</tt> and use the facilities provided by
5360 logrotate. Here is a good example for a logrotate config
5361 file (for more information see <manref name="logrotate"
5369 /etc/init.d/foo force-reload
5373 Which rotates all files under `/var/log/foo', saves 12
5374 compressed generations, and sends a HUP signal at the end of
5380 Log files should be removed when the package is
5381 purged (but not when it is only removed), by checking the
5382 argument to the <tt>postrm</tt> script (see the <em>Debian
5383 Packaging Manual</em> for details).</p>
5388 <heading>Permissions and owners</heading>
5391 The rules in this section are guidelines for general use.
5392 If necessary you may deviate from the details below.
5393 However, if you do so you must make sure that what is done
5394 is secure and you should try to be as consistent as possible
5395 with the rest of the system. You should probably also
5396 discuss it on <prgn>debian-devel</prgn> first.</p>
5399 Files should be owned by <tt>root.root</tt>, and made
5400 writable only by the owner and universally readable (and
5401 executable, if appropriate).</p>
5404 Directories should be mode 755 or (for group-writability)
5405 mode 2775. The ownership of the directory should be
5406 consistent with its mode--if a directory is mode 2775, it
5407 should be owned by the group that needs write access to
5411 Setuid and setgid executables should be mode 4755 or 2755
5412 respectively, and owned by the appropriate user or group.
5413 They should not be made unreadable (modes like 4711 or
5414 2711 or even 4111); doing so achieves no extra security,
5415 because anyone can find the binary in the freely available
5416 Debian package--it is merely inconvenient. For the same
5417 reason you should not restrict read or execute permissions
5418 on non-set-id executables.</p>
5421 Some setuid programs need to be restricted to particular
5422 sets of users, using file permissions. In this case they
5423 should be owned by the uid to which they are set-id, and
5424 by the group which should be allowed to execute them.
5425 They should have mode 4754; there is no point in making
5426 them unreadable to those users who must not be allowed to
5430 You must not arrange that the system administrator can only
5431 reconfigure the package to correspond to their local
5432 security policy by changing the permissions on a binary.
5433 Ordinary files installed by <prgn>dpkg</prgn> (as opposed
5434 to conffiles and other similar objects) have their
5435 permissions reset to the distributed permissions when the
5436 package is reinstalled. Instead you should consider (for
5437 example) creating a group for people allowed to use the
5438 program(s) and making any setuid executables executable
5439 only by that group.</p>
5442 If you need to create a new user or group for your package
5443 there are two possibilities. Firstly, you may need to
5444 make some files in the binary package be owned by this
5445 user or group, or you may need to compile the user or
5446 group id (rather than just the name) into the binary
5447 (though this latter should be avoided if possible, as in
5448 this case you need a statically allocated id).</p>
5451 If you need a statically allocated id, you must ask for a
5452 user or group id from the base system
5453 maintainer, and must not release the package until you
5454 have been allocated one. Once you have been allocated one
5455 you must make the package depend on a version of the base
5456 system with the id present in <tt>/etc/passwd</tt> or
5457 <tt>/etc/group</tt>, or alternatively arrange for your
5458 package to create the user or group itself with the
5459 correct id (using <tt>adduser</tt>) in its pre- or
5460 post-installation script (the latter is to be preferred if
5461 it is possible).</p>
5464 On the other hand, the program might be able to determine the
5465 uid or gid from the group name at runtime, so that a
5466 dynamic id can be used. In this case you should choose an
5467 appropriate user or group name, discussing this on
5468 <prgn>debian-devel</prgn> and checking with the base
5469 system maintainer that it is unique and that they do not
5470 wish you to use a statically allocated id instead. When
5471 this has been checked you must arrange for your package to
5472 create the user or group if necessary using
5473 <prgn>adduser</prgn> in the pre- or post-installation
5474 script (again, the latter is to be preferred if it is
5478 Note that changing the numeric value of an id associated with a name
5479 is very difficult, and involves searching the file system for all
5480 appropriate files. You need to think carefully whether a static or
5481 dynamic id is required, since changing your mind later will cause
5487 <heading>Customized programs</heading>
5489 <sect id="arch-spec">
5490 <heading>Architecture specification strings</heading>
5493 If a program needs to specify an <em>architecture specification
5494 string</em> in some place, the following format should be used:
5496 <arch>-<os>
5498 where `<arch>' is one of the following: i386, alpha, arm, m68k,
5499 powerpc, sparc and `<os>' is one of: linux, gnu. Use
5500 of <em>gnu</em> in this string is reserved for the GNU/Hurd
5501 operating system.</p>
5503 Note, that we don't want to use `<arch>-debian-linux'
5504 to apply to the rule `architecture-vendor-os' since this
5505 would make our programs incompatible to other Linux
5506 distributions. Also note, that we don't use
5507 `<arch>-unknown-linux', since the `unknown' does not
5508 look very good.</p></sect>
5512 <heading>Daemons</heading>
5515 The configuration files <tt>/etc/services</tt>,
5516 <tt>/etc/protocols</tt>, and <tt>/etc/rpc</tt> are managed
5517 by the <prgn>netbase</prgn> package and may not be modified
5518 by other packages.</p>
5521 If a package requires a new entry in one of these files, the
5522 maintainer should get in contact with the
5523 <prgn>netbase</prgn> maintainer, who will add the entries
5524 and release a new version of the <prgn>netbase</prgn>
5528 The configuration file <tt>/etc/inetd.conf</tt> must not be
5529 modified by the package's scripts except via the
5530 <prgn>update-inetd</prgn> script or the
5531 <prgn>DebianNet.pm</prgn> Perl module.</p>
5534 If a package wants to install an example entry into
5535 <tt>/etc/inetd.conf</tt>, the entry must be preceded with
5536 exactly one hash character (<tt>#</tt>). Such lines are
5537 treated as `commented out by user' by the
5538 <prgn>update-inetd</prgn> script and are not changed or
5539 activated during a package updates.</p></sect>
5543 <heading>Using pseudo-ttys and modifying wtmp, utmp and lastlog</heading>
5546 Some programs need to create pseudo-ttys. This should be done
5547 using Unix98 ptys if the C library supports it. The resulting
5548 program must not be installed setuid root, unless that
5549 is required for other functionality.
5553 The files <tt>/var/run/utmp</tt>, <tt>/var/log/wtmp</tt> and
5554 <tt>/var/log/lastlog</tt> must be installed writeable by
5555 group utmp. Programs who need to modify those files must
5556 be installed setgid utmp.
5561 <heading>Editors and pagers</heading>
5564 Some programs have the ability to launch an editor or pager
5565 program to edit or display a text document. Since there are
5566 lots of different editors and pagers available in the Debian
5567 distribution, the system administrator and each user should
5568 have the possibility to choose his/her preferred editor and
5572 In addition, every program should choose a good default
5573 editor/pager if none is selected by the user or system
5577 Thus, every program that launches an editor or pager must
5578 use the EDITOR or PAGER environment variables to determine
5579 the editor/pager the user wants to get started. If these
5580 variables are not set, the programs <tt>/usr/bin/editor</tt>
5581 and <tt>/usr/bin/pager</tt> should be used, respectively.</p>
5584 These two files are managed through `alternatives.' That is,
5585 every package providing an editor or pager must call the
5586 <prgn>update-alternatives</prgn> script to register these
5590 If it is very hard to adapt a program to make us of the
5591 EDITOR and PAGER variables, that program may be configured
5592 to use <tt>/usr/bin/sensible-editor</tt> and
5593 <tt>/usr/bin/sensible-pager</tt> as editor or pager program,
5594 respectively. These are two scripts provided in the Debian
5595 base system that check the EDITOR and PAGER variables and
5596 launch the appropriate program or fall back to
5597 <tt>/usr/bin/editor</tt> and <tt>/usr/bin/pager</tt>,
5601 A program may also use the VISUAL environment variable to
5602 determine the user's choice of editor. If it exists, it
5603 should take precedence over EDITOR. This is in fact what
5604 <tt>/usr/bin/sensible-editor</tt> does.</p>
5607 Since the Debian base system already provides an editor and
5608 a pager program, it is not required for a package to depend on
5609 `editor' and `pager', nor is it required for a package to
5610 provide such virtual packages.</p></sect>
5613 <sect id="web-appl">
5614 <heading>Web servers and applications</heading>
5617 This section describes the locations and URLs that should
5618 be used by all web servers and web application in the Debian
5624 <p>Cgi-bin executable files are installed in the
5627 /usr/lib/cgi-bin/<cgi-bin-name>
5629 and should be referred to as
5631 http://localhost/cgi-bin/<cgi-bin-name>
5632 </example></p></item>
5635 <item><p>Access to html documents</p>
5638 Html documents for a package are stored in
5639 <tt>/usr/share/doc/<var>package</var></tt> but should
5640 be accessed via symlinks as
5641 <tt>/usr/doc/<var>package</var></tt><footnote> for
5642 backward compatibility, see <ref id="usrdoc"></footnote>
5643 and can be referred to as
5645 http://localhost/doc/<package>/<filename>
5646 </example></p></item>
5649 <item><p>Web Document Root</p>
5652 Web Applications should try to avoid storing files in
5653 the Web Document Root. Instead they should use the
5654 /usr/share/doc/<package> directory for documents and
5655 register the Web Application via the menu package. If
5656 access to the web-root is unavoidable then use
5660 as the Document Root. This might be just a
5661 symbolic link to the location where the sysadmin has
5662 put the real document root.</p>
5665 </enumlist></p></sect>
5669 <heading>Mail transport agents</heading>
5672 Debian packages which process electronic mail, whether
5673 mail-user-agents (MUAs) or mail-transport-agents (MTAs),
5674 must make sure that they are compatible with the
5675 configuration decisions below. Failure to do this may
5676 result in lost mail, broken <tt>From:</tt> lines, and other
5677 serious brain damage!</p>
5680 The mail spool is <tt>/var/spool/mail</tt> and the interface
5681 to send a mail message is <tt>/usr/sbin/sendmail</tt> (as
5682 per the FHS). The mail spool is part of the base system
5683 and not part of the MTA package.</p>
5686 All Debian MUAs, MTAs, MDAs and other mailbox accessing
5687 programs (like IMAP daemons) must lock the mailbox in an
5688 NFS-safe way. This means that <tt>fcntl()</tt> locking must
5689 to be combined with dot locking. To avoid dead locks, a
5690 program should use <tt>fcntl()</tt> first and dot locking
5691 after this or alternatively implement the two locking
5692 methods in a non blocking way<footnote>
5694 If it is not possible to establish both locks, the
5695 system shouldn't wait for the second lock to be
5696 established, but remove the first lock, wait a (random)
5697 time, and start over locking again.</p>
5698 </footnote>. Using the functions <tt>maillock</tt> and
5699 <tt>mailunlock</tt> provided by the
5700 <tt>liblockfile*</tt><footnote>
5702 <tt>liblockfile</tt> version >>1.01</p>
5703 </footnote> packages is the recommended way to realize this.
5707 Mailboxes are generally 660 <tt><var>user</var>.mail</tt>
5708 unless the user has chosen otherwise. A MUA may remove a
5709 mailbox (unless it has nonstandard permissions) in which
5710 case the MTA or another MUA must recreate it if needed.
5711 Mailboxes must be writable by group mail.</p>
5714 The mail spool is 2775 <tt>root.mail</tt>, and MUAs should
5715 be setgid mail to do the locking mentioned above (and
5716 must obviously avoid accessing other users' mailboxes
5717 using this privilege).</p>
5720 <tt>/etc/aliases</tt> is the source file for the system mail
5721 aliases (e.g., postmaster, usenet, etc.)--it is the one
5722 which the sysadmin and <tt>postinst</tt> scripts may edit.
5723 After <tt>/etc/aliases</tt> is edited the program or human
5724 editing it must call <prgn>newaliases</prgn>. All MTA
5725 packages must come with a <prgn>newaliases</prgn> program,
5726 even if it does nothing, but older MTA packages do not do
5727 this so programs should not fail if <prgn>newaliases</prgn>
5728 cannot be found.</p>
5731 The convention of writing <tt>forward to
5732 <var>address</var></tt> in the mailbox itself is not
5733 supported. Use a <tt>.forward</tt> file instead.</p>
5736 The <prgn>rmail</prgn> program used by UUCP
5737 for incoming mail should be <tt>/usr/sbin/rmail</tt>.
5738 Likewise, <prgn>rsmtp</prgn>, for receiving
5739 batch-SMTP-over-UUCP, should be <tt>/usr/sbin/rsmtp</tt> if it
5743 If you need to know what name to use (for example) on
5744 outgoing news and mail messages which are generated locally,
5745 you should use the file <tt>/etc/mailname</tt>. It will
5746 contain the portion after the username and <tt>@</tt> (at)
5747 sign for email addresses of users on the machine (followed
5751 A package should check for the existence of this file. If
5752 it exists it should use it without comment. (An MTA's
5753 prompting configuration script may wish to prompt the user
5754 even if it finds this file exists.) If it does not exist it
5755 should prompt the user for the value and store it in
5756 <tt>/etc/mailname</tt> as well as using it in the package's
5757 configuration. The prompt should make it clear that the
5758 name will not just be used by that package. For example, in
5759 this situation the INN package says:
5761 Please enter the `mail name' of your system. This is the
5762 hostname portion of the address to be shown on outgoing
5763 news and mail messages. The default is
5764 <var>syshostname</var>, your system's host name. Mail
5765 name [`<var>syshostname</var>']:
5767 where <var>syshostname</var> is the output of <tt>hostname
5768 --fqdn</tt>.</p></sect>
5772 <heading>News system configuration</heading>
5775 All the configuration files related to the NNTP (news)
5776 servers and clients should be located under
5777 <tt>/etc/news</tt>.</p>
5780 There are some configuration issues that apply to a number
5781 of news clients and server packages on the machine. These
5785 <tag>/etc/news/organization</tag>
5786 <item><p>A string which should appear as the
5787 organization header for all messages posted
5788 by NNTP clients on the machine</p></item>
5790 <tag>/etc/news/server</tag>
5791 <item><p>Contains the FQDN of the upstream NNTP
5792 server, or localhost if the local machine is
5793 an NNTP server.</p></item>
5796 Other global files may be added as required for cross-package news
5797 configuration.</p></sect>
5801 <heading>Programs for the X Window System</heading>
5804 <em>Programs that may be configured with support for the X Window
5805 System</em> must be configured to do so and must declare any
5806 package dependencies necessary to satisfy their runtime
5807 requirements when using the X Window System, unless the package
5808 in question is of standard or higher priority, in which case
5809 X-specific binaries may be split into a separate package, or
5810 alternative versions of the package with X support may be
5813 <strong>NOTE</strong> The forthcoming major X Window
5814 System release shall probably change this
5818 This seems to be more what people want. It will enable
5819 packages like vim-tty to become legal if they are
5820 promoted to standard priority. Also, that X client in
5821 mtools can be split into its own package and made
5825 This paves the way for xlib6g and xfree86-common to be
5826 moved from standard to optional, <strong>if</strong> all
5827 Xlib dependent packages are moved from standard to
5828 optional priority (or if non-Xlib-linked versions are
5829 retained in standard). That, however is up to the
5830 affected package maintainers and the archive
5831 maintainers, and is not mandated by this policy.
5838 <em>Packages which provide an X server</em> that, directly or
5839 indirectly, communicates with real input and display hardware
5840 should declare in their control data that they provide the
5841 virtual package <tt>xserver</tt>.
5844 Rationale: implement current practice, and provide an
5845 actual policy for usage of the "xserver" virtual package
5846 which appears in the virtual packages list.
5847 In a nutshell, X servers that interface directly with
5848 the display and input hardware or via another subsystem
5849 (e.g., GGI) should provide xserver. Things like Xvfb,
5850 Xnest, and Xprt should not. <strong>NOTE</strong> The
5851 forthcoming major X Window System release shall probably
5852 change this drastically.
5858 <em>Packages that provide a terminal emulator</em> for the X
5859 Window System which support a terminal type with a terminfo
5860 description provided in the <tt>ncurses-base</tt> package
5861 should declare in their control data that they provide the
5862 virtual package <tt>x-terminal-emulator</tt>. They should
5863 also register themselves as an alternative for
5864 <tt>/usr/bin/x-terminal-emulator</tt>, with a priority of
5869 <em>Packages that provide window managers</em> should declare in
5870 their control data that they provide the virtual package
5871 <tt>x-window-manager</tt>. They should also register themselves as an
5872 alternative for <tt>/usr/bin/x-window-manager</tt>, with a priority
5873 calculated as follows:
5875 <item>Start with a priority of 20.</item>
5876 <item>If the window manager supports the Debian menu system,
5877 add 20 points if this support is available in the
5878 package's default configuration (i.e., no
5879 configuration files belonging to the system or user
5880 have to be edited to activate the feature); if
5881 configuration files must be modified, add only 10
5883 <item>If the window manager permits the X session to be
5884 restarted using a <em>different</em> window manager
5885 (without killing the X server) in its default
5886 configuration, add 10 points; otherwise add
5892 <em>Packages that provide fonts for the X Window System</em>
5893 must do a number of things to ensure that they are both
5894 available without modification of the X or font server
5895 configuration, and that they do not corrupt files used by
5896 other font packages to register information about themselves.
5899 Fonts of any type supported by the X Window System
5900 should be be in a separate binary package from any
5901 executables, libraries, or documentation (except that
5902 specific to the fonts shipped); if a program or
5903 library is <em>unusable</em> without one or more
5904 specific fonts, the package containing the program or
5905 library should declare a dependency on the package(s)
5906 containing the font(s) it requires.
5909 BDF fonts should be converted to PCF fonts with the
5910 <tt>bdftopcf</tt> utility (available in the
5911 <tt>xbase-clients</tt> package, <tt>gzip</tt>ped, and
5912 placed in a directory that corresponds to their
5916 100 dpi fonts should be placed in
5917 <tt>/usr/X11R6/lib/X11/fonts/100dpi/</tt>.
5920 75 dpi fonts should be placed in
5921 <tt>/usr/X11R6/lib/X11/fonts/75dpi/</tt>.
5924 Character-cell fonts, cursor fonts, and other
5925 low-resolution fonts should be placed in
5926 <tt>/usr/X11R6/lib/X11/fonts/misc/</tt>.
5931 Speedo fonts should be placed in
5932 <tt>/usr/X11R6/lib/X11/fonts/Speedo/</tt>.
5935 Type 1 fonts should be placed in
5936 <tt>/usr/X11R6/lib/X11/fonts/Type1/</tt>. If font
5937 metric files are available, they may be placed here as
5941 Subdirectories of <tt>/usr/X11R6/lib/X11/fonts/</tt>
5942 other than those listed above should be neither created nor
5943 used. (The <tt>PEX</tt> and <tt>cyrillic</tt> directories are
5944 excepted for historical reasons, but installation of files into
5945 these directories remains discouraged.)
5948 Font packages may, instead of placing files directly in
5949 the X font directories listed above, provide symbolic links in
5950 the font directory which point to the files' actual location
5951 in the filesystem. Such a location should comply with the
5955 Font packages should not contain both 75dpi and 100dpi
5956 versions of a font. If both are available, they should be
5957 provided in separate binary packages with "-75dpi" or "-100dpi"
5958 appended to the names of the packages containing the
5959 corresponding fonts.
5962 Fonts destined for the <tt>misc</tt> subdirectory should
5963 not be included in the same package as 75dpi or 100dpi fonts;
5964 instead, they should be provided in a separate package with
5965 "-misc" appended to its name.
5968 Font packages <em>must not</em> provide the files
5969 <tt>fonts.dir</tt>, <tt>fonts.alias</tt>, or
5970 <tt>fonts.scale</tt> in a font directory.
5973 <tt>fonts.dir</tt> files must not be provided at
5977 <tt>fonts.alias</tt> and <tt>fonts.scale</tt>
5978 files, if needed, should be provided in the
5980 <tt>/etc/X11/fonts/<em>fontdir</em>/<em>package</em>.<em>extension</em></tt>,
5981 where <em>fontdir</em> is the name of the
5983 <tt>/usr/X11R6/lib/X11/fonts/</tt> where the
5984 package's corresponding fonts are stored (e.g.,
5985 <tt>75dpi</tt> or <tt>misc</tt>),
5986 <em>package</em> is the name of the package that
5987 provides these fonts, and <em>extension</em> is
5988 either <tt>scale</tt> or <tt>alias</tt>,
5989 whichever corresponds to the file
5995 Font packages must declare a dependency on
5996 <tt>xbase-clients</tt> and, in the package
5997 post-installation and post-removal scripts, invoke the
5998 <tt>mkfontdir</tt> command on each directory into
5999 which they installed fonts.
6002 Font packages that provide one or more
6003 <tt>fonts.scale</tt> files as described above must declare a
6004 versioned dependency on <tt>xbase-clients (>=
6005 3.3.3.1-5)</tt> and invoke <tt>update-fonts-scale</tt> on each
6006 directory into which they installed fonts
6007 <em>before</em> invoking <tt>mkfontdir</tt> on that
6008 directory. This invocation must occur in both the
6009 post-installation and post-removal scripts.
6012 Font packages that provide one or more
6013 <tt>fonts.alias</tt> files as described above must
6014 declare a versioned dependency on <tt>xbase-clients
6015 (>= 3.3.3.1-5)</tt> and, in the package
6016 post-installation and post-removal scripts, invoke
6017 <tt>update-fonts-alias</tt> on each directory into
6018 which they installed fonts.
6021 Font packages must not provide alias names for the
6022 fonts they include which collide with alias names already in
6023 use by fonts already packaged.
6026 Font packages must not provide fonts with the same XLFD
6027 registry name as another font already packaged.
6033 <em>Application defaults</em> files must be installed in the
6034 directory <tt>/usr/X11R6/lib/X11/app-defaults/</tt>.
6036 <p>Note: This shall change very shortly.</p>
6038 They should not be registered as <em>conffile</em>s or
6039 otherwise treated as configuration files. Customization of
6040 programs' X resources may be supported with the provision of
6041 a file with the same name as that of the package placed in
6042 the <tt>/etc/X11/Xresources/</tt> directory, which must
6043 registered as a <em>conffile</em>. <em>Important:</em>
6044 packages that install files into the
6045 <tt>/etc/X11/Xresources/</tt> directory <em>must</em>
6046 declare a conflict with <tt>xbase (<<
6047 3.3.2.3a-2)</tt>; if this is not done it is possible for the
6048 installing package to destroy a previously-existing
6049 <tt>/etc/X11/Xresources</tt> <em>file</em> which had been
6050 customized by the system administrator.
6052 <p>Rationale: clarifies the language to properly
6053 address the package maintainer, not the system
6054 administrator, as to how to manage
6055 /etc/X11/Xresources.</p>
6061 <em>Packages using the X Window System should abide by the FHS
6062 standard whenever possible</em>; they should install binaries,
6063 libraries, manual pages, and other files in FHS-mandated
6064 locations wherever possible. This means that files must
6065 not be installed into <tt>/usr/X11R6/bin/</tt>,
6066 <tt>/usr/X11R6/lib/</tt>, or <tt>/usr/X11R6/man/</tt> unless
6067 this is necessary for the package to operate properly.
6068 Configuration files for window managers and display managers
6069 should be placed in a subdirectory of <tt>/etc/X11/</tt>
6070 corresponding to the package name due to these programs'
6071 tight integration with the mechanisms of the X Window
6072 System. Application-level programs should use the
6073 <tt>/etc/</tt> directory unless otherwise mandated by
6074 policy. The installation of files into subdirectories of
6075 <tt>/usr/X11R6/include/X11/</tt> and
6076 <tt>/usr/X11R6/lib/X11/</tt> is permitted but discouraged;
6077 package maintainers should determine if subdirectories of
6078 <tt>/usr/lib/</tt> and <tt>/usr/share/</tt> can be used
6079 instead (symlinks from the X11R6 directories to
6080 FHS-compliant locations is encouraged if the program is not
6081 easily configured to look elsewhere for its files).
6082 Packages must not provide -- or install files into -- the
6083 directories <tt>/usr/bin/X11/</tt>,
6084 <tt>/usr/include/X11/</tt>, or <tt>/usr/lib/X11/</tt>.
6085 Files within a package should, however, make reference to
6086 these directories, rather than their X11R6-named
6087 counterparts <tt>/usr/X11R6/bin/</tt>,
6088 <tt>/usr/X11R6/include/X11/</tt>, and
6089 <tt>/usr/X11R6/lib/X11/</tt>, if the resources being
6090 referred to have not been moved to FHS-compliant locations.
6094 <em>Programs that require the non-DFSG-compliant OSF/Motif
6095 library</em> should be compiled against and tested with
6096 LessTif (a free re-implementation of Motif) instead. If the
6097 maintainer judges that the program or programs do not work
6098 sufficiently well with LessTif to be distributed and
6099 supported, but do so when compiled against Motif, then two
6100 versions of the package should be created; one linked
6101 statically against Motif and with <tt>-smotif</tt> appended
6102 to the package name, and one linked dynamically against
6103 Motif and with <tt>-dmotif</tt> appended to the package
6104 name. Both Motif-linked versions are dependent upon
6105 non-DFSG-compliant software and thus cannot be uploaded to
6106 the main distribution; if the software is itself
6107 DFSG-compliant it may be uploaded to the contrib
6108 distribution. While known existing versions of OSF/Motif
6109 permit unlimited redistribution of binaries linked against
6110 the library (whether statically or dynamically), it is the
6111 package maintainer's responsibility to determine whether
6112 this is permitted by the license of the copy of OSF/Motif in
6113 his or her possession.
6119 <heading>Emacs lisp programs</heading>
6122 Please refer to the `Debian Emacs Policy' (documented in
6123 <tt>debian-emacs-policy.gz</tt> of the
6124 <prgn>emacsen-common</prgn> package) for details of how to
6125 package emacs lisp programs.</p></sect>
6129 <heading>Games</heading>
6132 The permissions on /var/games are 755
6133 <tt>root.root</tt>.</p>
6136 Each game decides on its own security policy.</p>
6139 Games which require protected, privileged access to
6140 high-score files, savegames, etc., may be made
6141 set-<em>group</em>-id (mode 2755) and owned by
6142 <tt>root.games</tt>, and use files and directories with
6143 appropriate permissions (770 <tt>root.games</tt>, for
6144 example). They must not be made
6145 set-<em>user</em>-id, as this causes security problems. (If
6146 an attacker can subvert any set-user-id game they can
6147 overwrite the executable of any other, causing other players
6148 of these games to run a Trojan horse program. With a
6149 set-group-id game the attacker only gets access to less
6150 important game data, and if they can get at the other
6151 players' accounts at all it will take considerably more
6155 Some packages, for example some fortune cookie programs, are
6156 configured by the upstream authors to install with their
6157 data files or other static information made unreadable so
6158 that they can only be accessed through set-id programs
6159 provided. You should not do this in a Debian package: anyone can
6160 download the <tt>.deb</tt> file and read the data from it,
6161 so there is no point making the files unreadable. Not
6162 making the files unreadable also means that you don't have
6163 to make so many programs set-id, which reduces the risk of a
6167 As described in the FHS, binaries of games should be
6168 installed in the directory <tt>/usr/games</tt>. This also
6169 applies to games that use the X Window System. Manual pages
6170 for games (X and non-X games) should be installed in
6171 <tt>/usr/share/man/man6</tt>.</p>
6175 <chapt><heading>Documentation</heading>
6179 <heading>Manual pages</heading>
6182 You should install manual pages in <prgn>nroff</prgn> source
6183 form, in appropriate places under <tt>/usr/share/man</tt>. You
6184 should only use sections 1 to 9 (see the FHS for more
6185 details). You must not install a preformatted `cat
6189 Each program, utility, and function should have an
6190 associated manpage included in the same package. It is
6191 suggested that all configuration files also have a manual
6192 page included as well.
6196 If no manual page is available for a particular program,
6197 utility, function or configuration file and this is reported as a bug on
6198 debian-bugs, a symbolic link from the requested manual page
6199 to the <manref name="undocumented" section="7"> manual page
6200 may be provided. This symbolic link can be created from
6201 <tt>debian/rules</tt> like this:
6203 ln -s ../man7/undocumented.7.gz \
6204 debian/tmp/usr/share/man/man[1-9]/the_requested_manpage.[1-9].gz
6206 This manpage claims that the lack of a manpage has been
6207 reported as a bug, so you may only do this if it really has
6208 (you can report it yourself, if you like). Do not close the
6209 bug report until a proper manpage is available.</p>
6212 You may forward a complaint about a missing manpage to the
6213 upstream authors, and mark the bug as forwarded in the
6214 Debian bug tracking system. Even though the GNU Project do
6215 not in general consider the lack of a manpage to be a bug,
6216 we do--if they tell you that they don't consider it a bug
6217 you should leave the bug in our bug tracking system open
6221 Manual pages should be installed compressed using <tt>gzip
6225 If one manpage needs to be accessible via several names it
6226 is better to use a symbolic link than the <tt>.so</tt>
6227 feature, but there is no need to fiddle with the relevant
6228 parts of the upstream source to change from <tt>.so</tt> to
6229 symlinks--don't do it unless it's easy. You should not create hard
6230 links in the manual page directories, nor put
6231 absolute filenames in <tt>.so</tt> directives. The filename
6232 in a <tt>.so</tt> in a manpage should be relative to the
6233 base of the manpage tree (usually
6234 <tt>/usr/share/man</tt>).</p></sect>
6238 <heading>Info documents</heading>
6241 Info documents should be installed in <tt>/usr/share/info</tt>.
6242 They should be compressed with <tt>gzip -9</tt>.</p>
6245 Your package should call <prgn>install-info</prgn> to update the Info
6247 file, in its post-installation script:
6249 install-info --quiet --section Development Development \
6250 /usr/share/info/foobar.info
6254 It is a good idea to specify a section for the location of
6255 your program; this is done with the <tt>--section</tt>
6256 switch. To determine which section to use, you should look
6257 at <tt>/usr/share/info/dir</tt> on your system and choose the most
6258 relevant (or create a new section if none of the current
6259 sections are relevant). Note that the <tt>--section</tt>
6260 flag takes two arguments; the first is a regular expression
6261 to match (case-insensitively) against an existing section,
6262 the second is used when creating a new one.</p>
6265 You should remove the entries in the pre-removal script:
6267 install-info --quiet --remove /usr/share/info/foobar.info
6271 If <prgn>install-info</prgn> cannot find a description entry
6272 in the Info file you must supply one. See <manref
6273 name="install-info" section="8"> for details.</p>
6277 <heading>Additional documentation</heading>
6280 Any additional documentation that comes with the package may
6281 be installed at the discretion of the package maintainer.
6282 Text documentation should be installed in a directory
6283 <tt>/usr/share/doc/<var>package</var></tt>, where
6284 <var>package</var> is the name of the package, and
6285 compressed with <tt>gzip -9</tt> unless it is small.</p>
6288 If a package comes with large amounts of documentation which
6289 many users of the package will not require you should create
6290 a separate binary package to contain it, so that it does not
6291 take up disk space on the machines of users who do not need
6292 or want it installed.</p>
6295 It is often a good idea to put text information files
6296 (<tt>README</tt>s, changelogs, and so forth) that come with
6297 the source package in <tt>/usr/share/doc/<var>package</var></tt>
6298 in the binary package. However, you don't need to install
6299 the instructions for building and installing the package, of
6304 <heading>Accessing the documentation</heading>
6307 Former Debian releases placed all additional documentation
6308 in <tt>/usr/doc/<var>package</var></tt>. To realize a
6310 <tt>/usr/share/doc/<var>package</var></tt>, each package
6311 must maintain a symlink <tt>/usr/doc/<var>package</var></tt>
6312 that points to the new location of its documentation in
6313 <tt>/usr/share/doc/<var>package</var></tt><footnote>These
6314 symlinks will be removed in the future, but they have to be
6315 there for compatibility reasons until all packages have
6316 moved and the policy is changed accordingly.</footnote>.
6317 The symlink must be created when the package is installed;
6318 it cannot be contained in the package itself due to problems
6319 with <prgn>dpkg</prgn>. One reasonable way to accomplish
6320 this is to put the following in the package's
6321 <prgn>postinst</prgn>:
6323 if [ "$1" = "configure" ]; then
6324 if [ -d /usr/doc -a ! -e /usr/doc/#PACKAGE# \
6325 -a -d /usr/share/doc/#PACKAGE# ]; then
6326 ln -sf ../share/doc/#PACKAGE# /usr/doc/#PACKAGE#
6330 And the following in the package's <prgn>prerm</prgn>:
6332 if [ \( "$1" = "upgrade" -o "$1" = "remove" \) \
6333 -a -L /usr/doc/#PACKAGE# ]; then
6334 rm -f /usr/doc/#PACKAGE#
6341 <heading>Preferred documentation formats</heading>
6344 The unification of Debian documentation is being carried out
6348 If your package comes with extensive documentation in a
6349 mark up format that can be converted to various other formats
6350 you should if possible ship HTML versions in a binary
6351 package, in the directory
6352 <tt>/usr/share/doc/<var>appropriate package</var></tt> or its
6355 <p>The rationale: The important thing here is that HTML
6356 docs should be available in <em>some</em> package, not
6357 necessarily in the main binary package, though. </p>
6362 Other formats such as PostScript may be provided at your
6366 <sect id="copyrightfile">
6367 <heading>Copyright information</heading>
6370 Every package must be accompanied by a verbatim copy of its
6371 copyright and distribution license in the file
6372 /usr/share/doc/<package-name>/copyright. This file must
6373 neither be compressed nor be a symbolic link.</p>
6376 In addition, the copyright file must say where the upstream
6377 sources (if any) were obtained, and should explain briefly what
6378 modifications were made in the Debian version of the package
6379 compared to the upstream one. It should name the original
6380 authors of the package and the Debian maintainer(s) who were
6381 involved with its creation.</p>
6384 /usr/share/doc/<package-name> may be a symbolic link to a
6385 directory in /usr/share/doc only if two packages both come from
6386 the same source and the first package has a "Depends"
6387 relationship on the second. These rules are important
6388 because copyrights must be extractable by mechanical
6392 Packages distributed under the UCB BSD license, the Artistic
6393 license, the GNU GPL, and the GNU LGPL should refer to the
6394 files /usr/share/common-licenses/BSD,
6395 /usr/share/common-licenses/Artistic,
6396 /usr/share/common-licenses/GPL, and
6397 /usr/share/common-licenses/LGPL.
6400 Why "licenses" and not "copyright"? Because
6401 <tt>/usr/doc/copyright</tt> used to contain all the
6402 copyright files, plus the four common licenses GPL,
6403 LGPL, Artistic and BSD. Now individual copyright files
6404 for packages are no longer in a common directory. Once
6405 <tt>/usr/doc/copyright</tt> is almost empty it makes
6406 sense to rename "copyright" to "licenses"
6409 Why "common-licenses" and not "licenses"? Because if I
6410 put just "licenses" I'm sure I will receive a bug report
6411 saying "license foo is not included in the licenses
6412 directory. They are not all the licenses, just a few
6413 common ones. I could use /usr/share/doc/common-licenses
6414 but I think this is too long, and, after all, the GPL
6415 does not "document" anything, it is merely a license.
6421 You should not use the copyright file as a general <tt>README</tt>
6422 file. If your package has such a file it should be
6423 installed in <tt>/usr/share/doc/<var>package</var>/README</tt> or
6424 <tt>README.Debian</tt> or some other appropriate place.</p>
6428 <heading>Examples</heading>
6431 Any examples (configurations, source files, whatever),
6432 should be installed in a directory
6433 <tt>/usr/share/doc/<var>package</var>/examples</tt>. These
6434 files should not be referenced by any program--they're there
6435 for the benefit of the system administrator and users, as
6436 documentation only. Architecture-specific example files
6437 should be installed in a directory
6438 <tt>/usr/lib/<var>package</var>/examples</tt>, and files in
6439 <tt>/usr/share/doc/<var>package</var>/examples</tt> symlink
6440 to files in it. Or the latter directory may be a symlink to
6444 <sect id="instchangelog">
6445 <heading>Changelog files</heading>
6448 Packages that are not Debian-native must contain a copy of
6449 <tt>debian/changelog</tt> file from the Debian source tree
6450 in <tt>/usr/share/doc/<var>package</var></tt> as
6451 <tt>changelog.Debian.gz</tt>. If an upstream changelog is
6452 available, it should be accessible as
6453 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt> in
6454 plain text. If the upstream changelog is distributed in
6455 HTML, it should be made available in that form as
6456 <tt>/usr/share/doc/<var>package</var>/changelog.html.gz</tt>
6457 and the <tt>changelog.gz</tt> should be generated using, eg,
6458 <tt>lynx -dump -nolist</tt>. If the upstream changelog files
6459 do not already conform to this naming convention, then this
6460 may be achieved either by renaming the files, or adding a
6461 symbolic link, at the maintainer's discretion.
6464 Rationale: People should not have to look into two
6465 places for upstream changelogs merely because they are
6473 All these files should be installed compressed using <tt>gzip -9</tt>,
6474 as they will become large with time even if they start out
6479 If the package has only one changelog which is used both as
6480 the Debian changelog and the upstream one because there is
6481 no separate upstream maintainer then that changelog should
6482 usually be installed as
6483 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>; if
6484 there is a separate upstream maintainer, but no upstream
6485 changelog, then the Debian changelog should still be called
6486 <tt>changelog.Debian.gz</tt>.</p>