Rewrite the Device files section
[debian-policy.git] / policy.sgml
blob4f022407eaf6ce9253577ab8506cf1c2e6555fe3
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 The current policy process is described in the <url name="Process"
226 id="Process.md"> document.
227 The actual editing is done by a group of maintainers that have
228 no editorial powers. These are the current maintainers:
230 <enumlist>
231 <item>Russ Allbery</item>
232 <item>Bill Allombert</item>
233 <item>Andreas Barth</item>
234 <item>Jonathan Nieder</item>
235 </enumlist>
236 </p>
239 While the authors of this document have tried hard to avoid
240 typos and other errors, these do still occur. If you discover
241 an error in this manual or if you want to give any
242 comments, suggestions, or criticisms please send an email to
243 the Debian Policy List,
244 <email>debian-policy@lists.debian.org</email>, or submit a
245 bug report against the <tt>debian-policy</tt> package.
246 </p>
249 Please do not try to reach the individual authors or maintainers
250 of the Policy Manual regarding changes to the Policy.
251 </p>
252 </sect>
254 <sect id="related">
255 <heading>Related documents</heading>
258 There are several other documents other than this Policy Manual
259 that are necessary to fully understand some Debian policies and
260 procedures.
261 </p>
264 The external "sub-policy" documents are referred to in:
265 <list compact="compact">
266 <item><ref id="fhs"></item>
267 <item><ref id="virtual_pkg"></item>
268 <item><ref id="menus"></item>
269 <item><ref id="perl"></item>
270 <item><ref id="maintscriptprompt"></item>
271 <item><ref id="emacs"></item>
272 </list>
273 </p>
276 In addition to those, which carry the weight of policy, there
277 is the Debian Developer's Reference. This document describes
278 procedures and resources for Debian developers, but it is
279 <em>not</em> normative; rather, it includes things that don't
280 belong in the Policy, such as best practices for developers.
281 </p>
284 The Developer's Reference is available in the
285 <package>developers-reference</package> package.
286 It's also available from the Debian web mirrors at
287 <tt><url name="/doc/developers-reference/"
288 id="http://www.debian.org/doc/developers-reference/"></tt>.
289 </p>
292 Finally, a <qref id="copyrightformat">specification for
293 machine-readable copyright files</qref> is maintained as part of
294 the <package>debian-policy</package> package using the same
295 procedure as the other policy documents. Use of this format is
296 optional.
297 </p>
298 </sect>
300 <sect id="definitions">
301 <heading>Definitions</heading>
304 The following terms are used in this Policy Manual:
305 <taglist>
306 <tag>ASCII</tag>
307 <item>
308 The character encoding specified by ANSI X3.4-1986 and its
309 predecessor standards, referred to in MIME as US-ASCII, and
310 corresponding to an encoding in eight bits per character of
311 the first 128 <url id="http://www.unicode.org/"
312 name="Unicode"> characters, with the eighth bit always zero.
313 </item>
314 <tag>UTF-8</tag>
315 <item>
316 The transformation format (sometimes called encoding) of
317 <url id="http://www.unicode.org/" name="Unicode"> defined by
318 <url id="http://www.rfc-editor.org/rfc/rfc3629.txt"
319 name="RFC 3629">. UTF-8 has the useful property of having
320 ASCII as a subset, so any text encoded in ASCII is trivially
321 also valid UTF-8.
322 </item>
323 </taglist>
324 </p>
325 </sect>
326 </chapt>
329 <chapt id="archive">
330 <heading>The Debian Archive</heading>
333 The Debian system is maintained and distributed as a
334 collection of <em>packages</em>. Since there are so many of
335 them (currently well over 15000), they are split into
336 <em>sections</em> and given <em>priorities</em> to simplify
337 the handling of them.
338 </p>
341 The effort of the Debian project is to build a free operating
342 system, but not every package we want to make accessible is
343 <em>free</em> in our sense (see the Debian Free Software
344 Guidelines, below), or may be imported/exported without
345 restrictions. Thus, the archive is split into areas<footnote>
346 The Debian archive software uses the term "component" internally
347 and in the Release file format to refer to the division of an
348 archive. The Debian Social Contract simply refers to "areas."
349 This document uses terminology similar to the Social Contract.
350 </footnote> based on their licenses and other restrictions.
351 </p>
354 The aims of this are:
356 <list compact="compact">
357 <item>to allow us to make as much software available as we can</item>
358 <item>to allow us to encourage everyone to write free software,
359 and</item>
360 <item>to allow us to make it easy for people to produce
361 CD-ROMs of our system without violating any licenses,
362 import/export restrictions, or any other laws.</item>
363 </list>
364 </p>
367 The <em>main</em> archive area forms the <em>Debian distribution</em>.
368 </p>
371 Packages in the other archive areas (<tt>contrib</tt>,
372 <tt>non-free</tt>) are not considered to be part of the Debian
373 distribution, although we support their use and provide
374 infrastructure for them (such as our bug-tracking system and
375 mailing lists). This Debian Policy Manual applies to these
376 packages as well.
377 </p>
379 <sect id="dfsg">
380 <heading>The Debian Free Software Guidelines</heading>
382 The Debian Free Software Guidelines (DFSG) form our
383 definition of "free software". These are:
384 <taglist>
385 <tag>1. Free Redistribution
386 </tag>
387 <item>
388 The license of a Debian component may not restrict any
389 party from selling or giving away the software as a
390 component of an aggregate software distribution
391 containing programs from several different
392 sources. The license may not require a royalty or
393 other fee for such sale.
394 </item>
395 <tag>2. Source Code
396 </tag>
397 <item>
398 The program must include source code, and must allow
399 distribution in source code as well as compiled form.
400 </item>
401 <tag>3. Derived Works
402 </tag>
403 <item>
404 The license must allow modifications and derived
405 works, and must allow them to be distributed under the
406 same terms as the license of the original software.
407 </item>
408 <tag>4. Integrity of The Author's Source Code
409 </tag>
410 <item>
411 The license may restrict source-code from being
412 distributed in modified form <em>only</em> if the
413 license allows the distribution of "patch files"
414 with the source code for the purpose of modifying the
415 program at build time. The license must explicitly
416 permit distribution of software built from modified
417 source code. The license may require derived works to
418 carry a different name or version number from the
419 original software. (This is a compromise. The Debian
420 Project encourages all authors to not restrict any
421 files, source or binary, from being modified.)
422 </item>
423 <tag>5. No Discrimination Against Persons or Groups
424 </tag>
425 <item>
426 The license must not discriminate against any person
427 or group of persons.
428 </item>
429 <tag>6. No Discrimination Against Fields of Endeavor
430 </tag>
431 <item>
432 The license must not restrict anyone from making use
433 of the program in a specific field of endeavor. For
434 example, it may not restrict the program from being
435 used in a business, or from being used for genetic
436 research.
437 </item>
438 <tag>7. Distribution of License
439 </tag>
440 <item>
441 The rights attached to the program must apply to all
442 to whom the program is redistributed without the need
443 for execution of an additional license by those
444 parties.
445 </item>
446 <tag>8. License Must Not Be Specific to Debian
447 </tag>
448 <item>
449 The rights attached to the program must not depend on
450 the program's being part of a Debian system. If the
451 program is extracted from Debian and used or
452 distributed without Debian but otherwise within the
453 terms of the program's license, all parties to whom
454 the program is redistributed must have the same
455 rights as those that are granted in conjunction with
456 the Debian system.
457 </item>
458 <tag>9. License Must Not Contaminate Other Software
459 </tag>
460 <item>
461 The license must not place restrictions on other
462 software that is distributed along with the licensed
463 software. For example, the license must not insist
464 that all other programs distributed on the same medium
465 must be free software.
466 </item>
467 <tag>10. Example Licenses
468 </tag>
469 <item>
470 The "GPL," "BSD," and "Artistic" licenses are examples of
471 licenses that we consider <em>free</em>.
472 </item>
473 </taglist>
474 </p>
475 </sect>
477 <sect id="sections">
478 <heading>Archive areas</heading>
480 <sect1 id="main">
481 <heading>The main archive area</heading>
484 The <em>main</em> archive area comprises the Debian
485 distribution. Only the packages in this area are considered
486 part of the distribution. None of the packages in
487 the <em>main</em> archive area require software outside of
488 that area to function. Anyone may use, share, modify and
489 redistribute the packages in this archive area
490 freely<footnote>
491 See <url id="http://www.debian.org/intro/free"
492 name="What Does Free Mean?"> for
493 more about what we mean by free software.
494 </footnote>.
495 </p>
498 Every package in <em>main</em> must comply with the DFSG
499 (Debian Free Software Guidelines).
500 </p>
503 In addition, the packages in <em>main</em>
504 <list compact="compact">
505 <item>
506 must not require or recommend a package outside
507 of <em>main</em> for compilation or execution (thus, the
508 package must not declare a "Pre-Depends", "Depends",
509 "Recommends", "Build-Depends", "Build-Depends-Indep",
510 or "Build-Depends-Arch" relationship on a non-<em>main</em>
511 package),
512 </item>
513 <item>
514 must not be so buggy that we refuse to support them,
516 </item>
517 <item>
518 must meet all policy requirements presented in this
519 manual.
520 </item>
521 </list>
522 </p>
524 </sect1>
526 <sect1 id="contrib">
527 <heading>The contrib archive area</heading>
530 The <em>contrib</em> archive area contains supplemental
531 packages intended to work with the Debian distribution, but
532 which require software outside of the distribution to either
533 build or function.
534 </p>
537 Every package in <em>contrib</em> must comply with the DFSG.
538 </p>
541 In addition, the packages in <em>contrib</em>
542 <list compact="compact">
543 <item>
544 must not be so buggy that we refuse to support them,
546 </item>
547 <item>
548 must meet all policy requirements presented in this
549 manual.
550 </item>
551 </list>
552 </p>
555 Examples of packages which would be included in
556 <em>contrib</em> are:
557 <list compact="compact">
558 <item>
559 free packages which require <em>contrib</em>,
560 <em>non-free</em> packages or packages which are not
561 in our archive at all for compilation or execution,
563 </item>
564 <item>
565 wrapper packages or other sorts of free accessories for
566 non-free programs.
567 </item>
568 </list>
569 </p>
570 </sect1>
572 <sect1 id="non-free">
573 <heading>The non-free archive area</heading>
576 The <em>non-free</em> archive area contains supplemental
577 packages intended to work with the Debian distribution that do
578 not comply with the DFSG or have other problems that make
579 their distribution problematic. They may not comply with all
580 of the policy requirements in this manual due to restrictions
581 on modifications or other limitations.
582 </p>
585 Packages must be placed in <em>non-free</em> if they are
586 not compliant with the DFSG or are encumbered by patents
587 or other legal issues that make their distribution
588 problematic.
589 </p>
592 In addition, the packages in <em>non-free</em>
593 <list compact="compact">
594 <item>
595 must not be so buggy that we refuse to support them,
597 </item>
598 <item>
599 must meet all policy requirements presented in this
600 manual that it is possible for them to meet.
601 <footnote>
602 It is possible that there are policy
603 requirements which the package is unable to
604 meet, for example, if the source is
605 unavailable. These situations will need to be
606 handled on a case-by-case basis.
607 </footnote>
608 </item>
609 </list>
610 </p>
611 </sect1>
613 </sect>
615 <sect id="pkgcopyright">
616 <heading>Copyright considerations</heading>
619 Every package must be accompanied by a verbatim copy of its
620 copyright information and distribution license in the file
621 <file>/usr/share/doc/<var>package</var>/copyright</file>
622 (see <ref id="copyrightfile"> for further details).
623 </p>
626 We reserve the right to restrict files from being included
627 anywhere in our archives if
628 <list compact="compact">
629 <item>
630 their use or distribution would break a law,
631 </item>
632 <item>
633 there is an ethical conflict in their distribution or
634 use,
635 </item>
636 <item>
637 we would have to sign a license for them, or
638 </item>
639 <item>
640 their distribution would conflict with other project
641 policies.
642 </item>
643 </list>
644 </p>
647 Programs whose authors encourage the user to make
648 donations are fine for the main distribution, provided
649 that the authors do not claim that not donating is
650 immoral, unethical, illegal or something similar; in such
651 a case they must go in <em>non-free</em>.
652 </p>
655 Packages whose copyright permission notices (or patent
656 problems) do not even allow redistribution of binaries
657 only, and where no special permission has been obtained,
658 must not be placed on the Debian FTP site and its mirrors
659 at all.
660 </p>
663 Note that under international copyright law (this applies
664 in the United States, too), <em>no</em> distribution or
665 modification of a work is allowed without an explicit
666 notice saying so. Therefore a program without a copyright
667 notice <em>is</em> copyrighted and you may not do anything
668 to it without risking being sued! Likewise if a program
669 has a copyright notice but no statement saying what is
670 permitted then nothing is permitted.
671 </p>
674 Many authors are unaware of the problems that restrictive
675 copyrights (or lack of copyright notices) can cause for
676 the users of their supposedly-free software. It is often
677 worthwhile contacting such authors diplomatically to ask
678 them to modify their license terms. However, this can be a
679 politically difficult thing to do and you should ask for
680 advice on the <tt>debian-legal</tt> mailing list first, as
681 explained below.
682 </p>
685 When in doubt about a copyright, send mail to
686 <email>debian-legal@lists.debian.org</email>. Be prepared
687 to provide us with the copyright statement. Software
688 covered by the GPL, public domain software and BSD-like
689 copyrights are safe; be wary of the phrases "commercial
690 use prohibited" and "distribution restricted".
691 </p>
692 </sect>
694 <sect id="subsections">
695 <heading>Sections</heading>
698 The packages in the archive areas <em>main</em>,
699 <em>contrib</em> and <em>non-free</em> are grouped further into
700 <em>sections</em> to simplify handling.
701 </p>
704 The archive area and section for each package should be
705 specified in the package's <tt>Section</tt> control record (see
706 <ref id="f-Section">). However, the maintainer of the Debian
707 archive may override this selection to ensure the consistency of
708 the Debian distribution. The <tt>Section</tt> field should be
709 of the form:
710 <list compact="compact">
711 <item>
712 <em>section</em> if the package is in the
713 <em>main</em> archive area,
714 </item>
715 <item>
716 <em>area/section</em> if the package is in
717 the <em>contrib</em> or <em>non-free</em>
718 archive areas.
719 </item>
720 </list>
721 </p>
724 The Debian archive maintainers provide the authoritative
725 list of sections. At present, they are:
726 admin,
727 cli-mono,
728 comm,
729 database,
730 debug,
731 devel,
732 doc,
733 editors,
734 education,
735 electronics,
736 embedded,
737 fonts,
738 games,
739 gnome,
740 gnu-r,
741 gnustep,
742 graphics,
743 hamradio,
744 haskell,
745 httpd,
746 interpreters,
747 introspection,
748 java,
749 kde,
750 kernel,
751 libdevel,
752 libs,
753 lisp,
754 localization,
755 mail,
756 math,
757 metapackages,
758 misc,
759 net,
760 news,
761 ocaml,
762 oldlibs,
763 otherosfs,
764 perl,
765 php,
766 python,
767 ruby,
768 science,
769 shells,
770 sound,
771 tasks,
772 tex,
773 text,
774 utils,
775 vcs,
776 video,
777 web,
778 x11,
779 xfce,
780 zope.
781 The additional section <em>debian-installer</em>
782 contains special packages used by the installer and is not used
783 for normal Debian packages.
784 </p>
787 For more information about the sections and their definitions,
788 see the <url id="http://packages.debian.org/unstable/"
789 name="list of sections in unstable">.
790 </p>
791 </sect>
793 <sect id="priorities">
794 <heading>Priorities</heading>
797 Each package should have a <em>priority</em> value, which is
798 included in the package's <em>control record</em>
799 (see <ref id="f-Priority">).
800 This information is used by the Debian package management tools to
801 separate high-priority packages from less-important packages.
802 </p>
805 The following <em>priority levels</em> are recognized by the
806 Debian package management tools.
807 <taglist>
808 <tag><tt>required</tt></tag>
809 <item>
810 Packages which are necessary for the proper
811 functioning of the system (usually, this means that
812 dpkg functionality depends on these packages).
813 Removing a <tt>required</tt> package may cause your
814 system to become totally broken and you may not even
815 be able to use <prgn>dpkg</prgn> to put things back,
816 so only do so if you know what you are doing. Systems
817 with only the <tt>required</tt> packages are probably
818 unusable, but they do have enough functionality to
819 allow the sysadmin to boot and install more software.
820 </item>
821 <tag><tt>important</tt></tag>
822 <item>
823 Important programs, including those which one would
824 expect to find on any Unix-like system. If the
825 expectation is that an experienced Unix person who
826 found it missing would say "What on earth is going on,
827 where is <prgn>foo</prgn>?", it must be an
828 <tt>important</tt> package.<footnote>
829 This is an important criterion because we are
830 trying to produce, amongst other things, a free
831 Unix.
832 </footnote>
833 Other packages without which the system will not run
834 well or be usable must also have priority
835 <tt>important</tt>. This does
836 <em>not</em> include Emacs, the X Window System, TeX
837 or any other large applications. The
838 <tt>important</tt> packages are just a bare minimum of
839 commonly-expected and necessary tools.
840 </item>
841 <tag><tt>standard</tt></tag>
842 <item>
843 These packages provide a reasonably small but not too
844 limited character-mode system. This is what will be
845 installed by default if the user doesn't select anything
846 else. It doesn't include many large applications.
847 </item>
848 <tag><tt>optional</tt></tag>
849 <item>
850 (In a sense everything that isn't required is
851 optional, but that's not what is meant here.) This is
852 all the software that you might reasonably want to
853 install if you didn't know what it was and don't have
854 specialized requirements. This is a much larger system
855 and includes the X Window System, a full TeX
856 distribution, and many applications. Note that
857 optional packages should not conflict with each other.
858 </item>
859 <tag><tt>extra</tt></tag>
860 <item>
861 This contains all packages that conflict with others
862 with required, important, standard or optional
863 priorities, or are only likely to be useful if you
864 already know what they are or have specialized
865 requirements (such as packages containing only detached
866 debugging symbols).
867 </item>
868 </taglist>
869 </p>
872 Packages must not depend on packages with lower priority
873 values (excluding build-time dependencies). In order to
874 ensure this, the priorities of one or more packages may need
875 to be adjusted.
876 </p>
877 </sect>
879 </chapt>
882 <chapt id="binary">
883 <heading>Binary packages</heading>
886 The Debian distribution is based on the Debian
887 package management system, called <prgn>dpkg</prgn>. Thus,
888 all packages in the Debian distribution must be provided
889 in the <tt>.deb</tt> file format.
890 </p>
893 A <tt>.deb</tt> package contains two sets of files: a set of files
894 to install on the system when the package is installed, and a set
895 of files that provide additional metadata about the package or
896 which are executed when the package is installed or removed. This
897 second set of files is called <em>control information files</em>.
898 Among those files are the package maintainer scripts
899 and <file>control</file>, the <qref id="binarycontrolfiles">binary
900 package control file</qref> that contains the control fields for
901 the package. Other control information files include
902 the <qref id="sharedlibs-symbols"><file>symbols</file> file</qref>
903 or <qref id="sharedlibs-shlibdeps"><file>shlibs</file> file</qref>
904 used to store shared library dependency information and
905 the <file>conffiles</file> file that lists the package's
906 configuration files (described in <ref id="config-files">).
907 </p>
910 There is unfortunately a collision of terminology here between
911 control information files and files in the Debian control file
912 format. Throughout this document, a <em>control file</em> refers
913 to a file in the Debian control file format. These files are
914 documented in <ref id="controlfields">. Only files referred to
915 specifically as <em>control information files</em> are the files
916 included in the control information file member of
917 the <file>.deb</file> file format used by binary packages. Most
918 control information files are not in the Debian control file
919 format.
920 </p>
922 <sect>
923 <heading>The package name</heading>
926 Every package must have a name that's unique within the Debian
927 archive.
928 </p>
931 The package name is included in the control field
932 <tt>Package</tt>, the format of which is described
933 in <ref id="f-Package">.
934 The package name is also included as a part of the file name
935 of the <tt>.deb</tt> file.
936 </p>
937 </sect>
939 <sect id="versions">
940 <heading>The version of a package</heading>
943 Every package has a version number recorded in its
944 <tt>Version</tt> control file field, described in
945 <ref id="f-Version">.
946 </p>
949 The package management system imposes an ordering on version
950 numbers, so that it can tell whether packages are being up- or
951 downgraded and so that package system front end applications
952 can tell whether a package it finds available is newer than
953 the one installed on the system. The version number format
954 has the most significant parts (as far as comparison is
955 concerned) at the beginning.
956 </p>
959 If an upstream package has problematic version numbers they
960 should be converted to a sane form for use in the
961 <tt>Version</tt> field.
962 </p>
964 <sect1>
965 <heading>Version numbers based on dates</heading>
968 In general, Debian packages should use the same version
969 numbers as the upstream sources. However, upstream version
970 numbers based on some date formats (sometimes used for
971 development or "snapshot" releases) will not be ordered
972 correctly by the package management software. For
973 example, <prgn>dpkg</prgn> will consider "96May01" to be
974 greater than "96Dec24".
975 </p>
978 To prevent having to use epochs for every new upstream
979 version, the date-based portion of any upstream version number
980 should be given in a way that sorts correctly: four-digit year
981 first, followed by a two-digit numeric month, followed by a
982 two-digit numeric date, possibly with punctuation between the
983 components.
984 </p>
987 Native Debian packages (i.e., packages which have been written
988 especially for Debian) whose version numbers include dates
989 should also follow these rules. If punctuation is desired
990 between the date components, remember that hyphen (<tt>-</tt>)
991 cannot be used in native package versions. Period
992 (<tt>.</tt>) is normally a good choice.
993 </p>
994 </sect1>
996 </sect>
998 <sect id="maintainer">
999 <heading>The maintainer of a package</heading>
1002 Every package must have a maintainer, except for orphaned
1003 packages as described below. The maintainer may be one person
1004 or a group of people reachable from a common email address, such
1005 as a mailing list. The maintainer is responsible for
1006 maintaining the Debian packaging files, evaluating and
1007 responding appropriately to reported bugs, uploading new
1008 versions of the package (either directly or through a sponsor),
1009 ensuring that the package is placed in the appropriate archive
1010 area and included in Debian releases as appropriate for the
1011 stability and utility of the package, and requesting removal of
1012 the package from the Debian distribution if it is no longer
1013 useful or maintainable.
1014 </p>
1017 The maintainer must be specified in the <tt>Maintainer</tt>
1018 control field with their correct name and a working email
1019 address. The email address given in the <tt>Maintainer</tt>
1020 control field must accept mail from those role accounts in
1021 Debian used to send automated mails regarding the package. This
1022 includes non-spam mail from the bug-tracking system, all mail
1023 from the Debian archive maintenance software, and other role
1024 accounts or automated processes that are commonly agreed on by
1025 the project.<footnote>
1026 A sample implementation of such a whitelist written for the
1027 Mailman mailing list management software is used for mailing
1028 lists hosted by alioth.debian.org.
1029 </footnote>
1030 If one person or team maintains several packages, they should
1031 use the same form of their name and email address in
1032 the <tt>Maintainer</tt> fields of those packages.
1033 </p>
1036 The format of the <tt>Maintainer</tt> control field is
1037 described in <ref id="f-Maintainer">.
1038 </p>
1041 If the maintainer of the package is a team of people with a
1042 shared email address, the <tt>Uploaders</tt> control field must
1043 be present and must contain at least one human with their
1044 personal email address. See <ref id="f-Uploaders"> for the
1045 syntax of that field.
1046 </p>
1049 An orphaned package is one with no current maintainer. Orphaned
1050 packages should have their <tt>Maintainer</tt> control field set
1051 to <tt>Debian QA Group &lt;packages@qa.debian.org&gt;</tt>.
1052 These packages are considered maintained by the Debian project
1053 as a whole until someone else volunteers to take over
1054 maintenance.<footnote>
1055 The detailed procedure for gracefully orphaning a package can
1056 be found in the Debian Developer's Reference
1057 (see <ref id="related">).
1058 </footnote>
1059 </p>
1060 </sect>
1062 <sect id="descriptions">
1063 <heading>The description of a package</heading>
1066 Every Debian package must have a <tt>Description</tt> control
1067 field which contains a synopsis and extended description of the
1068 package. Technical information about the format of the
1069 <tt>Description</tt> field is in <ref id="f-Description">.
1070 </p>
1073 The description should describe the package (the program) to a
1074 user (system administrator) who has never met it before so that
1075 they have enough information to decide whether they want to
1076 install it. This description should not just be copied verbatim
1077 from the program's documentation.
1078 </p>
1081 Put important information first, both in the synopsis and
1082 extended description. Sometimes only the first part of the
1083 synopsis or of the description will be displayed. You can
1084 assume that there will usually be a way to see the whole
1085 extended description.
1086 </p>
1089 The description should also give information about the
1090 significant dependencies and conflicts between this package
1091 and others, so that the user knows why these dependencies and
1092 conflicts have been declared.
1093 </p>
1096 Instructions for configuring or using the package should
1097 not be included (that is what installation scripts,
1098 manual pages, info files, etc., are for). Copyright
1099 statements and other administrivia should not be included
1100 either (that is what the copyright file is for).
1101 </p>
1103 <sect1 id="synopsis"><heading>The single line synopsis</heading>
1106 The single line synopsis should be kept brief - certainly
1107 under 80 characters.
1108 </p>
1111 Do not include the package name in the synopsis line. The
1112 display software knows how to display this already, and you
1113 do not need to state it. Remember that in many situations
1114 the user may only see the synopsis line - make it as
1115 informative as you can.
1116 </p>
1118 </sect1>
1120 <sect1 id="extendeddesc"><heading>The extended description</heading>
1123 Do not try to continue the single line synopsis into the
1124 extended description. This will not work correctly when
1125 the full description is displayed, and makes no sense
1126 where only the summary (the single line synopsis) is
1127 available.
1128 </p>
1131 The extended description should describe what the package
1132 does and how it relates to the rest of the system (in terms
1133 of, for example, which subsystem it is which part of).
1134 </p>
1137 The description field needs to make sense to anyone, even
1138 people who have no idea about any of the things the
1139 package deals with.<footnote>
1140 The blurb that comes with a program in its
1141 announcements and/or <prgn>README</prgn> files is
1142 rarely suitable for use in a description. It is
1143 usually aimed at people who are already in the
1144 community where the package is used.
1145 </footnote>
1146 </p>
1148 </sect1>
1150 </sect>
1152 <sect id="dependencies">
1153 <heading>Dependencies</heading>
1156 Every package must specify the dependency information
1157 about other packages that are required for the first to
1158 work correctly.
1159 </p>
1162 For example, a dependency entry must be provided for any
1163 shared libraries required by a dynamically-linked executable
1164 binary in a package.
1165 </p>
1168 Packages are not required to declare any dependencies they
1169 have on other packages which are marked <tt>Essential</tt>
1170 (see below), and should not do so unless they depend on a
1171 particular version of that package.<footnote>
1173 Essential is needed in part to avoid unresolvable dependency
1174 loops on upgrade. If packages add unnecessary dependencies
1175 on packages in this set, the chances that there
1176 <strong>will</strong> be an unresolvable dependency loop
1177 caused by forcing these Essential packages to be configured
1178 first before they need to be is greatly increased. It also
1179 increases the chances that frontends will be unable to
1180 <strong>calculate</strong> an upgrade path, even if one
1181 exists.
1182 </p>
1184 Also, functionality is rarely ever removed from the
1185 Essential set, but <em>packages</em> have been removed from
1186 the Essential set when the functionality moved to a
1187 different package. So depending on these packages <em>just
1188 in case</em> they stop being essential does way more harm
1189 than good.
1190 </p>
1191 </footnote>
1192 </p>
1195 Sometimes, unpacking one package requires that another package
1196 be first unpacked <em>and</em> configured. In this case, the
1197 depending package must specify this dependency in
1198 the <tt>Pre-Depends</tt> control field.
1199 </p>
1202 You should not specify a <tt>Pre-Depends</tt> entry for a
1203 package before this has been discussed on the
1204 <tt>debian-devel</tt> mailing list and a consensus about
1205 doing that has been reached.
1206 </p>
1209 The format of the package interrelationship control fields is
1210 described in <ref id="relationships">.
1211 </p>
1212 </sect>
1214 <sect id="virtual_pkg">
1215 <heading>Virtual packages</heading>
1218 Sometimes, there are several packages which offer
1219 more-or-less the same functionality. In this case, it's
1220 useful to define a <em>virtual package</em> whose name
1221 describes that common functionality. (The virtual
1222 packages only exist logically, not physically; that's why
1223 they are called <em>virtual</em>.) The packages with this
1224 particular function will then <em>provide</em> the virtual
1225 package. Thus, any other package requiring that function
1226 can simply depend on the virtual package without having to
1227 specify all possible packages individually.
1228 </p>
1231 All packages should use virtual package names where
1232 appropriate, and arrange to create new ones if necessary.
1233 They should not use virtual package names (except privately,
1234 amongst a cooperating group of packages) unless they have
1235 been agreed upon and appear in the list of virtual package
1236 names. (See also <ref id="virtual">)
1237 </p>
1240 The latest version of the authoritative list of virtual
1241 package names can be found in the <tt>debian-policy</tt> package.
1242 It is also available from the Debian web mirrors at
1243 <tt><url name="/doc/packaging-manuals/virtual-package-names-list.txt"
1244 id="http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt"></tt>.
1245 </p>
1248 The procedure for updating the list is described in the preface
1249 to the list.
1250 </p>
1252 </sect>
1254 <sect>
1255 <heading>Base system</heading>
1258 The <tt>base system</tt> is a minimum subset of the Debian
1259 system that is installed before everything else
1260 on a new system. Only very few packages are allowed to form
1261 part of the base system, in order to keep the required disk
1262 usage very small.
1263 </p>
1266 The base system consists of all those packages with priority
1267 <tt>required</tt> or <tt>important</tt>. Many of them will
1268 be tagged <tt>essential</tt> (see below).
1269 </p>
1270 </sect>
1272 <sect>
1273 <heading>Essential packages</heading>
1276 Essential is defined as the minimal set of functionality that
1277 must be available and usable on the system at all times, even
1278 when packages are in the "Unpacked" state.
1279 Packages are tagged <tt>essential</tt> for a system using the
1280 <tt>Essential</tt> control field. The format of the
1281 <tt>Essential</tt> control field is described in <ref
1282 id="f-Essential">.
1283 </p>
1286 Since these packages cannot be easily removed (one has to
1287 specify an extra <em>force option</em> to
1288 <prgn>dpkg</prgn> to do so), this flag must not be used
1289 unless absolutely necessary. A shared library package
1290 must not be tagged <tt>essential</tt>; dependencies will
1291 prevent its premature removal, and we need to be able to
1292 remove it when it has been superseded.
1293 </p>
1296 Since dpkg will not prevent upgrading of other packages
1297 while an <tt>essential</tt> package is in an unconfigured
1298 state, all <tt>essential</tt> packages must supply all of
1299 their core functionality even when unconfigured. If the
1300 package cannot satisfy this requirement it must not be
1301 tagged as essential, and any packages depending on this
1302 package must instead have explicit dependency fields as
1303 appropriate.
1304 </p>
1307 Maintainers should take great care in adding any programs,
1308 interfaces, or functionality to <tt>essential</tt> packages.
1309 Packages may assume that functionality provided by
1310 <tt>essential</tt> packages is always available without
1311 declaring explicit dependencies, which means that removing
1312 functionality from the Essential set is very difficult and is
1313 almost never done. Any capability added to an
1314 <tt>essential</tt> package therefore creates an obligation to
1315 support that capability as part of the Essential set in
1316 perpetuity.
1317 </p>
1320 You must not tag any packages <tt>essential</tt> before
1321 this has been discussed on the <tt>debian-devel</tt>
1322 mailing list and a consensus about doing that has been
1323 reached.
1324 </p>
1325 </sect>
1327 <sect id="maintscripts">
1328 <heading>Maintainer Scripts</heading>
1331 The package installation scripts should avoid producing
1332 output which is unnecessary for the user to see and
1333 should rely on <prgn>dpkg</prgn> to stave off boredom on
1334 the part of a user installing many packages. This means,
1335 amongst other things, not passing the <tt>--verbose</tt>
1336 option to <prgn>update-alternatives</prgn>.
1337 </p>
1340 Errors which occur during the execution of an installation
1341 script must be checked and the installation must not
1342 continue after an error.
1343 </p>
1346 Note that in general <ref id="scripts"> applies to package
1347 maintainer scripts, too.
1348 </p>
1351 You should not use <prgn>dpkg-divert</prgn> on a file belonging
1352 to another package without consulting the maintainer of that
1353 package first. When adding or removing diversions, package
1354 maintainer scripts must provide the <tt>--package</tt> flag
1355 to <prgn>dpkg-divert</prgn> and must not use <tt>--local</tt>.
1356 </p>
1359 All packages which supply an instance of a common command
1360 name (or, in general, filename) should generally use
1361 <prgn>update-alternatives</prgn>, so that they may be
1362 installed together. If <prgn>update-alternatives</prgn>
1363 is not used, then each package must use
1364 <tt>Conflicts</tt> to ensure that other packages are
1365 removed. (In this case, it may be appropriate to
1366 specify a conflict against earlier versions of something
1367 that previously did not use
1368 <prgn>update-alternatives</prgn>; this is an exception to
1369 the usual rule that versioned conflicts should be
1370 avoided.)
1371 </p>
1373 <sect1 id="maintscriptprompt">
1374 <heading>Prompting in maintainer scripts</heading>
1376 Package maintainer scripts may prompt the user if
1377 necessary. Prompting must be done by communicating
1378 through a program, such as <prgn>debconf</prgn>, which
1379 conforms to the Debian Configuration Management
1380 Specification, version 2 or higher.
1381 </p>
1384 Packages which are essential, or which are dependencies of
1385 essential packages, may fall back on another prompting method
1386 if no such interface is available when they are executed.
1387 </p>
1390 The Debian Configuration Management Specification is included
1391 in the <file>debconf_specification</file> files in the
1392 <package>debian-policy</package> package.
1393 It is also available from the Debian web mirrors at
1394 <tt><url name="/doc/packaging-manuals/debconf_specification.html"
1395 id="http://www.debian.org/doc/packaging-manuals/debconf_specification.html"></tt>.
1396 </p>
1399 Packages which use the Debian Configuration Management
1400 Specification may contain the additional control information
1401 files <file>config</file>
1402 and <file>templates</file>. <file>config</file> is an
1403 additional maintainer script used for package configuration,
1404 and <file>templates</file> contains templates used for user
1405 prompting. The <prgn>config</prgn> script might be run before
1406 the <prgn>preinst</prgn> script and before the package is
1407 unpacked or any of its dependencies or pre-dependencies are
1408 satisfied. Therefore it must work using only the tools
1409 present in <em>essential</em> packages.<footnote>
1410 <package>Debconf</package> or another tool that
1411 implements the Debian Configuration Management
1412 Specification will also be installed, and any
1413 versioned dependencies on it will be satisfied
1414 before preconfiguration begins.
1415 </footnote>
1416 </p>
1419 Packages which use the Debian Configuration Management
1420 Specification must allow for translation of their user-visible
1421 messages by using a gettext-based system such as the one
1422 provided by the <package>po-debconf</package> package.
1423 </p>
1426 Packages should try to minimize the amount of prompting
1427 they need to do, and they should ensure that the user
1428 will only ever be asked each question once. This means
1429 that packages should try to use appropriate shared
1430 configuration files (such as <file>/etc/papersize</file> and
1431 <file>/etc/news/server</file>), and shared
1432 <package>debconf</package> variables rather than each
1433 prompting for their own list of required pieces of
1434 information.
1435 </p>
1438 It also means that an upgrade should not ask the same
1439 questions again, unless the user has used
1440 <tt>dpkg --purge</tt> to remove the package's configuration.
1441 The answers to configuration questions should be stored in an
1442 appropriate place in <file>/etc</file> so that the user can
1443 modify them, and how this has been done should be
1444 documented.
1445 </p>
1448 If a package has a vitally important piece of
1449 information to pass to the user (such as "don't run me
1450 as I am, you must edit the following configuration files
1451 first or you risk your system emitting badly-formatted
1452 messages"), it should display this in the
1453 <prgn>config</prgn> or <prgn>postinst</prgn> script and
1454 prompt the user to hit return to acknowledge the
1455 message. Copyright messages do not count as vitally
1456 important (they belong in
1457 <file>/usr/share/doc/<var>package</var>/copyright</file>);
1458 neither do instructions on how to use a program (these
1459 should be in on-line documentation, where all the users
1460 can see them).
1461 </p>
1464 Any necessary prompting should almost always be confined
1465 to the <prgn>config</prgn> or <prgn>postinst</prgn>
1466 script. If it is done in the <prgn>postinst</prgn>, it
1467 should be protected with a conditional so that
1468 unnecessary prompting doesn't happen if a package's
1469 installation fails and the <prgn>postinst</prgn> is
1470 called with <tt>abort-upgrade</tt>,
1471 <tt>abort-remove</tt> or <tt>abort-deconfigure</tt>.
1472 </p>
1473 </sect1>
1475 </sect>
1477 </chapt>
1480 <chapt id="source">
1481 <heading>Source packages</heading>
1483 <sect id="standardsversion">
1484 <heading>Standards conformance</heading>
1487 Source packages should specify the most recent version number
1488 of this policy document with which your package complied
1489 when it was last updated.
1490 </p>
1493 This information may be used to file bug reports
1494 automatically if your package becomes too much out of date.
1495 </p>
1498 The version is specified in the <tt>Standards-Version</tt>
1499 control field.
1500 The format of the <tt>Standards-Version</tt> field is
1501 described in <ref id="f-Standards-Version">.
1502 </p>
1505 You should regularly, and especially if your package has
1506 become out of date, check for the newest Policy Manual
1507 available and update your package, if necessary. When your
1508 package complies with the new standards you should update the
1509 <tt>Standards-Version</tt> source package field and
1510 release it.<footnote>
1511 See the file <file>upgrading-checklist</file> for
1512 information about policy which has changed between
1513 different versions of this document.
1514 </footnote>
1515 </p>
1517 </sect>
1519 <sect id="pkg-relations">
1520 <heading>Package relationships</heading>
1523 Source packages should specify which binary packages they
1524 require to be installed or not to be installed in order to
1525 build correctly. For example, if building a package
1526 requires a certain compiler, then the compiler should be
1527 specified as a build-time dependency.
1528 </p>
1531 It is not necessary to explicitly specify build-time
1532 relationships on a minimal set of packages that are always
1533 needed to compile, link and put in a Debian package a
1534 standard "Hello World!" program written in C or C++. The
1535 required packages are called <em>build-essential</em>, and
1536 an informational list can be found in
1537 <file>/usr/share/doc/build-essential/list</file> (which is
1538 contained in the <tt>build-essential</tt>
1539 package).<footnote>
1540 Rationale:
1541 <list compact="compact">
1542 <item>
1543 This allows maintaining the list separately
1544 from the policy documents (the list does not
1545 need the kind of control that the policy
1546 documents do).
1547 </item>
1548 <item>
1549 Having a separate package allows one to install
1550 the build-essential packages on a machine, as
1551 well as allowing other packages such as tasks to
1552 require installation of the build-essential
1553 packages using the depends relation.
1554 </item>
1555 <item>
1556 The separate package allows bug reports against
1557 the list to be categorized separately from
1558 the policy management process in the BTS.
1559 </item>
1560 </list>
1561 </footnote>
1562 </p>
1565 When specifying the set of build-time dependencies, one
1566 should list only those packages explicitly required by the
1567 build. It is not necessary to list packages which are
1568 required merely because some other package in the list of
1569 build-time dependencies depends on them.<footnote>
1570 The reason for this is that dependencies change, and
1571 you should list all those packages, and <em>only</em>
1572 those packages that <em>you</em> need directly. What
1573 others need is their business. For example, if you
1574 only link against <file>libimlib</file>, you will need to
1575 build-depend on <package>libimlib2-dev</package> but
1576 not against any <tt>libjpeg*</tt> packages, even
1577 though <tt>libimlib2-dev</tt> currently depends on
1578 them: installation of <package>libimlib2-dev</package>
1579 will automatically ensure that all of its run-time
1580 dependencies are satisfied.
1581 </footnote>
1582 </p>
1585 If build-time dependencies are specified, it must be
1586 possible to build the package and produce working binaries
1587 on a system with only essential and build-essential
1588 packages installed and also those required to satisfy the
1589 build-time relationships (including any implied
1590 relationships). In particular, this means that version
1591 clauses should be used rigorously in build-time
1592 relationships so that one cannot produce bad or
1593 inconsistently configured packages when the relationships
1594 are properly satisfied.
1595 </p>
1598 <ref id="relationships"> explains the technical details.
1599 </p>
1600 </sect>
1602 <sect>
1603 <heading>Changes to the upstream sources</heading>
1606 If changes to the source code are made that are not
1607 specific to the needs of the Debian system, they should be
1608 sent to the upstream authors in whatever form they prefer
1609 so as to be included in the upstream version of the
1610 package.
1611 </p>
1614 If you need to configure the package differently for
1615 Debian or for Linux, and the upstream source doesn't
1616 provide a way to do so, you should add such configuration
1617 facilities (for example, a new <prgn>autoconf</prgn> test
1618 or <tt>#define</tt>) and send the patch to the upstream
1619 authors, with the default set to the way they originally
1620 had it. You can then easily override the default in your
1621 <file>debian/rules</file> or wherever is appropriate.
1622 </p>
1625 You should make sure that the <prgn>configure</prgn> utility
1626 detects the correct architecture specification string
1627 (refer to <ref id="arch-spec"> for details).
1628 </p>
1630 If your package includes the scripts <prgn>config.sub</prgn> and
1631 <prgn>config.guess</prgn>, you should arrange for the versions
1632 provided by the package <package>autotools-dev</package> be used
1633 instead (see <package>autotools-dev</package> documentation for
1634 details how to achieve that). This ensures that these files can
1635 be updated distribution-wide at build time when introducing
1636 new architectures.
1637 </p>
1640 If you need to edit a <prgn>Makefile</prgn> where GNU-style
1641 <prgn>configure</prgn> scripts are used, you should edit the
1642 <file>.in</file> files rather than editing the
1643 <prgn>Makefile</prgn> directly. This allows the user to
1644 reconfigure the package if necessary. You should
1645 <em>not</em> configure the package and edit the generated
1646 <prgn>Makefile</prgn>! This makes it impossible for someone
1647 else to later reconfigure the package without losing the
1648 changes you made.
1649 </p>
1651 </sect>
1653 <sect id="dpkgchangelog">
1654 <heading>Debian changelog: <file>debian/changelog</file></heading>
1657 Changes in the Debian version of the package should be
1658 briefly explained in the Debian changelog file
1659 <file>debian/changelog</file>.<footnote>
1661 Mistakes in changelogs are usually best rectified by
1662 making a new changelog entry rather than "rewriting
1663 history" by editing old changelog entries.
1664 </p>
1665 </footnote>
1666 This includes modifications
1667 made in the Debian package compared to the upstream one
1668 as well as other changes and updates to the package.
1669 <footnote>
1670 Although there is nothing stopping an author who is also
1671 the Debian maintainer from using this changelog for all
1672 their changes, it will have to be renamed if the Debian
1673 and upstream maintainers become different people. In such
1674 a case, however, it might be better to maintain the package
1675 as a non-native package.
1676 </footnote>
1677 </p>
1680 The format of the <file>debian/changelog</file> allows the
1681 package building tools to discover which version of the package
1682 is being built and find out other release-specific information.
1683 </p>
1686 That format is a series of entries like this:
1688 <example compact="compact">
1689 <var>package</var> (<var>version</var>) <var>distribution(s)</var>; urgency=<var>urgency</var>
1690 <var>
1691 [optional blank line(s), stripped]
1692 </var>
1693 * <var>change details</var>
1694 <var>more change details</var>
1695 <var>
1696 [blank line(s), included in output of dpkg-parsechangelog]
1697 </var>
1698 * <var>even more change details</var>
1699 <var>
1700 [optional blank line(s), stripped]
1701 </var>
1702 -- <var>maintainer name</var> &lt;<var>email address</var>&gt;<var>[two spaces]</var> <var>date</var>
1703 </example>
1704 </p>
1707 <var>package</var> and <var>version</var> are the source
1708 package name and version number.
1709 </p>
1712 <var>distribution(s)</var> lists the distributions where
1713 this version should be installed when it is uploaded - it
1714 is copied to the <tt>Distribution</tt> field in the
1715 <file>.changes</file> file. See <ref id="f-Distribution">.
1716 </p>
1719 <var>urgency</var> is the value for the <tt>Urgency</tt>
1720 field in the <file>.changes</file> file for the upload
1721 (see <ref id="f-Urgency">). It is not possible to specify
1722 an urgency containing commas; commas are used to separate
1723 <tt><var>keyword</var>=<var>value</var></tt> settings in the
1724 <prgn>dpkg</prgn> changelog format (though there is
1725 currently only one useful <var>keyword</var>,
1726 <tt>urgency</tt>).
1727 </p>
1730 The change details may in fact be any series of lines
1731 starting with at least two spaces, but conventionally each
1732 change starts with an asterisk and a separating space and
1733 continuation lines are indented so as to bring them in
1734 line with the start of the text above. Blank lines may be
1735 used here to separate groups of changes, if desired.
1736 </p>
1739 If this upload resolves bugs recorded in the Bug Tracking
1740 System (BTS), they may be automatically closed on the
1741 inclusion of this package into the Debian archive by
1742 including the string: <tt>closes: Bug#<var>nnnnn</var></tt>
1743 in the change details.<footnote>
1744 To be precise, the string should match the following
1745 Perl regular expression:
1746 <example>
1747 /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
1748 </example>
1749 Then all of the bug numbers listed will be closed by the
1750 archive maintenance software (<prgn>dak</prgn>) using the
1751 <var>version</var> of the changelog entry.
1752 </footnote>
1753 This information is conveyed via the <tt>Closes</tt> field
1754 in the <tt>.changes</tt> file (see <ref id="f-Closes">).
1755 </p>
1758 The maintainer name and email address used in the changelog
1759 should be the details of the person who prepared this release of
1760 the package. They are <em>not</em> necessarily those of the
1761 uploader or usual package maintainer.<footnote>
1762 In the case of a sponsored upload, the uploader signs the
1763 files, but the changelog maintainer name and address are those
1764 of the person who prepared this release. If the preparer of
1765 the release is not one of the usual maintainers of the package
1766 (as listed in
1767 the <qref id="f-Maintainer"><tt>Maintainer</tt></qref>
1768 or <qref id="f-Uploaders"><tt>Uploaders</tt></qref> control
1769 fields of the package), the first line of the changelog is
1770 conventionally used to explain why a non-maintainer is
1771 uploading the package. The Debian Developer's Reference
1772 (see <ref id="related">) documents the conventions
1773 used.</footnote>
1774 The information here will be copied to the <tt>Changed-By</tt>
1775 field in the <tt>.changes</tt> file
1776 (see <ref id="f-Changed-By">), and then later used to send an
1777 acknowledgement when the upload has been installed.
1778 </p>
1781 The <var>date</var> has the following format<footnote>
1782 This is the same as the format generated by <tt>date
1783 -R</tt>.
1784 </footnote> (compatible and with the same semantics of
1785 RFC 2822 and RFC 5322):
1786 <example>day-of-week, dd month yyyy hh:mm:ss +zzzz</example>
1787 where:
1788 <list compact="compact">
1789 <item>
1790 day-of week is one of: Mon, Tue, Wed, Thu, Fri, Sat, Sun
1791 </item>
1792 <item>
1793 dd is a one- or two-digit day of the month (01-31)
1794 </item>
1795 <item>
1796 month is one of: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug,
1797 Sep, Oct, Nov, Dec
1798 </item>
1799 <item>yyyy is the four-digit year (e.g. 2010)</item>
1800 <item>hh is the two-digit hour (00-23)</item>
1801 <item>mm is the two-digit minutes (00-59)</item>
1802 <item>ss is the two-digit seconds (00-60)</item>
1803 <item>
1804 +zzzz or -zzzz is the time zone offset from Coordinated
1805 Universal Time (UTC). "+" indicates that the time is ahead
1806 of (i.e., east of) UTC and "-" indicates that the time is
1807 behind (i.e., west of) UTC. The first two digits indicate
1808 the hour difference from UTC and the last two digits
1809 indicate the number of additional minutes difference from
1810 UTC. The last two digits must be in the range 00-59.
1811 </item>
1812 </list>
1813 </p>
1816 The first "title" line with the package name must start
1817 at the left hand margin. The "trailer" line with the
1818 maintainer and date details must be preceded by exactly
1819 one space. The maintainer details and the date must be
1820 separated by exactly two spaces.
1821 </p>
1824 The entire changelog must be encoded in UTF-8.
1825 </p>
1828 For more information on placement of the changelog files
1829 within binary packages, please see <ref id="changelogs">.
1830 </p>
1831 </sect>
1833 <sect id="dpkgcopyright">
1834 <heading>Copyright: <file>debian/copyright</file></heading>
1836 Every package must be accompanied by a verbatim copy of its
1837 copyright information and distribution license in the file
1838 <file>/usr/share/doc/<var>package</var>/copyright</file>
1839 (see <ref id="copyrightfile"> for further details). Also see
1840 <ref id="pkgcopyright"> for further considerations related
1841 to copyrights for packages.
1842 </p>
1843 </sect>
1844 <sect>
1845 <heading>Error trapping in makefiles</heading>
1848 When <prgn>make</prgn> invokes a command in a makefile
1849 (including your package's upstream makefiles and
1850 <file>debian/rules</file>), it does so using <prgn>sh</prgn>. This
1851 means that <prgn>sh</prgn>'s usual bad error handling
1852 properties apply: if you include a miniature script as one
1853 of the commands in your makefile you'll find that if you
1854 don't do anything about it then errors are not detected
1855 and <prgn>make</prgn> will blithely continue after
1856 problems.
1857 </p>
1860 Every time you put more than one shell command (this
1861 includes using a loop) in a makefile command you
1862 must make sure that errors are trapped. For
1863 simple compound commands, such as changing directory and
1864 then running a program, using <tt>&amp;&amp;</tt> rather
1865 than semicolon as a command separator is sufficient. For
1866 more complex commands including most loops and
1867 conditionals you should include a separate <tt>set -e</tt>
1868 command at the start of every makefile command that's
1869 actually one of these miniature shell scripts.
1870 </p>
1871 </sect>
1873 <sect id="timestamps">
1874 <heading>Time Stamps</heading>
1876 Maintainers should preserve the modification times of the
1877 upstream source files in a package, as far as is reasonably
1878 possible.<footnote>
1879 The rationale is that there is some information conveyed
1880 by knowing the age of the file, for example, you could
1881 recognize that some documentation is very old by looking
1882 at the modification time, so it would be nice if the
1883 modification time of the upstream source would be
1884 preserved.
1885 </footnote>
1886 </p>
1887 </sect>
1889 <sect id="restrictions">
1890 <heading>Restrictions on objects in source packages</heading>
1893 The source package may not contain any hard links<footnote>
1895 This is not currently detected when building source
1896 packages, but only when extracting
1897 them.
1898 </p>
1900 Hard links may be permitted at some point in the
1901 future, but would require a fair amount of
1902 work.
1903 </p>
1904 </footnote>, device special files, sockets or setuid or
1905 setgid files.<footnote>
1906 Setgid directories are allowed.
1907 </footnote>
1908 </p>
1909 </sect>
1911 <sect id="debianrules">
1912 <heading>Main building script: <file>debian/rules</file></heading>
1915 This file must be an executable makefile, and contains the
1916 package-specific recipes for compiling the package and
1917 building binary package(s) from the source.
1918 </p>
1921 It must start with the line <tt>#!/usr/bin/make -f</tt>,
1922 so that it can be invoked by saying its name rather than
1923 invoking <prgn>make</prgn> explicitly. That is, invoking
1924 either of <tt>make -f debian/rules <var>args...</var></tt>
1925 or <tt>./debian/rules <var>args...</var></tt> must result in
1926 identical behavior.
1927 </p>
1930 The following targets are required and must be implemented
1931 by <file>debian/rules</file>: <tt>clean</tt>, <tt>binary</tt>,
1932 <tt>binary-arch</tt>, <tt>binary-indep</tt>, <tt>build</tt>,
1933 <tt>build-arch</tt> and <tt>build-indep</tt>.
1934 These are the targets called by <prgn>dpkg-buildpackage</prgn>.
1935 </p>
1938 Since an interactive <file>debian/rules</file> script makes it
1939 impossible to auto-compile that package and also makes it hard
1940 for other people to reproduce the same binary package, all
1941 required targets must be non-interactive. It also follows that
1942 any target that these targets depend on must also be
1943 non-interactive.
1944 </p>
1946 For packages in the main archive, no required targets
1947 may attempt network access.
1948 </p>
1951 The targets are as follows:
1952 <taglist>
1953 <tag><tt>build</tt> (required)</tag>
1954 <item>
1956 The <tt>build</tt> target should perform all the
1957 configuration and compilation of the package.
1958 If a package has an interactive pre-build
1959 configuration routine, the Debian source package
1960 must either be built after this has taken place (so
1961 that the binary package can be built without rerunning
1962 the configuration) or the configuration routine
1963 modified to become non-interactive. (The latter is
1964 preferable if there are architecture-specific features
1965 detected by the configuration routine.)
1966 </p>
1969 For some packages, notably ones where the same
1970 source tree is compiled in different ways to produce
1971 two binary packages, the <tt>build</tt> target
1972 does not make much sense. For these packages it is
1973 good enough to provide two (or more) targets
1974 (<tt>build-a</tt> and <tt>build-b</tt> or whatever)
1975 for each of the ways of building the package, and a
1976 <tt>build</tt> target that does nothing. The
1977 <tt>binary</tt> target will have to build the
1978 package in each of the possible ways and make the
1979 binary package out of each.
1980 </p>
1983 The <tt>build</tt> target must not do anything
1984 that might require root privilege.
1985 </p>
1988 The <tt>build</tt> target may need to run the
1989 <tt>clean</tt> target first - see below.
1990 </p>
1993 When a package has a configuration and build routine
1994 which takes a long time, or when the makefiles are
1995 poorly designed, or when <tt>build</tt> needs to
1996 run <tt>clean</tt> first, it is a good idea to
1997 <tt>touch build</tt> when the build process is
1998 complete. This will ensure that if <tt>debian/rules
1999 build</tt> is run again it will not rebuild the whole
2000 program.<footnote>
2001 Another common way to do this is for <tt>build</tt>
2002 to depend on <prgn>build-stamp</prgn> and to do
2003 nothing else, and for the <prgn>build-stamp</prgn>
2004 target to do the building and to <tt>touch
2005 build-stamp</tt> on completion. This is
2006 especially useful if the build routine creates a
2007 file or directory called <tt>build</tt>; in such a
2008 case, <tt>build</tt> will need to be listed as
2009 a phony target (i.e., as a dependency of the
2010 <tt>.PHONY</tt> target). See the documentation of
2011 <prgn>make</prgn> for more information on phony
2012 targets.
2013 </footnote>
2014 </p>
2015 </item>
2017 <tag><tt>build-arch</tt> (required),
2018 <tt>build-indep</tt> (required)
2019 </tag>
2020 <item>
2022 The <tt>build-arch</tt> target must
2023 perform all the configuration and compilation required for
2024 producing all architecture-dependent binary packages
2025 (those packages for which the body of the
2026 <tt>Architecture</tt> field in <tt>debian/control</tt> is
2027 not <tt>all</tt>). Similarly, the <tt>build-indep</tt>
2028 target must perform all the configuration
2029 and compilation required for producing all
2030 architecture-independent binary packages (those packages
2031 for which the body of the <tt>Architecture</tt> field
2032 in <tt>debian/control</tt> is <tt>all</tt>).
2033 The <tt>build</tt> target
2034 should either depend on those targets or take the same
2035 actions as invoking those targets would perform.<footnote>
2036 This split allows binary-only builds to not install the
2037 dependencies required for the <tt>build-indep</tt>
2038 target and skip any resource-intensive build tasks that
2039 are only required when building architecture-independent
2040 binary packages.
2041 </footnote>
2042 </p>
2045 The <tt>build-arch</tt> and <tt>build-indep</tt> targets
2046 must not do anything that might require root privilege.
2047 </p>
2048 </item>
2050 <tag><tt>binary</tt> (required), <tt>binary-arch</tt>
2051 (required), <tt>binary-indep</tt> (required)
2052 </tag>
2053 <item>
2055 The <tt>binary</tt> target must be all that is
2056 necessary for the user to build the binary package(s)
2057 produced from this source package. It is
2058 split into two parts: <prgn>binary-arch</prgn> builds
2059 the binary packages which are specific to a particular
2060 architecture, and <tt>binary-indep</tt> builds
2061 those which are not.
2062 </p>
2064 <tt>binary</tt> may be (and commonly is) a target with
2065 no commands which simply depends on
2066 <tt>binary-arch</tt> and <tt>binary-indep</tt>.
2067 </p>
2069 Both <tt>binary-*</tt> targets should depend on the
2070 <tt>build</tt> target, or on the appropriate
2071 <tt>build-arch</tt> or <tt>build-indep</tt> target, so
2072 that the package is built if it has not been already. It
2073 should then create the relevant binary package(s),
2074 using <prgn>dpkg-gencontrol</prgn> to make their control
2075 files and <prgn>dpkg-deb</prgn> to build them and place
2076 them in the parent of the top level directory.
2077 </p>
2080 Both the <tt>binary-arch</tt> and
2081 <tt>binary-indep</tt> targets <em>must</em> exist.
2082 If one of them has nothing to do (which will always be
2083 the case if the source generates only a single binary
2084 package, whether architecture-dependent or not), it
2085 must still exist and must always succeed.
2086 </p>
2089 The <tt>binary</tt> targets must be invoked as
2090 root.<footnote>
2091 The <prgn>fakeroot</prgn> package often allows one
2092 to build a package correctly even without being
2093 root.
2094 </footnote>
2095 </p>
2096 </item>
2098 <tag><tt>clean</tt> (required)</tag>
2099 <item>
2101 This must undo any effects that the <tt>build</tt>
2102 and <tt>binary</tt> targets may have had, except
2103 that it should leave alone any output files created in
2104 the parent directory by a run of a <tt>binary</tt>
2105 target.
2106 </p>
2109 If a <tt>build</tt> file is touched at the end of
2110 the <tt>build</tt> target, as suggested above, it
2111 should be removed as the first action that
2112 <tt>clean</tt> performs, so that running
2113 <tt>build</tt> again after an interrupted
2114 <tt>clean</tt> doesn't think that everything is
2115 already done.
2116 </p>
2119 The <tt>clean</tt> target may need to be
2120 invoked as root if <tt>binary</tt> has been
2121 invoked since the last <tt>clean</tt>, or if
2122 <tt>build</tt> has been invoked as root (since
2123 <tt>build</tt> may create directories, for
2124 example).
2125 </p>
2126 </item>
2128 <tag><tt>get-orig-source</tt> (optional)</tag>
2129 <item>
2131 This target fetches the most recent version of the
2132 original source package from a canonical archive site
2133 (via FTP or WWW, for example), does any necessary
2134 rearrangement to turn it into the original source
2135 tar file format described below, and leaves it in the
2136 current directory.
2137 </p>
2140 This target may be invoked in any directory, and
2141 should take care to clean up any temporary files it
2142 may have left.
2143 </p>
2146 This target is optional, but providing it if
2147 possible is a good idea.
2148 </p>
2149 </item>
2151 <tag><tt>patch</tt> (optional)</tag>
2152 <item>
2154 This target performs whatever additional actions are
2155 required to make the source ready for editing (unpacking
2156 additional upstream archives, applying patches, etc.).
2157 It is recommended to be implemented for any package where
2158 <tt>dpkg-source -x</tt> does not result in source ready
2159 for additional modification. See
2160 <ref id="readmesource">.
2161 </p>
2162 </item>
2163 </taglist>
2166 The <tt>build</tt>, <tt>binary</tt> and
2167 <tt>clean</tt> targets must be invoked with the current
2168 directory being the package's top-level directory.
2169 </p>
2173 Additional targets may exist in <file>debian/rules</file>,
2174 either as published or undocumented interfaces or for the
2175 package's internal use.
2176 </p>
2179 The architectures we build on and build for are determined
2180 by <prgn>make</prgn> variables using the
2181 utility <prgn>dpkg-architecture</prgn>.
2182 You can determine the Debian architecture and the GNU style
2183 architecture specification string for the build architecture as
2184 well as for the host architecture. The build architecture is
2185 the architecture on which <file>debian/rules</file> is run and
2186 the package build is performed. The host architecture is the
2187 architecture on which the resulting package will be installed
2188 and run. The target architecture is the architecture of the
2189 packages that the compiler currently being built will generate.
2190 These are normally the same, but may be different in
2191 the case of cross-compilation (building packages for one
2192 architecture on machines of a different architecture), building a
2193 cross-compiler (a compiler package that will generate objects for
2194 one architecture, built on a machine of a different architecture)
2195 or a Canadian cross-compiler (a compiler that will generate
2196 objects for one architecture, built on a machine of a different
2197 architecture, that will run on yet a different architecture).
2198 </p>
2201 Here is a list of supported <prgn>make</prgn> variables:
2202 <list compact="compact">
2203 <item>
2204 <tt>DEB_*_ARCH</tt> (the Debian architecture)
2205 </item>
2206 <item>
2207 <tt>DEB_*_ARCH_CPU</tt> (the Debian CPU name)
2208 </item>
2209 <item>
2210 <tt>DEB_*_ARCH_BITS</tt> (the Debian CPU pointer size in bits)
2211 </item>
2212 <item>
2213 <tt>DEB_*_ARCH_ENDIAN</tt> (the Debian CPU endianness)
2214 </item>
2215 <item>
2216 <tt>DEB_*_ARCH_OS</tt> (the Debian System name)
2217 </item>
2218 <item>
2219 <tt>DEB_*_GNU_TYPE</tt> (the GNU style architecture
2220 specification string)
2221 </item>
2222 <item>
2223 <tt>DEB_*_GNU_CPU</tt> (the CPU part of
2224 <tt>DEB_*_GNU_TYPE</tt>)
2225 </item>
2226 <item>
2227 <tt>DEB_*_GNU_SYSTEM</tt> (the System part of
2228 <tt>DEB_*_GNU_TYPE</tt>)
2229 </list>
2230 where <tt>*</tt> is either <tt>BUILD</tt> for specification of
2231 the build architecture, <tt>HOST</tt> for specification of the
2232 host architecture or <tt>TARGET</tt> for specification of the
2233 target architecture.
2234 </p>
2237 Backward compatibility can be provided in the rules file
2238 by setting the needed variables to suitable default
2239 values; please refer to the documentation of
2240 <prgn>dpkg-architecture</prgn> for details.
2241 </p>
2244 It is important to understand that the <tt>DEB_*_ARCH</tt>
2245 string only determines which Debian architecture we are
2246 building on or for. It should not be used to get the CPU
2247 or system information; the <tt>DEB_*_ARCH_CPU</tt> and
2248 <tt>DEB_*_ARCH_OS</tt> variables should be used for that.
2249 GNU style variables should generally only be used with upstream
2250 build systems.
2251 </p>
2253 <sect1 id="debianrules-options">
2254 <heading><file>debian/rules</file> and
2255 <tt>DEB_BUILD_OPTIONS</tt></heading>
2258 Supporting the standardized environment variable
2259 <tt>DEB_BUILD_OPTIONS</tt> is recommended. This variable can
2260 contain several flags to change how a package is compiled and
2261 built. Each flag must be in the form <var>flag</var> or
2262 <var>flag</var>=<var>options</var>. If multiple flags are
2263 given, they must be separated by whitespace.<footnote>
2264 Some packages support any delimiter, but whitespace is the
2265 easiest to parse inside a makefile and avoids ambiguity with
2266 flag values that contain commas.
2267 </footnote>
2268 <var>flag</var> must start with a lowercase letter
2269 (<tt>a-z</tt>) and consist only of lowercase letters,
2270 numbers (<tt>0-9</tt>), and the characters
2271 <tt>-</tt> and <tt>_</tt> (hyphen and underscore).
2272 <var>options</var> must not contain whitespace. The same
2273 tag should not be given multiple times with conflicting
2274 values. Package maintainers may assume that
2275 <tt>DEB_BUILD_OPTIONS</tt> will not contain conflicting tags.
2276 </p>
2279 The meaning of the following tags has been standardized:
2280 <taglist>
2281 <tag>nocheck</tag>
2282 <item>
2283 This tag says to not run any build-time test suite
2284 provided by the package.
2285 </item>
2286 <tag>nodoc</tag>
2287 <item>
2288 This tag says to skip any build steps that only generate
2289 package documentation. Files required by other sections
2290 of Debian Policy, such as copyright and changelog files,
2291 must still be generated and put in the package, but other
2292 generated documentation such as help2man-generated pages,
2293 Doxygen-generated API documentation, or info pages
2294 generated from Texinfo sources should be skipped if
2295 possible. This option does not change the set of binary
2296 packages generated by the source package, but
2297 documentation-only binary packages may be nearly empty
2298 when built with this option.
2299 </item>
2300 <tag>noopt</tag>
2301 <item>
2302 The presence of this tag means that the package should
2303 be compiled with a minimum of optimization. For C
2304 programs, it is best to add <tt>-O0</tt> to
2305 <tt>CFLAGS</tt> (although this is usually the default).
2306 Some programs might fail to build or run at this level
2307 of optimization; it may be necessary to use
2308 <tt>-O1</tt>, for example.
2309 </item>
2310 <tag>nostrip</tag>
2311 <item>
2312 This tag means that the debugging symbols should not be
2313 stripped from the binary during installation, so that
2314 debugging information may be included in the package.
2315 </item>
2316 <tag>parallel=n</tag>
2317 <item>
2318 This tag means that the package should be built using up
2319 to <tt>n</tt> parallel processes if the package build
2320 system supports this.<footnote>
2321 Packages built with <tt>make</tt> can often implement
2322 this by passing the <tt>-j</tt><var>n</var> option to
2323 <tt>make</tt>.
2324 </footnote>
2325 If the package build system does not support parallel
2326 builds, this string must be ignored. If the package
2327 build system only supports a lower level of concurrency
2328 than <var>n</var>, the package should be built using as
2329 many parallel processes as the package build system
2330 supports. It is up to the package maintainer to decide
2331 whether the package build times are long enough and the
2332 package build system is robust enough to make supporting
2333 parallel builds worthwhile.
2334 </item>
2335 </taglist>
2336 </p>
2339 Unknown flags must be ignored by <file>debian/rules</file>.
2340 </p>
2343 The following makefile snippet is an example of how one may
2344 implement the build options; you will probably have to
2345 massage this example in order to make it work for your
2346 package.
2347 <example compact="compact">
2348 CFLAGS = -Wall -g
2349 INSTALL = install
2350 INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
2351 INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
2352 INSTALL_SCRIPT = $(INSTALL) -p -o root -g root -m 755
2353 INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755
2355 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
2356 CFLAGS += -O0
2357 else
2358 CFLAGS += -O2
2359 endif
2360 ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
2361 INSTALL_PROGRAM += -s
2362 endif
2363 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
2364 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
2365 MAKEFLAGS += -j$(NUMJOBS)
2366 endif
2368 build:
2369 # ...
2370 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
2371 # Code to run the package test suite.
2372 endif
2373 </example>
2374 </p>
2375 </sect1>
2376 </sect>
2378 <sect id="substvars">
2379 <heading>Variable substitutions: <file>debian/substvars</file></heading>
2382 When <prgn>dpkg-gencontrol</prgn>
2383 generates <qref id="binarycontrolfiles">binary package control
2384 files</qref> (<file>DEBIAN/control</file>), it performs variable
2385 substitutions on its output just before writing it. Variable
2386 substitutions have the form <tt>${<var>variable</var>}</tt>.
2387 The optional file <file>debian/substvars</file> contains
2388 variable substitutions to be used; variables can also be set
2389 directly from <file>debian/rules</file> using the <tt>-V</tt>
2390 option to the source packaging commands, and certain predefined
2391 variables are also available.
2392 </p>
2395 The <file>debian/substvars</file> file is usually generated and
2396 modified dynamically by <file>debian/rules</file> targets, in
2397 which case it must be removed by the <tt>clean</tt> target.
2398 </p>
2401 See <manref name="deb-substvars" section="5"> for full
2402 details about source variable substitutions, including the
2403 format of <file>debian/substvars</file>.</p>
2404 </sect>
2406 <sect id="debianwatch">
2407 <heading>Optional upstream source location: <file>debian/watch</file></heading>
2410 This is an optional, recommended configuration file for the
2411 <tt>uscan</tt> utility which defines how to automatically scan
2412 ftp or http sites for newly available updates of the
2413 package. This is used Debian QA
2414 tools to help with quality control and maintenance of the
2415 distribution as a whole.
2416 </p>
2418 </sect>
2420 <sect id="debianfiles">
2421 <heading>Generated files list: <file>debian/files</file></heading>
2424 This file is not a permanent part of the source tree; it
2425 is used while building packages to record which files are
2426 being generated. <prgn>dpkg-genchanges</prgn> uses it
2427 when it generates a <file>.changes</file> file.
2428 </p>
2431 It should not exist in a shipped source package, and so it
2432 (and any backup files or temporary files such as
2433 <file>files.new</file><footnote>
2434 <file>files.new</file> is used as a temporary file by
2435 <prgn>dpkg-gencontrol</prgn> and
2436 <prgn>dpkg-distaddfile</prgn> - they write a new
2437 version of <tt>files</tt> here before renaming it,
2438 to avoid leaving a corrupted copy if an error
2439 occurs.
2440 </footnote>) should be removed by the
2441 <tt>clean</tt> target. It may also be wise to
2442 ensure a fresh start by emptying or removing it at the
2443 start of the <tt>binary</tt> target.
2444 </p>
2447 When <prgn>dpkg-gencontrol</prgn> is run for a binary
2448 package, it adds an entry to <file>debian/files</file> for the
2449 <file>.deb</file> file that will be created when <tt>dpkg-deb
2450 --build</tt> is run for that binary package. So for most
2451 packages all that needs to be done with this file is to
2452 delete it in the <tt>clean</tt> target.
2453 </p>
2456 If a package upload includes files besides the source
2457 package and any binary packages whose control files were
2458 made with <prgn>dpkg-gencontrol</prgn> then they should be
2459 placed in the parent of the package's top-level directory
2460 and <prgn>dpkg-distaddfile</prgn> should be called to add
2461 the file to the list in <file>debian/files</file>.</p>
2462 </sect>
2464 <sect id="embeddedfiles">
2465 <heading>Convenience copies of code</heading>
2468 Some software packages include in their distribution convenience
2469 copies of code from other software packages, generally so that
2470 users compiling from source don't have to download multiple
2471 packages. Debian packages should not make use of these
2472 convenience copies unless the included package is explicitly
2473 intended to be used in this way.<footnote>
2474 For example, parts of the GNU build system work like this.
2475 </footnote>
2476 If the included code is already in the Debian archive in the
2477 form of a library, the Debian packaging should ensure that
2478 binary packages reference the libraries already in Debian and
2479 the convenience copy is not used. If the included code is not
2480 already in Debian, it should be packaged separately as a
2481 prerequisite if possible.
2482 <footnote>
2483 Having multiple copies of the same code in Debian is
2484 inefficient, often creates either static linking or shared
2485 library conflicts, and, most importantly, increases the
2486 difficulty of handling security vulnerabilities in the
2487 duplicated code.
2488 </footnote>
2489 </p>
2490 </sect>
2492 <sect id="readmesource">
2493 <heading>Source package handling:
2494 <file>debian/README.source</file></heading>
2497 If running <prgn>dpkg-source -x</prgn> on a source package
2498 doesn't produce the source of the package, ready for editing,
2499 and allow one to make changes and run
2500 <prgn>dpkg-buildpackage</prgn> to produce a modified package
2501 without taking any additional steps, creating a
2502 <file>debian/README.source</file> documentation file is
2503 recommended. This file should explain how to do all of the
2504 following:
2505 <enumlist>
2506 <item>Generate the fully patched source, in a form ready for
2507 editing, that would be built to create Debian
2508 packages. Doing this with a <tt>patch</tt> target in
2509 <file>debian/rules</file> is recommended; see
2510 <ref id="debianrules">.</item>
2511 <item>Modify the source and save those modifications so that
2512 they will be applied when building the package.</item>
2513 <item>Remove source modifications that are currently being
2514 applied when building the package.</item>
2515 <item>Optionally, document what steps are necessary to
2516 upgrade the Debian source package to a new upstream version,
2517 if applicable.</item>
2518 </enumlist>
2519 This explanation should include specific commands and mention
2520 any additional required Debian packages. It should not assume
2521 familiarity with any specific Debian packaging system or patch
2522 management tools.
2523 </p>
2526 This explanation may refer to a documentation file installed by
2527 one of the package's build dependencies provided that the
2528 referenced documentation clearly explains these tasks and is not
2529 a general reference manual.
2530 </p>
2533 <file>debian/README.source</file> may also include any other
2534 information that would be helpful to someone modifying the
2535 source package. Even if the package doesn't fit the above
2536 description, maintainers are encouraged to document in a
2537 <file>debian/README.source</file> file any source package with a
2538 particularly complex or unintuitive source layout or build
2539 system (for example, a package that builds the same source
2540 multiple times to generate different binary packages).
2541 </p>
2542 </sect>
2543 </chapt>
2546 <chapt id="controlfields">
2547 <heading>Control files and their fields</heading>
2550 The package management system manipulates data represented in
2551 a common format, known as <em>control data</em>, stored in
2552 <em>control files</em>.
2553 Control files are used for source packages, binary packages and
2554 the <file>.changes</file> files which control the installation
2555 of uploaded files<footnote>
2556 <prgn>dpkg</prgn>'s internal databases are in a similar
2557 format.
2558 </footnote>.
2559 </p>
2561 <sect id="controlsyntax">
2562 <heading>Syntax of control files</heading>
2565 A control file consists of one or more paragraphs of
2566 fields<footnote>
2567 The paragraphs are also sometimes referred to as stanzas.
2568 </footnote>.
2569 The paragraphs are separated by empty lines. Parsers may accept
2570 lines consisting solely of spaces and tabs as paragraph
2571 separators, but control files should use empty lines. Some control
2572 files allow only one paragraph; others allow several, in
2573 which case each paragraph usually refers to a different
2574 package. (For example, in source packages, the first
2575 paragraph refers to the source package, and later paragraphs
2576 refer to binary packages generated from the source.) The
2577 ordering of the paragraphs in control files is significant.
2578 </p>
2581 Each paragraph consists of a series of data fields. Each field
2582 consists of the field name followed by a colon and then the
2583 data/value associated with that field. The field name is
2584 composed of US-ASCII characters excluding control characters,
2585 space, and colon (i.e., characters in the ranges U+0021
2586 (<tt>!</tt>) through U+0039 (<tt>9</tt>), and U+003B
2587 (<tt>;</tt>) through U+007E (<tt>~</tt>), inclusive). Field
2588 names must not begin with the comment character
2589 (U+0023 <tt>#</tt>), nor with the hyphen character
2590 (U+002D <tt>-</tt>).
2591 </p>
2594 The field ends at the end of the line or at the end of the last
2595 continuation line (see below). Horizontal whitespace (spaces
2596 and tabs) may occur immediately before or after the value and is
2597 ignored there; it is conventional to put a single space after
2598 the colon. For example, a field might be:
2599 <example compact="compact">
2600 Package: libc6
2601 </example>
2602 the field name is <tt>Package</tt> and the field value
2603 <tt>libc6</tt>.
2604 </p>
2605 <p> Empty field values are only permitted in source package control files
2606 (<file>debian/control</file>). Such fields are ignored.
2607 </p>
2609 A paragraph must not contain more than one instance of a
2610 particular field name.
2611 </p>
2614 There are three types of fields:
2615 <taglist>
2616 <tag>simple</tag>
2617 <item>
2618 The field, including its value, must be a single line. Folding
2619 of the field is not permitted. This is the default field type
2620 if the definition of the field does not specify a different
2621 type.
2622 </item>
2623 <tag>folded</tag>
2624 <item>
2625 The value of a folded field is a logical line that may span
2626 several lines. The lines after the first are called
2627 continuation lines and must start with a space or a tab.
2628 Whitespace, including any newlines, is not significant in the
2629 field values of folded fields.<footnote>
2630 This folding method is similar to RFC 5322, allowing control
2631 files that contain only one paragraph and no multiline fields
2632 to be read by parsers written for RFC 5322.
2633 </footnote>
2634 </item>
2635 <tag>multiline</tag>
2636 <item>
2637 The value of a multiline field may comprise multiple continuation
2638 lines. The first line of the value, the part on the same line as
2639 the field name, often has special significance or may have to be
2640 empty. Other lines are added following the same syntax as the
2641 continuation lines of the folded fields. Whitespace, including newlines,
2642 is significant in the values of multiline fields.
2643 </item>
2644 </taglist>
2645 </p>
2648 Whitespace must not appear
2649 inside names (of packages, architectures, files or anything
2650 else) or version numbers, or between the characters of
2651 multi-character version relationships.
2652 </p>
2655 The presence and purpose of a field, and the syntax of its
2656 value may differ between types of control files.
2657 </p>
2660 Field names are not case-sensitive, but it is usual to
2661 capitalize the field names using mixed case as shown below.
2662 Field values are case-sensitive unless the description of the
2663 field says otherwise.
2664 </p>
2667 Paragraph separators (empty lines), and lines consisting only of
2668 U+0020 SPACE and U+0009 TAB, are not allowed within field values
2669 or between fields. Empty lines in field values are usually
2670 escaped by representing them by a U+0020 SPACE followed by a
2671 U+002E (<tt>.</tt>).
2672 </p>
2675 Lines starting with U+0023 (<tt>#</tt>), without any preceding
2676 whitespace, are comment lines that are only permitted in source
2677 package control files (<file>debian/control</file>). These
2678 comment lines are ignored, even between two continuation
2679 lines. They do not end logical lines.
2680 </p>
2683 All control files must be encoded in UTF-8.
2684 </p>
2685 </sect>
2687 <sect id="sourcecontrolfiles">
2688 <heading>Source package control files -- <file>debian/control</file></heading>
2691 The <file>debian/control</file> file contains the most vital
2692 (and version-independent) information about the source package
2693 and about the binary packages it creates.
2694 </p>
2697 The first paragraph of the control file contains information
2698 about the source package in general. The subsequent paragraphs
2699 each describe a binary package that the source tree builds.
2700 Each binary package built from this source package has a
2701 corresponding paragraph, except for any automatically-generated
2702 debug packages that do not require one.
2703 </p>
2706 The fields in the general paragraph (the first one, for the source
2707 package) are:
2709 <list compact="compact">
2710 <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2711 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2712 <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
2713 <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2714 <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2715 <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
2716 <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
2717 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2718 <item><qref id="f-VCS-fields"><tt>Vcs-Browser</tt>, <tt>Vcs-Git</tt>, et al.</qref></item>
2719 </list>
2720 </p>
2723 The fields in the binary package paragraphs are:
2725 <list compact="compact">
2726 <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
2727 <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2728 <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2729 <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2730 <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
2731 <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
2732 <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2733 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2734 <item><qref id="built-using"><tt>Built-Using</tt></qref></item>
2735 <item><qref id="f-Package-Type"><tt>Package-Type</tt></qref></item>
2736 </list>
2737 </p>
2740 The syntax and semantics of the fields are described below.
2741 </p>
2744 These fields are used by <prgn>dpkg-gencontrol</prgn> to
2745 generate control files for binary packages (see below), by
2746 <prgn>dpkg-genchanges</prgn> to generate the
2747 <file>.changes</file> file to accompany the upload, and by
2748 <prgn>dpkg-source</prgn> when it creates the
2749 <file>.dsc</file> source control file as part of a source
2750 archive. Some fields are folded in <file>debian/control</file>,
2751 but not in any other control
2752 file. These tools are responsible for removing the line
2753 breaks from such fields when using fields from
2754 <file>debian/control</file> to generate other control files.
2755 They are also responsible for discarding empty fields.
2756 </p>
2759 The fields here may contain variable references - their
2760 values will be substituted by <prgn>dpkg-gencontrol</prgn>,
2761 <prgn>dpkg-genchanges</prgn> or <prgn>dpkg-source</prgn>
2762 when they generate output control files.
2763 See <ref id="substvars"> for details.
2764 </p>
2765 </sect>
2767 <sect id="binarycontrolfiles">
2768 <heading>Binary package control files -- <file>DEBIAN/control</file></heading>
2771 The <file>DEBIAN/control</file> file contains the most vital
2772 (and version-dependent) information about a binary package. It
2773 consists of a single paragraph.
2774 </p>
2777 The fields in this file are:
2779 <list compact="compact">
2780 <item><qref id="f-Package"><tt>Package</tt></qref> (mandatory)</item>
2781 <item><qref id="f-Source"><tt>Source</tt></qref></item>
2782 <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2783 <item><qref id="f-Section"><tt>Section</tt></qref> (recommended)</item>
2784 <item><qref id="f-Priority"><tt>Priority</tt></qref> (recommended)</item>
2785 <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2786 <item><qref id="f-Essential"><tt>Essential</tt></qref></item>
2787 <item><qref id="binarydeps"><tt>Depends</tt> et al</qref></item>
2788 <item><qref id="f-Installed-Size"><tt>Installed-Size</tt></qref></item>
2789 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2790 <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2791 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2792 <item><qref id="built-using"><tt>Built-Using</tt></qref></item>
2793 </list>
2794 </p>
2795 </sect>
2797 <sect id="debiansourcecontrolfiles">
2798 <heading>Debian source control files -- <tt>.dsc</tt></heading>
2801 This file consists of a single paragraph, possibly surrounded by
2802 a PGP signature. The fields of that paragraph are listed below.
2803 Their syntax is described above, in <ref id="controlsyntax">.
2805 <list compact="compact">
2806 <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
2807 <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2808 <item><qref id="f-Binary"><tt>Binary</tt></qref></item>
2809 <item><qref id="f-Architecture"><tt>Architecture</tt></qref></item>
2810 <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2811 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2812 <item><qref id="f-Uploaders"><tt>Uploaders</tt></qref></item>
2813 <item><qref id="f-Homepage"><tt>Homepage</tt></qref></item>
2814 <item><qref id="f-VCS-fields"><tt>Vcs-Browser</tt>, <tt>Vcs-Git</tt>, et al.</qref></item>
2815 <item><qref id="f-Dgit"><tt>Dgit</tt></qref></item>
2816 <item><qref id="f-Standards-Version"><tt>Standards-Version</tt></qref> (recommended)</item>
2817 <item><qref id="sourcebinarydeps"><tt>Build-Depends</tt> et al</qref></item>
2818 <item><qref id="f-Package-List"><tt>Package-List</tt></qref> (recommended)</item>
2819 <item><qref id="f-Checksums"><tt>Checksums-Sha1</tt>
2820 and <tt>Checksums-Sha256</tt></qref> (mandatory)</item>
2821 <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
2822 </list>
2823 </p>
2826 The Debian source control file is generated by
2827 <prgn>dpkg-source</prgn> when it builds the source
2828 archive, from other files in the source package,
2829 described above. When unpacking, it is checked against
2830 the files and directories in the other parts of the
2831 source package.
2832 </p>
2834 </sect>
2836 <sect id="debianchangesfiles">
2837 <heading>Debian changes files -- <file>.changes</file></heading>
2840 The <file>.changes</file> files are used by the Debian archive
2841 maintenance software to process updates to packages. They
2842 consist of a single paragraph, possibly surrounded by a PGP
2843 signature. That paragraph contains information from the
2844 <file>debian/control</file> file and other data about the
2845 source package gathered via <file>debian/changelog</file>
2846 and <file>debian/rules</file>.
2847 </p>
2850 <file>.changes</file> files have a format version that is
2851 incremented whenever the documented fields or their meaning
2852 change. This document describes format &changesversion;.
2853 </p>
2856 The fields in this file are:
2858 <list compact="compact">
2859 <item><qref id="f-Format"><tt>Format</tt></qref> (mandatory)</item>
2860 <item><qref id="f-Date"><tt>Date</tt></qref> (mandatory)</item>
2861 <item><qref id="f-Source"><tt>Source</tt></qref> (mandatory)</item>
2862 <item><qref id="f-Binary"><tt>Binary</tt></qref> (mandatory)</item>
2863 <item><qref id="f-Architecture"><tt>Architecture</tt></qref> (mandatory)</item>
2864 <item><qref id="f-Version"><tt>Version</tt></qref> (mandatory)</item>
2865 <item><qref id="f-Distribution"><tt>Distribution</tt></qref> (mandatory)</item>
2866 <item><qref id="f-Urgency"><tt>Urgency</tt></qref> (recommended)</item>
2867 <item><qref id="f-Maintainer"><tt>Maintainer</tt></qref> (mandatory)</item>
2868 <item><qref id="f-Changed-By"><tt>Changed-By</tt></qref></item>
2869 <item><qref id="f-Description"><tt>Description</tt></qref> (mandatory)</item>
2870 <item><qref id="f-Closes"><tt>Closes</tt></qref></item>
2871 <item><qref id="f-Changes"><tt>Changes</tt></qref> (mandatory)</item>
2872 <item><qref id="f-Checksums"><tt>Checksums-Sha1</tt>
2873 and <tt>Checksums-Sha256</tt></qref> (mandatory)</item>
2874 <item><qref id="f-Files"><tt>Files</tt></qref> (mandatory)</item>
2875 </list>
2876 </p>
2877 </sect>
2879 <sect id="controlfieldslist">
2880 <heading>List of fields</heading>
2882 <sect1 id="f-Source">
2883 <heading><tt>Source</tt></heading>
2886 This field identifies the source package name.
2887 </p>
2890 In <file>debian/control</file> or a <file>.dsc</file> file,
2891 this field must contain only the name of the source package.
2892 </p>
2895 In a binary package control file or a <file>.changes</file>
2896 file, the source package name may be followed by a version
2897 number in parentheses<footnote>
2898 It is customary to leave a space after the package name
2899 if a version number is specified.
2900 </footnote>.
2901 This version number may be omitted (and is, by
2902 <prgn>dpkg-gencontrol</prgn>) if it has the same value as
2903 the <tt>Version</tt> field of the binary package in
2904 question. The field itself may be omitted from a binary
2905 package control file when the source package has the same
2906 name and version as the binary package.
2907 </p>
2910 Package names (both source and binary,
2911 see <ref id="f-Package">) must consist only of lower case
2912 letters (<tt>a-z</tt>), digits (<tt>0-9</tt>), plus
2913 (<tt>+</tt>) and minus (<tt>-</tt>) signs, and periods
2914 (<tt>.</tt>). They must be at least two characters long and
2915 must start with an alphanumeric character.
2916 </p>
2917 </sect1>
2919 <sect1 id="f-Maintainer">
2920 <heading><tt>Maintainer</tt></heading>
2923 The package maintainer's name and email address. The name
2924 must come first, then the email address inside angle
2925 brackets <tt>&lt;&gt;</tt> (in RFC822 format).
2926 </p>
2929 If the maintainer's name contains a full stop then the
2930 whole field will not work directly as an email address due
2931 to a misfeature in the syntax specified in RFC822; a
2932 program using this field as an address must check for this
2933 and correct the problem if necessary (for example by
2934 putting the name in round brackets and moving it to the
2935 end, and bringing the email address forward).
2936 </p>
2939 See <ref id="maintainer"> for additional requirements and
2940 information about package maintainers.
2941 </p>
2942 </sect1>
2944 <sect1 id="f-Uploaders">
2945 <heading><tt>Uploaders</tt></heading>
2948 List of the names and email addresses of co-maintainers of the
2949 package, if any. If the package has other maintainers besides
2950 the one named in the <qref id="f-Maintainer">Maintainer
2951 field</qref>, their names and email addresses should be listed
2952 here. The format of each entry is the same as that of the
2953 Maintainer field, and multiple entries must be comma
2954 separated.
2955 </p>
2958 This is normally an optional field, but if
2959 the <tt>Maintainer</tt> control field names a group of people
2960 and a shared email address, the <tt>Uploaders</tt> field must
2961 be present and must contain at least one human with their
2962 personal email address.
2963 </p>
2966 The Uploaders field in <file>debian/control</file> can be folded.
2967 </p>
2968 </sect1>
2970 <sect1 id="f-Changed-By">
2971 <heading><tt>Changed-By</tt></heading>
2974 The name and email address of the person who prepared this
2975 version of the package, usually a maintainer. The syntax is
2976 the same as for the <qref id="f-Maintainer">Maintainer
2977 field</qref>.
2978 </p>
2979 </sect1>
2981 <sect1 id="f-Section">
2982 <heading><tt>Section</tt></heading>
2985 This field specifies an application area into which the package
2986 has been classified. See <ref id="subsections">.
2987 </p>
2990 When it appears in the <file>debian/control</file> file,
2991 it gives the value for the subfield of the same name in
2992 the <tt>Files</tt> field of the <file>.changes</file> file.
2993 It also gives the default for the same field in the binary
2994 packages.
2995 </p>
2996 </sect1>
2998 <sect1 id="f-Priority">
2999 <heading><tt>Priority</tt></heading>
3002 This field represents how important it is that the user
3003 have the package installed. See <ref id="priorities">.
3004 </p>
3007 When it appears in the <file>debian/control</file> file,
3008 it gives the value for the subfield of the same name in
3009 the <tt>Files</tt> field of the <file>.changes</file> file.
3010 It also gives the default for the same field in the binary
3011 packages.
3012 </p>
3013 </sect1>
3015 <sect1 id="f-Package">
3016 <heading><tt>Package</tt></heading>
3019 The name of the binary package.
3020 </p>
3023 Binary package names must follow the same syntax and
3024 restrictions as source package names. See <ref id="f-Source">
3025 for the details.
3026 </p>
3027 </sect1>
3029 <sect1 id="f-Architecture">
3030 <heading><tt>Architecture</tt></heading>
3033 Depending on context and the control file used, the
3034 <tt>Architecture</tt> field can include the following sets of
3035 values:
3036 <list>
3037 <item>
3038 A unique single word identifying a Debian machine
3039 architecture as described in <ref id="arch-spec">.
3040 </item>
3041 <item>
3042 An architecture wildcard identifying a set of Debian
3043 machine architectures, see <ref id="arch-wildcard-spec">.
3044 <tt>any</tt> matches all Debian machine architectures
3045 and is the most frequently used.
3046 </item>
3047 <item>
3048 <tt>all</tt>, which indicates an
3049 architecture-independent package.
3050 </item>
3051 <item>
3052 <tt>source</tt>, which indicates a source package.
3053 </item>
3054 </list>
3055 </p>
3058 In the main <file>debian/control</file> file in the source
3059 package, this field may contain the special
3060 value <tt>all</tt>, the special architecture
3061 wildcard <tt>any</tt>, or a list of specific and wildcard
3062 architectures separated by spaces. If <tt>all</tt>
3063 or <tt>any</tt> appears, that value must be the entire
3064 contents of the field. Most packages will use
3065 either <tt>all</tt> or <tt>any</tt>.
3066 </p>
3069 Specifying a specific list of architectures indicates that the
3070 source will build an architecture-dependent package only on
3071 architectures included in the list. Specifying a list of
3072 architecture wildcards indicates that the source will build an
3073 architecture-dependent package on only those architectures
3074 that match any of the specified architecture wildcards.
3075 Specifying a list of architectures or architecture wildcards
3076 other than <tt>any</tt> is for the minority of cases where a
3077 program is not portable or is not useful on some
3078 architectures. Where possible, the program should be made
3079 portable instead.
3080 </p>
3083 In the Debian source control file <file>.dsc</file>, this
3084 field contains a list of architectures and architecture
3085 wildcards separated by spaces. When the list contains the
3086 architecture wildcard <tt>any</tt>, the only other value
3087 allowed in the list is <tt>all</tt>.
3088 </p>
3091 The list may include (or consist solely of) the special
3092 value <tt>all</tt>. In other words, in <file>.dsc</file>
3093 files unlike the <file>debian/control</file>, <tt>all</tt> may
3094 occur in combination with specific architectures.
3095 The <tt>Architecture</tt> field in the Debian source control
3096 file <file>.dsc</file> is generally constructed from
3097 the <tt>Architecture</tt> fields in
3098 the <file>debian/control</file> in the source package.
3099 </p>
3102 Specifying only <tt>any</tt> indicates that the source package
3103 isn't dependent on any particular architecture and should
3104 compile fine on any one. The produced binary package(s)
3105 will be specific to whatever the current build architecture is.
3106 </p>
3109 Specifying only <tt>all</tt> indicates that the source package
3110 will only build architecture-independent packages.
3111 </p>
3114 Specifying <tt>any all</tt> indicates that the source package
3115 isn't dependent on any particular architecture. The set of
3116 produced binary packages will include at least one
3117 architecture-dependent package and one architecture-independent
3118 package.
3119 </p>
3122 Specifying a list of architectures or architecture wildcards
3123 indicates that the source will build an architecture-dependent
3124 package, and will only work correctly on the listed or
3125 matching architectures. If the source package also builds at
3126 least one architecture-independent package, <tt>all</tt> will
3127 also be included in the list.
3128 </p>
3131 In a <file>.changes</file> file, the <tt>Architecture</tt>
3132 field lists the architecture(s) of the package(s) currently
3133 being uploaded. This will be a list; if the source for the
3134 package is also being uploaded, the special
3135 entry <tt>source</tt> is also present. <tt>all</tt> will be
3136 present if any architecture-independent packages are being
3137 uploaded. Architecture wildcards such as <tt>any</tt> must
3138 never occur in the <tt>Architecture</tt> field in
3139 the <file>.changes</file> file.
3140 </p>
3143 See <ref id="debianrules"> for information on how to get
3144 the architecture for the build process.
3145 </p>
3146 </sect1>
3148 <sect1 id="f-Essential">
3149 <heading><tt>Essential</tt></heading>
3152 This is a boolean field which may occur only in the
3153 control file of a binary package or in a per-package fields
3154 paragraph of a source package control file.
3155 </p>
3158 If set to <tt>yes</tt> then the package management system
3159 will refuse to remove the package (upgrading and replacing
3160 it is still possible). The other possible value is <tt>no</tt>,
3161 which is the same as not having the field at all.
3162 </p>
3163 </sect1>
3165 <sect1>
3166 <heading>Package interrelationship fields:
3167 <tt>Depends</tt>, <tt>Pre-Depends</tt>,
3168 <tt>Recommends</tt>, <tt>Suggests</tt>,
3169 <tt>Breaks</tt>, <tt>Conflicts</tt>,
3170 <tt>Provides</tt>, <tt>Replaces</tt>, <tt>Enhances</tt>
3171 </heading>
3174 These fields describe the package's relationships with
3175 other packages. Their syntax and semantics are described
3176 in <ref id="relationships">.</p>
3177 </sect1>
3179 <sect1 id="f-Standards-Version">
3180 <heading><tt>Standards-Version</tt></heading>
3183 The most recent version of the standards (the policy
3184 manual and associated texts) with which the package
3185 complies.
3186 </p>
3189 The version number has four components: major and minor
3190 version number and major and minor patch level. When the
3191 standards change in a way that requires every package to
3192 change the major number will be changed. Significant
3193 changes that will require work in many packages will be
3194 signaled by a change to the minor number. The major patch
3195 level will be changed for any change to the meaning of the
3196 standards, however small; the minor patch level will be
3197 changed when only cosmetic, typographical or other edits
3198 are made which neither change the meaning of the document
3199 nor affect the contents of packages.
3200 </p>
3203 Thus only the first three components of the policy version
3204 are significant in the <em>Standards-Version</em> control
3205 field, and so either these three components or all four
3206 components may be specified.<footnote>
3207 In the past, people specified the full version number
3208 in the Standards-Version field, for example "2.3.0.0".
3209 Since minor patch-level changes don't introduce new
3210 policy, it was thought it would be better to relax
3211 policy and only require the first 3 components to be
3212 specified, in this example "2.3.0". All four
3213 components may still be used if someone wishes to do so.
3214 </footnote>
3215 </p>
3217 </sect1>
3219 <sect1 id="f-Version">
3220 <heading><tt>Version</tt></heading>
3223 The version number of a package. The format is:
3224 [<var>epoch</var><tt>:</tt>]<var>upstream_version</var>[<tt>-</tt><var>debian_revision</var>]
3225 </p>
3228 The three components here are:
3229 <taglist>
3230 <tag><var>epoch</var></tag>
3231 <item>
3233 This is a single (generally small) unsigned integer. It
3234 may be omitted, in which case zero is assumed. If it is
3235 omitted then the <var>upstream_version</var> may not
3236 contain any colons.
3237 </p>
3240 It is provided to allow mistakes in the version numbers
3241 of older versions of a package, and also a package's
3242 previous version numbering schemes, to be left behind.
3243 </p>
3244 </item>
3246 <tag><var>upstream_version</var></tag>
3247 <item>
3249 This is the main part of the version number. It is
3250 usually the version number of the original ("upstream")
3251 package from which the <file>.deb</file> file has been made,
3252 if this is applicable. Usually this will be in the same
3253 format as that specified by the upstream author(s);
3254 however, it may need to be reformatted to fit into the
3255 package management system's format and comparison
3256 scheme.
3257 </p>
3260 The comparison behavior of the package management system
3261 with respect to the <var>upstream_version</var> is
3262 described below. The <var>upstream_version</var>
3263 portion of the version number is mandatory.
3264 </p>
3267 The <var>upstream_version</var> may contain only
3268 alphanumerics<footnote>
3269 Alphanumerics are <tt>A-Za-z0-9</tt> only.
3270 </footnote>
3271 and the characters <tt>.</tt> <tt>+</tt> <tt>-</tt>
3272 <tt>~</tt> (full stop, plus, hyphen,
3273 tilde) and should start with a digit. If there is no
3274 <var>debian_revision</var> then hyphens are not allowed.
3275 </p>
3276 </item>
3278 <tag><var>debian_revision</var></tag>
3279 <item>
3281 This part of the version number specifies the version of
3282 the Debian package based on the upstream version. It
3283 may contain only alphanumerics and the characters
3284 <tt>+</tt> <tt>.</tt> <tt>~</tt> (plus, full stop,
3285 tilde) and is compared in the same way as the
3286 <var>upstream_version</var> is.
3287 </p>
3290 It is optional; if it isn't present then the
3291 <var>upstream_version</var> may not contain a hyphen.
3292 This format represents the case where a piece of
3293 software was written specifically to be a Debian
3294 package, where the Debian package source must always
3295 be identical to the pristine source and therefore no
3296 revision indication is required.
3297 </p>
3300 It is conventional to restart the
3301 <var>debian_revision</var> at <tt>1</tt> each time the
3302 <var>upstream_version</var> is increased.
3303 </p>
3306 The package management system will break the version
3307 number apart at the last hyphen in the string (if there
3308 is one) to determine the <var>upstream_version</var> and
3309 <var>debian_revision</var>. The absence of a
3310 <var>debian_revision</var> is equivalent to a
3311 <var>debian_revision</var> of <tt>0</tt>.
3312 </p>
3313 </item>
3314 </taglist>
3315 </p>
3318 When comparing two version numbers, first the <var>epoch</var>
3319 of each are compared, then the <var>upstream_version</var> if
3320 <var>epoch</var> is equal, and then <var>debian_revision</var>
3321 if <var>upstream_version</var> is also equal.
3322 <var>epoch</var> is compared numerically. The
3323 <var>upstream_version</var> and <var>debian_revision</var>
3324 parts are compared by the package management system using the
3325 following algorithm:
3326 </p>
3329 The strings are compared from left to right.
3330 </p>
3333 First the initial part of each string consisting entirely of
3334 non-digit characters is determined. These two parts (one of
3335 which may be empty) are compared lexically. If a difference
3336 is found it is returned. The lexical comparison is a
3337 comparison of ASCII values modified so that all the letters
3338 sort earlier than all the non-letters and so that a tilde
3339 sorts before anything, even the end of a part. For example,
3340 the following parts are in sorted order from earliest to
3341 latest: <tt>~~</tt>, <tt>~~a</tt>, <tt>~</tt>, the empty part,
3342 <tt>a</tt>.<footnote>
3343 One common use of <tt>~</tt> is for upstream pre-releases.
3344 For example, <tt>1.0~beta1~svn1245</tt> sorts earlier than
3345 <tt>1.0~beta1</tt>, which sorts earlier than <tt>1.0</tt>.
3346 </footnote>
3347 </p>
3350 Then the initial part of the remainder of each string which
3351 consists entirely of digit characters is determined. The
3352 numerical values of these two parts are compared, and any
3353 difference found is returned as the result of the comparison.
3354 For these purposes an empty string (which can only occur at
3355 the end of one or both version strings being compared) counts
3356 as zero.
3357 </p>
3360 These two steps (comparing and removing initial non-digit
3361 strings and initial digit strings) are repeated until a
3362 difference is found or both strings are exhausted.
3363 </p>
3366 Note that the purpose of epochs is to allow us to leave behind
3367 mistakes in version numbering, and to cope with situations
3368 where the version numbering scheme changes. It is
3369 <em>not</em> intended to cope with version numbers containing
3370 strings of letters which the package management system cannot
3371 interpret (such as <tt>ALPHA</tt> or <tt>pre-</tt>), or with
3372 silly orderings.<footnote>
3373 The author of this manual has heard of a package whose
3374 versions went <tt>1.1</tt>, <tt>1.2</tt>, <tt>1.3</tt>,
3375 <tt>1</tt>, <tt>2.1</tt>, <tt>2.2</tt>, <tt>2</tt> and so
3376 forth.
3377 </footnote>
3378 </p>
3379 </sect1>
3381 <sect1 id="f-Description">
3382 <heading><tt>Description</tt></heading>
3385 In a source or binary control file, the <tt>Description</tt>
3386 field contains a description of the binary package, consisting
3387 of two parts, the synopsis or the short description, and the
3388 long description. It is a multiline field with the following
3389 format:
3390 </p>
3393 <example>
3394 Description: <var>single line synopsis</var>
3395 <var>extended description over several lines</var>
3396 </example>
3397 </p>
3400 The lines in the extended description can have these formats:
3401 </p>
3403 <p><list>
3405 <item>
3406 Those starting with a single space are part of a paragraph.
3407 Successive lines of this form will be word-wrapped when
3408 displayed. The leading space will usually be stripped off.
3409 The line must contain at least one non-whitespace character.
3410 </item>
3412 <item>
3413 Those starting with two or more spaces. These will be
3414 displayed verbatim. If the display cannot be panned
3415 horizontally, the displaying program will line wrap them "hard"
3416 (i.e., without taking account of word breaks). If it can they
3417 will be allowed to trail off to the right. None, one or two
3418 initial spaces may be deleted, but the number of spaces
3419 deleted from each line will be the same (so that you can have
3420 indenting work correctly, for example). The line must
3421 contain at least one non-whitespace character.
3422 </item>
3424 <item>
3425 Those containing a single space followed by a single full stop
3426 character. These are rendered as blank lines. This is the
3427 <em>only</em> way to get a blank line<footnote>
3428 Completely empty lines will not be rendered as blank lines.
3429 Instead, they will cause the parser to think you're starting
3430 a whole new record in the control file, and will therefore
3431 likely abort with an error.
3432 </footnote>.
3433 </item>
3435 <item>
3436 Those containing a space, a full stop and some more characters.
3437 These are for future expansion. Do not use them.
3438 </item>
3440 </list></p>
3443 Do not use tab characters. Their effect is not predictable.
3444 </p>
3447 See <ref id="descriptions"> for further information on this.
3448 </p>
3451 In a <file>.changes</file> file, the <tt>Description</tt>
3452 field contains a summary of the descriptions for the packages
3453 being uploaded. For this case, the first line of the field
3454 value (the part on the same line as <tt>Description:</tt>) is
3455 always empty. It is a multiline field, with one
3456 line per package. Each line is
3457 indented by one space and contains the name of a binary
3458 package, a space, a hyphen (<tt>-</tt>), a space, and the
3459 short description line from that package.
3460 </p>
3461 </sect1>
3463 <sect1 id="f-Distribution">
3464 <heading><tt>Distribution</tt></heading>
3467 In a <file>.changes</file> file or parsed changelog output
3468 this contains the (space-separated) name(s) of the
3469 distribution(s) where this version of the package should
3470 be installed. Valid distributions are determined by the
3471 archive maintainers.<footnote>
3472 Example distribution names in the Debian archive used in
3473 <file>.changes</file> files are:
3474 <taglist compact="compact">
3475 <tag><em>unstable</em></tag>
3476 <item>
3477 This distribution value refers to the
3478 <em>developmental</em> part of the Debian distribution
3479 tree. Most new packages, new upstream versions of
3480 packages and bug fixes go into the <em>unstable</em>
3481 directory tree.
3482 </item>
3484 <tag><em>experimental</em></tag>
3485 <item>
3486 The packages with this distribution value are deemed
3487 by their maintainers to be high risk. Oftentimes they
3488 represent early beta or developmental packages from
3489 various sources that the maintainers want people to
3490 try, but are not ready to be a part of the other parts
3491 of the Debian distribution tree.
3492 </item>
3493 </taglist>
3496 Others are used for updating stable releases or for
3497 security uploads. More information is available in the
3498 Debian Developer's Reference, section "The Debian
3499 archive".
3500 </p>
3501 </footnote>
3502 The Debian archive software only supports listing a single
3503 distribution. Migration of packages to other distributions is
3504 handled outside of the upload process.
3505 </p>
3506 </sect1>
3508 <sect1 id="f-Date">
3509 <heading><tt>Date</tt></heading>
3512 This field includes the date the package was built or last
3513 edited. It must be in the same format as the <var>date</var>
3514 in a <file>debian/changelog</file> entry.
3515 </p>
3518 The value of this field is usually extracted from the
3519 <file>debian/changelog</file> file - see
3520 <ref id="dpkgchangelog">).
3521 </p>
3522 </sect1>
3524 <sect1 id="f-Format">
3525 <heading><tt>Format</tt></heading>
3528 In <qref id="debianchangesfiles"><file>.changes</file></qref>
3529 files, this field declares the format version of that file.
3530 The syntax of the field value is the same as that of
3531 a <qref id="f-Version">package version number</qref> except
3532 that no epoch or Debian revision is allowed. The format
3533 described in this document is <tt>&changesversion;</tt>.
3534 </p>
3537 In <qref id="debiansourcecontrolfiles"><file>.dsc</file>
3538 Debian source control</qref> files, this field declares the
3539 format of the source package. The field value is used by
3540 programs acting on a source package to interpret the list of
3541 files in the source package and determine how to unpack it.
3542 The syntax of the field value is a numeric major revision, a
3543 period, a numeric minor revision, and then an optional subtype
3544 after whitespace, which if specified is an alphanumeric word
3545 in parentheses. The subtype is optional in the syntax but may
3546 be mandatory for particular source format revisions.
3547 <footnote>
3548 The source formats currently supported by the Debian archive
3549 software are <tt>1.0</tt>, <tt>3.0 (native)</tt>,
3550 and <tt>3.0 (quilt)</tt>.
3551 </footnote>
3552 </p>
3553 </sect1>
3555 <sect1 id="f-Urgency">
3556 <heading><tt>Urgency</tt></heading>
3559 This is a description of how important it is to upgrade to
3560 this version from previous ones. It consists of a single
3561 keyword taking one of the values <tt>low</tt>,
3562 <tt>medium</tt>, <tt>high</tt>, <tt>emergency</tt>, or
3563 <tt>critical</tt><footnote>
3564 Other urgency values are supported with configuration
3565 changes in the archive software but are not used in Debian.
3566 The urgency affects how quickly a package will be considered
3567 for inclusion into the <tt>testing</tt> distribution and
3568 gives an indication of the importance of any fixes included
3569 in the upload. <tt>Emergency</tt> and <tt>critical</tt> are
3570 treated as synonymous.
3571 </footnote> (not case-sensitive) followed by an optional
3572 commentary (separated by a space) which is usually in
3573 parentheses. For example:
3575 <example>
3576 Urgency: low (HIGH for users of diversions)
3577 </example>
3579 </p>
3582 The value of this field is usually extracted from the
3583 <file>debian/changelog</file> file - see
3584 <ref id="dpkgchangelog">.
3585 </p>
3586 </sect1>
3588 <sect1 id="f-Changes">
3589 <heading><tt>Changes</tt></heading>
3592 This multiline field contains the human-readable changes data, describing
3593 the differences between the last version and the current one.
3594 </p>
3597 The first line of the field value (the part on the same line
3598 as <tt>Changes:</tt>) is always empty. The content of the
3599 field is expressed as continuation lines, with each line
3600 indented by at least one space. Blank lines must be
3601 represented by a line consisting only of a space and a full
3602 stop (<tt>.</tt>).
3603 </p>
3606 The value of this field is usually extracted from the
3607 <file>debian/changelog</file> file - see
3608 <ref id="dpkgchangelog">).
3609 </p>
3612 Each version's change information should be preceded by a
3613 "title" line giving at least the version, distribution(s)
3614 and urgency, in a human-readable way.
3615 </p>
3618 If data from several versions is being returned the entry
3619 for the most recent version should be returned first, and
3620 entries should be separated by the representation of a
3621 blank line (the "title" line may also be followed by the
3622 representation of a blank line).
3623 </p>
3624 </sect1>
3626 <sect1 id="f-Binary">
3627 <heading><tt>Binary</tt></heading>
3630 This folded field is a list of binary packages. Its syntax and
3631 meaning varies depending on the control file in which it
3632 appears.
3633 </p>
3636 When it appears in the <file>.dsc</file> file, it lists binary
3637 packages which a source package can produce, separated by
3638 commas<footnote>
3639 A space after each comma is conventional.
3640 </footnote>. The source package
3641 does not necessarily produce all of these binary packages for
3642 every architecture. The source control file doesn't contain
3643 details of which architectures are appropriate for which of
3644 the binary packages.
3645 </p>
3648 When it appears in a <file>.changes</file> file, it lists the
3649 names of the binary packages being uploaded, separated by
3650 whitespace (not commas).
3651 </p>
3652 </sect1>
3654 <sect1 id="f-Installed-Size">
3655 <heading><tt>Installed-Size</tt></heading>
3658 This field appears in the control files of binary packages,
3659 and in the <file>Packages</file> files. It gives an estimate
3660 of the total amount of disk space required to install the
3661 named package. Actual installed size may vary based on block
3662 size, file system properties, or actions taken by package
3663 maintainer scripts.
3664 </p>
3667 The disk space is given as the integer value of the estimated
3668 installed size in bytes, divided by 1024 and rounded up.
3669 </p>
3670 </sect1>
3672 <sect1 id="f-Files">
3673 <heading><tt>Files</tt></heading>
3676 This field contains a list of files with information about
3677 each one. The exact information and syntax varies with
3678 the context.
3679 </p>
3682 In all cases, Files is a multiline field. The first line of
3683 the field value (the part on the same line as <tt>Files:</tt>)
3684 is always empty. The content of the field is expressed as
3685 continuation lines, one line per file. Each line must be
3686 indented by one space and contain a number of sub-fields,
3687 separated by spaces, as described below.
3688 </p>
3691 In the <file>.dsc</file> file, each line contains the MD5
3692 checksum, size and filename of the tar file and (if
3693 applicable) diff file which make up the remainder of the
3694 source package<footnote>
3695 That is, the parts which are not the <tt>.dsc</tt>.
3696 </footnote>. For example:
3697 <example>
3698 Files:
3699 c6f698f19f2a2aa07dbb9bbda90a2754 571925 example_1.2.orig.tar.gz
3700 938512f08422f3509ff36f125f5873ba 6220 example_1.2-1.diff.gz
3701 </example>
3702 The exact forms of the filenames are described
3703 in <ref id="pkg-sourcearchives">.
3704 </p>
3707 In the <file>.changes</file> file this contains one line per
3708 file being uploaded. Each line contains the MD5 checksum,
3709 size, section and priority and the filename. For example:
3710 <example>
3711 Files:
3712 4c31ab7bfc40d3cf49d7811987390357 1428 text extra example_1.2-1.dsc
3713 c6f698f19f2a2aa07dbb9bbda90a2754 571925 text extra example_1.2.orig.tar.gz
3714 938512f08422f3509ff36f125f5873ba 6220 text extra example_1.2-1.diff.gz
3715 7c98fe853b3bbb47a00e5cd129b6cb56 703542 text extra example_1.2-1_i386.deb
3716 </example>
3717 The <qref id="f-Section">section</qref>
3718 and <qref id="f-Priority">priority</qref> are the values of
3719 the corresponding fields in the main source control file. If
3720 no section or priority is specified then <tt>-</tt> should be
3721 used, though section and priority values must be specified for
3722 new packages to be installed properly.
3723 </p>
3726 The special value <tt>byhand</tt> for the section in a
3727 <tt>.changes</tt> file indicates that the file in question
3728 is not an ordinary package file and must be installed by
3729 hand by the distribution maintainers. If the section is
3730 <tt>byhand</tt> the priority should be <tt>-</tt>.
3731 </p>
3734 If a new Debian revision of a package is being shipped and
3735 no new original source archive is being distributed the
3736 <tt>.dsc</tt> must still contain the <tt>Files</tt> field
3737 entry for the original source archive
3738 <file><var>package</var>_<var>upstream-version</var>.orig.tar.gz</file>,
3739 but the <file>.changes</file> file should leave it out. In
3740 this case the original source archive on the distribution
3741 site must match exactly, byte-for-byte, the original
3742 source archive which was used to generate the
3743 <file>.dsc</file> file and diff which are being uploaded.</p>
3744 </sect1>
3746 <sect1 id="f-Closes">
3747 <heading><tt>Closes</tt></heading>
3750 A space-separated list of bug report numbers that the upload
3751 governed by the .changes file closes.
3752 </p>
3753 </sect1>
3755 <sect1 id="f-Homepage">
3756 <heading><tt>Homepage</tt></heading>
3759 The URL of the web site for this package, preferably (when
3760 applicable) the site from which the original source can be
3761 obtained and any additional upstream documentation or
3762 information may be found. The content of this field is a
3763 simple URL without any surrounding characters such as
3764 <tt>&lt;&gt;</tt>.
3765 </p>
3766 </sect1>
3768 <sect1 id="f-Checksums">
3769 <heading><tt>Checksums-Sha1</tt>
3770 and <tt>Checksums-Sha256</tt></heading>
3773 These multiline fields contain a list of files with a checksum and size
3774 for each one. Both <tt>Checksums-Sha1</tt>
3775 and <tt>Checksums-Sha256</tt> have the same syntax and differ
3776 only in the checksum algorithm used: SHA-1
3777 for <tt>Checksums-Sha1</tt> and SHA-256
3778 for <tt>Checksums-Sha256</tt>.
3779 </p>
3782 <tt>Checksums-Sha1</tt> and <tt>Checksums-Sha256</tt> are
3783 multiline fields. The first line of the field value (the part
3784 on the same line as <tt>Checksums-Sha1:</tt>
3785 or <tt>Checksums-Sha256:</tt>) is always empty. The content
3786 of the field is expressed as continuation lines, one line per
3787 file. Each line consists of the checksum, a space, the file
3788 size, a space, and the file name. For example (from
3789 a <file>.changes</file> file):
3790 <example>
3791 Checksums-Sha1:
3792 1f418afaa01464e63cc1ee8a66a05f0848bd155c 1276 example_1.0-1.dsc
3793 a0ed1456fad61116f868b1855530dbe948e20f06 171602 example_1.0.orig.tar.gz
3794 5e86ecf0671e113b63388dac81dd8d00e00ef298 6137 example_1.0-1.debian.tar.gz
3795 71a0ff7da0faaf608481195f9cf30974b142c183 548402 example_1.0-1_i386.deb
3796 Checksums-Sha256:
3797 ac9d57254f7e835bed299926fd51bf6f534597cc3fcc52db01c4bffedae81272 1276 example_1.0-1.dsc
3798 0d123be7f51e61c4bf15e5c492b484054be7e90f3081608a5517007bfb1fd128 171602 example_1.0.orig.tar.gz
3799 f54ae966a5f580571ae7d9ef5e1df0bd42d63e27cb505b27957351a495bc6288 6137 example_1.0-1.debian.tar.gz
3800 3bec05c03974fdecd11d020fc2e8250de8404867a8a2ce865160c250eb723664 548402 example_1.0-1_i386.deb
3801 </example>
3802 </p>
3805 In the <file>.dsc</file> file, these fields list all
3806 files that make up the source package. In
3807 the <file>.changes</file> file, these fields list all
3808 files being uploaded. The list of files in these fields
3809 must match the list of files in the <tt>Files</tt> field.
3810 </p>
3811 </sect1>
3813 <sect1>
3814 <heading><tt>DM-Upload-Allowed</tt></heading>
3817 Obsolete, see <qref id="f-DM-Upload-Allowed">below</qref>.
3818 </p>
3819 </sect1>
3821 <sect1 id="f-VCS-fields">
3822 <heading>Version Control System (VCS) fields</heading>
3825 Debian source packages are increasingly developed using VCSs. The
3826 purpose of the following fields is to indicate a publicly accessible
3827 repository where the Debian source package is developed.
3829 <taglist>
3830 <tag><tt>Vcs-Browser</tt></tag>
3831 <item>
3833 URL of a web interface for browsing the repository.
3834 </p>
3835 </item>
3837 <tag>
3838 <tt>Vcs-Arch</tt>, <tt>Vcs-Bzr</tt> (Bazaar), <tt>Vcs-Cvs</tt>,
3839 <tt>Vcs-Darcs</tt>, <tt>Vcs-Git</tt>, <tt>Vcs-Hg</tt>
3840 (Mercurial), <tt>Vcs-Mtn</tt> (Monotone), <tt>Vcs-Svn</tt>
3841 (Subversion)
3842 </tag>
3843 <item>
3845 The field name identifies the VCS. The field's value uses the
3846 version control system's conventional syntax for describing
3847 repository locations and should be sufficient to locate the
3848 repository used for packaging. Ideally, it also locates the
3849 branch used for development of new versions of the Debian
3850 package.
3851 </p>
3853 In the case of Git, the value consists of a URL, optionally
3854 followed by the word <tt>-b</tt> and the name of a branch in
3855 the indicated repository, following the syntax of the
3856 <tt>git clone</tt> command. If no branch is specified, the
3857 packaging should be on the default branch.
3858 </p>
3860 More than one different VCS may be specified for the same
3861 package.
3862 </p>
3863 </item>
3864 </taglist>
3865 </p>
3866 </sect1>
3868 <sect1 id="f-Package-List">
3869 <heading><tt>Package-List</tt></heading>
3872 Multiline field listing all the packages that can be built from
3873 the source package, considering every architecture. The first line
3874 of the field value is empty. Each one of the next lines describes
3875 one binary package, by listing its name, type, section and priority
3876 separated by spaces. Fifth and subsequent space-separated items
3877 may be present and parsers must allow them. See the
3878 <qref id="f-Package-Type">Package-Type</qref> field for a list of
3879 package types.
3880 </p>
3881 </sect1>
3883 <sect1 id="f-Package-Type">
3884 <heading><tt>Package-Type</tt></heading>
3887 Simple field containing a word indicating the type of package:
3888 <tt>deb</tt> for binary packages and <tt>udeb</tt> for micro binary
3889 packages. Other types not defined here may be indicated. In
3890 source package control files, the <tt>Package-Type</tt> field
3891 should be omitted instead of giving it a value of <tt>deb</tt>, as
3892 this value is assumed for paragraphs lacking this field.
3893 </p>
3894 </sect1>
3896 <sect1 id="f-Dgit">
3897 <heading><tt>Dgit</tt></heading>
3900 Folded field containing a single git commit hash, presented in
3901 full, followed optionally by whitespace and other data to be
3902 defined in future extensions.
3903 </p>
3906 Declares that the source package corresponds exactly to a
3907 referenced commit in a Git repository available at the canonical
3908 location called <em>dgit-repos</em>, used by <prgn>dgit</prgn>, a
3909 bidirectional gateway between the Debian archive and Git. The
3910 commit is reachable from at least one reference whose name matches
3911 <tt>refs/dgit/*</tt>. See the manual page of <prgn>dgit</prgn> for
3912 further details.
3913 </p>
3914 </sect1>
3915 </sect>
3917 <sect>
3918 <heading>User-defined fields</heading>
3921 Additional user-defined fields may be added to the
3922 source package control file. Such fields will be
3923 ignored, and not copied to (for example) binary or
3924 Debian source control files or upload control files.
3925 </p>
3928 If you wish to add additional unsupported fields to
3929 these output files you should use the mechanism
3930 described here.
3931 </p>
3934 Fields in the main source control information file with
3935 names starting <tt>X</tt>, followed by one or more of
3936 the letters <tt>BCS</tt> and a hyphen <tt>-</tt>, will
3937 be copied to the output files. Only the part of the
3938 field name after the hyphen will be used in the output
3939 file. Where the letter <tt>B</tt> is used the field
3940 will appear in binary package control files, where the
3941 letter <tt>S</tt> is used in Debian source control
3942 files and where <tt>C</tt> is used in upload control
3943 (<tt>.changes</tt>) files.
3944 </p>
3947 For example, if the main source information control file
3948 contains the field
3949 <example>
3950 XBS-Comment: I stand between the candle and the star.
3951 </example>
3952 then the binary and Debian source control files will contain the
3953 field
3954 <example>
3955 Comment: I stand between the candle and the star.
3956 </example>
3957 </p>
3959 </sect>
3961 <sect id="obsolete-control-data-fields">
3962 <heading>Obsolete fields</heading>
3965 The following fields have been obsoleted and may be found in packages
3966 conforming with previous versions of the Policy.
3967 </p>
3969 <sect1 id="f-DM-Upload-Allowed">
3970 <heading><tt>DM-Upload-Allowed</tt></heading>
3973 Indicates that Debian Maintainers may upload this package to
3974 the Debian archive. The only valid value is <tt>yes</tt>. This
3975 field was used to regulate uploads by Debian Maintainers, See the
3976 General Resolution <url id="http://www.debian.org/vote/2007/vote_003"
3977 name="Endorse the concept of Debian Maintainers"> for more details.
3978 </p>
3979 </sect1>
3981 </sect>
3983 </chapt>
3986 <chapt id="maintainerscripts">
3987 <heading>Package maintainer scripts and installation procedure</heading>
3989 <sect>
3990 <heading>Introduction to package maintainer scripts</heading>
3993 It is possible to supply scripts as part of a package which
3994 the package management system will run for you when your
3995 package is installed, upgraded or removed.
3996 </p>
3999 These scripts are the control information
4000 files <prgn>preinst</prgn>, <prgn>postinst</prgn>, <prgn>prerm</prgn>
4001 and <prgn>postrm</prgn>. They must be proper executable files;
4002 if they are scripts (which is recommended), they must start with
4003 the usual <tt>#!</tt> convention. They should be readable and
4004 executable by anyone, and must not be world-writable.
4005 </p>
4008 The package management system looks at the exit status from
4009 these scripts. It is important that they exit with a
4010 non-zero status if there is an error, so that the package
4011 management system can stop its processing. For shell
4012 scripts this means that you <em>almost always</em> need to
4013 use <tt>set -e</tt> (this is usually true when writing shell
4014 scripts, in fact). It is also important, of course, that
4015 they exit with a zero status if everything went well.
4016 </p>
4019 Additionally, packages interacting with users
4020 using <prgn>debconf</prgn> in the <prgn>postinst</prgn> script
4021 should install a <prgn>config</prgn> script as a control
4022 information file. See <ref id="maintscriptprompt"> for details.
4023 </p>
4026 When a package is upgraded a combination of the scripts from
4027 the old and new packages is called during the upgrade
4028 procedure. If your scripts are going to be at all
4029 complicated you need to be aware of this, and may need to
4030 check the arguments to your scripts.
4031 </p>
4034 Broadly speaking the <prgn>preinst</prgn> is called before
4035 (a particular version of) a package is unpacked, and the
4036 <prgn>postinst</prgn> afterwards; the <prgn>prerm</prgn>
4037 before (a version of) a package is removed and the
4038 <prgn>postrm</prgn> afterwards.
4039 </p>
4042 Programs called from maintainer scripts should not normally
4043 have a path prepended to them. Before installation is
4044 started, the package management system checks to see if the
4045 programs <prgn>ldconfig</prgn>, <prgn>start-stop-daemon</prgn>,
4046 and <prgn>update-rc.d</prgn> can be found via the
4047 <tt>PATH</tt> environment variable. Those programs, and any
4048 other program that one would expect to be in the
4049 <tt>PATH</tt>, should thus be invoked without an absolute
4050 pathname. Maintainer scripts should also not reset the
4051 <tt>PATH</tt>, though they might choose to modify it by
4052 prepending or appending package-specific directories. These
4053 considerations really apply to all shell scripts.</p>
4054 </sect>
4056 <sect id="idempotency">
4057 <heading>Maintainer scripts idempotency</heading>
4060 It is necessary for the error recovery procedures that the
4061 scripts be idempotent. This means that if it is run
4062 successfully, and then it is called again, it doesn't bomb
4063 out or cause any harm, but just ensures that everything is
4064 the way it ought to be. If the first call failed, or
4065 aborted half way through for some reason, the second call
4066 should merely do the things that were left undone the first
4067 time, if any, and exit with a success status if everything
4068 is OK.<footnote>
4069 This is so that if an error occurs, the user interrupts
4070 <prgn>dpkg</prgn> or some other unforeseen circumstance
4071 happens you don't leave the user with a badly-broken
4072 package when <prgn>dpkg</prgn> attempts to repeat the
4073 action.
4074 </footnote>
4075 </p>
4076 </sect>
4078 <sect id="controllingterminal">
4079 <heading>Controlling terminal for maintainer scripts</heading>
4082 Maintainer scripts are not guaranteed to run with a controlling
4083 terminal and may not be able to interact with the user. They
4084 must be able to fall back to noninteractive behavior if no
4085 controlling terminal is available. Maintainer scripts that
4086 prompt via a program conforming to the Debian Configuration
4087 Management Specification (see <ref id="maintscriptprompt">) may
4088 assume that program will handle falling back to noninteractive
4089 behavior.
4090 </p>
4093 For high-priority prompts without a reasonable default answer,
4094 maintainer scripts may abort if there is no controlling
4095 terminal. However, this situation should be avoided if at all
4096 possible, since it prevents automated or unattended installs.
4097 In most cases, users will consider this to be a bug in the
4098 package.
4099 </p>
4100 </sect>
4102 <sect id="exitstatus">
4103 <heading>Exit status</heading>
4106 Each script must return a zero exit status for
4107 success, or a nonzero one for failure, since the package
4108 management system looks for the exit status of these scripts
4109 and determines what action to take next based on that datum.
4110 </p>
4111 </sect>
4113 <sect id="mscriptsinstact"><heading>Summary of ways maintainer
4114 scripts are called
4115 </heading>
4118 What follows is a summary of all the ways in which maintainer
4119 scripts may be called along with what facilities those scripts
4120 may rely on being available at that time. Script names preceded
4121 by <var>new-</var> are the scripts from the new version of a
4122 package being installed, upgraded to, or downgraded to. Script
4123 names preceded by <var>old-</var> are the scripts from the old
4124 version of a package that is being upgraded from or downgraded
4125 from.
4126 </p>
4129 The <prgn>preinst</prgn> script may be called in the following
4130 ways:
4131 <taglist>
4132 <tag><var>new-preinst</var> <tt>install</tt></tag>
4133 <tag><var>new-preinst</var> <tt>install</tt>
4134 <var>old-version</var></tag>
4135 <tag><var>new-preinst</var> <tt>upgrade</tt>
4136 <var>old-version</var></tag>
4137 <item>
4138 The package will not yet be unpacked, so
4139 the <prgn>preinst</prgn> script cannot rely on any files
4140 included in its package. Only essential packages and
4141 pre-dependencies (<tt>Pre-Depends</tt>) may be assumed to be
4142 available. Pre-dependencies will have been configured at
4143 least once, but at the time the <prgn>preinst</prgn> is
4144 called they may only be in an "Unpacked" or "Half-Configured"
4145 state if a previous version of the pre-dependency was
4146 completely configured and has not been removed since then.
4147 </item>
4149 <tag><var>old-preinst</var> <tt>abort-upgrade</tt>
4150 <var>new-version</var></tag>
4151 <item>
4152 Called during error handling of an upgrade that failed after
4153 unpacking the new package because the <tt>postrm
4154 upgrade</tt> action failed. The unpacked files may be
4155 partly from the new version or partly missing, so the script
4156 cannot rely on files included in the package. Package
4157 dependencies may not be available. Pre-dependencies will be
4158 at least "Unpacked" following the same rules as above, except
4159 they may be only "Half-Installed" if an upgrade of the
4160 pre-dependency failed.<footnote>
4161 This can happen if the new version of the package no
4162 longer pre-depends on a package that had been partially
4163 upgraded.
4164 </footnote>
4165 </item>
4166 </taglist>
4167 </p>
4170 The <prgn>postinst</prgn> script may be called in the following
4171 ways:
4172 <taglist>
4173 <tag><var>postinst</var> <tt>configure</tt>
4174 <var>most-recently-configured-version</var></tag>
4175 <item>
4176 The files contained in the package will be unpacked. All
4177 package dependencies will at least be "Unpacked". If there
4178 are no circular dependencies involved, all package
4179 dependencies will be configured. For behavior in the case
4180 of circular dependencies, see the discussion
4181 in <ref id="binarydeps">.
4182 </item>
4184 <tag><var>old-postinst</var> <tt>abort-upgrade</tt>
4185 <var>new-version</var></tag>
4186 <tag><var>conflictor's-postinst</var> <tt>abort-remove</tt>
4187 <tt>in-favour</tt> <var>package</var>
4188 <var>new-version</var></tag>
4189 <tag><var>postinst</var> <tt>abort-remove</tt></tag>
4190 <tag><var>deconfigured's-postinst</var>
4191 <tt>abort-deconfigure</tt> <tt>in-favour</tt>
4192 <var>failed-install-package</var> <var>version</var>
4193 [<tt>removing</tt> <var>conflicting-package</var>
4194 <var>version</var>]</tag>
4195 <item>
4196 The files contained in the package will be unpacked. All
4197 package dependencies will at least be "Half-Installed" and
4198 will have previously been configured and not removed.
4199 However, dependencies may not be configured or even fully
4200 unpacked in some error situations.<footnote>
4201 For example, suppose packages foo and bar are "Installed"
4202 with foo depending on bar. If an upgrade of bar were
4203 started and then aborted, and then an attempt to remove
4204 foo failed because its <prgn>prerm</prgn> script failed,
4205 foo's <tt>postinst abort-remove</tt> would be called with
4206 bar only "Half-Installed".
4207 </footnote>
4208 The <prgn>postinst</prgn> should still attempt any actions
4209 for which its dependencies are required, since they will
4210 normally be available, but consider the correct error
4211 handling approach if those actions fail. Aborting
4212 the <prgn>postinst</prgn> action if commands or facilities
4213 from the package dependencies are not available is often the
4214 best approach.
4215 </item>
4216 </taglist>
4217 </p>
4220 The <prgn>prerm</prgn> script may be called in the following
4221 ways:
4222 <taglist>
4223 <tag><var>prerm</var> <tt>remove</tt></tag>
4224 <tag><var>old-prerm</var>
4225 <tt>upgrade</tt><var>new-version</var></tag>
4226 <tag><var>conflictor's-prerm</var> <tt>remove</tt>
4227 <tt>in-favour</tt> <var>package</var>
4228 <var>new-version</var></tag>
4229 <tag><var>deconfigured's-prerm</var> <tt>deconfigure</tt>
4230 <tt>in-favour</tt> <var>package-being-installed</var>
4231 <var>version</var> [<tt>removing</tt>
4232 <var>conflicting-package</var> <var>version</var>]</tag>
4233 <item>
4234 The package whose <prgn>prerm</prgn> is being called will be
4235 at least "Half-Installed". All package dependencies will at
4236 least be "Half-Installed" and will have previously been
4237 configured and not removed. If there was no error, all
4238 dependencies will at least be "Unpacked", but these actions
4239 may be called in various error states where dependencies are
4240 only "Half-Installed" due to a partial upgrade.
4241 </item>
4243 <tag><var>new-prerm</var> <tt>failed-upgrade</tt>
4244 <var>old-version</var></tag>
4245 <item>
4246 Called during error handling when <tt>prerm upgrade</tt>
4247 fails. The new package will not yet be unpacked, and all
4248 the same constraints as for <tt>preinst upgrade</tt> apply.
4249 </item>
4250 </taglist>
4251 </p>
4254 The <prgn>postrm</prgn> script may be called in the following
4255 ways:
4256 <taglist>
4257 <tag><var>postrm</var> <tt>remove</tt></tag>
4258 <tag><var>postrm</var> <tt>purge</tt></tag>
4259 <tag><var>old-postrm</var> <tt>upgrade</tt>
4260 <var>new-version</var></tag>
4261 <tag><var>disappearer's-postrm</var> <tt>disappear</tt>
4262 <var>overwriter</var> <var>overwriter-version</var></tag>
4263 <item>
4264 The <prgn>postrm</prgn> script is called after the package's
4265 files have been removed or replaced. The package
4266 whose <prgn>postrm</prgn> is being called may have
4267 previously been deconfigured and only be "Unpacked", at which
4268 point subsequent package changes do not consider its
4269 dependencies. Therefore, all <prgn>postrm</prgn> actions
4270 may only rely on essential packages and must gracefully skip
4271 any actions that require the package's dependencies if those
4272 dependencies are unavailable.<footnote>
4273 This is often done by checking whether the command or
4274 facility the <prgn>postrm</prgn> intends to call is
4275 available before calling it. For example:
4276 <example>
4277 if [ "$1" = purge ] &amp;&amp; [ -e /usr/share/debconf/confmodule ]; then
4278 . /usr/share/debconf/confmodule
4279 db_purge
4281 </example>
4282 in <prgn>postrm</prgn> purges the <prgn>debconf</prgn>
4283 configuration for the package
4284 if <package>debconf</package> is installed.
4285 </footnote>
4286 </item>
4288 <tag><var>new-postrm</var> <tt>failed-upgrade</tt>
4289 <var>old-version</var></tag>
4290 <item>
4291 Called when the old <tt>postrm upgrade</tt> action fails.
4292 The new package will be unpacked, but only essential
4293 packages and pre-dependencies can be relied on.
4294 Pre-dependencies will either be configured or will be
4295 "Unpacked" or "Half-Configured" but previously had been
4296 configured and was never removed.
4297 </item>
4299 <tag><var>new-postrm</var> <tt>abort-install</tt></tag>
4300 <tag><var>new-postrm</var> <tt>abort-install</tt>
4301 <var>old-version</var></tag>
4302 <tag><var>new-postrm</var> <tt>abort-upgrade</tt>
4303 <var>old-version</var></tag>
4304 <item>
4305 Called before unpacking the new package as part of the
4306 error handling of <prgn>preinst</prgn> failures. May assume
4307 the same state as <prgn>preinst</prgn> can assume.
4308 </item>
4309 </taglist>
4310 </p>
4311 </sect>
4313 <sect id="unpackphase">
4314 <heading>Details of unpack phase of installation or upgrade</heading>
4317 The procedure on installation/upgrade/overwrite/disappear
4318 (i.e., when running <tt>dpkg --unpack</tt>, or the unpack
4319 stage of <tt>dpkg --install</tt>) is as follows. In each
4320 case, if a major error occurs (unless listed below) the
4321 actions are, in general, run backwards - this means that the
4322 maintainer scripts are run with different arguments in
4323 reverse order. These are the "error unwind" calls listed
4324 below.
4326 <enumlist>
4327 <item>
4328 <enumlist>
4329 <item>
4330 If a version of the package is already "Installed", call
4331 <example compact="compact">
4332 <var>old-prerm</var> upgrade <var>new-version</var>
4333 </example>
4334 </item>
4335 <item>
4336 If the script runs but exits with a non-zero
4337 exit status, <prgn>dpkg</prgn> will attempt:
4338 <example compact="compact">
4339 <var>new-prerm</var> failed-upgrade <var>old-version</var>
4340 </example>
4341 If this works, the upgrade continues. If this
4342 does not work, the error unwind:
4343 <example compact="compact">
4344 <var>old-postinst</var> abort-upgrade <var>new-version</var>
4345 </example>
4346 If this works, then the old-version is
4347 "Installed", if not, the old version is in a
4348 "Half-Configured" state.
4349 </item>
4350 </enumlist>
4351 </item>
4353 <item>
4354 If a "conflicting" package is being removed at the same time,
4355 or if any package will be broken (due to <tt>Breaks</tt>):
4356 <enumlist>
4357 <item>
4358 If <tt>--auto-deconfigure</tt> is
4359 specified, call, for each package to be deconfigured
4360 due to <tt>Breaks</tt>:
4361 <example compact="compact">
4362 <var>deconfigured's-prerm</var> deconfigure \
4363 in-favour <var>package-being-installed</var> <var>version</var>
4364 </example>
4365 Error unwind:
4366 <example compact="compact">
4367 <var>deconfigured's-postinst</var> abort-deconfigure \
4368 in-favour <var>package-being-installed-but-failed</var> <var>version</var>
4369 </example>
4370 The deconfigured packages are marked as
4371 requiring configuration, so that if
4372 <tt>--install</tt> is used they will be
4373 configured again if possible.
4374 </item>
4375 <item>
4376 If any packages depended on a conflicting
4377 package being removed and <tt>--auto-deconfigure</tt> is
4378 specified, call, for each such package:
4379 <example compact="compact">
4380 <var>deconfigured's-prerm</var> deconfigure \
4381 in-favour <var>package-being-installed</var> <var>version</var> \
4382 removing <var>conflicting-package</var> <var>version</var>
4383 </example>
4384 Error unwind:
4385 <example compact="compact">
4386 <var>deconfigured's-postinst</var> abort-deconfigure \
4387 in-favour <var>package-being-installed-but-failed</var> <var>version</var> \
4388 removing <var>conflicting-package</var> <var>version</var>
4389 </example>
4390 The deconfigured packages are marked as
4391 requiring configuration, so that if
4392 <tt>--install</tt> is used they will be
4393 configured again if possible.
4394 </item>
4395 <item>
4396 To prepare for removal of each conflicting package, call:
4397 <example compact="compact">
4398 <var>conflictor's-prerm</var> remove \
4399 in-favour <var>package</var> <var>new-version</var>
4400 </example>
4401 Error unwind:
4402 <example compact="compact">
4403 <var>conflictor's-postinst</var> abort-remove \
4404 in-favour <var>package</var> <var>new-version</var>
4405 </example>
4406 </item>
4407 </enumlist>
4408 </item>
4410 <item>
4411 <enumlist>
4412 <item>
4413 If the package is being upgraded, call:
4414 <example compact="compact">
4415 <var>new-preinst</var> upgrade <var>old-version</var>
4416 </example>
4417 If this fails, we call:
4418 <example>
4419 <var>new-postrm</var> abort-upgrade <var>old-version</var>
4420 </example>
4421 <enumlist>
4422 <item>
4424 If that works, then
4425 <example>
4426 <var>old-postinst</var> abort-upgrade <var>new-version</var>
4427 </example>
4428 is called. If this works, then the old version
4429 is in an "Installed" state, or else it is left
4430 in an "Unpacked" state.
4431 </p>
4432 </item>
4433 <item>
4435 If it fails, then the old version is left
4436 in an "Half-Installed" state.
4437 </p>
4438 </item>
4439 </enumlist>
4441 </item>
4442 <item>
4443 Otherwise, if the package had some configuration
4444 files from a previous version installed (i.e., it
4445 is in the "Config-Files" state):
4446 <example compact="compact">
4447 <var>new-preinst</var> install <var>old-version</var>
4448 </example>
4449 Error unwind:
4450 <example>
4451 <var>new-postrm</var> abort-install <var>old-version</var>
4452 </example>
4453 If this fails, the package is left in a
4454 "Half-Installed" state, which requires a
4455 reinstall. If it works, the packages is left in
4456 a "Config-Files" state.
4457 </item>
4458 <item>
4459 Otherwise (i.e., the package was completely purged):
4460 <example compact="compact">
4461 <var>new-preinst</var> install
4462 </example>
4463 Error unwind:
4464 <example compact="compact">
4465 <var>new-postrm</var> abort-install
4466 </example>
4467 If the error-unwind fails, the package is in a
4468 "Half-Installed" phase, and requires a
4469 reinstall. If the error unwind works, the
4470 package is in the "Not-Installed" state.
4471 </item>
4472 </enumlist>
4473 </item>
4475 <item>
4477 The new package's files are unpacked, overwriting any
4478 that may be on the system already, for example any
4479 from the old version of the same package or from
4480 another package. Backups of the old files are kept
4481 temporarily, and if anything goes wrong the package
4482 management system will attempt to put them back as
4483 part of the error unwind.
4484 </p>
4487 It is an error for a package to contain files which
4488 are on the system in another package, unless
4489 <tt>Replaces</tt> is used (see <ref id="replaces">).
4490 </p>
4493 It is a more serious error for a package to contain a
4494 plain file or other kind of non-directory where another
4495 package has a directory (again, unless
4496 <tt>Replaces</tt> is used). This error can be
4497 overridden if desired using
4498 <tt>--force-overwrite-dir</tt>, but this is not
4499 advisable.
4500 </p>
4503 Packages which overwrite each other's files produce
4504 behavior which, though deterministic, is hard for the
4505 system administrator to understand. It can easily
4506 lead to "missing" programs if, for example, a package
4507 is unpacked which overwrites a file from another
4508 package, and is then removed again.<footnote>
4509 Part of the problem is due to what is arguably a
4510 bug in <prgn>dpkg</prgn>.
4511 </footnote>
4512 </p>
4515 A directory will never be replaced by a symbolic link
4516 to a directory or vice versa; instead, the existing
4517 state (symlink or not) will be left alone and
4518 <prgn>dpkg</prgn> will follow the symlink if there is
4519 one.
4520 </p>
4521 </item>
4523 <item>
4525 <enumlist>
4526 <item>
4527 If the package is being upgraded, call
4528 <example compact="compact">
4529 <var>old-postrm</var> upgrade <var>new-version</var>
4530 </example>
4531 </item>
4532 <item>
4533 If this fails, <prgn>dpkg</prgn> will attempt:
4534 <example compact="compact">
4535 <var>new-postrm</var> failed-upgrade <var>old-version</var>
4536 </example>
4537 If this works, installation continues. If not,
4538 Error unwind:
4539 <example compact="compact">
4540 <var>old-preinst</var> abort-upgrade <var>new-version</var>
4541 </example>
4542 If this fails, the old version is left in a
4543 "Half-Installed" state. If it works, dpkg now
4544 calls:
4545 <example compact="compact">
4546 <var>new-postrm</var> abort-upgrade <var>old-version</var>
4547 </example>
4548 If this fails, the old version is left in a
4549 "Half-Installed" state. If it works, dpkg now
4550 calls:
4551 <example compact="compact">
4552 <var>old-postinst</var> abort-upgrade <var>new-version</var>
4553 </example>
4554 If this fails, the old version is in an
4555 "Unpacked" state.
4556 </item>
4557 </enumlist>
4558 </p>
4561 This is the point of no return - if
4562 <prgn>dpkg</prgn> gets this far, it won't back off
4563 past this point if an error occurs. This will
4564 leave the package in a fairly bad state, which
4565 will require a successful re-installation to clear
4566 up, but it's when <prgn>dpkg</prgn> starts doing
4567 things that are irreversible.
4568 </p>
4569 </item>
4571 <item>
4572 Any files which were in the old version of the package
4573 but not in the new are removed.
4574 </item>
4576 <item>
4577 The new file list replaces the old.
4578 </item>
4580 <item>
4581 The new maintainer scripts replace the old.
4582 </item>
4584 <item>
4585 Any packages all of whose files have been overwritten
4586 during the installation, and which aren't required for
4587 dependencies, are considered to have been removed.
4588 For each such package
4589 <enumlist>
4590 <item>
4591 <prgn>dpkg</prgn> calls:
4592 <example compact="compact">
4593 <var>disappearer's-postrm</var> disappear \
4594 <var>overwriter</var> <var>overwriter-version</var>
4595 </example>
4596 </item>
4597 <item>
4598 The package's maintainer scripts are removed.
4599 </item>
4600 <item>
4601 It is noted in the status database as being in a
4602 sane state, namely "Not-Installed" (any conffiles
4603 it may have are ignored, rather than being
4604 removed by <prgn>dpkg</prgn>). Note that
4605 disappearing packages do not have their prerm
4606 called, because <prgn>dpkg</prgn> doesn't know
4607 in advance that the package is going to
4608 vanish.
4609 </item>
4610 </enumlist>
4611 </item>
4613 <item>
4614 Any files in the package we're unpacking that are also
4615 listed in the file lists of other packages are removed
4616 from those lists. (This will lobotomize the file list
4617 of the "conflicting" package if there is one.)
4618 </item>
4620 <item>
4621 The backup files made during installation, above, are
4622 deleted.
4623 </item>
4625 <item>
4627 The new package's status is now sane, and recorded as
4628 "Unpacked".
4629 </p>
4632 Here is another point of no return - if the
4633 conflicting package's removal fails we do not unwind
4634 the rest of the installation; the conflicting package
4635 is left in a half-removed limbo.
4636 </p>
4637 </item>
4639 <item>
4640 If there was a conflicting package we go and do the
4641 removal actions (described below), starting with the
4642 removal of the conflicting package's files (any that
4643 are also in the package being unpacked have already
4644 been removed from the conflicting package's file list,
4645 and so do not get removed now).
4646 </item>
4647 </enumlist>
4648 </p>
4649 </sect>
4651 <sect id="configdetails"><heading>Details of configuration</heading>
4654 When we configure a package (this happens with <tt>dpkg
4655 --install</tt> and <tt>dpkg --configure</tt>), we first
4656 update any <tt>conffile</tt>s and then call:
4657 <example compact="compact">
4658 <var>postinst</var> configure <var>most-recently-configured-version</var>
4659 </example>
4660 </p>
4663 No attempt is made to unwind after errors during
4664 configuration. If the configuration fails, the package is in
4665 a "Half-Configured" state, and an error message is generated.
4666 </p>
4669 If there is no most recently configured version
4670 <prgn>dpkg</prgn> will pass a null argument.
4671 <footnote>
4673 Historical note: Truly ancient (pre-1997) versions of
4674 <prgn>dpkg</prgn> passed <tt>&lt;unknown&gt;</tt>
4675 (including the angle brackets) in this case. Even older
4676 ones did not pass a second argument at all, under any
4677 circumstance. Note that upgrades using such an old dpkg
4678 version are unlikely to work for other reasons, even if
4679 this old argument behavior is handled by your postinst script.
4680 </p>
4681 </footnote>
4682 </p>
4683 </sect>
4685 <sect id="removedetails"><heading>Details of removal and/or
4686 configuration purging</heading>
4689 <enumlist>
4690 <item>
4692 <example compact="compact">
4693 <var>prerm</var> remove
4694 </example>
4695 </p>
4697 If prerm fails during replacement due to conflict
4698 <example>
4699 <var>conflictor's-postinst</var> abort-remove \
4700 in-favour <var>package</var> <var>new-version</var>
4701 </example>
4702 Or else we call:
4703 <example>
4704 <var>postinst</var> abort-remove
4705 </example>
4706 </p>
4708 If this fails, the package is in a "Half-Configured"
4709 state, or else it remains "Installed".
4710 </p>
4711 </item>
4712 <item>
4713 The package's files are removed (except <tt>conffile</tt>s).
4714 </item>
4715 <item>
4716 <example compact="compact">
4717 <var>postrm</var> remove
4718 </example>
4721 If it fails, there's no error unwind, and the package is in
4722 an "Half-Installed" state.
4723 </p>
4724 </item>
4725 <item>
4727 All the maintainer scripts except the <prgn>postrm</prgn>
4728 are removed.
4729 </p>
4732 If we aren't purging the package we stop here. Note
4733 that packages which have no <prgn>postrm</prgn> and no
4734 <tt>conffile</tt>s are automatically purged when
4735 removed, as there is no difference except for the
4736 <prgn>dpkg</prgn> status.
4737 </p>
4738 </item>
4739 <item>
4740 The <tt>conffile</tt>s and any backup files
4741 (<tt>~</tt>-files, <tt>#*#</tt> files,
4742 <tt>%</tt>-files, <tt>.dpkg-{old,new,tmp}</tt>, etc.)
4743 are removed.
4744 </item>
4745 <item>
4747 <example compact="compact">
4748 <var>postrm</var> purge
4749 </example>
4750 </p>
4752 If this fails, the package remains in a "Config-Files"
4753 state.
4754 </p>
4755 </item>
4756 <item>
4757 The package's file list is removed.
4758 </item>
4759 </enumlist>
4761 </p>
4762 </sect>
4763 </chapt>
4766 <chapt id="relationships">
4767 <heading>Declaring relationships between packages</heading>
4769 <sect id="depsyntax">
4770 <heading>Syntax of relationship fields</heading>
4773 These fields all have a uniform syntax. They are a list of
4774 package names separated by commas.
4775 </p>
4778 In the <tt>Depends</tt>, <tt>Recommends</tt>,
4779 <tt>Suggests</tt>, <tt>Pre-Depends</tt>,
4780 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt> and
4781 <tt>Build-Depends-Arch</tt>
4782 control fields of the package, which declare
4783 dependencies on other packages, the package names listed may
4784 also include lists of alternative package names, separated
4785 by vertical bar (pipe) symbols <tt>|</tt>. In such a case,
4786 that part of the dependency can be satisfied by any one of
4787 the alternative packages.
4788 </p>
4791 All of the fields except for <tt>Provides</tt> may restrict
4792 their applicability to particular versions of each named
4793 package. This is done in parentheses after each individual
4794 package name; the parentheses should contain a relation from
4795 the list below followed by a version number, in the format
4796 described in <ref id="f-Version">.
4797 </p>
4800 The relations allowed are <tt>&lt;&lt;</tt>, <tt>&lt;=</tt>,
4801 <tt>=</tt>, <tt>&gt;=</tt> and <tt>&gt;&gt;</tt> for strictly
4802 earlier, earlier or equal, exactly equal, later or equal and
4803 strictly later, respectively.<footnote>
4804 The relations <tt>&lt;</tt> and <tt>&gt;</tt> were previously
4805 allowed, but they were confusingly defined to mean
4806 earlier/later or equal rather than strictly
4807 earlier/later. <prgn>dpkg</prgn> still supports them with a
4808 warning, but they are no longer allowed by Debian Policy.
4809 </footnote>
4810 </p>
4813 Whitespace may appear at any point in the version
4814 specification subject to the rules in <ref
4815 id="controlsyntax">, and must appear where it's necessary to
4816 disambiguate; it is not otherwise significant. All of the
4817 relationship fields can only be folded in source package control files. For
4818 consistency and in case of future changes to
4819 <prgn>dpkg</prgn> it is recommended that a single space be
4820 used after a version relationship and before a version
4821 number; it is also conventional to put a single space after
4822 each comma, on either side of each vertical bar, and before
4823 each open parenthesis. When opening a continuation line in a relationship field, it
4824 is conventional to do so after a comma and before the space
4825 following that comma.
4826 </p>
4829 For example, a list of dependencies might appear as:
4830 <example compact="compact">
4831 Package: mutt
4832 Version: 1.3.17-1
4833 Depends: libc6 (&gt;= 2.2.1), exim | mail-transport-agent
4834 </example>
4835 </p>
4838 Relationships may be restricted to a certain set of
4839 architectures. This is indicated in brackets after each
4840 individual package name and the optional version specification.
4841 The brackets enclose a non-empty list of Debian architecture names
4842 in the format described in <ref id="arch-spec">,
4843 separated by whitespace. Exclamation marks may be prepended to
4844 each of the names. (It is not permitted for some names to be
4845 prepended with exclamation marks while others aren't.)
4846 </p>
4849 For build relationship fields
4850 (<tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
4851 <tt>Build-Depends-Arch</tt>, <tt>Build-Conflicts</tt>,
4852 <tt>Build-Conflicts-Indep</tt> and <tt>Build-Conflicts-Arch</tt>), if
4853 the current Debian host architecture is not in this list and
4854 there are no exclamation marks in the list, or it is in the list
4855 with a prepended exclamation mark, the package name and the
4856 associated version specification are ignored completely for the
4857 purposes of defining the relationships.
4858 </p>
4861 For example:
4862 <example compact="compact">
4863 Source: glibc
4864 Build-Depends-Indep: texinfo
4865 Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
4866 hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
4867 </example>
4868 requires <tt>kernel-headers-2.2.10</tt> on all architectures
4869 other than hurd-i386 and requires <tt>hurd-dev</tt> and
4870 <tt>gnumach-dev</tt> only on hurd-i386. Here is another example
4871 showing multiple architectures separated by spaces:
4872 <example compact="compact">
4873 Build-Depends:
4874 libluajit5.1-dev [i386 amd64 kfreebsd-i386 armel armhf powerpc mips],
4875 liblua5.1-dev [hurd-i386 ia64 kfreebsd-amd64 s390x sparc],
4876 </example>
4877 </p>
4880 For binary relationship fields and the <tt>Built-Using</tt>
4881 field, the architecture restriction
4882 syntax is only supported in the source package control
4883 file <file>debian/control</file>. When the corresponding binary
4884 package control file is generated, the relationship will either
4885 be omitted or included without the architecture restriction
4886 based on the architecture of the binary package. This means
4887 that architecture restrictions must not be used in binary
4888 relationship fields for architecture-independent packages
4889 (<tt>Architecture: all</tt>).
4890 </p>
4893 For example:
4894 <example compact="compact">
4895 Depends: foo [i386], bar [amd64]
4896 </example>
4897 becomes <tt>Depends: foo</tt> when the package is built on
4898 the <tt>i386</tt> architecture, <tt>Depends: bar</tt> when the
4899 package is built on the <tt>amd64</tt> architecture, and omitted
4900 entirely in binary packages built on all other architectures.
4901 </p>
4904 If the architecture-restricted dependency is part of a set of
4905 alternatives using <tt>|</tt>, that alternative is ignored
4906 completely on architectures that do not match the restriction.
4907 For example:
4908 <example compact="compact">
4909 Build-Depends: foo [!i386] | bar [!amd64]
4910 </example>
4911 is equivalent to <tt>bar</tt> on the i386 architecture, to
4912 <tt>foo</tt> on the amd64 architecture, and to <tt>foo |
4913 bar</tt> on all other architectures.
4914 </p>
4917 Relationships may also be restricted to a certain set of
4918 architectures using architecture wildcards in the format
4919 described in <ref id="arch-wildcard-spec">. The syntax for
4920 declaring such restrictions is the same as declaring
4921 restrictions using a certain set of architectures without
4922 architecture wildcards. For example:
4923 <example compact="compact">
4924 Build-Depends: foo [linux-any], bar [any-i386], baz [!linux-any]
4925 </example>
4926 is equivalent to <tt>foo</tt> on architectures using the Linux
4927 kernel and any cpu, <tt>bar</tt> on architectures using any
4928 kernel and an i386 cpu, and <tt>baz</tt> on any architecture
4929 using a kernel other than Linux.
4930 </p>
4933 Note that the binary package relationship fields such as
4934 <tt>Depends</tt> appear in one of the binary package
4935 sections of the control file, whereas the build-time
4936 relationships such as <tt>Build-Depends</tt> appear in the
4937 source package section of the control file (which is the
4938 first section).
4939 </p>
4940 </sect>
4942 <sect id="binarydeps">
4943 <heading>Binary Dependencies - <tt>Depends</tt>,
4944 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
4945 <tt>Pre-Depends</tt>
4946 </heading>
4949 Packages can declare in their control file that they have
4950 certain relationships to other packages - for example, that
4951 they may not be installed at the same time as certain other
4952 packages, and/or that they depend on the presence of others.
4953 </p>
4956 This is done using the <tt>Depends</tt>, <tt>Pre-Depends</tt>,
4957 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
4958 <tt>Breaks</tt> and <tt>Conflicts</tt> control fields.
4959 <tt>Breaks</tt> is described in <ref id="breaks">, and
4960 <tt>Conflicts</tt> is described in <ref id="conflicts">. The
4961 rest are described below.
4962 </p>
4965 These seven fields are used to declare a dependency
4966 relationship by one package on another. Except for
4967 <tt>Enhances</tt> and <tt>Breaks</tt>, they appear in the
4968 depending (binary) package's control file.
4969 (<tt>Enhances</tt> appears in the recommending package's
4970 control file, and <tt>Breaks</tt> appears in the version of
4971 depended-on package which causes the named package to
4972 break).
4973 </p>
4976 A <tt>Depends</tt> field takes effect <em>only</em> when a
4977 package is to be configured. It does not prevent a package
4978 being on the system in an unconfigured state while its
4979 dependencies are unsatisfied, and it is possible to replace
4980 a package whose dependencies are satisfied and which is
4981 properly installed with a different version whose
4982 dependencies are not and cannot be satisfied; when this is
4983 done the depending package will be left unconfigured (since
4984 attempts to configure it will give errors) and will not
4985 function properly. If it is necessary, a
4986 <tt>Pre-Depends</tt> field can be used, which has a partial
4987 effect even when a package is being unpacked, as explained
4988 in detail below. (The other three dependency fields,
4989 <tt>Recommends</tt>, <tt>Suggests</tt> and
4990 <tt>Enhances</tt>, are only used by the various front-ends
4991 to <prgn>dpkg</prgn> such as <prgn>apt-get</prgn>,
4992 <prgn>aptitude</prgn>, and <prgn>dselect</prgn>.)
4993 </p>
4996 Since <tt>Depends</tt> only places requirements on the order in
4997 which packages are configured, packages in an installation run
4998 are usually all unpacked first and all configured later.
4999 <footnote>
5000 This approach makes dependency resolution easier. If two
5001 packages A and B are being upgraded, the installed package A
5002 depends on exactly the installed package B, and the new
5003 package A depends on exactly the new package B (a common
5004 situation when upgrading shared libraries and their
5005 corresponding development packages), satisfying the
5006 dependencies at every stage of the upgrade would be
5007 impossible. This relaxed restriction means that both new
5008 packages can be unpacked together and then configured in their
5009 dependency order.
5010 </footnote>
5011 </p>
5014 If there is a circular dependency among packages being installed
5015 or removed, installation or removal order honoring the
5016 dependency order is impossible, requiring the dependency loop be
5017 broken at some point and the dependency requirements violated
5018 for at least one package. Packages involved in circular
5019 dependencies may not be able to rely on their dependencies being
5020 configured before they themselves are configured, depending on
5021 which side of the break of the circular dependency loop they
5022 happen to be on. If one of the packages in the loop has
5023 no <prgn>postinst</prgn> script, then the cycle will be broken
5024 at that package; this ensures that all <prgn>postinst</prgn>
5025 scripts are run with their dependencies properly configured if
5026 this is possible. Otherwise the breaking point is arbitrary.
5027 Packages should therefore avoid circular dependencies where
5028 possible, particularly if they have <prgn>postinst</prgn>
5029 scripts.
5030 </p>
5033 The meaning of the five dependency fields is as follows:
5034 <taglist>
5035 <tag><tt>Depends</tt></tag>
5036 <item>
5038 This declares an absolute dependency. A package will
5039 not be configured unless all of the packages listed in
5040 its <tt>Depends</tt> field have been correctly
5041 configured (unless there is a circular dependency as
5042 described above).
5043 </p>
5046 The <tt>Depends</tt> field should be used if the
5047 depended-on package is required for the depending
5048 package to provide a significant amount of
5049 functionality.
5050 </p>
5053 The <tt>Depends</tt> field should also be used if the
5054 <prgn>postinst</prgn> or <prgn>prerm</prgn> scripts
5055 require the depended-on package to be unpacked or
5056 configured in order to run. In the case of <tt>postinst
5057 configure</tt>, the depended-on packages will be unpacked
5058 and configured first. (If both packages are involved in a
5059 dependency loop, this might not work as expected; see the
5060 explanation a few paragraphs back.) In the case
5061 of <prgn>prerm</prgn> or other <prgn>postinst</prgn>
5062 actions, the package dependencies will normally be at
5063 least unpacked, but they may be only "Half-Installed" if a
5064 previous upgrade of the dependency failed.
5065 </p>
5068 Finally, the <tt>Depends</tt> field should be used if the
5069 depended-on package is needed by the <prgn>postrm</prgn>
5070 script to fully clean up after the package removal. There
5071 is no guarantee that package dependencies will be
5072 available when <prgn>postrm</prgn> is run, but the
5073 depended-on package is more likely to be available if the
5074 package declares a dependency (particularly in the case
5075 of <tt>postrm remove</tt>). The <prgn>postrm</prgn>
5076 script must gracefully skip actions that require a
5077 dependency if that dependency isn't available.
5078 </p>
5079 </item>
5081 <tag><tt>Recommends</tt></tag>
5082 <item>
5084 This declares a strong, but not absolute, dependency.
5085 </p>
5088 The <tt>Recommends</tt> field should list packages
5089 that would be found together with this one in all but
5090 unusual installations.
5091 </p>
5092 </item>
5094 <tag><tt>Suggests</tt></tag>
5095 <item>
5096 This is used to declare that one package may be more
5097 useful with one or more others. Using this field
5098 tells the packaging system and the user that the
5099 listed packages are related to this one and can
5100 perhaps enhance its usefulness, but that installing
5101 this one without them is perfectly reasonable.
5102 </item>
5104 <tag><tt>Enhances</tt></tag>
5105 <item>
5106 This field is similar to Suggests but works in the
5107 opposite direction. It is used to declare that a
5108 package can enhance the functionality of another
5109 package.
5110 </item>
5112 <tag><tt>Pre-Depends</tt></tag>
5113 <item>
5115 This field is like <tt>Depends</tt>, except that it
5116 also forces <prgn>dpkg</prgn> to complete installation
5117 of the packages named before even starting the
5118 installation of the package which declares the
5119 pre-dependency, as follows:
5120 </p>
5123 When a package declaring a pre-dependency is about to
5124 be <em>unpacked</em> the pre-dependency can be
5125 satisfied if the depended-on package is either fully
5126 configured, <em>or even if</em> the depended-on
5127 package(s) are only in the "Unpacked" or the "Half-Configured"
5128 state, provided that they have been configured
5129 correctly at some point in the past (and not removed
5130 or partially removed since). In this case, both the
5131 previously-configured and currently "Unpacked" or
5132 "Half-Configured" versions must satisfy any version
5133 clause in the <tt>Pre-Depends</tt> field.
5134 </p>
5137 When the package declaring a pre-dependency is about to
5138 be <em>configured</em>, the pre-dependency will be treated
5139 as a normal <tt>Depends</tt>. It will be considered
5140 satisfied only if the depended-on package has been
5141 correctly configured. However, unlike
5142 with <tt>Depends</tt>, <tt>Pre-Depends</tt> does not
5143 permit circular dependencies to be broken. If a circular
5144 dependency is encountered while attempting to honor
5145 <tt>Pre-Depends</tt>, the installation will be aborted.
5146 </p>
5149 <tt>Pre-Depends</tt> are also required if the
5150 <prgn>preinst</prgn> script depends on the named package.
5151 It is best to avoid this situation if possible.
5152 </p>
5155 <tt>Pre-Depends</tt> should be used sparingly,
5156 preferably only by packages whose premature upgrade or
5157 installation would hamper the ability of the system to
5158 continue with any upgrade that might be in progress.
5159 </p>
5162 You should not specify a <tt>Pre-Depends</tt> entry for a
5163 package before this has been discussed on the
5164 <tt>debian-devel</tt> mailing list and a consensus about
5165 doing that has been reached. See <ref id="dependencies">.
5166 </p>
5167 </item>
5168 </taglist>
5169 </p>
5172 When selecting which level of dependency to use you should
5173 consider how important the depended-on package is to the
5174 functionality of the one declaring the dependency. Some
5175 packages are composed of components of varying degrees of
5176 importance. Such a package should list using
5177 <tt>Depends</tt> the package(s) which are required by the
5178 more important components. The other components'
5179 requirements may be mentioned as Suggestions or
5180 Recommendations, as appropriate to the components' relative
5181 importance.
5182 </p>
5183 </sect>
5185 <sect id="breaks">
5186 <heading>Packages which break other packages - <tt>Breaks</tt></heading>
5189 When one binary package declares that it breaks another,
5190 <prgn>dpkg</prgn> will refuse to allow the package which
5191 declares <tt>Breaks</tt> to be unpacked unless the broken
5192 package is deconfigured first, and it will refuse to
5193 allow the broken package to be reconfigured.
5194 </p>
5197 A package will not be regarded as causing breakage merely
5198 because its configuration files are still installed; it must
5199 be at least "Half-Installed".
5200 </p>
5203 A special exception is made for packages which declare that
5204 they break their own package name or a virtual package which
5205 they provide (see below): this does not count as a real
5206 breakage.
5207 </p>
5210 Normally a <tt>Breaks</tt> entry will have an "earlier than"
5211 version clause; such a <tt>Breaks</tt> is introduced in the
5212 version of an (implicit or explicit) dependency which violates
5213 an assumption or reveals a bug in earlier versions of the broken
5214 package, or which takes over a file from earlier versions of the
5215 package named in <tt>Breaks</tt>. This use of <tt>Breaks</tt>
5216 will inform higher-level package management tools that the
5217 broken package must be upgraded before the new one.
5218 </p>
5221 If the breaking package also overwrites some files from the
5222 older package, it should use <tt>Replaces</tt> to ensure this
5223 goes smoothly. See <ref id="replaces"> for a full discussion
5224 of taking over files from other packages, including how to
5225 use <tt>Breaks</tt> in those cases.
5226 </p>
5229 Many of the cases where <tt>Breaks</tt> should be used were
5230 previously handled with <tt>Conflicts</tt>
5231 because <tt>Breaks</tt> did not yet exist.
5232 Many <tt>Conflicts</tt> fields should now be <tt>Breaks</tt>.
5233 See <ref id="conflicts"> for more information about the
5234 differences.
5235 </p>
5236 </sect>
5238 <sect id="conflicts">
5239 <heading>Conflicting binary packages - <tt>Conflicts</tt></heading>
5242 When one binary package declares a conflict with another using
5243 a <tt>Conflicts</tt> field, <prgn>dpkg</prgn> will refuse to
5244 allow them to be unpacked on the system at the same time. This
5245 is a stronger restriction than <tt>Breaks</tt>, which prevents
5246 the broken package from being configured while the breaking
5247 package is in the "Unpacked" state but allows both packages to
5248 be unpacked at the same time.
5249 </p>
5252 If one package is to be unpacked, the other must be removed
5253 first. If the package being unpacked is marked as replacing
5254 (see <ref id="replaces">, but note that <tt>Breaks</tt> should
5255 normally be used in this case) the one on the system, or the one
5256 on the system is marked as deselected, or both packages are
5257 marked <tt>Essential</tt>, then <prgn>dpkg</prgn> will
5258 automatically remove the package which is causing the conflict.
5259 Otherwise, it will halt the installation of the new package with
5260 an error. This mechanism is specifically designed to produce an
5261 error when the installed package is <tt>Essential</tt>, but the
5262 new package is not.
5263 </p>
5266 A package will not cause a conflict merely because its
5267 configuration files are still installed; it must be at least
5268 "Half-Installed".
5269 </p>
5272 A special exception is made for packages which declare a
5273 conflict with their own package name, or with a virtual
5274 package which they provide (see below): this does not
5275 prevent their installation, and allows a package to conflict
5276 with others providing a replacement for it. You use this
5277 feature when you want the package in question to be the only
5278 package providing some feature.
5279 </p>
5282 Normally, <tt>Breaks</tt> should be used instead
5283 of <tt>Conflicts</tt> since <tt>Conflicts</tt> imposes a
5284 stronger restriction on the ordering of package installation or
5285 upgrade and can make it more difficult for the package manager
5286 to find a correct solution to an upgrade or installation
5287 problem. <tt>Breaks</tt> should be used
5288 <list>
5289 <item>when moving a file from one package to another (see
5290 <ref id="replaces">),</item>
5291 <item>when splitting a package (a special case of the previous
5292 one), or</item>
5293 <item>when the breaking package exposes a bug in or interacts
5294 badly with particular versions of the broken
5295 package.</item>
5296 </list>
5297 <tt>Conflicts</tt> should be used
5298 <list>
5299 <item>when two packages provide the same file and will
5300 continue to do so,</item>
5301 <item>in conjunction with <tt>Provides</tt> when only one
5302 package providing a given virtual facility may be unpacked
5303 at a time (see <ref id="virtual">),</item>
5304 <item>in other cases where one must prevent simultaneous
5305 installation of two packages for reasons that are ongoing
5306 (not fixed in a later version of one of the packages) or
5307 that must prevent both packages from being unpacked at the
5308 same time, not just configured.</item>
5309 </list>
5310 Be aware that adding <tt>Conflicts</tt> is normally not the best
5311 solution when two packages provide the same files. Depending on
5312 the reason for that conflict, using alternatives or renaming the
5313 files is often a better approach. See, for
5314 example, <ref id="binaries">.
5315 </p>
5318 Neither <tt>Breaks</tt> nor <tt>Conflicts</tt> should be used
5319 unless two packages cannot be installed at the same time or
5320 installing them both causes one of them to be broken or
5321 unusable. Having similar functionality or performing the same
5322 tasks as another package is not sufficient reason to
5323 declare <tt>Breaks</tt> or <tt>Conflicts</tt> with that package.
5324 </p>
5327 A <tt>Conflicts</tt> entry may have an "earlier than" version
5328 clause if the reason for the conflict is corrected in a later
5329 version of one of the packages. However, normally the presence
5330 of an "earlier than" version clause is a sign
5331 that <tt>Breaks</tt> should have been used instead. An "earlier
5332 than" version clause in <tt>Conflicts</tt>
5333 prevents <prgn>dpkg</prgn> from upgrading or installing the
5334 package which declares such a conflict until the upgrade or
5335 removal of the conflicted-with package has been completed, which
5336 is a strong restriction.
5337 </p>
5338 </sect>
5340 <sect id="virtual"><heading>Virtual packages - <tt>Provides</tt>
5341 </heading>
5344 As well as the names of actual ("concrete") packages, the
5345 package relationship fields <tt>Depends</tt>,
5346 <tt>Recommends</tt>, <tt>Suggests</tt>, <tt>Enhances</tt>,
5347 <tt>Pre-Depends</tt>, <tt>Breaks</tt>, <tt>Conflicts</tt>,
5348 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
5349 <tt>Build-Depends-Arch</tt>, <tt>Build-Conflicts</tt>,
5350 <tt>Build-Conflicts-Indep</tt> and <tt>Build-Conflicts-Arch</tt>
5351 may mention "virtual packages".
5352 </p>
5355 A <em>virtual package</em> is one which appears in the
5356 <tt>Provides</tt> control field of another package. The effect
5357 is as if the package(s) which provide a particular virtual
5358 package name had been listed by name everywhere the virtual
5359 package name appears. (See also <ref id="virtual_pkg">)
5360 </p>
5363 If there are both concrete and virtual packages of the same
5364 name, then the dependency may be satisfied (or the conflict
5365 caused) by either the concrete package with the name in
5366 question or any other concrete package which provides the
5367 virtual package with the name in question. This is so that,
5368 for example, supposing we have
5369 <example compact="compact">
5370 Package: foo
5371 Depends: bar
5372 </example> and someone else releases an enhanced version of
5373 the <tt>bar</tt> package they can say:
5374 <example compact="compact">
5375 Package: bar-plus
5376 Provides: bar
5377 </example>
5378 and the <tt>bar-plus</tt> package will now also satisfy the
5379 dependency for the <tt>foo</tt> package.
5380 </p>
5383 If a relationship field has a version number attached, only real
5384 packages will be considered to see whether the relationship is
5385 satisfied (or the prohibition violated, for a conflict or
5386 breakage). In other words, if a version number is specified,
5387 this is a request to ignore all <tt>Provides</tt> for that
5388 package name and consider only real packages. The package
5389 manager will assume that a package providing that virtual
5390 package is not of the "right" version. A <tt>Provides</tt>
5391 field may not contain version numbers, and the version number of
5392 the concrete package which provides a particular virtual package
5393 will not be considered when considering a dependency on or
5394 conflict with the virtual package name.<footnote>
5395 It is possible that a future release of <prgn>dpkg</prgn> may
5396 add the ability to specify a version number for each virtual
5397 package it provides. This feature is not yet present,
5398 however, and is expected to be used only infrequently.
5399 </footnote>
5400 </p>
5403 To specify which of a set of real packages should be the default
5404 to satisfy a particular dependency on a virtual package, list
5405 the real package as an alternative before the virtual one.
5406 </p>
5409 If the virtual package represents a facility that can only be
5410 provided by one real package at a time, such as
5411 the <package>mail-transport-agent</package> virtual package that
5412 requires installation of a binary that would conflict with all
5413 other providers of that virtual package (see
5414 <ref id="mail-transport-agents">), all packages providing that
5415 virtual package should also declare a conflict with it
5416 using <tt>Conflicts</tt>. This will ensure that at most one
5417 provider of that virtual package is unpacked or installed at a
5418 time.
5419 </p>
5420 </sect>
5422 <sect id="replaces"><heading>Overwriting files and replacing
5423 packages - <tt>Replaces</tt></heading>
5426 Packages can declare in their control file that they should
5427 overwrite files in certain other packages, or completely replace
5428 other packages. The <tt>Replaces</tt> control field has these
5429 two distinct purposes.
5430 </p>
5432 <sect1><heading>Overwriting files in other packages</heading>
5435 It is usually an error for a package to contain files which
5436 are on the system in another package. However, if the
5437 overwriting package declares that it <tt>Replaces</tt> the one
5438 containing the file being overwritten, then <prgn>dpkg</prgn>
5439 will replace the file from the old package with that from the
5440 new. The file will no longer be listed as "owned" by the old
5441 package and will be taken over by the new package.
5442 Normally, <tt>Breaks</tt> should be used in conjunction
5443 with <tt>Replaces</tt>.<footnote>
5444 To see why <tt>Breaks</tt> is normally needed in addition
5445 to <tt>Replaces</tt>, consider the case of a file in the
5446 package <package>foo</package> being taken over by the
5447 package <package>foo-data</package>.
5448 <tt>Replaces</tt> will allow <package>foo-data</package> to
5449 be installed and take over that file. However,
5450 without <tt>Breaks</tt>, nothing
5451 requires <package>foo</package> to be upgraded to a newer
5452 version that knows it does not include that file and instead
5453 depends on <package>foo-data</package>. Nothing would
5454 prevent the new <package>foo-data</package> package from
5455 being installed and then removed, removing the file that it
5456 took over from <package>foo</package>. After that
5457 operation, the package manager would think the system was in
5458 a consistent state, but the <package>foo</package> package
5459 would be missing one of its files.
5460 </footnote>
5461 </p>
5464 For example, if a package <package>foo</package> is split
5465 into <package>foo</package> and <package>foo-data</package>
5466 starting at version 1.2-3, <package>foo-data</package> would
5467 have the fields
5468 <example compact="compact">
5469 Replaces: foo (&lt;&lt; 1.2-3)
5470 Breaks: foo (&lt;&lt; 1.2-3)
5471 </example>
5472 in its control file. The new version of the
5473 package <package>foo</package> would normally have the field
5474 <example compact="compact">
5475 Depends: foo-data (&gt;= 1.2-3)
5476 </example>
5477 (or possibly <tt>Recommends</tt> or even <tt>Suggests</tt> if
5478 the files moved into <package>foo-data</package> are not
5479 required for normal operation).
5480 </p>
5483 If a package is completely replaced in this way, so that
5484 <prgn>dpkg</prgn> does not know of any files it still
5485 contains, it is considered to have "disappeared". It will
5486 be marked as not wanted on the system (selected for
5487 removal) and "Not-Installed". Any <tt>conffile</tt>s
5488 details noted for the package will be ignored, as they
5489 will have been taken over by the overwriting package. The
5490 package's <prgn>postrm</prgn> script will be run with a
5491 special argument to allow the package to do any final
5492 cleanup required. See <ref id="mscriptsinstact">.
5493 <footnote>
5494 Replaces is a one way relationship. You have to install
5495 the replacing package after the replaced package.
5496 </footnote>
5497 </p>
5500 For this usage of <tt>Replaces</tt>, virtual packages (see
5501 <ref id="virtual">) are not considered when looking at a
5502 <tt>Replaces</tt> field. The packages declared as being
5503 replaced must be mentioned by their real names.
5504 </p>
5507 This usage of <tt>Replaces</tt> only takes effect when both
5508 packages are at least partially on the system at once. It is
5509 not relevant if the packages conflict unless the conflict has
5510 been overridden.
5511 </p>
5512 </sect1>
5514 <sect1><heading>Replacing whole packages, forcing their
5515 removal</heading>
5518 Second, <tt>Replaces</tt> allows the packaging system to
5519 resolve which package should be removed when there is a
5520 conflict (see <ref id="conflicts">). This usage only takes
5521 effect when the two packages <em>do</em> conflict, so that the
5522 two usages of this field do not interfere with each other.
5523 </p>
5526 In this situation, the package declared as being replaced
5527 can be a virtual package, so for example, all mail
5528 transport agents (MTAs) would have the following fields in
5529 their control files:
5530 <example compact="compact">
5531 Provides: mail-transport-agent
5532 Conflicts: mail-transport-agent
5533 Replaces: mail-transport-agent
5534 </example>
5535 ensuring that only one MTA can be unpacked at any one
5536 time. See <ref id="virtual"> for more information about this
5537 example.
5538 </sect1>
5539 </sect>
5541 <sect id="sourcebinarydeps">
5542 <heading>Relationships between source and binary packages -
5543 <tt>Build-Depends</tt>, <tt>Build-Depends-Indep</tt>,
5544 <tt>Build-Depends-Arch</tt>, <tt>Build-Conflicts</tt>,
5545 <tt>Build-Conflicts-Indep</tt>, <tt>Build-Conflicts-Arch</tt>
5546 </heading>
5549 Source packages that require certain binary packages to be
5550 installed or absent at the time of building the package
5551 can declare relationships to those binary packages.
5552 </p>
5555 This is done using the <tt>Build-Depends</tt>,
5556 <tt>Build-Depends-Indep</tt>, <tt>Build-Depends-Arch</tt>,
5557 <tt>Build-Conflicts</tt>, <tt>Build-Conflicts-Indep</tt> and
5558 <tt>Build-Conflicts-Arch</tt> control fields.
5559 </p>
5562 Build-dependencies on "build-essential" binary packages can be
5563 omitted. Please see <ref id="pkg-relations"> for more information.
5564 </p>
5567 The dependencies and conflicts they define must be satisfied
5568 (as defined earlier for binary packages) in order to invoke
5569 the targets in <tt>debian/rules</tt>, as follows:
5570 <taglist>
5571 <tag><tt>clean</tt></tag>
5572 <item>
5573 Only the <tt>Build-Depends</tt> and <tt>Build-Conflicts</tt>
5574 fields must be satisfied when this target is invoked.
5575 </item>
5576 <tag><tt>build-arch</tt>, and <tt>binary-arch</tt></tag>
5577 <item>
5578 The <tt>Build-Depends</tt>, <tt>Build-Conflicts</tt>,
5579 <tt>Build-Depends-Arch</tt>, and <tt>Build-Conflicts-Arch</tt>
5580 fields must be satisfied when these targets are invoked.
5581 </item>
5582 <tag><tt>build-indep</tt>, and <tt>binary-indep</tt></tag>
5583 <item>
5584 The <tt>Build-Depends</tt>, <tt>Build-Conflicts</tt>,
5585 <tt>Build-Depends-Indep</tt>, and <tt>Build-Conflicts-Indep</tt>
5586 fields must be satisfied when these targets are invoked.
5587 </item>
5588 <tag><tt>build</tt> and <tt>binary</tt></tag>
5589 <item>
5590 The <tt>Build-Depends</tt>, <tt>Build-Conflicts</tt>,
5591 <tt>Build-Depends-Indep</tt>, <tt>Build-Conflicts-Indep</tt>,
5592 <tt>Build-Depends-Arch</tt>, and <tt>Build-Conflicts-Arch</tt>
5593 fields must be satisfied when these targets are invoked.
5594 </item>
5595 </taglist>
5596 </p>
5597 </sect>
5599 <sect id="built-using">
5600 <heading>Additional source packages used to build the binary
5601 - <tt>Built-Using</tt>
5602 </heading>
5605 Some binary packages incorporate parts of other packages when built
5606 but do not have to depend on those packages. Examples include
5607 linking with static libraries or incorporating source code from
5608 another package during the build. In this case, the source packages
5609 of those other packages are a required part of the complete source
5610 (the binary package is not reproducible without them).
5611 </p>
5614 A <tt>Built-Using</tt> field must list the corresponding source
5615 package for any such binary package incorporated during the build
5616 <footnote>
5617 <tt>Build-Depends</tt> in the source package is not adequate since
5618 it (rightfully) does not document the exact version used in the
5619 build.
5620 </footnote>,
5621 including an "exactly equal" ("=") version relation on the version
5622 that was used to build that binary package<footnote>
5623 The archive software might reject packages that refer to
5624 non-existent sources.
5625 </footnote>.
5626 </p>
5629 A package using the source code from the gcc-4.6-source
5630 binary package built from the gcc-4.6 source package would
5631 have this field in its control file:
5632 <example compact="compact">
5633 Built-Using: gcc-4.6 (= 4.6.0-11)
5634 </example>
5635 </p>
5638 A package including binaries from grub2 and loadlin would
5639 have this field in its control file:
5640 <example compact="compact">
5641 Built-Using: grub2 (= 1.99-9), loadlin (= 1.6e-1)
5642 </example>
5643 </p>
5644 </sect>
5645 </chapt>
5648 <chapt id="sharedlibs"><heading>Shared libraries</heading>
5651 Packages containing shared libraries must be constructed with
5652 a little care to make sure that the shared library is always
5653 available. This is especially important for packages whose
5654 shared libraries are vitally important, such as the C library
5655 (currently <tt>libc6</tt>).
5656 </p>
5659 This section deals only with public shared libraries: shared
5660 libraries that are placed in directories searched by the dynamic
5661 linker by default or which are intended to be linked against
5662 normally and possibly used by other, independent packages. Shared
5663 libraries that are internal to a particular package or that are
5664 only loaded as dynamic modules are not covered by this section and
5665 are not subject to its requirements.
5666 </p>
5669 A shared library is identified by the <tt>SONAME</tt> attribute
5670 stored in its dynamic section. When a binary is linked against a
5671 shared library, the <tt>SONAME</tt> of the shared library is
5672 recorded in the binary's <tt>NEEDED</tt> section so that the
5673 dynamic linker knows that library must be loaded at runtime. The
5674 shared library file's full name (which usually contains additional
5675 version information not needed in the <tt>SONAME</tt>) is
5676 therefore normally not referenced directly. Instead, the shared
5677 library is loaded by its <tt>SONAME</tt>, which exists on the file
5678 system as a symlink pointing to the full name of the shared
5679 library. This symlink must be provided by the
5680 package. <ref id="sharedlibs-runtime"> describes how to do this.
5681 <footnote>
5682 This is a convention of shared library versioning, but not a
5683 requirement. Some libraries use the <tt>SONAME</tt> as the full
5684 library file name instead and therefore do not need a symlink.
5685 Most, however, encode additional information about
5686 backwards-compatible revisions as a minor version number in the
5687 file name. The <tt>SONAME</tt> itself only changes when
5688 binaries linked with the earlier version of the shared library
5689 may no longer work, but the filename may change with each
5690 release of the library. See <ref id="sharedlibs-runtime"> for
5691 more information.
5692 </footnote>
5693 </p>
5696 When linking a binary or another shared library against a shared
5697 library, the <tt>SONAME</tt> for that shared library is not yet
5698 known. Instead, the shared library is found by looking for a file
5699 matching the library name with <tt>.so</tt> appended. This file
5700 exists on the file system as a symlink pointing to the shared
5701 library.
5702 </p>
5705 Shared libraries are normally split into several binary packages.
5706 The <tt>SONAME</tt> symlink is installed by the runtime shared
5707 library package, and the bare <tt>.so</tt> symlink is installed in
5708 the development package since it's only used when linking binaries
5709 or shared libraries. However, there are some exceptions for
5710 unusual shared libraries or for shared libraries that are also
5711 loaded as dynamic modules by other programs.
5712 </p>
5715 This section is primarily concerned with how the separation of
5716 shared libraries into multiple packages should be done and how
5717 dependencies on and between shared library binary packages are
5718 managed in Debian. <ref id="libraries"> should be read in
5719 conjunction with this section and contains additional rules for
5720 the files contained in the shared library packages.
5721 </p>
5723 <sect id="sharedlibs-runtime">
5724 <heading>Run-time shared libraries</heading>
5727 The run-time shared library must be placed in a package
5728 whose name changes whenever the <tt>SONAME</tt> of the shared
5729 library changes. This allows several versions of the shared
5730 library to be installed at the same time, allowing installation
5731 of the new version of the shared library without immediately
5732 breaking binaries that depend on the old version. Normally, the
5733 run-time shared library and its <tt>SONAME</tt> symlink should
5734 be placed in a package named
5735 <package><var>libraryname</var><var>soversion</var></package>,
5736 where <var>soversion</var> is the version number in
5737 the <tt>SONAME</tt> of the shared library. Alternatively, if it
5738 would be confusing to directly append <var>soversion</var>
5739 to <var>libraryname</var> (if, for
5740 example, <var>libraryname</var> itself ends in a number), you
5741 should use
5742 <package><var>libraryname</var>-<var>soversion</var></package>
5743 instead.
5744 </p>
5747 To determine the <var>soversion</var>, look at
5748 the <tt>SONAME</tt> of the library, stored in the
5749 ELF <tt>SONAME</tt> attribute. It is usually of the
5750 form <tt><var>name</var>.so.<var>major-version</var></tt> (for
5751 example, <tt>libz.so.1</tt>). The version part is the part
5752 which comes after <tt>.so.</tt>, so in that example it
5753 is <tt>1</tt>. The soname may instead be of the
5754 form <tt><var>name</var>-<var>major-version</var>.so</tt>, such
5755 as <tt>libdb-5.1.so</tt>, in which case the name would
5756 be <tt>libdb</tt> and the version would be <tt>5.1</tt>.
5757 </p>
5760 If you have several shared libraries built from the same source
5761 tree, you may lump them all together into a single shared
5762 library package provided that all of their <tt>SONAME</tt>s will
5763 always change together. Be aware that this is not normally the
5764 case, and if the <tt>SONAME</tt>s do not change together,
5765 upgrading such a merged shared library package will be
5766 unnecessarily difficult because of file conflicts with the old
5767 version of the package. When in doubt, always split shared
5768 library packages so that each binary package installs a single
5769 shared library.
5770 </p>
5773 Every time the shared library ABI changes in a way that may
5774 break binaries linked against older versions of the shared
5775 library, the <tt>SONAME</tt> of the library and the
5776 corresponding name for the binary package containing the runtime
5777 shared library should change. Normally, this means
5778 the <tt>SONAME</tt> should change any time an interface is
5779 removed from the shared library or the signature of an interface
5780 (the number of parameters or the types of parameters that it
5781 takes, for example) is changed. This practice is vital to
5782 allowing clean upgrades from older versions of the package and
5783 clean transitions between the old ABI and new ABI without having
5784 to upgrade every affected package simultaneously.
5785 </p>
5788 The <tt>SONAME</tt> and binary package name need not, and indeed
5789 normally should not, change if new interfaces are added but none
5790 are removed or changed, since this will not break binaries
5791 linked against the old shared library. Correct versioning of
5792 dependencies on the newer shared library by binaries that use
5793 the new interfaces is handled via
5794 the <qref id="sharedlibs-depends"><tt>symbols</tt>
5795 or <tt>shlibs</tt> system</qref>.
5796 </p>
5799 The package should install the shared libraries under
5800 their normal names. For example, the <package>libgdbm3</package>
5801 package should install <file>libgdbm.so.3.0.0</file> as
5802 <file>/usr/lib/libgdbm.so.3.0.0</file>. The files should not be
5803 renamed or re-linked by any <prgn>prerm</prgn> or
5804 <prgn>postrm</prgn> scripts; <prgn>dpkg</prgn> will take care
5805 of renaming things safely without affecting running programs,
5806 and attempts to interfere with this are likely to lead to
5807 problems.
5808 </p>
5811 Shared libraries should not be installed executable, since
5812 the dynamic linker does not require this and trying to
5813 execute a shared library usually results in a core dump.
5814 </p>
5817 The run-time library package should include the symbolic link for
5818 the <tt>SONAME</tt> that <prgn>ldconfig</prgn> would create for
5819 the shared libraries. For example,
5820 the <package>libgdbm3</package> package should include a symbolic
5821 link from <file>/usr/lib/libgdbm.so.3</file> to
5822 <file>libgdbm.so.3.0.0</file>. This is needed so that the dynamic
5823 linker (for example <prgn>ld.so</prgn> or
5824 <prgn>ld-linux.so.*</prgn>) can find the library between the
5825 time that <prgn>dpkg</prgn> installs it and the time that
5826 <prgn>ldconfig</prgn> is run in the <prgn>postinst</prgn>
5827 script.<footnote>
5828 The package management system requires the library to be
5829 placed before the symbolic link pointing to it in the
5830 <file>.deb</file> file. This is so that when
5831 <prgn>dpkg</prgn> comes to install the symlink
5832 (overwriting the previous symlink pointing at an older
5833 version of the library), the new shared library is already
5834 in place. In the past, this was achieved by creating the
5835 library in the temporary packaging directory before
5836 creating the symlink. Unfortunately, this was not always
5837 effective, since the building of the tar file in the
5838 <file>.deb</file> depended on the behavior of the underlying
5839 file system. Some file systems (such as reiserfs) reorder
5840 the files so that the order of creation is forgotten.
5841 Since version 1.7.0, <prgn>dpkg</prgn>
5842 reorders the files itself as necessary when building a
5843 package. Thus it is no longer important to concern
5844 oneself with the order of file creation.
5845 </footnote>
5846 </p>
5848 <sect1 id="ldconfig">
5849 <heading><tt>ldconfig</tt></heading>
5852 Any package installing shared libraries in one of the default
5853 library directories of the dynamic linker (which are currently
5854 <file>/usr/lib</file> and <file>/lib</file>) or a directory that is
5855 listed in <file>/etc/ld.so.conf</file><footnote>
5856 These are currently <file>/usr/local/lib</file> plus
5857 directories under <file>/lib</file> and <file>/usr/lib</file>
5858 matching the multiarch triplet for the system architecture.
5859 </footnote>
5860 must use <prgn>ldconfig</prgn> to update the shared library
5861 system.
5862 </p>
5865 The package maintainer scripts must only call
5866 <prgn>ldconfig</prgn> under these circumstances:
5867 <list compact="compact">
5868 <item>When the <prgn>postinst</prgn> script is run with a
5869 first argument of <tt>configure</tt>, the script must call
5870 <prgn>ldconfig</prgn>, and may optionally invoke
5871 <prgn>ldconfig</prgn> at other times.
5872 </item>
5873 <item>When the <prgn>postrm</prgn> script is run with a
5874 first argument of <tt>remove</tt>, the script should call
5875 <prgn>ldconfig</prgn>.
5876 </item>
5877 </list>
5878 <footnote>
5880 During install or upgrade, the preinst is called before
5881 the new files are unpacked, so calling "ldconfig" is
5882 pointless. The preinst of an existing package can also be
5883 called if an upgrade fails. However, this happens during
5884 the critical time when a shared libs may exist on-disk
5885 under a temporary name. Thus, it is dangerous and
5886 forbidden by current policy to call "ldconfig" at this
5887 time.
5888 </p>
5891 When a package is installed or upgraded, "postinst
5892 configure" runs after the new files are safely on-disk.
5893 Since it is perfectly safe to invoke ldconfig
5894 unconditionally in a postinst, it is OK for a package to
5895 simply put ldconfig in its postinst without checking the
5896 argument. The postinst can also be called to recover from
5897 a failed upgrade. This happens before any new files are
5898 unpacked, so there is no reason to call "ldconfig" at this
5899 point.
5900 </p>
5903 For a package that is being removed, prerm is
5904 called with all the files intact, so calling ldconfig is
5905 useless. The other calls to "prerm" happen in the case of
5906 upgrade at a time when all the files of the old package
5907 are on-disk, so again calling "ldconfig" is pointless.
5908 </p>
5911 postrm, on the other hand, is called with the "remove"
5912 argument just after the files are removed, so this is
5913 the proper time to call "ldconfig" to notify the system
5914 of the fact that the shared libraries from the package
5915 are removed. The postrm can be called at several other
5916 times. At the time of "postrm purge", "postrm
5917 abort-install", or "postrm abort-upgrade", calling
5918 "ldconfig" is useless because the shared lib files are
5919 not on-disk. However, when "postrm" is invoked with
5920 arguments "upgrade", "failed-upgrade", or "disappear", a
5921 shared lib may exist on-disk under a temporary filename.
5922 </p>
5923 </footnote>
5924 </p>
5925 </sect1>
5927 </sect>
5929 <sect id="sharedlibs-support-files">
5930 <heading>Shared library support files</heading>
5933 If your package contains files whose names do not change with
5934 each change in the library shared object version, you must not
5935 put them in the shared library package. Otherwise, several
5936 versions of the shared library cannot be installed at the same
5937 time without filename clashes, making upgrades and transitions
5938 unnecessarily difficult.
5939 </p>
5942 It is recommended that supporting files and run-time support
5943 programs that do not need to be invoked manually by users, but
5944 are nevertheless required for the package to function, be placed
5945 (if they are binary) in a subdirectory of <file>/usr/lib</file>,
5946 preferably under <file>/usr/lib/</file><var>package-name</var>.
5947 If the program or file is architecture independent, the
5948 recommendation is for it to be placed in a subdirectory of
5949 <file>/usr/share</file> instead, preferably under
5950 <file>/usr/share/</file><var>package-name</var>. Following the
5951 <var>package-name</var> naming convention ensures that the file
5952 names change when the shared object version changes.
5953 </p>
5956 Run-time support programs that use the shared library but are
5957 not required for the library to function or files used by the
5958 shared library that can be used by any version of the shared
5959 library package should instead be put in a separate package.
5960 This package might typically be named
5961 <package><var>libraryname</var>-tools</package>; note the
5962 absence of the <var>soversion</var> in the package name.
5963 </p>
5966 Files and support programs only useful when compiling software
5967 against the library should be included in the development
5968 package for the library.<footnote>
5969 For example, a <file><var>package-name</var>-config</file>
5970 script or <package>pkg-config</package> configuration files.
5971 </footnote>
5972 </p>
5973 </sect>
5975 <sect id="sharedlibs-static">
5976 <heading>Static libraries</heading>
5979 The static library (<file><var>libraryname.a</var></file>)
5980 is usually provided in addition to the shared version.
5981 It is placed into the development package (see below).
5982 </p>
5985 In some cases, it is acceptable for a library to be
5986 available in static form only; these cases include:
5987 <list>
5988 <item>libraries for languages whose shared library support
5989 is immature or unstable</item>
5990 <item>libraries whose interfaces are in flux or under
5991 development (commonly the case when the library's
5992 major version number is zero, or where the ABI breaks
5993 across patchlevels)</item>
5994 <item>libraries which are explicitly intended to be
5995 available only in static form by their upstream
5996 author(s)</item>
5997 </list>
5998 </p>
6000 <sect id="sharedlibs-dev">
6001 <heading>Development files</heading>
6004 If there are development files associated with a shared library,
6005 the source package needs to generate a binary development package
6006 named <package><var>libraryname</var>-dev</package>, or if you
6007 need to support multiple development versions at a
6008 time, <package><var>libraryname</var><var>apiversion</var>-dev</package>.
6009 Installing the development package must result in installation of
6010 all the development files necessary for compiling programs against
6011 that shared library.<footnote>
6012 This wording allows the development files to be split into
6013 several packages, such as a separate architecture-independent
6014 <package><var>libraryname</var>-headers</package>, provided that
6015 the development package depends on all the required additional
6016 packages.
6017 </footnote>
6018 </p>
6021 In case several development versions of a library exist, you may
6022 need to use <prgn>dpkg</prgn>'s Conflicts mechanism (see
6023 <ref id="conflicts">) to ensure that the user only installs one
6024 development version at a time (as different development versions are
6025 likely to have the same header files in them, which would cause a
6026 filename clash if both were unpacked).
6027 </p>
6030 The development package should contain a symlink for the associated
6031 shared library without a version number. For example, the
6032 <package>libgdbm-dev</package> package should include a symlink
6033 from <file>/usr/lib/libgdbm.so</file> to
6034 <file>libgdbm.so.3.0.0</file>. This symlink is needed by the linker
6035 (<prgn>ld</prgn>) when compiling packages, as it will only look for
6036 <file>libgdbm.so</file> when compiling dynamically.
6037 </p>
6040 If the package provides Ada Library Information
6041 (<file>*.ali</file>) files for use with GNAT, these files must be
6042 installed read-only (mode 0444) so that GNAT will not attempt to
6043 recompile them. This overrides the normal file mode requirements
6044 given in <ref id="permissions-owners">.
6045 </p>
6046 </sect>
6048 <sect id="sharedlibs-intradeps">
6049 <heading>Dependencies between the packages of the same library</heading>
6052 Typically the development version should have an exact
6053 version dependency on the runtime library, to make sure that
6054 compilation and linking happens correctly. The
6055 <tt>${binary:Version}</tt> substitution variable can be
6056 useful for this purpose.
6057 <footnote>
6058 Previously, <tt>${Source-Version}</tt> was used, but its name
6059 was confusing and it has been deprecated since dpkg 1.13.19.
6060 </footnote>
6061 </p>
6062 </sect>
6064 <sect id="sharedlibs-depends">
6065 <heading>Dependencies between the library and other
6066 packages</heading>
6069 If a package contains a binary or library which links to a
6070 shared library, we must ensure that, when the package is
6071 installed on the system, all of the libraries needed are also
6072 installed. These dependencies must be added to the binary
6073 package when it is built, since they may change based on which
6074 version of a shared library the binary or library was linked
6075 with even if there are no changes to the source of the binary
6076 (for example, symbol versions change, macros become functions or
6077 vice versa, or the binary package may determine at compile-time
6078 whether new library interfaces are available and can be called).
6079 To allow these dependencies to be constructed, shared libraries
6080 must provide either a <file>symbols</file> file or
6081 a <file>shlibs</file> file. These provide information on the
6082 package dependencies required to ensure the presence of
6083 interfaces provided by this library. Any package with binaries
6084 or libraries linking to a shared library must use these files to
6085 determine the required dependencies when it is built. Other
6086 packages which use a shared library (for example using
6087 <tt>dlopen()</tt>) should compute appropriate dependencies
6088 using these files at build time as well.
6089 </p>
6092 The two mechanisms differ in the degree of detail that they
6093 provide. A <file>symbols</file> file documents, for each symbol
6094 exported by a library, the minimal version of the package any
6095 binary using this symbol will need. This is typically the
6096 version of the package in which the symbol was introduced. This
6097 information permits detailed analysis of the symbols used by a
6098 particular package and construction of an accurate dependency,
6099 but it requires the package maintainer to track more information
6100 about the shared library.
6101 </p>
6104 A <file>shlibs</file> file, in contrast, only documents the last
6105 time the library ABI changed in any way. It only provides
6106 information about the library as a whole, not individual
6107 symbols. When a package is built using a shared library with
6108 only a <file>shlibs</file> file, the generated dependency will
6109 require a version of the shared library equal to or newer than
6110 the version of the last ABI change. This generates
6111 unnecessarily restrictive dependencies compared
6112 to <file>symbols</file> files if none of the symbols used by the
6113 package have changed. This, in turn, may make upgrades
6114 needlessly complex and unnecessarily restrict use of the package
6115 on systems with older versions of the shared libraries.
6116 </p>
6119 <file>shlibs</file> files also only support a limited range of
6120 library SONAMEs, making it difficult to use <file>shlibs</file>
6121 files in some unusual corner cases.<footnote>
6122 A <file>shlibs</file> file represents an SONAME as a library
6123 name and version number, such as <tt>libfoo VERSION</tt>,
6124 instead of recording the actual SONAME. If the SONAME doesn't
6125 match one of the two expected formats
6126 (<tt>libfoo-VERSION.so</tt> or <tt>libfoo.so.VERSION</tt>), it
6127 cannot be represented.
6128 </footnote>
6129 </p>
6132 <file>symbols</file> files are therefore recommended for most
6133 shared library packages since they provide more accurate
6134 dependencies. For most C libraries, the additional detail
6135 required by <file>symbols</file> files is not too difficult to
6136 maintain. However, maintaining exhaustive symbols information
6137 for a C++ library can be quite onerous, so <file>shlibs</file>
6138 files may be more appropriate for most C++ libraries. Libraries
6139 with a corresponding udeb must also provide
6140 a <file>shlibs</file> file, since the udeb infrastructure does
6141 not use <file>symbols</file> files.
6142 </p>
6144 <sect1 id="dpkg-shlibdeps">
6145 <heading>Generating dependencies on shared libraries</heading>
6148 When a package that contains any shared libraries or compiled
6149 binaries is built, it must run <prgn>dpkg-shlibdeps</prgn> on
6150 each shared library and compiled binary to determine the
6151 libraries used and hence the dependencies needed by the
6152 package.<footnote>
6153 <prgn>dpkg-shlibdeps</prgn> will use a program
6154 like <prgn>objdump</prgn> or <prgn>readelf</prgn> to find
6155 the libraries and the symbols in those libraries directly
6156 needed by the binaries or shared libraries in the package.
6157 </footnote>
6158 To do this, put a call to <prgn>dpkg-shlibdeps</prgn> into
6159 your <file>debian/rules</file> file in the source package.
6160 List all of the compiled binaries, libraries, or loadable
6161 modules in your package.<footnote>
6162 The easiest way to call <prgn>dpkg-shlibdeps</prgn>
6163 correctly is to use a package helper framework such
6164 as <package>debhelper</package>. If you are
6165 using <package>debhelper</package>,
6166 the <prgn>dh_shlibdeps</prgn> program will do this work for
6167 you. It will also correctly handle multi-binary packages.
6168 </footnote>
6169 <prgn>dpkg-shlibdeps</prgn> will use the <file>symbols</file>
6170 or <file>shlibs</file> files installed by the shared libraries
6171 to generate dependency information. The package must then
6172 provide a substitution variable into which the discovered
6173 dependency information can be placed.
6174 </p>
6177 If you are creating a udeb for use in the Debian Installer,
6178 you will need to specify that <prgn>dpkg-shlibdeps</prgn>
6179 should use the dependency line of type <tt>udeb</tt> by adding
6180 the <tt>-tudeb</tt> option<footnote>
6181 <prgn>dh_shlibdeps</prgn> from the <tt>debhelper</tt> suite
6182 will automatically add this option if it knows it is
6183 processing a udeb.
6184 </footnote>. If there is no dependency line of
6185 type <tt>udeb</tt> in the <file>shlibs</file>
6186 file, <prgn>dpkg-shlibdeps</prgn> will fall back to the
6187 regular dependency line.
6188 </p>
6191 <prgn>dpkg-shlibdeps</prgn> puts the dependency information
6192 into the <file>debian/substvars</file> file by default, which
6193 is then used by <prgn>dpkg-gencontrol</prgn>. You will need
6194 to place a <tt>${shlibs:Depends}</tt> variable in
6195 the <tt>Depends</tt> field in the control file of every binary
6196 package built by this source package that contains compiled
6197 binaries, libraries, or loadable modules. If you have
6198 multiple binary packages, you will need to
6199 call <prgn>dpkg-shlibdeps</prgn> on each one which contains
6200 compiled libraries or binaries. For example, you could use
6201 the <tt>-T</tt> option to the <tt>dpkg</tt> utilities to
6202 specify a different <file>substvars</file> file for each
6203 binary package.<footnote>
6204 Again, <prgn>dh_shlibdeps</prgn>
6205 and <prgn>dh_gencontrol</prgn> will handle everything except
6206 the addition of the variable to the control file for you if
6207 you're using <package>debhelper</package>, including
6208 generating separate <file>substvars</file> files for each
6209 binary package and calling <prgn>dpkg-gencontrol</prgn> with
6210 the appropriate flags.
6211 </footnote>
6212 </p>
6215 For more details on <prgn>dpkg-shlibdeps</prgn>,
6216 see <manref name="dpkg-shlibdeps" section="1">.
6217 </p>
6220 We say that a binary <tt>foo</tt> <em>directly</em> uses a
6221 library <tt>libbar</tt> if it is explicitly linked with that
6222 library (that is, the library is listed in the
6223 ELF <tt>NEEDED</tt> attribute, caused by adding <tt>-lbar</tt>
6224 to the link line when the binary is created). Other libraries
6225 that are needed by <tt>libbar</tt> are
6226 linked <em>indirectly</em> to <tt>foo</tt>, and the dynamic
6227 linker will load them automatically when it
6228 loads <tt>libbar</tt>. A package should depend on the
6229 libraries it directly uses, but not the libraries it only uses
6230 indirectly. The dependencies for the libraries used
6231 directly will automatically pull in the indirectly-used
6232 libraries. <prgn>dpkg-shlibdeps</prgn> will handle this logic
6233 automatically, but package maintainers need to be aware of
6234 this distinction between directly and indirectly using a
6235 library if they have to override its results for some reason.
6236 <footnote>
6237 A good example of where this helps is the following. We
6238 could update <tt>libimlib</tt> with a new version that
6239 supports a new revision of a graphics format called dgf (but
6240 retaining the same major version number) and depends on a
6241 new library package <package>libdgf4</package> instead of
6242 the older <package>libdgf3</package>. If we
6243 used <prgn>ldd</prgn> to add dependencies for every library
6244 directly or indirectly linked with a binary, every package
6245 that uses <tt>libimlib</tt> would need to be recompiled so
6246 it would also depend on <package>libdgf4</package> in order
6247 to retire the older <package>libdgf3</package> package.
6248 Since dependencies are only added based on
6249 ELF <tt>NEEDED</tt> attribute, packages
6250 using <tt>libimlib</tt> can rely on <tt>libimlib</tt> itself
6251 having the dependency on an appropriate version
6252 of <tt>libdgf</tt> and do not need rebuilding.
6253 </footnote>
6254 </p>
6255 </sect1>
6257 <sect1 id="sharedlibs-updates">
6258 <heading>Shared library ABI changes</heading>
6261 Maintaining a shared library package using
6262 either <file>symbols</file> or <file>shlibs</file> files
6263 requires being aware of the exposed ABI of the shared library
6264 and any changes to it. Both <file>symbols</file>
6265 and <file>shlibs</file> files record every change to the ABI
6266 of the shared library; <file>symbols</file> files do so per
6267 public symbol, whereas <file>shlibs</file> files record only
6268 the last change for the entire library.
6269 </p>
6272 There are two types of ABI changes: ones that are
6273 backward-compatible and ones that are not. An ABI change is
6274 backward-compatible if any reasonable program or library that
6275 was linked with the previous version of the shared library
6276 will still work correctly with the new version of the shared
6277 library.<footnote>
6278 An example of an "unreasonable" program is one that uses
6279 library interfaces that are documented as internal and
6280 unsupported. If the only programs or libraries affected by
6281 a change are "unreasonable" ones, other techniques, such as
6282 declaring <tt>Breaks</tt> relationships with affected
6283 packages or treating their usage of the library as bugs in
6284 those packages, may be appropriate instead of changing the
6285 SONAME. However, the default approach is to change the
6286 SONAME for any change to the ABI that could break a program.
6287 </footnote>
6288 Adding new symbols to the shared library is a
6289 backward-compatible change. Removing symbols from the shared
6290 library is not. Changing the behavior of a symbol may or may
6291 not be backward-compatible depending on the change; for
6292 example, changing a function to accept a new enum constant not
6293 previously used by the library is generally
6294 backward-compatible, but changing the members of a struct that
6295 is passed into library functions is generally not unless the
6296 library takes special precautions to accept old versions of
6297 the data structure.
6298 </p>
6301 ABI changes that are not backward-compatible normally require
6302 changing the <tt>SONAME</tt> of the library and therefore the
6303 shared library package name, which forces rebuilding all
6304 packages using that shared library to update their
6305 dependencies and allow them to use the new version of the
6306 shared library. For more information,
6307 see <ref id="sharedlibs-runtime">. The remainder of this
6308 section will deal with backward-compatible changes.
6309 </p>
6312 Backward-compatible changes require either updating or
6313 recording the <var>minimal-version</var> for that symbol
6314 in <file>symbols</file> files or updating the version in
6315 the <var>dependencies</var> in <file>shlibs</file> files. For
6316 more information on how to do this in the two formats, see
6317 <ref id="symbols"> and <ref id="shlibs">. Below are general
6318 rules that apply to both files.
6319 </p>
6322 The easy case is when a public symbol is added. Simply add
6323 the version at which the symbol was introduced
6324 (for <file>symbols</file> files) or update the dependency
6325 version (for <file>shlibs</file>) files. But special care
6326 should be taken to update dependency versions when the
6327 behavior of a public symbol changes. This is easy to neglect,
6328 since there is no automated method of determining such
6329 changes, but failing to update versions in this case may
6330 result in binary packages with too-weak dependencies that will
6331 fail at runtime, possibly in ways that can cause security
6332 vulnerabilities. If the package maintainer believes that a
6333 symbol behavior change may have occurred but isn't sure, it's
6334 safer to update the version rather than leave it unmodified.
6335 This may result in unnecessarily strict dependencies, but it
6336 ensures that packages whose dependencies are satisfied will
6337 work properly.
6338 </p>
6341 A common example of when a change to the dependency version
6342 is required is a function that takes an enum or struct
6343 argument that controls what the function does. For example:
6344 <example>
6345 enum library_op { OP_FOO, OP_BAR };
6346 int library_do_operation(enum library_op);
6347 </example>
6348 If a new operation, <tt>OP_BAZ</tt>, is added,
6349 the <var>minimal-version</var>
6350 of <tt>library_do_operation</tt> (for <file>symbols</file>
6351 files) or the version in the dependency for the shared library
6352 (for <file>shlibs</file> files) must be increased to the
6353 version at which <tt>OP_BAZ</tt> was introduced. Otherwise, a
6354 binary built against the new version of the library (having
6355 detected at compile-time that the library
6356 supports <tt>OP_BAZ</tt>) may be installed with a shared
6357 library that doesn't support <tt>OP_BAZ</tt> and will fail at
6358 runtime when it tries to pass <tt>OP_BAZ</tt> into this
6359 function.
6360 </p>
6363 Dependency versions in either <file>symbols</file>
6364 or <file>shlibs</file> files normally should not contain the
6365 Debian revision of the package, since the library behavior is
6366 normally fixed for a particular upstream version and any
6367 Debian packaging of that upstream version will have the same
6368 behavior. In the rare case that the library behavior was
6369 changed in a particular Debian revision, appending <tt>~</tt>
6370 to the end of the version that includes the Debian revision is
6371 recommended, since this allows backports of the shared library
6372 package using the normal backport versioning convention to
6373 satisfy the dependency.
6374 </p>
6375 </sect1>
6377 <sect1 id="sharedlibs-symbols">
6378 <heading>The <tt>symbols</tt> system</heading>
6381 In the following sections, we will first describe where the
6382 various <file>symbols</file> files are to be found, then
6383 the <file>symbols</file> file format, and finally how to
6384 create <file>symbols</file> files if your package contains a
6385 shared library.
6386 </p>
6388 <sect2 id="symbols-paths">
6389 <heading>The <file>symbols</file> files present on the
6390 system</heading>
6393 <file>symbols</file> files for a shared library are normally
6394 provided by the shared library package as a control file,
6395 but there are several override paths that are checked first
6396 in case that information is wrong or missing. The following
6397 list gives them in the order in which they are read
6398 by <prgn>dpkg-shlibdeps</prgn> The first one that contains
6399 the required information is used.
6400 <list>
6401 <item>
6402 <p><file>debian/*/DEBIAN/symbols</file></p>
6405 During the package build, if the package itself
6406 contains shared libraries with <file>symbols</file>
6407 files, they will be generated in these staging
6408 directories by <prgn>dpkg-gensymbols</prgn>
6409 (see <ref id="providing-symbols">). <file>symbols</file>
6410 files found in the build tree take precedence
6411 over <file>symbols</file> files from other binary
6412 packages.
6413 </p>
6416 These files must exist
6417 before <prgn>dpkg-shlibdeps</prgn> is run or the
6418 dependencies of binaries and libraries from a source
6419 package on other libraries from that same source
6420 package will not be correct. In practice, this means
6421 that <prgn>dpkg-gensymbols</prgn> must be run
6422 before <prgn>dpkg-shlibdeps</prgn> during the package
6423 build.<footnote>
6424 An example may clarify. Suppose the source
6425 package <tt>foo</tt> generates two binary
6426 packages, <tt>libfoo2</tt> and <tt>foo-runtime</tt>.
6427 When building the binary packages, the contents of
6428 the packages are staged in the
6429 directories <file>debian/libfoo2</file>
6430 and <file>debian/foo-runtime</file> respectively.
6431 (<file>debian/tmp</file> could be used instead of
6432 one of these.) Since <tt>libfoo2</tt> provides
6433 the <tt>libfoo</tt> shared library, it will contain
6434 a <tt>symbols</tt> file, which will be installed
6435 in <file>debian/libfoo2/DEBIAN/symbols</file>,
6436 eventually to be included as a control file in that
6437 package. When <prgn>dpkg-shlibdeps</prgn> is run on
6439 executable <file>debian/foo-runtime/usr/bin/foo-prog</file>,
6440 it will examine
6441 the <file>debian/libfoo2/DEBIAN/symbols</file> file
6442 to determine whether <tt>foo-prog</tt>'s library
6443 dependencies are satisfied by any of the libraries
6444 provided by <tt>libfoo2</tt>. Since those binaries
6445 were linked against the just-built shared library as
6446 part of the build process, the <file>symbols</file>
6447 file for the newly-built <tt>libfoo2</tt> must take
6448 precedence over a <file>symbols</file> file for any
6449 other <tt>libfoo2</tt> package already installed on
6450 the system.
6451 </footnote>
6452 </p>
6453 </item>
6455 <item>
6457 <file>/etc/dpkg/symbols/<var>package</var>.symbols.<var>arch</var></file>
6458 and <file>/etc/dpkg/symbols/<var>package</var>.symbols</file>
6459 </p>
6462 Per-system overrides of shared library dependencies.
6463 These files normally do not exist. They are
6464 maintained by the local system administrator and must
6465 not be created by any Debian package.
6466 </p>
6467 </item>
6469 <item>
6470 <p><file>symbols</file> control files for packages
6471 installed on the system</p>
6474 The <file>symbols</file> control files for all the
6475 packages currently installed on the system are
6476 searched last. This will be the most common source of
6477 shared library dependency information. These files
6478 can be read with <tt>dpkg-query
6479 --control-show <var>package</var> symbols</tt>.
6480 </p>
6481 </item>
6482 </list>
6483 </p>
6486 Be aware that if a <file>debian/shlibs.local</file> exists
6487 in the source package, it will override
6488 any <file>symbols</file> files. This is the only case where
6489 a <file>shlibs</file> is used despite <file>symbols</file>
6490 files being present. See <ref id="shlibs-paths">
6491 and <ref id="sharedlibs-shlibdeps"> for more information.
6492 </p>
6493 </sect2>
6495 <sect2 id="symbols">
6496 <heading>The <file>symbols</file> File Format</heading>
6499 The following documents the format of
6500 the <file>symbols</file> control file as included in binary
6501 packages. These files are built from
6502 template <file>symbols</file> files in the source package
6503 by <prgn>dpkg-gensymbols</prgn>. The template files support
6504 a richer syntax that allows <prgn>dpkg-gensymbols</prgn> to
6505 do some of the tedious work involved in
6506 maintaining <file>symbols</file> files, such as handling C++
6507 symbols or optional symbols that may not exist on particular
6508 architectures. When writing <file>symbols</file> files for
6509 a shared library package, refer
6510 to <manref name="dpkg-gensymbols" section="1"> for the
6511 richer syntax.
6512 </p>
6515 A <file>symbols</file> may contain one or more entries, one
6516 for each shared library contained in the package
6517 corresponding to that <file>symbols</file>. Each entry has
6518 the following format:
6519 </p>
6522 <example>
6523 <var>library-soname</var> <var>main-dependency-template</var>
6524 [| <var>alternative-dependency-template</var>]
6525 [...]
6526 [* <var>field-name</var>: <var>field-value</var>]
6527 [...]
6528 <var>symbol</var> <var>minimal-version</var>[ <var>id-of-dependency-template</var> ]
6529 </example>
6530 </p>
6533 To explain this format, we'll use the <tt>zlib1g</tt>
6534 package as an example, which (at the time of writing)
6535 installs the shared
6536 library <file>/usr/lib/libz.so.1.2.3.4</file>. Mandatory
6537 lines will be described first, followed by optional lines.
6538 </p>
6541 <var>library-soname</var> must contain exactly the value of
6542 the ELF <tt>SONAME</tt> attribute of the shared library. In
6543 our example, this is <tt>libz.so.1</tt>.<footnote>
6544 This can be determined by using the command
6545 <example compact="compact">
6546 readelf -d /usr/lib/libz.so.1.2.3.4 | grep SONAME
6547 </example>
6548 </footnote>
6549 </p>
6552 <var>main-dependency-template</var> has the same syntax as a
6553 dependency field in a binary package control file, except
6554 that the string <tt>#MINVER#</tt> is replaced by a version
6555 restriction like <tt>(&gt;= <var>version</var>)</tt> or by
6556 nothing if an unversioned dependency is deemed sufficient.
6557 The version restriction will be based on which symbols from
6558 the shared library are referenced and the version at which
6559 they were introduced (see below). In nearly all
6560 cases, <var>main-dependency-template</var> will
6561 be <tt><var>package</var> #MINVER#</tt>,
6562 where <var>package</var> is the name of the binary package
6563 containing the shared library. This adds a simple,
6564 possibly-versioned dependency on the shared library package.
6565 In some rare cases, such as when multiple packages provide
6566 the same shared library ABI, the dependency template may
6567 need to be more complex.
6568 </p>
6571 In our example, the first line of
6572 the <tt>zlib1g</tt> <file>symbols</file> file would be:
6573 <example compact="compact">
6574 libz.so.1 zlib1g #MINVER#
6575 </example>
6576 </p>
6579 Each public symbol exported by the shared library must have
6580 a corresponding symbol line, indented by one
6581 space. <var>symbol</var> is the exported symbol (which, for
6582 C++, means the mangled symbol) followed by <tt>@</tt> and
6583 the symbol version, or the string <tt>Base</tt> if there is
6584 no symbol version. <var>minimal-version</var> is the most
6585 recent version of the shared library that changed the
6586 behavior of that symbol, whether by adding it, changing its
6587 function signature (the parameters, their types, or the
6588 return type), or changing its behavior in a way that is
6589 visible to a caller.
6590 <var>id-of-dependency-template</var> is an optional
6591 field that references
6592 an <var>alternative-dependency-template</var>; see below for
6593 a full description.
6594 </p>
6597 For example, <tt>libz.so.1</tt> contains the
6598 symbols <tt>compress</tt>
6599 and <tt>compressBound</tt>. <tt>compress</tt> has no symbol
6600 version and last changed its behavior in upstream
6601 version <tt>1:1.1.4</tt>. <tt>compressBound</tt> has the
6602 symbol version <tt>ZLIB_1.2.0</tt>, was introduced in
6603 upstream version <tt>1:1.2.0</tt>, and has not changed its
6604 behavior. Its <file>symbols</file> file therefore contains
6605 the lines:
6606 <example compact="compact">
6607 compress@Base 1:1.1.4
6608 compressBound@ZLIB_1.2.0 1:1.2.0
6609 </example>
6610 Packages using only <tt>compress</tt> would then get a
6611 dependency on <tt>zlib1g (&gt;= 1:1.1.4)</tt>, but packages
6612 using <tt>compressBound</tt> would get a dependency
6613 on <tt>zlib1g (&gt;= 1:1.2.0)</tt>.
6614 </p>
6617 One or more <var>alternative-dependency-template</var> lines
6618 may be provided. These are used in cases where some symbols
6619 in the shared library should use one dependency template
6620 while others should use a different template. The
6621 alternative dependency templates are used only if a symbol
6622 line contains the <var>id-of-dependency-template</var>
6623 field. The first alternative dependency template is
6624 numbered 1, the second 2, and so forth.<footnote>
6625 An example of where this may be needed is with a library
6626 that implements the libGL interface. All GL
6627 implementations provide the same set of base interfaces,
6628 and then may provide some additional interfaces only used
6629 by programs that require that specific GL implementation.
6630 So, for example, libgl1-mesa-glx may use the
6631 following <file>symbols</file> file:
6632 <example>
6633 libGL.so.1 libgl1
6634 | libgl1-mesa-glx #MINVER#
6635 publicGlSymbol@Base 6.3-1
6636 [...]
6637 implementationSpecificSymbol@Base 6.5.2-7 1
6638 [...]
6639 </example>
6640 Binaries or shared libraries using
6641 only <tt>publicGlSymbol</tt> would depend only
6642 on <tt>libgl1</tt> (which may be provided by multiple
6643 packages), but ones
6644 using <tt>implementationSpecificSymbol</tt> would get a
6645 dependency on <tt>libgl1-mesa-glx (&gt;= 6.5.2-7)</tt>
6646 </footnote>
6647 </p>
6650 Finally, the entry for the library may contain one or more
6651 metadata fields. Currently, the only
6652 supported <var>field-name</var>
6653 is <tt>Build-Depends-Package</tt>, whose value lists
6654 the <qref id="sharedlibs-dev">library development
6655 package</qref> on which packages using this shared library
6656 declare a build dependency. If this field is
6657 present, <prgn>dpkg-shlibdeps</prgn> uses it to ensure that
6658 the resulting binary package dependency on the shared
6659 library is at least as strict as the source package
6660 dependency on the shared library development
6661 package.<footnote>
6662 This field should normally not be necessary, since if the
6663 behavior of any symbol has changed, the corresponding
6664 symbol <var>minimal-version</var> should have been
6665 increased. But including it makes the <tt>symbols</tt>
6666 system more robust by tightening the dependency in cases
6667 where the package using the shared library specifically
6668 requires at least a particular version of the shared
6669 library development package for some reason.
6670 </footnote>
6671 For our example, the <tt>zlib1g</tt> <file>symbols</file>
6672 file would contain:
6673 <example compact="compact">
6674 * Build-Depends-Package: zlib1g-dev
6675 </example>
6676 </p>
6679 Also see <manref name="deb-symbols" section="5">.
6680 </p>
6681 </sect2>
6683 <sect2 id="providing-symbols">
6684 <heading>Providing a <file>symbols</file> file</heading>
6687 If your package provides a shared library, you should
6688 arrange to include a <file>symbols</file> control file
6689 following the format described above in that package. You
6690 must include either a <file>symbols</file> control file or
6691 a <file>shlibs</file> control file.
6692 </p>
6695 Normally, this is done by creating a <file>symbols</file> in
6696 the source package
6697 named <file>debian/<var>package</var>.symbols</file>
6698 or <file>debian/symbols</file>, possibly
6699 with <file>.<var>arch</var></file> appended if the symbols
6700 information varies by architecture. This file may use the
6701 extended syntax documented in <manref name="dpkg-gensymbols"
6702 section="1">. Then, call <prgn>dpkg-gensymbols</prgn> as
6703 part of the package build process. It will
6704 create <file>symbols</file> files in the package staging
6705 area based on the binaries and libraries in the package
6706 staging area and the <file>symbols</file> files in the
6707 source package.<footnote>
6708 If you are
6709 using <tt>debhelper</tt>, <prgn>dh_makeshlibs</prgn> will
6710 take care of calling either <prgn>dpkg-gensymbols</prgn>
6711 or generating a <file>shlibs</file> file as appropriate.
6712 </footnote>
6713 </p>
6716 Packages that provide <file>symbols</file> files must keep
6717 them up-to-date to ensure correct dependencies in packages
6718 that use the shared libraries. This means updating
6719 the <file>symbols</file> file whenever a new public symbol
6720 is added, changing the <var>minimal-version</var> field
6721 whenever a symbol changes behavior or signature in a
6722 backward-compatible way (see <ref id="sharedlibs-updates">),
6723 and changing the <var>library-soname</var>
6724 and <var>main-dependency-template</var>, and probably all of
6725 the <var>minimal-version</var> fields, when the library
6726 changes <tt>SONAME</tt>. Removing a public symbol from
6727 the <file>symbols</file> file because it's no longer
6728 provided by the library normally requires changing
6729 the <tt>SONAME</tt> of the library.
6730 See <ref id="sharedlibs-runtime"> for more information
6731 on <tt>SONAME</tt>s.
6732 </p>
6733 </sect2>
6734 </sect1>
6736 <sect1 id="sharedlibs-shlibdeps">
6737 <heading>The <tt>shlibs</tt> system</heading>
6740 The <tt>shlibs</tt> system is a simpler alternative to
6741 the <tt>symbols</tt> system for declaring dependencies for
6742 shared libraries. It may be more appropriate for C++
6743 libraries and other cases where tracking individual symbols is
6744 too difficult. It predated the <tt>symbols</tt> system and is
6745 therefore frequently seen in older packages. It is also
6746 required for udebs, which do not support <tt>symbols</tt>.
6747 </p>
6750 In the following sections, we will first describe where the
6751 various <file>shlibs</file> files are to be found, then how to
6752 use <prgn>dpkg-shlibdeps</prgn>, and finally
6753 the <file>shlibs</file> file format and how to create them.
6754 </p>
6756 <sect2 id="shlibs-paths">
6757 <heading>The <file>shlibs</file> files present on the
6758 system</heading>
6761 There are several places where <tt>shlibs</tt> files are
6762 found. The following list gives them in the order in which
6763 they are read by <prgn>dpkg-shlibdeps</prgn>. (The first
6764 one which gives the required information is used.)
6765 <list>
6766 <item>
6767 <p><file>debian/shlibs.local</file></p>
6770 This lists overrides for this package. This file
6771 should normally not be used, but may be needed
6772 temporarily in unusual situations to work around bugs
6773 in other packages, or in unusual cases where the
6774 normally declared dependency information in the
6775 installed <file>shlibs</file> file for a library
6776 cannot be used. This file overrides information
6777 obtained from any other source.
6778 </p>
6779 </item>
6781 <item>
6782 <p><file>/etc/dpkg/shlibs.override</file></p>
6785 This lists global overrides. This list is normally
6786 empty. It is maintained by the local system
6787 administrator.
6788 </p>
6789 </item>
6791 <item>
6792 <p><file>DEBIAN/shlibs</file> files in the "build
6793 directory"</p>
6796 These files are generated as part of the package build
6797 process and staged for inclusion as control files in
6798 the binary packages being built. They provide details
6799 of any shared libraries included in the same package.
6800 </p>
6801 </item>
6803 <item>
6804 <p><file>shlibs</file> control files for packages
6805 installed on the system</p>
6808 The <file>shlibs</file> control files for all the
6809 packages currently installed on the system. These
6810 files can be read using <tt>dpkg-query
6811 --control-show <var>package</var> shlibs</tt>.
6812 </p>
6813 </item>
6815 <item>
6816 <p><file>/etc/dpkg/shlibs.default</file></p>
6819 This file lists any shared libraries whose packages
6820 have failed to provide correct <file>shlibs</file>
6821 files. It was used when the <file>shlibs</file> setup
6822 was first introduced, but it is now normally empty.
6823 It is maintained by the <tt>dpkg</tt> maintainer.
6824 </p>
6825 </item>
6826 </list>
6827 </p>
6830 If a <file>symbols</file> file for a shared library package
6831 is available, <prgn>dpkg-shlibdeps</prgn> will always use it
6832 in preference to a <file>shlibs</file>, with the exception
6833 of <file>debian/shlibs.local</file>. The latter overrides
6834 any other <file>shlibs</file> or <file>symbols</file> files.
6835 </p>
6836 </sect2>
6838 <sect2 id="shlibs">
6839 <heading>The <file>shlibs</file> File Format</heading>
6842 Each <file>shlibs</file> file has the same format. Lines
6843 beginning with <tt>#</tt> are considered to be comments and
6844 are ignored. Each line is of the form:
6845 <example compact="compact">
6846 [<var>type</var>: ]<var>library-name</var> <var>soname-version</var> <var>dependencies ...</var>
6847 </example>
6848 </p>
6851 We will explain this by reference to the example of the
6852 <tt>zlib1g</tt> package, which (at the time of writing)
6853 installs the shared
6854 library <file>/usr/lib/libz.so.1.2.3.4</file>.
6855 </p>
6858 <var>type</var> is an optional element that indicates the
6859 type of package for which the line is valid. The only type
6860 currently in use is <tt>udeb</tt>. The colon and space
6861 after the type are required.
6862 </p>
6865 <var>library-name</var> is the name of the shared library,
6866 in this case <tt>libz</tt>. (This must match the name part
6867 of the soname, see below.)
6868 </p>
6871 <var>soname-version</var> is the version part of the
6872 ELF <tt>SONAME</tt> attribute of the library, determined the
6873 same way that the <var>soversion</var> component of the
6874 recommended shared library package name is determined.
6875 See <ref id="sharedlibs-runtime"> for the details.
6876 </p>
6879 <var>dependencies</var> has the same syntax as a dependency
6880 field in a binary package control file. It should give
6881 details of which packages are required to satisfy a binary
6882 built against the version of the library contained in the
6883 package. See <ref id="depsyntax"> for details on the
6884 syntax, and <ref id="sharedlibs-updates"> for details on how
6885 to maintain the dependency version constraint.
6886 </p>
6889 In our example, if the last change to the <tt>zlib1g</tt>
6890 package that could change behavior for a client of that
6891 library was in version <tt>1:1.2.3.3.dfsg-1</tt>, then
6892 the <tt>shlibs</tt> entry for this library could say:
6893 <example compact="compact">
6894 libz 1 zlib1g (&gt;= 1:1.2.3.3.dfsg)
6895 </example>
6896 This version restriction must be new enough that any binary
6897 built against the current version of the library will work
6898 with any version of the shared library that satisfies that
6899 dependency.
6900 </p>
6903 As zlib1g also provides a udeb containing the shared
6904 library, there would also be a second line:
6905 <example compact="compact">
6906 udeb: libz 1 zlib1g-udeb (&gt;= 1:1.2.3.3.dfsg)
6907 </example>
6908 </p>
6909 </sect2>
6911 <sect2>
6912 <heading>Providing a <file>shlibs</file> file</heading>
6915 To provide a <file>shlibs</file> file for a shared library
6916 binary package, create a <file>shlibs</file> file following
6917 the format described above and place it in
6918 the <file>DEBIAN</file> directory for that package during
6919 the build. It will then be included as a control file for
6920 that package<footnote>
6921 This is what <prgn>dh_makeshlibs</prgn> in
6922 the <package>debhelper</package> suite does. If your
6923 package also has a udeb that provides a shared
6924 library, <prgn>dh_makeshlibs</prgn> can automatically
6925 generate the <tt>udeb:</tt> lines if you specify the name
6926 of the udeb with the <tt>--add-udeb</tt> option.
6927 </footnote>.
6928 </p>
6931 Since <prgn>dpkg-shlibdeps</prgn> reads
6932 the <file>DEBIAN/shlibs</file> files in all of the binary
6933 packages being built from this source package, all of
6934 the <file>DEBIAN/shlibs</file> files should be installed
6935 before <prgn>dpkg-shlibdeps</prgn> is called on any of the
6936 binary packages.
6937 </p>
6938 </sect2>
6939 </sect1>
6940 </sect>
6941 </chapt>
6944 <chapt id="opersys"><heading>The Operating System</heading>
6946 <sect>
6947 <heading>File system hierarchy</heading>
6950 <sect1 id="fhs">
6951 <heading>File System Structure</heading>
6954 The location of all files and directories must comply with the
6955 Filesystem Hierarchy Standard (FHS), version 2.3, with the
6956 exceptions noted below, and except where doing so would
6957 violate other terms of Debian Policy. The following
6958 exceptions to the FHS apply:
6960 <enumlist>
6961 <item>
6963 The FHS requirement that architecture-independent
6964 application-specific static files be located in
6965 <file>/usr/share</file> is relaxed to a suggestion.
6967 In particular, a subdirectory of <file>/usr/lib</file> may
6968 be used by a package (or a collection of packages) to hold a
6969 mixture of architecture-independent and
6970 architecture-dependent files. However, when a directory is
6971 entirely composed of architecture-independent files, it
6972 should be located in <file>/usr/share</file>.
6973 </p>
6974 </item>
6975 <item>
6977 The optional rules related to user specific
6978 configuration files for applications are stored in
6979 the user's home directory are relaxed. It is
6980 recommended that such files start with the
6981 '<tt>.</tt>' character (a "dot file"), and if an
6982 application needs to create more than one dot file
6983 then the preferred placement is in a subdirectory
6984 with a name starting with a '.' character, (a "dot
6985 directory"). In this case it is recommended the
6986 configuration files not start with the '.'
6987 character.
6988 </p>
6989 </item>
6990 <item>
6992 The requirement for amd64 to use <file>/lib64</file>
6993 for 64 bit binaries is removed.
6994 </p>
6995 </item>
6996 <item>
6998 The requirement for object files, internal binaries, and
6999 libraries, including <file>libc.so.*</file>, to be located
7000 directly under <file>/lib{,32}</file> and
7001 <file>/usr/lib{,32}</file> is amended, permitting files
7002 to instead be installed to
7003 <file>/lib/<var>triplet</var></file> and
7004 <file>/usr/lib/<var>triplet</var></file>, where
7005 <tt><var>triplet</var></tt> is the value returned by
7006 <tt>dpkg-architecture -qDEB_HOST_MULTIARCH</tt> for the
7007 architecture of the package. Packages may <em>not</em>
7008 install files to any <var>triplet</var> path other
7009 than the one matching the architecture of that package;
7010 for instance, an <tt>Architecture: amd64</tt> package
7011 containing 32-bit x86 libraries may not install these
7012 libraries to <file>/usr/lib/i386-linux-gnu</file>.
7013 <footnote>
7014 This is necessary in order to reserve the directories for
7015 use in cross-installation of library packages from other
7016 architectures, as part of <tt>multiarch</tt>.
7017 </footnote>
7018 </p>
7020 The requirement for C and C++ headers files to be
7021 accessible through the search path
7022 <file>/usr/include/</file> is amended, permitting files to
7023 be accessible through the search path
7024 <file>/usr/include/<var>triplet</var></file> where
7025 <tt><var>triplet</var></tt> is as above. <footnote>
7026 This is necessary for architecture-dependent headers
7027 file to coexist in a <tt>multiarch</tt> setup.
7028 </footnote>
7029 </p>
7031 Applications may also use a single subdirectory under
7032 <file>/usr/lib/<var>triplet</var></file>.
7033 </p>
7035 The execution time linker/loader, ld*, must still be made
7036 available in the existing location under /lib or /lib64
7037 since this is part of the ELF ABI for the architecture.
7038 </p>
7039 </item>
7040 <item>
7042 The requirement that
7043 <file>/usr/local/share/man</file> be "synonymous"
7044 with <file>/usr/local/man</file> is relaxed to a
7045 recommendation</p>
7046 </item>
7047 <item>
7049 The requirement that windowmanagers with a single
7050 configuration file call it <file>system.*wmrc</file>
7051 is removed, as is the restriction that the window
7052 manager subdirectory be named identically to the
7053 window manager name itself.
7054 </p>
7055 </item>
7056 <item>
7058 The requirement that boot manager configuration
7059 files live in <file>/etc</file>, or at least are
7060 symlinked there, is relaxed to a recommendation.
7061 </p>
7062 </item>
7063 <item>
7065 The additional directory <file>/run</file> in the root
7066 file system is allowed. <file>/run</file>
7067 replaces <file>/var/run</file>, and the
7068 subdirectory <file>/run/lock</file>
7069 replaces <file>/var/lock</file>, with
7070 the <file>/var</file> directories replaced by symlinks
7071 for backwards compatibility. <file>/run</file>
7072 and <file>/run/lock</file> must follow all of the
7073 requirements in the FHS for <file>/var/run</file>
7074 and <file>/var/lock</file>, respectively, such as file
7075 naming conventions, file format requirements, or the
7076 requirement that files be cleared during the boot
7077 process. Files and directories residing
7078 in <file>/run</file> should be stored on a temporary
7079 file system.
7080 </p>
7081 </item>
7082 <item>
7084 The <file>/sys</file> directory in the root filesystem is
7085 additionally allowed. <footnote>This directory is used as
7086 mount point to mount virtual filesystems to get access to
7087 kernel information.</footnote>
7088 </p>
7089 </item>
7090 <item>
7092 The <file>/var/www</file> directory is additionally allowed.
7093 </p>
7094 </item>
7095 <item>
7097 The requirement for <file>/usr/local/lib<var>qual</var></file>
7098 to exist if <file>/lib<var>qual</var></file> or
7099 <file>/usr/lib<var>qual</var></file> exists (where
7100 <file>lib<var>qual</var></file> is a variant of
7101 <file>lib</file> such as <file>lib32</file> or
7102 <file>lib64</file>) is removed.
7103 </p>
7104 </item>
7105 <item>
7107 On GNU/Hurd systems, the following additional
7108 directories are allowed in the root
7109 filesystem: <file>/hurd</file>
7110 and <file>/servers</file>.<footnote>
7111 These directories are used to store translators and as
7112 a set of standard names for mount points,
7113 respectively.
7114 </footnote>
7115 </p>
7116 </item>
7117 </enumlist>
7118 </p>
7121 The version of this document referred here can be
7122 found in the <tt>debian-policy</tt> package or on <url
7123 id="http://www.debian.org/doc/packaging-manuals/fhs/"
7124 name="FHS (Debian copy)"> alongside this manual (or, if
7125 you have the <package>debian-policy</package> installed,
7126 you can try <url
7127 id="file:///usr/share/doc/debian-policy/fhs/" name="FHS
7128 (local copy)">). The
7129 latest version, which may be a more recent version, may
7130 be found on
7131 <url id="http://www.pathname.com/fhs/" name="FHS (upstream)">.
7132 Specific questions about following the standard may be
7133 asked on the <tt>debian-devel</tt> mailing list, or
7134 referred to the FHS mailing list (see the
7135 <url id="http://www.pathname.com/fhs/" name="FHS web site"> for
7136 more information).
7137 </p>
7138 </sect1>
7140 <sect1>
7141 <heading>Site-specific programs</heading>
7144 As mandated by the FHS, packages must not place any
7145 files in <file>/usr/local</file>, either by putting them in
7146 the file system archive to be unpacked by <prgn>dpkg</prgn>
7147 or by manipulating them in their maintainer scripts.
7148 </p>
7151 However, the package may create empty directories below
7152 <file>/usr/local</file> so that the system administrator knows
7153 where to place site-specific files. These are not
7154 directories <em>in</em> <file>/usr/local</file>, but are
7155 children of directories in <file>/usr/local</file>. These
7156 directories (<file>/usr/local/*/dir/</file>)
7157 should be removed on package removal if they are
7158 empty.
7159 </p>
7162 Note that this applies only to
7163 directories <em>below</em> <file>/usr/local</file>,
7164 not <em>in</em> <file>/usr/local</file>. Packages must
7165 not create sub-directories in the
7166 directory <file>/usr/local</file> itself, except those
7167 listed in FHS, section 4.5. However, you may create
7168 directories below them as you wish. You must not remove
7169 any of the directories listed in 4.5, even if you created
7170 them.
7171 </p>
7174 Since <file>/usr/local</file> can be mounted read-only from a
7175 remote server, these directories must be created and
7176 removed by the <prgn>postinst</prgn> and <prgn>prerm</prgn>
7177 maintainer scripts and not be included in the
7178 <file>.deb</file> archive. These scripts must not fail if
7179 either of these operations fail.
7180 </p>
7183 For example, the <tt>emacsen-common</tt> package could
7184 contain something like
7185 <example compact="compact">
7186 if [ ! -e /usr/local/share/emacs ]; then
7187 if mkdir /usr/local/share/emacs 2&gt;/dev/null; then
7188 if chown root:staff /usr/local/share/emacs; then
7189 chmod 2775 /usr/local/share/emacs || true
7193 </example>
7194 in its <prgn>postinst</prgn> script, and
7195 <example compact="compact">
7196 rmdir /usr/local/share/emacs/site-lisp 2&gt;/dev/null || true
7197 rmdir /usr/local/share/emacs 2&gt;/dev/null || true
7198 </example>
7199 in the <prgn>prerm</prgn> script. (Note that this form is
7200 used to ensure that if the script is interrupted, the
7201 directory <file>/usr/local/share/emacs</file> will still be
7202 removed.)
7203 </p>
7206 If you do create a directory in <file>/usr/local</file> for
7207 local additions to a package, you should ensure that
7208 settings in <file>/usr/local</file> take precedence over the
7209 equivalents in <file>/usr</file>.
7210 </p>
7213 However, because <file>/usr/local</file> and its contents are
7214 for exclusive use of the local administrator, a package
7215 must not rely on the presence or absence of files or
7216 directories in <file>/usr/local</file> for normal operation.
7217 </p>
7220 The <file>/usr/local</file> directory itself and all the
7221 subdirectories created by the package should (by default) have
7222 permissions 2775 (group-writable and set-group-id) and be
7223 owned by <tt>root:staff</tt>.
7224 </p>
7225 </sect1>
7227 <sect1>
7228 <heading>The system-wide mail directory</heading>
7230 The system-wide mail directory
7231 is <file>/var/mail</file>. This directory is part of the
7232 base system and should not be owned by any particular mail
7233 agents. The use of the old
7234 location <file>/var/spool/mail</file> is deprecated, even
7235 though the spool may still be physically located there.
7236 </p>
7237 </sect1>
7239 <sect1 id="fhs-run">
7240 <heading><file>/run</file> and <file>/run/lock</file></heading>
7243 The directory <file>/run</file> is cleared at boot, normally
7244 by being a mount point for a temporary file system. Packages
7245 therefore must not assume that any files or directories
7246 under <file>/run</file> other than <file>/run/lock</file>
7247 exist unless the package has arranged to create those files or
7248 directories since the last reboot. Normally, this is done by
7249 the package via an init script. See <ref id="writing-init">
7250 for more information.
7251 </p>
7254 Packages must not include files or directories
7255 under <file>/run</file>, or under the
7256 older <file>/var/run</file> and <file>/var/lock</file> paths.
7257 The latter paths will normally be symlinks or other
7258 redirections to <file>/run</file> for backwards compatibility.
7259 </p>
7260 </sect1>
7261 </sect>
7263 <sect>
7264 <heading>Users and groups</heading>
7266 <sect1>
7267 <heading>Introduction</heading>
7269 The Debian system can be configured to use either plain or
7270 shadow passwords.
7271 </p>
7274 Some user ids (UIDs) and group ids (GIDs) are reserved
7275 globally for use by certain packages. Because some
7276 packages need to include files which are owned by these
7277 users or groups, or need the ids compiled into binaries,
7278 these ids must be used on any Debian system only for the
7279 purpose for which they are allocated. This is a serious
7280 restriction, and we should avoid getting in the way of
7281 local administration policies. In particular, many sites
7282 allocate users and/or local system groups starting at 100.
7283 </p>
7286 Apart from this we should have dynamically allocated ids,
7287 which should by default be arranged in some sensible
7288 order, but the behavior should be configurable.
7289 </p>
7292 Packages other than <tt>base-passwd</tt> must not modify
7293 <file>/etc/passwd</file>, <file>/etc/shadow</file>,
7294 <file>/etc/group</file> or <file>/etc/gshadow</file>.
7295 </p>
7296 </sect1>
7298 <sect1>
7299 <heading>UID and GID classes</heading>
7301 The UID and GID numbers are divided into classes as
7302 follows:
7303 <taglist>
7304 <tag>0-99:</tag>
7305 <item>
7307 Globally allocated by the Debian project, the same
7308 on every Debian system. These ids will appear in
7309 the <file>passwd</file> and <file>group</file> files of all
7310 Debian systems, new ids in this range being added
7311 automatically as the <tt>base-passwd</tt> package is
7312 updated.
7313 </p>
7316 Packages which need a single statically allocated
7317 uid or gid should use one of these; their
7318 maintainers should ask the <tt>base-passwd</tt>
7319 maintainer for ids.
7320 </p>
7321 </item>
7323 <tag>100-999:</tag>
7324 <item>
7326 Dynamically allocated system users and groups.
7327 Packages which need a user or group, but can have
7328 this user or group allocated dynamically and
7329 differently on each system, should use <tt>adduser
7330 --system</tt> to create the group and/or user.
7331 <prgn>adduser</prgn> will check for the existence of
7332 the user or group, and if necessary choose an unused
7333 id based on the ranges specified in
7334 <file>adduser.conf</file>.
7335 </p>
7336 </item>
7338 <tag>1000-59999:</tag>
7339 <item>
7341 Dynamically allocated user accounts. By default
7342 <prgn>adduser</prgn> will choose UIDs and GIDs for
7343 user accounts in this range, though
7344 <file>adduser.conf</file> may be used to modify this
7345 behavior.
7346 </p>
7347 </item>
7349 <tag>60000-64999:</tag>
7350 <item>
7352 Globally allocated by the Debian project, but only
7353 created on demand. The ids are allocated centrally
7354 and statically, but the actual accounts are only
7355 created on users' systems on demand.
7356 </p>
7359 These ids are for packages which are obscure or
7360 which require many statically-allocated ids. These
7361 packages should check for and create the accounts in
7362 <file>/etc/passwd</file> or <file>/etc/group</file> (using
7363 <prgn>adduser</prgn> if it has this facility) if
7364 necessary. Packages which are likely to require
7365 further allocations should have a "hole" left after
7366 them in the allocation, to give them room to
7367 grow.
7368 </p>
7369 </item>
7371 <tag>65000-65533:</tag>
7372 <item>
7373 <p>Reserved.</p>
7374 </item>
7376 <tag>65534:</tag>
7377 <item>
7379 User <tt>nobody</tt>. The corresponding gid refers
7380 to the group <tt>nogroup</tt>.
7381 </p>
7382 </item>
7384 <tag>65535:</tag>
7385 <item>
7387 This value <em>must not</em> be used, because it was
7388 the error return sentinel value when <tt>uid_t</tt>
7389 was 16 bits.
7390 </p>
7391 </item>
7393 <tag>65536-4294967293:</tag>
7394 <item>
7396 Dynamically allocated user accounts. By
7397 default <prgn>adduser</prgn> will not allocate UIDs
7398 and GIDs in this range, to ease compatibility with
7399 legacy systems where <tt>uid_t</tt> is still 16
7400 bits.
7401 </p>
7402 </item>
7404 <tag>4294967294:</tag>
7405 <item>
7407 <tt>(uid_t)(-2) == (gid_t)(-2)</tt> <em>must not</em> be
7408 used, because it is used as the anonymous, unauthenticated
7409 user by some NFS implementations.
7410 </p>
7411 </item>
7413 <tag>4294967295:</tag>
7414 <item>
7416 <tt>(uid_t)(-1) == (gid_t)(-1)</tt> <em>must
7417 not</em> be used, because it is the error return
7418 sentinel value.
7419 </p>
7420 </item>
7421 </taglist>
7422 </p>
7423 </sect1>
7424 </sect>
7426 <sect id="sysvinit">
7427 <heading>System run levels and <file>init.d</file> scripts</heading>
7429 <sect1 id="etc-init.d">
7430 <heading>Introduction</heading>
7433 The <file>/etc/init.d</file> directory contains the scripts
7434 executed by <prgn>init</prgn> at boot time and when the
7435 init state (or "runlevel") is changed (see <manref
7436 name="init" section="8">).
7437 </p>
7440 There are at least two different, yet functionally
7441 equivalent, ways of handling these scripts. For the sake
7442 of simplicity, this document describes only the symbolic
7443 link method. However, it must not be assumed by maintainer
7444 scripts that this method is being used, and any automated
7445 manipulation of the various runlevel behaviors by
7446 maintainer scripts must be performed using
7447 <prgn>update-rc.d</prgn> as described below and not by
7448 manually installing or removing symlinks. For information
7449 on the implementation details of the other method,
7450 implemented in the <tt>file-rc</tt> package, please refer
7451 to the documentation of that package.
7452 </p>
7455 These scripts are referenced by symbolic links in the
7456 <file>/etc/rc<var>n</var>.d</file> directories. When changing
7457 runlevels, <prgn>init</prgn> looks in the directory
7458 <file>/etc/rc<var>n</var>.d</file> for the scripts it should
7459 execute, where <tt><var>n</var></tt> is the runlevel that
7460 is being changed to, or <tt>S</tt> for the boot-up
7461 scripts.
7462 </p>
7465 The names of the links all have the form
7466 <file>S<var>mm</var><var>script</var></file> or
7467 <file>K<var>mm</var><var>script</var></file> where
7468 <var>mm</var> is a two-digit number and <var>script</var>
7469 is the name of the script (this should be the same as the
7470 name of the actual script in <file>/etc/init.d</file>).
7471 </p>
7474 When <prgn>init</prgn> changes runlevel first the targets
7475 of the links whose names start with a <tt>K</tt> are
7476 executed, each with the single argument <tt>stop</tt>,
7477 followed by the scripts prefixed with an <tt>S</tt>, each
7478 with the single argument <tt>start</tt>. (The links are
7479 those in the <file>/etc/rc<var>n</var>.d</file> directory
7480 corresponding to the new runlevel.) The <tt>K</tt> links
7481 are responsible for killing services and the <tt>S</tt>
7482 link for starting services upon entering the runlevel.
7483 </p>
7486 For example, if we are changing from runlevel 2 to
7487 runlevel 3, init will first execute all of the <tt>K</tt>
7488 prefixed scripts it finds in <file>/etc/rc3.d</file>, and then
7489 all of the <tt>S</tt> prefixed scripts in that directory.
7490 The links starting with <tt>K</tt> will cause the
7491 referred-to file to be executed with an argument of
7492 <tt>stop</tt>, and the <tt>S</tt> links with an argument
7493 of <tt>start</tt>.
7494 </p>
7497 The two-digit number <var>mm</var> is used to determine
7498 the order in which to run the scripts: low-numbered links
7499 have their scripts run first. For example, the
7500 <tt>K20</tt> scripts will be executed before the
7501 <tt>K30</tt> scripts. This is used when a certain service
7502 must be started before another. For example, the name
7503 server <prgn>bind</prgn> might need to be started before
7504 the news server <prgn>inn</prgn> so that <prgn>inn</prgn>
7505 can set up its access lists. In this case, the script
7506 that starts <prgn>bind</prgn> would have a lower number
7507 than the script that starts <prgn>inn</prgn> so that it
7508 runs first:
7509 <example compact="compact">
7510 /etc/rc2.d/S17bind
7511 /etc/rc2.d/S70inn
7512 </example>
7513 </p>
7516 The two runlevels 0 (halt) and 6 (reboot) are slightly
7517 different. In these runlevels, the links with an
7518 <tt>S</tt> prefix are still called after those with a
7519 <tt>K</tt> prefix, but they too are called with the single
7520 argument <tt>stop</tt>.
7521 </p>
7522 </sect1>
7524 <sect1 id="writing-init">
7525 <heading>Writing the scripts</heading>
7528 Packages that include daemons for system services should
7529 place scripts in <file>/etc/init.d</file> to start or stop
7530 services at boot time or during a change of runlevel.
7531 These scripts should be named
7532 <file>/etc/init.d/<var>package</var></file>, and they should
7533 accept one argument, saying what to do:
7535 <taglist>
7536 <tag><tt>start</tt></tag>
7537 <item>start the service,</item>
7539 <tag><tt>stop</tt></tag>
7540 <item>stop the service,</item>
7542 <tag><tt>restart</tt></tag>
7543 <item>stop and restart the service if it's already running,
7544 otherwise start the service</item>
7546 <tag><tt>try-restart</tt></tag>
7547 <item>restart the service if it's already running,
7548 otherwise just report success.</item>
7550 <tag><tt>reload</tt></tag>
7551 <item><p>cause the configuration of the service to be
7552 reloaded without actually stopping and restarting
7553 the service,</item>
7555 <tag><tt>force-reload</tt></tag>
7556 <item>cause the configuration to be reloaded if the
7557 service supports this, otherwise restart the
7558 service.</item>
7560 <tag><tt>status</tt></tag>
7561 <item>report the current status of the service</item>
7562 </taglist>
7564 The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
7565 <tt>force-reload</tt> options should be supported by all
7566 scripts in <file>/etc/init.d</file>. Supporting
7567 <tt>status</tt> is recommended but not required.
7568 The <tt>reload</tt> and <tt>try-restart</tt> options are
7569 optional.
7570 </p>
7573 The <file>init.d</file> scripts must ensure that they will
7574 behave sensibly (i.e., returning success and not starting
7575 multiple copies of a service) if invoked with <tt>start</tt>
7576 when the service is already running, or with <tt>stop</tt>
7577 when it isn't, and that they don't kill unfortunately-named
7578 user processes. The best way to achieve this is usually to
7579 use <prgn>start-stop-daemon</prgn> with the <tt>--oknodo</tt>
7580 option.
7581 </p>
7584 Be careful of using <tt>set -e</tt> in <file>init.d</file>
7585 scripts. Writing correct <file>init.d</file> scripts requires
7586 accepting various error exit statuses when daemons are already
7587 running or already stopped without aborting
7588 the <file>init.d</file> script, and common <file>init.d</file>
7589 function libraries are not safe to call with <tt>set -e</tt>
7590 in effect<footnote>
7591 <tt>/lib/lsb/init-functions</tt>, which assists in writing
7592 LSB-compliant init scripts, may fail if <tt>set -e</tt> is
7593 in effect and echoing status messages to the console fails,
7594 for example.
7595 </footnote>. For <tt>init.d</tt> scripts, it's often easier
7596 to not use <tt>set -e</tt> and instead check the result of
7597 each command separately.
7598 </p>
7601 If a service reloads its configuration automatically (as
7602 in the case of <prgn>cron</prgn>, for example), the
7603 <tt>reload</tt> option of the <file>init.d</file> script
7604 should behave as if the configuration has been reloaded
7605 successfully.
7606 </p>
7609 The <file>/etc/init.d</file> scripts must be treated as
7610 configuration files, either (if they are present in the
7611 package, that is, in the .deb file) by marking them as
7612 <tt>conffile</tt>s, or, (if they do not exist in the .deb)
7613 by managing them correctly in the maintainer scripts (see
7614 <ref id="config-files">). This is important since we want
7615 to give the local system administrator the chance to adapt
7616 the scripts to the local system, e.g., to disable a
7617 service without de-installing the package, or to specify
7618 some special command line options when starting a service,
7619 while making sure their changes aren't lost during the next
7620 package upgrade.
7621 </p>
7624 These scripts should not fail obscurely when the
7625 configuration files remain but the package has been
7626 removed, as configuration files remain on the system after
7627 the package has been removed. Only when <prgn>dpkg</prgn>
7628 is executed with the <tt>--purge</tt> option will
7629 configuration files be removed. In particular, as the
7630 <file>/etc/init.d/<var>package</var></file> script itself is
7631 usually a <tt>conffile</tt>, it will remain on the system
7632 if the package is removed but not purged. Therefore, you
7633 should include a <tt>test</tt> statement at the top of the
7634 script, like this:
7635 <example compact="compact">
7636 test -f <var>program-executed-later-in-script</var> || exit 0
7637 </example>
7638 </p>
7641 Often there are some variables in the <file>init.d</file>
7642 scripts whose values control the behavior of the scripts,
7643 and which a system administrator is likely to want to
7644 change. As the scripts themselves are frequently
7645 <tt>conffile</tt>s, modifying them requires that the
7646 administrator merge in their changes each time the package
7647 is upgraded and the <tt>conffile</tt> changes. To ease
7648 the burden on the system administrator, such configurable
7649 values should not be placed directly in the script.
7650 Instead, they should be placed in a file in
7651 <file>/etc/default</file>, which typically will have the same
7652 base name as the <file>init.d</file> script. This extra file
7653 should be sourced by the script when the script runs. It
7654 must contain only variable settings and comments in SUSv3
7655 <prgn>sh</prgn> format. It may either be a
7656 <tt>conffile</tt> or a configuration file maintained by
7657 the package maintainer scripts. See <ref id="config-files">
7658 for more details.
7659 </p>
7662 To ensure that vital configurable values are always
7663 available, the <file>init.d</file> script should set default
7664 values for each of the shell variables it uses, either
7665 before sourcing the <file>/etc/default/</file> file or
7666 afterwards using something like the <tt>:
7667 ${VAR:=default}</tt> syntax. Also, the <file>init.d</file>
7668 script must behave sensibly and not fail if the
7669 <file>/etc/default</file> file is deleted.
7670 </p>
7673 Files and directories under <file>/run</file>, including ones
7674 referred to via the compatibility paths <file>/var/run</file>
7675 and <file>/var/lock</file>, are normally stored on a temporary
7676 filesystem and are normally not persistent across a reboot.
7677 The <file>init.d</file> scripts must handle this correctly.
7678 This will typically mean creating any required subdirectories
7679 dynamically when the <file>init.d</file> script is run.
7680 See <ref id="fhs-run"> for more information.
7681 </p>
7682 </sect1>
7684 <sect1>
7685 <heading>Interfacing with the initscript system</heading>
7688 Maintainers should use the abstraction layer provided by
7689 the <prgn>update-rc.d</prgn> and <prgn>invoke-rc.d</prgn>
7690 programs to deal with initscripts in their packages'
7691 scripts such as <prgn>postinst</prgn>, <prgn>prerm</prgn>
7692 and <prgn>postrm</prgn>.
7693 </p>
7696 Directly managing the /etc/rc?.d links and directly
7697 invoking the <file>/etc/init.d/</file> initscripts should
7698 be done only by packages providing the initscript
7699 subsystem (such as <prgn>sysv-rc</prgn> and
7700 <prgn>file-rc</prgn>).
7701 </p>
7703 <sect2>
7704 <heading>Managing the links</heading>
7707 The program <prgn>update-rc.d</prgn> is provided for
7708 package maintainers to arrange for the proper creation and
7709 removal of <file>/etc/rc<var>n</var>.d</file> symbolic links,
7710 or their functional equivalent if another method is being
7711 used. This may be used by maintainers in their packages'
7712 <prgn>postinst</prgn> and <prgn>postrm</prgn> scripts.
7713 </p>
7716 You must not include any <file>/etc/rc<var>n</var>.d</file>
7717 symbolic links in the actual archive or manually create or
7718 remove the symbolic links in maintainer scripts; you must
7719 use the <prgn>update-rc.d</prgn> program instead. (The
7720 former will fail if an alternative method of maintaining
7721 runlevel information is being used.) You must not include
7722 the <file>/etc/rc<var>n</var>.d</file> directories themselves
7723 in the archive either. (Only the <tt>sysvinit</tt>
7724 package may do so.)
7725 </p>
7728 By default <prgn>update-rc.d</prgn> will start services in
7729 each of the multi-user state runlevels (2, 3, 4, and 5)
7730 and stop them in the halt runlevel (0), the single-user
7731 runlevel (1) and the reboot runlevel (6). The system
7732 administrator will have the opportunity to customize
7733 runlevels by simply adding, moving, or removing the
7734 symbolic links in <file>/etc/rc<var>n</var>.d</file> if
7735 symbolic links are being used, or by modifying
7736 <file>/etc/runlevel.conf</file> if the <tt>file-rc</tt> method
7737 is being used.
7738 </p>
7741 To get the default behavior for your package, put in your
7742 <prgn>postinst</prgn> script
7743 <example compact="compact">
7744 update-rc.d <var>package</var> defaults
7745 </example>
7746 and in your <prgn>postrm</prgn>
7747 <example compact="compact">
7748 if [ "$1" = purge ]; then
7749 update-rc.d <var>package</var> remove
7751 </example>. Note that if your package changes runlevels
7752 or priority, you may have to remove and recreate the links,
7753 since otherwise the old links may persist. Refer to the
7754 documentation of <prgn>update-rc.d</prgn>.
7755 </p>
7758 This will use a default sequence number of 20. If it does
7759 not matter when or in which order the <file>init.d</file>
7760 script is run, use this default. If it does, then you
7761 should talk to the maintainer of the <prgn>sysvinit</prgn>
7762 package or post to <tt>debian-devel</tt>, and they will
7763 help you choose a number.
7764 </p>
7767 For more information about using <tt>update-rc.d</tt>,
7768 please consult its man page <manref name="update-rc.d"
7769 section="8">.
7770 </p>
7771 </sect2>
7773 <sect2>
7774 <heading>Running initscripts</heading>
7776 The program <prgn>invoke-rc.d</prgn> is provided to make
7777 it easier for package maintainers to properly invoke an
7778 initscript, obeying runlevel and other locally-defined
7779 constraints that might limit a package's right to start,
7780 stop and otherwise manage services. This program may be
7781 used by maintainers in their packages' scripts.
7782 </p>
7785 The package maintainer scripts must use
7786 <prgn>invoke-rc.d</prgn> to invoke the
7787 <file>/etc/init.d/*</file> initscripts, instead of
7788 calling them directly.
7789 </p>
7792 By default, <prgn>invoke-rc.d</prgn> will pass any
7793 action requests (start, stop, reload, restart...) to the
7794 <file>/etc/init.d</file> script, filtering out requests
7795 to start or restart a service out of its intended
7796 runlevels.
7797 </p>
7800 Most packages will simply need to change:
7801 <example compact="compact">
7802 /etc/init.d/<var>package</var> <var>action</var>
7803 </example> in their <prgn>postinst</prgn>
7804 and <prgn>prerm</prgn> scripts to:
7805 <example compact="compact">
7806 invoke-rc.d <var>package</var> <var>action</var>
7807 </example>
7808 </p>
7811 A package should register its initscript services using
7812 <prgn>update-rc.d</prgn> before it tries to invoke them
7813 using <prgn>invoke-rc.d</prgn>. Invocation of
7814 unregistered services may fail.
7815 </p>
7818 For more information about using
7819 <prgn>invoke-rc.d</prgn>, please consult its man page
7820 <manref name="invoke-rc.d" section="8">.
7821 </p>
7822 </sect2>
7823 </sect1>
7825 <sect1>
7826 <heading>Boot-time initialization</heading>
7829 There used to be another directory, <file>/etc/rc.boot</file>,
7830 which contained scripts which were run once per machine
7831 boot. This has been deprecated in favour of links from
7832 <file>/etc/rcS.d</file> to files in <file>/etc/init.d</file> as
7833 described in <ref id="etc-init.d">. Packages must not
7834 place files in <file>/etc/rc.boot</file>.
7835 </p>
7836 </sect1>
7838 <sect1>
7839 <heading>Example</heading>
7842 An example on which you can base your
7843 <file>/etc/init.d</file> scripts is found in
7844 <file>/etc/init.d/skeleton</file>.
7845 </p>
7847 </sect1>
7848 </sect>
7850 <sect>
7851 <heading>Console messages from <file>init.d</file> scripts</heading>
7854 This section describes the formats to be used for messages
7855 written to standard output by the <file>/etc/init.d</file>
7856 scripts. The intent is to improve the consistency of
7857 Debian's startup and shutdown look and feel. For this
7858 reason, please look very carefully at the details. We want
7859 the messages to have the same format in terms of wording,
7860 spaces, punctuation and case of letters.
7861 </p>
7864 Here is a list of overall rules that should be used for
7865 messages generated by <file>/etc/init.d</file> scripts.
7866 </p>
7869 <list>
7870 <item>
7871 The message should fit in one line (fewer than 80
7872 characters), start with a capital letter and end with
7873 a period (<tt>.</tt>) and line feed (<tt>"\n"</tt>).
7874 </item>
7876 <item>
7877 If the script is performing some time consuming task in
7878 the background (not merely starting or stopping a
7879 program, for instance), an ellipsis (three dots:
7880 <tt>...</tt>) should be output to the screen, with no
7881 leading or tailing whitespace or line feeds.
7882 </item>
7884 <item>
7885 The messages should appear as if the computer is telling
7886 the user what it is doing (politely :-), but should not
7887 mention "it" directly. For example, instead of:
7888 <example compact="compact">
7889 I'm starting network daemons: nfsd mountd.
7890 </example>
7891 the message should say
7892 <example compact="compact">
7893 Starting network daemons: nfsd mountd.
7894 </example>
7895 </item>
7896 </list>
7897 </p>
7900 <tt>init.d</tt> script should use the following standard
7901 message formats for the situations enumerated below.
7902 </p>
7905 <list>
7906 <item>
7907 <p>When daemons are started</p>
7910 If the script starts one or more daemons, the output
7911 should look like this (a single line, no leading
7912 spaces):
7913 <example compact="compact">
7914 Starting <var>description</var>: <var>daemon-1</var> ... <var>daemon-n</var>.
7915 </example>
7916 The <var>description</var> should describe the
7917 subsystem the daemon or set of daemons are part of,
7918 while <var>daemon-1</var> up to <var>daemon-n</var>
7919 denote each daemon's name (typically the file name of
7920 the program).
7921 </p>
7924 For example, the output of <file>/etc/init.d/lpd</file>
7925 would look like:
7926 <example compact="compact">
7927 Starting printer spooler: lpd.
7928 </example>
7929 </p>
7932 This can be achieved by saying
7933 <example compact="compact">
7934 echo -n "Starting printer spooler: lpd"
7935 start-stop-daemon --start --quiet --exec /usr/sbin/lpd
7936 echo "."
7937 </example>
7938 in the script. If there are more than one daemon to
7939 start, the output should look like this:
7940 <example compact="compact">
7941 echo -n "Starting remote file system services:"
7942 echo -n " nfsd"; start-stop-daemon --start --quiet nfsd
7943 echo -n " mountd"; start-stop-daemon --start --quiet mountd
7944 echo -n " ugidd"; start-stop-daemon --start --quiet ugidd
7945 echo "."
7946 </example>
7947 This makes it possible for the user to see what is
7948 happening and when the final daemon has been started.
7949 Care should be taken in the placement of white spaces:
7950 in the example above the system administrators can
7951 easily comment out a line if they don't want to start
7952 a specific daemon, while the displayed message still
7953 looks good.
7954 </p>
7955 </item>
7957 <item>
7958 <p>When a system parameter is being set</p>
7961 If you have to set up different system parameters
7962 during the system boot, you should use this format:
7963 <example compact="compact">
7964 Setting <var>parameter</var> to "<var>value</var>".
7965 </example>
7966 </p>
7969 You can use a statement such as the following to get
7970 the quotes right:
7971 <example compact="compact">
7972 echo "Setting DNS domainname to \"$domainname\"."
7973 </example>
7974 </p>
7977 Note that the same symbol (<tt>"</tt>) <!-- " --> is used
7978 for the left and right quotation marks. A grave accent
7979 (<tt>`</tt>) is not a quote character; neither is an
7980 apostrophe (<tt>'</tt>).
7981 </p>
7982 </item>
7984 <item>
7985 <p>When a daemon is stopped or restarted</p>
7988 When you stop or restart a daemon, you should issue a
7989 message identical to the startup message, except that
7990 <tt>Starting</tt> is replaced with <tt>Stopping</tt>
7991 or <tt>Restarting</tt> respectively.
7992 </p>
7995 For example, stopping the printer daemon will look like
7996 this:
7997 <example compact="compact">
7998 Stopping printer spooler: lpd.
7999 </example>
8000 </p>
8001 </item>
8003 <item>
8004 <p>When something is executed</p>
8007 There are several examples where you have to run a
8008 program at system startup or shutdown to perform a
8009 specific task, for example, setting the system's clock
8010 using <prgn>netdate</prgn> or killing all processes
8011 when the system shuts down. Your message should look
8012 like this:
8013 <example compact="compact">
8014 Doing something very useful...done.
8015 </example>
8016 You should print the <tt>done.</tt> immediately after
8017 the job has been completed, so that the user is
8018 informed why they have to wait. You can get this
8019 behavior by saying
8020 <example compact="compact">
8021 echo -n "Doing something very useful..."
8022 do_something
8023 echo "done."
8024 </example>
8025 in your script.
8026 </p>
8027 </item>
8029 <item>
8030 <p>When the configuration is reloaded</p>
8033 When a daemon is forced to reload its configuration
8034 files you should use the following format:
8035 <example compact="compact">
8036 Reloading <var>description</var> configuration...done.
8037 </example>
8038 where <var>description</var> is the same as in the
8039 daemon starting message.
8040 </p>
8041 </item>
8042 </list>
8043 </p>
8044 </sect>
8046 <sect id="cron-jobs">
8047 <heading>Cron jobs</heading>
8050 Packages must not modify the configuration file
8051 <file>/etc/crontab</file>, and they must not modify the files in
8052 <file>/var/spool/cron/crontabs</file>.
8053 </p>
8056 If a package wants to install a job that has to be executed via
8057 cron, it should place a file named as specified
8058 in <ref id="cron-files"> into one or more of the following
8059 directories:
8060 <example compact="compact">
8061 /etc/cron.hourly
8062 /etc/cron.daily
8063 /etc/cron.weekly
8064 /etc/cron.monthly
8065 </example>
8066 As these directory names imply, the files within them are
8067 executed on an hourly, daily, weekly, or monthly basis,
8068 respectively. The exact times are listed in
8069 <file>/etc/crontab</file>.
8070 </p>
8073 All files installed in any of these directories must be
8074 scripts (e.g., shell scripts or Perl scripts) so that they
8075 can easily be modified by the local system administrator.
8076 In addition, they must be treated as configuration files.
8077 </p>
8080 If a certain job has to be executed at some other frequency or
8081 at a specific time, the package should install a file in
8082 <file>/etc/cron.d</file> with a name as specified
8083 in <ref id="cron-files">. This file uses the same syntax
8084 as <file>/etc/crontab</file> and is processed
8085 by <prgn>cron</prgn> automatically. The file must also be
8086 treated as a configuration file. (Note that entries in the
8087 <file>/etc/cron.d</file> directory are not handled by
8088 <prgn>anacron</prgn>. Thus, you should only use this
8089 directory for jobs which may be skipped if the system is not
8090 running.)
8091 </p>
8094 Unlike <file>crontab</file> files described in the IEEE Std
8095 1003.1-2008 (POSIX.1) available from
8096 <url id="http://www.opengroup.org/onlinepubs/9699919799/"
8097 name="The Open Group">, the files in
8098 <file>/etc/cron.d</file> and the file
8099 <file>/etc/crontab</file> have seven fields; namely:
8100 <enumlist>
8101 <item>Minute [0,59]</item>
8102 <item>Hour [0,23]</item>
8103 <item>Day of the month [1,31]</item>
8104 <item>Month of the year [1,12]</item>
8105 <item>Day of the week ([0,6] with 0=Sunday)</item>
8106 <item>Username</item>
8107 <item>Command to be run</item>
8108 </enumlist>
8109 Ranges of numbers are allowed. Ranges are two numbers
8110 separated with a hyphen. The specified range is inclusive.
8111 Lists are allowed. A list is a set of numbers (or ranges)
8112 separated by commas. Step values can be used in conjunction
8113 with ranges.
8114 </p>
8117 The scripts or <tt>crontab</tt> entries in these directories should
8118 check if all necessary programs are installed before they
8119 try to execute them. Otherwise, problems will arise when a
8120 package was removed but not purged since configuration files
8121 are kept on the system in this situation.
8122 </p>
8125 Any <tt>cron</tt> daemon must provide
8126 <file>/usr/bin/crontab</file> and support normal
8127 <tt>crontab</tt> entries as specified in POSIX. The daemon
8128 must also support names for days and months, ranges, and
8129 step values. It has to support <file>/etc/crontab</file>,
8130 and correctly execute the scripts in
8131 <file>/etc/cron.d</file>. The daemon must also correctly
8132 execute scripts in
8133 <file>/etc/cron.{hourly,daily,weekly,monthly}</file>.
8134 </p>
8136 <sect1 id="cron-files">
8137 <heading>Cron job file names</heading>
8140 The file name of a cron job file should normally match the
8141 name of the package from which it comes.
8142 </p>
8145 If a package supplies multiple cron job files files in the
8146 same directory, the file names should all start with the name
8147 of the package (possibly modified as described below) followed
8148 by a hyphen (<tt>-</tt>) and a suitable suffix.
8149 </p>
8152 A cron job file name must not include any period or plus
8153 characters (<tt>.</tt> or <tt>+</tt>) characters as this will
8154 cause cron to ignore the file. Underscores (<tt>_</tt>)
8155 should be used instead of <tt>.</tt> and <tt>+</tt>
8156 characters.
8157 </p>
8158 </sect1>
8159 </sect>
8161 <sect id="menus">
8162 <heading>Menus</heading>
8165 Packages shipping applications that comply with minimal requirements
8166 described below for integration with desktop environments should
8167 register these applications in the desktop menu, following the
8168 <em>FreeDesktop</em> standard, using text files called
8169 <em>desktop entries</em>. Their format is described in the
8170 <em>Desktop Entry Specification</em> at
8171 <url id="http://standards.freedesktop.org/desktop-entry-spec/latest/">
8172 and complementary information can be found in the
8173 <em>Desktop Menu Specification</em> at
8174 <url id="http://standards.freedesktop.org/menu-spec/latest/">.
8175 </p>
8178 The desktop entry files are installed by the packages in the
8179 directory <file>/usr/share/applications</file> and the FreeDesktop
8180 menus are refreshed using <em>dpkg triggers</em>. It is therefore
8181 not necessary to depend on packages providing FreeDesktop menu
8182 systems.
8183 </p>
8186 Entries displayed in the FreeDesktop menu should conform to the
8187 following minima for relevance and visual integration.
8189 <list>
8190 <item>
8191 Unless hidden by default, the desktop entry must point to a PNG
8192 or SVG icon with a transparent background, providing at least
8193 the 22&times;22 size, and preferably up to 64&times;64. The icon
8194 should be neutral enough to integrate well with the default icon
8195 themes. It is encouraged to ship the icon in the default
8196 <em>hicolor</em> icon theme directories, or to use an existing
8197 icon from the <em>hicolor</em> theme.
8198 </item>
8200 <item>
8201 If the menu entry is not useful in the general case as a
8202 standalone application, the desktop entry should set the
8203 <tt>NoDisplay</tt> key to <var>true</var>, so that it can be
8204 configured to be displayed only by those who need it.
8205 </item>
8207 <item>
8208 In doubt, the package maintainer should coordinate with the
8209 maintainers of menu implementations through the
8210 <em>debian-desktop</em> mailing list in order to avoid problems
8211 with categories or bad interactions with other icons. Especially
8212 for packages which are part of installation tasks, the contents
8213 of the <tt>NotShowIn</tt>/<tt>OnlyShowIn</tt> keys should be
8214 validated by the maintainers of the relevant environments.
8215 </item>
8216 </list>
8217 </p>
8220 Since the FreeDesktop menu is a cross-distribution standard, the
8221 desktop entries written for Debian should be forwarded upstream,
8222 where they will benefit to other users and are more likely to
8223 receive extra contributions such as translations.
8224 </p>
8227 Packages can, to be compatible with Debian additions to some window
8228 managers that do not support the FreeDesktop standard, also provide a
8229 <em>Debian menu</em> file, following the <em>Debian menu policy</em>,
8230 which can be found in the <tt>menu-policy</tt> files in the
8231 <tt>debian-policy</tt> package. It is also available from the Debian
8232 web mirrors at <tt><url name="/doc/packaging-manuals/menu-policy/"
8233 id="http://www.debian.org/doc/packaging-manuals/menu-policy/"></tt>.
8234 </p>
8235 </sect>
8237 <sect id="mime">
8238 <heading>Multimedia handlers</heading>
8241 Media types (formerly known as MIME types, Multipurpose Internet Mail
8242 Extensions, RFCs 2045-2049) is a mechanism for encoding files and
8243 data streams and providing meta-information about them, in particular
8244 their type and format (e.g. <tt>image/png</tt>, <tt>text/html</tt>,
8245 <tt>audio/ogg</tt>).
8246 </p>
8249 Registration of media type handlers allows programs like mail
8250 user agents and web browsers to invoke these handlers to
8251 view, edit or display media types they don't support directly.
8252 </p>
8255 There are two overlapping systems to associate media types to programs
8256 which can handle them. The <em>mailcap</em> system is found on a
8257 large number of Unix systems. The <em>FreeDesktop</em> system is
8258 aimed at Desktop environments. In Debian, FreeDesktop entries are
8259 automatically translated in mailcap entries, therefore packages
8260 already using desktop entries should not use the mailcap system
8261 directly.
8262 </p>
8264 <sect1 id="media-types-freedesktop">
8265 <heading>Registration of media type handlers with desktop entries</heading>
8268 Packages shipping an application able to view, edit or point to
8269 files of a given media type, or open links with a given URI scheme,
8270 should list it in the <tt>MimeType</tt> key of the application's
8271 <qref id="menus">desktop entry</qref>. For URI schemes,
8272 the relevant MIME types are <tt>x-scheme-handler/*</tt> (e.g.
8273 <tt>x-scheme-handler/https</tt>).
8274 </p>
8275 </sect1>
8277 <sect1 id="mailcap">
8278 <heading>Registration of media type handlers with mailcap entries</heading>
8281 Packages that are not using desktop entries for registration should
8282 install a file in <manref name="mailcap" section="5"> format (RFC
8283 1524) in the directory <file>/usr/lib/mime/packages/</file>. The
8284 file name should be the binary package's name.
8285 </p>
8288 The <package>mime-support</package> package provides the
8289 <prgn>update-mime</prgn> program, which integrates these
8290 registrations in the <file>/etc/mailcap</file> file, using dpkg
8291 triggers<footnote>
8292 Creating, modifying or removing a file in
8293 <file>/usr/lib/mime/packages/</file> using maintainer scripts will
8294 not activate the trigger. In that case, it can be done by calling
8295 <tt>dpkg-trigger --no-await /usr/lib/mime/packages</tt> from
8296 the maintainer script after creating, modifying, or removing
8297 the file.
8298 </footnote>.
8301 Packages installing desktop entries should not install mailcap
8302 entries for the same program, because the
8303 <package>mime-support</package> package already reads desktop
8304 entries.
8305 </p>
8308 Packages using these facilities <em>should not</em> depend on,
8309 recommend, or suggest <prgn>mime-support</prgn>.
8310 </p>
8311 </sect1>
8313 <sect1 id="file-media-type">
8314 <heading>Providing media types to files</heading>
8317 The media type of a file is discovered by inspecting the file's
8318 extension or its <manref name="magic" section="5"> pattern, and
8319 interrogating a database associating them with media types.
8320 </p>
8323 To support new associations between media types and files, their
8324 characteristic file extensions and magic patterns should be
8325 registered to the IANA (Internet Assigned Numbers Authority). See
8326 <url id="http://www.iana.org/assignments/media-types"> and RFC 6838
8327 for details. This information will then propagate to the systems
8328 discovering file media types in Debian, provided by the
8329 <package>shared-mime-info</package>,
8330 <package>mime-support</package> and <package>file</package>
8331 packages. If registration and propagation can not be waited for,
8332 support can be asked to the maintainers of the packages mentioned
8333 above.
8334 </p>
8337 For files that are produced and read by a single application, it
8338 is also possible to declare this association to the
8339 <em>Shared MIME Info</em> system by installing in the directory
8340 <file>/usr/share/mime/packages</file> a file in the XML format
8341 specified at <url id="http://standards.freedesktop.org/shared-mime-info-spec/latest/">.
8342 </p>
8343 </sect1>
8344 </sect>
8346 <sect>
8347 <heading>Keyboard configuration</heading>
8350 To achieve a consistent keyboard configuration so that all
8351 applications interpret a keyboard event the same way, all
8352 programs in the Debian distribution must be configured to
8353 comply with the following guidelines.
8354 </p>
8357 The following keys must have the specified interpretations:
8359 <taglist>
8360 <tag><tt>&lt;--</tt></tag>
8361 <item>delete the character to the left of the cursor</item>
8363 <tag><tt>Delete</tt></tag>
8364 <item>delete the character to the right of the cursor</item>
8366 <tag><tt>Control+H</tt></tag>
8367 <item>emacs: the help prefix</item>
8368 </taglist>
8370 The interpretation of any keyboard events should be
8371 independent of the terminal that is used, be it a virtual
8372 console, an X terminal emulator, an rlogin/telnet session,
8373 etc.
8374 </p>
8377 The following list explains how the different programs
8378 should be set up to achieve this:
8379 </p>
8382 <list>
8383 <item>
8384 <tt>&lt;--</tt> generates <tt>KB_BackSpace</tt> in X.
8385 </item>
8387 <item>
8388 <tt>Delete</tt> generates <tt>KB_Delete</tt> in X.
8389 </item>
8391 <item>
8392 X translations are set up to make
8393 <tt>KB_Backspace</tt> generate ASCII DEL, and to make
8394 <tt>KB_Delete</tt> generate <tt>ESC [ 3 ~</tt> (this
8395 is the vt220 escape code for the "delete character"
8396 key). This must be done by loading the X resources
8397 using <prgn>xrdb</prgn> on all local X displays, not
8398 using the application defaults, so that the
8399 translation resources used correspond to the
8400 <prgn>xmodmap</prgn> settings.
8401 </item>
8403 <item>
8404 The Linux console is configured to make
8405 <tt>&lt;--</tt> generate DEL, and <tt>Delete</tt>
8406 generate <tt>ESC [ 3 ~</tt>.
8407 </item>
8409 <item>
8410 X applications are configured so that <tt>&lt;</tt>
8411 deletes left, and <tt>Delete</tt> deletes right. Motif
8412 applications already work like this.
8413 </item>
8415 <item>
8416 Terminals should have <tt>stty erase ^?</tt> .
8417 </item>
8419 <item>
8420 The <tt>xterm</tt> terminfo entry should have <tt>ESC
8421 [ 3 ~</tt> for <tt>kdch1</tt>, just as for
8422 <tt>TERM=linux</tt> and <tt>TERM=vt220</tt>.
8423 </item>
8425 <item>
8426 Emacs is programmed to map <tt>KB_Backspace</tt> or
8427 the <tt>stty erase</tt> character to
8428 <tt>delete-backward-char</tt>, and <tt>KB_Delete</tt>
8429 or <tt>kdch1</tt> to <tt>delete-forward-char</tt>, and
8430 <tt>^H</tt> to <tt>help</tt> as always.
8431 </item>
8433 <item>
8434 Other applications use the <tt>stty erase</tt>
8435 character and <tt>kdch1</tt> for the two delete keys,
8436 with ASCII DEL being "delete previous character" and
8437 <tt>kdch1</tt> being "delete character under
8438 cursor".
8439 </item>
8441 </list>
8442 </p>
8445 This will solve the problem except for the following
8446 cases:
8447 </p>
8450 <list>
8451 <item>
8452 Some terminals have a <tt>&lt;--</tt> key that cannot
8453 be made to produce anything except <tt>^H</tt>. On
8454 these terminals Emacs help will be unavailable on
8455 <tt>^H</tt> (assuming that the <tt>stty erase</tt>
8456 character takes precedence in Emacs, and has been set
8457 correctly). <tt>M-x help</tt> or <tt>F1</tt> (if
8458 available) can be used instead.
8459 </item>
8461 <item>
8462 Some operating systems use <tt>^H</tt> for <tt>stty
8463 erase</tt>. However, modern telnet versions and all
8464 rlogin versions propagate <tt>stty</tt> settings, and
8465 almost all UNIX versions honour <tt>stty erase</tt>.
8466 Where the <tt>stty</tt> settings are not propagated
8467 correctly, things can be made to work by using
8468 <tt>stty</tt> manually.
8469 </item>
8471 <item>
8472 Some systems (including previous Debian versions) use
8473 <prgn>xmodmap</prgn> to arrange for both
8474 <tt>&lt;--</tt> and <tt>Delete</tt> to generate
8475 <tt>KB_Delete</tt>. We can change the behavior of
8476 their X clients using the same X resources that we use
8477 to do it for our own clients, or configure our clients
8478 using their resources when things are the other way
8479 around. On displays configured like this
8480 <tt>Delete</tt> will not work, but <tt>&lt;--</tt>
8481 will.
8482 </item>
8484 <item>
8485 Some operating systems have different <tt>kdch1</tt>
8486 settings in their <tt>terminfo</tt> database for
8487 <tt>xterm</tt> and others. On these systems the
8488 <tt>Delete</tt> key will not work correctly when you
8489 log in from a system conforming to our policy, but
8490 <tt>&lt;--</tt> will.
8491 </item>
8492 </list>
8493 </p>
8494 </sect>
8496 <sect>
8497 <heading>Environment variables</heading>
8500 A program must not depend on environment variables to get
8501 reasonable defaults. (That's because these environment
8502 variables would have to be set in a system-wide
8503 configuration file like <file>/etc/profile</file>, which is not
8504 supported by all shells.)
8505 </p>
8508 If a program usually depends on environment variables for its
8509 configuration, the program should be changed to fall back to
8510 a reasonable default configuration if these environment
8511 variables are not present. If this cannot be done easily
8512 (e.g., if the source code of a non-free program is not
8513 available), the program must be replaced by a small
8514 "wrapper" shell script which sets the environment variables
8515 if they are not already defined, and calls the original program.
8516 </p>
8519 Here is an example of a wrapper script for this purpose:
8521 <example compact="compact">
8522 #!/bin/sh
8523 BAR=${BAR:-/var/lib/fubar}
8524 export BAR
8525 exec /usr/lib/foo/foo "$@"
8526 </example>
8527 </p>
8530 Furthermore, as <file>/etc/profile</file> is a configuration
8531 file of the <prgn>base-files</prgn> package, other packages must
8532 not put any environment variables or other commands into that
8533 file.
8534 </p>
8535 </sect>
8537 <sect id="doc-base">
8538 <heading>Registering Documents using doc-base</heading>
8541 The <package>doc-base</package> package implements a
8542 flexible mechanism for handling and presenting
8543 documentation. The recommended practice is for every Debian
8544 package that provides online documentation (other than just
8545 manual pages) to register these documents with
8546 <package>doc-base</package> by installing a
8547 <package>doc-base</package> control file in
8548 <file>/usr/share/doc-base/</file>.
8549 </p>
8551 Please refer to the documentation that comes with the
8552 <package>doc-base</package> package for information and
8553 details.
8554 </p>
8555 </sect>
8557 <sect id="alternateinit">
8558 <heading>Alternate init systems</heading>
8560 A number of other init systems are available now in Debian that
8561 can be used in place of <package>sysvinit</package>. Alternative
8562 init implementations must support running SysV init scripts as
8563 described at <ref id="sysvinit"> for compatibility.
8564 </p>
8566 Packages may integrate with these replacement init systems by
8567 providing implementation-specific configuration information about
8568 how and when to start a service or in what order to run certain
8569 tasks at boot time. However, any package integrating with other
8570 init systems must also be backwards-compatible with
8571 <package>sysvinit</package> by providing a SysV-style init script
8572 with the same name as and equivalent functionality to any
8573 init-specific job, as this is the only start-up configuration
8574 method guaranteed to be supported by all init implementations. An
8575 exception to this rule is scripts or jobs provided by the init
8576 implementation itself; such jobs may be required for an
8577 implementation-specific equivalent of the <file>/etc/rcS.d/</file>
8578 scripts and may not have a one-to-one correspondence with the init
8579 scripts.
8580 </p>
8581 <sect1 id="upstart">
8582 <heading>Event-based boot with upstart</heading>
8585 Packages may integrate with the <prgn>upstart</prgn> event-based
8586 boot system by installing job files in the
8587 <file>/etc/init</file> directory. SysV init scripts for which
8588 an equivalent upstart job is available must query the output of
8589 the command <prgn>initctl version</prgn> for the string
8590 <tt>upstart</tt> and avoid running in favor of the native
8591 upstart job, using a test such as this:
8592 <example compact="compact">
8593 if [ "$1" = start ] &amp;&amp; which initctl &gt;/dev/null &amp;&amp; initctl version | grep -q upstart
8594 then
8595 exit 1
8597 </example>
8598 </p>
8600 Because packages shipping upstart jobs may be installed on
8601 systems that are not using upstart, maintainer scripts must
8602 still use the common <prgn>update-rc.d</prgn> and
8603 <prgn>invoke-rc.d</prgn> interfaces for configuring runlevels
8604 and for starting and stopping services. These maintainer
8605 scripts must not call the upstart <prgn>start</prgn>,
8606 <prgn>restart</prgn>, <prgn>reload</prgn>, or <prgn>stop</prgn>
8607 interfaces directly. Instead, implementations of
8608 <prgn>invoke-rc.d</prgn> must detect when upstart is running and
8609 when an upstart job with the same name as an init script is
8610 present, and perform the requested action using the upstart job
8611 instead of the init script.
8612 </p>
8614 Dependency-based boot managers for SysV init scripts, such as
8615 <prgn>startpar</prgn>, may avoid running a given init script
8616 entirely when an equivalent upstart job is present, to avoid
8617 unnecessary forking of no-op init scripts. In this case, the
8618 boot manager should integrate with upstart to detect when the
8619 upstart job in question is started or stopped to know when the
8620 dependency has been satisfied.
8621 </p>
8622 </sect1>
8623 </sect>
8625 </chapt>
8628 <chapt id="files">
8629 <heading>Files</heading>
8631 <sect id="binaries">
8632 <heading>Binaries</heading>
8635 Two different packages must not install programs with
8636 different functionality but with the same filenames. (The
8637 case of two programs having the same functionality but
8638 different implementations is handled via "alternatives" or
8639 the "Conflicts" mechanism. See <ref id="maintscripts"> and
8640 <ref id="conflicts"> respectively.) If this case happens,
8641 one of the programs must be renamed. The maintainers should
8642 report this to the <tt>debian-devel</tt> mailing list and
8643 try to find a consensus about which program will have to be
8644 renamed. If a consensus cannot be reached, <em>both</em>
8645 programs must be renamed.
8646 </p>
8648 To support merged-<file>/usr</file> systems, packages must not
8649 install files in both <file><var>path</var></file>
8650 and <file>/usr/<var>path</var></file>. For example, a package
8651 may not install both <file>/bin/example</file>
8652 and <file>/usr/bin/example</file>.
8653 </p>
8655 If a file is moved between <file><var>path</var></file>
8656 and <file>/usr/<var>path</var></file> in revisions of a Debian
8657 package, and a compatibility symlink at the old path is needed,
8658 the symlink must be managed in a way that will not break
8659 when <file><var>path</var></file>
8660 and <file>/usr/<var>path</var></file> are the same underlying
8661 directory due to symlinks or other mechanisms.
8662 </p>
8664 Binary executables must not be statically linked with the GNU C
8665 library, since this prevents the binary from benefiting from
8666 fixes and improvements to the C library without being rebuilt
8667 and complicates security updates. This requirement may be
8668 relaxed for binary executables whose intended purpose is to
8669 diagnose and fix the system in situations where the GNU C
8670 library may not be usable (such as system recovery shells or
8671 utilities like ldconfig) or for binary executables where the
8672 security benefits of static linking outweigh the drawbacks.
8673 </p>
8675 By default, when a package is being built, any binaries
8676 created should include debugging information, as well as
8677 being compiled with optimization. You should also turn on
8678 as many reasonable compilation warnings as possible; this
8679 makes life easier for porters, who can then look at build
8680 logs for possible problems. For the C programming language,
8681 this means the following compilation parameters should be
8682 used:
8683 <example compact="compact">
8684 CC = gcc
8685 CFLAGS = -O2 -g -Wall # sane warning options vary between programs
8686 LDFLAGS = # none
8687 INSTALL = install -s # (or use strip on the files in debian/tmp)
8688 </example>
8689 </p>
8692 Note that by default all installed binaries should be stripped,
8693 either by using the <tt>-s</tt> flag to
8694 <prgn>install</prgn>, or by calling <prgn>strip</prgn> on
8695 the binaries after they have been copied into
8696 <file>debian/tmp</file> but before the tree is made into a
8697 package.
8698 </p>
8701 Although binaries in the build tree should be compiled with
8702 debugging information by default, it can often be difficult to
8703 debug programs if they are also subjected to compiler
8704 optimization. For this reason, it is recommended to support the
8705 standardized environment variable <tt>DEB_BUILD_OPTIONS</tt>
8706 (see <ref id="debianrules-options">). This variable can contain
8707 several flags to change how a package is compiled and built.
8708 </p>
8711 It is up to the package maintainer to decide what
8712 compilation options are best for the package. Certain
8713 binaries (such as computationally-intensive programs) will
8714 function better with certain flags (<tt>-O3</tt>, for
8715 example); feel free to use them. Please use good judgment
8716 here. Don't use flags for the sake of it; only use them
8717 if there is good reason to do so. Feel free to override
8718 the upstream author's ideas about which compilation
8719 options are best: they are often inappropriate for our
8720 environment.
8721 </p>
8722 </sect>
8725 <sect id="libraries">
8726 <heading>Libraries</heading>
8729 If the package is <strong>architecture: any</strong>, then
8730 the shared library compilation and linking flags must have
8731 <tt>-fPIC</tt>, or the package shall not build on some of
8732 the supported architectures<footnote>
8734 If you are using GCC, <tt>-fPIC</tt> produces code with
8735 relocatable position independent code, which is required for
8736 most architectures to create a shared library, with i386 and
8737 perhaps some others where non position independent code is
8738 permitted in a shared library.
8739 </p>
8741 Position independent code may have a performance penalty,
8742 especially on <tt>i386</tt>. However, in most cases the
8743 speed penalty must be measured against the memory wasted on
8744 the few architectures where non position independent code is
8745 even possible.
8746 </p>
8747 </footnote>. Any exception to this rule must be discussed on
8748 the mailing list <em>debian-devel@lists.debian.org</em>, and
8749 a rough consensus obtained. The reasons for not compiling
8750 with <tt>-fPIC</tt> flag must be recorded in the file
8751 <tt>README.Debian</tt>, and care must be taken to either
8752 restrict the architecture or arrange for <tt>-fPIC</tt> to
8753 be used on architectures where it is required.<footnote>
8755 Some of the reasons why this might be required is if the
8756 library contains hand crafted assembly code that is not
8757 relocatable, the speed penalty is excessive for compute
8758 intensive libs, and similar reasons.
8759 </p>
8760 </footnote>
8761 </p>
8763 As to the static libraries, the common case is not to have
8764 relocatable code, since there is no benefit, unless in specific
8765 cases; therefore the static version must not be compiled
8766 with the <tt>-fPIC</tt> flag. Any exception to this rule
8767 should be discussed on the mailing list
8768 <em>debian-devel@lists.debian.org</em>, and the reasons for
8769 compiling with the <tt>-fPIC</tt> flag must be recorded in
8770 the file <tt>README.Debian</tt>. <footnote>
8772 Some of the reasons for linking static libraries with
8773 the <tt>-fPIC</tt> flag are if, for example, one needs a
8774 Perl API for a library that is under rapid development,
8775 and has an unstable API, so shared libraries are
8776 pointless at this phase of the library's development. In
8777 that case, since Perl needs a library with relocatable
8778 code, it may make sense to create a static library with
8779 relocatable code. Another reason cited is if you are
8780 distilling various libraries into a common shared
8781 library, like <tt>mklibs</tt> does in the Debian
8782 installer project.
8783 </p>
8784 </footnote>
8785 </p>
8787 In other words, if both a shared and a static library is
8788 being built, each source unit (<tt>*.c</tt>, for example,
8789 for C files) will need to be compiled twice, for the normal
8790 case.
8791 </p>
8794 Libraries should be built with threading support and to be
8795 thread-safe if the library supports this.
8796 </p>
8799 Although not enforced by the build tools, shared libraries
8800 must be linked against all libraries that they use symbols from
8801 in the same way that binaries are. This ensures the correct
8802 functioning of the <qref id="sharedlibs-symbols">symbols</qref>
8803 and <qref id="sharedlibs-shlibdeps">shlibs</qref>
8804 systems and guarantees that all libraries can be safely opened
8805 with <tt>dlopen()</tt>. Packagers may wish to use the gcc
8806 option <tt>-Wl,-z,defs</tt> when building a shared library.
8807 Since this option enforces symbol resolution at build time,
8808 a missing library reference will be caught early as a fatal
8809 build error.
8810 </p>
8813 All installed shared libraries should be stripped with
8814 <example compact="compact">
8815 strip --strip-unneeded <var>your-lib</var>
8816 </example>
8817 (The option <tt>--strip-unneeded</tt> makes
8818 <prgn>strip</prgn> remove only the symbols which aren't
8819 needed for relocation processing.) Shared libraries can
8820 function perfectly well when stripped, since the symbols for
8821 dynamic linking are in a separate part of the ELF object
8822 file.<footnote>
8823 You might also want to use the options
8824 <tt>--remove-section=.comment</tt> and
8825 <tt>--remove-section=.note</tt> on both shared libraries
8826 and executables, and <tt>--strip-debug</tt> on static
8827 libraries.
8828 </footnote>
8829 </p>
8832 Note that under some circumstances it may be useful to
8833 install a shared library unstripped, for example when
8834 building a separate package to support debugging.
8835 </p>
8838 Shared object files (often <file>.so</file> files) that are not
8839 public libraries, that is, they are not meant to be linked
8840 to by third party executables (binaries of other packages),
8841 should be installed in subdirectories of the
8842 <file>/usr/lib</file> directory. Such files are exempt from the
8843 rules that govern ordinary shared libraries, except that
8844 they must not be installed executable and should be
8845 stripped.<footnote>
8846 A common example are the so-called "plug-ins",
8847 internal shared objects that are dynamically loaded by
8848 programs using <manref name="dlopen" section="3">.
8849 </footnote>
8850 </p>
8853 Packages that use <prgn>libtool</prgn> to create and install
8854 their shared libraries install a file containing additional
8855 metadata (ending in <file>.la</file>) alongside the library.
8856 For public libraries intended for use by other packages, these
8857 files normally should not be included in the Debian package,
8858 since the information they include is not necessary to link with
8859 the shared library on Debian and can add unnecessary additional
8860 dependencies to other programs or libraries.<footnote>
8861 These files store, among other things, all libraries on which
8862 that shared library depends. Unfortunately, if
8863 the <file>.la</file> file is present and contains that
8864 dependency information, using <prgn>libtool</prgn> when
8865 linking against that library will cause the resulting program
8866 or library to be linked against those dependencies as well,
8867 even if this is unnecessary. This can create unneeded
8868 dependencies on shared library packages that would otherwise
8869 be hidden behind the library ABI, and can make library
8870 transitions to new SONAMEs unnecessarily complicated and
8871 difficult to manage.
8872 </footnote>
8873 If the <file>.la</file> file is required for that library (if,
8874 for instance, it's loaded via <tt>libltdl</tt> in a way that
8875 requires that meta-information), the <tt>dependency_libs</tt>
8876 setting in the <file>.la</file> file should normally be set to
8877 the empty string. If the shared library development package has
8878 historically included the <file>.la</file>, it must be retained
8879 in the development package (with <tt>dependency_libs</tt>
8880 emptied) until all libraries that depend on it have removed or
8881 emptied <tt>dependency_libs</tt> in their <file>.la</file>
8882 files to prevent linking with those other libraries
8883 using <prgn>libtool</prgn> from failing.
8884 </p>
8887 If the <file>.la</file> must be included, it should be included
8888 in the development (<tt>-dev</tt>) package, unless the library
8889 will be loaded by <prgn>libtool</prgn>'s <tt>libltdl</tt>
8890 library. If it is intended for use with <tt>libltdl</tt>,
8891 the <file>.la</file> files must go in the run-time library
8892 package.
8893 </p>
8896 These requirements for handling of <file>.la</file> files do not
8897 apply to loadable modules or libraries not installed in
8898 directories searched by default by the dynamic linker. Packages
8899 installing loadable modules will frequently need to install
8900 the <file>.la</file> files alongside the modules so that they
8901 can be loaded by <tt>libltdl</tt>. <tt>dependency_libs</tt>
8902 does not need to be modified for libraries or modules that are
8903 not installed in directories searched by the dynamic linker by
8904 default and not intended for use by other packages.
8905 </p>
8908 You must make sure that you use only released versions of
8909 shared libraries to build your packages; otherwise other
8910 users will not be able to run your binaries
8911 properly. Producing source packages that depend on
8912 unreleased compilers is also usually a bad
8913 idea.
8914 </p>
8915 </sect>
8918 <sect>
8919 <heading>Shared libraries</heading>
8921 This section has moved to <ref id="sharedlibs">.
8922 </p>
8923 </sect>
8926 <sect id="scripts">
8927 <heading>Scripts</heading>
8930 All command scripts, including the package maintainer
8931 scripts inside the package and used by <prgn>dpkg</prgn>,
8932 should have a <tt>#!</tt> line naming the shell to be used
8933 to interpret them.
8934 </p>
8937 In the case of Perl scripts this should be
8938 <tt>#!/usr/bin/perl</tt>.
8939 </p>
8942 When scripts are installed into a directory in the system
8943 PATH, the script name should not include an extension such
8944 as <tt>.sh</tt> or <tt>.pl</tt> that denotes the scripting
8945 language currently used to implement it.
8946 </p>
8948 Shell scripts (<prgn>sh</prgn> and <prgn>bash</prgn>) other than
8949 <file>init.d</file> scripts should almost certainly start
8950 with <tt>set -e</tt> so that errors are detected.
8951 <file>init.d</file> scripts are something of a special case, due
8952 to how frequently they need to call commands that are allowed to
8953 fail, and it may instead be easier to check the exit status of
8954 commands directly. See <ref id="writing-init"> for more
8955 information about writing <file>init.d</file> scripts.
8956 </p>
8958 Every script should use <tt>set -e</tt> or check the exit status
8959 of <em>every</em> command.
8960 </p>
8962 Scripts may assume that <file>/bin/sh</file> implements the
8963 SUSv3 Shell Command Language<footnote>
8964 Single UNIX Specification, version 3, which is also IEEE
8965 1003.1-2004 (POSIX), and is available on the World Wide Web
8966 from <url id="http://www.unix.org/version3/online.html"
8967 name="The Open Group"> after free
8968 registration.</footnote>
8969 plus the following additional features not mandated by
8970 SUSv3:<footnote>
8971 These features are in widespread use in the Linux community
8972 and are implemented in all of bash, dash, and ksh, the most
8973 common shells users may wish to use as <file>/bin/sh</file>.
8974 </footnote>
8975 <list>
8976 <item><tt>echo -n</tt>, if implemented as a shell built-in,
8977 must not generate a newline.</item>
8978 <item><tt>test</tt>, if implemented as a shell built-in, must
8979 support <tt>-a</tt> and <tt>-o</tt> as binary logical
8980 operators.</item>
8981 <item><tt>local</tt> to create a scoped variable must be
8982 supported, including listing multiple variables in a single
8983 local command and assigning a value to a variable at the
8984 same time as localizing it. <tt>local</tt> may or
8985 may not preserve the variable value from an outer scope if
8986 no assignment is present. Uses such as:
8987 <example compact>
8988 fname () {
8989 local a b c=delta d
8990 # ... use a, b, c, d ...
8992 </example>
8993 must be supported and must set the value of <tt>c</tt> to
8994 <tt>delta</tt>.
8995 </item>
8996 <item>The XSI extension to <prgn>kill</prgn> allowing <tt>kill
8997 -<var>signal</var></tt>, where <var>signal</var> is either
8998 the name of a signal or one of the numeric signals listed in
8999 the XSI extension (0, 1, 2, 3, 6, 9, 14, and 15), must be
9000 supported if <prgn>kill</prgn> is implemented as a shell
9001 built-in.
9002 </item>
9003 <item>The XSI extension to <prgn>trap</prgn> allowing numeric
9004 signals must be supported. In addition to the signal
9005 numbers listed in the extension, which are the same as for
9006 <prgn>kill</prgn> above, 13 (SIGPIPE) must be allowed.
9007 </item>
9008 </list>
9009 If a shell script requires non-SUSv3 features from the shell
9010 interpreter other than those listed above, the appropriate shell
9011 must be specified in the first line of the script (e.g.,
9012 <tt>#!/bin/bash</tt>) and the package must depend on the package
9013 providing the shell (unless the shell package is marked
9014 "Essential", as in the case of <prgn>bash</prgn>).
9015 </p>
9018 You may wish to restrict your script to SUSv3 features plus the
9019 above set when possible so that it may use <file>/bin/sh</file>
9020 as its interpreter. Checking your script
9021 with <prgn>checkbashisms</prgn> from
9022 the <package>devscripts</package> package or running your script
9023 with an alternate shell such as <prgn>posh</prgn> may help
9024 uncover violations of the above requirements. If in doubt
9025 whether a script complies with these requirements,
9026 use <file>/bin/bash</file>.
9027 </p>
9030 Perl scripts should check for errors when making any
9031 system calls, including <tt>open</tt>, <tt>print</tt>,
9032 <tt>close</tt>, <tt>rename</tt> and <tt>system</tt>.
9033 </p>
9036 <prgn>csh</prgn> and <prgn>tcsh</prgn> should be avoided as
9037 scripting languages. See <em>Csh Programming Considered
9038 Harmful</em>, one of the <tt>comp.unix.*</tt> FAQs, which
9039 can be found at <url id="http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/">.
9040 If an upstream package comes with <prgn>csh</prgn> scripts
9041 then you must make sure that they start with
9042 <tt>#!/bin/csh</tt> and make your package depend on the
9043 <prgn>c-shell</prgn> virtual package.
9044 </p>
9047 Any scripts which create files in world-writeable
9048 directories (e.g., in <file>/tmp</file>) must use a
9049 mechanism which will fail atomically if a file with the same
9050 name already exists.
9051 </p>
9054 The Debian base system provides the <prgn>tempfile</prgn>
9055 and <prgn>mktemp</prgn> utilities for use by scripts for
9056 this purpose.
9057 </p>
9058 </sect>
9061 <sect>
9062 <heading>Symbolic links</heading>
9065 In general, symbolic links within a top-level directory should
9066 be relative, and symbolic links pointing from one top-level
9067 directory to or into another should be absolute. (A top-level
9068 directory is a sub-directory of the root
9069 directory <file>/</file>.) For example, a symbolic link
9070 from <file>/usr/lib/foo</file> to <file>/usr/share/bar</file>
9071 should be relative (<file>../share/bar</file>), but a symbolic
9072 link from <file>/var/run</file> to <file>/run</file> should be
9073 absolute.<footnote>
9074 This is necessary to allow top-level directories to be
9075 symlinks. If linking <file>/var/run</file>
9076 to <file>/run</file> were done with the relative symbolic
9077 link <file>../run</file>, but <file>/var</file> were a
9078 symbolic link to <file>/srv/disk1</file>, the symbolic link
9079 would point to <file>/srv/run</file> rather than the intended
9080 target.
9081 </footnote>
9082 Symbolic links must not traverse above the root directory.
9083 </p>
9086 In addition, symbolic links should be specified as short as
9087 possible, i.e., link targets like <file>foo/../bar</file> are
9088 deprecated.
9089 </p>
9092 Note that when creating a relative link using
9093 <prgn>ln</prgn> it is not necessary for the target of the
9094 link to exist relative to the working directory you're
9095 running <prgn>ln</prgn> from, nor is it necessary to change
9096 directory to the directory where the link is to be made.
9097 Simply include the string that should appear as the target
9098 of the link (this will be a pathname relative to the
9099 directory in which the link resides) as the first argument
9100 to <prgn>ln</prgn>.
9101 </p>
9104 For example, in your <prgn>Makefile</prgn> or
9105 <file>debian/rules</file>, you can do things like:
9106 <example compact="compact">
9107 ln -fs gcc $(prefix)/bin/cc
9108 ln -fs gcc debian/tmp/usr/bin/cc
9109 ln -fs ../sbin/sendmail $(prefix)/bin/runq
9110 ln -fs ../sbin/sendmail debian/tmp/usr/bin/runq
9111 </example>
9112 </p>
9115 A symbolic link pointing to a compressed file (in the sense
9116 that it is meant to be uncompressed with <prgn>unzip</prgn>
9117 or <prgn>zless</prgn> etc.) should always
9118 have the same file extension as the referenced file. (For
9119 example, if a file <file>foo.gz</file> is referenced by a
9120 symbolic link, the filename of the link has to end with
9121 "<file>.gz</file>" too, as in <file>bar.gz</file>.)
9122 </p>
9123 </sect>
9125 <sect>
9126 <heading>Device files</heading>
9129 Packages must not include device files or named pipes in the
9130 package file tree.
9131 </p>
9134 Debian packages should assume that device files
9135 in <file>/dev</file> are dynamically managed by the kernel or
9136 some other system facility and do not have to be explicitly
9137 created or managed by the package. Debian packages other than
9138 those whose purpose is to manage the <file>/dev</file> device
9139 file tree must not attempt to create or remove device files
9140 in <file>/dev</file> when a dynamic device management facility
9141 is in use.
9142 </p>
9145 If named pipes or device files outside of <file>/dev</file> are
9146 required by a package, they should normally be created when
9147 necessary by the programs in the package, by init scripts or
9148 systemd unit files, or by similar on-demand mechanisms. If such
9149 files need to be created during package installation, they must
9150 be created in the <pgrn>postinst</pgrn> maintainer
9151 script<footnote>
9152 It's better to use <prgn>mkfifo</prgn> rather
9153 than <prgn>mknod</prgn> to create named pipes to avoid false
9154 positives from automated checks for packages incorrectly
9155 creating device files.
9156 </footnote>
9157 and removed in either the <pgrn>prerm</pgrn> or
9158 the <pgrn>postrm</pgrn> maintainer script.
9159 </p>
9160 </sect>
9162 <sect id="config-files">
9163 <heading>Configuration files</heading>
9165 <sect1>
9166 <heading>Definitions</heading>
9169 <taglist>
9170 <tag>configuration file</tag>
9171 <item>
9172 A file that affects the operation of a program, or
9173 provides site- or host-specific information, or
9174 otherwise customizes the behavior of a program.
9175 Typically, configuration files are intended to be
9176 modified by the system administrator (if needed or
9177 desired) to conform to local policy or to provide
9178 more useful site-specific behavior.
9179 </item>
9181 <tag><tt>conffile</tt></tag>
9182 <item>
9183 A file listed in a package's <tt>conffiles</tt>
9184 file, and is treated specially by <prgn>dpkg</prgn>
9185 (see <ref id="configdetails">).
9186 </item>
9187 </taglist>
9188 </p>
9191 The distinction between these two is important; they are
9192 not interchangeable concepts. Almost all
9193 <tt>conffile</tt>s are configuration files, but many
9194 configuration files are not <tt>conffiles</tt>.
9195 </p>
9198 As noted elsewhere, <file>/etc/init.d</file> scripts,
9199 <file>/etc/default</file> files, scripts installed in
9200 <file>/etc/cron.{hourly,daily,weekly,monthly}</file>, and cron
9201 configuration installed in <file>/etc/cron.d</file> must be
9202 treated as configuration files. In general, any script that
9203 embeds configuration information is de-facto a configuration
9204 file and should be treated as such.
9205 </p>
9206 </sect1>
9208 <sect1>
9209 <heading>Location</heading>
9212 Any configuration files created or used by your package
9213 must reside in <file>/etc</file>. If there are several,
9214 consider creating a subdirectory of <file>/etc</file>
9215 named after your package.
9216 </p>
9219 If your package creates or uses configuration files
9220 outside of <file>/etc</file>, and it is not feasible to modify
9221 the package to use <file>/etc</file> directly, put the files
9222 in <file>/etc</file> and create symbolic links to those files
9223 from the location that the package requires.
9224 </p>
9225 </sect1>
9227 <sect1>
9228 <heading>Behavior</heading>
9231 Configuration file handling must conform to the following
9232 behavior:
9233 <list compact="compact">
9234 <item>
9235 local changes must be preserved during a package
9236 upgrade, and
9237 </item>
9238 <item>
9239 configuration files must be preserved when the
9240 package is removed, and only deleted when the
9241 package is purged.
9242 </item>
9243 </list>
9244 Obsolete configuration files without local changes should be
9245 removed by the package during upgrade.<footnote>
9246 The <prgn>dpkg-maintscript-helper</prgn> tool, available from the
9247 <package>dpkg</package> package, can help for this task.</footnote>
9248 </p>
9251 The easy way to achieve this behavior is to make the
9252 configuration file a <tt>conffile</tt>. This is
9253 appropriate only if it is possible to distribute a default
9254 version that will work for most installations, although
9255 some system administrators may choose to modify it. This
9256 implies that the default version will be part of the
9257 package distribution, and must not be modified by the
9258 maintainer scripts during installation (or at any other
9259 time).
9260 </p>
9263 In order to ensure that local changes are preserved
9264 correctly, no package may contain or make hard links to
9265 conffiles.<footnote>
9266 Rationale: There are two problems with hard links.
9267 The first is that some editors break the link while
9268 editing one of the files, so that the two files may
9269 unwittingly become unlinked and different. The second
9270 is that <prgn>dpkg</prgn> might break the hard link
9271 while upgrading <tt>conffile</tt>s.
9272 </footnote>
9273 </p>
9276 The other way to do it is via the maintainer scripts. In
9277 this case, the configuration file must not be listed as a
9278 <tt>conffile</tt> and must not be part of the package
9279 distribution. If the existence of a file is required for
9280 the package to be sensibly configured it is the
9281 responsibility of the package maintainer to provide
9282 maintainer scripts which correctly create, update and
9283 maintain the file and remove it on purge. (See <ref
9284 id="maintainerscripts"> for more information.) These
9285 scripts must be idempotent (i.e., must work correctly if
9286 <prgn>dpkg</prgn> needs to re-run them due to errors
9287 during installation or removal), must cope with all the
9288 variety of ways <prgn>dpkg</prgn> can call maintainer
9289 scripts, must not overwrite or otherwise mangle the user's
9290 configuration without asking, must not ask unnecessary
9291 questions (particularly during upgrades), and must
9292 otherwise be good citizens.
9293 </p>
9296 The scripts are not required to configure every possible
9297 option for the package, but only those necessary to get
9298 the package running on a given system. Ideally the
9299 sysadmin should not have to do any configuration other
9300 than that done (semi-)automatically by the
9301 <prgn>postinst</prgn> script.
9302 </p>
9305 A common practice is to create a script called
9306 <file><var>package</var>-configure</file> and have the
9307 package's <prgn>postinst</prgn> call it if and only if the
9308 configuration file does not already exist. In certain
9309 cases it is useful for there to be an example or template
9310 file which the maintainer scripts use. Such files should
9311 be in <file>/usr/share/<var>package</var></file> or
9312 <file>/usr/lib/<var>package</var></file> (depending on whether
9313 they are architecture-independent or not). There should
9314 be symbolic links to them from
9315 <file>/usr/share/doc/<var>package</var>/examples</file> if
9316 they are examples, and should be perfectly ordinary
9317 <prgn>dpkg</prgn>-handled files (<em>not</em>
9318 configuration files).
9319 </p>
9322 These two styles of configuration file handling must
9323 not be mixed, for that way lies madness:
9324 <prgn>dpkg</prgn> will ask about overwriting the file
9325 every time the package is upgraded.
9326 </p>
9327 </sect1>
9329 <sect1>
9330 <heading>Sharing configuration files</heading>
9333 If two or more packages use the same configuration file
9334 and it is reasonable for both to be installed at the same
9335 time, one of these packages must be defined as
9336 <em>owner</em> of the configuration file, i.e., it will be
9337 the package which handles that file as a configuration
9338 file. Other packages that use the configuration file must
9339 depend on the owning package if they require the
9340 configuration file to operate. If the other package will
9341 use the configuration file if present, but is capable of
9342 operating without it, no dependency need be declared.
9343 </p>
9346 If it is desirable for two or more related packages to
9347 share a configuration file <em>and</em> for all of the
9348 related packages to be able to modify that configuration
9349 file, then the following should be done:
9350 <enumlist compact="compact">
9351 <item>
9352 One of the related packages (the "owning" package)
9353 will manage the configuration file with maintainer
9354 scripts as described in the previous section.
9355 </item>
9356 <item>
9357 The owning package should also provide a program
9358 that the other packages may use to modify the
9359 configuration file.
9360 </item>
9361 <item>
9362 The related packages must use the provided program
9363 to make any desired modifications to the
9364 configuration file. They should either depend on
9365 the core package to guarantee that the configuration
9366 modifier program is available or accept gracefully
9367 that they cannot modify the configuration file if it
9368 is not. (This is in addition to the fact that the
9369 configuration file may not even be present in the
9370 latter scenario.)
9371 </item>
9372 </enumlist>
9373 </p>
9376 Sometimes it's appropriate to create a new package which
9377 provides the basic infrastructure for the other packages
9378 and which manages the shared configuration files. (The
9379 <tt>sgml-base</tt> package is a good example.)
9380 </p>
9383 If the configuration file cannot be shared as described above,
9384 the packages must be marked as conflicting with each other.
9385 Two packages that specify the same file as
9386 a <tt>conffile</tt> must conflict. This is an instance of the
9387 general rule about not sharing files. Neither alternatives
9388 nor diversions are likely to be appropriate in this case; in
9389 particular, <prgn>dpkg</prgn> does not handle diverted
9390 <tt>conffile</tt>s well.
9391 </p>
9394 When two packages both declare the same <tt>conffile</tt>, they
9395 may see left-over configuration files from each other even
9396 though they conflict with each other. If a user removes
9397 (without purging) one of the packages and installs the other,
9398 the new package will take over the <tt>conffile</tt> from the
9399 old package. If the file was modified by the user, it will be
9400 treated the same as any other locally
9401 modified <tt>conffile</tt> during an upgrade.
9402 </p>
9405 The maintainer scripts must not alter a <tt>conffile</tt>
9406 of <em>any</em> package, including the one the scripts
9407 belong to.
9408 </p>
9409 </sect1>
9411 <sect1>
9412 <heading>User configuration files ("dotfiles")</heading>
9415 The files in <file>/etc/skel</file> will automatically be
9416 copied into new user accounts by <prgn>adduser</prgn>.
9417 No other program should reference the files in
9418 <file>/etc/skel</file>.
9419 </p>
9422 Therefore, if a program needs a dotfile to exist in
9423 advance in <file>$HOME</file> to work sensibly, that dotfile
9424 should be installed in <file>/etc/skel</file> and treated as a
9425 configuration file.
9426 </p>
9429 However, programs that require dotfiles in order to
9430 operate sensibly are a bad thing, unless they do create
9431 the dotfiles themselves automatically.
9432 </p>
9435 Furthermore, programs should be configured by the Debian
9436 default installation to behave as closely to the upstream
9437 default behavior as possible.
9438 </p>
9441 Therefore, if a program in a Debian package needs to be
9442 configured in some way in order to operate sensibly, that
9443 should be done using a site-wide configuration file placed
9444 in <file>/etc</file>. Only if the program doesn't support a
9445 site-wide default configuration and the package maintainer
9446 doesn't have time to add it may a default per-user file be
9447 placed in <file>/etc/skel</file>.
9448 </p>
9451 <file>/etc/skel</file> should be as empty as we can make it.
9452 This is particularly true because there is no easy (or
9453 necessarily desirable) mechanism for ensuring that the
9454 appropriate dotfiles are copied into the accounts of
9455 existing users when a package is installed.
9456 </p>
9457 </sect1>
9458 </sect>
9460 <sect>
9461 <heading>Log files</heading>
9463 Log files should usually be named
9464 <file>/var/log/<var>package</var>.log</file>. If you have many
9465 log files, or need a separate directory for permission
9466 reasons (<file>/var/log</file> is writable only by
9467 <file>root</file>), you should usually create a directory named
9468 <file>/var/log/<var>package</var></file> and place your log
9469 files there.
9470 </p>
9473 Log files must be rotated occasionally so that they don't grow
9474 indefinitely. The best way to do this is to install a log
9475 rotation configuration file in the
9476 directory <file>/etc/logrotate.d</file>, normally
9477 named <file>/etc/logrotate.d/<var>package</var></file>, and use
9478 the facilities provided by <prgn>logrotate</prgn>.
9479 <footnote>
9481 The traditional approach to log files has been to set up
9482 <em>ad hoc</em> log rotation schemes using simple shell
9483 scripts and cron. While this approach is highly
9484 customizable, it requires quite a lot of sysadmin work.
9485 Even though the original Debian system helped a little
9486 by automatically installing a system which can be used
9487 as a template, this was deemed not enough.
9488 </p>
9491 The use of <prgn>logrotate</prgn>, a program developed
9492 by Red Hat, is better, as it centralizes log management.
9493 It has both a configuration file
9494 (<file>/etc/logrotate.conf</file>) and a directory where
9495 packages can drop their individual log rotation
9496 configurations (<file>/etc/logrotate.d</file>).
9497 </p>
9498 </footnote>
9499 Here is a good example for a logrotate config
9500 file (for more information see <manref name="logrotate"
9501 section="8">):
9502 <example compact="compact">
9503 /var/log/foo/*.log {
9504 rotate 12
9505 weekly
9506 compress
9507 missingok
9508 postrotate
9509 start-stop-daemon -K -p /var/run/foo.pid -s HUP -x /usr/sbin/foo -q
9510 endscript
9512 </example>
9513 This rotates all files under <file>/var/log/foo</file>, saves 12
9514 compressed generations, and tells the daemon to reopen its log
9515 files after the log rotation. It skips this log rotation
9516 (via <tt>missingok</tt>) if no such log file is present, which
9517 avoids errors if the package is removed but not purged.
9518 </p>
9521 Log files should be removed when the package is
9522 purged (but not when it is only removed). This should be
9523 done by the <prgn>postrm</prgn> script when it is called
9524 with the argument <tt>purge</tt> (see <ref
9525 id="removedetails">).
9526 </p>
9527 </sect>
9529 <sect id="permissions-owners">
9530 <heading>Permissions and owners</heading>
9533 The rules in this section are guidelines for general use.
9534 If necessary you may deviate from the details below.
9535 However, if you do so you must make sure that what is done
9536 is secure and you should try to be as consistent as possible
9537 with the rest of the system. You should probably also
9538 discuss it on <prgn>debian-devel</prgn> first.
9539 </p>
9542 Files should be owned by <tt>root:root</tt>, and made
9543 writable only by the owner and universally readable (and
9544 executable, if appropriate), that is mode 644 or 755.
9545 </p>
9548 Directories should be mode 755 or (for group-writability)
9549 mode 2775. The ownership of the directory should be
9550 consistent with its mode: if a directory is mode 2775, it
9551 should be owned by the group that needs write access to
9552 it.<footnote>
9554 When a package is upgraded, and the owner or permissions
9555 of a file included in the package has changed, dpkg
9556 arranges for the ownership and permissions to be
9557 correctly set upon installation. However, this does not
9558 extend to directories; the permissions and ownership of
9559 directories already on the system does not change on
9560 install or upgrade of packages. This makes sense, since
9561 otherwise common directories like <tt>/usr</tt> would
9562 always be in flux. To correctly change permissions of a
9563 directory the package owns, explicit action is required,
9564 usually in the <tt>postinst</tt> script. Care must be
9565 taken to handle downgrades as well, in that case.
9566 </p>
9567 </footnote>
9568 </p>
9571 Control information files should be owned by <tt>root:root</tt>
9572 and either mode 644 (for most files) or mode 755 (for
9573 executables such as <qref id="maintscripts">maintainer
9574 scripts</qref>).
9575 </p>
9578 Setuid and setgid executables should be mode 4755 or 2755
9579 respectively, and owned by the appropriate user or group.
9580 They should not be made unreadable (modes like 4711 or
9581 2711 or even 4111); doing so achieves no extra security,
9582 because anyone can find the binary in the freely available
9583 Debian package; it is merely inconvenient. For the same
9584 reason you should not restrict read or execute permissions
9585 on non-set-id executables.
9586 </p>
9589 Some setuid programs need to be restricted to particular
9590 sets of users, using file permissions. In this case they
9591 should be owned by the uid to which they are set-id, and by
9592 the group which should be allowed to execute them. They
9593 should have mode 4754; again there is no point in making
9594 them unreadable to those users who must not be allowed to
9595 execute them.
9596 </p>
9599 It is possible to arrange that the system administrator can
9600 reconfigure the package to correspond to their local
9601 security policy by changing the permissions on a binary:
9602 they can do this by using <prgn>dpkg-statoverride</prgn>, as
9603 described below.<footnote>
9604 Ordinary files installed by <prgn>dpkg</prgn> (as
9605 opposed to <tt>conffile</tt>s and other similar objects)
9606 normally have their permissions reset to the distributed
9607 permissions when the package is reinstalled. However,
9608 the use of <prgn>dpkg-statoverride</prgn> overrides this
9609 default behavior.
9610 </footnote>
9611 Another method you should consider is to create a group for
9612 people allowed to use the program(s) and make any setuid
9613 executables executable only by that group.
9614 </p>
9617 If you need to create a new user or group for your package
9618 there are two possibilities. Firstly, you may need to
9619 make some files in the binary package be owned by this
9620 user or group, or you may need to compile the user or
9621 group id (rather than just the name) into the binary
9622 (though this latter should be avoided if possible, as in
9623 this case you need a statically allocated id).</p>
9626 If you need a statically allocated id, you must ask for a
9627 user or group id from the <tt>base-passwd</tt> maintainer,
9628 and must not release the package until you have been
9629 allocated one. Once you have been allocated one you must
9630 either make the package depend on a version of the
9631 <tt>base-passwd</tt> package with the id present in
9632 <file>/etc/passwd</file> or <file>/etc/group</file>, or arrange for
9633 your package to create the user or group itself with the
9634 correct id (using <tt>adduser</tt>) in its
9635 <prgn>preinst</prgn> or <prgn>postinst</prgn>. (Doing it in
9636 the <prgn>postinst</prgn> is to be preferred if it is
9637 possible, otherwise a pre-dependency will be needed on the
9638 <tt>adduser</tt> package.)
9639 </p>
9642 On the other hand, the program might be able to determine the
9643 uid or gid from the user or group name at runtime, so that a
9644 dynamically allocated id can be used. In this case you should
9645 choose an appropriate user or group name, discussing this
9646 on <prgn>debian-devel</prgn> and checking that it is unique.
9647 When this has been checked you must arrange for your package to
9648 create the user or group if necessary using
9649 <prgn>adduser</prgn> in the <prgn>preinst</prgn> or
9650 <prgn>postinst</prgn> script (again, the latter is to be
9651 preferred if it is possible).
9652 </p>
9655 Note that changing the numeric value of an id associated
9656 with a name is very difficult, and involves searching the
9657 file system for all appropriate files. You need to think
9658 carefully whether a static or dynamic id is required, since
9659 changing your mind later will cause problems.
9660 </p>
9662 <sect1><heading>The use of <prgn>dpkg-statoverride</prgn></heading>
9664 This section is not intended as policy, but as a
9665 description of the use of <prgn>dpkg-statoverride</prgn>.
9666 </p>
9669 If a system administrator wishes to have a file (or
9670 directory or other such thing) installed with owner and
9671 permissions different from those in the distributed Debian
9672 package, they can use the <prgn>dpkg-statoverride</prgn>
9673 program to instruct <prgn>dpkg</prgn> to use the different
9674 settings every time the file is installed. Thus the
9675 package maintainer should distribute the files with their
9676 normal permissions, and leave it for the system
9677 administrator to make any desired changes. For example, a
9678 daemon which is normally required to be setuid root, but
9679 in certain situations could be used without being setuid,
9680 should be installed setuid in the <tt>.deb</tt>. Then the
9681 local system administrator can change this if they wish.
9682 If there are two standard ways of doing it, the package
9683 maintainer can use <tt>debconf</tt> to find out the
9684 preference, and call <prgn>dpkg-statoverride</prgn> in the
9685 maintainer script if necessary to accommodate the system
9686 administrator's choice. Care must be taken during
9687 upgrades to not override an existing setting.
9688 </p>
9691 Given the above, <prgn>dpkg-statoverride</prgn> is
9692 essentially a tool for system administrators and would not
9693 normally be needed in the maintainer scripts. There is
9694 one type of situation, though, where calls to
9695 <prgn>dpkg-statoverride</prgn> would be needed in the
9696 maintainer scripts, and that involves packages which use
9697 dynamically allocated user or group ids. In such a
9698 situation, something like the following idiom can be very
9699 helpful in the package's <prgn>postinst</prgn>, where
9700 <tt>sysuser</tt> is a dynamically allocated id:
9701 <example>
9702 for i in /usr/bin/foo /usr/sbin/bar
9704 # only do something when no setting exists
9705 if ! dpkg-statoverride --list $i &gt;/dev/null 2&gt;&amp;1
9706 then
9707 #include: debconf processing, question about foo and bar
9708 if [ "$RET" = "true" ] ; then
9709 dpkg-statoverride --update --add sysuser root 4755 $i
9712 done
9713 </example>
9714 The corresponding code to remove the override when the package
9715 is purged would be:
9716 <example>
9717 for i in /usr/bin/foo /usr/sbin/bar
9719 if dpkg-statoverride --list $i &gt;/dev/null 2&gt;&amp;1
9720 then
9721 dpkg-statoverride --remove $i
9723 done
9724 </example>
9725 </p>
9726 </sect1>
9727 </sect>
9729 <sect id="filenames">
9730 <heading>File names</heading>
9733 The name of the files installed by binary packages in the system PATH
9734 (namely <tt>/bin</tt>, <tt>/sbin</tt>, <tt>/usr/bin</tt>,
9735 <tt>/usr/sbin</tt> and <tt>/usr/games</tt>) must be encoded in
9736 ASCII.
9737 </p>
9740 The name of the files and directories installed by binary packages
9741 outside the system PATH must be encoded in UTF-8 and should be
9742 restricted to ASCII when it is possible to do so.
9743 </p>
9744 </sect>
9745 </chapt>
9748 <chapt id="customized-programs">
9749 <heading>Customized programs</heading>
9751 <sect id="arch-spec">
9752 <heading>Architecture specification strings</heading>
9755 If a program needs to specify an <em>architecture specification
9756 string</em> in some place, it should select one of the strings
9757 provided by <tt>dpkg-architecture -L</tt>. The strings are in
9758 the format <tt><var>os</var>-<var>arch</var></tt>, though the OS
9759 part is sometimes elided, as when the OS is Linux.
9760 </p>
9763 Note that we don't want to use
9764 <tt><var>arch</var>-debian-linux</tt> to apply to the rule
9765 <tt><var>architecture</var>-<var>vendor</var>-<var>os</var></tt>
9766 since this would make our programs incompatible with other
9767 Linux distributions. We also don't use something like
9768 <tt><var>arch</var>-unknown-linux</tt>, since the
9769 <tt>unknown</tt> does not look very good.
9770 </p>
9772 <sect1 id="arch-wildcard-spec">
9773 <heading>Architecture wildcards</heading>
9776 A package may specify an architecture wildcard. Architecture
9777 wildcards are in the format <tt>any</tt> (which matches every
9778 architecture), <tt><var>os</var></tt>-any, or
9779 any-<tt><var>cpu</var></tt>. <footnote>
9780 Internally, the package system normalizes the GNU triplets
9781 and the Debian arches into Debian arch triplets (which are
9782 kind of inverted GNU triplets), with the first component of
9783 the triplet representing the libc and ABI in use, and then
9784 does matching against those triplets. However, such
9785 triplets are an internal implementation detail that should
9786 not be used by packages directly. The libc and ABI portion
9787 is handled internally by the package system based on
9788 the <var>os</var> and <var>cpu</var>.
9789 </footnote>
9790 </p>
9791 </sect1>
9792 </sect>
9794 <sect>
9795 <heading>Daemons</heading>
9798 The configuration files <file>/etc/services</file>,
9799 <file>/etc/protocols</file>, and <file>/etc/rpc</file> are managed
9800 by the <prgn>netbase</prgn> package and must not be modified
9801 by other packages.
9802 </p>
9805 If a package requires a new entry in one of these files, the
9806 maintainer should get in contact with the
9807 <prgn>netbase</prgn> maintainer, who will add the entries
9808 and release a new version of the <prgn>netbase</prgn>
9809 package.
9810 </p>
9813 The configuration file <file>/etc/inetd.conf</file> must not be
9814 modified by the package's scripts except via the
9815 <prgn>update-inetd</prgn> script or the
9816 <file>DebianNet.pm</file> Perl module. See their documentation
9817 for details on how to add entries.
9818 </p>
9821 If a package wants to install an example entry into
9822 <file>/etc/inetd.conf</file>, the entry must be preceded with
9823 exactly one hash character (<tt>#</tt>). Such lines are
9824 treated as "commented out by user" by the
9825 <prgn>update-inetd</prgn> script and are not changed or
9826 activated during package updates.
9827 </p>
9828 </sect>
9830 <sect>
9831 <heading>Using pseudo-ttys and modifying wtmp, utmp and
9832 lastlog</heading>
9835 Some programs need to create pseudo-ttys. This should be done
9836 using Unix98 ptys if the C library supports it. The resulting
9837 program must not be installed setuid root, unless that
9838 is required for other functionality.
9839 </p>
9842 The files <file>/var/run/utmp</file>, <file>/var/log/wtmp</file> and
9843 <file>/var/log/lastlog</file> must be installed writable by
9844 group <tt>utmp</tt>. Programs which need to modify those
9845 files must be installed setgid <tt>utmp</tt>.
9846 </p>
9847 </sect>
9849 <sect>
9850 <heading>Editors and pagers</heading>
9853 Some programs have the ability to launch an editor or pager
9854 program to edit or display a text document. Since there are
9855 lots of different editors and pagers available in the Debian
9856 distribution, the system administrator and each user should
9857 have the possibility to choose their preferred editor and
9858 pager.
9859 </p>
9862 In addition, every program should choose a good default
9863 editor/pager if none is selected by the user or system
9864 administrator.
9865 </p>
9868 Thus, every program that launches an editor or pager must
9869 use the EDITOR or PAGER environment variable to determine
9870 the editor or pager the user wishes to use. If these
9871 variables are not set, the programs <file>/usr/bin/editor</file>
9872 and <file>/usr/bin/pager</file> should be used, respectively.
9873 </p>
9876 These two files are managed through the <prgn>dpkg</prgn>
9877 "alternatives" mechanism. Every package providing an editor or
9878 pager must call the <prgn>update-alternatives</prgn> script to
9879 register as an alternative for <file>/usr/bin/editor</file>
9880 or <file>/usr/bin/pager</file> as appropriate. The alternative
9881 should have a slave alternative
9882 for <file>/usr/share/man/man1/editor.1.gz</file>
9883 or <file>/usr/share/man/man1/pager.1.gz</file> pointing to the
9884 corresponding manual page.
9885 </p>
9888 If it is very hard to adapt a program to make use of the
9889 EDITOR or PAGER variables, that program may be configured to
9890 use <file>/usr/bin/sensible-editor</file> and
9891 <file>/usr/bin/sensible-pager</file> as the editor or pager
9892 program respectively. These are two scripts provided in the
9893 <package>sensible-utils</package> package that check the EDITOR
9894 and PAGER variables and launch the appropriate program, and fall
9895 back to <file>/usr/bin/editor</file>
9896 and <file>/usr/bin/pager</file> if the variable is not set.
9897 </p>
9900 A program may also use the VISUAL environment variable to
9901 determine the user's choice of editor. If it exists, it
9902 should take precedence over EDITOR. This is in fact what
9903 <file>/usr/bin/sensible-editor</file> does.
9904 </p>
9907 It is not required for a package to depend on
9908 <tt>editor</tt> and <tt>pager</tt>, nor is it required for a
9909 package to provide such virtual packages.<footnote>
9910 The Debian base system already provides an editor and a
9911 pager program.
9912 </footnote>
9913 </p>
9914 </sect>
9916 <sect id="web-appl">
9917 <heading>Web servers and applications</heading>
9920 This section describes the locations and URLs that should
9921 be used by all web servers and web applications in the
9922 Debian system.
9923 </p>
9926 <enumlist>
9927 <item>
9928 Cgi-bin executable files are installed in the
9929 directory
9930 <example compact="compact">
9931 /usr/lib/cgi-bin
9932 </example>
9933 or a subdirectory of that directory, and the script
9934 <example compact="compact">
9935 /usr/lib/cgi-bin/.../<var>cgi-bin-name</var>
9936 </example>
9937 should be referred to as
9938 <example compact="compact">
9939 http://localhost/cgi-bin/.../<var>cgi-bin-name</var>
9940 </example>
9941 </item>
9943 <item>
9944 <p>(Deleted)</p>
9945 </item>
9947 <item>
9948 <p>Access to images</p>
9950 It is recommended that images for a package be stored
9951 in <tt>/usr/share/images/<var>package</var></tt> and
9952 may be referred to through an alias <tt>/images/</tt>
9954 <example>
9955 http://localhost/images/<var>package</var>/<var>filename</var>
9956 </example>
9958 </p>
9959 </item>
9961 <item>
9962 <p>Web Document Root</p>
9965 Web Applications should try to avoid storing files in
9966 the Web Document Root. Instead they should use the
9967 /usr/share/doc/<var>package</var> directory for
9968 documents and register the Web Application via the
9969 <package>doc-base</package> package. If access to the
9970 web document root is unavoidable then use
9971 <example compact="compact">
9972 /var/www/html
9973 </example>
9974 as the Document Root. This might be just a symbolic
9975 link to the location where the system administrator
9976 has put the real document root.
9977 </p>
9978 </item>
9979 <item><p>Providing httpd and/or httpd-cgi</p>
9981 All web servers should provide the virtual package
9982 <tt>httpd</tt>. If a web server has CGI support it should
9983 provide <tt>httpd-cgi</tt> additionally.
9984 </p>
9986 All web applications which do not contain CGI scripts should
9987 depend on <tt>httpd</tt>, all those web applications which
9988 <tt>do</tt> contain CGI scripts, should depend on
9989 <tt>httpd-cgi</tt>.
9990 </p>
9991 </item>
9992 </enumlist>
9993 </p>
9994 </sect>
9996 <sect id="mail-transport-agents">
9997 <heading>Mail transport, delivery and user agents</heading>
10000 Debian packages which process electronic mail, whether mail
10001 user agents (MUAs) or mail transport agents (MTAs), must
10002 ensure that they are compatible with the configuration
10003 decisions below. Failure to do this may result in lost
10004 mail, broken <tt>From:</tt> lines, and other serious brain
10005 damage!
10006 </p>
10009 The mail spool is <file>/var/mail</file> and the interface to
10010 send a mail message is <file>/usr/sbin/sendmail</file> (as per
10011 the FHS). On older systems, the mail spool may be
10012 physically located in <file>/var/spool/mail</file>, but all
10013 access to the mail spool should be via the
10014 <file>/var/mail</file> symlink. The mail spool is part of the
10015 base system and not part of the MTA package.
10016 </p>
10019 All Debian MUAs, MTAs, MDAs and other mailbox accessing
10020 programs (such as IMAP daemons) must lock the mailbox in an
10021 NFS-safe way. This means that <tt>fcntl()</tt> locking must
10022 be combined with dot locking. To avoid deadlocks, a program
10023 should use <tt>fcntl()</tt> first and dot locking after
10024 this, or alternatively implement the two locking methods in
10025 a non blocking way<footnote>
10026 If it is not possible to establish both locks, the
10027 system shouldn't wait for the second lock to be
10028 established, but remove the first lock, wait a (random)
10029 time, and start over locking again.
10030 </footnote>. Using the functions <tt>maillock</tt> and
10031 <tt>mailunlock</tt> provided by the
10032 <tt>liblockfile*</tt> packages is the recommended way to
10033 accomplish this.
10034 </p>
10037 Mailboxes are generally either mode 600 and owned by
10038 <var>user</var> or mode 660 and owned by
10039 <tt><var>user</var>:mail</tt><footnote>
10040 There are two traditional permission schemes for mail spools:
10041 mode 600 with all mail delivery done by processes running as
10042 the destination user, or mode 660 and owned by group mail with
10043 mail delivery done by a process running as a system user in
10044 group mail. Historically, Debian required mode 660 mail
10045 spools to enable the latter model, but that model has become
10046 increasingly uncommon and the principle of least privilege
10047 indicates that mail systems that use the first model should
10048 use permissions of 600. If delivery to programs is permitted,
10049 it's easier to keep the mail system secure if the delivery
10050 agent runs as the destination user. Debian Policy therefore
10051 permits either scheme.
10052 </footnote>. The local system administrator may choose a
10053 different permission scheme; packages should not make
10054 assumptions about the permission and ownership of mailboxes
10055 unless required (such as when creating a new mailbox). A MUA
10056 may remove a mailbox (unless it has nonstandard permissions) in
10057 which case the MTA or another MUA must recreate it if needed.
10058 </p>
10061 The mail spool is 2775 <tt>root:mail</tt>, and MUAs should
10062 be setgid mail to do the locking mentioned above (and
10063 must obviously avoid accessing other users' mailboxes
10064 using this privilege).</p>
10067 <file>/etc/aliases</file> is the source file for the system mail
10068 aliases (e.g., postmaster, usenet, etc.), it is the one
10069 which the sysadmin and <prgn>postinst</prgn> scripts may
10070 edit. After <file>/etc/aliases</file> is edited the program or
10071 human editing it must call <prgn>newaliases</prgn>. All MTA
10072 packages must come with a <prgn>newaliases</prgn> program,
10073 even if it does nothing, but older MTA packages did not do
10074 this so programs should not fail if <prgn>newaliases</prgn>
10075 cannot be found. Note that because of this, all MTA
10076 packages must have <tt>Provides</tt>, <tt>Conflicts</tt> and
10077 <tt>Replaces: mail-transport-agent</tt> control fields.
10078 </p>
10081 The convention of writing <tt>forward to
10082 <var>address</var></tt> in the mailbox itself is not
10083 supported. Use a <tt>.forward</tt> file instead.</p>
10086 The <prgn>rmail</prgn> program used by UUCP
10087 for incoming mail should be <file>/usr/sbin/rmail</file>.
10088 Likewise, <prgn>rsmtp</prgn>, for receiving
10089 batch-SMTP-over-UUCP, should be <file>/usr/sbin/rsmtp</file> if it
10090 is supported.</p>
10093 If your package needs to know what hostname to use on (for
10094 example) outgoing news and mail messages which are generated
10095 locally, you should use the file <file>/etc/mailname</file>. It
10096 will contain the portion after the username and <tt>@</tt>
10097 (at) sign for email addresses of users on the machine
10098 (followed by a newline).
10099 </p>
10102 Such a package should check for the existence of this file
10103 when it is being configured. If it exists, it should be
10104 used without comment, although an MTA's configuration script
10105 may wish to prompt the user even if it finds that this file
10106 exists. If the file does not exist, the package should
10107 prompt the user for the value (preferably using
10108 <prgn>debconf</prgn>) and store it in <file>/etc/mailname</file>
10109 as well as using it in the package's configuration. The
10110 prompt should make it clear that the name will not just be
10111 used by that package. For example, in this situation the
10112 <tt>inn</tt> package could say something like:
10113 <example compact="compact">
10114 Please enter the "mail name" of your system. This is the
10115 hostname portion of the address to be shown on outgoing
10116 news and mail messages. The default is
10117 <var>syshostname</var>, your system's host name. Mail
10118 name ["<var>syshostname</var>"]:
10119 </example>
10120 where <var>syshostname</var> is the output of <tt>hostname
10121 --fqdn</tt>.
10122 </p>
10123 </sect>
10125 <sect>
10126 <heading>News system configuration</heading>
10129 All the configuration files related to the NNTP (news)
10130 servers and clients should be located under
10131 <file>/etc/news</file>.</p>
10134 There are some configuration issues that apply to a number
10135 of news clients and server packages on the machine. These
10136 are:
10138 <taglist>
10139 <tag><file>/etc/news/organization</file></tag>
10140 <item>
10141 A string which should appear as the
10142 organization header for all messages posted
10143 by NNTP clients on the machine
10144 </item>
10146 <tag><file>/etc/news/server</file></tag>
10147 <item>
10148 Contains the FQDN of the upstream NNTP
10149 server, or localhost if the local machine is
10150 an NNTP server.
10151 </item>
10152 </taglist>
10154 Other global files may be added as required for cross-package news
10155 configuration.
10156 </p>
10157 </sect>
10160 <sect>
10161 <heading>Programs for the X Window System</heading>
10163 <sect1>
10164 <heading>Providing X support and package priorities</heading>
10167 Programs that can be configured with support for the X
10168 Window System must be configured to do so and must declare
10169 any package dependencies necessary to satisfy their
10170 runtime requirements when using the X Window System. If
10171 such a package is of higher priority than the X packages
10172 on which it depends, it is required that either the
10173 X-specific components be split into a separate package, or
10174 that an alternative version of the package, which includes
10175 X support, be provided, or that the package's priority be
10176 lowered.
10177 </p>
10178 </sect1>
10180 <sect1>
10181 <heading>Packages providing an X server</heading>
10184 Packages that provide an X server that, directly or
10185 indirectly, communicates with real input and display
10186 hardware should declare in their <tt>Provides</tt> control
10187 field that they provide the virtual
10188 package <tt>xserver</tt>.<footnote>
10189 This implements current practice, and provides an
10190 actual policy for usage of the <tt>xserver</tt>
10191 virtual package which appears in the virtual packages
10192 list. In a nutshell, X servers that interface
10193 directly with the display and input hardware or via
10194 another subsystem (e.g., GGI) should provide
10195 <tt>xserver</tt>. Things like <tt>Xvfb</tt>,
10196 <tt>Xnest</tt>, and <tt>Xprt</tt> should not.
10197 </footnote>
10198 </p>
10199 </sect1>
10201 <sect1>
10202 <heading>Packages providing a terminal emulator</heading>
10205 Packages that provide a terminal emulator for the X Window
10206 System which meet the criteria listed below should declare in
10207 their <tt>Provides</tt> control field that they provide the
10208 virtual package <tt>x-terminal-emulator</tt>. They should
10209 also register themselves as an alternative for
10210 <file>/usr/bin/x-terminal-emulator</file>, with a priority of
10211 20. That alternative should have a slave alternative
10212 for <file>/usr/share/man/man1/x-terminal-emulator.1.gz</file>
10213 pointing to the corresponding manual page.
10214 </p>
10217 To be an <tt>x-terminal-emulator</tt>, a program must:
10218 <list compact="compact">
10219 <item>
10220 Be able to emulate a DEC VT100 terminal, or a
10221 compatible terminal.
10222 </item>
10224 <item>
10225 Support the command-line option <tt>-e
10226 <var>command</var></tt>, which creates a new
10227 terminal window<footnote>
10228 "New terminal window" does not necessarily mean
10229 a new top-level X window directly parented by
10230 the window manager; it could, if the terminal
10231 emulator application were so coded, be a new
10232 "view" in a multiple-document interface (MDI).
10233 </footnote>
10234 and runs the specified <var>command</var>,
10235 interpreting the entirety of the rest of the command
10236 line as a command to pass straight to exec, in the
10237 manner that <tt>xterm</tt> does.
10238 </item>
10240 <item>
10241 Support the command-line option <tt>-T
10242 <var>title</var></tt>, which creates a new terminal
10243 window with the window title <var>title</var>.
10244 </item>
10245 </list>
10246 </p>
10247 </sect1>
10249 <sect1>
10250 <heading>Packages providing a window manager</heading>
10253 Packages that provide a window manager should declare in
10254 their <tt>Provides</tt> control field that they provide the
10255 virtual package <tt>x-window-manager</tt>. They should also
10256 register themselves as an alternative for
10257 <file>/usr/bin/x-window-manager</file>, with a priority
10258 calculated as follows:
10259 <list compact="compact">
10260 <item>
10261 Start with a priority of 20.
10262 </item>
10264 <item>
10265 If the window manager supports the Debian menu
10266 system, add 20 points if this support is available
10267 in the package's default configuration (i.e., no
10268 configuration files belonging to the system or user
10269 have to be edited to activate the feature); if
10270 configuration files must be modified, add only 10
10271 points.
10272 </p>
10273 </item>
10275 <item>
10276 If the window manager complies with <url
10277 id="http://www.freedesktop.org/wiki/Specifications/wm-spec"
10278 name="The Window Manager Specification Project">,
10279 written by the <url id="http://www.freedesktop.org/wiki/"
10280 name="Free Desktop Group">, add 40 points.
10281 </item>
10283 <item>
10284 If the window manager permits the X session to be
10285 restarted using a <em>different</em> window manager
10286 (without killing the X server) in its default
10287 configuration, add 10 points; otherwise add none.
10288 </item>
10289 </list>
10290 That alternative should have a slave alternative
10291 for <file>/usr/share/man/man1/x-window-manager.1.gz</file>
10292 pointing to the corresponding manual page.
10293 </p>
10294 </sect1>
10296 <sect1>
10297 <heading>Packages providing fonts</heading>
10300 Packages that provide fonts for the X Window
10301 System<footnote>
10302 For the purposes of Debian Policy, a "font for the X
10303 Window System" is one which is accessed via X protocol
10304 requests. Fonts for the Linux console, for PostScript
10305 renderer, or any other purpose, do not fit this
10306 definition. Any tool which makes such fonts available
10307 to the X Window System, however, must abide by this
10308 font policy.
10309 </footnote>
10310 must do a number of things to ensure that they are both
10311 available without modification of the X or font server
10312 configuration, and that they do not corrupt files used by
10313 other font packages to register information about
10314 themselves.
10315 <enumlist>
10316 <item>
10317 Fonts of any type supported by the X Window System
10318 must be in a separate binary package from any
10319 executables, libraries, or documentation (except
10320 that specific to the fonts shipped, such as their
10321 license information). If one or more of the fonts
10322 so packaged are necessary for proper operation of
10323 the package with which they are associated the font
10324 package may be Recommended; if the fonts merely
10325 provide an enhancement, a Suggests relationship may
10326 be used. Packages must not Depend on font
10327 packages.<footnote>
10328 This is because the X server may retrieve fonts
10329 from the local file system or over the network
10330 from an X font server; the Debian package system
10331 is empowered to deal only with the local
10332 file system.
10333 </footnote>
10334 </item>
10336 <item>
10337 BDF fonts must be converted to PCF fonts with the
10338 <prgn>bdftopcf</prgn> utility (available in the
10339 <tt>xfonts-utils</tt> package, <prgn>gzip</prgn>ped, and
10340 placed in a directory that corresponds to their
10341 resolution:
10342 <list compact="compact">
10343 <item>
10344 100 dpi fonts must be placed in
10345 <file>/usr/share/fonts/X11/100dpi/</file>.
10346 </item>
10348 <item>
10349 75 dpi fonts must be placed in
10350 <file>/usr/share/fonts/X11/75dpi/</file>.
10351 </item>
10353 <item>
10354 Character-cell fonts, cursor fonts, and other
10355 low-resolution fonts must be placed in
10356 <file>/usr/share/fonts/X11/misc/</file>.
10357 </item>
10358 </list>
10359 </item>
10361 <item>
10362 Type 1 fonts must be placed in
10363 <file>/usr/share/fonts/X11/Type1/</file>. If font
10364 metric files are available, they must be placed here
10365 as well.
10366 </item>
10368 <item>
10369 Subdirectories of <file>/usr/share/fonts/X11/</file>
10370 other than those listed above must be neither
10371 created nor used. (The <file>PEX</file>, <file>CID</file>,
10372 <file>Speedo</file>, and <file>cyrillic</file> directories
10373 are excepted for historical reasons, but installation of
10374 files into these directories remains discouraged.)
10375 </item>
10377 <item>
10378 Font packages may, instead of placing files directly
10379 in the X font directories listed above, provide
10380 symbolic links in that font directory pointing to
10381 the files' actual location in the filesystem. Such
10382 a location must comply with the FHS.
10383 </item>
10385 <item>
10386 Font packages should not contain both 75dpi and
10387 100dpi versions of a font. If both are available,
10388 they should be provided in separate binary packages
10389 with <tt>-75dpi</tt> or <tt>-100dpi</tt> appended to
10390 the names of the packages containing the
10391 corresponding fonts.
10392 </item>
10394 <item>
10395 Fonts destined for the <file>misc</file> subdirectory
10396 should not be included in the same package as 75dpi
10397 or 100dpi fonts; instead, they should be provided in
10398 a separate package with <tt>-misc</tt> appended to
10399 its name.
10400 </item>
10402 <item>
10403 Font packages must not provide the files
10404 <file>fonts.dir</file>, <file>fonts.alias</file>, or
10405 <file>fonts.scale</file> in a font directory:
10406 <list>
10407 <item>
10408 <file>fonts.dir</file> files must not be provided at all.
10409 </item>
10411 <item>
10412 <file>fonts.alias</file> and <file>fonts.scale</file>
10413 files, if needed, should be provided in the
10414 directory
10415 <file>/etc/X11/fonts/<var>fontdir</var>/<var>package</var>.<var>extension</var></file>,
10416 where <var>fontdir</var> is the name of the
10417 subdirectory of
10418 <file>/usr/share/fonts/X11/</file> where the
10419 package's corresponding fonts are stored
10420 (e.g., <tt>75dpi</tt> or <tt>misc</tt>),
10421 <var>package</var> is the name of the package
10422 that provides these fonts, and
10423 <var>extension</var> is either <tt>scale</tt>
10424 or <tt>alias</tt>, whichever corresponds to
10425 the file contents.
10426 </item>
10427 </list>
10428 </item>
10430 <item>
10431 Font packages must declare a dependency on
10432 <tt>xfonts-utils</tt> in their <tt>Depends</tt>
10433 or <tt>Pre-Depends</tt> control field.
10434 </item>
10436 <item>
10437 Font packages that provide one or more
10438 <file>fonts.scale</file> files as described above must
10439 invoke <prgn>update-fonts-scale</prgn> on each
10440 directory into which they installed fonts
10441 <em>before</em> invoking
10442 <prgn>update-fonts-dir</prgn> on that directory.
10443 This invocation must occur in both the
10444 <prgn>postinst</prgn> (for all arguments) and
10445 <prgn>postrm</prgn> (for all arguments except
10446 <tt>upgrade</tt>) scripts.
10447 </item>
10449 <item>
10450 Font packages that provide one or more
10451 <file>fonts.alias</file> files as described above must
10452 invoke <prgn>update-fonts-alias</prgn> on each
10453 directory into which they installed fonts. This
10454 invocation must occur in both the
10455 <prgn>postinst</prgn> (for all arguments) and
10456 <prgn>postrm</prgn> (for all arguments except
10457 <tt>upgrade</tt>) scripts.
10458 </item>
10460 <item>
10461 Font packages must invoke
10462 <prgn>update-fonts-dir</prgn> on each directory into
10463 which they installed fonts. This invocation must
10464 occur in both the <prgn>postinst</prgn> (for all
10465 arguments) and <prgn>postrm</prgn> (for all
10466 arguments except <tt>upgrade</tt>) scripts.
10467 </item>
10469 <item>
10470 Font packages must not provide alias names for the
10471 fonts they include which collide with alias names
10472 already in use by fonts already packaged.
10473 </item>
10475 <item>
10476 Font packages must not provide fonts with the same
10477 XLFD registry name as another font already packaged.
10478 </item>
10479 </enumlist>
10480 </p>
10481 </sect1>
10483 <sect1 id="appdefaults">
10484 <heading>Application defaults files</heading>
10487 Application defaults files must be installed in the
10488 directory <file>/etc/X11/app-defaults/</file> (use of a
10489 localized subdirectory of <file>/etc/X11/</file> as described
10490 in the <em>X Toolkit Intrinsics - C Language
10491 Interface</em> manual is also permitted). They must be
10492 registered as <tt>conffile</tt>s or handled as
10493 configuration files.
10494 </p>
10497 Customization of programs' X resources may also be
10498 supported with the provision of a file with the same name
10499 as that of the package placed in
10500 the <file>/etc/X11/Xresources/</file> directory, which
10501 must be registered as a <tt>conffile</tt> or handled as a
10502 configuration file.<footnote>
10503 Note that this mechanism is not the same as using
10504 app-defaults; app-defaults are tied to the client
10505 binary on the local file system, whereas X resources
10506 are stored in the X server and affect all connecting
10507 clients.
10508 </footnote>
10509 </p>
10510 </sect1>
10512 <sect1>
10513 <heading>Installation directory issues</heading>
10516 Historically, packages using the X Window System used a
10517 separate set of installation directories from other packages.
10518 This practice has been discontinued and packages using the X
10519 Window System should now generally be installed in the same
10520 directories as any other package. Specifically, packages must
10521 not install files under the <file>/usr/X11R6/</file> directory
10522 and the <file>/usr/X11R6/</file> directory hierarchy should be
10523 regarded as obsolete.
10524 </p>
10527 Include files previously installed under
10528 <file>/usr/X11R6/include/X11/</file> should be installed into
10529 <file>/usr/include/X11/</file>. For files previously
10530 installed into subdirectories of
10531 <file>/usr/X11R6/lib/X11/</file>, package maintainers should
10532 determine if subdirectories of <file>/usr/lib/</file> and
10533 <file>/usr/share/</file> can be used. If not, a subdirectory
10534 of <file>/usr/lib/X11/</file> should be used.
10535 </p>
10538 Configuration files for window, display, or session managers
10539 or other applications that are tightly integrated with the X
10540 Window System may be placed in a subdirectory
10541 of <file>/etc/X11/</file> corresponding to the package name.
10542 Other X Window System applications should use
10543 the <file>/etc/</file> directory unless otherwise mandated by
10544 policy (such as for <ref id="appdefaults">).
10545 </p>
10546 </sect1>
10547 </sect>
10549 <sect id="perl">
10550 <heading>Perl programs and modules</heading>
10553 Perl programs and modules should follow the current Perl policy.
10554 </p>
10557 The Perl policy can be found in the <tt>perl-policy</tt>
10558 files in the <tt>debian-policy</tt> package.
10559 It is also available from the Debian web mirrors at
10560 <tt><url name="/doc/packaging-manuals/perl-policy/"
10561 id="http://www.debian.org/doc/packaging-manuals/perl-policy/"></tt>.
10562 </p>
10563 </sect>
10565 <sect id="emacs">
10566 <heading>Emacs lisp programs</heading>
10569 Please refer to the "Debian Emacs Policy" for details of how to
10570 package emacs lisp programs.
10571 </p>
10574 The Emacs policy is available in
10575 <file>debian-emacs-policy.gz</file> of the
10576 <package>emacsen-common</package> package.
10577 It is also available from the Debian web mirrors at
10578 <tt><url name="/doc/packaging-manuals/debian-emacs-policy"
10579 id="http://www.debian.org/doc/packaging-manuals/debian-emacs-policy"></tt>.
10580 </p>
10581 </sect>
10583 <sect>
10584 <heading>Games</heading>
10587 The permissions on <file>/var/games</file> are mode 755, owner
10588 <tt>root</tt> and group <tt>root</tt>.
10589 </p>
10592 Each game decides on its own security policy.</p>
10595 Games which require protected, privileged access to
10596 high-score files, saved games, etc., may be made
10597 set-<em>group</em>-id (mode 2755) and owned by
10598 <tt>root:games</tt>, and use files and directories with
10599 appropriate permissions (770 <tt>root:games</tt>, for
10600 example). They must not be made
10601 set-<em>user</em>-id, as this causes security problems. (If
10602 an attacker can subvert any set-user-id game they can
10603 overwrite the executable of any other, causing other players
10604 of these games to run a Trojan horse program. With a
10605 set-group-id game the attacker only gets access to less
10606 important game data, and if they can get at the other
10607 players' accounts at all it will take considerably more
10608 effort.)</p>
10611 Some packages, for example some fortune cookie programs, are
10612 configured by the upstream authors to install with their
10613 data files or other static information made unreadable so
10614 that they can only be accessed through set-id programs
10615 provided. You should not do this in a Debian package: anyone can
10616 download the <file>.deb</file> file and read the data from it,
10617 so there is no point making the files unreadable. Not
10618 making the files unreadable also means that you don't have
10619 to make so many programs set-id, which reduces the risk of a
10620 security hole.</p>
10623 As described in the FHS, binaries of games should be
10624 installed in the directory <file>/usr/games</file>. This also
10625 applies to games that use the X Window System. Manual pages
10626 for games (X and non-X games) should be installed in
10627 <file>/usr/share/man/man6</file>.</p>
10628 </sect>
10629 </chapt>
10632 <chapt id="docs">
10633 <heading>Documentation</heading>
10635 <sect>
10636 <heading>Manual pages</heading>
10639 You should install manual pages in <prgn>nroff</prgn> source
10640 form, in appropriate places under <file>/usr/share/man</file>.
10641 You should only use sections 1 to 9 (see the FHS for more
10642 details). You must not install a pre-formatted "cat page".
10643 </p>
10646 Each program, utility, and function should have an
10647 associated manual page included in the same package. It is
10648 suggested that all configuration files also have a manual
10649 page included as well. Manual pages for protocols and other
10650 auxiliary things are optional.
10651 </p>
10654 If no manual page is available, this is considered as a bug
10655 and should be reported to the Debian Bug Tracking System (the
10656 maintainer of the package is allowed to write this bug report
10657 themselves, if they so desire). Do not close the bug report
10658 until a proper man page is available.<footnote>
10659 It is not very hard to write a man page. See the
10660 <url id="http://www.schweikhardt.net/man_page_howto.html"
10661 name="Man-Page-HOWTO">,
10662 <manref name="man" section="7">, the examples created
10663 by <prgn>dh_make</prgn>, the helper
10664 program <prgn>help2man</prgn>, or the
10665 directory <file>/usr/share/doc/man-db/examples</file>.
10666 </footnote>
10667 </p>
10670 You may forward a complaint about a missing man page to the
10671 upstream authors, and mark the bug as forwarded in the
10672 Debian bug tracking system. Even though the GNU Project do
10673 not in general consider the lack of a man page to be a bug,
10674 we do; if they tell you that they don't consider it a bug
10675 you should leave the bug in our bug tracking system open
10676 anyway.
10677 </p>
10680 Manual pages should be installed compressed using <tt>gzip -9</tt>.
10681 </p>
10684 If one man page needs to be accessible via several names it
10685 is better to use a symbolic link than the <file>.so</file>
10686 feature, but there is no need to fiddle with the relevant
10687 parts of the upstream source to change from <file>.so</file> to
10688 symlinks: don't do it unless it's easy. You should not
10689 create hard links in the manual page directories, nor put
10690 absolute filenames in <file>.so</file> directives. The filename
10691 in a <file>.so</file> in a man page should be relative to the
10692 base of the man page tree (usually
10693 <file>/usr/share/man</file>). If you do not create any links
10694 (whether symlinks, hard links, or <tt>.so</tt> directives)
10695 in the file system to the alternate names of the man page,
10696 then you should not rely on <prgn>man</prgn> finding your
10697 man page under those names based solely on the information in
10698 the man page's header.<footnote>
10699 Supporting this in <prgn>man</prgn> often requires
10700 unreasonable processing time to find a manual page or to
10701 report that none exists, and moves knowledge into man's
10702 database that would be better left in the file system.
10703 This support is therefore deprecated and will cease to
10704 be present in the future.
10705 </footnote>
10706 </p>
10709 Manual pages in locale-specific subdirectories of
10710 <file>/usr/share/man</file> should use either UTF-8 or the usual
10711 legacy encoding for that language (normally the one corresponding
10712 to the shortest relevant locale name in
10713 <file>/usr/share/i18n/SUPPORTED</file>). For example, pages under
10714 <file>/usr/share/man/fr</file> should use either UTF-8 or
10715 ISO-8859-1.<footnote>
10716 <prgn>man</prgn> will automatically detect whether UTF-8 is in
10717 use. In future, all manual pages will be required to use
10718 UTF-8.
10719 </footnote>
10720 </p>
10723 A country name (the <tt>DE</tt> in <tt>de_DE</tt>) should not be
10724 included in the subdirectory name unless it indicates a
10725 significant difference in the language, as this excludes
10726 speakers of the language in other countries.<footnote>
10727 At the time of writing, Chinese and Portuguese are the main
10728 languages with such differences, so <file>pt_BR</file>,
10729 <file>zh_CN</file>, and <file>zh_TW</file> are all allowed.
10730 </footnote>
10731 </p>
10734 If a localized version of a manual page is provided, it should
10735 either be up-to-date or it should be obvious to the reader that
10736 it is outdated and the original manual page should be used
10737 instead. This can be done either by a note at the beginning of
10738 the manual page or by showing the missing or changed portions in
10739 the original language instead of the target language.
10740 </p>
10741 </sect>
10743 <sect>
10744 <heading>Info documents</heading>
10747 Info documents should be installed in <file>/usr/share/info</file>.
10748 They should be compressed with <tt>gzip -9</tt>.
10749 </p>
10752 The <prgn>install-info</prgn> program maintains a directory of
10753 installed info documents in <file>/usr/share/info/dir</file> for the
10754 use of info readers. This file must not be included in packages
10755 other than <package>install-info</package>.
10756 </p>
10759 <prgn>install-info</prgn> is automatically invoked when
10760 appropriate using dpkg triggers. Packages other than
10761 <package>install-info</package> <em>should not</em> invoke
10762 <prgn>install-info</prgn> directly and <em>should not</em>
10763 depend on, recommend, or suggest <package>install-info</package>
10764 for this purpose.
10765 </p>
10768 Info readers requiring the <file>/usr/share/info/dir</file> file
10769 should depend on <package>install-info</package>.
10770 </p>
10773 Info documents should contain section and directory entry
10774 information in the document for the use
10775 of <prgn>install-info</prgn>. The section should be specified
10776 via a line starting with <tt>INFO-DIR-SECTION</tt> followed by a
10777 space and the section of this info page. The directory entry or
10778 entries should be included between
10779 a <tt>START-INFO-DIR-ENTRY</tt> line and
10780 an <tt>END-INFO-DIR-ENTRY</tt> line. For example:
10781 <example>
10782 INFO-DIR-SECTION Individual utilities
10783 START-INFO-DIR-ENTRY
10784 * example: (example). An example info directory entry.
10785 END-INFO-DIR-ENTRY
10786 </example>
10787 To determine which section to use, you should look
10788 at <file>/usr/share/info/dir</file> on your system and choose
10789 the most relevant (or create a new section if none of the
10790 current sections are relevant).<footnote>
10791 Normally, info documents are generated from Texinfo source.
10792 To include this information in the generated info document, if
10793 it is absent, add commands like:
10794 <example>
10795 @dircategory Individual utilities
10796 @direntry
10797 * example: (example). An example info directory entry.
10798 @end direntry
10799 </example>
10800 to the Texinfo source of the document and ensure that the info
10801 documents are rebuilt from source during the package build.
10802 </footnote>
10803 </p>
10804 </sect>
10806 <sect id="docs-additional">
10807 <heading>Additional documentation</heading>
10810 Any additional documentation that comes with the package may be
10811 installed at the discretion of the package maintainer. It is
10812 often a good idea to include text information files
10813 (<file>README</file>s, FAQs, and so forth) that come with the
10814 source package in the binary package. However, you don't need
10815 to install the instructions for building and installing the
10816 package, of course!
10817 </p>
10820 Plain text documentation should be compressed with <tt>gzip
10821 -9</tt> unless it is small.
10822 </p>
10825 If a package comes with large amounts of documentation that many
10826 users of the package will not require, you should create a
10827 separate binary package to contain it so that it does not take
10828 up disk space on the machines of users who do not need or want
10829 it installed. As a special case of this rule, shared library
10830 documentation of any appreciable size should always be packaged
10831 with the library development package (<ref id="sharedlibs-dev">)
10832 or in a separate documentation package, since shared libraries
10833 are frequently installed as dependencies of other packages by
10834 users who have little interest in documentation of the library
10835 itself. The documentation package for the
10836 package <var>package</var> is conventionally
10837 named <var>package</var>-doc
10838 (or <var>package</var>-doc-<var>language-code</var> if there are
10839 separate documentation packages for multiple languages).
10840 </p>
10843 If <var>package</var> is a build tool, development tool,
10844 command-line tool, or library development package,
10845 <var>package</var> (or <var>package</var>-dev in the case of a
10846 library development package) already provides documentation in
10847 man, info, or plain text format, and <var>package</var>-doc
10848 provides HTML or other formats, <var>package</var> should declare
10849 at most a <tt>Suggests</tt> on <var>package</var>-doc. Otherwise,
10850 <var>package</var> should declare at most a <tt>Recommends</tt> on
10851 <var>package</var>-doc.
10852 </p>
10855 Additional documentation included in the package should be
10856 installed under <file>/usr/share/doc/<var>package</var></file>.
10857 If the documentation is packaged separately,
10858 as <var>package</var>-doc for example, it may be installed under
10859 either that path or into the documentation directory for the
10860 separate documentation package
10861 (<file>/usr/share/doc/<var>package</var>-doc</file> in this
10862 example). However, installing the documentation into the
10863 documentation directory of the main package is preferred since
10864 it is independent of the packaging method and will be easier for
10865 users to find.
10866 </p>
10869 Any separate package providing documentation must still install
10870 standard documentation files in its
10871 own <file>/usr/share/doc</file> directory as specified in the
10872 rest of this policy. See, for example, <ref id="copyrightfile">
10873 and <ref id="changelogs">.
10874 </p>
10877 Packages must not require the existence of any files in
10878 <file>/usr/share/doc/</file> in order to function
10879 <footnote>
10880 The system administrator should be able to delete files
10881 in <file>/usr/share/doc/</file> without causing any programs
10882 to break.
10883 </footnote>. Any files that are used or read by programs but
10884 are also useful as stand alone documentation should be installed
10885 elsewhere, such as
10886 under <file>/usr/share/<var>package</var>/</file>, and then
10887 included via symbolic links
10888 in <file>/usr/share/doc/<var>package</var></file>.
10889 </p>
10892 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
10893 link to another directory in <file>/usr/share/doc</file> only if
10894 the two packages both come from the same source and the
10895 first package Depends on the second.<footnote>
10897 Please note that this does not override the section on
10898 changelog files below, so the file
10899 <file>/usr/share/doc/<var>package</var>/changelog.Debian.gz</file>
10900 must refer to the changelog for the current version of
10901 <var>package</var> in question. In practice, this means
10902 that the sources of the target and the destination of the
10903 symlink must be the same (same source package and
10904 version).
10905 </p>
10906 </footnote>
10907 </p>
10908 </sect>
10910 <sect>
10911 <heading>Preferred documentation formats</heading>
10914 The unification of Debian documentation is being carried out
10915 via HTML.</p>
10918 If the package comes with extensive documentation in a
10919 markup format that can be converted to various other formats
10920 you should if possible ship HTML versions in a binary
10921 package.<footnote>
10922 Rationale: The important thing here is that HTML
10923 documentation should be available from <em>some</em>
10924 binary package.
10925 </footnote>
10926 The documentation must be installed as specified in
10927 <ref id="docs-additional">.
10928 </p>
10931 Other formats such as PostScript may be provided at the
10932 package maintainer's discretion.
10933 </p>
10934 </sect>
10936 <sect id="copyrightfile">
10937 <heading>Copyright information</heading>
10940 Every package must be accompanied by a verbatim copy of its
10941 copyright information and distribution license in the file
10942 <file>/usr/share/doc/<var>package</var>/copyright</file>. This
10943 file must neither be compressed nor be a symbolic link.
10944 </p>
10947 In addition, the copyright file must say where the upstream
10948 sources (if any) were obtained, and should name the original
10949 authors.
10950 </p>
10953 Packages in the <em>contrib</em> or <em>non-free</em> archive
10954 areas should state in the copyright file that the package is not
10955 part of the Debian distribution and briefly explain why.
10956 </p>
10959 A copy of the file which will be installed in
10960 <file>/usr/share/doc/<var>package</var>/copyright</file> should
10961 be in <file>debian/copyright</file> in the source package.
10962 </p>
10965 <file>/usr/share/doc/<var>package</var></file> may be a symbolic
10966 link to another directory in <file>/usr/share/doc</file> only if
10967 the two packages both come from the same source and the
10968 first package Depends on the second. These rules are important
10969 because <file>copyright</file> files must be extractable by
10970 mechanical means.
10971 </p>
10974 Packages distributed under the Apache license (version 2.0), the
10975 Artistic license, the GNU GPL (versions 1, 2, or 3), the GNU
10976 LGPL (versions 2, 2.1, or 3), the GNU FDL (versions 1.2 or 1.3),
10977 and the Mozilla Public License (version 1.1 or 2.0) should refer
10978 to the corresponding files under
10979 <file>/usr/share/common-licenses</file>,<footnote>
10981 In particular,
10982 <file>/usr/share/common-licenses/Apache-2.0</file>,
10983 <file>/usr/share/common-licenses/Artistic</file>,
10984 <file>/usr/share/common-licenses/GPL-1</file>,
10985 <file>/usr/share/common-licenses/GPL-2</file>,
10986 <file>/usr/share/common-licenses/GPL-3</file>,
10987 <file>/usr/share/common-licenses/LGPL-2</file>,
10988 <file>/usr/share/common-licenses/LGPL-2.1</file>,
10989 <file>/usr/share/common-licenses/LGPL-3</file>,
10990 <file>/usr/share/common-licenses/GFDL-1.2</file>,
10991 <file>/usr/share/common-licenses/GFDL-1.3</file>,
10992 <file>/usr/share/common-licenses/MPL-1.1</file>, and
10993 <file>/usr/share/common-licenses/MPL-2.0</file>
10994 respectively. The University of California BSD license is
10995 also included in <package>base-files</package> as
10996 <file>/usr/share/common-licenses/BSD</file>, but given the
10997 brevity of this license, its specificity to code whose
10998 copyright is held by the Regents of the University of
10999 California, and the frequency of minor wording changes, its
11000 text should be included in the copyright file rather than
11001 referencing this file.
11002 </p>
11003 </footnote> rather than quoting them in the copyright
11004 file.
11005 </p>
11008 You should not use the copyright file as a general <file>README</file>
11009 file. If your package has such a file it should be
11010 installed in <file>/usr/share/doc/<var>package</var>/README</file> or
11011 <file>README.Debian</file> or some other appropriate place.
11012 </p>
11015 All copyright files must be encoded in UTF-8.
11016 </p>
11018 <sect1 id="copyrightformat">
11019 <heading>Machine-readable copyright information</heading>
11022 A specification for a standard, machine-readable format
11023 for <file>debian/copyright</file> files is maintained as part
11024 of the <package>debian-policy</package> package. This
11025 document may be found in the <file>copyright-format</file>
11026 files in the <package>debian-policy</package> package. It is
11027 also available from the Debian web mirrors at
11028 <tt><url name="/doc/packaging-manuals/copyright-format/1.0/"
11029 id="http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"></tt>.
11030 </p>
11033 Use of this format is optional.
11034 </p>
11035 </sect1>
11036 </sect>
11038 <sect>
11039 <heading>Examples</heading>
11042 Any examples (configurations, source files, whatever),
11043 should be installed in a directory
11044 <file>/usr/share/doc/<var>package</var>/examples</file>. These
11045 files should not be referenced by any program: they're there
11046 for the benefit of the system administrator and users as
11047 documentation only. Architecture-specific example files
11048 should be installed in a directory
11049 <file>/usr/lib/<var>package</var>/examples</file> with symbolic
11050 links to them from
11051 <file>/usr/share/doc/<var>package</var>/examples</file>, or the
11052 latter directory itself may be a symbolic link to the
11053 former.
11054 </p>
11057 If the purpose of a package is to provide examples, then the
11058 example files may be installed into
11059 <file>/usr/share/doc/<var>package</var></file>.
11060 </p>
11061 </sect>
11063 <sect id="changelogs">
11064 <heading>Changelog files</heading>
11067 Packages that are not Debian-native must contain a
11068 compressed copy of the <file>debian/changelog</file> file from
11069 the Debian source tree in
11070 <file>/usr/share/doc/<var>package</var></file> with the name
11071 <file>changelog.Debian.gz</file>.
11072 </p>
11075 If an upstream changelog is available, it should be accessible as
11076 <file>/usr/share/doc/<var>package</var>/changelog.gz</file> in
11077 plain text. If the upstream changelog is distributed in
11078 HTML, it should be made available in that form as
11079 <file>/usr/share/doc/<var>package</var>/changelog.html.gz</file>
11080 and a plain text <file>changelog.gz</file> should be generated
11081 from it using, for example, <tt>lynx -dump -nolist</tt>. If
11082 the upstream changelog files do not already conform to this
11083 naming convention, then this may be achieved either by
11084 renaming the files, or by adding a symbolic link, at the
11085 maintainer's discretion.<footnote>
11086 Rationale: People should not have to look in places for
11087 upstream changelogs merely because they are given
11088 different names or are distributed in HTML format.
11089 </footnote>
11090 </p>
11093 All of these files should be installed compressed using
11094 <tt>gzip -9</tt>, as they will become large with time even
11095 if they start out small.
11096 </p>
11099 If the package has only one changelog which is used both as
11100 the Debian changelog and the upstream one because there is
11101 no separate upstream maintainer then that changelog should
11102 usually be installed as
11103 <file>/usr/share/doc/<var>package</var>/changelog.gz</file>; if
11104 there is a separate upstream maintainer, but no upstream
11105 changelog, then the Debian changelog should still be called
11106 <file>changelog.Debian.gz</file>.
11107 </p>
11110 For details about the format and contents of the Debian
11111 changelog file, please see <ref id="dpkgchangelog">.
11112 </p>
11113 </sect>
11114 </chapt>
11116 <appendix id="pkg-scope">
11117 <heading>Introduction and scope of these appendices</heading>
11120 These appendices are taken essentially verbatim from the
11121 now-deprecated Packaging Manual, version 3.2.1.0. They are
11122 the chapters which are likely to be of use to package
11123 maintainers and which have not already been included in the
11124 policy document itself. Most of these sections are very likely
11125 not relevant to policy; they should be treated as
11126 documentation for the packaging system. Please note that these
11127 appendices are included for convenience, and for historical
11128 reasons: they used to be part of policy package, and they have
11129 not yet been incorporated into dpkg documentation. However,
11130 they still have value, and hence they are presented here.
11131 </p>
11134 They have not yet been checked to ensure that they are
11135 compatible with the contents of policy, and if there are any
11136 contradictions, the version in the main policy document takes
11137 precedence. The remaining chapters of the old Packaging
11138 Manual have also not been read in detail to ensure that there
11139 are not parts which have been left out. Both of these will be
11140 done in due course.
11141 </p>
11144 Certain parts of the Packaging manual were integrated into the
11145 Policy Manual proper, and removed from the appendices. Links
11146 have been placed from the old locations to the new ones.
11147 </p>
11150 <prgn>dpkg</prgn> is a suite of programs for creating binary
11151 package files and installing and removing them on Unix
11152 systems.<footnote>
11153 <prgn>dpkg</prgn> is targeted primarily at Debian, but may
11154 work on or be ported to other systems.
11155 </footnote>
11156 </p>
11159 The binary packages are designed for the management of
11160 installed executable programs (usually compiled binaries) and
11161 their associated data, though source code examples and
11162 documentation are provided as part of some packages.</p>
11165 This manual describes the technical aspects of creating Debian
11166 binary packages (<file>.deb</file> files). It documents the
11167 behavior of the package management programs
11168 <prgn>dpkg</prgn>, <prgn>dselect</prgn> et al. and the way
11169 they interact with packages.</p>
11172 This manual does not go into detail about the options and
11173 usage of the package building and installation tools. It
11174 should therefore be read in conjunction with those programs'
11175 man pages.
11176 </p>
11179 The utility programs which are provided with <prgn>dpkg</prgn>
11180 not described in detail here, are documented in their man pages.
11181 </p>
11184 It is assumed that the reader is reasonably familiar with the
11185 <prgn>dpkg</prgn> System Administrators' manual.
11186 Unfortunately this manual does not yet exist.
11187 </p>
11190 The Debian version of the FSF's GNU hello program is provided as
11191 an example for people wishing to create Debian packages. However,
11192 while the examples are helpful, they do not replace the need to
11193 read and follow the Policy and Programmer's Manual.</p>
11194 </appendix>
11196 <appendix id="pkg-binarypkg">
11197 <heading>Binary packages (from old Packaging Manual)</heading>
11200 See <manref name="deb" section="5"> and <ref id="pkg-controlarea">.
11201 </p>
11203 <sect id="pkg-bincreating"><heading>Creating package files -
11204 <prgn>dpkg-deb</prgn>
11205 </heading>
11208 All manipulation of binary package files is done by
11209 <prgn>dpkg-deb</prgn>; it's the only program that has
11210 knowledge of the format. (<prgn>dpkg-deb</prgn> may be
11211 invoked by calling <prgn>dpkg</prgn>, as <prgn>dpkg</prgn>
11212 will spot that the options requested are appropriate to
11213 <prgn>dpkg-deb</prgn> and invoke that instead with the same
11214 arguments.)
11215 </p>
11218 In order to create a binary package, you must make a directory
11219 tree which contains all the files and directories you want to
11220 have in the file system data part of the package. In
11221 Debian-format source packages, this directory is usually
11222 either <file>debian/tmp</file>
11223 or <file>debian/<var>pkg</var></file>, relative to the top of
11224 the package's source tree.
11225 </p>
11228 They should have the locations (relative to the root of the
11229 directory tree you're constructing) ownerships and
11230 permissions which you want them to have on the system when
11231 they are installed.
11232 </p>
11235 With current versions of <prgn>dpkg</prgn> the uid/username
11236 and gid/groupname mappings for the users and groups being
11237 used should be the same on the system where the package is
11238 built and the one where it is installed.
11239 </p>
11242 You need to add one special directory to the root of the
11243 miniature file system tree you're creating:
11244 <prgn>DEBIAN</prgn>. It should contain the control
11245 information files, notably the binary package control file
11246 (see <ref id="pkg-controlfile">).
11247 </p>
11250 The <prgn>DEBIAN</prgn> directory will not appear in the
11251 file system archive of the package, and so won't be installed
11252 by <prgn>dpkg</prgn> when the package is unpacked.
11253 </p>
11256 When you've prepared the package, you should invoke:
11257 <example>
11258 dpkg --build <var>directory</var>
11259 </example>
11260 </p>
11263 This will build the package in
11264 <file><var>directory</var>.deb</file>. (<prgn>dpkg</prgn> knows
11265 that <tt>--build</tt> is a <prgn>dpkg-deb</prgn> option, so
11266 it invokes <prgn>dpkg-deb</prgn> with the same arguments to
11267 build the package.)
11268 </p>
11271 See the man page <manref name="dpkg-deb" section="8"> for details of how
11272 to examine the contents of this newly-created file. You may find the
11273 output of following commands enlightening:
11274 <example>
11275 dpkg-deb --info <var>filename</var>.deb
11276 dpkg-deb --contents <var>filename</var>.deb
11277 dpkg --contents <var>filename</var>.deb
11278 </example>
11279 To view the copyright file for a package you could use this command:
11280 <example>
11281 dpkg --fsys-tarfile <var>filename</var>.deb | tar xOf - --wildcards \*/copyright | pager
11282 </example>
11283 </p>
11284 </sect>
11286 <sect id="pkg-controlarea">
11287 <heading>Package control information files</heading>
11290 The control information portion of a binary package is a
11291 collection of files with names known to <prgn>dpkg</prgn>.
11292 It will treat the contents of these files specially - some
11293 of them contain information used by <prgn>dpkg</prgn> when
11294 installing or removing the package; others are scripts which
11295 the package maintainer wants <prgn>dpkg</prgn> to run.
11296 </p>
11299 It is possible to put other files in the package control
11300 information file area, but this is not generally a good idea
11301 (though they will largely be ignored).
11302 </p>
11305 Here is a brief list of the control information files supported
11306 by <prgn>dpkg</prgn> and a summary of what they're used for.
11307 </p>
11310 <taglist>
11311 <tag><tt>control</tt>
11312 <item>
11314 This is the key description file used by
11315 <prgn>dpkg</prgn>. It specifies the package's name
11316 and version, gives its description for the user,
11317 states its relationships with other packages, and so
11318 forth. See <ref id="sourcecontrolfiles"> and
11319 <ref id="binarycontrolfiles">.
11320 </p>
11323 It is usually generated automatically from information
11324 in the source package by the
11325 <prgn>dpkg-gencontrol</prgn> program, and with
11326 assistance from <prgn>dpkg-shlibdeps</prgn>.
11327 See <ref id="pkg-sourcetools">.
11328 </p>
11329 </item>
11331 <tag><tt>postinst</tt>, <tt>preinst</tt>, <tt>postrm</tt>,
11332 <tt>prerm</tt>
11333 </tag>
11334 <item>
11336 These are executable files (usually scripts) which
11337 <prgn>dpkg</prgn> runs during installation, upgrade
11338 and removal of packages. They allow the package to
11339 deal with matters which are particular to that package
11340 or require more complicated processing than that
11341 provided by <prgn>dpkg</prgn>. Details of when and
11342 how they are called are in <ref id="maintainerscripts">.
11343 </p>
11346 It is very important to make these scripts idempotent.
11347 See <ref id="idempotency">.
11348 </p>
11351 The maintainer scripts are not guaranteed to run with a
11352 controlling terminal and may not be able to interact with
11353 the user. See <ref id="controllingterminal">.
11354 </p>
11355 </item>
11357 <tag><tt>conffiles</tt>
11358 </tag>
11359 <item>
11360 This file contains a list of configuration files which
11361 are to be handled automatically by <prgn>dpkg</prgn>
11362 (see <ref id="pkg-conffiles">). Note that not necessarily
11363 every configuration file should be listed here.
11364 </item>
11366 <tag><tt>shlibs</tt>
11367 </tag>
11368 <item>
11369 This file contains a list of the shared libraries
11370 supplied by the package, with dependency details for
11371 each. This is used by <prgn>dpkg-shlibdeps</prgn>
11372 when it determines what dependencies are required in a
11373 package control file. The <tt>shlibs</tt> file format
11374 is described on <ref id="shlibs">.
11375 </item>
11376 </taglist>
11377 </p>
11379 <sect id="pkg-controlfile">
11380 <heading>The main control information file: <tt>control</tt></heading>
11383 The most important control information file used by
11384 <prgn>dpkg</prgn> when it installs a package is
11385 <tt>control</tt>. It contains all the package's "vital
11386 statistics".
11387 </p>
11390 The binary package control files of packages built from
11391 Debian sources are made by a special tool,
11392 <prgn>dpkg-gencontrol</prgn>, which reads
11393 <file>debian/control</file> and <file>debian/changelog</file> to
11394 find the information it needs. See <ref id="pkg-sourcepkg"> for
11395 more details.
11396 </p>
11399 The fields in binary package control files are listed in
11400 <ref id="binarycontrolfiles">.
11401 </p>
11404 A description of the syntax of control files and the purpose
11405 of the fields is available in <ref id="controlfields">.
11406 </p>
11407 </sect>
11409 <sect>
11410 <heading>Time Stamps</heading>
11413 See <ref id="timestamps">.
11414 </p>
11415 </sect>
11416 </appendix>
11418 <appendix id="pkg-sourcepkg">
11419 <heading>Source packages (from old Packaging Manual) </heading>
11422 The Debian binary packages in the distribution are generated
11423 from Debian sources, which are in a special format to assist
11424 the easy and automatic building of binaries.
11425 </p>
11427 <sect id="pkg-sourcetools">
11428 <heading>Tools for processing source packages</heading>
11431 Various tools are provided for manipulating source packages;
11432 they pack and unpack sources and help build of binary
11433 packages and help manage the distribution of new versions.
11434 </p>
11437 They are introduced and typical uses described here; see
11438 <manref name="dpkg-source" section="1"> for full
11439 documentation about their arguments and operation.
11440 </p>
11443 For examples of how to construct a Debian source package,
11444 and how to use those utilities that are used by Debian
11445 source packages, please see the <prgn>hello</prgn> example
11446 package.
11447 </p>
11449 <sect1 id="pkg-dpkg-source">
11450 <heading>
11451 <prgn>dpkg-source</prgn> - packs and unpacks Debian source
11452 packages
11453 </heading>
11456 This program is frequently used by hand, and is also
11457 called from package-independent automated building scripts
11458 such as <prgn>dpkg-buildpackage</prgn>.
11459 </p>
11462 To unpack a package it is typically invoked with
11463 <example>
11464 dpkg-source -x <var>.../path/to/filename</var>.dsc
11465 </example>
11466 </p>
11469 with the <file><var>filename</var>.tar.gz</file> and
11470 <file><var>filename</var>.diff.gz</file> (if applicable) in
11471 the same directory. It unpacks into
11472 <file><var>package</var>-<var>version</var></file>, and if
11473 applicable
11474 <file><var>package</var>-<var>version</var>.orig</file>, in
11475 the current directory.
11476 </p>
11479 To create a packed source archive it is typically invoked:
11480 <example>
11481 dpkg-source -b <var>package</var>-<var>version</var>
11482 </example>
11483 </p>
11486 This will create the <file>.dsc</file>, <file>.tar.gz</file> and
11487 <file>.diff.gz</file> (if appropriate) in the current
11488 directory. <prgn>dpkg-source</prgn> does not clean the
11489 source tree first - this must be done separately if it is
11490 required.
11491 </p>
11494 See also <ref id="pkg-sourcearchives">.</p>
11495 </sect1>
11498 <sect1 id="pkg-dpkg-buildpackage">
11499 <heading>
11500 <prgn>dpkg-buildpackage</prgn> - overall package-building
11501 control script
11502 </heading>
11505 See <manref name="dpkg-buildpackage" section="1">.
11506 </p>
11507 </sect1>
11509 <sect1 id="pkg-dpkg-gencontrol">
11510 <heading>
11511 <prgn>dpkg-gencontrol</prgn> - generates binary package
11512 control files
11513 </heading>
11516 This program is usually called from <file>debian/rules</file>
11517 (see <ref id="pkg-sourcetree">) in the top level of the source
11518 tree.
11519 </p>
11522 This is usually done just before the files and directories in the
11523 temporary directory tree where the package is being built have their
11524 permissions and ownerships set and the package is constructed using
11525 <prgn>dpkg-deb/</prgn>
11526 <footnote>
11527 This is so that the control file which is produced has
11528 the right permissions
11529 </footnote>.
11530 </p>
11533 <prgn>dpkg-gencontrol</prgn> must be called after all the
11534 files which are to go into the package have been placed in
11535 the temporary build directory, so that its calculation of
11536 the installed size of a package is correct.
11537 </p>
11540 It is also necessary for <prgn>dpkg-gencontrol</prgn> to
11541 be run after <prgn>dpkg-shlibdeps</prgn> so that the
11542 variable substitutions created by
11543 <prgn>dpkg-shlibdeps</prgn> in <file>debian/substvars</file>
11544 are available.
11545 </p>
11548 For a package which generates only one binary package, and
11549 which builds it in <file>debian/tmp</file> relative to the top
11550 of the source package, it is usually sufficient to call
11551 <prgn>dpkg-gencontrol</prgn>.
11552 </p>
11555 Sources which build several binaries will typically need
11556 something like:
11557 <example>
11558 dpkg-gencontrol -Pdebian/<var>pkg</var> -p<var>package</var>
11559 </example> The <tt>-P</tt> tells
11560 <prgn>dpkg-gencontrol</prgn> that the package is being
11561 built in a non-default directory, and the <tt>-p</tt>
11562 tells it which package's control file should be generated.
11563 </p>
11566 <prgn>dpkg-gencontrol</prgn> also adds information to the
11567 list of files in <file>debian/files</file>, for the benefit of
11568 (for example) a future invocation of
11569 <prgn>dpkg-genchanges</prgn>.</p>
11570 </sect1>
11572 <sect1 id="pkg-dpkg-shlibdeps">
11573 <heading>
11574 <prgn>dpkg-shlibdeps</prgn> - calculates shared library
11575 dependencies
11576 </heading>
11579 See <manref name="dpkg-shlibdeps" section="1">.
11580 </p>
11581 </sect1>
11583 <sect1 id="pkg-dpkg-distaddfile">
11584 <heading>
11585 <prgn>dpkg-distaddfile</prgn> - adds a file to
11586 <file>debian/files</file>
11587 </heading>
11590 Some packages' uploads need to include files other than
11591 the source and binary package files.
11592 </p>
11595 <prgn>dpkg-distaddfile</prgn> adds a file to the
11596 <file>debian/files</file> file so that it will be included in
11597 the <file>.changes</file> file when
11598 <prgn>dpkg-genchanges</prgn> is run.
11599 </p>
11602 It is usually invoked from the <tt>binary</tt> target of
11603 <file>debian/rules</file>:
11604 <example>
11605 dpkg-distaddfile <var>filename</var> <var>section</var> <var>priority</var>
11606 </example>
11607 The <var>filename</var> is relative to the directory where
11608 <prgn>dpkg-genchanges</prgn> will expect to find it - this
11609 is usually the directory above the top level of the source
11610 tree. The <file>debian/rules</file> target should put the
11611 file there just before or just after calling
11612 <prgn>dpkg-distaddfile</prgn>.
11613 </p>
11616 The <var>section</var> and <var>priority</var> are passed
11617 unchanged into the resulting <file>.changes</file> file.
11618 </p>
11619 </sect1>
11622 <sect1 id="pkg-dpkg-genchanges">
11623 <heading>
11624 <prgn>dpkg-genchanges</prgn> - generates a <file>.changes</file>
11625 upload control file
11626 </heading>
11629 See <manref name="dpkg-genchanges" section="1">.
11630 </p>
11631 </sect1>
11633 <sect1 id="pkg-dpkg-parsechangelog">
11634 <heading>
11635 <prgn>dpkg-parsechangelog</prgn> - produces parsed
11636 representation of a changelog
11637 </heading>
11640 See <manref name="dpkg-parsechangelog" section="1">.
11641 </p>
11642 </sect1>
11644 <sect1 id="pkg-dpkg-architecture">
11645 <heading>
11646 <prgn>dpkg-architecture</prgn> - information about the build and
11647 host system
11648 </heading>
11651 See <manref name="dpkg-architecture" section="1">.
11652 </p>
11653 </sect1>
11654 </sect>
11656 <sect id="pkg-sourcetree">
11657 <heading>The Debian package source tree</heading>
11660 The source archive scheme described later is intended to
11661 allow a Debian package source tree with some associated
11662 control information to be reproduced and transported easily.
11663 The Debian package source tree is a version of the original
11664 program with certain files added for the benefit of the
11665 packaging process, and with any other changes required
11666 made to the rest of the source code and installation
11667 scripts.
11668 </p>
11671 The extra files created for Debian are in the subdirectory
11672 <file>debian</file> of the top level of the Debian package
11673 source tree. They are described below.
11674 </p>
11676 <sect1 id="pkg-debianrules">
11677 <heading><file>debian/rules</file> - the main building script</heading>
11680 See <ref id="debianrules">.
11681 </p>
11682 </sect1>
11684 <sect1 id="pkg-srcsubstvars">
11685 <heading><file>debian/substvars</file> and variable substitutions</heading>
11688 See <ref id="substvars">.
11689 </p>
11691 </sect1>
11693 <sect1>
11694 <heading><file>debian/files</file></heading>
11697 See <ref id="debianfiles">.
11698 </p>
11699 </sect1>
11701 <sect1><heading><file>debian/tmp</file>
11702 </heading>
11705 This is the default temporary location for the construction of
11706 binary packages by the <tt>binary</tt> target. The
11707 directory <file>tmp</file> serves as the root of the file
11708 system tree as it is being constructed (for example, by using
11709 the package's upstream makefiles install targets and
11710 redirecting the output there), and it also contains
11711 the <tt>DEBIAN</tt> subdirectory.
11712 See <ref id="pkg-bincreating">.
11713 </p>
11716 This is only a default and can be easily overridden. Most
11717 packaging tools no longer use <file>debian/tmp</file>, instead
11718 preferring <file>debian/<var>pkg</var></file> for the common
11719 case of a source package building only one binary package.
11720 Such tools usually only use <file>debian/tmp</file> as a
11721 temporary staging area for built files and do not construct
11722 packages from it.
11723 </p>
11726 If several binary packages are generated from the same source
11727 tree, it is usual to use a separate
11728 <file>debian/<var>pkg</var></file> directory for each binary
11729 package as the temporary construction locations.
11730 </p>
11733 Whatever temporary directories are created and used by the
11734 <tt>binary</tt> target must of course be removed by the
11735 <tt>clean</tt> target.
11736 </p>
11737 </sect1>
11738 </sect>
11741 <sect id="pkg-sourcearchives"><heading>Source packages as archives
11742 </heading>
11745 As it exists on the FTP site, a Debian source package
11746 consists of three related files. You must have the right
11747 versions of all three to be able to use them.
11748 </p>
11751 <taglist>
11752 <tag>Debian source control file - <tt>.dsc</tt></tag>
11753 <item>
11754 This file is a control file used by <prgn>dpkg-source</prgn>
11755 to extract a source package.
11756 See <ref id="debiansourcecontrolfiles">.
11757 </item>
11759 <tag>
11760 Original source archive -
11761 <file>
11762 <var>package</var>_<var>upstream-version</var>.orig.tar.gz
11763 </file>
11764 </tag>
11766 <item>
11768 This is a compressed (with <tt>gzip -9</tt>)
11769 <prgn>tar</prgn> file containing the source code from
11770 the upstream authors of the program.
11771 </p>
11772 </item>
11774 <tag>
11775 Debian package diff -
11776 <file>
11777 <var>package</var>_<var>upstream_version-revision</var>.diff.gz
11778 </file>
11779 </tag>
11780 <item>
11783 This is a unified context diff (<tt>diff -u</tt>)
11784 giving the changes which are required to turn the
11785 original source into the Debian source. These changes
11786 may only include editing and creating plain files.
11787 The permissions of files, the targets of symbolic
11788 links and the characteristics of special files or
11789 pipes may not be changed and no files may be removed
11790 or renamed.
11791 </p>
11794 All the directories in the diff must exist, except the
11795 <file>debian</file> subdirectory of the top of the source
11796 tree, which will be created by
11797 <prgn>dpkg-source</prgn> if necessary when unpacking.
11798 </p>
11801 The <prgn>dpkg-source</prgn> program will
11802 automatically make the <file>debian/rules</file> file
11803 executable (see below).</p></item>
11804 </taglist>
11805 </p>
11808 If there is no original source code - for example, if the
11809 package is specially prepared for Debian or the Debian
11810 maintainer is the same as the upstream maintainer - the
11811 format is slightly different: then there is no diff, and the
11812 tarfile is named
11813 <file><var>package</var>_<var>version</var>.tar.gz</file>,
11814 and preferably contains a directory named
11815 <file><var>package</var>-<var>version</var></file>.
11816 </p>
11817 </sect>
11819 <sect>
11820 <heading>Unpacking a Debian source package without <prgn>dpkg-source</prgn></heading>
11823 <tt>dpkg-source -x</tt> is the recommended way to unpack a
11824 Debian source package. However, if it is not available it
11825 is possible to unpack a Debian source archive as follows:
11826 <enumlist compact="compact">
11827 <item>
11829 Untar the tarfile, which will create a <file>.orig</file>
11830 directory.</p>
11831 </item>
11832 <item>
11833 <p>Rename the <file>.orig</file> directory to
11834 <file><var>package</var>-<var>version</var></file>.</p>
11835 </item>
11836 <item>
11838 Create the subdirectory <file>debian</file> at the top of
11839 the source tree.</p>
11840 </item>
11841 <item><p>Apply the diff using <tt>patch -p0</tt>.</p>
11842 </item>
11843 <item><p>Untar the tarfile again if you want a copy of the original
11844 source code alongside the Debian version.</p>
11845 </item>
11846 </enumlist>
11849 It is not possible to generate a valid Debian source archive
11850 without using <prgn>dpkg-source</prgn>. In particular,
11851 attempting to use <prgn>diff</prgn> directly to generate the
11852 <file>.diff.gz</file> file will not work.
11853 </p>
11855 <sect1>
11856 <heading>Restrictions on objects in source packages</heading>
11859 The source package may not contain any hard links
11860 <footnote>
11861 This is not currently detected when building source
11862 packages, but only when extracting
11863 them.
11864 </footnote>
11865 <footnote>
11866 Hard links may be permitted at some point in the
11867 future, but would require a fair amount of
11868 work.
11869 </footnote>, device special files, sockets or setuid or
11870 setgid files.
11871 <footnote>
11872 Setgid directories are allowed.
11873 </footnote>
11874 </p>
11877 The source packaging tools manage the changes between the
11878 original and Debian source using <prgn>diff</prgn> and
11879 <prgn>patch</prgn>. Turning the original source tree as
11880 included in the <file>.orig.tar.gz</file> into the Debian
11881 package source must not involve any changes which cannot be
11882 handled by these tools. Problematic changes which cause
11883 <prgn>dpkg-source</prgn> to halt with an error when
11884 building the source package are:
11885 <list compact="compact">
11886 <item><p>Adding or removing symbolic links, sockets or pipes.</p>
11887 </item>
11888 <item><p>Changing the targets of symbolic links.</p>
11889 </item>
11890 <item><p>Creating directories, other than <file>debian</file>.</p>
11891 </item>
11892 <item><p>Changes to the contents of binary files.</p></item>
11893 </list> Changes which cause <prgn>dpkg-source</prgn> to
11894 print a warning but continue anyway are:
11895 <list compact="compact">
11896 <item>
11898 Removing files, directories or symlinks.
11899 <footnote>
11900 Renaming a file is not treated specially - it is
11901 seen as the removal of the old file (which
11902 generates a warning, but is otherwise ignored),
11903 and the creation of the new one.
11904 </footnote>
11905 </p>
11906 </item>
11907 <item>
11909 Changed text files which are missing the usual final
11910 newline (either in the original or the modified
11911 source tree).
11912 </p>
11913 </item>
11914 </list>
11915 Changes which are not represented, but which are not detected by
11916 <prgn>dpkg-source</prgn>, are:
11917 <list compact="compact">
11918 <item><p>Changing the permissions of files (other than
11919 <file>debian/rules</file>) and directories.</p></item>
11920 </list>
11921 </p>
11924 The <file>debian</file> directory and <file>debian/rules</file>
11925 are handled specially by <prgn>dpkg-source</prgn> - before
11926 applying the changes it will create the <file>debian</file>
11927 directory, and afterwards it will make
11928 <file>debian/rules</file> world-executable.
11929 </p>
11930 </sect1>
11931 </sect>
11932 </appendix>
11934 <appendix id="pkg-controlfields">
11935 <heading>Control files and their fields (from old Packaging Manual)</heading>
11938 Many of the tools in the <prgn>dpkg</prgn> suite manipulate
11939 data in a common format, known as control files. Binary and
11940 source packages have control data as do the <file>.changes</file>
11941 files which control the installation of uploaded files, and
11942 <prgn>dpkg</prgn>'s internal databases are in a similar
11943 format.
11944 </p>
11946 <sect>
11947 <heading>Syntax of control files</heading>
11950 See <ref id="controlsyntax">.
11951 </p>
11954 It is important to note that there are several fields which
11955 are optional as far as <prgn>dpkg</prgn> and the related
11956 tools are concerned, but which must appear in every Debian
11957 package, or whose omission may cause problems.
11958 </p>
11959 </sect>
11961 <sect>
11962 <heading>List of fields</heading>
11965 See <ref id="controlfieldslist">.
11966 </p>
11969 This section now contains only the fields that didn't belong
11970 to the Policy manual.
11971 </p>
11973 <sect1 id="pkg-f-Filename">
11974 <heading><tt>Filename</tt> and <tt>MSDOS-Filename</tt></heading>
11977 These fields in <tt>Packages</tt> files give the
11978 filename(s) of (the parts of) a package in the
11979 distribution directories, relative to the root of the
11980 Debian hierarchy. If the package has been split into
11981 several parts the parts are all listed in order, separated
11982 by spaces.
11983 </p>
11984 </sect1>
11986 <sect1 id="pkg-f-Size">
11987 <heading><tt>Size</tt> and <tt>MD5sum</tt></heading>
11990 These fields in <file>Packages</file> files give the size (in
11991 bytes, expressed in decimal) and MD5 checksum of the
11992 file(s) which make(s) up a binary package in the
11993 distribution. If the package is split into several parts
11994 the values for the parts are listed in order, separated by
11995 spaces.
11996 </p>
11997 </sect1>
11999 <sect1 id="pkg-f-Status">
12000 <heading><tt>Status</tt></heading>
12003 This field in <prgn>dpkg</prgn>'s status file records
12004 whether the user wants a package installed, removed or
12005 left alone, whether it is broken (requiring
12006 re-installation) or not and what its current state on the
12007 system is. Each of these pieces of information is a
12008 single word.
12009 </p>
12010 </sect1>
12012 <sect1 id="pkg-f-Config-Version">
12013 <heading><tt>Config-Version</tt></heading>
12016 If a package is not installed or not configured, this
12017 field in <prgn>dpkg</prgn>'s status file records the last
12018 version of the package which was successfully
12019 configured.
12020 </p>
12021 </sect1>
12023 <sect1 id="pkg-f-Conffiles">
12024 <heading><tt>Conffiles</tt></heading>
12027 This field in <prgn>dpkg</prgn>'s status file contains
12028 information about the automatically-managed configuration
12029 files held by a package. This field should <em>not</em>
12030 appear anywhere in a package!
12031 </p>
12032 </sect1>
12034 <sect1>
12035 <heading>Obsolete fields</heading>
12038 These are still recognized by <prgn>dpkg</prgn> but should
12039 not appear anywhere any more.
12041 <taglist compact="compact">
12043 <tag><tt>Revision</tt></tag>
12044 <tag><tt>Package-Revision</tt></tag>
12045 <tag><tt>Package_Revision</tt></tag>
12046 <item>
12047 The Debian revision part of the package version was
12048 at one point in a separate control field. This
12049 field went through several names.
12050 </item>
12052 <tag><tt>Recommended</tt></tag>
12053 <item>Old name for <tt>Recommends</tt>.</item>
12055 <tag><tt>Optional</tt></tag>
12056 <item>Old name for <tt>Suggests</tt>.</item>
12058 <tag><tt>Class</tt></tag>
12059 <item>Old name for <tt>Priority</tt>.</item>
12061 </taglist>
12062 </p>
12063 </sect1>
12064 </sect>
12066 </appendix>
12068 <appendix id="pkg-conffiles">
12069 <heading>Configuration file handling (from old Packaging Manual)</heading>
12072 <prgn>dpkg</prgn> can do a certain amount of automatic
12073 handling of package configuration files.
12074 </p>
12077 Whether this mechanism is appropriate depends on a number of
12078 factors, but basically there are two approaches to any
12079 particular configuration file.
12080 </p>
12083 The easy method is to ship a best-effort configuration in the
12084 package, and use <prgn>dpkg</prgn>'s conffile mechanism to
12085 handle updates. If the user is unlikely to want to edit the
12086 file, but you need them to be able to without losing their
12087 changes, and a new package with a changed version of the file
12088 is only released infrequently, this is a good approach.
12089 </p>
12092 The hard method is to build the configuration file from
12093 scratch in the <prgn>postinst</prgn> script, and to take the
12094 responsibility for fixing any mistakes made in earlier
12095 versions of the package automatically. This will be
12096 appropriate if the file is likely to need to be different on
12097 each system.
12098 </p>
12100 <sect><heading>Automatic handling of configuration files by
12101 <prgn>dpkg</prgn>
12102 </heading>
12105 A package may contain a control information file called
12106 <tt>conffiles</tt>. This file should be a list of filenames
12107 of configuration files needing automatic handling, separated
12108 by newlines. The filenames should be absolute pathnames,
12109 and the files referred to should actually exist in the
12110 package.
12111 </p>
12114 When a package is upgraded <prgn>dpkg</prgn> will process
12115 the configuration files during the configuration stage,
12116 shortly before it runs the package's <prgn>postinst</prgn>
12117 script,
12118 </p>
12121 For each file it checks to see whether the version of the
12122 file included in the package is the same as the one that was
12123 included in the last version of the package (the one that is
12124 being upgraded from); it also compares the version currently
12125 installed on the system with the one shipped with the last
12126 version.
12127 </p>
12130 If neither the user nor the package maintainer has changed
12131 the file, it is left alone. If one or the other has changed
12132 their version, then the changed version is preferred - i.e.,
12133 if the user edits their file, but the package maintainer
12134 doesn't ship a different version, the user's changes will
12135 stay, silently, but if the maintainer ships a new version
12136 and the user hasn't edited it the new version will be
12137 installed (with an informative message). If both have
12138 changed their version the user is prompted about the problem
12139 and must resolve the differences themselves.
12140 </p>
12143 The comparisons are done by calculating the MD5 message
12144 digests of the files, and storing the MD5 of the file as it
12145 was included in the most recent version of the package.
12146 </p>
12149 When a package is installed for the first time
12150 <prgn>dpkg</prgn> will install the file that comes with it,
12151 unless that would mean overwriting a file already on the
12152 file system.
12153 </p>
12156 However, note that <prgn>dpkg</prgn> will <em>not</em>
12157 replace a conffile that was removed by the user (or by a
12158 script). This is necessary because with some programs a
12159 missing file produces an effect hard or impossible to
12160 achieve in another way, so that a missing file needs to be
12161 kept that way if the user did it.
12162 </p>
12165 Note that a package should <em>not</em> modify a
12166 <prgn>dpkg</prgn>-handled conffile in its maintainer
12167 scripts. Doing this will lead to <prgn>dpkg</prgn> giving
12168 the user confusing and possibly dangerous options for
12169 conffile update when the package is upgraded.</p>
12170 </sect>
12172 <sect><heading>Fully-featured maintainer script configuration
12173 handling
12174 </heading>
12177 For files which contain site-specific information such as
12178 the hostname and networking details and so forth, it is
12179 better to create the file in the package's
12180 <prgn>postinst</prgn> script.
12181 </p>
12184 This will typically involve examining the state of the rest
12185 of the system to determine values and other information, and
12186 may involve prompting the user for some information which
12187 can't be obtained some other way.
12188 </p>
12191 When using this method there are a couple of important
12192 issues which should be considered:
12193 </p>
12196 If you discover a bug in the program which generates the
12197 configuration file, or if the format of the file changes
12198 from one version to the next, you will have to arrange for
12199 the postinst script to do something sensible - usually this
12200 will mean editing the installed configuration file to remove
12201 the problem or change the syntax. You will have to do this
12202 very carefully, since the user may have changed the file,
12203 perhaps to fix the very problem that your script is trying
12204 to deal with - you will have to detect these situations and
12205 deal with them correctly.
12206 </p>
12209 If you do go down this route it's probably a good idea to
12210 make the program that generates the configuration file(s) a
12211 separate program in <file>/usr/sbin</file>, by convention called
12212 <file><var>package</var>config</file> and then run that if
12213 appropriate from the post-installation script. The
12214 <tt><var>package</var>config</tt> program should not
12215 unquestioningly overwrite an existing configuration - if its
12216 mode of operation is geared towards setting up a package for
12217 the first time (rather than any arbitrary reconfiguration
12218 later) you should have it check whether the configuration
12219 already exists, and require a <tt>--force</tt> flag to
12220 overwrite it.</p></sect>
12221 </appendix>
12223 <appendix id="pkg-alternatives"><heading>Alternative versions of
12224 an interface - <prgn>update-alternatives</prgn> (from old
12225 Packaging Manual)
12226 </heading>
12229 When several packages all provide different versions of the
12230 same program or file it is useful to have the system select a
12231 default, but to allow the system administrator to change it
12232 and have their decisions respected.
12233 </p>
12236 For example, there are several versions of the <prgn>vi</prgn>
12237 editor, and there is no reason to prevent all of them from
12238 being installed at once, each under their own name
12239 (<prgn>nvi</prgn>, <prgn>vim</prgn> or whatever).
12240 Nevertheless it is desirable to have the name <tt>vi</tt>
12241 refer to something, at least by default.
12242 </p>
12245 If all the packages involved cooperate, this can be done with
12246 <prgn>update-alternatives</prgn>.
12247 </p>
12250 Each package provides its own version under its own name, and
12251 calls <prgn>update-alternatives</prgn> in its postinst to
12252 register its version (and again in its prerm to deregister
12253 it).
12254 </p>
12257 See the man page <manref name="update-alternatives"
12258 section="8"> for details.
12259 </p>
12262 If <prgn>update-alternatives</prgn> does not seem appropriate
12263 you may wish to consider using diversions instead.</p>
12264 </appendix>
12266 <appendix id="pkg-diversions"><heading>Diversions - overriding a
12267 package's version of a file (from old Packaging Manual)
12268 </heading>
12271 It is possible to have <prgn>dpkg</prgn> not overwrite a file
12272 when it reinstalls the package it belongs to, and to have it
12273 put the file from the package somewhere else instead.
12274 </p>
12277 This can be used locally to override a package's version of a
12278 file, or by one package to override another's version (or
12279 provide a wrapper for it).
12280 </p>
12283 Before deciding to use a diversion, read <ref
12284 id="pkg-alternatives"> to see if you really want a diversion
12285 rather than several alternative versions of a program.
12286 </p>
12289 There is a diversion list, which is read by <prgn>dpkg</prgn>,
12290 and updated by a special program <prgn>dpkg-divert</prgn>.
12291 Please see <manref name="dpkg-divert" section="8"> for full
12292 details of its operation.
12293 </p>
12296 When a package wishes to divert a file from another, it should
12297 call <prgn>dpkg-divert</prgn> in its preinst to add the
12298 diversion and rename the existing file. For example,
12299 supposing that a <prgn>smailwrapper</prgn> package wishes to
12300 install a wrapper around <file>/usr/sbin/smail</file>:
12301 <example>
12302 dpkg-divert --package smailwrapper --add --rename \
12303 --divert /usr/sbin/smail.real /usr/sbin/smail
12304 </example> The <tt>--package smailwrapper</tt> ensures that
12305 <prgn>smailwrapper</prgn>'s copy of <file>/usr/sbin/smail</file>
12306 can bypass the diversion and get installed as the true version.
12307 It's safe to add the diversion unconditionally on upgrades since
12308 it will be left unchanged if it already exists, but
12309 <prgn>dpkg-divert</prgn> will display a message. To suppress that
12310 message, make the command conditional on the version from which
12311 the package is being upgraded:
12312 <example>
12313 if [ upgrade != "$1" ] || dpkg --compare-versions "$2" lt 1.0-2; then
12314 dpkg-divert --package smailwrapper --add --rename \
12315 --divert /usr/sbin/smail.real /usr/sbin/smail
12317 </example> where <tt>1.0-2</tt> is the version at which the
12318 diversion was first added to the package. Running the command
12319 during abort-upgrade is pointless but harmless.
12320 </p>
12323 The postrm has to do the reverse:
12324 <example>
12325 if [ remove = "$1" -o abort-install = "$1" -o disappear = "$1" ]; then
12326 dpkg-divert --package smailwrapper --remove --rename \
12327 --divert /usr/sbin/smail.real /usr/sbin/smail
12329 </example> If the diversion was added at a particular version, the
12330 postrm should also handle the failure case of upgrading from an
12331 older version (unless the older version is so old that direct
12332 upgrades are no longer supported):
12333 <example>
12334 if [ abort-upgrade = "$1" ] &amp;&amp; dpkg --compare-versions "$2" lt 1.0-2; then
12335 dpkg-divert --package smailwrapper --remove --rename \
12336 --divert /usr/sbin/smail.real /usr/sbin/smail
12338 </example> where <tt>1.0-2</tt> is the version at which the
12339 diversion was first added to the package. The postrm should not
12340 remove the diversion on upgrades both because there's no reason to
12341 remove the diversion only to immediately re-add it and since the
12342 postrm of the old package is run after unpacking so the removal of
12343 the diversion will fail.
12344 </p>
12347 Do not attempt to divert a file which is vitally important for
12348 the system's operation - when using <prgn>dpkg-divert</prgn>
12349 there is a time, after it has been diverted but before
12350 <prgn>dpkg</prgn> has installed the new version, when the file
12351 does not exist.</p>
12354 Do not attempt to divert a conffile, as <prgn>dpkg</prgn> does not
12355 handle it well.
12356 </p>
12357 </appendix>
12359 </book>
12360 </debiandoc>
12361 <!-- Local variables: -->
12362 <!-- indent-tabs-mode: t -->
12363 <!-- End: -->
12364 <!-- vim:set ai sts=2 sw=2 tw=76: -->