guidelines.texi.beforeeric 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. \input texinfo @c -*-texinfo-*-
  2. @setfilename guidelines.info
  3. @set DATE 26th January 1996
  4. @setchapternewpage off
  5. @iftex
  6. @center @titlefont{Debian GNU/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. * debian-guidelines: (debian-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 GNU/Linux Packaging Guidelines
  23. @end ifinfo
  24. This file documents the steps that must be taken in the preparation
  25. of a Debian GNU/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 GNU/Linux
  37. archive.
  38. (This file was last updated on @value{DATE}. Please check the most
  39. recent @file{dpkg} package at any Debian GNU/Linux archive for a
  40. potentially more up to date copy.)
  41. @menu
  42. * Additional Information::
  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. @end menu
  50. @node Additional Information, Package Copyright, Top, Top
  51. @unnumbered Additional Information
  52. These Guidelines are intended to be fairly general. More specific
  53. information is available about certain aspects of building packages,
  54. such as how to use the features of Init under Debian GNU/Linux. This
  55. information can be found in the directory @file{project/standards}
  56. at any Debian GNU/Linux archive. At the time of this writing, the
  57. following documents are available:
  58. @table @file
  59. @item README.etc-skel
  60. A description of @file{/etc/skel} and @file{/usr/doc/examples}.
  61. @item descriptions.txt
  62. How to write an extended (and more useful) @file{DESCRIPTION} field.
  63. @item README.init
  64. How to use the features of Init under Debian GNU/Linux in packages.
  65. @item mailers.txt
  66. How to properly configure packages to use the Debian GNU/Linux mail
  67. system.
  68. @item maintainer-script-args.txt
  69. All the ways that the package maintainer scripts inside a package can
  70. be called by dpkg.
  71. @item dpkg-upgrades+errors.txt
  72. What order things happen in during a package upgrade.
  73. @item virtual-dependencies.txt
  74. How to use ``virtual dependencies'' in packages.
  75. @item virtual-package-names-list.text
  76. The list of virtual package names currently in use, together with the
  77. procedure for getting new virtual package names allocated.
  78. @item dependency-ordering.txt
  79. How to properly order package names in the @file{DEPENDS} field.
  80. @end table
  81. There are a number of documents that describe more technical
  82. details of dpkg's operation, that will probably only be of minority
  83. interest. Please read them if you're doing anything complicated.
  84. @table @file
  85. @item auto-deconfiguration.txt
  86. How dpkg can sometimes automatically deconfigure packages in order to
  87. do bulk installations smoothly.
  88. @item dpkg-essential-flag.txt
  89. How to tell dpkg a package is essential and should not be removed.
  90. (This is for the use of base system packages only.)
  91. @item dpkg-disappear-replace.txt
  92. What happens when a package appears to have been completely replaced.
  93. @end table
  94. In the future, we hope also to make available:
  95. @table @file
  96. @item copyright.txt
  97. How to choose a good copyright notice to attach to new programs.
  98. @item version-ordering.txt
  99. The algorithm with which packages' version numbers are compared.
  100. @end table
  101. Also, you should download the sample files and the sample package
  102. (GNU Hello) available in @file{standards/samples}. You may use any
  103. of this material as a starting point for new packages. The following
  104. sample files, incidentally, are available:
  105. @itemize @bullet
  106. @item debian.README
  107. @item debian.control
  108. @item debian.postinst
  109. @item debian.postrm
  110. @item debian.rules
  111. @end itemize
  112. @node Package Copyright, Package Content, Additional Information, Top
  113. @unnumbered Package Copyright
  114. Please study the copyright of your submission @emph{carefully}
  115. and @emph{understand it} before proceeding! If you have doubts or
  116. questions, please ask!
  117. In order to understand how we classify and distribute certain
  118. packages, it is important to understand the distinction between being
  119. freely available and being freely redistributable.
  120. Being @dfn{freely available}, quite simply, means that the software
  121. can be made available freely, at least for non-commercial purposes and
  122. in its original, unmodified form. This includes packages made available
  123. freely that have restrictions on non-commercial use, redistribution of
  124. modifications, etc. Being freely available, therefore, has nothing to
  125. do with being able to modify and redistribute the software. It only
  126. means that you can get a copy of the software without having to pay
  127. (and it does not necessarily mean that you can @emph{use} the software
  128. without having to pay---shareware is an example of freely available
  129. software).
  130. @dfn{freely redistributable}, while generally being freely available,
  131. goes beyond just being freely available. Freely redistributable means
  132. that that the software, in addition to being able to be made available
  133. freely, must be able to be freely modified and redistributed without
  134. restriction.
  135. All submissions to be included in the distribution proper @emph{must}
  136. be freely redistributable.
  137. In addition to the distribution, the Project maintains two separate
  138. archives of software packages with the distribution: the @file{contrib}
  139. archive and the @file{non-free} archive.
  140. @file{contrib} is an archive of user-contributed packages that are
  141. not maintained by the Project, packages that were once maintained by the
  142. Project but that are no longer actively maintained, and packages that
  143. are maintained by the Project but that are not yet considered ready for
  144. inclusion in the distribution proper (i.e., ALPHA and BETA packages).
  145. As above, all submissions for inclusion in the @file{contrib} archive
  146. @emph{must} be freely redistributable.
  147. @file{non-free} is an archive of packages with either restrictive or
  148. unclear terms of copying or modification. If a package has @emph{any}
  149. restrictions on modification or redistribution, it can not be included
  150. in the distribution or @file{contrib} archive. It can only be included
  151. in the @file{non-free} archive, and then only if it is freely available.
  152. In summary, in order to be included in the distribution proper or the
  153. @file{contrib} archive, a package must be @emph{freely redistributable}.
  154. Anyone must be able to make copies of it, modify it, redistribute it with
  155. their modifications in place, include it on a CD-ROM, or generally sell
  156. it. To be included in the @file{non-free} archive, a package may have
  157. restrictions, as long as the package remains @emph{freely available}. We
  158. must be available to make it available freely at the archive, and anyone
  159. must be able to make copies of it and use it for at least non-commercial,
  160. personal purposes. Software that will typically be included in
  161. @file{non-free} are software that does not allow commercial distribution,
  162. software that does not allow modification or redistribution of
  163. modifications, commercial ``demos'', and ``shareware''.
  164. When in doubt, send mail to @file{iwj10@@cus.cam.ac.uk} and
  165. @file{imurdock@@debian.org}. Be prepared to provide us with the
  166. copyright statement. Software covered by the GPL, public domain
  167. software and BSD-like copyrights are safe; be wary of the phrases
  168. ``commercial use prohibited'' and ``distribution restricted''.
  169. Every package submission @emph{must} be accompanied by verbatim copy
  170. of its copyright (with the exceptions of public domain packages and
  171. those covered by the UCB BSD licence or the GNU GPL or LGPL; in these
  172. cases simply indicate which is appropriate). This information must be
  173. included in a file installed to the directory @file{/usr/doc/copyright}.
  174. See below for details.
  175. @node Package Content, Source Package, Package Copyright, Top
  176. @unnumbered Package Content
  177. The following requirements apply equally to both the binary and
  178. source packages. In either case, when files have been installed,
  179. they must conform to the requirements described in this section.
  180. The primary rule in Debian GNU/Linux is to follow the Linux @dfn{File
  181. System Standard} (@dfn{FSSTND}). The location of installed files
  182. @emph{must} comply @emph{fully} with the FSSTND. The latest version of
  183. this document can be found alongside the Guidelines or at
  184. @file{tsx-11.mit.edu} in @file{/pub/linux/docs/linux-standards/fsstnd}.
  185. Specific questions about following the standard should be addressed to
  186. Daniel Quinlan, the FSSTND coordinator, at @code{quinlan@@yggdrasil.com}.
  187. In addition to the FSSTND, all Debian GNU/Linux packages must follow
  188. the guidelines below.
  189. @itemize @bullet
  190. @item
  191. Directories should be mode 755 or (for group-writability) mode 2775,
  192. with the exception of special ``system'' directories that need to be
  193. another mode. The ownership of the directory should be consistent with
  194. its mode---if a directory is mode 2775, it should be owned by the group
  195. that needs write access to it, of course. Use common sense in assigning
  196. permissions and ownerships to directories, and make sure that what is
  197. done is secure if it is ``non-standard''.
  198. @item
  199. Normal binaries should be mode 755 and owned by @code{root.root}. If
  200. there is a good reason to use a different mode or ownership, you may do
  201. so, but you must try to be as consistent as possible with the rest of
  202. the system. If you need to use a different mode or ownership, please
  203. discuss it with @code{imurdock@@debian.org}.
  204. @item
  205. Setuid binaries should normally be mode 4755 (not 4711!) and, of course,
  206. owned by the appropriate user.
  207. @item
  208. Setgid binaries should normally be mode 2755 (not 2711!) and, of course,
  209. owned by the appropriate group.
  210. @item
  211. Library files should generally be mode 644 and owned by
  212. @code{root.root}. If the package requires different permissions
  213. or ownerships to function correctly, they should be used instead.
  214. @item
  215. Manual pages should be mode 644 and owned by @code{root.root}. The
  216. @file{nroff} source must be installed. You should @emph{not} install
  217. a preformatted ``cat page'', and you should only use sections 1 to
  218. 9---see the FSSTND for more details.
  219. @item
  220. Info documents should be mode 644, owned by @code{root.root}, and
  221. compressed with @file{gzip -9} when installed. The package must call
  222. @file{install-info} to update the Info @file{dir} file. This should
  223. be done in the post-installation script (@file{postinst}), like this:
  224. @smallexample
  225. install-info --quiet /usr/info/foobar.info
  226. @end smallexample
  227. The entries should be removed by the pre-removal script (@file{prerm}),
  228. like this:
  229. @example
  230. install-info --quiet --remove /usr/info/foobar.info
  231. @end example
  232. It is also a good idea to specify a section for the Info @file{dir}
  233. entry. This is done with the @file{--section} switch. To determine
  234. which section to use, you should use look at @file{/usr/info/dir} on
  235. your system and choose the most relevant (or create a new section if
  236. none of the current sections are relevant).
  237. If @file{install-info} cannot find a description entry in the Info file
  238. you will have to supply one. See @file{install-info}(8) for details.
  239. @item
  240. If a package contains any shared libraries you will have to invoke
  241. @file{ldconfig} in both the @file{postinst} and @file{prerm} scripts
  242. to correctly update the library links. See @file{ldconfig}(8) for
  243. details.
  244. @item
  245. Any additional documentation that comes with the package can be
  246. installed at the discretion of the package maintainer. Text
  247. documentation should be mode 644, owned by @code{root.root}, installed
  248. to @file{/usr/doc}, and compressed with @file{gzip -9} unless it is small.
  249. If a subdirectory of @file{/usr/doc} is warranted, please do create one.
  250. Please do not install DVI, PostScript, or large textual documentation to
  251. @file{/usr/doc}. However, please do upload such documentation as a
  252. separate package so that it can be made available with the distribution.
  253. If a user has the need for the documentation, they can easily get it
  254. from the archive, CD-ROM, etc., but it should not take up disk space
  255. on the machines of the user who do not need or want it installed.
  256. @item
  257. Create a file named @file{/usr/doc/copyright/<@i{package}>} which gives
  258. details of the authorship and copyright of the package. If the package
  259. is distributed under the GNU General Public Licence, the GNU Library
  260. General Public Licence or the Regents of the University of California at
  261. Berkeley (BSD) licence, please say so instead of including a copy of the
  262. licence. The files @file{BSD}, @file{GPL}, and @file{LGPL} will be
  263. available in the @file{/usr/doc/copyright} directory for you to refer
  264. to. @file{/usr/doc/copyright/<@i{package}>} should not be compressed.
  265. @emph{All} authorship and copyright information from the original source
  266. package must be included in the @file{/usr/doc/copyright/<@i{package}>}
  267. file.
  268. @item
  269. Any example files (for example, sample configuration files) should
  270. be placed in the directory @file{/usr/doc/examples}. If the file is
  271. normally a hidden file, such as @file{.emacs}, then please call it
  272. @file{dot.emacs}, to avoid confusion. Again, you may create a
  273. subdirectory if it is needed.
  274. @item
  275. All symbolic links should be relative, not absolute. Absolute links,
  276. in general, cause problems when a file system is not mounted where it
  277. ``normally'' resides (for example, when mounted via NFS). In certain
  278. cases, however, relative links may also cause similar problems. I
  279. have generally made links into @file{/etc} and @file{/var} absolute
  280. and all other links relative. There may be other cases in which
  281. absolute links are necessary.
  282. Therefore, in the Makefile, do not do (even though it is easier):
  283. @smallexample
  284. install: all
  285. [...]
  286. ln -fs /usr/bin/gcc /usr/bin/cc
  287. [...]
  288. @end smallexample
  289. Instead, do:
  290. @smallexample
  291. ln -fs gcc /usr/bin/cc
  292. @end smallexample
  293. or
  294. @smallexample
  295. ( cd /usr/bin ; ln -fs gcc cc )
  296. @end smallexample
  297. Please do not create hard links in the manual page directories. In
  298. these cases, you should use relative symbolic links or files that
  299. @file{.so} (roff for `source') others instead.
  300. @item
  301. All command scripts should have a @code{#!} line naming the shell to be
  302. used to interpret them.
  303. @item
  304. In the case of Perl scripts this should be @code{#!/usr/bin/perl} or
  305. sometimes @code{#!/bin/perl}, as follows: if the script is a critical
  306. one that may be called when the @file{/usr} partition is unmounted or
  307. broken it should use @file{/bin/perl}. Otherwise (especially if the
  308. script is not specifically targetted at Debian) it should use Perl's
  309. standard location, @file{/usr/bin/perl}.
  310. @item
  311. Generally the following compilation parameters should be used:
  312. @display
  313. CC = gcc
  314. CFLAGS = -O2 -g -Wall # sane warning options vary between programs
  315. LDFLAGS = # none (or -N, if appropriate; see below)
  316. install -s (or strip)
  317. @end display
  318. Note that all installed binaries should be stripped, either by using the
  319. @code{-s} flag to @file{install}, or by calling @file{strip} on the
  320. binaries after they have been copied into the @file{debian-tmp} but
  321. before the tree is made into a package.
  322. Make sure that you do not link with @code{-g}, as this makes a.out
  323. compilers produce huge statically linked binaries. The @code{-g} flag
  324. is useful on compilation so that you have available a full set of
  325. debugging symbols in your built source tree, in case anyone should file
  326. a bug report involving (for example) a core dump.
  327. @code{-N} should only be used on binaries that are very small (less than
  328. 8K with the @code{-N} option, roughly) and are not likely to have
  329. multiple instances in memory. Do not use @code{-N} on daemons, no
  330. matter how small they are.
  331. It is up to the package maintainer to decide what compilation options
  332. are best for the package. Certain binaries (such as
  333. computationally-intensive programs) may function better with certain
  334. flags (@code{-O3}, for example); feel free to use them. Please use good
  335. judgment here. Don't add flags for the sake of adding flags; only add
  336. flags if there is good reason to do so.
  337. @item
  338. Please check with the base system maintainer (Ian Murdock) before using
  339. users or groups other than @code{root} and others specified in this
  340. document.
  341. @end itemize
  342. @node Source Package, Binary Package, Package Content, Top
  343. @unnumbered Source Package
  344. The source package should contain a file called @file{debian.rules}
  345. which contains at least the following targets, to be invoked in the top
  346. level directory:
  347. @smallexample
  348. build
  349. binary
  350. clean
  351. @end smallexample
  352. @file{debian.rules} should start with
  353. @example
  354. #!/usr/bin/make -f
  355. @end example
  356. @noindent and be executable. It is a good idea to arrange for it not
  357. to fail obscurely when invoked in the wrong directory, for example by
  358. testing for the existence of a file in the source directory.
  359. @itemize @bullet
  360. @item
  361. The @file{build} target should perform all non-interactive configuration
  362. and compilation of the package. If a package has an interactive
  363. pre-build configuration routine, the source package should be built
  364. @emph{after} this has taken place.
  365. For some packages, notably ones where the same source tree is
  366. compiled in different ways to produce two binary packages, the
  367. @file{build} target does not make much sense. For these packages it is
  368. good enough to provide two (or more) targets (@file{build-a} and
  369. @file{build-b} or whatever) for each of the ways of building the
  370. package, and a @file{build} target that does nothing. The @file{binary}
  371. target will have to build the package in each of the possible ways and
  372. make the binary package out of each.
  373. @item
  374. The @file{binary} target of @file{debian.rules} should be all that is
  375. necessary for the user to build the binary package. The binary package
  376. should be created using @file{dpkg} and placed in the parent of the top
  377. level directory. The next section describes how to construct binary
  378. packages from the @file{binary} target.
  379. @item
  380. The @file{clean} target should undo the effects of the @file{build}
  381. target and the @file{binary} target, except that it should leave alone
  382. any @file{../<@i{package}>-<@i{version}>.deb} file created by a run of
  383. @file{binary}.
  384. @item
  385. Additional targets may exist in @file{debian.rules}. We recommend using
  386. @file{source} and @file{diff} targets to build the Debianised source
  387. package and the Debianisation context diff, respectively. These files
  388. should be placed in @file{../foo-<@i{version}>.tar.gz} and
  389. @file{../foo-<@i{version}>.diff.gz}. The @file{install} target, for
  390. installing into a running system direct from the Debianised source
  391. tree, is no longer required. The sample @file{debian.rules} provides
  392. @file{source} and @file{diff} targets that should work with little or
  393. no alteration, providing that the package-specific variables at the top
  394. of the script have been properly defined.
  395. @item
  396. If you need to edit a @file{Makefile} where @file{configure} scripts
  397. are used, you should edit the @file{.in} files rather than editing
  398. the @file{Makefile} directly. This allows the user to reconfigure
  399. the package if necessary. You should @emph{not} configure the package
  400. and edit the generated @file{Makefile}! This makes it impossible for
  401. someone else to later reconfigure the package.
  402. @item
  403. Please document your changes to the source package so that future
  404. package maintainers know what has been changed. To do this, include
  405. a description of your changes in the @file{debian.README} (which, as
  406. described above, should already contain authorship and copyright
  407. information!) and include relevant information such as your name,
  408. electronic mail address, date, etc.
  409. @item
  410. If changes to the source code are made, please use a @file{define}. If
  411. they are changes required to compile or function under Linux in general,
  412. use @file{LINUX}. If it is a cosmetic or functional change, use
  413. @file{DEBIAN}.
  414. @item
  415. Create the source package using @file{tar}, and use @file{gzip -9} to
  416. compress it. Source packages should be named in the form
  417. <@i{package}>-<@i{version}>.tar.gz---for example,
  418. @file{fileutils-3.9-3.tar.gz}.
  419. NB, here @code{<@i{version}>} is the full Debian version number, in the
  420. form @code{<@i{original_version}>-<@i{debian_revision}>} (see below),
  421. but the tarfile should unpack into a directory named
  422. @code{<@i{package}>-<@i{original_version}>} (again, see the section
  423. below on version numbering).
  424. @item
  425. Create the context diff against the original package using @file{diff
  426. -cNr}, and use @file{gzip -9} to compress it. Context diffs should be
  427. named in the form <@i{package}>-<@i{version}>.diff.gz---for example,
  428. @file{fileutils-3.9-3.diff.gz}.
  429. @end itemize
  430. Please note that the package and patch filenames do @emph{not} need
  431. to fit in MS-DOS 8+3. They will be made available under an alternative
  432. 8+3 name in the archive by the archive maintainer, using a symlink.
  433. @node Binary Package, Control Files, Source Package, Top
  434. @unnumbered Binary Package
  435. The @file{binary} target of the source package @file{debian.rules}
  436. file should do the following (see the sample @file{debian.rules}
  437. for an implementation that you are free to modify and use in your own
  438. packages, of course):
  439. @itemize @bullet
  440. @item
  441. Create an empty directory in the top-level directory of the source
  442. package (deleting it first, if necessary), and install the files
  443. belonging to this package in that directory. For example, the directory
  444. could be called @file{debian-tmp} and would probably contain directories
  445. @file{debian-tmp/usr/bin}, @file{debian-tmp/usr/lib}, etc.
  446. (@file{debian-tmp} is the name traditionally used, and it is used in
  447. the sample @file{debian.rules} file, so we will use that name in the
  448. Guidelines.)
  449. @item
  450. Make sure that all the files under @file{debian-tmp} have the correct
  451. ownerships and permissions (@pxref{Package Content}, for more information
  452. about file locations, ownerships, and permissions.)
  453. @item
  454. Create a subdirectory of @file{debian-tmp} called @file{DEBIAN}. This
  455. directory contains the package control information, including at the
  456. very least the master information file named @file{control}. The next
  457. section describes the semantics and syntax of the files required and
  458. allowed here.
  459. @item
  460. Run @file{dpkg} to create the binary package, using something like
  461. @smallexample
  462. dpkg --build debian-tmp
  463. @end smallexample
  464. This will create a file called @file{debian-tmp.deb}, from the
  465. @file{debian-tmp} directory. You should rename this file to
  466. @file{../<@i{package}>-<@i{version}>.deb} after it is built.
  467. After the @file{binary} target has done all this, the
  468. @file{<@i{package}>-<@i{version}>.deb} file in the parent directory is
  469. the binary distribution. This file may be distributed and installed on
  470. any Debian GNU/Linux system with @file{dpkg} in the same manner and
  471. using the same methods as all packages are installed to the system.
  472. @item
  473. If a single source package corresponds to several binary packages, there
  474. should usually be a @file{debian.rules} file with a single @file{binary}
  475. target that builds all the binary packages involved and move all packages
  476. to the parent directory of that containing the source package.
  477. In this case, you should choose binary package names which are meant to
  478. make clear the close relationship between the binary packages and which
  479. source package the binary packages came from (for example, the
  480. @file{texinfo} source package build two binary packages: @file{texidoc}
  481. and @file{texinfo}). You should place the appropriate binary package
  482. name in the @file{Package} field of the control file (not the source
  483. package name), and you should consider whether the other binary packages
  484. that come from the same source tree should be mentioned in the
  485. @file{Depends}, @file{Recommends} or @file{Suggests} fields. You
  486. should put the source package name in the @file{Source} field.
  487. You should retain the source package version numbering in the
  488. @file{Version} field---the version number should be the same for the
  489. Debianised source tree and all the binary packages generated from it.
  490. See below for details of version numbers.
  491. @end itemize
  492. @node Control Files, , Binary Package, Top
  493. @unnumbered Control Files
  494. Each binary package contains, in addition to the files that comprise
  495. the actual package, a set of text files that control how @file{dpkg}
  496. installs, configures, upgrades, removes, etc. the package. These files
  497. are called @dfn{control files}. When creating the package, the control
  498. files should placed in a directory called @file{DEBIAN}, as described
  499. earlier (@pxref{Binary Package}, for further information).
  500. The control information files are:
  501. @table @code
  502. @item control
  503. The master package control information file.
  504. @item conffiles
  505. A list of package configuration files.
  506. @item preinst
  507. The package pre-installation script.
  508. @item postinst
  509. The package post-installation script.
  510. @item prerm
  511. The package pre-removal script.
  512. @item postrm
  513. The package post-removal script.
  514. @end table
  515. Of these, only @file{control} is required. The various installation
  516. scripts, and the configuration files list, will only be used if they are
  517. present.
  518. @menu
  519. * control::
  520. * conffiles::
  521. * Installation and Removal Scripts::
  522. * Dependencies and Conflicts::
  523. * Package Classification Fields::
  524. @end menu
  525. @node control, conffiles, Control Files, Control Files
  526. @unnumberedsec control
  527. The @file{control} file contains a number of fields. Each field
  528. begins with a field name, such as @file{Package} or @file{Version}
  529. (case insensitive), followed by a colon and optionally some spaces or
  530. tabs (a single space is conventional). Then comes the body of the
  531. field, which may be several lines long; each continuation line must
  532. start with at least one space or tab. (These are the same rules as
  533. apply to RFC822 mail headers.) Blank lines are not permitted in the
  534. control file.
  535. The required fields in the control file are the following:
  536. @table @code
  537. @item Package
  538. The name of the package.
  539. @item Description
  540. The description of the package.
  541. @item Maintainer
  542. The name and e-mail address of the maintainer of the package.
  543. @item Version
  544. The version number in the format
  545. @code{<@i{original_version}>-<@i{debian_revision}>}.
  546. @end table
  547. Each field has a particular format and meaning for the package
  548. installation tools.
  549. The value of @file{Package} should be the name of the package.
  550. Package names must start with an alphanumeric, must be at least two
  551. characters, and may contain only alphanumerics and the characters
  552. - + . @@ : = % _ (that is, hyphen, plus, stop, at, colon, equals,
  553. percent and underscore). They are not case sensitive.
  554. The @code{Maintainer} field should be in the form
  555. @smallexample
  556. Joe J. Bloggs <jbloggs@@foo.com>
  557. @end smallexample
  558. @noindent Note that this will not be useable as an email address if
  559. the name given contains full stop characters, because of a silly
  560. restriction in the Internet mail standards. If you want to use this
  561. as an email address in a program you should check for full stops and
  562. change the string to the form @code{jbloggs@@foo.com (Joe J. Bloggs)}
  563. if you find any.
  564. The @code{Version} field should be the version number of the
  565. package. For most packages which are not written specifically for
  566. Debian, this should be in the form
  567. @smallexample
  568. Version: <@i{original_version}>-<@i{debian_revision}>
  569. @end smallexample
  570. @noindent where @file{<@i{original_version}>} is the original package
  571. version number in whatever form the original package uses and
  572. @file{<@i{debian_revision}>} indicates which ``debianisation'' this is
  573. (this should usually be a plain number or perhaps a two numbers
  574. separated by a full stop, and should be incremented each time the
  575. package is changed or updated).
  576. Packages which are written specifically for Debian do not have a
  577. @i{debian_revision}, and their version number should simply be
  578. @i{version} (which should not contain any hyphens, to avoid
  579. confusion).
  580. There is an ordering imposed on version numbers, described in
  581. @file{version-ordering.txt}. This ordering is designed to `do the right
  582. thing' in most circumstances; if your package has an version number in
  583. an unusual format you may need to reformat it somewhat to get the
  584. ordering right. This is important because @file{dpkg} is (for example)
  585. reluctant to downgrade packages.
  586. The optional fields in the control file are the following:
  587. @table @code
  588. @item Depends
  589. The names of prerequisite packages.
  590. @item Recommends
  591. The names of related, recommended packages.
  592. @item Suggests
  593. The names of related, optional packages.
  594. @item Conflicts
  595. The names of packages which conflict with this package.
  596. @item Provides
  597. The names of virtual packages which this package provides.
  598. @item Priority
  599. The `priority' of the package, as shown and used by @file{dselect}.
  600. @item Section
  601. The `section' of the package, as shown and used by @file{dselect}, and
  602. used as a location for the package in the distribution.
  603. @item Essential
  604. A boolean field used by the base packages.
  605. @end table
  606. @noindent See below for details of the semantics and syntax of these
  607. fields. Most packages will need at least a @code{Depends} field.
  608. An example of a @file{control} file would be:
  609. @example
  610. Package: smail
  611. Version: 3.1.29.1-13
  612. Maintainer: Ian Jackson <iwj10@@cus.cam.ac.uk>
  613. Recommends: pine | mailx | elm | emacs | mail-user-agent
  614. Suggests: metamail
  615. Depends: cron, libc5
  616. Conflicts: sendmail
  617. Provides: mail-transport-agent
  618. Description: Electronic mail transport system.
  619. Smail is the recommended mail transport agent (MTA) for Debian.
  620. .
  621. An MTA is the innards of the mail system - it takes messages from
  622. user-friendly mailer programs and arranges for them to be delivered
  623. locally or passed on to other systems as required.
  624. .
  625. In order to make use of it you must have one or more user level
  626. mailreader programs such as elm, pine, mailx or Emacs (which has Rmail
  627. and VM as mailreaders) installed. If you wish to send messages other
  628. than just to other users of your system you must also have appropriate
  629. networking support, in the form of IP or UUCP.
  630. @end example
  631. In this case, @file{mail-user-agent} is a virtual package
  632. representing any user mailer program; the actual package names
  633. @file{pine} is quoted for the reasons described in
  634. @file{dependency-ordering.txt}, and the others because older versions
  635. of those packages do not have the appropriate @file{Provides} field.
  636. @node conffiles, Installation and Removal Scripts, control, Control Files
  637. @unnumberedsec conffiles
  638. The contents of @file{conffiles} is simply a list of configuration
  639. files in the package. When installing the package, @file{dpkg} uses
  640. an intelligent method to update these files. This will ensure that
  641. package-specific configuration files are not overwritten when a package
  642. is upgraded, unless the user wishes the installation tools to do so.
  643. Typically, files listed in conffiles are package-specific
  644. configuration files, which (according to the Linux Filesystem Standard)
  645. are stored in @file{/etc}. For example, the @code{sendmail} package may
  646. contain the file @file{/etc/sendmail.cf}, which we do not wish to
  647. overwrite automatically when the user upgrades the sendmail package.
  648. Only those files listed in @file{DEBIAN/conffiles} will be updated
  649. intelligently when a package is upgraded; all other files in the package
  650. will be overwritten by the upgrade process.
  651. Configuration files which will be functional as shipped and will
  652. probably need little or no local editing should simply be listed the
  653. @file{conffiles} file; in this case you need read no further.
  654. For packages whose configuration files will need modification on
  655. most systems there are two sensible approaches. Which one is chosen
  656. depends on how hard the configuration problem is and how much time the
  657. package maintainer has available.
  658. One option is for you to ship a minimal `best-effort' file in
  659. @file{/etc}, and list the file in @file{conffiles}. This will mean that
  660. the user will have to go and edit the file themselves to get the package
  661. to work properly, of course. The next time they upgrade the package, if
  662. you haven't changed the file version, their old file will be left in
  663. place. If you have modified your version then the user will get a
  664. prompt asking them which version of the file they want, theirs or yours.
  665. They will then usually have to resolve the discrepancies manually.
  666. The other option is to be preferred, if you can do it: don't put a
  667. copy of the configuration file in the package at all. Instead, you
  668. check in the postinst whether the file exists, and if it doesn't you
  669. prompt the user for the information you need to create a good one. This
  670. is obviously harder work.
  671. You also have to remember that you will have to keep up with your
  672. package's changes: if you discover a bug in the program which generates
  673. the configuration file, or if the format of the file changes from one
  674. version to the next, you will have to arrange for the postinst script to
  675. do something sensible---usually this will mean editing the installed
  676. configuration file to remove the problem or change the syntax. You will
  677. have to do this very carefully, since the user may have changed the
  678. file, perhaps to fix the very problem that your script is trying to deal
  679. with---you will have to detect these situations and deal with them
  680. correctly.
  681. If you do go down this route it's probably a good idea to make the
  682. program that generates the configuration file(s) a separate program in
  683. @file{/usr/sbin}, by convention called @i{package}@code{config}, and
  684. then run that if appropriate from the post-installation script. The
  685. @i{package}@code{config} program should not unquestioningly overwrite an
  686. existing configuration---if its mode of operation is geared towards
  687. setting up a package for the first time (rather than any arbitrary
  688. reconfiguration later) you should have it check whether the
  689. configuration already exists, and require a @code{--force} flag to
  690. overwrite it.
  691. @file{conffiles} should almost certainly list all the files contained
  692. in your package in the @file{/etc} directory. There may also be other
  693. files somewhere that the user is expected to edit, which should also be
  694. included. Note, however, that the FSSTND specifies that configuration
  695. files must be in @file{/etc}. No Debian package should contain
  696. configuration files in @file{/usr/etc}, and all programs should refer to
  697. configuration files in @file{/etc}.
  698. @noindent For example, the TCP/IP package might use a conffiles which contains
  699. @example
  700. /etc/init.d/netbase
  701. /etc/gateways
  702. /etc/protocols
  703. /etc/services
  704. /etc/hosts.allow
  705. /etc/hosts.deny
  706. /etc/rpc
  707. @end example
  708. @noindent and so on; the files
  709. @example
  710. /etc/hosts
  711. /etc/inetd.conf
  712. /etc/host.conf
  713. /etc/networks
  714. /etc/resolv.conf
  715. @end example
  716. @noindent might be generated by an interactive configuration program,
  717. and would then not be included in the package or listed in the
  718. @file{conffiles}.
  719. @node Installation and Removal Scripts, Dependencies and Conflicts, conffiles, Control Files
  720. @unnumberedsec Installation and Removal Scripts
  721. The scripts @file{preinst}, @file{postinst}, @file{prerm}, and
  722. @file{postrm} are optional (Bash or Perl) scripts. As the names
  723. would indicate, if these scripts exist, they will be executed before
  724. installing the package, after installation, before package removal,
  725. and after removal, respectively.
  726. They are given arguments which indicate the precise situation and
  727. action being performed---see @file{maintainer-script-args.txt} for
  728. details of exactly when each of the scripts is invoked and what its
  729. arguments are. Extra arguments and situations may be added later, so
  730. you should not test the number of arguments to your script to determine
  731. the situation, and you should choose the sense of your `if it is this
  732. then do this otherwise do that' tests carefully.
  733. These scripts can be used to perform any site-specific package
  734. configuration.
  735. Because the scripts will be exectued by the dpkg front-end, it is
  736. guaranteed that the scripts will be executed interactively. User input
  737. from the scripts should be read from standard input, not the user's
  738. terminal. Similarly, output should be sent to standard output.
  739. If your maintainer scripts need to prompt for passwords and/or do
  740. @i{full-screen} interaction should do these things to and from
  741. @file{/dev/tty}, since @file{dpkg} will at some point redirect scripts'
  742. standard input and output so that it can log the installation process.
  743. Likewise, because these scripts may be executed with standard output
  744. redirected into a pipe for logging purposes, Perl scripts should set
  745. unbuffered output by setting @code{$|=1} so that the output is printed
  746. immediately rather than being buffered.
  747. The scripts must be idempotent, and they must clean up after
  748. themselves properly. Ie, they must do the right thing if run multiple
  749. times, even if previous runs failed halfway through. This is so that if
  750. any errors occur, or if the @file{dpkg} run is interrupted, the user can
  751. recover by rerunning @file{dpkg}, and/or by upgrading to a new version
  752. and then rerunning the failed operation.
  753. These scripts should avoid producing output which it is unnecessary
  754. for the user to see and should rely on @file{dpkg} to stave off boredom
  755. on the part of a user installing many packages. This means, amongst
  756. other things, using the @file{--quiet} option on @file{install-info}.
  757. Packages should try to minimise the amount of prompting they need to
  758. do, and they should ensure that the user will only every be asked each
  759. question once. This means that packages should try to use appropriate
  760. shared configuration files (such as @file{/etc/papersize} and
  761. @file{/etc/news/server}), rather than each prompting for their own list
  762. of required pieces of information.
  763. It also means that an upgrade should not ask the same questions
  764. again, unless the user has used @code{dpkg --purge} to remove the
  765. package's configuration. The answers to configuration questions should
  766. be stored in an appropriate place in @file{/etc} so that the user can
  767. modify them, and how this has been done should be documented.
  768. If a package has a vitally important piece of information to pass to
  769. the user (such as "don't run me as I am, you must edit the following
  770. configuration files first or you risk your system emitting
  771. badly-formatted messages"), it should display this in the
  772. @file{postinst} script and prompt the user to hit Return to acknowledge
  773. the message. Copyright messages do not count as vitally important (they
  774. belong in @file{/usr/doc/copyright}; neither do instructions on how to
  775. use a program (these should be in on line documentation, where all the
  776. users can see them).
  777. They should return a zero exit status for success, or a nonzero one
  778. for failure. Note that if a script is a @code{#!/bin/sh} script it
  779. should probably start with @code{set -e}, to avoid continuing after
  780. errors---see @file{bash}(1) for details. Perl scripts should check for
  781. errors when making calls such as @code{open}, @code{print},
  782. @code{close}, @code{rename} and @code{system}.
  783. If these scripts exist they should be left in the @file{DEBIAN}
  784. directory with execute permission enabled and should contain an
  785. appropriate @code{#!} line, such as @code{#!/bin/bash} for a
  786. @code{bash} script or @code{#!/bin/perl} for a Perl script (see
  787. above).
  788. @node Dependencies and Conflicts, Package Classification Fields, Installation and Removal Scripts, Control Files
  789. @unnumberedsec Conflicts, Depends, Suggests, Recommends and Provides
  790. The @file{Depends} field lists packages that are required for this
  791. package to provide a significant amount of functionality. The package
  792. maintenance software will not allow a package to be installed without
  793. also installing packages listed in its @code{Depends} field, and will
  794. run the @code{postinst} scripts of packages listed in @code{Depends}
  795. fields before those of the packages which depend on them, and run the
  796. @code{prerm} scripts before.
  797. Packages containing dynamically-linked executable binaries (this
  798. includes almost all C programs) should include a @file{Depends} field
  799. which mentions the shared C library required for the program to run.
  800. For a.out binaries linked against @file{libc.so.4} the relevant package
  801. name is @file{libc}; for ELF binaries linked against @file{libc.so.5}
  802. the relevant package name is @file{libc5}.
  803. The @code{Recommends} field lists packages that would be found
  804. together with this one in all but unusual installations. The user-level
  805. package maintenance program @file{dselect} will warn the user if they
  806. select a package without those listed in its @code{Recommends} field.
  807. Note that @code{Recommends} fields don't currently have any implications
  808. for the order in which the maintainer scripts are run.
  809. The @code{Suggests} field lists packages that are related to this one
  810. and can perhaps enhance its usefulness, but without which installing
  811. this package is perfectly reasonable. The package maintenance software
  812. will not moan at the user for not selecting @code{Suggests} related
  813. packages, but may use the information in the @code{Suggests} field to
  814. assist the user during package selection.
  815. The syntax of @code{Depends}, @code{Recommends} and @code{Suggests}
  816. is a list of groups of alternative packages. Each group is a list of
  817. packages separated by vertical bar (or `pipe') symbols, @code{|}. The
  818. groups are separated by commas. Each package is a package name
  819. optionally followed by a version number specification in parentheses. A
  820. version number may start with a @code{>=}, in which case that version or
  821. any later will match, or @code{<=} for that version or any earlier
  822. version. A version number starting with a @code{>>} or @code{<<} will
  823. respectively match any later or earlier version. If a version number or
  824. a version number starting with @code{=} is specified an exact match is
  825. required. Commas are to be read as `AND', and pipes as `OR', with pipes
  826. binding more tightly.
  827. Versions of dpkg before 1.0.9 used @code{<} and @code{>} for
  828. @code{<=} and @code{>=} (these are still supported for backward
  829. compatibility), and did not support @code{<<} and @code{>>}.
  830. The @code{Conflicts} field lists packages that conflict with this
  831. one, for example by containing files with the same names (an example
  832. would be Smail vs. Sendmail). The package maintenance software will not
  833. allow conflicting packages to be installed. Two conflicting packages
  834. should each include a @code{Conflicts} line mentioning the other.
  835. The syntax of @code{Conflicts} is a list of package names (with
  836. optional version numbers), separated by commas (and optional
  837. whitespace). In the @code{Conflicts} field the comma should be read as
  838. `OR'.
  839. The @code{Provides} field lists the names of any `virtual packages'
  840. of which this packages is to be considered an instantiation. Virtual
  841. packages are used to allow packages to refer to a service they require
  842. (such as the availability of @file{/usr/sbin/sendmail}) without having
  843. to know the names of all the relevant packages. The virtual package
  844. names defined in @code{Provides} fields may be used in other packages'
  845. @code{Depends}, @code{Recommends}, @code{Suggests} and @code{Conflicts}
  846. fields. For more information about how to use virtual packages and
  847. which virtual package names to use read @file{virtual-dependencies.txt}
  848. and @file{virtual-package-names-list.text}.
  849. The syntax of @code{Provides} is a list of package names separated by
  850. commas (and optional whitespace).
  851. @node Package Classification Fields, , Dependencies and Conflicts, Control Files
  852. @unnumberedsec Priority, Section and Essential
  853. The @code{Priority} and @code{Section} fields are used by
  854. @file{dselect} when displaying the list of packages to the user. There
  855. is no need to put them into a package, since these are usually set by
  856. the distribution maintainers in the @file{Packages} file.
  857. However, if a user installs a package which is not part of the
  858. standard distribution, or without downloading and updating from a new
  859. @file{Packages} file, the information about the priority and section of
  860. a package will be absent, and the @file{dselect} package listing will
  861. have the package listed under `unclassified'. It is permissible for a
  862. package to include @code{Section} or @code{Priority} fields to improve
  863. this; however, if you do this you should make sure you keep the
  864. information up to date so that users are not shown conflicting
  865. information. The @code{Section} field can also be used by the
  866. distribution maintainers as a suggestion about which section you think
  867. is most appropriate for your package.
  868. The @code{Essential} field should only appear in packages in the
  869. installation's base system. If it is set to @code{yes} then @file{dpkg}
  870. will not remove the package even if asked to, and will make certain
  871. minor modifications to its installation procedures. The only other
  872. legal value is @code{no}, which is equivalent to the absence of the
  873. field.
  874. @bye
  875. @c local variables:
  876. @c kept-new-versions: 100
  877. @c version-control: t
  878. @c end: