debian/control doesn't list debug packages
[debian-policy.git] / policy.sgml
blobe5c7365b46ac2910ff7436931dcacf687467458c
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;
5 <!-- current Debian changes file format -->
6 <!entity changesversion "1.8">
7 ]>
8 <debiandoc>
10 <book>
11 <titlepag>
12 <title>Debian Policy Manual</title>
13 <author><qref id="authors">The Debian Policy Mailing List</qref></author>
14 <version>version &version;, &date;</version>
16 <abstract>
17 This manual describes the policy requirements for the Debian
18 distribution. This includes the structure and
19 contents of the Debian archive and several design issues of
20 the operating system, as well as technical requirements that
21 each package must satisfy to be included in the distribution.
22 </abstract>
24 <copyright>
25 <copyrightsummary>
26 Copyright &copy; 1996,1997,1998 Ian Jackson
27 and Christian Schwarz.
28 </copyrightsummary>
29 <p>
30 These are the copyright dates of the original Policy manual.
31 Since then, this manual has been updated by many others. No
32 comprehensive collection of copyright notices for subsequent
33 work exists.
34 </p>
36 <p>
37 This manual is free software; you may redistribute it and/or
38 modify it under the terms of the GNU General Public License
39 as published by the Free Software Foundation; either version
40 2, or (at your option) any later version.
41 </p>
43 <p>
44 This is distributed in the hope that it will be useful, but
45 <em>without any warranty</em>; without even the implied
46 warranty of merchantability or fitness for a particular
47 purpose. See the GNU General Public License for more
48 details.
49 </p>
51 <p>
52 A copy of the GNU General Public License is available as
53 <file>/usr/share/common-licenses/GPL</file> in the Debian
54 distribution or on the World Wide Web at
55 <url id="http://www.gnu.org/copyleft/gpl.html"
56 name="the GNU General Public Licence">. You can also
57 obtain it by writing to the Free Software Foundation, Inc.,
58 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
59 </p>
60 </copyright>
61 </titlepag>
63 <toc detail="sect1">
65 <chapt id="scope">
66 <heading>About this manual</heading>
67 <sect>
68 <heading>Scope</heading>
69 <p>
70 This manual describes the policy requirements for the Debian
71 distribution. This includes the structure and
72 contents of the Debian archive and several design issues of the
73 operating system, as well as technical requirements that
74 each package must satisfy to be included in the
75 distribution.
76 </p>
78 <p>
79 This manual also describes Debian policy as it relates to
80 creating Debian packages. It is not a tutorial on how to build
81 packages, nor is it exhaustive where it comes to describing
82 the behavior of the packaging system. Instead, this manual
83 attempts to define the interface to the package management
84 system that the developers have to be conversant with.<footnote>
85 Informally, the criteria used for inclusion is that the
86 material meet one of the following requirements:
87 <taglist compact="compact">
88 <tag>Standard interfaces</tag>
89 <item>
90 The material presented represents an interface to
91 the packaging system that is mandated for use, and
92 is used by, a significant number of packages, and
93 therefore should not be changed without peer
94 review. Package maintainers can then rely on this
95 interface not changing, and the package management
96 software authors need to ensure compatibility with
97 this interface definition. (Control file and
98 changelog file formats are examples.)
99 </item>
100 <tag>Chosen Convention</tag>
101 <item>
102 If there are a number of technically viable choices
103 that can be made, but one needs to select one of
104 these options for inter-operability. The version
105 number format is one example.
106 </item>
107 </taglist>
108 Please note that these are not mutually exclusive;
109 selected conventions often become parts of standard
110 interfaces.
111 </footnote>
112 </p>
115 The footnotes present in this manual are
116 merely informative, and are not part of Debian policy itself.
117 </p>
120 The appendices to this manual are not necessarily normative,
121 either. Please see <ref id="pkg-scope"> for more information.
122 </p>
125 In the normative part of this manual,
126 the words <em>must</em>, <em>should</em> and
127 <em>may</em>, and the adjectives <em>required</em>,
128 <em>recommended</em> and <em>optional</em>, are used to
129 distinguish the significance of the various guidelines in
130 this policy document. Packages that do not conform to the
131 guidelines denoted by <em>must</em> (or <em>required</em>)
132 will generally not be considered acceptable for the Debian
133 distribution. Non-conformance with guidelines denoted by
134 <em>should</em> (or <em>recommended</em>) will generally be
135 considered a bug, but will not necessarily render a package
136 unsuitable for distribution. Guidelines denoted by
137 <em>may</em> (or <em>optional</em>) are truly optional and
138 adherence is left to the maintainer's discretion.
139 </p>
142 These classifications are roughly equivalent to the bug
143 severities <em>serious</em> (for <em>must</em> or
144 <em>required</em> directive violations), <em>minor</em>,
145 <em>normal</em> or <em>important</em>
146 (for <em>should</em> or <em>recommended</em> directive
147 violations) and <em>wishlist</em> (for <em>optional</em>
148 items).
149 <footnote>
150 Compare RFC 2119. Note, however, that these words are
151 used in a different way in this document.
152 </footnote>
153 </p>
156 Much of the information presented in this manual will be
157 useful even when building a package which is to be
158 distributed in some other way or is intended for local use
159 only.
160 </p>
163 udebs (stripped-down binary packages used by the Debian Installer) do
164 not comply with all of the requirements discussed here. See the
165 <url name="Debian Installer internals manual"
166 id="http://d-i.alioth.debian.org/doc/internals/ch03.html"> for more
167 information about them.
168 </p>
169 </sect>
171 <sect>
172 <heading>New versions of this document</heading>
175 This manual is distributed via the Debian package
176 <package><url name="debian-policy"
177 id="http://packages.debian.org/debian-policy"></package>
178 (<httpsite>packages.debian.org</httpsite>
179 <httppath>/debian-policy</httppath>).
180 </p>
183 The current version of this document is also available from
184 the Debian web mirrors at
185 <tt><url name="/doc/debian-policy/"
186 id="http://www.debian.org/doc/debian-policy/"></tt>.
188 <httpsite>www.debian.org</httpsite>
189 <httppath>/doc/debian-policy/</httppath>)
190 Also available from the same directory are several other
191 formats: <file>policy.html.tar.gz</file>
192 (<httppath>/doc/debian-policy/policy.html.tar.gz</httppath>),
193 <file>policy.pdf.gz</file>
194 (<httppath>/doc/debian-policy/policy.pdf.gz</httppath>)
195 and <file>policy.ps.gz</file>
196 (<httppath>/doc/debian-policy/policy.ps.gz</httppath>).
197 </p>
200 The <package>debian-policy</package> package also includes the file
201 <file>upgrading-checklist.txt.gz</file> which indicates policy
202 changes between versions of this document.
203 </p>
204 </sect>
206 <sect id="authors">
207 <heading>Authors and Maintainers</heading>
210 Originally called "Debian GNU/Linux Policy Manual", this
211 manual was initially written in 1996 by Ian Jackson.
212 It was revised on November 27th, 1996 by David A. Morris.
213 Christian Schwarz added new sections on March 15th, 1997,
214 and reworked/restructured it in April-July 1997.
215 Christoph Lameter contributed the "Web Standard".
216 Julian Gilbey largely restructured it in 2001.
217 </p>
220 Since September 1998, the responsibility for the contents of
221 this document lies on the <url name="debian-policy mailing list"
222 id="mailto:debian-policy@lists.debian.org">. Proposals
223 are discussed there and inserted into policy after a certain
224 consensus is established.
225 <!-- insert shameless policy-process plug here eventually -->
226 The actual editing is done by a group of maintainers that have
227 no editorial powers. These are the current maintainers:
229 <enumlist>
230 <item>Russ Allbery</item>
231 <item>Bill Allombert</item>
232 <item>Andreas Barth</item>
233 <item>Jonathan Nieder</item>
234 </enumlist>
235 </p>
238 While the authors of this document have tried hard to avoid
239 typos and other errors, these do still occur. If you discover
240 an error in this manual or if you want to give any
241 comments, suggestions, or criticisms please send an email to
242 the Debian Policy List,
243 <email>debian-policy@lists.debian.org</email>, or submit a
244 bug report against the <tt>debian-policy</tt> package.
245 </p>
248 Please do not try to reach the individual authors or maintainers
249 of the Policy Manual regarding changes to the Policy.
250 </p>
251 </sect>
253 <sect id="related">
254 <heading>Related documents</heading>
257 There are several other documents other than this Policy Manual
258 that are necessary to fully understand some Debian policies and
259 procedures.
260 </p>
263 The external "sub-policy" documents are referred to in:
264 <list compact="compact">
265 <item><ref id="fhs"></item>
266 <item><ref id="virtual_pkg"></item>
267 <item><ref id="menus"></item>
268 <item><ref id="perl"></item>
269 <item><ref id="maintscriptprompt"></item>
270 <item><ref id="emacs"></item>
271 </list>
272 </p>
275 In addition to those, which carry the weight of policy, there
276 is the Debian Developer's Reference. This document describes
277 procedures and resources for Debian developers, but it is
278 <em>not</em> normative; rather, it includes things that don't
279 belong in the Policy, such as best practices for developers.
280 </p>
283 The Developer's Reference is available in the
284 <package>developers-reference</package> package.
285 It's also available from the Debian web mirrors at
286 <tt><url name="/doc/developers-reference/"
287 id="http://www.debian.org/doc/developers-reference/"></tt>.
288 </p>
291 Finally, a <qref id="copyrightformat">specification for
292 machine-readable copyright files</qref> is maintained as part of
293 the <package>debian-policy</package> package using the same
294 procedure as the other policy documents. Use of this format is
295 optional.
296 </p>
297 </sect>
299 <sect id="definitions">
300 <heading>Definitions</heading>
303 The following terms are used in this Policy Manual:
304 <taglist>
305 <tag>ASCII</tag>
306 <item>
307 The character encoding specified by ANSI X3.4-1986 and its
308 predecessor standards, referred to in MIME as US-ASCII, and
309 corresponding to an encoding in eight bits per character of
310 the first 128 <url id="http://www.unicode.org/"
311 name="Unicode"> characters, with the eighth bit always zero.
312 </item>
313 <tag>UTF-8</tag>
314 <item>
315 The transformation format (sometimes called encoding) of
316 <url id="http://www.unicode.org/" name="Unicode"> defined by
317 <url id="http://www.rfc-editor.org/rfc/rfc3629.txt"
318 name="RFC 3629">. UTF-8 has the useful property of having
319 ASCII as a subset, so any text encoded in ASCII is trivially
320 also valid UTF-8.
321 </item>
322 </taglist>
323 </p>
324 </sect>
325 </chapt>
328 <chapt id="archive">
329 <heading>The Debian Archive</heading>
332 The Debian system is maintained and distributed as a
333 collection of <em>packages</em>. Since there are so many of
334 them (currently well over 15000), they are split into
335 <em>sections</em> and given <em>priorities</em> to simplify
336 the handling of them.
337 </p>
340 The effort of the Debian project is to build a free operating
341 system, but not every package we want to make accessible is
342 <em>free</em> in our sense (see the Debian Free Software
343 Guidelines, below), or may be imported/exported without
344 restrictions. Thus, the archive is split into areas<footnote>
345 The Debian archive software uses the term "component" internally
346 and in the Release file format to refer to the division of an
347 archive. The Debian Social Contract simply refers to "areas."
348 This document uses terminology similar to the Social Contract.
349 </footnote> based on their licenses and other restrictions.
350 </p>
353 The aims of this are:
355 <list compact="compact">
356 <item>to allow us to make as much software available as we can</item>
357 <item>to allow us to encourage everyone to write free software,
358 and</item>
359 <item>to allow us to make it easy for people to produce
360 CD-ROMs of our system without violating any licenses,
361 import/export restrictions, or any other laws.</item>
362 </list>
363 </p>
366 The <em>main</em> archive area forms the <em>Debian distribution</em>.
367 </p>
370 Packages in the other archive areas (<tt>contrib</tt>,
371 <tt>non-free</tt>) are not considered to be part of the Debian
372 distribution, although we support their use and provide
373 infrastructure for them (such as our bug-tracking system and
374 mailing lists). This Debian Policy Manual applies to these
375 packages as well.
376 </p>
378 <sect id="dfsg">
379 <heading>The Debian Free Software Guidelines</heading>
381 The Debian Free Software Guidelines (DFSG) form our
382 definition of "free software". These are:
383 <taglist>
384 <tag>1. Free Redistribution
385 </tag>
386 <item>
387 The license of a Debian component may not restrict any
388 party from selling or giving away the software as a
389 component of an aggregate software distribution
390 containing programs from several different
391 sources. The license may not require a royalty or
392 other fee for such sale.
393 </item>
394 <tag>2. Source Code
395 </tag>
396 <item>
397 The program must include source code, and must allow
398 distribution in source code as well as compiled form.
399 </item>
400 <tag>3. Derived Works
401 </tag>
402 <item>
403 The license must allow modifications and derived
404 works, and must allow them to be distributed under the
405 same terms as the license of the original software.
406 </item>
407 <tag>4. Integrity of The Author's Source Code
408 </tag>
409 <item>
410 The license may restrict source-code from being
411 distributed in modified form <em>only</em> if the
412 license allows the distribution of "patch files"
413 with the source code for the purpose of modifying the
414 program at build time. The license must explicitly
415 permit distribution of software built from modified
416 source code. The license may require derived works to
417 carry a different name or version number from the
418 original software. (This is a compromise. The Debian
419 Project encourages all authors to not restrict any
420 files, source or binary, from being modified.)
421 </item>
422 <tag>5. No Discrimination Against Persons or Groups
423 </tag>
424 <item>
425 The license must not discriminate against any person
426 or group of persons.
427 </item>
428 <tag>6. No Discrimination Against Fields of Endeavor
429 </tag>
430 <item>
431 The license must not restrict anyone from making use
432 of the program in a specific field of endeavor. For
433 example, it may not restrict the program from being
434 used in a business, or from being used for genetic
435 research.
436 </item>
437 <tag>7. Distribution of License
438 </tag>
439 <item>
440 The rights attached to the program must apply to all
441 to whom the program is redistributed without the need
442 for execution of an additional license by those
443 parties.
444 </item>
445 <tag>8. License Must Not Be Specific to Debian
446 </tag>
447 <item>
448 The rights attached to the program must not depend on
449 the program's being part of a Debian system. If the
450 program is extracted from Debian and used or
451 distributed without Debian but otherwise within the
452 terms of the program's license, all parties to whom
453 the program is redistributed must have the same
454 rights as those that are granted in conjunction with
455 the Debian system.
456 </item>
457 <tag>9. License Must Not Contaminate Other Software
458 </tag>
459 <item>
460 The license must not place restrictions on other
461 software that is distributed along with the licensed
462 software. For example, the license must not insist
463 that all other programs distributed on the same medium
464 must be free software.
465 </item>
466 <tag>10. Example Licenses
467 </tag>
468 <item>
469 The "GPL," "BSD," and "Artistic" licenses are examples of
470 licenses that we consider <em>free</em>.
471 </item>
472 </taglist>
473 </p>
474 </sect>
476 <sect id="sections">
477 <heading>Archive areas</heading>
479 <sect1 id="main">
480 <heading>The main archive area</heading>
483 The <em>main</em> archive area comprises the Debian
484 distribution. Only the packages in this area are considered
485 part of the distribution. None of the packages in
486 the <em>main</em> archive area require software outside of
487 that area to function. Anyone may use, share, modify and
488 redistribute the packages in this archive area
489 freely<footnote>
490 See <url id="http://www.debian.org/intro/free"
491 name="What Does Free Mean?"> for
492 more about what we mean by free software.
493 </footnote>.
494 </p>
497 Every package in <em>main</em> must comply with the DFSG
498 (Debian Free Software Guidelines).
499 </p>
502 In addition, the packages in <em>main</em>
503 <list compact="compact">
504 <item>
505 must not require or recommend a package outside
506 of <em>main</em> for compilation or execution (thus, the
507 package must not declare a "Pre-Depends", "Depends",
508 "Recommends", "Build-Depends", "Build-Depends-Indep",
509 or "Build-Depends-Arch" relationship on a non-<em>main</em>
510 package),
511 </item>
512 <item>
513 must not be so buggy that we refuse to support them,
515 </item>
516 <item>
517 must meet all policy requirements presented in this
518 manual.
519 </item>
520 </list>
521 </p>
523 </sect1>
525 <sect1 id="contrib">
526 <heading>The contrib archive area</heading>
529 The <em>contrib</em> archive area contains supplemental
530 packages intended to work with the Debian distribution, but
531 which require software outside of the distribution to either
532 build or function.
533 </p>
536 Every package in <em>contrib</em> must comply with the DFSG.
537 </p>
540 In addition, the packages in <em>contrib</em>
541 <list compact="compact">
542 <item>
543 must not be so buggy that we refuse to support them,
545 </item>
546 <item>
547 must meet all policy requirements presented in this
548 manual.
549 </item>
550 </list>
551 </p>
554 Examples of packages which would be included in
555 <em>contrib</em> are:
556 <list compact="compact">
557 <item>
558 free packages which require <em>contrib</em>,
559 <em>non-free</em> packages or packages which are not
560 in our archive at all for compilation or execution,
562 </item>
563 <item>
564 wrapper packages or other sorts of free accessories for
565 non-free programs.
566 </item>
567 </list>
568 </p>
569 </sect1>
571 <sect1 id="non-free">
572 <heading>The non-free archive area</heading>
575 The <em>non-free</em> archive area contains supplemental
576 packages intended to work with the Debian distribution that do
577 not comply with the DFSG or have other problems that make
578 their distribution problematic. They may not comply with all
579 of the policy requirements in this manual due to restrictions
580 on modifications or other limitations.
581 </p>
584 Packages must be placed in <em>non-free</em> if they are
585 not compliant with the DFSG or are encumbered by patents
586 or other legal issues that make their distribution
587 problematic.
588 </p>
591 In addition, the packages in <em>non-free</em>
592 <list compact="compact">
593 <item>
594 must not be so buggy that we refuse to support them,
596 </item>
597 <item>
598 must meet all policy requirements presented in this
599 manual that it is possible for them to meet.
600 <footnote>
601 It is possible that there are policy
602 requirements which the package is unable to
603 meet, for example, if the source is
604 unavailable. These situations will need to be
605 handled on a case-by-case basis.
606 </footnote>
607 </item>
608 </list>
609 </p>
610 </sect1>
612 </sect>
614 <sect id="pkgcopyright">
615 <heading>Copyright considerations</heading>
618 Every package must be accompanied by a verbatim copy of its
619 copyright information and distribution license in the file
620 <file>/usr/share/doc/<var>package</var>/copyright</file>
621 (see <ref id="copyrightfile"> for further details).
622 </p>
625 We reserve the right to restrict files from being included
626 anywhere in our archives if
627 <list compact="compact">
628 <item>
629 their use or distribution would break a law,
630 </item>
631 <item>
632 there is an ethical conflict in their distribution or
633 use,
634 </item>
635 <item>
636 we would have to sign a license for them, or
637 </item>
638 <item>
639 their distribution would conflict with other project
640 policies.
641 </item>
642 </list>
643 </p>
646 Programs whose authors encourage the user to make
647 donations are fine for the main distribution, provided
648 that the authors do not claim that not donating is
649 immoral, unethical, illegal or something similar; in such
650 a case they must go in <em>non-free</em>.
651 </p>
654 Packages whose copyright permission notices (or patent
655 problems) do not even allow redistribution of binaries
656 only, and where no special permission has been obtained,
657 must not be placed on the Debian FTP site and its mirrors
658 at all.
659 </p>
662 Note that under international copyright law (this applies
663 in the United States, too), <em>no</em> distribution or
664 modification of a work is allowed without an explicit
665 notice saying so. Therefore a program without a copyright
666 notice <em>is</em> copyrighted and you may not do anything
667 to it without risking being sued! Likewise if a program
668 has a copyright notice but no statement saying what is
669 permitted then nothing is permitted.
670 </p>
673 Many authors are unaware of the problems that restrictive
674 copyrights (or lack of copyright notices) can cause for
675 the users of their supposedly-free software. It is often
676 worthwhile contacting such authors diplomatically to ask
677 them to modify their license terms. However, this can be a
678 politically difficult thing to do and you should ask for
679 advice on the <tt>debian-legal</tt> mailing list first, as
680 explained below.
681 </p>
684 When in doubt about a copyright, send mail to
685 <email>debian-legal@lists.debian.org</email>. Be prepared
686 to provide us with the copyright statement. Software
687 covered by the GPL, public domain software and BSD-like
688 copyrights are safe; be wary of the phrases "commercial
689 use prohibited" and "distribution restricted".
690 </p>
691 </sect>
693 <sect id="subsections">
694 <heading>Sections</heading>
697 The packages in the archive areas <em>main</em>,
698 <em>contrib</em> and <em>non-free</em> are grouped further into
699 <em>sections</em> to simplify handling.
700 </p>
703 The archive area and section for each package should be
704 specified in the package's <tt>Section</tt> control record (see
705 <ref id="f-Section">). However, the maintainer of the Debian
706 archive may override this selection to ensure the consistency of
707 the Debian distribution. The <tt>Section</tt> field should be
708 of the form:
709 <list compact="compact">
710 <item>
711 <em>section</em> if the package is in the
712 <em>main</em> archive area,
713 </item>
714 <item>
715 <em>area/section</em> if the package is in
716 the <em>contrib</em> or <em>non-free</em>
717 archive areas.
718 </item>
719 </list>
720 </p>
723 The Debian archive maintainers provide the authoritative
724 list of sections. At present, they are:
725 admin,
726 cli-mono,
727 comm,
728 database,
729 debug,
730 devel,
731 doc,
732 editors,
733 education,
734 electronics,
735 embedded,
736 fonts,
737 games,
738 gnome,
739 gnu-r,
740 gnustep,
741 graphics,
742 hamradio,
743 haskell,
744 httpd,
745 interpreters,
746 introspection,
747 java,
748 kde,
749 kernel,
750 libdevel,
751 libs,
752 lisp,
753 localization,
754 mail,
755 math,
756 metapackages,
757 misc,
758 net,
759 news,
760 ocaml,
761 oldlibs,
762 otherosfs,
763 perl,
764 php,
765 python,
766 ruby,
767 science,
768 shells,
769 sound,
770 tasks,
771 tex,
772 text,
773 utils,
774 vcs,
775 video,
776 web,
777 x11,
778 xfce,
779 zope.
780 The additional section <em>debian-installer</em>
781 contains special packages used by the installer and is not used
782 for normal Debian packages.
783 </p>
786 For more information about the sections and their definitions,
787 see the <url id="http://packages.debian.org/unstable/"
788 name="list of sections in unstable">.
789 </p>
790 </sect>
792 <sect id="priorities">
793 <heading>Priorities</heading>
796 Each package should have a <em>priority</em> value, which is
797 included in the package's <em>control record</em>
798 (see <ref id="f-Priority">).
799 This information is used by the Debian package management tools to
800 separate high-priority packages from less-important packages.
801 </p>
804 The following <em>priority levels</em> are recognized by the
805 Debian package management tools.
806 <taglist>
807 <tag><tt>required</tt></tag>
808 <item>
809 Packages which are necessary for the proper
810 functioning of the system (usually, this means that
811 dpkg functionality depends on these packages).
812 Removing a <tt>required</tt> package may cause your
813 system to become totally broken and you may not even
814 be able to use <prgn>dpkg</prgn> to put things back,
815 so only do so if you know what you are doing. Systems
816 with only the <tt>required</tt> packages are probably
817 unusable, but they do have enough functionality to
818 allow the sysadmin to boot and install more software.
819 </item>
820 <tag><tt>important</tt></tag>
821 <item>
822 Important programs, including those which one would
823 expect to find on any Unix-like system. If the
824 expectation is that an experienced Unix person who
825 found it missing would say "What on earth is going on,
826 where is <prgn>foo</prgn>?", it must be an
827 <tt>important</tt> package.<footnote>
828 This is an important criterion because we are
829 trying to produce, amongst other things, a free
830 Unix.
831 </footnote>
832 Other packages without which the system will not run
833 well or be usable must also have priority
834 <tt>important</tt>. This does
835 <em>not</em> include Emacs, the X Window System, TeX
836 or any other large applications. The
837 <tt>important</tt> packages are just a bare minimum of
838 commonly-expected and necessary tools.
839 </item>
840 <tag><tt>standard</tt></tag>
841 <item>
842 These packages provide a reasonably small but not too
843 limited character-mode system. This is what will be
844 installed by default if the user doesn't select anything
845 else. It doesn't include many large applications.
846 </item>
847 <tag><tt>optional</tt></tag>
848 <item>
849 (In a sense everything that isn't required is
850 optional, but that's not what is meant here.) This is
851 all the software that you might reasonably want to
852 install if you didn't know what it was and don't have
853 specialized requirements. This is a much larger system
854 and includes the X Window System, a full TeX
855 distribution, and many applications. Note that
856 optional packages should not conflict with each other.
857 </item>
858 <tag><tt>extra</tt></tag>
859 <item>
860 This contains all packages that conflict with others
861 with required, important, standard or optional
862 priorities, or are only likely to be useful if you
863 already know what they are or have specialized
864 requirements (such as packages containing only detached
865 debugging symbols).
866 </item>
867 </taglist>
868 </p>
871 Packages must not depend on packages with lower priority
872 values (excluding build-time dependencies). In order to
873 ensure this, the priorities of one or more packages may need
874 to be adjusted.
875 </p>
876 </sect>
878 </chapt>
881 <chapt id="binary">
882 <heading>Binary packages</heading>
885 The Debian distribution is based on the Debian
886 package management system, called <prgn>dpkg</prgn>. Thus,
887 all packages in the Debian distribution must be provided
888 in the <tt>.deb</tt> file format.
889 </p>
892 A <tt>.deb</tt> package contains two sets of files: a set of files
893 to install on the system when the package is installed, and a set
894 of files that provide additional metadata about the package or
895 which are executed when the package is installed or removed. This
896 second set of files is called <em>control information files</em>.
897 Among those files are the package maintainer scripts
898 and <file>control</file>, the <qref id="binarycontrolfiles">binary
899 package control file</qref> that contains the control fields for
900 the package. Other control information files include
901 the <qref id="sharedlibs-symbols"><file>symbols</file> file</qref>
902 or <qref id="sharedlibs-shlibdeps"><file>shlibs</file> file</qref>
903 used to store shared library dependency information and
904 the <file>conffiles</file> file that lists the package's
905 configuration files (described in <ref id="config-files">).
906 </p>
909 There is unfortunately a collision of terminology here between
910 control information files and files in the Debian control file
911 format. Throughout this document, a <em>control file</em> refers
912 to a file in the Debian control file format. These files are
913 documented in <ref id="controlfields">. Only files referred to
914 specifically as <em>control information files</em> are the files
915 included in the control information file member of
916 the <file>.deb</file> file format used by binary packages. Most
917 control information files are not in the Debian control file
918 format.
919 </p>
921 <sect>
922 <heading>The package name</heading>
925 Every package must have a name that's unique within the Debian
926 archive.
927 </p>
930 The package name is included in the control field
931 <tt>Package</tt>, the format of which is described
932 in <ref id="f-Package">.
933 The package name is also included as a part of the file name
934 of the <tt>.deb</tt> file.
935 </p>
936 </sect>
938 <sect id="versions">
939 <heading>The version of a package</heading>
942 Every package has a version number recorded in its
943 <tt>Version</tt> control file field, described in
944 <ref id="f-Version">.
945 </p>
948 The package management system imposes an ordering on version
949 numbers, so that it can tell whether packages are being up- or
950 downgraded and so that package system front end applications
951 can tell whether a package it finds available is newer than
952 the one installed on the system. The version number format
953 has the most significant parts (as far as comparison is
954 concerned) at the beginning.
955 </p>
958 If an upstream package has problematic version numbers they
959 should be converted to a sane form for use in the
960 <tt>Version</tt> field.
961 </p>
963 <sect1>
964 <heading>Version numbers based on dates</heading>
967 In general, Debian packages should use the same version
968 numbers as the upstream sources. However, upstream version
969 numbers based on some date formats (sometimes used for
970 development or "snapshot" releases) will not be ordered
971 correctly by the package management software. For
972 example, <prgn>dpkg</prgn> will consider "96May01" to be
973 greater than "96Dec24".
974 </p>
977 To prevent having to use epochs for every new upstream
978 version, the date-based portion of any upstream version number
979 should be given in a way that sorts correctly: four-digit year
980 first, followed by a two-digit numeric month, followed by a
981 two-digit numeric date, possibly with punctuation between the
982 components.
983 </p>
986 Native Debian packages (i.e., packages which have been written
987 especially for Debian) whose version numbers include dates
988 should also follow these rules. If punctuation is desired
989 between the date components, remember that hyphen (<tt>-</tt>)
990 cannot be used in native package versions. Period
991 (<tt>.</tt>) is normally a good choice.
992 </p>
993 </sect1>
995 </sect>
997 <sect id="maintainer">
998 <heading>The maintainer of a package</heading>
1001 Every package must have a maintainer, except for orphaned
1002 packages as described below. The maintainer may be one person
1003 or a group of people reachable from a common email address, such
1004 as a mailing list. The maintainer is responsible for
1005 maintaining the Debian packaging files, evaluating and
1006 responding appropriately to reported bugs, uploading new
1007 versions of the package (either directly or through a sponsor),
1008 ensuring that the package is placed in the appropriate archive
1009 area and included in Debian releases as appropriate for the
1010 stability and utility of the package, and requesting removal of
1011 the package from the Debian distribution if it is no longer
1012 useful or maintainable.
1013 </p>
1016 The maintainer must be specified in the <tt>Maintainer</tt>
1017 control field with their correct name and a working email
1018 address. The email address given in the <tt>Maintainer</tt>
1019 control field must accept mail from those role accounts in
1020 Debian used to send automated mails regarding the package. This
1021 includes non-spam mail from the bug-tracking system, all mail
1022 from the Debian archive maintenance software, and other role
1023 accounts or automated processes that are commonly agreed on by
1024 the project.<footnote>
1025 A sample implementation of such a whitelist written for the
1026 Mailman mailing list management software is used for mailing
1027 lists hosted by alioth.debian.org.
1028 </footnote>
1029 If one person or team maintains several packages, they should
1030 use the same form of their name and email address in
1031 the <tt>Maintainer</tt> fields of those packages.
1032 </p>
1035 The format of the <tt>Maintainer</tt> control field is
1036 described in <ref id="f-Maintainer">.
1037 </p>
1040 If the maintainer of the package is a team of people with a
1041 shared email address, the <tt>Uploaders</tt> control field must
1042 be present and must contain at least one human with their
1043 personal email address. See <ref id="f-Uploaders"> for the
1044 syntax of that field.
1045 </p>
1048 An orphaned package is one with no current maintainer. Orphaned
1049 packages should have their <tt>Maintainer</tt> control field set
1050 to <tt>Debian QA Group &lt;packages@qa.debian.org&gt;</tt>.
1051 These packages are considered maintained by the Debian project
1052 as a whole until someone else volunteers to take over
1053 maintenance.<footnote>
1054 The detailed procedure for gracefully orphaning a package can
1055 be found in the Debian Developer's Reference
1056 (see <ref id="related">).
1057 </footnote>
1058 </p>
1059 </sect>
1061 <sect id="descriptions">
1062 <heading>The description of a package</heading>
1065 Every Debian package must have a <tt>Description</tt> control
1066 field which contains a synopsis and extended description of the
1067 package. Technical information about the format of the
1068 <tt>Description</tt> field is in <ref id="f-Description">.
1069 </p>
1072 The description should describe the package (the program) to a
1073 user (system administrator) who has never met it before so that
1074 they have enough information to decide whether they want to
1075 install it. This description should not just be copied verbatim
1076 from the program's documentation.
1077 </p>
1080 Put important information first, both in the synopsis and
1081 extended description. Sometimes only the first part of the
1082 synopsis or of the description will be displayed. You can
1083 assume that there will usually be a way to see the whole
1084 extended description.
1085 </p>
1088 The description should also give information about the
1089 significant dependencies and conflicts between this package
1090 and others, so that the user knows why these dependencies and
1091 conflicts have been declared.
1092 </p>
1095 Instructions for configuring or using the package should
1096 not be included (that is what installation scripts,
1097 manual pages, info files, etc., are for). Copyright
1098 statements and other administrivia should not be included
1099 either (that is what the copyright file is for).
1100 </p>
1102 <sect1 id="synopsis"><heading>The single line synopsis</heading>
1105 The single line synopsis should be kept brief - certainly
1106 under 80 characters.
1107 </p>
1110 Do not include the package name in the synopsis line. The
1111 display software knows how to display this already, and you
1112 do not need to state it. Remember that in many situations
1113 the user may only see the synopsis line - make it as
1114 informative as you can.
1115 </p>
1117 </sect1>
1119 <sect1 id="extendeddesc"><heading>The extended description</heading>
1122 Do not try to continue the single line synopsis into the
1123 extended description. This will not work correctly when
1124 the full description is displayed, and makes no sense
1125 where only the summary (the single line synopsis) is
1126 available.
1127 </p>
1130 The extended description should describe what the package
1131 does and how it relates to the rest of the system (in terms
1132 of, for example, which subsystem it is which part of).
1133 </p>
1136 The description field needs to make sense to anyone, even
1137 people who have no idea about any of the things the
1138 package deals with.<footnote>
1139 The blurb that comes with a program in its
1140 announcements and/or <prgn>README</prgn> files is
1141 rarely suitable for use in a description. It is
1142 usually aimed at people who are already in the
1143 community where the package is used.
1144 </footnote>
1145 </p>
1147 </sect1>
1149 </sect>
1151 <sect id="dependencies">
1152 <heading>Dependencies</heading>
1155 Every package must specify the dependency information
1156 about other packages that are required for the first to
1157 work correctly.
1158 </p>
1161 For example, a dependency entry must be provided for any
1162 shared libraries required by a dynamically-linked executable
1163 binary in a package.
1164 </p>
1167 Packages are not required to declare any dependencies they
1168 have on other packages which are marked <tt>Essential</tt>
1169 (see below), and should not do so unless they depend on a
1170 particular version of that package.<footnote>
1172 Essential is needed in part to avoid unresolvable dependency
1173 loops on upgrade. If packages add unnecessary dependencies
1174 on packages in this set, the chances that there
1175 <strong>will</strong> be an unresolvable dependency loop
1176 caused by forcing these Essential packages to be configured
1177 first before they need to be is greatly increased. It also
1178 increases the chances that frontends will be unable to
1179 <strong>calculate</strong> an upgrade path, even if one
1180 exists.
1181 </p>
1183 Also, functionality is rarely ever removed from the
1184 Essential set, but <em>packages</em> have been removed from
1185 the Essential set when the functionality moved to a
1186 different package. So depending on these packages <em>just
1187 in case</em> they stop being essential does way more harm
1188 than good.
1189 </p>
1190 </footnote>
1191 </p>
1194 Sometimes, unpacking one package requires that another package
1195 be first unpacked <em>and</em> configured. In this case, the
1196 depending package must specify this dependency in
1197 the <tt>Pre-Depends</tt> control field.
1198 </p>
1201 You should not specify a <tt>Pre-Depends</tt> entry for a
1202 package before this has been discussed on the
1203 <tt>debian-devel</tt> mailing list and a consensus about
1204 doing that has been reached.
1205 </p>
1208 The format of the package interrelationship control fields is
1209 described in <ref id="relationships">.
1210 </p>
1211 </sect>
1213 <sect id="virtual_pkg">
1214 <heading>Virtual packages</heading>
1217 Sometimes, there are several packages which offer
1218 more-or-less the same functionality. In this case, it's
1219 useful to define a <em>virtual package</em> whose name
1220 describes that common functionality. (The virtual
1221 packages only exist logically, not physically; that's why
1222 they are called <em>virtual</em>.) The packages with this
1223 particular function will then <em>provide</em> the virtual
1224 package. Thus, any other package requiring that function
1225 can simply depend on the virtual package without having to
1226 specify all possible packages individually.
1227 </p>
1230 All packages should use virtual package names where
1231 appropriate, and arrange to create new ones if necessary.
1232 They should not use virtual package names (except privately,
1233 amongst a cooperating group of packages) unless they have
1234 been agreed upon and appear in the list of virtual package
1235 names. (See also <ref id="virtual">)
1236 </p>
1239 The latest version of the authoritative list of virtual
1240 package names can be found in the <tt>debian-policy</tt> package.
1241 It is also available from the Debian web mirrors at
1242 <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
1243 id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>.
1244 </p>
1247 The procedure for updating the list is described in the preface
1248 to the list.
1249 </p>
1251 </sect>
1253 <sect>
1254 <heading>Base system</heading>
1257 The <tt>base system</tt> is a minimum subset of the Debian
1258 system that is installed before everything else
1259 on a new system. Only very few packages are allowed to form
1260 part of the base system, in order to keep the required disk
1261 usage very small.
1262 </p>
1265 The base system consists of all those packages with priority
1266 <tt>required</tt> or <tt>important</tt>. Many of them will
1267 be tagged <tt>essential</tt> (see below).
1268 </p>
1269 </sect>
1271 <sect>
1272 <heading>Essential packages</heading>
1275 Essential is defined as the minimal set of functionality that
1276 must be available and usable on the system at all times, even
1277 when packages are in the "Unpacked" state.
1278 Packages are tagged <tt>essential</tt> for a system using the
1279 <tt>Essential</tt> control field. The format of the
1280 <tt>Essential</tt> control field is described in <ref
1281 id="f-Essential">.
1282 </p>
1285 Since these packages cannot be easily removed (one has to
1286 specify an extra <em>force option</em> to
1287 <prgn>dpkg</prgn> to do so), this flag must not be used
1288 unless absolutely necessary. A shared library package
1289 must not be tagged <tt>essential</tt>; dependencies will
1290 prevent its premature removal, and we need to be able to
1291 remove it when it has been superseded.
1292 </p>
1295 Since dpkg will not prevent upgrading of other packages
1296 while an <tt>essential</tt> package is in an unconfigured
1297 state, all <tt>essential</tt> packages must supply all of
1298 their core functionality even when unconfigured. If the
1299 package cannot satisfy this requirement it must not be
1300 tagged as essential, and any packages depending on this
1301 package must instead have explicit dependency fields as
1302 appropriate.
1303 </p>
1306 Maintainers should take great care in adding any programs,
1307 interfaces, or functionality to <tt>essential</tt> packages.
1308 Packages may assume that functionality provided by
1309 <tt>essential</tt> packages is always available without
1310 declaring explicit dependencies, which means that removing
1311 functionality from the Essential set is very difficult and is
1312 almost never done. Any capability added to an
1313 <tt>essential</tt> package therefore creates an obligation to
1314 support that capability as part of the Essential set in
1315 perpetuity.
1316 </p>
1319 You must not tag any packages <tt>essential</tt> before
1320 this has been discussed on the <tt>debian-devel</tt>
1321 mailing list and a consensus about doing that has been
1322 reached.
1323 </p>
1324 </sect>
1326 <sect id="maintscripts">
1327 <heading>Maintainer Scripts</heading>
1330 The package installation scripts should avoid producing
1331 output which is unnecessary for the user to see and
1332 should rely on <prgn>dpkg</prgn> to stave off boredom on
1333 the part of a user installing many packages. This means,
1334 amongst other things, not passing the <tt>--verbose</tt>
1335 option to <prgn>update-alternatives</prgn>.
1336 </p>
1339 Errors which occur during the execution of an installation
1340 script must be checked and the installation must not
1341 continue after an error.
1342 </p>
1345 Note that in general <ref id="scripts"> applies to package
1346 maintainer scripts, too.
1347 </p>
1350 You should not use <prgn>dpkg-divert</prgn> on a file belonging
1351 to another package without consulting the maintainer of that
1352 package first. When adding or removing diversions, package
1353 maintainer scripts must provide the <tt>--package</tt> flag
1354 to <prgn>dpkg-divert</prgn> and must not use <tt>--local</tt>.
1355 </p>
1358 All packages which supply an instance of a common command
1359 name (or, in general, filename) should generally use
1360 <prgn>update-alternatives</prgn>, so that they may be
1361 installed together. If <prgn>update-alternatives</prgn>
1362 is not used, then each package must use
1363 <tt>Conflicts</tt> to ensure that other packages are
1364 removed. (In this case, it may be appropriate to
1365 specify a conflict against earlier versions of something
1366 that previously did not use
1367 <prgn>update-alternatives</prgn>; this is an exception to
1368 the usual rule that versioned conflicts should be
1369 avoided.)
1370 </p>
1372 <sect1 id="maintscriptprompt">
1373 <heading>Prompting in maintainer scripts</heading>
1375 Package maintainer scripts may prompt the user if
1376 necessary. Prompting must be done by communicating
1377 through a program, such as <prgn>debconf</prgn>, which
1378 conforms to the Debian Configuration Management
1379 Specification, version 2 or higher.
1380 </p>
1383 Packages which are essential, or which are dependencies of
1384 essential packages, may fall back on another prompting method
1385 if no such interface is available when they are executed.
1386 </p>
1389 The Debian Configuration Management Specification is included
1390 in the <file>debconf_specification</file> files in the
1391 <package>debian-policy</package> package.
1392 It is also available from the Debian web mirrors at
1393 <tt><url name="/doc/packaging-manuals/debconf_specification.html"
1394 id="http://www.debian.org/doc/packaging-manuals/debconf_specification.html"></tt>.
1395 </p>
1398 Packages which use the Debian Configuration Management
1399 Specification may contain the additional control information
1400 files <file>config</file>
1401 and <file>templates</file>. <file>config</file> is an
1402 additional maintainer script used for package configuration,
1403 and <file>templates</file> contains templates used for user
1404 prompting. The <prgn>config</prgn> script might be run before
1405 the <prgn>preinst</prgn> script and before the package is
1406 unpacked or any of its dependencies or pre-dependencies are
1407 satisfied. Therefore it must work using only the tools
1408 present in <em>essential</em> packages.<footnote>
1409 <package>Debconf</package> or another tool that
1410 implements the Debian Configuration Management
1411 Specification will also be installed, and any
1412 versioned dependencies on it will be satisfied
1413 before preconfiguration begins.
1414 </footnote>
1415 </p>
1418 Packages which use the Debian Configuration Management
1419 Specification must allow for translation of their user-visible
1420 messages by using a gettext-based system such as the one
1421 provided by the <package>po-debconf</package> package.
1422 </p>
1425 Packages should try to minimize the amount of prompting
1426 they need to do, and they should ensure that the user
1427 will only ever be asked each question once. This means
1428 that packages should try to use appropriate shared
1429 configuration files (such as <file>/etc/papersize</file> and
1430 <file>/etc/news/server</file>), and shared
1431 <package>debconf</package> variables rather than each
1432 prompting for their own list of required pieces of
1433 information.
1434 </p>
1437 It also means that an upgrade should not ask the same
1438 questions again, unless the user has used
1439 <tt>dpkg --purge</tt> to remove the package's configuration.
1440 The answers to configuration questions should be stored in an
1441 appropriate place in <file>/etc</file> so that the user can
1442 modify them, and how this has been done should be
1443 documented.
1444 </p>
1447 If a package has a vitally important piece of
1448 information to pass to the user (such as "don't run me
1449 as I am, you must edit the following configuration files
1450 first or you risk your system emitting badly-formatted
1451 messages"), it should display this in the
1452 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1453 prompt the user to hit return to acknowledge the
1454 message. Copyright messages do not count as vitally
1455 important (they belong in
1456 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1457 neither do instructions on how to use a program (these
1458 should be in on-line documentation, where all the users
1459 can see them).
1460 </p>
1463 Any necessary prompting should almost always be confined
1464 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1465 script. If it is done in the <prgn>postinst</prgn>, it
1466 should be protected with a conditional so that
1467 unnecessary prompting doesn't happen if a package's
1468 installation fails and the <prgn>postinst</prgn> is
1469 called with <tt>abort-upgrade</tt>,
1470 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.
1471 </p>
1472 </sect1>
1474 </sect>
1476 </chapt>
1479 <chapt id="source">
1480 <heading>Source packages</heading>
1482 <sect id="standardsversion">
1483 <heading>Standards conformance</heading>
1486 Source packages should specify the most recent version number
1487 of this policy document with which your package complied
1488 when it was last updated.
1489 </p>
1492 This information may be used to file bug reports
1493 automatically if your package becomes too much out of date.
1494 </p>
1497 The version is specified in the <tt>Standards-Version</tt>
1498 control field.
1499 The format of the <tt>Standards-Version</tt> field is
1500 described in <ref id="f-Standards-Version">.
1501 </p>
1504 You should regularly, and especially if your package has
1505 become out of date, check for the newest Policy Manual
1506 available and update your package, if necessary. When your
1507 package complies with the new standards you should update the
1508 <tt>Standards-Version</tt> source package field and
1509 release it.<footnote>
1510 See the file <file>upgrading-checklist</file> for
1511 information about policy which has changed between
1512 different versions of this document.
1513 </footnote>
1514 </p>
1516 </sect>
1518 <sect id="pkg-relations">
1519 <heading>Package relationships</heading>
1522 Source packages should specify which binary packages they
1523 require to be installed or not to be installed in order to
1524 build correctly. For example, if building a package
1525 requires a certain compiler, then the compiler should be
1526 specified as a build-time dependency.
1527 </p>
1530 It is not necessary to explicitly specify build-time
1531 relationships on a minimal set of packages that are always
1532 needed to compile, link and put in a Debian package a
1533 standard "Hello World!" program written in C or C++. The
1534 required packages are called <em>build-essential</em>, and
1535 an informational list can be found in
1536 <file>/usr/share/doc/build-essential/list</file> (which is
1537 contained in the <tt>build-essential</tt>
1538 package).<footnote>
1539 Rationale:
1540 <list compact="compact">
1541 <item>
1542 This allows maintaining the list separately
1543 from the policy documents (the list does not
1544 need the kind of control that the policy
1545 documents do).
1546 </item>
1547 <item>
1548 Having a separate package allows one to install
1549 the build-essential packages on a machine, as
1550 well as allowing other packages such as tasks to
1551 require installation of the build-essential
1552 packages using the depends relation.
1553 </item>
1554 <item>
1555 The separate package allows bug reports against
1556 the list to be categorized separately from
1557 the policy management process in the BTS.
1558 </item>
1559 </list>
1560 </footnote>
1561 </p>
1564 When specifying the set of build-time dependencies, one
1565 should list only those packages explicitly required by the
1566 build. It is not necessary to list packages which are
1567 required merely because some other package in the list of
1568 build-time dependencies depends on them.<footnote>
1569 The reason for this is that dependencies change, and
1570 you should list all those packages, and <em>only</em>
1571 those packages that <em>you</em> need directly. What
1572 others need is their business. For example, if you
1573 only link against <file>libimlib</file>, you will need to
1574 build-depend on <package>libimlib2-dev</package> but
1575 not against any <tt>libjpeg*</tt> packages, even
1576 though <tt>libimlib2-dev</tt> currently depends on
1577 them: installation of <package>libimlib2-dev</package>
1578 will automatically ensure that all of its run-time
1579 dependencies are satisfied.
1580 </footnote>
1581 </p>
1584 If build-time dependencies are specified, it must be
1585 possible to build the package and produce working binaries
1586 on a system with only essential and build-essential
1587 packages installed and also those required to satisfy the
1588 build-time relationships (including any implied
1589 relationships). In particular, this means that version
1590 clauses should be used rigorously in build-time
1591 relationships so that one cannot produce bad or
1592 inconsistently configured packages when the relationships
1593 are properly satisfied.
1594 </p>
1597 <ref id="relationships"> explains the technical details.
1598 </p>
1599 </sect>
1601 <sect>
1602 <heading>Changes to the upstream sources</heading>
1605 If changes to the source code are made that are not
1606 specific to the needs of the Debian system, they should be
1607 sent to the upstream authors in whatever form they prefer
1608 so as to be included in the upstream version of the
1609 package.
1610 </p>
1613 If you need to configure the package differently for
1614 Debian or for Linux, and the upstream source doesn't
1615 provide a way to do so, you should add such configuration
1616 facilities (for example, a new <prgn>autoconf</prgn> test
1617 or <tt>#define</tt>) and send the patch to the upstream
1618 authors, with the default set to the way they originally
1619 had it. You can then easily override the default in your
1620 <file>debian/rules</file> or wherever is appropriate.
1621 </p>
1624 You should make sure that the <prgn>configure</prgn> utility
1625 detects the correct architecture specification string
1626 (refer to <ref id="arch-spec"> for details).
1627 </p>
1629 If your package includes the scripts <prgn>config.sub</prgn> and
1630 <prgn>config.guess</prgn>, you should arrange for the versions
1631 provided by the package <package>autotools-dev</package> be used
1632 instead (see <package>autotools-dev</package> documentation for
1633 details how to achieve that). This ensures that these files can
1634 be updated distribution-wide at build time when introducing
1635 new architectures.
1636 </p>
1639 If you need to edit a <prgn>Makefile</prgn> where GNU-style
1640 <prgn>configure</prgn> scripts are used, you should edit the
1641 <file>.in</file> files rather than editing the
1642 <prgn>Makefile</prgn> directly. This allows the user to
1643 reconfigure the package if necessary. You should
1644 <em>not</em> configure the package and edit the generated
1645 <prgn>Makefile</prgn>! This makes it impossible for someone
1646 else to later reconfigure the package without losing the
1647 changes you made.
1648 </p>
1650 </sect>
1652 <sect id="dpkgchangelog">
1653 <heading>Debian changelog: <file>debian/changelog</file></heading>
1656 Changes in the Debian version of the package should be
1657 briefly explained in the Debian changelog file
1658 <file>debian/changelog</file>.<footnote>
1660 Mistakes in changelogs are usually best rectified by
1661 making a new changelog entry rather than "rewriting
1662 history" by editing old changelog entries.
1663 </p>
1664 </footnote>
1665 This includes modifications
1666 made in the Debian package compared to the upstream one
1667 as well as other changes and updates to the package.
1668 <footnote>
1669 Although there is nothing stopping an author who is also
1670 the Debian maintainer from using this changelog for all
1671 their changes, it will have to be renamed if the Debian
1672 and upstream maintainers become different people. In such
1673 a case, however, it might be better to maintain the package
1674 as a non-native package.
1675 </footnote>
1676 </p>
1679 The format of the <file>debian/changelog</file> allows the
1680 package building tools to discover which version of the package
1681 is being built and find out other release-specific information.
1682 </p>
1685 That format is a series of entries like this:
1687 <example compact="compact">
1688 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
1689 <var>
1690 [optional blank line(s), stripped]
1691 </var>
1692 * <var>change details</var>
1693 <var>more change details</var>
1694 <var>
1695 [blank line(s), included in output of dpkg-parsechangelog]
1696 </var>
1697 * <var>even more change details</var>
1698 <var>
1699 [optional blank line(s), stripped]
1700 </var>
1701 -- <var>maintainer name</var> &lt;<var>email address</var>&gt;<var>[two spaces]</var> <var>date</var>
1702 </example>
1703 </p>
1706 <var>package</var> and <var>version</var> are the source
1707 package name and version number.
1708 </p>
1711 <var>distribution(s)</var> lists the distributions where
1712 this version should be installed when it is uploaded - it
1713 is copied to the <tt>Distribution</tt> field in the
1714 <file>.changes</file> file. See <ref id="f-Distribution">.
1715 </p>
1718 <var>urgency</var> is the value for the <tt>Urgency</tt>
1719 field in the <file>.changes</file> file for the upload
1720 (see <ref id="f-Urgency">). It is not possible to specify
1721 an urgency containing commas; commas are used to separate
1722 <tt><var>keyword</var>=<var>value</var></tt> settings in the
1723 <prgn>dpkg</prgn> changelog format (though there is
1724 currently only one useful <var>keyword</var>,
1725 <tt>urgency</tt>).
1726 </p>
1729 The change details may in fact be any series of lines
1730 starting with at least two spaces, but conventionally each
1731 change starts with an asterisk and a separating space and
1732 continuation lines are indented so as to bring them in
1733 line with the start of the text above. Blank lines may be
1734 used here to separate groups of changes, if desired.
1735 </p>
1738 If this upload resolves bugs recorded in the Bug Tracking
1739 System (BTS), they may be automatically closed on the
1740 inclusion of this package into the Debian archive by
1741 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
1742 in the change details.<footnote>
1743 To be precise, the string should match the following
1744 Perl regular expression:
1745 <example>
1746 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
1747 </example>
1748 Then all of the bug numbers listed will be closed by the
1749 archive maintenance software (<prgn>dak</prgn>) using the
1750 <var>version</var> of the changelog entry.
1751 </footnote>
1752 This information is conveyed via the <tt>Closes</tt> field
1753 in the <tt>.changes</tt> file (see <ref id="f-Closes">).
1754 </p>
1757 The maintainer name and email address used in the changelog
1758 should be the details of the person who prepared this release of
1759 the package. They are <em>not</em> necessarily those of the
1760 uploader or usual package maintainer.<footnote>
1761 In the case of a sponsored upload, the uploader signs the
1762 files, but the changelog maintainer name and address are those
1763 of the person who prepared this release. If the preparer of
1764 the release is not one of the usual maintainers of the package
1765 (as listed in
1766 the <qref id="f-Maintainer"><tt>Maintainer</tt></qref>
1767 or <qref id="f-Uploaders"><tt>Uploaders</tt></qref> control
1768 fields of the package), the first line of the changelog is
1769 conventionally used to explain why a non-maintainer is
1770 uploading the package. The Debian Developer's Reference
1771 (see <ref id="related">) documents the conventions
1772 used.</footnote>
1773 The information here will be copied to the <tt>Changed-By</tt>
1774 field in the <tt>.changes</tt> file
1775 (see <ref id="f-Changed-By">), and then later used to send an
1776 acknowledgement when the upload has been installed.
1777 </p>
1780 The <var>date</var> has the following format<footnote>
1781 This is the same as the format generated by <tt>date
1782 -R</tt>.
1783 </footnote> (compatible and with the same semantics of
1784 RFC 2822 and RFC 5322):
1785 <example>day-of-week, dd month yyyy hh:mm:ss +zzzz</example>
1786 where:
1787 <list compact="compact">
1788 <item>
1789 day-of week is one of: Mon, Tue, Wed, Thu, Fri, Sat, Sun
1790 </item>
1791 <item>
1792 dd is a one- or two-digit day of the month (01-31)
1793 </item>
1794 <item>
1795 month is one of: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug,
1796 Sep, Oct, Nov, Dec
1797 </item>
1798 <item>yyyy is the four-digit year (e.g. 2010)</item>
1799 <item>hh is the two-digit hour (00-23)</item>
1800 <item>mm is the two-digit minutes (00-59)</item>
1801 <item>ss is the two-digit seconds (00-60)</item>
1802 <item>
1803 +zzzz or -zzzz is the time zone offset from Coordinated
1804 Universal Time (UTC). "+" indicates that the time is ahead
1805 of (i.e., east of) UTC and "-" indicates that the time is
1806 behind (i.e., west of) UTC. The first two digits indicate
1807 the hour difference from UTC and the last two digits
1808 indicate the number of additional minutes difference from
1809 UTC. The last two digits must be in the range 00-59.
1810 </item>
1811 </list>
1812 </p>
1815 The first "title" line with the package name must start
1816 at the left hand margin. The "trailer" line with the
1817 maintainer and date details must be preceded by exactly
1818 one space. The maintainer details and the date must be
1819 separated by exactly two spaces.
1820 </p>
1823 The entire changelog must be encoded in UTF-8.
1824 </p>
1827 For more information on placement of the changelog files
1828 within binary packages, please see <ref id="changelogs">.
1829 </p>
1830 </sect>
1832 <sect id="dpkgcopyright">
1833 <heading>Copyright: <file>debian/copyright</file></heading>
1835 Every package must be accompanied by a verbatim copy of its
1836 copyright information and distribution license in the file
1837 <file>/usr/share/doc/<var>package</var>/copyright</file>
1838 (see <ref id="copyrightfile"> for further details). Also see
1839 <ref id="pkgcopyright"> for further considerations related
1840 to copyrights for packages.
1841 </p>
1842 </sect>
1843 <sect>
1844 <heading>Error trapping in makefiles</heading>
1847 When <prgn>make</prgn> invokes a command in a makefile
1848 (including your package's upstream makefiles and
1849 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1850 means that <prgn>sh</prgn>'s usual bad error handling
1851 properties apply: if you include a miniature script as one
1852 of the commands in your makefile you'll find that if you
1853 don't do anything about it then errors are not detected
1854 and <prgn>make</prgn> will blithely continue after
1855 problems.
1856 </p>
1859 Every time you put more than one shell command (this
1860 includes using a loop) in a makefile command you
1861 must make sure that errors are trapped. For
1862 simple compound commands, such as changing directory and
1863 then running a program, using <tt>&amp;&amp;</tt> rather
1864 than semicolon as a command separator is sufficient. For
1865 more complex commands including most loops and
1866 conditionals you should include a separate <tt>set -e</tt>
1867 command at the start of every makefile command that's
1868 actually one of these miniature shell scripts.
1869 </p>
1870 </sect>
1872 <sect id="timestamps">
1873 <heading>Time Stamps</heading>
1875 Maintainers should preserve the modification times of the
1876 upstream source files in a package, as far as is reasonably
1877 possible.<footnote>
1878 The rationale is that there is some information conveyed
1879 by knowing the age of the file, for example, you could
1880 recognize that some documentation is very old by looking
1881 at the modification time, so it would be nice if the
1882 modification time of the upstream source would be
1883 preserved.
1884 </footnote>
1885 </p>
1886 </sect>
1888 <sect id="restrictions">
1889 <heading>Restrictions on objects in source packages</heading>
1892 The source package may not contain any hard links<footnote>
1894 This is not currently detected when building source
1895 packages, but only when extracting
1896 them.
1897 </p>
1899 Hard links may be permitted at some point in the
1900 future, but would require a fair amount of
1901 work.
1902 </p>
1903 </footnote>, device special files, sockets or setuid or
1904 setgid files.<footnote>
1905 Setgid directories are allowed.
1906 </footnote>
1907 </p>
1908 </sect>
1910 <sect id="debianrules">
1911 <heading>Main building script: <file>debian/rules</file></heading>
1914 This file must be an executable makefile, and contains the
1915 package-specific recipes for compiling the package and
1916 building binary package(s) from the source.
1917 </p>
1920 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1921 so that it can be invoked by saying its name rather than
1922 invoking <prgn>make</prgn> explicitly. That is, invoking
1923 either of <tt>make -f debian/rules <em>args...</em></tt>
1924 or <tt>./debian/rules <em>args...</em></tt> must result in
1925 identical behavior.
1926 </p>
1929 The following targets are required and must be implemented
1930 by <file>debian/rules</file>: <tt>clean</tt>, <tt>binary</tt>,
1931 <tt>binary-arch</tt>, <tt>binary-indep</tt>, <tt>build</tt>,
1932 <tt>build-arch</tt> and <tt>build-indep</tt>.
1933 These are the targets called by <prgn>dpkg-buildpackage</prgn>.
1934 </p>
1937 Since an interactive <file>debian/rules</file> script makes it
1938 impossible to auto-compile that package and also makes it hard
1939 for other people to reproduce the same binary package, all
1940 required targets must be non-interactive. It also follows that
1941 any target that these targets depend on must also be
1942 non-interactive.
1943 </p>
1945 For packages in the main archive, no required targets
1946 may attempt network access.
1947 </p>
1950 The targets are as follows:
1951 <taglist>
1952 <tag><tt>build</tt> (required)</tag>
1953 <item>
1955 The <tt>build</tt> target should perform all the
1956 configuration and compilation of the package.
1957 If a package has an interactive pre-build
1958 configuration routine, the Debian source package
1959 must either be built after this has taken place (so
1960 that the binary package can be built without rerunning
1961 the configuration) or the configuration routine
1962 modified to become non-interactive. (The latter is
1963 preferable if there are architecture-specific features
1964 detected by the configuration routine.)
1965 </p>
1968 For some packages, notably ones where the same
1969 source tree is compiled in different ways to produce
1970 two binary packages, the <tt>build</tt> target
1971 does not make much sense. For these packages it is
1972 good enough to provide two (or more) targets
1973 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1974 for each of the ways of building the package, and a
1975 <tt>build</tt> target that does nothing. The
1976 <tt>binary</tt> target will have to build the
1977 package in each of the possible ways and make the
1978 binary package out of each.
1979 </p>
1982 The <tt>build</tt> target must not do anything
1983 that might require root privilege.
1984 </p>
1987 The <tt>build</tt> target may need to run the
1988 <tt>clean</tt> target first - see below.
1989 </p>
1992 When a package has a configuration and build routine
1993 which takes a long time, or when the makefiles are
1994 poorly designed, or when <tt>build</tt> needs to
1995 run <tt>clean</tt> first, it is a good idea to
1996 <tt>touch build</tt> when the build process is
1997 complete. This will ensure that if <tt>debian/rules
1998 build</tt> is run again it will not rebuild the whole
1999 program.<footnote>
2000 Another common way to do this is for <tt>build</tt>
2001 to depend on <prgn>build-stamp</prgn> and to do
2002 nothing else, and for the <prgn>build-stamp</prgn>
2003 target to do the building and to <tt>touch
2004 build-stamp</tt> on completion. This is
2005 especially useful if the build routine creates a
2006 file or directory called <tt>build</tt>; in such a
2007 case, <tt>build</tt> will need to be listed as
2008 a phony target (i.e., as a dependency of the
2009 <tt>.PHONY</tt> target). See the documentation of
2010 <prgn>make</prgn> for more information on phony
2011 targets.
2012 </footnote>
2013 </p>
2014 </item>
2016 <tag><tt>build-arch</tt> (required),
2017 <tt>build-indep</tt> (required)
2018 </tag>
2019 <item>
2021 The <tt>build-arch</tt> target must
2022 perform all the configuration and compilation required for
2023 producing all architecture-dependent binary packages
2024 (those packages for which the body of the
2025 <tt>Architecture</tt> field in <tt>debian/control</tt> is
2026 not <tt>all</tt>). Similarly, the <tt>build-indep</tt>
2027 target must perform all the configuration
2028 and compilation required for producing all
2029 architecture-independent binary packages (those packages
2030 for which the body of the <tt>Architecture</tt> field
2031 in <tt>debian/control</tt> is <tt>all</tt>).
2032 The <tt>build</tt> target
2033 should either depend on those targets or take the same
2034 actions as invoking those targets would perform.<footnote>
2035 This split allows binary-only builds to not install the
2036 dependencies required for the <tt>build-indep</tt>
2037 target and skip any resource-intensive build tasks that
2038 are only required when building architecture-independent
2039 binary packages.
2040 </footnote>
2041 </p>
2044 The <tt>build-arch</tt> and <tt>build-indep</tt> targets
2045 must not do anything that might require root privilege.
2046 </p>
2047 </item>
2049 <tag><tt>binary</tt> (required), <tt>binary-arch</tt>
2050 (required), <tt>binary-indep</tt> (required)
2051 </tag>
2052 <item>
2054 The <tt>binary</tt> target must be all that is
2055 necessary for the user to build the binary package(s)
2056 produced from this source package. It is
2057 split into two parts: <prgn>binary-arch</prgn> builds
2058 the binary packages which are specific to a particular
2059 architecture, and <tt>binary-indep</tt> builds
2060 those which are not.
2061 </p>
2063 <tt>binary</tt> may be (and commonly is) a target with
2064 no commands which simply depends on
2065 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
2066 </p>
2068 Both <tt>binary-*</tt> targets should depend on the
2069 <tt>build</tt> target, or on the appropriate
2070 <tt>build-arch</tt> or <tt>build-indep</tt> target, so
2071 that the package is built if it has not been already. It
2072 should then create the relevant binary package(s),
2073 using <prgn>dpkg-gencontrol</prgn> to make their control
2074 files and <prgn>dpkg-deb</prgn> to build them and place
2075 them in the parent of the top level directory.
2076 </p>
2079 Both the <tt>binary-arch</tt> and
2080 <tt>binary-indep</tt> targets <em>must</em> exist.
2081 If one of them has nothing to do (which will always be
2082 the case if the source generates only a single binary
2083 package, whether architecture-dependent or not), it
2084 must still exist and must always succeed.
2085 </p>
2088 The <tt>binary</tt> targets must be invoked as
2089 root.<footnote>
2090 The <prgn>fakeroot</prgn> package often allows one
2091 to build a package correctly even without being
2092 root.
2093 </footnote>
2094 </p>
2095 </item>
2097 <tag><tt>clean</tt> (required)</tag>
2098 <item>
2100 This must undo any effects that the <tt>build</tt>
2101 and <tt>binary</tt> targets may have had, except
2102 that it should leave alone any output files created in
2103 the parent directory by a run of a <tt>binary</tt>
2104 target.
2105 </p>
2108 If a <tt>build</tt> file is touched at the end of
2109 the <tt>build</tt> target, as suggested above, it
2110 should be removed as the first action that
2111 <tt>clean</tt> performs, so that running
2112 <tt>build</tt> again after an interrupted
2113 <tt>clean</tt> doesn't think that everything is
2114 already done.
2115 </p>
2118 The <tt>clean</tt> target may need to be
2119 invoked as root if <tt>binary</tt> has been
2120 invoked since the last <tt>clean</tt>, or if
2121 <tt>build</tt> has been invoked as root (since
2122 <tt>build</tt> may create directories, for
2123 example).
2124 </p>
2125 </item>
2127 <tag><tt>get-orig-source</tt> (optional)</tag>
2128 <item>
2130 This target fetches the most recent version of the
2131 original source package from a canonical archive site
2132 (via FTP or WWW, for example), does any necessary
2133 rearrangement to turn it into the original source
2134 tar file format described below, and leaves it in the
2135 current directory.
2136 </p>
2139 This target may be invoked in any directory, and
2140 should take care to clean up any temporary files it
2141 may have left.
2142 </p>
2145 This target is optional, but providing it if
2146 possible is a good idea.
2147 </p>
2148 </item>
2150 <tag><tt>patch</tt> (optional)</tag>
2151 <item>
2153 This target performs whatever additional actions are
2154 required to make the source ready for editing (unpacking
2155 additional upstream archives, applying patches, etc.).
2156 It is recommended to be implemented for any package where
2157 <tt>dpkg-source -x</tt> does not result in source ready
2158 for additional modification. See
2159 <ref id="readmesource">.
2160 </p>
2161 </item>
2162 </taglist>
2165 The <tt>build</tt>, <tt>binary</tt> and
2166 <tt>clean</tt> targets must be invoked with the current
2167 directory being the package's top-level directory.
2168 </p>
2172 Additional targets may exist in <file>debian/rules</file>,
2173 either as published or undocumented interfaces or for the
2174 package's internal use.
2175 </p>
2178 The architectures we build on and build for are determined
2179 by <prgn>make</prgn> variables using the
2180 utility <prgn>dpkg-architecture</prgn>.
2181 You can determine the Debian architecture and the GNU style
2182 architecture specification string for the build architecture as
2183 well as for the host architecture. The build architecture is
2184 the architecture on which <file>debian/rules</file> is run and
2185 the package build is performed. The host architecture is the
2186 architecture on which the resulting package will be installed
2187 and run. These are normally the same, but may be different in
2188 the case of cross-compilation (building packages for one
2189 architecture on machines of a different architecture).
2190 </p>
2193 Here is a list of supported <prgn>make</prgn> variables:
2194 <list compact="compact">
2195 <item>
2196 <tt>DEB_*_ARCH</tt> (the Debian architecture)
2197 </item>
2198 <item>
2199 <tt>DEB_*_ARCH_CPU</tt> (the Debian CPU name)
2200 </item>
2201 <item>
2202 <tt>DEB_*_ARCH_OS</tt> (the Debian System name)
2203 </item>
2204 <item>
2205 <tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2206 specification string)
2207 </item>
2208 <item>
2209 <tt>DEB_*_GNU_CPU</tt> (the CPU part of
2210 <tt>DEB_*_GNU_TYPE</tt>)
2211 </item>
2212 <item>
2213 <tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2214 <tt>DEB_*_GNU_TYPE</tt>)
2215 </list>
2216 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2217 the build architecture or <tt>HOST</tt> for specification of the
2218 host architecture.
2219 </p>
2222 Backward compatibility can be provided in the rules file
2223 by setting the needed variables to suitable default
2224 values; please refer to the documentation of
2225 <prgn>dpkg-architecture</prgn> for details.
2226 </p>
2229 It is important to understand that the <tt>DEB_*_ARCH</tt>
2230 string only determines which Debian architecture we are
2231 building on or for. It should not be used to get the CPU
2232 or system information; the <tt>DEB_*_ARCH_CPU</tt> and
2233 <tt>DEB_*_ARCH_OS</tt> variables should be used for that.
2234 GNU style variables should generally only be used with upstream
2235 build systems.
2236 </p>
2238 <sect1 id="debianrules-options">
2239 <heading><file>debian/rules</file> and
2240 <tt>DEB_BUILD_OPTIONS</tt></heading>
2243 Supporting the standardized environment variable
2244 <tt>DEB_BUILD_OPTIONS</tt> is recommended. This variable can
2245 contain several flags to change how a package is compiled and
2246 built. Each flag must be in the form <var>flag</var> or
2247 <var>flag</var>=<var>options</var>. If multiple flags are
2248 given, they must be separated by whitespace.<footnote>
2249 Some packages support any delimiter, but whitespace is the
2250 easiest to parse inside a makefile and avoids ambiguity with
2251 flag values that contain commas.
2252 </footnote>
2253 <var>flag</var> must start with a lowercase letter
2254 (<tt>a-z</tt>) and consist only of lowercase letters,
2255 numbers (<tt>0-9</tt>), and the characters
2256 <tt>-</tt> and <tt>_</tt> (hyphen and underscore).
2257 <var>options</var> must not contain whitespace. The same
2258 tag should not be given multiple times with conflicting
2259 values. Package maintainers may assume that
2260 <tt>DEB_BUILD_OPTIONS</tt> will not contain conflicting tags.
2261 </p>
2264 The meaning of the following tags has been standardized:
2265 <taglist>
2266 <tag>nocheck</tag>
2267 <item>
2268 This tag says to not run any build-time test suite
2269 provided by the package.
2270 </item>
2271 <tag>nodoc</tag>
2272 <item>
2273 This tag says to skip any build steps that only generate
2274 package documentation. Files required by other sections
2275 of Debian Policy, such as copyright and changelog files,
2276 must still be generated and put in the package, but other
2277 generated documentation such as help2man-generated pages,
2278 Doxygen-generated API documentation, or info pages
2279 generated from Texinfo sources should be skipped if
2280 possible. This option does not change the set of binary
2281 packages generated by the source package, but
2282 documentation-only binary packages may be nearly empty
2283 when built with this option.
2284 </item>
2285 <tag>noopt</tag>
2286 <item>
2287 The presence of this tag means that the package should
2288 be compiled with a minimum of optimization. For C
2289 programs, it is best to add <tt>-O0</tt> to
2290 <tt>CFLAGS</tt> (although this is usually the default).
2291 Some programs might fail to build or run at this level
2292 of optimization; it may be necessary to use
2293 <tt>-O1</tt>, for example.
2294 </item>
2295 <tag>nostrip</tag>
2296 <item>
2297 This tag means that the debugging symbols should not be
2298 stripped from the binary during installation, so that
2299 debugging information may be included in the package.
2300 </item>
2301 <tag>parallel=n</tag>
2302 <item>
2303 This tag means that the package should be built using up
2304 to <tt>n</tt> parallel processes if the package build
2305 system supports this.<footnote>
2306 Packages built with <tt>make</tt> can often implement
2307 this by passing the <tt>-j</tt><var>n</var> option to
2308 <tt>make</tt>.
2309 </footnote>
2310 If the package build system does not support parallel
2311 builds, this string must be ignored. If the package
2312 build system only supports a lower level of concurrency
2313 than <var>n</var>, the package should be built using as
2314 many parallel processes as the package build system
2315 supports. It is up to the package maintainer to decide
2316 whether the package build times are long enough and the
2317 package build system is robust enough to make supporting
2318 parallel builds worthwhile.
2319 </item>
2320 </taglist>
2321 </p>
2324 Unknown flags must be ignored by <file>debian/rules</file>.
2325 </p>
2328 The following makefile snippet is an example of how one may
2329 implement the build options; you will probably have to
2330 massage this example in order to make it work for your
2331 package.
2332 <example compact="compact">
2333 CFLAGS = -Wall -g
2334 INSTALL = install
2335 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
2336 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
2337 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
2338 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
2340 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
2341 CFLAGS += -O0
2342 else
2343 CFLAGS += -O2
2344 endif
2345 ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
2346 INSTALL_PROGRAM += -s
2347 endif
2348 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
2349 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
2350 MAKEFLAGS += -j$(NUMJOBS)
2351 endif
2353 build:
2354 # ...
2355 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
2356 # Code to run the package test suite.
2357 endif
2358 </example>
2359 </p>
2360 </sect1>
2361 </sect>
2363 <!-- FIXME: section pkg-srcsubstvars is the same as substvars -->
2364 <sect id="substvars">
2365 <heading>Variable substitutions: <file>debian/substvars</file></heading>
2368 When <prgn>dpkg-gencontrol</prgn>
2369 generates <qref id="binarycontrolfiles">binary package control
2370 files</qref> (<file>DEBIAN/control</file>), it performs variable
2371 substitutions on its output just before writing it. Variable
2372 substitutions have the form <tt>${<var>variable</var>}</tt>.
2373 The optional file <file>debian/substvars</file> contains
2374 variable substitutions to be used; variables can also be set
2375 directly from <file>debian/rules</file> using the <tt>-V</tt>
2376 option to the source packaging commands, and certain predefined
2377 variables are also available.
2378 </p>
2381 The <file>debian/substvars</file> file is usually generated and
2382 modified dynamically by <file>debian/rules</file> targets, in
2383 which case it must be removed by the <tt>clean</tt> target.
2384 </p>
2387 See <manref name="deb-substvars" section="5"> for full
2388 details about source variable substitutions, including the
2389 format of <file>debian/substvars</file>.</p>
2390 </sect>
2392 <sect id="debianwatch">
2393 <heading>Optional upstream source location: <file>debian/watch</file></heading>
2396 This is an optional, recommended configuration file for the
2397 <tt>uscan</tt> utility which defines how to automatically scan
2398 ftp or http sites for newly available updates of the
2399 package. This is used Debian QA
2400 tools to help with quality control and maintenance of the
2401 distribution as a whole.
2402 </p>
2404 </sect>
2406 <sect id="debianfiles">
2407 <heading>Generated files list: <file>debian/files</file></heading>
2410 This file is not a permanent part of the source tree; it
2411 is used while building packages to record which files are
2412 being generated. <prgn>dpkg-genchanges</prgn> uses it
2413 when it generates a <file>.changes</file> file.
2414 </p>
2417 It should not exist in a shipped source package, and so it
2418 (and any backup files or temporary files such as
2419 <file>files.new</file><footnote>
2420 <file>files.new</file> is used as a temporary file by
2421 <prgn>dpkg-gencontrol</prgn> and
2422 <prgn>dpkg-distaddfile</prgn> - they write a new
2423 version of <tt>files</tt> here before renaming it,
2424 to avoid leaving a corrupted copy if an error
2425 occurs.
2426 </footnote>) should be removed by the
2427 <tt>clean</tt> target. It may also be wise to
2428 ensure a fresh start by emptying or removing it at the
2429 start of the <tt>binary</tt> target.
2430 </p>
2433 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2434 package, it adds an entry to <file>debian/files</file> for the
2435 <file>.deb</file> file that will be created when <tt>dpkg-deb
2436 --build</tt> is run for that binary package. So for most
2437 packages all that needs to be done with this file is to
2438 delete it in the <tt>clean</tt> target.
2439 </p>
2442 If a package upload includes files besides the source
2443 package and any binary packages whose control files were
2444 made with <prgn>dpkg-gencontrol</prgn> then they should be
2445 placed in the parent of the package's top-level directory
2446 and <prgn>dpkg-distaddfile</prgn> should be called to add
2447 the file to the list in <file>debian/files</file>.</p>
2448 </sect>
2450 <sect id="embeddedfiles">
2451 <heading>Convenience copies of code</heading>
2454 Some software packages include in their distribution convenience
2455 copies of code from other software packages, generally so that
2456 users compiling from source don't have to download multiple
2457 packages. Debian packages should not make use of these
2458 convenience copies unless the included package is explicitly
2459 intended to be used in this way.<footnote>
2460 For example, parts of the GNU build system work like this.
2461 </footnote>
2462 If the included code is already in the Debian archive in the
2463 form of a library, the Debian packaging should ensure that
2464 binary packages reference the libraries already in Debian and
2465 the convenience copy is not used. If the included code is not
2466 already in Debian, it should be packaged separately as a
2467 prerequisite if possible.
2468 <footnote>
2469 Having multiple copies of the same code in Debian is
2470 inefficient, often creates either static linking or shared
2471 library conflicts, and, most importantly, increases the
2472 difficulty of handling security vulnerabilities in the
2473 duplicated code.
2474 </footnote>
2475 </p>
2476 </sect>
2478 <sect id="readmesource">
2479 <heading>Source package handling:
2480 <file>debian/README.source</file></heading>
2483 If running <prgn>dpkg-source -x</prgn> on a source package
2484 doesn't produce the source of the package, ready for editing,
2485 and allow one to make changes and run
2486 <prgn>dpkg-buildpackage</prgn> to produce a modified package
2487 without taking any additional steps, creating a
2488 <file>debian/README.source</file> documentation file is
2489 recommended. This file should explain how to do all of the
2490 following:
2491 <enumlist>
2492 <item>Generate the fully patched source, in a form ready for
2493 editing, that would be built to create Debian
2494 packages. Doing this with a <tt>patch</tt> target in
2495 <file>debian/rules</file> is recommended; see
2496 <ref id="debianrules">.</item>
2497 <item>Modify the source and save those modifications so that
2498 they will be applied when building the package.</item>
2499 <item>Remove source modifications that are currently being
2500 applied when building the package.</item>
2501 <item>Optionally, document what steps are necessary to
2502 upgrade the Debian source package to a new upstream version,
2503 if applicable.</item>
2504 </enumlist>
2505 This explanation should include specific commands and mention
2506 any additional required Debian packages. It should not assume
2507 familiarity with any specific Debian packaging system or patch
2508 management tools.
2509 </p>
2512 This explanation may refer to a documentation file installed by
2513 one of the package's build dependencies provided that the
2514 referenced documentation clearly explains these tasks and is not
2515 a general reference manual.
2516 </p>
2519 <file>debian/README.source</file> may also include any other
2520 information that would be helpful to someone modifying the
2521 source package. Even if the package doesn't fit the above
2522 description, maintainers are encouraged to document in a
2523 <file>debian/README.source</file> file any source package with a
2524 particularly complex or unintuitive source layout or build
2525 system (for example, a package that builds the same source
2526 multiple times to generate different binary packages).
2527 </p>
2528 </sect>
2529 </chapt>
2532 <chapt id="controlfields">
2533 <heading>Control files and their fields</heading>
2536 The package management system manipulates data represented in
2537 a common format, known as <em>control data</em>, stored in
2538 <em>control files</em>.
2539 Control files are used for source packages, binary packages and
2540 the <file>.changes</file> files which control the installation
2541 of uploaded files<footnote>
2542 <prgn>dpkg</prgn>'s internal databases are in a similar
2543 format.
2544 </footnote>.
2545 </p>
2547 <sect id="controlsyntax">
2548 <heading>Syntax of control files</heading>
2551 A control file consists of one or more paragraphs of
2552 fields<footnote>
2553 The paragraphs are also sometimes referred to as stanzas.
2554 </footnote>.
2555 The paragraphs are separated by empty lines. Parsers may accept
2556 lines consisting solely of spaces and tabs as paragraph
2557 separators, but control files should use empty lines. Some control
2558 files allow only one paragraph; others allow several, in
2559 which case each paragraph usually refers to a different
2560 package. (For example, in source packages, the first
2561 paragraph refers to the source package, and later paragraphs
2562 refer to binary packages generated from the source.) The
2563 ordering of the paragraphs in control files is significant.
2564 </p>
2567 Each paragraph consists of a series of data fields. Each field
2568 consists of the field name followed by a colon and then the
2569 data/value associated with that field. The field name is
2570 composed of US-ASCII characters excluding control characters,
2571 space, and colon (i.e., characters in the ranges U+0021
2572 (<tt>!</tt>) through U+0039 (<tt>9</tt>), and U+003B
2573 (<tt>;</tt>) through U+007E (<tt>~</tt>), inclusive). Field
2574 names must not begin with the comment character
2575 (U+0023 <tt>#</tt>), nor with the hyphen character
2576 (U+002D <tt>-</tt>).
2577 </p>
2580 The field ends at the end of the line or at the end of the last
2581 continuation line (see below). Horizontal whitespace (spaces
2582 and tabs) may occur immediately before or after the value and is
2583 ignored there; it is conventional to put a single space after
2584 the colon. For example, a field might be:
2585 <example compact="compact">
2586 Package: libc6
2587 </example>
2588 the field name is <tt>Package</tt> and the field value
2589 <tt>libc6</tt>.
2590 </p>
2591 <p> Empty field values are only permitted in source package control files
2592 (<file>debian/control</file>). Such fields are ignored.
2593 </p>
2595 A paragraph must not contain more than one instance of a
2596 particular field name.
2597 </p>
2600 There are three types of fields:
2601 <taglist>
2602 <tag>simple</tag>
2603 <item>
2604 The field, including its value, must be a single line. Folding
2605 of the field is not permitted. This is the default field type
2606 if the definition of the field does not specify a different
2607 type.
2608 </item>
2609 <tag>folded</tag>
2610 <item>
2611 The value of a folded field is a logical line that may span
2612 several lines. The lines after the first are called
2613 continuation lines and must start with a space or a tab.
2614 Whitespace, including any newlines, is not significant in the
2615 field values of folded fields.<footnote>
2616 This folding method is similar to RFC 5322, allowing control
2617 files that contain only one paragraph and no multiline fields
2618 to be read by parsers written for RFC 5322.
2619 </footnote>
2620 </item>
2621 <tag>multiline</tag>
2622 <item>
2623 The value of a multiline field may comprise multiple continuation
2624 lines. The first line of the value, the part on the same line as
2625 the field name, often has special significance or may have to be
2626 empty. Other lines are added following the same syntax as the
2627 continuation lines of the folded fields. Whitespace, including newlines,
2628 is significant in the values of multiline fields.
2629 </item>
2630 </taglist>
2631 </p>
2634 Whitespace must not appear
2635 inside names (of packages, architectures, files or anything
2636 else) or version numbers, or between the characters of
2637 multi-character version relationships.
2638 </p>
2641 The presence and purpose of a field, and the syntax of its
2642 value may differ between types of control files.
2643 </p>
2646 Field names are not case-sensitive, but it is usual to
2647 capitalize the field names using mixed case as shown below.
2648 Field values are case-sensitive unless the description of the
2649 field says otherwise.
2650 </p>
2653 Paragraph separators (empty lines), and lines consisting only of
2654 U+0020 SPACE and U+0009 TAB, are not allowed within field values
2655 or between fields. Empty lines in field values are usually
2656 escaped by representing them by a U+0020 SPACE followed by a
2657 U+002E (<tt>.</tt>).
2658 </p>
2661 Lines starting with U+0023 (<tt>#</tt>), without any preceding
2662 whitespace, are comment lines that are only permitted in source
2663 package control files (<file>debian/control</file>). These
2664 comment lines are ignored, even between two continuation
2665 lines. They do not end logical lines.
2666 </p>
2669 All control files must be encoded in UTF-8.
2670 </p>
2671 </sect>
2673 <sect id="sourcecontrolfiles">
2674 <heading>Source package control files -- <file>debian/control</file></heading>
2677 The <file>debian/control</file> file contains the most vital
2678 (and version-independent) information about the source package
2679 and about the binary packages it creates.
2680 </p>
2683 The first paragraph of the control file contains information
2684 about the source package in general. The subsequent paragraphs
2685 each describe a binary package that the source tree builds.
2686 Each binary package built from this source package has a
2687 corresponding paragraph, except for any automatically-generated
2688 debug packages that do not require one.
2689 </p>
2692 The fields in the general paragraph (the first one, for the source
2693 package) are:
2695 <list compact="compact">
2696 <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2697 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2698 <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
2699 <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2700 <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2701 <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
2702 <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
2703 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2704 <item><qref id="f-VCS-fields"><tt>Vcs-Browser</tt>, <tt>Vcs-Git</tt>, et al.</qref></item>
2705 </list>
2706 </p>
2709 The fields in the binary package paragraphs are:
2711 <list compact="compact">
2712 <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
2713 <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2714 <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2715 <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2716 <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
2717 <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
2718 <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2719 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2720 <item><qref id="built-using"><tt>Built-Using</tt></qref></item>
2721 <item><qref id="f-Package-Type"><tt>Package-Type</tt></qref></item>
2722 </list>
2723 </p>
2726 The syntax and semantics of the fields are described below.
2727 </p>
2730 These fields are used by <prgn>dpkg-gencontrol</prgn> to
2731 generate control files for binary packages (see below), by
2732 <prgn>dpkg-genchanges</prgn> to generate the
2733 <file>.changes</file> file to accompany the upload, and by
2734 <prgn>dpkg-source</prgn> when it creates the
2735 <file>.dsc</file> source control file as part of a source
2736 archive. Some fields are folded in <file>debian/control</file>,
2737 but not in any other control
2738 file. These tools are responsible for removing the line
2739 breaks from such fields when using fields from
2740 <file>debian/control</file> to generate other control files.
2741 They are also responsible for discarding empty fields.
2742 </p>
2745 The fields here may contain variable references - their
2746 values will be substituted by <prgn>dpkg-gencontrol</prgn>,
2747 <prgn>dpkg-genchanges</prgn> or <prgn>dpkg-source</prgn>
2748 when they generate output control files.
2749 See <ref id="substvars"> for details.
2750 </p>
2751 </sect>
2753 <sect id="binarycontrolfiles">
2754 <heading>Binary package control files -- <file>DEBIAN/control</file></heading>
2757 The <file>DEBIAN/control</file> file contains the most vital
2758 (and version-dependent) information about a binary package. It
2759 consists of a single paragraph.
2760 </p>
2763 The fields in this file are:
2765 <list compact="compact">
2766 <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
2767 <item><qref id="f-Source"><tt>Source</tt></qref></item>
2768 <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2769 <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2770 <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2771 <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2772 <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
2773 <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
2774 <item><qref id="f-Installed-Size"><tt>Installed-Size</tt></qref></item>
2775 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2776 <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2777 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2778 <item><qref id="built-using"><tt>Built-Using</tt></qref></item>
2779 </list>
2780 </p>
2781 </sect>
2783 <sect id="debiansourcecontrolfiles">
2784 <heading>Debian source control files -- <tt>.dsc</tt></heading>
2787 This file consists of a single paragraph, possibly surrounded by
2788 a PGP signature. The fields of that paragraph are listed below.
2789 Their syntax is described above, in <ref id="controlsyntax">.
2791 <list compact="compact">
2792 <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
2793 <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2794 <item><qref id="f-Binary"><tt>Binary</tt></qref></item>
2795 <item><qref id="f-Architecture"><tt>Architecture</tt></qref></item>
2796 <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2797 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2798 <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
2799 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2800 <item><qref id="f-VCS-fields"><tt>Vcs-Browser</tt>, <tt>Vcs-Git</tt>, et al.</qref></item>
2801 <item><qref id="f-Dgit"><tt>Dgit</tt></qref></item>
2802 <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
2803 <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
2804 <item><qref id="f-Package-List"><tt>Package-List</tt></qref> (recommended)</item>
2805 <item><qref id="f-Checksums"><tt>Checksums-Sha1</tt>
2806 and <tt>Checksums-Sha256</tt></qref> (mandatory)</item>
2807 <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
2808 </list>
2809 </p>
2812 The Debian source control file is generated by
2813 <prgn>dpkg-source</prgn> when it builds the source
2814 archive, from other files in the source package,
2815 described above. When unpacking, it is checked against
2816 the files and directories in the other parts of the
2817 source package.
2818 </p>
2820 </sect>
2822 <sect id="debianchangesfiles">
2823 <heading>Debian changes files -- <file>.changes</file></heading>
2826 The <file>.changes</file> files are used by the Debian archive
2827 maintenance software to process updates to packages. They
2828 consist of a single paragraph, possibly surrounded by a PGP
2829 signature. That paragraph contains information from the
2830 <file>debian/control</file> file and other data about the
2831 source package gathered via <file>debian/changelog</file>
2832 and <file>debian/rules</file>.
2833 </p>
2836 <file>.changes</file> files have a format version that is
2837 incremented whenever the documented fields or their meaning
2838 change. This document describes format &changesversion;.
2839 </p>
2842 The fields in this file are:
2844 <list compact="compact">
2845 <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
2846 <item><qref id="f-Date"><tt>Date</tt></qref> (mandatory)</item>
2847 <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2848 <item><qref id="f-Binary"><tt>Binary</tt></qref> (mandatory)</item>
2849 <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2850 <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2851 <item><qref id="f-Distribution"><tt>Distribution</tt></qref> (mandatory)</item>
2852 <item><qref id="f-Urgency"><tt>Urgency</tt></qref> (recommended)</item>
2853 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2854 <item><qref id="f-Changed-By"><tt>Changed-By</tt></qref></item>
2855 <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2856 <item><qref id="f-Closes"><tt>Closes</tt></qref></item>
2857 <item><qref id="f-Changes"><tt>Changes</tt></qref> (mandatory)</item>
2858 <item><qref id="f-Checksums"><tt>Checksums-Sha1</tt>
2859 and <tt>Checksums-Sha256</tt></qref> (mandatory)</item>
2860 <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
2861 </list>
2862 </p>
2863 </sect>
2865 <sect id="controlfieldslist">
2866 <heading>List of fields</heading>
2868 <sect1 id="f-Source">
2869 <heading><tt>Source</tt></heading>
2872 This field identifies the source package name.
2873 </p>
2876 In <file>debian/control</file> or a <file>.dsc</file> file,
2877 this field must contain only the name of the source package.
2878 </p>
2881 In a binary package control file or a <file>.changes</file>
2882 file, the source package name may be followed by a version
2883 number in parentheses<footnote>
2884 It is customary to leave a space after the package name
2885 if a version number is specified.
2886 </footnote>.
2887 This version number may be omitted (and is, by
2888 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
2889 the <tt>Version</tt> field of the binary package in
2890 question. The field itself may be omitted from a binary
2891 package control file when the source package has the same
2892 name and version as the binary package.
2893 </p>
2896 Package names (both source and binary,
2897 see <ref id="f-Package">) must consist only of lower case
2898 letters (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus
2899 (<tt>+</tt>) and minus (<tt>-</tt>) signs, and periods
2900 (<tt>.</tt>). They must be at least two characters long and
2901 must start with an alphanumeric character.
2902 </p>
2903 </sect1>
2905 <sect1 id="f-Maintainer">
2906 <heading><tt>Maintainer</tt></heading>
2909 The package maintainer's name and email address. The name
2910 must come first, then the email address inside angle
2911 brackets <tt>&lt;&gt;</tt> (in RFC822 format).
2912 </p>
2915 If the maintainer's name contains a full stop then the
2916 whole field will not work directly as an email address due
2917 to a misfeature in the syntax specified in RFC822; a
2918 program using this field as an address must check for this
2919 and correct the problem if necessary (for example by
2920 putting the name in round brackets and moving it to the
2921 end, and bringing the email address forward).
2922 </p>
2925 See <ref id="maintainer"> for additional requirements and
2926 information about package maintainers.
2927 </p>
2928 </sect1>
2930 <sect1 id="f-Uploaders">
2931 <heading><tt>Uploaders</tt></heading>
2934 List of the names and email addresses of co-maintainers of the
2935 package, if any. If the package has other maintainers besides
2936 the one named in the <qref id="f-Maintainer">Maintainer
2937 field</qref>, their names and email addresses should be listed
2938 here. The format of each entry is the same as that of the
2939 Maintainer field, and multiple entries must be comma
2940 separated.
2941 </p>
2944 This is normally an optional field, but if
2945 the <tt>Maintainer</tt> control field names a group of people
2946 and a shared email address, the <tt>Uploaders</tt> field must
2947 be present and must contain at least one human with their
2948 personal email address.
2949 </p>
2952 The Uploaders field in <file>debian/control</file> can be folded.
2953 </p>
2954 </sect1>
2956 <sect1 id="f-Changed-By">
2957 <heading><tt>Changed-By</tt></heading>
2960 The name and email address of the person who prepared this
2961 version of the package, usually a maintainer. The syntax is
2962 the same as for the <qref id="f-Maintainer">Maintainer
2963 field</qref>.
2964 </p>
2965 </sect1>
2967 <sect1 id="f-Section">
2968 <heading><tt>Section</tt></heading>
2971 This field specifies an application area into which the package
2972 has been classified. See <ref id="subsections">.
2973 </p>
2976 When it appears in the <file>debian/control</file> file,
2977 it gives the value for the subfield of the same name in
2978 the <tt>Files</tt> field of the <file>.changes</file> file.
2979 It also gives the default for the same field in the binary
2980 packages.
2981 </p>
2982 </sect1>
2984 <sect1 id="f-Priority">
2985 <heading><tt>Priority</tt></heading>
2988 This field represents how important it is that the user
2989 have the package installed. See <ref id="priorities">.
2990 </p>
2993 When it appears in the <file>debian/control</file> file,
2994 it gives the value for the subfield of the same name in
2995 the <tt>Files</tt> field of the <file>.changes</file> file.
2996 It also gives the default for the same field in the binary
2997 packages.
2998 </p>
2999 </sect1>
3001 <sect1 id="f-Package">
3002 <heading><tt>Package</tt></heading>
3005 The name of the binary package.
3006 </p>
3009 Binary package names must follow the same syntax and
3010 restrictions as source package names. See <ref id="f-Source">
3011 for the details.
3012 </p>
3013 </sect1>
3015 <sect1 id="f-Architecture">
3016 <heading><tt>Architecture</tt></heading>
3019 Depending on context and the control file used, the
3020 <tt>Architecture</tt> field can include the following sets of
3021 values:
3022 <list>
3023 <item>
3024 A unique single word identifying a Debian machine
3025 architecture as described in <ref id="arch-spec">.
3026 </item>
3027 <item>
3028 An architecture wildcard identifying a set of Debian
3029 machine architectures, see <ref id="arch-wildcard-spec">.
3030 <tt>any</tt> matches all Debian machine architectures
3031 and is the most frequently used.
3032 </item>
3033 <item>
3034 <tt>all</tt>, which indicates an
3035 architecture-independent package.
3036 </item>
3037 <item>
3038 <tt>source</tt>, which indicates a source package.
3039 </item>
3040 </list>
3041 </p>
3044 In the main <file>debian/control</file> file in the source
3045 package, this field may contain the special
3046 value <tt>all</tt>, the special architecture
3047 wildcard <tt>any</tt>, or a list of specific and wildcard
3048 architectures separated by spaces. If <tt>all</tt>
3049 or <tt>any</tt> appears, that value must be the entire
3050 contents of the field. Most packages will use
3051 either <tt>all</tt> or <tt>any</tt>.
3052 </p>
3055 Specifying a specific list of architectures indicates that the
3056 source will build an architecture-dependent package only on
3057 architectures included in the list. Specifying a list of
3058 architecture wildcards indicates that the source will build an
3059 architecture-dependent package on only those architectures
3060 that match any of the specified architecture wildcards.
3061 Specifying a list of architectures or architecture wildcards
3062 other than <tt>any</tt> is for the minority of cases where a
3063 program is not portable or is not useful on some
3064 architectures. Where possible, the program should be made
3065 portable instead.
3066 </p>
3069 In the Debian source control file <file>.dsc</file>, this
3070 field contains a list of architectures and architecture
3071 wildcards separated by spaces. When the list contains the
3072 architecture wildcard <tt>any</tt>, the only other value
3073 allowed in the list is <tt>all</tt>.
3074 </p>
3077 The list may include (or consist solely of) the special
3078 value <tt>all</tt>. In other words, in <file>.dsc</file>
3079 files unlike the <file>debian/control</file>, <tt>all</tt> may
3080 occur in combination with specific architectures.
3081 The <tt>Architecture</tt> field in the Debian source control
3082 file <file>.dsc</file> is generally constructed from
3083 the <tt>Architecture</tt> fields in
3084 the <file>debian/control</file> in the source package.
3085 </p>
3088 Specifying only <tt>any</tt> indicates that the source package
3089 isn't dependent on any particular architecture and should
3090 compile fine on any one. The produced binary package(s)
3091 will be specific to whatever the current build architecture is.
3092 </p>
3095 Specifying only <tt>all</tt> indicates that the source package
3096 will only build architecture-independent packages.
3097 </p>
3100 Specifying <tt>any all</tt> indicates that the source package
3101 isn't dependent on any particular architecture. The set of
3102 produced binary packages will include at least one
3103 architecture-dependent package and one architecture-independent
3104 package.
3105 </p>
3108 Specifying a list of architectures or architecture wildcards
3109 indicates that the source will build an architecture-dependent
3110 package, and will only work correctly on the listed or
3111 matching architectures. If the source package also builds at
3112 least one architecture-independent package, <tt>all</tt> will
3113 also be included in the list.
3114 </p>
3117 In a <file>.changes</file> file, the <tt>Architecture</tt>
3118 field lists the architecture(s) of the package(s) currently
3119 being uploaded. This will be a list; if the source for the
3120 package is also being uploaded, the special
3121 entry <tt>source</tt> is also present. <tt>all</tt> will be
3122 present if any architecture-independent packages are being
3123 uploaded. Architecture wildcards such as <tt>any</tt> must
3124 never occur in the <tt>Architecture</tt> field in
3125 the <file>.changes</file> file.
3126 </p>
3129 See <ref id="debianrules"> for information on how to get
3130 the architecture for the build process.
3131 </p>
3132 </sect1>
3134 <sect1 id="f-Essential">
3135 <heading><tt>Essential</tt></heading>
3138 This is a boolean field which may occur only in the
3139 control file of a binary package or in a per-package fields
3140 paragraph of a source package control file.
3141 </p>
3144 If set to <tt>yes</tt> then the package management system
3145 will refuse to remove the package (upgrading and replacing
3146 it is still possible). The other possible value is <tt>no</tt>,
3147 which is the same as not having the field at all.
3148 </p>
3149 </sect1>
3151 <sect1>
3152 <heading>Package interrelationship fields:
3153 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3154 <tt>Recommends</tt>, <tt>Suggests</tt>,
3155 <tt>Breaks</tt>, <tt>Conflicts</tt>,
3156 <tt>Provides</tt>, <tt>Replaces</tt>, <tt>Enhances</tt>
3157 </heading>
3160 These fields describe the package's relationships with
3161 other packages. Their syntax and semantics are described
3162 in <ref id="relationships">.</p>
3163 </sect1>
3165 <sect1 id="f-Standards-Version">
3166 <heading><tt>Standards-Version</tt></heading>
3169 The most recent version of the standards (the policy
3170 manual and associated texts) with which the package
3171 complies.
3172 </p>
3175 The version number has four components: major and minor
3176 version number and major and minor patch level. When the
3177 standards change in a way that requires every package to
3178 change the major number will be changed. Significant
3179 changes that will require work in many packages will be
3180 signaled by a change to the minor number. The major patch
3181 level will be changed for any change to the meaning of the
3182 standards, however small; the minor patch level will be
3183 changed when only cosmetic, typographical or other edits
3184 are made which neither change the meaning of the document
3185 nor affect the contents of packages.
3186 </p>
3189 Thus only the first three components of the policy version
3190 are significant in the <em>Standards-Version</em> control
3191 field, and so either these three components or all four
3192 components may be specified.<footnote>
3193 In the past, people specified the full version number
3194 in the Standards-Version field, for example "2.3.0.0".
3195 Since minor patch-level changes don't introduce new
3196 policy, it was thought it would be better to relax
3197 policy and only require the first 3 components to be
3198 specified, in this example "2.3.0". All four
3199 components may still be used if someone wishes to do so.
3200 </footnote>
3201 </p>
3203 </sect1>
3205 <sect1 id="f-Version">
3206 <heading><tt>Version</tt></heading>
3209 The version number of a package. The format is:
3210 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
3211 </p>
3214 The three components here are:
3215 <taglist>
3216 <tag><var>epoch</var></tag>
3217 <item>
3219 This is a single (generally small) unsigned integer. It
3220 may be omitted, in which case zero is assumed. If it is
3221 omitted then the <var>upstream_version</var> may not
3222 contain any colons.
3223 </p>
3226 It is provided to allow mistakes in the version numbers
3227 of older versions of a package, and also a package's
3228 previous version numbering schemes, to be left behind.
3229 </p>
3230 </item>
3232 <tag><var>upstream_version</var></tag>
3233 <item>
3235 This is the main part of the version number. It is
3236 usually the version number of the original ("upstream")
3237 package from which the <file>.deb</file> file has been made,
3238 if this is applicable. Usually this will be in the same
3239 format as that specified by the upstream author(s);
3240 however, it may need to be reformatted to fit into the
3241 package management system's format and comparison
3242 scheme.
3243 </p>
3246 The comparison behavior of the package management system
3247 with respect to the <var>upstream_version</var> is
3248 described below. The <var>upstream_version</var>
3249 portion of the version number is mandatory.
3250 </p>
3253 The <var>upstream_version</var> may contain only
3254 alphanumerics<footnote>
3255 Alphanumerics are <tt>A-Za-z0-9</tt> only.
3256 </footnote>
3257 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
3258 <tt>~</tt> (full stop, plus, hyphen,
3259 tilde) and should start with a digit. If there is no
3260 <var>debian_revision</var> then hyphens are not allowed.
3261 </p>
3262 </item>
3264 <tag><var>debian_revision</var></tag>
3265 <item>
3267 This part of the version number specifies the version of
3268 the Debian package based on the upstream version. It
3269 may contain only alphanumerics and the characters
3270 <tt>+</tt> <tt>.</tt> <tt>~</tt> (plus, full stop,
3271 tilde) and is compared in the same way as the
3272 <var>upstream_version</var> is.
3273 </p>
3276 It is optional; if it isn't present then the
3277 <var>upstream_version</var> may not contain a hyphen.
3278 This format represents the case where a piece of
3279 software was written specifically to be a Debian
3280 package, where the Debian package source must always
3281 be identical to the pristine source and therefore no
3282 revision indication is required.
3283 </p>
3286 It is conventional to restart the
3287 <var>debian_revision</var> at <tt>1</tt> each time the
3288 <var>upstream_version</var> is increased.
3289 </p>
3292 The package management system will break the version
3293 number apart at the last hyphen in the string (if there
3294 is one) to determine the <var>upstream_version</var> and
3295 <var>debian_revision</var>. The absence of a
3296 <var>debian_revision</var> is equivalent to a
3297 <var>debian_revision</var> of <tt>0</tt>.
3298 </p>
3299 </item>
3300 </taglist>
3301 </p>
3304 When comparing two version numbers, first the <var>epoch</var>
3305 of each are compared, then the <var>upstream_version</var> if
3306 <var>epoch</var> is equal, and then <var>debian_revision</var>
3307 if <var>upstream_version</var> is also equal.
3308 <var>epoch</var> is compared numerically. The
3309 <var>upstream_version</var> and <var>debian_revision</var>
3310 parts are compared by the package management system using the
3311 following algorithm:
3312 </p>
3315 The strings are compared from left to right.
3316 </p>
3319 First the initial part of each string consisting entirely of
3320 non-digit characters is determined. These two parts (one of
3321 which may be empty) are compared lexically. If a difference
3322 is found it is returned. The lexical comparison is a
3323 comparison of ASCII values modified so that all the letters
3324 sort earlier than all the non-letters and so that a tilde
3325 sorts before anything, even the end of a part. For example,
3326 the following parts are in sorted order from earliest to
3327 latest: <tt>~~</tt>, <tt>~~a</tt>, <tt>~</tt>, the empty part,
3328 <tt>a</tt>.<footnote>
3329 One common use of <tt>~</tt> is for upstream pre-releases.
3330 For example, <tt>1.0~beta1~svn1245</tt> sorts earlier than
3331 <tt>1.0~beta1</tt>, which sorts earlier than <tt>1.0</tt>.
3332 </footnote>
3333 </p>
3336 Then the initial part of the remainder of each string which
3337 consists entirely of digit characters is determined. The
3338 numerical values of these two parts are compared, and any
3339 difference found is returned as the result of the comparison.
3340 For these purposes an empty string (which can only occur at
3341 the end of one or both version strings being compared) counts
3342 as zero.
3343 </p>
3346 These two steps (comparing and removing initial non-digit
3347 strings and initial digit strings) are repeated until a
3348 difference is found or both strings are exhausted.
3349 </p>
3352 Note that the purpose of epochs is to allow us to leave behind
3353 mistakes in version numbering, and to cope with situations
3354 where the version numbering scheme changes. It is
3355 <em>not</em> intended to cope with version numbers containing
3356 strings of letters which the package management system cannot
3357 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
3358 silly orderings.<footnote>
3359 The author of this manual has heard of a package whose
3360 versions went <tt>1.1</tt>, <tt>1.2</tt>, <tt>1.3</tt>,
3361 <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>, <tt>2</tt> and so
3362 forth.
3363 </footnote>
3364 </p>
3365 </sect1>
3367 <sect1 id="f-Description">
3368 <heading><tt>Description</tt></heading>
3371 In a source or binary control file, the <tt>Description</tt>
3372 field contains a description of the binary package, consisting
3373 of two parts, the synopsis or the short description, and the
3374 long description. It is a multiline field with the following
3375 format:
3376 </p>
3379 <example>
3380 Description: &lt;single line synopsis&gt;
3381 &lt;extended description over several lines&gt;
3382 </example>
3383 </p>
3386 The lines in the extended description can have these formats:
3387 </p>
3389 <p><list>
3391 <item>
3392 Those starting with a single space are part of a paragraph.
3393 Successive lines of this form will be word-wrapped when
3394 displayed. The leading space will usually be stripped off.
3395 The line must contain at least one non-whitespace character.
3396 </item>
3398 <item>
3399 Those starting with two or more spaces. These will be
3400 displayed verbatim. If the display cannot be panned
3401 horizontally, the displaying program will line wrap them "hard"
3402 (i.e., without taking account of word breaks). If it can they
3403 will be allowed to trail off to the right. None, one or two
3404 initial spaces may be deleted, but the number of spaces
3405 deleted from each line will be the same (so that you can have
3406 indenting work correctly, for example). The line must
3407 contain at least one non-whitespace character.
3408 </item>
3410 <item>
3411 Those containing a single space followed by a single full stop
3412 character. These are rendered as blank lines. This is the
3413 <em>only</em> way to get a blank line<footnote>
3414 Completely empty lines will not be rendered as blank lines.
3415 Instead, they will cause the parser to think you're starting
3416 a whole new record in the control file, and will therefore
3417 likely abort with an error.
3418 </footnote>.
3419 </item>
3421 <item>
3422 Those containing a space, a full stop and some more characters.
3423 These are for future expansion. Do not use them.
3424 </item>
3426 </list></p>
3429 Do not use tab characters. Their effect is not predictable.
3430 </p>
3433 See <ref id="descriptions"> for further information on this.
3434 </p>
3437 In a <file>.changes</file> file, the <tt>Description</tt>
3438 field contains a summary of the descriptions for the packages
3439 being uploaded. For this case, the first line of the field
3440 value (the part on the same line as <tt>Description:</tt>) is
3441 always empty. It is a multiline field, with one
3442 line per package. Each line is
3443 indented by one space and contains the name of a binary
3444 package, a space, a hyphen (<tt>-</tt>), a space, and the
3445 short description line from that package.
3446 </p>
3447 </sect1>
3449 <sect1 id="f-Distribution">
3450 <heading><tt>Distribution</tt></heading>
3453 In a <file>.changes</file> file or parsed changelog output
3454 this contains the (space-separated) name(s) of the
3455 distribution(s) where this version of the package should
3456 be installed. Valid distributions are determined by the
3457 archive maintainers.<footnote>
3458 Example distribution names in the Debian archive used in
3459 <file>.changes</file> files are:
3460 <taglist compact="compact">
3461 <tag><em>unstable</em></tag>
3462 <item>
3463 This distribution value refers to the
3464 <em>developmental</em> part of the Debian distribution
3465 tree. Most new packages, new upstream versions of
3466 packages and bug fixes go into the <em>unstable</em>
3467 directory tree.
3468 </item>
3470 <tag><em>experimental</em></tag>
3471 <item>
3472 The packages with this distribution value are deemed
3473 by their maintainers to be high risk. Oftentimes they
3474 represent early beta or developmental packages from
3475 various sources that the maintainers want people to
3476 try, but are not ready to be a part of the other parts
3477 of the Debian distribution tree.
3478 </item>
3479 </taglist>
3482 Others are used for updating stable releases or for
3483 security uploads. More information is available in the
3484 Debian Developer's Reference, section "The Debian
3485 archive".
3486 </p>
3487 </footnote>
3488 The Debian archive software only supports listing a single
3489 distribution. Migration of packages to other distributions is
3490 handled outside of the upload process.
3491 </p>
3492 </sect1>
3494 <sect1 id="f-Date">
3495 <heading><tt>Date</tt></heading>
3498 This field includes the date the package was built or last
3499 edited. It must be in the same format as the <var>date</var>
3500 in a <file>debian/changelog</file> entry.
3501 </p>
3504 The value of this field is usually extracted from the
3505 <file>debian/changelog</file> file - see
3506 <ref id="dpkgchangelog">).
3507 </p>
3508 </sect1>
3510 <sect1 id="f-Format">
3511 <heading><tt>Format</tt></heading>
3514 In <qref id="debianchangesfiles"><file>.changes</file></qref>
3515 files, this field declares the format version of that file.
3516 The syntax of the field value is the same as that of
3517 a <qref id="f-Version">package version number</qref> except
3518 that no epoch or Debian revision is allowed. The format
3519 described in this document is <tt>&changesversion;</tt>.
3520 </p>
3523 In <qref id="debiansourcecontrolfiles"><file>.dsc</file>
3524 Debian source control</qref> files, this field declares the
3525 format of the source package. The field value is used by
3526 programs acting on a source package to interpret the list of
3527 files in the source package and determine how to unpack it.
3528 The syntax of the field value is a numeric major revision, a
3529 period, a numeric minor revision, and then an optional subtype
3530 after whitespace, which if specified is an alphanumeric word
3531 in parentheses. The subtype is optional in the syntax but may
3532 be mandatory for particular source format revisions.
3533 <footnote>
3534 The source formats currently supported by the Debian archive
3535 software are <tt>1.0</tt>, <tt>3.0 (native)</tt>,
3536 and <tt>3.0 (quilt)</tt>.
3537 </footnote>
3538 </p>
3539 </sect1>
3541 <sect1 id="f-Urgency">
3542 <heading><tt>Urgency</tt></heading>
3545 This is a description of how important it is to upgrade to
3546 this version from previous ones. It consists of a single
3547 keyword taking one of the values <tt>low</tt>,
3548 <tt>medium</tt>, <tt>high</tt>, <tt>emergency</tt>, or
3549 <tt>critical</tt><footnote>
3550 Other urgency values are supported with configuration
3551 changes in the archive software but are not used in Debian.
3552 The urgency affects how quickly a package will be considered
3553 for inclusion into the <tt>testing</tt> distribution and
3554 gives an indication of the importance of any fixes included
3555 in the upload. <tt>Emergency</tt> and <tt>critical</tt> are
3556 treated as synonymous.
3557 </footnote> (not case-sensitive) followed by an optional
3558 commentary (separated by a space) which is usually in
3559 parentheses. For example:
3561 <example>
3562 Urgency: low (HIGH for users of diversions)
3563 </example>
3565 </p>
3568 The value of this field is usually extracted from the
3569 <file>debian/changelog</file> file - see
3570 <ref id="dpkgchangelog">.
3571 </p>
3572 </sect1>
3574 <sect1 id="f-Changes">
3575 <heading><tt>Changes</tt></heading>
3578 This multiline field contains the human-readable changes data, describing
3579 the differences between the last version and the current one.
3580 </p>
3583 The first line of the field value (the part on the same line
3584 as <tt>Changes:</tt>) is always empty. The content of the
3585 field is expressed as continuation lines, with each line
3586 indented by at least one space. Blank lines must be
3587 represented by a line consisting only of a space and a full
3588 stop (<tt>.</tt>).
3589 </p>
3592 The value of this field is usually extracted from the
3593 <file>debian/changelog</file> file - see
3594 <ref id="dpkgchangelog">).
3595 </p>
3598 Each version's change information should be preceded by a
3599 "title" line giving at least the version, distribution(s)
3600 and urgency, in a human-readable way.
3601 </p>
3604 If data from several versions is being returned the entry
3605 for the most recent version should be returned first, and
3606 entries should be separated by the representation of a
3607 blank line (the "title" line may also be followed by the
3608 representation of a blank line).
3609 </p>
3610 </sect1>
3612 <sect1 id="f-Binary">
3613 <heading><tt>Binary</tt></heading>
3616 This folded field is a list of binary packages. Its syntax and
3617 meaning varies depending on the control file in which it
3618 appears.
3619 </p>
3622 When it appears in the <file>.dsc</file> file, it lists binary
3623 packages which a source package can produce, separated by
3624 commas<footnote>
3625 A space after each comma is conventional.
3626 </footnote>. The source package
3627 does not necessarily produce all of these binary packages for
3628 every architecture. The source control file doesn't contain
3629 details of which architectures are appropriate for which of
3630 the binary packages.
3631 </p>
3634 When it appears in a <file>.changes</file> file, it lists the
3635 names of the binary packages being uploaded, separated by
3636 whitespace (not commas).
3637 </p>
3638 </sect1>
3640 <sect1 id="f-Installed-Size">
3641 <heading><tt>Installed-Size</tt></heading>
3644 This field appears in the control files of binary packages,
3645 and in the <file>Packages</file> files. It gives an estimate
3646 of the total amount of disk space required to install the
3647 named package. Actual installed size may vary based on block
3648 size, file system properties, or actions taken by package
3649 maintainer scripts.
3650 </p>
3653 The disk space is given as the integer value of the estimated
3654 installed size in bytes, divided by 1024 and rounded up.
3655 </p>
3656 </sect1>
3658 <sect1 id="f-Files">
3659 <heading><tt>Files</tt></heading>
3662 This field contains a list of files with information about
3663 each one. The exact information and syntax varies with
3664 the context.
3665 </p>
3668 In all cases, Files is a multiline field. The first line of
3669 the field value (the part on the same line as <tt>Files:</tt>)
3670 is always empty. The content of the field is expressed as
3671 continuation lines, one line per file. Each line must be
3672 indented by one space and contain a number of sub-fields,
3673 separated by spaces, as described below.
3674 </p>
3677 In the <file>.dsc</file> file, each line contains the MD5
3678 checksum, size and filename of the tar file and (if
3679 applicable) diff file which make up the remainder of the
3680 source package<footnote>
3681 That is, the parts which are not the <tt>.dsc</tt>.
3682 </footnote>. For example:
3683 <example>
3684 Files:
3685 c6f698f19f2a2aa07dbb9bbda90a2754 571925 example_1.2.orig.tar.gz
3686 938512f08422f3509ff36f125f5873ba 6220 example_1.2-1.diff.gz
3687 </example>
3688 The exact forms of the filenames are described
3689 in <ref id="pkg-sourcearchives">.
3690 </p>
3693 In the <file>.changes</file> file this contains one line per
3694 file being uploaded. Each line contains the MD5 checksum,
3695 size, section and priority and the filename. For example:
3696 <example>
3697 Files:
3698 4c31ab7bfc40d3cf49d7811987390357 1428 text extra example_1.2-1.dsc
3699 c6f698f19f2a2aa07dbb9bbda90a2754 571925 text extra example_1.2.orig.tar.gz
3700 938512f08422f3509ff36f125f5873ba 6220 text extra example_1.2-1.diff.gz
3701 7c98fe853b3bbb47a00e5cd129b6cb56 703542 text extra example_1.2-1_i386.deb
3702 </example>
3703 The <qref id="f-Section">section</qref>
3704 and <qref id="f-Priority">priority</qref> are the values of
3705 the corresponding fields in the main source control file. If
3706 no section or priority is specified then <tt>-</tt> should be
3707 used, though section and priority values must be specified for
3708 new packages to be installed properly.
3709 </p>
3712 The special value <tt>byhand</tt> for the section in a
3713 <tt>.changes</tt> file indicates that the file in question
3714 is not an ordinary package file and must be installed by
3715 hand by the distribution maintainers. If the section is
3716 <tt>byhand</tt> the priority should be <tt>-</tt>.
3717 </p>
3720 If a new Debian revision of a package is being shipped and
3721 no new original source archive is being distributed the
3722 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
3723 entry for the original source archive
3724 <file><var>package</var>_<var>upstream-version</var>.orig.tar.gz</file>,
3725 but the <file>.changes</file> file should leave it out. In
3726 this case the original source archive on the distribution
3727 site must match exactly, byte-for-byte, the original
3728 source archive which was used to generate the
3729 <file>.dsc</file> file and diff which are being uploaded.</p>
3730 </sect1>
3732 <sect1 id="f-Closes">
3733 <heading><tt>Closes</tt></heading>
3736 A space-separated list of bug report numbers that the upload
3737 governed by the .changes file closes.
3738 </p>
3739 </sect1>
3741 <sect1 id="f-Homepage">
3742 <heading><tt>Homepage</tt></heading>
3745 The URL of the web site for this package, preferably (when
3746 applicable) the site from which the original source can be
3747 obtained and any additional upstream documentation or
3748 information may be found. The content of this field is a
3749 simple URL without any surrounding characters such as
3750 <tt>&lt;&gt;</tt>.
3751 </p>
3752 </sect1>
3754 <sect1 id="f-Checksums">
3755 <heading><tt>Checksums-Sha1</tt>
3756 and <tt>Checksums-Sha256</tt></heading>
3759 These multiline fields contain a list of files with a checksum and size
3760 for each one. Both <tt>Checksums-Sha1</tt>
3761 and <tt>Checksums-Sha256</tt> have the same syntax and differ
3762 only in the checksum algorithm used: SHA-1
3763 for <tt>Checksums-Sha1</tt> and SHA-256
3764 for <tt>Checksums-Sha256</tt>.
3765 </p>
3768 <tt>Checksums-Sha1</tt> and <tt>Checksums-Sha256</tt> are
3769 multiline fields. The first line of the field value (the part
3770 on the same line as <tt>Checksums-Sha1:</tt>
3771 or <tt>Checksums-Sha256:</tt>) is always empty. The content
3772 of the field is expressed as continuation lines, one line per
3773 file. Each line consists of the checksum, a space, the file
3774 size, a space, and the file name. For example (from
3775 a <file>.changes</file> file):
3776 <example>
3777 Checksums-Sha1:
3778 1f418afaa01464e63cc1ee8a66a05f0848bd155c 1276 example_1.0-1.dsc
3779 a0ed1456fad61116f868b1855530dbe948e20f06 171602 example_1.0.orig.tar.gz
3780 5e86ecf0671e113b63388dac81dd8d00e00ef298 6137 example_1.0-1.debian.tar.gz
3781 71a0ff7da0faaf608481195f9cf30974b142c183 548402 example_1.0-1_i386.deb
3782 Checksums-Sha256:
3783 ac9d57254f7e835bed299926fd51bf6f534597cc3fcc52db01c4bffedae81272 1276 example_1.0-1.dsc
3784 0d123be7f51e61c4bf15e5c492b484054be7e90f3081608a5517007bfb1fd128 171602 example_1.0.orig.tar.gz
3785 f54ae966a5f580571ae7d9ef5e1df0bd42d63e27cb505b27957351a495bc6288 6137 example_1.0-1.debian.tar.gz
3786 3bec05c03974fdecd11d020fc2e8250de8404867a8a2ce865160c250eb723664 548402 example_1.0-1_i386.deb
3787 </example>
3788 </p>
3791 In the <file>.dsc</file> file, these fields list all
3792 files that make up the source package. In
3793 the <file>.changes</file> file, these fields list all
3794 files being uploaded. The list of files in these fields
3795 must match the list of files in the <tt>Files</tt> field.
3796 </p>
3797 </sect1>
3799 <sect1>
3800 <heading><tt>DM-Upload-Allowed</tt></heading>
3803 Obsolete, see <qref id="f-DM-Upload-Allowed">below</qref>.
3804 </p>
3805 </sect1>
3807 <sect1 id="f-VCS-fields">
3808 <heading>Version Control System (VCS) fields</heading>
3811 Debian source packages are increasingly developed using VCSs. The
3812 purpose of the following fields is to indicate a publicly accessible
3813 repository where the Debian source package is developed.
3815 <taglist>
3816 <tag><tt>Vcs-Browser</tt></tag>
3817 <item>
3819 URL of a web interface for browsing the repository.
3820 </p>
3821 </item>
3823 <tag>
3824 <tt>Vcs-Arch</tt>, <tt>Vcs-Bzr</tt> (Bazaar), <tt>Vcs-Cvs</tt>,
3825 <tt>Vcs-Darcs</tt>, <tt>Vcs-Git</tt>, <tt>Vcs-Hg</tt>
3826 (Mercurial), <tt>Vcs-Mtn</tt> (Monotone), <tt>Vcs-Svn</tt>
3827 (Subversion)
3828 </tag>
3829 <item>
3831 The field name identifies the VCS. The field's value uses the
3832 version control system's conventional syntax for describing
3833 repository locations and should be sufficient to locate the
3834 repository used for packaging. Ideally, it also locates the
3835 branch used for development of new versions of the Debian
3836 package.
3837 </p>
3839 In the case of Git, the value consists of a URL, optionally
3840 followed by the word <tt>-b</tt> and the name of a branch in
3841 the indicated repository, following the syntax of the
3842 <tt>git clone</tt> command. If no branch is specified, the
3843 packaging should be on the default branch.
3844 </p>
3846 More than one different VCS may be specified for the same
3847 package.
3848 </p>
3849 </item>
3850 </taglist>
3851 </p>
3852 </sect1>
3854 <sect1 id="f-Package-List">
3855 <heading><tt>Package-List</tt></heading>
3858 Multiline field listing all the packages that can be built from
3859 the source package, considering every architecture. The first line
3860 of the field value is empty. Each one of the next lines describes
3861 one binary package, by listing its name, type, section and priority
3862 separated by spaces. Fifth and subsequent space-separated items
3863 may be present and parsers must allow them. See the
3864 <qref id="f-Package-Type">Package-Type</qref> field for a list of
3865 package types.
3866 </p>
3867 </sect1>
3869 <sect1 id="f-Package-Type">
3870 <heading><tt>Package-Type</tt></heading>
3873 Simple field containing a word indicating the type of package:
3874 <tt>deb</tt> for binary packages and <tt>udeb</tt> for micro binary
3875 packages. Other types not defined here may be indicated. In
3876 source package control files, the <tt>Package-Type</tt> field
3877 should be omitted instead of giving it a value of <tt>deb</tt>, as
3878 this value is assumed for paragraphs lacking this field.
3879 </p>
3880 </sect1>
3882 <sect1 id="f-Dgit">
3883 <heading><tt>Dgit</tt></heading>
3886 Folded field containing a single git commit hash, presented in
3887 full, followed optionally by whitespace and other data to be
3888 defined in future extensions.
3889 </p>
3892 Declares that the source package corresponds exactly to a
3893 referenced commit in a Git repository available at the canonical
3894 location called <em>dgit-repos</em>, used by <prgn>dgit</prgn>, a
3895 bidirectional gateway between the Debian archive and Git. The
3896 commit is reachable from at least one reference whose name matches
3897 <tt>refs/dgit/*</tt>. See the manual page of <prgn>dgit</prgn> for
3898 further details.
3899 </p>
3900 </sect1>
3901 </sect>
3903 <sect>
3904 <heading>User-defined fields</heading>
3907 Additional user-defined fields may be added to the
3908 source package control file. Such fields will be
3909 ignored, and not copied to (for example) binary or
3910 Debian source control files or upload control files.
3911 </p>
3914 If you wish to add additional unsupported fields to
3915 these output files you should use the mechanism
3916 described here.
3917 </p>
3920 Fields in the main source control information file with
3921 names starting <tt>X</tt>, followed by one or more of
3922 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
3923 be copied to the output files. Only the part of the
3924 field name after the hyphen will be used in the output
3925 file. Where the letter <tt>B</tt> is used the field
3926 will appear in binary package control files, where the
3927 letter <tt>S</tt> is used in Debian source control
3928 files and where <tt>C</tt> is used in upload control
3929 (<tt>.changes</tt>) files.
3930 </p>
3933 For example, if the main source information control file
3934 contains the field
3935 <example>
3936 XBS-Comment: I stand between the candle and the star.
3937 </example>
3938 then the binary and Debian source control files will contain the
3939 field
3940 <example>
3941 Comment: I stand between the candle and the star.
3942 </example>
3943 </p>
3945 </sect>
3947 <sect id="obsolete-control-data-fields">
3948 <heading>Obsolete fields</heading>
3951 The following fields have been obsoleted and may be found in packages
3952 conforming with previous versions of the Policy.
3953 </p>
3955 <sect1 id="f-DM-Upload-Allowed">
3956 <heading><tt>DM-Upload-Allowed</tt></heading>
3959 Indicates that Debian Maintainers may upload this package to
3960 the Debian archive. The only valid value is <tt>yes</tt>. This
3961 field was used to regulate uploads by Debian Maintainers, See the
3962 General Resolution <url id="http://www.debian.org/vote/2007/vote_003"
3963 name="Endorse the concept of Debian Maintainers"> for more details.
3964 </p>
3965 </sect1>
3967 </sect>
3969 </chapt>
3972 <chapt id="maintainerscripts">
3973 <heading>Package maintainer scripts and installation procedure</heading>
3975 <sect>
3976 <heading>Introduction to package maintainer scripts</heading>
3979 It is possible to supply scripts as part of a package which
3980 the package management system will run for you when your
3981 package is installed, upgraded or removed.
3982 </p>
3985 These scripts are the control information
3986 files <prgn>preinst</prgn>, <prgn>postinst</prgn>, <prgn>prerm</prgn>
3987 and <prgn>postrm</prgn>. They must be proper executable files;
3988 if they are scripts (which is recommended), they must start with
3989 the usual <tt>#!</tt> convention. They should be readable and
3990 executable by anyone, and must not be world-writable.
3991 </p>
3994 The package management system looks at the exit status from
3995 these scripts. It is important that they exit with a
3996 non-zero status if there is an error, so that the package
3997 management system can stop its processing. For shell
3998 scripts this means that you <em>almost always</em> need to
3999 use <tt>set -e</tt> (this is usually true when writing shell
4000 scripts, in fact). It is also important, of course, that
4001 they exit with a zero status if everything went well.
4002 </p>
4005 Additionally, packages interacting with users
4006 using <prgn>debconf</prgn> in the <prgn>postinst</prgn> script
4007 should install a <prgn>config</prgn> script as a control
4008 information file. See <ref id="maintscriptprompt"> for details.
4009 </p>
4012 When a package is upgraded a combination of the scripts from
4013 the old and new packages is called during the upgrade
4014 procedure. If your scripts are going to be at all
4015 complicated you need to be aware of this, and may need to
4016 check the arguments to your scripts.
4017 </p>
4020 Broadly speaking the <prgn>preinst</prgn> is called before
4021 (a particular version of) a package is unpacked, and the
4022 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
4023 before (a version of) a package is removed and the
4024 <prgn>postrm</prgn> afterwards.
4025 </p>
4028 Programs called from maintainer scripts should not normally
4029 have a path prepended to them. Before installation is
4030 started, the package management system checks to see if the
4031 programs <prgn>ldconfig</prgn>, <prgn>start-stop-daemon</prgn>,
4032 and <prgn>update-rc.d</prgn> can be found via the
4033 <tt>PATH</tt> environment variable. Those programs, and any
4034 other program that one would expect to be in the
4035 <tt>PATH</tt>, should thus be invoked without an absolute
4036 pathname. Maintainer scripts should also not reset the
4037 <tt>PATH</tt>, though they might choose to modify it by
4038 prepending or appending package-specific directories. These
4039 considerations really apply to all shell scripts.</p>
4040 </sect>
4042 <sect id="idempotency">
4043 <heading>Maintainer scripts idempotency</heading>
4046 It is necessary for the error recovery procedures that the
4047 scripts be idempotent. This means that if it is run
4048 successfully, and then it is called again, it doesn't bomb
4049 out or cause any harm, but just ensures that everything is
4050 the way it ought to be. If the first call failed, or
4051 aborted half way through for some reason, the second call
4052 should merely do the things that were left undone the first
4053 time, if any, and exit with a success status if everything
4054 is OK.<footnote>
4055 This is so that if an error occurs, the user interrupts
4056 <prgn>dpkg</prgn> or some other unforeseen circumstance
4057 happens you don't leave the user with a badly-broken
4058 package when <prgn>dpkg</prgn> attempts to repeat the
4059 action.
4060 </footnote>
4061 </p>
4062 </sect>
4064 <sect id="controllingterminal">
4065 <heading>Controlling terminal for maintainer scripts</heading>
4068 Maintainer scripts are not guaranteed to run with a controlling
4069 terminal and may not be able to interact with the user. They
4070 must be able to fall back to noninteractive behavior if no
4071 controlling terminal is available. Maintainer scripts that
4072 prompt via a program conforming to the Debian Configuration
4073 Management Specification (see <ref id="maintscriptprompt">) may
4074 assume that program will handle falling back to noninteractive
4075 behavior.
4076 </p>
4079 For high-priority prompts without a reasonable default answer,
4080 maintainer scripts may abort if there is no controlling
4081 terminal. However, this situation should be avoided if at all
4082 possible, since it prevents automated or unattended installs.
4083 In most cases, users will consider this to be a bug in the
4084 package.
4085 </p>
4086 </sect>
4088 <sect id="exitstatus">
4089 <heading>Exit status</heading>
4092 Each script must return a zero exit status for
4093 success, or a nonzero one for failure, since the package
4094 management system looks for the exit status of these scripts
4095 and determines what action to take next based on that datum.
4096 </p>
4097 </sect>
4099 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
4100 scripts are called
4101 </heading>
4104 What follows is a summary of all the ways in which maintainer
4105 scripts may be called along with what facilities those scripts
4106 may rely on being available at that time. Script names preceded
4107 by <var>new-</var> are the scripts from the new version of a
4108 package being installed, upgraded to, or downgraded to. Script
4109 names preceded by <var>old-</var> are the scripts from the old
4110 version of a package that is being upgraded from or downgraded
4111 from.
4112 </p>
4115 The <prgn>preinst</prgn> script may be called in the following
4116 ways:
4117 <taglist>
4118 <tag><var>new-preinst</var> <tt>install</tt></tag>
4119 <tag><var>new-preinst</var> <tt>install</tt>
4120 <var>old-version</var></tag>
4121 <tag><var>new-preinst</var> <tt>upgrade</tt>
4122 <var>old-version</var></tag>
4123 <item>
4124 The package will not yet be unpacked, so
4125 the <prgn>preinst</prgn> script cannot rely on any files
4126 included in its package. Only essential packages and
4127 pre-dependencies (<tt>Pre-Depends</tt>) may be assumed to be
4128 available. Pre-dependencies will have been configured at
4129 least once, but at the time the <prgn>preinst</prgn> is
4130 called they may only be in an "Unpacked" or "Half-Configured"
4131 state if a previous version of the pre-dependency was
4132 completely configured and has not been removed since then.
4133 </item>
4135 <tag><var>old-preinst</var> <tt>abort-upgrade</tt>
4136 <var>new-version</var></tag>
4137 <item>
4138 Called during error handling of an upgrade that failed after
4139 unpacking the new package because the <tt>postrm
4140 upgrade</tt> action failed. The unpacked files may be
4141 partly from the new version or partly missing, so the script
4142 cannot rely on files included in the package. Package
4143 dependencies may not be available. Pre-dependencies will be
4144 at least "Unpacked" following the same rules as above, except
4145 they may be only "Half-Installed" if an upgrade of the
4146 pre-dependency failed.<footnote>
4147 This can happen if the new version of the package no
4148 longer pre-depends on a package that had been partially
4149 upgraded.
4150 </footnote>
4151 </item>
4152 </taglist>
4153 </p>
4156 The <prgn>postinst</prgn> script may be called in the following
4157 ways:
4158 <taglist>
4159 <tag><var>postinst</var> <tt>configure</tt>
4160 <var>most-recently-configured-version</var></tag>
4161 <item>
4162 The files contained in the package will be unpacked. All
4163 package dependencies will at least be "Unpacked". If there
4164 are no circular dependencies involved, all package
4165 dependencies will be configured. For behavior in the case
4166 of circular dependencies, see the discussion
4167 in <ref id="binarydeps">.
4168 </item>
4170 <tag><var>old-postinst</var> <tt>abort-upgrade</tt>
4171 <var>new-version</var></tag>
4172 <tag><var>conflictor's-postinst</var> <tt>abort-remove</tt>
4173 <tt>in-favour</tt> <var>package</var>
4174 <var>new-version</var></tag>
4175 <tag><var>postinst</var> <tt>abort-remove</tt></tag>
4176 <tag><var>deconfigured's-postinst</var>
4177 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
4178 <var>failed-install-package</var> <var>version</var>
4179 [<tt>removing</tt> <var>conflicting-package</var>
4180 <var>version</var>]</tag>
4181 <item>
4182 The files contained in the package will be unpacked. All
4183 package dependencies will at least be "Half-Installed" and
4184 will have previously been configured and not removed.
4185 However, dependencies may not be configured or even fully
4186 unpacked in some error situations.<footnote>
4187 For example, suppose packages foo and bar are "Installed"
4188 with foo depending on bar. If an upgrade of bar were
4189 started and then aborted, and then an attempt to remove
4190 foo failed because its <prgn>prerm</prgn> script failed,
4191 foo's <tt>postinst abort-remove</tt> would be called with
4192 bar only "Half-Installed".
4193 </footnote>
4194 The <prgn>postinst</prgn> should still attempt any actions
4195 for which its dependencies are required, since they will
4196 normally be available, but consider the correct error
4197 handling approach if those actions fail. Aborting
4198 the <prgn>postinst</prgn> action if commands or facilities
4199 from the package dependencies are not available is often the
4200 best approach.
4201 </item>
4202 </taglist>
4203 </p>
4206 The <prgn>prerm</prgn> script may be called in the following
4207 ways:
4208 <taglist>
4209 <tag><var>prerm</var> <tt>remove</tt></tag>
4210 <tag><var>old-prerm</var>
4211 <tt>upgrade</tt><var>new-version</var></tag>
4212 <tag><var>conflictor's-prerm</var> <tt>remove</tt>
4213 <tt>in-favour</tt> <var>package</var>
4214 <var>new-version</var></tag>
4215 <tag><var>deconfigured's-prerm</var> <tt>deconfigure</tt>
4216 <tt>in-favour</tt> <var>package-being-installed</var>
4217 <var>version</var> [<tt>removing</tt>
4218 <var>conflicting-package</var> <var>version</var>]</tag>
4219 <item>
4220 The package whose <prgn>prerm</prgn> is being called will be
4221 at least "Half-Installed". All package dependencies will at
4222 least be "Half-Installed" and will have previously been
4223 configured and not removed. If there was no error, all
4224 dependencies will at least be "Unpacked", but these actions
4225 may be called in various error states where dependencies are
4226 only "Half-Installed" due to a partial upgrade.
4227 </item>
4229 <tag><var>new-prerm</var> <tt>failed-upgrade</tt>
4230 <var>old-version</var></tag>
4231 <item>
4232 Called during error handling when <tt>prerm upgrade</tt>
4233 fails. The new package will not yet be unpacked, and all
4234 the same constraints as for <tt>preinst upgrade</tt> apply.
4235 </item>
4236 </taglist>
4237 </p>
4240 The <prgn>postrm</prgn> script may be called in the following
4241 ways:
4242 <taglist>
4243 <tag><var>postrm</var> <tt>remove</tt></tag>
4244 <tag><var>postrm</var> <tt>purge</tt></tag>
4245 <tag><var>old-postrm</var> <tt>upgrade</tt>
4246 <var>new-version</var></tag>
4247 <tag><var>disappearer's-postrm</var> <tt>disappear</tt>
4248 <var>overwriter</var> <var>overwriter-version</var></tag>
4249 <item>
4250 The <prgn>postrm</prgn> script is called after the package's
4251 files have been removed or replaced. The package
4252 whose <prgn>postrm</prgn> is being called may have
4253 previously been deconfigured and only be "Unpacked", at which
4254 point subsequent package changes do not consider its
4255 dependencies. Therefore, all <prgn>postrm</prgn> actions
4256 may only rely on essential packages and must gracefully skip
4257 any actions that require the package's dependencies if those
4258 dependencies are unavailable.<footnote>
4259 This is often done by checking whether the command or
4260 facility the <prgn>postrm</prgn> intends to call is
4261 available before calling it. For example:
4262 <example>
4263 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
4264 . /usr/share/debconf/confmodule
4265 db_purge
4267 </example>
4268 in <prgn>postrm</prgn> purges the <prgn>debconf</prgn>
4269 configuration for the package
4270 if <package>debconf</package> is installed.
4271 </footnote>
4272 </item>
4274 <tag><var>new-postrm</var> <tt>failed-upgrade</tt>
4275 <var>old-version</var></tag>
4276 <item>
4277 Called when the old <tt>postrm upgrade</tt> action fails.
4278 The new package will be unpacked, but only essential
4279 packages and pre-dependencies can be relied on.
4280 Pre-dependencies will either be configured or will be
4281 "Unpacked" or "Half-Configured" but previously had been
4282 configured and was never removed.
4283 </item>
4285 <tag><var>new-postrm</var> <tt>abort-install</tt></tag>
4286 <tag><var>new-postrm</var> <tt>abort-install</tt>
4287 <var>old-version</var></tag>
4288 <tag><var>new-postrm</var> <tt>abort-upgrade</tt>
4289 <var>old-version</var></tag>
4290 <item>
4291 Called before unpacking the new package as part of the
4292 error handling of <prgn>preinst</prgn> failures. May assume
4293 the same state as <prgn>preinst</prgn> can assume.
4294 </item>
4295 </taglist>
4296 </p>
4297 </sect>
4299 <sect id="unpackphase">
4300 <heading>Details of unpack phase of installation or upgrade</heading>
4303 The procedure on installation/upgrade/overwrite/disappear
4304 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
4305 stage of <tt>dpkg --install</tt>) is as follows. In each
4306 case, if a major error occurs (unless listed below) the
4307 actions are, in general, run backwards - this means that the
4308 maintainer scripts are run with different arguments in
4309 reverse order. These are the "error unwind" calls listed
4310 below.
4312 <enumlist>
4313 <item>
4314 <enumlist>
4315 <item>
4316 If a version of the package is already "Installed", call
4317 <example compact="compact">
4318 <var>old-prerm</var> upgrade <var>new-version</var>
4319 </example>
4320 </item>
4321 <item>
4322 If the script runs but exits with a non-zero
4323 exit status, <prgn>dpkg</prgn> will attempt:
4324 <example compact="compact">
4325 <var>new-prerm</var> failed-upgrade <var>old-version</var>
4326 </example>
4327 If this works, the upgrade continues. If this
4328 does not work, the error unwind:
4329 <example compact="compact">
4330 <var>old-postinst</var> abort-upgrade <var>new-version</var>
4331 </example>
4332 If this works, then the old-version is
4333 "Installed", if not, the old version is in a
4334 "Half-Configured" state.
4335 </item>
4336 </enumlist>
4337 </item>
4339 <item>
4340 If a "conflicting" package is being removed at the same time,
4341 or if any package will be broken (due to <tt>Breaks</tt>):
4342 <enumlist>
4343 <item>
4344 If <tt>--auto-deconfigure</tt> is
4345 specified, call, for each package to be deconfigured
4346 due to <tt>Breaks</tt>:
4347 <example compact="compact">
4348 <var>deconfigured's-prerm</var> deconfigure \
4349 in-favour <var>package-being-installed</var> <var>version</var>
4350 </example>
4351 Error unwind:
4352 <example compact="compact">
4353 <var>deconfigured's-postinst</var> abort-deconfigure \
4354 in-favour <var>package-being-installed-but-failed</var> <var>version</var>
4355 </example>
4356 The deconfigured packages are marked as
4357 requiring configuration, so that if
4358 <tt>--install</tt> is used they will be
4359 configured again if possible.
4360 </item>
4361 <item>
4362 If any packages depended on a conflicting
4363 package being removed and <tt>--auto-deconfigure</tt> is
4364 specified, call, for each such package:
4365 <example compact="compact">
4366 <var>deconfigured's-prerm</var> deconfigure \
4367 in-favour <var>package-being-installed</var> <var>version</var> \
4368 removing <var>conflicting-package</var> <var>version</var>
4369 </example>
4370 Error unwind:
4371 <example compact="compact">
4372 <var>deconfigured's-postinst</var> abort-deconfigure \
4373 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
4374 removing <var>conflicting-package</var> <var>version</var>
4375 </example>
4376 The deconfigured packages are marked as
4377 requiring configuration, so that if
4378 <tt>--install</tt> is used they will be
4379 configured again if possible.
4380 </item>
4381 <item>
4382 To prepare for removal of each conflicting package, call:
4383 <example compact="compact">
4384 <var>conflictor's-prerm</var> remove \
4385 in-favour <var>package</var> <var>new-version</var>
4386 </example>
4387 Error unwind:
4388 <example compact="compact">
4389 <var>conflictor's-postinst</var> abort-remove \
4390 in-favour <var>package</var> <var>new-version</var>
4391 </example>
4392 </item>
4393 </enumlist>
4394 </item>
4396 <item>
4397 <enumlist>
4398 <item>
4399 If the package is being upgraded, call:
4400 <example compact="compact">
4401 <var>new-preinst</var> upgrade <var>old-version</var>
4402 </example>
4403 If this fails, we call:
4404 <example>
4405 <var>new-postrm</var> abort-upgrade <var>old-version</var>
4406 </example>
4407 <enumlist>
4408 <item>
4410 If that works, then
4411 <example>
4412 <var>old-postinst</var> abort-upgrade <var>new-version</var>
4413 </example>
4414 is called. If this works, then the old version
4415 is in an "Installed" state, or else it is left
4416 in an "Unpacked" state.
4417 </p>
4418 </item>
4419 <item>
4421 If it fails, then the old version is left
4422 in an "Half-Installed" state.
4423 </p>
4424 </item>
4425 </enumlist>
4427 </item>
4428 <item>
4429 Otherwise, if the package had some configuration
4430 files from a previous version installed (i.e., it
4431 is in the "Config-Files" state):
4432 <example compact="compact">
4433 <var>new-preinst</var> install <var>old-version</var>
4434 </example>
4435 Error unwind:
4436 <example>
4437 <var>new-postrm</var> abort-install <var>old-version</var>
4438 </example>
4439 If this fails, the package is left in a
4440 "Half-Installed" state, which requires a
4441 reinstall. If it works, the packages is left in
4442 a "Config-Files" state.
4443 </item>
4444 <item>
4445 Otherwise (i.e., the package was completely purged):
4446 <example compact="compact">
4447 <var>new-preinst</var> install
4448 </example>
4449 Error unwind:
4450 <example compact="compact">
4451 <var>new-postrm</var> abort-install
4452 </example>
4453 If the error-unwind fails, the package is in a
4454 "Half-Installed" phase, and requires a
4455 reinstall. If the error unwind works, the
4456 package is in the "Not-Installed" state.
4457 </item>
4458 </enumlist>
4459 </item>
4461 <item>
4463 The new package's files are unpacked, overwriting any
4464 that may be on the system already, for example any
4465 from the old version of the same package or from
4466 another package. Backups of the old files are kept
4467 temporarily, and if anything goes wrong the package
4468 management system will attempt to put them back as
4469 part of the error unwind.
4470 </p>
4473 It is an error for a package to contain files which
4474 are on the system in another package, unless
4475 <tt>Replaces</tt> is used (see <ref id="replaces">).
4476 <!--
4477 The following paragraph is not currently the case:
4478 Currently the <tt>- - force-overwrite</tt> flag is
4479 enabled, downgrading it to a warning, but this may not
4480 always be the case.
4482 </p>
4485 It is a more serious error for a package to contain a
4486 plain file or other kind of non-directory where another
4487 package has a directory (again, unless
4488 <tt>Replaces</tt> is used). This error can be
4489 overridden if desired using
4490 <tt>--force-overwrite-dir</tt>, but this is not
4491 advisable.
4492 </p>
4495 Packages which overwrite each other's files produce
4496 behavior which, though deterministic, is hard for the
4497 system administrator to understand. It can easily
4498 lead to "missing" programs if, for example, a package
4499 is unpacked which overwrites a file from another
4500 package, and is then removed again.<footnote>
4501 Part of the problem is due to what is arguably a
4502 bug in <prgn>dpkg</prgn>.
4503 </footnote>
4504 </p>
4507 A directory will never be replaced by a symbolic link
4508 to a directory or vice versa; instead, the existing
4509 state (symlink or not) will be left alone and
4510 <prgn>dpkg</prgn> will follow the symlink if there is
4511 one.
4512 </p>
4513 </item>
4515 <item>
4517 <enumlist>
4518 <item>
4519 If the package is being upgraded, call
4520 <example compact="compact">
4521 <var>old-postrm</var> upgrade <var>new-version</var>
4522 </example>
4523 </item>
4524 <item>
4525 If this fails, <prgn>dpkg</prgn> will attempt:
4526 <example compact="compact">
4527 <var>new-postrm</var> failed-upgrade <var>old-version</var>
4528 </example>
4529 If this works, installation continues. If not,
4530 Error unwind:
4531 <example compact="compact">
4532 <var>old-preinst</var> abort-upgrade <var>new-version</var>
4533 </example>
4534 If this fails, the old version is left in a
4535 "Half-Installed" state. If it works, dpkg now
4536 calls:
4537 <example compact="compact">
4538 <var>new-postrm</var> abort-upgrade <var>old-version</var>
4539 </example>
4540 If this fails, the old version is left in a
4541 "Half-Installed" state. If it works, dpkg now
4542 calls:
4543 <example compact="compact">
4544 <var>old-postinst</var> abort-upgrade <var>new-version</var>
4545 </example>
4546 If this fails, the old version is in an
4547 "Unpacked" state.
4548 </item>
4549 </enumlist>
4550 </p>
4553 This is the point of no return - if
4554 <prgn>dpkg</prgn> gets this far, it won't back off
4555 past this point if an error occurs. This will
4556 leave the package in a fairly bad state, which
4557 will require a successful re-installation to clear
4558 up, but it's when <prgn>dpkg</prgn> starts doing
4559 things that are irreversible.
4560 </p>
4561 </item>
4563 <item>
4564 Any files which were in the old version of the package
4565 but not in the new are removed.
4566 </item>
4568 <item>
4569 The new file list replaces the old.
4570 </item>
4572 <item>
4573 The new maintainer scripts replace the old.
4574 </item>
4576 <item>
4577 Any packages all of whose files have been overwritten
4578 during the installation, and which aren't required for
4579 dependencies, are considered to have been removed.
4580 For each such package
4581 <enumlist>
4582 <item>
4583 <prgn>dpkg</prgn> calls:
4584 <example compact="compact">
4585 <var>disappearer's-postrm</var> disappear \
4586 <var>overwriter</var> <var>overwriter-version</var>
4587 </example>
4588 </item>
4589 <item>
4590 The package's maintainer scripts are removed.
4591 </item>
4592 <item>
4593 It is noted in the status database as being in a
4594 sane state, namely "Not-Installed" (any conffiles
4595 it may have are ignored, rather than being
4596 removed by <prgn>dpkg</prgn>). Note that
4597 disappearing packages do not have their prerm
4598 called, because <prgn>dpkg</prgn> doesn't know
4599 in advance that the package is going to
4600 vanish.
4601 </item>
4602 </enumlist>
4603 </item>
4605 <item>
4606 Any files in the package we're unpacking that are also
4607 listed in the file lists of other packages are removed
4608 from those lists. (This will lobotomize the file list
4609 of the "conflicting" package if there is one.)
4610 </item>
4612 <item>
4613 The backup files made during installation, above, are
4614 deleted.
4615 </item>
4617 <item>
4619 The new package's status is now sane, and recorded as
4620 "Unpacked".
4621 </p>
4624 Here is another point of no return - if the
4625 conflicting package's removal fails we do not unwind
4626 the rest of the installation; the conflicting package
4627 is left in a half-removed limbo.
4628 </p>
4629 </item>
4631 <item>
4632 If there was a conflicting package we go and do the
4633 removal actions (described below), starting with the
4634 removal of the conflicting package's files (any that
4635 are also in the package being unpacked have already
4636 been removed from the conflicting package's file list,
4637 and so do not get removed now).
4638 </item>
4639 </enumlist>
4640 </p>
4641 </sect>
4643 <sect id="configdetails"><heading>Details of configuration</heading>
4646 When we configure a package (this happens with <tt>dpkg
4647 --install</tt> and <tt>dpkg --configure</tt>), we first
4648 update any <tt>conffile</tt>s and then call:
4649 <example compact="compact">
4650 <var>postinst</var> configure <var>most-recently-configured-version</var>
4651 </example>
4652 </p>
4655 No attempt is made to unwind after errors during
4656 configuration. If the configuration fails, the package is in
4657 a "Half-Configured" state, and an error message is generated.
4658 </p>
4661 If there is no most recently configured version
4662 <prgn>dpkg</prgn> will pass a null argument.
4663 <footnote>
4665 Historical note: Truly ancient (pre-1997) versions of
4666 <prgn>dpkg</prgn> passed <tt>&lt;unknown&gt;</tt>
4667 (including the angle brackets) in this case. Even older
4668 ones did not pass a second argument at all, under any
4669 circumstance. Note that upgrades using such an old dpkg
4670 version are unlikely to work for other reasons, even if
4671 this old argument behavior is handled by your postinst script.
4672 </p>
4673 </footnote>
4674 </p>
4675 </sect>
4677 <sect id="removedetails"><heading>Details of removal and/or
4678 configuration purging</heading>
4681 <enumlist>
4682 <item>
4684 <example compact="compact">
4685 <var>prerm</var> remove
4686 </example>
4687 </p>
4689 If prerm fails during replacement due to conflict
4690 <example>
4691 <var>conflictor's-postinst</var> abort-remove \
4692 in-favour <var>package</var> <var>new-version</var>
4693 </example>
4694 Or else we call:
4695 <example>
4696 <var>postinst</var> abort-remove
4697 </example>
4698 </p>
4700 If this fails, the package is in a "Half-Configured"
4701 state, or else it remains "Installed".
4702 </p>
4703 </item>
4704 <item>
4705 The package's files are removed (except <tt>conffile</tt>s).
4706 </item>
4707 <item>
4708 <example compact="compact">
4709 <var>postrm</var> remove
4710 </example>
4713 If it fails, there's no error unwind, and the package is in
4714 an "Half-Installed" state.
4715 </p>
4716 </item>
4717 <item>
4719 All the maintainer scripts except the <prgn>postrm</prgn>
4720 are removed.
4721 </p>
4724 If we aren't purging the package we stop here. Note
4725 that packages which have no <prgn>postrm</prgn> and no
4726 <tt>conffile</tt>s are automatically purged when
4727 removed, as there is no difference except for the
4728 <prgn>dpkg</prgn> status.
4729 </p>
4730 </item>
4731 <item>
4732 The <tt>conffile</tt>s and any backup files
4733 (<tt>~</tt>-files, <tt>#*#</tt> files,
4734 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
4735 are removed.
4736 </item>
4737 <item>
4739 <example compact="compact">
4740 <var>postrm</var> purge
4741 </example>
4742 </p>
4744 If this fails, the package remains in a "Config-Files"
4745 state.
4746 </p>
4747 </item>
4748 <item>
4749 The package's file list is removed.
4750 </item>
4751 </enumlist>
4753 </p>
4754 </sect>
4755 </chapt>
4758 <chapt id="relationships">
4759 <heading>Declaring relationships between packages</heading>
4761 <sect id="depsyntax">
4762 <heading>Syntax of relationship fields</heading>
4765 These fields all have a uniform syntax. They are a list of
4766 package names separated by commas.
4767 </p>
4770 In the <tt>Depends</tt>, <tt>Recommends</tt>,
4771 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
4772 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt> and
4773 <tt>Build-Depends-Arch</tt>
4774 control fields of the package, which declare
4775 dependencies on other packages, the package names listed may
4776 also include lists of alternative package names, separated
4777 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
4778 that part of the dependency can be satisfied by any one of
4779 the alternative packages.
4780 </p>
4783 All of the fields except for <tt>Provides</tt> may restrict
4784 their applicability to particular versions of each named
4785 package. This is done in parentheses after each individual
4786 package name; the parentheses should contain a relation from
4787 the list below followed by a version number, in the format
4788 described in <ref id="f-Version">.
4789 </p>
4792 The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
4793 <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for strictly
4794 earlier, earlier or equal, exactly equal, later or equal and
4795 strictly later, respectively.<footnote>
4796 The relations <tt>&lt;</tt> and <tt>&gt;</tt> were previously
4797 allowed, but they were confusingly defined to mean
4798 earlier/later or equal rather than strictly
4799 earlier/later. <prgn>dpkg</prgn> still supports them with a
4800 warning, but they are no longer allowed by Debian Policy.
4801 </footnote>
4802 </p>
4805 Whitespace may appear at any point in the version
4806 specification subject to the rules in <ref
4807 id="controlsyntax">, and must appear where it's necessary to
4808 disambiguate; it is not otherwise significant. All of the
4809 relationship fields can only be folded in source package control files. For
4810 consistency and in case of future changes to
4811 <prgn>dpkg</prgn> it is recommended that a single space be
4812 used after a version relationship and before a version
4813 number; it is also conventional to put a single space after
4814 each comma, on either side of each vertical bar, and before
4815 each open parenthesis. When opening a continuation line in a relationship field, it
4816 is conventional to do so after a comma and before the space
4817 following that comma.
4818 </p>
4821 For example, a list of dependencies might appear as:
4822 <example compact="compact">
4823 Package: mutt
4824 Version: 1.3.17-1
4825 Depends: libc6 (>= 2.2.1), exim | mail-transport-agent
4826 </example>
4827 </p>
4830 Relationships may be restricted to a certain set of
4831 architectures. This is indicated in brackets after each
4832 individual package name and the optional version specification.
4833 The brackets enclose a non-empty list of Debian architecture names
4834 in the format described in <ref id="arch-spec">,
4835 separated by whitespace. Exclamation marks may be prepended to
4836 each of the names. (It is not permitted for some names to be
4837 prepended with exclamation marks while others aren't.)
4838 </p>
4841 For build relationship fields
4842 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
4843 <tt>Build-Depends-Arch</tt>, <tt>Build-Conflicts</tt>,
4844 <tt>Build-Conflicts-Indep</tt> and <tt>Build-Conflicts-Arch</tt>), if
4845 the current Debian host architecture is not in this list and
4846 there are no exclamation marks in the list, or it is in the list
4847 with a prepended exclamation mark, the package name and the
4848 associated version specification are ignored completely for the
4849 purposes of defining the relationships.
4850 </p>
4853 For example:
4854 <example compact="compact">
4855 Source: glibc
4856 Build-Depends-Indep: texinfo
4857 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
4858 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
4859 </example>
4860 requires <tt>kernel-headers-2.2.10</tt> on all architectures
4861 other than hurd-i386 and requires <tt>hurd-dev</tt> and
4862 <tt>gnumach-dev</tt> only on hurd-i386. Here is another example
4863 showing multiple architectures separated by spaces:
4864 <example compact="compact">
4865 Build-Depends:
4866 libluajit5.1-dev [i386 amd64 kfreebsd-i386 armel armhf powerpc mips],
4867 liblua5.1-dev [hurd-i386 ia64 kfreebsd-amd64 s390x sparc],
4868 </example>
4869 </p>
4872 For binary relationship fields and the <tt>Built-Using</tt>
4873 field, the architecture restriction
4874 syntax is only supported in the source package control
4875 file <file>debian/control</file>. When the corresponding binary
4876 package control file is generated, the relationship will either
4877 be omitted or included without the architecture restriction
4878 based on the architecture of the binary package. This means
4879 that architecture restrictions must not be used in binary
4880 relationship fields for architecture-independent packages
4881 (<tt>Architecture: all</tt>).
4882 </p>
4885 For example:
4886 <example compact="compact">
4887 Depends: foo [i386], bar [amd64]
4888 </example>
4889 becomes <tt>Depends: foo</tt> when the package is built on
4890 the <tt>i386</tt> architecture, <tt>Depends: bar</tt> when the
4891 package is built on the <tt>amd64</tt> architecture, and omitted
4892 entirely in binary packages built on all other architectures.
4893 </p>
4896 If the architecture-restricted dependency is part of a set of
4897 alternatives using <tt>|</tt>, that alternative is ignored
4898 completely on architectures that do not match the restriction.
4899 For example:
4900 <example compact="compact">
4901 Build-Depends: foo [!i386] | bar [!amd64]
4902 </example>
4903 is equivalent to <tt>bar</tt> on the i386 architecture, to
4904 <tt>foo</tt> on the amd64 architecture, and to <tt>foo |
4905 bar</tt> on all other architectures.
4906 </p>
4909 Relationships may also be restricted to a certain set of
4910 architectures using architecture wildcards in the format
4911 described in <ref id="arch-wildcard-spec">. The syntax for
4912 declaring such restrictions is the same as declaring
4913 restrictions using a certain set of architectures without
4914 architecture wildcards. For example:
4915 <example compact="compact">
4916 Build-Depends: foo [linux-any], bar [any-i386], baz [!linux-any]
4917 </example>
4918 is equivalent to <tt>foo</tt> on architectures using the Linux
4919 kernel and any cpu, <tt>bar</tt> on architectures using any
4920 kernel and an i386 cpu, and <tt>baz</tt> on any architecture
4921 using a kernel other than Linux.
4922 </p>
4925 Note that the binary package relationship fields such as
4926 <tt>Depends</tt> appear in one of the binary package
4927 sections of the control file, whereas the build-time
4928 relationships such as <tt>Build-Depends</tt> appear in the
4929 source package section of the control file (which is the
4930 first section).
4931 </p>
4932 </sect>
4934 <sect id="binarydeps">
4935 <heading>Binary Dependencies - <tt>Depends</tt>,
4936 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
4937 <tt>Pre-Depends</tt>
4938 </heading>
4941 Packages can declare in their control file that they have
4942 certain relationships to other packages - for example, that
4943 they may not be installed at the same time as certain other
4944 packages, and/or that they depend on the presence of others.
4945 </p>
4948 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
4949 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
4950 <tt>Breaks</tt> and <tt>Conflicts</tt> control fields.
4951 <tt>Breaks</tt> is described in <ref id="breaks">, and
4952 <tt>Conflicts</tt> is described in <ref id="conflicts">. The
4953 rest are described below.
4954 </p>
4957 These seven fields are used to declare a dependency
4958 relationship by one package on another. Except for
4959 <tt>Enhances</tt> and <tt>Breaks</tt>, they appear in the
4960 depending (binary) package's control file.
4961 (<tt>Enhances</tt> appears in the recommending package's
4962 control file, and <tt>Breaks</tt> appears in the version of
4963 depended-on package which causes the named package to
4964 break).
4965 </p>
4968 A <tt>Depends</tt> field takes effect <em>only</em> when a
4969 package is to be configured. It does not prevent a package
4970 being on the system in an unconfigured state while its
4971 dependencies are unsatisfied, and it is possible to replace
4972 a package whose dependencies are satisfied and which is
4973 properly installed with a different version whose
4974 dependencies are not and cannot be satisfied; when this is
4975 done the depending package will be left unconfigured (since
4976 attempts to configure it will give errors) and will not
4977 function properly. If it is necessary, a
4978 <tt>Pre-Depends</tt> field can be used, which has a partial
4979 effect even when a package is being unpacked, as explained
4980 in detail below. (The other three dependency fields,
4981 <tt>Recommends</tt>, <tt>Suggests</tt> and
4982 <tt>Enhances</tt>, are only used by the various front-ends
4983 to <prgn>dpkg</prgn> such as <prgn>apt-get</prgn>,
4984 <prgn>aptitude</prgn>, and <prgn>dselect</prgn>.)
4985 </p>
4988 Since <tt>Depends</tt> only places requirements on the order in
4989 which packages are configured, packages in an installation run
4990 are usually all unpacked first and all configured later.
4991 <footnote>
4992 This approach makes dependency resolution easier. If two
4993 packages A and B are being upgraded, the installed package A
4994 depends on exactly the installed package B, and the new
4995 package A depends on exactly the new package B (a common
4996 situation when upgrading shared libraries and their
4997 corresponding development packages), satisfying the
4998 dependencies at every stage of the upgrade would be
4999 impossible. This relaxed restriction means that both new
5000 packages can be unpacked together and then configured in their
5001 dependency order.
5002 </footnote>
5003 </p>
5006 If there is a circular dependency among packages being installed
5007 or removed, installation or removal order honoring the
5008 dependency order is impossible, requiring the dependency loop be
5009 broken at some point and the dependency requirements violated
5010 for at least one package. Packages involved in circular
5011 dependencies may not be able to rely on their dependencies being
5012 configured before they themselves are configured, depending on
5013 which side of the break of the circular dependency loop they
5014 happen to be on. If one of the packages in the loop has
5015 no <prgn>postinst</prgn> script, then the cycle will be broken
5016 at that package; this ensures that all <prgn>postinst</prgn>
5017 scripts are run with their dependencies properly configured if
5018 this is possible. Otherwise the breaking point is arbitrary.
5019 Packages should therefore avoid circular dependencies where
5020 possible, particularly if they have <prgn>postinst</prgn>
5021 scripts.
5022 </p>
5025 The meaning of the five dependency fields is as follows:
5026 <taglist>
5027 <tag><tt>Depends</tt></tag>
5028 <item>
5030 This declares an absolute dependency. A package will
5031 not be configured unless all of the packages listed in
5032 its <tt>Depends</tt> field have been correctly
5033 configured (unless there is a circular dependency as
5034 described above).
5035 </p>
5038 The <tt>Depends</tt> field should be used if the
5039 depended-on package is required for the depending
5040 package to provide a significant amount of
5041 functionality.
5042 </p>
5045 The <tt>Depends</tt> field should also be used if the
5046 <prgn>postinst</prgn> or <prgn>prerm</prgn> scripts
5047 require the depended-on package to be unpacked or
5048 configured in order to run. In the case of <tt>postinst
5049 configure</tt>, the depended-on packages will be unpacked
5050 and configured first. (If both packages are involved in a
5051 dependency loop, this might not work as expected; see the
5052 explanation a few paragraphs back.) In the case
5053 of <prgn>prerm</prgn> or other <prgn>postinst</prgn>
5054 actions, the package dependencies will normally be at
5055 least unpacked, but they may be only "Half-Installed" if a
5056 previous upgrade of the dependency failed.
5057 </p>
5060 Finally, the <tt>Depends</tt> field should be used if the
5061 depended-on package is needed by the <prgn>postrm</prgn>
5062 script to fully clean up after the package removal. There
5063 is no guarantee that package dependencies will be
5064 available when <prgn>postrm</prgn> is run, but the
5065 depended-on package is more likely to be available if the
5066 package declares a dependency (particularly in the case
5067 of <tt>postrm remove</tt>). The <prgn>postrm</prgn>
5068 script must gracefully skip actions that require a
5069 dependency if that dependency isn't available.
5070 </p>
5071 </item>
5073 <tag><tt>Recommends</tt></tag>
5074 <item>
5076 This declares a strong, but not absolute, dependency.
5077 </p>
5080 The <tt>Recommends</tt> field should list packages
5081 that would be found together with this one in all but
5082 unusual installations.
5083 </p>
5084 </item>
5086 <tag><tt>Suggests</tt></tag>
5087 <item>
5088 This is used to declare that one package may be more
5089 useful with one or more others. Using this field
5090 tells the packaging system and the user that the
5091 listed packages are related to this one and can
5092 perhaps enhance its usefulness, but that installing
5093 this one without them is perfectly reasonable.
5094 </item>
5096 <tag><tt>Enhances</tt></tag>
5097 <item>
5098 This field is similar to Suggests but works in the
5099 opposite direction. It is used to declare that a
5100 package can enhance the functionality of another
5101 package.
5102 </item>
5104 <tag><tt>Pre-Depends</tt></tag>
5105 <item>
5107 This field is like <tt>Depends</tt>, except that it
5108 also forces <prgn>dpkg</prgn> to complete installation
5109 of the packages named before even starting the
5110 installation of the package which declares the
5111 pre-dependency, as follows:
5112 </p>
5115 When a package declaring a pre-dependency is about to
5116 be <em>unpacked</em> the pre-dependency can be
5117 satisfied if the depended-on package is either fully
5118 configured, <em>or even if</em> the depended-on
5119 package(s) are only in the "Unpacked" or the "Half-Configured"
5120 state, provided that they have been configured
5121 correctly at some point in the past (and not removed
5122 or partially removed since). In this case, both the
5123 previously-configured and currently "Unpacked" or
5124 "Half-Configured" versions must satisfy any version
5125 clause in the <tt>Pre-Depends</tt> field.
5126 </p>
5129 When the package declaring a pre-dependency is about to
5130 be <em>configured</em>, the pre-dependency will be treated
5131 as a normal <tt>Depends</tt>. It will be considered
5132 satisfied only if the depended-on package has been
5133 correctly configured. However, unlike
5134 with <tt>Depends</tt>, <tt>Pre-Depends</tt> does not
5135 permit circular dependencies to be broken. If a circular
5136 dependency is encountered while attempting to honor
5137 <tt>Pre-Depends</tt>, the installation will be aborted.
5138 </p>
5141 <tt>Pre-Depends</tt> are also required if the
5142 <prgn>preinst</prgn> script depends on the named package.
5143 It is best to avoid this situation if possible.
5144 </p>
5147 <tt>Pre-Depends</tt> should be used sparingly,
5148 preferably only by packages whose premature upgrade or
5149 installation would hamper the ability of the system to
5150 continue with any upgrade that might be in progress.
5151 </p>
5154 You should not specify a <tt>Pre-Depends</tt> entry for a
5155 package before this has been discussed on the
5156 <tt>debian-devel</tt> mailing list and a consensus about
5157 doing that has been reached. See <ref id="dependencies">.
5158 </p>
5159 </item>
5160 </taglist>
5161 </p>
5164 When selecting which level of dependency to use you should
5165 consider how important the depended-on package is to the
5166 functionality of the one declaring the dependency. Some
5167 packages are composed of components of varying degrees of
5168 importance. Such a package should list using
5169 <tt>Depends</tt> the package(s) which are required by the
5170 more important components. The other components'
5171 requirements may be mentioned as Suggestions or
5172 Recommendations, as appropriate to the components' relative
5173 importance.
5174 </p>
5175 </sect>
5177 <sect id="breaks">
5178 <heading>Packages which break other packages - <tt>Breaks</tt></heading>
5181 When one binary package declares that it breaks another,
5182 <prgn>dpkg</prgn> will refuse to allow the package which
5183 declares <tt>Breaks</tt> to be unpacked unless the broken
5184 package is deconfigured first, and it will refuse to
5185 allow the broken package to be reconfigured.
5186 </p>
5189 A package will not be regarded as causing breakage merely
5190 because its configuration files are still installed; it must
5191 be at least "Half-Installed".
5192 </p>
5195 A special exception is made for packages which declare that
5196 they break their own package name or a virtual package which
5197 they provide (see below): this does not count as a real
5198 breakage.
5199 </p>
5202 Normally a <tt>Breaks</tt> entry will have an "earlier than"
5203 version clause; such a <tt>Breaks</tt> is introduced in the
5204 version of an (implicit or explicit) dependency which violates
5205 an assumption or reveals a bug in earlier versions of the broken
5206 package, or which takes over a file from earlier versions of the
5207 package named in <tt>Breaks</tt>. This use of <tt>Breaks</tt>
5208 will inform higher-level package management tools that the
5209 broken package must be upgraded before the new one.
5210 </p>
5213 If the breaking package also overwrites some files from the
5214 older package, it should use <tt>Replaces</tt> to ensure this
5215 goes smoothly. See <ref id="replaces"> for a full discussion
5216 of taking over files from other packages, including how to
5217 use <tt>Breaks</tt> in those cases.
5218 </p>
5221 Many of the cases where <tt>Breaks</tt> should be used were
5222 previously handled with <tt>Conflicts</tt>
5223 because <tt>Breaks</tt> did not yet exist.
5224 Many <tt>Conflicts</tt> fields should now be <tt>Breaks</tt>.
5225 See <ref id="conflicts"> for more information about the
5226 differences.
5227 </p>
5228 </sect>
5230 <sect id="conflicts">
5231 <heading>Conflicting binary packages - <tt>Conflicts</tt></heading>
5234 When one binary package declares a conflict with another using
5235 a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will refuse to
5236 allow them to be unpacked on the system at the same time. This
5237 is a stronger restriction than <tt>Breaks</tt>, which prevents
5238 the broken package from being configured while the breaking
5239 package is in the "Unpacked" state but allows both packages to
5240 be unpacked at the same time.
5241 </p>
5244 If one package is to be unpacked, the other must be removed
5245 first. If the package being unpacked is marked as replacing
5246 (see <ref id="replaces">, but note that <tt>Breaks</tt> should
5247 normally be used in this case) the one on the system, or the one
5248 on the system is marked as deselected, or both packages are
5249 marked <tt>Essential</tt>, then <prgn>dpkg</prgn> will
5250 automatically remove the package which is causing the conflict.
5251 Otherwise, it will halt the installation of the new package with
5252 an error. This mechanism is specifically designed to produce an
5253 error when the installed package is <tt>Essential</tt>, but the
5254 new package is not.
5255 </p>
5258 A package will not cause a conflict merely because its
5259 configuration files are still installed; it must be at least
5260 "Half-Installed".
5261 </p>
5264 A special exception is made for packages which declare a
5265 conflict with their own package name, or with a virtual
5266 package which they provide (see below): this does not
5267 prevent their installation, and allows a package to conflict
5268 with others providing a replacement for it. You use this
5269 feature when you want the package in question to be the only
5270 package providing some feature.
5271 </p>
5274 Normally, <tt>Breaks</tt> should be used instead
5275 of <tt>Conflicts</tt> since <tt>Conflicts</tt> imposes a
5276 stronger restriction on the ordering of package installation or
5277 upgrade and can make it more difficult for the package manager
5278 to find a correct solution to an upgrade or installation
5279 problem. <tt>Breaks</tt> should be used
5280 <list>
5281 <item>when moving a file from one package to another (see
5282 <ref id="replaces">),</item>
5283 <item>when splitting a package (a special case of the previous
5284 one), or</item>
5285 <item>when the breaking package exposes a bug in or interacts
5286 badly with particular versions of the broken
5287 package.</item>
5288 </list>
5289 <tt>Conflicts</tt> should be used
5290 <list>
5291 <item>when two packages provide the same file and will
5292 continue to do so,</item>
5293 <item>in conjunction with <tt>Provides</tt> when only one
5294 package providing a given virtual facility may be unpacked
5295 at a time (see <ref id="virtual">),</item>
5296 <item>in other cases where one must prevent simultaneous
5297 installation of two packages for reasons that are ongoing
5298 (not fixed in a later version of one of the packages) or
5299 that must prevent both packages from being unpacked at the
5300 same time, not just configured.</item>
5301 </list>
5302 Be aware that adding <tt>Conflicts</tt> is normally not the best
5303 solution when two packages provide the same files. Depending on
5304 the reason for that conflict, using alternatives or renaming the
5305 files is often a better approach. See, for
5306 example, <ref id="binaries">.
5307 </p>
5310 Neither <tt>Breaks</tt> nor <tt>Conflicts</tt> should be used
5311 unless two packages cannot be installed at the same time or
5312 installing them both causes one of them to be broken or
5313 unusable. Having similar functionality or performing the same
5314 tasks as another package is not sufficient reason to
5315 declare <tt>Breaks</tt> or <tt>Conflicts</tt> with that package.
5316 </p>
5319 A <tt>Conflicts</tt> entry may have an "earlier than" version
5320 clause if the reason for the conflict is corrected in a later
5321 version of one of the packages. However, normally the presence
5322 of an "earlier than" version clause is a sign
5323 that <tt>Breaks</tt> should have been used instead. An "earlier
5324 than" version clause in <tt>Conflicts</tt>
5325 prevents <prgn>dpkg</prgn> from upgrading or installing the
5326 package which declares such a conflict until the upgrade or
5327 removal of the conflicted-with package has been completed, which
5328 is a strong restriction.
5329 </p>
5330 </sect>
5332 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
5333 </heading>
5336 As well as the names of actual ("concrete") packages, the
5337 package relationship fields <tt>Depends</tt>,
5338 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
5339 <tt>Pre-Depends</tt>, <tt>Breaks</tt>, <tt>Conflicts</tt>,
5340 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
5341 <tt>Build-Depends-Arch</tt>, <tt>Build-Conflicts</tt>,
5342 <tt>Build-Conflicts-Indep</tt> and <tt>Build-Conflicts-Arch</tt>
5343 may mention "virtual packages".
5344 </p>
5347 A <em>virtual package</em> is one which appears in the
5348 <tt>Provides</tt> control field of another package. The effect
5349 is as if the package(s) which provide a particular virtual
5350 package name had been listed by name everywhere the virtual
5351 package name appears. (See also <ref id="virtual_pkg">)
5352 </p>
5355 If there are both concrete and virtual packages of the same
5356 name, then the dependency may be satisfied (or the conflict
5357 caused) by either the concrete package with the name in
5358 question or any other concrete package which provides the
5359 virtual package with the name in question. This is so that,
5360 for example, supposing we have
5361 <example compact="compact">
5362 Package: foo
5363 Depends: bar
5364 </example> and someone else releases an enhanced version of
5365 the <tt>bar</tt> package they can say:
5366 <example compact="compact">
5367 Package: bar-plus
5368 Provides: bar
5369 </example>
5370 and the <tt>bar-plus</tt> package will now also satisfy the
5371 dependency for the <tt>foo</tt> package.
5372 </p>
5375 If a relationship field has a version number attached, only real
5376 packages will be considered to see whether the relationship is
5377 satisfied (or the prohibition violated, for a conflict or
5378 breakage). In other words, if a version number is specified,
5379 this is a request to ignore all <tt>Provides</tt> for that
5380 package name and consider only real packages. The package
5381 manager will assume that a package providing that virtual
5382 package is not of the "right" version. A <tt>Provides</tt>
5383 field may not contain version numbers, and the version number of
5384 the concrete package which provides a particular virtual package
5385 will not be considered when considering a dependency on or
5386 conflict with the virtual package name.<footnote>
5387 It is possible that a future release of <prgn>dpkg</prgn> may
5388 add the ability to specify a version number for each virtual
5389 package it provides. This feature is not yet present,
5390 however, and is expected to be used only infrequently.
5391 </footnote>
5392 </p>
5395 To specify which of a set of real packages should be the default
5396 to satisfy a particular dependency on a virtual package, list
5397 the real package as an alternative before the virtual one.
5398 </p>
5401 If the virtual package represents a facility that can only be
5402 provided by one real package at a time, such as
5403 the <package>mail-transport-agent</package> virtual package that
5404 requires installation of a binary that would conflict with all
5405 other providers of that virtual package (see
5406 <ref id="mail-transport-agents">), all packages providing that
5407 virtual package should also declare a conflict with it
5408 using <tt>Conflicts</tt>. This will ensure that at most one
5409 provider of that virtual package is unpacked or installed at a
5410 time.
5411 </p>
5412 </sect>
5414 <sect id="replaces"><heading>Overwriting files and replacing
5415 packages - <tt>Replaces</tt></heading>
5418 Packages can declare in their control file that they should
5419 overwrite files in certain other packages, or completely replace
5420 other packages. The <tt>Replaces</tt> control field has these
5421 two distinct purposes.
5422 </p>
5424 <sect1><heading>Overwriting files in other packages</heading>
5427 It is usually an error for a package to contain files which
5428 are on the system in another package. However, if the
5429 overwriting package declares that it <tt>Replaces</tt> the one
5430 containing the file being overwritten, then <prgn>dpkg</prgn>
5431 will replace the file from the old package with that from the
5432 new. The file will no longer be listed as "owned" by the old
5433 package and will be taken over by the new package.
5434 Normally, <tt>Breaks</tt> should be used in conjunction
5435 with <tt>Replaces</tt>.<footnote>
5436 To see why <tt>Breaks</tt> is normally needed in addition
5437 to <tt>Replaces</tt>, consider the case of a file in the
5438 package <package>foo</package> being taken over by the
5439 package <package>foo-data</package>.
5440 <tt>Replaces</tt> will allow <package>foo-data</package> to
5441 be installed and take over that file. However,
5442 without <tt>Breaks</tt>, nothing
5443 requires <package>foo</package> to be upgraded to a newer
5444 version that knows it does not include that file and instead
5445 depends on <package>foo-data</package>. Nothing would
5446 prevent the new <package>foo-data</package> package from
5447 being installed and then removed, removing the file that it
5448 took over from <package>foo</package>. After that
5449 operation, the package manager would think the system was in
5450 a consistent state, but the <package>foo</package> package
5451 would be missing one of its files.
5452 </footnote>
5453 </p>
5456 For example, if a package <package>foo</package> is split
5457 into <package>foo</package> and <package>foo-data</package>
5458 starting at version 1.2-3, <package>foo-data</package> would
5459 have the fields
5460 <example compact="compact">
5461 Replaces: foo (&lt;&lt; 1.2-3)
5462 Breaks: foo (&lt;&lt; 1.2-3)
5463 </example>
5464 in its control file. The new version of the
5465 package <package>foo</package> would normally have the field
5466 <example compact="compact">
5467 Depends: foo-data (&gt;= 1.2-3)
5468 </example>
5469 (or possibly <tt>Recommends</tt> or even <tt>Suggests</tt> if
5470 the files moved into <package>foo-data</package> are not
5471 required for normal operation).
5472 </p>
5475 If a package is completely replaced in this way, so that
5476 <prgn>dpkg</prgn> does not know of any files it still
5477 contains, it is considered to have "disappeared". It will
5478 be marked as not wanted on the system (selected for
5479 removal) and "Not-Installed". Any <tt>conffile</tt>s
5480 details noted for the package will be ignored, as they
5481 will have been taken over by the overwriting package. The
5482 package's <prgn>postrm</prgn> script will be run with a
5483 special argument to allow the package to do any final
5484 cleanup required. See <ref id="mscriptsinstact">.
5485 <footnote>
5486 Replaces is a one way relationship. You have to install
5487 the replacing package after the replaced package.
5488 </footnote>
5489 </p>
5492 For this usage of <tt>Replaces</tt>, virtual packages (see
5493 <ref id="virtual">) are not considered when looking at a
5494 <tt>Replaces</tt> field. The packages declared as being
5495 replaced must be mentioned by their real names.
5496 </p>
5499 This usage of <tt>Replaces</tt> only takes effect when both
5500 packages are at least partially on the system at once. It is
5501 not relevant if the packages conflict unless the conflict has
5502 been overridden.
5503 </p>
5504 </sect1>
5506 <sect1><heading>Replacing whole packages, forcing their
5507 removal</heading>
5510 Second, <tt>Replaces</tt> allows the packaging system to
5511 resolve which package should be removed when there is a
5512 conflict (see <ref id="conflicts">). This usage only takes
5513 effect when the two packages <em>do</em> conflict, so that the
5514 two usages of this field do not interfere with each other.
5515 </p>
5518 In this situation, the package declared as being replaced
5519 can be a virtual package, so for example, all mail
5520 transport agents (MTAs) would have the following fields in
5521 their control files:
5522 <example compact="compact">
5523 Provides: mail-transport-agent
5524 Conflicts: mail-transport-agent
5525 Replaces: mail-transport-agent
5526 </example>
5527 ensuring that only one MTA can be unpacked at any one
5528 time. See <ref id="virtual"> for more information about this
5529 example.
5530 </sect1>
5531 </sect>
5533 <sect id="sourcebinarydeps">
5534 <heading>Relationships between source and binary packages -
5535 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
5536 <tt>Build-Depends-Arch</tt>, <tt>Build-Conflicts</tt>,
5537 <tt>Build-Conflicts-Indep</tt>, <tt>Build-Conflicts-Arch</tt>
5538 </heading>
5541 Source packages that require certain binary packages to be
5542 installed or absent at the time of building the package
5543 can declare relationships to those binary packages.
5544 </p>
5547 This is done using the <tt>Build-Depends</tt>,
5548 <tt>Build-Depends-Indep</tt>, <tt>Build-Depends-Arch</tt>,
5549 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt> and
5550 <tt>Build-Conflicts-Arch</tt> control fields.
5551 </p>
5554 Build-dependencies on "build-essential" binary packages can be
5555 omitted. Please see <ref id="pkg-relations"> for more information.
5556 </p>
5559 The dependencies and conflicts they define must be satisfied
5560 (as defined earlier for binary packages) in order to invoke
5561 the targets in <tt>debian/rules</tt>, as follows:
5562 <taglist>
5563 <tag><tt>clean</tt></tag>
5564 <item>
5565 Only the <tt>Build-Depends</tt> and <tt>Build-Conflicts</tt>
5566 fields must be satisfied when this target is invoked.
5567 </item>
5568 <tag><tt>build-arch</tt>, and <tt>binary-arch</tt></tag>
5569 <item>
5570 The <tt>Build-Depends</tt>, <tt>Build-Conflicts</tt>,
5571 <tt>Build-Depends-Arch</tt>, and <tt>Build-Conflicts-Arch</tt>
5572 fields must be satisfied when these targets are invoked.
5573 </item>
5574 <tag><tt>build-indep</tt>, and <tt>binary-indep</tt></tag>
5575 <item>
5576 The <tt>Build-Depends</tt>, <tt>Build-Conflicts</tt>,
5577 <tt>Build-Depends-Indep</tt>, and <tt>Build-Conflicts-Indep</tt>
5578 fields must be satisfied when these targets are invoked.
5579 </item>
5580 <tag><tt>build</tt> and <tt>binary</tt></tag>
5581 <item>
5582 The <tt>Build-Depends</tt>, <tt>Build-Conflicts</tt>,
5583 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt>,
5584 <tt>Build-Depends-Arch</tt>, and <tt>Build-Conflicts-Arch</tt>
5585 fields must be satisfied when these targets are invoked.
5586 </item>
5587 </taglist>
5588 </p>
5589 </sect>
5591 <sect id="built-using">
5592 <heading>Additional source packages used to build the binary
5593 - <tt>Built-Using</tt>
5594 </heading>
5597 Some binary packages incorporate parts of other packages when built
5598 but do not have to depend on those packages. Examples include
5599 linking with static libraries or incorporating source code from
5600 another package during the build. In this case, the source packages
5601 of those other packages are a required part of the complete source
5602 (the binary package is not reproducible without them).
5603 </p>
5606 A <tt>Built-Using</tt> field must list the corresponding source
5607 package for any such binary package incorporated during the build
5608 <footnote>
5609 <tt>Build-Depends</tt> in the source package is not adequate since
5610 it (rightfully) does not document the exact version used in the
5611 build.
5612 </footnote>,
5613 including an "exactly equal" ("=") version relation on the version
5614 that was used to build that binary package<footnote>
5615 The archive software might reject packages that refer to
5616 non-existent sources.
5617 </footnote>.
5618 </p>
5621 A package using the source code from the gcc-4.6-source
5622 binary package built from the gcc-4.6 source package would
5623 have this field in its control file:
5624 <example compact="compact">
5625 Built-Using: gcc-4.6 (= 4.6.0-11)
5626 </example>
5627 </p>
5630 A package including binaries from grub2 and loadlin would
5631 have this field in its control file:
5632 <example compact="compact">
5633 Built-Using: grub2 (= 1.99-9), loadlin (= 1.6e-1)
5634 </example>
5635 </p>
5636 </sect>
5637 </chapt>
5640 <chapt id="sharedlibs"><heading>Shared libraries</heading>
5643 Packages containing shared libraries must be constructed with
5644 a little care to make sure that the shared library is always
5645 available. This is especially important for packages whose
5646 shared libraries are vitally important, such as the C library
5647 (currently <tt>libc6</tt>).
5648 </p>
5651 This section deals only with public shared libraries: shared
5652 libraries that are placed in directories searched by the dynamic
5653 linker by default or which are intended to be linked against
5654 normally and possibly used by other, independent packages. Shared
5655 libraries that are internal to a particular package or that are
5656 only loaded as dynamic modules are not covered by this section and
5657 are not subject to its requirements.
5658 </p>
5661 A shared library is identified by the <tt>SONAME</tt> attribute
5662 stored in its dynamic section. When a binary is linked against a
5663 shared library, the <tt>SONAME</tt> of the shared library is
5664 recorded in the binary's <tt>NEEDED</tt> section so that the
5665 dynamic linker knows that library must be loaded at runtime. The
5666 shared library file's full name (which usually contains additional
5667 version information not needed in the <tt>SONAME</tt>) is
5668 therefore normally not referenced directly. Instead, the shared
5669 library is loaded by its <tt>SONAME</tt>, which exists on the file
5670 system as a symlink pointing to the full name of the shared
5671 library. This symlink must be provided by the
5672 package. <ref id="sharedlibs-runtime"> describes how to do this.
5673 <footnote>
5674 This is a convention of shared library versioning, but not a
5675 requirement. Some libraries use the <tt>SONAME</tt> as the full
5676 library file name instead and therefore do not need a symlink.
5677 Most, however, encode additional information about
5678 backwards-compatible revisions as a minor version number in the
5679 file name. The <tt>SONAME</tt> itself only changes when
5680 binaries linked with the earlier version of the shared library
5681 may no longer work, but the filename may change with each
5682 release of the library. See <ref id="sharedlibs-runtime"> for
5683 more information.
5684 </footnote>
5685 </p>
5688 When linking a binary or another shared library against a shared
5689 library, the <tt>SONAME</tt> for that shared library is not yet
5690 known. Instead, the shared library is found by looking for a file
5691 matching the library name with <tt>.so</tt> appended. This file
5692 exists on the file system as a symlink pointing to the shared
5693 library.
5694 </p>
5697 Shared libraries are normally split into several binary packages.
5698 The <tt>SONAME</tt> symlink is installed by the runtime shared
5699 library package, and the bare <tt>.so</tt> symlink is installed in
5700 the development package since it's only used when linking binaries
5701 or shared libraries. However, there are some exceptions for
5702 unusual shared libraries or for shared libraries that are also
5703 loaded as dynamic modules by other programs.
5704 </p>
5707 This section is primarily concerned with how the separation of
5708 shared libraries into multiple packages should be done and how
5709 dependencies on and between shared library binary packages are
5710 managed in Debian. <ref id="libraries"> should be read in
5711 conjunction with this section and contains additional rules for
5712 the files contained in the shared library packages.
5713 </p>
5715 <sect id="sharedlibs-runtime">
5716 <heading>Run-time shared libraries</heading>
5719 The run-time shared library must be placed in a package
5720 whose name changes whenever the <tt>SONAME</tt> of the shared
5721 library changes. This allows several versions of the shared
5722 library to be installed at the same time, allowing installation
5723 of the new version of the shared library without immediately
5724 breaking binaries that depend on the old version. Normally, the
5725 run-time shared library and its <tt>SONAME</tt> symlink should
5726 be placed in a package named
5727 <package><var>libraryname</var><var>soversion</var></package>,
5728 where <var>soversion</var> is the version number in
5729 the <tt>SONAME</tt> of the shared library. Alternatively, if it
5730 would be confusing to directly append <var>soversion</var>
5731 to <var>libraryname</var> (if, for
5732 example, <var>libraryname</var> itself ends in a number), you
5733 should use
5734 <package><var>libraryname</var>-<var>soversion</var></package>
5735 instead.
5736 </p>
5739 To determine the <var>soversion</var>, look at
5740 the <tt>SONAME</tt> of the library, stored in the
5741 ELF <tt>SONAME</tt> attribute. It is usually of the
5742 form <tt><var>name</var>.so.<var>major-version</var></tt> (for
5743 example, <tt>libz.so.1</tt>). The version part is the part
5744 which comes after <tt>.so.</tt>, so in that example it
5745 is <tt>1</tt>. The soname may instead be of the
5746 form <tt><var>name</var>-<var>major-version</var>.so</tt>, such
5747 as <tt>libdb-5.1.so</tt>, in which case the name would
5748 be <tt>libdb</tt> and the version would be <tt>5.1</tt>.
5749 </p>
5752 If you have several shared libraries built from the same source
5753 tree, you may lump them all together into a single shared
5754 library package provided that all of their <tt>SONAME</tt>s will
5755 always change together. Be aware that this is not normally the
5756 case, and if the <tt>SONAME</tt>s do not change together,
5757 upgrading such a merged shared library package will be
5758 unnecessarily difficult because of file conflicts with the old
5759 version of the package. When in doubt, always split shared
5760 library packages so that each binary package installs a single
5761 shared library.
5762 </p>
5765 Every time the shared library ABI changes in a way that may
5766 break binaries linked against older versions of the shared
5767 library, the <tt>SONAME</tt> of the library and the
5768 corresponding name for the binary package containing the runtime
5769 shared library should change. Normally, this means
5770 the <tt>SONAME</tt> should change any time an interface is
5771 removed from the shared library or the signature of an interface
5772 (the number of parameters or the types of parameters that it
5773 takes, for example) is changed. This practice is vital to
5774 allowing clean upgrades from older versions of the package and
5775 clean transitions between the old ABI and new ABI without having
5776 to upgrade every affected package simultaneously.
5777 </p>
5780 The <tt>SONAME</tt> and binary package name need not, and indeed
5781 normally should not, change if new interfaces are added but none
5782 are removed or changed, since this will not break binaries
5783 linked against the old shared library. Correct versioning of
5784 dependencies on the newer shared library by binaries that use
5785 the new interfaces is handled via
5786 the <qref id="sharedlibs-depends"><tt>symbols</tt>
5787 or <tt>shlibs</tt> system</qref>.
5788 </p>
5791 The package should install the shared libraries under
5792 their normal names. For example, the <package>libgdbm3</package>
5793 package should install <file>libgdbm.so.3.0.0</file> as
5794 <file>/usr/lib/libgdbm.so.3.0.0</file>. The files should not be
5795 renamed or re-linked by any <prgn>prerm</prgn> or
5796 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
5797 of renaming things safely without affecting running programs,
5798 and attempts to interfere with this are likely to lead to
5799 problems.
5800 </p>
5803 Shared libraries should not be installed executable, since
5804 the dynamic linker does not require this and trying to
5805 execute a shared library usually results in a core dump.
5806 </p>
5809 The run-time library package should include the symbolic link for
5810 the <tt>SONAME</tt> that <prgn>ldconfig</prgn> would create for
5811 the shared libraries. For example,
5812 the <package>libgdbm3</package> package should include a symbolic
5813 link from <file>/usr/lib/libgdbm.so.3</file> to
5814 <file>libgdbm.so.3.0.0</file>. This is needed so that the dynamic
5815 linker (for example <prgn>ld.so</prgn> or
5816 <prgn>ld-linux.so.*</prgn>) can find the library between the
5817 time that <prgn>dpkg</prgn> installs it and the time that
5818 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
5819 script.<footnote>
5820 The package management system requires the library to be
5821 placed before the symbolic link pointing to it in the
5822 <file>.deb</file> file. This is so that when
5823 <prgn>dpkg</prgn> comes to install the symlink
5824 (overwriting the previous symlink pointing at an older
5825 version of the library), the new shared library is already
5826 in place. In the past, this was achieved by creating the
5827 library in the temporary packaging directory before
5828 creating the symlink. Unfortunately, this was not always
5829 effective, since the building of the tar file in the
5830 <file>.deb</file> depended on the behavior of the underlying
5831 file system. Some file systems (such as reiserfs) reorder
5832 the files so that the order of creation is forgotten.
5833 Since version 1.7.0, <prgn>dpkg</prgn>
5834 reorders the files itself as necessary when building a
5835 package. Thus it is no longer important to concern
5836 oneself with the order of file creation.
5837 </footnote>
5838 </p>
5840 <sect1 id="ldconfig">
5841 <heading><tt>ldconfig</tt></heading>
5844 Any package installing shared libraries in one of the default
5845 library directories of the dynamic linker (which are currently
5846 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
5847 listed in <file>/etc/ld.so.conf</file><footnote>
5848 These are currently <file>/usr/local/lib</file> plus
5849 directories under <file>/lib</file> and <file>/usr/lib</file>
5850 matching the multiarch triplet for the system architecture.
5851 </footnote>
5852 must use <prgn>ldconfig</prgn> to update the shared library
5853 system.
5854 </p>
5857 The package maintainer scripts must only call
5858 <prgn>ldconfig</prgn> under these circumstances:
5859 <list compact="compact">
5860 <item>When the <prgn>postinst</prgn> script is run with a
5861 first argument of <tt>configure</tt>, the script must call
5862 <prgn>ldconfig</prgn>, and may optionally invoke
5863 <prgn>ldconfig</prgn> at other times.
5864 </item>
5865 <item>When the <prgn>postrm</prgn> script is run with a
5866 first argument of <tt>remove</tt>, the script should call
5867 <prgn>ldconfig</prgn>.
5868 </item>
5869 </list>
5870 <footnote>
5872 During install or upgrade, the preinst is called before
5873 the new files are unpacked, so calling "ldconfig" is
5874 pointless. The preinst of an existing package can also be
5875 called if an upgrade fails. However, this happens during
5876 the critical time when a shared libs may exist on-disk
5877 under a temporary name. Thus, it is dangerous and
5878 forbidden by current policy to call "ldconfig" at this
5879 time.
5880 </p>
5883 When a package is installed or upgraded, "postinst
5884 configure" runs after the new files are safely on-disk.
5885 Since it is perfectly safe to invoke ldconfig
5886 unconditionally in a postinst, it is OK for a package to
5887 simply put ldconfig in its postinst without checking the
5888 argument. The postinst can also be called to recover from
5889 a failed upgrade. This happens before any new files are
5890 unpacked, so there is no reason to call "ldconfig" at this
5891 point.
5892 </p>
5895 For a package that is being removed, prerm is
5896 called with all the files intact, so calling ldconfig is
5897 useless. The other calls to "prerm" happen in the case of
5898 upgrade at a time when all the files of the old package
5899 are on-disk, so again calling "ldconfig" is pointless.
5900 </p>
5903 postrm, on the other hand, is called with the "remove"
5904 argument just after the files are removed, so this is
5905 the proper time to call "ldconfig" to notify the system
5906 of the fact that the shared libraries from the package
5907 are removed. The postrm can be called at several other
5908 times. At the time of "postrm purge", "postrm
5909 abort-install", or "postrm abort-upgrade", calling
5910 "ldconfig" is useless because the shared lib files are
5911 not on-disk. However, when "postrm" is invoked with
5912 arguments "upgrade", "failed-upgrade", or "disappear", a
5913 shared lib may exist on-disk under a temporary filename.
5914 </p>
5915 </footnote>
5916 </p>
5917 </sect1>
5919 </sect>
5921 <sect id="sharedlibs-support-files">
5922 <heading>Shared library support files</heading>
5925 If your package contains files whose names do not change with
5926 each change in the library shared object version, you must not
5927 put them in the shared library package. Otherwise, several
5928 versions of the shared library cannot be installed at the same
5929 time without filename clashes, making upgrades and transitions
5930 unnecessarily difficult.
5931 </p>
5934 It is recommended that supporting files and run-time support
5935 programs that do not need to be invoked manually by users, but
5936 are nevertheless required for the package to function, be placed
5937 (if they are binary) in a subdirectory of <file>/usr/lib</file>,
5938 preferably under <file>/usr/lib/</file><var>package-name</var>.
5939 If the program or file is architecture independent, the
5940 recommendation is for it to be placed in a subdirectory of
5941 <file>/usr/share</file> instead, preferably under
5942 <file>/usr/share/</file><var>package-name</var>. Following the
5943 <var>package-name</var> naming convention ensures that the file
5944 names change when the shared object version changes.
5945 </p>
5948 Run-time support programs that use the shared library but are
5949 not required for the library to function or files used by the
5950 shared library that can be used by any version of the shared
5951 library package should instead be put in a separate package.
5952 This package might typically be named
5953 <package><var>libraryname</var>-tools</package>; note the
5954 absence of the <var>soversion</var> in the package name.
5955 </p>
5958 Files and support programs only useful when compiling software
5959 against the library should be included in the development
5960 package for the library.<footnote>
5961 For example, a <file><var>package-name</var>-config</file>
5962 script or <package>pkg-config</package> configuration files.
5963 </footnote>
5964 </p>
5965 </sect>
5967 <sect id="sharedlibs-static">
5968 <heading>Static libraries</heading>
5971 The static library (<file><var>libraryname.a</var></file>)
5972 is usually provided in addition to the shared version.
5973 It is placed into the development package (see below).
5974 </p>
5977 In some cases, it is acceptable for a library to be
5978 available in static form only; these cases include:
5979 <list>
5980 <item>libraries for languages whose shared library support
5981 is immature or unstable</item>
5982 <item>libraries whose interfaces are in flux or under
5983 development (commonly the case when the library's
5984 major version number is zero, or where the ABI breaks
5985 across patchlevels)</item>
5986 <item>libraries which are explicitly intended to be
5987 available only in static form by their upstream
5988 author(s)</item>
5989 </list>
5990 </p>
5992 <sect id="sharedlibs-dev">
5993 <heading>Development files</heading>
5996 If there are development files associated with a shared library,
5997 the source package needs to generate a binary development package
5998 named <package><var>libraryname</var><var>soversion</var>-dev</package>,
5999 or if you prefer only to support one development version at a
6000 time, <package><var>libraryname</var>-dev</package>. Installing
6001 the development package must result in installation of all the
6002 development files necessary for compiling programs against that
6003 shared library.<footnote>
6004 This wording allows the development files to be split into
6005 several packages, such as a separate architecture-independent
6006 <package><var>libraryname</var>-headers</package>, provided that
6007 the development package depends on all the required additional
6008 packages.
6009 </footnote>
6010 </p>
6013 In case several development versions of a library exist, you may
6014 need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
6015 <ref id="conflicts">) to ensure that the user only installs one
6016 development version at a time (as different development versions are
6017 likely to have the same header files in them, which would cause a
6018 filename clash if both were unpacked).
6019 </p>
6022 The development package should contain a symlink for the associated
6023 shared library without a version number. For example, the
6024 <package>libgdbm-dev</package> package should include a symlink
6025 from <file>/usr/lib/libgdbm.so</file> to
6026 <file>libgdbm.so.3.0.0</file>. This symlink is needed by the linker
6027 (<prgn>ld</prgn>) when compiling packages, as it will only look for
6028 <file>libgdbm.so</file> when compiling dynamically.
6029 </p>
6032 If the package provides Ada Library Information
6033 (<file>*.ali</file>) files for use with GNAT, these files must be
6034 installed read-only (mode 0444) so that GNAT will not attempt to
6035 recompile them. This overrides the normal file mode requirements
6036 given in <ref id="permissions-owners">.
6037 </p>
6038 </sect>
6040 <sect id="sharedlibs-intradeps">
6041 <heading>Dependencies between the packages of the same library</heading>
6044 Typically the development version should have an exact
6045 version dependency on the runtime library, to make sure that
6046 compilation and linking happens correctly. The
6047 <tt>${binary:Version}</tt> substitution variable can be
6048 useful for this purpose.
6049 <footnote>
6050 Previously, <tt>${Source-Version}</tt> was used, but its name
6051 was confusing and it has been deprecated since dpkg 1.13.19.
6052 </footnote>
6053 </p>
6054 </sect>
6056 <sect id="sharedlibs-depends">
6057 <heading>Dependencies between the library and other
6058 packages</heading>
6061 If a package contains a binary or library which links to a
6062 shared library, we must ensure that, when the package is
6063 installed on the system, all of the libraries needed are also
6064 installed. These dependencies must be added to the binary
6065 package when it is built, since they may change based on which
6066 version of a shared library the binary or library was linked
6067 with even if there are no changes to the source of the binary
6068 (for example, symbol versions change, macros become functions or
6069 vice versa, or the binary package may determine at compile-time
6070 whether new library interfaces are available and can be called).
6071 To allow these dependencies to be constructed, shared libraries
6072 must provide either a <file>symbols</file> file or
6073 a <file>shlibs</file> file. These provide information on the
6074 package dependencies required to ensure the presence of
6075 interfaces provided by this library. Any package with binaries
6076 or libraries linking to a shared library must use these files to
6077 determine the required dependencies when it is built. Other
6078 packages which use a shared library (for example using
6079 <tt>dlopen()</tt>) should compute appropriate dependencies
6080 using these files at build time as well.
6081 </p>
6084 The two mechanisms differ in the degree of detail that they
6085 provide. A <file>symbols</file> file documents, for each symbol
6086 exported by a library, the minimal version of the package any
6087 binary using this symbol will need. This is typically the
6088 version of the package in which the symbol was introduced. This
6089 information permits detailed analysis of the symbols used by a
6090 particular package and construction of an accurate dependency,
6091 but it requires the package maintainer to track more information
6092 about the shared library.
6093 </p>
6096 A <file>shlibs</file> file, in contrast, only documents the last
6097 time the library ABI changed in any way. It only provides
6098 information about the library as a whole, not individual
6099 symbols. When a package is built using a shared library with
6100 only a <file>shlibs</file> file, the generated dependency will
6101 require a version of the shared library equal to or newer than
6102 the version of the last ABI change. This generates
6103 unnecessarily restrictive dependencies compared
6104 to <file>symbols</file> files if none of the symbols used by the
6105 package have changed. This, in turn, may make upgrades
6106 needlessly complex and unnecessarily restrict use of the package
6107 on systems with older versions of the shared libraries.
6108 </p>
6111 <file>shlibs</file> files also only support a limited range of
6112 library SONAMEs, making it difficult to use <file>shlibs</file>
6113 files in some unusual corner cases.<footnote>
6114 A <file>shlibs</file> file represents an SONAME as a library
6115 name and version number, such as <tt>libfoo VERSION</tt>,
6116 instead of recording the actual SONAME. If the SONAME doesn't
6117 match one of the two expected formats
6118 (<tt>libfoo-VERSION.so</tt> or <tt>libfoo.so.VERSION</tt>), it
6119 cannot be represented.
6120 </footnote>
6121 </p>
6124 <file>symbols</file> files are therefore recommended for most
6125 shared library packages since they provide more accurate
6126 dependencies. For most C libraries, the additional detail
6127 required by <file>symbols</file> files is not too difficult to
6128 maintain. However, maintaining exhaustive symbols information
6129 for a C++ library can be quite onerous, so <file>shlibs</file>
6130 files may be more appropriate for most C++ libraries. Libraries
6131 with a corresponding udeb must also provide
6132 a <file>shlibs</file> file, since the udeb infrastructure does
6133 not use <file>symbols</file> files.
6134 </p>
6136 <sect1 id="dpkg-shlibdeps">
6137 <heading>Generating dependencies on shared libraries</heading>
6140 When a package that contains any shared libraries or compiled
6141 binaries is built, it must run <prgn>dpkg-shlibdeps</prgn> on
6142 each shared library and compiled binary to determine the
6143 libraries used and hence the dependencies needed by the
6144 package.<footnote>
6145 <prgn>dpkg-shlibdeps</prgn> will use a program
6146 like <prgn>objdump</prgn> or <prgn>readelf</prgn> to find
6147 the libraries and the symbols in those libraries directly
6148 needed by the binaries or shared libraries in the package.
6149 </footnote>
6150 To do this, put a call to <prgn>dpkg-shlibdeps</prgn> into
6151 your <file>debian/rules</file> file in the source package.
6152 List all of the compiled binaries, libraries, or loadable
6153 modules in your package.<footnote>
6154 The easiest way to call <prgn>dpkg-shlibdeps</prgn>
6155 correctly is to use a package helper framework such
6156 as <package>debhelper</package>. If you are
6157 using <package>debhelper</package>,
6158 the <prgn>dh_shlibdeps</prgn> program will do this work for
6159 you. It will also correctly handle multi-binary packages.
6160 </footnote>
6161 <prgn>dpkg-shlibdeps</prgn> will use the <file>symbols</file>
6162 or <file>shlibs</file> files installed by the shared libraries
6163 to generate dependency information. The package must then
6164 provide a substitution variable into which the discovered
6165 dependency information can be placed.
6166 </p>
6169 If you are creating a udeb for use in the Debian Installer,
6170 you will need to specify that <prgn>dpkg-shlibdeps</prgn>
6171 should use the dependency line of type <tt>udeb</tt> by adding
6172 the <tt>-tudeb</tt> option<footnote>
6173 <prgn>dh_shlibdeps</prgn> from the <tt>debhelper</tt> suite
6174 will automatically add this option if it knows it is
6175 processing a udeb.
6176 </footnote>. If there is no dependency line of
6177 type <tt>udeb</tt> in the <file>shlibs</file>
6178 file, <prgn>dpkg-shlibdeps</prgn> will fall back to the
6179 regular dependency line.
6180 </p>
6183 <prgn>dpkg-shlibdeps</prgn> puts the dependency information
6184 into the <file>debian/substvars</file> file by default, which
6185 is then used by <prgn>dpkg-gencontrol</prgn>. You will need
6186 to place a <tt>${shlibs:Depends}</tt> variable in
6187 the <tt>Depends</tt> field in the control file of every binary
6188 package built by this source package that contains compiled
6189 binaries, libraries, or loadable modules. If you have
6190 multiple binary packages, you will need to
6191 call <prgn>dpkg-shlibdeps</prgn> on each one which contains
6192 compiled libraries or binaries. For example, you could use
6193 the <tt>-T</tt> option to the <tt>dpkg</tt> utilities to
6194 specify a different <file>substvars</file> file for each
6195 binary package.<footnote>
6196 Again, <prgn>dh_shlibdeps</prgn>
6197 and <prgn>dh_gencontrol</prgn> will handle everything except
6198 the addition of the variable to the control file for you if
6199 you're using <package>debhelper</package>, including
6200 generating separate <file>substvars</file> files for each
6201 binary package and calling <prgn>dpkg-gencontrol</prgn> with
6202 the appropriate flags.
6203 </footnote>
6204 </p>
6207 For more details on <prgn>dpkg-shlibdeps</prgn>,
6208 see <manref name="dpkg-shlibdeps" section="1">.
6209 </p>
6212 We say that a binary <tt>foo</tt> <em>directly</em> uses a
6213 library <tt>libbar</tt> if it is explicitly linked with that
6214 library (that is, the library is listed in the
6215 ELF <tt>NEEDED</tt> attribute, caused by adding <tt>-lbar</tt>
6216 to the link line when the binary is created). Other libraries
6217 that are needed by <tt>libbar</tt> are
6218 linked <em>indirectly</em> to <tt>foo</tt>, and the dynamic
6219 linker will load them automatically when it
6220 loads <tt>libbar</tt>. A package should depend on the
6221 libraries it directly uses, but not the libraries it only uses
6222 indirectly. The dependencies for the libraries used
6223 directly will automatically pull in the indirectly-used
6224 libraries. <prgn>dpkg-shlibdeps</prgn> will handle this logic
6225 automatically, but package maintainers need to be aware of
6226 this distinction between directly and indirectly using a
6227 library if they have to override its results for some reason.
6228 <footnote>
6229 A good example of where this helps is the following. We
6230 could update <tt>libimlib</tt> with a new version that
6231 supports a new revision of a graphics format called dgf (but
6232 retaining the same major version number) and depends on a
6233 new library package <package>libdgf4</package> instead of
6234 the older <package>libdgf3</package>. If we
6235 used <prgn>ldd</prgn> to add dependencies for every library
6236 directly or indirectly linked with a binary, every package
6237 that uses <tt>libimlib</tt> would need to be recompiled so
6238 it would also depend on <package>libdgf4</package> in order
6239 to retire the older <package>libdgf3</package> package.
6240 Since dependencies are only added based on
6241 ELF <tt>NEEDED</tt> attribute, packages
6242 using <tt>libimlib</tt> can rely on <tt>libimlib</tt> itself
6243 having the dependency on an appropriate version
6244 of <tt>libdgf</tt> and do not need rebuilding.
6245 </footnote>
6246 </p>
6247 </sect1>
6249 <sect1 id="sharedlibs-updates">
6250 <heading>Shared library ABI changes</heading>
6253 Maintaining a shared library package using
6254 either <file>symbols</file> or <file>shlibs</file> files
6255 requires being aware of the exposed ABI of the shared library
6256 and any changes to it. Both <file>symbols</file>
6257 and <file>shlibs</file> files record every change to the ABI
6258 of the shared library; <file>symbols</file> files do so per
6259 public symbol, whereas <file>shlibs</file> files record only
6260 the last change for the entire library.
6261 </p>
6264 There are two types of ABI changes: ones that are
6265 backward-compatible and ones that are not. An ABI change is
6266 backward-compatible if any reasonable program or library that
6267 was linked with the previous version of the shared library
6268 will still work correctly with the new version of the shared
6269 library.<footnote>
6270 An example of an "unreasonable" program is one that uses
6271 library interfaces that are documented as internal and
6272 unsupported. If the only programs or libraries affected by
6273 a change are "unreasonable" ones, other techniques, such as
6274 declaring <tt>Breaks</tt> relationships with affected
6275 packages or treating their usage of the library as bugs in
6276 those packages, may be appropriate instead of changing the
6277 SONAME. However, the default approach is to change the
6278 SONAME for any change to the ABI that could break a program.
6279 </footnote>
6280 Adding new symbols to the shared library is a
6281 backward-compatible change. Removing symbols from the shared
6282 library is not. Changing the behavior of a symbol may or may
6283 not be backward-compatible depending on the change; for
6284 example, changing a function to accept a new enum constant not
6285 previously used by the library is generally
6286 backward-compatible, but changing the members of a struct that
6287 is passed into library functions is generally not unless the
6288 library takes special precautions to accept old versions of
6289 the data structure.
6290 </p>
6293 ABI changes that are not backward-compatible normally require
6294 changing the <tt>SONAME</tt> of the library and therefore the
6295 shared library package name, which forces rebuilding all
6296 packages using that shared library to update their
6297 dependencies and allow them to use the new version of the
6298 shared library. For more information,
6299 see <ref id="sharedlibs-runtime">. The remainder of this
6300 section will deal with backward-compatible changes.
6301 </p>
6304 Backward-compatible changes require either updating or
6305 recording the <var>minimal-version</var> for that symbol
6306 in <file>symbols</file> files or updating the version in
6307 the <var>dependencies</var> in <file>shlibs</file> files. For
6308 more information on how to do this in the two formats, see
6309 <ref id="symbols"> and <ref id="shlibs">. Below are general
6310 rules that apply to both files.
6311 </p>
6314 The easy case is when a public symbol is added. Simply add
6315 the version at which the symbol was introduced
6316 (for <file>symbols</file> files) or update the dependency
6317 version (for <file>shlibs</file>) files. But special care
6318 should be taken to update dependency versions when the
6319 behavior of a public symbol changes. This is easy to neglect,
6320 since there is no automated method of determining such
6321 changes, but failing to update versions in this case may
6322 result in binary packages with too-weak dependencies that will
6323 fail at runtime, possibly in ways that can cause security
6324 vulnerabilities. If the package maintainer believes that a
6325 symbol behavior change may have occurred but isn't sure, it's
6326 safer to update the version rather than leave it unmodified.
6327 This may result in unnecessarily strict dependencies, but it
6328 ensures that packages whose dependencies are satisfied will
6329 work properly.
6330 </p>
6333 A common example of when a change to the dependency version
6334 is required is a function that takes an enum or struct
6335 argument that controls what the function does. For example:
6336 <example>
6337 enum library_op { OP_FOO, OP_BAR };
6338 int library_do_operation(enum library_op);
6339 </example>
6340 If a new operation, <tt>OP_BAZ</tt>, is added,
6341 the <var>minimal-version</var>
6342 of <tt>library_do_operation</tt> (for <file>symbols</file>
6343 files) or the version in the dependency for the shared library
6344 (for <file>shlibs</file> files) must be increased to the
6345 version at which <tt>OP_BAZ</tt> was introduced. Otherwise, a
6346 binary built against the new version of the library (having
6347 detected at compile-time that the library
6348 supports <tt>OP_BAZ</tt>) may be installed with a shared
6349 library that doesn't support <tt>OP_BAZ</tt> and will fail at
6350 runtime when it tries to pass <tt>OP_BAZ</tt> into this
6351 function.
6352 </p>
6355 Dependency versions in either <file>symbols</file>
6356 or <file>shlibs</file> files normally should not contain the
6357 Debian revision of the package, since the library behavior is
6358 normally fixed for a particular upstream version and any
6359 Debian packaging of that upstream version will have the same
6360 behavior. In the rare case that the library behavior was
6361 changed in a particular Debian revision, appending <tt>~</tt>
6362 to the end of the version that includes the Debian revision is
6363 recommended, since this allows backports of the shared library
6364 package using the normal backport versioning convention to
6365 satisfy the dependency.
6366 </p>
6367 </sect1>
6369 <sect1 id="sharedlibs-symbols">
6370 <heading>The <tt>symbols</tt> system</heading>
6373 In the following sections, we will first describe where the
6374 various <file>symbols</file> files are to be found, then
6375 the <file>symbols</file> file format, and finally how to
6376 create <file>symbols</file> files if your package contains a
6377 shared library.
6378 </p>
6380 <sect2 id="symbols-paths">
6381 <heading>The <file>symbols</file> files present on the
6382 system</heading>
6385 <file>symbols</file> files for a shared library are normally
6386 provided by the shared library package as a control file,
6387 but there are several override paths that are checked first
6388 in case that information is wrong or missing. The following
6389 list gives them in the order in which they are read
6390 by <prgn>dpkg-shlibdeps</prgn> The first one that contains
6391 the required information is used.
6392 <list>
6393 <item>
6394 <p><file>debian/*/DEBIAN/symbols</file></p>
6397 During the package build, if the package itself
6398 contains shared libraries with <file>symbols</file>
6399 files, they will be generated in these staging
6400 directories by <prgn>dpkg-gensymbols</prgn>
6401 (see <ref id="providing-symbols">). <file>symbols</file>
6402 files found in the build tree take precedence
6403 over <file>symbols</file> files from other binary
6404 packages.
6405 </p>
6408 These files must exist
6409 before <prgn>dpkg-shlibdeps</prgn> is run or the
6410 dependencies of binaries and libraries from a source
6411 package on other libraries from that same source
6412 package will not be correct. In practice, this means
6413 that <prgn>dpkg-gensymbols</prgn> must be run
6414 before <prgn>dpkg-shlibdeps</prgn> during the package
6415 build.<footnote>
6416 An example may clarify. Suppose the source
6417 package <tt>foo</tt> generates two binary
6418 packages, <tt>libfoo2</tt> and <tt>foo-runtime</tt>.
6419 When building the binary packages, the contents of
6420 the packages are staged in the
6421 directories <file>debian/libfoo2</file>
6422 and <file>debian/foo-runtime</file> respectively.
6423 (<file>debian/tmp</file> could be used instead of
6424 one of these.) Since <tt>libfoo2</tt> provides
6425 the <tt>libfoo</tt> shared library, it will contain
6426 a <tt>symbols</tt> file, which will be installed
6427 in <file>debian/libfoo2/DEBIAN/symbols</file>,
6428 eventually to be included as a control file in that
6429 package. When <prgn>dpkg-shlibdeps</prgn> is run on
6431 executable <file>debian/foo-runtime/usr/bin/foo-prog</file>,
6432 it will examine
6433 the <file>debian/libfoo2/DEBIAN/symbols</file> file
6434 to determine whether <tt>foo-prog</tt>'s library
6435 dependencies are satisfied by any of the libraries
6436 provided by <tt>libfoo2</tt>. Since those binaries
6437 were linked against the just-built shared library as
6438 part of the build process, the <file>symbols</file>
6439 file for the newly-built <tt>libfoo2</tt> must take
6440 precedence over a <file>symbols</file> file for any
6441 other <tt>libfoo2</tt> package already installed on
6442 the system.
6443 </footnote>
6444 </p>
6445 </item>
6447 <item>
6449 <file>/etc/dpkg/symbols/<var>package</var>.symbols.<var>arch</var></file>
6450 and <file>/etc/dpkg/symbols/<var>package</var>.symbols</file>
6451 </p>
6454 Per-system overrides of shared library dependencies.
6455 These files normally do not exist. They are
6456 maintained by the local system administrator and must
6457 not be created by any Debian package.
6458 </p>
6459 </item>
6461 <item>
6462 <p><file>symbols</file> control files for packages
6463 installed on the system</p>
6466 The <file>symbols</file> control files for all the
6467 packages currently installed on the system are
6468 searched last. This will be the most common source of
6469 shared library dependency information. These files
6470 can be read with <tt>dpkg-query
6471 --control-show <var>package</var> symbols</tt>.
6472 </p>
6473 </item>
6474 </list>
6475 </p>
6478 Be aware that if a <file>debian/shlibs.local</file> exists
6479 in the source package, it will override
6480 any <file>symbols</file> files. This is the only case where
6481 a <file>shlibs</file> is used despite <file>symbols</file>
6482 files being present. See <ref id="shlibs-paths">
6483 and <ref id="sharedlibs-shlibdeps"> for more information.
6484 </p>
6485 </sect2>
6487 <sect2 id="symbols">
6488 <heading>The <file>symbols</file> File Format</heading>
6491 The following documents the format of
6492 the <file>symbols</file> control file as included in binary
6493 packages. These files are built from
6494 template <file>symbols</file> files in the source package
6495 by <prgn>dpkg-gensymbols</prgn>. The template files support
6496 a richer syntax that allows <prgn>dpkg-gensymbols</prgn> to
6497 do some of the tedious work involved in
6498 maintaining <file>symbols</file> files, such as handling C++
6499 symbols or optional symbols that may not exist on particular
6500 architectures. When writing <file>symbols</file> files for
6501 a shared library package, refer
6502 to <manref name="dpkg-gensymbols" section="1"> for the
6503 richer syntax.
6504 </p>
6507 A <file>symbols</file> may contain one or more entries, one
6508 for each shared library contained in the package
6509 corresponding to that <file>symbols</file>. Each entry has
6510 the following format:
6511 </p>
6514 <example>
6515 <var>library-soname</var> <var>main-dependency-template</var>
6516 [| <var>alternative-dependency-template</var>]
6517 [...]
6518 [* <var>field-name</var>: <var>field-value</var>]
6519 [...]
6520 <var>symbol</var> <var>minimal-version</var>[ <var>id-of-dependency-template</var> ]
6521 </example>
6522 </p>
6525 To explain this format, we'll use the <tt>zlib1g</tt>
6526 package as an example, which (at the time of writing)
6527 installs the shared
6528 library <file>/usr/lib/libz.so.1.2.3.4</file>. Mandatory
6529 lines will be described first, followed by optional lines.
6530 </p>
6533 <var>library-soname</var> must contain exactly the value of
6534 the ELF <tt>SONAME</tt> attribute of the shared library. In
6535 our example, this is <tt>libz.so.1</tt>.<footnote>
6536 This can be determined by using the command
6537 <example compact="compact">
6538 readelf -d /usr/lib/libz.so.1.2.3.4 | grep SONAME
6539 </example>
6540 </footnote>
6541 </p>
6544 <var>main-dependency-template</var> has the same syntax as a
6545 dependency field in a binary package control file, except
6546 that the string <tt>#MINVER#</tt> is replaced by a version
6547 restriction like <tt>(>= <var>version</var>)</tt> or by
6548 nothing if an unversioned dependency is deemed sufficient.
6549 The version restriction will be based on which symbols from
6550 the shared library are referenced and the version at which
6551 they were introduced (see below). In nearly all
6552 cases, <var>main-dependency-template</var> will
6553 be <tt><var>package</var> #MINVER#</tt>,
6554 where <var>package</var> is the name of the binary package
6555 containing the shared library. This adds a simple,
6556 possibly-versioned dependency on the shared library package.
6557 In some rare cases, such as when multiple packages provide
6558 the same shared library ABI, the dependency template may
6559 need to be more complex.
6560 </p>
6563 In our example, the first line of
6564 the <tt>zlib1g</tt> <file>symbols</file> file would be:
6565 <example compact="compact">
6566 libz.so.1 zlib1g #MINVER#
6567 </example>
6568 </p>
6571 Each public symbol exported by the shared library must have
6572 a corresponding symbol line, indented by one
6573 space. <var>symbol</var> is the exported symbol (which, for
6574 C++, means the mangled symbol) followed by <tt>@</tt> and
6575 the symbol version, or the string <tt>Base</tt> if there is
6576 no symbol version. <var>minimal-version</var> is the most
6577 recent version of the shared library that changed the
6578 behavior of that symbol, whether by adding it, changing its
6579 function signature (the parameters, their types, or the
6580 return type), or changing its behavior in a way that is
6581 visible to a caller.
6582 <var>id-of-dependency-template</var> is an optional
6583 field that references
6584 an <var>alternative-dependency-template</var>; see below for
6585 a full description.
6586 </p>
6589 For example, <tt>libz.so.1</tt> contains the
6590 symbols <tt>compress</tt>
6591 and <tt>compressBound</tt>. <tt>compress</tt> has no symbol
6592 version and last changed its behavior in upstream
6593 version <tt>1:1.1.4</tt>. <tt>compressBound</tt> has the
6594 symbol version <tt>ZLIB_1.2.0</tt>, was introduced in
6595 upstream version <tt>1:1.2.0</tt>, and has not changed its
6596 behavior. Its <file>symbols</file> file therefore contains
6597 the lines:
6598 <example compact="compact">
6599 compress@Base 1:1.1.4
6600 compressBound@ZLIB_1.2.0 1:1.2.0
6601 </example>
6602 Packages using only <tt>compress</tt> would then get a
6603 dependency on <tt>zlib1g (>= 1:1.1.4)</tt>, but packages
6604 using <tt>compressBound</tt> would get a dependency
6605 on <tt>zlib1g (>= 1:1.2.0)</tt>.
6606 </p>
6609 One or more <var>alternative-dependency-template</var> lines
6610 may be provided. These are used in cases where some symbols
6611 in the shared library should use one dependency template
6612 while others should use a different template. The
6613 alternative dependency templates are used only if a symbol
6614 line contains the <var>id-of-dependency-template</var>
6615 field. The first alternative dependency template is
6616 numbered 1, the second 2, and so forth.<footnote>
6617 An example of where this may be needed is with a library
6618 that implements the libGL interface. All GL
6619 implementations provide the same set of base interfaces,
6620 and then may provide some additional interfaces only used
6621 by programs that require that specific GL implementation.
6622 So, for example, libgl1-mesa-glx may use the
6623 following <file>symbols</file> file:
6624 <example>
6625 libGL.so.1 libgl1
6626 | libgl1-mesa-glx #MINVER#
6627 publicGlSymbol@Base 6.3-1
6628 [...]
6629 implementationSpecificSymbol@Base 6.5.2-7 1
6630 [...]
6631 </example>
6632 Binaries or shared libraries using
6633 only <tt>publicGlSymbol</tt> would depend only
6634 on <tt>libgl1</tt> (which may be provided by multiple
6635 packages), but ones
6636 using <tt>implementationSpecificSymbol</tt> would get a
6637 dependency on <tt>libgl1-mesa-glx (>= 6.5.2-7)</tt>
6638 </footnote>
6639 </p>
6642 Finally, the entry for the library may contain one or more
6643 metadata fields. Currently, the only
6644 supported <var>field-name</var>
6645 is <tt>Build-Depends-Package</tt>, whose value lists
6646 the <qref id="sharedlibs-dev">library development
6647 package</qref> on which packages using this shared library
6648 declare a build dependency. If this field is
6649 present, <prgn>dpkg-shlibdeps</prgn> uses it to ensure that
6650 the resulting binary package dependency on the shared
6651 library is at least as strict as the source package
6652 dependency on the shared library development
6653 package.<footnote>
6654 This field should normally not be necessary, since if the
6655 behavior of any symbol has changed, the corresponding
6656 symbol <var>minimal-version</var> should have been
6657 increased. But including it makes the <tt>symbols</tt>
6658 system more robust by tightening the dependency in cases
6659 where the package using the shared library specifically
6660 requires at least a particular version of the shared
6661 library development package for some reason.
6662 </footnote>
6663 For our example, the <tt>zlib1g</tt> <file>symbols</file>
6664 file would contain:
6665 <example compact="compact">
6666 * Build-Depends-Package: zlib1g-dev
6667 </example>
6668 </p>
6671 Also see <manref name="deb-symbols" section="5">.
6672 </p>
6673 </sect2>
6675 <sect2 id="providing-symbols">
6676 <heading>Providing a <file>symbols</file> file</heading>
6679 If your package provides a shared library, you should
6680 arrange to include a <file>symbols</file> control file
6681 following the format described above in that package. You
6682 must include either a <file>symbols</file> control file or
6683 a <file>shlibs</file> control file.
6684 </p>
6687 Normally, this is done by creating a <file>symbols</file> in
6688 the source package
6689 named <file>debian/<var>package</var>.symbols</file>
6690 or <file>debian/symbols</file>, possibly
6691 with <file>.<var>arch</var></file> appended if the symbols
6692 information varies by architecture. This file may use the
6693 extended syntax documented in <manref name="dpkg-gensymbols"
6694 section="1">. Then, call <prgn>dpkg-gensymbols</prgn> as
6695 part of the package build process. It will
6696 create <file>symbols</file> files in the package staging
6697 area based on the binaries and libraries in the package
6698 staging area and the <file>symbols</file> files in the
6699 source package.<footnote>
6700 If you are
6701 using <tt>debhelper</tt>, <prgn>dh_makeshlibs</prgn> will
6702 take care of calling either <prgn>dpkg-gensymbols</prgn>
6703 or generating a <file>shlibs</file> file as appropriate.
6704 </footnote>
6705 </p>
6708 Packages that provide <file>symbols</file> files must keep
6709 them up-to-date to ensure correct dependencies in packages
6710 that use the shared libraries. This means updating
6711 the <file>symbols</file> file whenever a new public symbol
6712 is added, changing the <var>minimal-version</var> field
6713 whenever a symbol changes behavior or signature in a
6714 backward-compatible way (see <ref id="sharedlibs-updates">),
6715 and changing the <var>library-soname</var>
6716 and <var>main-dependency-template</var>, and probably all of
6717 the <var>minimal-version</var> fields, when the library
6718 changes <tt>SONAME</tt>. Removing a public symbol from
6719 the <file>symbols</file> file because it's no longer
6720 provided by the library normally requires changing
6721 the <tt>SONAME</tt> of the library.
6722 See <ref id="sharedlibs-runtime"> for more information
6723 on <tt>SONAME</tt>s.
6724 </p>
6725 </sect2>
6726 </sect1>
6728 <sect1 id="sharedlibs-shlibdeps">
6729 <heading>The <tt>shlibs</tt> system</heading>
6732 The <tt>shlibs</tt> system is a simpler alternative to
6733 the <tt>symbols</tt> system for declaring dependencies for
6734 shared libraries. It may be more appropriate for C++
6735 libraries and other cases where tracking individual symbols is
6736 too difficult. It predated the <tt>symbols</tt> system and is
6737 therefore frequently seen in older packages. It is also
6738 required for udebs, which do not support <tt>symbols</tt>.
6739 </p>
6742 In the following sections, we will first describe where the
6743 various <file>shlibs</file> files are to be found, then how to
6744 use <prgn>dpkg-shlibdeps</prgn>, and finally
6745 the <file>shlibs</file> file format and how to create them.
6746 </p>
6748 <sect2 id="shlibs-paths">
6749 <heading>The <file>shlibs</file> files present on the
6750 system</heading>
6753 There are several places where <tt>shlibs</tt> files are
6754 found. The following list gives them in the order in which
6755 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
6756 one which gives the required information is used.)
6757 <list>
6758 <item>
6759 <p><file>debian/shlibs.local</file></p>
6762 This lists overrides for this package. This file
6763 should normally not be used, but may be needed
6764 temporarily in unusual situations to work around bugs
6765 in other packages, or in unusual cases where the
6766 normally declared dependency information in the
6767 installed <file>shlibs</file> file for a library
6768 cannot be used. This file overrides information
6769 obtained from any other source.
6770 </p>
6771 </item>
6773 <item>
6774 <p><file>/etc/dpkg/shlibs.override</file></p>
6777 This lists global overrides. This list is normally
6778 empty. It is maintained by the local system
6779 administrator.
6780 </p>
6781 </item>
6783 <item>
6784 <p><file>DEBIAN/shlibs</file> files in the "build
6785 directory"</p>
6788 These files are generated as part of the package build
6789 process and staged for inclusion as control files in
6790 the binary packages being built. They provide details
6791 of any shared libraries included in the same package.
6792 </p>
6793 </item>
6795 <item>
6796 <p><file>shlibs</file> control files for packages
6797 installed on the system</p>
6800 The <file>shlibs</file> control files for all the
6801 packages currently installed on the system. These
6802 files can be read using <tt>dpkg-query
6803 --control-show <var>package</var> shlibs</tt>.
6804 </p>
6805 </item>
6807 <item>
6808 <p><file>/etc/dpkg/shlibs.default</file></p>
6811 This file lists any shared libraries whose packages
6812 have failed to provide correct <file>shlibs</file>
6813 files. It was used when the <file>shlibs</file> setup
6814 was first introduced, but it is now normally empty.
6815 It is maintained by the <tt>dpkg</tt> maintainer.
6816 </p>
6817 </item>
6818 </list>
6819 </p>
6822 If a <file>symbols</file> file for a shared library package
6823 is available, <prgn>dpkg-shlibdeps</prgn> will always use it
6824 in preference to a <file>shlibs</file>, with the exception
6825 of <file>debian/shlibs.local</file>. The latter overrides
6826 any other <file>shlibs</file> or <file>symbols</file> files.
6827 </p>
6828 </sect2>
6830 <sect2 id="shlibs">
6831 <heading>The <file>shlibs</file> File Format</heading>
6834 Each <file>shlibs</file> file has the same format. Lines
6835 beginning with <tt>#</tt> are considered to be comments and
6836 are ignored. Each line is of the form:
6837 <example compact="compact">
6838 [<var>type</var>: ]<var>library-name</var> <var>soname-version</var> <var>dependencies ...</var>
6839 </example>
6840 </p>
6843 We will explain this by reference to the example of the
6844 <tt>zlib1g</tt> package, which (at the time of writing)
6845 installs the shared
6846 library <file>/usr/lib/libz.so.1.2.3.4</file>.
6847 </p>
6850 <var>type</var> is an optional element that indicates the
6851 type of package for which the line is valid. The only type
6852 currently in use is <tt>udeb</tt>. The colon and space
6853 after the type are required.
6854 </p>
6857 <var>library-name</var> is the name of the shared library,
6858 in this case <tt>libz</tt>. (This must match the name part
6859 of the soname, see below.)
6860 </p>
6863 <var>soname-version</var> is the version part of the
6864 ELF <tt>SONAME</tt> attribute of the library, determined the
6865 same way that the <var>soversion</var> component of the
6866 recommended shared library package name is determined.
6867 See <ref id="sharedlibs-runtime"> for the details.
6868 </p>
6871 <var>dependencies</var> has the same syntax as a dependency
6872 field in a binary package control file. It should give
6873 details of which packages are required to satisfy a binary
6874 built against the version of the library contained in the
6875 package. See <ref id="depsyntax"> for details on the
6876 syntax, and <ref id="sharedlibs-updates"> for details on how
6877 to maintain the dependency version constraint.
6878 </p>
6881 In our example, if the last change to the <tt>zlib1g</tt>
6882 package that could change behavior for a client of that
6883 library was in version <tt>1:1.2.3.3.dfsg-1</tt>, then
6884 the <tt>shlibs</tt> entry for this library could say:
6885 <example compact="compact">
6886 libz 1 zlib1g (>= 1:1.2.3.3.dfsg)
6887 </example>
6888 This version restriction must be new enough that any binary
6889 built against the current version of the library will work
6890 with any version of the shared library that satisfies that
6891 dependency.
6892 </p>
6895 As zlib1g also provides a udeb containing the shared
6896 library, there would also be a second line:
6897 <example compact="compact">
6898 udeb: libz 1 zlib1g-udeb (>= 1:1.2.3.3.dfsg)
6899 </example>
6900 </p>
6901 </sect2>
6903 <sect2>
6904 <heading>Providing a <file>shlibs</file> file</heading>
6907 To provide a <file>shlibs</file> file for a shared library
6908 binary package, create a <file>shlibs</file> file following
6909 the format described above and place it in
6910 the <file>DEBIAN</file> directory for that package during
6911 the build. It will then be included as a control file for
6912 that package<footnote>
6913 This is what <prgn>dh_makeshlibs</prgn> in
6914 the <package>debhelper</package> suite does. If your
6915 package also has a udeb that provides a shared
6916 library, <prgn>dh_makeshlibs</prgn> can automatically
6917 generate the <tt>udeb:</tt> lines if you specify the name
6918 of the udeb with the <tt>--add-udeb</tt> option.
6919 </footnote>.
6920 </p>
6923 Since <prgn>dpkg-shlibdeps</prgn> reads
6924 the <file>DEBIAN/shlibs</file> files in all of the binary
6925 packages being built from this source package, all of
6926 the <file>DEBIAN/shlibs</file> files should be installed
6927 before <prgn>dpkg-shlibdeps</prgn> is called on any of the
6928 binary packages.
6929 </p>
6930 </sect2>
6931 </sect1>
6932 </sect>
6933 </chapt>
6936 <chapt id="opersys"><heading>The Operating System</heading>
6938 <sect>
6939 <heading>File system hierarchy</heading>
6942 <sect1 id="fhs">
6943 <heading>File System Structure</heading>
6946 The location of all files and directories must comply with the
6947 Filesystem Hierarchy Standard (FHS), version 2.3, with the
6948 exceptions noted below, and except where doing so would
6949 violate other terms of Debian Policy. The following
6950 exceptions to the FHS apply:
6952 <enumlist>
6953 <item>
6955 The FHS requirement that architecture-independent
6956 application-specific static files be located in
6957 <file>/usr/share</file> is relaxed to a suggestion.
6959 In particular, a subdirectory of <file>/usr/lib</file> may
6960 be used by a package (or a collection of packages) to hold a
6961 mixture of architecture-independent and
6962 architecture-dependent files. However, when a directory is
6963 entirely composed of architecture-independent files, it
6964 should be located in <file>/usr/share</file>.
6965 </p>
6966 </item>
6967 <item>
6969 The optional rules related to user specific
6970 configuration files for applications are stored in
6971 the user's home directory are relaxed. It is
6972 recommended that such files start with the
6973 '<tt>.</tt>' character (a "dot file"), and if an
6974 application needs to create more than one dot file
6975 then the preferred placement is in a subdirectory
6976 with a name starting with a '.' character, (a "dot
6977 directory"). In this case it is recommended the
6978 configuration files not start with the '.'
6979 character.
6980 </p>
6981 </item>
6982 <item>
6984 The requirement for amd64 to use <file>/lib64</file>
6985 for 64 bit binaries is removed.
6986 </p>
6987 </item>
6988 <item>
6990 The requirement for object files, internal binaries, and
6991 libraries, including <file>libc.so.*</file>, to be located
6992 directly under <file>/lib{,32}</file> and
6993 <file>/usr/lib{,32}</file> is amended, permitting files
6994 to instead be installed to
6995 <file>/lib/<var>triplet</var></file> and
6996 <file>/usr/lib/<var>triplet</var></file>, where
6997 <tt><var>triplet</var></tt> is the value returned by
6998 <tt>dpkg-architecture -qDEB_HOST_MULTIARCH</tt> for the
6999 architecture of the package. Packages may <em>not</em>
7000 install files to any <var>triplet</var> path other
7001 than the one matching the architecture of that package;
7002 for instance, an <tt>Architecture: amd64</tt> package
7003 containing 32-bit x86 libraries may not install these
7004 libraries to <file>/usr/lib/i386-linux-gnu</file>.
7005 <footnote>
7006 This is necessary in order to reserve the directories for
7007 use in cross-installation of library packages from other
7008 architectures, as part of <tt>multiarch</tt>.
7009 </footnote>
7010 </p>
7012 The requirement for C and C++ headers files to be
7013 accessible through the search path
7014 <file>/usr/include/</file> is amended, permitting files to
7015 be accessible through the search path
7016 <file>/usr/include/<var>triplet</var></file> where
7017 <tt><var>triplet</var></tt> is as above. <footnote>
7018 This is necessary for architecture-dependent headers
7019 file to coexist in a <tt>multiarch</tt> setup.
7020 </footnote>
7021 </p>
7023 Applications may also use a single subdirectory under
7024 <file>/usr/lib/<var>triplet</var></file>.
7025 </p>
7027 The execution time linker/loader, ld*, must still be made
7028 available in the existing location under /lib or /lib64
7029 since this is part of the ELF ABI for the architecture.
7030 </p>
7031 </item>
7032 <item>
7034 The requirement that
7035 <file>/usr/local/share/man</file> be "synonymous"
7036 with <file>/usr/local/man</file> is relaxed to a
7037 recommendation</p>
7038 </item>
7039 <item>
7041 The requirement that windowmanagers with a single
7042 configuration file call it <file>system.*wmrc</file>
7043 is removed, as is the restriction that the window
7044 manager subdirectory be named identically to the
7045 window manager name itself.
7046 </p>
7047 </item>
7048 <item>
7050 The requirement that boot manager configuration
7051 files live in <file>/etc</file>, or at least are
7052 symlinked there, is relaxed to a recommendation.
7053 </p>
7054 </item>
7055 <item>
7057 The additional directory <file>/run</file> in the root
7058 file system is allowed. <file>/run</file>
7059 replaces <file>/var/run</file>, and the
7060 subdirectory <file>/run/lock</file>
7061 replaces <file>/var/lock</file>, with
7062 the <file>/var</file> directories replaced by symlinks
7063 for backwards compatibility. <file>/run</file>
7064 and <file>/run/lock</file> must follow all of the
7065 requirements in the FHS for <file>/var/run</file>
7066 and <file>/var/lock</file>, respectively, such as file
7067 naming conventions, file format requirements, or the
7068 requirement that files be cleared during the boot
7069 process. Files and directories residing
7070 in <file>/run</file> should be stored on a temporary
7071 file system.
7072 </p>
7074 Packages must not assume the <file>/run</file>
7075 directory exists or is usable without a dependency
7076 on <tt>initscripts (>= 2.88dsf-13.3)</tt> until the
7077 stable release of Debian supports <file>/run</file>.
7078 </p>
7079 </item>
7080 <item>
7082 The <file>/sys</file> directory in the root filesystem is
7083 additionally allowed. <footnote>This directory is used as
7084 mount point to mount virtual filesystems to get access to
7085 kernel information.</footnote>
7086 </p>
7087 </item>
7088 <item>
7090 The <file>/var/www</file> directory is additionally allowed.
7091 </p>
7092 </item>
7093 <item>
7095 The requirement for <file>/usr/local/lib&lt;qual&gt;</file>
7096 to exist if <file>/lib&lt;qual&gt;</file> or
7097 <file>/usr/lib&lt;qual&gt;</file> exists (where
7098 <file>lib&lt;qual&gt;</file> is a variant of
7099 <file>lib</file> such as <file>lib32</file> or
7100 <file>lib64</file>) is removed.
7101 </p>
7102 </item>
7103 <item>
7105 On GNU/Hurd systems, the following additional
7106 directories are allowed in the root
7107 filesystem: <file>/hurd</file>
7108 and <file>/servers</file>.<footnote>
7109 These directories are used to store translators and as
7110 a set of standard names for mount points,
7111 respectively.
7112 </footnote>
7113 </p>
7114 </item>
7115 </enumlist>
7116 </p>
7119 The version of this document referred here can be
7120 found in the <tt>debian-policy</tt> package or on <url
7121 id="http://www.debian.org/doc/packaging-manuals/fhs/"
7122 name="FHS (Debian copy)"> alongside this manual (or, if
7123 you have the <package>debian-policy</package> installed,
7124 you can try <url
7125 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
7126 (local copy)">). The
7127 latest version, which may be a more recent version, may
7128 be found on
7129 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
7130 Specific questions about following the standard may be
7131 asked on the <tt>debian-devel</tt> mailing list, or
7132 referred to the FHS mailing list (see the
7133 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
7134 more information).
7135 </p>
7136 </sect1>
7138 <sect1>
7139 <heading>Site-specific programs</heading>
7142 As mandated by the FHS, packages must not place any
7143 files in <file>/usr/local</file>, either by putting them in
7144 the file system archive to be unpacked by <prgn>dpkg</prgn>
7145 or by manipulating them in their maintainer scripts.
7146 </p>
7149 However, the package may create empty directories below
7150 <file>/usr/local</file> so that the system administrator knows
7151 where to place site-specific files. These are not
7152 directories <em>in</em> <file>/usr/local</file>, but are
7153 children of directories in <file>/usr/local</file>. These
7154 directories (<file>/usr/local/*/dir/</file>)
7155 should be removed on package removal if they are
7156 empty.
7157 </p>
7160 Note that this applies only to
7161 directories <em>below</em> <file>/usr/local</file>,
7162 not <em>in</em> <file>/usr/local</file>. Packages must
7163 not create sub-directories in the
7164 directory <file>/usr/local</file> itself, except those
7165 listed in FHS, section 4.5. However, you may create
7166 directories below them as you wish. You must not remove
7167 any of the directories listed in 4.5, even if you created
7168 them.
7169 </p>
7172 Since <file>/usr/local</file> can be mounted read-only from a
7173 remote server, these directories must be created and
7174 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
7175 maintainer scripts and not be included in the
7176 <file>.deb</file> archive. These scripts must not fail if
7177 either of these operations fail.
7178 </p>
7181 For example, the <tt>emacsen-common</tt> package could
7182 contain something like
7183 <example compact="compact">
7184 if [ ! -e /usr/local/share/emacs ]; then
7185 if mkdir /usr/local/share/emacs 2>/dev/null; then
7186 if chown root:staff /usr/local/share/emacs; then
7187 chmod 2775 /usr/local/share/emacs || true
7191 </example>
7192 in its <prgn>postinst</prgn> script, and
7193 <example compact="compact">
7194 rmdir /usr/local/share/emacs/site-lisp 2>/dev/null || true
7195 rmdir /usr/local/share/emacs 2>/dev/null || true
7196 </example>
7197 in the <prgn>prerm</prgn> script. (Note that this form is
7198 used to ensure that if the script is interrupted, the
7199 directory <file>/usr/local/share/emacs</file> will still be
7200 removed.)
7201 </p>
7204 If you do create a directory in <file>/usr/local</file> for
7205 local additions to a package, you should ensure that
7206 settings in <file>/usr/local</file> take precedence over the
7207 equivalents in <file>/usr</file>.
7208 </p>
7211 However, because <file>/usr/local</file> and its contents are
7212 for exclusive use of the local administrator, a package
7213 must not rely on the presence or absence of files or
7214 directories in <file>/usr/local</file> for normal operation.
7215 </p>
7218 The <file>/usr/local</file> directory itself and all the
7219 subdirectories created by the package should (by default) have
7220 permissions 2775 (group-writable and set-group-id) and be
7221 owned by <tt>root:staff</tt>.
7222 </p>
7223 </sect1>
7225 <sect1>
7226 <heading>The system-wide mail directory</heading>
7228 The system-wide mail directory
7229 is <file>/var/mail</file>. This directory is part of the
7230 base system and should not be owned by any particular mail
7231 agents. The use of the old
7232 location <file>/var/spool/mail</file> is deprecated, even
7233 though the spool may still be physically located there.
7234 </p>
7235 </sect1>
7237 <sect1 id="fhs-run">
7238 <heading><file>/run</file> and <file>/run/lock</file></heading>
7241 The directory <file>/run</file> is cleared at boot, normally
7242 by being a mount point for a temporary file system. Packages
7243 therefore must not assume that any files or directories
7244 under <file>/run</file> other than <file>/run/lock</file>
7245 exist unless the package has arranged to create those files or
7246 directories since the last reboot. Normally, this is done by
7247 the package via an init script. See <ref id="writing-init">
7248 for more information.
7249 </p>
7252 Packages must not include files or directories
7253 under <file>/run</file>, or under the
7254 older <file>/var/run</file> and <file>/var/lock</file> paths.
7255 The latter paths will normally be symlinks or other
7256 redirections to <file>/run</file> for backwards compatibility.
7257 </p>
7258 </sect1>
7259 </sect>
7261 <sect>
7262 <heading>Users and groups</heading>
7264 <sect1>
7265 <heading>Introduction</heading>
7267 The Debian system can be configured to use either plain or
7268 shadow passwords.
7269 </p>
7272 Some user ids (UIDs) and group ids (GIDs) are reserved
7273 globally for use by certain packages. Because some
7274 packages need to include files which are owned by these
7275 users or groups, or need the ids compiled into binaries,
7276 these ids must be used on any Debian system only for the
7277 purpose for which they are allocated. This is a serious
7278 restriction, and we should avoid getting in the way of
7279 local administration policies. In particular, many sites
7280 allocate users and/or local system groups starting at 100.
7281 </p>
7284 Apart from this we should have dynamically allocated ids,
7285 which should by default be arranged in some sensible
7286 order, but the behavior should be configurable.
7287 </p>
7290 Packages other than <tt>base-passwd</tt> must not modify
7291 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
7292 <file>/etc/group</file> or <file>/etc/gshadow</file>.
7293 </p>
7294 </sect1>
7296 <sect1>
7297 <heading>UID and GID classes</heading>
7299 The UID and GID numbers are divided into classes as
7300 follows:
7301 <taglist>
7302 <tag>0-99:</tag>
7303 <item>
7305 Globally allocated by the Debian project, the same
7306 on every Debian system. These ids will appear in
7307 the <file>passwd</file> and <file>group</file> files of all
7308 Debian systems, new ids in this range being added
7309 automatically as the <tt>base-passwd</tt> package is
7310 updated.
7311 </p>
7314 Packages which need a single statically allocated
7315 uid or gid should use one of these; their
7316 maintainers should ask the <tt>base-passwd</tt>
7317 maintainer for ids.
7318 </p>
7319 </item>
7321 <tag>100-999:</tag>
7322 <item>
7324 Dynamically allocated system users and groups.
7325 Packages which need a user or group, but can have
7326 this user or group allocated dynamically and
7327 differently on each system, should use <tt>adduser
7328 --system</tt> to create the group and/or user.
7329 <prgn>adduser</prgn> will check for the existence of
7330 the user or group, and if necessary choose an unused
7331 id based on the ranges specified in
7332 <file>adduser.conf</file>.
7333 </p>
7334 </item>
7336 <tag>1000-59999:</tag>
7337 <item>
7339 Dynamically allocated user accounts. By default
7340 <prgn>adduser</prgn> will choose UIDs and GIDs for
7341 user accounts in this range, though
7342 <file>adduser.conf</file> may be used to modify this
7343 behavior.
7344 </p>
7345 </item>
7347 <tag>60000-64999:</tag>
7348 <item>
7350 Globally allocated by the Debian project, but only
7351 created on demand. The ids are allocated centrally
7352 and statically, but the actual accounts are only
7353 created on users' systems on demand.
7354 </p>
7357 These ids are for packages which are obscure or
7358 which require many statically-allocated ids. These
7359 packages should check for and create the accounts in
7360 <file>/etc/passwd</file> or <file>/etc/group</file> (using
7361 <prgn>adduser</prgn> if it has this facility) if
7362 necessary. Packages which are likely to require
7363 further allocations should have a "hole" left after
7364 them in the allocation, to give them room to
7365 grow.
7366 </p>
7367 </item>
7369 <tag>65000-65533:</tag>
7370 <item>
7371 <p>Reserved.</p>
7372 </item>
7374 <tag>65534:</tag>
7375 <item>
7377 User <tt>nobody</tt>. The corresponding gid refers
7378 to the group <tt>nogroup</tt>.
7379 </p>
7380 </item>
7382 <tag>65535:</tag>
7383 <item>
7385 This value <em>must not</em> be used, because it was
7386 the error return sentinel value when <tt>uid_t</tt>
7387 was 16 bits.
7388 </p>
7389 </item>
7391 <tag>65536-4294967293:</tag>
7392 <item>
7394 Dynamically allocated user accounts. By
7395 default <prgn>adduser</prgn> will not allocate UIDs
7396 and GIDs in this range, to ease compatibility with
7397 legacy systems where <tt>uid_t</tt> is still 16
7398 bits.
7399 </p>
7400 </item>
7402 <tag>4294967294:</tag>
7403 <item>
7405 <tt>(uid_t)(-2) == (gid_t)(-2)</tt> <em>must not</em> be
7406 used, because it is used as the anonymous, unauthenticated
7407 user by some NFS implementations.
7408 </p>
7409 </item>
7411 <tag>4294967295:</tag>
7412 <item>
7414 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
7415 not</em> be used, because it is the error return
7416 sentinel value.
7417 </p>
7418 </item>
7419 </taglist>
7420 </p>
7421 </sect1>
7422 </sect>
7424 <sect id="sysvinit">
7425 <heading>System run levels and <file>init.d</file> scripts</heading>
7427 <sect1 id="/etc/init.d">
7428 <heading>Introduction</heading>
7431 The <file>/etc/init.d</file> directory contains the scripts
7432 executed by <prgn>init</prgn> at boot time and when the
7433 init state (or "runlevel") is changed (see <manref
7434 name="init" section="8">).
7435 </p>
7438 There are at least two different, yet functionally
7439 equivalent, ways of handling these scripts. For the sake
7440 of simplicity, this document describes only the symbolic
7441 link method. However, it must not be assumed by maintainer
7442 scripts that this method is being used, and any automated
7443 manipulation of the various runlevel behaviors by
7444 maintainer scripts must be performed using
7445 <prgn>update-rc.d</prgn> as described below and not by
7446 manually installing or removing symlinks. For information
7447 on the implementation details of the other method,
7448 implemented in the <tt>file-rc</tt> package, please refer
7449 to the documentation of that package.
7450 </p>
7453 These scripts are referenced by symbolic links in the
7454 <file>/etc/rc<var>n</var>.d</file> directories. When changing
7455 runlevels, <prgn>init</prgn> looks in the directory
7456 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
7457 execute, where <tt><var>n</var></tt> is the runlevel that
7458 is being changed to, or <tt>S</tt> for the boot-up
7459 scripts.
7460 </p>
7463 The names of the links all have the form
7464 <file>S<var>mm</var><var>script</var></file> or
7465 <file>K<var>mm</var><var>script</var></file> where
7466 <var>mm</var> is a two-digit number and <var>script</var>
7467 is the name of the script (this should be the same as the
7468 name of the actual script in <file>/etc/init.d</file>).
7469 </p>
7472 When <prgn>init</prgn> changes runlevel first the targets
7473 of the links whose names start with a <tt>K</tt> are
7474 executed, each with the single argument <tt>stop</tt>,
7475 followed by the scripts prefixed with an <tt>S</tt>, each
7476 with the single argument <tt>start</tt>. (The links are
7477 those in the <file>/etc/rc<var>n</var>.d</file> directory
7478 corresponding to the new runlevel.) The <tt>K</tt> links
7479 are responsible for killing services and the <tt>S</tt>
7480 link for starting services upon entering the runlevel.
7481 </p>
7484 For example, if we are changing from runlevel 2 to
7485 runlevel 3, init will first execute all of the <tt>K</tt>
7486 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
7487 all of the <tt>S</tt> prefixed scripts in that directory.
7488 The links starting with <tt>K</tt> will cause the
7489 referred-to file to be executed with an argument of
7490 <tt>stop</tt>, and the <tt>S</tt> links with an argument
7491 of <tt>start</tt>.
7492 </p>
7495 The two-digit number <var>mm</var> is used to determine
7496 the order in which to run the scripts: low-numbered links
7497 have their scripts run first. For example, the
7498 <tt>K20</tt> scripts will be executed before the
7499 <tt>K30</tt> scripts. This is used when a certain service
7500 must be started before another. For example, the name
7501 server <prgn>bind</prgn> might need to be started before
7502 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
7503 can set up its access lists. In this case, the script
7504 that starts <prgn>bind</prgn> would have a lower number
7505 than the script that starts <prgn>inn</prgn> so that it
7506 runs first:
7507 <example compact="compact">
7508 /etc/rc2.d/S17bind
7509 /etc/rc2.d/S70inn
7510 </example>
7511 </p>
7514 The two runlevels 0 (halt) and 6 (reboot) are slightly
7515 different. In these runlevels, the links with an
7516 <tt>S</tt> prefix are still called after those with a
7517 <tt>K</tt> prefix, but they too are called with the single
7518 argument <tt>stop</tt>.
7519 </p>
7520 </sect1>
7522 <sect1 id="writing-init">
7523 <heading>Writing the scripts</heading>
7526 Packages that include daemons for system services should
7527 place scripts in <file>/etc/init.d</file> to start or stop
7528 services at boot time or during a change of runlevel.
7529 These scripts should be named
7530 <file>/etc/init.d/<var>package</var></file>, and they should
7531 accept one argument, saying what to do:
7533 <taglist>
7534 <tag><tt>start</tt></tag>
7535 <item>start the service,</item>
7537 <tag><tt>stop</tt></tag>
7538 <item>stop the service,</item>
7540 <tag><tt>restart</tt></tag>
7541 <item>stop and restart the service if it's already running,
7542 otherwise start the service</item>
7544 <tag><tt>reload</tt></tag>
7545 <item><p>cause the configuration of the service to be
7546 reloaded without actually stopping and restarting
7547 the service,</item>
7549 <tag><tt>force-reload</tt></tag>
7550 <item>cause the configuration to be reloaded if the
7551 service supports this, otherwise restart the
7552 service.</item>
7553 </taglist>
7555 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
7556 <tt>force-reload</tt> options should be supported by all
7557 scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
7558 option is optional.
7559 </p>
7562 The <file>init.d</file> scripts must ensure that they will
7563 behave sensibly (i.e., returning success and not starting
7564 multiple copies of a service) if invoked with <tt>start</tt>
7565 when the service is already running, or with <tt>stop</tt>
7566 when it isn't, and that they don't kill unfortunately-named
7567 user processes. The best way to achieve this is usually to
7568 use <prgn>start-stop-daemon</prgn> with the <tt>--oknodo</tt>
7569 option.
7570 </p>
7573 Be careful of using <tt>set -e</tt> in <file>init.d</file>
7574 scripts. Writing correct <file>init.d</file> scripts requires
7575 accepting various error exit statuses when daemons are already
7576 running or already stopped without aborting
7577 the <file>init.d</file> script, and common <file>init.d</file>
7578 function libraries are not safe to call with <tt>set -e</tt>
7579 in effect<footnote>
7580 <tt>/lib/lsb/init-functions</tt>, which assists in writing
7581 LSB-compliant init scripts, may fail if <tt>set -e</tt> is
7582 in effect and echoing status messages to the console fails,
7583 for example.
7584 </footnote>. For <tt>init.d</tt> scripts, it's often easier
7585 to not use <tt>set -e</tt> and instead check the result of
7586 each command separately.
7587 </p>
7590 If a service reloads its configuration automatically (as
7591 in the case of <prgn>cron</prgn>, for example), the
7592 <tt>reload</tt> option of the <file>init.d</file> script
7593 should behave as if the configuration has been reloaded
7594 successfully.
7595 </p>
7598 The <file>/etc/init.d</file> scripts must be treated as
7599 configuration files, either (if they are present in the
7600 package, that is, in the .deb file) by marking them as
7601 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
7602 by managing them correctly in the maintainer scripts (see
7603 <ref id="config-files">). This is important since we want
7604 to give the local system administrator the chance to adapt
7605 the scripts to the local system, e.g., to disable a
7606 service without de-installing the package, or to specify
7607 some special command line options when starting a service,
7608 while making sure their changes aren't lost during the next
7609 package upgrade.
7610 </p>
7613 These scripts should not fail obscurely when the
7614 configuration files remain but the package has been
7615 removed, as configuration files remain on the system after
7616 the package has been removed. Only when <prgn>dpkg</prgn>
7617 is executed with the <tt>--purge</tt> option will
7618 configuration files be removed. In particular, as the
7619 <file>/etc/init.d/<var>package</var></file> script itself is
7620 usually a <tt>conffile</tt>, it will remain on the system
7621 if the package is removed but not purged. Therefore, you
7622 should include a <tt>test</tt> statement at the top of the
7623 script, like this:
7624 <example compact="compact">
7625 test -f <var>program-executed-later-in-script</var> || exit 0
7626 </example>
7627 </p>
7630 Often there are some variables in the <file>init.d</file>
7631 scripts whose values control the behavior of the scripts,
7632 and which a system administrator is likely to want to
7633 change. As the scripts themselves are frequently
7634 <tt>conffile</tt>s, modifying them requires that the
7635 administrator merge in their changes each time the package
7636 is upgraded and the <tt>conffile</tt> changes. To ease
7637 the burden on the system administrator, such configurable
7638 values should not be placed directly in the script.
7639 Instead, they should be placed in a file in
7640 <file>/etc/default</file>, which typically will have the same
7641 base name as the <file>init.d</file> script. This extra file
7642 should be sourced by the script when the script runs. It
7643 must contain only variable settings and comments in SUSv3
7644 <prgn>sh</prgn> format. It may either be a
7645 <tt>conffile</tt> or a configuration file maintained by
7646 the package maintainer scripts. See <ref id="config-files">
7647 for more details.
7648 </p>
7651 To ensure that vital configurable values are always
7652 available, the <file>init.d</file> script should set default
7653 values for each of the shell variables it uses, either
7654 before sourcing the <file>/etc/default/</file> file or
7655 afterwards using something like the <tt>:
7656 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
7657 script must behave sensibly and not fail if the
7658 <file>/etc/default</file> file is deleted.
7659 </p>
7662 Files and directories under <file>/run</file>, including ones
7663 referred to via the compatibility paths <file>/var/run</file>
7664 and <file>/var/lock</file>, are normally stored on a temporary
7665 filesystem and are normally not persistent across a reboot.
7666 The <file>init.d</file> scripts must handle this correctly.
7667 This will typically mean creating any required subdirectories
7668 dynamically when the <file>init.d</file> script is run.
7669 See <ref id="fhs-run"> for more information.
7670 </p>
7671 </sect1>
7673 <sect1>
7674 <heading>Interfacing with the initscript system</heading>
7677 Maintainers should use the abstraction layer provided by
7678 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
7679 programs to deal with initscripts in their packages'
7680 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
7681 and <prgn>postrm</prgn>.
7682 </p>
7685 Directly managing the /etc/rc?.d links and directly
7686 invoking the <file>/etc/init.d/</file> initscripts should
7687 be done only by packages providing the initscript
7688 subsystem (such as <prgn>sysv-rc</prgn> and
7689 <prgn>file-rc</prgn>).
7690 </p>
7692 <sect2>
7693 <heading>Managing the links</heading>
7696 The program <prgn>update-rc.d</prgn> is provided for
7697 package maintainers to arrange for the proper creation and
7698 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
7699 or their functional equivalent if another method is being
7700 used. This may be used by maintainers in their packages'
7701 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.
7702 </p>
7705 You must not include any <file>/etc/rc<var>n</var>.d</file>
7706 symbolic links in the actual archive or manually create or
7707 remove the symbolic links in maintainer scripts; you must
7708 use the <prgn>update-rc.d</prgn> program instead. (The
7709 former will fail if an alternative method of maintaining
7710 runlevel information is being used.) You must not include
7711 the <file>/etc/rc<var>n</var>.d</file> directories themselves
7712 in the archive either. (Only the <tt>sysvinit</tt>
7713 package may do so.)
7714 </p>
7717 By default <prgn>update-rc.d</prgn> will start services in
7718 each of the multi-user state runlevels (2, 3, 4, and 5)
7719 and stop them in the halt runlevel (0), the single-user
7720 runlevel (1) and the reboot runlevel (6). The system
7721 administrator will have the opportunity to customize
7722 runlevels by simply adding, moving, or removing the
7723 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
7724 symbolic links are being used, or by modifying
7725 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
7726 is being used.
7727 </p>
7730 To get the default behavior for your package, put in your
7731 <prgn>postinst</prgn> script
7732 <example compact="compact">
7733 update-rc.d <var>package</var> defaults
7734 </example>
7735 and in your <prgn>postrm</prgn>
7736 <example compact="compact">
7737 if [ "$1" = purge ]; then
7738 update-rc.d <var>package</var> remove
7740 </example>. Note that if your package changes runlevels
7741 or priority, you may have to remove and recreate the links,
7742 since otherwise the old links may persist. Refer to the
7743 documentation of <prgn>update-rc.d</prgn>.
7744 </p>
7747 This will use a default sequence number of 20. If it does
7748 not matter when or in which order the <file>init.d</file>
7749 script is run, use this default. If it does, then you
7750 should talk to the maintainer of the <prgn>sysvinit</prgn>
7751 package or post to <tt>debian-devel</tt>, and they will
7752 help you choose a number.
7753 </p>
7756 For more information about using <tt>update-rc.d</tt>,
7757 please consult its man page <manref name="update-rc.d"
7758 section="8">.
7759 </p>
7760 </sect2>
7762 <sect2>
7763 <heading>Running initscripts</heading>
7765 The program <prgn>invoke-rc.d</prgn> is provided to make
7766 it easier for package maintainers to properly invoke an
7767 initscript, obeying runlevel and other locally-defined
7768 constraints that might limit a package's right to start,
7769 stop and otherwise manage services. This program may be
7770 used by maintainers in their packages' scripts.
7771 </p>
7774 The package maintainer scripts must use
7775 <prgn>invoke-rc.d</prgn> to invoke the
7776 <file>/etc/init.d/*</file> initscripts, instead of
7777 calling them directly.
7778 </p>
7781 By default, <prgn>invoke-rc.d</prgn> will pass any
7782 action requests (start, stop, reload, restart...) to the
7783 <file>/etc/init.d</file> script, filtering out requests
7784 to start or restart a service out of its intended
7785 runlevels.
7786 </p>
7789 Most packages will simply need to change:
7790 <example compact="compact">/etc/init.d/&lt;package&gt;
7791 &lt;action&gt;</example> in their <prgn>postinst</prgn>
7792 and <prgn>prerm</prgn> scripts to:
7793 <example compact="compact">
7794 if which invoke-rc.d >/dev/null 2>&1; then
7795 invoke-rc.d <var>package</var> &lt;action&gt;
7796 else
7797 /etc/init.d/<var>package</var> &lt;action&gt;
7799 </example>
7800 </p>
7803 A package should register its initscript services using
7804 <prgn>update-rc.d</prgn> before it tries to invoke them
7805 using <prgn>invoke-rc.d</prgn>. Invocation of
7806 unregistered services may fail.
7807 </p>
7810 For more information about using
7811 <prgn>invoke-rc.d</prgn>, please consult its man page
7812 <manref name="invoke-rc.d" section="8">.
7813 </p>
7814 </sect2>
7815 </sect1>
7817 <sect1>
7818 <heading>Boot-time initialization</heading>
7821 There used to be another directory, <file>/etc/rc.boot</file>,
7822 which contained scripts which were run once per machine
7823 boot. This has been deprecated in favour of links from
7824 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
7825 described in <ref id="/etc/init.d">. Packages must not
7826 place files in <file>/etc/rc.boot</file>.
7827 </p>
7828 </sect1>
7830 <sect1>
7831 <heading>Example</heading>
7834 An example on which you can base your
7835 <file>/etc/init.d</file> scripts is found in
7836 <file>/etc/init.d/skeleton</file>.
7837 </p>
7839 </sect1>
7840 </sect>
7842 <sect>
7843 <heading>Console messages from <file>init.d</file> scripts</heading>
7846 This section describes the formats to be used for messages
7847 written to standard output by the <file>/etc/init.d</file>
7848 scripts. The intent is to improve the consistency of
7849 Debian's startup and shutdown look and feel. For this
7850 reason, please look very carefully at the details. We want
7851 the messages to have the same format in terms of wording,
7852 spaces, punctuation and case of letters.
7853 </p>
7856 Here is a list of overall rules that should be used for
7857 messages generated by <file>/etc/init.d</file> scripts.
7858 </p>
7861 <list>
7862 <item>
7863 The message should fit in one line (fewer than 80
7864 characters), start with a capital letter and end with
7865 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
7866 </item>
7868 <item>
7869 If the script is performing some time consuming task in
7870 the background (not merely starting or stopping a
7871 program, for instance), an ellipsis (three dots:
7872 <tt>...</tt>) should be output to the screen, with no
7873 leading or tailing whitespace or line feeds.
7874 </item>
7876 <item>
7877 The messages should appear as if the computer is telling
7878 the user what it is doing (politely :-), but should not
7879 mention "it" directly. For example, instead of:
7880 <example compact="compact">
7881 I'm starting network daemons: nfsd mountd.
7882 </example>
7883 the message should say
7884 <example compact="compact">
7885 Starting network daemons: nfsd mountd.
7886 </example>
7887 </item>
7888 </list>
7889 </p>
7892 <tt>init.d</tt> script should use the following standard
7893 message formats for the situations enumerated below.
7894 </p>
7897 <list>
7898 <item>
7899 <p>When daemons are started</p>
7902 If the script starts one or more daemons, the output
7903 should look like this (a single line, no leading
7904 spaces):
7905 <example compact="compact">
7906 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
7907 </example>
7908 The <var>description</var> should describe the
7909 subsystem the daemon or set of daemons are part of,
7910 while <var>daemon-1</var> up to <var>daemon-n</var>
7911 denote each daemon's name (typically the file name of
7912 the program).
7913 </p>
7916 For example, the output of <file>/etc/init.d/lpd</file>
7917 would look like:
7918 <example compact="compact">
7919 Starting printer spooler: lpd.
7920 </example>
7921 </p>
7924 This can be achieved by saying
7925 <example compact="compact">
7926 echo -n "Starting printer spooler: lpd"
7927 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
7928 echo "."
7929 </example>
7930 in the script. If there are more than one daemon to
7931 start, the output should look like this:
7932 <example compact="compact">
7933 echo -n "Starting remote file system services:"
7934 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
7935 echo -n " mountd"; start-stop-daemon --start --quiet mountd
7936 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
7937 echo "."
7938 </example>
7939 This makes it possible for the user to see what is
7940 happening and when the final daemon has been started.
7941 Care should be taken in the placement of white spaces:
7942 in the example above the system administrators can
7943 easily comment out a line if they don't want to start
7944 a specific daemon, while the displayed message still
7945 looks good.
7946 </p>
7947 </item>
7949 <item>
7950 <p>When a system parameter is being set</p>
7953 If you have to set up different system parameters
7954 during the system boot, you should use this format:
7955 <example compact="compact">
7956 Setting <var>parameter</var> to "<var>value</var>".
7957 </example>
7958 </p>
7961 You can use a statement such as the following to get
7962 the quotes right:
7963 <example compact="compact">
7964 echo "Setting DNS domainname to \"$domainname\"."
7965 </example>
7966 </p>
7969 Note that the same symbol (<tt>"</tt>) <!-- " --> is used
7970 for the left and right quotation marks. A grave accent
7971 (<tt>`</tt>) is not a quote character; neither is an
7972 apostrophe (<tt>'</tt>).
7973 </p>
7974 </item>
7976 <item>
7977 <p>When a daemon is stopped or restarted</p>
7980 When you stop or restart a daemon, you should issue a
7981 message identical to the startup message, except that
7982 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
7983 or <tt>Restarting</tt> respectively.
7984 </p>
7987 For example, stopping the printer daemon will look like
7988 this:
7989 <example compact="compact">
7990 Stopping printer spooler: lpd.
7991 </example>
7992 </p>
7993 </item>
7995 <item>
7996 <p>When something is executed</p>
7999 There are several examples where you have to run a
8000 program at system startup or shutdown to perform a
8001 specific task, for example, setting the system's clock
8002 using <prgn>netdate</prgn> or killing all processes
8003 when the system shuts down. Your message should look
8004 like this:
8005 <example compact="compact">
8006 Doing something very useful...done.
8007 </example>
8008 You should print the <tt>done.</tt> immediately after
8009 the job has been completed, so that the user is
8010 informed why they have to wait. You can get this
8011 behavior by saying
8012 <example compact="compact">
8013 echo -n "Doing something very useful..."
8014 do_something
8015 echo "done."
8016 </example>
8017 in your script.
8018 </p>
8019 </item>
8021 <item>
8022 <p>When the configuration is reloaded</p>
8025 When a daemon is forced to reload its configuration
8026 files you should use the following format:
8027 <example compact="compact">
8028 Reloading <var>description</var> configuration...done.
8029 </example>
8030 where <var>description</var> is the same as in the
8031 daemon starting message.
8032 </p>
8033 </item>
8034 </list>
8035 </p>
8036 </sect>
8038 <sect id="cron-jobs">
8039 <heading>Cron jobs</heading>
8042 Packages must not modify the configuration file
8043 <file>/etc/crontab</file>, and they must not modify the files in
8044 <file>/var/spool/cron/crontabs</file>.
8045 </p>
8048 If a package wants to install a job that has to be executed via
8049 cron, it should place a file named as specified
8050 in <ref id="cron-files"> into one or more of the following
8051 directories:
8052 <example compact="compact">
8053 /etc/cron.hourly
8054 /etc/cron.daily
8055 /etc/cron.weekly
8056 /etc/cron.monthly
8057 </example>
8058 As these directory names imply, the files within them are
8059 executed on an hourly, daily, weekly, or monthly basis,
8060 respectively. The exact times are listed in
8061 <file>/etc/crontab</file>.
8062 </p>
8065 All files installed in any of these directories must be
8066 scripts (e.g., shell scripts or Perl scripts) so that they
8067 can easily be modified by the local system administrator.
8068 In addition, they must be treated as configuration files.
8069 </p>
8072 If a certain job has to be executed at some other frequency or
8073 at a specific time, the package should install a file in
8074 <file>/etc/cron.d</file> with a name as specified
8075 in <ref id="cron-files">. This file uses the same syntax
8076 as <file>/etc/crontab</file> and is processed
8077 by <prgn>cron</prgn> automatically. The file must also be
8078 treated as a configuration file. (Note that entries in the
8079 <file>/etc/cron.d</file> directory are not handled by
8080 <prgn>anacron</prgn>. Thus, you should only use this
8081 directory for jobs which may be skipped if the system is not
8082 running.)
8083 </p>
8086 Unlike <file>crontab</file> files described in the IEEE Std
8087 1003.1-2008 (POSIX.1) available from
8088 <url id="http://www.opengroup.org/onlinepubs/9699919799/"
8089 name="The Open Group">, the files in
8090 <file>/etc/cron.d</file> and the file
8091 <file>/etc/crontab</file> have seven fields; namely:
8092 <enumlist>
8093 <item>Minute [0,59]</item>
8094 <item>Hour [0,23]</item>
8095 <item>Day of the month [1,31]</item>
8096 <item>Month of the year [1,12]</item>
8097 <item>Day of the week ([0,6] with 0=Sunday)</item>
8098 <item>Username</item>
8099 <item>Command to be run</item>
8100 </enumlist>
8101 Ranges of numbers are allowed. Ranges are two numbers
8102 separated with a hyphen. The specified range is inclusive.
8103 Lists are allowed. A list is a set of numbers (or ranges)
8104 separated by commas. Step values can be used in conjunction
8105 with ranges.
8106 </p>
8109 The scripts or <tt>crontab</tt> entries in these directories should
8110 check if all necessary programs are installed before they
8111 try to execute them. Otherwise, problems will arise when a
8112 package was removed but not purged since configuration files
8113 are kept on the system in this situation.
8114 </p>
8117 Any <tt>cron</tt> daemon must provide
8118 <file>/usr/bin/crontab</file> and support normal
8119 <tt>crontab</tt> entries as specified in POSIX. The daemon
8120 must also support names for days and months, ranges, and
8121 step values. It has to support <file>/etc/crontab</file>,
8122 and correctly execute the scripts in
8123 <file>/etc/cron.d</file>. The daemon must also correctly
8124 execute scripts in
8125 <file>/etc/cron.{hourly,daily,weekly,monthly}</file>.
8126 </p>
8128 <sect1 id="cron-files">
8129 <heading>Cron job file names</heading>
8132 The file name of a cron job file should normally match the
8133 name of the package from which it comes.
8134 </p>
8137 If a package supplies multiple cron job files files in the
8138 same directory, the file names should all start with the name
8139 of the package (possibly modified as described below) followed
8140 by a hyphen (<tt>-</tt>) and a suitable suffix.
8141 </p>
8144 A cron job file name must not include any period or plus
8145 characters (<tt>.</tt> or <tt>+</tt>) characters as this will
8146 cause cron to ignore the file. Underscores (<tt>_</tt>)
8147 should be used instead of <tt>.</tt> and <tt>+</tt>
8148 characters.
8149 </p>
8150 </sect1>
8151 </sect>
8153 <sect id="menus">
8154 <heading>Menus</heading>
8157 Packages shipping applications that comply with minimal requirements
8158 described below for integration with desktop environments should
8159 register these applications in the desktop menu, following the
8160 <em>FreeDesktop</em> standard, using text files called
8161 <em>desktop entries</em>. Their format is described in the
8162 <em>Desktop Entry Specification</em> at
8163 <url id="http://standards.freedesktop.org/desktop-entry-spec/latest/">
8164 and complementary information can be found in the
8165 <em>Desktop Menu Specification</em> at
8166 <url id="http://standards.freedesktop.org/menu-spec/latest/">.
8167 </p>
8170 The desktop entry files are installed by the packages in the
8171 directory <file>/usr/share/applications</file> and the FreeDesktop
8172 menus are refreshed using <em>dpkg triggers</em>. It is therefore
8173 not necessary to depend on packages providing FreeDesktop menu
8174 systems.
8175 </p>
8178 Entries displayed in the FreeDesktop menu should conform to the
8179 following minima for relevance and visual integration.
8181 <list>
8182 <item>
8183 Unless hidden by default, the desktop entry must point to a PNG
8184 or SVG icon with a transparent background, providing at least
8185 the 22&times;22 size, and preferably up to 64&times;64. The icon
8186 should be neutral enough to integrate well with the default icon
8187 themes. It is encouraged to ship the icon in the default
8188 <em>hicolor</em> icon theme directories, or to use an existing
8189 icon from the <em>hicolor</em> theme.
8190 </item>
8192 <item>
8193 If the menu entry is not useful in the general case as a
8194 standalone application, the desktop entry should set the
8195 <tt>NoDisplay</tt> key to <var>true</var>, so that it can be
8196 configured to be displayed only by those who need it.
8197 </item>
8199 <item>
8200 In doubt, the package maintainer should coordinate with the
8201 maintainers of menu implementations through the
8202 <em>debian-desktop</em> mailing list in order to avoid problems
8203 with categories or bad interactions with other icons. Especially
8204 for packages which are part of installation tasks, the contents
8205 of the <tt>NotShowIn</tt>/<tt>OnlyShowIn</tt> keys should be
8206 validated by the maintainers of the relevant environments.
8207 </item>
8208 </list>
8209 </p>
8212 Since the FreeDesktop menu is a cross-distribution standard, the
8213 desktop entries written for Debian should be forwarded upstream,
8214 where they will benefit to other users and are more likely to
8215 receive extra contributions such as translations.
8216 </p>
8219 Packages can, to be compatible with Debian additions to some window
8220 managers that do not support the FreeDesktop standard, also provide a
8221 <em>Debian menu</em> file, following the <em>Debian menu policy</em>,
8222 which can be found in the <tt>menu-policy</tt> files in the
8223 <tt>debian-policy</tt> package. It is also available from the Debian
8224 web mirrors at <tt><url name="/doc/packaging-manuals/menu-policy/"
8225 id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>.
8226 </p>
8227 </sect>
8229 <sect id="mime">
8230 <heading>Multimedia handlers</heading>
8233 Media types (formerly known as MIME types, Multipurpose Internet Mail
8234 Extensions, RFCs 2045-2049) is a mechanism for encoding files and
8235 data streams and providing meta-information about them, in particular
8236 their type and format (e.g. <tt>image/png</tt>, <tt>text/html</tt>,
8237 <tt>audio/ogg</tt>).
8238 </p>
8241 Registration of media type handlers allows programs like mail
8242 user agents and web browsers to invoke these handlers to
8243 view, edit or display media types they don't support directly.
8244 </p>
8247 There are two overlapping systems to associate media types to programs
8248 which can handle them. The <em>mailcap</em> system is found on a
8249 large number of Unix systems. The <em>FreeDesktop</em> system is
8250 aimed at Desktop environments. In Debian, FreeDesktop entries are
8251 automatically translated in mailcap entries, therefore packages
8252 already using desktop entries should not use the mailcap system
8253 directly.
8254 </p>
8256 <sect1 id="media-types-freedesktop">
8257 <heading>Registration of media type handlers with desktop entries</heading>
8260 Packages shipping an application able to view, edit or point to
8261 files of a given media type, or open links with a given URI scheme,
8262 should list it in the <tt>MimeType</tt> key of the application's
8263 <qref id="menus">desktop entry</qref>. For URI schemes,
8264 the relevant MIME types are <tt>x-scheme-handler/*</tt> (e.g.
8265 <tt>x-scheme-handler/https</tt>).
8266 </p>
8267 </sect1>
8269 <sect1 id="mailcap">
8270 <heading>Registration of media type handlers with mailcap entries</heading>
8273 Packages that are not using desktop entries for registration should
8274 install a file in <manref name="mailcap" section="5"> format (RFC
8275 1524) in the directory <file>/usr/lib/mime/packages/</file>. The
8276 file name should be the binary package's name.
8277 </p>
8280 The <package>mime-support</package> package provides the
8281 <prgn>update-mime</prgn> program, which integrates these
8282 registrations in the <file>/etc/mailcap</file> file, using dpkg
8283 triggers<footnote>
8284 Creating, modifying or removing a file in
8285 <file>/usr/lib/mime/packages/</file> using maintainer scripts will
8286 not activate the trigger. In that case, it can be done by calling
8287 <tt>dpkg-trigger --no-await /usr/lib/mime/packages</tt> from
8288 the maintainer script after creating, modifying, or removing
8289 the file.
8290 </footnote>.
8293 Packages installing desktop entries should not install mailcap
8294 entries for the same program, because the
8295 <package>mime-support</package> package already reads desktop
8296 entries.
8297 </p>
8300 Packages using these facilities <em>should not</em> depend on,
8301 recommend, or suggest <prgn>mime-support</prgn>.
8302 </p>
8303 </sect1>
8305 <sect1 id="file-media-type">
8306 <heading>Providing media types to files</heading>
8309 The media type of a file is discovered by inspecting the file's
8310 extension or its <manref name="magic" section="5"> pattern, and
8311 interrogating a database associating them with media types.
8312 </p>
8315 To support new associations between media types and files, their
8316 characteristic file extensions and magic patterns should be
8317 registered to the IANA (Internet Assigned Numbers Authority). See
8318 <url id="http://www.iana.org/assignments/media-types"> and RFC 6838
8319 for details. This information will then propagate to the systems
8320 discovering file media types in Debian, provided by the
8321 <package>shared-mime-info</package>,
8322 <package>mime-support</package> and <package>file</package>
8323 packages. If registration and propagation can not be waited for,
8324 support can be asked to the maintainers of the packages mentioned
8325 above.
8326 </p>
8329 For files that are produced and read by a single application, it
8330 is also possible to declare this association to the
8331 <em>Shared MIME Info</em> system by installing in the directory
8332 <file>/usr/share/mime/packages</file> a file in the XML format
8333 specified at <url id="http://standards.freedesktop.org/shared-mime-info-spec/latest/">.
8334 </p>
8335 </sect1>
8336 </sect>
8338 <sect>
8339 <heading>Keyboard configuration</heading>
8342 To achieve a consistent keyboard configuration so that all
8343 applications interpret a keyboard event the same way, all
8344 programs in the Debian distribution must be configured to
8345 comply with the following guidelines.
8346 </p>
8349 The following keys must have the specified interpretations:
8351 <taglist>
8352 <tag><tt>&lt;--</tt></tag>
8353 <item>delete the character to the left of the cursor</item>
8355 <tag><tt>Delete</tt></tag>
8356 <item>delete the character to the right of the cursor</item>
8358 <tag><tt>Control+H</tt></tag>
8359 <item>emacs: the help prefix</item>
8360 </taglist>
8362 The interpretation of any keyboard events should be
8363 independent of the terminal that is used, be it a virtual
8364 console, an X terminal emulator, an rlogin/telnet session,
8365 etc.
8366 </p>
8369 The following list explains how the different programs
8370 should be set up to achieve this:
8371 </p>
8374 <list>
8375 <item>
8376 <tt>&lt;--</tt> generates <tt>KB_BackSpace</tt> in X.
8377 </item>
8379 <item>
8380 <tt>Delete</tt> generates <tt>KB_Delete</tt> in X.
8381 </item>
8383 <item>
8384 X translations are set up to make
8385 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
8386 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
8387 is the vt220 escape code for the "delete character"
8388 key). This must be done by loading the X resources
8389 using <prgn>xrdb</prgn> on all local X displays, not
8390 using the application defaults, so that the
8391 translation resources used correspond to the
8392 <prgn>xmodmap</prgn> settings.
8393 </item>
8395 <item>
8396 The Linux console is configured to make
8397 <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
8398 generate <tt>ESC [ 3 ~</tt>.
8399 </item>
8401 <item>
8402 X applications are configured so that <tt>&lt;</tt>
8403 deletes left, and <tt>Delete</tt> deletes right. Motif
8404 applications already work like this.
8405 </item>
8407 <item>
8408 Terminals should have <tt>stty erase ^?</tt> .
8409 </item>
8411 <item>
8412 The <tt>xterm</tt> terminfo entry should have <tt>ESC
8413 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
8414 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.
8415 </item>
8417 <item>
8418 Emacs is programmed to map <tt>KB_Backspace</tt> or
8419 the <tt>stty erase</tt> character to
8420 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
8421 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
8422 <tt>^H</tt> to <tt>help</tt> as always.
8423 </item>
8425 <item>
8426 Other applications use the <tt>stty erase</tt>
8427 character and <tt>kdch1</tt> for the two delete keys,
8428 with ASCII DEL being "delete previous character" and
8429 <tt>kdch1</tt> being "delete character under
8430 cursor".
8431 </item>
8433 </list>
8434 </p>
8437 This will solve the problem except for the following
8438 cases:
8439 </p>
8442 <list>
8443 <item>
8444 Some terminals have a <tt>&lt;--</tt> key that cannot
8445 be made to produce anything except <tt>^H</tt>. On
8446 these terminals Emacs help will be unavailable on
8447 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
8448 character takes precedence in Emacs, and has been set
8449 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
8450 available) can be used instead.
8451 </item>
8453 <item>
8454 Some operating systems use <tt>^H</tt> for <tt>stty
8455 erase</tt>. However, modern telnet versions and all
8456 rlogin versions propagate <tt>stty</tt> settings, and
8457 almost all UNIX versions honour <tt>stty erase</tt>.
8458 Where the <tt>stty</tt> settings are not propagated
8459 correctly, things can be made to work by using
8460 <tt>stty</tt> manually.
8461 </item>
8463 <item>
8464 Some systems (including previous Debian versions) use
8465 <prgn>xmodmap</prgn> to arrange for both
8466 <tt>&lt;--</tt> and <tt>Delete</tt> to generate
8467 <tt>KB_Delete</tt>. We can change the behavior of
8468 their X clients using the same X resources that we use
8469 to do it for our own clients, or configure our clients
8470 using their resources when things are the other way
8471 around. On displays configured like this
8472 <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
8473 will.
8474 </item>
8476 <item>
8477 Some operating systems have different <tt>kdch1</tt>
8478 settings in their <tt>terminfo</tt> database for
8479 <tt>xterm</tt> and others. On these systems the
8480 <tt>Delete</tt> key will not work correctly when you
8481 log in from a system conforming to our policy, but
8482 <tt>&lt;--</tt> will.
8483 </item>
8484 </list>
8485 </p>
8486 </sect>
8488 <sect>
8489 <heading>Environment variables</heading>
8492 A program must not depend on environment variables to get
8493 reasonable defaults. (That's because these environment
8494 variables would have to be set in a system-wide
8495 configuration file like <file>/etc/profile</file>, which is not
8496 supported by all shells.)
8497 </p>
8500 If a program usually depends on environment variables for its
8501 configuration, the program should be changed to fall back to
8502 a reasonable default configuration if these environment
8503 variables are not present. If this cannot be done easily
8504 (e.g., if the source code of a non-free program is not
8505 available), the program must be replaced by a small
8506 "wrapper" shell script which sets the environment variables
8507 if they are not already defined, and calls the original program.
8508 </p>
8511 Here is an example of a wrapper script for this purpose:
8513 <example compact="compact">
8514 #!/bin/sh
8515 BAR=${BAR:-/var/lib/fubar}
8516 export BAR
8517 exec /usr/lib/foo/foo "$@"
8518 </example>
8519 </p>
8522 Furthermore, as <file>/etc/profile</file> is a configuration
8523 file of the <prgn>base-files</prgn> package, other packages must
8524 not put any environment variables or other commands into that
8525 file.
8526 </p>
8527 </sect>
8529 <sect id="doc-base">
8530 <heading>Registering Documents using doc-base</heading>
8533 The <package>doc-base</package> package implements a
8534 flexible mechanism for handling and presenting
8535 documentation. The recommended practice is for every Debian
8536 package that provides online documentation (other than just
8537 manual pages) to register these documents with
8538 <package>doc-base</package> by installing a
8539 <package>doc-base</package> control file in
8540 <file>/usr/share/doc-base/</file>.
8541 </p>
8543 Please refer to the documentation that comes with the
8544 <package>doc-base</package> package for information and
8545 details.
8546 </p>
8547 </sect>
8549 <sect id="alternateinit">
8550 <heading>Alternate init systems</heading>
8552 A number of other init systems are available now in Debian that
8553 can be used in place of <package>sysvinit</package>. Alternative
8554 init implementations must support running SysV init scripts as
8555 described at <ref id="sysvinit"> for compatibility.
8556 </p>
8558 Packages may integrate with these replacement init systems by
8559 providing implementation-specific configuration information about
8560 how and when to start a service or in what order to run certain
8561 tasks at boot time. However, any package integrating with other
8562 init systems must also be backwards-compatible with
8563 <package>sysvinit</package> by providing a SysV-style init script
8564 with the same name as and equivalent functionality to any
8565 init-specific job, as this is the only start-up configuration
8566 method guaranteed to be supported by all init implementations. An
8567 exception to this rule is scripts or jobs provided by the init
8568 implementation itself; such jobs may be required for an
8569 implementation-specific equivalent of the <file>/etc/rcS.d/</file>
8570 scripts and may not have a one-to-one correspondence with the init
8571 scripts.
8572 </p>
8573 <sect1 id="upstart">
8574 <heading>Event-based boot with upstart</heading>
8577 Packages may integrate with the <prgn>upstart</prgn> event-based
8578 boot system by installing job files in the
8579 <file>/etc/init</file> directory. SysV init scripts for which
8580 an equivalent upstart job is available must query the output of
8581 the command <prgn>initctl version</prgn> for the string
8582 <tt>upstart</tt> and avoid running in favor of the native
8583 upstart job, using a test such as this:
8584 <example compact="compact">
8585 if [ "$1" = start ] && which initctl >/dev/null && initctl version | grep -q upstart
8586 then
8587 exit 1
8589 </example>
8590 </p>
8592 Because packages shipping upstart jobs may be installed on
8593 systems that are not using upstart, maintainer scripts must
8594 still use the common <prgn>update-rc.d</prgn> and
8595 <prgn>invoke-rc.d</prgn> interfaces for configuring runlevels
8596 and for starting and stopping services. These maintainer
8597 scripts must not call the upstart <prgn>start</prgn>,
8598 <prgn>restart</prgn>, <prgn>reload</prgn>, or <prgn>stop</prgn>
8599 interfaces directly. Instead, implementations of
8600 <prgn>invoke-rc.d</prgn> must detect when upstart is running and
8601 when an upstart job with the same name as an init script is
8602 present, and perform the requested action using the upstart job
8603 instead of the init script.
8604 </p>
8606 Dependency-based boot managers for SysV init scripts, such as
8607 <prgn>startpar</prgn>, may avoid running a given init script
8608 entirely when an equivalent upstart job is present, to avoid
8609 unnecessary forking of no-op init scripts. In this case, the
8610 boot manager should integrate with upstart to detect when the
8611 upstart job in question is started or stopped to know when the
8612 dependency has been satisfied.
8613 </p>
8614 </sect1>
8615 </sect>
8617 </chapt>
8620 <chapt id="files">
8621 <heading>Files</heading>
8623 <sect id="binaries">
8624 <heading>Binaries</heading>
8627 Two different packages must not install programs with
8628 different functionality but with the same filenames. (The
8629 case of two programs having the same functionality but
8630 different implementations is handled via "alternatives" or
8631 the "Conflicts" mechanism. See <ref id="maintscripts"> and
8632 <ref id="conflicts"> respectively.) If this case happens,
8633 one of the programs must be renamed. The maintainers should
8634 report this to the <tt>debian-devel</tt> mailing list and
8635 try to find a consensus about which program will have to be
8636 renamed. If a consensus cannot be reached, <em>both</em>
8637 programs must be renamed.
8638 </p>
8640 To support merged-<file>/usr</file> systems, packages must not
8641 install files in both <file><var>path</var></file>
8642 and <file>/usr/<var>path</var></file>. For example, a package
8643 may not install both <file>/bin/example</file>
8644 and <file>/usr/bin/example</file>.
8645 </p>
8647 If a file is moved between <file><var>path</var></file>
8648 and <file>/usr/<var>path</var></file> in revisions of a Debian
8649 package, and a compatibility symlink at the old path is needed,
8650 the symlink must be managed in a way that will not break
8651 when <file><var>path</var></file>
8652 and <file>/usr/<var>path</var></file> are the same underlying
8653 directory due to symlinks or other mechanisms.
8654 </p>
8656 Binary executables must not be statically linked with the GNU C
8657 library, since this prevents the binary from benefiting from
8658 fixes and improvements to the C library without being rebuilt
8659 and complicates security updates. This requirement may be
8660 relaxed for binary executables whose intended purpose is to
8661 diagnose and fix the system in situations where the GNU C
8662 library may not be usable (such as system recovery shells or
8663 utilities like ldconfig) or for binary executables where the
8664 security benefits of static linking outweigh the drawbacks.
8665 </p>
8667 By default, when a package is being built, any binaries
8668 created should include debugging information, as well as
8669 being compiled with optimization. You should also turn on
8670 as many reasonable compilation warnings as possible; this
8671 makes life easier for porters, who can then look at build
8672 logs for possible problems. For the C programming language,
8673 this means the following compilation parameters should be
8674 used:
8675 <example compact="compact">
8676 CC = gcc
8677 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
8678 LDFLAGS = # none
8679 INSTALL = install -s # (or use strip on the files in debian/tmp)
8680 </example>
8681 </p>
8684 Note that by default all installed binaries should be stripped,
8685 either by using the <tt>-s</tt> flag to
8686 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
8687 the binaries after they have been copied into
8688 <file>debian/tmp</file> but before the tree is made into a
8689 package.
8690 </p>
8693 Although binaries in the build tree should be compiled with
8694 debugging information by default, it can often be difficult to
8695 debug programs if they are also subjected to compiler
8696 optimization. For this reason, it is recommended to support the
8697 standardized environment variable <tt>DEB_BUILD_OPTIONS</tt>
8698 (see <ref id="debianrules-options">). This variable can contain
8699 several flags to change how a package is compiled and built.
8700 </p>
8703 It is up to the package maintainer to decide what
8704 compilation options are best for the package. Certain
8705 binaries (such as computationally-intensive programs) will
8706 function better with certain flags (<tt>-O3</tt>, for
8707 example); feel free to use them. Please use good judgment
8708 here. Don't use flags for the sake of it; only use them
8709 if there is good reason to do so. Feel free to override
8710 the upstream author's ideas about which compilation
8711 options are best: they are often inappropriate for our
8712 environment.
8713 </p>
8714 </sect>
8717 <sect id="libraries">
8718 <heading>Libraries</heading>
8721 If the package is <strong>architecture: any</strong>, then
8722 the shared library compilation and linking flags must have
8723 <tt>-fPIC</tt>, or the package shall not build on some of
8724 the supported architectures<footnote>
8726 If you are using GCC, <tt>-fPIC</tt> produces code with
8727 relocatable position independent code, which is required for
8728 most architectures to create a shared library, with i386 and
8729 perhaps some others where non position independent code is
8730 permitted in a shared library.
8731 </p>
8733 Position independent code may have a performance penalty,
8734 especially on <tt>i386</tt>. However, in most cases the
8735 speed penalty must be measured against the memory wasted on
8736 the few architectures where non position independent code is
8737 even possible.
8738 </p>
8739 </footnote>. Any exception to this rule must be discussed on
8740 the mailing list <em>debian-devel@lists.debian.org</em>, and
8741 a rough consensus obtained. The reasons for not compiling
8742 with <tt>-fPIC</tt> flag must be recorded in the file
8743 <tt>README.Debian</tt>, and care must be taken to either
8744 restrict the architecture or arrange for <tt>-fPIC</tt> to
8745 be used on architectures where it is required.<footnote>
8747 Some of the reasons why this might be required is if the
8748 library contains hand crafted assembly code that is not
8749 relocatable, the speed penalty is excessive for compute
8750 intensive libs, and similar reasons.
8751 </p>
8752 </footnote>
8753 </p>
8755 As to the static libraries, the common case is not to have
8756 relocatable code, since there is no benefit, unless in specific
8757 cases; therefore the static version must not be compiled
8758 with the <tt>-fPIC</tt> flag. Any exception to this rule
8759 should be discussed on the mailing list
8760 <em>debian-devel@lists.debian.org</em>, and the reasons for
8761 compiling with the <tt>-fPIC</tt> flag must be recorded in
8762 the file <tt>README.Debian</tt>. <footnote>
8764 Some of the reasons for linking static libraries with
8765 the <tt>-fPIC</tt> flag are if, for example, one needs a
8766 Perl API for a library that is under rapid development,
8767 and has an unstable API, so shared libraries are
8768 pointless at this phase of the library's development. In
8769 that case, since Perl needs a library with relocatable
8770 code, it may make sense to create a static library with
8771 relocatable code. Another reason cited is if you are
8772 distilling various libraries into a common shared
8773 library, like <tt>mklibs</tt> does in the Debian
8774 installer project.
8775 </p>
8776 </footnote>
8777 </p>
8779 In other words, if both a shared and a static library is
8780 being built, each source unit (<tt>*.c</tt>, for example,
8781 for C files) will need to be compiled twice, for the normal
8782 case.
8783 </p>
8786 Libraries should be built with threading support and to be
8787 thread-safe if the library supports this.
8788 </p>
8791 Although not enforced by the build tools, shared libraries
8792 must be linked against all libraries that they use symbols from
8793 in the same way that binaries are. This ensures the correct
8794 functioning of the <qref id="sharedlibs-symbols">symbols</qref>
8795 and <qref id="sharedlibs-shlibdeps">shlibs</qref>
8796 systems and guarantees that all libraries can be safely opened
8797 with <tt>dlopen()</tt>. Packagers may wish to use the gcc
8798 option <tt>-Wl,-z,defs</tt> when building a shared library.
8799 Since this option enforces symbol resolution at build time,
8800 a missing library reference will be caught early as a fatal
8801 build error.
8802 </p>
8805 All installed shared libraries should be stripped with
8806 <example compact="compact">
8807 strip --strip-unneeded <var>your-lib</var>
8808 </example>
8809 (The option <tt>--strip-unneeded</tt> makes
8810 <prgn>strip</prgn> remove only the symbols which aren't
8811 needed for relocation processing.) Shared libraries can
8812 function perfectly well when stripped, since the symbols for
8813 dynamic linking are in a separate part of the ELF object
8814 file.<footnote>
8815 You might also want to use the options
8816 <tt>--remove-section=.comment</tt> and
8817 <tt>--remove-section=.note</tt> on both shared libraries
8818 and executables, and <tt>--strip-debug</tt> on static
8819 libraries.
8820 </footnote>
8821 </p>
8824 Note that under some circumstances it may be useful to
8825 install a shared library unstripped, for example when
8826 building a separate package to support debugging.
8827 </p>
8830 Shared object files (often <file>.so</file> files) that are not
8831 public libraries, that is, they are not meant to be linked
8832 to by third party executables (binaries of other packages),
8833 should be installed in subdirectories of the
8834 <file>/usr/lib</file> directory. Such files are exempt from the
8835 rules that govern ordinary shared libraries, except that
8836 they must not be installed executable and should be
8837 stripped.<footnote>
8838 A common example are the so-called "plug-ins",
8839 internal shared objects that are dynamically loaded by
8840 programs using <manref name="dlopen" section="3">.
8841 </footnote>
8842 </p>
8845 Packages that use <prgn>libtool</prgn> to create and install
8846 their shared libraries install a file containing additional
8847 metadata (ending in <file>.la</file>) alongside the library.
8848 For public libraries intended for use by other packages, these
8849 files normally should not be included in the Debian package,
8850 since the information they include is not necessary to link with
8851 the shared library on Debian and can add unnecessary additional
8852 dependencies to other programs or libraries.<footnote>
8853 These files store, among other things, all libraries on which
8854 that shared library depends. Unfortunately, if
8855 the <file>.la</file> file is present and contains that
8856 dependency information, using <prgn>libtool</prgn> when
8857 linking against that library will cause the resulting program
8858 or library to be linked against those dependencies as well,
8859 even if this is unnecessary. This can create unneeded
8860 dependencies on shared library packages that would otherwise
8861 be hidden behind the library ABI, and can make library
8862 transitions to new SONAMEs unnecessarily complicated and
8863 difficult to manage.
8864 </footnote>
8865 If the <file>.la</file> file is required for that library (if,
8866 for instance, it's loaded via <tt>libltdl</tt> in a way that
8867 requires that meta-information), the <tt>dependency_libs</tt>
8868 setting in the <file>.la</file> file should normally be set to
8869 the empty string. If the shared library development package has
8870 historically included the <file>.la</file>, it must be retained
8871 in the development package (with <tt>dependency_libs</tt>
8872 emptied) until all libraries that depend on it have removed or
8873 emptied <tt>dependency_libs</tt> in their <file>.la</file>
8874 files to prevent linking with those other libraries
8875 using <prgn>libtool</prgn> from failing.
8876 </p>
8879 If the <file>.la</file> must be included, it should be included
8880 in the development (<tt>-dev</tt>) package, unless the library
8881 will be loaded by <prgn>libtool</prgn>'s <tt>libltdl</tt>
8882 library. If it is intended for use with <tt>libltdl</tt>,
8883 the <file>.la</file> files must go in the run-time library
8884 package.
8885 </p>
8888 These requirements for handling of <file>.la</file> files do not
8889 apply to loadable modules or libraries not installed in
8890 directories searched by default by the dynamic linker. Packages
8891 installing loadable modules will frequently need to install
8892 the <file>.la</file> files alongside the modules so that they
8893 can be loaded by <tt>libltdl</tt>. <tt>dependency_libs</tt>
8894 does not need to be modified for libraries or modules that are
8895 not installed in directories searched by the dynamic linker by
8896 default and not intended for use by other packages.
8897 </p>
8900 You must make sure that you use only released versions of
8901 shared libraries to build your packages; otherwise other
8902 users will not be able to run your binaries
8903 properly. Producing source packages that depend on
8904 unreleased compilers is also usually a bad
8905 idea.
8906 </p>
8907 </sect>
8910 <sect>
8911 <heading>Shared libraries</heading>
8913 This section has moved to <ref id="sharedlibs">.
8914 </p>
8915 </sect>
8918 <sect id="scripts">
8919 <heading>Scripts</heading>
8922 All command scripts, including the package maintainer
8923 scripts inside the package and used by <prgn>dpkg</prgn>,
8924 should have a <tt>#!</tt> line naming the shell to be used
8925 to interpret them.
8926 </p>
8929 In the case of Perl scripts this should be
8930 <tt>#!/usr/bin/perl</tt>.
8931 </p>
8934 When scripts are installed into a directory in the system
8935 PATH, the script name should not include an extension such
8936 as <tt>.sh</tt> or <tt>.pl</tt> that denotes the scripting
8937 language currently used to implement it.
8938 </p>
8940 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>) other than
8941 <file>init.d</file> scripts should almost certainly start
8942 with <tt>set -e</tt> so that errors are detected.
8943 <file>init.d</file> scripts are something of a special case, due
8944 to how frequently they need to call commands that are allowed to
8945 fail, and it may instead be easier to check the exit status of
8946 commands directly. See <ref id="writing-init"> for more
8947 information about writing <file>init.d</file> scripts.
8948 </p>
8950 Every script should use <tt>set -e</tt> or check the exit status
8951 of <em>every</em> command.
8952 </p>
8954 Scripts may assume that <file>/bin/sh</file> implements the
8955 SUSv3 Shell Command Language<footnote>
8956 Single UNIX Specification, version 3, which is also IEEE
8957 1003.1-2004 (POSIX), and is available on the World Wide Web
8958 from <url id="http://www.unix.org/version3/online.html"
8959 name="The Open Group"> after free
8960 registration.</footnote>
8961 plus the following additional features not mandated by
8962 SUSv3:<footnote>
8963 These features are in widespread use in the Linux community
8964 and are implemented in all of bash, dash, and ksh, the most
8965 common shells users may wish to use as <file>/bin/sh</file>.
8966 </footnote>
8967 <list>
8968 <item><tt>echo -n</tt>, if implemented as a shell built-in,
8969 must not generate a newline.</item>
8970 <item><tt>test</tt>, if implemented as a shell built-in, must
8971 support <tt>-a</tt> and <tt>-o</tt> as binary logical
8972 operators.</item>
8973 <item><tt>local</tt> to create a scoped variable must be
8974 supported, including listing multiple variables in a single
8975 local command and assigning a value to a variable at the
8976 same time as localizing it. <tt>local</tt> may or
8977 may not preserve the variable value from an outer scope if
8978 no assignment is present. Uses such as:
8979 <example compact>
8980 fname () {
8981 local a b c=delta d
8982 # ... use a, b, c, d ...
8984 </example>
8985 must be supported and must set the value of <tt>c</tt> to
8986 <tt>delta</tt>.
8987 </item>
8988 <item>The XSI extension to <prgn>kill</prgn> allowing <tt>kill
8989 -<var>signal</var></tt>, where <var>signal</var> is either
8990 the name of a signal or one of the numeric signals listed in
8991 the XSI extension (0, 1, 2, 3, 6, 9, 14, and 15), must be
8992 supported if <prgn>kill</prgn> is implemented as a shell
8993 built-in.
8994 </item>
8995 <item>The XSI extension to <prgn>trap</prgn> allowing numeric
8996 signals must be supported. In addition to the signal
8997 numbers listed in the extension, which are the same as for
8998 <prgn>kill</prgn> above, 13 (SIGPIPE) must be allowed.
8999 </item>
9000 </list>
9001 If a shell script requires non-SUSv3 features from the shell
9002 interpreter other than those listed above, the appropriate shell
9003 must be specified in the first line of the script (e.g.,
9004 <tt>#!/bin/bash</tt>) and the package must depend on the package
9005 providing the shell (unless the shell package is marked
9006 "Essential", as in the case of <prgn>bash</prgn>).
9007 </p>
9010 You may wish to restrict your script to SUSv3 features plus the
9011 above set when possible so that it may use <file>/bin/sh</file>
9012 as its interpreter. Checking your script
9013 with <prgn>checkbashisms</prgn> from
9014 the <package>devscripts</package> package or running your script
9015 with an alternate shell such as <prgn>posh</prgn> may help
9016 uncover violations of the above requirements. If in doubt
9017 whether a script complies with these requirements,
9018 use <file>/bin/bash</file>.
9019 </p>
9022 Perl scripts should check for errors when making any
9023 system calls, including <tt>open</tt>, <tt>print</tt>,
9024 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
9025 </p>
9028 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
9029 scripting languages. See <em>Csh Programming Considered
9030 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
9031 can be found at <url id="http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/">.
9032 If an upstream package comes with <prgn>csh</prgn> scripts
9033 then you must make sure that they start with
9034 <tt>#!/bin/csh</tt> and make your package depend on the
9035 <prgn>c-shell</prgn> virtual package.
9036 </p>
9039 Any scripts which create files in world-writeable
9040 directories (e.g., in <file>/tmp</file>) must use a
9041 mechanism which will fail atomically if a file with the same
9042 name already exists.
9043 </p>
9046 The Debian base system provides the <prgn>tempfile</prgn>
9047 and <prgn>mktemp</prgn> utilities for use by scripts for
9048 this purpose.
9049 </p>
9050 </sect>
9053 <sect>
9054 <heading>Symbolic links</heading>
9057 In general, symbolic links within a top-level directory should
9058 be relative, and symbolic links pointing from one top-level
9059 directory to or into another should be absolute. (A top-level
9060 directory is a sub-directory of the root
9061 directory <file>/</file>.) For example, a symbolic link
9062 from <file>/usr/lib/foo</file> to <file>/usr/share/bar</file>
9063 should be relative (<file>../share/bar</file>), but a symbolic
9064 link from <file>/var/run</file> to <file>/run</file> should be
9065 absolute.<footnote>
9066 This is necessary to allow top-level directories to be
9067 symlinks. If linking <file>/var/run</file>
9068 to <file>/run</file> were done with the relative symbolic
9069 link <file>../run</file>, but <file>/var</file> were a
9070 symbolic link to <file>/srv/disk1</file>, the symbolic link
9071 would point to <file>/srv/run</file> rather than the intended
9072 target.
9073 </footnote>
9074 Symbolic links must not traverse above the root directory.
9075 </p>
9078 In addition, symbolic links should be specified as short as
9079 possible, i.e., link targets like <file>foo/../bar</file> are
9080 deprecated.
9081 </p>
9084 Note that when creating a relative link using
9085 <prgn>ln</prgn> it is not necessary for the target of the
9086 link to exist relative to the working directory you're
9087 running <prgn>ln</prgn> from, nor is it necessary to change
9088 directory to the directory where the link is to be made.
9089 Simply include the string that should appear as the target
9090 of the link (this will be a pathname relative to the
9091 directory in which the link resides) as the first argument
9092 to <prgn>ln</prgn>.
9093 </p>
9096 For example, in your <prgn>Makefile</prgn> or
9097 <file>debian/rules</file>, you can do things like:
9098 <example compact="compact">
9099 ln -fs gcc $(prefix)/bin/cc
9100 ln -fs gcc debian/tmp/usr/bin/cc
9101 ln -fs ../sbin/sendmail $(prefix)/bin/runq
9102 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
9103 </example>
9104 </p>
9107 A symbolic link pointing to a compressed file (in the sense
9108 that it is meant to be uncompressed with <prgn>unzip</prgn>
9109 or <prgn>zless</prgn> etc.) should always
9110 have the same file extension as the referenced file. (For
9111 example, if a file <file>foo.gz</file> is referenced by a
9112 symbolic link, the filename of the link has to end with
9113 "<file>.gz</file>" too, as in <file>bar.gz</file>.)
9114 </p>
9115 </sect>
9117 <sect>
9118 <heading>Device files</heading>
9121 Packages must not include device files or named pipes in the
9122 package file tree.
9123 </p>
9126 If a package needs any special device files that are not
9127 included in the base system, it must call
9128 <prgn>MAKEDEV</prgn> in the <prgn>postinst</prgn> script,
9129 after notifying the user<footnote>
9130 This notification could be done via a (low-priority)
9131 debconf message, or an echo (printf) statement.
9132 </footnote>.
9133 </p>
9136 Packages must not remove any device files in the
9137 <prgn>postrm</prgn> or any other script. This is left to the
9138 system administrator.
9139 </p>
9142 Debian uses the serial devices
9143 <file>/dev/ttyS*</file>. Programs using the old
9144 <file>/dev/cu*</file> devices should be changed to use
9145 <file>/dev/ttyS*</file>.
9146 </p>
9149 Named pipes needed by the package must be created in
9150 the <prgn>postinst</prgn> script<footnote>
9151 It's better to use <prgn>mkfifo</prgn> rather
9152 than <prgn>mknod</prgn> to create named pipes so that
9153 automated checks for packages incorrectly creating device
9154 files with <prgn>mknod</prgn> won't have false positives.
9155 </footnote> and removed in
9156 the <prgn>prerm</prgn> or <prgn>postrm</prgn> script as
9157 appropriate.
9158 </p>
9159 </sect>
9161 <sect id="config-files">
9162 <heading>Configuration files</heading>
9164 <sect1>
9165 <heading>Definitions</heading>
9168 <taglist>
9169 <tag>configuration file</tag>
9170 <item>
9171 A file that affects the operation of a program, or
9172 provides site- or host-specific information, or
9173 otherwise customizes the behavior of a program.
9174 Typically, configuration files are intended to be
9175 modified by the system administrator (if needed or
9176 desired) to conform to local policy or to provide
9177 more useful site-specific behavior.
9178 </item>
9180 <tag><tt>conffile</tt></tag>
9181 <item>
9182 A file listed in a package's <tt>conffiles</tt>
9183 file, and is treated specially by <prgn>dpkg</prgn>
9184 (see <ref id="configdetails">).
9185 </item>
9186 </taglist>
9187 </p>
9190 The distinction between these two is important; they are
9191 not interchangeable concepts. Almost all
9192 <tt>conffile</tt>s are configuration files, but many
9193 configuration files are not <tt>conffiles</tt>.
9194 </p>
9197 As noted elsewhere, <file>/etc/init.d</file> scripts,
9198 <file>/etc/default</file> files, scripts installed in
9199 <file>/etc/cron.{hourly,daily,weekly,monthly}</file>, and cron
9200 configuration installed in <file>/etc/cron.d</file> must be
9201 treated as configuration files. In general, any script that
9202 embeds configuration information is de-facto a configuration
9203 file and should be treated as such.
9204 </p>
9205 </sect1>
9207 <sect1>
9208 <heading>Location</heading>
9211 Any configuration files created or used by your package
9212 must reside in <file>/etc</file>. If there are several,
9213 consider creating a subdirectory of <file>/etc</file>
9214 named after your package.
9215 </p>
9218 If your package creates or uses configuration files
9219 outside of <file>/etc</file>, and it is not feasible to modify
9220 the package to use <file>/etc</file> directly, put the files
9221 in <file>/etc</file> and create symbolic links to those files
9222 from the location that the package requires.
9223 </p>
9224 </sect1>
9226 <sect1>
9227 <heading>Behavior</heading>
9230 Configuration file handling must conform to the following
9231 behavior:
9232 <list compact="compact">
9233 <item>
9234 local changes must be preserved during a package
9235 upgrade, and
9236 </item>
9237 <item>
9238 configuration files must be preserved when the
9239 package is removed, and only deleted when the
9240 package is purged.
9241 </item>
9242 </list>
9243 Obsolete configuration files without local changes should be
9244 removed by the package during upgrade.<footnote>
9245 The <prgn>dpkg-maintscript-helper</prgn> tool, available from the
9246 <package>dpkg</package> package, can help for this task.</footnote>
9247 </p>
9250 The easy way to achieve this behavior is to make the
9251 configuration file a <tt>conffile</tt>. This is
9252 appropriate only if it is possible to distribute a default
9253 version that will work for most installations, although
9254 some system administrators may choose to modify it. This
9255 implies that the default version will be part of the
9256 package distribution, and must not be modified by the
9257 maintainer scripts during installation (or at any other
9258 time).
9259 </p>
9262 In order to ensure that local changes are preserved
9263 correctly, no package may contain or make hard links to
9264 conffiles.<footnote>
9265 Rationale: There are two problems with hard links.
9266 The first is that some editors break the link while
9267 editing one of the files, so that the two files may
9268 unwittingly become unlinked and different. The second
9269 is that <prgn>dpkg</prgn> might break the hard link
9270 while upgrading <tt>conffile</tt>s.
9271 </footnote>
9272 </p>
9275 The other way to do it is via the maintainer scripts. In
9276 this case, the configuration file must not be listed as a
9277 <tt>conffile</tt> and must not be part of the package
9278 distribution. If the existence of a file is required for
9279 the package to be sensibly configured it is the
9280 responsibility of the package maintainer to provide
9281 maintainer scripts which correctly create, update and
9282 maintain the file and remove it on purge. (See <ref
9283 id="maintainerscripts"> for more information.) These
9284 scripts must be idempotent (i.e., must work correctly if
9285 <prgn>dpkg</prgn> needs to re-run them due to errors
9286 during installation or removal), must cope with all the
9287 variety of ways <prgn>dpkg</prgn> can call maintainer
9288 scripts, must not overwrite or otherwise mangle the user's
9289 configuration without asking, must not ask unnecessary
9290 questions (particularly during upgrades), and must
9291 otherwise be good citizens.
9292 </p>
9295 The scripts are not required to configure every possible
9296 option for the package, but only those necessary to get
9297 the package running on a given system. Ideally the
9298 sysadmin should not have to do any configuration other
9299 than that done (semi-)automatically by the
9300 <prgn>postinst</prgn> script.
9301 </p>
9304 A common practice is to create a script called
9305 <file><var>package</var>-configure</file> and have the
9306 package's <prgn>postinst</prgn> call it if and only if the
9307 configuration file does not already exist. In certain
9308 cases it is useful for there to be an example or template
9309 file which the maintainer scripts use. Such files should
9310 be in <file>/usr/share/<var>package</var></file> or
9311 <file>/usr/lib/<var>package</var></file> (depending on whether
9312 they are architecture-independent or not). There should
9313 be symbolic links to them from
9314 <file>/usr/share/doc/<var>package</var>/examples</file> if
9315 they are examples, and should be perfectly ordinary
9316 <prgn>dpkg</prgn>-handled files (<em>not</em>
9317 configuration files).
9318 </p>
9321 These two styles of configuration file handling must
9322 not be mixed, for that way lies madness:
9323 <prgn>dpkg</prgn> will ask about overwriting the file
9324 every time the package is upgraded.
9325 </p>
9326 </sect1>
9328 <sect1>
9329 <heading>Sharing configuration files</heading>
9332 If two or more packages use the same configuration file
9333 and it is reasonable for both to be installed at the same
9334 time, one of these packages must be defined as
9335 <em>owner</em> of the configuration file, i.e., it will be
9336 the package which handles that file as a configuration
9337 file. Other packages that use the configuration file must
9338 depend on the owning package if they require the
9339 configuration file to operate. If the other package will
9340 use the configuration file if present, but is capable of
9341 operating without it, no dependency need be declared.
9342 </p>
9345 If it is desirable for two or more related packages to
9346 share a configuration file <em>and</em> for all of the
9347 related packages to be able to modify that configuration
9348 file, then the following should be done:
9349 <enumlist compact="compact">
9350 <item>
9351 One of the related packages (the "owning" package)
9352 will manage the configuration file with maintainer
9353 scripts as described in the previous section.
9354 </item>
9355 <item>
9356 The owning package should also provide a program
9357 that the other packages may use to modify the
9358 configuration file.
9359 </item>
9360 <item>
9361 The related packages must use the provided program
9362 to make any desired modifications to the
9363 configuration file. They should either depend on
9364 the core package to guarantee that the configuration
9365 modifier program is available or accept gracefully
9366 that they cannot modify the configuration file if it
9367 is not. (This is in addition to the fact that the
9368 configuration file may not even be present in the
9369 latter scenario.)
9370 </item>
9371 </enumlist>
9372 </p>
9375 Sometimes it's appropriate to create a new package which
9376 provides the basic infrastructure for the other packages
9377 and which manages the shared configuration files. (The
9378 <tt>sgml-base</tt> package is a good example.)
9379 </p>
9382 If the configuration file cannot be shared as described above,
9383 the packages must be marked as conflicting with each other.
9384 Two packages that specify the same file as
9385 a <tt>conffile</tt> must conflict. This is an instance of the
9386 general rule about not sharing files. Neither alternatives
9387 nor diversions are likely to be appropriate in this case; in
9388 particular, <prgn>dpkg</prgn> does not handle diverted
9389 <tt>conffile</tt>s well.
9390 </p>
9393 When two packages both declare the same <tt>conffile</tt>, they
9394 may see left-over configuration files from each other even
9395 though they conflict with each other. If a user removes
9396 (without purging) one of the packages and installs the other,
9397 the new package will take over the <tt>conffile</tt> from the
9398 old package. If the file was modified by the user, it will be
9399 treated the same as any other locally
9400 modified <tt>conffile</tt> during an upgrade.
9401 </p>
9404 The maintainer scripts must not alter a <tt>conffile</tt>
9405 of <em>any</em> package, including the one the scripts
9406 belong to.
9407 </p>
9408 </sect1>
9410 <sect1>
9411 <heading>User configuration files ("dotfiles")</heading>
9414 The files in <file>/etc/skel</file> will automatically be
9415 copied into new user accounts by <prgn>adduser</prgn>.
9416 No other program should reference the files in
9417 <file>/etc/skel</file>.
9418 </p>
9421 Therefore, if a program needs a dotfile to exist in
9422 advance in <file>$HOME</file> to work sensibly, that dotfile
9423 should be installed in <file>/etc/skel</file> and treated as a
9424 configuration file.
9425 </p>
9428 However, programs that require dotfiles in order to
9429 operate sensibly are a bad thing, unless they do create
9430 the dotfiles themselves automatically.
9431 </p>
9434 Furthermore, programs should be configured by the Debian
9435 default installation to behave as closely to the upstream
9436 default behavior as possible.
9437 </p>
9440 Therefore, if a program in a Debian package needs to be
9441 configured in some way in order to operate sensibly, that
9442 should be done using a site-wide configuration file placed
9443 in <file>/etc</file>. Only if the program doesn't support a
9444 site-wide default configuration and the package maintainer
9445 doesn't have time to add it may a default per-user file be
9446 placed in <file>/etc/skel</file>.
9447 </p>
9450 <file>/etc/skel</file> should be as empty as we can make it.
9451 This is particularly true because there is no easy (or
9452 necessarily desirable) mechanism for ensuring that the
9453 appropriate dotfiles are copied into the accounts of
9454 existing users when a package is installed.
9455 </p>
9456 </sect1>
9457 </sect>
9459 <sect>
9460 <heading>Log files</heading>
9462 Log files should usually be named
9463 <file>/var/log/<var>package</var>.log</file>. If you have many
9464 log files, or need a separate directory for permission
9465 reasons (<file>/var/log</file> is writable only by
9466 <file>root</file>), you should usually create a directory named
9467 <file>/var/log/<var>package</var></file> and place your log
9468 files there.
9469 </p>
9472 Log files must be rotated occasionally so that they don't grow
9473 indefinitely. The best way to do this is to install a log
9474 rotation configuration file in the
9475 directory <file>/etc/logrotate.d</file>, normally
9476 named <file>/etc/logrotate.d/<var>package</var></file>, and use
9477 the facilities provided by <prgn>logrotate</prgn>.
9478 <footnote>
9480 The traditional approach to log files has been to set up
9481 <em>ad hoc</em> log rotation schemes using simple shell
9482 scripts and cron. While this approach is highly
9483 customizable, it requires quite a lot of sysadmin work.
9484 Even though the original Debian system helped a little
9485 by automatically installing a system which can be used
9486 as a template, this was deemed not enough.
9487 </p>
9490 The use of <prgn>logrotate</prgn>, a program developed
9491 by Red Hat, is better, as it centralizes log management.
9492 It has both a configuration file
9493 (<file>/etc/logrotate.conf</file>) and a directory where
9494 packages can drop their individual log rotation
9495 configurations (<file>/etc/logrotate.d</file>).
9496 </p>
9497 </footnote>
9498 Here is a good example for a logrotate config
9499 file (for more information see <manref name="logrotate"
9500 section="8">):
9501 <example compact="compact">
9502 /var/log/foo/*.log {
9503 rotate 12
9504 weekly
9505 compress
9506 missingok
9507 postrotate
9508 start-stop-daemon -K -p /var/run/foo.pid -s HUP -x /usr/sbin/foo -q
9509 endscript
9511 </example>
9512 This rotates all files under <file>/var/log/foo</file>, saves 12
9513 compressed generations, and tells the daemon to reopen its log
9514 files after the log rotation. It skips this log rotation
9515 (via <tt>missingok</tt>) if no such log file is present, which
9516 avoids errors if the package is removed but not purged.
9517 </p>
9520 Log files should be removed when the package is
9521 purged (but not when it is only removed). This should be
9522 done by the <prgn>postrm</prgn> script when it is called
9523 with the argument <tt>purge</tt> (see <ref
9524 id="removedetails">).
9525 </p>
9526 </sect>
9528 <sect id="permissions-owners">
9529 <heading>Permissions and owners</heading>
9532 The rules in this section are guidelines for general use.
9533 If necessary you may deviate from the details below.
9534 However, if you do so you must make sure that what is done
9535 is secure and you should try to be as consistent as possible
9536 with the rest of the system. You should probably also
9537 discuss it on <prgn>debian-devel</prgn> first.
9538 </p>
9541 Files should be owned by <tt>root:root</tt>, and made
9542 writable only by the owner and universally readable (and
9543 executable, if appropriate), that is mode 644 or 755.
9544 </p>
9547 Directories should be mode 755 or (for group-writability)
9548 mode 2775. The ownership of the directory should be
9549 consistent with its mode: if a directory is mode 2775, it
9550 should be owned by the group that needs write access to
9551 it.<footnote>
9553 When a package is upgraded, and the owner or permissions
9554 of a file included in the package has changed, dpkg
9555 arranges for the ownership and permissions to be
9556 correctly set upon installation. However, this does not
9557 extend to directories; the permissions and ownership of
9558 directories already on the system does not change on
9559 install or upgrade of packages. This makes sense, since
9560 otherwise common directories like <tt>/usr</tt> would
9561 always be in flux. To correctly change permissions of a
9562 directory the package owns, explicit action is required,
9563 usually in the <tt>postinst</tt> script. Care must be
9564 taken to handle downgrades as well, in that case.
9565 </p>
9566 </footnote>
9567 </p>
9570 Control information files should be owned by <tt>root:root</tt>
9571 and either mode 644 (for most files) or mode 755 (for
9572 executables such as <qref id="maintscripts">maintainer
9573 scripts</qref>).
9574 </p>
9577 Setuid and setgid executables should be mode 4755 or 2755
9578 respectively, and owned by the appropriate user or group.
9579 They should not be made unreadable (modes like 4711 or
9580 2711 or even 4111); doing so achieves no extra security,
9581 because anyone can find the binary in the freely available
9582 Debian package; it is merely inconvenient. For the same
9583 reason you should not restrict read or execute permissions
9584 on non-set-id executables.
9585 </p>
9588 Some setuid programs need to be restricted to particular
9589 sets of users, using file permissions. In this case they
9590 should be owned by the uid to which they are set-id, and by
9591 the group which should be allowed to execute them. They
9592 should have mode 4754; again there is no point in making
9593 them unreadable to those users who must not be allowed to
9594 execute them.
9595 </p>
9598 It is possible to arrange that the system administrator can
9599 reconfigure the package to correspond to their local
9600 security policy by changing the permissions on a binary:
9601 they can do this by using <prgn>dpkg-statoverride</prgn>, as
9602 described below.<footnote>
9603 Ordinary files installed by <prgn>dpkg</prgn> (as
9604 opposed to <tt>conffile</tt>s and other similar objects)
9605 normally have their permissions reset to the distributed
9606 permissions when the package is reinstalled. However,
9607 the use of <prgn>dpkg-statoverride</prgn> overrides this
9608 default behavior.
9609 </footnote>
9610 Another method you should consider is to create a group for
9611 people allowed to use the program(s) and make any setuid
9612 executables executable only by that group.
9613 </p>
9616 If you need to create a new user or group for your package
9617 there are two possibilities. Firstly, you may need to
9618 make some files in the binary package be owned by this
9619 user or group, or you may need to compile the user or
9620 group id (rather than just the name) into the binary
9621 (though this latter should be avoided if possible, as in
9622 this case you need a statically allocated id).</p>
9625 If you need a statically allocated id, you must ask for a
9626 user or group id from the <tt>base-passwd</tt> maintainer,
9627 and must not release the package until you have been
9628 allocated one. Once you have been allocated one you must
9629 either make the package depend on a version of the
9630 <tt>base-passwd</tt> package with the id present in
9631 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
9632 your package to create the user or group itself with the
9633 correct id (using <tt>adduser</tt>) in its
9634 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
9635 the <prgn>postinst</prgn> is to be preferred if it is
9636 possible, otherwise a pre-dependency will be needed on the
9637 <tt>adduser</tt> package.)
9638 </p>
9641 On the other hand, the program might be able to determine the
9642 uid or gid from the user or group name at runtime, so that a
9643 dynamically allocated id can be used. In this case you should
9644 choose an appropriate user or group name, discussing this
9645 on <prgn>debian-devel</prgn> and checking that it is unique.
9646 When this has been checked you must arrange for your package to
9647 create the user or group if necessary using
9648 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
9649 <prgn>postinst</prgn> script (again, the latter is to be
9650 preferred if it is possible).
9651 </p>
9654 Note that changing the numeric value of an id associated
9655 with a name is very difficult, and involves searching the
9656 file system for all appropriate files. You need to think
9657 carefully whether a static or dynamic id is required, since
9658 changing your mind later will cause problems.
9659 </p>
9661 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
9663 This section is not intended as policy, but as a
9664 description of the use of <prgn>dpkg-statoverride</prgn>.
9665 </p>
9668 If a system administrator wishes to have a file (or
9669 directory or other such thing) installed with owner and
9670 permissions different from those in the distributed Debian
9671 package, they can use the <prgn>dpkg-statoverride</prgn>
9672 program to instruct <prgn>dpkg</prgn> to use the different
9673 settings every time the file is installed. Thus the
9674 package maintainer should distribute the files with their
9675 normal permissions, and leave it for the system
9676 administrator to make any desired changes. For example, a
9677 daemon which is normally required to be setuid root, but
9678 in certain situations could be used without being setuid,
9679 should be installed setuid in the <tt>.deb</tt>. Then the
9680 local system administrator can change this if they wish.
9681 If there are two standard ways of doing it, the package
9682 maintainer can use <tt>debconf</tt> to find out the
9683 preference, and call <prgn>dpkg-statoverride</prgn> in the
9684 maintainer script if necessary to accommodate the system
9685 administrator's choice. Care must be taken during
9686 upgrades to not override an existing setting.
9687 </p>
9690 Given the above, <prgn>dpkg-statoverride</prgn> is
9691 essentially a tool for system administrators and would not
9692 normally be needed in the maintainer scripts. There is
9693 one type of situation, though, where calls to
9694 <prgn>dpkg-statoverride</prgn> would be needed in the
9695 maintainer scripts, and that involves packages which use
9696 dynamically allocated user or group ids. In such a
9697 situation, something like the following idiom can be very
9698 helpful in the package's <prgn>postinst</prgn>, where
9699 <tt>sysuser</tt> is a dynamically allocated id:
9700 <example>
9701 for i in /usr/bin/foo /usr/sbin/bar
9703 # only do something when no setting exists
9704 if ! dpkg-statoverride --list $i >/dev/null 2>&1
9705 then
9706 #include: debconf processing, question about foo and bar
9707 if [ "$RET" = "true" ] ; then
9708 dpkg-statoverride --update --add sysuser root 4755 $i
9711 done
9712 </example>
9713 The corresponding code to remove the override when the package
9714 is purged would be:
9715 <example>
9716 for i in /usr/bin/foo /usr/sbin/bar
9718 if dpkg-statoverride --list $i >/dev/null 2>&1
9719 then
9720 dpkg-statoverride --remove $i
9722 done
9723 </example>
9724 </p>
9725 </sect1>
9726 </sect>
9728 <sect id="filenames">
9729 <heading>File names</heading>
9732 The name of the files installed by binary packages in the system PATH
9733 (namely <tt>/bin</tt>, <tt>/sbin</tt>, <tt>/usr/bin</tt>,
9734 <tt>/usr/sbin</tt> and <tt>/usr/games</tt>) must be encoded in
9735 ASCII.
9736 </p>
9739 The name of the files and directories installed by binary packages
9740 outside the system PATH must be encoded in UTF-8 and should be
9741 restricted to ASCII when it is possible to do so.
9742 </p>
9743 </sect>
9744 </chapt>
9747 <chapt id="customized-programs">
9748 <heading>Customized programs</heading>
9750 <sect id="arch-spec">
9751 <heading>Architecture specification strings</heading>
9754 If a program needs to specify an <em>architecture specification
9755 string</em> in some place, it should select one of the strings
9756 provided by <tt>dpkg-architecture -L</tt>. The strings are in
9757 the format <tt><var>os</var>-<var>arch</var></tt>, though the OS
9758 part is sometimes elided, as when the OS is Linux.
9759 </p>
9762 Note that we don't want to use
9763 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
9764 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
9765 since this would make our programs incompatible with other
9766 Linux distributions. We also don't use something like
9767 <tt><var>arch</var>-unknown-linux</tt>, since the
9768 <tt>unknown</tt> does not look very good.
9769 </p>
9771 <sect1 id="arch-wildcard-spec">
9772 <heading>Architecture wildcards</heading>
9775 A package may specify an architecture wildcard. Architecture
9776 wildcards are in the format <tt>any</tt> (which matches every
9777 architecture), <tt><var>os</var></tt>-any, or
9778 any-<tt><var>cpu</var></tt>. <footnote>
9779 Internally, the package system normalizes the GNU triplets
9780 and the Debian arches into Debian arch triplets (which are
9781 kind of inverted GNU triplets), with the first component of
9782 the triplet representing the libc and ABI in use, and then
9783 does matching against those triplets. However, such
9784 triplets are an internal implementation detail that should
9785 not be used by packages directly. The libc and ABI portion
9786 is handled internally by the package system based on
9787 the <var>os</var> and <var>cpu</var>.
9788 </footnote>
9789 </p>
9790 </sect1>
9791 </sect>
9793 <sect>
9794 <heading>Daemons</heading>
9797 The configuration files <file>/etc/services</file>,
9798 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
9799 by the <prgn>netbase</prgn> package and must not be modified
9800 by other packages.
9801 </p>
9804 If a package requires a new entry in one of these files, the
9805 maintainer should get in contact with the
9806 <prgn>netbase</prgn> maintainer, who will add the entries
9807 and release a new version of the <prgn>netbase</prgn>
9808 package.
9809 </p>
9812 The configuration file <file>/etc/inetd.conf</file> must not be
9813 modified by the package's scripts except via the
9814 <prgn>update-inetd</prgn> script or the
9815 <file>DebianNet.pm</file> Perl module. See their documentation
9816 for details on how to add entries.
9817 </p>
9820 If a package wants to install an example entry into
9821 <file>/etc/inetd.conf</file>, the entry must be preceded with
9822 exactly one hash character (<tt>#</tt>). Such lines are
9823 treated as "commented out by user" by the
9824 <prgn>update-inetd</prgn> script and are not changed or
9825 activated during package updates.
9826 </p>
9827 </sect>
9829 <sect>
9830 <heading>Using pseudo-ttys and modifying wtmp, utmp and
9831 lastlog</heading>
9834 Some programs need to create pseudo-ttys. This should be done
9835 using Unix98 ptys if the C library supports it. The resulting
9836 program must not be installed setuid root, unless that
9837 is required for other functionality.
9838 </p>
9841 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
9842 <file>/var/log/lastlog</file> must be installed writable by
9843 group <tt>utmp</tt>. Programs which need to modify those
9844 files must be installed setgid <tt>utmp</tt>.
9845 </p>
9846 </sect>
9848 <sect>
9849 <heading>Editors and pagers</heading>
9852 Some programs have the ability to launch an editor or pager
9853 program to edit or display a text document. Since there are
9854 lots of different editors and pagers available in the Debian
9855 distribution, the system administrator and each user should
9856 have the possibility to choose their preferred editor and
9857 pager.
9858 </p>
9861 In addition, every program should choose a good default
9862 editor/pager if none is selected by the user or system
9863 administrator.
9864 </p>
9867 Thus, every program that launches an editor or pager must
9868 use the EDITOR or PAGER environment variable to determine
9869 the editor or pager the user wishes to use. If these
9870 variables are not set, the programs <file>/usr/bin/editor</file>
9871 and <file>/usr/bin/pager</file> should be used, respectively.
9872 </p>
9875 These two files are managed through the <prgn>dpkg</prgn>
9876 "alternatives" mechanism. Every package providing an editor or
9877 pager must call the <prgn>update-alternatives</prgn> script to
9878 register as an alternative for <file>/usr/bin/editor</file>
9879 or <file>/usr/bin/pager</file> as appropriate. The alternative
9880 should have a slave alternative
9881 for <file>/usr/share/man/man1/editor.1.gz</file>
9882 or <file>/usr/share/man/man1/pager.1.gz</file> pointing to the
9883 corresponding manual page.
9884 </p>
9887 If it is very hard to adapt a program to make use of the
9888 EDITOR or PAGER variables, that program may be configured to
9889 use <file>/usr/bin/sensible-editor</file> and
9890 <file>/usr/bin/sensible-pager</file> as the editor or pager
9891 program respectively. These are two scripts provided in the
9892 <package>sensible-utils</package> package that check the EDITOR
9893 and PAGER variables and launch the appropriate program, and fall
9894 back to <file>/usr/bin/editor</file>
9895 and <file>/usr/bin/pager</file> if the variable is not set.
9896 </p>
9899 A program may also use the VISUAL environment variable to
9900 determine the user's choice of editor. If it exists, it
9901 should take precedence over EDITOR. This is in fact what
9902 <file>/usr/bin/sensible-editor</file> does.
9903 </p>
9906 It is not required for a package to depend on
9907 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
9908 package to provide such virtual packages.<footnote>
9909 The Debian base system already provides an editor and a
9910 pager program.
9911 </footnote>
9912 </p>
9913 </sect>
9915 <sect id="web-appl">
9916 <heading>Web servers and applications</heading>
9919 This section describes the locations and URLs that should
9920 be used by all web servers and web applications in the
9921 Debian system.
9922 </p>
9925 <enumlist>
9926 <item>
9927 Cgi-bin executable files are installed in the
9928 directory
9929 <example compact="compact">
9930 /usr/lib/cgi-bin
9931 </example>
9932 or a subdirectory of that directory, and the script
9933 <example compact="compact">
9934 /usr/lib/cgi-bin/.../<var>cgi-bin-name</var>
9935 </example>
9936 should be referred to as
9937 <example compact="compact">
9938 http://localhost/cgi-bin/.../<var>cgi-bin-name</var>
9939 </example>
9940 </item>
9942 <item>
9943 <p>(Deleted)</p>
9944 </item>
9946 <item>
9947 <p>Access to images</p>
9949 It is recommended that images for a package be stored
9950 in <tt>/usr/share/images/<var>package</var></tt> and
9951 may be referred to through an alias <tt>/images/</tt>
9953 <example>
9954 http://localhost/images/&lt;package&gt;/&lt;filename&gt;
9955 </example>
9957 </p>
9958 </item>
9960 <item>
9961 <p>Web Document Root</p>
9964 Web Applications should try to avoid storing files in
9965 the Web Document Root. Instead they should use the
9966 /usr/share/doc/<var>package</var> directory for
9967 documents and register the Web Application via the
9968 <package>doc-base</package> package. If access to the
9969 web document root is unavoidable then use
9970 <example compact="compact">
9971 /var/www/html
9972 </example>
9973 as the Document Root. This might be just a symbolic
9974 link to the location where the system administrator
9975 has put the real document root.
9976 </p>
9977 </item>
9978 <item><p>Providing httpd and/or httpd-cgi</p>
9980 All web servers should provide the virtual package
9981 <tt>httpd</tt>. If a web server has CGI support it should
9982 provide <tt>httpd-cgi</tt> additionally.
9983 </p>
9985 All web applications which do not contain CGI scripts should
9986 depend on <tt>httpd</tt>, all those web applications which
9987 <tt>do</tt> contain CGI scripts, should depend on
9988 <tt>httpd-cgi</tt>.
9989 </p>
9990 </item>
9991 </enumlist>
9992 </p>
9993 </sect>
9995 <sect id="mail-transport-agents">
9996 <heading>Mail transport, delivery and user agents</heading>
9999 Debian packages which process electronic mail, whether mail
10000 user agents (MUAs) or mail transport agents (MTAs), must
10001 ensure that they are compatible with the configuration
10002 decisions below. Failure to do this may result in lost
10003 mail, broken <tt>From:</tt> lines, and other serious brain
10004 damage!
10005 </p>
10008 The mail spool is <file>/var/mail</file> and the interface to
10009 send a mail message is <file>/usr/sbin/sendmail</file> (as per
10010 the FHS). On older systems, the mail spool may be
10011 physically located in <file>/var/spool/mail</file>, but all
10012 access to the mail spool should be via the
10013 <file>/var/mail</file> symlink. The mail spool is part of the
10014 base system and not part of the MTA package.
10015 </p>
10018 All Debian MUAs, MTAs, MDAs and other mailbox accessing
10019 programs (such as IMAP daemons) must lock the mailbox in an
10020 NFS-safe way. This means that <tt>fcntl()</tt> locking must
10021 be combined with dot locking. To avoid deadlocks, a program
10022 should use <tt>fcntl()</tt> first and dot locking after
10023 this, or alternatively implement the two locking methods in
10024 a non blocking way<footnote>
10025 If it is not possible to establish both locks, the
10026 system shouldn't wait for the second lock to be
10027 established, but remove the first lock, wait a (random)
10028 time, and start over locking again.
10029 </footnote>. Using the functions <tt>maillock</tt> and
10030 <tt>mailunlock</tt> provided by the
10031 <tt>liblockfile*</tt> packages is the recommended way to
10032 accomplish this.
10033 </p>
10036 Mailboxes are generally either mode 600 and owned by
10037 <var>user</var> or mode 660 and owned by
10038 <tt><var>user</var>:mail</tt><footnote>
10039 There are two traditional permission schemes for mail spools:
10040 mode 600 with all mail delivery done by processes running as
10041 the destination user, or mode 660 and owned by group mail with
10042 mail delivery done by a process running as a system user in
10043 group mail. Historically, Debian required mode 660 mail
10044 spools to enable the latter model, but that model has become
10045 increasingly uncommon and the principle of least privilege
10046 indicates that mail systems that use the first model should
10047 use permissions of 600. If delivery to programs is permitted,
10048 it's easier to keep the mail system secure if the delivery
10049 agent runs as the destination user. Debian Policy therefore
10050 permits either scheme.
10051 </footnote>. The local system administrator may choose a
10052 different permission scheme; packages should not make
10053 assumptions about the permission and ownership of mailboxes
10054 unless required (such as when creating a new mailbox). A MUA
10055 may remove a mailbox (unless it has nonstandard permissions) in
10056 which case the MTA or another MUA must recreate it if needed.
10057 </p>
10060 The mail spool is 2775 <tt>root:mail</tt>, and MUAs should
10061 be setgid mail to do the locking mentioned above (and
10062 must obviously avoid accessing other users' mailboxes
10063 using this privilege).</p>
10066 <file>/etc/aliases</file> is the source file for the system mail
10067 aliases (e.g., postmaster, usenet, etc.), it is the one
10068 which the sysadmin and <prgn>postinst</prgn> scripts may
10069 edit. After <file>/etc/aliases</file> is edited the program or
10070 human editing it must call <prgn>newaliases</prgn>. All MTA
10071 packages must come with a <prgn>newaliases</prgn> program,
10072 even if it does nothing, but older MTA packages did not do
10073 this so programs should not fail if <prgn>newaliases</prgn>
10074 cannot be found. Note that because of this, all MTA
10075 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
10076 <tt>Replaces: mail-transport-agent</tt> control fields.
10077 </p>
10080 The convention of writing <tt>forward to
10081 <var>address</var></tt> in the mailbox itself is not
10082 supported. Use a <tt>.forward</tt> file instead.</p>
10085 The <prgn>rmail</prgn> program used by UUCP
10086 for incoming mail should be <file>/usr/sbin/rmail</file>.
10087 Likewise, <prgn>rsmtp</prgn>, for receiving
10088 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
10089 is supported.</p>
10092 If your package needs to know what hostname to use on (for
10093 example) outgoing news and mail messages which are generated
10094 locally, you should use the file <file>/etc/mailname</file>. It
10095 will contain the portion after the username and <tt>@</tt>
10096 (at) sign for email addresses of users on the machine
10097 (followed by a newline).
10098 </p>
10101 Such a package should check for the existence of this file
10102 when it is being configured. If it exists, it should be
10103 used without comment, although an MTA's configuration script
10104 may wish to prompt the user even if it finds that this file
10105 exists. If the file does not exist, the package should
10106 prompt the user for the value (preferably using
10107 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
10108 as well as using it in the package's configuration. The
10109 prompt should make it clear that the name will not just be
10110 used by that package. For example, in this situation the
10111 <tt>inn</tt> package could say something like:
10112 <example compact="compact">
10113 Please enter the "mail name" of your system. This is the
10114 hostname portion of the address to be shown on outgoing
10115 news and mail messages. The default is
10116 <var>syshostname</var>, your system's host name. Mail
10117 name ["<var>syshostname</var>"]:
10118 </example>
10119 where <var>syshostname</var> is the output of <tt>hostname
10120 --fqdn</tt>.
10121 </p>
10122 </sect>
10124 <sect>
10125 <heading>News system configuration</heading>
10128 All the configuration files related to the NNTP (news)
10129 servers and clients should be located under
10130 <file>/etc/news</file>.</p>
10133 There are some configuration issues that apply to a number
10134 of news clients and server packages on the machine. These
10135 are:
10137 <taglist>
10138 <tag><file>/etc/news/organization</file></tag>
10139 <item>
10140 A string which should appear as the
10141 organization header for all messages posted
10142 by NNTP clients on the machine
10143 </item>
10145 <tag><file>/etc/news/server</file></tag>
10146 <item>
10147 Contains the FQDN of the upstream NNTP
10148 server, or localhost if the local machine is
10149 an NNTP server.
10150 </item>
10151 </taglist>
10153 Other global files may be added as required for cross-package news
10154 configuration.
10155 </p>
10156 </sect>
10159 <sect>
10160 <heading>Programs for the X Window System</heading>
10162 <sect1>
10163 <heading>Providing X support and package priorities</heading>
10166 Programs that can be configured with support for the X
10167 Window System must be configured to do so and must declare
10168 any package dependencies necessary to satisfy their
10169 runtime requirements when using the X Window System. If
10170 such a package is of higher priority than the X packages
10171 on which it depends, it is required that either the
10172 X-specific components be split into a separate package, or
10173 that an alternative version of the package, which includes
10174 X support, be provided, or that the package's priority be
10175 lowered.
10176 </p>
10177 </sect1>
10179 <sect1>
10180 <heading>Packages providing an X server</heading>
10183 Packages that provide an X server that, directly or
10184 indirectly, communicates with real input and display
10185 hardware should declare in their <tt>Provides</tt> control
10186 field that they provide the virtual
10187 package <tt>xserver</tt>.<footnote>
10188 This implements current practice, and provides an
10189 actual policy for usage of the <tt>xserver</tt>
10190 virtual package which appears in the virtual packages
10191 list. In a nutshell, X servers that interface
10192 directly with the display and input hardware or via
10193 another subsystem (e.g., GGI) should provide
10194 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
10195 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
10196 </footnote>
10197 </p>
10198 </sect1>
10200 <sect1>
10201 <heading>Packages providing a terminal emulator</heading>
10204 Packages that provide a terminal emulator for the X Window
10205 System which meet the criteria listed below should declare in
10206 their <tt>Provides</tt> control field that they provide the
10207 virtual package <tt>x-terminal-emulator</tt>. They should
10208 also register themselves as an alternative for
10209 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
10210 20. That alternative should have a slave alternative
10211 for <file>/usr/share/man/man1/x-terminal-emulator.1.gz</file>
10212 pointing to the corresponding manual page.
10213 </p>
10216 To be an <tt>x-terminal-emulator</tt>, a program must:
10217 <list compact="compact">
10218 <item>
10219 Be able to emulate a DEC VT100 terminal, or a
10220 compatible terminal.
10221 </item>
10223 <item>
10224 Support the command-line option <tt>-e
10225 <var>command</var></tt>, which creates a new
10226 terminal window<footnote>
10227 "New terminal window" does not necessarily mean
10228 a new top-level X window directly parented by
10229 the window manager; it could, if the terminal
10230 emulator application were so coded, be a new
10231 "view" in a multiple-document interface (MDI).
10232 </footnote>
10233 and runs the specified <var>command</var>,
10234 interpreting the entirety of the rest of the command
10235 line as a command to pass straight to exec, in the
10236 manner that <tt>xterm</tt> does.
10237 </item>
10239 <item>
10240 Support the command-line option <tt>-T
10241 <var>title</var></tt>, which creates a new terminal
10242 window with the window title <var>title</var>.
10243 </item>
10244 </list>
10245 </p>
10246 </sect1>
10248 <sect1>
10249 <heading>Packages providing a window manager</heading>
10252 Packages that provide a window manager should declare in
10253 their <tt>Provides</tt> control field that they provide the
10254 virtual package <tt>x-window-manager</tt>. They should also
10255 register themselves as an alternative for
10256 <file>/usr/bin/x-window-manager</file>, with a priority
10257 calculated as follows:
10258 <list compact="compact">
10259 <item>
10260 Start with a priority of 20.
10261 </item>
10263 <item>
10264 If the window manager supports the Debian menu
10265 system, add 20 points if this support is available
10266 in the package's default configuration (i.e., no
10267 configuration files belonging to the system or user
10268 have to be edited to activate the feature); if
10269 configuration files must be modified, add only 10
10270 points.
10271 </p>
10272 </item>
10274 <item>
10275 If the window manager complies with <url
10276 id="http://www.freedesktop.org/wiki/Specifications/wm-spec"
10277 name="The Window Manager Specification Project">,
10278 written by the <url id="http://www.freedesktop.org/wiki/"
10279 name="Free Desktop Group">, add 40 points.
10280 </item>
10282 <item>
10283 If the window manager permits the X session to be
10284 restarted using a <em>different</em> window manager
10285 (without killing the X server) in its default
10286 configuration, add 10 points; otherwise add none.
10287 </item>
10288 </list>
10289 That alternative should have a slave alternative
10290 for <file>/usr/share/man/man1/x-window-manager.1.gz</file>
10291 pointing to the corresponding manual page.
10292 </p>
10293 </sect1>
10295 <sect1>
10296 <heading>Packages providing fonts</heading>
10299 Packages that provide fonts for the X Window
10300 System<footnote>
10301 For the purposes of Debian Policy, a "font for the X
10302 Window System" is one which is accessed via X protocol
10303 requests. Fonts for the Linux console, for PostScript
10304 renderer, or any other purpose, do not fit this
10305 definition. Any tool which makes such fonts available
10306 to the X Window System, however, must abide by this
10307 font policy.
10308 </footnote>
10309 must do a number of things to ensure that they are both
10310 available without modification of the X or font server
10311 configuration, and that they do not corrupt files used by
10312 other font packages to register information about
10313 themselves.
10314 <enumlist>
10315 <item>
10316 Fonts of any type supported by the X Window System
10317 must be in a separate binary package from any
10318 executables, libraries, or documentation (except
10319 that specific to the fonts shipped, such as their
10320 license information). If one or more of the fonts
10321 so packaged are necessary for proper operation of
10322 the package with which they are associated the font
10323 package may be Recommended; if the fonts merely
10324 provide an enhancement, a Suggests relationship may
10325 be used. Packages must not Depend on font
10326 packages.<footnote>
10327 This is because the X server may retrieve fonts
10328 from the local file system or over the network
10329 from an X font server; the Debian package system
10330 is empowered to deal only with the local
10331 file system.
10332 </footnote>
10333 </item>
10335 <item>
10336 BDF fonts must be converted to PCF fonts with the
10337 <prgn>bdftopcf</prgn> utility (available in the
10338 <tt>xfonts-utils</tt> package, <prgn>gzip</prgn>ped, and
10339 placed in a directory that corresponds to their
10340 resolution:
10341 <list compact="compact">
10342 <item>
10343 100 dpi fonts must be placed in
10344 <file>/usr/share/fonts/X11/100dpi/</file>.
10345 </item>
10347 <item>
10348 75 dpi fonts must be placed in
10349 <file>/usr/share/fonts/X11/75dpi/</file>.
10350 </item>
10352 <item>
10353 Character-cell fonts, cursor fonts, and other
10354 low-resolution fonts must be placed in
10355 <file>/usr/share/fonts/X11/misc/</file>.
10356 </item>
10357 </list>
10358 </item>
10360 <item>
10361 Type 1 fonts must be placed in
10362 <file>/usr/share/fonts/X11/Type1/</file>. If font
10363 metric files are available, they must be placed here
10364 as well.
10365 </item>
10367 <item>
10368 Subdirectories of <file>/usr/share/fonts/X11/</file>
10369 other than those listed above must be neither
10370 created nor used. (The <file>PEX</file>, <file>CID</file>,
10371 <file>Speedo</file>, and <file>cyrillic</file> directories
10372 are excepted for historical reasons, but installation of
10373 files into these directories remains discouraged.)
10374 </item>
10376 <item>
10377 Font packages may, instead of placing files directly
10378 in the X font directories listed above, provide
10379 symbolic links in that font directory pointing to
10380 the files' actual location in the filesystem. Such
10381 a location must comply with the FHS.
10382 </item>
10384 <item>
10385 Font packages should not contain both 75dpi and
10386 100dpi versions of a font. If both are available,
10387 they should be provided in separate binary packages
10388 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
10389 the names of the packages containing the
10390 corresponding fonts.
10391 </item>
10393 <item>
10394 Fonts destined for the <file>misc</file> subdirectory
10395 should not be included in the same package as 75dpi
10396 or 100dpi fonts; instead, they should be provided in
10397 a separate package with <tt>-misc</tt> appended to
10398 its name.
10399 </item>
10401 <item>
10402 Font packages must not provide the files
10403 <file>fonts.dir</file>, <file>fonts.alias</file>, or
10404 <file>fonts.scale</file> in a font directory:
10405 <list>
10406 <item>
10407 <file>fonts.dir</file> files must not be provided at all.
10408 </item>
10410 <item>
10411 <file>fonts.alias</file> and <file>fonts.scale</file>
10412 files, if needed, should be provided in the
10413 directory
10414 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
10415 where <var>fontdir</var> is the name of the
10416 subdirectory of
10417 <file>/usr/share/fonts/X11/</file> where the
10418 package's corresponding fonts are stored
10419 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
10420 <var>package</var> is the name of the package
10421 that provides these fonts, and
10422 <var>extension</var> is either <tt>scale</tt>
10423 or <tt>alias</tt>, whichever corresponds to
10424 the file contents.
10425 </item>
10426 </list>
10427 </item>
10429 <item>
10430 Font packages must declare a dependency on
10431 <tt>xfonts-utils</tt> in their <tt>Depends</tt>
10432 or <tt>Pre-Depends</tt> control field.
10433 </item>
10435 <item>
10436 Font packages that provide one or more
10437 <file>fonts.scale</file> files as described above must
10438 invoke <prgn>update-fonts-scale</prgn> on each
10439 directory into which they installed fonts
10440 <em>before</em> invoking
10441 <prgn>update-fonts-dir</prgn> on that directory.
10442 This invocation must occur in both the
10443 <prgn>postinst</prgn> (for all arguments) and
10444 <prgn>postrm</prgn> (for all arguments except
10445 <tt>upgrade</tt>) scripts.
10446 </item>
10448 <item>
10449 Font packages that provide one or more
10450 <file>fonts.alias</file> files as described above must
10451 invoke <prgn>update-fonts-alias</prgn> on each
10452 directory into which they installed fonts. This
10453 invocation must occur in both the
10454 <prgn>postinst</prgn> (for all arguments) and
10455 <prgn>postrm</prgn> (for all arguments except
10456 <tt>upgrade</tt>) scripts.
10457 </item>
10459 <item>
10460 Font packages must invoke
10461 <prgn>update-fonts-dir</prgn> on each directory into
10462 which they installed fonts. This invocation must
10463 occur in both the <prgn>postinst</prgn> (for all
10464 arguments) and <prgn>postrm</prgn> (for all
10465 arguments except <tt>upgrade</tt>) scripts.
10466 </item>
10468 <item>
10469 Font packages must not provide alias names for the
10470 fonts they include which collide with alias names
10471 already in use by fonts already packaged.
10472 </item>
10474 <item>
10475 Font packages must not provide fonts with the same
10476 XLFD registry name as another font already packaged.
10477 </item>
10478 </enumlist>
10479 </p>
10480 </sect1>
10482 <sect1 id="appdefaults">
10483 <heading>Application defaults files</heading>
10486 Application defaults files must be installed in the
10487 directory <file>/etc/X11/app-defaults/</file> (use of a
10488 localized subdirectory of <file>/etc/X11/</file> as described
10489 in the <em>X Toolkit Intrinsics - C Language
10490 Interface</em> manual is also permitted). They must be
10491 registered as <tt>conffile</tt>s or handled as
10492 configuration files.
10493 </p>
10496 Customization of programs' X resources may also be
10497 supported with the provision of a file with the same name
10498 as that of the package placed in
10499 the <file>/etc/X11/Xresources/</file> directory, which
10500 must be registered as a <tt>conffile</tt> or handled as a
10501 configuration file.<footnote>
10502 Note that this mechanism is not the same as using
10503 app-defaults; app-defaults are tied to the client
10504 binary on the local file system, whereas X resources
10505 are stored in the X server and affect all connecting
10506 clients.
10507 </footnote>
10508 </p>
10509 </sect1>
10511 <sect1>
10512 <heading>Installation directory issues</heading>
10515 Historically, packages using the X Window System used a
10516 separate set of installation directories from other packages.
10517 This practice has been discontinued and packages using the X
10518 Window System should now generally be installed in the same
10519 directories as any other package. Specifically, packages must
10520 not install files under the <file>/usr/X11R6/</file> directory
10521 and the <file>/usr/X11R6/</file> directory hierarchy should be
10522 regarded as obsolete.
10523 </p>
10526 Include files previously installed under
10527 <file>/usr/X11R6/include/X11/</file> should be installed into
10528 <file>/usr/include/X11/</file>. For files previously
10529 installed into subdirectories of
10530 <file>/usr/X11R6/lib/X11/</file>, package maintainers should
10531 determine if subdirectories of <file>/usr/lib/</file> and
10532 <file>/usr/share/</file> can be used. If not, a subdirectory
10533 of <file>/usr/lib/X11/</file> should be used.
10534 </p>
10537 Configuration files for window, display, or session managers
10538 or other applications that are tightly integrated with the X
10539 Window System may be placed in a subdirectory
10540 of <file>/etc/X11/</file> corresponding to the package name.
10541 Other X Window System applications should use
10542 the <file>/etc/</file> directory unless otherwise mandated by
10543 policy (such as for <ref id="appdefaults">).
10544 </p>
10545 </sect1>
10546 </sect>
10548 <sect id="perl">
10549 <heading>Perl programs and modules</heading>
10552 Perl programs and modules should follow the current Perl policy.
10553 </p>
10556 The Perl policy can be found in the <tt>perl-policy</tt>
10557 files in the <tt>debian-policy</tt> package.
10558 It is also available from the Debian web mirrors at
10559 <tt><url name="/doc/packaging-manuals/perl-policy/"
10560 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>.
10561 </p>
10562 </sect>
10564 <sect id="emacs">
10565 <heading>Emacs lisp programs</heading>
10568 Please refer to the "Debian Emacs Policy" for details of how to
10569 package emacs lisp programs.
10570 </p>
10573 The Emacs policy is available in
10574 <file>debian-emacs-policy.gz</file> of the
10575 <package>emacsen-common</package> package.
10576 It is also available from the Debian web mirrors at
10577 <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
10578 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
10579 </p>
10580 </sect>
10582 <sect>
10583 <heading>Games</heading>
10586 The permissions on <file>/var/games</file> are mode 755, owner
10587 <tt>root</tt> and group <tt>root</tt>.
10588 </p>
10591 Each game decides on its own security policy.</p>
10594 Games which require protected, privileged access to
10595 high-score files, saved games, etc., may be made
10596 set-<em>group</em>-id (mode 2755) and owned by
10597 <tt>root:games</tt>, and use files and directories with
10598 appropriate permissions (770 <tt>root:games</tt>, for
10599 example). They must not be made
10600 set-<em>user</em>-id, as this causes security problems. (If
10601 an attacker can subvert any set-user-id game they can
10602 overwrite the executable of any other, causing other players
10603 of these games to run a Trojan horse program. With a
10604 set-group-id game the attacker only gets access to less
10605 important game data, and if they can get at the other
10606 players' accounts at all it will take considerably more
10607 effort.)</p>
10610 Some packages, for example some fortune cookie programs, are
10611 configured by the upstream authors to install with their
10612 data files or other static information made unreadable so
10613 that they can only be accessed through set-id programs
10614 provided. You should not do this in a Debian package: anyone can
10615 download the <file>.deb</file> file and read the data from it,
10616 so there is no point making the files unreadable. Not
10617 making the files unreadable also means that you don't have
10618 to make so many programs set-id, which reduces the risk of a
10619 security hole.</p>
10622 As described in the FHS, binaries of games should be
10623 installed in the directory <file>/usr/games</file>. This also
10624 applies to games that use the X Window System. Manual pages
10625 for games (X and non-X games) should be installed in
10626 <file>/usr/share/man/man6</file>.</p>
10627 </sect>
10628 </chapt>
10631 <chapt id="docs">
10632 <heading>Documentation</heading>
10634 <sect>
10635 <heading>Manual pages</heading>
10638 You should install manual pages in <prgn>nroff</prgn> source
10639 form, in appropriate places under <file>/usr/share/man</file>.
10640 You should only use sections 1 to 9 (see the FHS for more
10641 details). You must not install a pre-formatted "cat page".
10642 </p>
10645 Each program, utility, and function should have an
10646 associated manual page included in the same package. It is
10647 suggested that all configuration files also have a manual
10648 page included as well. Manual pages for protocols and other
10649 auxiliary things are optional.
10650 </p>
10653 If no manual page is available, this is considered as a bug
10654 and should be reported to the Debian Bug Tracking System (the
10655 maintainer of the package is allowed to write this bug report
10656 themselves, if they so desire). Do not close the bug report
10657 until a proper man page is available.<footnote>
10658 It is not very hard to write a man page. See the
10659 <url id="http://www.schweikhardt.net/man_page_howto.html"
10660 name="Man-Page-HOWTO">,
10661 <manref name="man" section="7">, the examples created
10662 by <prgn>dh_make</prgn>, the helper
10663 program <prgn>help2man</prgn>, or the
10664 directory <file>/usr/share/doc/man-db/examples</file>.
10665 </footnote>
10666 </p>
10669 You may forward a complaint about a missing man page to the
10670 upstream authors, and mark the bug as forwarded in the
10671 Debian bug tracking system. Even though the GNU Project do
10672 not in general consider the lack of a man page to be a bug,
10673 we do; if they tell you that they don't consider it a bug
10674 you should leave the bug in our bug tracking system open
10675 anyway.
10676 </p>
10679 Manual pages should be installed compressed using <tt>gzip -9</tt>.
10680 </p>
10683 If one man page needs to be accessible via several names it
10684 is better to use a symbolic link than the <file>.so</file>
10685 feature, but there is no need to fiddle with the relevant
10686 parts of the upstream source to change from <file>.so</file> to
10687 symlinks: don't do it unless it's easy. You should not
10688 create hard links in the manual page directories, nor put
10689 absolute filenames in <file>.so</file> directives. The filename
10690 in a <file>.so</file> in a man page should be relative to the
10691 base of the man page tree (usually
10692 <file>/usr/share/man</file>). If you do not create any links
10693 (whether symlinks, hard links, or <tt>.so</tt> directives)
10694 in the file system to the alternate names of the man page,
10695 then you should not rely on <prgn>man</prgn> finding your
10696 man page under those names based solely on the information in
10697 the man page's header.<footnote>
10698 Supporting this in <prgn>man</prgn> often requires
10699 unreasonable processing time to find a manual page or to
10700 report that none exists, and moves knowledge into man's
10701 database that would be better left in the file system.
10702 This support is therefore deprecated and will cease to
10703 be present in the future.
10704 </footnote>
10705 </p>
10708 Manual pages in locale-specific subdirectories of
10709 <file>/usr/share/man</file> should use either UTF-8 or the usual
10710 legacy encoding for that language (normally the one corresponding
10711 to the shortest relevant locale name in
10712 <file>/usr/share/i18n/SUPPORTED</file>). For example, pages under
10713 <file>/usr/share/man/fr</file> should use either UTF-8 or
10714 ISO-8859-1.<footnote>
10715 <prgn>man</prgn> will automatically detect whether UTF-8 is in
10716 use. In future, all manual pages will be required to use
10717 UTF-8.
10718 </footnote>
10719 </p>
10722 A country name (the <tt>DE</tt> in <tt>de_DE</tt>) should not be
10723 included in the subdirectory name unless it indicates a
10724 significant difference in the language, as this excludes
10725 speakers of the language in other countries.<footnote>
10726 At the time of writing, Chinese and Portuguese are the main
10727 languages with such differences, so <file>pt_BR</file>,
10728 <file>zh_CN</file>, and <file>zh_TW</file> are all allowed.
10729 </footnote>
10730 </p>
10733 If a localized version of a manual page is provided, it should
10734 either be up-to-date or it should be obvious to the reader that
10735 it is outdated and the original manual page should be used
10736 instead. This can be done either by a note at the beginning of
10737 the manual page or by showing the missing or changed portions in
10738 the original language instead of the target language.
10739 </p>
10740 </sect>
10742 <sect>
10743 <heading>Info documents</heading>
10746 Info documents should be installed in <file>/usr/share/info</file>.
10747 They should be compressed with <tt>gzip -9</tt>.
10748 </p>
10751 The <prgn>install-info</prgn> program maintains a directory of
10752 installed info documents in <file>/usr/share/info/dir</file> for the
10753 use of info readers. This file must not be included in packages
10754 other than <package>install-info</package>.
10755 </p>
10758 <prgn>install-info</prgn> is automatically invoked when
10759 appropriate using dpkg triggers. Packages other than
10760 <package>install-info</package> <em>should not</em> invoke
10761 <prgn>install-info</prgn> directly and <em>should not</em>
10762 depend on, recommend, or suggest <package>install-info</package>
10763 for this purpose.
10764 </p>
10767 Info readers requiring the <file>/usr/share/info/dir</file> file
10768 should depend on <package>install-info</package>.
10769 </p>
10772 Info documents should contain section and directory entry
10773 information in the document for the use
10774 of <prgn>install-info</prgn>. The section should be specified
10775 via a line starting with <tt>INFO-DIR-SECTION</tt> followed by a
10776 space and the section of this info page. The directory entry or
10777 entries should be included between
10778 a <tt>START-INFO-DIR-ENTRY</tt> line and
10779 an <tt>END-INFO-DIR-ENTRY</tt> line. For example:
10780 <example>
10781 INFO-DIR-SECTION Individual utilities
10782 START-INFO-DIR-ENTRY
10783 * example: (example). An example info directory entry.
10784 END-INFO-DIR-ENTRY
10785 </example>
10786 To determine which section to use, you should look
10787 at <file>/usr/share/info/dir</file> on your system and choose
10788 the most relevant (or create a new section if none of the
10789 current sections are relevant).<footnote>
10790 Normally, info documents are generated from Texinfo source.
10791 To include this information in the generated info document, if
10792 it is absent, add commands like:
10793 <example>
10794 @dircategory Individual utilities
10795 @direntry
10796 * example: (example). An example info directory entry.
10797 @end direntry
10798 </example>
10799 to the Texinfo source of the document and ensure that the info
10800 documents are rebuilt from source during the package build.
10801 </footnote>
10802 </p>
10803 </sect>
10805 <sect id="docs-additional">
10806 <heading>Additional documentation</heading>
10809 Any additional documentation that comes with the package may be
10810 installed at the discretion of the package maintainer. It is
10811 often a good idea to include text information files
10812 (<file>README</file>s, FAQs, and so forth) that come with the
10813 source package in the binary package. However, you don't need
10814 to install the instructions for building and installing the
10815 package, of course!
10816 </p>
10819 Plain text documentation should be compressed with <tt>gzip
10820 -9</tt> unless it is small.
10821 </p>
10824 If a package comes with large amounts of documentation that many
10825 users of the package will not require, you should create a
10826 separate binary package to contain it so that it does not take
10827 up disk space on the machines of users who do not need or want
10828 it installed. As a special case of this rule, shared library
10829 documentation of any appreciable size should always be packaged
10830 with the library development package (<ref id="sharedlibs-dev">)
10831 or in a separate documentation package, since shared libraries
10832 are frequently installed as dependencies of other packages by
10833 users who have little interest in documentation of the library
10834 itself. The documentation package for the
10835 package <var>package</var> is conventionally
10836 named <var>package</var>-doc
10837 (or <var>package</var>-doc-<var>language-code</var> if there are
10838 separate documentation packages for multiple languages).
10839 </p>
10842 Additional documentation included in the package should be
10843 installed under <file>/usr/share/doc/<var>package</var></file>.
10844 If the documentation is packaged separately,
10845 as <var>package</var>-doc for example, it may be installed under
10846 either that path or into the documentation directory for the
10847 separate documentation package
10848 (<file>/usr/share/doc/<var>package</var>-doc</file> in this
10849 example). However, installing the documentation into the
10850 documentation directory of the main package is preferred since
10851 it is independent of the packaging method and will be easier for
10852 users to find.
10853 </p>
10856 Any separate package providing documentation must still install
10857 standard documentation files in its
10858 own <file>/usr/share/doc</file> directory as specified in the
10859 rest of this policy. See, for example, <ref id="copyrightfile">
10860 and <ref id="changelogs">.
10861 </p>
10864 Packages must not require the existence of any files in
10865 <file>/usr/share/doc/</file> in order to function
10866 <footnote>
10867 The system administrator should be able to delete files
10868 in <file>/usr/share/doc/</file> without causing any programs
10869 to break.
10870 </footnote>. Any files that are used or read by programs but
10871 are also useful as stand alone documentation should be installed
10872 elsewhere, such as
10873 under <file>/usr/share/<var>package</var>/</file>, and then
10874 included via symbolic links
10875 in <file>/usr/share/doc/<var>package</var></file>.
10876 </p>
10879 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
10880 link to another directory in <file>/usr/share/doc</file> only if
10881 the two packages both come from the same source and the
10882 first package Depends on the second.<footnote>
10884 Please note that this does not override the section on
10885 changelog files below, so the file
10886 <file>/usr/share/doc/<var>package</var>/changelog.Debian.gz</file>
10887 must refer to the changelog for the current version of
10888 <var>package</var> in question. In practice, this means
10889 that the sources of the target and the destination of the
10890 symlink must be the same (same source package and
10891 version).
10892 </p>
10893 </footnote>
10894 </p>
10895 </sect>
10897 <sect>
10898 <heading>Preferred documentation formats</heading>
10901 The unification of Debian documentation is being carried out
10902 via HTML.</p>
10905 If the package comes with extensive documentation in a
10906 markup format that can be converted to various other formats
10907 you should if possible ship HTML versions in a binary
10908 package.<footnote>
10909 Rationale: The important thing here is that HTML
10910 documentation should be available from <em>some</em>
10911 binary package.
10912 </footnote>
10913 The documentation must be installed as specified in
10914 <ref id="docs-additional">.
10915 </p>
10918 Other formats such as PostScript may be provided at the
10919 package maintainer's discretion.
10920 </p>
10921 </sect>
10923 <sect id="copyrightfile">
10924 <heading>Copyright information</heading>
10927 Every package must be accompanied by a verbatim copy of its
10928 copyright information and distribution license in the file
10929 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
10930 file must neither be compressed nor be a symbolic link.
10931 </p>
10934 In addition, the copyright file must say where the upstream
10935 sources (if any) were obtained, and should name the original
10936 authors.
10937 </p>
10940 Packages in the <em>contrib</em> or <em>non-free</em> archive
10941 areas should state in the copyright file that the package is not
10942 part of the Debian distribution and briefly explain why.
10943 </p>
10946 A copy of the file which will be installed in
10947 <file>/usr/share/doc/<var>package</var>/copyright</file> should
10948 be in <file>debian/copyright</file> in the source package.
10949 </p>
10952 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
10953 link to another directory in <file>/usr/share/doc</file> only if
10954 the two packages both come from the same source and the
10955 first package Depends on the second. These rules are important
10956 because <file>copyright</file> files must be extractable by
10957 mechanical means.
10958 </p>
10961 Packages distributed under the Apache license (version 2.0), the
10962 Artistic license, the GNU GPL (versions 1, 2, or 3), the GNU
10963 LGPL (versions 2, 2.1, or 3), the GNU FDL (versions 1.2 or 1.3),
10964 and the Mozilla Public License (version 1.1 or 2.0) should refer
10965 to the corresponding files under
10966 <file>/usr/share/common-licenses</file>,<footnote>
10968 In particular,
10969 <file>/usr/share/common-licenses/Apache-2.0</file>,
10970 <file>/usr/share/common-licenses/Artistic</file>,
10971 <file>/usr/share/common-licenses/GPL-1</file>,
10972 <file>/usr/share/common-licenses/GPL-2</file>,
10973 <file>/usr/share/common-licenses/GPL-3</file>,
10974 <file>/usr/share/common-licenses/LGPL-2</file>,
10975 <file>/usr/share/common-licenses/LGPL-2.1</file>,
10976 <file>/usr/share/common-licenses/LGPL-3</file>,
10977 <file>/usr/share/common-licenses/GFDL-1.2</file>,
10978 <file>/usr/share/common-licenses/GFDL-1.3</file>,
10979 <file>/usr/share/common-licenses/MPL-1.1</file>, and
10980 <file>/usr/share/common-licenses/MPL-2.0</file>
10981 respectively. The University of California BSD license is
10982 also included in <package>base-files</package> as
10983 <file>/usr/share/common-licenses/BSD</file>, but given the
10984 brevity of this license, its specificity to code whose
10985 copyright is held by the Regents of the University of
10986 California, and the frequency of minor wording changes, its
10987 text should be included in the copyright file rather than
10988 referencing this file.
10989 </p>
10990 </footnote> rather than quoting them in the copyright
10991 file.
10992 </p>
10995 You should not use the copyright file as a general <file>README</file>
10996 file. If your package has such a file it should be
10997 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
10998 <file>README.Debian</file> or some other appropriate place.
10999 </p>
11002 All copyright files must be encoded in UTF-8.
11003 </p>
11005 <sect1 id="copyrightformat">
11006 <heading>Machine-readable copyright information</heading>
11009 A specification for a standard, machine-readable format
11010 for <file>debian/copyright</file> files is maintained as part
11011 of the <package>debian-policy</package> package. This
11012 document may be found in the <file>copyright-format</file>
11013 files in the <package>debian-policy</package> package. It is
11014 also available from the Debian web mirrors at
11015 <tt><url name="/doc/packaging-manuals/copyright-format/1.0/"
11016 id="http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"></tt>.
11017 </p>
11020 Use of this format is optional.
11021 </p>
11022 </sect1>
11023 </sect>
11025 <sect>
11026 <heading>Examples</heading>
11029 Any examples (configurations, source files, whatever),
11030 should be installed in a directory
11031 <file>/usr/share/doc/<var>package</var>/examples</file>. These
11032 files should not be referenced by any program: they're there
11033 for the benefit of the system administrator and users as
11034 documentation only. Architecture-specific example files
11035 should be installed in a directory
11036 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
11037 links to them from
11038 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
11039 latter directory itself may be a symbolic link to the
11040 former.
11041 </p>
11044 If the purpose of a package is to provide examples, then the
11045 example files may be installed into
11046 <file>/usr/share/doc/<var>package</var></file>.
11047 </p>
11048 </sect>
11050 <sect id="changelogs">
11051 <heading>Changelog files</heading>
11054 Packages that are not Debian-native must contain a
11055 compressed copy of the <file>debian/changelog</file> file from
11056 the Debian source tree in
11057 <file>/usr/share/doc/<var>package</var></file> with the name
11058 <file>changelog.Debian.gz</file>.
11059 </p>
11062 If an upstream changelog is available, it should be accessible as
11063 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
11064 plain text. If the upstream changelog is distributed in
11065 HTML, it should be made available in that form as
11066 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
11067 and a plain text <file>changelog.gz</file> should be generated
11068 from it using, for example, <tt>lynx -dump -nolist</tt>. If
11069 the upstream changelog files do not already conform to this
11070 naming convention, then this may be achieved either by
11071 renaming the files, or by adding a symbolic link, at the
11072 maintainer's discretion.<footnote>
11073 Rationale: People should not have to look in places for
11074 upstream changelogs merely because they are given
11075 different names or are distributed in HTML format.
11076 </footnote>
11077 </p>
11080 All of these files should be installed compressed using
11081 <tt>gzip -9</tt>, as they will become large with time even
11082 if they start out small.
11083 </p>
11086 If the package has only one changelog which is used both as
11087 the Debian changelog and the upstream one because there is
11088 no separate upstream maintainer then that changelog should
11089 usually be installed as
11090 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
11091 there is a separate upstream maintainer, but no upstream
11092 changelog, then the Debian changelog should still be called
11093 <file>changelog.Debian.gz</file>.
11094 </p>
11097 For details about the format and contents of the Debian
11098 changelog file, please see <ref id="dpkgchangelog">.
11099 </p>
11100 </sect>
11101 </chapt>
11103 <appendix id="pkg-scope">
11104 <heading>Introduction and scope of these appendices</heading>
11107 These appendices are taken essentially verbatim from the
11108 now-deprecated Packaging Manual, version 3.2.1.0. They are
11109 the chapters which are likely to be of use to package
11110 maintainers and which have not already been included in the
11111 policy document itself. Most of these sections are very likely
11112 not relevant to policy; they should be treated as
11113 documentation for the packaging system. Please note that these
11114 appendices are included for convenience, and for historical
11115 reasons: they used to be part of policy package, and they have
11116 not yet been incorporated into dpkg documentation. However,
11117 they still have value, and hence they are presented here.
11118 </p>
11121 They have not yet been checked to ensure that they are
11122 compatible with the contents of policy, and if there are any
11123 contradictions, the version in the main policy document takes
11124 precedence. The remaining chapters of the old Packaging
11125 Manual have also not been read in detail to ensure that there
11126 are not parts which have been left out. Both of these will be
11127 done in due course.
11128 </p>
11131 Certain parts of the Packaging manual were integrated into the
11132 Policy Manual proper, and removed from the appendices. Links
11133 have been placed from the old locations to the new ones.
11134 </p>
11137 <prgn>dpkg</prgn> is a suite of programs for creating binary
11138 package files and installing and removing them on Unix
11139 systems.<footnote>
11140 <prgn>dpkg</prgn> is targeted primarily at Debian, but may
11141 work on or be ported to other systems.
11142 </footnote>
11143 </p>
11146 The binary packages are designed for the management of
11147 installed executable programs (usually compiled binaries) and
11148 their associated data, though source code examples and
11149 documentation are provided as part of some packages.</p>
11152 This manual describes the technical aspects of creating Debian
11153 binary packages (<file>.deb</file> files). It documents the
11154 behavior of the package management programs
11155 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
11156 they interact with packages.</p>
11159 This manual does not go into detail about the options and
11160 usage of the package building and installation tools. It
11161 should therefore be read in conjunction with those programs'
11162 man pages.
11163 </p>
11166 The utility programs which are provided with <prgn>dpkg</prgn>
11167 not described in detail here, are documented in their man pages.
11168 </p>
11171 It is assumed that the reader is reasonably familiar with the
11172 <prgn>dpkg</prgn> System Administrators' manual.
11173 Unfortunately this manual does not yet exist.
11174 </p>
11177 The Debian version of the FSF's GNU hello program is provided as
11178 an example for people wishing to create Debian packages. However,
11179 while the examples are helpful, they do not replace the need to
11180 read and follow the Policy and Programmer's Manual.</p>
11181 </appendix>
11183 <appendix id="pkg-binarypkg">
11184 <heading>Binary packages (from old Packaging Manual)</heading>
11187 See <manref name="deb" section="5"> and <ref id="pkg-controlarea">.
11188 </p>
11190 <sect id="pkg-bincreating"><heading>Creating package files -
11191 <prgn>dpkg-deb</prgn>
11192 </heading>
11195 All manipulation of binary package files is done by
11196 <prgn>dpkg-deb</prgn>; it's the only program that has
11197 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
11198 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
11199 will spot that the options requested are appropriate to
11200 <prgn>dpkg-deb</prgn> and invoke that instead with the same
11201 arguments.)
11202 </p>
11205 In order to create a binary package, you must make a directory
11206 tree which contains all the files and directories you want to
11207 have in the file system data part of the package. In
11208 Debian-format source packages, this directory is usually
11209 either <file>debian/tmp</file>
11210 or <file>debian/<var>pkg</var></file>, relative to the top of
11211 the package's source tree.
11212 </p>
11215 They should have the locations (relative to the root of the
11216 directory tree you're constructing) ownerships and
11217 permissions which you want them to have on the system when
11218 they are installed.
11219 </p>
11222 With current versions of <prgn>dpkg</prgn> the uid/username
11223 and gid/groupname mappings for the users and groups being
11224 used should be the same on the system where the package is
11225 built and the one where it is installed.
11226 </p>
11229 You need to add one special directory to the root of the
11230 miniature file system tree you're creating:
11231 <prgn>DEBIAN</prgn>. It should contain the control
11232 information files, notably the binary package control file
11233 (see <ref id="pkg-controlfile">).
11234 </p>
11237 The <prgn>DEBIAN</prgn> directory will not appear in the
11238 file system archive of the package, and so won't be installed
11239 by <prgn>dpkg</prgn> when the package is unpacked.
11240 </p>
11243 When you've prepared the package, you should invoke:
11244 <example>
11245 dpkg --build <var>directory</var>
11246 </example>
11247 </p>
11250 This will build the package in
11251 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
11252 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
11253 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
11254 build the package.)
11255 </p>
11258 See the man page <manref name="dpkg-deb" section="8"> for details of how
11259 to examine the contents of this newly-created file. You may find the
11260 output of following commands enlightening:
11261 <example>
11262 dpkg-deb --info <var>filename</var>.deb
11263 dpkg-deb --contents <var>filename</var>.deb
11264 dpkg --contents <var>filename</var>.deb
11265 </example>
11266 To view the copyright file for a package you could use this command:
11267 <example>
11268 dpkg --fsys-tarfile <var>filename</var>.deb | tar xOf - --wildcards \*/copyright | pager
11269 </example>
11270 </p>
11271 </sect>
11273 <sect id="pkg-controlarea">
11274 <heading>Package control information files</heading>
11277 The control information portion of a binary package is a
11278 collection of files with names known to <prgn>dpkg</prgn>.
11279 It will treat the contents of these files specially - some
11280 of them contain information used by <prgn>dpkg</prgn> when
11281 installing or removing the package; others are scripts which
11282 the package maintainer wants <prgn>dpkg</prgn> to run.
11283 </p>
11286 It is possible to put other files in the package control
11287 information file area, but this is not generally a good idea
11288 (though they will largely be ignored).
11289 </p>
11292 Here is a brief list of the control information files supported
11293 by <prgn>dpkg</prgn> and a summary of what they're used for.
11294 </p>
11297 <taglist>
11298 <tag><tt>control</tt>
11299 <item>
11301 This is the key description file used by
11302 <prgn>dpkg</prgn>. It specifies the package's name
11303 and version, gives its description for the user,
11304 states its relationships with other packages, and so
11305 forth. See <ref id="sourcecontrolfiles"> and
11306 <ref id="binarycontrolfiles">.
11307 </p>
11310 It is usually generated automatically from information
11311 in the source package by the
11312 <prgn>dpkg-gencontrol</prgn> program, and with
11313 assistance from <prgn>dpkg-shlibdeps</prgn>.
11314 See <ref id="pkg-sourcetools">.
11315 </p>
11316 </item>
11318 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
11319 <tt>prerm</tt>
11320 </tag>
11321 <item>
11323 These are executable files (usually scripts) which
11324 <prgn>dpkg</prgn> runs during installation, upgrade
11325 and removal of packages. They allow the package to
11326 deal with matters which are particular to that package
11327 or require more complicated processing than that
11328 provided by <prgn>dpkg</prgn>. Details of when and
11329 how they are called are in <ref id="maintainerscripts">.
11330 </p>
11333 It is very important to make these scripts idempotent.
11334 See <ref id="idempotency">.
11335 </p>
11338 The maintainer scripts are not guaranteed to run with a
11339 controlling terminal and may not be able to interact with
11340 the user. See <ref id="controllingterminal">.
11341 </p>
11342 </item>
11344 <tag><tt>conffiles</tt>
11345 </tag>
11346 <item>
11347 This file contains a list of configuration files which
11348 are to be handled automatically by <prgn>dpkg</prgn>
11349 (see <ref id="pkg-conffiles">). Note that not necessarily
11350 every configuration file should be listed here.
11351 </item>
11353 <tag><tt>shlibs</tt>
11354 </tag>
11355 <item>
11356 This file contains a list of the shared libraries
11357 supplied by the package, with dependency details for
11358 each. This is used by <prgn>dpkg-shlibdeps</prgn>
11359 when it determines what dependencies are required in a
11360 package control file. The <tt>shlibs</tt> file format
11361 is described on <ref id="shlibs">.
11362 </item>
11363 </taglist>
11364 </p>
11366 <sect id="pkg-controlfile">
11367 <heading>The main control information file: <tt>control</tt></heading>
11370 The most important control information file used by
11371 <prgn>dpkg</prgn> when it installs a package is
11372 <tt>control</tt>. It contains all the package's "vital
11373 statistics".
11374 </p>
11377 The binary package control files of packages built from
11378 Debian sources are made by a special tool,
11379 <prgn>dpkg-gencontrol</prgn>, which reads
11380 <file>debian/control</file> and <file>debian/changelog</file> to
11381 find the information it needs. See <ref id="pkg-sourcepkg"> for
11382 more details.
11383 </p>
11386 The fields in binary package control files are listed in
11387 <ref id="binarycontrolfiles">.
11388 </p>
11391 A description of the syntax of control files and the purpose
11392 of the fields is available in <ref id="controlfields">.
11393 </p>
11394 </sect>
11396 <sect>
11397 <heading>Time Stamps</heading>
11400 See <ref id="timestamps">.
11401 </p>
11402 </sect>
11403 </appendix>
11405 <appendix id="pkg-sourcepkg">
11406 <heading>Source packages (from old Packaging Manual) </heading>
11409 The Debian binary packages in the distribution are generated
11410 from Debian sources, which are in a special format to assist
11411 the easy and automatic building of binaries.
11412 </p>
11414 <sect id="pkg-sourcetools">
11415 <heading>Tools for processing source packages</heading>
11418 Various tools are provided for manipulating source packages;
11419 they pack and unpack sources and help build of binary
11420 packages and help manage the distribution of new versions.
11421 </p>
11424 They are introduced and typical uses described here; see
11425 <manref name="dpkg-source" section="1"> for full
11426 documentation about their arguments and operation.
11427 </p>
11430 For examples of how to construct a Debian source package,
11431 and how to use those utilities that are used by Debian
11432 source packages, please see the <prgn>hello</prgn> example
11433 package.
11434 </p>
11436 <sect1 id="pkg-dpkg-source">
11437 <heading>
11438 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
11439 packages
11440 </heading>
11443 This program is frequently used by hand, and is also
11444 called from package-independent automated building scripts
11445 such as <prgn>dpkg-buildpackage</prgn>.
11446 </p>
11449 To unpack a package it is typically invoked with
11450 <example>
11451 dpkg-source -x <var>.../path/to/filename</var>.dsc
11452 </example>
11453 </p>
11456 with the <file><var>filename</var>.tar.gz</file> and
11457 <file><var>filename</var>.diff.gz</file> (if applicable) in
11458 the same directory. It unpacks into
11459 <file><var>package</var>-<var>version</var></file>, and if
11460 applicable
11461 <file><var>package</var>-<var>version</var>.orig</file>, in
11462 the current directory.
11463 </p>
11466 To create a packed source archive it is typically invoked:
11467 <example>
11468 dpkg-source -b <var>package</var>-<var>version</var>
11469 </example>
11470 </p>
11473 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
11474 <file>.diff.gz</file> (if appropriate) in the current
11475 directory. <prgn>dpkg-source</prgn> does not clean the
11476 source tree first - this must be done separately if it is
11477 required.
11478 </p>
11481 See also <ref id="pkg-sourcearchives">.</p>
11482 </sect1>
11485 <sect1 id="pkg-dpkg-buildpackage">
11486 <heading>
11487 <prgn>dpkg-buildpackage</prgn> - overall package-building
11488 control script
11489 </heading>
11492 See <manref name="dpkg-buildpackage" section="1">.
11493 </p>
11494 </sect1>
11496 <sect1 id="pkg-dpkg-gencontrol">
11497 <heading>
11498 <prgn>dpkg-gencontrol</prgn> - generates binary package
11499 control files
11500 </heading>
11503 This program is usually called from <file>debian/rules</file>
11504 (see <ref id="pkg-sourcetree">) in the top level of the source
11505 tree.
11506 </p>
11509 This is usually done just before the files and directories in the
11510 temporary directory tree where the package is being built have their
11511 permissions and ownerships set and the package is constructed using
11512 <prgn>dpkg-deb/</prgn>
11513 <footnote>
11514 This is so that the control file which is produced has
11515 the right permissions
11516 </footnote>.
11517 </p>
11520 <prgn>dpkg-gencontrol</prgn> must be called after all the
11521 files which are to go into the package have been placed in
11522 the temporary build directory, so that its calculation of
11523 the installed size of a package is correct.
11524 </p>
11527 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
11528 be run after <prgn>dpkg-shlibdeps</prgn> so that the
11529 variable substitutions created by
11530 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
11531 are available.
11532 </p>
11535 For a package which generates only one binary package, and
11536 which builds it in <file>debian/tmp</file> relative to the top
11537 of the source package, it is usually sufficient to call
11538 <prgn>dpkg-gencontrol</prgn>.
11539 </p>
11542 Sources which build several binaries will typically need
11543 something like:
11544 <example>
11545 dpkg-gencontrol -Pdebian/<var>pkg</var> -p<var>package</var>
11546 </example> The <tt>-P</tt> tells
11547 <prgn>dpkg-gencontrol</prgn> that the package is being
11548 built in a non-default directory, and the <tt>-p</tt>
11549 tells it which package's control file should be generated.
11550 </p>
11553 <prgn>dpkg-gencontrol</prgn> also adds information to the
11554 list of files in <file>debian/files</file>, for the benefit of
11555 (for example) a future invocation of
11556 <prgn>dpkg-genchanges</prgn>.</p>
11557 </sect1>
11559 <sect1 id="pkg-dpkg-shlibdeps">
11560 <heading>
11561 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
11562 dependencies
11563 </heading>
11566 See <manref name="dpkg-shlibdeps" section="1">.
11567 </p>
11568 </sect1>
11570 <sect1 id="pkg-dpkg-distaddfile">
11571 <heading>
11572 <prgn>dpkg-distaddfile</prgn> - adds a file to
11573 <file>debian/files</file>
11574 </heading>
11577 Some packages' uploads need to include files other than
11578 the source and binary package files.
11579 </p>
11582 <prgn>dpkg-distaddfile</prgn> adds a file to the
11583 <file>debian/files</file> file so that it will be included in
11584 the <file>.changes</file> file when
11585 <prgn>dpkg-genchanges</prgn> is run.
11586 </p>
11589 It is usually invoked from the <tt>binary</tt> target of
11590 <file>debian/rules</file>:
11591 <example>
11592 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
11593 </example>
11594 The <var>filename</var> is relative to the directory where
11595 <prgn>dpkg-genchanges</prgn> will expect to find it - this
11596 is usually the directory above the top level of the source
11597 tree. The <file>debian/rules</file> target should put the
11598 file there just before or just after calling
11599 <prgn>dpkg-distaddfile</prgn>.
11600 </p>
11603 The <var>section</var> and <var>priority</var> are passed
11604 unchanged into the resulting <file>.changes</file> file.
11605 </p>
11606 </sect1>
11609 <sect1 id="pkg-dpkg-genchanges">
11610 <heading>
11611 <prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file>
11612 upload control file
11613 </heading>
11616 See <manref name="dpkg-genchanges" section="1">.
11617 </p>
11618 </sect1>
11620 <sect1 id="pkg-dpkg-parsechangelog">
11621 <heading>
11622 <prgn>dpkg-parsechangelog</prgn> - produces parsed
11623 representation of a changelog
11624 </heading>
11627 See <manref name="dpkg-parsechangelog" section="1">.
11628 </p>
11629 </sect1>
11631 <sect1 id="pkg-dpkg-architecture">
11632 <heading>
11633 <prgn>dpkg-architecture</prgn> - information about the build and
11634 host system
11635 </heading>
11638 See <manref name="dpkg-architecture" section="1">.
11639 </p>
11640 </sect1>
11641 </sect>
11643 <sect id="pkg-sourcetree">
11644 <heading>The Debian package source tree</heading>
11647 The source archive scheme described later is intended to
11648 allow a Debian package source tree with some associated
11649 control information to be reproduced and transported easily.
11650 The Debian package source tree is a version of the original
11651 program with certain files added for the benefit of the
11652 packaging process, and with any other changes required
11653 made to the rest of the source code and installation
11654 scripts.
11655 </p>
11658 The extra files created for Debian are in the subdirectory
11659 <file>debian</file> of the top level of the Debian package
11660 source tree. They are described below.
11661 </p>
11663 <sect1 id="pkg-debianrules">
11664 <heading><file>debian/rules</file> - the main building script</heading>
11667 See <ref id="debianrules">.
11668 </p>
11669 </sect1>
11671 <sect1 id="pkg-srcsubstvars">
11672 <heading><file>debian/substvars</file> and variable substitutions</heading>
11675 See <ref id="substvars">.
11676 </p>
11678 </sect1>
11680 <sect1>
11681 <heading><file>debian/files</file></heading>
11684 See <ref id="debianfiles">.
11685 </p>
11686 </sect1>
11688 <sect1><heading><file>debian/tmp</file>
11689 </heading>
11692 This is the default temporary location for the construction of
11693 binary packages by the <tt>binary</tt> target. The
11694 directory <file>tmp</file> serves as the root of the file
11695 system tree as it is being constructed (for example, by using
11696 the package's upstream makefiles install targets and
11697 redirecting the output there), and it also contains
11698 the <tt>DEBIAN</tt> subdirectory.
11699 See <ref id="pkg-bincreating">.
11700 </p>
11703 This is only a default and can be easily overridden. Most
11704 packaging tools no longer use <file>debian/tmp</file>, instead
11705 preferring <file>debian/<var>pkg</var></file> for the common
11706 case of a source package building only one binary package.
11707 Such tools usually only use <file>debian/tmp</file> as a
11708 temporary staging area for built files and do not construct
11709 packages from it.
11710 </p>
11713 If several binary packages are generated from the same source
11714 tree, it is usual to use a separate
11715 <file>debian/<var>pkg</var></file> directory for each binary
11716 package as the temporary construction locations.
11717 </p>
11720 Whatever temporary directories are created and used by the
11721 <tt>binary</tt> target must of course be removed by the
11722 <tt>clean</tt> target.
11723 </p>
11724 </sect1>
11725 </sect>
11728 <sect id="pkg-sourcearchives"><heading>Source packages as archives
11729 </heading>
11732 As it exists on the FTP site, a Debian source package
11733 consists of three related files. You must have the right
11734 versions of all three to be able to use them.
11735 </p>
11738 <taglist>
11739 <tag>Debian source control file - <tt>.dsc</tt></tag>
11740 <item>
11741 This file is a control file used by <prgn>dpkg-source</prgn>
11742 to extract a source package.
11743 See <ref id="debiansourcecontrolfiles">.
11744 </item>
11746 <tag>
11747 Original source archive -
11748 <file>
11749 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
11750 </file>
11751 </tag>
11753 <item>
11755 This is a compressed (with <tt>gzip -9</tt>)
11756 <prgn>tar</prgn> file containing the source code from
11757 the upstream authors of the program.
11758 </p>
11759 </item>
11761 <tag>
11762 Debian package diff -
11763 <file>
11764 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
11765 </file>
11766 </tag>
11767 <item>
11770 This is a unified context diff (<tt>diff -u</tt>)
11771 giving the changes which are required to turn the
11772 original source into the Debian source. These changes
11773 may only include editing and creating plain files.
11774 The permissions of files, the targets of symbolic
11775 links and the characteristics of special files or
11776 pipes may not be changed and no files may be removed
11777 or renamed.
11778 </p>
11781 All the directories in the diff must exist, except the
11782 <file>debian</file> subdirectory of the top of the source
11783 tree, which will be created by
11784 <prgn>dpkg-source</prgn> if necessary when unpacking.
11785 </p>
11788 The <prgn>dpkg-source</prgn> program will
11789 automatically make the <file>debian/rules</file> file
11790 executable (see below).</p></item>
11791 </taglist>
11792 </p>
11795 If there is no original source code - for example, if the
11796 package is specially prepared for Debian or the Debian
11797 maintainer is the same as the upstream maintainer - the
11798 format is slightly different: then there is no diff, and the
11799 tarfile is named
11800 <file><var>package</var>_<var>version</var>.tar.gz</file>,
11801 and preferably contains a directory named
11802 <file><var>package</var>-<var>version</var></file>.
11803 </p>
11804 </sect>
11806 <sect>
11807 <heading>Unpacking a Debian source package without <prgn>dpkg-source</prgn></heading>
11810 <tt>dpkg-source -x</tt> is the recommended way to unpack a
11811 Debian source package. However, if it is not available it
11812 is possible to unpack a Debian source archive as follows:
11813 <enumlist compact="compact">
11814 <item>
11816 Untar the tarfile, which will create a <file>.orig</file>
11817 directory.</p>
11818 </item>
11819 <item>
11820 <p>Rename the <file>.orig</file> directory to
11821 <file><var>package</var>-<var>version</var></file>.</p>
11822 </item>
11823 <item>
11825 Create the subdirectory <file>debian</file> at the top of
11826 the source tree.</p>
11827 </item>
11828 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
11829 </item>
11830 <item><p>Untar the tarfile again if you want a copy of the original
11831 source code alongside the Debian version.</p>
11832 </item>
11833 </enumlist>
11836 It is not possible to generate a valid Debian source archive
11837 without using <prgn>dpkg-source</prgn>. In particular,
11838 attempting to use <prgn>diff</prgn> directly to generate the
11839 <file>.diff.gz</file> file will not work.
11840 </p>
11842 <sect1>
11843 <heading>Restrictions on objects in source packages</heading>
11846 The source package may not contain any hard links
11847 <footnote>
11848 This is not currently detected when building source
11849 packages, but only when extracting
11850 them.
11851 </footnote>
11852 <footnote>
11853 Hard links may be permitted at some point in the
11854 future, but would require a fair amount of
11855 work.
11856 </footnote>, device special files, sockets or setuid or
11857 setgid files.
11858 <footnote>
11859 Setgid directories are allowed.
11860 </footnote>
11861 </p>
11864 The source packaging tools manage the changes between the
11865 original and Debian source using <prgn>diff</prgn> and
11866 <prgn>patch</prgn>. Turning the original source tree as
11867 included in the <file>.orig.tar.gz</file> into the Debian
11868 package source must not involve any changes which cannot be
11869 handled by these tools. Problematic changes which cause
11870 <prgn>dpkg-source</prgn> to halt with an error when
11871 building the source package are:
11872 <list compact="compact">
11873 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
11874 </item>
11875 <item><p>Changing the targets of symbolic links.</p>
11876 </item>
11877 <item><p>Creating directories, other than <file>debian</file>.</p>
11878 </item>
11879 <item><p>Changes to the contents of binary files.</p></item>
11880 </list> Changes which cause <prgn>dpkg-source</prgn> to
11881 print a warning but continue anyway are:
11882 <list compact="compact">
11883 <item>
11885 Removing files, directories or symlinks.
11886 <footnote>
11887 Renaming a file is not treated specially - it is
11888 seen as the removal of the old file (which
11889 generates a warning, but is otherwise ignored),
11890 and the creation of the new one.
11891 </footnote>
11892 </p>
11893 </item>
11894 <item>
11896 Changed text files which are missing the usual final
11897 newline (either in the original or the modified
11898 source tree).
11899 </p>
11900 </item>
11901 </list>
11902 Changes which are not represented, but which are not detected by
11903 <prgn>dpkg-source</prgn>, are:
11904 <list compact="compact">
11905 <item><p>Changing the permissions of files (other than
11906 <file>debian/rules</file>) and directories.</p></item>
11907 </list>
11908 </p>
11911 The <file>debian</file> directory and <file>debian/rules</file>
11912 are handled specially by <prgn>dpkg-source</prgn> - before
11913 applying the changes it will create the <file>debian</file>
11914 directory, and afterwards it will make
11915 <file>debian/rules</file> world-executable.
11916 </p>
11917 </sect1>
11918 </sect>
11919 </appendix>
11921 <appendix id="pkg-controlfields">
11922 <heading>Control files and their fields (from old Packaging Manual)</heading>
11925 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
11926 data in a common format, known as control files. Binary and
11927 source packages have control data as do the <file>.changes</file>
11928 files which control the installation of uploaded files, and
11929 <prgn>dpkg</prgn>'s internal databases are in a similar
11930 format.
11931 </p>
11933 <sect>
11934 <heading>Syntax of control files</heading>
11937 See <ref id="controlsyntax">.
11938 </p>
11941 It is important to note that there are several fields which
11942 are optional as far as <prgn>dpkg</prgn> and the related
11943 tools are concerned, but which must appear in every Debian
11944 package, or whose omission may cause problems.
11945 </p>
11946 </sect>
11948 <sect>
11949 <heading>List of fields</heading>
11952 See <ref id="controlfieldslist">.
11953 </p>
11956 This section now contains only the fields that didn't belong
11957 to the Policy manual.
11958 </p>
11960 <sect1 id="pkg-f-Filename">
11961 <heading><tt>Filename</tt> and <tt>MSDOS-Filename</tt></heading>
11964 These fields in <tt>Packages</tt> files give the
11965 filename(s) of (the parts of) a package in the
11966 distribution directories, relative to the root of the
11967 Debian hierarchy. If the package has been split into
11968 several parts the parts are all listed in order, separated
11969 by spaces.
11970 </p>
11971 </sect1>
11973 <sect1 id="pkg-f-Size">
11974 <heading><tt>Size</tt> and <tt>MD5sum</tt></heading>
11977 These fields in <file>Packages</file> files give the size (in
11978 bytes, expressed in decimal) and MD5 checksum of the
11979 file(s) which make(s) up a binary package in the
11980 distribution. If the package is split into several parts
11981 the values for the parts are listed in order, separated by
11982 spaces.
11983 </p>
11984 </sect1>
11986 <sect1 id="pkg-f-Status">
11987 <heading><tt>Status</tt></heading>
11990 This field in <prgn>dpkg</prgn>'s status file records
11991 whether the user wants a package installed, removed or
11992 left alone, whether it is broken (requiring
11993 re-installation) or not and what its current state on the
11994 system is. Each of these pieces of information is a
11995 single word.
11996 </p>
11997 </sect1>
11999 <sect1 id="pkg-f-Config-Version">
12000 <heading><tt>Config-Version</tt></heading>
12003 If a package is not installed or not configured, this
12004 field in <prgn>dpkg</prgn>'s status file records the last
12005 version of the package which was successfully
12006 configured.
12007 </p>
12008 </sect1>
12010 <sect1 id="pkg-f-Conffiles">
12011 <heading><tt>Conffiles</tt></heading>
12014 This field in <prgn>dpkg</prgn>'s status file contains
12015 information about the automatically-managed configuration
12016 files held by a package. This field should <em>not</em>
12017 appear anywhere in a package!
12018 </p>
12019 </sect1>
12021 <sect1>
12022 <heading>Obsolete fields</heading>
12025 These are still recognized by <prgn>dpkg</prgn> but should
12026 not appear anywhere any more.
12028 <taglist compact="compact">
12030 <tag><tt>Revision</tt></tag>
12031 <tag><tt>Package-Revision</tt></tag>
12032 <tag><tt>Package_Revision</tt></tag>
12033 <item>
12034 The Debian revision part of the package version was
12035 at one point in a separate control field. This
12036 field went through several names.
12037 </item>
12039 <tag><tt>Recommended</tt></tag>
12040 <item>Old name for <tt>Recommends</tt>.</item>
12042 <tag><tt>Optional</tt></tag>
12043 <item>Old name for <tt>Suggests</tt>.</item>
12045 <tag><tt>Class</tt></tag>
12046 <item>Old name for <tt>Priority</tt>.</item>
12048 </taglist>
12049 </p>
12050 </sect1>
12051 </sect>
12053 </appendix>
12055 <appendix id="pkg-conffiles">
12056 <heading>Configuration file handling (from old Packaging Manual)</heading>
12059 <prgn>dpkg</prgn> can do a certain amount of automatic
12060 handling of package configuration files.
12061 </p>
12064 Whether this mechanism is appropriate depends on a number of
12065 factors, but basically there are two approaches to any
12066 particular configuration file.
12067 </p>
12070 The easy method is to ship a best-effort configuration in the
12071 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
12072 handle updates. If the user is unlikely to want to edit the
12073 file, but you need them to be able to without losing their
12074 changes, and a new package with a changed version of the file
12075 is only released infrequently, this is a good approach.
12076 </p>
12079 The hard method is to build the configuration file from
12080 scratch in the <prgn>postinst</prgn> script, and to take the
12081 responsibility for fixing any mistakes made in earlier
12082 versions of the package automatically. This will be
12083 appropriate if the file is likely to need to be different on
12084 each system.
12085 </p>
12087 <sect><heading>Automatic handling of configuration files by
12088 <prgn>dpkg</prgn>
12089 </heading>
12092 A package may contain a control information file called
12093 <tt>conffiles</tt>. This file should be a list of filenames
12094 of configuration files needing automatic handling, separated
12095 by newlines. The filenames should be absolute pathnames,
12096 and the files referred to should actually exist in the
12097 package.
12098 </p>
12101 When a package is upgraded <prgn>dpkg</prgn> will process
12102 the configuration files during the configuration stage,
12103 shortly before it runs the package's <prgn>postinst</prgn>
12104 script,
12105 </p>
12108 For each file it checks to see whether the version of the
12109 file included in the package is the same as the one that was
12110 included in the last version of the package (the one that is
12111 being upgraded from); it also compares the version currently
12112 installed on the system with the one shipped with the last
12113 version.
12114 </p>
12117 If neither the user nor the package maintainer has changed
12118 the file, it is left alone. If one or the other has changed
12119 their version, then the changed version is preferred - i.e.,
12120 if the user edits their file, but the package maintainer
12121 doesn't ship a different version, the user's changes will
12122 stay, silently, but if the maintainer ships a new version
12123 and the user hasn't edited it the new version will be
12124 installed (with an informative message). If both have
12125 changed their version the user is prompted about the problem
12126 and must resolve the differences themselves.
12127 </p>
12130 The comparisons are done by calculating the MD5 message
12131 digests of the files, and storing the MD5 of the file as it
12132 was included in the most recent version of the package.
12133 </p>
12136 When a package is installed for the first time
12137 <prgn>dpkg</prgn> will install the file that comes with it,
12138 unless that would mean overwriting a file already on the
12139 file system.
12140 </p>
12143 However, note that <prgn>dpkg</prgn> will <em>not</em>
12144 replace a conffile that was removed by the user (or by a
12145 script). This is necessary because with some programs a
12146 missing file produces an effect hard or impossible to
12147 achieve in another way, so that a missing file needs to be
12148 kept that way if the user did it.
12149 </p>
12152 Note that a package should <em>not</em> modify a
12153 <prgn>dpkg</prgn>-handled conffile in its maintainer
12154 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
12155 the user confusing and possibly dangerous options for
12156 conffile update when the package is upgraded.</p>
12157 </sect>
12159 <sect><heading>Fully-featured maintainer script configuration
12160 handling
12161 </heading>
12164 For files which contain site-specific information such as
12165 the hostname and networking details and so forth, it is
12166 better to create the file in the package's
12167 <prgn>postinst</prgn> script.
12168 </p>
12171 This will typically involve examining the state of the rest
12172 of the system to determine values and other information, and
12173 may involve prompting the user for some information which
12174 can't be obtained some other way.
12175 </p>
12178 When using this method there are a couple of important
12179 issues which should be considered:
12180 </p>
12183 If you discover a bug in the program which generates the
12184 configuration file, or if the format of the file changes
12185 from one version to the next, you will have to arrange for
12186 the postinst script to do something sensible - usually this
12187 will mean editing the installed configuration file to remove
12188 the problem or change the syntax. You will have to do this
12189 very carefully, since the user may have changed the file,
12190 perhaps to fix the very problem that your script is trying
12191 to deal with - you will have to detect these situations and
12192 deal with them correctly.
12193 </p>
12196 If you do go down this route it's probably a good idea to
12197 make the program that generates the configuration file(s) a
12198 separate program in <file>/usr/sbin</file>, by convention called
12199 <file><var>package</var>config</file> and then run that if
12200 appropriate from the post-installation script. The
12201 <tt><var>package</var>config</tt> program should not
12202 unquestioningly overwrite an existing configuration - if its
12203 mode of operation is geared towards setting up a package for
12204 the first time (rather than any arbitrary reconfiguration
12205 later) you should have it check whether the configuration
12206 already exists, and require a <tt>--force</tt> flag to
12207 overwrite it.</p></sect>
12208 </appendix>
12210 <appendix id="pkg-alternatives"><heading>Alternative versions of
12211 an interface - <prgn>update-alternatives</prgn> (from old
12212 Packaging Manual)
12213 </heading>
12216 When several packages all provide different versions of the
12217 same program or file it is useful to have the system select a
12218 default, but to allow the system administrator to change it
12219 and have their decisions respected.
12220 </p>
12223 For example, there are several versions of the <prgn>vi</prgn>
12224 editor, and there is no reason to prevent all of them from
12225 being installed at once, each under their own name
12226 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
12227 Nevertheless it is desirable to have the name <tt>vi</tt>
12228 refer to something, at least by default.
12229 </p>
12232 If all the packages involved cooperate, this can be done with
12233 <prgn>update-alternatives</prgn>.
12234 </p>
12237 Each package provides its own version under its own name, and
12238 calls <prgn>update-alternatives</prgn> in its postinst to
12239 register its version (and again in its prerm to deregister
12240 it).
12241 </p>
12244 See the man page <manref name="update-alternatives"
12245 section="8"> for details.
12246 </p>
12249 If <prgn>update-alternatives</prgn> does not seem appropriate
12250 you may wish to consider using diversions instead.</p>
12251 </appendix>
12253 <appendix id="pkg-diversions"><heading>Diversions - overriding a
12254 package's version of a file (from old Packaging Manual)
12255 </heading>
12258 It is possible to have <prgn>dpkg</prgn> not overwrite a file
12259 when it reinstalls the package it belongs to, and to have it
12260 put the file from the package somewhere else instead.
12261 </p>
12264 This can be used locally to override a package's version of a
12265 file, or by one package to override another's version (or
12266 provide a wrapper for it).
12267 </p>
12270 Before deciding to use a diversion, read <ref
12271 id="pkg-alternatives"> to see if you really want a diversion
12272 rather than several alternative versions of a program.
12273 </p>
12276 There is a diversion list, which is read by <prgn>dpkg</prgn>,
12277 and updated by a special program <prgn>dpkg-divert</prgn>.
12278 Please see <manref name="dpkg-divert" section="8"> for full
12279 details of its operation.
12280 </p>
12283 When a package wishes to divert a file from another, it should
12284 call <prgn>dpkg-divert</prgn> in its preinst to add the
12285 diversion and rename the existing file. For example,
12286 supposing that a <prgn>smailwrapper</prgn> package wishes to
12287 install a wrapper around <file>/usr/sbin/smail</file>:
12288 <example>
12289 dpkg-divert --package smailwrapper --add --rename \
12290 --divert /usr/sbin/smail.real /usr/sbin/smail
12291 </example> The <tt>--package smailwrapper</tt> ensures that
12292 <prgn>smailwrapper</prgn>'s copy of <file>/usr/sbin/smail</file>
12293 can bypass the diversion and get installed as the true version.
12294 It's safe to add the diversion unconditionally on upgrades since
12295 it will be left unchanged if it already exists, but
12296 <prgn>dpkg-divert</prgn> will display a message. To suppress that
12297 message, make the command conditional on the version from which
12298 the package is being upgraded:
12299 <example>
12300 if [ upgrade != "$1" ] || dpkg --compare-versions "$2" lt 1.0-2; then
12301 dpkg-divert --package smailwrapper --add --rename \
12302 --divert /usr/sbin/smail.real /usr/sbin/smail
12304 </example> where <tt>1.0-2</tt> is the version at which the
12305 diversion was first added to the package. Running the command
12306 during abort-upgrade is pointless but harmless.
12307 </p>
12310 The postrm has to do the reverse:
12311 <example>
12312 if [ remove = "$1" -o abort-install = "$1" -o disappear = "$1" ]; then
12313 dpkg-divert --package smailwrapper --remove --rename \
12314 --divert /usr/sbin/smail.real /usr/sbin/smail
12316 </example> If the diversion was added at a particular version, the
12317 postrm should also handle the failure case of upgrading from an
12318 older version (unless the older version is so old that direct
12319 upgrades are no longer supported):
12320 <example>
12321 if [ abort-upgrade = "$1" ] && dpkg --compare-versions "$2" lt 1.0-2; then
12322 dpkg-divert --package smailwrapper --remove --rename \
12323 --divert /usr/sbin/smail.real /usr/sbin/smail
12325 </example> where <tt>1.0-2</tt> is the version at which the
12326 diversion was first added to the package. The postrm should not
12327 remove the diversion on upgrades both because there's no reason to
12328 remove the diversion only to immediately re-add it and since the
12329 postrm of the old package is run after unpacking so the removal of
12330 the diversion will fail.
12331 </p>
12334 Do not attempt to divert a file which is vitally important for
12335 the system's operation - when using <prgn>dpkg-divert</prgn>
12336 there is a time, after it has been diverted but before
12337 <prgn>dpkg</prgn> has installed the new version, when the file
12338 does not exist.</p>
12341 Do not attempt to divert a conffile, as <prgn>dpkg</prgn> does not
12342 handle it well.
12343 </p>
12344 </appendix>
12346 </book>
12347 </debiandoc>
12348 <!-- Local variables: -->
12349 <!-- indent-tabs-mode: t -->
12350 <!-- End: -->
12351 <!-- vim:set ai sts=2 sw=2 tw=76: -->