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 adminstrivia 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>Manoj Srivastava <email>srivasta@debian.org</email></p>
72 Copyright ©1996,1997,1998 Ian Jackson
73 and Christian Schwarz.
76 This manual is free software; you may redistribute it and/or
77 modify it under the terms of the GNU General Public License
78 as published by the Free Software Foundation; either version
79 2, or (at your option) any later version.
83 This is distributed in the hope that it will be useful, but
84 <em>without any warranty</em>; without even the implied
85 warranty of merchantability or fitness for a particular
86 purpose. See the GNU General Public License for more
90 A copy of the GNU General Public License is available as
91 <tt>/usr/share/common-licences/GPL</tt> in the Debian GNU/Linux
92 distribution or on the World Wide Web at
93 <url id="http://www.gnu.org/copyleft/gpl.html"
94 name="&urlname">. You can also obtain it by writing to the
95 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
96 Boston, MA 02111-1307, USA.
104 <heading>About this manual</heading>
106 <heading>Scope</heading>
108 This manual describes the policy requirements for the Debian
109 GNU/Linux distribution. This includes the structure and
110 contents of the Debian archive, several design issues of the
111 operating system, as well as technical requirements that
112 each package must satisfy to be included in the
116 This manual does <em>not</em> describe the technical
117 mechanisms involved in package creation, installation, and
118 removal. This information can be found in the <em>Debian
119 Packaging Manual</em> and the <em>Debian System
120 Administrators' Manual</em>.
123 This document assumes familiarity with these other two
124 manuals. Unfortunately, the <em>System Administrators'
125 Manual</em> does not exist yet.
128 Much of the information presented in this manual will be
129 useful even when building a package which is to be
130 distributed in some other way or is for local use.
134 <heading>New versions of this document</heading>
136 The current version of this document is always accessible from the
139 id="ftp://ftp.debian.org/debian/doc/manuals/debian-policy.html.tar.gz" name="&urlname">
140 or from the Debian WWW server at
141 <url id="http://www.debian.org/doc/manuals/debian-policy/"
145 In addition, this manual is distributed via the Debian package
146 <tt>debian-policy</tt>
150 <heading>Feedback</heading>
153 As the Debian GNU/Linux system is continuously evolving this
154 manual is changed from time to time.
157 While the authors of this document tried hard not to include
158 any typos or other errors these still occur. If you discover
159 an error in this manual or if you want to tell us any
160 comments, suggestions, or critics please send an email to
161 the Debian Policy List,
162 <email>debian-policy@lists.debian.org</email>, or submit a
163 bug report against the <tt>debian-policy</tt> package.
168 <heading>The Debian Archive</heading>
170 The Debian GNU/Linux system is maintained and distributed as a
171 collection of <em>packages</em>. Since there are so many of them (over
172 2600) they are split into <em>sections</em> and <em>priorities</em> to
173 simplify handling of them.
176 The effort of the Debian project is to build a free operating
177 system, but not every package we want to make accessible is
178 <em>free</em> in our sense (see Debian Free Software
179 Guidelines, below), or may be imported/exported without
180 restrictions. Thus, the archive is split into the sections
181 <em>main</em>, <em>non-us</em>, <em>non-free</em>, and
182 <em>contrib</em>.</p>
184 The <em>main</em> section forms the <em>Debian GNU/Linux
185 distribution</em>. </p>
187 Packages in the other sections are not considered as part of
188 the Debian distribution, though we support their use, and we
189 provide infrastructure for them (such as our bug-tracking
190 system and mailing lists). This Debian Policy Manual applies
191 to these packages as well.</p>
193 <sect id="pkgcopyright">
194 <heading>Package copyright and sections</heading>
196 The aims of this policy are:
198 <list compact="compact">
200 <p>We want to make as much software available as we
204 <p>We want to encourage everyone to write free software.</p>
207 <p> We want to make it easy for people to produce
208 CD-ROMs of our system without violating any licenses,
209 import/export restrictions, or any other laws.</p>
214 <heading>The Debian Free Software Guidelines</heading>
216 The Debian Free Software Guidelines (DFSG) is our
217 definition of `free' software.
219 <tag>Free Redistribution
223 The license of a Debian component may not restrict any
224 party from selling or giving away the software as a
225 component of an aggregate software distribution
226 containing programs from several different
227 sources. The license may not require a royalty or
228 other fee for such sale.
235 The program must include source code, and must allow
236 distribution in source code as well as compiled form.
243 The license must allow modifications and derived
244 works, and must allow them to be distributed under the
245 same terms as the license of the original software.
248 <tag>Integrity of The Author's Source Code
252 The license may restrict source-code from being
253 distributed in modified form <em>only</em> if the
254 license allows the distribution of ``patch files''
255 with the source code for the purpose of modifying the
256 program at build time. The license must explicitly
257 permit distribution of software built from modified
258 source code. The license may require derived works to
259 carry a different name or version number from the
260 original software. (This is a compromise. The Debian
261 group encourages all authors to not restrict any
262 files, source or binary, from being modified.)
265 <tag>No Discrimination Against Persons or Groups
269 The license must not discriminate against any person
273 <tag>No Discrimination Against Fields of Endeavor
277 The license must not restrict anyone from making use
278 of the program in a specific field of endeavor. For
279 example, it may not restrict the program from being
280 used in a business, or from being used for genetic
284 <tag>Distribution of License
288 The rights attached to the program must apply to all
289 to whom the program is redistributed without the need
290 for execution of an additional license by those
294 <tag>License Must Not Be Specific to Debian
298 The rights attached to the program must not depend on
299 the program's being part of a Debian system. If the
300 program is extracted from Debian and used or
301 distributed without Debian but otherwise within the
302 terms of the program's license, all parties to whom
303 the program is redistributed must have the same
304 rights as those that are granted in conjunction with
308 <tag>License Must Not Contaminate Other Software
312 The license must not place restrictions on other
313 software that is distributed along with the licensed
314 software. For example, the license must not insist
315 that all other programs distributed on the same medium
316 must be free software.
319 <tag>Example Licenses
323 The ``GPL,'' ``BSD,'' and ``Artistic'' licenses are
324 examples of licenses that we consider <em>free</em>.
331 <heading>The main section</heading>
333 Every package in "main" must comply with the DFSG (Debian
334 Free Software Guidelines).</p>
337 In addition, the packages in "main"
338 <list compact="compact">
341 must not require a package outside of "main" for
342 compilation or execution (thus, the package may not
343 declare a "Depends" or "Recommends" relationship on a
349 must not be so buggy that we refuse to support them,
354 must meet all policy requirements presented in this
362 <heading>The contrib section</heading>
364 Every package in "contrib" must comply with the DFSG.
368 Examples of packages which would be included in "contrib" are
369 <list compact="compact">
372 free packages which require "contrib", "non-free", or
373 "non-US" packages or packages which are not in our
374 archive at all for compilation or execution,
379 wrapper packages or other sorts of free accessories for
385 packages which we don't want to support because they are too
391 packages which fail to meet some other policy requirements in
399 <heading>The non-free section</heading>
401 `Non-free' contains packages which are not compliant with
402 the DFSG or which are encumbered by patents or other legal
403 issues that make their distribution problematic.</p>
405 All packages in `non-free' must be electronically
406 distributable across international borders.
410 <heading>The non-us server</heading>
412 Some programs with cryptographic program code must be stored
413 on the "non-us" server because of export restrictions of the
416 This applies only to packages which contain cryptographic
417 code. A package containing a program with an interface to a
418 cryptographic program or a program that's dynamically linked
419 against a cryptographic library can be distributed if it is
420 capable of running without the cryptography library or
425 <heading>Further copyright considerations</heading>
427 Every package must be accompanied by a verbatim copy of its
428 copyright and distribution license in the file
429 /usr/share/doc/<package-name>/copyright (see <ref
430 id="copyrightfile"> for details).</p>
432 We reserve the right to restrict files from being included
433 anywhere in our archives if
434 <list compact="compact">
437 their use or distribution would break a law,
442 there is an ethical conflict in their distribution or
448 we would have to sign a license for them, or
453 their distribution would conflict with other project
461 Programs whose authors encourage the user to make donations
462 are fine for the main distribution, provided that the
463 authors do not claim that not donating is immoral,
464 unethical, illegal or something similar; otherwise they must
465 go in contrib (or non-free, if even distribution is
466 restricted by such statements).</p>
469 Packages whose copyright permission notices (or patent
470 problems) do not allow redistribution even of only binaries,
471 and where no special permission has been obtained, cannot be
472 placed on the Debian FTP site and its mirrors at all.</p>
475 Note, that under international copyright law (this applies
476 in the United States, too) <em>no</em> distribution or
477 modification of a work is allowed without an explicit notice
478 saying so. Therefore a program without a copyright notice
479 <em>is</em> copyrighted and you may not do anything to it
480 without risking being sued! Likewise if a program has a
481 copyright notice but no statement saying what is permitted
482 then nothing is permitted.</p>
485 Many authors are unaware of the problems that restrictive
486 copyrights (or lack of copyright notices) can cause for the
487 users of their supposedly-free software. It is often
488 worthwhile contacting such authors diplomatically to ask
489 them to modify their license terms. However, this is a
490 politically difficult thing to do and you should ask for
491 advice on <tt>debian-devel</tt> first.</p>
494 When in doubt, send mail to
495 <email>debian-devel@lists.debian.org</email>. Be prepared
496 to provide us with the copyright statement. Software
497 covered by the GPL, public domain software and BSD-like
498 copyrights are safe; be wary of the phrases `commercial use
499 prohibited' and `distribution restricted'.</p>
502 <heading>Subsections</heading>
505 The packages in all the sections (<em>main</em>,
506 <em>contrib</em>, <em>non-US</em>, and <em>non-free</em>)
507 are grouped further into <em>subsections</em> to simplify
508 handling of them.</p>
511 The section for each package is specified in the package's
512 <em>control record</em>. However, the maintainer of the
513 Debian archive may override this selection to assure the
514 consistency of the Debian distribution. </p>
517 Please check the current Debian distribution to see which
518 sections are available.</p>
521 <heading>Priorities</heading>
524 Each package is given a certain <em>priority</em> value,
525 which is included in the package's <em>control
526 record</em>. This information is used in the Debian package
527 management tool to separate high-priority packages from
528 less-important packages.</p>
531 The following <em>priority levels</em> are supported by the
532 Debian package management system, <prgn>dpkg</prgn>.
534 <tag><tt>required</tt></tag>
537 <tt>required</tt> packages are necessary for the
538 proper functioning of the system. You must not remove
539 these packages or your system may become totally
540 broken and you may not even be able to use
541 <prgn>dpkg</prgn> to put things back. Systems with
542 only the <tt>required</tt> packages are probably
543 unusable, but they do have enough functionality to
544 allow the sysadmin to boot and install more
547 <tag><tt>important</tt></tag>
550 Important programs, including those which one would
551 expect to find on any Unix-like system. If the
552 expectation is that an experienced Unix person who
553 found it missing would say `What the F*!@<+ is
554 going on, where is <prgn>foo</prgn>', it must be in
555 <tt>important</tt>. This is an important criterion
556 because we are trying to produce, amongst other
557 things, a free Unix. Other packages without which the
558 system will not run well or be usable must also be
559 here. This does <em>not</em> include Emacs, the X
560 Window System, TeX or any other large applications.
561 The <tt>important</tt> packages are just a bare
562 minimum of commonly-expected and necessary tools.</p>
564 <tag><tt>standard</tt></tag>
567 These packages provide a reasonably small but not too
568 limited character-mode system. This is what will
569 install by default if the user doesn't select anything
570 else. It doesn't include many large applications, but
571 it does include Emacs (this is more of a piece of
572 infrastructure than an application) and a reasonable
573 subset of TeX and LaTeX (if this is possible without
576 <tag><tt>optional</tt></tag>
579 (In a sense everything is optional that isn't
580 required, but that's not what is meant here.) This is
581 all the software that you might reasonably want to
582 install if you didn't know what it was or don't have
583 specialized requirements. This is a much larger system
584 and includes the X Window System, a full TeX
585 distribution, and many applications.</p>
587 <tag><tt>extra</tt></tag>
590 This contains packages that conflict with others with
591 higher priorities, or are only likely to be useful if
592 you already know what they are or have specialized
599 Packages may not depend on packages with lower priority
600 values. If this does happen, one of the priority values
601 will have to be adapted.
606 <heading>Binary packages</heading>
609 The Debian GNU/Linux distribution is based on the Debian
610 package management system, called <prgn>dpkg</prgn>. Thus,
611 all packages in the Debian distribution have to be provided
612 in the <tt>.deb</tt> file format.</p>
616 <heading>The package name</heading>
619 Every package must have a name that's unique within the Debian
623 Package names may only consist of lower case letters, digits (0-9),
624 plus (+) or minus (-) signs, and periods (.).</p>
627 The package name is part of the file name of the
628 <tt>.deb</tt> file and is included in the control field
634 <heading>The maintainer of a package</heading>
637 Every package must have exactly one maintainer at a
638 time. This person is responsible that the license of the
639 package's software complies with the policy of the
640 distribution this package is included in.</p>
643 The maintainer must be specified in the
644 <tt>Maintainer</tt> control field with the correct name
645 and a working email address for the Debian maintainer of
646 the package. If one person maintains several packages
647 he/she should try to avoid having different forms of their
648 name and email address in different <tt>Maintainer</tt>
652 If the maintainer of a package quits from the Debian
653 project the Debian QA Group
654 <email>debian-qa@lists.debian.org</email> takes over the
655 maintainership of the package until someone else
656 volunteers for that task. These packages are called
657 <em>orphaned packages</em>.
663 <heading>The description of a package</heading>
666 Every Debian package must have an extended description
667 stored in the appropriate field of the control record.</p>
670 The description must be written so that it tells the user
671 what they need to know to decide whether to install the
672 package. This description should not just be copied from
673 the blurb for the program. Instructions for configuring
674 or using the package must not be included -- that is what
675 installation scripts, manual pages, Info files, etc. are
676 for. Copyright statements and other administrivia must
677 not be included -- that is what the copyright file is
683 <heading>Dependencies</heading>
686 Every package has to specify the dependency information
687 about other packages, that are required for the first to
691 For example, for any shared libraries required by
692 dynamically-linked executable binary in a package a
693 dependency entry has to be provided.</p>
696 It is not necessary for other packages to declare any
697 dependencies they have on other packages which are marked
698 <tt>Essential</tt> (see below).</p>
701 Sometimes, a package requires another package to be
702 installed <em>and</em> configured before it can be
703 installed. In this case, you'll have to specify a
704 <tt>Pre-Depends</tt> entry for the package.</p>
707 You must not specify a <tt>Pre-Depends</tt> entry for a
708 package before this has been discussed on the
709 <tt>debian-devel</tt> mailing list and a consensus about
710 doing that has been reached.</p></sect1>
714 <heading>Virtual packages</heading>
717 Sometimes, there are several packages doing more-or-less
718 the same job. In this case, it's useful to define a
719 <em>virtual package</em> who's name describes the function
720 the packages have. (The virtual packages just exist
721 logically, not physically--that's why they are called
722 <em>virtual</em>.) The packages with this particular
723 function will then <em>provide</em> the virtual
724 package. Thus, any other package requiring that function
725 can simply depend on the virtual package without having to
726 specify all possible packages individually.</p>
729 All packages must use virtual package names where
730 appropriate, and arrange to create new ones if necessary.
731 They must not use virtual package names (except privately,
732 amongst a cooperating group of packages) unless they have
733 been agreed upon and appear in the list of virtual package
737 The latest version of the authoritative list of virtual
738 package names can be found on
739 <ftpsite>ftp.debian.org</ftpsite> in
740 <ftppath>/debian/doc/package-developer/virtual-package-names-list.text</ftppath>
741 or your local mirror. In addition, it is included in the
742 <tt>debian-policy</tt> package. The procedure for updating
743 the list is described at the top of the file.</p></sect1>
747 <heading>Base packages</heading>
750 The packages included in the <tt>base</tt> section have a
751 special function. They form a minimum subset of the Debian
752 GNU/Linux system that is installed before everything else
753 on a new system. Thus, only very few packages are allowed
754 to go into the <tt>base</tt> section to keep the required
755 disk usage very small.</p>
758 Most of these packages should have the priority value
759 <tt>required</tt> or at least <tt>important</tt>, and many
760 of them will be tagged <tt>essential</tt> (see below).</p>
763 You must not place any packages into the <tt>base</tt>
764 section before this has been discussed on the
765 <tt>debian-devel</tt> mailing list and a consensus about
766 doing that has been reached.</p></sect1>
770 <heading>Essential packages</heading>
773 Some packages are tagged <tt>essential</tt>. (They have
774 <tt>Essential: yes</tt> in their package control record.)
775 This flag is used for packages that are <em>essential</em>
779 Since these packages can not easily be removed (you'll
780 have to specify an extra <em>force option</em> to
781 <prgn>dpkg</prgn>) this flag must only be used where
782 absolutely necessary.
784 A shared library package must not be tagged
785 <em>essential</em>--the dependencies will prevent its
786 premature removal, and we need to be able to remove it
787 when it has been superseded.</p>
790 You must not tag any packages <tt>essential</tt> before
791 this has been discussed on the <tt>debian-devel</tt>
792 mailing and a consensus about doing that has been
797 <heading>Maintainer scripts</heading>
800 The package installation scripts must avoid producing
801 output which it is unnecessary for the user to see and
802 should rely on <prgn>dpkg</prgn> to stave off boredom on
803 the part of a user installing many packages. This means,
804 amongst other things, using the <tt>--quiet</tt> option on
805 <prgn>install-info</prgn>.</p>
808 Packages should try to minimize the amount of prompting
809 they need to do, and they should ensure that the user will
810 only ever be asked each question once. This means that
811 packages should try to use appropriate shared
812 configuration files (such as <tt>/etc/papersize</tt> and
813 <tt>/etc/news/server</tt>), rather than each prompting for
814 their own list of required pieces of information.</p>
817 It also means that an upgrade should not ask the same
818 questions again, unless the user has used <tt>dpkg
819 --purge</tt> to remove the package's configuration. The
820 answers to configuration questions should be stored in an
821 appropriate place in <tt>/etc</tt> so that the user can
822 modify them, and how this has been done should be
826 If a package has a vitally important piece of information
827 to pass to the user (such as "don't run me as I am, you
828 must edit the following configuration files first or you
829 risk your system emitting badly-formatted messages"), it
830 should display this in the <prgn>postinst</prgn> script
831 and prompt the user to hit return to acknowledge the
832 message. Copyright messages do not count as vitally
833 important (they belong in
834 <tt>/usr/share/doc/<var>package</var>/copyright</tt>); neither
835 do instructions on how to use a program (these should be
836 in on line documentation, where all the users can see
840 Any necessary prompting should almost always be confined
841 to the post-installation script, and should be protected
842 with a conditional so that unnecessary prompting doesn't
843 happen if a package's installation fails and the
844 <prgn>postinst</prgn> is called with
845 <tt>abort-upgrade</tt>, <tt>abort-remove</tt> or
846 <tt>abort-deconfigure</tt>.</p>
849 Errors which occur during the execution of an installation
850 script <em>must</em> be checked and the installation
851 <em>must not</em> continue after an error.</p>
854 Note, that <ref id="scripts">, in general applies to
855 package maintainer scripts, too.</p>
858 Do not use <prgn>dpkg-divert</prgn> on a file belonging to
859 another package without consulting the maintainer of that
863 In order for <prgn>update-alternatives</prgn> to work
864 correctly all the packages which supply an instance of the
865 `shared' command name (or, in general, filename) must use
866 it. You can use <tt>Conflicts</tt> to force the
867 De-installation of other packages supplying it which do not
868 (yet) use <prgn>update-alternatives</prgn>. It may in
869 this case be appropriate to specify a conflict on earlier
870 versions on something--this is an exception to the usual
871 rule that this is not allowed.</p>
875 <heading>Source packages</heading>
878 <heading>Standards conformance</heading>
881 You should specify the most recent version of the
882 packaging standards with which your package complies in
883 the source package's <tt>Standards-Version</tt> field.</p>
886 This value will be used to file bug reports automatically
887 if your package becomes too much out of date.</p>
890 The value corresponds to a version of the Debian manuals,
891 as can be found on the title page or page headers and
892 footers (depending on the format).</p>
895 The version number has four components--major and minor
896 number and major and minor patch level. When the
897 standards change in a way that requires every package to
898 change the major number will be changed. Significant
899 changes that will require work in many packages will be
900 signaled by a change to the minor number. The major patch
901 level will be changed for any change to the meaning of the
902 standards, however small; the minor patch level will be
903 changed when only cosmetic, typographical or other edits
904 which do not change the meaning are made, or changes which
905 do not affect the contents of packages.</p>
908 For package maintainers, only the first 3 digits of the
909 manual version are significant in representing the
910 <em>Standards-Version</em>, and either these 3 digits or
911 the complete 4 digits can be specified--that's up to the
915 In the past, people specified 4 digits in the
916 Standards-Version field, like `2.3.0.0'. Since any
917 `patch-level changes' don't introduce new policy, it
918 was thought it would be better to relax policy and
919 only require that the first 3 digits are specified. (4
920 digits can still be used if someone wants to do so.)
926 You should regularly, and especially if your package has
927 become out of date, check for the newest Policy Manual
928 available and update your package, if necessary. When your
929 package complies with the new standards you may update the
930 <tt>Standards-Version</tt> source package field and
931 release it.</p></sect1>
935 <heading>Changes to the upstream sources</heading>
938 If changes to the source code are made that are generally
939 applicable please try to get them included in the upstream
940 version of the package by supplying the upstream authors
941 with the changes in whatever form they prefer.</p>
944 If you need to configure the package differently for
945 Debian or for Linux, and the upstream source doesn't
946 provide a way to configure it the way you need to, please
947 add such configuration facilities (for example, a new
948 <prgn>autoconf</prgn> test or <tt>#define</tt>) and send
949 the patch to the upstream authors, with the default set to
950 the way they originally had it. You can then easily
951 override the default in your <tt>debian/rules</tt> or
952 wherever is appropriate.</p>
955 Please make sure that the <prgn>configure</prgn> utility
956 detects the correct architecture specification string
957 (refer to <ref id="arch-spec"> for details).</p>
960 If you need to edit a <prgn>Makefile</prgn> where
961 GNU-style <prgn>configure</prgn> scripts are used, you
962 should edit the <tt>.in</tt> files rather than editing the
963 <prgn>Makefile</prgn> directly. This allows the user to
964 reconfigure the package if necessary. You should
965 <em>not</em> configure the package and edit the generated
966 <prgn>Makefile</prgn>! This makes it impossible for
967 someone else to later reconfigure the package.</p></sect1>
971 <heading>Documenting your changes</heading>
974 Document your changes and updates to the source package
975 properly in the <tt>debian/changelog</tt> file.</p>
978 A copy of the file which will be installed in
979 <tt>/usr/share/doc/<var>package</var>/copyright</tt> should be
980 in <tt>debian/copyright</tt>.</p>
983 In non-experimental packages you may only use a format for
984 <tt>debian/changelog</tt> which is supported by the most
985 recent released version of <prgn>dpkg</prgn>. If your
986 format is not supported and there is general support for
987 it you should contact the <prgn>dpkg</prgn> maintainer to
988 have the parser script for your format included in the
989 <prgn>dpkg</prgn> package. (You will need to agree that
990 the parser and its manpage may be distributed under the
991 GNU GPL, just as the rest of <prgn>dpkg</prgn>
996 <heading>Error trapping in makefiles</heading>
999 When <prgn>make</prgn> invokes a command in a makefile
1000 (including your package's upstream makefiles and the
1001 <tt>debian/rules</tt>) it does so using <tt>sh</tt>. This
1002 means that <tt>sh</tt>'s usual bad error handling
1003 properties apply: if you include a miniature script as one
1004 of the commands in your makefile you'll find that if you
1005 don't do anything about it then errors are not detected
1006 and <prgn>make</prgn> will blithely continue after
1010 Every time you put more than one shell command (this
1011 includes using a loop) in a makefile command you
1012 <em>must</em> make sure that errors are trapped. For
1013 simple compound commands, such as changing directory and
1014 then running a program, using <tt>&&</tt> rather
1015 than semicolon as a command separator is sufficient. For
1016 more complex commands including most loops and
1017 conditionals you must include a separate <tt>set -e</tt>
1018 command at the start of every makefile command that's
1019 actually one of these miniature shell scripts.</p></sect1>
1023 <heading>Obsolete constructs and libraries</heading>
1026 The include file <prgn><varargs.h></prgn> is
1027 provided to support end-users compiling very old software;
1028 the library <tt>libtermcap</tt> is provided to support the
1029 execution of software which has been linked against it
1030 (either old programs or those such as Netscape which are
1031 only available in binary form).</p>
1034 Debian packages should be ported to include
1035 <prgn><stdarg.h></prgn> and <tt>ncurses</tt> when
1040 <chapt><heading>The Operating System</heading>
1044 <heading>File system hierarchy</heading>
1048 <heading>Linux File system Structure</heading>
1051 The location of all installed files and directories must
1052 comply (with some exceptions
1054 <p>In an as yet unreleased version of the standard, the
1055 location of the mail spool and state information
1056 directories has changed; and we propose to follow the
1057 latter, since that would mean that we do not have to
1058 move things around again when the new version of the
1059 FHS comes around). The changes are, amongst others,
1060 s%/var/mail%/var/spool/mail% and
1061 s%/var/state%/var/lib%</p>
1063 ) with the Linux File system Hierarchy Standard
1064 (FHS). The latest version of this document can be found
1065 alongside this manual or on
1066 <ftpsite>tsx-11.mit.edu</ftpsite> in
1067 <ftppath>/pub/linux/docs/linux-standards/fsstnd/</ftppath>.
1068 Specific questions about following the standard may be
1069 asked on <prgn>debian-devel</prgn>, or referred to Daniel
1070 Quinlan, the FHS coordinator, at
1071 <email>quinlan@pathname.com</email>.</p></sect1>
1075 <heading>Site-specific programs</heading>
1078 As mandated by the FHS no package should place any
1079 files in <tt>/usr/local</tt>, either by putting them in
1080 the file system archive to be unpacked by <prgn>dpkg</prgn>
1081 or by manipulating them in their maintainer scripts.</p>
1084 However, the package should create empty directories below
1085 <tt>/usr/local</tt> so that the system administrator knows
1086 where to place site-specific files. These directories
1087 should be removed on package removal if they are
1091 Note, that this applies only to directories <em>below</em>
1092 <tt>/usr/local</tt>, not <em>in</em>
1093 <tt>/usr/local</tt>. The directory <tt>/usr/local</tt>
1094 itself may only contain the sub-directories listed in
1095 FHS, section 4.6. However, you may create directories
1096 below them as you wish. You may not remove any of the
1097 directories listed in 4.6, even if you created them.</p>
1100 Since <tt>/usr/local</tt> may be mounted read-only from a
1101 remote server, these directories have to be created and
1102 removed by the <tt>postinst</tt> and <tt>prerm</tt>
1103 maintainer scripts. These scripts must not fail if either
1104 of these operations fail. (In the future, it will be
1105 possible to tell <prgn>dpkg</prgn> not to unpack files
1106 matching certain patterns, so that the directories can be
1107 included in the <tt>.deb</tt> packages and system
1108 administrators who do not wish these directories in
1109 /usr/local do not need to have them.)</p>
1112 For example, the <prgn>emacs</prgn> package will contain
1114 mkdir -p /usr/local/lib/emacs/site-lisp || true
1116 in the <tt>postinst</tt> script, and
1118 rmdir /usr/local/lib/emacs/site-lisp && \
1119 rmdir /usr/local/lib/emacs || \
1122 in the <tt>prerm</tt> script.</p>
1125 If you do create a directory in <tt>/usr/local</tt> for
1126 local additions to a package, you must ensure that
1127 settings in <tt>/usr/local</tt> take precedence over the
1128 equivalents in <tt>/usr</tt>.</p>
1131 The <tt>/usr/local</tt> directory itself and all the subdirectories
1132 created by the package should have permissions 2775 (group-writable
1133 and set-group-id) and be owned by <tt>root.staff</tt>.</p>
1138 <heading>Users and groups</heading>
1141 The Debian system can be configured to use either plain or
1142 shadow passwords.</p>
1145 Some user ids (UIDs) and group ids (GIDs) are reserved
1146 globally for use by certain packages. Because some packages
1147 need to include files which are owned by these users or
1148 groups, or need the ids compiled into binaries, these ids
1149 must be used on any Debian system only for the purpose for
1150 which they are allocated. This is a serious restriction, and
1151 we should avoid getting in the way of local administration
1152 policies. In particular, many sites allocate users and/or
1153 local system groups starting at 100.</p>
1156 Apart from this we should have dynamically allocated ids,
1157 which should by default be arranged in some sensible
1158 order--but the behavior should be configurable.</p>
1161 No package except <tt>base-passwd</tt> may modify
1162 <tt>/etc/passwd</tt>, <tt>/etc/shadow</tt>, or
1163 <tt>/etc/group</tt>.</p>
1166 The UID and GID ranges are as follows:
1171 Globally allocated by the Debian project, must be the
1172 same on every Debian system. These ids will appear in
1173 the <tt>passwd</tt> and <tt>group</tt> files of all
1174 Debian systems, new ids in this range being added
1175 automatically as the <tt>base-passwd</tt> package is
1179 Packages which need a single statically allocated uid
1180 or gid should use one of these; their maintainers
1181 should ask the <tt>base-passwd</tt> maintainer for
1188 Dynamically allocated system users and groups.
1189 Packages which need a user or group, but can have this
1190 user or group allocated dynamically and differently on
1191 each system, should use `<tt>adduser --system</tt>' to
1192 create the group and/or user. <prgn>adduser</prgn>
1193 will check for the existence of the user or group, and
1194 if necessary choose an unused id based on the ranged
1195 specified in <tt>adduser.conf</tt>.</p></item>
1198 <tag>1000-29999:</tag>
1201 Dynamically allocated user accounts. By default
1202 <prgn>adduser</prgn> will choose UIDs and GIDs for
1203 user accounts in this range, though
1204 <tt>adduser.conf</tt> may be used to modify this
1208 <tag>30000-59999:</tag>
1210 <p>Reserved.</p></item>
1213 <tag>60000-64999:</tag>
1216 Globally allocated by the Debian project, but only
1217 created on demand. The ids are allocated centrally and
1218 statically, but the actual accounts are only created
1219 on users' systems on demand.</p>
1222 These ids are for packages which are obscure or which
1223 require many statically-allocated ids. These packages
1224 should check for and create the accounts in
1225 <tt>/etc/passwd</tt> or <tt>/etc/group</tt> (using
1226 <prgn>adduser</prgn> if it has this facility) if
1227 necessary. Packages which are likely to require
1228 further allocations should have a `hole' left after
1229 them in the allocation, to give them room to
1233 <tag>65000-65533:</tag>
1235 <p>Reserved.</p></item>
1240 <p>User `<tt>nobody</tt>.'</p></item>
1246 <tt>(uid_t)(-1) == (gid_t)(-1)</tt>. NOT TO BE USED,
1247 because it is the error return sentinel value.</p>
1252 <sect id="sysvinit">
1253 <heading>System run levels</heading>
1257 <heading>Introduction</heading>
1260 The <tt>/etc/init.d</tt> directory contains the scripts
1261 executed by <prgn>init</prgn> at boot time and when init
1262 state (or `runlevel') is changed (see <manref name="init"
1263 section="8">).</p> <p>
1265 These scripts are being referenced by symbolic links in
1266 the <tt>/etc/rc<var>n</var>.d</tt> directories. When
1267 changing runlevels, <prgn>init</prgn> looks in the
1268 directory <tt>/etc/rc<var>n</var>.d</tt> for the scripts
1269 it should execute, where <var>n</var> is the runlevel that
1270 is being changed to, or `S' for the boot-up scripts.</p>
1273 The names of the links all have the form
1274 <tt>S<var>mm</var><var>script</var></tt> or
1275 <tt>K<var>mm</var><var>script</var></tt> where
1276 <var>mm</var> is a two-digit number and <var>script</var>
1277 is the name of the script (this should be the same as the
1278 name of the actual script in <tt>/etc/init.d</tt>.
1280 When <prgn>init</prgn> changes runlevel first the targets
1281 of the links whose names starting with a <tt>K</tt> are
1282 executed, each with the single argument <tt>stop</tt>,
1283 followed by the scripts prefixed with an <tt>S</tt>, each
1284 with the single argument <tt>start</tt>. The <tt>K</tt>
1285 links are responsible for killing services and the
1286 <tt>S</tt> link for starting services upon entering the
1290 For example, if we are changing from runlevel 2 to
1291 runlevel 3, init will first execute all of the <tt>K</tt>
1292 prefixed scripts it finds in <tt>/etc/rc3.d</tt>, and then
1293 all of the <tt>S</tt> prefixed scripts. The links
1294 starting with <tt>K</tt> will cause the referred-to file
1295 to be executed with an argument of <tt>stop</tt>, and the
1296 <tt>S</tt> links with an argument of <tt>start</tt>.</p>
1299 The two-digit number <var>mm</var> is used to decide which
1300 order to start and stop things in--low-numbered links have
1301 their scripts run first. For example, the <tt>K20</tt>
1302 scripts will be executed before the <tt>K30</tt> scripts.
1303 This is used when a certain service must be started before
1304 another. For example, the name server <prgn>bind</prgn>
1305 might need to be started before the news server
1306 <prgn>inn</prgn> so that <prgn>inn</prgn> can set up its
1307 access lists. In this case, the script that starts
1308 <prgn>bind</prgn> should have a lower number than the
1309 script that starts <prgn>inn</prgn> so that it runs first:
1318 <heading>Writing the scripts</heading>
1321 Packages can and should place scripts in
1322 <tt>/etc/init.d</tt> to start or stop services at boot
1323 time or during a change of runlevel. These scripts should
1324 be named <tt>/etc/init.d/<var>package</var></tt>, and they
1325 should accept one argument, saying what to do:
1328 <tag><tt>start</tt></tag>
1329 <item><p>start the service,</p></item>
1331 <tag><tt>stop</tt></tag>
1332 <item><p>stop the service,</p></item>
1334 <tag><tt>restart</tt></tag>
1335 <item><p>stop and restart the service,</p></item>
1337 <tag><tt>reload</tt></tag>
1338 <item><p>cause the configuration of the service to be
1339 reloaded without actually stopping and restarting
1340 the service,</p></item>
1342 <tag><tt>force-reload</tt></tag> <item><p>cause the
1343 configuration to be reloaded if the service supports
1344 this, otherwise restart the service.</p></item>
1347 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
1348 <tt>force-reload</tt> options must be supported by all
1349 scripts in <tt>/etc/init.d</tt>, the <tt>reload</tt>
1350 option is optional.</p>
1353 The <tt>init.d</tt> scripts should ensure that they will
1354 behave sensibly if invoked with <tt>start</tt> when the
1355 service is already running, or with <tt>stop</tt> when it
1356 isn't, and that they don't kill unfortunately-named user
1357 processes. The best way to achieve this is usually to use
1358 <prgn>start-stop-daemon</prgn>.</p>
1361 If a service reloads its configuration automatically (as
1362 in the case of <prgn>cron</prgn>, for example), the
1363 <tt>reload</tt> option of the <tt>init.d</tt> script
1364 should behave as if the configuration has been reloaded
1368 These scripts should not fail obscurely when the
1369 configuration files remain but the package has been
1370 removed, as the default in <prgn>dpkg</prgn> is to leave
1371 configuration files on the system after the package has
1372 been removed. Only when it is executed with the
1373 <tt>--purge</tt> option will dpkg remove configuration
1374 files. Therefore, you should include a <tt>test</tt>
1375 statement at the top of the script, like this:
1377 test -f <var>program-executed-later-in-script</var> || exit 0
1378 </example></p></sect1>
1381 <heading>Managing the links</heading>
1384 A program is provided, <prgn>update-rc.d</prgn>, to make
1385 it easier for package maintainers to arrange for the
1386 proper creation and removal of
1387 <tt>/etc/rc<var>n</var>.d</tt> symbolic links from their
1388 <tt>postinst</tt> and <tt>postrm</tt> scripts.</p>
1391 You should use this script to make changes to
1392 <tt>/etc/rc<var>n</var>.d</tt> and <em>never</em> include
1393 any <tt>/etc/rc<var>n</var>.d</tt> symbolic links in the
1397 By default <prgn>update-rc.d</prgn> will start services in
1398 each of the multi-user state runlevels (2, 3, 4, and 5)
1399 and stop them in the halt runlevel (0), the single-user
1400 runlevel (1) and the reboot runlevel (6). The system
1401 administrator will have the opportunity to customize
1402 runlevels by simply adding, moving, or removing the
1403 symbolic links in <tt>/etc/rc<var>n</var>.d</tt>.</p>
1406 To get the default behavior for your package, put in your
1407 <tt>postinst</tt> script
1409 update-rc.d <var>package</var> defaults >/dev/null
1411 and in your <tt>postrm</tt>
1413 if [ purge = "$1" ]; then
1414 update-rc.d <var>package</var> remove >/dev/null
1419 This will use a default sequence number of 20. If it does
1420 not matter when or in which order the script is run, use
1421 this default. If it does, then you should talk to the
1422 maintainer of the <prgn>sysvinit</prgn> package or post to
1423 <tt>debian-devel</tt>, and they will help you choose a
1427 For more information about using <tt>update-rc.d</tt>,
1428 please consult its manpage <manref name="update-rc.d"
1429 section="8">.</p></sect1>
1433 <heading>Boot-time initialization</heading>
1436 There is another directory, <tt>/etc/rc.boot</tt>, which
1437 contains scripts which are run once per machine boot.
1438 This facility is provided for initialization of hardware
1439 devices, cleaning up of leftover files, and so forth.</p>
1442 For example, the <prgn>kbd</prgn> package provides a
1443 script here for initializing the keyboard layout and
1444 console font and mode.</p>
1447 The files in <tt>/etc/rc.boot</tt> should <em>not</em> be
1448 links into <tt>/etc/init.d</tt>--they should be the
1449 scripts themselves.</p>
1452 <tt>rc.boot</tt> should <em>not</em> be used for starting
1453 general-purpose daemons and similar activities. This
1454 should be done using the <tt>rc<var>n</var>.d</tt> scheme,
1455 above, so that the services can be started and stopped
1456 cleanly when the runlevel changes or the machine is to be
1457 shut down or rebooted.</p></sect1>
1461 <heading>Notes</heading>
1464 <em>Do not</em> include the
1465 <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in the
1466 <tt>.deb</tt> file system archive! <em>This will cause
1467 problems!</em> You should create them with
1468 <prgn>update-rc.d</prgn>, as above.</p>
1471 <em>Do not</em> include the <tt>/etc/rc<var>n</var>.d/*</tt> symbolic links in
1472 <prgn>dpkg</prgn>'s conffiles list! <em>This will cause
1473 problems!</em> <em>Do</em>,
1474 however, include the <tt>/etc/init.d</tt> scripts in
1475 conffiles. (This is important since we want to give the
1476 local system administrator the chance to adapt the scripts
1477 to the local system--e.g., to disable a service without
1478 De-installing the package, or to specify some special
1479 command line options when starting a service--while making
1480 sure her changes aren't lost during the next package
1481 upgrade.)</p></sect1>
1484 <heading>Example</heading>
1487 The <prgn>bind</prgn> DNS (nameserver) package wants to
1488 make sure that the nameserver is running in multiuser
1489 runlevels, and is properly shut down with the system. It
1490 puts a script in <tt>/etc/init.d</tt>, naming the script
1491 appropriately <tt>bind</tt>. As you can see, the script
1492 interprets the argument <tt>reload</tt> to send the
1493 nameserver a <tt>HUP</tt> signal (causing it to reload its
1494 configuration); this way the user can say
1495 <tt>/etc/init.d/bind reload</tt> to reload the name
1502 # Original version by Robert Leslie
1503 # <rob@mars.org>, edited by iwj and cs
1505 test -x /usr/sbin/named || exit 0
1509 echo -n "Starting domain name service: named"
1510 start-stop-daemon --start --quiet --exec /usr/sbin/named
1514 echo -n "Stopping domain name service: named"
1515 start-stop-daemon --stop --quiet \
1516 --pidfile /var/run/named.pid --exec /usr/sbin/named
1520 echo -n "Restarting domain name service: named"
1521 start-stop-daemon --stop --quiet \
1522 --pidfile /var/run/named.pid --exec /usr/sbin/named
1523 start-stop-daemon --start --verbose --exec /usr/sbin/named
1526 force-reload|reload)
1527 echo -n "Reloading configuration of domain name service: named"
1528 start-stop-daemon --stop --signal 1 --quiet \
1529 --pidfile /var/run/named.pid --exec /usr/sbin/named
1533 echo "Usage: /etc/init.d/bind {start|stop|restart|reload|force-reload}" >&2
1542 Another example on which to base your <tt>/etc/init.d</tt>
1543 scripts is in <tt>/etc/init.d/skeleton</tt>.</p>
1546 If this package is happy with the default setup from
1547 <prgn>update-rc.d</prgn>, namely an ordering number of 20
1548 and having named running in all runlevels, it can say in
1549 its <tt>postinst</tt>:
1551 update-rc.d bind defaults >/dev/null
1553 And in its <tt>postrm</tt>, to remove the links when the
1556 if [ purge = "$1" ]; then
1557 update-rc.d acct remove >/dev/null
1563 <heading>Cron jobs</heading>
1566 Packages may not touch the configuration file
1567 <tt>/etc/crontab</tt>, nor may they modify the files in
1568 <tt>/var/spool/cron/crontabs</tt>.</p>
1571 If a package wants to install a job that has to be executed
1572 via cron, it should place a file with the name if the
1573 package in one of the following directories:
1579 As these directory names say, the files within them are executed on
1580 a daily, weekly, or monthly basis, respectively.</p>
1583 If a certain job has to be executed more frequently than
1584 `daily,' the package should install a file
1585 <tt>/etc/cron.d/<package-name></tt> tagged as
1586 configuration file. This file uses the same syntax as
1587 <tt>/etc/crontab</tt> and is processed by <prgn>cron</prgn>
1588 automatically. (Note, that scripts in the
1589 <tt>/etc/cron.d</tt> directory are not handled by
1590 <prgn>anacron</prgn>. Thus, you should only use this
1591 directory for jobs which may be skipped if the system is not
1595 All files installed in any of these directories have to be
1596 scripts (shell scripts, Perl scripts, etc.) so that they can
1597 easily be modified by the local system administrator. In
1598 addition, they have to be registered as configuration
1602 The scripts in these directories have to check, if all
1603 necessary programs are installed before they try to execute
1604 them. Otherwise, problems will arise when a package was
1605 removed (but not purged), since the configuration files are
1606 kept on the system in this situation.</p></sect>
1610 <heading>Console messages</heading>
1613 This section describes different formats for messages
1614 written to standard output by the <tt>/etc/init.d</tt>
1615 scripts. The intent is to improve the consistency of
1616 Debian's startup and shutdown look and feel.</p>
1619 Please look very careful at the details. We want to get the
1620 messages to look exactly the same way concerning spaces,
1621 punctuation, and case of letters.</p>
1624 Here is a list of overall rules that you should use when you
1625 create output messages. They can be useful if you have a
1626 non-standard message that isn't covered in the sections
1633 Every message should cover one line, start with a
1634 capital letter and end with a period `.'.</p></item>
1639 If you want to express that the computer is working on
1640 something (performing a specific task, not starting or
1641 stopping a program), we use an ``ellipsis'', namely
1642 three dots `...'. Note that we don't insert spaces in
1643 front of or behind the dots. If the task has been
1644 completed we write `done.' and a line feed.</p></item>
1649 Design your messages as if the computer is telling you
1650 what he is doing (let him be polite :-) but don't
1651 mention ``him'' directly. For example, if you think
1654 I'm starting network daemons: nfsd mountd.
1658 Starting network daemons: nfsd mountd.
1659 </example></p></item>
1663 The following formats must be used</p>
1668 <p>when daemons get started.</p>
1671 Use this format if your script starts one or more
1672 daemons. The output should look like this (a single
1673 line, no leading spaces):
1675 Starting <description>: <daemon-1> <daemon-2> <...> <daemon-n>.
1677 The <description> should describe the subsystem
1678 the daemon or set of daemons are part of, while
1679 <daemon-1> up to <daemon-n> denote each
1680 daemon's name (typically the file name of the
1684 For example, the output of /etc/init.d/lpd would look like:
1686 Starting printer spooler: lpd.
1690 This can be achieved by saying
1692 echo -n "Starting printer spooler: lpd"
1693 start-stop-daemon --start --quiet lpd
1696 in the script. If you have more than one daemon to
1697 start, you should do the following:
1699 echo -n "Starting remote file system services:"
1700 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
1701 echo -n " mountd"; start-stop-daemon --start --quiet mountd
1702 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
1705 This makes it possible for the user to see what takes
1706 so long and when the final daemon has been
1707 started. Please be careful where to put spaces: In the
1708 example above the system administrator can easily
1709 comment out a line if he don't wants to start a
1710 specific daemon, while the displayed message still
1711 looks good.</p></item>
1715 <p>when something needs to be configured.</p>
1718 If you have to set up different parameters of the
1719 system upon boot up, you can use this format:
1721 Setting <parameter> to `<value>'.
1725 You can use the following echo statement to get the quotes right:
1727 echo "Setting DNS domainname to \`"value"'."
1731 Note that the left quotation mark (`) is different
1732 from the right (').</p></item>
1735 <p>when a daemon is stopped.</p>
1738 When you stop a daemon you should issue a message
1739 similar to the startup message, except that `Starting'
1740 is replaced with `Stopping'.</p>
1743 So stopping the printer daemon will like like this:
1745 Stopping printer spooler: lpd.
1746 </example></p></item>
1749 <p>when something is executed.</p>
1752 There a several examples where you have to run a
1753 program at system startup or shutdown to perform a
1754 specific task. For example, setting the system's clock
1755 via `netdate' or killing all processes when the system
1756 comes down. Your message should like this:
1758 Doing something very useful...done.
1760 You should print the `done.' right after the job has been completed,
1761 so that the user gets informed why he has to wait. You can get this
1764 echo -n "Doing something very useful..."
1768 in your script.</p></item>
1771 <p>when the configuration is reloaded.</p>
1774 When a daemon is forced to reload its configuration
1775 files you should use the following format:
1777 Reloading <daemon's-name> configuration...done.
1778 </example></p></item>
1781 <p>when none of the above rules apply.</p>
1784 If you have to print a message that doesn't fit into
1785 the styles described above, you can use something
1786 appropriate, but please have a look at the overall
1787 rules listed above.</p></item>
1792 <heading>Menus</heading>
1795 Menu entries should follow the current menu policy as
1796 defined in the file <ftpsite>ftp.debian.org</ftpsite> in
1797 <ftppath>/debian/doc/package-developer/menu_policy.txt</ftppath>
1798 or your local mirror.
1802 The Debian <tt>menu</tt> packages provides a unique
1803 interface between packages providing applications and
1804 documents, and <em>menu programs</em> (either X window
1805 managers or text-based menu programs as
1806 <prgn>pdmenu</prgn>).</p>
1809 All packages that provide applications that need not be
1810 passed any special command line arguments for normal
1811 operation should register a menu entry for those
1812 applications, so that users of the <tt>menu</tt> package
1813 will automatically get menu entries in their window
1814 managers, as well in shells like <tt>pdmenu</tt>.</p>
1817 Please refer to the <em>Debian Menu System</em> document
1818 that comes with the <tt>menu</tt> package for information
1819 about how to register your applications and web
1820 documents.</p></sect>
1824 <heading>Keyboard configuration</heading>
1827 To achieve a consistent keyboard configuration (i.e., all
1828 applications interpret a keyboard event the same way) all
1829 programs in the Debian distribution have to be configured to
1830 comply with the following guidelines.</p>
1833 Here is a list that contains certain keys and their interpretation:
1836 <tag><tt><--</tt></tag>
1837 <item><p>delete the character to the left of the cursor</p></item>
1839 <tag><tt>Delete</tt></tag>
1840 <item><p>delete the character to the right of the cursor</p></item>
1842 <tag><tt>Control+H</tt></tag>
1843 <item><p>emacs: the help prefix</p></item>
1846 The interpretation of any keyboard events should be independent
1847 of the terminal that's used, be it a virtual console, an X
1848 terminal emulator, an rlogin/telnet session, etc.</p>
1851 The following list explains how the different programs
1852 should be set up to achieve this:</p>
1855 <list compact="compact">
1856 <item><p>`<tt><--</tt>' generates KB_Backspace in
1859 <item><p>`<tt>Delete</tt>' generates KB_Delete in X.</p></item>
1863 X translations are set up to make KB_Backspace
1864 generate ASCII DEL, and to make KB_Delete generate
1865 <tt>ESC [ 3 ~</tt> (this is the vt220 escape code for
1866 the `delete character' key). This must be done by
1867 loading the resources using xrdb on all local X
1868 displays, not using the application defaults, so that
1869 the translation resources used correspond to the
1870 xmodmap settings.</p></item>
1874 The Linux console is configured to make
1875 `<tt><--</tt>' generate DEL, and `Delete' generate
1876 <tt>ESC [ 3 ~</tt> (this is the case at the
1880 X applications are configured so that Backspace
1881 deletes left, and Delete deletes right. Motif
1882 applications already work like this.</p></item>
1884 <item><p>stty erase <tt>^?</tt> .</p></item>
1887 The `xterm' terminfo entry should have <tt>ESC [ 3
1888 ~</tt> for kdch1, just like TERM=linux and
1889 TERM=vt220.</p></item>
1892 Emacs is programmed to map KB_Backspace or the `stty
1893 erase' character to delete-backward-char, and
1894 KB_Delete or kdch1 to delete-forward-char, and
1895 <tt>^H</tt> to help as always.</p></item>
1898 Other applications use the `stty erase' character and
1899 kdch1 for the two delete keys, with ASCII DEL being
1900 `delete previous character' and kdch1 being `delete
1901 character under cursor'.</p></item>
1905 This will solve the problem except for:</p>
1908 <list compact="compact">
1910 Some terminals have a <tt><--</tt> key that cannot
1911 be made to produce anything except <tt>^H</tt>. On
1912 these terminals Emacs help will be unavailable on
1913 <tt>^H</tt> (assuming that the `stty erase' character
1914 takes precedence in Emacs, and has been set
1915 correctly). M-x help or F1 (if available) can be used
1919 Some operating systems use <tt>^H</tt> for stty erase.
1920 However, modern telnet versions and all rlogin
1921 versions propagate stty settings, and almost all UNIX
1922 versions honour stty erase. Where the stty settings
1923 are not propagated correctly things can be made to
1924 work by using stty manually.</p></item>
1927 Some systems (including previous Debian versions) use
1928 xmodmap to arrange for both <tt><--</tt> and Delete
1929 to generate KB_Delete). We can change the behavior
1930 of their X clients via the same X resources that we
1931 use to do it for our own, or have our clients be
1932 configured via their resources when things are the
1933 other way around. On displays configured like this
1934 Delete will not work, but <tt><--</tt>
1938 Some operating systems have different kdch1 settings
1939 in their terminfo for xterm and others. On these
1940 systems the Delete key will not work correctly when
1941 you log in from a system conforming to our policy, but
1942 <tt><--</tt> will.</p></item>
1949 <heading>Environment variables</heading>
1952 No program may depend on environment variables to get
1953 reasonable defaults. (That's because these environment
1954 variables would have to be set in a system-wide
1955 configuration file like /etc/profile, which is not supported
1959 If a program should depend on environment variables for its
1960 configuration, the program has to be changed to fall back to
1961 a reasonable default configuration if these environment
1962 variables are not present. If this cannot be done easily
1963 (e.g., if the source code of a non-free program is not
1964 available), the program should be replaced by a small
1965 `wrapper' shell script which sets the environment variables
1966 and calls the original program.</p>
1969 Here is an example of a wrapper script for this purpose:
1975 exec /usr/lib/foo/foo "$@"
1979 Furthermore, as <tt>/etc/profile</tt> is a configuration
1980 file of the <prgn>bash</prgn> package, no other package may
1981 put any environment variables or other commands into that
1986 <heading>Files</heading>
1990 <heading>Binaries</heading>
1993 It is not allowed that two packages install programs with
1994 different functionality but with the same filenames. (The
1995 case of two programs having the same functionality but
1996 different implementations is handled via `alternatives.')
1997 If this case happens, one of the programs has to be
1998 renamed. The maintainers should report this to the
1999 developers' mailing and try to find a consensus about
2000 which package will have to be renamed. If a consensus can
2001 not be reached, <em>both</em> programs must be
2005 Generally the following compilation parameters should be used:
2008 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
2010 install -s # (or use strip on the files in debian/tmp)
2014 Note that all installed binaries should be stripped,
2015 either by using the <tt>-s</tt> flag to
2016 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
2017 the binaries after they have been copied into
2018 <tt>debian/tmp</tt> but before the tree is made into a
2022 The <tt>-g</tt> flag is useful on compilation so that you
2023 have available a full set of debugging symbols in your
2024 built source tree, in case anyone should file a bug report
2025 involving (for example) a core dump.</p>
2028 The <tt>-N</tt> flag should not be used. On a.out systems
2029 it may have been useful for some very small binaries, but
2030 for ELF it has no good effect.</p>
2033 It is up to the package maintainer to decide what
2034 compilation options are best for the package. Certain
2035 binaries (such as computationally-intensive programs) may
2036 function better with certain flags (<tt>-O3</tt>, for
2037 example); feel free to use them. Please use good judgment
2038 here. Don't use flags for the sake of it; only use them
2039 if there is good reason to do so. Feel free to override
2040 the upstream author's ideas about which compilation
2041 options are best--they are often inappropriate for our
2042 environment.</p></sect>
2046 <heading>Libraries</heading>
2049 All libraries must have a shared version in the lib
2050 package and a static version in the lib-dev package. The
2051 shared version must be compiled with <tt>-fPIC</tt>, and
2052 the static version must not be. In other words, each
2053 <tt>*.c</tt> file is compiled twice.</p>
2056 You have to specify the gcc option <tt>-D_REENTRANT</tt>
2057 when building a library (either static or shared) to make
2058 the library compatible with LinuxThreads.</p>
2061 Note that all installed shared libraries should be
2064 strip --strip-unneeded <your-lib>
2066 (The option `--strip-unneeded' makes <tt>strip</tt> remove
2067 only the symbols which aren't needed for relocation
2068 processing.) Shared libraries can function perfectly well
2069 when stripped, since the symbols for dynamic linking are
2070 in a separate part of the ELF object file.</p>
2073 Note that under some circumstances it may be useful to
2074 install a shared library unstripped, for example when
2075 building a separate package to support debugging.
2079 An ever increasing number of packages are using libtool to
2080 do their linking. The latest GNU libtools (>= 1.3a) can take
2081 advantage of installed libtool archive files (`*.la'). The
2082 main advantage of libtool's .la files is that it allows
2083 libtool to store and subsequently access metadata with
2084 respect to the libraries it builds. libtool will search for
2085 those files, which contain a lot of useful information about
2086 a library (e.g. dependency libraries for static
2087 linking). Also, they're essential for programs using
2092 Certainly libtool is fully capable of linking against shared
2093 libraries which don't have .la files, but being a mere shell
2094 script it can add considerably to the build time of a
2095 libtool using package if that shell-script has to derive all
2096 this information from first principles for each library every
2097 time it is linked. With the advent of libtool-1.4 (and to a
2098 lesser extent libtool-1.3), the .la files will also store
2099 information about inter-library dependencies which cannot
2100 necessarily be derived after the .la file is deleted.
2104 Packages that use libtool to create shared libraries must
2105 include the <em>.la</em> files in the <em>-dev</em>
2106 packages. This is a good idea in general, and especially
2107 for static linking issues.
2111 Please make sure that you use only released versions of
2112 shared libraries to build your packages; otherwise other
2113 users will not be able to run your binaries
2114 properly. Producing source packages that depend on
2115 unreleased compilers is also usually a bad
2122 <heading>Shared libraries</heading>
2125 Packages involving shared libraries should be split up
2126 into several binary packages.</p>
2129 For a straightforward library which has a development
2130 environment and a runtime kit including just shared
2131 libraries you need to create two packages:
2132 <tt><var>libraryname</var><var>soname</var></tt>
2133 (<var>soname</var> is the shared object name of the shared
2134 library--it's the thing that has to match exactly between
2135 building an executable and running it for the dynamic
2136 linker to be able run the program; usually the
2137 <var>soname</var> is the major number of the library) and
2138 <tt><var>libraryname</var><var>soname</var>-dev</tt>.</p>
2141 If you prefer only to support one development version at a
2142 time you may name the development package
2143 <tt><var>libraryname</var>-dev</tt>; otherwise you may
2144 wish to use <prgn>dpkg</prgn>'s conflicts mechanism to
2145 ensure that the user only installs one development version
2146 at a time (after all, different development versions are
2147 likely to have the same header files in them, causing a
2148 filename clash if both are installed). Typically the
2149 development version will also need an exact version
2150 dependency on the runtime library, to make sure that
2151 compilation and linking happens correctly.</p>
2154 Packages which use the shared library should have a
2155 dependency on the name of the shared library package,
2156 <tt><var>libraryname</var><var>soname</var></tt>. When
2157 the <var>soname</var> changes you can have both versions
2158 of the library installed while moving from the old library
2162 If your package has some run-time support programs which
2163 use the shared library you must <em>not</em> put them in
2164 the shared library package. If you do that then you won't
2165 be able to install several versions of the shared library
2166 without getting filename clashes. Instead, either create
2167 a third package for the runtime binaries (this package
2168 might typically be named
2169 <tt><var>libraryname</var>-runtime</tt>--note the absence
2170 of the <var>soname</var> in the package name) or if the
2171 development package is small include them in there.</p>
2174 If you have several shared libraries built from the same
2175 source tree you can lump them all together into a single
2176 shared library package, provided that you change all their
2177 <var>soname</var>s at once (so that you don't get filename
2178 clashes if you try to install different versions of the
2179 combined shared libraries package).</p>
2182 Follow the directions in the <em>Debian Packaging
2183 Manual</em> for putting the shared library in its package,
2184 and make sure you include a <tt>shlibs</tt> control area
2185 file with details of the dependencies for packages which
2186 use the library.</p>
2189 Shared libraries should <em>not</em> be installed
2190 executable, since <prgn>ld.so</prgn> does not require this
2191 and trying to execute a shared library results in a core
2196 <heading>Scripts</heading>
2199 All command scripts, including the package maintainer
2200 scripts inside the package and used by <prgn>dpkg</prgn>,
2201 should have a <tt>#!</tt> line naming the shell to be used
2202 to interpret them.</p>
2205 In the case of Perl scripts this should be
2206 <tt>#!/usr/bin/perl</tt>.</p>
2209 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>)
2210 should almost certainly start with <tt>set -e</tt> so that
2211 errors are detected. Every script <em>must</em> use
2212 <tt>set -e</tt> or check the exit status of <em>every</em>
2216 The standard shell interpreter `<tt>/bin/sh</tt>' may be a
2217 symbolic link to any POSIX compatible shell. Thus, shell
2218 scripts specifying `<tt>/bin/sh</tt>' as interpreter may
2219 only use POSIX features. If a script requires non-POSIX
2220 features from the shell interpreter, the appropriate shell
2221 has to be specified in the first line of the script (e.g.,
2222 `<tt>#!/bin/bash</tt>') and the package has to depend on
2223 the package providing the shell (unless the shell package
2224 is marked `Essential', e.g., in the case of
2225 <prgn>bash</prgn>).</p>
2228 Restrict your script to POSIX features when possible so
2229 that it may use <tt>/bin/sh</tt> as its interpreter. If
2230 your script works with <prgn>ash</prgn>, it's probably
2231 POSIX compliant, but if you are in doubt, use
2232 <tt>/bin/bash</tt>.</p>
2235 Perl scripts should check for errors when making any
2236 system calls, including <tt>open</tt>, <tt>print</tt>,
2237 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.</p>
2240 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided
2241 as scripting languages. See <em>Csh Programming
2242 Considered Harmful</em>, one of the <tt>comp.unix.*</tt>
2243 FAQs. It can be found on
2244 <url id="http://language.perl.com/versus/csh.whynot">, or
2245 <url id="http://www.cpan.org/doc/FMTEYEWTK/versus/csh.whynot">
2246 or even on <ftpsite>ftp.cpan.org</ftpsite>
2247 <ftppath>/pub/perl/CPAN/doc/FMTEYEWTK/versus/csh.whynot</ftppath>.
2248 If an upstream package comes with <prgn>csh</prgn> scripts
2249 then you must make sure that they start with
2250 <tt>#!/bin/csh</tt> and make your package depend on the
2251 <prgn>c-shell</prgn> virtual package.</p>
2254 Any scripts which create files in world-writable
2255 directories (e.g., in <tt>/tmp</tt>) have to use a
2256 mechanism which will fail if a file with the same name
2260 The Debian base distribution provides the
2261 <prgn>tempfile</prgn> and <prgn>mktemp</prgn> utilities
2262 for use by scripts for this purpose.</p></sect>
2266 <heading>Symbolic links</heading>
2269 In general, symbolic links within a top-level directory
2270 should be relative, and symbolic links pointing from one
2271 top-level directory into another should be absolute. (A
2272 top-level directory is a sub-directory of the root
2276 In addition, symbolic links should be specified as short
2277 as possible, i.e., link targets like `foo/../bar' are
2281 Note that when creating a relative link using
2282 <prgn>ln</prgn> it is not necessary for the target of the
2283 link to exist relative to the working directory you're
2284 running <prgn>ln</prgn> from; nor is it necessary to
2285 change directory to the directory where the link is to be
2286 made. Simply include the string that should appear as the
2287 target of the link (this will be a pathname relative to
2288 the directory in which the link resides) as the first
2289 argument to <prgn>ln</prgn>.</p>
2292 For example, in your <prgn>Makefile</prgn> or
2293 <tt>debian/rules</tt>, do things like:
2295 ln -fs gcc $(prefix)/bin/cc
2296 ln -fs gcc debian/tmp/usr/bin/cc
2297 ln -fs ../sbin/sendmail $(prefix)/bin/runq
2298 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
2302 A symbolic link pointing to a compressed file should
2303 always have the same file extension as the referenced
2304 file. (For example, if a file `<tt>foo.gz</tt>' is
2305 referenced by a symbolic link, the filename of the link
2306 has to end with `<tt>.gz</tt>' too, as in
2307 `bar.gz.')</p></sect>
2311 <heading>Device files</heading>
2314 No package may include device files in the package file
2318 If a package needs any special device files that are not
2319 included in the base system, it has to call
2320 <prgn>makedev</prgn> in the <tt>postinst</tt> script,
2321 after asking the user for permission to do so.</p>
2324 No package should remove any device files in the
2325 <tt>postrm</tt> or any other script. This is left to the
2326 system administrator.</p>
2329 Debian uses the serial devices
2330 <tt>/dev/tty*</tt>. Programs using the old
2331 <tt>/dev/cu*</tt> devices should be changed to use
2332 <tt>/dev/tty*</tt>.</p></sect>
2336 <heading>Configuration files</heading>
2339 Any configuration files created or used by your package
2340 should reside in <tt>/etc</tt>. If there are several you
2341 should consider creating a subdirectory named after your
2345 It is almost certain that any file in <tt>/etc</tt> that
2346 is in your package's file system archive should be listed
2347 in <prgn>dpkg</prgn>'s <tt>conffiles</tt> control area
2348 file. (See the <em>Debian Packaging
2352 Only packages that are tagged <em>conflicting</em> with
2353 each other may specify the same file as
2354 <tt>conffile</tt>. A package may not modify a
2355 configuration file of another package.</p>
2358 If two or more packages use the same configuration file,
2359 one of these packages has to be defined as <em>owner</em>
2360 of the configuration file, i.e., it has to list the file
2361 as <tt>conffile</tt> and has to provide a program that
2362 modifies the configuration file.</p>
2365 The other packages have to depend on the <em>owner</em>
2366 package and use that program to update the configuration
2370 Sometimes it's appropriate to build a new package, which
2371 just provides the basic <em>infrastructure</em> for the
2372 other packages and which manages the shared configuration
2373 files. (Check out the <prgn>sgml-base</prgn> package as an
2377 Files in <tt>/etc/skel</tt> will automatically be copied
2378 into new user accounts by <prgn>adduser</prgn>. They
2379 should not be referenced there by any program.</p>
2382 Therefore, if a program needs a dotfile to exist in
2383 advance in <tt>$HOME</tt> to work sensibly that dotfile
2384 should be installed in <tt>/etc/skel</tt> (and listed in
2385 conffiles, if it is not generated and modified dynamically
2386 by the package's installation scripts).</p>
2389 However, programs that require dotfiles in order to
2390 operate sensibly (dotfiles that they do not create
2391 themselves automatically, that is) are a bad thing, and
2392 programs should be configured by the Debian default
2393 installation as close to normal as possible.</p>
2396 Therefore, if a program in a Debian package needs to be
2397 configured in some way in order to operate sensibly that
2398 configuration should be done in a site-wide global
2399 configuration file elsewhere in <tt>/etc</tt>. Only if
2400 the program doesn't support a site-wide default
2401 configuration and the package maintainer doesn't have time
2402 to add it should a default per-user file be placed in
2403 <tt>/etc/skel</tt>.</p>
2406 <tt>/etc/skel</tt> should be as empty as we can make it.
2407 This is particularly true because there is no easy
2408 mechanism for ensuring that the appropriate dotfiles are
2409 copied into the accounts of existing users when a package
2413 Ideally the sysadmin should not have to do any
2414 configuration other than that done (semi-)automatically by
2415 the <tt>postinst</tt> script.</p>
2419 <heading>Log files</heading>
2421 The traditional approach to log files has been to set up ad
2422 hoc log rotation schemes using simple shell scripts and
2423 cron. While this approach is highly customizable, it
2424 requires quite a lot of sysadmin work. Even though the
2425 original Debian system helped a little by automatically
2426 installing a system which can be used as a template, this
2427 was deemed not enough.
2431 A better scheme is to use logrotate, a GPL'd program
2432 developed by Red Hat, which centralizes log management. It
2433 has both a config file (<tt>/etc/logrotate.conf</tt>) and a
2434 directory where packages can drop logrotation info
2435 (<tt>/etc/logrotate.d</tt>).
2439 Log files should usually be named
2440 <tt>/var/log/<var>package</var>.log</tt>. If you have many
2441 log files, or need a separate directory for permissions
2442 reasons (<tt>/var/log</tt> is writable only by
2443 <tt>root</tt>), you should usually create a directory named
2444 <tt>/var/log/<var>package</var></tt>.</p>
2447 Make sure that any log files are rotated occasionally so
2448 that they don't grow indefinitely; the best way to do this
2449 is to drop a script into the directory
2450 <tt>/etc/logrotate.d</tt> and use the facilities provided by
2451 logrotate. Here is a good example for a logrotate config
2452 file (for more information see <manref name="logrotate"
2460 /etc/init.d/foo force-reload
2464 Which rotates all files under `/var/log/foo', saves 12
2465 compressed generations, and sends a HUP signal at the end of
2471 Make sure that any log files are removed when the package is
2472 purged (but not when it is only removed), by checking the
2473 argument to the <tt>postrm</tt> script (see the <em>Debian
2474 Packaging Manual</em> for details).</p>
2479 <heading>Permissions and owners</heading>
2482 The rules in this section are guidelines for general use.
2483 If necessary you may deviate from the details below.
2484 However, if you do so you must make sure that what is done
2485 is secure and you must try to be as consistent as possible
2486 with the rest of the system. You should probably also
2487 discuss it on <prgn>debian-devel</prgn> first.</p>
2490 Files should be owned by <tt>root.root</tt>, and made
2491 writable only by the owner and universally readable (and
2492 executable, if appropriate).</p>
2495 Directories should be mode 755 or (for group-writability)
2496 mode 2775. The ownership of the directory should be
2497 consistent with its mode--if a directory is mode 2775, it
2498 should be owned by the group that needs write access to
2502 Setuid and setgid executables should be mode 4755 or 2755
2503 respectively, and owned by the appropriate user or group.
2504 They should not be made unreadable (modes like 4711 or
2505 2711 or even 4111); doing so achieves no extra security,
2506 because anyone can find the binary in the freely available
2507 Debian package--it is merely inconvenient. For the same
2508 reason you should not restrict read or execute permissions
2509 on non-set-id executables.</p>
2512 Some setuid programs need to be restricted to particular
2513 sets of users, using file permissions. In this case they
2514 should be owned by the uid to which they are set-id, and
2515 by the group which should be allowed to execute them.
2516 They should have mode 4754; there is no point in making
2517 them unreadable to those users who must not be allowed to
2521 Do not arrange that the system administrator can only
2522 reconfigure the package to correspond to their local
2523 security policy by changing the permissions on a binary.
2524 Ordinary files installed by <prgn>dpkg</prgn> (as opposed
2525 to conffiles and other similar objects) have their
2526 permissions reset to the distributed permissions when the
2527 package is reinstalled. Instead you should consider (for
2528 example) creating a group for people allowed to use the
2529 program(s) and making any setuid executables executable
2530 only by that group.</p>
2533 If you need to create a new user or group for your package
2534 there are two possibilities. Firstly, you may need to
2535 make some files in the binary package be owned by this
2536 user or group, or you may need to compile the user or
2537 group id (rather than just the name) into the binary
2538 (though this latter should be avoided if possible). In
2539 this case you need a statically allocated id.</p>
2542 You must ask for a user or group id from the base system
2543 maintainer, and must not release the package until you
2544 have been allocated one. Once you have been allocated one
2545 you must make the package depend on a version of the base
2546 system with the id present in <tt>/etc/passwd</tt> or
2547 <tt>/etc/group</tt>, or alternatively arrange for your
2548 package to create the user or group itself with the
2549 correct id (using <tt>adduser</tt>) in its pre- or
2550 post-installation script (the latter is to be preferred if
2551 it is possible).</p>
2554 On the other hand, the program may able to determine the
2555 uid or gid from the group name at runtime, so that a
2556 dynamic id can be used. In this case you must choose an
2557 appropriate user or group name, discussing this on
2558 <prgn>debian-devel</prgn> and checking with the base
2559 system maintainer that it is unique and that they do not
2560 wish you to use a statically allocated id instead. When
2561 this has been checked you must arrange for your package to
2562 create the user or group if necessary using
2563 <prgn>adduser</prgn> in the pre- or post-installation
2564 script (again, the latter is to be preferred if it is
2568 Note that changing the numeric value of an id associated with a name
2569 is very difficult, and involves searching the file system for all
2570 appropriate files. You need to think carefully whether a static or
2571 dynamic id is required, since changing your mind later will cause
2577 <heading>Customized programs</heading>
2579 <sect id="arch-spec">
2580 <heading>Architecture specification strings</heading>
2583 If a program needs to specify an <em>architecture specification
2584 string</em> in some place, the following format has to be used:
2586 <arch>-<os>
2588 where `<arch>' is one of the following: i386, alpha, arm, m68k,
2589 powerpc, sparc and `<os>' is one of: linux, gnu. Use
2590 of <em>gnu</em> in this string is reserved for the GNU/Hurd
2591 operating system. .</p>
2593 Note, that we don't want to use `<arch>-debian-linux'
2594 to apply to the rule `architecture-vendor-os' since this
2595 would make our programs incompatible to other Linux
2596 distributions. Also note, that we don't use
2597 `<arch>-unknown-linux', since the `unknown' does not
2598 look very good.</p></sect>
2602 <heading>Daemons</heading>
2605 The configuration files <tt>/etc/services</tt>,
2606 <tt>/etc/protocols</tt>, and <tt>/etc/rpc</tt> are managed
2607 by the <prgn>netbase</prgn> package and may not be modified
2608 by other packages.</p>
2611 If a package requires a new entry in one of these files, the
2612 maintainer has to get in contact with the
2613 <prgn>netbase</prgn> maintainer, who will add the entries
2614 and release a new version of the <prgn>netbase</prgn>
2618 The configuration file <tt>/etc/inetd.conf</tt> may be
2619 modified by the package's scripts only via the
2620 <prgn>update-inetd</prgn> script or the
2621 <prgn>DebianNet.pm</prgn> Perl module.</p>
2624 If a package wants to install an example entry into
2625 <tt>/etc/inetd.conf</tt>, the entry has to be preceded with
2626 exactly one hash character (#). Such lines are treated as
2627 `commented out by user' by the <prgn>update-inetd</prgn>
2628 script and are not changed or activated during a package
2633 <heading>Using pseudo-ttys and modifying wtmp, utmp and lastlog</heading>
2636 Some programs need to create pseudo-ttys. This should be done
2637 using Unix98 ptys if the C library supports it. The resulting
2638 program must not be installed setuid root, unless that
2639 is required for other functionality.
2643 The files <tt>/var/run/utmp</tt>, <tt>/var/log/wtmp</tt> and
2644 <tt>/var/log/lastlog</tt> must be installed writeable by
2645 group utmp. Programs who need to modify those files must
2646 be installed install setgid utmp.
2651 <heading>Editors and pagers</heading>
2654 Some programs have the ability to launch an editor or pager
2655 program to edit or display a text document. Since there are
2656 lots of different editors and pagers available in the Debian
2657 distribution, the system administrator and each user should
2658 have the possibility to choose his/her preferred editor and
2662 In addition, every program should choose a good default
2663 editor/pager if none is selected by the user or system
2667 Thus, every program that launches an editor or pager has to
2668 use the EDITOR or PAGER environment variables to determine
2669 the editor/pager the user wants to get started. If these
2670 variables are not set, the programs `/usr/bin/editor' and
2671 `/usr/bin/pager' have to be used, respectively.</p>
2674 These two files are managed through `alternatives.' That is,
2675 every package providing an editor or pager has to call the
2676 `update-alternatives' script to register these programs.</p>
2679 If it is very hard to adapt a program to make us of the
2680 EDITOR and PAGER variable, that program should be configured
2681 to use `/usr/bin/sensible-editor' and
2682 `/usr/bin/sensible-pager' as editor or pager program,
2683 respectively. These are two scripts provided in the Debian
2684 base system that check the EDITOR and PAGER variables and
2685 launches the appropriate program or falls back to
2686 `/usr/bin/editor' and `/usr/bin/pager', automatically.</p>
2689 Since the Debian base system already provides an editor and
2690 a pager program, there is no need for a package to depend on
2691 `editor' and `pager', nor is it necessary for a package to
2692 provide such virtual packages.</p></sect>
2695 <sect id="web-appl">
2696 <heading>Web servers and applications</heading>
2699 This section describes the locations and URLs that have to
2700 be used by all web servers and web application in the Debian
2706 <p>Cgi-bin executable files are installed in the
2709 /usr/lib/cgi-bin/<cgi-bin-name>
2711 and can be referred to as
2713 http://localhost/cgi-bin/<cgi-bin-name>
2714 </example></p></item>
2717 <item><p>Access to html documents</p>
2720 Html documents for a package are stored in
2721 /usr/share/doc/<var>package</var> and can be referred to as
2723 http://localhost/doc/<package>/<filename>
2724 </example></p></item>
2727 <item><p>Web Document Root</p>
2730 Web Applications should try to avoid storing files in
2731 the Web Document Root. Instead use the
2732 /usr/share/doc/<package> directory for documents and
2733 register the Web Application via the menu package. If
2734 access to the web-root is unavoidable then use
2738 as the Document Root. This might be just a
2739 symbolic link to the location where the sysadmin has
2740 put the real document root.</p>
2743 </enumlist></p></sect>
2747 <heading>Mail transport agents</heading>
2750 Debian packages which process electronic mail, whether
2751 mail-user-agents (MUAs) or mail-transport-agents (MTAs),
2752 <em>must</em> make sure that they are compatible with the
2753 configuration decisions below. Failure to do this may
2754 result in lost mail, broken <tt>From:</tt> lines, and other
2755 serious brain damage!</p>
2758 The mail spool is <tt>/var/spool/mail</tt> and the interface
2759 to send a mail message is <tt>/usr/sbin/sendmail</tt> (as
2760 per the FHS). The mail spool is part of the base system
2761 and not part of the MTA package.</p>
2764 All Debian MUAs and MTAs have to use the <tt>maillock</tt>
2765 and <tt>mailunlock</tt> functions provided by the
2766 <tt>liblockfile</tt> packages to lock and unlock mail
2767 boxes. These functions implement a NFS-safe locking
2768 mechanism. (It is ok if MUAs and MTAs don't link against
2769 liblockfile but use a <em>compatible</em> mechanism. Please
2770 compare the mechanisms very carefully!)</p>
2773 Mailboxes are generally 660 <tt><var>user</var>.mail</tt>
2774 unless the user has chosen otherwise. A MUA may remove a
2775 mailbox (unless it has nonstandard permissions) in which
2776 case the MTA or another MUA must recreate it if needed.
2777 Mailboxes must be writable by group mail.</p>
2780 The mail spool is 2775 <tt>mail.mail</tt>, and MUAs need to
2781 be setgid mail to do the locking mentioned above (and
2782 obviously need to avoid accessing other users' mailboxes
2783 using this privilege).</p>
2786 <tt>/etc/aliases</tt> is the source file for the system mail
2787 aliases (e.g., postmaster, usenet, etc.)--it is the one
2788 which the sysadmin and <tt>postinst</tt> scripts may edit.
2789 After <tt>/etc/aliases</tt> is edited the program or human
2790 editing it must call <prgn>newaliases</prgn>. All MTA
2791 packages should come with a <prgn>newaliases</prgn> program,
2792 even if it does nothing, but older MTA packages do not do
2793 this so programs should not fail if <prgn>newaliases</prgn>
2794 cannot be found.</p>
2797 The convention of writing <tt>forward to
2798 <var>address</var></tt> in the mailbox itself is not
2799 supported. Use a <tt>.forward</tt> file instead.</p>
2802 The location for the <prgn>rmail</prgn> program used by UUCP
2803 for incoming mail is <tt>/usr/sbin/rmail</tt>, as per the
2804 FHS. Likewise, <prgn>rsmtp</prgn>, for receiving
2805 batch-SMTP-over-UUCP, is in <tt>/usr/sbin/rsmtp</tt> if it
2809 If you need to know what name to use (for example) on
2810 outgoing news and mail messages which are generated locally,
2811 you should use the file <tt>/etc/mailname</tt>. It will
2812 contain the portion after the username and <tt>@</tt> (at)
2813 sign for email addresses of users on the machine (followed
2817 A package should check for the existence of this file. If
2818 it exists it should use it without comment. (An MTA's
2819 prompting configuration script may wish to prompt the user
2820 even if it finds this file exists.) If it does not exist it
2821 should prompt the user for the value and store it in
2822 <tt>/etc/mailname</tt> as well as using it in the package's
2823 configuration. The prompt should make it clear that the
2824 name will not just be used by that package. For example, in
2825 this situation the INN package says:
2827 Please enter the `mail name' of your system. This is the
2828 hostname portion of the address to be shown on outgoing
2829 news and mail messages. The default is
2830 <var>syshostname</var>, your system's host name. Mail
2831 name [`<var>syshostname</var>']:
2833 where <var>syshostname</var> is the output of <tt>hostname
2834 --fqdn</tt>.</p></sect>
2838 <heading>News system configuration</heading>
2841 All the configuration files related to the NNTP (news)
2842 servers and clients should be located under
2843 <tt>/etc/news</tt>.</p>
2846 There are some configuration issues that apply to a number
2847 of news clients and server packages on the machine. These
2851 <tag>/etc/news/organization</tag>
2852 <item><p>A string which shall appear as the
2853 organization header for all messages posted
2854 by NNTP clients on the machine</p></item>
2856 <tag>/etc/news/server</tag>
2857 <item><p>Contains the FQDN of the upstream NNTP
2858 server, or localhost if the local machine is
2859 an NNTP server.</p></item>
2862 Other global files may be added as required for cross-package news
2863 configuration.</p></sect>
2867 <heading>Programs for the X Window System</heading>
2870 Some programs can be configured with or without support for the X
2871 Window System. Typically, binaries produced with support for X
2872 will need the X shared libraries to run.
2876 Such programs should be configured <em>with</em> X support,
2877 and should declare a dependency on <tt>xlib6g</tt> (which
2878 contains X shared libraries). Users who wish to use the
2879 program can install just the relatively small
2880 <tt>xfree86-common</tt> and <tt>xlib6g</tt> packages, and do
2881 not need to install the whole of X.</p>
2884 Do not create two versions (one with X support and one
2885 without) of your package.</p>
2888 <em>Application defaults</em> files have to be installed in
2889 the directory <tt>/usr/X11R6/lib/X11/app-defaults/</tt>.
2890 They are considered as part of the program code. Thus, they
2891 should not be modified and should not be tagged as
2892 <em>conffile</em>s. If the local system administrator wants
2893 to customize X applications globally, a file with the same
2894 name as that of the package should be placed in the
2895 <tt>/etc/X11/Xresources/</tt> directory instead.
2896 <em>Important:</em> packages that install files into the
2897 <tt>/etc/X11/Xresources/</tt> directory <em>must</em>
2898 declare a conflict with <tt>xbase (<<
2899 3.3.2.3a-2)</tt>; if this is not done it is possible for the
2900 package to destroy a previously-existing
2901 <tt>/etc/X11/Xresources</tt> <em>file</em>.</p>
2904 No package should ever install files into the directories
2905 <tt>/usr/bin/X11/</tt>, <tt>/usr/doc/X11/</tt>,
2906 <tt>/usr/include/X11/</tt>, or <tt>/usr/lib/X11/</tt>; these
2907 directories are actually symbolic links, which <tt>dpkg</tt>
2908 does not follow when unpacking a package. Instead, use
2909 <tt>/usr/X11R6/bin/</tt>, <tt>/usr/doc/package/</tt> (i.e.,
2910 place files with the rest of your package's documentation),
2911 <tt>/usr/X11R6/include/</tt>, and
2912 <tt>/usr/X11R6/lib/</tt>. This restriction governs only the
2913 paths used by the package as it is unpacked onto the system; it
2914 is permissible, and even preferable, for files within a package
2915 (shell scripts, for instance) to refer to the
2916 <tt>/usr/{bin,include,lib}/X11/</tt> directories rather than
2917 their <tt>/usr/X11R6/</tt> counterparts -- this way they do not
2918 have to be modified in the event that the X Window System
2919 packages install their files into a different directory in the
2923 If you package a program that requires the (non-free)
2924 OSF/Motif library, you should try to determine whether the
2925 programs works reasonably well with the free
2926 re-implementation of Motif called LessTif. If so, build the
2927 package using the LessTif libraries; it can then go into the
2928 main section of the package repository and become an
2929 official part of the Debian distribution.</p>
2932 If however, the Motif-based program works insufficiently
2933 well with LessTif, you should instead provide "-smotif" and "-dmotif"
2934 versions (appending these identifiers to the name of the
2935 package), which are statically and dynamically linked
2936 against the Motif libraries, respectively. (All known
2937 versions of OSF/Motif permit redistribution of
2938 statically-linked binaries using the library, but check the
2939 license on your copy of Motif to be sure.) This two-package
2940 approach allows users without Motif to use the package,
2941 whereas users with Motif installed can enjoy the advantages
2942 of the dynamically-linked version (a considerable savings in
2943 disk space usage, download time, etc.). Neither "-smotif"
2944 nor "-dmotif" packages can go into the main section; if the
2945 licensing on the package is compatible with the Debian Free
2946 Software Guidelines, it may go into the contrib section;
2947 otherwise it must go into the non-free section.
2954 <heading>Emacs lisp programs</heading>
2957 Please refer to the `Debian Emacs Policy' (documented in
2958 <tt>debian-emacs-policy.gz</tt> of the
2959 <prgn>emacsen-common</prgn> package) for details of how to
2960 package emacs lisp programs.</p></sect>
2964 <heading>Games</heading>
2967 The permissions on /var/lib/games are 755
2968 <tt>root.root</tt>.</p>
2971 Each game decides on its own security policy.</p>
2974 Games which require protected, privileged access to
2975 high-score files, savegames, etc., must be made
2976 set-<em>group</em>-id (mode 2755) and owned by
2977 <tt>root.games</tt>, and use files and directories with
2978 appropriate permissions (770 <tt>root.games</tt>, for
2979 example). They must <em>not</em> be made
2980 set-<em>user</em>-id, as this causes security problems. (If
2981 an attacker can subvert any set-user-id game they can
2982 overwrite the executable of any other, causing other players
2983 of these games to run a Trojan horse program. With a
2984 set-group-id game the attacker only gets access to less
2985 important game data, and if they can get at the other
2986 players' accounts at all it will take considerably more
2990 Some packages, for example some fortune cookie programs, are
2991 configured by the upstream authors to install with their
2992 data files or other static information made unreadable so
2993 that they can only be accessed through set-id programs
2994 provided. Do not do this in a Debian package: anyone can
2995 download the <tt>.deb</tt> file and read the data from it,
2996 so there is no point making the files unreadable. Not
2997 making the files unreadable also means that you don't have
2998 to make so many programs set-id, which reduces the risk of a
3002 As described in the FHS, binaries of games should be
3003 installed in the directory <tt>/usr/games</tt>. This also
3004 applies to games that use the X Window system. Manual pages
3005 for games (X and non-X games) should be installed in
3006 <tt>/usr/share/man/man6</tt>.</p>
3010 <chapt><heading>Documentation</heading>
3014 <heading>Manual pages</heading>
3017 You must install manual pages in <prgn>nroff</prgn> source
3018 form, in appropriate places under <tt>/usr/share/man</tt>. You
3019 should only use sections 1 to 9 (see the FHS for more
3020 details). You must <em>not</em> install a preformatted `cat
3024 If no manual page is available for a particular program,
3025 utility or function and this is reported as a bug on
3026 debian-bugs, a symbolic link from the requested manual page
3027 to the <manref name="undocumented" section="7"> manual page
3028 should be provided. This symbolic link can be created from
3029 <tt>debian/rules</tt> like this:
3031 ln -s ../man7/undocumented.7.gz \
3032 debian/tmp/usr/share/man/man[1-9]/the_requested_manpage.[1-9].gz
3034 This manpage claims that the lack of a manpage has been
3035 reported as a bug, so you may only do this if it really has
3036 (you can report it yourself, if you like). Do not close the
3037 bug report until a proper manpage is available.</p>
3040 You may forward a complaint about a missing manpage to the
3041 upstream authors, and mark the bug as forwarded in the
3042 Debian bug tracking system. Even though the GNU Project do
3043 not in general consider the lack of a manpage to be a bug,
3044 we do--if they tell you that they don't consider it a bug
3045 you should leave the bug in our bug tracking system open
3049 Manual pages should be installed compressed using <tt>gzip
3053 If one manpage needs to be accessible via several names it
3054 is better to use a symbolic link than the <tt>.so</tt>
3055 feature, but there is no need to fiddle with the relevant
3056 parts of the upstream source to change from <tt>.so</tt> to
3057 symlinks--don't do it unless it's easy. Do not create hard
3058 links in the manual page directories, and do not put
3059 absolute filenames in <tt>.so</tt> directives. The filename
3060 in a <tt>.so</tt> in a manpage should be relative to the
3061 base of the manpage tree (usually
3062 <tt>/usr/share/man</tt>).</p></sect>
3066 <heading>Info documents</heading>
3069 Info documents should be installed in <tt>/usr/share/info</tt>.
3070 They should be compressed with <tt>gzip -9</tt>.</p>
3073 Your package must call <prgn>install-info</prgn> to update the Info
3075 file, in its post-installation script:
3077 install-info --quiet --section Development Development \
3078 /usr/share/info/foobar.info
3082 It is a good idea to specify a section for the location of
3083 your program; this is done with the <tt>--section</tt>
3084 switch. To determine which section to use, you should look
3085 at <tt>/usr/share/info/dir</tt> on your system and choose the most
3086 relevant (or create a new section if none of the current
3087 sections are relevant). Note that the <tt>--section</tt>
3088 flag takes two arguments; the first is a regular expression
3089 to match (case-insensitively) against an existing section,
3090 the second is used when creating a new one.</p>
3093 You must remove the entries in the pre-removal script:
3095 install-info --quiet --remove /usr/share/info/foobar.info
3099 If <prgn>install-info</prgn> cannot find a description entry
3100 in the Info file you will have to supply one. See <manref
3101 name="install-info" section="8"> for details.</p>
3105 <heading>Additional documentation</heading>
3108 Any additional documentation that comes with the package can
3109 be installed at the discretion of the package maintainer.
3110 Text documentation should be installed in a directory
3111 <tt>/usr/share/doc/<var>package</var></tt>, where
3112 <var>package</var> is the name of the package, and
3113 compressed with <tt>gzip -9</tt> unless it is small.</p>
3116 If a package comes with large amounts of documentation which
3117 many users of the package will not require you should create
3118 a separate binary package to contain it, so that it does not
3119 take up disk space on the machines of users who do not need
3120 or want it installed.</p>
3123 It is often a good idea to put text information files
3124 (<tt>README</tt>s, changelogs, and so forth) that come with
3125 the source package in <tt>/usr/share/doc/<var>package</var></tt>
3126 in the binary package. However, you don't need to install
3127 the instructions for building and installing the package, of
3132 <heading>Preferred documentation formats</heading>
3135 The unification of Debian documentation is being carried out
3139 If your package comes with extensive documentation in a
3140 mark up format that can be converted to various other formats
3141 you should if possible ship HTML versions in a binary
3142 package, in the directory
3143 <tt>/usr/share/doc/<var>appropriate package</var></tt> or its
3146 <p>The rationale: The important thing here is that HTML
3147 docs should be available in <em>some</em> package, not
3148 necessarily in the main binary package, though. </p>
3153 Other formats such as PostScript may be provided at your
3157 <sect id="copyrightfile">
3158 <heading>Copyright information</heading>
3161 Every package must be accompanied by a verbatim copy of its
3162 copyright and distribution license in the file
3163 /usr/share/doc/<package-name>/copyright. This file must
3164 neither be compressed nor be a symbolic link.</p>
3167 In addition, the copyright file must say where the upstream
3168 sources (if any) were obtained, and explain briefly what
3169 modifications were made in the Debian version of the package
3170 compared to the upstream one. It must name the original
3171 authors of the package and the Debian maintainer(s) who were
3172 involved with its creation.</p>
3175 /usr/share/doc/<package-name> may be a symbolic link to a
3176 directory in /usr/share/doc only if two packages both come from
3177 the same source and the first package has a "Depends"
3178 relationship on the second. These rules are important
3179 because copyrights must be extractable by mechanical
3183 Packages distributed under the UCB BSD license, the Artistic
3184 license, the GNU GPL, and the GNU LGPL should refer to the
3185 files /usr/share/common-licenses/BSD,
3186 /usr/share/common-licenses/Artistic,
3187 /usr/share/common-licenses/GPL, and
3188 /usr/share/common-licenses/LGPL.
3191 Why "licenses" and not "copyright"? Because
3192 <tt>/usr/doc/copyright</tt> used to contain all the
3193 copyright files, plus the four common licenses GPL,
3194 LGPL, Artistic and BSD. Now individual copyright files
3195 for packages are no longer in a common directory. Once
3196 <tt>/usr/doc/copyright</tt> is almost empty it makes
3197 sense to rename "copyright" to "licenses"
3200 Why "common-licenses" and not "licenses"? Because if I
3201 put just "licenses" I'm sure I will receive a bug report
3202 saying "license foo is not included in the licenses
3203 directory. They are not all the licenses, just a few
3204 common ones. I could use /usr/share/doc/common-licenses
3205 but I think this is too long, and, after all, the GPL
3206 does not "document" anything, it is merely a license.
3212 Do not use the copyright file as a general <tt>README</tt>
3213 file. If your package has such a file it should be
3214 installed in <tt>/usr/share/doc/<var>package</var>/README</tt> or
3215 <tt>README.Debian</tt> or some other appropriate place.</p>
3219 <heading>Examples</heading>
3222 Any examples (configurations, source files, whatever),
3223 should be installed in a directory
3224 <tt>/usr/share/doc/<var>package</var>/examples</tt>. These files
3225 should not be referenced by any program--they're there for
3226 the benefit of the system administrator and users, as
3227 documentation only.</p>
3230 <sect id="instchangelog">
3231 <heading>Changelog files</heading>
3234 This installed file must contain a copy of the
3235 <tt>debian/changelog</tt> file from your Debian source tree,
3236 and a copy of the upstream changelog file if there is one.
3237 The debian/changelog file should be installed in
3238 <tt>/usr/share/doc/<var>package</var></tt> as
3239 <tt>changelog.Debian.gz</tt>. If the upstream changelog
3240 file is text formatted, it must be accessible as
3241 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>. If
3242 the upstream changelog file is HTML formatted, it must be
3244 <tt>/usr/share/doc/<var>package</var>/changelog.html.gz</tt>.
3245 If the upstream changelog files do not already conform to
3246 this naming convention, then this may be achieved by either
3247 renaming the files or adding a symbolic link at the
3248 packaging developer's discretion. </p>
3251 Both should be installed compressed using <tt>gzip -9</tt>,
3252 as they will become large with time even if they start out
3256 If the package has only one changelog which is used both as
3257 the Debian changelog and the upstream one because there is
3258 no separate upstream maintainer then that changelog should
3259 usually be installed as
3260 <tt>/usr/share/doc/<var>package</var>/changelog.gz</tt>; if
3261 there is a separate upstream maintainer, but no upstream
3262 changelog, then the Debian changelog should still be called
3263 <tt>changelog.Debian.gz</tt>.</p>