programmer.sgml 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352
  1. <!doctype debiandoc system [
  2. <!entity % manuals-version-def system "manuals-version">
  3. %manuals-version-def;
  4. ]>
  5. <!--
  6. Debian Linux dpkg package installation tool.
  7. programmers' manual.
  8. Copyright (C)1996 Ian Jackson; released under the terms of the GNU
  9. General Public License, version 2 or (at your option) any later.
  10. -->
  11. <book>
  12. <title><prgn/dpkg/ programmers' manual
  13. <author>Ian Jackson <email/ijackson@gnu.ai.mit.edu/
  14. <version>version &manuals-version; (dpkg &dpkg-version;), <date>
  15. <abstract>
  16. This manual describes the technical aspects of creating Debian binary
  17. and source packages. It also documents the interface between
  18. <prgn/dselect/ and its access method scripts. It does not deal with
  19. the Debian Project policy requirements, and it assumes familiarity
  20. with <prgn/dpkg/'s functions from the system administrator's
  21. perspective.
  22. <copyright>Copyright &copy;1996 Ian Jackson.
  23. <p>
  24. This manual is free software; you may redistribute it and/or modify it
  25. under the terms of the GNU General Public License as published by the
  26. Free Software Foundation; either version 2, or (at your option) any
  27. later version.
  28. <p>
  29. This is distributed in the hope that it will be useful, but
  30. <em>without any warranty</em>; without even the implied warranty of
  31. merchantability or fitness for a particular purpose. See the GNU
  32. General Public License for more details.
  33. <p>
  34. You should have received a copy of the GNU General Public License with
  35. your Debian GNU/Linux system, in <tt>/usr/doc/copyright/GPL</tt>, or
  36. with the <prgn/dpkg/ source package as the file <tt>COPYING</tt>. If
  37. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  38. Cambridge, MA 02139, USA.
  39. <toc sect>
  40. <!-- Describes the technical interface between a package and dpkg.
  41. How to safely put shared libraries in a package. Details of dpkg's
  42. handling of individual files. Sections on when to use which feature
  43. (eg Replaces vs. Replaces/Conflicts vs. update-alternatives
  44. vs. diversions) Cross-references to the policy document (see below)
  45. where appropriate. Description of the interface between dselect and
  46. its access methods. Hints on where to start with a new package (ie,
  47. the hello package). What to do about file aliasing.
  48. file aliasing
  49. Manpages are required for: update-rc.d, diversions,
  50. update-alternatives, install-info in a package.
  51. -->
  52. <chapt id="scope">Introduction and scope of this manual
  53. <p>
  54. <prgn/dpkg/ is a suite of programs for creating binary package files
  55. and installing and removing them on Unix systems.<footnote><prgn/dpkg/
  56. is targetted primarily at Debian GNU/Linux, but may work on or be
  57. ported to other systems.</footnote>
  58. <p>
  59. The binary packages are designed for the management of installed
  60. executable programs (usually compiled binaries) and their associated
  61. data, though source code examples and documentation are provided as
  62. part of some packages.
  63. <p>
  64. This manual describes the technical aspects of creating Debian binary
  65. packages (<tt/.deb/ files). It documents the behaviour of the
  66. package management programs <prgn/dpkg/, <prgn/dselect/ et al. and and the
  67. way they interact with packages.
  68. <p>
  69. It also documents the interaction between <prgn/dselect/'s core and the
  70. access method scripts it uses to actually install the selected
  71. packages, and describes how to create a new access method.
  72. <p>
  73. This manual does not go into detail about the options and usage of the
  74. package building and installation tools. It should therefore be read
  75. in conjuction with those programs' manpages.
  76. <p>
  77. The utility programs which are provided with <prgn/dpkg/ for managing
  78. various system configuration and similar issues, such as
  79. <prgn/update-rc.d/ and <prgn/install-info/, are not described in
  80. detail here - please see their manpages.
  81. <p>
  82. It does <em/not/ describe the policy requirements imposed on Debian
  83. packages, such as the permissions on files and directories,
  84. documentation requirements, upload procedure, and so on. You should
  85. see the Debian packaging policy manual for these details. (Many of
  86. them will probably turn out to be helpful even if you don't plan to
  87. upload your package and make it available as part of the
  88. distribution.)
  89. <p>
  90. It is assumed that the reader is reasonably familiar with the
  91. <prgn/dpkg/ System Administrators' manual. Unfortunately this manual
  92. does not yet exist.
  93. <p>
  94. The Debian version of the FSF's GNU hello program is provided as an
  95. example for people wishing to create Debian packages.
  96. <p>
  97. <em>Note that this document is still a draft!</em>
  98. <chapt id="binarypkg">Binary packages
  99. <p>
  100. The binary package has two main sections. The first part consists of
  101. various control information files and scripts used by <prgn/dpkg/ when
  102. installing and removing. See <ref id="controlarea">.
  103. <p>
  104. The second part is an archive (currently a <prgn/tar/ archive)
  105. containing files and directories to be installed.
  106. <p>
  107. In the future binary packages may also contain other components, such
  108. as checksums and digital signatures.
  109. <sect id="bincreating">Creating package files - <prgn/dpkg-deb/
  110. <p>
  111. All manipulation of binary package files is done by <prgn/dpkg-deb/;
  112. it's the only program that has knowledge of the format.
  113. (<prgn/dpkg-deb/ may be invoked by calling <prgn/dpkg/, as <prgn/dpkg/ will
  114. spot that the options requested are appropriate to <prgn/dpkg-deb/ and
  115. invoke that instead with the same arguments.)
  116. <p>
  117. In order to create a binary package you must make a directory tree
  118. which contains all the files and directories you want to have in the
  119. filesystem data part of the package. In Debian-format source packages
  120. this directory is usually <tt>debian/tmp</tt>, relative to the top of
  121. the package's source tree.
  122. <p>
  123. They should have the locations (relative to the root of the directory
  124. tree you're constructing) ownerships and permissions which you want
  125. them to have on the system when they are installed.
  126. <p>
  127. With current versions of <prgn/dpkg/ the uid/username and gid/groupname
  128. mappings for the users and groups being used should be the same on the
  129. system where the package is built and the one where it is installed.
  130. <p>
  131. You need to add one special directory to the root of the miniature
  132. filesystem tree you're creating: <prgn/DEBIAN/. It should contain the
  133. control information files, notably the binary package control file
  134. (see <ref id="controlfile">).
  135. <p>
  136. The <prgn/DEBIAN/ directory will not appear in the filesystem archive of
  137. the package, and so won't be installed by <prgn/dpkg/ when the package
  138. is installed.
  139. <p>
  140. When you've prepared the package, you should invoke:
  141. <example>
  142. dpkg --build <var/directory/
  143. </example>
  144. <p>
  145. This will build the package in <tt/<var/directory/.deb/.
  146. (<prgn/dpkg/ knows that <tt/--build/ is a <prgn/dpkg-deb/ option, so it
  147. invokes <prgn/dpkg-deb/ with the same arguments to build the package.)
  148. <p>
  149. See the manpage <manref name="dpkg-deb" section=8> for details of how
  150. to examine the contents of this newly-created file. You may find the
  151. output of following commands enlightening:
  152. <example>
  153. dpkg-deb --info <var/filename/.deb
  154. dpkg-deb --contents <var/filename/.deb
  155. </example>
  156. <sect id="controlarea">Package control information files
  157. <p>
  158. The control information portion of a binary package is a collection of
  159. files with names known to <prgn/dpkg/. It will treat the contents of
  160. these files specially - some of them contain information used by
  161. <prgn/dpkg/ when installing or removing the package; others are scripts
  162. which the package maintainer wants <prgn/dpkg/ to run.
  163. <p>
  164. It is possible to put other files in the package control area, but
  165. this is not generally a good idea (though they will largely be
  166. ignored).
  167. <p>
  168. Here is a brief list of the control info files supported by <prgn/dpkg/
  169. and a summary of what they're used for.
  170. <p>
  171. <taglist>
  172. <tag><tt/control/
  173. <item>
  174. This is the key description file used by <prgn/dpkg/. It specifies the
  175. package's name and version, gives its description for the user, states
  176. its relationships with other packages, and so forth.
  177. See <ref id="controlfile">.
  178. <p>
  179. It is usually generated automatically from information in the source
  180. package by the <prgn/dpkg-gencontrol/ program, and with assistance
  181. from <prgn/dpkg-shlibdeps/. See <ref id="sourcetools">.
  182. <tag><tt/postinst/, <tt/preinst/, <tt/postrm/, <tt/prerm/
  183. <item>
  184. These are exectuable files (usually scripts) which <prgn/dpkg/ runs
  185. during installation, upgrade and removal of packages. They allow the
  186. package to deal with matters which are particular to that package or
  187. require more complicated processing than that provided by <prgn/dpkg/.
  188. Details of when and how they are called are in
  189. <ref id="maintainerscripts">.
  190. <p>
  191. It is very important to make these scripts itempotent.<footnote>That
  192. means that if it runs successfully or fails and then you call it again
  193. it doesn't bomb out, but just ensures that everything is the way it
  194. ought to be.</footnote> This is so that if an error occurs, the user
  195. interrupts <prgn/dpkg/ or some other unforeseen circumstance happens you
  196. don't leave the user with a badly-broken package.
  197. <p>
  198. The maintainer scripts are guaranteed to run with a controlling
  199. terminal and can interact with the user. If they need to prompt for
  200. passwords, do full-screen interaction or something similar you should
  201. do these things to and from <tt>/dev/tty</>, since <prgn/dpkg/ will at
  202. some point redirect scripts' standard input and output so that it can
  203. log the installation process. Likewise, because these scripts may be
  204. executed with standard output redirected into a pipe for logging
  205. purposes, Perl scripts should set unbuffered output by setting
  206. <tt/$|=1/ so that the output is printed immediately rather than being
  207. buffered.
  208. <p>
  209. Each script should return a zero exit status for success, or a nonzero
  210. one for failure.
  211. <tag><tt/conffiles/
  212. <item>
  213. This file contains a list of configuration files which are to be
  214. handled automatically by <prgn/dpkg/ (see <ref id="conffiles">). Note
  215. that not necessarily every configuration file should be listed here.
  216. <tag><tt/shlibs/
  217. <item>
  218. This file contains a list of the shared libraries supplied by the
  219. package, with dependency details for each. This is used by
  220. <prgn/dpkg-shlibdeps/ when it determines what dependencies are
  221. required in a package control file.
  222. <p>
  223. Each line is of the form:
  224. <example>
  225. <var/library-name/ <var/version-or-soname/ <var/dependencies .../
  226. </example>
  227. <p>
  228. <var/library-name/ is the name of the shared library, for example
  229. <tt/libc5/.
  230. <p>
  231. <var/version-or-soname/ is the soname of the library - ie, the thing
  232. that must exactly match for the library to be recognised by
  233. <prgn/ld.so/. Usually this is major version number of the library.
  234. <p>
  235. <var/dependencies/ has the same syntax as a dependency field in a
  236. binary package control file. It should give details of which
  237. package(s) are required to satisfy a binary built against the version
  238. of the library contained in the package. See <ref id="depsyntax">.
  239. <p>
  240. For example, if the package <tt/foo/ contains <tt/libfoo.so.1.2.3/,
  241. where the soname of the library is <tt/libfoo.so.1/, and the first
  242. version of the package which contained a minor number of at least
  243. <tt/2.3/ was <var/1.2.3-1/, then the package's <var/shlibs/ could
  244. say:
  245. <example>
  246. libfoo 1 foo (>= 1.2.3-1)
  247. </example>
  248. <p>
  249. The version-specific dependency is to avoid warnings from <prgn/ld.so/
  250. about using older shared libraries with newer binaries.
  251. </taglist>
  252. <sect id="controlfile">The main control information file: <tt/control/
  253. <p>
  254. The most important control information file used by <prgn/dpkg/ when it
  255. installs a package is <tt/control/. It contains all the package's
  256. `vital statistics'.
  257. <p>
  258. The binary package control files of packages built from Debian sources
  259. are made by a special tool, <prgn/dpkg-gencontrol/, which reads
  260. <tt>debian/control</> and <tt>debian/changelog</> to find the
  261. information it needs. See <ref id="sourcepkg"> for more details.
  262. <p>
  263. The fields in binary package control files are:
  264. <list compact>
  265. <item><qref id="f-Package"><tt/Package/</> (mandatory)
  266. <item><qref id="versions"><tt/Version/</> (mandatory)
  267. <item><qref id="f-Architecture"><tt/Architecture/</>
  268. (mandatory)<footnote>This field should appear in all packages, though
  269. <prgn/dpkg/ doesn't require it yet so that old packages can still be
  270. installed.</footnote>
  271. <item><qref id="relationships"><tt/Depends/, <tt/Provides/ et al.</>
  272. <item><qref id="f-Essential"><tt/Essential/</>
  273. <item><qref id="f-Maintainer"><tt/Maintainer/</>
  274. <item><qref id="f-classification"><tt/Section/, <tt/Priority/</>
  275. <item><qref id="f-Source"><tt/Source/</>
  276. <item><qref id="descriptions"><tt/Description/</>
  277. <item><qref id="f-Installed-Size"><tt/Installed-Size/</>
  278. </list>
  279. <p>
  280. A description of the syntax of control files and the purpose of these
  281. fields is available in <ref id="controlfields">.
  282. <chapt id="sourcepkg">Source packages
  283. <p>
  284. The Debian binary packages in the distribution are generated from
  285. Debian sources, which are in a special format to assist the easy and
  286. automatic building of binaries.
  287. <sect id="sourcetools">Tools for processing source packages
  288. <p>
  289. Various tools are provided for manipulating source packages; they pack
  290. and unpack sources and help build of binary packages and help manage
  291. the distribution of new versions.
  292. <p>
  293. They are introduced and typical uses described here; see <manref
  294. name=dpkg-source section=1> for full documentation about their
  295. arguments and operation.
  296. <p>
  297. For examples of how to construct a Debian source package, and how to
  298. use those utilities that are used by Debian source packages, please
  299. see the <prgn/hello/ example package.
  300. <sect1><prgn/dpkg-source/ - packs and unpacks Debian source packages
  301. <p>
  302. This program is frequently used by hand, and is also called from
  303. package-independent automated building scripts such as
  304. <prgn/dpkg-buildpackage/.
  305. <p>
  306. To unpack a package it is typically invoked with
  307. <example>
  308. dpkg-source -x <var>.../path/to/filename</>.dsc
  309. </example>
  310. with the <tt/<var/filename/.tar.gz/ and
  311. <tt/<var/filename/.diff.gz/ (if applicable) in the same directory. It
  312. unpacks into <tt/<var/package/-<var/version//, and if applicable
  313. <tt/<var/package/-<var/version/.orig/, in the current directory.
  314. <p>
  315. To create a packed source archive it is typically invoked:
  316. <example>
  317. dpkg-source -b <var/package/-<var/version/
  318. </example>
  319. This will create the <tt/.dsc/, <tt/.tar.gz/ and <tt/.diff.gz/ (if
  320. appropriate) in the current directory. <prgn/dpkg-source/ does not
  321. clean the source tree first - this must be done separately if it is
  322. required.
  323. <p>
  324. See also <ref id="sourcearchives">.
  325. <sect1><prgn/dpkg-buildpackage/ - overall package-building control
  326. script
  327. <p>
  328. <prgn/dpkg-buildpackage/ is a script which invokes <prgn/dpkg-source/,
  329. the <tt>debian/rules</> targets <prgn/clean/, <prgn/build/ and
  330. <prgn/binary/, <prgn/dpkg-genchanges/ and <prgn/pgp/ to build a signed
  331. source and binary package upload.
  332. <p>
  333. It is usually invoked by hand from the top level of the built or
  334. unbuilt source directory. It may be invoked with no arguments; useful
  335. arguments include:
  336. <taglist compact>
  337. <tag><tt/-uc/, <tt/-us/
  338. <item>Do not PGP-sign the <tt/.changes/ file or the source package
  339. <tt/.dsc/ file, respectively.
  340. <tag><tt/-p<var/pgp-command//
  341. <item>Invoke <var/pgp-command/ instead of finding <tt/pgp/ on the
  342. <prgn/PATH/. <var/pgp-command/ must behave just like <prgn/pgp/.
  343. <tag><tt/-r<var/root-command//
  344. <item>When root privilege is required, invoke the command
  345. <var/root-command/. <var/root-command/ should invoke its first
  346. argument as a command, from the <prgn/PATH/ if necessary, and pass its
  347. second and subsequent arguments to the command it calls. If no
  348. <var/root-command/ is supplied then <var/dpkg-buildpackage/ will take
  349. no special action to gain root privilege, so that for most packages it
  350. will have to be invoked as root to start with.
  351. <tag><tt/-b/, <tt/-B/
  352. <item>Two types of binary-only build and upload - see <manref
  353. name=dpkg-source section=1>.
  354. </taglist>
  355. <sect1><prgn/dpkg-gencontrol/ - generates binary package control files
  356. <p>
  357. This program is usually called from <tt>debian/rules</> (see <ref
  358. id="sourcetree">) in the top level of the source tree.
  359. <p>
  360. This is usually done just before the files and directories in the
  361. temporary directory tree where the package is being built have their
  362. permissions and ownerships set and the package is constructed using
  363. <prgn/dpkg-deb/<footnote>This is so that the control file which is
  364. produced has the right permissions</footnote>.
  365. <p>
  366. <prgn/dpkg-gencontrol/ must be called after all the files which are to
  367. go into the package have been placed in the temporary build directory,
  368. so that its calculation of the installed size of a package is correct.
  369. <p>
  370. It is also necessary for <prgn/dpkg-gencontrol/ to be run after
  371. <prgn/dpkg-shlibdeps/ so that the variable substitutions created by
  372. <prgn/dpkg-shlibdeps/ in <tt>debian/substvars</> are available.
  373. <p>
  374. For a package which generates only one binary package, and which
  375. builds it in <tt>debian/tmp</> relative to the top of the source
  376. package, it is usually sufficient to call:
  377. <example>
  378. dpkg-gencontrol
  379. </example>
  380. <p>
  381. Sources which build several binaries will typically need something
  382. like:
  383. <example>
  384. dpkg-gencontrol -Pdebian/tmp-<var/pkg/ -p<var/package/
  385. </example>
  386. The <tt/-P/ tells <prgn/dpkg-gencontrol/ that the package is being
  387. built in a non-default directory, and the <tt/-p/ tells it which
  388. package's control file should be generated.
  389. <p>
  390. <prgn/dpkg-gencontrol/ also adds information to the list of files in
  391. <tt>debian/files</>, for the benefit of (for example) a future
  392. invocation of <prgn/dpkg-genchanges/.
  393. <sect1><prgn/dpkg-shlibdeps/ - calculates shared library dependencies
  394. <p>
  395. This program is usually called from <tt>debian/rules</> just before
  396. <prgn/dpkg-gencontrol/ (see <ref id="sourcetree">), in the top level
  397. of the source tree.
  398. <p>
  399. Its arguments are executables<footnote>They may be specified either
  400. in the locations in the source tree where they are created or in the
  401. locations in the temporary build tree where they are installed prior
  402. to binary package creation.</footnote> for which shared library
  403. dependencies should be included in the binary package's control file.
  404. <p>
  405. If some of the executable(s) shared libraries should only warrant a
  406. <tt/Recommends/ or <tt/Suggests/, or if some warrant a
  407. <tt/Pre-Depends/, this can be achieved by using the
  408. <tt/-d<var/dependency-field// option before those executable(s).
  409. (Each <tt/-d/ option takes effect until the next <tt/-d/.)
  410. <p>
  411. <prgn/dpkg-shlibdeps/ does not directly cause the output control file
  412. to be modified. Instead by default it adds to the
  413. <tt>debian/substvars</> file variable settings like
  414. <tt/shlibs:Depends/. These variable settings must be referenced in
  415. dependency fields in the appropriate per-binary-package sections of
  416. the source control file.
  417. <p>
  418. For example, the <prgn/procps/ package generates two kinds of
  419. binaries, simple C binaries like <prgn/ps/ which require a
  420. predependency and full-screen ncurses binaries like <prgn/top/ which
  421. require only a recommendation. It can say in its <tt>debian/rules</>:
  422. <example>
  423. dpkg-shlibdeps -dPre-Depends ps -dRecommends top
  424. </example>
  425. and then in its main control file <tt>debian/control</>:
  426. <example>
  427. <var/.../
  428. Package: procps
  429. Pre-Depends: ${shlibs:Pre-Depends}
  430. Recommends: ${shlibs:Recommends}
  431. <var/.../
  432. </example>
  433. <p>
  434. Sources which produce several binary packages with different shared
  435. library dependency requirements can use the <tt/-p<var/varnameprefix//
  436. option to override the default <tt/shlib:/ prefix (one invocation of
  437. <prgn/dpkg-shlibdeps/ per setting of this option). They can thus
  438. produce several sets of dependency variables, each of the form
  439. <tt/<var/varnameprefix/:<var/dependencyfield//, which can be referred
  440. to in the appropriate parts of the binary package control files.
  441. <sect1><prgn/dpkg-distaddfile/ - adds a file to <tt>debian/files</>
  442. <p>
  443. Some packages' uploads need to include files other than the source and
  444. binary package files.
  445. <p>
  446. <prgn/dpkg-distaddfile/ adds a file to the <tt>debian/files</> file so
  447. that it will be included in the <tt/.changes/ file when
  448. <prgn/dpkg-genchanges/ is run.
  449. <p>
  450. It is usually invoked from the <prgn/binary/ target of
  451. <tt>debian/rules</>:
  452. <example>
  453. dpkg-distaddfile <var/filename/ <var/section/ <var/priority/
  454. </example>
  455. The <var/filename/ is relative to the directory where
  456. <prgn/dpkg-genchanges/ will expect to find it - this is usually the
  457. directory above the top level of the source tree. The
  458. <tt>debian/rules</> target should put the file there just before or
  459. just after calling <prgn/dpkg-distaddfile/.
  460. <p>
  461. The <var/section/ and <var/priority/ are passed unchanged into the
  462. resulting <tt/.changes/ file. See <ref id="f-classification">.
  463. <sect1><prgn/dpkg-genchanges/ - generates a <tt/.changes/ upload
  464. control file
  465. <p>
  466. This program is usually called by package-independent automatic
  467. building scripts such as <prgn/dpkg-buildpackage/, but it may also be
  468. called by hand.
  469. <p>
  470. It is usually called in the top level of a built source tree, and when
  471. invoked with no arguments will print out a straightforward
  472. <tt/.changes/ file based on the information in the source package's
  473. changelog and control file and the binary and source packages which
  474. should have been built.
  475. <sect1><prgn/dpkg-parsechangelog/ - produces parsed representation of
  476. a changelog
  477. <p>
  478. This program is used internally by <prgn/dpkg-source/ et al. It may
  479. also occasionally be useful in <tt>debian/rules</> and elsewhere. It
  480. parses a changelog, <tt>debian/changelog</> by default, and prints a
  481. control-file format representation of the information in it to
  482. standard output.
  483. <sect id="sourcetree">The Debianised source tree
  484. <p>
  485. The source archive scheme described later is intended to allow a
  486. Debianised source tree with some associated control information to be
  487. reproduced and transported easily. The Debianised source tree is a
  488. version of the original program with certain files added for the
  489. benefit of the Debianisation process, and with any other changes
  490. required made to the rest of the source code and installation scripts.
  491. <p>
  492. The extra files created for Debian are in the subdirectory <tt/debian/
  493. of the top level of the Debianised source tree. They are described
  494. below.
  495. <sect1><tt>debian/rules</tt> - the main building script
  496. <p>
  497. This file is an executable makefile, and contains the package-specific
  498. recipies for compiling the package and building binary package(s) out
  499. of the source.
  500. <p>
  501. It must start with the line <tt>#!/usr/bin/make -f</tt>, so that it
  502. can be invoked by saying its name rather than invoking <prgn/make/
  503. explicitly.
  504. <p>
  505. The targets which are required to be present are:
  506. <taglist>
  507. <tag/<tt/build//
  508. <item>
  509. This should perform all non-interactive configuration and compilation
  510. of the package. If a package has an interactive pre-build
  511. configuration routine, the Debianised source package should be built
  512. after this has taken place, so that it can be built without rerunning
  513. the configuration.
  514. <p>
  515. For some packages, notably ones where the same source tree is compiled
  516. in different ways to produce two binary packages, the <prgn/build/
  517. target does not make much sense. For these packages it is good enough
  518. to provide two (or more) targets (<tt/build-a/ and <tt/build-b/ or
  519. whatever) for each of the ways of building the package, and a
  520. <prgn/build/ target that does nothing. The <prgn/binary/ target will have
  521. to build the package in each of the possible ways and make the binary
  522. package out of each.
  523. <p>
  524. The <prgn/build/ target must not do anything that might require root
  525. privilege.
  526. <p>
  527. The <prgn/build/ target may need to run <prgn/clean/ first - see below.
  528. <p>
  529. When a package has a configuration routine that takes a long time, or
  530. when the makefiles are poorly designed, or when <prgn/build/ needs to
  531. run <prgn/clean/ first, it is a good idea to <tt/touch build/ when the
  532. build process is complete. This will ensure that if <tt>debian/rules
  533. build</tt> is run again it will not rebuild the whole program.
  534. <tag/<tt/binary/, <tt/binary-arch/, <tt/binary-indep/
  535. <item>
  536. The <prgn/binary/ target should be all that is necessary for the user
  537. to build the binary package. It is split into two parts:
  538. <prgn/binary-arch/ builds the packages' output files which are
  539. specific to a particular architecture, and <prgn/binary-indep/
  540. builds those which are not.
  541. <p>
  542. <prgn/binary/ should usually be a target with no commands which simply
  543. depends on <prgn/binary-arch/ and <prgn/binary-indep/.
  544. <p>
  545. Both <prgn/binary-*/ targets should depend on the <prgn/build/ target,
  546. above, so that the package is built if it has not been already. It
  547. should then create the relevant binary package(s), using
  548. <prgn/dpkg-gencontrol/ to make their control files and <prgn/dpkg-deb/
  549. to build them and place them in the parent of the top level directory.
  550. <p>
  551. If one of the <prgn/binary-*/ targets has nothing to do (this will be
  552. always be the case if the source generates only a single binary
  553. package, whether architecture-dependent or not) it <em/must/ still
  554. exist, but should always succeed.
  555. <p>
  556. <ref id="binarypkg"> describes how to construct binary packages.
  557. <p>
  558. The <prgn/binary/ targets must be invoked as root.
  559. <tag/<tt/clean//
  560. <item>
  561. This should undo any effects that the <prgn/build/ and <prgn/binary/
  562. targets may have had, except that it should leave alone any output
  563. files created in the parent directory by a run of <prgn/binary/.
  564. <p>
  565. If a <prgn/build/ file is touched at the end of the <prgn/build/ target,
  566. as suggested above, it must be removed as the first thing that
  567. <prgn/clean/ does, so that running <prgn/build/ again after an interrupted
  568. <prgn/clean/ doesn't think that everything is already done.
  569. <p>
  570. The <prgn/clean/ target must be invoked as root if <prgn/binary/ has
  571. been invoked since the last <prgn/clean/, or if <prgn/build/ has been
  572. invoked as root (since <prgn/build/ may create directories, for
  573. example).
  574. <tag/<tt/get-orig-source//
  575. <item>
  576. This target fetches the most recent version of the original source
  577. package from a canonical archive site (via FTP or WWW, for example),
  578. does any necessary rearrangement to turn it into the original source
  579. tarfile format described below, and leaves it in the current directory.
  580. <p>
  581. This target may be invoked in any directory, and should take care to
  582. clean up any temporary files it may have left.
  583. <p>
  584. This target is optional, but providing it if possible is a good idea.
  585. </taglist>
  586. The <prgn/build/, <prgn/binary/ and <prgn/clean/ targets must be
  587. invoked with a current directory of the package's top-level
  588. directory.
  589. <p>
  590. Additional targets may exist in <tt>debian/rules</tt>, either as
  591. published or undocumented interfaces or for the package's internal
  592. use.
  593. <sect1><tt>debian/control</tt>
  594. <p>
  595. This file contains version-independent details about the source
  596. package and about the binary packages it creates.
  597. <p>
  598. It is a series of sets of control fields, each syntactically similar
  599. to a binary package control file. The sets are separated by one or
  600. more blank lines. The first set is information about the source
  601. package in general; each subsequent set describes one binary package
  602. that the source tree builds.
  603. <p>
  604. The syntax and semantics of the fields are described below in
  605. <ref id="controlfields">.
  606. <p>
  607. The general (binary-package-independent) fields are:
  608. <list compact>
  609. <item><qref id="f-Source"><tt/Source/</> (mandatory)
  610. <item><qref id="f-Maintainer"><tt/Maintainer/</>
  611. <item><qref id="f-classification"><tt/Section/ and <tt/Priority/</>
  612. (classification, mandatory)
  613. <item><qref id="f-Standards-Version"><tt/Standards-Version/</>
  614. </list>
  615. <p>
  616. The per-binary-package fields are:
  617. <list compact>
  618. <item><qref id="f-Package"><tt/Package/</> (mandatory)
  619. <item><qref id="f-Architecture"><tt/Architecture/</> (mandatory)
  620. <item><qref id="descriptions"><tt/Description/</>
  621. <item><qref id="f-classification"><tt/Section/ and <tt/Priority/</> (classification)
  622. <item><qref id="f-Essential"><tt/Essential/</>
  623. <item><qref id="relationships"><tt/Depends/ et al.</> (package interrelationships)
  624. </list>
  625. <p>
  626. These fields are used by <prgn/dpkg-gencontrol/ to generate control
  627. files for binary packages (see below), by <prgn/dpkg-genchanges/ to
  628. generate the <tt/.changes/ file to accompany the upload, and by
  629. <prgn/dpkg-source/ when it creates the <tt/.dsc/ source control file as
  630. part of a source archive.
  631. <p>
  632. The fields here may contain variable references - their values will be
  633. substituted by <prgn/dpkg-gencontrol/, <prgn/dpkg-genchanges/ or
  634. <prgn/dpkg-source/ when they generate output control files. See <ref
  635. id="srcsubstvars"> for details.
  636. <p>
  637. <sect2>User-defined fields
  638. <p>
  639. Additional user-defined fields may be added to the source package
  640. control file. Such fields will be ignored, and not copied to (for
  641. example) binary or source package control files or upload control
  642. files.
  643. <p>
  644. If you wish to add additional unsupported fields to these output files
  645. you should use the mechanism described here.
  646. <p>
  647. Fields in the main source control information file with names starting
  648. <tt/X/, followed by one or more of the letters <tt/BCS/ and a hyphen
  649. <tt/-/, will be copied to the output files. Only the part of the
  650. field name after the hyphen will be used in the output file. Where
  651. the letter <tt/B/ is used the field will appear in binary package
  652. control files, where the letter <tt/S/ is used in source package
  653. control files and where <tt/C/ is used in upload control
  654. (<tt/.changes/) files.
  655. <p>
  656. For example, if the main source information control file contains the
  657. field
  658. <example>
  659. XBS-Comment: I stand between the candle and the star.
  660. </example>
  661. then the binary and source package control files will contain the
  662. field
  663. <example>
  664. Comment: I stand between the candle and the star.
  665. </example>
  666. <sect1 id="dpkgchangelog"><tt>debian/changelog</>
  667. <p>
  668. This file records the changes to the Debian-specific parts of the
  669. package<footnote>Though there is nothing stopping an author who is
  670. also the Debian maintainer from using it for all their changes, it
  671. will have to be renamed if the Debian and upstream maintainers become
  672. different people.</footnote>.
  673. <p>
  674. It has a special format which allows the package building tools to
  675. discover which version of the package is being built and find out
  676. other release-specific information.
  677. <p>
  678. That format is a series of entries like this:
  679. <example>
  680. <var/package/ (<var/version/) <var/distribution(s)/; urgency=<var/urgency/
  681. * <var/change details/
  682. <var/more change details/
  683. * <var/even more change details/
  684. -- <var/maintainer name and email address/ <var/date/
  685. </example>
  686. <p>
  687. <var/package/ and <var/version/ are the source package name and
  688. version number. <var/distribution(s)/ lists the distributions where
  689. this version should be installed when it is uploaded - it is copied to
  690. the <tt/Distribution/ field in the <tt/.changes/ file. See <ref
  691. id="f-Distribution">.
  692. <p>
  693. <var/urgency/ is the value for the <tt/Urgency/ field in the
  694. <tt/.changes/ file for the upload. See <ref id="f-Urgency">. It is
  695. not possible to specify an urgency containing commas; commas are used
  696. to separate <tt/<var/keyword/=<var/value// settings in the <prgn/dpkg/
  697. changelog format (though there is currently only one useful
  698. <var/keyword/, <tt/urgency/).
  699. <p>
  700. The change details may in fact be any series of lines starting with at
  701. least two spaces, but conventionally each change starts with an
  702. asterisk and a separating space and continuation lines are indented so
  703. as to bring them in line with the start of the text above. Blank
  704. lines may be used here to separate groups of changes, if desired.
  705. <p>
  706. The maintainer name and email address should <em/not/ necessarily be
  707. those of the usual package maintainer. They should be the details of
  708. the person doing <em/this/ version. The information here will be
  709. copied to the <tt/.changes/ file, and then later used to send an
  710. acknowledgement when the upload has been installed.
  711. <p>
  712. The <var/date/ should be in RFC822 format<footnote>This is generated
  713. by the <prgn/822-date/ program.</footnote>; it should include the
  714. timezone specified numerically, with the timezone name or abbreviation
  715. optionally present as a comment.
  716. <p>
  717. The first `title' line with the package name should start at the left
  718. hand margin; the `trailer' line with the maintainer and date details
  719. should be preceded by exactly one space. The maintainer details and
  720. the date must be separated by exactly two spaces.
  721. <p>
  722. An Emacs mode for editing this format is available: it is called
  723. <tt/debian-changelog-mode/. You can have this mode selected
  724. automatically when you edit a Debian changelog by adding a local
  725. variables clause to the end of the changelog.
  726. <sect2>Defining alternative changelog formats
  727. <p>
  728. It is possible to use a different format to the standard one, by
  729. providing a parser for the format you wish to use.
  730. <p>
  731. In order to have <tt/dpkg-parsechangelog/ run your parser, you must
  732. include a line within the last 40 lines of your file matching the Perl
  733. regular expression:
  734. <tt>\schangelog-format:\s+([0-9a-z]+)\W</tt>
  735. The part in parentheses should be the name of the format. For
  736. example, you might say:
  737. <example>
  738. @@@ changelog-format: joebloggs @@@
  739. </example>
  740. Changelog format names are non-empty strings of alphanumerics.
  741. <p>
  742. If such a line exists then <tt/dpkg-parsechangelog/ will look for the
  743. parser as <tt>/usr/lib/dpkg/parsechangelog/<var/format-name/</> or
  744. <tt>/usr/local/lib/dpkg/parsechangelog/<var/format-name/</>; it is an
  745. error for it not to find it, or for it not to be an executable
  746. program. The default changelog format is <tt/dpkg/, and a parser for
  747. it is provided with the <tt/dpkg/ package.
  748. <p>
  749. The parser will be invoked with the changelog open on standard input
  750. at the start of the file. It should read the file (it may seek if it
  751. wishes) to determine the information required and return the parsed
  752. information to standard output in the form of a series of control
  753. fields in the standard format. By default it should return
  754. information about only the most recent version in the changelog; it
  755. should accept a <tt/-v<var/version// option to return changes
  756. information from all versions present <em/strictly after/
  757. <var/version/, and it should then be an error for <var/version/ not to
  758. be present in the changelog.
  759. <p>
  760. The fields are:
  761. <list compact>
  762. <item><qref id="f-Source"><tt/Source/</>
  763. <item><qref id="versions"><tt/Version/</> (mandatory)
  764. <item><qref id="f-Distribution"><tt/Distribution/</> (mandatory)
  765. <item><qref id="f-Urgency"><tt/Urgency/</> (mandatory)
  766. <item><qref id="f-Maintainer"><tt/Maintainer/</> (mandatory)
  767. <item><qref id="f-Date"><tt/Date/</>
  768. <item><qref id="f-Changes"><tt/Changes/</> (mandatory)
  769. </list>
  770. <p>
  771. If several versions are being returned (due to the use of <tt/-v/),
  772. the urgency value should be of the highest urgency code listed at the
  773. start of any of the versions requested followed by the concatenated
  774. (space-separated) comments from all the versions requested; the
  775. maintainer, version, distribution and date should always be from the
  776. most recent version.
  777. <p>
  778. For the format of the <tt/Changes/ field see <ref id="f-Changes">.
  779. <p>
  780. If the changelog format which is being parsed always or almost always
  781. leaves a blank line between individual change notes these blank lines
  782. should be stripped out, so as to make the resulting output compact.
  783. <p>
  784. If the changelog format does not contain date or package name
  785. information this information should be omitted from the output. The
  786. parser should not attempt to synthesise it or find it from other
  787. sources.
  788. <p>
  789. If the changelog does not have the expected format the parser should
  790. exit with a nonzero exit status, rather than trying to muddle through
  791. and possibly generating incorrect output.
  792. <p>
  793. A changelog parser may not interact with the user at all.
  794. <sect1 id="srcsubstvars"><tt>debian/substvars</> and variable substitutions
  795. <p>
  796. When <prgn/dpkg-gencontrol/, <prgn/dpkg-genchanges/ and
  797. <prgn/dpkg-source/ generate control files they do variable
  798. substitutions on their output just before writing it. Variable
  799. substitutions have the form <tt/${<var/variable-name/}/. The optional
  800. file <tt>debian/substvars</> contains variable substitutions to be
  801. used; variables can also be set directly from <tt>debian/rules</>
  802. using the <tt/-V/ option to the source packaging commands, and certain
  803. predefined variables are available.
  804. <p>
  805. The file may be a static part of the source archive, or generated and
  806. modified dynamically by <tt>debian/rules</> targets. In the latter
  807. case it must be removed by the <prgn/clean/ target.
  808. <p>
  809. See <manref name=dpkg-source section=1> for full details about source
  810. variable substitutions, including the format of
  811. <tt>debian/substvars</>.
  812. <sect1><tt>debian/files</>
  813. <p>
  814. This file is not a permanent part of the source tree; it is used while
  815. building packages to record which files are being generated.
  816. <prgn/dpkg-genchanges/ uses it when it generates a <tt/.changes/ file.
  817. <p>
  818. It should not exist in a shipped source package, and so it (and any
  819. backup files or temporary files such as
  820. <tt/files.new/<footnote><tt/files.new/ is used as a temporary file by
  821. <prgn/dpkg-gencontrol/ and <prgn/dpkg-distaddfile/ - they write a new
  822. version of <tt/files/ here before renaming it, to avoid leaving a
  823. corrupted copy if an error occurs</footnote>) should be removed by the
  824. <prgn/clean/ target. It may also be wise to ensure a fresh start by
  825. emptying or removing it at the start of the <prgn/binary/ target.
  826. <p>
  827. <prgn/dpkg-gencontrol/ adds an entry to this file for the <tt/.deb/
  828. file that will be created by <prgn/dpkg-deb/ from the control file
  829. that it generates, so for most packages all that needs to be done with
  830. this file is to delete it in <prgn/clean/.
  831. <p>
  832. If a package upload includes files besides the source package and any
  833. binary packages whose control files were made with
  834. <prgn/dpkg-gencontrol/ then they should be placed in the parent of the
  835. package's top-level directory and <prgn/dpkg-distaddfile/ should be
  836. called to add the file to the list in <tt>debian/files</>.
  837. <sect1><tt>debian/tmp</>
  838. <p>
  839. This is the canonical temporary location for the construction of
  840. binary packages by the <prgn/binary/ target. The directory <tt/tmp/
  841. serves as the root of the filesystem tree as it is being constructed
  842. (for example, by using the package's upstream makefiles install
  843. targets and redirecting the output there), and it also contains the
  844. <tt/DEBIAN/ subdirectory. See <ref id="bincreating">.
  845. <p>
  846. If several binary packages are generated from the same source tree it
  847. is usual to use several <tt>debian/tmp<var/something/</> directories,
  848. for example <tt/tmp-a/ or <tt/tmp-doc/.
  849. <p>
  850. Whatever <tt>tmp</> directories are created and used by <prgn/binary/
  851. must of course be removed by the <prgn/clean/ target.
  852. <sect id="sourcearchives">Source packages as archives
  853. <p>
  854. As it exists on the FTP site, a Debian source package consists of
  855. three related files. You must have the right versions of all three to
  856. be able to use them.
  857. <p>
  858. <taglist>
  859. <tag/Debian source control file - <tt/.dsc//
  860. <item>
  861. This file contains a series of fields, identified and separated just
  862. like the fields in the control file of a binary package. The fields
  863. are listed below; their syntax is described above, in
  864. <ref id="controlfields">.
  865. <list compact>
  866. <item><qref id="f-Source"><tt/Source/</>
  867. <item><qref id="versions"><tt/Version/</>
  868. <item><qref id="f-Maintainer"><tt/Maintainer/</>
  869. <item><qref id="f-Binary"><tt/Binary/</>
  870. <item><qref id="f-Architecture"><tt/Architecture/</>
  871. <item><qref id="f-Standards-Version"><tt/Standards-Version/</>
  872. <item><qref id="f-Files"><tt/Files/</>
  873. </list>
  874. <p>
  875. The source package control file is generated by <prgn/dpkg-source/
  876. when it builds the source archive, from other files in the source
  877. package, described above. When unpacking it is checked against the
  878. files and directories in the other parts of the source package, as
  879. described below.
  880. <tag/Original source archive - <tt/<var/package/_<var/upstream-version/.orig.tar.gz//
  881. <item>
  882. This is a compressed (with <tt/gzip -9/) <prgn/tar/ file containing
  883. the source code from the upstream authors of the program. The tarfile
  884. unpacks into a directory
  885. <tt/<var/package/-<var/upstream-version/.orig/, and does not contain
  886. files anywhere other than in there or in its subdirectories.
  887. <tag/Debianisation diff - <tt/<var/package/_<var/version-revision/.diff.gz//
  888. <item>
  889. This is a unified context diff (<tt/diff -u/) giving the changes which
  890. are required to turn the original source into the Debian source.
  891. These changes may only include editing and creating plain files. The
  892. permissions of files, the targets of symbolic links and the
  893. characteristics of special files or pipes may not be changed and no
  894. files may be removed or renamed.
  895. <p>
  896. All the directories in the diff must exist, except the <tt/debian/
  897. subdirectory of the top of the source tree, which will be created by
  898. <prgn/dpkg-source/ if necessary when unpacking.
  899. <p>
  900. The <prgn/dpkg-source/ program will automatically make the
  901. <tt>debian/rules</tt> file executable (see below).
  902. </taglist>
  903. <p>
  904. If there is no original source code - for example, if the package is
  905. specially prepared for Debian or the Debian maintainer is the same as
  906. the upstream maintainer - the format is slightly different: then there
  907. is no diff, and the tarfile is named
  908. <tt/<var/package/_<var/version/.tar.gz</> and contains a directory
  909. <tt/<var/package/-<var/version/</>.
  910. <sect>Unpacking a Debian source package without <prgn/dpkg-source/
  911. <p>
  912. <tt/dpkg-source -x/ is the recommended way to unpack a Debian source
  913. package. However, if it is not available it is possible to unpack a
  914. Debian source archive as follows:
  915. <enumlist compact>
  916. <item>Untar the tarfile, which will create a <tt/.orig/ directory.
  917. <item>Rename the <tt/.orig/ directory to
  918. <tt/<var/package/-<var/version//.
  919. <item>Create the subdirectory <tt/debian/ at the top of the source
  920. tree.
  921. <item>Apply the diff using <tt/patch -p0/.
  922. <item>Untar the tarfile again if you want a copy of the original
  923. source code alongside the Debianised version.
  924. </enumlist>
  925. <p>
  926. It is not possible to generate a valid Debian source archive without
  927. using <prgn/dpkg-source/. In particular, attempting to use
  928. <prgn/diff/ directly to generate the <tt/.diff.gz/ file will not work.
  929. <sect1>Restrictions on objects in source packages
  930. <p>
  931. The source package may not contain any device special files, sockets
  932. or setuid or setgid files.<footnote>Setgid directories are
  933. allowed.</footnote>
  934. <p>
  935. The source packaging tools manage the changes between the original and
  936. Debianised source using <prgn/diff/ and <prgn/patch/. Turning the
  937. original source tree as included in the <tt/.orig.tar.gz/ into the
  938. debianised source must not involve any changes which cannot be handled
  939. by these tools. Problematic changes which cause <prgn/dpkg-source/ to
  940. halt with an error when building the source package are:
  941. <list compact>
  942. <item>Adding or removing symbolic links, sockets or pipes.
  943. <item>Changing the targets of symbolic links.
  944. <item>Creating directories, other than <tt/debian/.
  945. <item>Changes to the contents of binary files.
  946. </list>
  947. Changes which cause <prgn/dpkg-source/ to print a warning but continue
  948. anyway are:
  949. <list compact>
  950. <item>Removing files, directories or symlinks. <footnote>Renaming a
  951. file is not treated specially - it is seen as the removal of the old
  952. file (which generates a warning, but is otherwise ignored), and the
  953. creation of the new one.</footnote>
  954. <item>Changed text files which are missing the usual final newline
  955. (either in the original or the modified source tree).
  956. </list>
  957. Changes which are not represented, but which are not detected by
  958. <prgn/dpkg-source/, are:
  959. <list compact>
  960. <item>Changing the permissions of files (other than
  961. <tt>debian/rules</>) and directories.
  962. </list>
  963. <p>
  964. The <tt/debian/ directory and <tt>debian/rules</> are handled
  965. specially by <prgn/dpkg-source/ - before applying the changes it will
  966. create the <tt/debian/ directory, and afterwards it will make
  967. <tt>debian/rules</> world-exectuable.
  968. <chapt id="controlfields">Control files and their fields
  969. <p>
  970. Many of the tools in the <prgn/dpkg/ suite manipulate data in a common
  971. format, known as control files. Binary and source packages have
  972. control data as do the <tt/.changes/ files which control the
  973. installation of uploaded files, and <prgn/dpkg/'s internal databases
  974. are in a similar format.
  975. <sect>Syntax of control files
  976. <p>
  977. A file consists of one or more paragraphs of fields. The paragraphs
  978. are separated by blank lines. Some control files only allow one
  979. paragraph; others allow several, in which case each paragraph often
  980. refers to a different package.
  981. <p>
  982. Each paragraph is a series of fields and values; each field consists
  983. of a name, followed by a colon and the value. It ends at the end of
  984. the line. Horizontal whitespace (spaces and tabs) may occur before or
  985. after the value and is ignored there; it is conventional to put a
  986. single space after the colon.
  987. <p>
  988. Some fields' values may span several lines; in this case each
  989. continuation line <em/must/ start with a space or tab. Any trailing
  990. spaces or tabs at the end of individual lines of a field value are
  991. ignored.
  992. <p>
  993. Except where otherwise stated only a single line of data is allowed
  994. and whitespace is not significant in a field body. Whitespace may
  995. never appear inside names (of packages, architectures, files or
  996. anything else), version numbers or in between the characters of
  997. multi-character version relationships.
  998. <p>
  999. Field names are not case-sensitive, but it is usual to capitalise the
  1000. fields using mixed case as shown below.
  1001. <p>
  1002. Blank lines, or lines consisting only of spaces and tabs, are not
  1003. allowed within field values or between fields - that would mean a new
  1004. paragraph.
  1005. <p>
  1006. It is important to note that there are several fields which are
  1007. optional as far as <prgn/dpkg/ and the related tools are concerned,
  1008. but which must appear in every Debian package, or whose omission may
  1009. cause problems. When writing the control files for Debian packages
  1010. you <em/must/ read the Debian policy manual in conjuction with the
  1011. details below and the list of fields for the particular file.
  1012. <sect>List of fields
  1013. <sect1 id="f-Package"><tt/Package/
  1014. <p>
  1015. The name of the binary package. Package names consist of the
  1016. alphanumerics and <tt/+/ <tt/-/ <tt/./ (plus, minus and full
  1017. stop).<footnote>The characters <tt/@/ <tt/:/ <tt/=/ <tt/%/ <tt/_/ (at,
  1018. colon, equals, percent and underscore) used to be legal and are still
  1019. accepted when found in a package file, but may not be used in new
  1020. packages</footnote>
  1021. <p>
  1022. They must be at least two characters and must start with an
  1023. alphanumeric. In current versions of dpkg they are sort of
  1024. case-sensitive<footnote>This is a bug.</footnote>; use lowercase
  1025. package names unless the package you're building (or referring to, in
  1026. other fields) is already using uppercase.
  1027. <sect1 id="f-Version"><tt/Version/
  1028. <p>
  1029. This lists the source or binary package's version number - see <ref
  1030. id="versions">.
  1031. <sect1 id="f-Architecture"><tt/Architecture/
  1032. <p>
  1033. This is the architecture string; it is a single word for the CPU
  1034. architecture.
  1035. <p>
  1036. <prgn/dpkg/ will check the declared architecture of a binary package
  1037. against its own compiled-in value before it installs it.
  1038. <p>
  1039. The special value <tt/all/ indicates that the package is
  1040. architecture-independent.
  1041. <p>
  1042. In the main <tt>debian/control</> file in the source package, or in
  1043. the source package control file <tt/.dsc/, a list of architectures
  1044. (separated by spaces) is also allowed, as is the special value
  1045. <tt/any/. A list indicates that the source will build an
  1046. architecture-dependent package, and will only work correctly on the
  1047. listed architectures. <tt/any/ indicates that though the source
  1048. package isn't dependent on any particular architecture and should
  1049. compile fine on any one, the binary package(s) produced are not
  1050. architecture-independent but will instead be specific to whatever the
  1051. current build architecture is.
  1052. <p>
  1053. In a <tt/.changes/ file the <tt/Architecture/ field lists the
  1054. architecture(s) of the package(s) currently being uploaded. This will
  1055. be a list; if the source for the package is being uploaded too the
  1056. special entry <tt/source/ is also present.
  1057. <p>
  1058. The current build architecture can be determined using <tt/dpkg
  1059. --print-architecture/.<footnote>This actually invokes
  1060. <example>
  1061. gcc --print-libgcc-file-name
  1062. </example>
  1063. and parses and decomposes the output and looks the CPU type from the
  1064. GCC configuration in a table in <prgn/dpkg/. This is so that it will
  1065. work if you're cross-compiling.
  1066. </footnote>
  1067. This value is automatically used by <prgn/dpkg-gencontrol/ when
  1068. building the control file for a binary package for which the source
  1069. control information doesn't specify architecture <tt/all/.
  1070. <p>
  1071. There is a separate option, <tt/--print-installation-architecture/,
  1072. for finding out what architecture <prgn/dpkg/ is willing to install.
  1073. This information is also in the output of <tt/dpkg --version/.
  1074. <sect1 id="f-Maintainer"><tt/Maintainer/
  1075. <p>
  1076. The package maintainer's name and email address. The name should come
  1077. first, then the email address inside angle brackets <tt/&lt;&gt/ (in
  1078. RFC822 format).
  1079. <p>
  1080. If the maintainer's name contains a full stop then the whole field
  1081. will not work directly as an email address due to a misfeature in the
  1082. syntax specified in RFC822; a program using this field as an address
  1083. must check for this and correct the problem if necessary (for example
  1084. by putting the name in round brackets and moving it to the end, and
  1085. bringing the email address forward).
  1086. <p>
  1087. In a <tt/.changes/ file or parsed changelog data this contains the
  1088. name and email address of the person responsible for the particular
  1089. version in question - this may not be the package's usual maintainer.
  1090. <p>
  1091. This field is usually optional in as far as the <prgn/dpkg/ are
  1092. concerned, but its absence when building packages usually generates a
  1093. warning.
  1094. <sect1 id="f-Source"><tt/Source/
  1095. <p>
  1096. This field identifies the source package name.
  1097. <p>
  1098. In a main source control information or a <tt/.changes/ or <tt/.dsc/
  1099. file or parsed changelog data this may contain only the name of the
  1100. source package.
  1101. <p>
  1102. In the control file of a binary package (or in a <tt/Packages/ file)
  1103. it may be followed by a version number in parentheses.<footnote>It is
  1104. usual to leave a space after the package name if a version number is
  1105. specified.</footnote> This version number may be omitted (and is, by
  1106. <prgn/dpkg-gencontrol/) if it has the same value as the <tt/Version/
  1107. field of the binary package in question. The field itself may be
  1108. omitted from a binary package control file when the source package has
  1109. the same name and version as the binary package.
  1110. <sect1>Package interrelationship fields:
  1111. <tt/Depends/, <tt/Pre-Depends/, <tt/Recommends/
  1112. <tt/Suggests/, <tt/Conflicts/, <tt/Provides/, <tt/Replaces/
  1113. <p>
  1114. These fields describe the package's relationships with other packages.
  1115. Their syntax and semantics are described in <ref id="relationships">.
  1116. <sect1 id="f-Description"><tt/Description/
  1117. <p>
  1118. In a binary package <tt/Packages/ file or main source control file
  1119. this field contains a description of the binary package, in a special
  1120. format. See <ref id="descriptions"> for details.
  1121. <p>
  1122. In a <tt/.changes/ file it contains a summary of the descriptions for
  1123. the packages being uploaded. The part of the field before the first
  1124. newline is empty; thereafter each line has the name of a binary
  1125. package and the summary description line from that binary package.
  1126. Each line is indented by one space.
  1127. <sect1 id="f-Essential"><tt/Essential/
  1128. <p>
  1129. This is a boolean field which may occur only in the control file of a
  1130. binary package (or in the <tt/Packages/ file) or in a per-package
  1131. fields paragraph of a main source control data file.
  1132. <p>
  1133. If set to <tt/yes/ then <prgn/dpkg/ and <prgn/dselect/ will refuse to
  1134. remove the package (though it can be upgraded and/or replaced). The
  1135. other possible value is <tt/no/, which is the same as not having the
  1136. field at all.
  1137. <sect1 id="f-classification"><tt/Section/ and <tt/Priority/
  1138. <p>
  1139. These two fields classify the package. The <tt/Priority/ represents
  1140. how important that it is that the user have it installed; the
  1141. <tt/Section/ represents an application area into which the package has
  1142. been classified.
  1143. <p>
  1144. When they appear in the <tt>debian/control</> file these fields give
  1145. values for the section and priority subfields of the <tt/Files/ field
  1146. of the <tt/.changes/ file, and give defaults for the section and
  1147. priority of the binary packages.
  1148. <p>
  1149. The section and priority are represented, though not as separate
  1150. fields, in the information for each file in the <qref
  1151. id="f-Files"><tt/Files/</> field of a <tt/.changes/ file. The
  1152. section value in a <tt/.changes/ file is used to decide where to
  1153. install a package in the FTP archive.
  1154. <p>
  1155. These fields are not used by by <prgn/dpkg/ proper, but by
  1156. <prgn/dselect/ when it sorts packages and selects defaults. See the
  1157. Debian policy manual for the priorities in use and the criteria for
  1158. selecting the priority for a Debian package, and look at the Debian
  1159. FTP archive for a list of currently in-use priorities.
  1160. <p>
  1161. These fields may appear in binary package control files, in which case
  1162. they provide a default value in case the <tt/Packages/ files are
  1163. missing the information. <prgn/dpkg/ and <prgn/dselect/ will only use
  1164. the value from a <tt/.deb/ file if they have no other information; a
  1165. value listed in a <tt/Packages/ file will always take precedence. By
  1166. default <prgn/dpkg-genchanges/ does not include the section and
  1167. priority in the control file of a binary package - use the <tt/-isp/,
  1168. <tt/-is/ or <tt/-ip/ options to achieve this effect.
  1169. <sect1 id="f-Binary"><tt/Binary/
  1170. <p>
  1171. This field is a list of binary packages.
  1172. <p>
  1173. When it appears in the <tt/.dsc/ file it is the list of binary
  1174. packages which a source package can produce. It does not necessarily
  1175. produce all of these binary packages for every architecture. The
  1176. source control file doesn't contain details of which architectures are
  1177. appropriate for which of the binary packages.
  1178. <p>
  1179. When it appears in a <tt/.changes/ file it lists the names of the
  1180. binary packages actually being uploaded.
  1181. <p>
  1182. The syntax is a list of binary packages separated by
  1183. commas.<footnote>A space after each comma is conventional.</footnote>
  1184. Currently the packages must be separated using only spaces in the
  1185. <tt/.changes/ file.
  1186. <sect1 id="f-Installed-Size"><tt/Installed-Size/
  1187. <p>
  1188. This field appears in the control files of binary packages, and in the
  1189. <tt/Packages/ files. It gives the total amount of disk space
  1190. required to install the named package.
  1191. <p>
  1192. The disk space is represented in kilobytes as a simple decimal number.
  1193. <sect1 id="f-Files"><tt/Files/
  1194. <p>
  1195. This field contains a list of files with information about each one.
  1196. The exact information and syntax varies with the context. In all
  1197. cases the the part of the field contents on the same line as the field
  1198. name is empty. The remainder of the field is one line per file, each
  1199. line being indented by one space and containing a number of sub-fields
  1200. separated by spaces.
  1201. <p>
  1202. In the <tt/.dsc/ (Debian source control) file each line contains the
  1203. MD5 checksum, size and filename of the tarfile and (if applicable)
  1204. diff file which make up the remainder of the source
  1205. package.<footnote>That is, the parts which are not the
  1206. <tt/.dsc/.</footnote> The exact forms of the filenames are described
  1207. in <ref id="sourcearchives">.
  1208. <p>
  1209. In the <tt/.changes/ file this contains one line per file being
  1210. uploaded. Each line contains the MD5 checksum, size, section and
  1211. priority and the filename. The section and priority are the values of
  1212. the corresponding fields in the main source control file - see <ref
  1213. id="f-classification">. If no section or priority is specified then
  1214. <tt/-/ should be used, though section and priority values must be
  1215. specified for new packages to be installed properly.
  1216. <p>
  1217. The special value <tt/byhand/ for the section in a <tt/.changes/ file
  1218. indicates that the file in question is not an ordinary package file
  1219. and must by installed by hand by the distribution maintainers. If the
  1220. section is <tt/byhand/ the priority should be <tt/-/.
  1221. <p>
  1222. If a new Debian revision of a package is being shipped and no new
  1223. original source archive is being distributed the <tt/.dsc/ must still
  1224. contain the <tt/Files/ field entry for the original source archive
  1225. <tt/<var/package/-<var/upstream-version/.orig.tar.gz/, but the
  1226. <tt/.changes/ file should leave it out. In this case the original
  1227. source archive on the distribution site must match exactly,
  1228. byte-for-byte, the original source archive which was used to generate
  1229. the <tt/.dsc/ file and diff which are being uploaded.
  1230. <sect1 id="f-Standards-Version"><tt/Standards-Version/
  1231. <p>
  1232. The most recent version of the standards (the <prgn/dpkg/ programmers'
  1233. and policy manuals and associated texts) with which the package
  1234. complies. This is updated manually when editing the source package to
  1235. conform to newer standards; it can sometimes be used to tell when a
  1236. package needs attention.
  1237. <p>
  1238. Its format is the same as that of a version number except that no
  1239. epoch or Debian revision is allowed - see <ref id="versions">.
  1240. <sect1 id="f-Distribution"><tt/Distribution/
  1241. <p>
  1242. In a <tt/.changes/ file or parsed changelog output this contains the
  1243. (space-separated) name(s) of the distribution(s) where this version of
  1244. the package should be or was installed. Distribution names follow the
  1245. rules for package names. (See <ref id="f-Package">).
  1246. <p>
  1247. Current distribution values are <tt/stable/, <tt/unstable/,
  1248. <tt/contrib/, <tt/non-free/ and <tt/experimental/.
  1249. <sect1 id="f-Urgency"><tt/Urgency/
  1250. <p>
  1251. This is a description of how important it is to upgrade to this
  1252. version from previous ones. It consists of a single keyword usually
  1253. taking one of the values <tt/LOW/, <tt/MEDIUM/ or <tt/HIGH/) followed
  1254. by an optional commentary (separated by a space) which is usually in
  1255. parentheses. For example:
  1256. <example>
  1257. Urgency: LOW (HIGH for diversions users)
  1258. </example>
  1259. <p>
  1260. This field appears in the <tt/.changes/ file and in parsed changelogs;
  1261. its value appears as the value of the <tt/urgency/ attribute in a
  1262. <prgn/dpkg/-style changelog (see <ref id="dpkgchangelog">).
  1263. <p>
  1264. Urgency keywords are not case-sensitive.
  1265. <sect1 id="f-Date"><tt/Date/
  1266. <p>
  1267. In <tt/.changes/ files and parsed changelogs, this gives the date the
  1268. package was built or last edited.
  1269. <sect1 id="f-Format"><tt/Format/
  1270. <p>
  1271. This field occurs in <tt/.changes/ files, and specifies a format
  1272. revision for the file. The format described here is version <tt/1.5/.
  1273. The syntax of the format value is the same as that of a package
  1274. version number except that no epoch or Debian revision is allowed -
  1275. see <ref id="versions">.
  1276. <sect1 id="f-Changes"><tt/Changes/
  1277. <p>
  1278. In a <tt/.changes/ file or parsed changelog this field contains the
  1279. human-readable changes data, describing the differences between the
  1280. last version and the current one.
  1281. <p>
  1282. There should be nothing in this field before the first newline; all
  1283. the subsequent lines must be indented by at least one space; blank
  1284. lines must be represented by a line consiting only of a space and a
  1285. full stop.
  1286. <p>
  1287. Each version's change information should be preceded by a `title' line
  1288. giving at least the version, distribution(s) and urgency, in a
  1289. human-readable way.
  1290. <p>
  1291. If data from several versions is being returned the entry for the most
  1292. recent version should be returned first, and entries should be
  1293. separated by the representation of a blank line (the `title' line may
  1294. also be followed by the representation of blank line).
  1295. <sect1 id="f-Filename"><tt/Filename/ and <tt/MSDOS-Filename/
  1296. <p>
  1297. These fields in <tt/Packages/ files give the filename(s) of (the parts
  1298. of) a package in the distribution directories, relative to the root of
  1299. the Debian hierarchy. If the package has been split into several
  1300. parts the parts are all listed in order, separated by spaces.
  1301. <sect1 id="f-Size"><tt/Size/ and <tt/MD5sum/
  1302. <p>
  1303. These fields in <tt/Packages/ files give the size (in bytes, expressed
  1304. in decimal) and MD5 checksum of the file(s) which make(s) up a binary
  1305. package in the distribution. If the package is split into several
  1306. parts the values for the parts are listed in order, separated by
  1307. spaces.
  1308. <sect1 id="f-Status"><tt/Status/
  1309. <p>
  1310. This field in <prgn/dpkg/'s status file records whether the user wants a
  1311. package installed, removed or left alone, whether it is broken
  1312. (requiring reinstallation) or not and what its current state on the
  1313. system is. Each of these pieces of information is a single word.
  1314. <sect1 id="f-Config-Version"><tt/Config-Version/
  1315. <p>
  1316. If a package is not installed or not configured, this field in
  1317. <prgn/dpkg/'s status file records the last version of the package which
  1318. was successfully configured.
  1319. <sect1 id="f-Conffiles"><tt/Conffiles/
  1320. <p>
  1321. This field in <prgn/dpkg/'s status file contains information about the
  1322. automatically-managed configuration files held by a package. This
  1323. field should <em/not/ appear anywhere in a package!
  1324. <sect1>Obsolete fields
  1325. <p>
  1326. These are still recognised by <prgn/dpkg/ but should not appear anywhere
  1327. any more.
  1328. <taglist compact>
  1329. <tag><tt/Revision/
  1330. <tag><tt/Package-Revision/
  1331. <tag><tt/Package_Revision/
  1332. <item>
  1333. The Debian revision part of the package version was at one point in a
  1334. separate control file field. This field went through several names.
  1335. <tag><tt/Recommended/
  1336. <item>Old name for <tt/Recommends/
  1337. <tag><tt/Optional/
  1338. <item>Old name for <tt/Suggests/.
  1339. <tag><tt/Class/
  1340. <item>Old name for <tt/Priority/.
  1341. </taglist>
  1342. <chapt id="versions">Version numbering
  1343. <p>
  1344. Every package has a version number, in its <tt/Version/ control file
  1345. field.
  1346. <p>
  1347. <prgn/dpkg/ imposes an ordering on version numbers, so that it can tell
  1348. whether packages are being up- or downgraded and so that <prgn/dselect/
  1349. can tell whether a package it finds available is newer than the one
  1350. installed on the system. The version number format has the most
  1351. significant parts (as far as comparison is concerned) at the
  1352. beginning.
  1353. <p>
  1354. The version number format is:
  1355. &lsqb<var/epoch/<tt/:/&rsqb;<var/upstream-version/&lsqb;<tt/-/<var/debian-revision/&rsqb;.
  1356. <p>
  1357. The three components here are:
  1358. <taglist>
  1359. <tag><var/epoch/
  1360. <item>
  1361. This is a single unsigned integer, which should usually be small. It
  1362. may be omitted, in which case zero is assumed. If it is omitted then
  1363. the <var/upstream-version/ may not contain any colons.
  1364. <p>
  1365. It is provided to allow mistakes in the version numbers of older
  1366. versions of a package, and also a package's previous version numbering
  1367. schemes, to be left behind.
  1368. <p>
  1369. <prgn/dpkg/ will not usually display the epoch unless it is essential
  1370. (non-zero, or if the <var/upstream-version/ contains a colon);
  1371. <prgn/dselect/ does not display epochs at all in the main part of the
  1372. package selection display.
  1373. <tag><var/upstream-version/
  1374. <item>
  1375. This is the main part of the version. It is usually version number of
  1376. the original (`upstream') package of which the <tt/.deb/ file has been
  1377. made, if this is applicable. Usually this will be in the same format
  1378. as that specified by the upstream author(s); however, it may need to
  1379. be reformatted to fit into <prgn/dpkg/'s format and comparison scheme.
  1380. <p>
  1381. The comparison behaviour of <prgn/dpkg/ with respect to the
  1382. <var/upstream-version/ is described below. The <var/upstream-version/
  1383. portion of the version number is mandatory.
  1384. <p>
  1385. The <var/upstream-version/ may contain only alphanumerics and the
  1386. characters <tt/+/ <tt/./ <tt/-/ <tt/:/ (full stop, plus, hyphen,
  1387. colon) and should start with a digit. If there is no
  1388. <var/debian-revision/ then hyphens are not allowed; if there is no
  1389. <var/epoch/ then colons are not allowed.
  1390. <tag><var/debian-revision/
  1391. <item>
  1392. This part of the version represents the version of the modifications
  1393. that were made to the package to make it a Debian binary package. It
  1394. is in the same format as the <var/upstream-version/ and <prgn/dpkg/
  1395. compares it in the same way.
  1396. <p>
  1397. It is optional; if it isn't present then the <var/upstream-version/
  1398. may not contain a hyphen. This format represents the case where a
  1399. piece of software was written specifically to be turned into a Debian
  1400. binary package, and so there is only one `debianization' of it and
  1401. therefore no revision indication is required.
  1402. <p>
  1403. It is conventional to restart the <var/debian-revision/ at <tt/1/ each
  1404. time the <var/upstream-version/ is increased.
  1405. <p>
  1406. <prgn/dpkg/ will break the <var/upstream-version/ and
  1407. <var/debian-revision/ apart at the last hyphen in the string. The
  1408. absence of a <var/debian-revision/ compares earlier than the presence
  1409. of one (but note that the <var/debian-revision/ is the least
  1410. significant part of the version number).
  1411. <p>
  1412. The <var/debian-revision/ may contain only alphanumerics and the
  1413. characters <tt/+/ and <tt/./ (plus and full stop).
  1414. </taglist>
  1415. The <var/upstream-version/ and <var/debian-revision/ parts are
  1416. compared by <prgn/dpkg/ using the same algorithm:
  1417. <p>
  1418. The strings are compared from left to right.
  1419. <p>
  1420. First the initial part of each string consisting entirely of non-digit
  1421. characters is determined. These two parts (one of which may be empty)
  1422. are compared lexically. If a difference is found it is returned. The
  1423. lexical comparison is a comparison of ASCII values modified so that
  1424. all the letters sort earlier than all the non-letters.
  1425. <p>
  1426. Then the initial part of the remainder of each string which consists
  1427. entirely of digit characters is determined. The numerical values of
  1428. these two parts are compared, and any difference found is returned as
  1429. the result of the comparison. For these purposes an empty string
  1430. (which can only occur at the end of one or both version strings being
  1431. compared) counts as zero.
  1432. <p>
  1433. These two steps are repeated (chopping initial non-digit strings and
  1434. initial digit strings off from the start) until a difference is found
  1435. or both strings are exhausted.
  1436. <p>
  1437. Note that the purpose of epochs is to allow us to leave behind
  1438. mistakes in version numbering, and to cope with situations where the
  1439. version numbering changes. It is <em/not/ there to cope with version
  1440. numbers containing strings of letters which <prgn/dpkg/ cannot interpret
  1441. (such as <tt/ALPHA/ or <tt/pre-/), or with silly orderings (the author
  1442. of this manual has heard of a package whose versions went <tt/1.1/,
  1443. <tt/1.2/, <tt/1.3/, <tt/1/, <tt/2.1/, <tt/2.2/, <tt/2/ and so forth).
  1444. <p>
  1445. If an upstream package has problematic version numbers they should be
  1446. converted to a sane form for use in the <tt/Version/ field.
  1447. <chapt id="maintainerscripts">Package maintainer scripts
  1448. and installation procedure
  1449. <sect>Introduction to package maintainer scripts
  1450. <p>
  1451. It is possible supply scripts as part of a package which <prgn/dpkg/
  1452. will run for you when your package is installed, upgraded or removed.
  1453. <p>
  1454. These scripts should be the files <tt/preinst/, <tt/postinst/,
  1455. <tt/prerm/ and <tt/postrm/ in the control area of the package. They
  1456. must be proper exectuable files; if they are scripts (which is
  1457. recommended) they must start with the usual <tt/#!/ convention. They
  1458. should be readable and executable to anyone, and not world-writeable.
  1459. <p>
  1460. <prgn/dpkg/ looks at the exit status from these scripts. It is
  1461. important that they exit with a non-zero status if there is an error,
  1462. so that <prgn/dpkg/ can stop its processing. For shell scripts this
  1463. means that you <em/almost always/ need to use <tt/set -e/ (this is
  1464. usually true when writing shell scripts, in fact). It is also
  1465. important, of course, that they don't exit with a non-zero status if
  1466. everything went well.
  1467. <p>
  1468. It is necessary for the error recovery procedures that the scripts be
  1469. idempotent: ie, invoking the same script several times in the same
  1470. situation should do no harm. If the first call failed, or aborted
  1471. half way through for some reason, the second call should merely do the
  1472. things that were left undone the first time, if any, and exit with a
  1473. success status.
  1474. <p>
  1475. When a package is upgraded a combination of the scripts from the old
  1476. and new packages is called in amongst the other steps of the upgrade
  1477. procedure. If your scripts are going to be at all complicated you
  1478. need to be aware of this, and may need to check the arguments to your
  1479. scripts.
  1480. <p>
  1481. Broadly speaking the <prgn/preinst/ is called before (a particular
  1482. version of) a package is installed, and the <prgn/postinst/ afterwards;
  1483. the <prgn/prerm/ before (a version of) a package is removed and the
  1484. <prgn/postrm/ afterwards.
  1485. <sect id="mscriptsinstact">Summary of ways maintainer scripts are called
  1486. <p>
  1487. <list compact>
  1488. <item><var/new-preinst/ <tt/install/
  1489. <item><var/new-preinst/ <tt/install/ <var/old-version/
  1490. <item><var/new-preinst/ <tt/upgrade/ <var/old-version/
  1491. <item><var/old-preinst/ <tt/abort-upgrade/ <var/new-version/
  1492. </list>
  1493. <p>
  1494. <list compact>
  1495. <item><var/postinst/ <tt/configure/ <var/most-recently-configured-version/
  1496. <item><var/old-postinst/ <tt/abort-upgrade/ <var/new version/
  1497. <item><var/conflictor's-postinst/ <tt/abort-remove/
  1498. <tt/in-favour/ <var/package/ <var/new-version/
  1499. <item><var/deconfigured's-postinst/ <tt/abort-deconfigure/
  1500. <tt/in-favour/ <var/failed-install-package/ <var/version/
  1501. <tt/removing/ <var/conflicting-package/ <var/version/
  1502. </list>
  1503. <p>
  1504. <list compact>
  1505. <item><var/prerm/ <tt/remove/
  1506. <item><var/old-prerm/ <tt/upgrade/ <var/new-version/
  1507. <item><var/new-prerm/ <tt/failed-upgrade/ <var/old-version/
  1508. <item><var/conflictor's-prerm/ <tt/remove/ <tt/in-favour/
  1509. <var/package/ <var/new-version/
  1510. <item><var/deconfigured's-prerm/ <tt/deconfigure/
  1511. <tt/in-favour/ <var/package-being-installed/ <var/version/
  1512. <tt/removing/ <var/conflicting-package/ <var/version/
  1513. </list>
  1514. <p>
  1515. <list compact>
  1516. <item><var/postrm/ <tt/remove/
  1517. <item><var/postrm/ <tt/purge/
  1518. <item><var/old-postrm/ <tt/upgrade/ <var/new-version/
  1519. <item><var/new-postrm/ <tt/failed-upgrade/ <var/old-version/
  1520. <item><var/new-postrm/ <tt/abort-install/
  1521. <item><var/new-postrm/ <tt/abort-install/ <var/old-version/
  1522. <item><var/new-postrm/ <tt/abort-upgrade/ <var/old-version/
  1523. <item><var/disappearer's-postrm/ <tt/disappear/ <var/overwriter/ <var/new-version/
  1524. </list>
  1525. <sect>Details of unpack phase of installation or upgrade
  1526. <p>
  1527. The procedure on installation/upgrade/overwrite/disappear (ie, when
  1528. running <tt/dpkg --unpack/, or the unpack stage of <tt/dpkg
  1529. --install/) is as follows. In each case if an error occurs the
  1530. actions in are general run backwards - this means that the maintainer
  1531. scripts are run with different arguments in reverse order. These are
  1532. the `error unwind' calls listed below.
  1533. <enumlist>
  1534. <item>
  1535. <enumlist>
  1536. <item>
  1537. If a version the package is already
  1538. installed, call
  1539. <example>
  1540. <var/old-prerm/ upgrade <var/new-version/
  1541. </example>
  1542. <item>
  1543. If this gives an error (ie, a non-zero exit status), dpkg will
  1544. attempt instead:
  1545. <example>
  1546. <var/new-prerm/ failed-upgrade <var/old-version/
  1547. </example>
  1548. Error unwind, for both the above cases:
  1549. <example>
  1550. <var/old-postinst/ abort-upgrade <var/new-version/
  1551. </example>
  1552. </enumlist>
  1553. <item>
  1554. If a `conflicting' package is being removed at the same time:
  1555. <enumlist>
  1556. <item>
  1557. If any packages depended on that conflicting package and
  1558. <tt/--auto-deconfigure/ is specified, call, for each such package:
  1559. <example>
  1560. <var/deconfigured's-prerm/ deconfigure \
  1561. in-favour <var/package-being-installed/ <var/version/ \
  1562. removing <var/conflicting-package/ <var/version/
  1563. </example>
  1564. Error unwind:
  1565. <example>
  1566. <var/deconfigured's-postinst/ abort-deconfigure \
  1567. in-favour <var/package-being-installed-but-failed/ <var/version/ \
  1568. removing <var/conflicting-package/ <var/version/
  1569. </example>
  1570. The deconfigured packages are marked as requiring configuration, so
  1571. that if <tt/--install/ is used they will be configured again if
  1572. possible.
  1573. <item>
  1574. To prepare for removal of the conflicting package, call:
  1575. <example>
  1576. <var/conflictor's-prerm/ remove in-favour <var/package/ <var/new-version/
  1577. </example>
  1578. Error unwind:
  1579. <example>
  1580. <var/conflictor's-postinst/ abort-remove \
  1581. in-favour <var/package/ <var/new-version/
  1582. </example>
  1583. </enumlist>
  1584. <item>
  1585. <enumlist>
  1586. <item>
  1587. If the package is being upgraded, call:
  1588. <example>
  1589. <var/new-preinst/ upgrade <var/old-version/
  1590. </example>
  1591. <item>
  1592. Otherwise, if the package had some configuration files from a previous
  1593. version installed (ie, it is in the `configuration files only' state):
  1594. <example>
  1595. <var/new-preinst/ install <var/old-version/
  1596. </example>
  1597. <item>
  1598. Otherwise (ie, the package was completely purged):
  1599. <example>
  1600. <var/new-preinst/ install
  1601. </example>
  1602. Error unwind versions, respectively:
  1603. <example>
  1604. <var/new-postrm/ abort-upgrade <var/old-version/
  1605. <var/new-postrm/ abort-install <var/old-version/
  1606. <var/new-postrm/ abort-install
  1607. </example>
  1608. </enumlist>
  1609. <item>
  1610. The new package's files are unpacked, overwriting any that may be on
  1611. the system already, for example any from the old version of the same
  1612. package or from another package (backups of the old files are left
  1613. around, and if anything goes wrong dpkg will attempt to put them back
  1614. as part of the error unwind).
  1615. <p>
  1616. It is an error for a package to contains files which are on the system
  1617. in another package, unless <tt/Replaces/ is used (see
  1618. <ref id="replaces">). Currently the <tt/--force-overwrite/ flag is
  1619. enabled, downgrading it to a warning, but this may not always be the
  1620. case.
  1621. <p>
  1622. It is a more serious error for a package to contain a plain file or
  1623. other kind of nondirectory where another package has a directory
  1624. (again, unless <tt/Replaces/ is used). This error can be overridden
  1625. if desired using <tt/--force-overwrite-dir/, but this is not -->
  1626. --advisable.
  1627. <p>
  1628. Packages which overwrite each other's files produce behaviour which
  1629. though deterministic is hard for the system administrator to
  1630. understand. It can easily lead to `missing' programs if, for example,
  1631. a package is installed which overwrites a file from another package,
  1632. and is then removed again.<footnote>Part of the problem is due to what
  1633. is arguably a bug in <prgn/dpkg/.</footnote>
  1634. <p>
  1635. A directory will never be replaced by a symbolic links to a directory
  1636. or vice versa; instead, the existing state (symlink or not) will be
  1637. left alone and <prgn/dpkg/ will follow the symlink if there is one.
  1638. <item>
  1639. <enumlist>
  1640. <item>
  1641. If the package is being upgraded, call
  1642. <example>
  1643. <var/old-postrm/ upgrade <var/new-version/
  1644. </example>
  1645. <item>
  1646. If this fails, <prgn/dpkg/ will attempt:
  1647. <example>
  1648. <var/new-postrm/ failed-upgrade <var/old-version/
  1649. </example>
  1650. Error unwind, for both cases:
  1651. <example>
  1652. <var/old-preinst/ abort-upgrade <var/new-version/
  1653. </example>
  1654. </enumlist>
  1655. This is the point of no return - if <prgn/dpkg/ gets this far, it won't
  1656. back off past this point if an error occurs. This will leave the
  1657. package in a fairly bad state, which will require a successful
  1658. reinstallation to clear up, but it's when <prgn/dpkg/ starts doing
  1659. things that are irreversible.
  1660. <item>
  1661. Any files which were in the old version of the package but not in the
  1662. new are removed.
  1663. <item>
  1664. The new file list replaces the old.
  1665. <item>
  1666. The new maintainer scripts replace the old.
  1667. <item>
  1668. Any packages all of whose files have been overwritten during the
  1669. installation, and which aren't required for dependencies, are considered
  1670. to have been removed. For each such package,
  1671. <enumlist>
  1672. <item>
  1673. <prgn/dpkg/ calls:
  1674. <example>
  1675. <var/disappearer's-postrm/ disappear \
  1676. <var/overwriter/ <var/overwriter-version/
  1677. </example>
  1678. <item>
  1679. The package's maintainer scripts are removed.
  1680. <item>
  1681. It is noted in the status database as being in a sane state, namely
  1682. not installed (any conffiles it may have are ignored, rather than
  1683. being removed by <prgn/dpkg/). Note that disappearing packages do not
  1684. have their prerm called, because <prgn/dpkg/ doesn't know in advance
  1685. that the package is going to vanish.
  1686. </enumlist>
  1687. <item>
  1688. Any files in the package we're unpacking that are also listed in the
  1689. file lists of other packages are removed from those lists. (This will
  1690. lobotomise the file list of the `conflicting' package if there is one.)
  1691. <item>
  1692. The backup files made during installation, above, are deleted.
  1693. <item>
  1694. The new package's status is now sane, and recorded as `unpacked'. Here
  1695. is another point of no return - if the conflicting package's removal
  1696. fails we do not unwind the rest of the installation; the conflicting
  1697. package is left in a half-removed limbo.
  1698. <item>
  1699. If there was a conflicting package we go and do the removal actions
  1700. (described below), starting with the removal of the conflicting
  1701. package's files (any that are also in the package being installed
  1702. have already been removed from the conflicting package's file list,
  1703. and so do not get removed now).
  1704. </enumlist>
  1705. <sect>Details of configuration
  1706. <p>
  1707. When we configure a package (this happens with <tt/dpkg --install/, or
  1708. with <tt/--configure/), we first update the conffiles and then call:
  1709. <example>
  1710. <var/postinst/ configure <var/most-recently-configured-version/
  1711. </example>
  1712. <p>
  1713. No attempt is made to unwind after errors during configuration.
  1714. <p>
  1715. If there is no most recently configured version <prgn/dpkg/ will pass a
  1716. null argument; older versions of dpkg may pass
  1717. <tt>&lt;unknown&gt;</tt> (including the angle brackets) in this case.
  1718. Even older ones do not pass a second argument at all, under any
  1719. circumstances.
  1720. <sect>Details of removal and/or configuration purging
  1721. <p>
  1722. <enumlist>
  1723. <item>
  1724. <example>
  1725. <var/prerm/ remove
  1726. </example>
  1727. <item>
  1728. The package's files are removed (except conffiles).
  1729. <item>
  1730. <example>
  1731. <var/postrm/ remove
  1732. </example>
  1733. <item>
  1734. All the maintainer scripts except the postrm are removed.
  1735. <p>
  1736. If we aren't purging the package we stop here. Note that packages
  1737. which have no postrm and no conffiles are automatically purged when
  1738. removed, as there is no difference except for the <prgn/dpkg/ status.
  1739. <item>
  1740. The conffiles and any backup files (<tt/~/-files, <tt/#*#/ files,
  1741. <tt/%/-files, <tt/.dpkg-{old,new,tmp}/, etc.) are removed.
  1742. <item>
  1743. <example>
  1744. <var/postrm/ purge
  1745. </example>
  1746. <item>
  1747. The package's file list is removed.
  1748. </enumlist>
  1749. No attempt is made to unwind after errors during removal.
  1750. <chapt id="descriptions">Descriptions of packages - the
  1751. <tt/Description/ field
  1752. <p>
  1753. The <tt/Description/ control file field is used by <prgn/dselect/ when
  1754. the user is selecting which packages to install and by <prgn/dpkg/
  1755. when it displays information about the status of packages and so
  1756. forth. It is included on the FTP site in the <prgn/Packages/ files,
  1757. and may also be used by the Debian WWW pages.
  1758. <p>
  1759. The description is intended to describe the program to a user who has
  1760. never met it before so that they know whether they want to install it.
  1761. It should also give information about the significant dependencies and
  1762. conflicts between this package and others, so that the user knows why
  1763. these dependencies and conflicts have been declared.
  1764. <p>
  1765. The field's format is as follows:
  1766. <example>
  1767. Description: <var/single line synopsis/
  1768. <var/extended description over several lines/
  1769. </example>
  1770. <p>
  1771. The synopsis is often printed in lists of packages and so forth, and
  1772. should be as informative as possible. Every package should also have
  1773. an extended description.
  1774. <p>
  1775. <sect>Types of formatting line in the extended description
  1776. <p>
  1777. <list>
  1778. <item>
  1779. Those starting with a single space are part of a paragraph.
  1780. Successive lines of this form will be word-wrapped when displayed.
  1781. The leading space will usually be stripped off.
  1782. <item>
  1783. Those starting with two or more spaces. These will be displayed
  1784. verbatim. If the display cannot be panned horizontally the
  1785. displaying program will linewrap them `hard' (ie, without taking
  1786. account of word breaks). If it can they will be allowed to trail
  1787. off to the right. None, one or two initial spaces may be deleted,
  1788. but the number of spaces deleted from each line will be the same
  1789. (so that you can have indenting work correctly, for example).
  1790. <item>
  1791. Those containing a single space followed by a single full stop
  1792. character. These are rendered as blank lines. This is the <em/only/
  1793. way to get a blank line - see below.
  1794. <item>
  1795. Those containing a space, a full stop and some more characters. These
  1796. are for future expansion. Do not use them.
  1797. </list>
  1798. <sect>Notes about writing descriptions
  1799. <p>
  1800. <em/Always/ start extended description lines with at least one
  1801. whitespace character. Fields in the control file and in the Packages
  1802. file are separated by field names starting in the first column, just
  1803. as message header fields are in RFC822. Forgetting the whitespace
  1804. will cause <prgn/dpkg-deb/<footnote>Version 0.93.23 or
  1805. later.</footnote> to produce a syntax error when trying to build the
  1806. package. If you force it to build anyway <prgn/dpkg/ will refuse to
  1807. install the resulting mess.
  1808. <p>
  1809. <em/Do not/ include any completely <em/empty/ lines. These separate
  1810. different records in the Packages file and different packages in the
  1811. <tt>debian/control</> file, and are forbidden in package control
  1812. files. See the previous paragraph for what happens if you get this
  1813. wrong.
  1814. <p>
  1815. The single line synopsis should be kept brief - certainly under 80
  1816. characters. <prgn/dselect/ displays between 25 and 49 characters
  1817. without panning if you're using an 80-column terminal, depending on
  1818. what display options are in effect.
  1819. <p>
  1820. Do not include the package name in the synopsis line. The display
  1821. software knows how to display this already, and you do not need to
  1822. state it. Remember that in many situations the user may only see
  1823. the synopsis line - make it as informative as you can.
  1824. <p>
  1825. The extended description should describe what the package does and
  1826. how it relates to the rest of the system (in terms of, for
  1827. example, which subsystem it is which part of).
  1828. <p>
  1829. The blurb that comes with a program in its announcements and/or
  1830. <prgn/README/ files is rarely suitable for use in a description. It
  1831. is usually aimed at people who are already in the community where the
  1832. package is used. The description field needs to make sense to anyone,
  1833. even people who have no idea about any of the
  1834. things the package deals with.
  1835. <p>
  1836. Put important information first, both in the synopis and extended
  1837. description. Sometimes only the first part of the synopsis or of
  1838. the description will be displayed. You can assume that there will
  1839. usually be a way to see the whole extended description.
  1840. <p>
  1841. You may include information about dependencies and so forth in the
  1842. extended description, if you wish.
  1843. <p>
  1844. Do not use tab characters. Their effect is not predictable.
  1845. <p>
  1846. Do not try to linewrap the summary (the part on the same line as the
  1847. field name <tt/Description/) into the extended description. This will
  1848. not work correctly when the full description is displayed, and makes
  1849. no sense where only the summary is available.
  1850. <sect>Example description in control file for Smail
  1851. <p>
  1852. <example>
  1853. Package: smail
  1854. Version: 3.1.29.1-13
  1855. Maintainer: Ian Jackson &lt;iwj10@cus.cam.ac.uk&gt;
  1856. Recommends: pine | mailx | elm | emacs | mail-user-agent
  1857. Suggests: metamail
  1858. Depends: cron, libc5
  1859. Conflicts: sendmail
  1860. Provides: mail-transport-agent
  1861. Description: Electronic mail transport system.
  1862. Smail is the recommended mail transport agent (MTA) for Debian.
  1863. .
  1864. An MTA is the innards of the mail system - it takes messages from
  1865. user-friendly mailer programs and arranges for them to be delivered
  1866. locally or passed on to other systems as required.
  1867. .
  1868. In order to make use of it you must have one or more user level
  1869. mailreader programs such as elm, pine, mailx or Emacs (which has Rmail
  1870. and VM as mailreaders) installed. If you wish to send messages other
  1871. than just to other users of your system you must also have appropriate
  1872. and VM as mailreaders) installed. If you wish to send messages other
  1873. than just to other users of your system you must also have appropriate
  1874. networking support, in the form of IP or UUCP.
  1875. </example>
  1876. <chapt id="relationships">Declaring relationships between packages
  1877. <p>
  1878. Packages can declare in their control file that they have certain
  1879. relationships to other packages - for example, that they may not be
  1880. installed at the same time as certain other packages, and/or that they
  1881. depend on the presence of others, or that they should overwrite files
  1882. in certain other packages if present.
  1883. <p>
  1884. This is done using the <tt/Depends/, <tt/Recommends/, <tt/Suggests/,
  1885. <tt/Conflicts/, <tt/Provides/ and <tt/Replaces/ control file fields.
  1886. <p>
  1887. <sect id="depsyntax">Syntax of relationship fields
  1888. <p>
  1889. These fields all have a uniform syntax. They are a list of package
  1890. names separated by commas.
  1891. <p>
  1892. In <tt/Depends/, <tt/Recommends/, <tt/Suggests/ and <tt/Pre-Depends/
  1893. (the fields which declare dependencies of the package in which they
  1894. occur on other packages) these package names may also be lists of
  1895. alternative package names, separated by vertical bar symbols <tt/|/
  1896. (pipe symbols).
  1897. <p>
  1898. All the fields except <tt/Provides/ may restrict their applicability
  1899. to particular versions of each named package. This is done in
  1900. parentheses after each individual package name; the parentheses should
  1901. contain a relation from the list below followed by a version number,
  1902. in the format described in <ref id="versions">.
  1903. <p>
  1904. The relations allowed are
  1905. <tt/&lt;&lt;/,
  1906. <tt/&lt;=/,
  1907. <tt/=/,
  1908. <tt/&gt;=/ and
  1909. <tt/&gt;&gt;/
  1910. for strictly earlier, earlier or equal, exactly equal, later or equal
  1911. and strictly later, respectively. The forms <tt/&lt;/ and <tt/&gt;/
  1912. were used to mean earlier/later or equal, rather than strictly
  1913. earlier/later, so they should not appear in new packages (though
  1914. <prgn/dpkg/ still supports them).
  1915. <p>
  1916. Whitespace may appear at any point in the version specification, and
  1917. must appear where it's necessary to disambiguate; it is not otherwise
  1918. significant. For consistency and in case of future changes to
  1919. <prgn/dpkg/ it is recommended that a single space be used after a
  1920. version relationship and before a version number; it is usual also to
  1921. put a single space after each comma, on either side of each vertical
  1922. bar, and before each open parenthesis.
  1923. <p>
  1924. For example:
  1925. <example>
  1926. Package: metamail
  1927. Version: 2.7-3
  1928. Depends: libc5 (>= 5.2.18-4), mime-support, csh | tcsh
  1929. </example>
  1930. <sect>Dependencies - <tt/Depends/, <tt/Recommends/, <tt/Suggests/, <tt/Pre-Depends/
  1931. <p>
  1932. These four fields are used to declare a dependency by one package on
  1933. another. They appear in the depending package's control file.
  1934. <p>
  1935. All but <tt/Pre-Depends/ (discussed below) take effect <em/only/ when
  1936. a package is to be configured. They do not prevent a package being on
  1937. the system in an unconfigured state while its dependencies are
  1938. unsatisfied, and it is possible to replace a package whose
  1939. dependencies are satisfied and which is properly installed with a
  1940. different version whose dependencies are not and cannot be satisfied;
  1941. when this is done the depending package will be left unconfigured
  1942. (since attempts to configure it will give errors) and will not
  1943. function properly.
  1944. <p>
  1945. For this reason packages in an installation run are usually all
  1946. unpacked first and all configured later; this gives later versions of
  1947. packages with dependencies on later versions of other packages the
  1948. opportunity to have their dependencies satisfied.
  1949. <p>
  1950. Thus <tt/Depends/ allows package maintainers to impose an order in
  1951. which packages should be configured.
  1952. <taglist>
  1953. <tag><tt/Depends/
  1954. <item>
  1955. This declares an absolute dependency.
  1956. <p>
  1957. <prgn/dpkg/ will not configure
  1958. packages whose dependencies aren't satisfied. If it is asked to make
  1959. an installation which would cause an installed package's dependencies
  1960. to become unsatisfied it will complain<footnote>Current versions
  1961. (1.2.4) of <prgn/dpkg/ have a bug in this area which will cause some of
  1962. these problems to be ignored.</footnote>, unless
  1963. <tt/--auto-deconfigure/ is specified, in which case those packages
  1964. will be deconfigured before the installation proceeds.
  1965. <p>
  1966. <prgn/dselect/ makes it hard for the user to select packages for
  1967. installation, removal or upgrade in a way that would mean that
  1968. packages' <prgn/Depends/ fields would be unsatisfied. The user can
  1969. override this if they wish, for example if they know that <prgn/dselect/
  1970. has an out-of-date view of the real package relationships.
  1971. <p>
  1972. The <tt/Depends/ field should be used if the depended-on package is
  1973. required for the depending package to provide a significant amount of
  1974. functionality.
  1975. <tag><tt/Recommends/
  1976. <item>
  1977. This declares a strong, but not absolute, dependency.
  1978. <p>
  1979. <tt/Recommends/ is ignored by <prgn/dpkg/, so that users using the
  1980. command-line (who are presumed to know what they're doing) will not be
  1981. impeded.
  1982. <p>
  1983. It is treated by <prgn/dselect/ exactly as <tt/Depends/ is; this makes
  1984. it hard for the user to select things so as to leave <tt/Recommends/
  1985. fields unsatisfied, but they are able to do so by being persistent.
  1986. <p>
  1987. The <tt/Recommends/ field should list packages that would be found
  1988. together with this one in all but unusual installations.
  1989. <tag><tt/Suggests/
  1990. <item>
  1991. This is used to declare that one package may be more useful with one
  1992. or more others. Using this field tells the packaging system and the
  1993. user that the listed packages are be related to this one and can
  1994. perhaps enhance its usefulness, but that installing this one without
  1995. them is perfectly reasonable.
  1996. <p>
  1997. <prgn/dselect/ will offer suggsted packages to the system administrator
  1998. when they select the suggesting package, but the default is not to
  1999. install the suggested package.
  2000. <tag><tt/Pre-Depends/
  2001. <item>
  2002. This field is like <tt/Depends/, except that it also forces <prgn/dpkg/
  2003. to complete installation of the packages named before even starting
  2004. the installation of the package which declares the predependency.
  2005. <p>
  2006. <prgn/dselect/ checks for predependencies when it is doing an
  2007. installation run, and will attempt to find the packages which are
  2008. required to be installed first and do so in the right order.
  2009. <p>
  2010. However, this process is slow (because it requires repeated
  2011. invocations of <prgn/dpkg/) and troublesome (because it requires
  2012. guessing where to find the appropriate files).
  2013. <p>
  2014. For these reasons, and because this field imposes restrictions on the
  2015. order in which packages may be unpacked (which can be difficult for
  2016. installations from multipart media, for example), <tt/Pre-Depends/
  2017. should be used sparingly, preferably only by packages whose premature
  2018. upgrade or installation would hamper the ability of the system to
  2019. continue with any upgrade that might be in progress.
  2020. <p>
  2021. When the package declaring it is being configured, a
  2022. <tt/Pre-Dependency/ will be considered satisfied only if the depending
  2023. package has been correctly configured, just as if an ordinary
  2024. <tt/Depends/ had been used.
  2025. <p>
  2026. However, when a package declaring a predependency is being unpacked
  2027. the predependency can be satisfied even if the depended-on package(s)
  2028. are only unpacked or half-configured, provided that they have been
  2029. configured correctly at some point in the past (and not removed or
  2030. partially removed since). In this case both the previously-configured
  2031. and currently unpacked or half-configured versions must satisfy any
  2032. version clause in the <tt/Pre-Depends/ field.
  2033. </taglist>
  2034. <sect1>Dependencies on shared libraries
  2035. <p>
  2036. The dependency fields listed above are used by packages which need
  2037. shared libraries to declare dependencies on the appropriate packages.
  2038. <p>
  2039. These dependencies are usually determined automatically using
  2040. <prgn/dpkg-shlibdeps/ and inserted in the package control file using
  2041. the control file substitution variables mechanism; see <ref
  2042. id="srcsubstvars"> and <ref id="sourcetools">.
  2043. <sect1>Deconfiguration due to removal during bulk installations
  2044. <p>
  2045. If <prgn/dpkg/ would like to remove a package due to a conflict, as
  2046. described above, but this would violate a dependency of some other
  2047. package on the system, <prgn/dpkg/ will usually not remove the
  2048. conflicting package and halt with an error.
  2049. <p>
  2050. However, if the <tt/--auto-deconfigure/ (<tt/-B/) option is used
  2051. <prgn/dpkg/ will automatically `deconfigure' the package with the
  2052. problematic dependency, so that the conflicting package can be removed
  2053. and the package we're trying to install can be installed. If
  2054. <prgn/dpkg/ is being asked to install packages (rather than just
  2055. unpacking them) it will try to reconfigure the package when it has
  2056. unpacked all its arguments, in the hope that one of the other packages
  2057. it is installing will satisfy the problematic dependency.
  2058. <p>
  2059. <prgn/dselect/ supplies this argument to <prgn/dpkg/ when it invokes it,
  2060. so that bulk installations proceed smoothly.
  2061. <sect id="conflicts">Alternative packages - <tt/Conflicts/ and <tt/Replaces/
  2062. <p>
  2063. When one package declares a conflict with another <prgn/dpkg/ will
  2064. refuse to allow them to be installed on the system at the same time.
  2065. <p>
  2066. If one package is to be installed, the other must be removed first -
  2067. if the package being installed is marked as replacing (<ref
  2068. id="replaces">) the one on the system, or the one on the system is
  2069. marked as deselected, or both packages are marked <tt/Essential/, then
  2070. <prgn/dpkg/ will automatically remove the package which is causing the
  2071. conflict, otherwise it will halt the installation of the new package
  2072. with an error.
  2073. <p>
  2074. <prgn/dselect/ makes it hard to select conflicting packages, though the
  2075. user can override this if they wish. If they do not override it then
  2076. <prgn/dselect/ will select one of the packages for removal, and the user
  2077. must make sure it is the right one. In the future <prgn/dselect/ will
  2078. look for the presence of a <tt/Replaces/ field to help decide which
  2079. package should be installed and which removed.
  2080. <p>
  2081. A package will not cause a conflict merely because its configuration
  2082. files are still installed; it must be at least half-installed.
  2083. <p>
  2084. A special exception is made for packages which declare a conflict with
  2085. their own package name, or with a virtual package which they provide
  2086. (see below): this does not prevent their installation, and allows a
  2087. package to conflict with others providing a replacement for it. You
  2088. use this feature when you want the package in question to be the only
  2089. package providing something.
  2090. <p>
  2091. A <tt/Conflicts/ entry should almost never have an `earlier than'
  2092. version clause. This would prevent <prgn/dpkg/ from upgrading or
  2093. installing the package which declared such a conflict until the
  2094. upgrade or removal of the conflicted-with package had been completed.
  2095. This aspect of installation ordering is not handled by <prgn/dselect/,
  2096. so that the use <tt/Conflicts/ in this way is likely to cause problems
  2097. for `bulk run' upgrades and installations.
  2098. <p>
  2099. <sect id="virtual">Virtual packages - <tt/Provides/
  2100. <p>
  2101. As well as the names of actual (`concrete') packages, the package
  2102. relationship fields <tt/Depends/, <tt/Recommends/, <tt/Suggests/ and
  2103. <tt/Conflicts/ may mention virtual packages.
  2104. <p>
  2105. A virtual package is one which appears in the <tt/Provides/ control
  2106. file field of another package. The effect is as if the package(s)
  2107. which provide a particular virtual package name had been listed by
  2108. name everywhere were the virtual package name appears.
  2109. <p>
  2110. If there are both a real and a virtual package of the same name then
  2111. the dependency may be satisfied (or the conflict caused) by either the
  2112. real package or any of the virtual packages which provide it. This is
  2113. so that, for example, supposing we have
  2114. <example>
  2115. Package: vm
  2116. Depends: emacs
  2117. </example>
  2118. and someone else releases an xemacs package they can say
  2119. <example>
  2120. Package: xemacs
  2121. Provides: emacs
  2122. </example>
  2123. and all will work in the interim (until a purely virtual package name
  2124. is decided on and the <tt/emacs/ and <tt/vm/ packages are changed to
  2125. use it).
  2126. <p>
  2127. If a dependency or a conflict has a version number attached then only
  2128. real packages will be considered to see whether the relationship is
  2129. satisfied (or the prohibition violated, for a conflict) - it is
  2130. assumed that a real package which provides virtual package is not of
  2131. the `right' version. So, a <tt/Provides/ field may not contain
  2132. version numbers, and the version number of the concrete package which
  2133. provides a particular virtual package will not be looked at when
  2134. considering a dependency on or conflict with the virtual package name.
  2135. <p>
  2136. If you want to specify which of a set of real packages should be the
  2137. default to satisfy a particular dependency on a virtual package, you
  2138. should list the real package as alternative before the virtual.
  2139. <p>
  2140. <sect id="replaces"><tt/Replaces/ - overwriting files and replacing packages
  2141. <p>
  2142. The <tt/Replaces/ control file field has two purposes, which come into
  2143. play in different situations.
  2144. <p>
  2145. Virtual packages (<ref id="virtual">) are not considered when looking
  2146. at a <tt/Replaces/ field - the packages declared as being replaced
  2147. must be mentioned by their real names.
  2148. <sect1>Overwriting files in other packages
  2149. <p>
  2150. Firstly, as mentioned before, it is usually an error for a package to
  2151. contains files which are on the system in another package, though
  2152. currently the <tt/--force-overwrite/ flag is enabled by default,
  2153. downgrading the error to a warning,
  2154. <p>
  2155. If the overwriting package declares that it replaces the one
  2156. containing the file being overwritten then <prgn/dpkg/ will proceed, and
  2157. replace the file from the old package with that from the new. The
  2158. file will no longer be listed as `owned' by the old package.
  2159. <p>
  2160. If a package is completely replaced in this way, so that <prgn/dpkg/
  2161. does not know of any files it still contains, it is considered to have
  2162. disappeared. It will be marked as not wanted on the system (selected
  2163. for removal) and not installed. Any conffiles details noted in the
  2164. package will be ignored, as they will have been taken over by the
  2165. replacing package(s). The package's <prgn/postrm/ script will be run to
  2166. allow the package to do any final cleanup required.
  2167. See <ref id="mscriptsinstact">.
  2168. <p>
  2169. In the future <prgn/dpkg/ will discard files which overwrite those from
  2170. another package which declares that it replaces the one being
  2171. installed (so that you can install an older version of a package
  2172. without problems).
  2173. <p>
  2174. This usage of <tt/Replaces/ only takes effect when both packages are
  2175. at least partially on the system at once, so that it can only happen
  2176. if they do not conflict or if the conflict has been overridden.
  2177. <sect1>Replacing whole packages, forcing their removal
  2178. <p>
  2179. Secondly, <tt/Replaces/ allows <prgn/dpkg/ and <prgn/dselect/ to resolve
  2180. which package should be removed when a conflict - see
  2181. <ref id="conflicts">. This usage only takes effect when the two
  2182. packages <em/do/ conflict, so that the two effects do not interfere
  2183. with each other.
  2184. <p>
  2185. <sect>Defaults for satisfying dependencies - ordering
  2186. <p>
  2187. Ordering is significant in dependency fields.
  2188. <p>
  2189. Usually dselect will suggest to the user that they select the package
  2190. with the most `fundamental' class (eg, it will prefer Base packages to
  2191. Optional ones), or the one that they `most wanted' to select in some
  2192. sense.
  2193. <p>
  2194. In the absence of other information <prgn/dselect/ will offer a
  2195. default selection of the first named package in a list of
  2196. alternatives.
  2197. <p>
  2198. However, there is no way to specify the `order' of several packages
  2199. which all provide the same thing, when that thing is listed as a
  2200. dependency.
  2201. <p>
  2202. Therefore a dependency on a virtual package should contain a concrete
  2203. package name as the first alternative, so that this is the default.
  2204. <p>
  2205. For example, consider the set of packages:
  2206. <example>
  2207. Package: glibcdoc
  2208. Recommends: info-browser
  2209. Package: info
  2210. Provides: info-browser
  2211. Package: emacs
  2212. Provides: info-browser
  2213. </example>
  2214. <p>
  2215. If <prgn/emacs/ and <prgn/info/ both have the same priority then
  2216. <prgn/dselect/'s choice is essentially random. Better would be
  2217. <example>
  2218. Package: glibcdoc
  2219. Recommends: info | info-browser
  2220. </example>
  2221. so that <prgn/dselect/ defaults to selecting the lightweight standalone
  2222. info browser.
  2223. <chapt id="conffiles">Configuration file handling
  2224. <p>
  2225. <prgn/dpkg/ can do a certain amount of automatic handling of package
  2226. configuration files.
  2227. <p>
  2228. Whether this mechanism is appropriate depends on a number of factors,
  2229. but basically there are two approaches to any particular configuration
  2230. file.
  2231. <p>
  2232. The easy method is to ship a best-effort configuration in the package,
  2233. and use <prgn/dpkg/'s conffile mechanism to handle updates. If the user
  2234. is unlikely to want to edit the file, but you need them to be able to
  2235. without losing their changes, and a new package with a changed version
  2236. of the file is only released infrequently, this is a good approach.
  2237. <p>
  2238. The hard method is to build the configuration file from scratch in the
  2239. <prgn/postinst/ script, and to take the responsibility for fixing any
  2240. mistakes made in earlier versions of the package automatically. This
  2241. will be appropriate if the file is likely to need to be different on
  2242. each system.
  2243. <sect>Automatic handling of configuration files by <prgn/dpkg/
  2244. <p>
  2245. A package may contain a control area file called <tt/conffiles/. This
  2246. file should be a list of filenames of configuration files needing
  2247. automatic handling, separated by newlines. The filenames should be
  2248. absolute pathnames, and the files referred to should actually exist in
  2249. the package.
  2250. <p>
  2251. When a package is upgraded <prgn/dpkg/ will process the configuration
  2252. files during the configuration stage, shortly before it runs the
  2253. package's <prgn/postinst/ script,
  2254. <p>
  2255. For each file it checks to see whether the version of the file
  2256. included in the package is the same as the one that was included in
  2257. the last version of the package (the one that is being upgraded
  2258. from); it also compares the version currently installed on the system
  2259. with the one shipped with the last version.
  2260. <p>
  2261. If neither the user nor the package maintainer has changed the file,
  2262. it is left alone. If one or the other has changed their version, then
  2263. the changed version is preferred - ie, if the user edits their file,
  2264. but the package maintainer doesn't ship a different version, the
  2265. user's changes will stay, silently, but if the maintainer ships a new
  2266. version and the user hasn't edited it the new version will be
  2267. installed (with an informative message). If both have changed their
  2268. version the user is prompted about the problem and must resolve the
  2269. differences themselves.
  2270. <p>
  2271. The comparisons are done by calculating the MD5 message digests of the
  2272. files, and storing the MD5 of the file as it was included in the most
  2273. recent version of the package.
  2274. <p>
  2275. When a package is installed for the first time <prgn/dpkg/ will install
  2276. the file that comes with it, unless that would mean overwriting a file
  2277. already on the filesystem.
  2278. <p>
  2279. However, note that <prgn/dpkg/ will <em/not/ replace a conffile that
  2280. was removed by the user (or by a script). This is necessary because
  2281. with some programs a missing file produces an effect hard or
  2282. impossible to achieve in another way, so that a missing file needs to
  2283. be kept that way if the user did it.
  2284. <p>
  2285. Note that a package should <em/not/ modify a <prgn/dpkg/-handled
  2286. conffile in its maintainer scripts. Doing this will lead to
  2287. <prgn/dpkg/ giving the user confusing and possibly dangerous options
  2288. for conffile update when the package is upgraded.
  2289. <sect>Fully-featured maintainer script configuration handling
  2290. <p>
  2291. For files which contain site-specific information such as the hostname
  2292. and networking details and so forth, it is better to create the file
  2293. in the package's <prgn/postinst/ script.
  2294. <p>
  2295. This will typically involve examining the state of the rest of the
  2296. system to determine values and other information, and may involve
  2297. prompting the user for some information which can't be obtained some
  2298. other way.
  2299. <p>
  2300. When using this method there are a couple of important issues which
  2301. should be considered:
  2302. <p>
  2303. If you discover a bug in the program which generates the configuration
  2304. file, or if the format of the file changes from one version to the
  2305. next, you will have to arrange for the postinst script to do something
  2306. sensible - usually this will mean editing the installed configuration
  2307. file to remove the problem or change the syntax. You will have to do
  2308. this very carefully, since the user may have changed the file, perhaps
  2309. to fix the very problem that your script is trying to deal with - you
  2310. will have to detect these situations and deal with them correctly.
  2311. <p>
  2312. If you do go down this route it's probably a good idea to make the
  2313. program that generates the configuration file(s) a separate program in
  2314. <tt>/usr/sbin</>, by convention called <tt/<var/package/config/ and
  2315. then run that if appropriate from the post-installation script. The
  2316. <tt/<var/package/config/ program should not unquestioningly overwrite
  2317. an existing configuration - if its mode of operation is geared towards
  2318. setting up a package for the first time (rather than any arbitrary
  2319. reconfiguration later) you should have it check whether the
  2320. configuration already exists, and require a <tt/--force/ flag to
  2321. overwrite it.
  2322. <chapt id="alternatives">Alternative versions of an interface -
  2323. <prgn/update-alternatives/
  2324. <p>
  2325. When several packages all provide different versions of the same
  2326. program or file it is useful to have the system select a default, but
  2327. to allow the system administrator to change it and have their
  2328. decisions respected.
  2329. <p>
  2330. For example, there are several versions of the <prgn/vi/ editor, and
  2331. there is no reason to prevent all of them from being installed at
  2332. once, each under their own name (<prgn/nvi/, <prgn/vim/ or whatever).
  2333. Nevertheless it is desirable to have the name <tt/vi/ refer to
  2334. something, at least by default.
  2335. <p>
  2336. If all the packages involved cooperate, this can be done with
  2337. <prgn/update-alternatives/.
  2338. <p>
  2339. Each package provides its own version under its own name, and calls
  2340. <prgn/update-alternatives/ in its postinst to register its version
  2341. (and again in its prerm to deregister it).
  2342. <p>
  2343. See the manpage <manref name=update-alternatives section=8> for
  2344. details.
  2345. <p>
  2346. If <prgn/update-alternatives/ does not seem appropriate you may wish
  2347. to consider using diversions instead.
  2348. <chapt id="diversions">Diversions - overriding a package's version of a file
  2349. <p>
  2350. It is possible to have <prgn/dpkg/ not overwrite a file when it
  2351. reinstalls the package it belongs to, and to have it put the file from
  2352. the package somewhere else instead.
  2353. <p>
  2354. This can be used locally to override a package's version of a file, or
  2355. by one package to override another's version (or provide a wrapper for
  2356. it).
  2357. <p>
  2358. Before deciding to use a diversion, read <ref id="alternatives"> to
  2359. see if you really want a diversion rather than several alternative
  2360. versions of a program.
  2361. <p>
  2362. There is a diversion list, which is read by <prgn/dpkg/, and updated
  2363. by a special program <prgn/dpkg-divert/. Please see <manref
  2364. name=dpkg-divert section=8> for full details of its operation.
  2365. <p>
  2366. When a package wishes to divert a file from another, it should call
  2367. <prgn/dpkg-divert/ in its preinst to add the diversion and rename the
  2368. existing file. For example, supposing that a <prgn/smailwrapper/
  2369. package wishes to install a wrapper around <tt>/usr/sbin/smail</>:
  2370. <example>
  2371. if [ install = "$1" ]; then
  2372. dpkg-divert --package smailwrapper --add --rename \
  2373. --divert /usr/sbin/smail.real /usr/sbin/smail
  2374. fi
  2375. </example>
  2376. Testing <tt/$1/ is necessary so that the script doesn't try to add the
  2377. diversion again when <prgn/smailwrapper/ is upgraded. The
  2378. <tt/--package smailwrapper/ ensures that <prgn/smailwrapper/'s copy of
  2379. <tt>/usr/sbin/smail</> can bypass the diversion and get installed as
  2380. the true version.
  2381. <p>
  2382. The postrm has to do the reverse:
  2383. <example>
  2384. if [ remove = "$1" ]; then
  2385. dpkg-divert --package smailwrapper --remove --rename \
  2386. --divert /usr/sbin/smail.real /usr/sbin/smail
  2387. fi
  2388. </example>
  2389. <p>
  2390. Do not attempt to divert a file which is vitally important for the
  2391. system's operation - when using <prgn/dpkg-divert/ there is a time,
  2392. after it has been diverted but before <prgn/dpkg/ has installed the
  2393. new version, when the file does not exist.
  2394. <chapt id="sharedlibs">Shared libraries
  2395. <p>
  2396. Packages containing shared libraries must be constructed with a little
  2397. care to make sure that the shared library is always available. This
  2398. is especially important for packages whose shared libraries are
  2399. vitally important, such as the libc.
  2400. <p>
  2401. Firstly, your package should install the shared libraries under their
  2402. normal names. For example, the <prgn/libgdbm1/ package should install
  2403. <tt/libgdbm.so.1.7.3/ as <tt>/usr/lib/libgdbm.so.1.7.3</tt>. The
  2404. files should not be renamed or relinked by any prerm or postrm
  2405. scripts; <prgn/dpkg/ will take care of renaming things safely without
  2406. affecting running programs, and attempts to interfere with this are
  2407. likely to lead to problems.
  2408. <p>
  2409. Secondly, your package should include the symlink that <prgn/ldconfig/
  2410. would create for the shared libraries. For example, the
  2411. <prgn/libgdbm1/ package should include a symlink from
  2412. <tt>/usr/lib/libgdbm.so.1</tt> to <tt/libgdbm.so.1.7.3/. This is
  2413. needed so that <prgn/ld.so/ can find the library in between the time
  2414. <prgn/dpkg/ installs it and <prgn/ldconfig/ is run in the
  2415. <prgn/postinst/ script. Futhermore, and <em/this is very important/,
  2416. the library must be placed before the symlink pointing to it in the
  2417. <tt/.deb/ file. This is so that by the time <prgn/dpkg/ comes to
  2418. install the symlink (overwriting the previous symlink pointing at an
  2419. older version of the library) the new shared library is already in
  2420. place. Currently the way to ensure the ordering is done properly is
  2421. to install the library in the appropriate <tt>debian/tmp/.../lib</>
  2422. directory before creating the symlink, by putting the commands in the
  2423. <tt>debian/rules</> in the appropriate order.
  2424. <p>
  2425. If you do the above your package does not need to call <prgn/ldconfig/
  2426. in its maintainer scripts. It is especially important not to call
  2427. <prgn/ldconfig/ in the postrm or preinst scripts in the case where the
  2428. package is being upgraded (see the programmer's manual), as
  2429. <prgn/ldconfig/ will see the temporary names that <prgn/dpkg/ uses for the
  2430. files while it is installing them and will make the shared library
  2431. links point to them, just before <prgn/dpkg/ continues the installation
  2432. and removes the links!
  2433. <chapt id="sysvinit">Configuration of <prgn/init/
  2434. <p>
  2435. <sect>Introduction to the <tt/init.d/ scheme
  2436. <p>
  2437. The <tt>/etc/init.d</> directory contains the scripts executed by
  2438. <prgn/init/ when init state (or `runlevel') is changed (see <manref
  2439. name=init section=8>).
  2440. <p>
  2441. These scripts are be referenced by symbolic links in the
  2442. <tt>/etc/rc<var/n/.d</> directories. When changing runlevels, init
  2443. looks in the directory <tt>/etc/rc<var/n/.d</> for the scripts it
  2444. should execute, where <var/n/ is the runlevel that is being changed
  2445. to.
  2446. <p>
  2447. The names of the links all have the form <tt/S<var/mm/<var/script// or
  2448. <tt/K<var/mm/<var/script// where <var/mm/ is a two-digit number and
  2449. <var/script/ is the name of the script (this should be the same as the
  2450. name of the actual script in <tt>/etc/init.d</>.
  2451. When <prgn/init/ changes runlevel first the targets of the links whose
  2452. names starting with a <tt/K/ are executed, each with the single
  2453. argument <tt/stop/, followed by the scripts prefixed with an <tt/S/,
  2454. each with the single argument <tt/start/. The <tt/K/ links are
  2455. responsible for killing services and the <tt/S/ link for starting
  2456. services upon entering the runlevel.
  2457. <p>
  2458. For example, if we are changing from runlevel 2 to runlevel 3, init
  2459. will first execute all of the <tt/K/ prefixed scripts it finds in
  2460. <tt>/etc/rc3.d</>, and then all of the <tt/S/ prefixed scripts. The
  2461. links starting with <tt/K/ will cause the referred-to file to be
  2462. executed with an argument of <tt/stop/, and the <tt/S/ links with an
  2463. argument of <tt/start/.
  2464. <p>
  2465. The two-digit number <var/mm/ is used to decide which order to start
  2466. and stop things in - low-numbered links have their scripts run first.
  2467. For example, the <tt/K20/ scripts will be executed before the <tt/K30/
  2468. scripts. This is used when a certain service must be started before
  2469. another. For example, the name server <prgn/bind/ might need to be
  2470. started before the news server <prgn/inn/ so that <prgn/inn/ can set
  2471. up its access lists. In this case, the script that starts <prgn/bind/
  2472. should have a lower number than the script that starts <prgn/inn/ so
  2473. that it runs first:
  2474. <example>
  2475. /etc/rc2.d/S17bind
  2476. /etc/rc2.d/S70inn
  2477. </example>
  2478. <sect>Writing <tt/init.d/ scripts
  2479. <p>
  2480. Packages can and should place scripts in <tt>/etc/init.d</> to start
  2481. or stop services at boot time or during a change of runlevel. These
  2482. scripts should be named <tt>/etc/init.d/<var/package/</>, and they
  2483. should accept one argument, saying what to do: <tt/start/, meaning to
  2484. starts the service, or <tt/stop/, to stop the service. Optionally
  2485. they can support <tt/reload/ which causes the configuration to be
  2486. reloaded.
  2487. <p>
  2488. The <tt/init.d/ scripts should ensure that they will behave sensibly
  2489. if invoked with <tt/start/ when the service is already running, or
  2490. with <tt/stop/ when it isn't, and that they don't kill
  2491. unfortunately-named user processes. The best way to achieve this is
  2492. usually to use <prgn/start-stop-daemon/.
  2493. <p>
  2494. These scripts should not fail obscurely when the configuration files
  2495. remain but the package has been removed, as the default in <prgn/dpkg/
  2496. is to leave configuration files on the system after the package has
  2497. been removed. Only when it is executed with the <tt/--purge/ option
  2498. will dpkg remove configuration files. Therefore, you should include a
  2499. <tt/test/ statement at the top of the script, like this:
  2500. <example>
  2501. test -f <var/program-executed-later-in-script/ || exit 0
  2502. </example>
  2503. <sect>Managing the <tt/rc<var/n/.d/ links - <prgn/update-rc.d/
  2504. <p>
  2505. A program is provided, <prgn/update-rc.d/, to make it easier for
  2506. package maintainers to arrange for the proper creation and removal of
  2507. <tt>/etc/rc<var/n/.d</> symbolic links from their postinst and postrm
  2508. scripts.
  2509. <p>
  2510. You should use this script to make changes to <tt>/etc/rc<var/n/.d</>
  2511. and <em/never/ include any <tt>/etc/rc<var/n/.d</> symbolic links in
  2512. the actual archive.
  2513. <p>
  2514. By default <prgn/update-rc.d/ will start services in each of the
  2515. multi-user state runlevels (2, 3, 4, and 5) and stop them in the halt
  2516. runlevel (0), the single-user runlevel (1) and the reboot runlevel
  2517. (6). The system administrator will have the opportunity to customize
  2518. runlevels by simply adding, moving, or removing the symbolic links in
  2519. <tt>/etc/rc<var/n/.d</>.
  2520. <p>
  2521. To get the default behaviour for your package, put in your postinst
  2522. script
  2523. <example>
  2524. update-rc.d <var/package/ default &gt;/dev/null
  2525. </example>
  2526. and in your postrm
  2527. <example>
  2528. if [ purge = "$1" ]; then
  2529. update-rc.d <var/package/ remove &gt;/dev/null
  2530. fi
  2531. </example>
  2532. <p>
  2533. This will use a default sequence number of 20. If it does not matter
  2534. when or in which order the script is run, use this default. If it
  2535. does, then you should talk to the maintainer of the <prgn/sysvinit/
  2536. package or post to <tt>debian-devel</>, and they will help you choose
  2537. a number.
  2538. <p>
  2539. For more information about using <tt/update-rc.d/, please consult its
  2540. manpage <manref name=update-rc.d section=8>.
  2541. <sect>Boot-time initialisation - <tt/rc.boot/
  2542. <p>
  2543. There is another directory, <tt>/etc/rc.boot</>, which contains
  2544. scripts which are run once per machine boot. This facility is
  2545. provided for initialisation of hardware devices, cleaning up of
  2546. leftover files, and so forth.
  2547. <p>
  2548. For example, the <prgn/kbd/ package provides a script here for
  2549. initialising the keyboard layout and console font and mode.
  2550. <p>
  2551. The files in <tt>/etc/rc.boot</> should <em/not/ be links into
  2552. <tt>/etc/init.d</> - they should be the scripts themselves.
  2553. <p>
  2554. <tt/rc.boot/ should <em/not/ be used for starting general-purpose
  2555. daemons and similar activities. This should be done using the
  2556. <tt/rc<var/n/.d/ scheme, above, so that the services can be started
  2557. and stopped cleanly when the runlevel changes or the machine is to be
  2558. shut down or rebooted.
  2559. <sect>Notes
  2560. <p>
  2561. <em/Do not/ include the <tt>/etc/rc<var/n/.d/*</> symbolic links in
  2562. the <tt/.deb/ filesystem archive! <em/This will cause problems!/
  2563. You should create them with <prgn/update-rc.d/, as above.
  2564. <p>
  2565. <em/Do not/ include the <tt>/etc/rc<var/n/.d/*</> symbolic links in
  2566. <prgn/dpkg/'s conffiles list! <em/This will cause problems!/
  2567. <em/Do/, however, include the <tt>/etc/init.d</> scripts in conffiles.
  2568. <sect>Example
  2569. <p>
  2570. The <prgn/bind/ DNS (nameserver) package wants to make sure that the
  2571. nameserver is running in multiuser runlevels, and is properly shut
  2572. down with the system. It puts a script in <tt>/etc/init.d</>, naming
  2573. the script appropriately <tt/bind/. As you can see, the script
  2574. interprets the argument <tt/reload/ to send the nameserver a <tt/HUP/
  2575. signal (causing it to reload its configuration); this way the user can
  2576. say <tt>/etc/init.d/bind reload</> to reload the nameserver.
  2577. <p>
  2578. <example>
  2579. #!/bin/sh
  2580. # Original version by Robert Leslie &lt;rob@mars.org&gt;, edited by iwj
  2581. test -x /usr/sbin/named || exit 0
  2582. case "$1" in
  2583. start)
  2584. test -f /etc/named.boot -a -f /var/named/boot.options || exit 0
  2585. start-stop-daemon --start --verbose --exec /usr/sbin/named
  2586. ;;
  2587. stop)
  2588. start-stop-daemon --stop --verbose \
  2589. --pidfile /var/run/named.pid --exec /usr/sbin/named
  2590. ;;
  2591. reload)
  2592. start-stop-daemon --stop --signal 1 --verbose \
  2593. --pidfile /var/run/named.pid --exec /usr/sbin/named
  2594. ;;
  2595. *)
  2596. echo "Usage: /etc/init.d/bind {start|stop|reload}" >&2
  2597. exit 1
  2598. ;;
  2599. esac
  2600. exit 0
  2601. </example>
  2602. <p>
  2603. Another example on which to base your <tt>/etc/init.d</> scripts is in
  2604. <tt>/etc/init.d/skeleton</>.
  2605. <p>
  2606. If this package is happy with the default setup from
  2607. <prgn/update-rc.d/, namely an ordering number of 20 and having named
  2608. running in all runlevels, it can say in its postinst:
  2609. <example>
  2610. update-rc.d bind default >/dev/null
  2611. </example>
  2612. And in its postrm, to remove the links when the package is purged:
  2613. <example>
  2614. if [ purge = "$1" ]; then
  2615. update-rc.d acct remove >/dev/null
  2616. fi
  2617. </example>
  2618. <chapt id="methif"><prgn/dselect/'s interface to its installation methods
  2619. <p>
  2620. <prgn/dselect/ calls scripts from its installation methods when it
  2621. needs to actually access data from the distribution. The core program
  2622. <prgn/dselect/ itself just calls these scripts and provides the
  2623. package and access method selection interfaces. The installation
  2624. methods are responsible for invoking <prgn/dpkg/ as appropriate.
  2625. <p>
  2626. Each installation method has three scripts:
  2627. <list compact>
  2628. <item>Setup installation parameters.
  2629. <item>Update list of available packages.
  2630. <item>Install.
  2631. </list>
  2632. <p>
  2633. <prgn/dselect/ searches for methods in <tt>/usr/lib/dpkg/methods</>
  2634. and <tt>/usr/local/lib/dpkg/methods</>.
  2635. <sect>Functions of the method scripts
  2636. <p>
  2637. The setup script is run just after the user has chosen an installation
  2638. method. It should prompt the user for parameters like the site to
  2639. NFS-mount or FTP from, the directory to use, or the directory or
  2640. filesystem where the <tt/.deb/ files can be found, or the tape or
  2641. floppy device to install from. It should store the responses under
  2642. <tt>/var/lib/dpkg/methods</> - see below. If no available
  2643. packages list is available it should perhaps offer to scan the
  2644. available packages.
  2645. <p>
  2646. The update script should obtain a list of available packages if
  2647. possible, and run <tt/dpkg --update-avail/, <tt/dpkg --merge-avail/
  2648. and/or <tt/dpkg --forget-old-unavail/ to load it into <prgn/dpkg/ and
  2649. <prgn/dselect/'s database of available packages. If no packages list
  2650. was available and the user was offered and accepted the option of
  2651. scanning the actual files available this scan should be done here,
  2652. using <tt/dpkg --record-avail/.
  2653. <p>
  2654. The install script should feed all the available <tt/.deb/ files to
  2655. <tt/dpkg --iGOEB/ (this is equivalent to <tt/dpkg --install
  2656. --refuse-downgrade --selected-only --skip-same-version
  2657. --auto-deconfigure/). The <tt/-R/ (<tt/--recursive/) option for
  2658. traversing subdirectories may also be useful here).
  2659. <p>
  2660. If any of these scripts needs to display a message for the user, it
  2661. should wait for the user to hit `return' before exiting so that
  2662. dselect doesn't immediately rewrite the screen.
  2663. <p>
  2664. If a method script succeeds (returns a zero exit status)
  2665. <prgn/dselect/ will return immediately to the main menu, with the
  2666. `next' option highlighted ready for the user to select it. If it
  2667. fails <prgn/dselect/ will display a message and wait for the user to
  2668. hit return.
  2669. <sect>Location and arguments of the method scripts
  2670. <p>
  2671. A set of scripts (henceforth known as a group) may provide several
  2672. methods on the `main menu' with different behaviour. For example,
  2673. there might be a generic get-packages-by-FTP group which might provide
  2674. methods in the main menu for installation directly from one of the
  2675. Debian mirror sites as well as for installation from a user-specified
  2676. site.
  2677. <p>
  2678. Each group of methods implemented by the same set of scripts should
  2679. have a subdirectory <tt>/usr/lib/dpkg/methods/<var/group/</> or
  2680. <tt>/usr/local/lib/dpkg/methods/<var/group/</>, containing:
  2681. <taglist compact>
  2682. <tag><tt/names/
  2683. <item>a list of user-visible methods provided by these scripts.
  2684. <tag><tt/setup/
  2685. <tag><tt/update/
  2686. <tag><tt/install/
  2687. <item>executable programs, the scripts themselves.
  2688. <tag><tt/desc.<var/option//
  2689. <item>description file.
  2690. </taglist>
  2691. <p>
  2692. <tt/names/ will be formatted as a list of lines, each containing:
  2693. <example>
  2694. <var/sequence/ <var/method/ <var/summary/
  2695. </example>
  2696. <p>
  2697. <var/sequence/ is a two-digit number that will be used much like
  2698. <tt/rc.d/ prefixes to control the order in the main menu. If in doubt
  2699. use 50.
  2700. <p>
  2701. <var/method/ is a name which is displayed by <prgn/dselect/ as the
  2702. name of the method, and which will be passed to <tt/setup/,
  2703. <tt/update/ and <tt/unpack/ as their first argument.
  2704. <p>
  2705. <var/summary/ is the brief description string for <prgn/dselect/'s menu.
  2706. <p>
  2707. Each of the three scripts gets the same three arguments: <var/vardir/,
  2708. <var/group/ and <var/method/. <var/vardir/ is the base directory for
  2709. storing <prgn/dpkg/ and <prgn/dselect/'s state, usually
  2710. <tt>/var/lib/dpkg</>; this is passed in so that the <tt/--admindir/
  2711. option to <prgn/dselect/ is honoured).
  2712. <p>
  2713. Each option may have an extended description in
  2714. <tt/desc.<var/option//. This should be formatted like the extended
  2715. description part of a <tt/Description/ field entry <em/shifted one
  2716. character to the left/.
  2717. <p>
  2718. <tt><var/vardir//methods</> will exist, and a method group may use a
  2719. <tt><var/vardir//methods/<var/group/</> directory to store its state.
  2720. <p>
  2721. The group name and method name must follow the rules for C identifiers.
  2722. </book>