guidelines.texi 79 KB

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