guidelines.texi 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941
  1. \input texinfo @c -*-texinfo-*-
  2. @setfilename guidelines.info
  3. @set DATE 26th January 1996
  4. @setchapternewpage off
  5. @iftex
  6. @center @titlefont{Debian Linux Packaging Guidelines}
  7. @tex
  8. \vskip2pt \hrule height 2pt width \hsize \vskip2pt
  9. @end tex
  10. @sp 0.5
  11. @center @value{DATE}
  12. @end iftex
  13. @ifinfo
  14. @format
  15. START-INFO-DIR-ENTRY
  16. * Guidelines: (guidelines). How to make Debian packages.
  17. END-INFO-DIR-ENTRY
  18. @end format
  19. @end ifinfo
  20. @node Top, Additional Information, (dir), (dir)
  21. @ifinfo
  22. @top Debian Linux Packaging Guidelines
  23. @end ifinfo
  24. This file documents the steps that must be taken in the preparation
  25. of a Debian Linux package. All submissions to be included in the
  26. distribution proper and all packages to be considered for @file{contrib}
  27. or @file{non-free} availability @emph{must} conform to the guidelines
  28. and standards described in this document or they cannot be included or
  29. made available at the archive with the distribution.
  30. Please read the Guidelines carefully. If you have comments or
  31. questions, please contact @code{debian-devel@@pixar.com}. If you are
  32. planning on going further than just contributing a package (i.e., if
  33. you plan to maintain it for an extended period of time or if you are
  34. generally interested in becoming more involved in the Project), you
  35. should join the @code{debian-devel} mailing list. For more details,
  36. read @file{info/mailing-lists.txt}, available at any Debian Linux
  37. archive.
  38. (This file was last updated on @value{DATE}. Please check the most
  39. recent @file{dpkg} package at any Debian Linux archive for a
  40. potentially more up to date copy.)
  41. @menu
  42. * Additional Information:: Where other info is to be found.
  43. * Package Copyright:: A few words about the importance of
  44. understanding the package copyright.
  45. * Package Content:: Requirements for the package content.
  46. * Source Package:: Creating the source package.
  47. * Binary Package:: Creating the binary package.
  48. * Control Files:: The binary package control files.
  49. * Appendix:: More specific details about some aspects.
  50. @end menu
  51. @node Additional Information, Package Copyright, Top, Top
  52. @unnumbered Additional Information
  53. These Guidelines are intended to be fairly general. More specific
  54. information is available about certain aspects of building packages,
  55. such as how to use the features of Init under Debian Linux and how
  56. to interact with some more technical details of dpkg's operation. This
  57. information can be found in the directory @file{doc/package-developer}
  58. at any Debian Linux archive. At the time of this writing, the
  59. following documents are available:
  60. @table @file
  61. @item virtual-package-names-list.text
  62. The list of virtual package names currently in use, together with the
  63. procedure for getting new virtual package names allocated.
  64. @item auto-deconfiguration.txt
  65. How dpkg can sometimes automatically deconfigure packages in order to
  66. do bulk installations smoothly.
  67. @item dpkg-essential-flag.txt
  68. How to tell dpkg a package is essential and should not be removed.
  69. (This is for the use of base system packages only.)
  70. @item dpkg-disappear-replace.txt
  71. What happens when a package appears to have been completely replaced.
  72. @end table
  73. In the future, we hope also to make available:
  74. @table @file
  75. @item copyright.txt
  76. How to choose a good copyright notice to attach to new programs.
  77. @item version-ordering.txt
  78. The algorithm with which packages' version numbers are compared.
  79. @end table
  80. Also, you should download the sample files and the sample package
  81. (GNU Hello) available in @file{standards/samples}. You may use any
  82. of this material as a starting point for new packages. The following
  83. sample files, incidentally, are available:
  84. @itemize @bullet
  85. @item debian.README
  86. @item debian.control
  87. @item debian.postinst
  88. @item debian.postrm
  89. @item debian.rules
  90. @end itemize
  91. Some more detailed information about certain topics is available in the
  92. appendix to this document (@pxref{Appendix}).
  93. @node Package Copyright, Package Content, Additional Information, Top
  94. @unnumbered Package Copyright
  95. Please study the copyright of your submission @emph{carefully}
  96. and @emph{understand it} before proceeding! If you have doubts or
  97. questions, please ask!
  98. In order to understand how we classify and distribute certain
  99. packages, it is important to understand the distinction between being
  100. freely available and being freely redistributable.
  101. Being @dfn{freely available}, quite simply, means that the software
  102. can be made available freely, at least for non-commercial purposes and
  103. in its original, unmodified form. This includes packages made available
  104. freely that have restrictions on non-commercial use, redistribution of
  105. modifications, etc. Being freely available, therefore, has nothing to
  106. do with being able to modify and redistribute the software. It only
  107. means that you can get a copy of the software without having to pay
  108. (and it does not necessarily mean that you can @emph{use} the software
  109. without having to pay---shareware is an example of freely available
  110. software).
  111. @dfn{freely redistributable}, while generally being freely available,
  112. goes beyond just being freely available. Freely redistributable means
  113. that that the software, in addition to being able to be made available
  114. freely, must be able to be freely modified and redistributed without
  115. restriction.
  116. All submissions to be included in the distribution proper @emph{must}
  117. be freely redistributable.
  118. In addition to the distribution, the Project maintains two separate
  119. archives of software packages with the distribution: the @file{contrib}
  120. archive and the @file{non-free} archive.
  121. @file{contrib} is an archive of user-contributed packages that are
  122. not maintained by the Project, packages that were once maintained by the
  123. Project but that are no longer actively maintained, and packages that
  124. are maintained by the Project but that are not yet considered ready for
  125. inclusion in the distribution proper (i.e., ALPHA and BETA packages).
  126. As above, all submissions for inclusion in the @file{contrib} archive
  127. @emph{must} be freely redistributable.
  128. @file{non-free} is an archive of packages with either restrictive or
  129. unclear terms of copying or modification. If a package has @emph{any}
  130. restrictions on modification or redistribution, it can not be included
  131. in the distribution or @file{contrib} archive. It can only be included
  132. in the @file{non-free} archive, and then only if it is freely available.
  133. In summary, in order to be included in the distribution proper or the
  134. @file{contrib} archive, a package must be @emph{freely redistributable}.
  135. Anyone must be able to make copies of it, modify it, redistribute it with
  136. their modifications in place, include it on a CD-ROM, or generally sell
  137. it. To be included in the @file{non-free} archive, a package may have
  138. restrictions, as long as the package remains @emph{freely available}. We
  139. must be available to make it available freely at the archive, and anyone
  140. must be able to make copies of it and use it for at least non-commercial,
  141. personal purposes. Software that will typically be included in
  142. @file{non-free} are software that does not allow commercial distribution,
  143. software that does not allow modification or redistribution of
  144. modifications, commercial ``demos'', and ``shareware''.
  145. When in doubt, send mail to @file{debian-devel@@lists.debian.org}.
  146. Be prepared to provide us with the copyright statement. Software
  147. covered by the GPL, public domain software and BSD-like copyrights are
  148. safe; be wary of the phrases ``commercial use prohibited'' and
  149. ``distribution restricted''.
  150. Every package submission @emph{must} be accompanied by verbatim copy
  151. of its copyright (with the exceptions of public domain packages and
  152. those covered by the UCB BSD licence or the GNU GPL or LGPL; in these
  153. cases simply indicate which is appropriate). This information must be
  154. included in a file installed to the directory @file{/usr/doc/copyright}.
  155. See below for details.
  156. @node Package Content, Source Package, Package Copyright, Top
  157. @unnumbered Package Content
  158. The following requirements apply equally to both the binary and
  159. source packages. In either case, when files have been installed,
  160. they must conform to the requirements described in this section.
  161. The primary rule in Debian Linux is to follow the Linux @dfn{File
  162. System Standard} (@dfn{FSSTND}). The location of installed files
  163. @emph{must} comply @emph{fully} with the FSSTND. The latest version of
  164. this document can be found alongside the Guidelines or at
  165. @file{tsx-11.mit.edu} in @file{/pub/linux/docs/linux-standards/fsstnd}.
  166. Specific questions about following the standard should be addressed to
  167. Daniel Quinlan, the FSSTND coordinator, at @code{quinlan@@yggdrasil.com}.
  168. In addition to the FSSTND, all Debian Linux packages must follow
  169. the guidelines below.
  170. @itemize @bullet
  171. @item
  172. Directories should be mode 755 or (for group-writability) mode 2775,
  173. with the exception of special ``system'' directories that need to be
  174. another mode. The ownership of the directory should be consistent with
  175. its mode---if a directory is mode 2775, it should be owned by the group
  176. that needs write access to it, of course. Use common sense in assigning
  177. permissions and ownerships to directories, and make sure that what is
  178. done is secure if it is ``non-standard''.
  179. @item
  180. Normal binaries should be mode 755 and owned by @code{root.root}. If
  181. there is a good reason to use a different mode or ownership, you may do
  182. so, but you must try to be as consistent as possible with the rest of
  183. the system. If you need to use a different mode or ownership, please
  184. discuss it with @code{imurdock@@debian.org}.
  185. @item
  186. Setuid binaries should normally be mode 4755 (not 4711!) and, of course,
  187. owned by the appropriate user.
  188. @item
  189. Setgid binaries should normally be mode 2755 (not 2711!) and, of course,
  190. owned by the appropriate group.
  191. @item
  192. Library files should generally be mode 644 and owned by
  193. @code{root.root}; shared libraries should be mode 755. If the package
  194. requires different permissions or ownerships to function correctly, they
  195. should be used instead.
  196. @item
  197. Manual pages should be mode 644 and owned by @code{root.root}. The
  198. @file{nroff} source must be installed. You should @emph{not} install a
  199. preformatted ``cat page'', and you should only use sections 1 to 9---see
  200. the FSSTND for more details. If no manual page is available for a
  201. particular program, utility or function and this is reported as a bug on
  202. debian-bugs, a symbolic link from the requested manual page to the
  203. @file{undocumented}(7) manual page should be provided. This symbolic
  204. link can be created from @file{debian.rules} like this:
  205. @smallexample
  206. ln -s ../man7/undocumented.7 debian-tmp/usr/man/man[1-9]/the_requested_manpage.[1-9]
  207. @end smallexample
  208. Do not close the bug report until a proper manpage is available. You
  209. may forward the complaint to the upstream maintainers, and mark the bug
  210. as forwarded in the Debian bug tracking system. The GNU Project do not
  211. in general consider the lack of a manpage to be a bug, but we do - if
  212. they tell you to go away leave the bug open anyway.
  213. @item
  214. Info documents should be mode 644, owned by @code{root.root}, and
  215. compressed with @file{gzip -9} when installed. The package must call
  216. @file{install-info} to update the Info @file{dir} file. This should
  217. be done in the post-installation script (@file{postinst}), like this:
  218. @smallexample
  219. install-info --quiet /usr/info/foobar.info
  220. @end smallexample
  221. The entries should be removed by the pre-removal script (@file{prerm}),
  222. like this:
  223. @smallexample
  224. install-info --quiet --remove /usr/info/foobar.info
  225. @end smallexample
  226. It is also a good idea to specify a section for the Info @file{dir}
  227. entry. This is done with the @file{--section} switch. To determine
  228. which section to use, you should use look at @file{/usr/info/dir} on
  229. your system and choose the most relevant (or create a new section if
  230. none of the current sections are relevant).
  231. If @file{install-info} cannot find a description entry in the Info file
  232. you will have to supply one. See @file{install-info}(8) for details.
  233. @item
  234. If a package contains any shared libraries you will have to invoke
  235. @file{ldconfig} in both the @file{postinst} and @file{prerm} scripts
  236. to correctly update the library links. See @file{ldconfig}(8) for
  237. details.
  238. @item
  239. Any additional documentation that comes with the package can be
  240. installed at the discretion of the package maintainer. Text
  241. documentation should be mode 644, owned by @code{root.root}, installed
  242. to @file{/usr/doc}, and compressed with @file{gzip -9} unless it is small.
  243. If a subdirectory of @file{/usr/doc} is warranted, please do create one.
  244. Please do not install DVI, PostScript, or large textual documentation in
  245. the same package; upload such documentation as a separate package
  246. (installing its files in @file{/usr/doc}) so that it can be made
  247. available with the distribution. If a user has the need for the
  248. documentation, they can easily get it from the archive, CD-ROM, etc.,
  249. but it should not take up disk space on the machines of the user who do
  250. not need or want it installed.
  251. @item
  252. Create a file named @file{/usr/doc/copyright/<@i{package}>} which gives
  253. details of the authorship and copyright of the package. If the package
  254. is distributed under the GNU General Public Licence, the GNU Library
  255. General Public Licence or the Regents of the University of California at
  256. Berkeley (BSD) licence, please say so instead of including a copy of the
  257. licence. The files @file{BSD}, @file{GPL}, and @file{LGPL} will be
  258. available in the @file{/usr/doc/copyright} directory for you to refer
  259. to. @file{/usr/doc/copyright/<@i{package}>} should not be compressed.
  260. @emph{All} authorship and copyright information from the original source
  261. package must be included in the @file{/usr/doc/copyright/<@i{package}>}
  262. file.
  263. @item
  264. Any example files (for example, sample configuration files) should
  265. be placed in the directory @file{/usr/doc/examples}. If the file is
  266. normally a hidden file, such as @file{.emacs}, then please call it
  267. @file{dot.emacs}, to avoid confusion. Again, you may create a
  268. subdirectory if it is needed.
  269. @item
  270. All symbolic links should be relative, not absolute. Absolute links,
  271. in general, cause problems when a file system is not mounted where it
  272. ``normally'' resides (for example, when mounted via NFS). In certain
  273. cases, however, relative links may also cause similar problems. I
  274. have generally made links into @file{/etc} and @file{/var} absolute
  275. and all other links relative. There may be other cases in which
  276. absolute links are necessary.
  277. Therefore, in the @file{Makefile} or @file{debian.rules}, do not do:
  278. @smallexample
  279. install: all
  280. [...]
  281. ln -fs /usr/bin/gcc /usr/bin/cc
  282. [...]
  283. @end smallexample
  284. Instead, do:
  285. @smallexample
  286. ln -fs gcc /usr/bin/cc
  287. @end smallexample
  288. or
  289. @smallexample
  290. ( cd /usr/bin ; ln -fs gcc cc )
  291. @end smallexample
  292. Please do not create hard links in the manual page directories. In
  293. these cases, you should use relative symbolic links or files that
  294. @file{.so} (roff for `source') others instead.
  295. @item
  296. All command scripts should have a @code{#!} line naming the shell to be
  297. used to interpret them.
  298. @item
  299. In the case of Perl scripts this should be @code{#!/usr/bin/perl} or
  300. sometimes @code{#!/bin/perl}, as follows: if the script is a critical
  301. one that may be called when the @file{/usr} partition is unmounted or
  302. broken it should use @file{/bin/perl}. Otherwise (especially if the
  303. script is not specifically targetted at Debian) it should use Perl's
  304. standard location, @file{/usr/bin/perl}.
  305. @item
  306. Generally the following compilation parameters should be used:
  307. @display
  308. CC = gcc
  309. CFLAGS = -O2 -g -Wall # sane warning options vary between programs
  310. LDFLAGS = # none (or -N, if appropriate; see below)
  311. install -s (or strip)
  312. @end display
  313. Note that all installed binaries should be stripped, either by using the
  314. @code{-s} flag to @file{install}, or by calling @file{strip} on the
  315. binaries after they have been copied into the @file{debian-tmp} but
  316. before the tree is made into a package.
  317. Make sure that you do not link with @code{-g}, as this makes a.out
  318. compilers produce huge statically linked binaries. The @code{-g} flag
  319. is useful on compilation so that you have available a full set of
  320. debugging symbols in your built source tree, in case anyone should file
  321. a bug report involving (for example) a core dump.
  322. @code{-N} should only be used on binaries that are very small (less than
  323. 8K with the @code{-N} option, roughly) and are not likely to have
  324. multiple instances in memory. Do not use @code{-N} on daemons, no
  325. matter how small they are.
  326. It is up to the package maintainer to decide what compilation options
  327. are best for the package. Certain binaries (such as
  328. computationally-intensive programs) may function better with certain
  329. flags (@code{-O3}, for example); feel free to use them. Please use good
  330. judgment here. Don't add flags for the sake of adding flags; only add
  331. flags if there is good reason to do so.
  332. @item
  333. Please make sure that you use only released versions of shared libraries
  334. to build your packages; otherwise other users will not be able to run
  335. your binaries properly. Producing source packages that depend on
  336. unreleased compilers is also usually a bad idea.
  337. @item
  338. Logfiles should usually be named @file{/var/log/<package>}, or
  339. @file{/var/log/<package>.<something>} if you have several logfiles. It
  340. may be appropriate to create a directory. Make sure that any logfiles
  341. are rotated occasionally so that they don't grow indefinitely; the best
  342. way to do this is to use @file{savelog} from the cron package in an
  343. @file{/etc/cron.daily}, @file{/etc/cron.weekly} or
  344. @file{/etc/cron.monthly} script.
  345. @item
  346. Please check with the base system maintainer (Ian Murdock) before using
  347. users or groups other than @code{root} and others specified in this
  348. document.
  349. @end itemize
  350. @node Source Package, Binary Package, Package Content, Top
  351. @unnumbered Source Package
  352. The source package should contain a file called @file{debian.rules}
  353. which contains at least the following targets, to be invoked in the top
  354. level directory:
  355. @smallexample
  356. build
  357. binary
  358. clean
  359. @end smallexample
  360. @file{debian.rules} should start with
  361. @smallexample
  362. #!/usr/bin/make -f
  363. @end smallexample
  364. @noindent and be executable. It is a good idea to arrange for it not
  365. to fail obscurely when invoked in the wrong directory, for example by
  366. testing for the existence of a file in the source directory.
  367. @itemize @bullet
  368. @item
  369. The @file{build} target should perform all non-interactive configuration
  370. and compilation of the package. If a package has an interactive
  371. pre-build configuration routine, the source package should be built
  372. @emph{after} this has taken place.
  373. For some packages, notably ones where the same source tree is
  374. compiled in different ways to produce two binary packages, the
  375. @file{build} target does not make much sense. For these packages it is
  376. good enough to provide two (or more) targets (@file{build-a} and
  377. @file{build-b} or whatever) for each of the ways of building the
  378. package, and a @file{build} target that does nothing. The @file{binary}
  379. target will have to build the package in each of the possible ways and
  380. make the binary package out of each.
  381. @item
  382. The @file{binary} target of @file{debian.rules} should be all that is
  383. necessary for the user to build the binary package. The binary package
  384. should be created using @file{dpkg} and placed in the parent of the top
  385. level directory. The next section describes how to construct binary
  386. packages from the @file{binary} target.
  387. @item
  388. The @file{clean} target should undo the effects of the @file{build}
  389. target and the @file{binary} target, except that it should leave alone
  390. any @file{../<@i{package}>-<@i{version}>.deb} file created by a run of
  391. @file{binary}.
  392. @item
  393. Additional targets may exist in @file{debian.rules}. We recommend using
  394. @file{source} and @file{diff} targets to build the Debianised source
  395. package and the Debianisation context diff, respectively. These files
  396. should be placed in @file{../foo-<@i{version}>.tar.gz} and
  397. @file{../foo-<@i{version}>.diff.gz}. The @file{install} target, for
  398. installing into a running system direct from the Debianised source
  399. tree, is no longer required. The sample @file{debian.rules} provides
  400. @file{source} and @file{diff} targets that should work with little or
  401. no alteration, providing that the package-specific variables at the top
  402. of the script have been properly defined.
  403. @item
  404. If you need to edit a @file{Makefile} where @file{configure} scripts
  405. are used, you should edit the @file{.in} files rather than editing
  406. the @file{Makefile} directly. This allows the user to reconfigure
  407. the package if necessary. You should @emph{not} configure the package
  408. and edit the generated @file{Makefile}! This makes it impossible for
  409. someone else to later reconfigure the package.
  410. @item
  411. Please document your changes to the source package so that future
  412. package maintainers know what has been changed. To do this, include
  413. a description of your changes in the @file{debian.README} (which, as
  414. described above, should already contain authorship and copyright
  415. information!) and include relevant information such as your name,
  416. electronic mail address, date, etc. The @file{debian.README} file
  417. should also document any `unusual' packages which must be installed for
  418. this one to compile.
  419. @item
  420. If changes to the source code are made that are applicable to Linux
  421. systems or systems in general please try to get them included in the
  422. upstream version of the package by supplying the upstream authors with
  423. the changes in whatever form they prefer.
  424. If changes to the source code are made, please use a @file{define}. If
  425. they are changes required to compile or function under Linux in general,
  426. use @file{LINUX}. If it is a cosmetic or functional change, use
  427. @file{DEBIAN}.
  428. @item
  429. Create the source package using @file{tar}, and use @file{gzip -9} to
  430. compress it. Source packages should be named in the form
  431. <@i{package}>-<@i{version}>.tar.gz---for example,
  432. @file{fileutils-3.9-3.tar.gz}.
  433. NB, here @code{<@i{version}>} is the full Debian version number, in the
  434. form @code{<@i{original_version}>-<@i{debian_revision}>} (see below),
  435. but the tarfile should unpack into a directory named
  436. @code{<@i{package}>-<@i{original_version}>} (again, see the section
  437. below on version numbering).
  438. @item
  439. Create the unified context diff against the original package using
  440. @file{diff -uNr}, and use @file{gzip -9} to compress it. Diffs should
  441. be named in the form <@i{package}>-<@i{version}>.diff.gz---for example,
  442. @file{fileutils-3.9-3.diff.gz}.
  443. @end itemize
  444. Please note that the package and patch filenames do @emph{not} need
  445. to fit in MS-DOS 8+3. They will be made available under an alternative
  446. 8+3 name in the archive by the archive maintainer, using a symlink.
  447. @node Binary Package, Control Files, Source Package, Top
  448. @unnumbered Binary Package
  449. The @file{binary} target of the source package @file{debian.rules}
  450. file should do the following (see the sample @file{debian.rules}
  451. for an implementation that you are free to modify and use in your own
  452. packages, of course):
  453. @itemize @bullet
  454. @item
  455. Create an empty directory in the top-level directory of the source
  456. package (deleting it first, if necessary), and install the files
  457. belonging to this package in that directory. For example, the directory
  458. could be called @file{debian-tmp} and would probably contain directories
  459. @file{debian-tmp/usr/bin}, @file{debian-tmp/usr/lib}, etc.
  460. (@file{debian-tmp} is the name traditionally used, and it is used in
  461. the sample @file{debian.rules} file, so we will use that name in the
  462. Guidelines.)
  463. @item
  464. Make sure that all the files under @file{debian-tmp} have the correct
  465. ownerships and permissions (@pxref{Package Content}, for more information
  466. about file locations, ownerships, and permissions.)
  467. @item
  468. Create a subdirectory of @file{debian-tmp} called @file{DEBIAN}. This
  469. directory contains the package control information, including at the
  470. very least the master information file named @file{control}. The next
  471. section describes the semantics and syntax of the files required and
  472. allowed here.
  473. @item
  474. Run @file{dpkg} to create the binary package, using something like
  475. @smallexample
  476. dpkg --build debian-tmp
  477. @end smallexample
  478. This will create a file called @file{debian-tmp.deb}, from the
  479. @file{debian-tmp} directory. You should rename this file to
  480. @file{../<@i{package}>-<@i{version}>.deb} after it is built.
  481. After the @file{binary} target has done all this, the
  482. @file{<@i{package}>-<@i{version}>.deb} file in the parent directory is
  483. the binary distribution. This file may be distributed and installed on
  484. any Debian Linux system with @file{dpkg} in the same manner and
  485. using the same methods as all packages are installed to the system.
  486. @item
  487. If a single source package corresponds to several binary packages, there
  488. should usually be a @file{debian.rules} file with a single @file{binary}
  489. target that builds all the binary packages involved and move all packages
  490. to the parent directory of that containing the source package.
  491. In this case, you should choose binary package names which are meant to
  492. make clear the close relationship between the binary packages and which
  493. source package the binary packages came from (for example, the
  494. @file{texinfo} source package build two binary packages: @file{texidoc}
  495. and @file{texinfo}). You should place the appropriate binary package
  496. name in the @file{Package} field of the control file (not the source
  497. package name), and you should consider whether the other binary packages
  498. that come from the same source tree should be mentioned in the
  499. @file{Depends}, @file{Recommends} or @file{Suggests} fields. You
  500. should put the source package name in the @file{Source} field.
  501. You should retain the source package version numbering in the
  502. @file{Version} field, if possible---the version number should be the
  503. same for the Debianised source tree and all the binary packages
  504. generated from it. It is more important, though, that the version
  505. numbers sort correctly. See below for details of version numbers.
  506. @end itemize
  507. @node Control Files, Appendix, Binary Package, Top
  508. @unnumbered Control Files
  509. Each binary package contains, in addition to the files that comprise
  510. the actual package, a set of text files that control how @file{dpkg}
  511. installs, configures, upgrades, removes, etc. the package. These files
  512. are called @dfn{control files}. When creating the package, the control
  513. files should placed in a directory called @file{DEBIAN}, as described
  514. earlier (@pxref{Binary Package}, for further information).
  515. The control information files are:
  516. @table @code
  517. @item control
  518. The master package control information file.
  519. @item conffiles
  520. A list of package configuration files.
  521. @item preinst
  522. The package pre-installation script.
  523. @item postinst
  524. The package post-installation script.
  525. @item prerm
  526. The package pre-removal script.
  527. @item postrm
  528. The package post-removal script.
  529. @end table
  530. Of these, only @file{control} is required. The various installation
  531. scripts, and the configuration files list, will only be used if they are
  532. present.
  533. @menu
  534. * control::
  535. * conffiles::
  536. * Installation and Removal Scripts::
  537. * Dependencies and Conflicts::
  538. * Package Classification Fields::
  539. @end menu
  540. @node control, conffiles, Control Files, Control Files
  541. @unnumberedsec control
  542. The @file{control} file contains a number of fields. Each field
  543. begins with a field name, such as @file{Package} or @file{Version}
  544. (case insensitive), followed by a colon and optionally some spaces or
  545. tabs (a single space is conventional). Then comes the body of the
  546. field, which may be several lines long; each continuation line must
  547. start with at least one space or tab. (These are the same rules as
  548. apply to RFC822 mail headers.) Blank lines are not permitted in the
  549. control file.
  550. The required fields in the control file are the following:
  551. @table @code
  552. @item Package
  553. The name of the package.
  554. @item Description
  555. The description of the package. How to write an extended and more
  556. usefull description field can be found in @pxref{How to write the Description control file field}.
  557. @item Maintainer
  558. The name and e-mail address of the maintainer of the package.
  559. @item Version
  560. The version number in the format
  561. @code{<@i{original_version}>-<@i{debian_revision}>}.
  562. @end table
  563. Each field has a particular format and meaning for the package
  564. installation tools.
  565. The value of @file{Package} should be the name of the package. Package
  566. names must start with an alphanumeric, must be at least two characters,
  567. and may contain only alphanumerics and the characters - + . (that is,
  568. hyphen, plus, stop) @footnote{The characters @@ : = % _ (at, colon,
  569. equals, percent and underscore) used to be legal and are still accepted
  570. when found in a package file, but may not be used in new packages}.
  571. They are sort of case sensitive - please try to get the case right first
  572. time.
  573. The @code{Maintainer} field should be in the form
  574. @smallexample
  575. Joe J. Bloggs <jbloggs@@foo.com>
  576. @end smallexample
  577. @noindent Note that this will not be useable as an email address if
  578. the name given contains full stop characters, because of a silly
  579. restriction in the Internet mail standards. If you want to use this
  580. as an email address in a program you should check for full stops and
  581. change the string to the form @code{jbloggs@@foo.com (Joe J. Bloggs)}
  582. if you find any.
  583. The @code{Version} field should be the version number of the
  584. package. For most packages which are not written specifically for
  585. Debian, this should be in the form
  586. @smallexample
  587. Version: <@i{original_version}>-<@i{debian_revision}>
  588. @end smallexample
  589. @noindent where @file{<@i{original_version}>} is the original package
  590. version number in whatever form the original package uses and
  591. @file{<@i{debian_revision}>} indicates which ``debianisation'' this is
  592. (this should usually be a plain number or perhaps a two numbers
  593. separated by a full stop, and should be incremented each time the
  594. package is changed or updated).
  595. Packages which are written specifically for Debian do not have a
  596. @i{debian_revision}, and their version number should simply be
  597. @i{version} (which should not contain any hyphens, to avoid
  598. confusion).
  599. There is an ordering imposed on version numbers, described in
  600. @file{version-ordering.txt}. This ordering is designed to `do the right
  601. thing' in most circumstances; if your package has an version number in
  602. an unusual format you may need to reformat it somewhat to get the
  603. ordering right. This is important because @file{dpkg} is (for example)
  604. reluctant to downgrade packages.
  605. The optional fields in the control file are the following:
  606. @table @code
  607. @item Depends
  608. The names of prerequisite packages.
  609. @item Recommends
  610. The names of related, recommended packages.
  611. @item Suggests
  612. The names of related, optional packages.
  613. @item Conflicts
  614. The names of packages which conflict with this package.
  615. @item Provides
  616. The names of virtual packages which this package provides.
  617. @item Priority
  618. The `priority' of the package, as shown and used by @file{dselect}.
  619. @item Section
  620. The `section' of the package, as shown and used by @file{dselect}, and
  621. used as a location for the package in the distribution.
  622. @item Essential
  623. A boolean field used by the base packages.
  624. @item Pre-Depends
  625. Used by base packages to ensure that (for example) shared libraries are
  626. present before they are upgraded. This feature is for expert use only.
  627. @item Source
  628. Gives the name of the source package when several binary packages are
  629. generated from a single source tree.
  630. @end table
  631. @noindent See below for details of the semantics and syntax of these
  632. fields. Most packages will need at least a @code{Depends} field.
  633. An example of a @file{control} file would be:
  634. @smallexample
  635. Package: smail
  636. Version: 3.1.29.1-13
  637. Maintainer: Ian Jackson <iwj10@@cus.cam.ac.uk>
  638. Recommends: pine | mailx | elm | emacs | mail-user-agent
  639. Suggests: metamail
  640. Depends: cron, libc5
  641. Conflicts: sendmail
  642. Provides: mail-transport-agent
  643. Description: Electronic mail transport system.
  644. Smail is the recommended mail transport agent (MTA) for Debian.
  645. .
  646. An MTA is the innards of the mail system - it takes messages from
  647. user-friendly mailer programs and arranges for them to be delivered
  648. locally or passed on to other systems as required.
  649. .
  650. In order to make use of it you must have one or more user level
  651. mailreader programs such as elm, pine, mailx or Emacs (which has Rmail
  652. and VM as mailreaders) installed. If you wish to send messages other
  653. than just to other users of your system you must also have appropriate
  654. networking support, in the form of IP or UUCP.
  655. @end smallexample
  656. In this case, @file{mail-user-agent} is a virtual package
  657. representing any user mailer program; the actual package names
  658. @file{pine} is quoted for the reasons described in
  659. @file{dependency-ordering.txt}, and the others because older versions
  660. of those packages do not have the appropriate @file{Provides} field.
  661. @node conffiles, Installation and Removal Scripts, control, Control Files
  662. @unnumberedsec conffiles
  663. The contents of @file{conffiles} is simply a list of configuration
  664. files in the package. When installing the package, @file{dpkg} uses
  665. an intelligent method to update these files. This will ensure that
  666. package-specific configuration files are not overwritten when a package
  667. is upgraded, unless the user wishes the installation tools to do so.
  668. Typically, files listed in conffiles are package-specific
  669. configuration files, which (according to the Linux Filesystem Standard)
  670. are stored in @file{/etc}. For example, the @code{sendmail} package may
  671. contain the file @file{/etc/sendmail.cf}, which we do not wish to
  672. overwrite automatically when the user upgrades the sendmail package.
  673. Only those files listed in @file{DEBIAN/conffiles} will be updated
  674. intelligently when a package is upgraded; all other files in the package
  675. will be overwritten by the upgrade process.
  676. Configuration files which will be functional as shipped and will
  677. probably need little or no local editing should simply be listed the
  678. @file{conffiles} file; in this case you need read no further.
  679. For packages whose configuration files will need modification on
  680. most systems there are two sensible approaches. Which one is chosen
  681. depends on how hard the configuration problem is and how much time the
  682. package maintainer has available.
  683. One option is for you to ship a minimal `best-effort' file in
  684. @file{/etc}, and list the file in @file{conffiles}. This will mean that
  685. the user will have to go and edit the file themselves to get the package
  686. to work properly, of course. The next time they upgrade the package, if
  687. you haven't changed the file version, their old file will be left in
  688. place. If you have modified your version then the user will get a
  689. prompt asking them which version of the file they want, theirs or yours.
  690. They will then usually have to resolve the discrepancies manually.
  691. The other option is to be preferred, if you can do it: do not put a
  692. copy of the configuration file in the package at all. Instead, you
  693. check in the postinst whether the file exists, and if it doesn't you
  694. prompt the user for the information you need to create a good one. This
  695. is obviously harder work.
  696. You also have to remember that you will have to keep up with your
  697. package's changes: if you discover a bug in the program which generates
  698. the configuration file, or if the format of the file changes from one
  699. version to the next, you will have to arrange for the postinst script to
  700. do something sensible---usually this will mean editing the installed
  701. configuration file to remove the problem or change the syntax. You will
  702. have to do this very carefully, since the user may have changed the
  703. file, perhaps to fix the very problem that your script is trying to deal
  704. with---you will have to detect these situations and deal with them
  705. correctly.
  706. If you do go down this route it's probably a good idea to make the
  707. program that generates the configuration file(s) a separate program in
  708. @file{/usr/sbin}, by convention called @i{package}@code{config}, and
  709. then run that if appropriate from the post-installation script. The
  710. @i{package}@code{config} program should not unquestioningly overwrite an
  711. existing configuration---if its mode of operation is geared towards
  712. setting up a package for the first time (rather than any arbitrary
  713. reconfiguration later) you should have it check whether the
  714. configuration already exists, and require a @code{--force} flag to
  715. overwrite it.
  716. @file{conffiles} should almost certainly list all the files contained
  717. in your package in the @file{/etc} directory. There may also be other
  718. files somewhere that the user is expected to edit, which should also be
  719. included. Note, however, that the FSSTND specifies that configuration
  720. files must be in @file{/etc}. No Debian package should contain
  721. configuration files in @file{/usr/etc}, and all programs should refer to
  722. configuration files in @file{/etc}.
  723. @noindent For example, the TCP/IP package might use a conffiles which contains
  724. @smallexample
  725. /etc/init.d/netbase
  726. /etc/gateways
  727. /etc/protocols
  728. /etc/services
  729. /etc/hosts.allow
  730. /etc/hosts.deny
  731. /etc/rpc
  732. @end smallexample
  733. @noindent and so on; the files
  734. @smallexample
  735. /etc/hosts
  736. /etc/inetd.conf
  737. /etc/host.conf
  738. /etc/networks
  739. /etc/resolv.conf
  740. @end smallexample
  741. @noindent might be generated by an interactive configuration program,
  742. and would then not be included in the package or listed in the
  743. @file{conffiles}.
  744. @node Installation and Removal Scripts, Dependencies and Conflicts, conffiles, Control Files
  745. @unnumberedsec Installation and Removal Scripts
  746. The scripts @file{preinst}, @file{postinst}, @file{prerm}, and
  747. @file{postrm} are optional (Bash or Perl) scripts. As the names
  748. would indicate, if these scripts exist, they will be executed before
  749. installing the package, after installation, before package removal,
  750. and after removal, respectively.
  751. They are given arguments which indicate the precise situation and
  752. action being performed---see
  753. @pxref{Maintainer script arguments and how dpkg does things} for
  754. details of exactly when each of the scripts is invoked and what its
  755. arguments are. Extra arguments and situations may be added later, so
  756. you should not test the number of arguments to your script to determine
  757. the situation, and you should choose the sense of your `if it is this
  758. then do this otherwise do that' tests carefully.
  759. These scripts can be used to perform any site-specific package
  760. configuration.
  761. Because the scripts will be exectued by the dpkg front-end, it is
  762. guaranteed that the scripts will be executed interactively. User input
  763. from the scripts should be read from standard input, not the user's
  764. terminal. Similarly, output should be sent to standard output.
  765. If your maintainer scripts need to prompt for passwords and/or do
  766. @i{full-screen} interaction should do these things to and from
  767. @file{/dev/tty}, since @file{dpkg} will at some point redirect scripts'
  768. standard input and output so that it can log the installation process.
  769. Likewise, because these scripts may be executed with standard output
  770. redirected into a pipe for logging purposes, Perl scripts should set
  771. unbuffered output by setting @code{$|=1} so that the output is printed
  772. immediately rather than being buffered.
  773. The scripts must be idempotent, and they must clean up after
  774. themselves properly. Ie, they must do the right thing if run multiple
  775. times, even if previous runs failed halfway through. This is so that if
  776. any errors occur, or if the @file{dpkg} run is interrupted, the user can
  777. recover by rerunning @file{dpkg}, and/or by upgrading to a new version
  778. and then rerunning the failed operation.
  779. These scripts should avoid producing output which it is unnecessary
  780. for the user to see and should rely on @file{dpkg} to stave off boredom
  781. on the part of a user installing many packages. This means, amongst
  782. other things, using the @file{--quiet} option on @file{install-info}.
  783. Packages should try to minimise the amount of prompting they need to
  784. do, and they should ensure that the user will only every be asked each
  785. question once. This means that packages should try to use appropriate
  786. shared configuration files (such as @file{/etc/papersize} and
  787. @file{/etc/news/server}), rather than each prompting for their own list
  788. of required pieces of information.
  789. It also means that an upgrade should not ask the same questions
  790. again, unless the user has used @code{dpkg --purge} to remove the
  791. package's configuration. The answers to configuration questions should
  792. be stored in an appropriate place in @file{/etc} so that the user can
  793. modify them, and how this has been done should be documented.
  794. If a package has a vitally important piece of information to pass to
  795. the user (such as "don't run me as I am, you must edit the following
  796. configuration files first or you risk your system emitting
  797. badly-formatted messages"), it should display this in the
  798. @file{postinst} script and prompt the user to hit Return to acknowledge
  799. the message. Copyright messages do not count as vitally important (they
  800. belong in @file{/usr/doc/copyright}; neither do instructions on how to
  801. use a program (these should be in on line documentation, where all the
  802. users can see them).
  803. They should return a zero exit status for success, or a nonzero one
  804. for failure. Note that if a script is a @code{#!/bin/sh} script it
  805. should probably start with @code{set -e}, to avoid continuing after
  806. errors---see @file{bash}(1) for details. Perl scripts should check for
  807. errors when making calls such as @code{open}, @code{print},
  808. @code{close}, @code{rename} and @code{system}.
  809. If these scripts exist they should be left in the @file{DEBIAN}
  810. directory with execute permission enabled and should contain an
  811. appropriate @code{#!} line, such as @code{#!/bin/bash} for a
  812. @code{bash} script or @code{#!/bin/perl} for a Perl script (see
  813. above).
  814. @node Dependencies and Conflicts, Package Classification Fields, Installation and Removal Scripts, Control Files
  815. @unnumberedsec Conflicts, Depends, Suggests, Recommends and Provides
  816. The @file{Depends} field lists packages that are required for this
  817. package to provide a significant amount of functionality. The package
  818. maintenance software will not allow a package to be installed without
  819. also installing packages listed in its @code{Depends} field, and will
  820. run the @code{postinst} scripts of packages listed in @code{Depends}
  821. fields before those of the packages which depend on them, and run the
  822. @code{prerm} scripts before.
  823. Packages containing dynamically-linked executable binaries (this
  824. includes almost all C programs) should include a @file{Depends} field
  825. which mentions the shared C library required for the program to run.
  826. For a.out binaries linked against @file{libc.so.4} the relevant package
  827. name is @file{libc} (for the a.out stable 0.93 tree) or @file{libc4}
  828. (for the unstable development 1.1 tree); for ELF binaries linked against
  829. @file{libc.so.5} the relevant package name is @file{libc5}.
  830. The @code{Recommends} field lists packages that would be found
  831. together with this one in all but unusual installations. The user-level
  832. package maintenance program @file{dselect} will warn the user if they
  833. select a package without those listed in its @code{Recommends} field.
  834. Note that @code{Recommends} fields do not currently have any implications
  835. for the order in which the maintainer scripts are run.
  836. The @code{Suggests} field lists packages that are related to this one
  837. and can perhaps enhance its usefulness, but without which installing
  838. this package is perfectly reasonable. The package maintenance software
  839. will not moan at the user for not selecting @code{Suggests} related
  840. packages, but may use the information in the @code{Suggests} field to
  841. assist the user during package selection.
  842. The syntax of @code{Depends}, @code{Recommends} and @code{Suggests}
  843. is a list of groups of alternative packages. Each group is a list of
  844. packages separated by vertical bar (or `pipe') symbols, @code{|}. The
  845. groups are separated by commas. Each package is a package name
  846. optionally followed by a version number specification in parentheses. A
  847. version number may start with a @code{>=}, in which case that version or
  848. any later will match, or @code{<=} for that version or any earlier
  849. version. A version number starting with a @code{>>} or @code{<<} will
  850. respectively match any later or earlier version. If a version number or
  851. a version number starting with @code{=} is specified an exact match is
  852. required. Commas are to be read as `AND', and pipes as `OR', with pipes
  853. binding more tightly.
  854. Versions of dpkg before 1.0.9 used @code{<} and @code{>} for
  855. @code{<=} and @code{>=} (these are still supported for backward
  856. compatibility), and did not support @code{<<} and @code{>>}.
  857. The @code{Conflicts} field lists packages that conflict with this
  858. one, for example by containing files with the same names (an example
  859. would be Smail vs. Sendmail). The package maintenance software will not
  860. allow conflicting packages to be installed. Two conflicting packages
  861. should each include a @code{Conflicts} line mentioning the other.
  862. The syntax of @code{Conflicts} is a list of package names (with
  863. optional version numbers), separated by commas (and optional
  864. whitespace). In the @code{Conflicts} field the comma should be read as
  865. `OR'.
  866. The @code{Provides} field lists the names of any `virtual packages'
  867. of which this packages is to be considered an instantiation. Virtual
  868. packages are used to allow packages to refer to a service they require
  869. (such as the availability of @file{/usr/sbin/sendmail}) without having
  870. to know the names of all the relevant packages. The virtual package
  871. names defined in @code{Provides} fields may be used in other packages'
  872. @code{Depends}, @code{Recommends}, @code{Suggests} and @code{Conflicts}
  873. fields. For more information about how to use virtual packages and
  874. which virtual package names to use read @pxref{Virtual dependencies} and
  875. @file{doc/package-developer/virtual-package-names-list.text}.
  876. The syntax of @code{Provides} is a list of package names separated by
  877. commas (and optional whitespace).
  878. @node Package Classification Fields, , Dependencies and Conflicts, Control Files
  879. @unnumberedsec Priority, Section and Essential
  880. The @code{Priority} and @code{Section} fields are used by
  881. @file{dselect} when displaying the list of packages to the user. There
  882. is no need to put them into a package, since these are usually set by
  883. the distribution maintainers in the @file{Packages} file.
  884. However, if a user installs a package which is not part of the
  885. standard distribution, or without downloading and updating from a new
  886. @file{Packages} file, the information about the priority and section of
  887. a package will be absent, and the @file{dselect} package listing will
  888. have the package listed under `unclassified'. It is permissible for a
  889. package to include @code{Section} or @code{Priority} fields to improve
  890. this; however, if you do this you should make sure you keep the
  891. information up to date so that users are not shown conflicting
  892. information. The @code{Section} field can also be used by the
  893. distribution maintainers as a suggestion about which section you think
  894. is most appropriate for your package.
  895. The values for the @code{Section} and @code{Priority} fields should be
  896. determined by the distribution maintainers; if you don't know what to
  897. put in them just leave them out. You can add them later, if you like,
  898. but remember that you'll then have to reissue your package if the
  899. distribution maintainers change the classification of your package.
  900. The @code{Essential} field should only appear in packages in the
  901. installation's base system. If it is set to @code{yes} then @file{dpkg}
  902. will not remove the package even if asked to, and will make certain
  903. minor modifications to its installation procedures. The only other
  904. legal value is @code{no}, which is equivalent to the absence of the
  905. field.
  906. @appendix
  907. @node Appendix, , Control Files, Top
  908. @unnumbered Appendix
  909. @comment node-name, next, previous, up
  910. @menu
  911. * configuration files -- /etc/skel vs /usr/doc/examples::
  912. * How to write the Description control file field::
  913. * Configuration of init::
  914. * Maintainer script arguments and how dpkg does things::
  915. * Mail processing packages::
  916. * Virtual dependencies::
  917. @end menu
  918. @node configuration files -- /etc/skel vs /usr/doc/examples, How to write the Description control file field, Appendix, Appendix
  919. @comment node-name, next, previous, up
  920. @unnumberedsec configuration files -- /etc/skel vs /usr/doc/examples
  921. There seems to be a certain amount of confusion about @file{/etc/skel}
  922. and @file{/usr/doc/examples}. The most important thing to remember is
  923. the following:
  924. Files in @file{/etc/skel} will @emph{automatically} be copied into
  925. @emph{new} user accounts by @file{adduser}. They should not
  926. be referenced there by any program. Files in @file{/usr/doc/examples}
  927. should not be installed automatically.
  928. Therefore, if the program in question need a dotfile to exist in advance
  929. in @file{$HOME} to work @emph{sensibly} that dotfile should be installed
  930. in @file{/etc/skel} (and listed in conffiles; @pxref{conffiles}).
  931. However, programs that require dotfiles in order to operate sensibly
  932. (dotfiles that they do not create themselves automatically, that is) are
  933. a bad thing, and that programs should be configured by the Debian
  934. default installation as close to normal as possible.
  935. Therefore, if a program in a Debian package needs to be configured in
  936. some way in order to operate sensibly that configuration should be done
  937. in a site-wide global configuration file elsewhere in @file{/etc} (and
  938. that file should be listed in conffiles). Only if the program doesn't
  939. support a site-wide default configuration should a default per-user file
  940. be placed in @file{/etc/skel} (and listed in conffiles;
  941. @pxref{conffiles}).
  942. The idea is as follows:
  943. The sysadmin should ideally not have to do any configuration other than
  944. that done @w{(semi-)}automatically by the postinst script.
  945. However, if they wish to change their configuration themselves
  946. (because the configuration they want is beyond the scope of the
  947. autoconfiguration, or because the autoconfiguration doesn't exist yet,
  948. or because they just want to do it themselves for any reason) then
  949. @file{/usr/doc/examples} exists as @emph{documentation} for their benefit.
  950. The only time these files should be read are by the sysadmin using their
  951. favourite editor or pager, or @emph{perhaps} (in very complex packages)
  952. by the postinst as a template to build on or modify.
  953. @file{/etc/skel} is part of the @emph{implementation} of this
  954. configuration. It contains the files that are copied into new user
  955. accounts. It should probably be as empty as we can make it.
  956. Examples:
  957. @table @code
  958. @item .profile
  959. @file{/etc/skel} should not contain a @file{.profile} file. Anything
  960. that needs to be done there should be done in @file{/etc/profile}.
  961. Anything that should not go in @file{/etc/profile} (users can't avoid
  962. running @file{/etc/profile}) probably should not be in the default
  963. configuration. bash has generally good default behaviour.
  964. @item .bash_logout
  965. Likewise, bash functions perfectly happily without a
  966. @file{.bash_logout}, so none should be provided, since anything in it is
  967. a deviation from the sensible default behaviour.
  968. @item .xsession
  969. @file{/etc/skel} should not contain a @file{.xsession}. @file{xdm}'s
  970. system-wide startup file @file{/usr/lib/X11/xdm/Xsession} supports a
  971. system-wide default user configuration (which should probably be
  972. @file{/etc/X11/Xsession} or some such) which may be overridden by
  973. @file{.xsession} in the user's home directory. Therefore there is no
  974. need for a @file{.xsession} to be installed by default and none should
  975. be provided.
  976. Instead, a sensible @file{/etc/X11/Xsession} should be provided, and if
  977. desired this can be used as a template by users who wish to install
  978. their own configuration, or alternatively a more comprehensive example
  979. with much commented-out interesting stuff could be put in
  980. @file{/usr/doc/examples}.
  981. If the sysadmin wishes to change the system-wide default they should
  982. probably do this by editing @file{/etc/X11/Xsession} rather than
  983. creating the file in @file{/etc/skel}, because the former will affect
  984. all user accounts that haven't explicitly overridden things by creating
  985. their own file while the latter will only affect new accounts.
  986. All the configuration necessary for a program to function should be
  987. provided. Therefore sysadmins will not need to go through
  988. @file{/usr/doc/examples} while editing configuration files in
  989. @file{/etc} except in extreme cases (like INN) where the configuration
  990. was too difficult to do automatically.
  991. @item site-wide defaults
  992. Site-wide defaults should not go in @file{/etc/skel}. In the case of
  993. twm, for example, the system-wide default should be in
  994. @file{/etc/X11/system.twmrc}. (The default location for this in X11R5,
  995. btw, is in @file{/usr/lib/X11} somewhere, but we can't put it on
  996. @file{/usr} because of CDROM distributions, etc - hence the FSSTND's
  997. mandate to put configuration files in @file{/etc}.)
  998. @item .twmrc
  999. There should be no @file{.twmrc} file in @file{/etc/skel}. You can have
  1000. one in @file{/usr/doc/examples} if you @emph{like}, but why bother if
  1001. @file{system.twmrc} is a good example (and indeed is the one the user is
  1002. using before they create their own)?
  1003. @item m4
  1004. @file{/usr/doc/examples} isn't mainly for example @emph{configuration
  1005. files}. It's for any kind of example file distributed with a package.
  1006. For example, GNU m4 comes with a whole pile of example m4 macro scripts,
  1007. which is exactly what @file{/usr/doc/examples} is for.
  1008. @end table
  1009. Summary
  1010. Files that should be installed in new user accounts should be in
  1011. @file{/etc/skel}, as that will ensure that they @emph{are} installed in
  1012. new user accounts! However, we should try to avoid the need for this.
  1013. @file{/usr/doc/examples} is just what it says: documentation in the form
  1014. of examples. If a sysadmin is required to go and read these files for
  1015. their system to work they should be told about it. For example, here
  1016. is what the Smail postinst script says right at the start:
  1017. @smallexample
  1018. I can do certain kinds of automatic configuration of your
  1019. mail system, by asking you a number of questions. Later you
  1020. may to confirm and/or correct your answers. In any case,
  1021. comprehensive information on configuring Smail is in
  1022. smail(5) and in /usr/doc/examples/smail and
  1023. /usr/doc/smail-admin-guide.
  1024. @end smallexample
  1025. @node How to write the Description control file field, Configuration of init, configuration files -- /etc/skel vs /usr/doc/examples, Appendix
  1026. @unnumberedsec How to write the Description control file field
  1027. The format of the @code{Description} field is as follows:
  1028. @smallexample
  1029. Description: <single line synopsis>
  1030. <extended description over several lines>
  1031. @end smallexample
  1032. The extended description has several kinds of line:
  1033. @itemize @bullet
  1034. @item
  1035. Those starting with a single space are part of a paragraph. Successive
  1036. lines of this form will be word-wrapped when displayed. The leading
  1037. space will usually be stripped off.
  1038. @item
  1039. Those starting with two or more spaces. These will be displayed
  1040. verbatim. If the display cannot be panned horizontally the displaying
  1041. program will linewrap them `hard' (ie, without taking account of word
  1042. breaks). If it can they will be allowed to trail off to the right.
  1043. None, one or two initial spaces may be deleted, but the number of spaces
  1044. deleted from each line will be the same (so that you can have indenting
  1045. work correctly, for example).
  1046. @item
  1047. Those containing a single space followed by a single full stop
  1048. character. These are rendered as blank lines. This is the @emph{only}
  1049. way to get a blank line - see below.
  1050. @item
  1051. Those containing a space, a full stop and some more characters. These
  1052. are for future expansion. @emph{Do not} use them.
  1053. @end itemize
  1054. IMPORTANT and not so important TIPS:
  1055. @itemize @bullet
  1056. @item
  1057. @emph{Always} start extended description lines with at least @emph{one}
  1058. whitespace character. Fields in the control file and in the Packages
  1059. file are separated by field names starting in the first column, just as
  1060. in RFC822. Forgetting the whitespace will cause @file{dpkg-deb}
  1061. (>=0.93.23) to produce a syntax error when trying to build the package.
  1062. If you force it to build anyway @file{dpkg} will refuse to install the
  1063. resulting mess.
  1064. @item
  1065. @emph{Do not} include any completely @emph{empty} lines. These separate
  1066. different records in the Packages file, and are forbidden in control
  1067. files. See the previous paragraph for what happens if you get this
  1068. wrong.
  1069. @item
  1070. The single line synopsis should be kept brief - certainly under 80
  1071. characters. @file{dselect} displays the @emph{first 49} characters if
  1072. you're using an 80-column terminal.
  1073. @item
  1074. Do not include the package name in the synopsis line. The display
  1075. software knows how to display this already, and you do not need to
  1076. state it. Remember that in many situations the user may only see the
  1077. synopsis line - make it as informative as you can.
  1078. @item
  1079. The extended description should describe what the package does and how
  1080. it relates to the rest of the system (in terms of, for example, which
  1081. subsystem it is which part of).
  1082. @item
  1083. Put important information first, both in the synopis and extended
  1084. description. Sometimes only the first part of the synopsis or of the
  1085. description will be displayed. You can assume that there will usually
  1086. be a way to see the whole extended description.
  1087. @item
  1088. You may include information about dependencies and so forth in the
  1089. extended description, if you wish.
  1090. @item
  1091. Do not use tab characters. Their effect is not predictable.
  1092. @end itemize
  1093. Example control file for Smail:
  1094. @smallexample
  1095. Package: smail
  1096. Version: 3.1.29.1-13
  1097. Maintainer: Ian Jackson <iwj10@@cus.cam.ac.uk>
  1098. Recommends: pine | mailx | elm | emacs | mail-user-agent
  1099. Suggests: metamail
  1100. Depends: cron, libc5
  1101. Conflicts: sendmail
  1102. Provides: mail-transport-agent
  1103. Description: Electronic mail transport system.
  1104. Smail is the recommended mail transport agent (MTA) for Debian.
  1105. .
  1106. An MTA is the innards of the mail system - it takes messages from
  1107. user-friendly mailer programs and arranges for them to be delivered
  1108. locally or passed on to other systems as required.
  1109. .
  1110. In order to make use of it you must have one or more user level
  1111. mailreader programs such as elm, pine, mailx or Emacs (which has Rmail
  1112. and VM as mailreaders) installed. If you wish to send messages other
  1113. than just to other users of your system you must also have appropriate
  1114. networking support, in the form of IP or UUCP.
  1115. @end smallexample
  1116. @node Configuration of init, Maintainer script arguments and how dpkg does things, How to write the Description control file field, Appendix
  1117. @unnumberedsec Configuration of init
  1118. The @file{/etc/init.d} directory contains the scripts executed by
  1119. init(8) when init state (or "runlevel") is changed. This includes the
  1120. boot process, when the multi-user state begins. Several of these
  1121. scripts are included with init and are intended to be executed
  1122. @emph{once}, usually at boot time. An example is
  1123. @file{/etc/init.d/boot}, which is executed at boot time to check and
  1124. mount file systems, activate swap, load kernel modules, etc.--everything
  1125. that needs to be done before the multi-user state begins.
  1126. @file{/etc/init.d} also contains the scripts that are executed when
  1127. entering runlevel 0 (halt), runlevel 1 (single-user) and runlevel 6
  1128. (reboot).
  1129. Packages can (and should) place scripts in @file{/etc/init.d} to start
  1130. or stop services at boot time or during a change of runlevel. These
  1131. scripts should be named @file{/etc/init.d/}<package>, and they should
  1132. accept one of two arguments: "start", which starts the services, or
  1133. "stop", which stops the services. These scripts should ensure that they
  1134. will behave sensibly if invoked with "start" when the service is already
  1135. running, or with "stop" when it isn't---the best way to achieve this is
  1136. often to use @file{start-stop-daemon}.
  1137. This script should not fail obscurely when the configuration files
  1138. remain but the package has been removed, as the default in dpkg is to
  1139. leave configuration files on the system after the package has been
  1140. removed. Only when it is executed with the `--purge' option will dpkg
  1141. remove configuration files. Therefore, you should include a `test'
  1142. statement at the top of the script, like this:
  1143. @smallexample
  1144. test -f <program-executed-later-in-script> || exit 0
  1145. @end smallexample
  1146. These scripts should be referenced, when appropriate, by symbolic links
  1147. in the @file{/etc/rc?.d} directories, as below.
  1148. When changing runlevels, init looks in the directory @file{/etc/rc<n>.d}
  1149. for the scripts it should execute, where <n> is the runlevel that is
  1150. being changed to. Please note that the "scripts" in @file{/etc/rc?.d}
  1151. are not actually scripts; they are symbolic links, referencing actual
  1152. scripts in @file{/etc/init.d}. For simplicity, we refer to them as
  1153. "scripts".
  1154. First, the scripts prefixed with a "K" are executed, followed by the
  1155. scripts prefixed with an "S". The "K" scripts are responsible for
  1156. killing certain services and the "S" scripts for starting certain
  1157. services upon @emph{entering} the runlevel. For example, if we are
  1158. changing from runlevel 2 to runlevel 3, init will first execute all of
  1159. the "K" prefixed scripts it finds in @file{/etc/rc3.d} (to kill
  1160. services), and then all of the "S" prefixed scripts it finds in
  1161. @file{/etc/rc3.d} (to start services). The "K" scripts will execute the
  1162. file it references with an argument of "stop", and the "S" scripts will
  1163. execute this file with an argument of "start".
  1164. After the "K" or "S" prefix, there should be a number specified, and
  1165. this number should be between 00 and 99. The number determines the
  1166. order in which the scripts are run. For example, the "K20" scripts will
  1167. be executed before the "K30" scripts. You can use this number to make
  1168. sure that a certain service is started before another. For example, on
  1169. some machines, the program @file{setserial} may need to properly set an
  1170. IRQ before the @file{ppp} program uses a modem to connect to a network.
  1171. In this case, the script that runs @file{setserial} should have a lower
  1172. number than the script that starts @file{ppp} so that it runs first:
  1173. @smallexample
  1174. @file{/etc/rc2.d/S10setserial}
  1175. @file{/etc/rc2.d/S20ppp}
  1176. @end smallexample
  1177. If it does not matter when or in which order the script is run, use the
  1178. number "20". If it does, then you should talk to the maintainer of the
  1179. @code{sysvinit} package or post to @code{debian-devel}, and they will
  1180. help you choose a number.
  1181. In Debian Linux, we try to ship our software in as much of a
  1182. "default" state as possible. Therefore, unless there is a good reason
  1183. for doing differently, we ask that you start the services in each of the
  1184. multi-user state runlevels (2, 3, 4, and 5) and stop them in the halt
  1185. runlevel (0), the single-user runlevel (1) and the reboot runlevel (6).
  1186. The system administrator will have the opportunity to customize
  1187. runlevels by simply adding, moving, or removing the symbolic links in
  1188. @file{/etc/rc?.d}. This is why we default to running everything in the
  1189. multi-user state--a reasonable default--and the administrator can easily
  1190. customize init to be as complex and sophisticated as he or she wants it
  1191. to be beyond this.
  1192. We provide a script, @file{update-rc.d}, to make it easier for package
  1193. maintainers to arrange for the proper creation and removal of
  1194. @file{/etc/rc?.d} symbolic links from their postinst and postrm scripts.
  1195. You should use this script to make changes to @file{/etc/rc?.d} and
  1196. @emph{never} include any @file{/etc/rc.?.d} symbolic links in the actual
  1197. archive.
  1198. @itemize @bullet
  1199. @item
  1200. In the postinst script, you need only do the following to setup
  1201. @file{/etc/rc?.d}. You should redirect standard output to
  1202. @file{/dev/null}, as @file{update-rc.d} produces insignificant output:
  1203. @smallexample
  1204. update-rc.d <package> default >/dev/null
  1205. @end smallexample
  1206. where <package> is the name of the file as it appears in
  1207. @file{/etc/init.d}. It will use the default number of "20", as
  1208. mentioned above. If you need to use a different number, you can specify
  1209. it after "default":
  1210. @smallexample
  1211. update-rc.d <package> default 30 >/dev/null
  1212. @end smallexample
  1213. @item
  1214. In the postrm script, you need only do the following @emph{if and only
  1215. if} it is called with the `purge' argument:
  1216. @smallexample
  1217. if [ purge = "$1" ]
  1218. then
  1219. update-rc.d <package> remove >/dev/null
  1220. fi
  1221. @end smallexample
  1222. @end itemize
  1223. @unnumberedsubsec Important Note:
  1224. @emph{Do not} include the @file{/etc/rc?.d/*} symbolic links in the
  1225. archive! @emph{This will cause problems!} You should create them with
  1226. update-rc.d, as above.
  1227. @emph{Do not} include the @file{/etc/rc?.d/*} symbolic links in
  1228. conffiles! @emph{This will cause problems!} @emph{Do}, however,
  1229. include the @file{/etc/init.d} scripts in conffiles.
  1230. @unnumberedsubsec Example:
  1231. The process accounting package wants to make sure that process
  1232. accounting is started at boot time and that it is stopped before the
  1233. system is halted, enters the single-user state, or is rebooted (so
  1234. that the @file{/var} file system can be properly unmounted). It puts
  1235. a script that does this in @file{/etc/init.d}, naming the script
  1236. appropriately "acct". This script accepts one of two arguments:
  1237. either "start", which starts process accounting, or "stop", which
  1238. stops it. To ensure that it does not fail obscurely when the
  1239. configuration files remain but the package has been removed, we
  1240. include a `test' statement at the top of the script:
  1241. @smallexample
  1242. #! /bin/sh
  1243. #
  1244. # Start process accounting.
  1245. . /etc/init.d/functions
  1246. test -f /usr/sbin/accton || exit 0
  1247. case "$1" in
  1248. start)
  1249. echo "Starting process accounting"
  1250. /usr/sbin/accton /var/account/pacct
  1251. ;;
  1252. stop)
  1253. echo "Stopping process accounting"
  1254. /usr/sbin/accton
  1255. ;;
  1256. *)
  1257. echo "Usage: /etc/init.d/acct @{start|stop@}"
  1258. exit 1
  1259. esac
  1260. exit 0
  1261. @end smallexample
  1262. You may find a skeletal script from which to base your @file{/etc/init.d}
  1263. scripts in @file{/etc/init.d/skeleton}.
  1264. We want to stop then (re)start process accounting when entering a
  1265. multi-user state--runlevels 2, 3, 4, and 5--and we want to stop it when
  1266. leaving such a state--runlevels 0 (halt), 1 (single) and 6 (reboot).
  1267. These are good defaults, and we accomplish this by including the
  1268. following in the postinst:
  1269. @smallexample
  1270. update-rc.d acct default >/dev/null
  1271. @end smallexample
  1272. When the user removes the acct packages with the `--purge' option, we
  1273. want to make sure the @file{/etc/rc?.d} symbolic links are properly
  1274. removed, so we include the following in the postrm:
  1275. @smallexample
  1276. update-rc.d acct remove >/dev/null
  1277. @end smallexample
  1278. Otherwise, the @file{/etc/rc?.d} symbolic links will remain on the system
  1279. along with @file{/etc/init.d/acct} script.
  1280. @node Maintainer script arguments and how dpkg does things, Mail processing packages, Configuration of init, Appendix
  1281. @unnumberedsec Maintainer script arguments and how dpkg does things
  1282. This appendix describes exactly how maintainer scripts are called, with
  1283. what arguments, in what order, and what @file{dpkg} does in between.
  1284. In all cases version numbers are <version>-<revision>, if the package
  1285. has both, or just <version>. @code{upgrade} is used even when the new
  1286. version number looks lower than the old. If there is no appropriate
  1287. version then the argument may be the empty string (or, in versions of
  1288. dpkg before 1.2.1, @code{<unknown>}).
  1289. @unnumberedsubsec Summary
  1290. @smallexample
  1291. <new preinst> install
  1292. <new preinst> install <old-version>
  1293. <new preinst> upgrade <old-version>
  1294. <old preinst> abort-upgrade <new-version>
  1295. <postinst> configure <most-recently-configured-version>
  1296. <old postinst> abort-upgrade <new version>
  1297. <conflictor's postinst> abort-remove in-favour <package> <new version>
  1298. <deconfigured's postinst> abort-deconfigure \
  1299. in-favour <package-being-installed-but-failed> <version>
  1300. removing <conflicting-package> <version>
  1301. <prerm> remove
  1302. <old prerm> upgrade <new version>
  1303. <new prerm> failed-upgrade <old-vppersion>
  1304. <conflictor's prerm> remove in-favour <package> <new version>
  1305. <deconfigured's prerm> deconfigure \
  1306. in-favour <package-being-installed> <version> \
  1307. removing <conflicting-package> <version>
  1308. <postrm> remove
  1309. <postrm> purge
  1310. <old postrm> upgrade <new-version>
  1311. <new postrm> failed-upgrade <old-version>
  1312. <new postrm> abort-install
  1313. <new postrm> abort-install <old-version>
  1314. <new postrm> abort-upgrade <old-version>
  1315. <disappearer's postrm> disappear <overwriter> <new version>
  1316. @end smallexample
  1317. @unnumberedsubsec Details of unpack phase of installation or upgrade
  1318. The procedure on installation/upgrade/overwrite/disappear (ie, when
  1319. running @code{dpkg --unpack}, or the unpack stage of @code{dpkg
  1320. --install}) is as follows. In each case if an error occurs the actions
  1321. in are general run backwards - this means that the maintainer scripts
  1322. are run with different arguments in reverse order. These are the `error
  1323. unwind' calls listed below.
  1324. @enumerate
  1325. @item
  1326. @noindent @enumerate a
  1327. @item
  1328. If a version the package is already
  1329. installed, call
  1330. @smallexample
  1331. <old prerm> upgrade <new version>
  1332. @end smallexample
  1333. @item
  1334. If this gives an error (ie, a non-zero exit status), dpkg will
  1335. attempt instead:
  1336. @smallexample
  1337. <new prerm> failed-upgrade <old-version>
  1338. @end smallexample
  1339. @noindent error unwind, for both the above cases:
  1340. @smallexample
  1341. <old postinst> abort-upgrade <new version>
  1342. @end smallexample
  1343. @end enumerate
  1344. @item
  1345. If a `conflicting' package is being removed at the same time:
  1346. @noindent @enumerate a
  1347. @item
  1348. If any packages depended on that conflicting package and
  1349. @code{--auto-deconfigure} is specified, call, for each such package:
  1350. @smallexample
  1351. <deconfigured's prerm> deconfigure \
  1352. in-favour <package-being-installed> <version> \
  1353. removing <conflicting-package> <version>
  1354. @end smallexample
  1355. @noindent error unwind:
  1356. @smallexample
  1357. <deconfigured's postinst> abort-deconfigure \
  1358. in-favour <package-being-installed-but-failed> <version>
  1359. removing <conflicting-package> <version>
  1360. @end smallexample
  1361. The deconfigured packages are marked as requiring configuration, so
  1362. that if --install is used they will be configured again if possible.
  1363. @item
  1364. To prepare for removal of the conflicting package, call:
  1365. @smallexample
  1366. <conflictor's prerm> remove in-favour <package> <new version>
  1367. @end smallexample
  1368. @noindent error unwind:
  1369. @smallexample
  1370. <conflictor's postinst> abort-remove in-favour <package> <new version>
  1371. @end smallexample
  1372. @end enumerate
  1373. @item
  1374. @noindent @enumerate a
  1375. @item
  1376. If the package is being upgraded, call
  1377. @smallexample
  1378. <new preinst> upgrade <old-version>
  1379. @end smallexample
  1380. @item
  1381. otherwise, if the package had some configuration files from a previous
  1382. version installed (ie, it is in the conffiles-only state):
  1383. @smallexample
  1384. <new preinst> install <old-version>
  1385. @end smallexample
  1386. @item
  1387. otherwise (ie, the package was completely purged):
  1388. @smallexample
  1389. <new preinst> install
  1390. @end smallexample
  1391. @noindent error unwind versions, respectively:
  1392. @smallexample
  1393. <new postrm> abort-upgrade <old-version>
  1394. <new postrm> abort-install <old-version>
  1395. <new postrm> abort-install
  1396. @end smallexample
  1397. @end enumerate
  1398. @item
  1399. The new package's files are unpacked, overwriting any that may be on the
  1400. system already, for example any from the old package or from another
  1401. package (backups of the old files are left around, and if anything goes
  1402. wrong dpkg will attempt to put them back as part of the error unwind).
  1403. @item
  1404. @noindent @enumerate a
  1405. @item
  1406. If the package is being upgraded, call
  1407. @smallexample
  1408. <old postrm> upgrade <new-version>
  1409. @end smallexample
  1410. @item
  1411. If this fails, dpkg will attempt:
  1412. @smallexample
  1413. <new postrm> failed-upgrade <old-version>
  1414. @end smallexample
  1415. @noindent error unwind, for both cases:
  1416. @smallexample
  1417. <old preinst> abort-upgrade <new-version>
  1418. @end smallexample
  1419. @end enumerate
  1420. This is the point of no return - if dpkg gets this far, it won't back
  1421. off past this point if an error occurs. This will leave the package in
  1422. a fairly bad state, which will require a successful reinstallation to
  1423. clear up, but it's when dpkg starts doing things that are irreversible.
  1424. @item
  1425. Any files which were in the old version of the package but not in the
  1426. new are removed.
  1427. @item
  1428. The new file list replaces the old.
  1429. @item
  1430. The new maintainer scripts replace the old.
  1431. @item
  1432. Any packages all of whose files have been overwritten during the
  1433. installation, and which aren't required for dependencies, are considered
  1434. to have been removed. For each such package,
  1435. @noindent @enumerate a
  1436. @item
  1437. dpkg calls:
  1438. @smallexample
  1439. <disappearer's postrm> disappear <overwriter> <new version>
  1440. @end smallexample
  1441. @item
  1442. The package's maintainer scripts are removed.
  1443. @item
  1444. It is noted in the status database as being in a sane state, namely not
  1445. installed (any conffiles it may have are ignored). Note that
  1446. disappearing packages do not have their prerm called, because dpkg
  1447. doesn't know in advance that the package is going to vanish.
  1448. @end enumerate
  1449. @item
  1450. Any files in the package we're unpacking that are also listed in the
  1451. file lists of other packages are removed from those lists. (This will
  1452. lobotomise the file list of the `conflicting' package if there is one.)
  1453. @item
  1454. The backup files made at 4. are deleted.
  1455. @item
  1456. The new package's status is now sane, and recorded as `unpacked'. Here
  1457. is another point of no return - if the conflicting package's removal
  1458. fails we do not unwind the rest of the installation; the conflicting
  1459. package is left in a half-removed limbo.
  1460. @item
  1461. If there was a conflicting package we go and do the removal actions,
  1462. starting from point 2. of the removal, below.
  1463. @end enumerate
  1464. @unnumberedsubsec Details of configuration
  1465. When we configure a package (this happens with @code{dpkg --install}, or with
  1466. @code{--configure}), we first update the conffiles and then call:
  1467. @smallexample
  1468. <postinst> configure <most-recently-configured-version>
  1469. @end smallexample
  1470. No attempt is made to unwind after errors during configuration.
  1471. @unnumberedsubsec Details of removal and/or configration purging
  1472. @enumerate
  1473. @item
  1474. @smallexample
  1475. <prerm> remove
  1476. @end smallexample
  1477. @item
  1478. The package's files are removed (except conffiles).
  1479. @item
  1480. @smallexample
  1481. <postrm> remove
  1482. @end smallexample
  1483. @item
  1484. All the maintainer scripts except the postrm are removed.
  1485. If we aren't purging the package we stop here. Note that packages which
  1486. have no postrm and no conffiles are automatically purged when removed,
  1487. as there is no difference except for the dpkg status.
  1488. @item
  1489. The conffiles and any backup files (@samp{~}-files, @samp{#*#} files,
  1490. @samp{%}-files, .dpkg-@{old,new,tmp@}, etc.) are removed.
  1491. @item
  1492. @smallexample
  1493. <postrm> purge
  1494. @end smallexample
  1495. @item
  1496. The package's file list is removed.
  1497. @end enumerate
  1498. No attempt is made to unwind after errors during removal.
  1499. @node Mail processing packages, Virtual dependencies, Maintainer script arguments and how dpkg does things, Appendix
  1500. @unnumberedsec Mail processing packages
  1501. Debian packages which process electronic mail (whether mail-user-agents
  1502. (MUA) or alternative mail-transport-agents (MTA)) @emph{must} make sure
  1503. that they are compatible with the configuration decisions below.
  1504. Failure to do this may result in lost mail, broken @code{From:} lines,
  1505. and other serious brain damage!
  1506. @itemize @bullet
  1507. @item
  1508. The mail spool is @file{/var/spool/mail} and the interface to send a
  1509. mail message is @file{/usr/sbin/sendmail} (as per the FSSTND). The mail
  1510. spool is part of the base and not part of the MTA package.
  1511. @item
  1512. Mailboxes are locked using the @file{.lock} lockfile convention, rather
  1513. than fcntl, flock or lockf.
  1514. @item
  1515. Mailboxes are generally 660 @file{<user>.mail} unless the user has
  1516. chosen otherwise. A MUA may remove a mailbox (unless it has nonstandard
  1517. permissions) in which case the MTA or another MUA must recreate it if
  1518. needed. Mailboxes must be writeable by group mail.
  1519. @item
  1520. The mail spool is 2775 mail.mail, and MUA's need to be setgid mail to do
  1521. the locking mentioned above (and obviously need to avoid accessing other
  1522. users' mailboxes using this privilege).
  1523. @item
  1524. @file{/etc/aliases} is the source file for the system mail aliases (e.g.
  1525. postmaster, usenet, etc.) - it is the one which the sysadmin and
  1526. postinst scripts may edit.
  1527. @item
  1528. The convention of writing `forward to <address>' in the mailbox itself
  1529. is not supported. Use a @file{.forward} file instead.
  1530. @item
  1531. The location for the @file{rmail} program used by UUCP for incoming mail
  1532. is @file{/usr/sbin/rmail}, as per the FSSTND. Likewise, @file{rsmtp},
  1533. for receiving batch-SMTP-over-UUCP, is in @file{/usr/sbin/rsmtp} if it
  1534. is supported.
  1535. @item
  1536. Smail is not using HoneyDanBer UUCP, whose uux apparently accepts -a and
  1537. -g options.
  1538. @item
  1539. If you need to know what name to use (for example) on outgoing news and
  1540. mail messages which are generated locally, you should use the file
  1541. @file{/etc/mailname}. It will contain the portion after the username
  1542. and @samp{@@} sign for email addresses of users on the machine (followed
  1543. by a newline).
  1544. @end itemize
  1545. A package should check for the existence of this file. If it exists it
  1546. should use it without comment @footnote{An MTA's prompting configuration
  1547. script may wish to prompt the user even if it finds this file exists.}.
  1548. If it does not exist it should prompt the user for the value and store
  1549. it in @file{/etc/mailname} as well as using it in the package's
  1550. configuration. The prompt should make it clear that the name will not
  1551. just be used by that package. E.g., in the same situation the INN
  1552. package says:
  1553. @smallexample
  1554. Please enter the `mail name' of your system. This is the hostname
  1555. portion of the address to be shown on outgoing news and mail messages.
  1556. The default is `$syshostname', your system's host name.
  1557. Mail name [`$syshostname']:
  1558. @end smallexample
  1559. ($syshostname is the output of `hostname --fqdn').
  1560. @node Virtual dependencies, , Mail processing packages, Appendix
  1561. @comment node-name, next, previous, up
  1562. @unnumberedsec Virtual dependencies
  1563. Virtual packages are in the same namespace as real packages, and may
  1564. have the same name. The meaning of a virtual package in a
  1565. dependency/conflicts list is exactly that of listing all the real
  1566. packages which state that they are an instantiation of that virtual
  1567. package.
  1568. This is done with a new Provides field in the control file, with a
  1569. syntax much like the Conflicts field.
  1570. The idea is that we can have something like:
  1571. @smallexample
  1572. Package: elm
  1573. Depends: mta
  1574. Package: smail
  1575. Provides: mta
  1576. Conflicts: mta
  1577. Package: sendmail
  1578. Provides: mta
  1579. Conflicts: mta
  1580. @end smallexample
  1581. @noindent The result is equivalent to elm having said
  1582. @smallexample
  1583. Package: elm
  1584. Depends: smail | sendmail
  1585. @end smallexample
  1586. (There'll be a special case to say that a package may conflict with a
  1587. virtual package which it provides - clearly ...)
  1588. If there are both a real and a virtual package of the same name then
  1589. the dependency may be satisfied (or the conflict caused) by either the
  1590. real package or any of the virtual packages which provide it. This is
  1591. so that, for example, supposing we have
  1592. @smallexample
  1593. Package: lout
  1594. Optional: ghostview
  1595. @end smallexample
  1596. (this is a fictional example - the Lout package should not mention
  1597. ghostview), and someone else comes up with a nice PostScript
  1598. previewer, then they can just say
  1599. @smallexample
  1600. Package: marvelpostview
  1601. Provides: ghostview
  1602. @end smallexample
  1603. and all will work in the interim (until, say, the Lout maintainer
  1604. changes things).
  1605. If a dependency or a conflict has a version number attached then only
  1606. real packages will be considered to see whether the relationship is
  1607. satisfied (or prohibited, for a conflict) - it is assumed that a real
  1608. package which provides virtual package is not of the `right' version.
  1609. If there is demand it can be arranged that a package which provides a
  1610. virtual package may mention a version number, though this is unlikely to
  1611. be helpful:
  1612. @smallexample
  1613. Provides: mta (2.0)
  1614. @end smallexample
  1615. If you want to specify which of a set of real packages should be the
  1616. default to satisfy a particular dependency on a virtual package, you can
  1617. simply list the real package as alternative before the virtual one:
  1618. @smallexample
  1619. Package: xbaseR6
  1620. Recommended: xsvga | x-server
  1621. Provides: x-base, xr6shlib
  1622. Package: xsvga
  1623. Recommended: x-base
  1624. Provides: x-server
  1625. Package: x8514
  1626. Recommended: x-base
  1627. Provides: x-server
  1628. @end smallexample
  1629. Virtual package names should generally not be used in the names of
  1630. @file{/etc/init.d} scripts, configuration files, logfiles, and so on, so
  1631. that several programs providing the same virtual package name can be
  1632. installed.
  1633. @bye