programmer.sgml 118 KB

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